diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index f9ffed909..c68516dfb 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -229,7 +229,7 @@ jobs: - name: Homebrew run: | which pkg-config || brew install pkg-config - brew install qt6 jq mongo-c-driver@1 gflags glog lz4 yarn + brew install qt6 jq mongo-c-driver@2 gflags glog lz4 yarn - name: configure for debug run: | export PKG_CONFIG_PATH=$(echo "$(find -L "$(brew --prefix)/opt" -type d \( -path "*/lib/pkgconfig" -o -path "*/share/pkgconfig" \) 2>/dev/null)" | sort -u | paste -sd ":" -):$PKG_CONFIG_PATH @@ -314,52 +314,6 @@ jobs: run: | ./testall.sh - build-macos13: - runs-on: macos-13 - steps: - - uses: actions/checkout@main - - name: Homebrew - run: | - which pkg-config || brew install pkg-config - brew install qt6 jq mongo-c-driver@1 gflags glog lz4 yarn - - name: configure for debug - run: | - export PKG_CONFIG_PATH=$(echo "$(find -L "$(brew --prefix)/opt" -type d \( -path "*/lib/pkgconfig" -o -path "*/share/pkgconfig" \) 2>/dev/null)" | sort -u | paste -sd ":" -):$PKG_CONFIG_PATH - ./configure --prefix=/usr/local --enable-shared-mongoc --enable-shared-glog --enable-shared-lz4 --enable-debug - - name: build for debug - run: | - make -j4 -C src - sudo make -C src install - make -j4 -C tools - sudo make -C tools install - - name: configure - run: | - export PKG_CONFIG_PATH=$(echo "$(find -L "$(brew --prefix)/opt" -type d \( -path "*/lib/pkgconfig" -o -path "*/share/pkgconfig" \) 2>/dev/null)" | sort -u | paste -sd ":" -):$PKG_CONFIG_PATH - ./configure --prefix=/usr/local --enable-shared-mongoc --enable-shared-glog --enable-shared-lz4 - - name: build - run: | - make -j4 -C src - sudo make -C src install - make -j4 -C tools - sudo make -C tools install - - name: version - run: | - treefrog -v - tspawn --show-drivers - - name: brew install for test - run: | - brew install redis memcached - brew services start redis - brew services start memcached - - name: testall.sh - working-directory: src/test - run: | - ./testall.sh - - name: releasetest - working-directory: tools/test - run: | - ./testall.sh - build-windows-qt68-msvc2022: runs-on: windows-latest steps: diff --git a/3rdparty/mongo-c-driver-1.26.2/.clang-format b/3rdparty/mongo-c-driver-1.26.2/.clang-format deleted file mode 100644 index aabdf6dc5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.clang-format +++ /dev/null @@ -1,37 +0,0 @@ ---- -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: 'false' -AlignConsecutiveDeclarations: 'false' -AlignEscapedNewlinesLeft: 'true' -AllowAllParametersOfDeclarationOnNextLine: 'true' -AllowShortBlocksOnASingleLine: 'false' -AllowShortCaseLabelsOnASingleLine: 'false' -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: 'false' -AllowShortLoopsOnASingleLine: 'false' -AlwaysBreakAfterReturnType: All -BinPackArguments: 'false' -BinPackParameters: 'false' -BreakBeforeBraces: Linux -ColumnLimit: '80' -ContinuationIndentWidth: '3' -IndentCaseLabels: 'false' -IndentWidth: '3' -KeepEmptyLinesAtTheStartOfBlocks: 'false' -Language: Cpp -MaxEmptyLinesToKeep: '2' -SortIncludes: 'false' -SpaceAfterCStyleCast: 'true' -SpaceBeforeAssignmentOperators: 'true' -SpaceBeforeParens: Always -SpaceInEmptyParentheses: 'false' -SpacesInAngles: 'false' -SpacesInCStyleCastParentheses: 'false' -SpacesInContainerLiterals: 'true' -SpacesInParentheses: 'false' -SpacesInSquareBrackets: 'false' -Standard: Cpp11 -TabWidth: '3' -UseTab: Never - -... diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/README.md b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/README.md deleted file mode 100644 index 3d5c388fd..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Generating the Evergreen Configuration Files - -The scripts in this directory are used to generate the Evergreen configuration -files stored in `.evergreen/generated_configs/`. - -The easiest way to execute these scripts is using the Poetry to install the -dependencies and then run the scripts. - -**Note**: These scripts require Python 3.10 or newer. - - -## Setting Up - -Before running, use Poetry to install a virtualenv containing the dependencies. -This can be done by using the `poetry.sh` (or `poetry.ps1`) script contained in -the `tools/` directory at the root of the `mongo-c-driver` repository: - -```sh -./tools/poetry.sh install --with=dev -``` - -Or with PowerShell: - -```pwsh -./tools/poetry.ps1 install --with=dev -``` - - -## Running the Generator - -The package defines a program `mc-evg-generate`, which can be run within the -virtualenv. This can be done via Poetry as well, following the setup: - -```sh -./tools/poetry.sh run mc-evg-generate -``` - -This command will ready the generation files and generate a new set of Evergreen -configs in `.evergreen/config_generator/generated_configs`. - -The `mc-evg-generate` command executes `main` function defined in -`config_generator/generate.py`. - - -## Modifying the Configs - -To modify the Evergreen configuration, update the Python scripts within the -`etc/`, `config_generator/`, and `legacy_config_generator/` directories, and -execute `mc-evg-generate` again. diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/abi_compliance_check.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/abi_compliance_check.py deleted file mode 100644 index 7dd4a94fd..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/abi_compliance_check.py +++ /dev/null @@ -1,57 +0,0 @@ -from shrub.v3.evg_command import EvgCommandType -from shrub.v3.evg_command import s3_put -from shrub.v3.evg_task import EvgTask - -from config_generator.etc.function import Function -from config_generator.etc.utils import bash_exec - - -class CheckABICompliance(Function): - name = 'abi-compliance-check' - commands = [ - bash_exec( - command_type=EvgCommandType.SETUP, - add_expansions_to_env=True, - working_dir='mongoc', - script='.evergreen/scripts/abi-compliance-check.sh' - ), - bash_exec( - command_type=EvgCommandType.TEST, - working_dir='mongoc', - env={ - 'AWS_ACCESS_KEY_ID': '${aws_key}', - 'AWS_SECRET_ACCESS_KEY': '${aws_secret}', - }, - script='''\ - aws s3 cp abi-compliance/compat_reports s3://mciuploads/${project}/${build_variant}/${revision}/${version_id}/${build_id}/abi-compliance/compat_reports --recursive --acl public-read --region us-east-1 - [[ ! -f ./abi-compliance/abi-error.txt ]] - ''' - ), - s3_put( - aws_key='${aws_key}', - aws_secret='${aws_secret}', - bucket='mciuploads', - content_type='text/html', - display_name='ABI Report:', - local_files_include_filter='mongoc/abi-compliance/compat_reports/**/*.html', - permissions='public-read', - remote_file='${project}/${build_variant}/${revision}/${version_id}/${build_id}/abi-compliance/compat_report.html', - ), - ] - - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - - -def functions(): - return CheckABICompliance.defn() - - -def tasks(): - return [ - EvgTask( - name=CheckABICompliance.name, - commands=[CheckABICompliance.call()], - ) - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/c_std_compile.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/c_std_compile.py deleted file mode 100644 index de11c211d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/c_std_compile.py +++ /dev/null @@ -1,98 +0,0 @@ -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_command import EvgCommandType -from shrub.v3.evg_task import EvgTaskRef - -from config_generator.etc.distros import find_large_distro -from config_generator.etc.distros import make_distro_str -from config_generator.etc.distros import to_cc -from config_generator.etc.function import Function -from config_generator.etc.utils import bash_exec -from config_generator.etc.utils import Task - - -TAG = 'std-matrix' - - -# pylint: disable=line-too-long -# fmt: off -MATRIX = [ - ('archlinux', 'clang', None, [11, ]), - ('debian92', 'clang', None, [11, ]), - ('ubuntu1604', 'clang', 'i686', [11, ]), - ('ubuntu1604', 'clang', None, [11, ]), - ('ubuntu1804', 'clang', 'i686', [11, ]), - ('ubuntu1804', 'gcc', None, [11, ]), - ('debian10', 'clang', None, [11, ]), - ('debian10', 'gcc', None, [11, 17]), - ('debian11', 'clang', None, [11, ]), - ('debian11', 'gcc', None, [11, 17]), - ('ubuntu2004', 'clang', None, [11, ]), - ('ubuntu2004', 'gcc', None, [11, ]), - ('windows-vsCurrent', 'vs2017x64', None, [11, 17]), -] -# fmt: on -# pylint: enable=line-too-long - - -class StdCompile(Function): - name = 'std-compile' - commands = [ - bash_exec( - command_type=EvgCommandType.TEST, - add_expansions_to_env=True, - working_dir='mongoc', - script='.evergreen/scripts/compile-std.sh', - ), - ] - - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - - -def functions(): - return StdCompile.defn() - - -def tasks(): - res = [] - - for distro_name, compiler, arch, stds in MATRIX: - tags = [TAG, distro_name, compiler, 'compile'] - - distro = find_large_distro(distro_name) - - compile_vars = None - compile_vars = {'CC': to_cc(compiler)} - - if arch: - tags.append(arch) - compile_vars.update({'MARCH': arch}) - - distro_str = make_distro_str(distro_name, compiler, arch) - - for std in stds: - with_std = {'C_STD_VERSION': std} - - task_name = f'std-c{std}-{distro_str}-compile' - - res.append( - Task( - name=task_name, - run_on=distro.name, - tags=tags + [f'std-c{std}'], - commands=[StdCompile.call(vars=compile_vars | with_std)], - ) - ) - - return res - - -def variants(): - return [ - BuildVariant( - name=TAG, - display_name=TAG, - tasks=[EvgTaskRef(name=f'.{TAG}')], - ), - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/cse/darwinssl.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/cse/darwinssl.py deleted file mode 100644 index 08f345e15..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/cse/darwinssl.py +++ /dev/null @@ -1,75 +0,0 @@ -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_task import EvgTaskRef - -from config_generator.etc.compile import generate_compile_tasks - -from config_generator.etc.cse.compile import CompileCommon -from config_generator.etc.cse.test import generate_test_tasks - - -SSL = 'darwinssl' -TAG = f'cse-matrix-{SSL}' - - -# pylint: disable=line-too-long -# fmt: off -COMPILE_MATRIX = [ - ('macos-1100', 'clang', None, ['cyrus']), -] - -# TODO (CDRIVER-3789): test cse with the 'sharded' topology. -TEST_MATRIX = [ - ('macos-1100', 'clang', None, 'cyrus', ['auth'], ['server', 'replica' ], ['4.2', '4.4', '5.0', '6.0' ]), - - # Test 7.0+ with a replica set since Queryable Encryption does not support the 'server' topology. Queryable Encryption tests require 7.0+. - ('macos-1100', 'clang', None, 'cyrus', ['auth'], ['server', 'replica' ], [ '7.0', 'latest']), -] -# fmt: on -# pylint: enable=line-too-long - - -class DarwinSSLCompileCommon(CompileCommon): - ssl = 'DARWIN' - - -class SaslCyrusDarwinSSLCompile(DarwinSSLCompileCommon): - name = 'cse-sasl-cyrus-darwinssl-compile' - commands = DarwinSSLCompileCommon.compile_commands(sasl='CYRUS') - - -def functions(): - return SaslCyrusDarwinSSLCompile.defn() - - -def tasks(): - res = [] - - SASL_TO_FUNC = { - 'cyrus': SaslCyrusDarwinSSLCompile, - } - - MORE_TAGS = ['cse'] - - res += generate_compile_tasks( - SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS - ) - - res += generate_test_tasks(SSL, TAG, TEST_MATRIX) - - return res - - -def variants(): - expansions = { - 'CLIENT_SIDE_ENCRYPTION': 'on', - 'DEBUG': 'ON', - } - - return [ - BuildVariant( - name=TAG, - display_name=TAG, - tasks=[EvgTaskRef(name=f'.{TAG}')], - expansions=expansions, - ), - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/cse/openssl.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/cse/openssl.py deleted file mode 100644 index a0d8f7b3f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/cse/openssl.py +++ /dev/null @@ -1,98 +0,0 @@ -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_task import EvgTaskRef - -from config_generator.etc.compile import generate_compile_tasks -from config_generator.etc.function import merge_defns - -from config_generator.etc.cse.compile import CompileCommon -from config_generator.etc.cse.test import generate_test_tasks - - -SSL = 'openssl' -TAG = f'cse-matrix-{SSL}' - - -# pylint: disable=line-too-long -# fmt: off -COMPILE_MATRIX = [ - ('debian10', 'gcc', None, ['cyrus']), - ('debian11', 'gcc', None, ['cyrus']), - ('debian92', 'clang', None, ['cyrus']), - ('debian92', 'gcc', None, ['cyrus']), - ('rhel80', 'gcc', None, ['cyrus']), - ('rhel83-zseries', 'gcc', None, ['cyrus']), - ('ubuntu1604', 'clang', None, ['cyrus']), - ('ubuntu1804-arm64', 'gcc', None, ['cyrus']), - ('ubuntu1804', 'gcc', None, ['cyrus']), - ('ubuntu2004', 'gcc', None, ['cyrus']), - ('ubuntu2004-arm64', 'gcc', None, ['cyrus']), - ('windows-vsCurrent', 'vs2017x64', None, ['cyrus']), -] - -# TODO (CDRIVER-3789): test cse with the 'sharded' topology. -TEST_MATRIX = [ - # 4.2 and 4.4 not available on rhel83-zseries. - ('rhel83-zseries', 'gcc', None, 'cyrus', ['auth'], ['server'], ['5.0']), - - ('ubuntu1804-arm64', 'gcc', None, 'cyrus', ['auth'], ['server'], ['4.2', '4.4', '5.0', '6.0' ]), - ('ubuntu1804', 'gcc', None, 'cyrus', ['auth'], ['server'], ['4.2', '4.4', '5.0', '6.0' ]), - ('windows-vsCurrent', 'vs2017x64', None, 'cyrus', ['auth'], ['server'], ['4.2', '4.4', '5.0', '6.0' ]), - - # Test 7.0+ with a replica set since Queryable Encryption does not support the 'server' topology. Queryable Encryption tests require 7.0+. - # Test 7.0+ with Ubuntu 20.04+ since MongoDB 7.0 no longer ships binaries for Ubuntu 18.04. - ('ubuntu2004', 'gcc', None, 'cyrus', ['auth'], ['server', 'replica'], [ '7.0', 'latest']), - ('rhel83-zseries', 'gcc', None, 'cyrus', ['auth'], ['server', 'replica'], [ '7.0', 'latest']), - ('ubuntu2004-arm64', 'gcc', None, 'cyrus', ['auth'], ['server', 'replica'], [ '7.0', 'latest']), - ('windows-vsCurrent', 'vs2017x64', None, 'cyrus', ['auth'], ['server', 'replica'], [ '7.0', 'latest']), -] -# fmt: on -# pylint: enable=line-too-long - - -class OpenSSLCompileCommon(CompileCommon): - ssl = 'OPENSSL' - - -class SaslCyrusOpenSSLCompile(OpenSSLCompileCommon): - name = 'cse-sasl-cyrus-openssl-compile' - commands = OpenSSLCompileCommon.compile_commands(sasl='CYRUS') - - -def functions(): - return merge_defns( - SaslCyrusOpenSSLCompile.defn(), - ) - - -def tasks(): - res = [] - - SASL_TO_FUNC = { - 'cyrus': SaslCyrusOpenSSLCompile, - } - - MORE_TAGS = ['cse'] - - res += generate_compile_tasks( - SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS - ) - - res += generate_test_tasks(SSL, TAG, TEST_MATRIX) - - return res - - -def variants(): - expansions = { - 'CLIENT_SIDE_ENCRYPTION': 'on', - 'DEBUG': 'ON', - } - - return [ - BuildVariant( - name=TAG, - display_name=TAG, - tasks=[EvgTaskRef(name=f'.{TAG}')], - expansions=expansions, - ), - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/cse/winssl.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/cse/winssl.py deleted file mode 100644 index 71ab279ed..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/cse/winssl.py +++ /dev/null @@ -1,76 +0,0 @@ -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_task import EvgTaskRef - -from config_generator.etc.compile import generate_compile_tasks - -from config_generator.etc.cse.compile import CompileCommon -from config_generator.etc.cse.test import generate_test_tasks - - -SSL = 'winssl' -TAG = f'cse-matrix-{SSL}' - - -# pylint: disable=line-too-long -# fmt: off -COMPILE_MATRIX = [ - ('windows-64-vs2015', 'vs2015x64', None, ['cyrus']), - ('windows-vsCurrent', 'vs2017x64', None, ['cyrus']), -] - -# TODO (CDRIVER-3789): test cse with the 'sharded' topology. -TEST_MATRIX = [ - ('windows-vsCurrent', 'vs2017x64', None, 'cyrus', ['auth'], ['server'], ['4.2', '4.4', '5.0', '6.0' ]), - - # Test 7.0+ with a replica set since Queryable Encryption does not support the 'server' topology. Queryable Encryption tests require 7.0+. - ('windows-vsCurrent', 'vs2017x64', None, 'cyrus', ['auth'], ['server', 'replica' ], [ '7.0', 'latest']), -] -# fmt: on -# pylint: enable=line-too-long - - -class WinSSLCompileCommon(CompileCommon): - ssl = 'WINDOWS' - - -class SaslCyrusWinSSLCompile(WinSSLCompileCommon): - name = 'cse-sasl-cyrus-winssl-compile' - commands = WinSSLCompileCommon.compile_commands(sasl='CYRUS') - - -def functions(): - return SaslCyrusWinSSLCompile.defn() - - -def tasks(): - res = [] - - SASL_TO_FUNC = { - 'cyrus': SaslCyrusWinSSLCompile, - } - - MORE_TAGS = ['cse'] - - res += generate_compile_tasks( - SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS - ) - - res += generate_test_tasks(SSL, TAG, TEST_MATRIX) - - return res - - -def variants(): - expansions = { - 'CLIENT_SIDE_ENCRYPTION': 'on', - 'DEBUG': 'ON', - } - - return [ - BuildVariant( - name=TAG, - display_name=TAG, - tasks=[EvgTaskRef(name=f'.{TAG}')], - expansions=expansions, - ), - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/early_termination.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/early_termination.py deleted file mode 100644 index 979431cb3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/early_termination.py +++ /dev/null @@ -1,22 +0,0 @@ -from config_generator.etc.function import Function -from config_generator.etc.utils import bash_exec - - -class EarlyTermination(Function): - name = 'early-termination' - commands = [ - bash_exec( - script='''\ - echo 'EVERGREEN HOST WAS UNEXPECTEDLY TERMINATED!!!' 1>&2 - echo 'Restart this Evergreen task and try again!' 1>&2 - ''' - ), - ] - - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - - -def functions(): - return EarlyTermination.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/earthly.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/earthly.py deleted file mode 100644 index 419751b01..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/earthly.py +++ /dev/null @@ -1,195 +0,0 @@ -from __future__ import annotations - -import functools -import itertools -from typing import Any, Iterable, Literal, TypeVar, get_args, NamedTuple, get_type_hints -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_task import EvgTaskRef -from ..etc.utils import Task -from shrub.v3.evg_command import subprocess_exec, EvgCommandType - -T = TypeVar("T") - -_ENV_PARAM_NAME = "MONGOC_EARTHLY_ENV" -"The name of the EVG expansion parameter used to key the Earthly build env" - -EnvKey = Literal["u22", "alpine3.18", "archlinux"] -"Identifiers for environments. These correspond to special '*-env' targets in the Earthfile." - -_ENV_NAMES: dict[EnvKey, str] = { - "u22": "Ubuntu 22.04", - "alpine3.18": "Alpine 3.18", - "archlinux": "Arch Linux", -} -"A mapping from environment keys to 'pretty' environment names" - -# Other options: SSPI (Windows only), AUTO (not reliably test-able without more environments) -SASLOption = Literal["Cyrus", "off"] -"Valid options for the SASL configuration parameter" -TLSOption = Literal["LibreSSL", "OpenSSL", "off"] -"Options for the TLS backend configuration parameter (AKA 'ENABLE_SSL')" -CxxVersion = Literal["master", "r3.8.0"] -"C++ driver refs that are under CI test" - -# A Unicode non-breaking space character -_BULLET = "\N{Bullet}" - - -class Configuration(NamedTuple): - """ - Represent a complete set of argument values to give to the Earthly task - execution. Each field name matches the ARG in the Earthfile. - - Adding/removing fields will add/remove dimensions on the task matrix. - - The 'env' parameter is not encoded here, but is managed separately. - - Keep this in sync with the 'PartialConfiguration' class defined below! - """ - - sasl: SASLOption - tls: TLSOption - test_mongocxx_ref: CxxVersion - - @classmethod - def all(cls) -> Iterable[Configuration]: - """ - Generate all configurations for all options of our parameters. - """ - # Iter each configuration parameter: - fields: Iterable[tuple[str, type]] = get_type_hints(Configuration).items() - # Generate lists of pairs of parameter names their options: - all_pairs: Iterable[Iterable[tuple[str, str]]] = ( - # Generate a (key, opt) pair for each option in parameter 'key' - [(key, opt) for opt in get_args(typ)] - # Over each parameter and type thereof: - for key, typ in fields - ) - # Now generate the cross product of all alternative for all options: - matrix: Iterable[dict[str, Any]] = map(dict, itertools.product(*all_pairs)) - for items in matrix: - # Convert each item to a Configuration: - yield Configuration(**items) - - @property - def suffix(self) -> str: - return f"{_BULLET}".join(f"{k}={v}" for k, v in self._asdict().items()) - - -def task_filter(env: EnvKey, conf: Configuration) -> bool: - """ - Control which tasks are actually defined by matching on the platform and - configuration values. - """ - match env, conf: - # We only need one task with "sasl=off" - case "u22", ("off", "OpenSSL", "master"): - return True - # Other sasl=off tasks we'll just ignore: - case _, ("off", _tls, _cxx): - return False - # Ubuntu does not ship with a LibreSSL package: - case e, (_sasl, "LibreSSL", _cxx) if _ENV_NAMES[e].startswith("Ubuntu"): - return False - # Anything else: Allow it to run: - case _: - return True - - -def envs_for(config: Configuration) -> Iterable[EnvKey]: - """Get all environment keys that are not excluded for the given configuration""" - all_envs: tuple[EnvKey, ...] = get_args(EnvKey) - allow_env_for_config = functools.partial(task_filter, conf=config) - return filter(allow_env_for_config, all_envs) - - -def earthly_task( - *, - name: str, - targets: Iterable[str], - config: Configuration, -) -> Task | None: - # Attach "earthly-xyz" tags to the task to allow build variants to select - # these tasks by the environment of that variant. - env_tags = sorted(f"earthly-{e}" for e in sorted(envs_for(config))) - if not env_tags: - # All environments have been excluded for this configuration. This means - # the task itself should not be run: - return - # Generate the build-arg arguments based on the configuration options. The - # NamedTuple field names must match with the ARG keys in the Earthfile! - earthly_args = [f"--{key}={val}" for key, val in config._asdict().items()] - return Task( - name=name, - commands=[ - # First, just build the "env-warmup" which will prepare the build environment. - # This won't generate any output, but allows EVG to track it as a separate build step - # for timing and logging purposes. The subequent build step will cache-hit the - # warmed-up build environments. - subprocess_exec( - "bash", - args=[ - "tools/earthly.sh", - "+env-warmup", - f"--env=${{{_ENV_PARAM_NAME}}}", - *earthly_args, - ], - working_dir="mongoc", - command_type=EvgCommandType.SETUP, - ), - # Now execute the main tasks: - subprocess_exec( - "bash", - args=[ - "tools/earthly.sh", - "+run", - f"--targets={' '.join(targets)}", - f"--env=${{{_ENV_PARAM_NAME}}}", - *earthly_args, - ], - working_dir="mongoc", - command_type=EvgCommandType.TEST, - ), - ], - tags=[f"earthly", "pr-merge-gate", *env_tags], - run_on=CONTAINER_RUN_DISTROS, - ) - - -CONTAINER_RUN_DISTROS = [ - "ubuntu2204-small", - "ubuntu2204-large", - "ubuntu2004-small", - "ubuntu2004", - "ubuntu1804", - "ubuntu1804-medium", - "debian10", - "debian11", - "amazon2", -] - - -def tasks() -> Iterable[Task]: - for conf in Configuration.all(): - task = earthly_task( - name=f"check:{conf.suffix}", - targets=("test-example", "test-cxx-driver"), - config=conf, - ) - if task is not None: - yield task - - -def variants() -> list[BuildVariant]: - envs: tuple[EnvKey, ...] = get_args(EnvKey) - return [ - BuildVariant( - name=f"earthly-{env}", - tasks=[EvgTaskRef(name=f".earthly-{env}")], - display_name=_ENV_NAMES[env], - expansions={ - _ENV_PARAM_NAME: env, - }, - ) - for env in envs - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/fetch_source.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/fetch_source.py deleted file mode 100644 index 8ad040f0b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/fetch_source.py +++ /dev/null @@ -1,55 +0,0 @@ -from shrub.v3.evg_command import EvgCommandType -from shrub.v3.evg_command import expansions_update -from shrub.v3.evg_command import git_get_project - -from config_generator.etc.function import Function -from config_generator.etc.utils import bash_exec - - -class FetchSource(Function): - name = 'fetch-source' - command_type = EvgCommandType.SETUP - commands = [ - git_get_project(command_type=command_type, directory='mongoc'), - bash_exec( - command_type=command_type, - working_dir='mongoc', - script='''\ - set -o errexit - set -o pipefail - if [ -n "${github_pr_number}" -o "${is_patch}" = "true" ]; then - # This is a GitHub PR or patch build, probably branched from master - if command -v python3 &>/dev/null; then - # Prefer python3 if it is available - echo $(python3 ./build/calc_release_version.py --next-minor) > VERSION_CURRENT - else - echo $(python ./build/calc_release_version.py --next-minor) > VERSION_CURRENT - fi - VERSION=$VERSION_CURRENT-${version_id} - else - VERSION=latest - fi - echo "CURRENT_VERSION: $VERSION" > expansion.yml - ''' - ), - expansions_update(command_type=command_type, - file='mongoc/expansion.yml'), - # Scripts may not be executable on Windows. - bash_exec( - command_type=EvgCommandType.SETUP, - working_dir='mongoc', - script='''\ - for file in $(find .evergreen/scripts -type f); do - chmod +rx "$file" || exit - done - ''' - ), - ] - - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - - -def functions(): - return FetchSource.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/prepare_kerberos.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/prepare_kerberos.py deleted file mode 100644 index c0b73c2fe..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/prepare_kerberos.py +++ /dev/null @@ -1,36 +0,0 @@ -from shrub.v3.evg_command import EvgCommandType - -from config_generator.etc.function import Function -from config_generator.etc.utils import bash_exec - - -class PrepareKerberos(Function): - name = 'prepare-kerberos' - commands = [ - bash_exec( - command_type=EvgCommandType.SETUP, - working_dir='mongoc', - silent=True, - script='''\ - if test "${keytab|}" && command -v kinit >/dev/null; then - echo "${keytab}" > /tmp/drivers.keytab.base64 - base64 --decode /tmp/drivers.keytab.base64 > /tmp/drivers.keytab - if touch /etc/krb5.conf 2>/dev/null; then - cat .evergreen/etc/kerberos.realm | tee -a /etc/krb5.conf - elif command sudo true 2>/dev/null; then - cat .evergreen/etc/kerberos.realm | sudo tee -a /etc/krb5.conf - else - echo "Cannot append kerberos.realm to /etc/krb5.conf; skipping." 1>&2 - fi - fi - ''' - ), - ] - - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - - -def functions(): - return PrepareKerberos.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/asan_cse.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/asan_cse.py deleted file mode 100644 index 2ffa970b8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/asan_cse.py +++ /dev/null @@ -1,51 +0,0 @@ -from config_generator.etc.compile import generate_compile_tasks - -from config_generator.etc.sanitizers.test import generate_test_tasks - -from config_generator.components.cse.openssl import SaslCyrusOpenSSLCompile - -from config_generator.components.sanitizers.asan import TAG - - -# pylint: disable=line-too-long -# fmt: off -COMPILE_MATRIX = [ - ('ubuntu1804', 'clang', None, ['cyrus']), - ('ubuntu2004', 'clang', None, ['cyrus']), -] - -TEST_MATRIX = [ - ('ubuntu1804', 'clang', None, 'cyrus', ['auth'], ['server'], ['4.2', '4.4', '5.0', '6.0']), - - # Test 7.0+ with a replica set since Queryable Encryption does not support the 'server' topology. Queryable Encryption tests require 7.0+. - # Test 7.0+ with Ubuntu 20.04+ since MongoDB 7.0 no longer ships binaries for Ubuntu 18.04. - ('ubuntu2004', 'clang', None, 'cyrus', ['auth'], ['server', 'replica'], ['7.0', 'latest']), -] -# fmt: on -# pylint: enable=line-too-long - - -MORE_TAGS = ['cse', 'asan'] - - -def tasks(): - res = [] - - SSL = 'openssl' - SASL_TO_FUNC = { - 'cyrus': SaslCyrusOpenSSLCompile, - } - - res += generate_compile_tasks( - SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS - ) - - res += generate_test_tasks(SSL, TAG, TEST_MATRIX, MORE_TAGS) - - res += generate_test_tasks( - SSL, TAG, TEST_MATRIX, MORE_TAGS, - MORE_TEST_TAGS=['with-mongocrypt'], - MORE_VARS={'SKIP_CRYPT_SHARED_LIB': 'on'} - ) - - return res diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/asan_sasl.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/asan_sasl.py deleted file mode 100644 index 2279969db..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/asan_sasl.py +++ /dev/null @@ -1,44 +0,0 @@ -from config_generator.etc.compile import generate_compile_tasks - -from config_generator.etc.sanitizers.test import generate_test_tasks - -from config_generator.components.sasl.openssl import SaslCyrusOpenSSLCompile - -from config_generator.components.sanitizers.asan import TAG - - -# pylint: disable=line-too-long -# fmt: off -COMPILE_MATRIX = [ - ('ubuntu1604', 'clang', None, ['cyrus']), - ('ubuntu1804', 'clang', None, ['cyrus']), - ('ubuntu2004', 'clang', None, ['cyrus']), -] - -TEST_MATRIX = [ - ('ubuntu1604', 'clang', None, 'cyrus', ['auth'], ['server', 'replica', 'sharded'], ['3.6', ]), - ('ubuntu1804', 'clang', None, 'cyrus', ['auth'], ['server', 'replica', 'sharded'], [ '4.0', '4.2', '4.4', '5.0', '6.0']), - - # Test 7.0+ with Ubuntu 20.04+ since MongoDB 7.0 no longer ships binaries for Ubuntu 18.04. - ('ubuntu2004', 'clang', None, 'cyrus', ['auth'], ['server', 'replica', 'sharded'], ['7.0', 'latest']), -] -# fmt: on -# pylint: enable=line-too-long - - -def tasks(): - res = [] - - SSL = 'openssl' - - SASL_TO_FUNC = { - 'cyrus': SaslCyrusOpenSSLCompile, - } - - res += generate_compile_tasks( - SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, ['asan'] - ) - - res += generate_test_tasks(SSL, TAG, TEST_MATRIX, ['asan']) - - return res diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/tsan_sasl.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/tsan_sasl.py deleted file mode 100644 index 5ec02f917..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/tsan_sasl.py +++ /dev/null @@ -1,42 +0,0 @@ -from config_generator.etc.compile import generate_compile_tasks - -from config_generator.etc.sanitizers.test import generate_test_tasks - -from config_generator.components.sasl.openssl import SaslCyrusOpenSSLCompile - -from config_generator.components.sanitizers.tsan import TAG - - -# pylint: disable=line-too-long -# fmt: off -COMPILE_MATRIX = [ - ('ubuntu1804', 'clang', None, ['cyrus']), - ('ubuntu2004', 'clang', None, ['cyrus']), -] - -TEST_OPENSSL_MATRIX = [ - ('ubuntu1804', 'clang', None, 'cyrus', ['auth'], ['server', 'replica', 'sharded'], ['4.0', '4.2', '4.4', '5.0', '6.0']), - - # Test 7.0+ with Ubuntu 20.04+ since MongoDB 7.0 no longer ships binaries for Ubuntu 18.04. - ('ubuntu2004', 'clang', None, 'cyrus', ['auth'], ['server', 'replica', 'sharded'], ['7.0', 'latest']), -] -# fmt: on -# pylint: enable=line-too-long - - -MORE_TAGS = ['tsan'] - - -def tasks(): - res = [] - - SSL = 'openssl' - SASL_TO_FUNC = {'cyrus': SaslCyrusOpenSSLCompile} - - res += generate_compile_tasks( - SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS - ) - - res += generate_test_tasks(SSL, TAG, TEST_OPENSSL_MATRIX, MORE_TAGS) - - return res diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/darwinssl.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/darwinssl.py deleted file mode 100644 index 791388a00..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/darwinssl.py +++ /dev/null @@ -1,69 +0,0 @@ -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_task import EvgTaskRef - -from config_generator.etc.function import merge_defns -from config_generator.etc.compile import generate_compile_tasks - -from config_generator.etc.sasl.compile import CompileCommon -from config_generator.etc.sasl.test import generate_test_tasks - - -SSL = 'darwinssl' -TAG = f'sasl-matrix-{SSL}' - - -# pylint: disable=line-too-long -# fmt: off -COMPILE_MATRIX = [ - ('macos-1100', 'clang', None, ['cyrus']), - ('macos-1100-arm64', 'clang', None, ['cyrus']), -] - -TEST_MATRIX = [ - ('macos-1100', 'clang', None, 'cyrus', ['auth'], ['server'], ['3.6', '4.0', '4.2', '4.4', '5.0', '6.0', '7.0', 'latest']), -] -# fmt: on -# pylint: enable=line-too-long - - -class DarwinSSLCompileCommon(CompileCommon): - ssl = 'DARWIN' - - -class SaslCyrusDarwinSSLCompile(DarwinSSLCompileCommon): - name = 'sasl-cyrus-darwinssl-compile' - commands = DarwinSSLCompileCommon.compile_commands(sasl='CYRUS') - - -def functions(): - return merge_defns( - SaslCyrusDarwinSSLCompile.defn(), - ) - - -def tasks(): - res = [] - - SASL_TO_FUNC = { - 'cyrus': SaslCyrusDarwinSSLCompile, - } - - res += generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX) - res += generate_test_tasks(SSL, TAG, TEST_MATRIX) - - return res - - -def variants(): - expansions = { - 'DEBUG': 'ON' - } - - return [ - BuildVariant( - name=TAG, - display_name=TAG, - tasks=[EvgTaskRef(name=f'.{TAG}')], - expansions=expansions, - ), - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/nossl.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/nossl.py deleted file mode 100644 index 8be889765..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/nossl.py +++ /dev/null @@ -1,73 +0,0 @@ -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_task import EvgTaskRef - -from config_generator.etc.function import merge_defns -from config_generator.etc.compile import generate_compile_tasks - -from config_generator.etc.sasl.compile import CompileCommon -from config_generator.etc.sasl.test import generate_test_tasks - - -SSL = 'nossl' -TAG = f'sasl-matrix-{SSL}' - - -# pylint: disable=line-too-long -# fmt: off -COMPILE_MATRIX = [ - ('ubuntu1604', 'gcc', None, ['off']), - ('ubuntu1804', 'gcc', None, ['off']), - ('ubuntu2004', 'gcc', None, ['off']), - ('windows-vsCurrent', 'vs2017x64', None, ['off']), -] - -TEST_MATRIX = [ - ('ubuntu1604', 'gcc', None, 'off', ['noauth'], ['server', 'replica', 'sharded'], ['3.6', ]), - ('ubuntu1804', 'gcc', None, 'off', ['noauth'], ['server', 'replica', 'sharded'], [ '4.0', '4.2', '4.4', '5.0', '6.0', ]), - ('ubuntu2004', 'gcc', None, 'off', ['noauth'], ['server', 'replica', 'sharded'], [ '7.0', 'latest']), -] -# fmt: on -# pylint: enable=line-too-long - - -class NoSSLCompileCommon(CompileCommon): - ssl = 'OFF' - - -class SaslOffNoSSLCompile(NoSSLCompileCommon): - name = 'sasl-off-nossl-compile' - commands = NoSSLCompileCommon.compile_commands(sasl='OFF') - - -def functions(): - return merge_defns( - SaslOffNoSSLCompile.defn(), - ) - - -def tasks(): - res = [] - - SASL_TO_FUNC = { - 'off': SaslOffNoSSLCompile, - } - - res += generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX) - res += generate_test_tasks(SSL, TAG, TEST_MATRIX) - - return res - - -def variants(): - expansions = { - 'DEBUG': 'ON' - } - - return [ - BuildVariant( - name=TAG, - display_name=TAG, - tasks=[EvgTaskRef(name=f'.{TAG}')], - expansions=expansions, - ), - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/openssl.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/openssl.py deleted file mode 100644 index f1b7a6c3d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/openssl.py +++ /dev/null @@ -1,97 +0,0 @@ -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_task import EvgTaskRef - -from config_generator.etc.function import merge_defns -from config_generator.etc.compile import generate_compile_tasks - -from config_generator.etc.sasl.compile import CompileCommon -from config_generator.etc.sasl.test import generate_test_tasks - - -SSL = 'openssl' -TAG = f'sasl-matrix-{SSL}' - - -# pylint: disable=line-too-long -# fmt: off -COMPILE_MATRIX = [ - ('archlinux', 'clang', None, ['cyrus']), - ('archlinux', 'gcc', None, ['cyrus']), - ('debian10', 'gcc', None, ['cyrus']), - ('debian11', 'gcc', None, ['cyrus']), - ('debian92', 'clang', None, ['cyrus']), - ('debian92', 'gcc', None, ['cyrus']), - ('rhel70', 'gcc', None, ['cyrus']), - ('rhel80', 'gcc', None, ['cyrus']), - ('rhel81-power8', 'gcc', None, ['cyrus']), - ('rhel83-zseries', 'gcc', None, ['cyrus']), - ('ubuntu1604-arm64', 'gcc', None, ['cyrus']), - ('ubuntu1604', 'clang', None, ['cyrus']), - ('ubuntu1804-arm64', 'gcc', None, ['cyrus']), - ('ubuntu1804', 'gcc', None, ['cyrus']), - ('ubuntu2004-arm64', 'gcc', None, ['cyrus']), - ('ubuntu2004', 'gcc', None, ['cyrus']), - ('windows-vsCurrent', 'vs2017x64', None, ['cyrus']), -] - -TEST_MATRIX = [ - ('rhel81-power8', 'gcc', None, 'cyrus', ['auth'], ['server', ], [ '4.2', '4.4', '5.0', '6.0', '7.0', 'latest']), - ('rhel83-zseries', 'gcc', None, 'cyrus', ['auth'], ['server', ], [ '5.0', '6.0', '7.0', 'latest']), - ('ubuntu1804-arm64', 'gcc', None, 'cyrus', ['auth'], ['server', ], [ '4.2', '4.4', '5.0', '6.0', ]), - ('ubuntu1804', 'gcc', None, 'cyrus', ['auth'], ['server', 'replica'], ['4.0', '4.2', '4.4', '5.0', '6.0', ]), - - # Test 7.0+ with Ubuntu 20.04+ since MongoDB 7.0 no longer ships binaries for Ubuntu 18.04. - ('ubuntu2004-arm64', 'gcc', None, 'cyrus', ['auth'], ['server'], ['7.0', 'latest']), - ('ubuntu2004', 'gcc', None, 'cyrus', ['auth'], ['server'], ['7.0', 'latest']), - ('windows-vsCurrent', 'vs2017x64', None, 'cyrus', ['auth'], ['server'], [ 'latest']), - - # Test ARM64 + 4.0 on Ubuntu 16.04, as MongoDB server does not produce - # downloads for Ubuntu 18.04 arm64. - # See: https://www.mongodb.com/docs/manual/administration/production-notes/ - ('ubuntu1604-arm64', 'gcc', None, 'cyrus', ['auth'], ['server'], ['4.0']), -] -# fmt: on -# pylint: enable=line-too-long - - -class OpenSSLCompileCommon(CompileCommon): - ssl = 'OPENSSL' - - -class SaslCyrusOpenSSLCompile(OpenSSLCompileCommon): - name = 'sasl-cyrus-openssl-compile' - commands = OpenSSLCompileCommon.compile_commands(sasl='CYRUS') - - -def functions(): - return merge_defns( - SaslCyrusOpenSSLCompile.defn(), - ) - - -def tasks(): - res = [] - - SASL_TO_FUNC = { - 'cyrus': SaslCyrusOpenSSLCompile, - } - - res += generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX) - res += generate_test_tasks(SSL, TAG, TEST_MATRIX) - - return res - - -def variants(): - expansions = { - 'DEBUG': 'ON' - } - - return [ - BuildVariant( - name=TAG, - display_name=TAG, - tasks=[EvgTaskRef(name=f'.{TAG}')], - expansions=expansions, - ), - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/winssl.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/winssl.py deleted file mode 100644 index c5855fc75..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sasl/winssl.py +++ /dev/null @@ -1,92 +0,0 @@ -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_task import EvgTaskRef - -from config_generator.etc.function import merge_defns -from config_generator.etc.compile import generate_compile_tasks - -from config_generator.etc.sasl.compile import CompileCommon -from config_generator.etc.sasl.test import generate_test_tasks - - -SSL = 'winssl' -TAG = f'sasl-matrix-{SSL}' - - -# pylint: disable=line-too-long -# fmt: off -COMPILE_MATRIX = [ - ('windows-64-vs2013', 'vs2013x64', None, [ 'cyrus', ]), - ('windows-64-vs2013', 'vs2013x86', None, ['off', ]), - ('windows-64-vs2015', 'vs2015x64', None, [ 'cyrus', ]), - ('windows-64-vs2015', 'vs2015x86', None, ['off', ]), - ('windows-vsCurrent', 'mingw', None, [ 'sspi']), - ('windows-vsCurrent', 'vs2017x64', None, ['off', 'cyrus', 'sspi']), - ('windows-vsCurrent', 'vs2017x86', None, ['off', 'sspi']), -] - -TEST_MATRIX = [ - ('windows-vsCurrent', 'vs2017x64', None, 'cyrus', ['auth'], ['server'], ['3.6', '4.0', '4.2', '4.4', '5.0', '6.0', '7.0', 'latest']), - - ('windows-vsCurrent', 'mingw', None, 'sspi', ['auth'], ['server'], ['latest']), - ('windows-vsCurrent', 'vs2017x64', None, 'sspi', ['auth'], ['server'], ['latest']), - ('windows-vsCurrent', 'vs2017x86', None, 'sspi', ['auth'], ['server'], ['latest']), -] -# fmt: on -# pylint: enable=line-too-long - - -class WinSSLCompileCommon(CompileCommon): - ssl = 'WINDOWS' - - -class SaslOffWinSSLCompile(WinSSLCompileCommon): - name = 'sasl-off-winssl-compile' - commands = WinSSLCompileCommon.compile_commands(sasl='OFF') - - -class SaslCyrusWinSSLCompile(WinSSLCompileCommon): - name = 'sasl-cyrus-winssl-compile' - commands = WinSSLCompileCommon.compile_commands(sasl='CYRUS') - - -class SaslSspiWinSSLCompile(WinSSLCompileCommon): - name = 'sasl-sspi-winssl-compile' - commands = WinSSLCompileCommon.compile_commands(sasl='SSPI') - - -def functions(): - return merge_defns( - SaslOffWinSSLCompile.defn(), - SaslCyrusWinSSLCompile.defn(), - SaslSspiWinSSLCompile.defn(), - ) - - -def tasks(): - res = [] - - SASL_TO_FUNC = { - 'off': SaslOffWinSSLCompile, - 'cyrus': SaslCyrusWinSSLCompile, - 'sspi': SaslSspiWinSSLCompile, - } - - res += generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX) - res += generate_test_tasks(SSL, TAG, TEST_MATRIX) - - return res - - -def variants(): - expansions = { - 'DEBUG': 'ON' - } - - return [ - BuildVariant( - name=TAG, - display_name=TAG, - tasks=[EvgTaskRef(name=f'.{TAG}')], - expansions=expansions, - ), - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/scan_build.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/scan_build.py deleted file mode 100644 index 7280a48cc..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/scan_build.py +++ /dev/null @@ -1,93 +0,0 @@ -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_command import EvgCommandType -from shrub.v3.evg_command import FunctionCall -from shrub.v3.evg_task import EvgTaskRef - -from config_generator.etc.distros import find_large_distro -from config_generator.etc.distros import make_distro_str -from config_generator.etc.distros import to_cc -from config_generator.etc.function import Function -from config_generator.etc.utils import bash_exec -from config_generator.etc.utils import Task - - -TAG = 'scan-build-matrix' - - -# pylint: disable=line-too-long -# fmt: off -MATRIX = [ - ('macos-1100', 'clang', None ), - ('ubuntu1604-arm64', 'clang', None ), - ('ubuntu1604', 'clang', 'i686'), - ('ubuntu1604', 'clang', None ), - ('ubuntu1804-arm64', 'clang', None ), - ('ubuntu1804', 'clang', 'i686'), -] -# fmt: on -# pylint: enable=line-too-long - - -class ScanBuild(Function): - name = 'scan-build' - commands = [ - bash_exec( - command_type=EvgCommandType.TEST, - add_expansions_to_env=True, - redirect_standard_error_to_output=True, - working_dir='mongoc', - script='.evergreen/scripts/compile-scan-build.sh', - ), - ] - - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - - -def functions(): - return ScanBuild.defn() - - -def tasks(): - res = [] - - for distro_name, compiler, arch in MATRIX: - tags = [TAG, distro_name, compiler] - - distro = find_large_distro(distro_name) - - compile_vars = None - compile_vars = {'CC': to_cc(compiler)} - - if arch: - tags.append(arch) - compile_vars.update({'MARCH': arch}) - - distro_str = make_distro_str(distro_name, compiler, arch) - - task_name = f'scan-build-{distro_str}' - - res.append( - Task( - name=task_name, - run_on=distro.name, - tags=tags, - commands=[ - ScanBuild.call(vars=compile_vars), - FunctionCall(func='upload scan artifacts'), - ], - ) - ) - - return res - - -def variants(): - return [ - BuildVariant( - name=TAG, - display_name=TAG, - tasks=[EvgTaskRef(name=f'.{TAG}')], - ), - ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/compile.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/compile.py deleted file mode 100644 index 75e9c661c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/compile.py +++ /dev/null @@ -1,50 +0,0 @@ -from config_generator.etc.distros import find_large_distro -from config_generator.etc.distros import make_distro_str -from config_generator.etc.distros import to_cc -from config_generator.etc.utils import Task - -from config_generator.components.funcs.upload_build import UploadBuild - - -def generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, MATRIX, MORE_TAGS=None, MORE_VARS=None): - res = [] - - MORE_TAGS = MORE_TAGS if MORE_TAGS else [] - MORE_VARS = MORE_VARS if MORE_VARS else {} - - for distro_name, compiler, arch, sasls, in MATRIX: - tags = [TAG, 'compile', distro_name, compiler] + MORE_TAGS - - distro = find_large_distro(distro_name) - - compile_vars = None - compile_vars = {'CC': to_cc(compiler)} - - if arch: - tags.append(arch) - compile_vars.update({'MARCH': arch}) - - compile_vars.update(MORE_VARS) - - distro_str = make_distro_str(distro_name, compiler, arch) - - for sasl in sasls: - task_name = f'sasl-{sasl}-{SSL}-{distro_str}-compile' - - for tag in MORE_TAGS: - task_name = f'{tag}-{task_name}' - - commands = [] - commands.append(SASL_TO_FUNC[sasl].call(vars=compile_vars)) - commands.append(UploadBuild.call()) - - res.append( - Task( - name=task_name, - run_on=distro.name, - tags=tags + [f'sasl-{sasl}'], - commands=commands, - ) - ) - - return res diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/cse/compile.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/cse/compile.py deleted file mode 100644 index 602d8a565..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/cse/compile.py +++ /dev/null @@ -1,41 +0,0 @@ -from typing import ClassVar - -from shrub.v3.evg_command import EvgCommand -from shrub.v3.evg_command import EvgCommandType -from shrub.v3.evg_command import expansions_update -from shrub.v3.evg_command import KeyValueParam - -from config_generator.etc.utils import bash_exec - -from config_generator.etc.function import Function - - -class CompileCommon(Function): - ssl: ClassVar[str | None] - - @classmethod - def compile_commands(cls, sasl=None) -> list[EvgCommand]: - updates = [] - - if cls.ssl: - updates.append(KeyValueParam(key='SSL', value=cls.ssl)) - - if sasl: - updates.append(KeyValueParam(key='SASL', value=sasl)) - - return [ - expansions_update(updates=updates), - bash_exec( - command_type=EvgCommandType.TEST, - script='EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON ${EXTRA_CONFIGURE_FLAGS}" .evergreen/scripts/compile.sh', - working_dir='mongoc', - add_expansions_to_env=True, - env={ - 'COMPILE_LIBMONGOCRYPT': 'ON', - }, - ), - ] - - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/cse/test.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/cse/test.py deleted file mode 100644 index a168bd2b8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/cse/test.py +++ /dev/null @@ -1,76 +0,0 @@ -from itertools import product - -from shrub.v3.evg_command import expansions_update -from shrub.v3.evg_command import KeyValueParam -from shrub.v3.evg_task import EvgTaskDependency - -from config_generator.etc.distros import find_small_distro -from config_generator.etc.distros import make_distro_str -from config_generator.etc.distros import to_cc -from config_generator.etc.utils import Task - -from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration -from config_generator.components.funcs.fetch_build import FetchBuild -from config_generator.components.funcs.fetch_det import FetchDET -from config_generator.components.funcs.run_mock_kms_servers import RunMockKMSServers -from config_generator.components.funcs.run_tests import RunTests - - -def generate_test_tasks(SSL, TAG, MATRIX): - res = [] - - TOPOLOGY_TO_STR = { - 'server': 'server', - 'replica': 'replica_set', - 'sharded': 'sharded_cluster', - } - - for distro_name, compiler, arch, sasl, auths, topologies, server_vers in MATRIX: - tags = [TAG, 'test', distro_name, compiler, f'sasl-{sasl}', 'cse'] - test_distro = find_small_distro(distro_name) - - compile_vars = [] - compile_vars.append(KeyValueParam(key='CC', value=to_cc(compiler))) - - if arch: - tags.append(arch) - compile_vars.append(KeyValueParam(key='MARCH', value=arch)) - - distro_str = make_distro_str(distro_name, compiler, arch) - compile_task_name = f'cse-sasl-{sasl}-{SSL}-{distro_str}-compile' - - for auth, topology, server_ver in product(auths, topologies, server_vers): - test_tags = tags + [auth, topology, server_ver] - # Do not add `nossl` tag to prevent being selected by legacy config variants. - # Remove the `if` when CDRIVER-4571 is resolved. - if SSL != 'nossl': - test_tags += [SSL] - test_task_name = f'cse-sasl-{sasl}-{SSL}-{distro_str}-test-{server_ver}-{topology}-{auth}' - - test_commands = [] - test_commands.append(FetchBuild.call(build_name=compile_task_name)) - - updates = compile_vars + [ - KeyValueParam(key='AUTH', value=auth), - KeyValueParam(key='MONGODB_VERSION', value=server_ver), - KeyValueParam(key='TOPOLOGY', value=TOPOLOGY_TO_STR[topology]), - KeyValueParam(key='SSL', value=SSL), - ] - - test_commands.append(expansions_update(updates=updates)) - test_commands.append(FetchDET.call()) - test_commands.append(BootstrapMongoOrchestration.call()) - test_commands.append(RunMockKMSServers.call()) - test_commands.append(RunTests.call()) - - res.append( - Task( - name=test_task_name, - run_on=test_distro.name, - tags=test_tags, - depends_on=[EvgTaskDependency(name=compile_task_name)], - commands=test_commands, - ) - ) - - return res diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/distros.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/distros.py deleted file mode 100644 index a1f670897..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/distros.py +++ /dev/null @@ -1,266 +0,0 @@ -from typing import Literal - -from pydantic import BaseModel, validator -from packaging.version import Version - - -class Distro(BaseModel): - """ - Defines common properties of a given Evergreen distro. - - * name: Name of the distro. - * os: Name of the operating system. - * os_type: One of Linux, MacOS, or Windows. - * os_ver: Version of the operating system. - * vs_ver: Version of Visual Studio available. - * size: Size of tasks the distro is designed to handle. - * arch: Target architecture. - """ - - name: str - os: str | None = None - os_type: Literal['linux', 'macos', 'windows'] | None = None - os_ver: str | None = None - vs_ver: Literal[ - '2013', - '2015', - '2017', - '2019', - '2022', - 'vsCurrent', - 'vsCurrent2', - 'vsMulti', - ] | None = None - size: Literal['small', 'large'] | None = None - arch: Literal['arm64', 'power8', 'zseries'] | None = None - - @validator('os_ver') - @classmethod - def validate_os_ver(cls, value): - return Version(value) - -# See: https://evergreen.mongodb.com/distros -# pylint: disable=line-too-long -#fmt: off -ARCHLINUX_DISTROS = [ - Distro(name='archlinux-large', os='archlinux', os_type='linux', size='large'), - Distro(name='archlinux-small', os='archlinux', os_type='linux', size='small'), - Distro(name='archlinux-new-large', os='archlinux', os_type='linux', size='large'), - Distro(name='archlinux-new-small', os='archlinux', os_type='linux', size='small'), -] - -DEBIAN_DISTROS = [ - Distro(name='debian10-large', os='debian', os_type='linux', os_ver='10', size='large'), - Distro(name='debian10-small', os='debian', os_type='linux', os_ver='10', size='small'), - Distro(name='debian11-large', os='debian', os_type='linux', os_ver='11', size='large'), - Distro(name='debian11-small', os='debian', os_type='linux', os_ver='11', size='small'), - Distro(name='debian92-large', os='debian', os_type='linux', os_ver='9.2', size='large'), - Distro(name='debian92-small', os='debian', os_type='linux', os_ver='9.2', size='small'), -] - -MACOS_DISTROS = [ - Distro(name='macos-1100', os='macos', os_type='macos', os_ver='11.00'), -] - -MACOS_ARM64_DISTROS = [ - Distro(name='macos-1100-arm64', os='macos', os_type='macos', os_ver='11.00', arch='arm64'), -] - -RHEL_DISTROS = [ - Distro(name='rhel70-large', os='rhel', os_type='linux', os_ver='7.0', size='large'), - Distro(name='rhel70-small', os='rhel', os_type='linux', os_ver='7.0', size='small'), - Distro(name='rhel76-large', os='rhel', os_type='linux', os_ver='7.6', size='large'), - Distro(name='rhel76-small', os='rhel', os_type='linux', os_ver='7.6', size='small'), - Distro(name='rhel80-large', os='rhel', os_type='linux', os_ver='8.0', size='large'), - Distro(name='rhel80-small', os='rhel', os_type='linux', os_ver='8.0', size='small'), - Distro(name='rhel84-large', os='rhel', os_type='linux', os_ver='8.4', size='large'), - Distro(name='rhel84-small', os='rhel', os_type='linux', os_ver='8.4', size='small'), - Distro(name='rhel87-large', os='rhel', os_type='linux', os_ver='8.7', size='large'), - Distro(name='rhel87-small', os='rhel', os_type='linux', os_ver='8.7', size='small'), - Distro(name='rhel90-large', os='rhel', os_type='linux', os_ver='9.0', size='large'), - Distro(name='rhel90-small', os='rhel', os_type='linux', os_ver='9.0', size='small'), -] - -RHEL_ARM64_DISTROS = [ - Distro(name='rhel82-arm64-large', os='rhel', os_type='linux', os_ver='8.2', size='large', arch='arm64'), - Distro(name='rhel82-arm64-small', os='rhel', os_type='linux', os_ver='8.2', size='small', arch='arm64'), - Distro(name='rhel90-arm64-large', os='rhel', os_type='linux', os_ver='9.0', size='large', arch='arm64'), - Distro(name='rhel90-arm64-small', os='rhel', os_type='linux', os_ver='9.0', size='small', arch='arm64'), -] - -RHEL_POWER8_DISTROS = [ - Distro(name='rhel71-power8-large', os='rhel', os_type='linux', os_ver='7.1', size='large', arch='power8'), - Distro(name='rhel71-power8-small', os='rhel', os_type='linux', os_ver='7.1', size='small', arch='power8'), - Distro(name='rhel81-power8-large', os='rhel', os_type='linux', os_ver='8.1', size='large', arch='power8'), - Distro(name='rhel81-power8-small', os='rhel', os_type='linux', os_ver='8.1', size='small', arch='power8'), -] - -RHEL_ZSERIES_DISTROS = [ - Distro(name='rhel67-zseries-large', os='rhel', os_type='linux', os_ver='6.7', size='large', arch='zseries'), - Distro(name='rhel67-zseries-small', os='rhel', os_type='linux', os_ver='6.7', size='small', arch='zseries'), - Distro(name='rhel72-zseries-large', os='rhel', os_type='linux', os_ver='7.2', size='large', arch='zseries'), - Distro(name='rhel72-zseries-small', os='rhel', os_type='linux', os_ver='7.2', size='small', arch='zseries'), - Distro(name='rhel83-zseries-large', os='rhel', os_type='linux', os_ver='8.3', size='large', arch='zseries'), - Distro(name='rhel83-zseries-small', os='rhel', os_type='linux', os_ver='8.3', size='small', arch='zseries'), -] - -UBUNTU_DISTROS = [ - Distro(name='ubuntu1604-large', os='ubuntu', os_type='linux', os_ver='16.04', size='large'), - Distro(name='ubuntu1604-small', os='ubuntu', os_type='linux', os_ver='16.04', size='small'), - Distro(name='ubuntu1804-large', os='ubuntu', os_type='linux', os_ver='18.04', size='large'), - Distro(name='ubuntu1804-small', os='ubuntu', os_type='linux', os_ver='18.04', size='small'), - Distro(name='ubuntu2004-large', os='ubuntu', os_type='linux', os_ver='20.04', size='large'), - Distro(name='ubuntu2004-small', os='ubuntu', os_type='linux', os_ver='20.04', size='small'), - Distro(name='ubuntu2204-large', os='ubuntu', os_type='linux', os_ver='22.04', size='large'), - Distro(name='ubuntu2204-small', os='ubuntu', os_type='linux', os_ver='22.04', size='small'), -] - -UBUNTU_POWER8_DISTROS = [ - Distro(name='ubuntu1604-power8-large', os='ubuntu', os_type='linux', os_ver='16.04', size='large', arch='power8'), - Distro(name='ubuntu1604-power8-small', os='ubuntu', os_type='linux', os_ver='16.04', size='small', arch='power8'), - Distro(name='ubuntu1804-power8-large', os='ubuntu', os_type='linux', os_ver='18.04', size='large', arch='power8'), - Distro(name='ubuntu1804-power8-small', os='ubuntu', os_type='linux', os_ver='18.04', size='small', arch='power8'), -] - -UBUNTU_ARM64_DISTROS = [ - Distro(name='ubuntu1604-arm64-large', os='ubuntu', os_type='linux', os_ver='16.04', size='large', arch='arm64'), - Distro(name='ubuntu1604-arm64-small', os='ubuntu', os_type='linux', os_ver='16.04', size='small', arch='arm64'), - Distro(name='ubuntu1804-arm64-large', os='ubuntu', os_type='linux', os_ver='18.04', size='large', arch='arm64'), - Distro(name='ubuntu1804-arm64-small', os='ubuntu', os_type='linux', os_ver='18.04', size='small', arch='arm64'), - Distro(name='ubuntu2004-arm64-large', os='ubuntu', os_type='linux', os_ver='20.04', size='large', arch='arm64'), - Distro(name='ubuntu2004-arm64-small', os='ubuntu', os_type='linux', os_ver='20.04', size='small', arch='arm64'), - Distro(name='ubuntu2204-arm64-large', os='ubuntu', os_type='linux', os_ver='22.04', size='large', arch='arm64'), - Distro(name='ubuntu2204-arm64-small', os='ubuntu', os_type='linux', os_ver='22.04', size='small', arch='arm64'), -] - -UBUNTU_ZSERIES_DISTROS = [ - Distro(name='ubuntu1604-zseries-large', os='ubuntu', os_type='linux', os_ver='16.04', size='large', arch='zseries'), - Distro(name='ubuntu1604-zseries-small', os='ubuntu', os_type='linux', os_ver='16.04', size='small', arch='zseries'), - Distro(name='ubuntu1804-zseries-large', os='ubuntu', os_type='linux', os_ver='18.04', size='large', arch='zseries'), - Distro(name='ubuntu1804-zseries-small', os='ubuntu', os_type='linux', os_ver='18.04', size='small', arch='zseries'), -] - -WINDOWS_DISTROS = [ - Distro(name='windows-64-vs2013-large', os='windows', os_type='windows', vs_ver='2013', size='large'), - Distro(name='windows-64-vs2013-small', os='windows', os_type='windows', vs_ver='2013', size='small'), - Distro(name='windows-64-vs2015-large', os='windows', os_type='windows', vs_ver='2015', size='large'), - Distro(name='windows-64-vs2015-small', os='windows', os_type='windows', vs_ver='2015', size='small'), - Distro(name='windows-64-vs2017-large', os='windows', os_type='windows', vs_ver='2017', size='large'), - Distro(name='windows-64-vs2017-small', os='windows', os_type='windows', vs_ver='2017', size='small'), - Distro(name='windows-64-vs2019-large', os='windows', os_type='windows', vs_ver='2019', size='large'), - Distro(name='windows-64-vs2019-small', os='windows', os_type='windows', vs_ver='2019', size='small'), - - Distro(name='windows-2022-large', os='windows', os_type='windows', os_ver='2022'), - Distro(name='windows-2022-small', os='windows', os_type='windows', os_ver='2022'), - - Distro(name='windows-64-2019', os='windows', os_type='windows', os_ver='2019'), - - Distro(name='windows-64-vsMulti-small', os='windows', os_type='windows', vs_ver='vsMulti', size='small'), - - Distro(name='windows-vsCurrent-2022-large', os='windows', os_type='windows', os_ver='2022', vs_ver='vsCurrent', size='large'), - Distro(name='windows-vsCurrent-2022-small', os='windows', os_type='windows', os_ver='2022', vs_ver='vsCurrent', size='small'), - - Distro(name='windows-vsCurrent-large', os='windows', os_type='windows', vs_ver='vsCurrent', size='large'), # Windows Server 2019 - Distro(name='windows-vsCurrent-small', os='windows', os_type='windows', vs_ver='vsCurrent', size='small'), # Windows Server 2019 - - Distro(name='windows-vsCurrent2-large', os='windows', os_type='windows', vs_ver='vsCurrent2', size='large'), - Distro(name='windows-vsCurrent2-small', os='windows', os_type='windows', vs_ver='vsCurrent2', size='small'), -] -#fmt: on -# pylint: enable=line-too-long - -# Ensure no-arch distros are ordered before arch-specific distros. -ALL_DISTROS = [] + \ - ARCHLINUX_DISTROS + \ - DEBIAN_DISTROS + \ - MACOS_DISTROS + \ - MACOS_ARM64_DISTROS + \ - RHEL_DISTROS + \ - RHEL_ARM64_DISTROS + \ - RHEL_POWER8_DISTROS + \ - RHEL_ZSERIES_DISTROS + \ - UBUNTU_DISTROS + \ - UBUNTU_ARM64_DISTROS + \ - UBUNTU_POWER8_DISTROS + \ - UBUNTU_ZSERIES_DISTROS + \ - WINDOWS_DISTROS - - -def find_distro(name) -> Distro: - candidates = [d for d in ALL_DISTROS if name == d.name] - - if not candidates: - raise ValueError(f'could not find a distro with the name {name}') - - return candidates[0] - - -def find_large_distro(name) -> Distro: - candidates = [d for d in ALL_DISTROS if f'{name}-large' == d.name] - - if candidates: - return candidates[0] - - return find_distro(name) - - -def find_small_distro(name) -> Distro: - candidates = [d for d in ALL_DISTROS if f'{name}-small' == d.name] - - if candidates: - return candidates[0] - - return find_distro(name) - - -def make_distro_str(distro_name, compiler, arch) -> str: - if distro_name.startswith('windows-vsCurrent'): - # Rename `windows-vsCurrent-*` distros to `windows-` where`` - # is the Windows Server version used by the distro, e.g.: - # ('windows-vsCurrent-2022', 'vs2017x64', None) -> windows-2022-vs2017-x64 - # ('windows-vsCurrent-2022', 'mingw', None) -> windows-2022-mingw - # ('windows-vsCurrent', 'vs2017x64', None) -> windows-2019-vs2017-x64 - # ('windows-vsCurrent', 'mingw', None) -> windows-2019-mingw - maybe_arch = compiler[len('vs20XY'):] - if maybe_arch in ('x86', 'x64'): - compiler_str = compiler[:-len(maybe_arch)] + '-' + maybe_arch - else: - compiler_str = compiler - if distro_name.startswith('windows-vsCurrent-'): - distro_str = 'windows-' + \ - distro_name[len('windows-vsCurrent-'):] + f'-{compiler_str}' - else: - distro_str = 'windows-2019' + f'-{compiler_str}' - elif distro_name.startswith('windows-64-vs'): - # Abbreviate 'windows-64-vs' as 'vs' and append '-' if - # given in compiler string as 'vs', e.g.: - # ('windows-64-vs2017', 'vs2017x64', None) -> vs2017-x64 - # ('windows-64-vs2017', 'mingw', None) -> vs2017-mingw - distro_str = distro_name[len('windows-64-'):] + { - 'vs2013x64': '-x64', - 'vs2013x86': '-x86', - 'vs2015x64': '-x64', - 'vs2015x86': '-x86', - 'vs2017x64': '-x64', - 'vs2017x86': '-x86', - }.get(compiler, f'-{compiler}') - else: - distro_str = distro_name - if compiler: - distro_str += f'-{compiler}' - - if arch: - distro_str += f'-{arch}' - - return distro_str - - -def to_cc(compiler): - return { - 'vs2013x64': 'Visual Studio 12 2013 Win64', - 'vs2013x86': 'Visual Studio 12 2013', - 'vs2015x64': 'Visual Studio 14 2015 Win64', - 'vs2015x86': 'Visual Studio 14 2015', - 'vs2017x64': 'Visual Studio 15 2017 Win64', - 'vs2017x86': 'Visual Studio 15 2017', - }.get(compiler, compiler) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/sanitizers/test.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/sanitizers/test.py deleted file mode 100644 index 43a3438b8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/sanitizers/test.py +++ /dev/null @@ -1,105 +0,0 @@ -from itertools import product - -from shrub.v3.evg_command import expansions_update -from shrub.v3.evg_command import KeyValueParam -from shrub.v3.evg_task import EvgTaskDependency - -from config_generator.etc.distros import find_small_distro -from config_generator.etc.distros import make_distro_str -from config_generator.etc.distros import to_cc -from config_generator.etc.utils import Task - -from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration -from config_generator.components.funcs.fetch_build import FetchBuild -from config_generator.components.funcs.fetch_det import FetchDET -from config_generator.components.funcs.run_simple_http_server import RunSimpleHTTPServer -from config_generator.components.funcs.run_mock_kms_servers import RunMockKMSServers -from config_generator.components.funcs.run_tests import RunTests - - -def generate_test_tasks(SSL, TAG, MATRIX, MORE_COMPILE_TAGS=None, MORE_TEST_TAGS=None, MORE_VARS=None): - res = [] - - TOPOLOGY_TO_STR = { - 'server': 'server', - 'replica': 'replica_set', - 'sharded': 'sharded_cluster', - } - - MORE_COMPILE_TAGS = MORE_COMPILE_TAGS if MORE_COMPILE_TAGS else [] - MORE_TEST_TAGS = MORE_TEST_TAGS if MORE_TEST_TAGS else [] - MORE_VARS = MORE_VARS if MORE_VARS else {} - - for distro_name, compiler, arch, sasl, auths, topologies, server_vers in MATRIX: - tags = [ - TAG, 'test', distro_name, compiler, f'sasl-{sasl}' - ] + MORE_COMPILE_TAGS - - test_distro = find_small_distro(distro_name) - - compile_vars = [] - compile_vars.append(KeyValueParam(key='CC', value=to_cc(compiler))) - - if arch: - tags.append(arch) - compile_vars.append(KeyValueParam(key='MARCH', value=arch)) - - distro_str = make_distro_str(distro_name, compiler, arch) - - base_task_name = f'sasl-{sasl}-{SSL}-{distro_str}' - - for tag in MORE_COMPILE_TAGS: - base_task_name = f'{tag}-{base_task_name}' - - compile_task_name = f'{base_task_name}-compile' - - for auth, topology, server_ver in product(auths, topologies, server_vers): - test_tags = tags + [auth, topology, server_ver] + MORE_TEST_TAGS - # Do not add `nossl` tag to prevent being selected by legacy config variants. - # Remove the `if` when CDRIVER-4571 is resolved. - if SSL != 'nossl': - test_tags += [SSL] - test_task_name = f'{base_task_name}-test-{server_ver}-{topology}-{auth}' - - for tag in MORE_TEST_TAGS: - test_task_name += f'-{tag}' - - test_commands = [] - test_commands.append(FetchBuild.call(build_name=compile_task_name)) - - updates = compile_vars + [ - KeyValueParam(key='AUTH', value=auth), - KeyValueParam(key='MONGODB_VERSION', value=server_ver), - KeyValueParam(key='TOPOLOGY', value=TOPOLOGY_TO_STR[topology]), - KeyValueParam(key='SSL', value=SSL), - ] - - if 'cse' in MORE_COMPILE_TAGS: - updates.append( - KeyValueParam(key='CLIENT_SIDE_ENCRYPTION', value='on') - ) - - for key, value in MORE_VARS.items(): - updates.append(KeyValueParam(key=key, value=value)) - - test_commands.append(expansions_update(updates=updates)) - test_commands.append(FetchDET.call()) - test_commands.append(BootstrapMongoOrchestration.call()) - test_commands.append(RunSimpleHTTPServer.call()) - - if 'cse' in MORE_COMPILE_TAGS: - test_commands.append(RunMockKMSServers.call()) - - test_commands.append(RunTests.call()) - - res.append( - Task( - name=test_task_name, - run_on=test_distro.name, - tags=test_tags, - depends_on=[EvgTaskDependency(name=compile_task_name)], - commands=test_commands, - ) - ) - - return res diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/sasl/compile.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/sasl/compile.py deleted file mode 100644 index c43f4ca14..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/sasl/compile.py +++ /dev/null @@ -1,36 +0,0 @@ -from typing import ClassVar - -from shrub.v3.evg_command import EvgCommand -from shrub.v3.evg_command import EvgCommandType - -from config_generator.etc.utils import bash_exec - -from config_generator.etc.function import Function - - -class CompileCommon(Function): - ssl: ClassVar[str | None] - - @classmethod - def compile_commands(cls, sasl=None) -> list[EvgCommand]: - env = {} - - if cls.ssl: - env['SSL'] = cls.ssl - - if sasl: - env['SASL'] = sasl - - return [ - bash_exec( - command_type=EvgCommandType.TEST, - add_expansions_to_env=True, - env=env, - working_dir='mongoc', - script='.evergreen/scripts/compile.sh', - ), - ] - - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/sasl/test.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/sasl/test.py deleted file mode 100644 index fd1a4f6a5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/sasl/test.py +++ /dev/null @@ -1,77 +0,0 @@ -from itertools import product - -from shrub.v3.evg_command import expansions_update -from shrub.v3.evg_command import KeyValueParam -from shrub.v3.evg_task import EvgTaskDependency - -from config_generator.etc.distros import find_small_distro -from config_generator.etc.distros import make_distro_str -from config_generator.etc.distros import to_cc -from config_generator.etc.utils import Task - -from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration -from config_generator.components.funcs.fetch_build import FetchBuild -from config_generator.components.funcs.fetch_det import FetchDET -from config_generator.components.funcs.run_simple_http_server import RunSimpleHTTPServer -from config_generator.components.funcs.run_tests import RunTests - - -def generate_test_tasks(SSL, TAG, MATRIX): - res = [] - - TOPOLOGY_TO_STR = { - 'server': 'server', - 'replica': 'replica_set', - 'sharded': 'sharded_cluster', - } - - for distro_name, compiler, arch, sasl, auths, topologies, server_vers in MATRIX: - tags = [TAG, 'test', distro_name, compiler] - test_distro = find_small_distro(distro_name) - - compile_vars = [] - compile_vars.append(KeyValueParam(key='CC', value=to_cc(compiler))) - - if arch: - tags.append(arch) - compile_vars.append(KeyValueParam(key='MARCH', value=arch)) - - distro_str = make_distro_str(distro_name, compiler, arch) - compile_task_name = f'sasl-{sasl}-{SSL}-{distro_str}-compile' - - for auth, topology, server_ver in product(auths, topologies, server_vers): - test_tags = tags + [f'sasl-{sasl}', auth, topology, server_ver] - # Do not add `nossl` tag to prevent being selected by legacy config variants. - # Remove the `if` when CDRIVER-4571 is resolved. - if SSL != 'nossl': - test_tags += [SSL] - - test_task_name = f'sasl-{sasl}-{SSL}-{distro_str}-test-{server_ver}-{topology}-{auth}' - - test_commands = [] - test_commands.append(FetchBuild.call(build_name=compile_task_name)) - - updates = compile_vars + [ - KeyValueParam(key='AUTH', value=auth), - KeyValueParam(key='MONGODB_VERSION', value=server_ver), - KeyValueParam(key='TOPOLOGY', value=TOPOLOGY_TO_STR[topology]), - KeyValueParam(key='SSL', value=SSL), - ] - - test_commands.append(expansions_update(updates=updates)) - test_commands.append(FetchDET.call()) - test_commands.append(BootstrapMongoOrchestration.call()) - test_commands.append(RunSimpleHTTPServer.call()) - test_commands.append(RunTests.call()) - - res.append( - Task( - name=test_task_name, - run_on=test_distro.name, - tags=test_tags, - depends_on=[EvgTaskDependency(name=compile_task_name)], - commands=test_commands, - ) - ) - - return res diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/utils.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/utils.py deleted file mode 100644 index 9609df5f6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/utils.py +++ /dev/null @@ -1,212 +0,0 @@ -from importlib import import_module -from pathlib import Path -from textwrap import dedent -from typing import Sequence, Iterable, Mapping - -import yaml - -from shrub.v3.evg_project import EvgProject -from shrub.v3.evg_task import EvgTask -from shrub.v3.evg_command import subprocess_exec, EvgCommandType - - -# Equivalent to EvgTask but defines additional properties. -class Task(EvgTask): - """ - An evergreen task model that also includes additional properties. - - (The shrub.py model is missing some properties) - """ - - disable: bool = False - run_on: str | Sequence[str] | None = None - - -# Automatically formats the provided script and invokes it in Bash. -def bash_exec( - script, - *, - include_expansions_in_env: Iterable[str] | None = None, - working_dir: str | None = None, - command_type: EvgCommandType | None = None, - env: Mapping[str, str] | None = None, - **kwargs, -): - return subprocess_exec( - binary="bash", - args=["-c", dedent(script)], - include_expansions_in_env=list(include_expansions_in_env) if include_expansions_in_env else None, - working_dir=working_dir, - command_type=command_type, - env=dict(env) if env else None, - **kwargs, - ) - - -def all_components(): - res = [] - - # .evergreen/config_generator/etc/utils.py -> .evergreen/config_generator/components - components_dir = Path(__file__).parent.parent / 'components' - - all_paths = components_dir.glob('**/*.py') - - for path in sorted(all_paths): - component_path = path.relative_to(components_dir) - component_str = str(component_path.with_suffix('')) # Drop '.py'. - component_str = component_str.replace('/', '.') # 'a/b' -> 'a.b' - module_name = f'config_generator.components.{component_str}' - res.append(import_module(module_name)) - - return res - - -# Helper function to print component name for diagnostic purposes. -def component_name(component): - component_prefix = 'config_generator.components.' - res = component.__name__[len(component_prefix):] - return res - - -def write_to_file(yml, filename): - # .evergreen/config_generator/etc/utils.py -> .evergreen - evergreen_dir = Path(__file__).parent.parent.parent - filename = evergreen_dir / 'generated_configs' / filename - - with open(filename.resolve(), 'w', encoding='utf-8') as file: - file.write(yml) - - -class ConfigDumper(yaml.SafeDumper): - # Represent multiline strings in the form: - # key: | - # multiline string - # multiline string - # multiline string - def represent_scalar(self, tag, value, style=None): - if isinstance(value, str) and '\n' in value: - style = '|' - - return super().represent_scalar(tag, value, style) - - # Prefer using double quotes when able. - def analyze_scalar(self, scalar): - res = super().analyze_scalar(scalar) - if res.allow_single_quoted and res.allow_double_quoted: - res.allow_single_quoted = False - return res - - # Represent flow mappings with space after left brace: - # node: { key: value } - # ^ - def expect_flow_mapping(self): - super().expect_flow_mapping() - self.write_indicator('', False) - - # Represent flow mappings with space before right brace: - # node: { key: value } - # ^ - def expect_flow_mapping_key(self): - if isinstance(self.event, yaml.MappingEndEvent): - self.write_indicator(' ', False) - super().expect_flow_mapping_key() - - # Allow for special-casing depending on parent node. - def represent_special_mapping(self, tag, mapping, flow_style): - value = [] - - for item_key, item_value in mapping: - node_key = self.represent_data(item_key) - - if item_key == 'tags': - # Represent task tags using flow style to reduce line count: - # - name: task-name - # tags: [A, B, C] - node_value = self.represent_sequence( - 'tag:yaml.org,2002:seq', item_value, flow_style=True) - elif item_key == 'depends_on' and len(item_value) == 1: - # Represent task depends_on using flow style when only one - # dependency is given to reduce line count: - # - name: task-name - # depends_on: [{ name: dependency }] - node_value = self.represent_sequence( - 'tag:yaml.org,2002:seq', item_value, flow_style=True) - else: - # Use default behavior. - node_value = self.represent_data(item_value) - - value.append((node_key, node_value)) - - node = yaml.MappingNode(tag, value, flow_style=flow_style) - - if self.alias_key is not None: - self.represented_objects[self.alias_key] = node - - return node - - # Make an effort to order fields in a readable manner. - # Ordering applies to *all* mappings regardless of the parent node. - def represent_mapping(self, tag, mapping, flow_style=False): - # Represent updates mapping for expansions.update commands using flow - # style to reduce line count: - # - command: expansions.update - # params: - # updates: - # - { key: KEY, value: VALUE } - # - { key: KEY, value: VALUE } - # - { key: KEY, value: VALUE } - if len(mapping) == 2 and 'key' in mapping and 'value' in mapping: - flow_style = True - - before = [ - 'name', - 'display_name', - 'command', - 'type', - 'run_on', - 'tags', - 'depends_on', - 'binary', - 'working_dir', - ] - - after = [ - 'commands', - 'args', - ] - - ordered = { - field: mapping.pop(field) for field in before if field in mapping - } - - suffix = { - field: mapping.pop(field) for field in after if field in mapping - } - - ordered.update(sorted(mapping.items())) - ordered.update(suffix) - - return self.represent_special_mapping(tag, ordered.items(), flow_style) - - # Ensure a block sequence is indented relative to its parent node:: - # key: - # - a - # - b - # - c - # instead of:: - # key: - # - a - # - b - # - c - def increase_indent(self, flow=None, indentless=None): - indentless = False - return super().increase_indent(flow=flow, indentless=indentless) - - -def to_yaml(project: EvgProject) -> str: - return yaml.dump( - project.dict(exclude_none=True, exclude_unset=True, by_alias=True), - Dumper=ConfigDumper, - default_flow_style=False, - width=float('inf'), - ) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generate.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generate.py deleted file mode 100644 index f2d33043d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generate.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python3 - -# Generates *.yml files under .evergreen/generated_configs. -# -# Install dependencies by running (preferably in a virtual environment): -# python -m pip install -r .evergreen/config_generator/requirements.txt -# -# Invoke this using the command: -# python3 .evergreen/config_generator/generate-config.py - - -import sys - -from importlib import import_module - - -GENERATOR_NAMES = [ - "functions", - "tasks", - "task_groups", - "variants", - "legacy_config", -] - - -def main(): - # Requires Python 3.10 or newer. - assert sys.version_info.major >= 3 - assert sys.version_info.minor >= 10 - - for name in GENERATOR_NAMES: - m = import_module(f"config_generator.generators.{name}") - print(f"Running {name}.generate()...") - m.generate() - print(f"Running {name}.generate()... done.") - - -if __name__ == "__main__": - main() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/requirements.txt b/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/requirements.txt deleted file mode 100644 index cfb282356..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ --e git+https://github.com/mongodb-labs/drivers-evergreen-tools#egg=evergreen_config_generator&subdirectory=evergreen_config_generator -git-url-parse==1.2.2 -packaging==23.1 -pbr==5.11.1 -pydantic==1.10.4 -PyYAML==5.4.1 -shrub.py==3.0.4 -typing_extensions==4.4.0 -yamlordereddictloader==0.4.0 diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/spec.patch b/3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/spec.patch deleted file mode 100644 index 73a4109e2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/spec.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- mongo-c-driver.spec -+++ mongo-c-driver.spec -@@ -10,7 +10,7 @@ - %global gh_project mongo-c-driver - %global libname libmongoc - %global libver 1.0 --%global up_version 1.26.1 -+%global up_version 1.26.2 - #global up_prever rc0 - # disabled as require a MongoDB server - %bcond_with tests -@@ -20,7 +20,7 @@ - - Name: mongo-c-driver - Summary: Client library written in C for MongoDB --Version: %{up_version}%{?up_prever:~%{up_prever}} -+Version: %{up_version}%{?up_prever} - Release: 1%{?dist} - # See THIRD_PARTY_NOTICES - License: Apache-2.0 AND ISC AND MIT AND Zlib diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/legacy-config.yml b/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/legacy-config.yml deleted file mode 100644 index 4d5004c00..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/legacy-config.yml +++ /dev/null @@ -1,14497 +0,0 @@ -#################################### -# Evergreen configuration -# -# Generated with evergreen_config_generator from -# github.com/mongodb-labs/drivers-evergreen-tools -# -# DO NOT EDIT THIS FILE -# -#################################### -functions: - install ssl: - - command: shell.exec - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - bash .evergreen/scripts/install-ssl.sh - upload coverage: - - command: shell.exec - params: - silent: true - working_dir: mongoc - shell: bash - script: |- - set -o errexit - export AWS_ACCESS_KEY_ID=${aws_key} - export AWS_SECRET_ACCESS_KEY=${aws_secret} - aws s3 cp coverage s3://mciuploads/${project}/${build_variant}/${revision}/${version_id}/${build_id}/coverage/ --recursive --acl public-read --region us-east-1 - - command: s3.put - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - remote_file: ${project}/${build_variant}/${revision}/${version_id}/${build_id}/coverage/index.html - bucket: mciuploads - permissions: public-read - local_file: mongoc/coverage/index.html - content_type: text/html - display_name: Coverage Report - upload scan artifacts: - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - if find scan -name \*.html | grep -q html; then - (cd scan && find . -name index.html -exec echo "
  • {}
  • " \;) >> scan.html - else - echo "No issues found" > scan.html - fi - - command: shell.exec - params: - silent: true - working_dir: mongoc - shell: bash - script: |- - set -o errexit - export AWS_ACCESS_KEY_ID=${aws_key} - export AWS_SECRET_ACCESS_KEY=${aws_secret} - aws s3 cp scan s3://mciuploads/${project}/${build_variant}/${revision}/${version_id}/${build_id}/scan/ --recursive --acl public-read --region us-east-1 - - command: s3.put - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - remote_file: ${project}/${build_variant}/${revision}/${version_id}/${build_id}/scan/index.html - bucket: mciuploads - permissions: public-read - local_file: mongoc/scan.html - content_type: text/html - display_name: Scan Build Report - run auth tests: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - bash .evergreen/scripts/run-auth-tests.sh - link sample program: - - command: shell.exec - type: test - params: - working_dir: mongoc - include_expansions_in_env: - - distro_id - shell: bash - script: |- - set -o errexit - # Compile a program that links dynamically or statically to libmongoc, - # using variables from pkg-config or CMake's find_package command. - export BUILD_SAMPLE_WITH_CMAKE=${BUILD_SAMPLE_WITH_CMAKE} - export BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=${BUILD_SAMPLE_WITH_CMAKE_DEPRECATED} - export ENABLE_SSL=${ENABLE_SSL} - export ENABLE_SNAPPY=${ENABLE_SNAPPY} - LINK_STATIC= bash .evergreen/scripts/link-sample-program.sh - LINK_STATIC=1 bash .evergreen/scripts/link-sample-program.sh - link sample program bson: - - command: shell.exec - type: test - params: - working_dir: mongoc - include_expansions_in_env: - - distro_id - shell: bash - script: |- - set -o errexit - # Compile a program that links dynamically or statically to libbson, - # using variables from pkg-config or from CMake's find_package command. - BUILD_SAMPLE_WITH_CMAKE= BUILD_SAMPLE_WITH_CMAKE_DEPRECATED= LINK_STATIC= bash .evergreen/scripts/link-sample-program-bson.sh - BUILD_SAMPLE_WITH_CMAKE= BUILD_SAMPLE_WITH_CMAKE_DEPRECATED= LINK_STATIC=1 bash .evergreen/scripts/link-sample-program-bson.sh - BUILD_SAMPLE_WITH_CMAKE=1 BUILD_SAMPLE_WITH_CMAKE_DEPRECATED= LINK_STATIC= bash .evergreen/scripts/link-sample-program-bson.sh - BUILD_SAMPLE_WITH_CMAKE=1 BUILD_SAMPLE_WITH_CMAKE_DEPRECATED= LINK_STATIC=1 bash .evergreen/scripts/link-sample-program-bson.sh - BUILD_SAMPLE_WITH_CMAKE=1 BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=1 LINK_STATIC= bash .evergreen/scripts/link-sample-program-bson.sh - BUILD_SAMPLE_WITH_CMAKE=1 BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=1 LINK_STATIC=1 bash .evergreen/scripts/link-sample-program-bson.sh - link sample program MSVC: - - command: shell.exec - type: test - params: - working_dir: mongoc - include_expansions_in_env: - - distro_id - shell: bash - script: |- - set -o errexit - # Build libmongoc with CMake and compile a program that links - # dynamically or statically to it, using variables from CMake's - # find_package command. - export ENABLE_SSL=${ENABLE_SSL} - export ENABLE_SNAPPY=${ENABLE_SNAPPY} - . .evergreen/scripts/use-tools.sh paths - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(native-path "$(find_cmake_latest)")" - LINK_STATIC= cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc.cmd - LINK_STATIC=1 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc.cmd - link sample program mingw: - - command: shell.exec - type: test - params: - working_dir: mongoc - include_expansions_in_env: - - distro_id - shell: bash - script: |- - set -o errexit - # Build libmongoc with CMake and compile a program that links - # dynamically to it, using variables from pkg-config.exe. - . .evergreen/scripts/use-tools.sh paths - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(native-path "$(find_cmake_latest)")" - cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw.cmd - link sample program MSVC bson: - - command: shell.exec - type: test - params: - working_dir: mongoc - include_expansions_in_env: - - distro_id - shell: bash - script: |- - set -o errexit - # Build libmongoc with CMake and compile a program that links - # dynamically or statically to it, using variables from CMake's - # find_package command. - export ENABLE_SSL=${ENABLE_SSL} - export ENABLE_SNAPPY=${ENABLE_SNAPPY} - . .evergreen/scripts/use-tools.sh paths - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(native-path "$(find_cmake_latest)")" - LINK_STATIC= cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc-bson.cmd - LINK_STATIC=1 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc-bson.cmd - link sample program mingw bson: - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - # Build libmongoc with CMake and compile a program that links - # dynamically to it, using variables from pkg-config.exe. - . .evergreen/scripts/use-tools.sh paths - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(native-path "$(find_cmake_latest)")" - cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw-bson.cmd - update codecov.io: - - command: shell.exec - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - # Note: coverage is currently only enabled on the ubuntu1804 distro. - # This script does not support MacOS, Windows, or non-x86_64 distros. - # Update accordingly if code coverage is expanded to other distros. - curl -Os https://uploader.codecov.io/latest/linux/codecov - chmod +x codecov - # -Z: Exit with a non-zero value if error. - # -g: Run with gcov support. - # -t: Codecov upload token. - # perl: filter verbose "Found" list and "Processing" messages. - ./codecov -Zgt "${codecov_token}" | perl -lne 'print if not m|^.*\.gcov(\.\.\.)?$|' - compile coverage: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - COVERAGE=ON DEBUG=ON bash .evergreen/scripts/compile.sh - build mongohouse: - - command: shell.exec - type: test - params: - shell: bash - script: |- - set -o errexit - cd drivers-evergreen-tools - export DRIVERS_TOOLS=$(pwd) - bash .evergreen/atlas_data_lake/pull-mongohouse-image.sh - run mongohouse: - - command: shell.exec - type: test - params: - shell: bash - script: |- - set -o errexit - cd drivers-evergreen-tools - export DRIVERS_TOOLS=$(pwd) - bash .evergreen/atlas_data_lake/run-mongohouse-image.sh - test mongohouse: - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - echo "Waiting for mongohouse to start..." - wait_for_mongohouse() { - for _ in $(seq 300); do - # Exit code 7: "Failed to connect to host". - if curl -s localhost:$1; (("$?" != 7)); then - return 0 - else - sleep 1 - fi - done - echo "Could not detect mongohouse on port $1" 1>&2 - return 1 - } - wait_for_mongohouse 27017 || exit - echo "Waiting for mongohouse to start... done." - pgrep -a "mongohouse" - export RUN_MONGOHOUSE_TESTS=ON - ./src/libmongoc/test-libmongoc --no-fork -l /mongohouse/* -d --skip-tests .evergreen/etc/skip-tests.txt - run aws tests: - - command: ec2.assume_role - params: - role_arn: ${aws_test_secrets_role} - - command: shell.exec - type: test - params: - working_dir: mongoc - include_expansions_in_env: - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY - - AWS_SESSION_TOKEN - shell: bash - script: |- - set -o errexit - pushd ../drivers-evergreen-tools/.evergreen/auth_aws - ./setup_secrets.sh drivers/aws_auth - popd # ../drivers-evergreen-tools/.evergreen/auth_aws - - command: shell.exec - type: test - params: - working_dir: mongoc - include_expansions_in_env: - - TESTCASE - shell: bash - script: |- - set -o errexit - pushd ../drivers-evergreen-tools/.evergreen/auth_aws - . ./activate-authawsvenv.sh - popd # ../drivers-evergreen-tools/.evergreen/auth_aws - bash .evergreen/scripts/run-aws-tests.sh -tasks: -- name: hardened-compile - tags: - - hardened - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS="-fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -fPIE -O" DEBUG="ON" LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now" SNAPPY="OFF" ZLIB="OFF" ZSTD="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-compression-zlib - tags: - - compression - - zlib - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SNAPPY="OFF" ZLIB="BUNDLED" ZSTD="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-compression-snappy - tags: - - compression - - snappy - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SNAPPY="ON" ZLIB="OFF" ZSTD="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-compression-zstd - tags: - - compression - - zstd - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SNAPPY="OFF" ZLIB="OFF" ZSTD="ON" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-compression - tags: - - compression - - snappy - - zlib - - zstd - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SNAPPY="ON" ZLIB="BUNDLED" ZSTD="ON" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-no-align - tags: - - debug-compile - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF" SNAPPY="OFF" ZLIB="BUNDLED" ZSTD="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-nosasl-nossl - tags: - - debug-compile - - nosasl - - nossl - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SSL="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-lto - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS="-flto" DEBUG="ON" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-lto-thin - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS="-flto=thin" DEBUG="ON" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-no-counters - tags: - - debug-compile - - no-counters - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" ENABLE_SHM_COUNTERS="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-asan-clang - tags: - - asan-clang - - debug-compile - - special - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS="-fno-omit-frame-pointer" CHECK_LOG="ON" DEBUG="ON" EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF" SANITIZE="address" SNAPPY="OFF" ZLIB="BUNDLED" ZSTD="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-asan-clang-openssl - tags: - - asan-clang - - debug-compile - - special - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS="-fno-omit-frame-pointer" CHECK_LOG="ON" DEBUG="ON" EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF" SANITIZE="address" SNAPPY="OFF" SSL="OPENSSL" ZLIB="BUNDLED" ZSTD="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: compile-tracing - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS="-Werror -Wno-cast-align" DEBUG="ON" TRACING="ON" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: release-compile - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env RELEASE="ON" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-nosasl-openssl - tags: - - debug-compile - - nosasl - - openssl - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SSL="OPENSSL" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-nosasl-openssl-static - tags: - - debug-compile - - nosasl - - openssl-static - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SSL="OPENSSL_STATIC" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-nosasl-darwinssl - tags: - - darwinssl - - debug-compile - - nosasl - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SSL="DARWIN" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-nosasl-winssl - tags: - - debug-compile - - nosasl - - winssl - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SSL="WINDOWS" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-sasl-nossl - tags: - - debug-compile - - nossl - - sasl - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SASL="AUTO" SSL="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-sasl-openssl - tags: - - debug-compile - - openssl - - sasl - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SASL="AUTO" SSL="OPENSSL" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-sasl-openssl-static - tags: - - debug-compile - - openssl-static - - sasl - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SASL="AUTO" SSL="OPENSSL_STATIC" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-sasl-darwinssl - tags: - - darwinssl - - debug-compile - - sasl - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SASL="AUTO" SSL="DARWIN" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-sspi-nossl - tags: - - debug-compile - - nossl - - sspi - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SASL="SSPI" SSL="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-sspi-openssl - tags: - - debug-compile - - openssl - - sspi - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SASL="SSPI" SSL="OPENSSL" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-sspi-openssl-static - tags: - - debug-compile - - openssl-static - - sspi - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SASL="SSPI" SSL="OPENSSL_STATIC" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-rdtscp - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" ENABLE_RDTSCP="ON" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-sspi-winssl - tags: - - debug-compile - - sspi - - winssl - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SASL="SSPI" SSL="WINDOWS" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-nosrv - tags: - - debug-compile - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG="ON" SRV="OFF" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: link-with-cmake - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program - vars: - BUILD_SAMPLE_WITH_CMAKE: 1 -- name: link-with-cmake-ssl - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program - vars: - BUILD_SAMPLE_WITH_CMAKE: 1 - ENABLE_SSL: 1 -- name: link-with-cmake-snappy - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program - vars: - BUILD_SAMPLE_WITH_CMAKE: 1 - ENABLE_SNAPPY: 'ON' -- name: link-with-cmake-mac - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program - vars: - BUILD_SAMPLE_WITH_CMAKE: 1 -- name: link-with-cmake-deprecated - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program - vars: - BUILD_SAMPLE_WITH_CMAKE: 1 - BUILD_SAMPLE_WITH_CMAKE_DEPRECATED: 1 -- name: link-with-cmake-ssl-deprecated - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program - vars: - BUILD_SAMPLE_WITH_CMAKE: 1 - BUILD_SAMPLE_WITH_CMAKE_DEPRECATED: 1 - ENABLE_SSL: 1 -- name: link-with-cmake-snappy-deprecated - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program - vars: - BUILD_SAMPLE_WITH_CMAKE: 1 - BUILD_SAMPLE_WITH_CMAKE_DEPRECATED: 1 - ENABLE_SNAPPY: 'ON' -- name: link-with-cmake-mac-deprecated - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program - vars: - BUILD_SAMPLE_WITH_CMAKE: 1 - BUILD_SAMPLE_WITH_CMAKE_DEPRECATED: 1 -- name: link-with-cmake-windows - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program MSVC -- name: link-with-cmake-windows-ssl - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - SSL: openssl - - func: link sample program MSVC - vars: - ENABLE_SSL: 1 -- name: link-with-cmake-windows-snappy - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program MSVC - vars: - ENABLE_SNAPPY: 'ON' -- name: link-with-cmake-mingw - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program mingw -- name: link-with-pkg-config - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program -- name: link-with-pkg-config-mac - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program -- name: link-with-pkg-config-ssl - commands: - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: link sample program - vars: - ENABLE_SSL: 1 -- name: link-with-bson - commands: - - func: link sample program bson -- name: link-with-bson-mac - commands: - - func: link sample program bson -- name: link-with-bson-windows - commands: - - func: link sample program MSVC bson -- name: link-with-bson-mingw - commands: - - func: link sample program mingw bson -- name: debian-package-build - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - export IS_PATCH="${is_patch}" - sh .evergreen/scripts/debian_package_build.sh - - command: s3.put - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - remote_file: ${project}/${branch_name}/mongo-c-driver-debian-packages-${CURRENT_VERSION}.tar.gz - bucket: mciuploads - permissions: public-read - local_file: deb.tar.gz - content_type: ${content_type|application/x-gzip} - - command: s3.put - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - remote_file: ${project}/${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-debian-packages.tar.gz - bucket: mciuploads - permissions: public-read - local_file: deb.tar.gz - content_type: ${content_type|application/x-gzip} - - command: s3.put - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - remote_file: ${project}/${branch_name}/mongo-c-driver-debian-packages-i386-${CURRENT_VERSION}.tar.gz - bucket: mciuploads - permissions: public-read - local_file: deb-i386.tar.gz - content_type: ${content_type|application/x-gzip} - - command: s3.put - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - remote_file: ${project}/${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-debian-packages-i386.tar.gz - bucket: mciuploads - permissions: public-read - local_file: deb-i386.tar.gz - content_type: ${content_type|application/x-gzip} -- name: rpm-package-build - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - export IS_PATCH="${is_patch}" - sh .evergreen/scripts/check_rpm_spec.sh - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - sh .evergreen/scripts/build_snapshot_rpm.sh - - command: s3.put - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - remote_file: ${project}/${branch_name}/mongo-c-driver-rpm-packages-${CURRENT_VERSION}.tar.gz - bucket: mciuploads - permissions: public-read - local_file: rpm.tar.gz - content_type: ${content_type|application/x-gzip} - - command: s3.put - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - remote_file: ${project}/${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-rpm-packages.tar.gz - bucket: mciuploads - permissions: public-read - local_file: rpm.tar.gz - content_type: ${content_type|application/x-gzip} -- name: install-uninstall-check-mingw - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - include_expansions_in_env: - - distro_id - shell: bash - script: |- - set -o errexit - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(find_cmake_latest)" - export CC="C:/mingw-w64/x86_64-4.9.1-posix-seh-rt_v3-rev1/mingw64/bin/gcc.exe" - BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd - cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd -- name: install-uninstall-check-msvc - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - include_expansions_in_env: - - distro_id - shell: bash - script: |- - set -o errexit - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(find_cmake_latest)" - export CC="Visual Studio 14 2015 Win64" - BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd - cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd -- name: install-uninstall-check - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - include_expansions_in_env: - - distro_id - shell: bash - script: |- - set -o errexit - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(find_cmake_latest)" - DESTDIR="$(pwd)/dest" bash ./.evergreen/scripts/install-uninstall-check.sh - BSON_ONLY=1 bash ./.evergreen/scripts/install-uninstall-check.sh - bash ./.evergreen/scripts/install-uninstall-check.sh -- name: debug-compile-with-warnings - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS="-Werror -Wno-cast-align" DEBUG="ON" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-sasl-openssl-static-cse - tags: - - client-side-encryption - - debug-compile - - openssl-static - - sasl - - special - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env COMPILE_LIBMONGOCRYPT="ON" DEBUG="ON" EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON" SASL="AUTO" SSL="OPENSSL_STATIC" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: install ssl - vars: - SSL: openssl-1.0.1u - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS="-Wno-redundant-decls" DEBUG="ON" SASL="OFF" SSL="OPENSSL" bash .evergreen/scripts/compile.sh - - func: upload-build -- name: build-and-test-with-toolchain - commands: - - command: s3.get - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - remote_file: mongo-c-toolchain/${distro_id}/2023/06/07/mongo-c-toolchain.tar.gz - bucket: mongo-c-toolchain - local_file: mongo-c-toolchain.tar.gz - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - bash ./.evergreen/scripts/build-and-test-with-toolchain.sh -- name: install-libmongoc-after-libbson - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - bash ./.evergreen/scripts/install-libmongoc-after-libbson.sh -- name: test-coverage-latest-replica-set-auth-sasl-openssl - tags: - - latest - - test-coverage - commands: - - func: compile coverage - vars: - SASL: AUTO - SSL: OPENSSL - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: latest - SSL: openssl - TOPOLOGY: replica_set - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: auth - COVERAGE: 'ON' - SSL: openssl - - func: upload coverage - - func: update codecov.io -- name: test-coverage-latest-replica-set-auth-sasl-openssl-cse - tags: - - client-side-encryption - - latest - - test-coverage - commands: - - func: compile coverage - vars: - COMPILE_LIBMONGOCRYPT: 'ON' - EXTRA_CONFIGURE_FLAGS: EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON" - SASL: AUTO - SSL: OPENSSL - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: latest - SSL: openssl - TOPOLOGY: replica_set - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - vars: - AUTH: auth - CLIENT_SIDE_ENCRYPTION: 'ON' - COVERAGE: 'ON' - SSL: openssl - - func: upload coverage - - func: update codecov.io -- name: test-dns-openssl - depends_on: - name: debug-compile-sasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sasl-openssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - - func: run-tests - vars: - AUTH: noauth - DNS: 'on' - SSL: ssl -- name: test-dns-winssl - depends_on: - name: debug-compile-sspi-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sspi-winssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - - func: run-tests - vars: - AUTH: noauth - DNS: 'on' - SSL: ssl -- name: test-dns-darwinssl - depends_on: - name: debug-compile-sasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sasl-darwinssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - - func: run-tests - vars: - AUTH: noauth - DNS: 'on' - SSL: ssl -- name: test-dns-loadbalanced-openssl - depends_on: - name: debug-compile-sasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sasl-openssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - LOAD_BALANCER: 'on' - SSL: ssl - TOPOLOGY: sharded_cluster - - func: fetch-det - - func: start-load-balancer - vars: - MONGODB_URI: mongodb://localhost:27017,localhost:27018 - - func: run-tests - vars: - AUTH: noauth - DNS: loadbalanced - SSL: ssl -- name: test-dns-auth-openssl - depends_on: - name: debug-compile-sasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sasl-openssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: replica_set - AUTHSOURCE: thisDB - - func: run-tests - vars: - AUTH: auth - DNS: dns-auth - SSL: ssl -- name: test-dns-auth-winssl - depends_on: - name: debug-compile-sspi-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sspi-winssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: replica_set - AUTHSOURCE: thisDB - - func: run-tests - vars: - AUTH: auth - DNS: dns-auth - SSL: ssl -- name: test-dns-auth-darwinssl - depends_on: - name: debug-compile-sasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sasl-darwinssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: replica_set - AUTHSOURCE: thisDB - - func: run-tests - vars: - AUTH: auth - DNS: dns-auth - SSL: ssl -- name: test-latest-server-compression-zlib - tags: - - compression - - latest - - zlib - depends_on: - name: debug-compile-compression-zlib - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-compression-zlib - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - ORCHESTRATION_FILE: zlib - SSL: nossl - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: noauth - COMPRESSORS: zlib - SSL: nossl -- name: test-latest-server-compression-snappy - tags: - - compression - - latest - - snappy - depends_on: - name: debug-compile-compression-snappy - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-compression-snappy - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - ORCHESTRATION_FILE: snappy - SSL: nossl - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: noauth - COMPRESSORS: snappy - SSL: nossl -- name: test-latest-server-compression-zstd - tags: - - compression - - latest - - zstd - depends_on: - name: debug-compile-compression-zstd - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-compression-zstd - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - ORCHESTRATION_FILE: zstd - SSL: nossl - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: noauth - COMPRESSORS: zstd - SSL: nossl -- name: test-latest-server-compression - tags: - - compression - - latest - - snappy - - zlib - - zstd - depends_on: - name: debug-compile-compression - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-compression - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - ORCHESTRATION_FILE: snappy-zlib-zstd - SSL: nossl - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: noauth - COMPRESSORS: snappy,zlib,zstd - SSL: nossl -- name: retry-true-latest-server - depends_on: - name: debug-compile-sasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sasl-openssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - TOPOLOGY: server - - func: run-simple-http-server - - func: run-tests - vars: - URI: mongodb://localhost/?retryWrites=true -- name: test-latest-server-hardened - tags: - - hardened - - latest - depends_on: - name: hardened-compile - commands: - - func: fetch-build - vars: - BUILD_NAME: hardened-compile - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - TOPOLOGY: server - - func: run-simple-http-server - - func: run-tests - vars: - URI: null -- name: authentication-tests-openssl - tags: - - authentication-tests - - openssl - - sasl - depends_on: - name: debug-compile-sasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sasl-openssl - - func: prepare-kerberos - - func: run auth tests -- name: authentication-tests-darwinssl - tags: - - authentication-tests - - darwinssl - - sasl - depends_on: - name: debug-compile-sasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sasl-darwinssl - - func: prepare-kerberos - - func: run auth tests -- name: authentication-tests-winssl - tags: - - authentication-tests - - sspi - - winssl - depends_on: - name: debug-compile-sspi-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sspi-winssl - - func: prepare-kerberos - - func: run auth tests -- name: authentication-tests-openssl-nosasl - tags: - - authentication-tests - - nosasl - - openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: prepare-kerberos - - func: run auth tests -- name: test-mongohouse - depends_on: - name: debug-compile-sasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-sasl-openssl - - func: fetch-det - - func: build mongohouse - - func: run mongohouse - - func: test mongohouse -- name: authentication-tests-asan-memcheck - tags: - - asan - - authentication-tests - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env SANITIZE=address DEBUG=ON SASL=AUTO SSL=OPENSSL EXTRA_CONFIGURE_FLAGS='-DENABLE_EXTRA_ALIGNMENT=OFF' bash .evergreen/scripts/compile.sh - - func: prepare-kerberos - - func: run auth tests - vars: - ASAN: 'on' -- name: test-versioned-api-7.0 - tags: - - '7.0' - - versioned-api - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '7.0' - REQUIRE_API_VERSION: 'true' - SSL: ssl - TOPOLOGY: server - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: auth - MONGODB_API_VERSION: 1 - SSL: ssl -- name: test-versioned-api-accept-version-two-7.0 - tags: - - '7.0' - - versioned-api - depends_on: - name: debug-compile-nosasl-nossl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-nossl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - MONGODB_VERSION: '7.0' - ORCHESTRATION_FILE: versioned-api-testing - SSL: nossl - TOPOLOGY: server - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: noauth - MONGODB_API_VERSION: 1 - SSL: nossl -- name: test-versioned-api-6.0 - tags: - - '6.0' - - versioned-api - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '6.0' - REQUIRE_API_VERSION: 'true' - SSL: ssl - TOPOLOGY: server - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: auth - MONGODB_API_VERSION: 1 - SSL: ssl -- name: test-versioned-api-accept-version-two-6.0 - tags: - - '6.0' - - versioned-api - depends_on: - name: debug-compile-nosasl-nossl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-nossl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - MONGODB_VERSION: '6.0' - ORCHESTRATION_FILE: versioned-api-testing - SSL: nossl - TOPOLOGY: server - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: noauth - MONGODB_API_VERSION: 1 - SSL: nossl -- name: test-versioned-api-5.0 - tags: - - '5.0' - - versioned-api - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '5.0' - REQUIRE_API_VERSION: 'true' - SSL: ssl - TOPOLOGY: server - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: auth - MONGODB_API_VERSION: 1 - SSL: ssl -- name: test-versioned-api-accept-version-two-5.0 - tags: - - '5.0' - - versioned-api - depends_on: - name: debug-compile-nosasl-nossl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-nossl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - MONGODB_VERSION: '5.0' - ORCHESTRATION_FILE: versioned-api-testing - SSL: nossl - TOPOLOGY: server - - func: run-simple-http-server - - func: run-tests - vars: - AUTH: noauth - MONGODB_API_VERSION: 1 - SSL: nossl -- name: build-and-run-authentication-tests-openssl-1.0.1 - commands: - - func: install ssl - vars: - SSL: openssl-1.0.1u - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS=-Wno-redundant-decls DEBUG=ON SASL=OFF SSL=OPENSSL bash .evergreen/scripts/compile.sh - - func: run auth tests - - func: upload-build -- name: build-and-run-authentication-tests-openssl-1.0.1-fips - commands: - - func: install ssl - vars: - SSL: openssl-1.0.1u-fips - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS=-Wno-redundant-decls DEBUG=ON SASL=OFF SSL=OPENSSL bash .evergreen/scripts/compile.sh - - func: run auth tests - - func: upload-build -- name: build-and-run-authentication-tests-openssl-1.0.2 - commands: - - func: install ssl - vars: - SSL: openssl-1.0.2l - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env CFLAGS=-Wno-redundant-decls DEBUG=ON SASL=OFF SSL=OPENSSL bash .evergreen/scripts/compile.sh - - func: run auth tests - - func: upload-build -- name: build-and-run-authentication-tests-openssl-1.1.0 - commands: - - func: install ssl - vars: - SSL: openssl-1.1.0l - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG=ON SASL=OFF SSL=OPENSSL bash .evergreen/scripts/compile.sh - - func: run auth tests - - func: upload-build -- name: build-and-run-authentication-tests-libressl-2.5 - commands: - - func: install ssl - vars: - SSL: libressl-2.5.2 - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG=ON SASL=OFF SSL=LIBRESSL bash .evergreen/scripts/compile.sh - - func: run auth tests - vars: - require_tls12: true - - func: upload-build -- name: build-and-run-authentication-tests-libressl-3.0-auto - commands: - - func: install ssl - vars: - SSL: libressl-3.0.2 - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG=ON SASL=OFF SSL=AUTO bash .evergreen/scripts/compile.sh - - func: run auth tests - vars: - require_tls12: true - - func: upload-build -- name: build-and-run-authentication-tests-libressl-3.0 - commands: - - func: install ssl - vars: - SSL: libressl-3.0.2 - - command: shell.exec - type: test - params: - working_dir: mongoc - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - env DEBUG=ON SASL=OFF SSL=LIBRESSL bash .evergreen/scripts/compile.sh - - func: run auth tests - vars: - require_tls12: true - - func: upload-build -- name: test-latest-server-ipv6-client-ipv6-noauth-nosasl-nossl - tags: - - ipv4-ipv6 - - latest - - nosasl - - nossl - - server - depends_on: - name: debug-compile-nosasl-nossl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-nossl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - IPV4_ONLY: 'off' - - func: run-simple-http-server - - func: run-tests - vars: - IPV4_ONLY: 'off' - URI: mongodb://[::1]/ -- name: test-latest-server-ipv6-client-ipv4-noauth-nosasl-nossl - tags: - - ipv4-ipv6 - - latest - - nosasl - - nossl - - server - depends_on: - name: debug-compile-nosasl-nossl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-nossl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - IPV4_ONLY: 'off' - - func: run-simple-http-server - - func: run-tests - vars: - IPV4_ONLY: 'off' - URI: mongodb://127.0.0.1/ -- name: test-latest-server-ipv4-client-ipv4-noauth-nosasl-nossl - tags: - - ipv4-ipv6 - - latest - - nosasl - - nossl - - server - depends_on: - name: debug-compile-nosasl-nossl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-nossl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - IPV4_ONLY: 'on' - - func: run-simple-http-server - - func: run-tests - vars: - IPV4_ONLY: 'on' - URI: mongodb://127.0.0.1/ -- name: test-latest-server-ipv4-client-localhost-noauth-nosasl-nossl - tags: - - ipv4-ipv6 - - latest - - nosasl - - nossl - - server - depends_on: - name: debug-compile-nosasl-nossl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-nossl - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - IPV4_ONLY: 'on' - - func: run-simple-http-server - - func: run-tests - vars: - IPV4_ONLY: 'on' - URI: mongodb://localhost/ -- name: debug-compile-aws - commands: - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - export distro_id='${distro_id}' # Required by find_cmake_latest. - . .evergreen/scripts/find-cmake-latest.sh - cmake_binary="$(find_cmake_latest)" - # Allow reuse of ccache compilation results between different build directories. - export CCACHE_BASEDIR CCACHE_NOHASHDIR - CCACHE_BASEDIR="$(pwd)" - CCACHE_NOHASHDIR=1 - # Compile test-awsauth. Disable unnecessary dependencies since test-awsauth is copied to a remote Ubuntu 20.04 ECS cluster for testing, which may not have all dependent libraries. - export CC='${CC}' - "$cmake_binary" -DENABLE_TRACING=ON -DENABLE_SASL=OFF -DENABLE_SNAPPY=OFF -DENABLE_ZSTD=OFF -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF . - "$cmake_binary" --build . --target test-awsauth - - func: upload-build -- name: test-aws-openssl-regular-latest - tags: - - latest - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: latest - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: REGULAR -- name: test-aws-openssl-regular-7.0 - tags: - - '7.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '7.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: REGULAR -- name: test-aws-openssl-regular-6.0 - tags: - - '6.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '6.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: REGULAR -- name: test-aws-openssl-regular-5.0 - tags: - - '5.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '5.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: REGULAR -- name: test-aws-openssl-regular-4.4 - tags: - - '4.4' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '4.4' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: REGULAR -- name: test-aws-openssl-ec2-latest - tags: - - latest - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: latest - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: EC2 -- name: test-aws-openssl-ec2-7.0 - tags: - - '7.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '7.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: EC2 -- name: test-aws-openssl-ec2-6.0 - tags: - - '6.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '6.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: EC2 -- name: test-aws-openssl-ec2-5.0 - tags: - - '5.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '5.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: EC2 -- name: test-aws-openssl-ec2-4.4 - tags: - - '4.4' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '4.4' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: EC2 -- name: test-aws-openssl-ecs-latest - tags: - - latest - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: latest - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ECS -- name: test-aws-openssl-ecs-7.0 - tags: - - '7.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '7.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ECS -- name: test-aws-openssl-ecs-6.0 - tags: - - '6.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '6.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ECS -- name: test-aws-openssl-ecs-5.0 - tags: - - '5.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '5.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ECS -- name: test-aws-openssl-ecs-4.4 - tags: - - '4.4' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '4.4' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ECS -- name: test-aws-openssl-lambda-latest - tags: - - latest - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: latest - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: LAMBDA -- name: test-aws-openssl-lambda-7.0 - tags: - - '7.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '7.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: LAMBDA -- name: test-aws-openssl-lambda-6.0 - tags: - - '6.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '6.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: LAMBDA -- name: test-aws-openssl-lambda-5.0 - tags: - - '5.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '5.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: LAMBDA -- name: test-aws-openssl-lambda-4.4 - tags: - - '4.4' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '4.4' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: LAMBDA -- name: test-aws-openssl-assume_role-latest - tags: - - latest - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: latest - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ASSUME_ROLE -- name: test-aws-openssl-assume_role-7.0 - tags: - - '7.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '7.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ASSUME_ROLE -- name: test-aws-openssl-assume_role-6.0 - tags: - - '6.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '6.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ASSUME_ROLE -- name: test-aws-openssl-assume_role-5.0 - tags: - - '5.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '5.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ASSUME_ROLE -- name: test-aws-openssl-assume_role-4.4 - tags: - - '4.4' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '4.4' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ASSUME_ROLE -- name: test-aws-openssl-assume_role_with_web_identity-latest - tags: - - latest - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: latest - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY -- name: test-aws-openssl-assume_role_with_web_identity-7.0 - tags: - - '7.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '7.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY -- name: test-aws-openssl-assume_role_with_web_identity-6.0 - tags: - - '6.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '6.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY -- name: test-aws-openssl-assume_role_with_web_identity-5.0 - tags: - - '5.0' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '5.0' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY -- name: test-aws-openssl-assume_role_with_web_identity-4.4 - tags: - - '4.4' - - test-aws - depends_on: - name: debug-compile-aws - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-aws - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - MONGODB_VERSION: '4.4' - ORCHESTRATION_FILE: auth-aws - TOPOLOGY: server - - func: run aws tests - vars: - TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY -- name: ocsp-openssl-test_1-rsa-delegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-rsa-delegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-rsa-delegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-rsa-delegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-rsa-delegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-ecdsa-delegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-ecdsa-delegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-ecdsa-delegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-ecdsa-delegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-ecdsa-delegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-rsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-rsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-rsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-rsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-rsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-ecdsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_1-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-rsa-delegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-rsa-delegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-rsa-delegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-rsa-delegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-rsa-delegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-ecdsa-delegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-ecdsa-delegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-ecdsa-delegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-ecdsa-delegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-ecdsa-delegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-rsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-rsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-rsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-rsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-rsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-ecdsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_2-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-rsa-delegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-rsa-delegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-rsa-delegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-rsa-delegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-rsa-delegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_3-rsa-delegate-latest - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_3-rsa-delegate-7.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_3-rsa-delegate-6.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_3-rsa-delegate-5.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_3-rsa-delegate-4.4 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_3-rsa-delegate-latest - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_3-rsa-delegate-7.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_3-rsa-delegate-6.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_3-rsa-delegate-5.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_3-rsa-delegate-4.4 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-ecdsa-delegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-ecdsa-delegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-ecdsa-delegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-ecdsa-delegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-ecdsa-delegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-rsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-rsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-rsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-rsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-rsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_3-rsa-nodelegate-latest - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_3-rsa-nodelegate-7.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_3-rsa-nodelegate-6.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_3-rsa-nodelegate-5.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_3-rsa-nodelegate-4.4 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_3-rsa-nodelegate-latest - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_3-rsa-nodelegate-7.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_3-rsa-nodelegate-6.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_3-rsa-nodelegate-5.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_3-rsa-nodelegate-4.4 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-ecdsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_3-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-rsa-delegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-rsa-delegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-rsa-delegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-rsa-delegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-rsa-delegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_4-rsa-delegate-latest - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_4-rsa-delegate-7.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_4-rsa-delegate-6.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_4-rsa-delegate-5.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_4-rsa-delegate-4.4 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_4-rsa-delegate-latest - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_4-rsa-delegate-7.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_4-rsa-delegate-6.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_4-rsa-delegate-5.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_4-rsa-delegate-4.4 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-ecdsa-delegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-ecdsa-delegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-ecdsa-delegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-ecdsa-delegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-ecdsa-delegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-rsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-rsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-rsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-rsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-rsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_4-rsa-nodelegate-latest - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_4-rsa-nodelegate-7.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_4-rsa-nodelegate-6.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_4-rsa-nodelegate-5.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-test_4-rsa-nodelegate-4.4 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_4-rsa-nodelegate-latest - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_4-rsa-nodelegate-7.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_4-rsa-nodelegate-6.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_4-rsa-nodelegate-5.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-test_4-rsa-nodelegate-4.4 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-ecdsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-test_4-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-latest - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-7.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-6.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-5.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-4.4 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-latest - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-7.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-6.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-5.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-4.4 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-latest - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-7.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-6.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-5.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-4.4 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-latest - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-7.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-6.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-5.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-4.4 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-latest - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-7.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-6.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-5.0 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-4.4 - tags: - - ocsp-darwinssl - depends_on: - name: debug-compile-nosasl-darwinssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-darwinssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-latest - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-7.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-6.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-5.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-4.4 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-latest - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-7.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-6.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-5.0 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-4.4 - tags: - - ocsp-winssl - depends_on: - name: debug-compile-nosasl-winssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-winssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-test.sh - patchable: false -- name: ocsp-openssl-cache-rsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-cache-rsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-cache-rsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-cache-rsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-cache-rsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-cache-ecdsa-nodelegate-latest - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-cache-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-cache-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-cache-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-cache-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl - depends_on: - name: debug-compile-nosasl-openssl - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-latest - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: latest - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-7.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '7.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-6.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '6.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-5.0 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '5.0' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-4.4 - tags: - - ocsp-openssl-1.0.1 - depends_on: - name: debug-compile-nosasl-openssl-1.0.1 - commands: - - func: fetch-build - vars: - BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 - - func: fetch-det - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF bash .evergreen/scripts/run-ocsp-responder.sh - - func: bootstrap-mongo-orchestration - vars: - MONGODB_VERSION: '4.4' - OCSP: 'on' - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling - SSL: ssl - TOPOLOGY: server - - command: shell.exec - type: test - params: - working_dir: mongoc - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa bash .evergreen/scripts/run-ocsp-cache-test.sh - patchable: false -- name: testazurekms-task - commands: - - func: fetch-source - - command: shell.exec - params: - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - echo "Building test-azurekms ... begin" - pushd mongoc - ./.evergreen/scripts/compile-test-azurekms.sh - popd - echo "Building test-azurekms ... end" - echo "Copying files ... begin" - export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup} - export AZUREKMS_VMNAME=${AZUREKMS_VMNAME} - export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey - DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools - mkdir testazurekms - cp ./mongoc/src/libmongoc/test-azurekms ./mongoc/install/lib/libmongocrypt.* testazurekms - tar czf testazurekms.tgz testazurekms/* - AZUREKMS_SRC="testazurekms.tgz" \ - AZUREKMS_DST="./" \ - $DRIVERS_TOOLS/.evergreen/csfle/azurekms/copy-file.sh - echo "Copying files ... end" - echo "Untarring file ... begin" - AZUREKMS_CMD="tar xf testazurekms.tgz" \ - $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh - echo "Untarring file ... end" - - command: shell.exec - type: test - params: - shell: bash - script: |- - set -o errexit - export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup} - export AZUREKMS_VMNAME=${AZUREKMS_VMNAME} - export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey - DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools - AZUREKMS_CMD="LD_LIBRARY_PATH=./testazurekms MONGODB_URI='mongodb://localhost:27017' KEY_NAME='${testazurekms_keyname}' KEY_VAULT_ENDPOINT='${testazurekms_keyvaultendpoint}' ./testazurekms/test-azurekms" \ - $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh -- name: testazurekms-fail-task - commands: - - func: fetch-source - - command: shell.exec - params: - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - pushd mongoc - ./.evergreen/scripts/compile-test-azurekms.sh - popd - - command: shell.exec - type: test - params: - shell: bash - script: |- - set -o errexit - LD_LIBRARY_PATH=$PWD/install \ - MONGODB_URI='mongodb://localhost:27017' \ - KEY_NAME='${testazurekms_keyname}' \ - KEY_VAULT_ENDPOINT='${testazurekms_keyvaultendpoint}' \ - EXPECT_ERROR='Error from Azure IMDS server' \ - ./mongoc/src/libmongoc/test-azurekms -- name: testgcpkms-task - commands: - - func: fetch-source - - command: shell.exec - params: - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - echo "Building test-gcpkms ... begin" - pushd mongoc - ./.evergreen/scripts/compile-test-gcpkms.sh - popd - echo "Building test-gcpkms ... end" - echo "Copying files ... begin" - export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} - export GCPKMS_PROJECT=${GCPKMS_PROJECT} - export GCPKMS_ZONE=${GCPKMS_ZONE} - export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} - DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools - mkdir testgcpkms - cp ./mongoc/src/libmongoc/test-gcpkms ./mongoc/install/lib/libmongocrypt.* testgcpkms - tar czf testgcpkms.tgz testgcpkms/* - GCPKMS_SRC="testgcpkms.tgz" GCPKMS_DST=$GCPKMS_INSTANCENAME: $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/copy-file.sh - echo "Copying files ... end" - echo "Untarring file ... begin" - GCPKMS_CMD="tar xf testgcpkms.tgz" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh - echo "Untarring file ... end" - - command: shell.exec - type: test - params: - shell: bash - script: |- - set -o errexit - export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} - export GCPKMS_PROJECT=${GCPKMS_PROJECT} - export GCPKMS_ZONE=${GCPKMS_ZONE} - export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} - DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools - GCPKMS_CMD="LD_LIBRARY_PATH=./testgcpkms MONGODB_URI='mongodb://localhost:27017' ./testgcpkms/test-gcpkms" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh -- name: testgcpkms-fail-task - commands: - - command: shell.exec - params: - add_expansions_to_env: true - shell: bash - script: |- - set -o errexit - pushd mongoc - ./.evergreen/scripts/compile-test-gcpkms.sh - popd - - command: shell.exec - type: test - params: - shell: bash - script: |- - set -o errexit - export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} - export GCPKMS_PROJECT=${GCPKMS_PROJECT} - export GCPKMS_ZONE=${GCPKMS_ZONE} - export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} - LD_LIBRARY_PATH=$(pwd)/install MONGODB_URI='mongodb://localhost:27017' EXPECT_ERROR='Failed to connect to: metadata.google.internal' ./mongoc/src/libmongoc/test-gcpkms -task_groups: -- name: testazurekms_task_group - setup_group: - - func: fetch-det - - command: shell.exec - params: - shell: bash - script: |- - set -o errexit - DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools - echo '${testazurekms_publickey}' > /tmp/testazurekms_publickey - echo '${testazurekms_privatekey}' > /tmp/testazurekms_privatekey - # Set 600 permissions on private key file. Otherwise ssh / scp may error with permissions "are too open". - chmod 600 /tmp/testazurekms_privatekey - export AZUREKMS_CLIENTID=${testazurekms_clientid} - export AZUREKMS_TENANTID=${testazurekms_tenantid} - export AZUREKMS_SECRET=${testazurekms_secret} - export AZUREKMS_DRIVERS_TOOLS=$DRIVERS_TOOLS - export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup} - export AZUREKMS_PUBLICKEYPATH=/tmp/testazurekms_publickey - export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey - export AZUREKMS_SCOPE=${testazurekms_scope} - export AZUREKMS_VMNAME_PREFIX=CDRIVER - $DRIVERS_TOOLS/.evergreen/csfle/azurekms/create-and-setup-vm.sh - - command: expansions.update - params: - file: testazurekms-expansions.yml - teardown_group: - - command: expansions.update - params: - file: testazurekms-expansions.yml - - command: shell.exec - params: - shell: bash - script: |- - set -o errexit - DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools - export AZUREKMS_VMNAME=${AZUREKMS_VMNAME} - export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup} - $DRIVERS_TOOLS/.evergreen/csfle/azurekms/delete-vm.sh - setup_group_can_fail_task: true - setup_group_timeout_secs: 1800 - tasks: - - testazurekms-task -- name: testgcpkms_task_group - setup_group: - - func: fetch-det - - command: shell.exec - params: - shell: bash - script: |- - set -o errexit - DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools - echo '${testgcpkms_key_file}' > /tmp/testgcpkms_key_file.json - export GCPKMS_KEYFILE=/tmp/testgcpkms_key_file.json - export GCPKMS_DRIVERS_TOOLS=$DRIVERS_TOOLS - export GCPKMS_SERVICEACCOUNT="${testgcpkms_service_account}" - $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/create-and-setup-instance.sh - - command: expansions.update - params: - file: testgcpkms-expansions.yml - teardown_group: - - command: shell.exec - params: - shell: bash - script: |- - set -o errexit - DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools - export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} - export GCPKMS_PROJECT=${GCPKMS_PROJECT} - export GCPKMS_ZONE=${GCPKMS_ZONE} - export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} - $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/delete-instance.sh - setup_group_can_fail_task: true - setup_group_timeout_secs: 1800 - tasks: - - testgcpkms-task -buildvariants: -- name: abi-compliance-check - display_name: ABI Compliance Check - run_on: - - ubuntu1804-small - - ubuntu1804-medium - - ubuntu1804-large - tasks: - - abi-compliance-check -- name: smoke - display_name: Smoke Tests - expansions: - SKIP_LEGACY_SHELL: '1' - run_on: ubuntu2204-small - tasks: - - make-docs - - kms-divergence-check - - release-compile - - debug-compile-no-counters - - compile-tracing - - link-with-cmake - - link-with-cmake-deprecated - - link-with-cmake-ssl - - link-with-cmake-ssl-deprecated - - link-with-cmake-snappy - - link-with-cmake-snappy-deprecated - - name: link-with-cmake-mac - distros: - - macos-1100 - - name: link-with-cmake-mac-deprecated - distros: - - macos-1100 - - name: link-with-cmake-windows - distros: - - windows-vsCurrent-large - - name: link-with-cmake-windows-ssl - distros: - - windows-vsCurrent-large - - name: link-with-cmake-windows-snappy - distros: - - windows-vsCurrent-large - - name: link-with-cmake-mingw - distros: - - windows-vsCurrent-large - - name: link-with-pkg-config - distros: - - ubuntu1804-test - - name: link-with-pkg-config-mac - distros: - - macos-1100 - - link-with-pkg-config-ssl - - link-with-bson - - name: link-with-bson-windows - distros: - - windows-vsCurrent-large - - name: link-with-bson-mac - distros: - - macos-1100 - - name: link-with-bson-mingw - distros: - - windows-vsCurrent-large - - check-headers - - install-uninstall-check - - name: install-uninstall-check-mingw - distros: - - windows-vsCurrent-large - - name: install-uninstall-check-msvc - distros: - - windows-vsCurrent-large - - debug-compile-with-warnings - - name: build-and-test-with-toolchain - distros: - - debian10-small - - install-libmongoc-after-libbson - tags: - - pr-merge-gate -- name: clang38 - display_name: clang 3.8 (Debian 9.2) - expansions: - CC: clang - run_on: debian92-test - tasks: - - release-compile - - debug-compile-nosasl-nossl - - .latest .nossl -- name: openssl - display_name: OpenSSL / LibreSSL - run_on: archlinux-build - tasks: - - build-and-run-authentication-tests-openssl-1.0.1 - - build-and-run-authentication-tests-openssl-1.0.2 - - build-and-run-authentication-tests-openssl-1.1.0 - - build-and-run-authentication-tests-openssl-1.0.1-fips - - build-and-run-authentication-tests-libressl-2.5 - - build-and-run-authentication-tests-libressl-3.0-auto - - build-and-run-authentication-tests-libressl-3.0 -- name: clang37 - display_name: clang 3.7 (Archlinux) - expansions: - CC: clang - run_on: archlinux-test - tasks: - - release-compile - - debug-compile-sasl-openssl - - debug-compile-nosasl-openssl - - .authentication-tests .openssl -- name: clang60-i686 - display_name: clang 6.0 (i686) (Ubuntu 18.04) - expansions: - CC: clang - MARCH: i686 - run_on: ubuntu1804-test - tasks: - - release-compile - - debug-compile-nosasl-nossl - - debug-compile-no-align - - .debug-compile !.sspi .nossl .nosasl - - .latest .nossl .nosasl -- name: clang38-i686 - display_name: clang 3.8 (i686) (Ubuntu 16.04) - expansions: - CC: clang - MARCH: i686 - run_on: ubuntu1604-test - tasks: - - release-compile - - debug-compile-no-align -- name: clang38ubuntu - display_name: clang 3.8 (Ubuntu 16.04) - expansions: - CC: clang - run_on: ubuntu1604-test - tasks: - - .compression !.zstd - - release-compile - - debug-compile-sasl-openssl - - debug-compile-nosasl-openssl - - debug-compile-no-align - - .authentication-tests .openssl -- name: gcc82rhel - display_name: GCC 8.2 (RHEL 8.0) - expansions: - CC: gcc - run_on: rhel80-test - tasks: - - .hardened - - .compression !.snappy !.zstd - - release-compile - - debug-compile-nosasl-nossl - - debug-compile-nosasl-openssl - - debug-compile-sasl-openssl - - .authentication-tests .openssl - - .latest .nossl -- name: gcc48rhel - display_name: GCC 4.8 (RHEL 7.0) - expansions: - CC: gcc - run_on: rhel70 - tasks: - - .hardened - - .compression !.snappy - - release-compile - - debug-compile-nosasl-nossl - - debug-compile-sasl-openssl - - debug-compile-nosasl-openssl - - .authentication-tests .openssl - - .latest .nossl -- name: gcc63 - display_name: GCC 6.3 (Debian 9.2) - expansions: - CC: gcc - run_on: debian92-test - tasks: - - release-compile - - debug-compile-nosasl-nossl - - .latest .nossl -- name: gcc83 - display_name: GCC 8.3 (Debian 10.0) - expansions: - CC: gcc - run_on: debian10-test - tasks: - - release-compile - - debug-compile-nosasl-nossl - - .latest .nossl -- name: gcc102 - display_name: GCC 10.2 (Debian 11.0) - expansions: - CC: gcc - run_on: debian11-large - tasks: - - release-compile - - debug-compile-nosasl-nossl - - .latest .nossl -- name: gcc94 - display_name: GCC 9.4 (Ubuntu 20.04) - expansions: - CC: gcc - run_on: ubuntu2004-large - tasks: - - release-compile - - debug-compile-nosasl-nossl - - .latest .nossl -- name: gcc75-i686 - display_name: GCC 7.5 (i686) (Ubuntu 18.04) - expansions: - CC: gcc - MARCH: i686 - run_on: ubuntu1804-test - tasks: - - release-compile - - debug-compile-nosasl-nossl - - debug-compile-no-align - - .latest .nossl .nosasl -- name: gcc75 - display_name: GCC 7.5 (Ubuntu 18.04) - expansions: - CC: gcc - run_on: ubuntu1804-test - tasks: - - .compression !.zstd - - debug-compile-nosrv - - release-compile - - debug-compile-nosasl-nossl - - debug-compile-no-align - - debug-compile-sasl-openssl - - debug-compile-nosasl-openssl - - .authentication-tests .openssl - - .authentication-tests .asan - - .test-coverage - - .latest .nossl - - retry-true-latest-server - - test-dns-openssl - - test-dns-auth-openssl - - test-dns-loadbalanced-openssl -- name: gcc54 - display_name: GCC 5.4 (Ubuntu 16.04) - expansions: - CC: gcc - run_on: ubuntu1604-test - tasks: - - .compression !.zstd - - debug-compile-nosrv - - release-compile - - debug-compile-no-align -- name: darwin - display_name: '*Darwin, macOS (Apple LLVM)' - expansions: - CC: clang - run_on: macos-1100 - tasks: - - .compression !.snappy - - release-compile - - debug-compile-nosasl-nossl - - debug-compile-rdtscp - - debug-compile-no-align - - debug-compile-nosrv - - debug-compile-sasl-darwinssl - - debug-compile-nosasl-nossl - - .authentication-tests .darwinssl - - .latest .nossl - - test-dns-darwinssl - - test-dns-auth-darwinssl - - debug-compile-lto - - debug-compile-lto-thin - - debug-compile-aws - - test-aws-openssl-regular-4.4 - - test-aws-openssl-regular-latest -- name: windows-2017-32 - display_name: Windows (i686) (VS 2017) - expansions: - CC: Visual Studio 15 2017 - run_on: windows-vsCurrent-large - tasks: - - debug-compile-nosasl-nossl - - .latest .nossl .nosasl -- name: windows-2017 - display_name: Windows (VS 2017) - expansions: - CC: Visual Studio 15 2017 Win64 - run_on: windows-vsCurrent-large - tasks: - - debug-compile-nosasl-nossl - - debug-compile-nosasl-openssl - - debug-compile-sspi-winssl - - .latest .nossl - - .nosasl .latest .nossl - - test-dns-winssl - - test-dns-auth-winssl - - debug-compile-aws - - test-aws-openssl-regular-4.4 - - test-aws-openssl-regular-latest - - .authentication-tests .openssl !.sasl - - .authentication-tests .winssl -- name: windows-2015 - display_name: Windows (VS 2015) - expansions: - CC: Visual Studio 14 2015 Win64 - run_on: windows-64-vs2015-compile - tasks: - - .compression !.snappy !.zstd !.latest - - release-compile - - debug-compile-sspi-winssl - - debug-compile-no-align - - debug-compile-nosrv - - .authentication-tests .winssl -- name: windows-2015-32 - display_name: Windows (i686) (VS 2015) - expansions: - CC: Visual Studio 14 2015 - run_on: windows-64-vs2015-compile - tasks: - - .compression !.snappy !.zstd !.latest - - release-compile - - debug-compile-sspi-winssl - - debug-compile-no-align - - .authentication-tests .winssl -- name: windows-2013 - display_name: Windows (VS 2013) - expansions: - CC: Visual Studio 12 2013 Win64 - run_on: windows-64-vs2013-compile - tasks: - - .compression !.snappy !.zstd !.latest - - release-compile - - debug-compile-sspi-winssl - - .authentication-tests .winssl -- name: windows-2013-32 - display_name: Windows (i686) (VS 2013) - expansions: - CC: Visual Studio 12 2013 - run_on: windows-64-vs2013-compile - tasks: - - release-compile - - debug-compile-rdtscp - - debug-compile-sspi-winssl - - .authentication-tests .winssl -- name: mingw-windows2016 - display_name: MinGW-W64 (Windows Server 2016) - expansions: - CC: mingw - run_on: windows-vsCurrent-large - tasks: - - debug-compile-nosasl-nossl - - .latest .nossl .nosasl .server -- name: mingw - display_name: MinGW-W64 - expansions: - CC: mingw - run_on: windows-vsCurrent-large - tasks: - - debug-compile-no-align -- name: power8-rhel81 - display_name: Power8 (ppc64le) (RHEL 8.1) - expansions: - CC: gcc - run_on: rhel81-power8-test - tasks: - - release-compile - - debug-compile-nosasl-nossl - - debug-compile-sasl-openssl - - .latest .nossl - - test-dns-openssl - batchtime: 1440 -- name: arm-ubuntu1804 - display_name: '*ARM (aarch64) (Ubuntu 18.04)' - expansions: - CC: gcc - run_on: ubuntu1804-arm64-large - tasks: - - .compression !.snappy !.zstd - - debug-compile-no-align - - release-compile - - debug-compile-nosasl-nossl - - debug-compile-nosasl-openssl - - debug-compile-sasl-openssl - - .authentication-tests .openssl - - .latest .nossl - - test-dns-openssl - batchtime: 1440 -- name: arm-ubuntu1604 - display_name: '*ARM (aarch64) (Ubuntu 16.04)' - expansions: - CC: gcc - run_on: ubuntu1604-arm64-large - tasks: - - .compression !.snappy !.zstd - - debug-compile-no-align - - release-compile - batchtime: 1440 -- name: zseries-rhel83 - display_name: '*zSeries' - expansions: - CC: gcc - run_on: rhel83-zseries-small - tasks: - - release-compile - - debug-compile-no-align - - debug-compile-nosasl-nossl - - debug-compile-nosasl-openssl - - debug-compile-sasl-openssl - - .authentication-tests .openssl - - .latest .nossl - batchtime: 1440 -- name: clang60ubuntu - display_name: clang 6.0 (Ubuntu 18.04) - expansions: - CC: clang - run_on: ubuntu1804-test - tasks: - - debug-compile-sasl-openssl-static - - .authentication-tests .asan -- name: aws-ubuntu2004 - display_name: AWS Tests (Ubuntu 20.04) - expansions: - CC: clang - run_on: ubuntu2004-small - tasks: - - debug-compile-aws - - .test-aws .4.4 - - .test-aws .5.0 -- name: aws-ubuntu2204 - display_name: AWS Tests (Ubuntu 22.04) - expansions: - CC: clang - run_on: ubuntu2004-small - tasks: - - debug-compile-aws - - .test-aws .6.0 - - .test-aws .7.0 - - .test-aws .latest -- name: mongohouse - display_name: Mongohouse Test - run_on: ubuntu2204-small - tasks: - - debug-compile-sasl-openssl - - test-mongohouse -- name: ocsp - display_name: OCSP tests - run_on: ubuntu2004-small - tasks: - - name: debug-compile-nosasl-openssl - - name: debug-compile-nosasl-openssl-static - - name: debug-compile-nosasl-darwinssl - distros: - - macos-1100 - - name: debug-compile-nosasl-winssl - distros: - - windows-vsCurrent-large - - name: .ocsp-openssl - - name: .ocsp-darwinssl - distros: - - macos-1100 - - name: .ocsp-winssl - distros: - - windows-vsCurrent-large - - name: debug-compile-nosasl-openssl-1.0.1 - - name: .ocsp-openssl-1.0.1 - batchtime: 10080 -- name: packaging - display_name: Linux Distro Packaging - run_on: ubuntu1804-test - tasks: - - debian-package-build - - name: rpm-package-build - distros: - - rhel90-arm64-small - tags: - - pr-merge-gate -- name: versioned-api-ubuntu1804 - display_name: Versioned API Tests (Ubuntu 18.04) - run_on: ubuntu1804-test - tasks: - - debug-compile-nosasl-openssl - - debug-compile-nosasl-nossl - - .versioned-api .5.0 - - .versioned-api .6.0 -- name: versioned-api-ubuntu2004 - display_name: Versioned API Tests (Ubuntu 20.04) - run_on: ubuntu2004-test - tasks: - - debug-compile-nosasl-openssl - - debug-compile-nosasl-nossl - - .versioned-api .7.0 -- name: testazurekms-variant - display_name: Azure KMS - run_on: debian10-small - tasks: - - testazurekms_task_group - - testazurekms-fail-task - batchtime: 20160 -- name: testgcpkms-variant - display_name: GCP KMS - run_on: debian11-small - tasks: - - testgcpkms_task_group - - testgcpkms-fail-task - batchtime: 20160 diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/tasks.yml b/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/tasks.yml deleted file mode 100644 index e8724eb79..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/tasks.yml +++ /dev/null @@ -1,4877 +0,0 @@ -tasks: - - name: abi-compliance-check - commands: - - func: abi-compliance-check - - name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile - run_on: ubuntu1804-large - tags: [sanitizers-matrix-asan, compile, ubuntu1804, clang, cse, asan, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-test-4.2-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, cse, asan, auth, server, "4.2", openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-test-4.2-server-auth-with-mongocrypt - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, cse, asan, auth, server, "4.2", with-mongocrypt, openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-test-4.4-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, cse, asan, auth, server, "4.4", openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-test-4.4-server-auth-with-mongocrypt - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, cse, asan, auth, server, "4.4", with-mongocrypt, openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-test-5.0-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, cse, asan, auth, server, "5.0", openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-test-5.0-server-auth-with-mongocrypt - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, cse, asan, auth, server, "5.0", with-mongocrypt, openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-test-6.0-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, cse, asan, auth, server, "6.0", openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-test-6.0-server-auth-with-mongocrypt - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, cse, asan, auth, server, "6.0", with-mongocrypt, openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile - run_on: ubuntu2004-large - tags: [sanitizers-matrix-asan, compile, ubuntu2004, clang, cse, asan, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-test-7.0-replica-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, cse, asan, auth, replica, "7.0", openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-test-7.0-replica-auth-with-mongocrypt - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, cse, asan, auth, replica, "7.0", with-mongocrypt, openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-test-7.0-server-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, cse, asan, auth, server, "7.0", openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-test-7.0-server-auth-with-mongocrypt - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, cse, asan, auth, server, "7.0", with-mongocrypt, openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-test-latest-replica-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, cse, asan, auth, replica, latest, openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-test-latest-replica-auth-with-mongocrypt - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, cse, asan, auth, replica, latest, with-mongocrypt, openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-test-latest-server-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, cse, asan, auth, server, latest, openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-test-latest-server-auth-with-mongocrypt - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, cse, asan, auth, server, latest, with-mongocrypt, openssl] - depends_on: [{ name: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-cse-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } - - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-mock-kms-servers - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1604-clang-compile - run_on: ubuntu1604-large - tags: [sanitizers-matrix-asan, compile, ubuntu1604, clang, asan, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: asan-sasl-cyrus-openssl-ubuntu1604-clang-test-3.6-replica-auth - run_on: ubuntu1604-small - tags: [sanitizers-matrix-asan, test, ubuntu1604, clang, sasl-cyrus, asan, auth, replica, "3.6", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1604-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1604-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "3.6" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1604-clang-test-3.6-server-auth - run_on: ubuntu1604-small - tags: [sanitizers-matrix-asan, test, ubuntu1604, clang, sasl-cyrus, asan, auth, server, "3.6", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1604-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1604-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "3.6" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1604-clang-test-3.6-sharded-auth - run_on: ubuntu1604-small - tags: [sanitizers-matrix-asan, test, ubuntu1604, clang, sasl-cyrus, asan, auth, sharded, "3.6", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1604-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1604-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "3.6" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - run_on: ubuntu1804-large - tags: [sanitizers-matrix-asan, compile, ubuntu1804, clang, asan, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.0-replica-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, replica, "4.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.0-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, server, "4.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.0-sharded-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, sharded, "4.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.2-replica-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, replica, "4.2", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.2-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, server, "4.2", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.2-sharded-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, sharded, "4.2", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.4-replica-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, replica, "4.4", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.4-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, server, "4.4", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.4-sharded-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, sharded, "4.4", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-5.0-replica-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, replica, "5.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-5.0-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, server, "5.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-5.0-sharded-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, sharded, "5.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-6.0-replica-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, replica, "6.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-6.0-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, server, "6.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu1804-clang-test-6.0-sharded-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-asan, test, ubuntu1804, clang, sasl-cyrus, asan, auth, sharded, "6.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile - run_on: ubuntu2004-large - tags: [sanitizers-matrix-asan, compile, ubuntu2004, clang, asan, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: asan-sasl-cyrus-openssl-ubuntu2004-clang-test-7.0-replica-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, asan, auth, replica, "7.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu2004-clang-test-7.0-server-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, asan, auth, server, "7.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu2004-clang-test-7.0-sharded-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, asan, auth, sharded, "7.0", openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu2004-clang-test-latest-replica-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, asan, auth, replica, latest, openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu2004-clang-test-latest-server-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, asan, auth, server, latest, openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: asan-sasl-cyrus-openssl-ubuntu2004-clang-test-latest-sharded-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-asan, test, ubuntu2004, clang, sasl-cyrus, asan, auth, sharded, latest, openssl] - depends_on: [{ name: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: asan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: check-headers - commands: - - func: check-headers - - name: "check:sasl=Cyrus\u2022tls=LibreSSL\u2022test_mongocxx_ref=master" - run_on: - - ubuntu2204-small - - ubuntu2204-large - - ubuntu2004-small - - ubuntu2004 - - ubuntu1804 - - ubuntu1804-medium - - debian10 - - debian11 - - amazon2 - tags: [earthly, pr-merge-gate, earthly-alpine3.18, earthly-archlinux] - commands: - - command: subprocess.exec - type: setup - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +env-warmup - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=LibreSSL - - --test_mongocxx_ref=master - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +run - - --targets=test-example test-cxx-driver - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=LibreSSL - - --test_mongocxx_ref=master - - name: "check:sasl=Cyrus\u2022tls=LibreSSL\u2022test_mongocxx_ref=r3.8.0" - run_on: - - ubuntu2204-small - - ubuntu2204-large - - ubuntu2004-small - - ubuntu2004 - - ubuntu1804 - - ubuntu1804-medium - - debian10 - - debian11 - - amazon2 - tags: [earthly, pr-merge-gate, earthly-alpine3.18, earthly-archlinux] - commands: - - command: subprocess.exec - type: setup - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +env-warmup - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=LibreSSL - - --test_mongocxx_ref=r3.8.0 - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +run - - --targets=test-example test-cxx-driver - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=LibreSSL - - --test_mongocxx_ref=r3.8.0 - - name: "check:sasl=Cyrus\u2022tls=OpenSSL\u2022test_mongocxx_ref=master" - run_on: - - ubuntu2204-small - - ubuntu2204-large - - ubuntu2004-small - - ubuntu2004 - - ubuntu1804 - - ubuntu1804-medium - - debian10 - - debian11 - - amazon2 - tags: [earthly, pr-merge-gate, earthly-alpine3.18, earthly-archlinux, earthly-u22] - commands: - - command: subprocess.exec - type: setup - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +env-warmup - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=OpenSSL - - --test_mongocxx_ref=master - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +run - - --targets=test-example test-cxx-driver - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=OpenSSL - - --test_mongocxx_ref=master - - name: "check:sasl=Cyrus\u2022tls=OpenSSL\u2022test_mongocxx_ref=r3.8.0" - run_on: - - ubuntu2204-small - - ubuntu2204-large - - ubuntu2004-small - - ubuntu2004 - - ubuntu1804 - - ubuntu1804-medium - - debian10 - - debian11 - - amazon2 - tags: [earthly, pr-merge-gate, earthly-alpine3.18, earthly-archlinux, earthly-u22] - commands: - - command: subprocess.exec - type: setup - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +env-warmup - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=OpenSSL - - --test_mongocxx_ref=r3.8.0 - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +run - - --targets=test-example test-cxx-driver - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=OpenSSL - - --test_mongocxx_ref=r3.8.0 - - name: "check:sasl=Cyrus\u2022tls=off\u2022test_mongocxx_ref=master" - run_on: - - ubuntu2204-small - - ubuntu2204-large - - ubuntu2004-small - - ubuntu2004 - - ubuntu1804 - - ubuntu1804-medium - - debian10 - - debian11 - - amazon2 - tags: [earthly, pr-merge-gate, earthly-alpine3.18, earthly-archlinux, earthly-u22] - commands: - - command: subprocess.exec - type: setup - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +env-warmup - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=off - - --test_mongocxx_ref=master - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +run - - --targets=test-example test-cxx-driver - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=off - - --test_mongocxx_ref=master - - name: "check:sasl=Cyrus\u2022tls=off\u2022test_mongocxx_ref=r3.8.0" - run_on: - - ubuntu2204-small - - ubuntu2204-large - - ubuntu2004-small - - ubuntu2004 - - ubuntu1804 - - ubuntu1804-medium - - debian10 - - debian11 - - amazon2 - tags: [earthly, pr-merge-gate, earthly-alpine3.18, earthly-archlinux, earthly-u22] - commands: - - command: subprocess.exec - type: setup - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +env-warmup - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=off - - --test_mongocxx_ref=r3.8.0 - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +run - - --targets=test-example test-cxx-driver - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=Cyrus - - --tls=off - - --test_mongocxx_ref=r3.8.0 - - name: "check:sasl=off\u2022tls=OpenSSL\u2022test_mongocxx_ref=master" - run_on: - - ubuntu2204-small - - ubuntu2204-large - - ubuntu2004-small - - ubuntu2004 - - ubuntu1804 - - ubuntu1804-medium - - debian10 - - debian11 - - amazon2 - tags: [earthly, pr-merge-gate, earthly-u22] - commands: - - command: subprocess.exec - type: setup - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +env-warmup - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=off - - --tls=OpenSSL - - --test_mongocxx_ref=master - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - args: - - tools/earthly.sh - - +run - - --targets=test-example test-cxx-driver - - --env=${MONGOC_EARTHLY_ENV} - - --sasl=off - - --tls=OpenSSL - - --test_mongocxx_ref=master - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - run_on: macos-1100 - tags: [cse-matrix-darwinssl, compile, macos-1100, clang, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-darwinssl-compile - vars: - CC: clang - - func: upload-build - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-4.2-replica-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, replica, "4.2", darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-4.2-server-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, server, "4.2", darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-4.4-replica-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, replica, "4.4", darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-4.4-server-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, server, "4.4", darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-5.0-replica-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, replica, "5.0", darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-5.0-server-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, server, "5.0", darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-6.0-replica-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, replica, "6.0", darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-6.0-server-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, server, "6.0", darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-7.0-replica-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, replica, "7.0", darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-7.0-server-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, server, "7.0", darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-latest-replica-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, replica, latest, darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-darwinssl-macos-1100-clang-test-latest-server-auth - run_on: macos-1100 - tags: [cse-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, cse, auth, server, latest, darwinssl] - depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-debian10-gcc-compile - run_on: debian10-large - tags: [cse-matrix-openssl, compile, debian10, gcc, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: cse-sasl-cyrus-openssl-debian11-gcc-compile - run_on: debian11-large - tags: [cse-matrix-openssl, compile, debian11, gcc, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: cse-sasl-cyrus-openssl-debian92-clang-compile - run_on: debian92-large - tags: [cse-matrix-openssl, compile, debian92, clang, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: cse-sasl-cyrus-openssl-debian92-gcc-compile - run_on: debian92-large - tags: [cse-matrix-openssl, compile, debian92, gcc, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: cse-sasl-cyrus-openssl-rhel80-gcc-compile - run_on: rhel80-large - tags: [cse-matrix-openssl, compile, rhel80, gcc, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile - run_on: rhel83-zseries-large - tags: [cse-matrix-openssl, compile, rhel83-zseries, gcc, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-test-5.0-server-auth - run_on: rhel83-zseries-small - tags: [cse-matrix-openssl, test, rhel83-zseries, gcc, sasl-cyrus, cse, auth, server, "5.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-test-7.0-replica-auth - run_on: rhel83-zseries-small - tags: [cse-matrix-openssl, test, rhel83-zseries, gcc, sasl-cyrus, cse, auth, replica, "7.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-test-7.0-server-auth - run_on: rhel83-zseries-small - tags: [cse-matrix-openssl, test, rhel83-zseries, gcc, sasl-cyrus, cse, auth, server, "7.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-test-latest-replica-auth - run_on: rhel83-zseries-small - tags: [cse-matrix-openssl, test, rhel83-zseries, gcc, sasl-cyrus, cse, auth, replica, latest, openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-test-latest-server-auth - run_on: rhel83-zseries-small - tags: [cse-matrix-openssl, test, rhel83-zseries, gcc, sasl-cyrus, cse, auth, server, latest, openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-rhel83-zseries-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu1604-clang-compile - run_on: ubuntu1604-large - tags: [cse-matrix-openssl, compile, ubuntu1604, clang, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile - run_on: ubuntu1804-arm64-large - tags: [cse-matrix-openssl, compile, ubuntu1804-arm64, gcc, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-test-4.2-server-auth - run_on: ubuntu1804-arm64-small - tags: [cse-matrix-openssl, test, ubuntu1804-arm64, gcc, sasl-cyrus, cse, auth, server, "4.2", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-test-4.4-server-auth - run_on: ubuntu1804-arm64-small - tags: [cse-matrix-openssl, test, ubuntu1804-arm64, gcc, sasl-cyrus, cse, auth, server, "4.4", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-test-5.0-server-auth - run_on: ubuntu1804-arm64-small - tags: [cse-matrix-openssl, test, ubuntu1804-arm64, gcc, sasl-cyrus, cse, auth, server, "5.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-test-6.0-server-auth - run_on: ubuntu1804-arm64-small - tags: [cse-matrix-openssl, test, ubuntu1804-arm64, gcc, sasl-cyrus, cse, auth, server, "6.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu1804-gcc-compile - run_on: ubuntu1804-large - tags: [cse-matrix-openssl, compile, ubuntu1804, gcc, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: cse-sasl-cyrus-openssl-ubuntu1804-gcc-test-4.2-server-auth - run_on: ubuntu1804-small - tags: [cse-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, cse, auth, server, "4.2", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu1804-gcc-test-4.4-server-auth - run_on: ubuntu1804-small - tags: [cse-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, cse, auth, server, "4.4", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu1804-gcc-test-5.0-server-auth - run_on: ubuntu1804-small - tags: [cse-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, cse, auth, server, "5.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu1804-gcc-test-6.0-server-auth - run_on: ubuntu1804-small - tags: [cse-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, cse, auth, server, "6.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile - run_on: ubuntu2004-arm64-large - tags: [cse-matrix-openssl, compile, ubuntu2004-arm64, gcc, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-7.0-replica-auth - run_on: ubuntu2004-arm64-small - tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, replica, "7.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-7.0-server-auth - run_on: ubuntu2004-arm64-small - tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, server, "7.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-latest-replica-auth - run_on: ubuntu2004-arm64-small - tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, replica, latest, openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-latest-server-auth - run_on: ubuntu2004-arm64-small - tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, server, latest, openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile - run_on: ubuntu2004-large - tags: [cse-matrix-openssl, compile, ubuntu2004, gcc, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-test-7.0-replica-auth - run_on: ubuntu2004-small - tags: [cse-matrix-openssl, test, ubuntu2004, gcc, sasl-cyrus, cse, auth, replica, "7.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-test-7.0-server-auth - run_on: ubuntu2004-small - tags: [cse-matrix-openssl, test, ubuntu2004, gcc, sasl-cyrus, cse, auth, server, "7.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-test-latest-replica-auth - run_on: ubuntu2004-small - tags: [cse-matrix-openssl, test, ubuntu2004, gcc, sasl-cyrus, cse, auth, replica, latest, openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-test-latest-server-auth - run_on: ubuntu2004-small - tags: [cse-matrix-openssl, test, ubuntu2004, gcc, sasl-cyrus, cse, auth, server, latest, openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - run_on: windows-vsCurrent-large - tags: [cse-matrix-openssl, compile, windows-vsCurrent, vs2017x64, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-openssl-compile - vars: - CC: Visual Studio 15 2017 Win64 - - func: upload-build - - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-4.2-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "4.2", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-4.4-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "4.4", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-5.0-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "5.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-6.0-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "6.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-7.0-replica-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, "7.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-7.0-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "7.0", openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-latest-replica-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, latest, openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-latest-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, latest, openssl] - depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-winssl-vs2015-x64-compile - run_on: windows-64-vs2015-large - tags: [cse-matrix-winssl, compile, windows-64-vs2015, vs2015x64, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-winssl-compile - vars: - CC: Visual Studio 14 2015 Win64 - - func: upload-build - - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - run_on: windows-vsCurrent-large - tags: [cse-matrix-winssl, compile, windows-vsCurrent, vs2017x64, cse, sasl-cyrus] - commands: - - func: cse-sasl-cyrus-winssl-compile - vars: - CC: Visual Studio 15 2017 Win64 - - func: upload-build - - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-4.2-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "4.2", winssl] - depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-4.4-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "4.4", winssl] - depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-5.0-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "5.0", winssl] - depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-6.0-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "6.0", winssl] - depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-7.0-replica-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, "7.0", winssl] - depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-7.0-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "7.0", winssl] - depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-latest-replica-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, latest, winssl] - depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-latest-server-auth - run_on: windows-vsCurrent-small - tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, latest, winssl] - depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-mock-kms-servers - - func: run-tests - - name: kms-divergence-check - commands: - - func: kms-divergence-check - - name: loadbalanced-rhel87-gcc-compile - run_on: rhel87-large - tags: [loadbalanced, rhel87, gcc] - commands: - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - env: - CC: gcc - CFLAGS: -fno-omit-frame-pointer - EXTRA_CONFIGURE_FLAGS: -DENABLE_EXTRA_ALIGNMENT=OFF - SSL: OPENSSL - args: - - -c - - .evergreen/scripts/compile.sh - - func: upload-build - - name: loadbalanced-rhel87-gcc-test-5.0-auth-openssl - run_on: rhel87-small - tags: [loadbalanced, rhel87, gcc, auth, openssl] - depends_on: [{ name: loadbalanced-rhel87-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: loadbalanced-rhel87-gcc-compile - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - LOAD_BALANCER: "on" - MONGODB_VERSION: "5.0" - SSL: openssl - TOPOLOGY: sharded_cluster - - func: run-simple-http-server - - func: start-load-balancer - vars: - MONGODB_URI: mongodb://localhost:27017,localhost:27018 - - func: run-tests - vars: - AUTH: auth - CC: gcc - LOADBALANCED: loadbalanced - SSL: openssl - - name: loadbalanced-rhel87-gcc-test-5.0-noauth-nossl - run_on: rhel87-small - tags: [loadbalanced, rhel87, gcc, noauth, nossl] - depends_on: [{ name: loadbalanced-rhel87-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: loadbalanced-rhel87-gcc-compile - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - LOAD_BALANCER: "on" - MONGODB_VERSION: "5.0" - SSL: nossl - TOPOLOGY: sharded_cluster - - func: run-simple-http-server - - func: start-load-balancer - vars: - MONGODB_URI: mongodb://localhost:27017,localhost:27018 - - func: run-tests - vars: - AUTH: noauth - CC: gcc - LOADBALANCED: loadbalanced - SSL: nossl - - name: loadbalanced-rhel87-gcc-test-6.0-auth-openssl - run_on: rhel87-small - tags: [loadbalanced, rhel87, gcc, auth, openssl] - depends_on: [{ name: loadbalanced-rhel87-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: loadbalanced-rhel87-gcc-compile - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - LOAD_BALANCER: "on" - MONGODB_VERSION: "6.0" - SSL: openssl - TOPOLOGY: sharded_cluster - - func: run-simple-http-server - - func: start-load-balancer - vars: - MONGODB_URI: mongodb://localhost:27017,localhost:27018 - - func: run-tests - vars: - AUTH: auth - CC: gcc - LOADBALANCED: loadbalanced - SSL: openssl - - name: loadbalanced-rhel87-gcc-test-6.0-noauth-nossl - run_on: rhel87-small - tags: [loadbalanced, rhel87, gcc, noauth, nossl] - depends_on: [{ name: loadbalanced-rhel87-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: loadbalanced-rhel87-gcc-compile - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - LOAD_BALANCER: "on" - MONGODB_VERSION: "6.0" - SSL: nossl - TOPOLOGY: sharded_cluster - - func: run-simple-http-server - - func: start-load-balancer - vars: - MONGODB_URI: mongodb://localhost:27017,localhost:27018 - - func: run-tests - vars: - AUTH: noauth - CC: gcc - LOADBALANCED: loadbalanced - SSL: nossl - - name: loadbalanced-rhel87-gcc-test-7.0-auth-openssl - run_on: rhel87-small - tags: [loadbalanced, rhel87, gcc, auth, openssl] - depends_on: [{ name: loadbalanced-rhel87-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: loadbalanced-rhel87-gcc-compile - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - LOAD_BALANCER: "on" - MONGODB_VERSION: "7.0" - SSL: openssl - TOPOLOGY: sharded_cluster - - func: run-simple-http-server - - func: start-load-balancer - vars: - MONGODB_URI: mongodb://localhost:27017,localhost:27018 - - func: run-tests - vars: - AUTH: auth - CC: gcc - LOADBALANCED: loadbalanced - SSL: openssl - - name: loadbalanced-rhel87-gcc-test-7.0-noauth-nossl - run_on: rhel87-small - tags: [loadbalanced, rhel87, gcc, noauth, nossl] - depends_on: [{ name: loadbalanced-rhel87-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: loadbalanced-rhel87-gcc-compile - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - LOAD_BALANCER: "on" - MONGODB_VERSION: "7.0" - SSL: nossl - TOPOLOGY: sharded_cluster - - func: run-simple-http-server - - func: start-load-balancer - vars: - MONGODB_URI: mongodb://localhost:27017,localhost:27018 - - func: run-tests - vars: - AUTH: noauth - CC: gcc - LOADBALANCED: loadbalanced - SSL: nossl - - name: loadbalanced-rhel87-gcc-test-latest-auth-openssl - run_on: rhel87-small - tags: [loadbalanced, rhel87, gcc, auth, openssl] - depends_on: [{ name: loadbalanced-rhel87-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: loadbalanced-rhel87-gcc-compile - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: auth - LOAD_BALANCER: "on" - MONGODB_VERSION: latest - SSL: openssl - TOPOLOGY: sharded_cluster - - func: run-simple-http-server - - func: start-load-balancer - vars: - MONGODB_URI: mongodb://localhost:27017,localhost:27018 - - func: run-tests - vars: - AUTH: auth - CC: gcc - LOADBALANCED: loadbalanced - SSL: openssl - - name: loadbalanced-rhel87-gcc-test-latest-noauth-nossl - run_on: rhel87-small - tags: [loadbalanced, rhel87, gcc, noauth, nossl] - depends_on: [{ name: loadbalanced-rhel87-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: loadbalanced-rhel87-gcc-compile - - func: fetch-det - - func: bootstrap-mongo-orchestration - vars: - AUTH: noauth - LOAD_BALANCER: "on" - MONGODB_VERSION: latest - SSL: nossl - TOPOLOGY: sharded_cluster - - func: run-simple-http-server - - func: start-load-balancer - vars: - MONGODB_URI: mongodb://localhost:27017,localhost:27018 - - func: run-tests - vars: - AUTH: noauth - CC: gcc - LOADBALANCED: loadbalanced - SSL: nossl - - name: make-docs - commands: - - func: make-docs - - func: upload-docs - - func: upload-man-pages - - name: mock-server-test - run_on: ubuntu2204-small - commands: - - func: fetch-det - - func: run-simple-http-server - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - add_expansions_to_env: true - args: - - -c - - .evergreen/scripts/compile.sh - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - args: - - -c - - .evergreen/scripts/run-mock-server-tests.sh - - name: openssl-static-compile-debian10-gcc - run_on: debian10-large - tags: [openssl-static-matrix, debian10, gcc] - commands: - - func: openssl-static-compile - vars: - CC: gcc - - name: openssl-static-compile-debian11-gcc - run_on: debian11-large - tags: [openssl-static-matrix, debian11, gcc] - commands: - - func: openssl-static-compile - vars: - CC: gcc - - name: openssl-static-compile-debian92-gcc - run_on: debian92-large - tags: [openssl-static-matrix, debian92, gcc] - commands: - - func: openssl-static-compile - vars: - CC: gcc - - name: openssl-static-compile-ubuntu2004-gcc - run_on: ubuntu2004-large - tags: [openssl-static-matrix, ubuntu2004, gcc] - commands: - - func: openssl-static-compile - vars: - CC: gcc - - name: sasl-cyrus-darwinssl-macos-1100-arm64-clang-compile - run_on: macos-1100-arm64 - tags: [sasl-matrix-darwinssl, compile, macos-1100-arm64, clang, sasl-cyrus] - commands: - - func: sasl-cyrus-darwinssl-compile - vars: - CC: clang - - func: upload-build - - name: sasl-cyrus-darwinssl-macos-1100-clang-compile - run_on: macos-1100 - tags: [sasl-matrix-darwinssl, compile, macos-1100, clang, sasl-cyrus] - commands: - - func: sasl-cyrus-darwinssl-compile - vars: - CC: clang - - func: upload-build - - name: sasl-cyrus-darwinssl-macos-1100-clang-test-3.6-server-auth - run_on: macos-1100 - tags: [sasl-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, auth, server, "3.6", darwinssl] - depends_on: [{ name: sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "3.6" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-darwinssl-macos-1100-clang-test-4.0-server-auth - run_on: macos-1100 - tags: [sasl-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, auth, server, "4.0", darwinssl] - depends_on: [{ name: sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-darwinssl-macos-1100-clang-test-4.2-server-auth - run_on: macos-1100 - tags: [sasl-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, auth, server, "4.2", darwinssl] - depends_on: [{ name: sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-darwinssl-macos-1100-clang-test-4.4-server-auth - run_on: macos-1100 - tags: [sasl-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, auth, server, "4.4", darwinssl] - depends_on: [{ name: sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-darwinssl-macos-1100-clang-test-5.0-server-auth - run_on: macos-1100 - tags: [sasl-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, auth, server, "5.0", darwinssl] - depends_on: [{ name: sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-darwinssl-macos-1100-clang-test-6.0-server-auth - run_on: macos-1100 - tags: [sasl-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, auth, server, "6.0", darwinssl] - depends_on: [{ name: sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-darwinssl-macos-1100-clang-test-7.0-server-auth - run_on: macos-1100 - tags: [sasl-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, auth, server, "7.0", darwinssl] - depends_on: [{ name: sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-darwinssl-macos-1100-clang-test-latest-server-auth - run_on: macos-1100 - tags: [sasl-matrix-darwinssl, test, macos-1100, clang, sasl-cyrus, auth, server, latest, darwinssl] - depends_on: [{ name: sasl-cyrus-darwinssl-macos-1100-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-darwinssl-macos-1100-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: darwinssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-archlinux-clang-compile - run_on: archlinux-large - tags: [sasl-matrix-openssl, compile, archlinux, clang, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: sasl-cyrus-openssl-archlinux-gcc-compile - run_on: archlinux-large - tags: [sasl-matrix-openssl, compile, archlinux, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-debian10-gcc-compile - run_on: debian10-large - tags: [sasl-matrix-openssl, compile, debian10, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-debian11-gcc-compile - run_on: debian11-large - tags: [sasl-matrix-openssl, compile, debian11, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-debian92-clang-compile - run_on: debian92-large - tags: [sasl-matrix-openssl, compile, debian92, clang, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: sasl-cyrus-openssl-debian92-gcc-compile - run_on: debian92-large - tags: [sasl-matrix-openssl, compile, debian92, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-rhel70-gcc-compile - run_on: rhel70-large - tags: [sasl-matrix-openssl, compile, rhel70, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-rhel80-gcc-compile - run_on: rhel80-large - tags: [sasl-matrix-openssl, compile, rhel80, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-rhel81-power8-gcc-compile - run_on: rhel81-power8-large - tags: [sasl-matrix-openssl, compile, rhel81-power8, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-rhel81-power8-gcc-test-4.2-server-auth - run_on: rhel81-power8-small - tags: [sasl-matrix-openssl, test, rhel81-power8, gcc, sasl-cyrus, auth, server, "4.2", openssl] - depends_on: [{ name: sasl-cyrus-openssl-rhel81-power8-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-rhel81-power8-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-rhel81-power8-gcc-test-4.4-server-auth - run_on: rhel81-power8-small - tags: [sasl-matrix-openssl, test, rhel81-power8, gcc, sasl-cyrus, auth, server, "4.4", openssl] - depends_on: [{ name: sasl-cyrus-openssl-rhel81-power8-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-rhel81-power8-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-rhel81-power8-gcc-test-5.0-server-auth - run_on: rhel81-power8-small - tags: [sasl-matrix-openssl, test, rhel81-power8, gcc, sasl-cyrus, auth, server, "5.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-rhel81-power8-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-rhel81-power8-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-rhel81-power8-gcc-test-6.0-server-auth - run_on: rhel81-power8-small - tags: [sasl-matrix-openssl, test, rhel81-power8, gcc, sasl-cyrus, auth, server, "6.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-rhel81-power8-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-rhel81-power8-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-rhel81-power8-gcc-test-7.0-server-auth - run_on: rhel81-power8-small - tags: [sasl-matrix-openssl, test, rhel81-power8, gcc, sasl-cyrus, auth, server, "7.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-rhel81-power8-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-rhel81-power8-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-rhel81-power8-gcc-test-latest-server-auth - run_on: rhel81-power8-small - tags: [sasl-matrix-openssl, test, rhel81-power8, gcc, sasl-cyrus, auth, server, latest, openssl] - depends_on: [{ name: sasl-cyrus-openssl-rhel81-power8-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-rhel81-power8-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-rhel83-zseries-gcc-compile - run_on: rhel83-zseries-large - tags: [sasl-matrix-openssl, compile, rhel83-zseries, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-rhel83-zseries-gcc-test-5.0-server-auth - run_on: rhel83-zseries-small - tags: [sasl-matrix-openssl, test, rhel83-zseries, gcc, sasl-cyrus, auth, server, "5.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-rhel83-zseries-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-rhel83-zseries-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-rhel83-zseries-gcc-test-6.0-server-auth - run_on: rhel83-zseries-small - tags: [sasl-matrix-openssl, test, rhel83-zseries, gcc, sasl-cyrus, auth, server, "6.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-rhel83-zseries-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-rhel83-zseries-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-rhel83-zseries-gcc-test-7.0-server-auth - run_on: rhel83-zseries-small - tags: [sasl-matrix-openssl, test, rhel83-zseries, gcc, sasl-cyrus, auth, server, "7.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-rhel83-zseries-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-rhel83-zseries-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-rhel83-zseries-gcc-test-latest-server-auth - run_on: rhel83-zseries-small - tags: [sasl-matrix-openssl, test, rhel83-zseries, gcc, sasl-cyrus, auth, server, latest, openssl] - depends_on: [{ name: sasl-cyrus-openssl-rhel83-zseries-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-rhel83-zseries-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1604-arm64-gcc-compile - run_on: ubuntu1604-arm64-large - tags: [sasl-matrix-openssl, compile, ubuntu1604-arm64, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-ubuntu1604-arm64-gcc-test-4.0-server-auth - run_on: ubuntu1604-arm64-small - tags: [sasl-matrix-openssl, test, ubuntu1604-arm64, gcc, sasl-cyrus, auth, server, "4.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1604-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1604-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1604-clang-compile - run_on: ubuntu1604-large - tags: [sasl-matrix-openssl, compile, ubuntu1604, clang, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile - run_on: ubuntu1804-arm64-large - tags: [sasl-matrix-openssl, compile, ubuntu1804-arm64, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-test-4.2-server-auth - run_on: ubuntu1804-arm64-small - tags: [sasl-matrix-openssl, test, ubuntu1804-arm64, gcc, sasl-cyrus, auth, server, "4.2", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-test-4.4-server-auth - run_on: ubuntu1804-arm64-small - tags: [sasl-matrix-openssl, test, ubuntu1804-arm64, gcc, sasl-cyrus, auth, server, "4.4", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-test-5.0-server-auth - run_on: ubuntu1804-arm64-small - tags: [sasl-matrix-openssl, test, ubuntu1804-arm64, gcc, sasl-cyrus, auth, server, "5.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-test-6.0-server-auth - run_on: ubuntu1804-arm64-small - tags: [sasl-matrix-openssl, test, ubuntu1804-arm64, gcc, sasl-cyrus, auth, server, "6.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-gcc-compile - run_on: ubuntu1804-large - tags: [sasl-matrix-openssl, compile, ubuntu1804, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-ubuntu1804-gcc-test-4.0-replica-auth - run_on: ubuntu1804-small - tags: [sasl-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, auth, replica, "4.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-gcc-test-4.0-server-auth - run_on: ubuntu1804-small - tags: [sasl-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, auth, server, "4.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-gcc-test-4.2-replica-auth - run_on: ubuntu1804-small - tags: [sasl-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, auth, replica, "4.2", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-gcc-test-4.2-server-auth - run_on: ubuntu1804-small - tags: [sasl-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, auth, server, "4.2", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-gcc-test-4.4-replica-auth - run_on: ubuntu1804-small - tags: [sasl-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, auth, replica, "4.4", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-gcc-test-4.4-server-auth - run_on: ubuntu1804-small - tags: [sasl-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, auth, server, "4.4", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-gcc-test-5.0-replica-auth - run_on: ubuntu1804-small - tags: [sasl-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, auth, replica, "5.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-gcc-test-5.0-server-auth - run_on: ubuntu1804-small - tags: [sasl-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, auth, server, "5.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-gcc-test-6.0-replica-auth - run_on: ubuntu1804-small - tags: [sasl-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, auth, replica, "6.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu1804-gcc-test-6.0-server-auth - run_on: ubuntu1804-small - tags: [sasl-matrix-openssl, test, ubuntu1804, gcc, sasl-cyrus, auth, server, "6.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile - run_on: ubuntu2004-arm64-large - tags: [sasl-matrix-openssl, compile, ubuntu2004-arm64, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-7.0-server-auth - run_on: ubuntu2004-arm64-small - tags: [sasl-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, auth, server, "7.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-latest-server-auth - run_on: ubuntu2004-arm64-small - tags: [sasl-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, auth, server, latest, openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu2004-gcc-compile - run_on: ubuntu2004-large - tags: [sasl-matrix-openssl, compile, ubuntu2004, gcc, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-cyrus-openssl-ubuntu2004-gcc-test-7.0-server-auth - run_on: ubuntu2004-small - tags: [sasl-matrix-openssl, test, ubuntu2004, gcc, sasl-cyrus, auth, server, "7.0", openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-ubuntu2004-gcc-test-latest-server-auth - run_on: ubuntu2004-small - tags: [sasl-matrix-openssl, test, ubuntu2004, gcc, sasl-cyrus, auth, server, latest, openssl] - depends_on: [{ name: sasl-cyrus-openssl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - run_on: windows-vsCurrent-large - tags: [sasl-matrix-openssl, compile, windows-vsCurrent, vs2017x64, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: Visual Studio 15 2017 Win64 - - func: upload-build - - name: sasl-cyrus-openssl-windows-2019-vs2017-x64-test-latest-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, auth, server, latest, openssl] - depends_on: [{ name: sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-openssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-winssl-vs2013-x64-compile - run_on: windows-64-vs2013-large - tags: [sasl-matrix-winssl, compile, windows-64-vs2013, vs2013x64, sasl-cyrus] - commands: - - func: sasl-cyrus-winssl-compile - vars: - CC: Visual Studio 12 2013 Win64 - - func: upload-build - - name: sasl-cyrus-winssl-vs2015-x64-compile - run_on: windows-64-vs2015-large - tags: [sasl-matrix-winssl, compile, windows-64-vs2015, vs2015x64, sasl-cyrus] - commands: - - func: sasl-cyrus-winssl-compile - vars: - CC: Visual Studio 14 2015 Win64 - - func: upload-build - - name: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - run_on: windows-vsCurrent-large - tags: [sasl-matrix-winssl, compile, windows-vsCurrent, vs2017x64, sasl-cyrus] - commands: - - func: sasl-cyrus-winssl-compile - vars: - CC: Visual Studio 15 2017 Win64 - - func: upload-build - - name: sasl-cyrus-winssl-windows-2019-vs2017-x64-test-3.6-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, auth, server, "3.6", winssl] - depends_on: [{ name: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "3.6" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-winssl-windows-2019-vs2017-x64-test-4.0-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, auth, server, "4.0", winssl] - depends_on: [{ name: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-winssl-windows-2019-vs2017-x64-test-4.2-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, auth, server, "4.2", winssl] - depends_on: [{ name: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-winssl-windows-2019-vs2017-x64-test-4.4-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, auth, server, "4.4", winssl] - depends_on: [{ name: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-winssl-windows-2019-vs2017-x64-test-5.0-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, auth, server, "5.0", winssl] - depends_on: [{ name: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-winssl-windows-2019-vs2017-x64-test-6.0-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, auth, server, "6.0", winssl] - depends_on: [{ name: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-winssl-windows-2019-vs2017-x64-test-7.0-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, auth, server, "7.0", winssl] - depends_on: [{ name: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-cyrus-winssl-windows-2019-vs2017-x64-test-latest-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, auth, server, latest, winssl] - depends_on: [{ name: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-cyrus-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1604-gcc-compile - run_on: ubuntu1604-large - tags: [sasl-matrix-nossl, compile, ubuntu1604, gcc, sasl-off] - commands: - - func: sasl-off-nossl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-off-nossl-ubuntu1604-gcc-test-3.6-replica-noauth - run_on: ubuntu1604-small - tags: [sasl-matrix-nossl, test, ubuntu1604, gcc, sasl-off, noauth, replica, "3.6"] - depends_on: [{ name: sasl-off-nossl-ubuntu1604-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1604-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "3.6" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1604-gcc-test-3.6-server-noauth - run_on: ubuntu1604-small - tags: [sasl-matrix-nossl, test, ubuntu1604, gcc, sasl-off, noauth, server, "3.6"] - depends_on: [{ name: sasl-off-nossl-ubuntu1604-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1604-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "3.6" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1604-gcc-test-3.6-sharded-noauth - run_on: ubuntu1604-small - tags: [sasl-matrix-nossl, test, ubuntu1604, gcc, sasl-off, noauth, sharded, "3.6"] - depends_on: [{ name: sasl-off-nossl-ubuntu1604-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1604-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "3.6" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-compile - run_on: ubuntu1804-large - tags: [sasl-matrix-nossl, compile, ubuntu1804, gcc, sasl-off] - commands: - - func: sasl-off-nossl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-off-nossl-ubuntu1804-gcc-test-4.0-replica-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, replica, "4.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-4.0-server-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, server, "4.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-4.0-sharded-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, sharded, "4.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-4.2-replica-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, replica, "4.2"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-4.2-server-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, server, "4.2"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-4.2-sharded-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, sharded, "4.2"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-4.4-replica-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, replica, "4.4"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-4.4-server-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, server, "4.4"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-4.4-sharded-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, sharded, "4.4"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-5.0-replica-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, replica, "5.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-5.0-server-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, server, "5.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-5.0-sharded-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, sharded, "5.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-6.0-replica-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, replica, "6.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-6.0-server-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, server, "6.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu1804-gcc-test-6.0-sharded-noauth - run_on: ubuntu1804-small - tags: [sasl-matrix-nossl, test, ubuntu1804, gcc, sasl-off, noauth, sharded, "6.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu1804-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu1804-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu2004-gcc-compile - run_on: ubuntu2004-large - tags: [sasl-matrix-nossl, compile, ubuntu2004, gcc, sasl-off] - commands: - - func: sasl-off-nossl-compile - vars: - CC: gcc - - func: upload-build - - name: sasl-off-nossl-ubuntu2004-gcc-test-7.0-replica-noauth - run_on: ubuntu2004-small - tags: [sasl-matrix-nossl, test, ubuntu2004, gcc, sasl-off, noauth, replica, "7.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu2004-gcc-test-7.0-server-noauth - run_on: ubuntu2004-small - tags: [sasl-matrix-nossl, test, ubuntu2004, gcc, sasl-off, noauth, server, "7.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu2004-gcc-test-7.0-sharded-noauth - run_on: ubuntu2004-small - tags: [sasl-matrix-nossl, test, ubuntu2004, gcc, sasl-off, noauth, sharded, "7.0"] - depends_on: [{ name: sasl-off-nossl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu2004-gcc-test-latest-replica-noauth - run_on: ubuntu2004-small - tags: [sasl-matrix-nossl, test, ubuntu2004, gcc, sasl-off, noauth, replica, latest] - depends_on: [{ name: sasl-off-nossl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu2004-gcc-test-latest-server-noauth - run_on: ubuntu2004-small - tags: [sasl-matrix-nossl, test, ubuntu2004, gcc, sasl-off, noauth, server, latest] - depends_on: [{ name: sasl-off-nossl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-ubuntu2004-gcc-test-latest-sharded-noauth - run_on: ubuntu2004-small - tags: [sasl-matrix-nossl, test, ubuntu2004, gcc, sasl-off, noauth, sharded, latest] - depends_on: [{ name: sasl-off-nossl-ubuntu2004-gcc-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-off-nossl-ubuntu2004-gcc-compile - - command: expansions.update - params: - updates: - - { key: CC, value: gcc } - - { key: AUTH, value: noauth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: nossl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-off-nossl-windows-2019-vs2017-x64-compile - run_on: windows-vsCurrent-large - tags: [sasl-matrix-nossl, compile, windows-vsCurrent, vs2017x64, sasl-off] - commands: - - func: sasl-off-nossl-compile - vars: - CC: Visual Studio 15 2017 Win64 - - func: upload-build - - name: sasl-off-winssl-vs2013-x86-compile - run_on: windows-64-vs2013-large - tags: [sasl-matrix-winssl, compile, windows-64-vs2013, vs2013x86, sasl-off] - commands: - - func: sasl-off-winssl-compile - vars: - CC: Visual Studio 12 2013 - - func: upload-build - - name: sasl-off-winssl-vs2015-x86-compile - run_on: windows-64-vs2015-large - tags: [sasl-matrix-winssl, compile, windows-64-vs2015, vs2015x86, sasl-off] - commands: - - func: sasl-off-winssl-compile - vars: - CC: Visual Studio 14 2015 - - func: upload-build - - name: sasl-off-winssl-windows-2019-vs2017-x64-compile - run_on: windows-vsCurrent-large - tags: [sasl-matrix-winssl, compile, windows-vsCurrent, vs2017x64, sasl-off] - commands: - - func: sasl-off-winssl-compile - vars: - CC: Visual Studio 15 2017 Win64 - - func: upload-build - - name: sasl-off-winssl-windows-2019-vs2017-x86-compile - run_on: windows-vsCurrent-large - tags: [sasl-matrix-winssl, compile, windows-vsCurrent, vs2017x86, sasl-off] - commands: - - func: sasl-off-winssl-compile - vars: - CC: Visual Studio 15 2017 - - func: upload-build - - name: sasl-sspi-winssl-windows-2019-mingw-compile - run_on: windows-vsCurrent-large - tags: [sasl-matrix-winssl, compile, windows-vsCurrent, mingw, sasl-sspi] - commands: - - func: sasl-sspi-winssl-compile - vars: - CC: mingw - - func: upload-build - - name: sasl-sspi-winssl-windows-2019-mingw-test-latest-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, mingw, sasl-sspi, auth, server, latest, winssl] - depends_on: [{ name: sasl-sspi-winssl-windows-2019-mingw-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-sspi-winssl-windows-2019-mingw-compile - - command: expansions.update - params: - updates: - - { key: CC, value: mingw } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-sspi-winssl-windows-2019-vs2017-x64-compile - run_on: windows-vsCurrent-large - tags: [sasl-matrix-winssl, compile, windows-vsCurrent, vs2017x64, sasl-sspi] - commands: - - func: sasl-sspi-winssl-compile - vars: - CC: Visual Studio 15 2017 Win64 - - func: upload-build - - name: sasl-sspi-winssl-windows-2019-vs2017-x64-test-latest-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-sspi, auth, server, latest, winssl] - depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x64-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x64-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 Win64 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: sasl-sspi-winssl-windows-2019-vs2017-x86-compile - run_on: windows-vsCurrent-large - tags: [sasl-matrix-winssl, compile, windows-vsCurrent, vs2017x86, sasl-sspi] - commands: - - func: sasl-sspi-winssl-compile - vars: - CC: Visual Studio 15 2017 - - func: upload-build - - name: sasl-sspi-winssl-windows-2019-vs2017-x86-test-latest-server-auth - run_on: windows-vsCurrent-small - tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x86, sasl-sspi, auth, server, latest, winssl] - depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x86-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x86-compile - - command: expansions.update - params: - updates: - - { key: CC, value: Visual Studio 15 2017 } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: winssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: scan-build-macos-1100-clang - run_on: macos-1100 - tags: [scan-build-matrix, macos-1100, clang] - commands: - - func: scan-build - vars: - CC: clang - - func: upload scan artifacts - - name: scan-build-ubuntu1604-arm64-clang - run_on: ubuntu1604-arm64-large - tags: [scan-build-matrix, ubuntu1604-arm64, clang] - commands: - - func: scan-build - vars: - CC: clang - - func: upload scan artifacts - - name: scan-build-ubuntu1604-clang - run_on: ubuntu1604-large - tags: [scan-build-matrix, ubuntu1604, clang] - commands: - - func: scan-build - vars: - CC: clang - - func: upload scan artifacts - - name: scan-build-ubuntu1604-clang-i686 - run_on: ubuntu1604-large - tags: [scan-build-matrix, ubuntu1604, clang, i686] - commands: - - func: scan-build - vars: - CC: clang - MARCH: i686 - - func: upload scan artifacts - - name: scan-build-ubuntu1804-arm64-clang - run_on: ubuntu1804-arm64-large - tags: [scan-build-matrix, ubuntu1804-arm64, clang] - commands: - - func: scan-build - vars: - CC: clang - - func: upload scan artifacts - - name: scan-build-ubuntu1804-clang-i686 - run_on: ubuntu1804-large - tags: [scan-build-matrix, ubuntu1804, clang, i686] - commands: - - func: scan-build - vars: - CC: clang - MARCH: i686 - - func: upload scan artifacts - - name: std-c11-archlinux-clang-compile - run_on: archlinux-large - tags: [std-matrix, archlinux, clang, compile, std-c11] - commands: - - func: std-compile - vars: - CC: clang - C_STD_VERSION: 11 - - name: std-c11-debian10-clang-compile - run_on: debian10-large - tags: [std-matrix, debian10, clang, compile, std-c11] - commands: - - func: std-compile - vars: - CC: clang - C_STD_VERSION: 11 - - name: std-c11-debian10-gcc-compile - run_on: debian10-large - tags: [std-matrix, debian10, gcc, compile, std-c11] - commands: - - func: std-compile - vars: - CC: gcc - C_STD_VERSION: 11 - - name: std-c11-debian11-clang-compile - run_on: debian11-large - tags: [std-matrix, debian11, clang, compile, std-c11] - commands: - - func: std-compile - vars: - CC: clang - C_STD_VERSION: 11 - - name: std-c11-debian11-gcc-compile - run_on: debian11-large - tags: [std-matrix, debian11, gcc, compile, std-c11] - commands: - - func: std-compile - vars: - CC: gcc - C_STD_VERSION: 11 - - name: std-c11-debian92-clang-compile - run_on: debian92-large - tags: [std-matrix, debian92, clang, compile, std-c11] - commands: - - func: std-compile - vars: - CC: clang - C_STD_VERSION: 11 - - name: std-c11-ubuntu1604-clang-compile - run_on: ubuntu1604-large - tags: [std-matrix, ubuntu1604, clang, compile, std-c11] - commands: - - func: std-compile - vars: - CC: clang - C_STD_VERSION: 11 - - name: std-c11-ubuntu1604-clang-i686-compile - run_on: ubuntu1604-large - tags: [std-matrix, ubuntu1604, clang, compile, i686, std-c11] - commands: - - func: std-compile - vars: - CC: clang - C_STD_VERSION: 11 - MARCH: i686 - - name: std-c11-ubuntu1804-clang-i686-compile - run_on: ubuntu1804-large - tags: [std-matrix, ubuntu1804, clang, compile, i686, std-c11] - commands: - - func: std-compile - vars: - CC: clang - C_STD_VERSION: 11 - MARCH: i686 - - name: std-c11-ubuntu1804-gcc-compile - run_on: ubuntu1804-large - tags: [std-matrix, ubuntu1804, gcc, compile, std-c11] - commands: - - func: std-compile - vars: - CC: gcc - C_STD_VERSION: 11 - - name: std-c11-ubuntu2004-clang-compile - run_on: ubuntu2004-large - tags: [std-matrix, ubuntu2004, clang, compile, std-c11] - commands: - - func: std-compile - vars: - CC: clang - C_STD_VERSION: 11 - - name: std-c11-ubuntu2004-gcc-compile - run_on: ubuntu2004-large - tags: [std-matrix, ubuntu2004, gcc, compile, std-c11] - commands: - - func: std-compile - vars: - CC: gcc - C_STD_VERSION: 11 - - name: std-c11-windows-2019-vs2017-x64-compile - run_on: windows-vsCurrent-large - tags: [std-matrix, windows-vsCurrent, vs2017x64, compile, std-c11] - commands: - - func: std-compile - vars: - CC: Visual Studio 15 2017 Win64 - C_STD_VERSION: 11 - - name: std-c17-debian10-gcc-compile - run_on: debian10-large - tags: [std-matrix, debian10, gcc, compile, std-c17] - commands: - - func: std-compile - vars: - CC: gcc - C_STD_VERSION: 17 - - name: std-c17-debian11-gcc-compile - run_on: debian11-large - tags: [std-matrix, debian11, gcc, compile, std-c17] - commands: - - func: std-compile - vars: - CC: gcc - C_STD_VERSION: 17 - - name: std-c17-windows-2019-vs2017-x64-compile - run_on: windows-vsCurrent-large - tags: [std-matrix, windows-vsCurrent, vs2017x64, compile, std-c17] - commands: - - func: std-compile - vars: - CC: Visual Studio 15 2017 Win64 - C_STD_VERSION: 17 - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - run_on: ubuntu1804-large - tags: [sanitizers-matrix-tsan, compile, ubuntu1804, clang, tsan, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.0-replica-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, replica, "4.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.0-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, server, "4.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.0-sharded-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, sharded, "4.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.2-replica-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, replica, "4.2", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.2-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, server, "4.2", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.2-sharded-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, sharded, "4.2", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.2" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.4-replica-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, replica, "4.4", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.4-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, server, "4.4", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-4.4-sharded-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, sharded, "4.4", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "4.4" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-5.0-replica-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, replica, "5.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-5.0-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, server, "5.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-5.0-sharded-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, sharded, "5.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "5.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-6.0-replica-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, replica, "6.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-6.0-server-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, server, "6.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-test-6.0-sharded-auth - run_on: ubuntu1804-small - tags: [sanitizers-matrix-tsan, test, ubuntu1804, clang, sasl-cyrus, tsan, auth, sharded, "6.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu1804-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "6.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile - run_on: ubuntu2004-large - tags: [sanitizers-matrix-tsan, compile, ubuntu2004, clang, tsan, sasl-cyrus] - commands: - - func: sasl-cyrus-openssl-compile - vars: - CC: clang - - func: upload-build - - name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-test-7.0-replica-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-tsan, test, ubuntu2004, clang, sasl-cyrus, tsan, auth, replica, "7.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-test-7.0-server-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-tsan, test, ubuntu2004, clang, sasl-cyrus, tsan, auth, server, "7.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-test-7.0-sharded-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-tsan, test, ubuntu2004, clang, sasl-cyrus, tsan, auth, sharded, "7.0", openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: "7.0" } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-test-latest-replica-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-tsan, test, ubuntu2004, clang, sasl-cyrus, tsan, auth, replica, latest, openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: replica_set } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-test-latest-server-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-tsan, test, ubuntu2004, clang, sasl-cyrus, tsan, auth, server, latest, openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: server } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests - - name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-test-latest-sharded-auth - run_on: ubuntu2004-small - tags: [sanitizers-matrix-tsan, test, ubuntu2004, clang, sasl-cyrus, tsan, auth, sharded, latest, openssl] - depends_on: [{ name: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile }] - commands: - - func: fetch-build - vars: - BUILD_NAME: tsan-sasl-cyrus-openssl-ubuntu2004-clang-compile - - command: expansions.update - params: - updates: - - { key: CC, value: clang } - - { key: AUTH, value: auth } - - { key: MONGODB_VERSION, value: latest } - - { key: TOPOLOGY, value: sharded_cluster } - - { key: SSL, value: openssl } - - func: fetch-det - - func: bootstrap-mongo-orchestration - - func: run-simple-http-server - - func: run-tests diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/variants.yml b/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/variants.yml deleted file mode 100644 index 2b294d150..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/variants.yml +++ /dev/null @@ -1,109 +0,0 @@ -buildvariants: - - name: cse-matrix-darwinssl - display_name: cse-matrix-darwinssl - expansions: - CLIENT_SIDE_ENCRYPTION: "on" - DEBUG: "ON" - tasks: - - name: .cse-matrix-darwinssl - - name: cse-matrix-openssl - display_name: cse-matrix-openssl - expansions: - CLIENT_SIDE_ENCRYPTION: "on" - DEBUG: "ON" - tasks: - - name: .cse-matrix-openssl - - name: cse-matrix-winssl - display_name: cse-matrix-winssl - expansions: - CLIENT_SIDE_ENCRYPTION: "on" - DEBUG: "ON" - tasks: - - name: .cse-matrix-winssl - - name: earthly-alpine3.18 - display_name: Alpine 3.18 - expansions: - MONGOC_EARTHLY_ENV: alpine3.18 - tasks: - - name: .earthly-alpine3.18 - - name: earthly-archlinux - display_name: Arch Linux - expansions: - MONGOC_EARTHLY_ENV: archlinux - tasks: - - name: .earthly-archlinux - - name: earthly-u22 - display_name: Ubuntu 22.04 - expansions: - MONGOC_EARTHLY_ENV: u22 - tasks: - - name: .earthly-u22 - - name: loadbalanced - display_name: loadbalanced - tasks: - - name: .loadbalanced - - name: mock-server-test - display_name: Mock Server Test - expansions: - ASAN: "on" - CC: gcc - CFLAGS: -fno-omit-frame-pointer - EXTRA_CONFIGURE_FLAGS: -DENABLE_EXTRA_ALIGNMENT=OFF - SANITIZE: address,undefined - tasks: - - name: mock-server-test - - name: openssl-static-matrix - display_name: openssl-static-matrix - tasks: - - name: .openssl-static-matrix - - name: sanitizers-matrix-asan - display_name: sanitizers-matrix-asan - expansions: - ASAN: "on" - CFLAGS: -fno-omit-frame-pointer - CHECK_LOG: "ON" - EXTRA_CONFIGURE_FLAGS: -DENABLE_EXTRA_ALIGNMENT=OFF - SANITIZE: address,undefined - tasks: - - name: .sanitizers-matrix-asan - - name: sanitizers-matrix-tsan - display_name: sanitizers-matrix-tsan - expansions: - CFLAGS: -fno-omit-frame-pointer - CHECK_LOG: "ON" - EXTRA_CONFIGURE_FLAGS: -DENABLE_EXTRA_ALIGNMENT=OFF -DENABLE_SHM_COUNTERS=OFF - SANITIZE: thread - tasks: - - name: .sanitizers-matrix-tsan - - name: sasl-matrix-darwinssl - display_name: sasl-matrix-darwinssl - expansions: - DEBUG: "ON" - tasks: - - name: .sasl-matrix-darwinssl - - name: sasl-matrix-nossl - display_name: sasl-matrix-nossl - expansions: - DEBUG: "ON" - tasks: - - name: .sasl-matrix-nossl - - name: sasl-matrix-openssl - display_name: sasl-matrix-openssl - expansions: - DEBUG: "ON" - tasks: - - name: .sasl-matrix-openssl - - name: sasl-matrix-winssl - display_name: sasl-matrix-winssl - expansions: - DEBUG: "ON" - tasks: - - name: .sasl-matrix-winssl - - name: scan-build-matrix - display_name: scan-build-matrix - tasks: - - name: .scan-build-matrix - - name: std-matrix - display_name: std-matrix - tasks: - - name: .std-matrix diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/__init__.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/__init__.py deleted file mode 100644 index c25199a84..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/__init__.py +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import sys -from collections import OrderedDict as OD -from typing import Any, Iterable, Mapping, MutableMapping, MutableSequence, Sequence, Union - -Scalar = Union[str, bool, int, None, float] -"YAML simple schema scalar types" -ValueSequence = Sequence["Value"] -"Sequence of YAML simple values" -MutableValueArray = MutableSequence["Value"] -"A mutable sequence of JSON values" -ValueMapping = Mapping[Scalar, "Value"] -"A YAML mapping type (arbitrary scalars as keys)" -MutableValueMapping = MutableMapping[Scalar, "Value"] -"A mutable YAML mapping type" -Value = Union[ValueSequence, ValueMapping, Scalar] -"Any YAML simple value" -MutableValue = Union[MutableValueMapping, MutableValueArray, Scalar] -"Any YAML simple value, which may be a mutable sequence or map" - -ValueOrderedDict = OD[Scalar, Value] -"An OrderedDict of YAML values" - - -try: - import yaml - import yamlordereddictloader # type: ignore -except ImportError: - sys.stderr.write("try 'pip install -r evergreen_config_generator/requirements.txt'\n") - raise - - -class ConfigObject(object): - @property - def name(self) -> str: - return "UNSET" - - def to_dict(self) -> Value: - return OD([("name", self.name)]) - - -# We want legible YAML tasks: -# -# - name: debug-compile -# tags: [zlib, snappy, compression, openssl] -# commands: -# - command: shell.exec -# params: -# script: |- -# set -o errexit -# ... -# -# Write values compactly except multiline strings, which use "|" style. Write -# tag sets as lists. - - -class _Dumper(yamlordereddictloader.Dumper): - def __init__(self, *args: Value, **kwargs: Value): - super().__init__(*args, **kwargs) # type: ignore - self.add_representer(set, type(self).represent_set) - # Use "multi_representer" to represent all subclasses of ConfigObject. - self.add_multi_representer(ConfigObject, type(self).represent_config_object) - - def represent_scalar(self, tag: str, value: Value, style: str | None = None) -> yaml.ScalarNode: - if isinstance(value, (str)) and "\n" in value: - style = "|" - return super().represent_scalar(tag, value, style) # type: ignore - - def represent_set(self, data: Iterable[Value]) -> yaml.MappingNode: - return super().represent_list(sorted(set(data))) # type: ignore - - def represent_config_object(self, obj: ConfigObject) -> yaml.Node: - d = obj.to_dict() - return super().represent_data(d) # type: ignore - - -def yaml_dump(obj: Any): - return yaml.dump(obj, Dumper=_Dumper, default_flow_style=False) - - -def generate(config: Any, path: str): - """Dump config to a file as YAML. - config is a dict, preferably an OrderedDict. path is a file path. - """ - f = open(path, "w+") - f.write( - """#################################### -# Evergreen configuration -# -# Generated with evergreen_config_generator from -# github.com/mongodb-labs/drivers-evergreen-tools -# -# DO NOT EDIT THIS FILE -# -#################################### -""" - ) - f.write(yaml_dump(config)) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/functions.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/functions.py deleted file mode 100644 index 4b2757af6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/functions.py +++ /dev/null @@ -1,127 +0,0 @@ -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from collections import OrderedDict as OD -from textwrap import dedent -from typing import Iterable - -from evergreen_config_generator import ConfigObject - -from . import Value, MutableValueMapping, ValueMapping, ValueOrderedDict - - -def func(func_name: str, **kwargs: Value) -> MutableValueMapping: - od: MutableValueMapping = OD([("func", func_name)]) - if kwargs: - od["vars"] = OD(sorted(kwargs.items())) - - return od - - -def s3_put(remote_file: str, project_path: bool = True, **kwargs: Value) -> ValueMapping: - if project_path: - remote_file = "${project}/" + remote_file - - return ValueOrderedDict( - [ - ("command", "s3.put"), - ( - "params", - ValueOrderedDict( - ( - ("aws_key", "${aws_key}"), - ("aws_secret", "${aws_secret}"), - ("remote_file", remote_file), - ("bucket", "mciuploads"), - ("permissions", "public-read"), - *kwargs.items(), - ) - ), - ), - ] - ) - - -def strip_lines(s: str) -> str: - return "\n".join(line for line in s.split("\n") if line.strip()) - - -def shell_exec( - script: str, - test: bool = True, - errexit: bool = True, - xtrace: bool = False, - silent: bool = False, - continue_on_err: bool = False, - working_dir: str | None = None, - background: bool = False, - add_expansions_to_env: bool = False, - redirect_standard_error_to_output: bool = False, - include_expansions_in_env: Iterable[str] = (), -) -> ValueMapping: - dedented = "" - if errexit: - dedented += "set -o errexit\n" - - if xtrace: - dedented += "set -o xtrace\n" - - dedented += dedent(strip_lines(script)) - command = ValueOrderedDict([("command", "shell.exec")]) - if test: - command["type"] = "test" - - command["params"] = OD() - if silent: - command["params"]["silent"] = True - - if working_dir is not None: - command["params"]["working_dir"] = working_dir - - if continue_on_err: - command["params"]["continue_on_err"] = True - - if background: - command["params"]["background"] = True - - if add_expansions_to_env: - command["params"]["add_expansions_to_env"] = True - - if redirect_standard_error_to_output: - command["params"]["redirect_standard_error_to_output"] = True - - if include_expansions_in_env: - command["params"]["include_expansions_in_env"] = list(include_expansions_in_env) - - command["params"]["shell"] = "bash" - command["params"]["script"] = dedented - return command - - -def targz_pack(target: str, source_dir: str, *include: str) -> ValueMapping: - return OD( - [ - ("command", "archive.targz_pack"), - ("params", OD([("target", target), ("source_dir", source_dir), ("include", list(include))])), - ] - ) - - -class Function(ConfigObject): - def __init__(self, *commands: Value): - super(Function, self).__init__() - self.commands = commands - - def to_dict(self) -> Value: - return list(self.commands) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/taskgroups.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/taskgroups.py deleted file mode 100644 index 9fa9fa6e0..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/taskgroups.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from typing import MutableMapping -from evergreen_config_generator import ConfigObject - -from . import Value, ValueSequence - - -class TaskGroup(ConfigObject): - def __init__(self, name: str): - self._task_group_name = name - self.setup_group: ValueSequence | None = None - self.teardown_group: ValueSequence | None = None - self.setup_task: str | None = None - self.teardown_task: str | None = None - self.max_hosts: int | None = None - self.timeout: int | None = None - self.setup_group_can_fail_task: bool | None = None - self.setup_group_timeout_secs: int | None = None - self.share_processes: bool | None = None - self.tasks: ValueSequence | None = None - - @property - def name(self) -> str: - return self._task_group_name - - def to_dict(self) -> Value: - v = super().to_dict() - assert isinstance(v, MutableMapping) - # See possible TaskGroup attributes from the Evergreen wiki: - # https://github.com/evergreen-ci/evergreen/wiki/Project-Configuration-Files#task-groups - attrs = [ - "setup_group", - "teardown_group", - "setup_task", - "teardown_task", - "max_hosts", - "timeout", - "setup_group_can_fail_task", - "setup_group_timeout_secs", - "share_processes", - "tasks", - ] - - for i in attrs: - if getattr(self, i, None): - v[i] = getattr(self, i) - return v diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/tasks.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/tasks.py deleted file mode 100644 index 68f06048c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/tasks.py +++ /dev/null @@ -1,230 +0,0 @@ -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from collections import OrderedDict as OD -import copy -from itertools import chain, product -import itertools -from typing import ClassVar, Iterable, Literal, Mapping, MutableMapping, Sequence, Union - -from evergreen_config_generator import ConfigObject -from evergreen_config_generator.functions import func - -from . import Value, MutableValueMapping, ValueSequence - - -DependencySpec = Union[str, Mapping[str, Value]] - - -class Task(ConfigObject): - def __init__( - self, - task_name: str | None = None, - commands: Iterable[Value] = (), - tags: Iterable[str] = (), - depends_on: Iterable[DependencySpec] = (), - exec_timeout_secs: int | None = None, - ): - self._name = task_name - self._tags = list(tags) - self.options: MutableValueMapping = OD() - self.commands: ValueSequence = list(commands) - self.exec_timeout_secs = exec_timeout_secs - self._depends_on = list(map(self._normal_dep, depends_on)) - - if exec_timeout_secs is not None: - self.options["exec_timeout_secs"] = exec_timeout_secs - - @property - def dependencies(self) -> Sequence[Mapping[str, Value]]: - main = list(self._depends_on) - main.extend(map(self._normal_dep, self.additional_dependencies())) - return tuple(main) - - def _normal_dep(self, spec: DependencySpec) -> Mapping[str, Value]: - if isinstance(spec, str): - return OD([("name", spec)]) - return spec - - @property - def tags(self) -> Sequence[str]: - return tuple(sorted(chain(self.additional_tags(), self._tags))) - - def pre_commands(self) -> Iterable[Value]: - return () - - def main_commands(self) -> Iterable[Value]: - return () - - def post_commands(self) -> Iterable[Value]: - return () - - def additional_dependencies(self) -> Iterable[DependencySpec]: - return () - - @property - def name(self) -> str: - assert self._name is not None, f'Task {self} did not set a name, and did not override the "name" property' - return self._name - - def additional_tags(self) -> Iterable[str]: - return () - - def add_dependency(self, dependency: DependencySpec): - if isinstance(dependency, str): - dependency = OD([("name", dependency)]) - - self._depends_on.append(dependency) - - def to_dict(self): - task: MutableValueMapping = super().to_dict() # type: ignore - assert isinstance(task, MutableMapping) - if self.tags: - task["tags"] = list(self.tags) - task.update(self.options) - deps: Sequence[MutableValueMapping] = list(self.dependencies) # type: ignore - if deps: - if len(deps) == 1: - task["depends_on"] = OD(deps[0]) - else: - task["depends_on"] = copy.deepcopy(deps) - task["commands"] = list( - itertools.chain( - self.pre_commands(), - self.main_commands(), - self.commands, - self.post_commands(), - ) - ) - return task - - -NamedTask = Task - - -class FuncTask(NamedTask): - def __init__( - self, - task_name: str, - functions: Iterable[str], - tags: Iterable[str] = (), - depends_on: Iterable[DependencySpec] = (), - exec_timeout_secs: int | None = None, - ): - commands = [func(func_name) for func_name in functions] - super().__init__(task_name, commands, tags=tags, depends_on=depends_on, exec_timeout_secs=exec_timeout_secs) - super(FuncTask, self).__init__(task_name, commands=commands) - - -class Prohibited(Exception): - pass - - -def require(rule: bool) -> None: - if not rule: - raise Prohibited() - - -def prohibit(rule: bool) -> None: - if rule: - raise Prohibited() - - -def both_or_neither(rule0: bool, rule1: bool) -> None: - if rule0: - require(rule1) - else: - prohibit(rule1) - - -class SettingsAccess: - def __init__(self, inst: "MatrixTask") -> None: - self._task = inst - - def __getattr__(self, __setting: str) -> str | bool: - return self._task.setting_value(__setting) - - -class MatrixTask(Task): - axes: ClassVar[Mapping[str, Sequence[str | bool]]] = OD() - - def __init__(self, settings: Mapping[str, str | bool]): - super().__init__() - self._settings = {k: v for k, v in settings.items()} - for axis, options in type(self).axes.items(): - if axis not in self._settings: - self._settings[axis] = options[0] - - def display(self, axis_name: str) -> str: - value = self.setting_value(axis_name) - if value is False: - # E.g., if self.auth is False, return 'noauth'. - return f"no{axis_name}" - elif value is True: - return axis_name - else: - return value - - def on_off(self, key: str, val: str) -> Literal["on", "off"]: - return "on" if self.setting_value(key) == val else "off" - - @property - def name(self) -> str: - return "-".join(self.name_parts()) - - def name_parts(self) -> Iterable[str]: - raise NotImplementedError - - @property - def settings(self) -> SettingsAccess: - return SettingsAccess(self) - - def setting_value(self, axis: str) -> str | bool: - assert ( - axis in type(self).axes.keys() - ), f'Attempted to inspect setting "{axis}", which is not defined for this task type' - return self._settings[axis] - - def setting_eq(self, axis: str, val: str | bool) -> bool: - current = self.setting_value(axis) - options = type(self).axes[axis] - assert ( - val in options - ), f'Looking for value "{val}" on setting "{axis}", but that is not a supported option (Expects one of {options})' - return current == val - - def is_valid_combination(self) -> bool: - try: - return self.do_is_valid_combination() - except Prohibited: - print(f"Ignoring invalid combination {self.name!r}") - return False - - def do_is_valid_combination(self) -> bool: - return True - - @classmethod - def matrix(cls): - for cell in product(*cls.axes.values()): - axis_values = dict(zip(cls.axes, cell)) - task = cls(settings=axis_values) - if task.allowed: - yield task - - @property - def allowed(self): - try: - return self.do_is_valid_combination() - except Prohibited: - return False diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/variants.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/variants.py deleted file mode 100644 index dde960f56..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_generator/variants.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from typing import Iterable, Mapping -from evergreen_config_generator import ConfigObject - -from . import ValueMapping - - -class Variant(ConfigObject): - def __init__( - self, - name: str, - display_name: str, - run_on: list[str] | str, - tasks: Iterable[str | ValueMapping], - expansions: Mapping[str, str] | None = None, - tags: Iterable[str] = (), - batchtime: int | None = None, - ): - super(Variant, self).__init__() - self._variant_name = name - self.display_name = display_name - self.run_on = run_on - self.tasks = tasks - self.expansions = expansions - self.tags = list(tags) - self.batchtime = batchtime - - @property - def name(self): - return self._variant_name - - def to_dict(self): - v = super(Variant, self).to_dict() - for i in "display_name", "expansions", "run_on", "tasks", "batchtime", "tags": - if getattr(self, i): - v[i] = getattr(self, i) - return v diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/__init__.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/__init__.py deleted file mode 100644 index 99754646f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/__init__.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from typing import Iterable -from evergreen_config_generator.functions import shell_exec - - -def shell_mongoc( - script: str, - test: bool = True, - errexit: bool = True, - xtrace: bool = False, - silent: bool = False, - continue_on_err: bool = False, - background: bool = False, - add_expansions_to_env: bool = False, - redirect_standard_error_to_output: bool = False, - include_expansions_in_env: Iterable[str] = (), -): - return shell_exec( - script, - working_dir="mongoc", - test=test, - errexit=errexit, - xtrace=xtrace, - silent=silent, - continue_on_err=continue_on_err, - background=background, - add_expansions_to_env=add_expansions_to_env, - include_expansions_in_env=include_expansions_in_env, - redirect_standard_error_to_output=redirect_standard_error_to_output, - ) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/functions.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/functions.py deleted file mode 100644 index 181697b0f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/functions.py +++ /dev/null @@ -1,219 +0,0 @@ -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from collections import OrderedDict as OD - -from evergreen_config_generator.functions import ( - Function, s3_put, shell_exec) -from evergreen_config_lib import shell_mongoc - -build_path = '${build_variant}/${revision}/${version_id}/${build_id}' - -all_functions = OD([ - ('install ssl', Function( - shell_mongoc(r''' - bash .evergreen/scripts/install-ssl.sh - ''', test=False, add_expansions_to_env=True), - )), - ('upload coverage', Function( - shell_mongoc(r''' - export AWS_ACCESS_KEY_ID=${aws_key} - export AWS_SECRET_ACCESS_KEY=${aws_secret} - aws s3 cp coverage s3://mciuploads/${project}/%s/coverage/ --recursive --acl public-read --region us-east-1 - ''' % (build_path,), test=False, silent=True), - s3_put(build_path + '/coverage/index.html', aws_key='${aws_key}', - aws_secret='${aws_secret}', - local_file='mongoc/coverage/index.html', bucket='mciuploads', - permissions='public-read', content_type='text/html', - display_name='Coverage Report'), - )), - ('upload scan artifacts', Function( - shell_mongoc(r''' - if find scan -name \*.html | grep -q html; then - (cd scan && find . -name index.html -exec echo "
  • {}
  • " \;) >> scan.html - else - echo "No issues found" > scan.html - fi - '''), - shell_mongoc(r''' - export AWS_ACCESS_KEY_ID=${aws_key} - export AWS_SECRET_ACCESS_KEY=${aws_secret} - aws s3 cp scan s3://mciuploads/${project}/%s/scan/ --recursive --acl public-read --region us-east-1 - ''' % (build_path,), test=False, silent=True), - s3_put(build_path + '/scan/index.html', aws_key='${aws_key}', - aws_secret='${aws_secret}', local_file='mongoc/scan.html', - bucket='mciuploads', permissions='public-read', - content_type='text/html', display_name='Scan Build Report'), - )), - # Use "silent=True" to hide output since errors may contain credentials. - ('run auth tests', Function( - shell_mongoc(r''' - bash .evergreen/scripts/run-auth-tests.sh - ''', add_expansions_to_env=True), - )), - ('link sample program', Function( - shell_mongoc(r''' - # Compile a program that links dynamically or statically to libmongoc, - # using variables from pkg-config or CMake's find_package command. - export BUILD_SAMPLE_WITH_CMAKE=${BUILD_SAMPLE_WITH_CMAKE} - export BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=${BUILD_SAMPLE_WITH_CMAKE_DEPRECATED} - export ENABLE_SSL=${ENABLE_SSL} - export ENABLE_SNAPPY=${ENABLE_SNAPPY} - LINK_STATIC= bash .evergreen/scripts/link-sample-program.sh - LINK_STATIC=1 bash .evergreen/scripts/link-sample-program.sh - ''', - include_expansions_in_env=['distro_id']), - )), - ('link sample program bson', Function( - shell_mongoc(r''' - # Compile a program that links dynamically or statically to libbson, - # using variables from pkg-config or from CMake's find_package command. - BUILD_SAMPLE_WITH_CMAKE= BUILD_SAMPLE_WITH_CMAKE_DEPRECATED= LINK_STATIC= bash .evergreen/scripts/link-sample-program-bson.sh - BUILD_SAMPLE_WITH_CMAKE= BUILD_SAMPLE_WITH_CMAKE_DEPRECATED= LINK_STATIC=1 bash .evergreen/scripts/link-sample-program-bson.sh - BUILD_SAMPLE_WITH_CMAKE=1 BUILD_SAMPLE_WITH_CMAKE_DEPRECATED= LINK_STATIC= bash .evergreen/scripts/link-sample-program-bson.sh - BUILD_SAMPLE_WITH_CMAKE=1 BUILD_SAMPLE_WITH_CMAKE_DEPRECATED= LINK_STATIC=1 bash .evergreen/scripts/link-sample-program-bson.sh - BUILD_SAMPLE_WITH_CMAKE=1 BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=1 LINK_STATIC= bash .evergreen/scripts/link-sample-program-bson.sh - BUILD_SAMPLE_WITH_CMAKE=1 BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=1 LINK_STATIC=1 bash .evergreen/scripts/link-sample-program-bson.sh - ''', - include_expansions_in_env=['distro_id']), - )), - ('link sample program MSVC', Function( - shell_mongoc(r''' - # Build libmongoc with CMake and compile a program that links - # dynamically or statically to it, using variables from CMake's - # find_package command. - export ENABLE_SSL=${ENABLE_SSL} - export ENABLE_SNAPPY=${ENABLE_SNAPPY} - . .evergreen/scripts/use-tools.sh paths - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(native-path "$(find_cmake_latest)")" - LINK_STATIC= cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc.cmd - LINK_STATIC=1 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc.cmd - ''', - include_expansions_in_env=['distro_id']), - )), - ('link sample program mingw', Function( - shell_mongoc(r''' - # Build libmongoc with CMake and compile a program that links - # dynamically to it, using variables from pkg-config.exe. - . .evergreen/scripts/use-tools.sh paths - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(native-path "$(find_cmake_latest)")" - cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw.cmd - ''', - include_expansions_in_env=['distro_id']), - )), - ('link sample program MSVC bson', Function( - shell_mongoc(r''' - # Build libmongoc with CMake and compile a program that links - # dynamically or statically to it, using variables from CMake's - # find_package command. - export ENABLE_SSL=${ENABLE_SSL} - export ENABLE_SNAPPY=${ENABLE_SNAPPY} - . .evergreen/scripts/use-tools.sh paths - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(native-path "$(find_cmake_latest)")" - LINK_STATIC= cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc-bson.cmd - LINK_STATIC=1 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc-bson.cmd - ''', - include_expansions_in_env=['distro_id']), - )), - ('link sample program mingw bson', Function( - shell_mongoc(r''' - # Build libmongoc with CMake and compile a program that links - # dynamically to it, using variables from pkg-config.exe. - . .evergreen/scripts/use-tools.sh paths - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(native-path "$(find_cmake_latest)")" - cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw-bson.cmd - '''), - )), - ('update codecov.io', Function( - shell_mongoc(r''' - # Note: coverage is currently only enabled on the ubuntu1804 distro. - # This script does not support MacOS, Windows, or non-x86_64 distros. - # Update accordingly if code coverage is expanded to other distros. - curl -Os https://uploader.codecov.io/latest/linux/codecov - chmod +x codecov - # -Z: Exit with a non-zero value if error. - # -g: Run with gcov support. - # -t: Codecov upload token. - # perl: filter verbose "Found" list and "Processing" messages. - ./codecov -Zgt "${codecov_token}" | perl -lne 'print if not m|^.*\.gcov(\.\.\.)?$|' - ''', test=False), - )), - ('compile coverage', Function( - shell_mongoc(r''' - COVERAGE=ON DEBUG=ON bash .evergreen/scripts/compile.sh - ''', add_expansions_to_env=True), - )), - ('build mongohouse', Function( - shell_exec(r''' - cd drivers-evergreen-tools - export DRIVERS_TOOLS=$(pwd) - bash .evergreen/atlas_data_lake/pull-mongohouse-image.sh - '''), - )), - ('run mongohouse', Function( - shell_exec(r''' - cd drivers-evergreen-tools - export DRIVERS_TOOLS=$(pwd) - bash .evergreen/atlas_data_lake/run-mongohouse-image.sh - '''), - )), - ('test mongohouse', Function( - shell_mongoc(r''' - echo "Waiting for mongohouse to start..." - wait_for_mongohouse() { - for _ in $(seq 300); do - # Exit code 7: "Failed to connect to host". - if curl -s localhost:$1; (("$?" != 7)); then - return 0 - else - sleep 1 - fi - done - echo "Could not detect mongohouse on port $1" 1>&2 - return 1 - } - wait_for_mongohouse 27017 || exit - echo "Waiting for mongohouse to start... done." - pgrep -a "mongohouse" - export RUN_MONGOHOUSE_TESTS=ON - ./src/libmongoc/test-libmongoc --no-fork -l /mongohouse/* -d --skip-tests .evergreen/etc/skip-tests.txt - '''), - )), - ('run aws tests', Function( - # Assume role to get AWS secrets. - { - "command": "ec2.assume_role", - "params": { - "role_arn": "${aws_test_secrets_role}" - } - }, - - shell_mongoc(r''' - pushd ../drivers-evergreen-tools/.evergreen/auth_aws - ./setup_secrets.sh drivers/aws_auth - popd # ../drivers-evergreen-tools/.evergreen/auth_aws - ''', include_expansions_in_env=["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]), - - shell_mongoc(r''' - pushd ../drivers-evergreen-tools/.evergreen/auth_aws - . ./activate-authawsvenv.sh - popd # ../drivers-evergreen-tools/.evergreen/auth_aws - bash .evergreen/scripts/run-aws-tests.sh - ''', include_expansions_in_env=["TESTCASE"]) - )), -]) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/taskgroups.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/taskgroups.py deleted file mode 100644 index 33bee5771..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/taskgroups.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from typing import Sequence -from evergreen_config_generator.taskgroups import TaskGroup - -all_task_groups: Sequence[TaskGroup] = [] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/tasks.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/tasks.py deleted file mode 100644 index c2f896a61..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/tasks.py +++ /dev/null @@ -1,1133 +0,0 @@ -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from collections import OrderedDict as OD -from itertools import chain -from typing import ClassVar, Iterable, Literal, Mapping, MutableMapping, MutableSequence, Optional, Sequence - -from evergreen_config_generator import Value, Scalar -from evergreen_config_generator.functions import func, s3_put -from evergreen_config_generator.tasks import ( - both_or_neither, - MatrixTask, - NamedTask, - prohibit, - require, - Task, - DependencySpec, -) -from evergreen_config_lib import shell_mongoc -from pkg_resources import parse_version - - -ToggleStr = Literal["OFF", "ON"] -OptToggleStr = Optional[ToggleStr] -TopologyStr = Literal["server"] - - -class CompileTask(NamedTask): - cls_compile_sh_env: ClassVar[Mapping[str, str]] = {} - cls_tags: ClassVar[Sequence[str]] = () - cls_sanitize: ClassVar[Sequence[str]] = () - - def __init__( - self, - task_name: str, - tags: Iterable[str] = (), - config: str = "debug", - compression: str | None = "default", - suffix_commands: Iterable[Value] = (), - depends_on: Iterable[DependencySpec] = (), - prefix_commands: Iterable[Value] = (), - sanitize: Iterable[Literal["undefined", "address", "thread"]] = (), - *, - CFLAGS: str | None = None, - LDFLAGS: str | None = None, - EXTRA_CONFIGURE_FLAGS: str | None = None, - SSL: Literal["WINDOWS", "DARWIN", "OPENSSL", "OPENSSL_STATIC", "LIBRESSL", "OFF", None] = None, - ENABLE_SHM_COUNTERS: OptToggleStr = None, - CHECK_LOG: OptToggleStr = None, - TRACING: OptToggleStr = None, - SASL: Literal[None, "OFF", "AUTO", "CYRUS", "SSPI"] = None, - ENABLE_RDTSCP: OptToggleStr = None, - SRV: OptToggleStr = None, - ): - super(CompileTask, self).__init__(task_name=task_name, depends_on=depends_on, tags=tags) - - self.suffix_commands = list(suffix_commands) - self.prefix_commands = list(prefix_commands) - - # Environment variables for .evergreen/scripts/compile.sh. - self.compile_sh_opt: dict[str, str] = {} - if config == "debug": - self.compile_sh_opt["DEBUG"] = "ON" - else: - assert config == "release" - self.compile_sh_opt["RELEASE"] = "ON" - - if CFLAGS: - self.compile_sh_opt["CFLAGS"] = CFLAGS - if LDFLAGS: - self.compile_sh_opt["LDFLAGS"] = LDFLAGS - if EXTRA_CONFIGURE_FLAGS: - self.compile_sh_opt["EXTRA_CONFIGURE_FLAGS"] = EXTRA_CONFIGURE_FLAGS - if SSL: - self.compile_sh_opt["SSL"] = SSL - if ENABLE_SHM_COUNTERS: - self.compile_sh_opt["ENABLE_SHM_COUNTERS"] = ENABLE_SHM_COUNTERS - if CHECK_LOG: - self.compile_sh_opt["CHECK_LOG"] = CHECK_LOG - if TRACING: - self.compile_sh_opt["TRACING"] = TRACING - if SASL: - self.compile_sh_opt["SASL"] = SASL - if ENABLE_RDTSCP: - self.compile_sh_opt["ENABLE_RDTSCP"] = ENABLE_RDTSCP - if SRV: - self.compile_sh_opt["SRV"] = SRV - - if compression != "default": - self.compile_sh_opt["SNAPPY"] = "ON" if compression in ("all", "snappy") else "OFF" - self.compile_sh_opt["ZLIB"] = "BUNDLED" if compression in ("all", "zlib") else "OFF" - self.compile_sh_opt["ZSTD"] = "ON" if compression in ("all", "zstd") else "OFF" - - if sanitize: - self.compile_sh_opt["SANITIZE"] = ",".join(sanitize) - - self.compile_sh_opt.update(type(self).cls_compile_sh_env) - - def additional_script_env(self) -> Mapping[str, str]: - return {} - - def to_dict(self): - task = super(CompileTask, self).to_dict() - commands = task["commands"] - assert isinstance(commands, MutableSequence), task - - commands.extend(self.prefix_commands) - - script = "env" - for opt, value in sorted(self.compile_sh_opt.items()): - script += ' %s="%s"' % (opt, value) - - script += " bash .evergreen/scripts/compile.sh" - commands.append(shell_mongoc(script, add_expansions_to_env=True)) - commands.append(func("upload-build")) - commands.extend(self.suffix_commands) - return task - - def additional_tags(self) -> Iterable[str]: - yield from super().additional_tags() - yield from self.cls_tags - - -class SpecialTask(CompileTask): - cls_tags: ClassVar[Sequence[str]] = ["special"] - - -class CompileWithClientSideEncryption(CompileTask): - cls_compile_sh_env: ClassVar[Mapping[str, str]] = dict( - # Compiling with ClientSideEncryption support requires linking against the library libmongocrypt. - COMPILE_LIBMONGOCRYPT="ON", - EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON", - ) - cls_tags: ClassVar[Sequence[str]] = "client-side-encryption", "special" - - -class CompileWithClientSideEncryptionAsan(CompileTask): - cls_compile_sh_env: ClassVar[Mapping[str, str]] = dict( - CFLAGS="-fno-omit-frame-pointer", - COMPILE_LIBMONGOCRYPT="ON", - CHECK_LOG="ON", - EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF", - PATH="/usr/lib/llvm-3.8/bin:$PATH", - ) - cls_tags: ClassVar[Sequence[str]] = ["client-side-encryption"] - cls_sanitize: ClassVar[Sequence[str]] = ["address"] - - -class LinkTask(NamedTask): - def __init__( - self, task_name: str, suffix_commands: Iterable[Value], orchestration: Literal[True, False, "ssl"] = True - ): - if orchestration == "ssl": - # Actual value of SSL does not matter here so long as it is not 'nossl'. - bootstrap_commands = [func("fetch-det"), func("bootstrap-mongo-orchestration", SSL="openssl")] - elif orchestration: - bootstrap_commands = [func("fetch-det"), func("bootstrap-mongo-orchestration")] - else: - bootstrap_commands = [] - - super().__init__( - task_name=task_name, - commands=bootstrap_commands + list(suffix_commands), - ) - - -all_tasks = [ - CompileTask( - "hardened-compile", - tags=["hardened"], - compression=None, - CFLAGS="-fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -fPIE -O", - LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now", - ), - CompileTask("debug-compile-compression-zlib", tags=["zlib", "compression"], compression="zlib"), - CompileTask("debug-compile-compression-snappy", tags=["snappy", "compression"], compression="snappy"), - CompileTask("debug-compile-compression-zstd", tags=["zstd", "compression"], compression="zstd"), - CompileTask("debug-compile-compression", tags=["zlib", "snappy", "zstd", "compression"], compression="all"), - CompileTask( - "debug-compile-no-align", - tags=["debug-compile"], - compression="zlib", - EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF", - ), - CompileTask("debug-compile-nosasl-nossl", tags=["debug-compile", "nosasl", "nossl"], SSL="OFF"), - CompileTask("debug-compile-lto", CFLAGS="-flto"), - CompileTask("debug-compile-lto-thin", CFLAGS="-flto=thin"), - CompileTask("debug-compile-no-counters", tags=["debug-compile", "no-counters"], ENABLE_SHM_COUNTERS="OFF"), - SpecialTask( - "debug-compile-asan-clang", - tags=["debug-compile", "asan-clang"], - compression="zlib", - CFLAGS="-fno-omit-frame-pointer", - CHECK_LOG="ON", - sanitize=["address"], - EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF", - ), - SpecialTask( - "debug-compile-asan-clang-openssl", - tags=["debug-compile", "asan-clang"], - compression="zlib", - CFLAGS="-fno-omit-frame-pointer", - CHECK_LOG="ON", - sanitize=["address"], - EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF", - SSL="OPENSSL", - ), - CompileTask("compile-tracing", TRACING="ON", CFLAGS="-Werror -Wno-cast-align"), - CompileTask("release-compile", config="release"), - CompileTask("debug-compile-nosasl-openssl", tags=["debug-compile", "nosasl", "openssl"], SSL="OPENSSL"), - CompileTask( - "debug-compile-nosasl-openssl-static", tags=["debug-compile", "nosasl", "openssl-static"], SSL="OPENSSL_STATIC" - ), - CompileTask("debug-compile-nosasl-darwinssl", tags=["debug-compile", "nosasl", "darwinssl"], SSL="DARWIN"), - CompileTask("debug-compile-nosasl-winssl", tags=["debug-compile", "nosasl", "winssl"], SSL="WINDOWS"), - CompileTask("debug-compile-sasl-nossl", tags=["debug-compile", "sasl", "nossl"], SASL="AUTO", SSL="OFF"), - CompileTask("debug-compile-sasl-openssl", tags=["debug-compile", "sasl", "openssl"], SASL="AUTO", SSL="OPENSSL"), - CompileTask( - "debug-compile-sasl-openssl-static", - tags=["debug-compile", "sasl", "openssl-static"], - SASL="AUTO", - SSL="OPENSSL_STATIC", - ), - CompileTask("debug-compile-sasl-darwinssl", tags=["debug-compile", "sasl", "darwinssl"], SASL="AUTO", SSL="DARWIN"), - CompileTask("debug-compile-sspi-nossl", tags=["debug-compile", "sspi", "nossl"], SASL="SSPI", SSL="OFF"), - CompileTask("debug-compile-sspi-openssl", tags=["debug-compile", "sspi", "openssl"], SASL="SSPI", SSL="OPENSSL"), - CompileTask( - "debug-compile-sspi-openssl-static", - tags=["debug-compile", "sspi", "openssl-static"], - SASL="SSPI", - SSL="OPENSSL_STATIC", - ), - CompileTask("debug-compile-rdtscp", ENABLE_RDTSCP="ON"), - CompileTask("debug-compile-sspi-winssl", tags=["debug-compile", "sspi", "winssl"], SASL="SSPI", SSL="WINDOWS"), - CompileTask("debug-compile-nosrv", tags=["debug-compile"], SRV="OFF"), - LinkTask("link-with-cmake", suffix_commands=[func("link sample program", BUILD_SAMPLE_WITH_CMAKE=1)]), - LinkTask( - "link-with-cmake-ssl", - suffix_commands=[func("link sample program", BUILD_SAMPLE_WITH_CMAKE=1, ENABLE_SSL=1)], - ), - LinkTask( - "link-with-cmake-snappy", - suffix_commands=[func("link sample program", BUILD_SAMPLE_WITH_CMAKE=1, ENABLE_SNAPPY="ON")], - ), - LinkTask("link-with-cmake-mac", suffix_commands=[func("link sample program", BUILD_SAMPLE_WITH_CMAKE=1)]), - LinkTask( - "link-with-cmake-deprecated", - suffix_commands=[func("link sample program", BUILD_SAMPLE_WITH_CMAKE=1, BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=1)], - ), - LinkTask( - "link-with-cmake-ssl-deprecated", - suffix_commands=[ - func( - "link sample program", - BUILD_SAMPLE_WITH_CMAKE=1, - BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=1, - ENABLE_SSL=1, - ) - ], - ), - LinkTask( - "link-with-cmake-snappy-deprecated", - suffix_commands=[ - func( - "link sample program", - BUILD_SAMPLE_WITH_CMAKE=1, - BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=1, - ENABLE_SNAPPY="ON", - ) - ], - ), - LinkTask( - "link-with-cmake-mac-deprecated", - suffix_commands=[func("link sample program", BUILD_SAMPLE_WITH_CMAKE=1, BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=1)], - ), - LinkTask("link-with-cmake-windows", suffix_commands=[func("link sample program MSVC")]), - LinkTask( - "link-with-cmake-windows-ssl", - suffix_commands=[func("link sample program MSVC", ENABLE_SSL=1)], - orchestration="ssl", - ), - LinkTask("link-with-cmake-windows-snappy", suffix_commands=[func("link sample program MSVC", ENABLE_SNAPPY="ON")]), - LinkTask("link-with-cmake-mingw", suffix_commands=[func("link sample program mingw")]), - LinkTask("link-with-pkg-config", suffix_commands=[func("link sample program")]), - LinkTask("link-with-pkg-config-mac", suffix_commands=[func("link sample program")]), - LinkTask("link-with-pkg-config-ssl", suffix_commands=[func("link sample program", ENABLE_SSL=1)]), - LinkTask("link-with-bson", suffix_commands=[func("link sample program bson")], orchestration=False), - LinkTask("link-with-bson-mac", suffix_commands=[func("link sample program bson")], orchestration=False), - LinkTask("link-with-bson-windows", suffix_commands=[func("link sample program MSVC bson")], orchestration=False), - LinkTask("link-with-bson-mingw", suffix_commands=[func("link sample program mingw bson")], orchestration=False), - NamedTask( - "debian-package-build", - commands=[ - shell_mongoc('export IS_PATCH="${is_patch}"\n' "sh .evergreen/scripts/debian_package_build.sh"), - s3_put( - local_file="deb.tar.gz", - remote_file="${branch_name}/mongo-c-driver-debian-packages-${CURRENT_VERSION}.tar.gz", - content_type="${content_type|application/x-gzip}", - ), - s3_put( - local_file="deb.tar.gz", - remote_file="${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-debian-packages.tar.gz", - content_type="${content_type|application/x-gzip}", - ), - s3_put( - local_file="deb-i386.tar.gz", - remote_file="${branch_name}/mongo-c-driver-debian-packages-i386-${CURRENT_VERSION}.tar.gz", - content_type="${content_type|application/x-gzip}", - ), - s3_put( - local_file="deb-i386.tar.gz", - remote_file="${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-debian-packages-i386.tar.gz", - content_type="${content_type|application/x-gzip}", - ), - ], - ), - NamedTask( - "rpm-package-build", - commands=[ - shell_mongoc('export IS_PATCH="${is_patch}"\n' "sh .evergreen/scripts/check_rpm_spec.sh"), - shell_mongoc("sh .evergreen/scripts/build_snapshot_rpm.sh"), - s3_put( - local_file="rpm.tar.gz", - remote_file="${branch_name}/mongo-c-driver-rpm-packages-${CURRENT_VERSION}.tar.gz", - content_type="${content_type|application/x-gzip}", - ), - s3_put( - local_file="rpm.tar.gz", - remote_file="${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-rpm-packages.tar.gz", - content_type="${content_type|application/x-gzip}", - ), - ], - ), - NamedTask( - "install-uninstall-check-mingw", - commands=[ - shell_mongoc( - r""" - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(find_cmake_latest)" - export CC="C:/mingw-w64/x86_64-4.9.1-posix-seh-rt_v3-rev1/mingw64/bin/gcc.exe" - BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd - cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd""", - include_expansions_in_env=["distro_id"], - ) - ], - ), - NamedTask( - "install-uninstall-check-msvc", - commands=[ - shell_mongoc( - r""" - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(find_cmake_latest)" - export CC="Visual Studio 14 2015 Win64" - BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd - cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd""", - include_expansions_in_env=["distro_id"], - ) - ], - ), - NamedTask( - "install-uninstall-check", - commands=[ - shell_mongoc( - r""" - . .evergreen/scripts/find-cmake-latest.sh - export CMAKE="$(find_cmake_latest)" - DESTDIR="$(pwd)/dest" bash ./.evergreen/scripts/install-uninstall-check.sh - BSON_ONLY=1 bash ./.evergreen/scripts/install-uninstall-check.sh - bash ./.evergreen/scripts/install-uninstall-check.sh""", - include_expansions_in_env=["distro_id"], - ) - ], - ), - CompileTask("debug-compile-with-warnings", CFLAGS="-Werror -Wno-cast-align"), - CompileWithClientSideEncryption( - "debug-compile-sasl-openssl-static-cse", - tags=["debug-compile", "sasl", "openssl-static"], - SASL="AUTO", - SSL="OPENSSL_STATIC", - ), - CompileTask( - "debug-compile-nosasl-openssl-1.0.1", - prefix_commands=[func("install ssl", SSL="openssl-1.0.1u")], - CFLAGS="-Wno-redundant-decls", - SSL="OPENSSL", - SASL="OFF", - ), - NamedTask( - "build-and-test-with-toolchain", - commands=[ - OD( - [ - ("command", "s3.get"), - ( - "params", - OD( - [ - ("aws_key", "${aws_key}"), - ("aws_secret", "${aws_secret}"), - ("remote_file", "mongo-c-toolchain/${distro_id}/2023/06/07/mongo-c-toolchain.tar.gz"), - ("bucket", "mongo-c-toolchain"), - ("local_file", "mongo-c-toolchain.tar.gz"), - ] - ), - ), - ] - ), - shell_mongoc("bash ./.evergreen/scripts/build-and-test-with-toolchain.sh"), - ], - ), - NamedTask( - "install-libmongoc-after-libbson", - commands=[shell_mongoc("bash ./.evergreen/scripts/install-libmongoc-after-libbson.sh"),], - ), -] - - -class CoverageTask(MatrixTask): - axes = OD( - [ - ("version", ["latest"]), - ("topology", ["replica_set"]), - ("auth", [True]), - ("sasl", ["sasl"]), - ("ssl", ["openssl"]), - ("cse", [False, True]), - ] - ) - - def additional_tags(self) -> Iterable[str]: - yield from super().additional_tags() - yield "test-coverage" - yield str(self.settings.version) - if self.cse: - yield "client-side-encryption" - - def name_parts(self) -> Iterable[str]: - yield "test-coverage" - yield self.display("version") - yield self.display("topology").replace("_", "-") - yield from map(self.display, ("auth", "sasl", "ssl")) - if self.settings.cse: - yield "cse" - - @property - def cse(self) -> bool: - return bool(self.settings.cse) - - def post_commands(self) -> Iterable[Value]: - if self.cse: - yield func( - "compile coverage", - SASL="AUTO", - SSL="OPENSSL", - COMPILE_LIBMONGOCRYPT="ON", - EXTRA_CONFIGURE_FLAGS='EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON"', - ) - else: - yield func("compile coverage", SASL="AUTO", SSL="OPENSSL") - - yield func("fetch-det") - yield func( - "bootstrap-mongo-orchestration", - MONGODB_VERSION=self.settings.version, - TOPOLOGY=self.settings.topology, - AUTH=self.display("auth"), - SSL=self.display("ssl"), - ) - yield func("run-simple-http-server") - extra = {"COVERAGE": "ON"} - if self.cse: - extra["CLIENT_SIDE_ENCRYPTION"] = "ON" - yield func("run-mock-kms-servers") - yield func("run-tests", AUTH=self.display("auth"), SSL=self.display("ssl"), **extra) - yield func("upload coverage") - yield func("update codecov.io") - - def do_is_valid_combination(self) -> bool: - # Limit coverage tests to test-coverage-latest-replica-set-auth-sasl-openssl (+ cse). - require(self.setting_eq("topology", "replica_set")) - require(self.setting_eq("sasl", "sasl")) - require(self.setting_eq("ssl", "openssl")) - require(self.setting_eq("version", "latest")) - require(self.settings.auth is True) - - if not self.cse: - # No further requirements - return True - - # CSE has extra requirements - if self.settings.version != "latest": - # We only work with 4.2 or newer for CSE - require(parse_version(str(self.settings.version)) >= parse_version("4.2")) - return True - - -all_tasks = chain(all_tasks, CoverageTask.matrix()) - - -class DNSTask(MatrixTask): - axes = OD( - [ - ("auth", [False, True]), - ("loadbalanced", [False, True]), - ("ssl", ["openssl", "winssl", "darwinssl"]), - ] - ) - - name_prefix = "test-dns" - - def additional_dependencies(self) -> Iterable[DependencySpec]: - yield self.build_task_name - - @property - def build_task_name(self) -> str: - sasl = "sspi" if self.settings.ssl == "winssl" else "sasl" - return f'debug-compile-{sasl}-{self.display("ssl")}' - - def name_parts(self) -> Iterable[str]: - yield "test-dns" - if self.settings.auth: - yield "auth" - if self.settings.loadbalanced: - yield "loadbalanced" - yield self.display("ssl") - - def post_commands(self) -> Iterable[Value]: - yield func("fetch-build", BUILD_NAME=self.build_task_name) - yield func("fetch-det") - if self.settings.loadbalanced: - orchestration = func( - "bootstrap-mongo-orchestration", - TOPOLOGY="sharded_cluster", - AUTH="auth" if self.settings.auth else "noauth", - SSL="ssl", - LOAD_BALANCER="on", - ) - else: - orchestration = func( - "bootstrap-mongo-orchestration", - TOPOLOGY="replica_set", - AUTH="auth" if self.settings.auth else "noauth", - SSL="ssl", - ) - - if self.settings.auth: - vars = orchestration["vars"] - assert isinstance(vars, MutableMapping) - vars["AUTHSOURCE"] = "thisDB" - - yield orchestration - - dns = "on" - if self.settings.loadbalanced: - dns = "loadbalanced" - yield func("fetch-det") - yield func("start-load-balancer", MONGODB_URI="mongodb://localhost:27017,localhost:27018") - elif self.settings.auth: - dns = "dns-auth" - yield func("run-tests", SSL="ssl", AUTH=self.display("auth"), DNS=dns) - - def do_is_valid_combination(self) -> bool: - prohibit(bool(self.settings.loadbalanced) and bool(self.settings.auth)) - # Load balancer tests only run on some Linux hosts in Evergreen until CDRIVER-4041 is resolved. - prohibit(bool(self.settings.loadbalanced) and self.settings.ssl in ["darwinssl", "winssl"]) - return True - - -all_tasks = chain(all_tasks, DNSTask.matrix()) - - -class CompressionTask(MatrixTask): - axes = OD([("compression", ["zlib", "snappy", "zstd", "compression"])]) - name_prefix = "test-latest-server" - - def additional_dependencies(self) -> Iterable[DependencySpec]: - yield self.build_task_name - - @property - def build_task_name(self) -> str: - return f"debug-compile-{self._compressor_suffix()}" - - def additional_tags(self) -> Iterable[str]: - yield from super().additional_tags() - yield "compression" - yield "latest" - yield from self._compressor_list() - - def name_parts(self) -> Iterable[str]: - return [self.name_prefix, self._compressor_suffix()] - - def post_commands(self) -> Iterable[Value]: - yield func("fetch-build", BUILD_NAME=self.build_task_name) - yield func("fetch-det") - if self.settings.compression == "compression": - orc_file = "snappy-zlib-zstd" - else: - orc_file = self.settings.compression - yield func("bootstrap-mongo-orchestration", AUTH="noauth", SSL="nossl", ORCHESTRATION_FILE=orc_file) - yield func("run-simple-http-server") - yield func("run-tests", AUTH="noauth", SSL="nossl", COMPRESSORS=",".join(self._compressor_list())) - - def _compressor_suffix(self): - if self.settings.compression == "zlib": - return "compression-zlib" - elif self.settings.compression == "snappy": - return "compression-snappy" - elif self.settings.compression == "zstd": - return "compression-zstd" - else: - return "compression" - - def _compressor_list(self): - if self.settings.compression == "zlib": - return ["zlib"] - elif self.settings.compression == "snappy": - return ["snappy"] - elif self.settings.compression == "zstd": - return ["zstd"] - else: - return ["snappy", "zlib", "zstd"] - - -all_tasks = chain(all_tasks, CompressionTask.matrix()) - - -class SpecialIntegrationTask(NamedTask): - def __init__( - self, - task_name: str, - main_dep: str = "debug-compile-sasl-openssl", - uri: str | None = None, - tags: Iterable[str] = (), - version: str = "latest", - topology: str = "server", - ): - self._main_dep = main_dep - super().__init__(task_name, depends_on=[self._main_dep], tags=tags) - self._uri = uri - self._version = version - self._topo = topology - - def pre_commands(self) -> Iterable[Value]: - yield func("fetch-build", BUILD_NAME=self._main_dep) - yield func("fetch-det") - yield func("bootstrap-mongo-orchestration", MONGODB_VERSION=self._version, TOPOLOGY=self._topo) - yield func("run-simple-http-server") - yield func("run-tests", URI=self._uri) - - -all_tasks = chain( - all_tasks, - [ - # Verify that retryWrites=true is ignored with standalone. - SpecialIntegrationTask("retry-true-latest-server", uri="mongodb://localhost/?retryWrites=true"), - SpecialIntegrationTask("test-latest-server-hardened", "hardened-compile", tags=["hardened", "latest"]), - ], -) - - -class AuthTask(MatrixTask): - axes = OD([("sasl", ["sasl", "sspi", False]), ("ssl", ["openssl", "darwinssl", "winssl"])]) - - name_prefix = "authentication-tests" - - def additional_tags(self) -> Iterable[str]: - yield from super().additional_tags() - yield "authentication-tests" - yield self.display("ssl") - yield self.display("sasl") - - def additional_dependencies(self) -> Iterable[DependencySpec]: - yield self.build_task_name - - def post_commands(self) -> Iterable[Value]: - yield func("fetch-build", BUILD_NAME=self.build_task_name) - yield func("prepare-kerberos") - yield func("run auth tests") - - @property - def build_task_name(self) -> str: - return f'debug-compile-{self.display("sasl")}-{self.display("ssl")}' - - def name_parts(self) -> Iterable[str]: - yield self.name_prefix - yield self.display("ssl") - if not self.settings.sasl: - yield "nosasl" - - def do_is_valid_combination(self) -> bool: - both_or_neither(self.settings.ssl == "winssl", self.settings.sasl == "sspi") - if not self.settings.sasl: - require(self.settings.ssl == "openssl") - return True - - -all_tasks = chain(all_tasks, AuthTask.matrix()) - - -class PostCompileTask(NamedTask): - def __init__(self, name: str, tags: Iterable[str], get_build: str, commands: Iterable[Value]): - super().__init__(name, commands=commands, tags=tags, depends_on=[get_build]) - self._dep = get_build - - def pre_commands(self) -> Iterable[Value]: - yield func("fetch-build", BUILD_NAME=self._dep) - - -all_tasks = chain( - all_tasks, - [ - PostCompileTask( - "test-mongohouse", - tags=[], - get_build="debug-compile-sasl-openssl", - commands=[func("fetch-det"), func("build mongohouse"), func("run mongohouse"), func("test mongohouse")], - ), - NamedTask( - "authentication-tests-asan-memcheck", - tags=["authentication-tests", "asan"], - commands=[ - shell_mongoc( - """ - env SANITIZE=address DEBUG=ON SASL=AUTO SSL=OPENSSL EXTRA_CONFIGURE_FLAGS='-DENABLE_EXTRA_ALIGNMENT=OFF' bash .evergreen/scripts/compile.sh - """, - add_expansions_to_env=True, - ), - func("prepare-kerberos"), - func("run auth tests", ASAN="on"), - ], - ) - ], -) - -# Add API version tasks. -for server_version in [ "7.0", "6.0", "5.0"]: - all_tasks = chain( - all_tasks, - [ - PostCompileTask( - "test-versioned-api-" + server_version, - tags=["versioned-api", f"{server_version}"], - get_build="debug-compile-nosasl-openssl", - commands=[ - func("fetch-det"), - func( - "bootstrap-mongo-orchestration", - TOPOLOGY="server", - AUTH="auth", - SSL="ssl", - MONGODB_VERSION=server_version, - REQUIRE_API_VERSION="true", - ), - func("run-simple-http-server"), - func("run-tests", MONGODB_API_VERSION=1, AUTH="auth", SSL="ssl"), - ], - ), - PostCompileTask( - "test-versioned-api-accept-version-two-" + server_version, - tags=["versioned-api", f"{server_version}"], - get_build="debug-compile-nosasl-nossl", - commands=[ - func("fetch-det"), - func( - "bootstrap-mongo-orchestration", - TOPOLOGY="server", - AUTH="noauth", - SSL="nossl", - MONGODB_VERSION=server_version, - ORCHESTRATION_FILE="versioned-api-testing", - ), - func("run-simple-http-server"), - func("run-tests", MONGODB_API_VERSION=1, AUTH="noauth", SSL="nossl"), - ], - ) - ] - ) - - -class SSLTask(Task): - def __init__( - self, - version: str, - patch: str, - cflags: str = "", - fips: bool = False, - enable_ssl: str | Literal[False] = False, - test_params: Mapping[str, Scalar] | None = None, - ): - full_version = version + patch + ("-fips" if fips else "") - self.enable_ssl = enable_ssl - script = "env" - if cflags: - script += f" CFLAGS={cflags}" - - script += " DEBUG=ON SASL=OFF" - - if enable_ssl is not False: - script += " SSL=" + enable_ssl - elif "libressl" in version: - script += " SSL=LIBRESSL" - else: - script += " SSL=OPENSSL" - - script += " bash .evergreen/scripts/compile.sh" - - super(SSLTask, self).__init__( - commands=[ - func("install ssl", SSL=full_version), - shell_mongoc(script, add_expansions_to_env=True), - func("run auth tests", **(test_params or {})), - func("upload-build"), - ] - ) - - self.version = version - self.fips = fips - - @property - def name(self): - s = "build-and-run-authentication-tests-" + self.version - if self.fips: - return s + "-fips" - if self.enable_ssl is not False: - return s + "-" + str(self.enable_ssl).lower() - - return s - - -all_tasks = chain( - all_tasks, - [ - SSLTask( - "openssl-1.0.1", - "u", - cflags="-Wno-redundant-decls", - ), - SSLTask("openssl-1.0.1", "u", cflags="-Wno-redundant-decls", fips=True), - SSLTask( - "openssl-1.0.2", - "l", - cflags="-Wno-redundant-decls", - ), - SSLTask("openssl-1.1.0", "l"), - SSLTask("libressl-2.5", ".2", test_params=dict(require_tls12=True)), - SSLTask("libressl-3.0", ".2", enable_ssl="AUTO", test_params=dict(require_tls12=True)), - SSLTask("libressl-3.0", ".2", test_params=dict(require_tls12=True)), - ], -) - - -class IPTask(MatrixTask): - axes = OD( - [ - ("client", ["ipv6", "ipv4", "localhost"]), - ("server", ["ipv6", "ipv4"]), - ] - ) - - name_prefix = "test-latest" - - def additional_dependencies(self) -> Iterable[DependencySpec]: - yield "debug-compile-nosasl-nossl" - - def additional_tags(self) -> Iterable[str]: - yield from super().additional_tags() - yield from ("nossl", "nosasl", "server", "ipv4-ipv6", "latest") - - def post_commands(self) -> Iterable[Value]: - return [ - func("fetch-build", BUILD_NAME="debug-compile-nosasl-nossl"), - func("fetch-det"), - func("bootstrap-mongo-orchestration", IPV4_ONLY=self.on_off("server", "ipv4")), - func("run-simple-http-server"), - func( - "run-tests", - IPV4_ONLY=self.on_off("server", "ipv4"), - URI={ - "ipv6": "mongodb://[::1]/", - "ipv4": "mongodb://127.0.0.1/", - "localhost": "mongodb://localhost/", - }[str(self.settings.client)], - ), - ] - - def name_parts(self) -> Iterable[str]: - return ( - self.name_prefix, - f'server-{self.display("server")}', - f'client-{self.display("client")}', - "noauth", - "nosasl", - "nossl", - ) - - def do_is_valid_combination(self) -> bool: - # This would fail by design. - if self.settings.server == "ipv4": - prohibit(self.settings.client == "ipv6") - - # Default configuration is tested in other variants. - if self.settings.server == "ipv6": - prohibit(self.settings.client == "localhost") - return True - - -all_tasks = chain(all_tasks, IPTask.matrix()) - -aws_compile_task = NamedTask( - "debug-compile-aws", - commands=[ - shell_mongoc( - """ - export distro_id='${distro_id}' # Required by find_cmake_latest. - . .evergreen/scripts/find-cmake-latest.sh - cmake_binary="$(find_cmake_latest)" - - # Allow reuse of ccache compilation results between different build directories. - export CCACHE_BASEDIR CCACHE_NOHASHDIR - CCACHE_BASEDIR="$(pwd)" - CCACHE_NOHASHDIR=1 - - # Compile test-awsauth. Disable unnecessary dependencies since test-awsauth is copied to a remote Ubuntu 20.04 ECS cluster for testing, which may not have all dependent libraries. - export CC='${CC}' - "$cmake_binary" -DENABLE_TRACING=ON -DENABLE_SASL=OFF -DENABLE_SNAPPY=OFF -DENABLE_ZSTD=OFF -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF . - "$cmake_binary" --build . --target test-awsauth - """ - ), - func("upload-build"), - ], -) - -all_tasks = chain(all_tasks, [aws_compile_task]) - - -class AWSTestTask(MatrixTask): - axes = OD( - [ - ("testcase", ["regular", "ec2", "ecs", "lambda", "assume_role", "assume_role_with_web_identity"]), - ("version", ["latest", "7.0", "6.0", "5.0", "4.4"]), - ] - ) - - name_prefix = "test-aws-openssl" - - def additional_dependencies(self) -> Iterable[DependencySpec]: - yield "debug-compile-aws" - - def additional_tags(self) -> Iterable[str]: - yield from super().additional_tags() - yield f'{self.settings.version}' - yield f'test-aws' - - def post_commands(self) -> Iterable[Value]: - return [ - func("fetch-build", BUILD_NAME="debug-compile-aws"), - func("fetch-det"), - func( - "bootstrap-mongo-orchestration", - AUTH="auth", - ORCHESTRATION_FILE="auth-aws", - MONGODB_VERSION=self.settings.version, - TOPOLOGY="server", - ), - func("run aws tests", TESTCASE=str(self.settings.testcase).upper()), - ] - - @property - def name(self): - return f"{self.name_prefix}-{self.settings.testcase}-{self.settings.version}" - - -all_tasks = chain(all_tasks, AWSTestTask.matrix()) - - -class OCSPTask(MatrixTask): - axes = OD( - [ - ( - "test", - [ - "test_1", - "test_2", - "test_3", - "test_4", - "soft_fail_test", - "malicious_server_test_1", - "malicious_server_test_2", - "cache", - ], - ), - ("delegate", ["delegate", "nodelegate"]), - ("cert", ["rsa", "ecdsa"]), - ("ssl", ["openssl", "openssl-1.0.1", "darwinssl", "winssl"]), - ("version", ["latest", "7.0", "6.0", "5.0", "4.4"]), - ] - ) - - name_prefix = "test-ocsp" - - @property - def build_task_name(self) -> str: - return f'debug-compile-nosasl-{self.display("ssl")}' - - def additional_tags(self) -> Iterable[str]: - yield from super().additional_tags() - yield f'ocsp-{self.display("ssl")}' - - def additional_dependencies(self) -> Iterable[DependencySpec]: - yield self.build_task_name - - @property - def name(self): - return f"ocsp-{self.settings.ssl}-{self.test}-{self.settings.cert}-{self.settings.delegate}-{self.settings.version}" - - @property - def test(self) -> str: - return str(self.settings.test) - - def post_commands(self) -> Iterable[Value]: - yield func("fetch-build", BUILD_NAME=self.build_task_name) - yield func("fetch-det") - - stapling = "mustStaple" - if self.test in ["test_3", "test_4", "soft_fail_test", "cache"]: - stapling = "disableStapling" - if self.test in ["malicious_server_test_1", "malicious_server_test_2"]: - stapling = "mustStaple-disableStapling" - - orchestration_file = "%s-basic-tls-ocsp-%s" % (self.settings.cert, stapling) - orchestration = func( - "bootstrap-mongo-orchestration", - MONGODB_VERSION=self.settings.version, - TOPOLOGY="server", - SSL="ssl", - OCSP="on", - ORCHESTRATION_FILE=orchestration_file, - ) - - # The cache test expects a revoked response from an OCSP responder, exactly like TEST_4. - test_column = "TEST_4" if self.test == "cache" else str(self.test).upper() - use_delegate = "ON" if self.settings.delegate == "delegate" else "OFF" - - yield ( - shell_mongoc( - f""" - TEST_COLUMN={test_column} CERT_TYPE={self.settings.cert} USE_DELEGATE={use_delegate} bash .evergreen/scripts/run-ocsp-responder.sh - """ - ) - ) - - yield (orchestration) - - if self.build_task_name == "debug-compile-nosasl-openssl-1.0.1": - # LD_LIBRARY_PATH is needed so the in-tree OpenSSL 1.0.1 is found at runtime - if self.test == "cache": - yield ( - shell_mongoc( - f""" - LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE={self.settings.cert} bash .evergreen/scripts/run-ocsp-cache-test.sh - """ - ) - ) - else: - yield ( - shell_mongoc( - f""" - LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN={self.test.upper()} CERT_TYPE={self.settings.cert} bash .evergreen/scripts/run-ocsp-test.sh - """ - ) - ) - else: - if self.test == "cache": - yield ( - shell_mongoc( - f""" - CERT_TYPE={self.settings.cert} bash .evergreen/scripts/run-ocsp-cache-test.sh - """ - ) - ) - else: - yield ( - shell_mongoc( - f""" - TEST_COLUMN={self.test.upper()} CERT_TYPE={self.settings.cert} bash .evergreen/scripts/run-ocsp-test.sh - """ - ) - ) - - def to_dict(self): - task = super(MatrixTask, self).to_dict() - - # OCSP tests should run with a batchtime of 14 days. Avoid running OCSP - # tests in patch builds by default (only in commit builds). - task["patchable"] = False - - return task - - # Testing in OCSP has a lot of exceptions. - def do_is_valid_combination(self) -> bool: - if self.settings.ssl == "darwinssl": - # Secure Transport quietly ignores a must-staple certificate with no stapled response. - prohibit(self.test == "malicious_server_test_2") - - # ECDSA certs can't be loaded (in the PEM format they're stored) on Windows/macOS. Skip them. - if self.settings.ssl == "darwinssl" or self.settings.ssl == "winssl": - prohibit(self.settings.cert == "ecdsa") - - # OCSP stapling is not supported on macOS or Windows. - if self.settings.ssl == "darwinssl" or self.settings.ssl == "winssl": - prohibit(self.test in ["test_1", "test_2", "cache"]) - - if self.test == "soft_fail_test" or self.test == "malicious_server_test_2" or self.test == "cache": - prohibit(self.settings.delegate == "delegate") - return True - - -all_tasks = chain(all_tasks, OCSPTask.matrix()) - -all_tasks = list(all_tasks) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/variants.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/variants.py deleted file mode 100644 index ed9f21698..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/variants.py +++ /dev/null @@ -1,503 +0,0 @@ -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from collections import OrderedDict as OD - -from evergreen_config_generator.variants import Variant - - -mobile_flags = ( - " -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY" - " -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY" - " -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER" - " -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY" -) - - -def days(n: int) -> int: - "Calculate the number of minutes in the given number of days" - return n * 24 * 60 - - -all_variants = [ - Variant( - "abi-compliance-check", - "ABI Compliance Check", - ["ubuntu1804-small", "ubuntu1804-medium", "ubuntu1804-large"], - ["abi-compliance-check"], - ), - Variant( - "smoke", - "Smoke Tests", - "ubuntu2204-small", - [ - "make-docs", - "kms-divergence-check", - "release-compile", - "debug-compile-no-counters", - "compile-tracing", - "link-with-cmake", - "link-with-cmake-deprecated", - "link-with-cmake-ssl", - "link-with-cmake-ssl-deprecated", - "link-with-cmake-snappy", - "link-with-cmake-snappy-deprecated", - OD([("name", "link-with-cmake-mac"), ("distros", ["macos-1100"])]), - OD([("name", "link-with-cmake-mac-deprecated"), ("distros", ["macos-1100"])]), - OD([("name", "link-with-cmake-windows"), ("distros", ["windows-vsCurrent-large"])]), - OD([("name", "link-with-cmake-windows-ssl"), ("distros", ["windows-vsCurrent-large"])]), - OD([("name", "link-with-cmake-windows-snappy"), ("distros", ["windows-vsCurrent-large"])]), - OD([("name", "link-with-cmake-mingw"), ("distros", ["windows-vsCurrent-large"])]), - OD([("name", "link-with-pkg-config"), ("distros", ["ubuntu1804-test"])]), - OD([("name", "link-with-pkg-config-mac"), ("distros", ["macos-1100"])]), - "link-with-pkg-config-ssl", - "link-with-bson", - OD([("name", "link-with-bson-windows"), ("distros", ["windows-vsCurrent-large"])]), - OD([("name", "link-with-bson-mac"), ("distros", ["macos-1100"])]), - OD([("name", "link-with-bson-mingw"), ("distros", ["windows-vsCurrent-large"])]), - "check-headers", - "install-uninstall-check", - OD([("name", "install-uninstall-check-mingw"), ("distros", ["windows-vsCurrent-large"])]), - OD([("name", "install-uninstall-check-msvc"), ("distros", ["windows-vsCurrent-large"])]), - "debug-compile-with-warnings", - OD([("name", "build-and-test-with-toolchain"), ("distros", ["debian10-small"])]), - "install-libmongoc-after-libbson", - ], - { - # Disable the MongoDB legacy shell download, which is not available in 5.0 for u22 - "SKIP_LEGACY_SHELL": "1" - }, - tags=["pr-merge-gate"], - ), - Variant( - "clang38", - "clang 3.8 (Debian 9.2)", - "debian92-test", - ["release-compile", "debug-compile-nosasl-nossl", ".latest .nossl"], - {"CC": "clang"}, - ), - Variant( - "openssl", - "OpenSSL / LibreSSL", - "archlinux-build", - [ - "build-and-run-authentication-tests-openssl-1.0.1", - "build-and-run-authentication-tests-openssl-1.0.2", - "build-and-run-authentication-tests-openssl-1.1.0", - "build-and-run-authentication-tests-openssl-1.0.1-fips", - "build-and-run-authentication-tests-libressl-2.5", - "build-and-run-authentication-tests-libressl-3.0-auto", - "build-and-run-authentication-tests-libressl-3.0", - ], - {}, - ), - Variant( - "clang37", - "clang 3.7 (Archlinux)", - "archlinux-test", - [ - "release-compile", - "debug-compile-sasl-openssl", - "debug-compile-nosasl-openssl", - ".authentication-tests .openssl", - ], - {"CC": "clang"}, - ), - Variant( - "clang60-i686", - "clang 6.0 (i686) (Ubuntu 18.04)", - "ubuntu1804-test", - [ - "release-compile", - "debug-compile-nosasl-nossl", - "debug-compile-no-align", - ".debug-compile !.sspi .nossl .nosasl", - ".latest .nossl .nosasl", - ], - {"CC": "clang", "MARCH": "i686"}, - ), - Variant( - "clang38-i686", - "clang 3.8 (i686) (Ubuntu 16.04)", - "ubuntu1604-test", - ["release-compile", "debug-compile-no-align"], - {"CC": "clang", "MARCH": "i686"}, - ), - Variant( - "clang38ubuntu", - "clang 3.8 (Ubuntu 16.04)", - "ubuntu1604-test", - [ - ".compression !.zstd", - "release-compile", - "debug-compile-sasl-openssl", - "debug-compile-nosasl-openssl", - "debug-compile-no-align", - ".authentication-tests .openssl", - ], - {"CC": "clang"}, - ), - Variant( - "gcc82rhel", - "GCC 8.2 (RHEL 8.0)", - "rhel80-test", - [ - ".hardened", - ".compression !.snappy !.zstd", - "release-compile", - "debug-compile-nosasl-nossl", - "debug-compile-nosasl-openssl", - "debug-compile-sasl-openssl", - ".authentication-tests .openssl", - ".latest .nossl", - ], - {"CC": "gcc"}, - ), - Variant( - "gcc48rhel", - "GCC 4.8 (RHEL 7.0)", - "rhel70", - # Skip client-side-encryption tests on RHEL 7.0 due to OCSP errors - # with Azure. See CDRIVER-3620 and CDRIVER-3814. - [ - ".hardened", - ".compression !.snappy", - "release-compile", - "debug-compile-nosasl-nossl", - "debug-compile-sasl-openssl", - "debug-compile-nosasl-openssl", - ".authentication-tests .openssl", - ".latest .nossl", - ], - {"CC": "gcc"}, - ), - Variant( - "gcc63", - "GCC 6.3 (Debian 9.2)", - "debian92-test", - ["release-compile", "debug-compile-nosasl-nossl", ".latest .nossl"], - {"CC": "gcc"}, - ), - Variant( - "gcc83", - "GCC 8.3 (Debian 10.0)", - "debian10-test", - ["release-compile", "debug-compile-nosasl-nossl", ".latest .nossl"], - {"CC": "gcc"}, - ), - Variant( - "gcc102", - "GCC 10.2 (Debian 11.0)", - "debian11-large", - ["release-compile", "debug-compile-nosasl-nossl", ".latest .nossl"], - {"CC": "gcc"}, - ), - Variant( - "gcc94", - "GCC 9.4 (Ubuntu 20.04)", - "ubuntu2004-large", - ["release-compile", "debug-compile-nosasl-nossl", ".latest .nossl"], - {"CC": "gcc"}, - ), - Variant( - "gcc75-i686", - "GCC 7.5 (i686) (Ubuntu 18.04)", - "ubuntu1804-test", - ["release-compile", "debug-compile-nosasl-nossl", "debug-compile-no-align", ".latest .nossl .nosasl"], - {"CC": "gcc", "MARCH": "i686"}, - ), - Variant( - "gcc75", - "GCC 7.5 (Ubuntu 18.04)", - "ubuntu1804-test", - [ - ".compression !.zstd", - "debug-compile-nosrv", - "release-compile", - "debug-compile-nosasl-nossl", - "debug-compile-no-align", - "debug-compile-sasl-openssl", - "debug-compile-nosasl-openssl", - ".authentication-tests .openssl", - ".authentication-tests .asan", - ".test-coverage", - ".latest .nossl", - "retry-true-latest-server", - "test-dns-openssl", - "test-dns-auth-openssl", - "test-dns-loadbalanced-openssl", - ], - {"CC": "gcc"}, - ), - Variant( - "gcc54", - "GCC 5.4 (Ubuntu 16.04)", - "ubuntu1604-test", - [".compression !.zstd", "debug-compile-nosrv", "release-compile", "debug-compile-no-align"], - {"CC": "gcc"}, - ), - Variant( - "darwin", - "*Darwin, macOS (Apple LLVM)", - "macos-1100", - [ - ".compression !.snappy", - "release-compile", - "debug-compile-nosasl-nossl", - "debug-compile-rdtscp", - "debug-compile-no-align", - "debug-compile-nosrv", - "debug-compile-sasl-darwinssl", - "debug-compile-nosasl-nossl", - ".authentication-tests .darwinssl", - ".latest .nossl", - "test-dns-darwinssl", - "test-dns-auth-darwinssl", - "debug-compile-lto", - "debug-compile-lto-thin", - "debug-compile-aws", - "test-aws-openssl-regular-4.4", - "test-aws-openssl-regular-latest", - ], - {"CC": "clang"}, - ), - Variant( - "windows-2017-32", - "Windows (i686) (VS 2017)", - "windows-vsCurrent-large", - ["debug-compile-nosasl-nossl", ".latest .nossl .nosasl"], - {"CC": "Visual Studio 15 2017"}, - ), - Variant( - "windows-2017", - "Windows (VS 2017)", - "windows-vsCurrent-large", - [ - "debug-compile-nosasl-nossl", - "debug-compile-nosasl-openssl", - "debug-compile-sspi-winssl", - ".latest .nossl", - ".nosasl .latest .nossl", - "test-dns-winssl", - "test-dns-auth-winssl", - "debug-compile-aws", - "test-aws-openssl-regular-4.4", - "test-aws-openssl-regular-latest", - # Authentication tests with OpenSSL on Windows are only run on the vs2017 variant. - # Older vs variants fail to verify certificates against Atlas tests. - ".authentication-tests .openssl !.sasl", - ".authentication-tests .winssl", - ], - {"CC": "Visual Studio 15 2017 Win64"}, - ), - Variant( - "windows-2015", - "Windows (VS 2015)", - "windows-64-vs2015-compile", - [ - ".compression !.snappy !.zstd !.latest", - "release-compile", - "debug-compile-sspi-winssl", - "debug-compile-no-align", - "debug-compile-nosrv", - ".authentication-tests .winssl", - ], - {"CC": "Visual Studio 14 2015 Win64"}, - ), - Variant( - "windows-2015-32", - "Windows (i686) (VS 2015)", - "windows-64-vs2015-compile", - [ - ".compression !.snappy !.zstd !.latest", - "release-compile", - "debug-compile-sspi-winssl", - "debug-compile-no-align", - ".authentication-tests .winssl", - ], - {"CC": "Visual Studio 14 2015"}, - ), - Variant( - "windows-2013", - "Windows (VS 2013)", - "windows-64-vs2013-compile", - [ - ".compression !.snappy !.zstd !.latest", - "release-compile", - "debug-compile-sspi-winssl", - ".authentication-tests .winssl", - ], - {"CC": "Visual Studio 12 2013 Win64"}, - ), - Variant( - "windows-2013-32", - "Windows (i686) (VS 2013)", - "windows-64-vs2013-compile", - ["release-compile", "debug-compile-rdtscp", "debug-compile-sspi-winssl", ".authentication-tests .winssl"], - {"CC": "Visual Studio 12 2013"}, - ), - Variant( - "mingw-windows2016", - "MinGW-W64 (Windows Server 2016)", - "windows-vsCurrent-large", - ["debug-compile-nosasl-nossl", ".latest .nossl .nosasl .server"], - {"CC": "mingw"}, - ), - Variant("mingw", "MinGW-W64", "windows-vsCurrent-large", ["debug-compile-no-align"], {"CC": "mingw"}), - Variant( - "power8-rhel81", - "Power8 (ppc64le) (RHEL 8.1)", - "rhel81-power8-test", - [ - "release-compile", - "debug-compile-nosasl-nossl", - "debug-compile-sasl-openssl", - ".latest .nossl", - "test-dns-openssl", - ], - {"CC": "gcc"}, - batchtime=days(1), - ), - Variant( - "arm-ubuntu1804", - "*ARM (aarch64) (Ubuntu 18.04)", - "ubuntu1804-arm64-large", - [ - ".compression !.snappy !.zstd", - "debug-compile-no-align", - "release-compile", - "debug-compile-nosasl-nossl", - "debug-compile-nosasl-openssl", - "debug-compile-sasl-openssl", - ".authentication-tests .openssl", - ".latest .nossl", - "test-dns-openssl", - ], - {"CC": "gcc"}, - batchtime=days(1), - ), - Variant( - "arm-ubuntu1604", - "*ARM (aarch64) (Ubuntu 16.04)", - "ubuntu1604-arm64-large", - [".compression !.snappy !.zstd", "debug-compile-no-align", "release-compile"], - {"CC": "gcc"}, - batchtime=days(1), - ), - Variant( - "zseries-rhel83", - "*zSeries", - "rhel83-zseries-small", - [ - "release-compile", - # '.compression', --> TODO: waiting on ticket CDRIVER-3258 - "debug-compile-no-align", - "debug-compile-nosasl-nossl", - "debug-compile-nosasl-openssl", - "debug-compile-sasl-openssl", - ".authentication-tests .openssl", - ".latest .nossl", - ], - {"CC": "gcc"}, - batchtime=days(1), - ), - Variant( - "clang60ubuntu", - "clang 6.0 (Ubuntu 18.04)", - "ubuntu1804-test", - [ - "debug-compile-sasl-openssl-static", - ".authentication-tests .asan", - ], - {"CC": "clang"}, - ), - # Run AWS tests for MongoDB 4.4 and 5.0 on Ubuntu 20.04. AWS setup scripts expect Ubuntu 20.04+. MongoDB 4.4 and 5.0 are not available on 22.04. - Variant( - "aws-ubuntu2004", - "AWS Tests (Ubuntu 20.04)", - "ubuntu2004-small", - [ - "debug-compile-aws", - ".test-aws .4.4", - ".test-aws .5.0", - ], - {"CC": "clang"}, - ), - Variant( - "aws-ubuntu2204", - "AWS Tests (Ubuntu 22.04)", - "ubuntu2004-small", - [ - "debug-compile-aws", - ".test-aws .6.0", - ".test-aws .7.0", - ".test-aws .latest", - ], - {"CC": "clang"}, - ), - Variant("mongohouse", "Mongohouse Test", "ubuntu2204-small", ["debug-compile-sasl-openssl", "test-mongohouse"], {}), - Variant( - "ocsp", - "OCSP tests", - "ubuntu2004-small", - [ - OD([("name", "debug-compile-nosasl-openssl")]), - OD([("name", "debug-compile-nosasl-openssl-static")]), - OD([("name", "debug-compile-nosasl-darwinssl"), ("distros", ["macos-1100"])]), - OD([("name", "debug-compile-nosasl-winssl"), ("distros", ["windows-vsCurrent-large"])]), - OD([("name", ".ocsp-openssl")]), - OD([("name", ".ocsp-darwinssl"), ("distros", ["macos-1100"])]), - OD([("name", ".ocsp-winssl"), ("distros", ["windows-vsCurrent-large"])]), - OD([("name", "debug-compile-nosasl-openssl-1.0.1")]), - OD([("name", ".ocsp-openssl-1.0.1")]), - ], - {}, - batchtime=days(7), - ), - Variant( - "packaging", - "Linux Distro Packaging", - "ubuntu1804-test", - [ - "debian-package-build", - OD([("name", "rpm-package-build"), ("distros", ["rhel90-arm64-small"])]), - ], - {}, - tags=["pr-merge-gate"], - ), - Variant( - "versioned-api-ubuntu1804", - "Versioned API Tests (Ubuntu 18.04)", - "ubuntu1804-test", - [ - "debug-compile-nosasl-openssl", - "debug-compile-nosasl-nossl", - ".versioned-api .5.0", - ".versioned-api .6.0", - ], - {}, - ), - # Test 7.0+ with Ubuntu 20.04+ since MongoDB 7.0 no longer ships binaries for Ubuntu 18.04. - Variant( - "versioned-api-ubuntu2004", - "Versioned API Tests (Ubuntu 20.04)", - "ubuntu2004-test", - [ - "debug-compile-nosasl-openssl", - "debug-compile-nosasl-nossl", - ".versioned-api .7.0", - ], - {}, - ), -] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/abi-compliance-check.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/abi-compliance-check.sh deleted file mode 100644 index ba4eb431b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/abi-compliance-check.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit - -# create all needed directories -mkdir abi-compliance -mkdir abi-compliance/changes-install -mkdir abi-compliance/latest-release-install -mkdir abi-compliance/dumps - -python ./build/calc_release_version.py --next-minor >VERSION_CURRENT -python ./build/calc_release_version.py --next-minor -p >VERSION_RELEASED - -declare newest current -newest="$(cat VERSION_RELEASED)" -current="$(cat VERSION_CURRENT)" - -# build the current changes -env \ - CFLAGS="-g -Og" \ - EXTRA_CONFIGURE_FLAGS="-DCMAKE_INSTALL_PREFIX=./abi-compliance/changes-install" \ - bash .evergreen/scripts/compile.sh - -# checkout the newest release -git checkout "tags/${newest}" -f - -declare compile_script=".evergreen/scripts/compile.sh" -if [[ ! -f "${compile_script}" ]]; then - # Compatibility: remove once latest release contains relocated script. - compile_script=".evergreen/compile.sh" -fi - -# build the newest release -env \ - CFLAGS="-g -Og" \ - EXTRA_CONFIGURE_FLAGS="-DCMAKE_INSTALL_PREFIX=./abi-compliance/latest-release-install" \ - bash "${compile_script}" - -# check for abi compliance. Generates HTML Reports. -cd abi-compliance - -cat >|old.xml <${newest} - -$(pwd)/latest-release-install/include/libmongoc-1.0/mongoc/mongoc.h -$(pwd)/latest-release-install/include/libbson-1.0/bson/bson.h - -$(pwd)/latest-release-install/lib -DOC - -cat >|new.xml <${current} - -$(pwd)/changes-install/include/libmongoc-1.0/mongoc/mongoc.h -$(pwd)/changes-install/include/libbson-1.0/bson/bson.h - -$(pwd)/changes-install/lib -DOC - -if ! abi-compliance-checker -lib mongo-c-driver -old old.xml -new new.xml; then - touch ./abi-error.txt -fi diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-files.py b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-files.py deleted file mode 100644 index 1321bd3ae..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-files.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Check that there are no missing .c or .h files in the release tarball. -""" -import os -import re -import sys - -if len(sys.argv) != 3: - print("Usage: python check_files.py" - " " - " ") - sys.exit(1) - -REPO_SRC_DIR = sys.argv[1] -TAR_SRC_DIR = sys.argv[2] - -pattern = re.compile(r".*\.(c|h)$") - -repo_src_files = set() -tar_src_files = set() - -# Files that are generated by cmake are expected not to be in the repository. -cmake_produced = [ - "libbson/src/bson/bson-version.h", - "libmongoc/src/mongoc/mongoc-version.h", - "zlib-1.2.13/zconf.h", -] - -for root, dirs, files in os.walk(REPO_SRC_DIR): - for file in files: - relpath = os.path.relpath(os.path.join(root, file), REPO_SRC_DIR) - - if pattern.match(relpath): - repo_src_files.add(relpath) - -for root, dirs, files in os.walk(TAR_SRC_DIR): - for file in files: - relpath = os.path.relpath(os.path.join(root, file), TAR_SRC_DIR) - if relpath in cmake_produced: - continue - if pattern.match(relpath): - tar_src_files.add(relpath) - -if tar_src_files != repo_src_files: - print("Files produced from tarball differ from repository") - print("Tarball produced the following files NOT in repository") - for file in sorted(tar_src_files.difference(repo_src_files)): - print(" " + file) - print("Repository has the following files NOT in tarball") - for file in sorted(repo_src_files.difference(tar_src_files)): - print(" " + file) - sys.exit(1) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-installed-files-bson.bat b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-installed-files-bson.bat deleted file mode 100644 index bc3bb27b5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-installed-files-bson.bat +++ /dev/null @@ -1,76 +0,0 @@ -rem Validations shared by link-sample-program-msvc-bson.bat and -rem link-sample-program-mingw-bson.bat - -echo off - -rem Notice that the dll goes in "bin". -set DLL=%INSTALL_DIR%\bin\bson-1.0.dll -set LIB_DLL=%INSTALL_DIR%\bin\libbson-1.0.dll -set LIB_LIB=%INSTALL_DIR%\lib\libbson-1.0.lib -if "%MINGW%"=="1" ( - if not exist %LIB_DLL% ( - echo %LIB_DLL% is missing! - exit /B 1 - ) else ( - echo libbson-1.0.dll check ok - ) - if exist %DLL% ( - echo %DLL% is present and should not be! - exit /B 1 - ) -) else ( - if not exist %DLL% ( - echo %DLL% is missing! - exit /B 1 - ) else ( - echo bson-1.0.dll check ok - ) - if exist %LIB_LIB% ( - echo %LIB_LIB% is present and should not be! - exit /B 1 - ) else ( - echo libbson-1.0.lib check ok - ) -) -if not exist %INSTALL_DIR%\lib\pkgconfig\libbson-1.0.pc ( - echo libbson-1.0.pc missing! - exit /B 1 -) else ( - echo libbson-1.0.pc check ok -) -if not exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-1.0-config.cmake ( - echo bson-1.0-config.cmake missing! - exit /B 1 -) else ( - echo bson-1.0-config.cmake check ok -) -if not exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-1.0-config-version.cmake ( - echo bson-1.0-config-version.cmake missing! - exit /B 1 -) else ( - echo bson-1.0-config-version.cmake check ok -) -if not exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-targets.cmake ( - echo bson-targets.cmake missing! - exit /B 1 -) else ( - echo bson-targets.cmake check ok -) - -if "%LINK_STATIC%"=="1" ( - if not exist %INSTALL_DIR%\lib\pkgconfig\libbson-static-1.0.pc ( - echo libbson-static-1.0.pc missing! - exit /B 1 - ) else ( - echo libbson-static-1.0.pc check ok - ) -) else ( - if exist %INSTALL_DIR%\lib\pkgconfig\libbson-static-1.0.pc ( - echo libbson-static-1.0.pc should not have been installed! - exit /B 1 - ) else ( - echo libbson-static-1.0.pc missing, as expected - ) -) - -echo on diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-installed-files.bat b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-installed-files.bat deleted file mode 100644 index f75d365a4..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-installed-files.bat +++ /dev/null @@ -1,66 +0,0 @@ -rem Validations shared by link-sample-program-msvc.bat and -rem link-sample-program-mingw.bat - -echo off - -rem Notice that the dll goes in "bin". -set DLL=%INSTALL_DIR%\bin\mongoc-1.0.dll -set LIB_DLL=%INSTALL_DIR%\bin\libmongoc-1.0.dll -set LIB_LIB=%INSTALL_DIR%\lib\libmongoc-1.0.lib -if "%MINGW%"=="1" ( - if not exist %LIB_DLL% ( - echo %LIB_DLL% is missing! - exit /B 1 - ) else ( - echo libmongoc-1.0.dll check ok - ) - if exist %DLL% ( - echo %DLL% is present and should not be! - exit /B 1 - ) -) else ( - if not exist %DLL% ( - echo %DLL% is missing! - exit /B 1 - ) else ( - echo mongoc-1.0.dll check ok - ) - if exist %LIB_LIB% ( - echo %LIB_LIB% is present and should not be! - exit /B 1 - ) else ( - echo libmongoc-1.0.lib check ok - ) -) -if not exist %INSTALL_DIR%\lib\pkgconfig\libmongoc-1.0.pc ( - echo libmongoc-1.0.pc missing! - exit /B 1 -) else ( - echo libmongoc-1.0.pc check ok -) -if not exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-1.0-config.cmake ( - echo mongoc-1.0-config.cmake missing! - exit /B 1 -) else ( - echo mongoc-1.0-config.cmake check ok -) -if not exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-1.0-config-version.cmake ( - echo mongoc-1.0-config-version.cmake missing! - exit /B 1 -) else ( - echo mongoc-1.0-config-version.cmake check ok -) -if not exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-targets.cmake ( - echo mongoc-targets.cmake missing! - exit /B 1 -) else ( - echo mongoc-targets.cmake check ok -) -if not exist %INSTALL_DIR%\lib\pkgconfig\libmongoc-static-1.0.pc ( - echo libmongoc-static-1.0.pc missing! - exit /B 1 -) else ( - echo libmongoc-static-1.0.pc check ok -) - -echo on diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-libmongocrypt.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-libmongocrypt.sh deleted file mode 100755 index 3444fc4b8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-libmongocrypt.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -compile_libmongocrypt() { - declare -r cmake_binary="${1:?}" - declare -r mongoc_dir="${2:?}" - declare -r install_dir="${3:?}" - - # When updating libmongocrypt, consider also updating the copy of - # libmongocrypt's kms-message in `src/kms-message`. Run - # `.evergreen/scripts/kms-divergence-check.sh` to ensure that there is no - # divergence in the copied files. - - # TODO: once 1.9.0 is released (containing MONGOCRYPT-605) replace the following with: - # git clone -q --depth=1 https://github.com/mongodb/libmongocrypt --branch 1.9.0 || return - { - git clone -q https://github.com/mongodb/libmongocrypt || return - # Check out commit containing MONGOCRYPT-605 - git -C libmongocrypt checkout c87cc3489c9a68875ff7fab541154841469991fb - } - - declare -a crypt_cmake_flags=( - "-DMONGOCRYPT_MONGOC_DIR=${mongoc_dir}" - "-DBUILD_TESTING=OFF" - "-DENABLE_ONLINE_TESTS=OFF" - "-DENABLE_MONGOC=OFF" - "-DBUILD_VERSION=1.9.0-pre" - ) - - DEBUG="0" \ - CMAKE_EXE="${cmake_binary}" \ - MONGOCRYPT_INSTALL_PREFIX=${install_dir} \ - DEFAULT_BUILD_ONLY=true \ - LIBMONGOCRYPT_EXTRA_CMAKE_FLAGS="${crypt_cmake_flags[*]}" \ - ./libmongocrypt/.evergreen/compile.sh || return -} - -: "${1:?"missing path to CMake binary"}" -: "${2:?"missing path to mongoc directory"}" -: "${3:?"missing path to install directory"}" - -compile_libmongocrypt "${1}" "${2}" "${3}" diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-std.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-std.sh deleted file mode 100755 index f304c96ff..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-std.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o pipefail - -# shellcheck source=.evergreen/scripts/env-var-utils.sh -. "$(dirname "${BASH_SOURCE[0]}")/env-var-utils.sh" -. "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" paths - -check_var_req CC - -check_var_opt C_STD_VERSION -check_var_opt CFLAGS -check_var_opt MARCH - -declare script_dir -script_dir="$(to_absolute "$(dirname "${BASH_SOURCE[0]}")")" - -declare mongoc_dir -mongoc_dir="$(to_absolute "${script_dir}/../..")" - -declare install_dir="${mongoc_dir}/install-dir" - -declare -a configure_flags - -configure_flags_append() { - configure_flags+=("${@:?}") -} - -configure_flags_append_if_not_null() { - declare var="${1:?}" - if [[ -n "${!var:-}" ]]; then - shift - configure_flags+=("${@:?}") - fi -} - -configure_flags_append "-DCMAKE_PREFIX_PATH=${install_dir}" -configure_flags_append "-DCMAKE_SKIP_RPATH=TRUE" # Avoid hardcoding absolute paths to dependency libraries. -configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF" -configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=ON" -configure_flags_append "-DENABLE_DEBUG_ASSERTIONS=ON" -configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON" - -configure_flags_append_if_not_null C_STD_VERSION "-DCMAKE_C_STANDARD=${C_STD_VERSION}" - -if [[ "${OSTYPE}" == darwin* && "${HOSTTYPE}" == "arm64" ]]; then - configure_flags_append "-DCMAKE_OSX_ARCHITECTURES=arm64" -fi - -if [[ "${CC}" =~ ^"Visual Studio " ]]; then - # Avoid C standard conformance issues with Windows 10 SDK headers. - # See: https://developercommunity.visualstudio.com/t/stdc17-generates-warning-compiling-windowsh/1249671#T-N1257345 - configure_flags_append "-DCMAKE_SYSTEM_VERSION=10.0.20348.0" -fi - -declare -a flags - -if [[ ! "${CC}" =~ ^"Visual Studio " ]]; then - case "${MARCH}" in - i686) - flags+=("-m32" "-march=i386") - ;; - esac - - case "${HOSTTYPE}" in - s390x) - flags+=("-march=z196" "-mtune=zEC12") - ;; - x86_64) - flags+=("-m64" "-march=x86-64") - ;; - powerpc64le) - flags+=("-mcpu=power8" "-mtune=power8" "-mcmodel=medium") - ;; - esac -fi - -if [[ "${CC}" =~ ^"Visual Studio " ]]; then - # Even with -DCMAKE_SYSTEM_VERSION=10.0.20348.0, winbase.h emits conformance warnings. - flags+=('/wd5105') -fi - -# CMake and compiler environment variables. -export CC -export CXX -export CFLAGS -export CXXFLAGS - -CFLAGS+=" ${flags+${flags[*]}}" -CXXFLAGS+=" ${flags+${flags[*]}}" - -if [[ "${OSTYPE}" == darwin* ]]; then - CFLAGS+=" -Wno-unknown-pragmas" -fi - -case "${CC}" in -clang) - CXX=clang++ - ;; -gcc) - CXX=g++ - ;; -esac - -# Ensure find-cmake-latest.sh is sourced *before* add-build-dirs-to-paths.sh -# to avoid interfering with potential CMake build configuration. -# shellcheck source=.evergreen/scripts/find-cmake-latest.sh -. "${script_dir}/find-cmake-latest.sh" -declare cmake_binary -cmake_binary="$(find_cmake_latest)" - -# shellcheck source=.evergreen/scripts/add-build-dirs-to-paths.sh -. "${script_dir}/add-build-dirs-to-paths.sh" - -export PKG_CONFIG_PATH -PKG_CONFIG_PATH="${install_dir}/lib/pkgconfig:${PKG_CONFIG_PATH:-}" - -if [[ "${OSTYPE}" == darwin* ]]; then - # MacOS does not have nproc. - nproc() { - sysctl -n hw.logicalcpu - } -fi - -echo "Installing libmongocrypt..." -# shellcheck source=.evergreen/scripts/compile-libmongocrypt.sh -"${script_dir}/compile-libmongocrypt.sh" "${cmake_binary}" "${mongoc_dir}" "${install_dir}" &>output.txt || { - cat output.txt 1>&2 - exit 1 -} -echo "Installing libmongocrypt... done." - -echo "CFLAGS: ${CFLAGS}" -echo "configure_flags: ${configure_flags[*]}" - -# Allow reuse of ccache compilation results between different build directories. -export CCACHE_BASEDIR CCACHE_NOHASHDIR -CCACHE_BASEDIR="$(pwd)" -CCACHE_NOHASHDIR=1 - -"${cmake_binary}" "${configure_flags[@]}" . -"${cmake_binary}" --build . diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-windows.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-windows.sh deleted file mode 100755 index 3a792aa4a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-windows.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o pipefail - -set -o igncr # Ignore CR in this script for Windows compatibility. - -# shellcheck source=.evergreen/scripts/env-var-utils.sh -. "$(dirname "${BASH_SOURCE[0]}")/env-var-utils.sh" -. "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" paths - -check_var_opt BYPASS_FIND_CMAKE "OFF" -check_var_opt C_STD_VERSION # CMake default: 99. -check_var_opt CC "Visual Studio 15 2017 Win64" -check_var_opt COMPILE_LIBMONGOCRYPT "OFF" -check_var_opt DEBUG "OFF" -check_var_opt EXTRA_CONFIGURE_FLAGS -check_var_opt RELEASE "OFF" -check_var_opt SASL "SSPI" # CMake default: AUTO. -check_var_opt SNAPPY # CMake default: AUTO. -check_var_opt SRV # CMake default: AUTO. -check_var_opt SSL "WINDOWS" # CMake default: OFF. -check_var_opt ZSTD # CMake default: AUTO. -check_var_opt ZLIB # CMake default: AUTO. - -declare script_dir -script_dir="$(to_absolute "$(dirname "${BASH_SOURCE[0]}")")" - -declare mongoc_dir -mongoc_dir="$(to_absolute "${script_dir}/../..")" - -declare -a configure_flags - -configure_flags_append() { - configure_flags+=("${@:?}") -} - -configure_flags_append_if_not_null() { - declare var="${1:?}" - if [[ -n "${!var:-}" ]]; then - shift - configure_flags+=("${@:?}") - fi -} - -declare install_dir="${mongoc_dir}/install-dir" - -## * Note: For additional configure-time context, the following lines can be -## * uncommented to enable CMake's debug output: -# configure_flags_append --log-level=debug -# configure_flags_append --log-context - -configure_flags_append "-DCMAKE_INSTALL_PREFIX=$(native-path "${install_dir}")" -configure_flags_append "-DCMAKE_PREFIX_PATH=$(native-path "${install_dir}")" -configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF" -configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON" - -configure_flags_append_if_not_null C_STD_VERSION "-DCMAKE_C_STANDARD=${C_STD_VERSION:-}" -configure_flags_append_if_not_null SASL "-DENABLE_SASL=${SASL:-}" -configure_flags_append_if_not_null SNAPPY "-DENABLE_SNAPPY=${SNAPPY:-}" -configure_flags_append_if_not_null SRV "-DENABLE_SRV=${SRV:-}" -configure_flags_append_if_not_null ZLIB "-DENABLE_ZLIB=${ZLIB:-}" - -if [[ "${DEBUG}" == "ON" ]]; then - configure_flags_append "-DCMAKE_BUILD_TYPE=Debug" -else - configure_flags_append "-DCMAKE_BUILD_TYPE=RelWithDebInfo" -fi - -if [ "${SSL}" == "OPENSSL_STATIC" ]; then - configure_flags_append "-DENABLE_SSL=OPENSSL" "-DOPENSSL_USE_STATIC_LIBS=ON" -else - configure_flags_append "-DENABLE_SSL=${SSL}" -fi - -declare -a extra_configure_flags -IFS=' ' read -ra extra_configure_flags <<<"${EXTRA_CONFIGURE_FLAGS:-}" - -declare build_config - -if [[ "${RELEASE}" == "ON" ]]; then - build_config="RelWithDebInfo" -else - build_config="Debug" - configure_flags_append "-DENABLE_DEBUG_ASSERTIONS=ON" -fi - -declare cmake_binary -if [[ "${BYPASS_FIND_CMAKE:-}" == "OFF" ]]; then - # shellcheck source=.evergreen/scripts/find-cmake-version.sh - . "${script_dir}/find-cmake-latest.sh" - - cmake_binary="$(find_cmake_latest)" -else - cmake_binary="cmake" -fi - -"${cmake_binary:?}" --version - -if [[ "${CC}" =~ mingw ]]; then - # MinGW has trouble compiling src/cpp-check.cpp without some assistance. - configure_flags_append "-DCMAKE_CXX_STANDARD=11" - cmake_binary=$(native-path "$cmake_binary") - - build_dir=$(native-path "$mongoc_dir") - env \ - "CC=gcc" \ - "CXX=g++" \ - "$cmake_binary" \ - -G "MinGW Makefiles" \ - -D CMAKE_PREFIX_PATH="$(native-path "$install_dir/lib/cmake")" \ - "${configure_flags[@]}" \ - "${extra_configure_flags[@]}" \ - -B "$build_dir" \ - -S "$(native-path "$mongoc_dir")" - - env "$cmake_binary" --build "$build_dir" --parallel "$(nproc)" - exit 0 -fi - -declare compile_flags=( - "/m" # Number of concurrent processes. No value=# of cpus -) - -if [ "${COMPILE_LIBMONGOCRYPT}" = "ON" ]; then - echo "Installing libmongocrypt..." - # shellcheck source=.evergreen/scripts/compile-libmongocrypt.sh - "${script_dir}/compile-libmongocrypt.sh" "${cmake_binary}" "$(native-path "${mongoc_dir}")" "${install_dir}" &>output.txt || { - cat output.txt 1>&2 - exit 1 - } - echo "Installing libmongocrypt... done." - - # Fail if the C driver is unable to find the installed libmongocrypt. - configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=ON" -fi - -"${cmake_binary}" -G "$CC" "${configure_flags[@]}" "${extra_configure_flags[@]}" -"${cmake_binary}" --build . --target ALL_BUILD --config "${build_config}" -- "${compile_flags[@]}" -"${cmake_binary}" --build . --target INSTALL --config "${build_config}" -- "${compile_flags[@]}" diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile.sh deleted file mode 100755 index 142627f25..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -if [[ "${OSTYPE}" == "cygwin" ]]; then - bash .evergreen/scripts/compile-windows.sh -else - bash .evergreen/scripts/compile-unix.sh -fi diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/find-cmake.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/find-cmake.sh deleted file mode 100755 index f41f69125..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/find-cmake.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -set -o errexit # Exit the script with error if any of the commands fail - -find_cmake () -{ - CMAKE=${CMAKE:-} - IGNORE_SYSTEM_CMAKE=${IGNORE_SYSTEM_CMAKE:-} - if [ ! -z "$CMAKE" ]; then - return 0 - elif [ -f "/Applications/cmake-3.2.2-Darwin-x86_64/CMake.app/Contents/bin/cmake" ]; then - CMAKE="/Applications/cmake-3.2.2-Darwin-x86_64/CMake.app/Contents/bin/cmake" - elif [ -f "/Applications/Cmake.app/Contents/bin/cmake" ]; then - CMAKE="/Applications/Cmake.app/Contents/bin/cmake" - elif [ -f "/opt/cmake/bin/cmake" ]; then - CMAKE="/opt/cmake/bin/cmake" - elif [ -z "$IGNORE_SYSTEM_CMAKE" ] && command -v cmake 2>/dev/null; then - CMAKE=cmake - elif uname -a | grep -iq 'x86_64 GNU/Linux'; then - if [ -f "$(pwd)/cmake-3.11.0/bin/cmake" ]; then - CMAKE="$(pwd)/cmake-3.11.0/bin/cmake" - return 0 - fi - curl --retry 5 https://cmake.org/files/v3.11/cmake-3.11.0-Linux-x86_64.tar.gz -sS --max-time 120 --fail --output cmake.tar.gz - mkdir cmake-3.11.0 - tar xzf cmake.tar.gz -C cmake-3.11.0 --strip-components=1 - CMAKE=$(pwd)/cmake-3.11.0/bin/cmake - elif [ -f "/cygdrive/c/cmake/bin/cmake" ]; then - CMAKE="/cygdrive/c/cmake/bin/cmake" - fi - if [ -z "$CMAKE" -o -z "$( $CMAKE --version 2>/dev/null )" ]; then - # Some images have no cmake yet, or a broken cmake (see: BUILD-8570) - echo "-- MAKE CMAKE --" - CMAKE_INSTALL_DIR=$(readlink -f cmake-install) - curl --retry 5 https://cmake.org/files/v3.11/cmake-3.11.0.tar.gz -sS --max-time 120 --fail --output cmake.tar.gz - tar xzf cmake.tar.gz - cd cmake-3.11.0 - ./bootstrap --prefix="${CMAKE_INSTALL_DIR}" - make -j8 - make install - cd .. - CMAKE="${CMAKE_INSTALL_DIR}/bin/cmake" - echo "-- DONE MAKING CMAKE --" - fi -} - -find_cmake diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-uninstall-check-windows.cmd b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-uninstall-check-windows.cmd deleted file mode 100644 index 332e072f9..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-uninstall-check-windows.cmd +++ /dev/null @@ -1,252 +0,0 @@ -REM Supported/used environment variables: -REM CC Compiler, "mingw" or "Visual Studio 14 2015 Win64". -REM BSON_ONLY Whether to build only the BSON library. - -rem Ensure Cygwin executables like sh.exe are not in PATH -rem set PATH=C:\Windows\system32;C:\Windows - -echo on -echo - -set SRCROOT=%CD% -set TAR=C:\cygwin\bin\tar -set CMAKE=C:\cmake\bin\cmake -set CMAKE_MAKE_PROGRAM=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\mingw32-make.exe -rem Ensure Cygwin executables like sh.exe are not in PATH -set PATH=C:\cygwin\bin;C:\Windows\system32;C:\Windows;C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin;C:\mongoc;src\libbson;src\libmongoc - -if "%BSON_ONLY%"=="1" ( - set BUILD_DIR=%CD%\build-dir-bson - set INSTALL_DIR=%CD%\install-dir-bson -) else ( - set BUILD_DIR=%CD%\build-dir-mongoc - set INSTALL_DIR=%CD%\install-dir-mongoc -) -rmdir /S /Q %BUILD_DIR% -mkdir %BUILD_DIR% - -rmdir /S /Q %INSTALL_DIR% -mkdir %INSTALL_DIR% - -set PATH=%PATH%;%INSTALL_DIR%\bin - -cd %BUILD_DIR% -robocopy "%SRCROOT%" "%BUILD_DIR%" /E /XD ".git" "%BUILD_DIR%" "_build" "cmake-build" /NP /NFL /NDL - -if "%BSON_ONLY%"=="1" ( - set BSON_ONLY_OPTION=-DENABLE_MONGOC=OFF -) else ( - set BSON_ONLY_OPTION=-DENABLE_MONGOC=ON -) - -echo.%CC%| findstr /I "gcc">Nul && ( - rem Build libmongoc, with flags that the downstream R driver mongolite uses - %CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake %BSON_ONLY_OPTION% . - %CMAKE% --build . - if errorlevel 1 ( - exit /B 1 - ) - %CMAKE% --build . --target install - if errorlevel 1 ( - exit /B 1 - ) - - REM no kms-message components should be installed - if exist %INSTALL_DIR%\include\kms_message\kms_message.h ( - echo kms_message.h found! - exit /B 1 - ) else ( - echo kms_message.h check ok - ) - if exist %INSTALL_DIR%\lib\libkms_message-static.a ( - echo libkms_message-static.a found! - exit /B 1 - ) else ( - echo libkms_message-static.a check ok - ) - if exist %INSTALL_DIR%\lib\cmake\kms_message\kms_message-config.cmake ( - echo kms_message-config.cmake found! - exit /B 1 - ) else ( - echo kms_message-config.cmake check ok - ) - - echo > %INSTALL_DIR%\lib\canary.txt - - dir %INSTALL_DIR%\share\mongo-c-driver - - %CMAKE% --build . --target uninstall - if errorlevel 1 ( - exit /B 1 - ) -) || ( - %CMAKE% -G "%CC%" "-DCMAKE_INSTALL_PREFIX=%INSTALL_DIR%" "-DCMAKE_BUILD_TYPE=Debug" %BSON_ONLY_OPTION% . - %CMAKE% --build . --config Debug - if errorlevel 1 ( - exit /B 1 - ) - %CMAKE% --build . --config Debug --target install - if errorlevel 1 ( - exit /B 1 - ) - - echo > %INSTALL_DIR%\lib\canary.txt - - REM no kms-message components should be installed - if exist %INSTALL_DIR%\include\kms_message\kms_message.h ( - echo kms_message.h found! - exit /B 1 - ) else ( - echo kms_message.h check ok - ) - if exist %INSTALL_DIR%\lib\libkms_message-static.a ( - echo libkms_message-static.a found! - exit /B 1 - ) else ( - echo libkms_message-static.a check ok - ) - if exist %INSTALL_DIR%\lib\cmake\kms_message\kms_message-config.cmake ( - echo kms_message-config.cmake found! - exit /B 1 - ) else ( - echo kms_message-config.cmake check ok - ) - - dir %INSTALL_DIR%\share\mongo-c-driver - - %CMAKE% --build . --target uninstall - if errorlevel 1 ( - exit /B 1 - ) -) - -if exist %INSTALL_DIR%\lib\pkgconfig\libbson-1.0.pc ( - echo libbson-1.0.pc found! - exit /B 1 -) else ( - echo libbson-1.0.pc check ok -) -if exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-1.0-config.cmake ( - echo bson-1.0-config.cmake found! - exit /B 1 -) else ( - echo bson-1.0-config.cmake check ok -) -if exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-1.0-config-version.cmake ( - echo bson-1.0-config-version.cmake found! - exit /B 1 -) else ( - echo bson-1.0-config-version.cmake check ok -) -if exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-targets.cmake ( - echo bson-targets.cmake found! - exit /B 1 -) else ( - echo bson-targets.cmake check ok -) -if not exist %INSTALL_DIR%\lib\canary.txt ( - echo canary.txt not found! - exit /B 1 -) else ( - echo canary.txt check ok -) -if not exist %INSTALL_DIR%\lib ( - echo %INSTALL_DIR%\lib not found! - exit /B 1 -) else ( - echo %INSTALL_DIR%\lib check ok -) -if "%BSON_ONLY%" NEQ "1" ( - if exist %INSTALL_DIR%\lib\pkgconfig\libmongoc-1.0.pc ( - echo libmongoc-1.0.pc found! - exit /B 1 - ) else ( - echo libmongoc-1.0.pc check ok - ) - if exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-1.0-config.cmake ( - echo mongoc-1.0-config.cmake found! - exit /B 1 - ) else ( - echo mongoc-1.0-config.cmake check ok - ) - if exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-1.0-config-version.cmake ( - echo mongoc-1.0-config-version.cmake found! - exit /B 1 - ) else ( - echo mongoc-1.0-config-version.cmake check ok - ) - if exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-targets.cmake ( - echo mongoc-targets.cmake found! - exit /B 1 - ) else ( - echo mongoc-targets.cmake check ok - ) -) -if exist %INSTALL_DIR%\include\libbson-1.0\bson\bson.h ( - echo bson\bson.h found! - exit /B 1 -) else ( - echo bson\bson.h check ok -) -if exist %INSTALL_DIR%\include\libbson-1.0\bson.h ( - echo bson.h found! - exit /B 1 -) else ( - echo bson.h check ok -) -if exist %INSTALL_DIR%\include\libbson-1.0 ( - echo $INSTALL_DIR\include\libbson-1.0 found! - exit /B 1 -) else ( - echo $INSTALL_DIR\include\libbson-1.0 check ok -) -if "%BSON_ONLY%" NEQ "1" ( - if exist %INSTALL_DIR%\include\libmongoc-1.0\mongoc\mongoc.h ( - echo mongoc\mongoc.h found! - exit /B 1 - ) else ( - echo mongoc\mongoc.h check ok - ) - if exist %INSTALL_DIR%\include\libmongoc-1.0\mongoc.h ( - echo mongoc.h found! - exit /B 1 - ) else ( - echo mongoc.h check ok - ) - if exist %INSTALL_DIR%\include\libmongoc-1.0 ( - echo $INSTALL_DIR\include\libmongoc-1.0 found! - exit /B 1 - ) else ( - echo $INSTALL_DIR\include\libmongoc-1.0 check ok - ) -) -if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall-bson.cmd ( - echo uninstall-bson.cmd found! - exit /B 1 -) else ( - echo uninstall-bson.cmd check ok -) -if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall.cmd ( - echo uninstall.cmd found! - exit /B 1 -) else ( - echo uninstall.cmd check ok -) -if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall-bson.sh ( - echo uninstall-bson.sh found! - exit /B 1 -) else ( - echo uninstall-bson.sh check ok -) -if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall.sh ( - echo uninstall.sh found! - exit /B 1 -) else ( - echo uninstall.sh check ok -) -if exist %INSTALL_DIR%\share\mongo-c-driver ( - echo $INSTALL_DIR\share\mongo-c-driver found! - exit /B 1 -) else ( - echo $INSTALL_DIR\share\mongo-c-driver check ok -) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-uninstall-check.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-uninstall-check.sh deleted file mode 100644 index 7ca4773de..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-uninstall-check.sh +++ /dev/null @@ -1,207 +0,0 @@ -#!/bin/sh -set -o errexit # Exit the script with error if any of the commands fail - -# Supported/used environment variables: -# CMAKE Path to cmake executable. -# BSON_ONLY Whether to build only the BSON library. - - -DIR=$(dirname $0) -. $DIR/find-cmake-latest.sh -CMAKE=$(find_cmake_latest) -. $DIR/check-symlink.sh -SRCROOT=$(pwd) - -SCRATCH_DIR=$(pwd)/.scratch -rm -rf "$SCRATCH_DIR" -mkdir -p "$SCRATCH_DIR" -cp -vr -- "$SRCROOT"/* "$SCRATCH_DIR" - -if [ "$BSON_ONLY" ]; then - BUILD_DIR=$SCRATCH_DIR/build-dir-bson - INSTALL_PREFIX=$SCRATCH_DIR/install-dir-bson -else - BUILD_DIR=$SCRATCH_DIR/build-dir-mongoc - INSTALL_PREFIX=$SCRATCH_DIR/install-dir-mongoc -fi - -if [ "$DESTDIR" ]; then - INSTALL_DIR="${DESTDIR}/${INSTALL_PREFIX}" -else - INSTALL_DIR=$INSTALL_PREFIX -fi - -rm -rf $BUILD_DIR -mkdir $BUILD_DIR - -rm -rf $INSTALL_DIR -mkdir -p $INSTALL_DIR - -cd $BUILD_DIR - -cp -r -- "$SRCROOT"/* "$SCRATCH_DIR" - -if [ "$BSON_ONLY" ]; then - BSON_ONLY_OPTION="-DENABLE_MONGOC=OFF" -else - BSON_ONLY_OPTION="-DENABLE_MONGOC=ON" -fi - -# Allow reuse of ccache compilation results between different build directories. -export CCACHE_BASEDIR CCACHE_NOHASHDIR -CCACHE_BASEDIR="$SCRATCH_DIR" -CCACHE_NOHASHDIR=1 - -$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $BSON_ONLY_OPTION "$SCRATCH_DIR" -$CMAKE --build . -if [ "$DESTDIR" ]; then - DESTDIR=$DESTDIR $CMAKE --build . --target install -else - $CMAKE --build . --target install -fi -touch $INSTALL_DIR/lib/canary.txt - -# no kms-message components should be installed -if test -f $INSTALL_DIR/include/kms_message/kms_message.h; then - echo "kms_message.h found!" - exit 1 -else - echo "kms_message.h check ok" -fi -if test -f $INSTALL_DIR/lib/libkms_message-static.a; then - echo "libkms_message-static.a found!" - exit 1 -else - echo "libkms_message-static.a check ok" -fi -if test -f $INSTALL_DIR/lib/cmake/kms_message/kms_message-config.cmake; then - echo "kms_message-config.cmake found!" - exit 1 -else - echo "kms_message-config.cmake check ok" -fi - -ls -l $INSTALL_DIR/share/mongo-c-driver - -$CMAKE --build . --target uninstall - -set +o xtrace - -if test -f $INSTALL_DIR/lib/pkgconfig/libbson-1.0.pc; then - echo "libbson-1.0.pc found!" - exit 1 -else - echo "libbson-1.0.pc check ok" -fi -if test -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-1.0-config.cmake; then - echo "bson-1.0-config.cmake found!" - exit 1 -else - echo "bson-1.0-config.cmake check ok" -fi -if test -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-1.0-config-version.cmake; then - echo "bson-1.0-config-version.cmake found!" - exit 1 -else - echo "bson-1.0-config-version.cmake check ok" -fi -if test -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-targets.cmake; then - echo "bson-targets.cmake found!" - exit 1 -else - echo "bson-targets.cmake check ok" -fi -if test ! -f $INSTALL_DIR/lib/canary.txt; then - echo "canary.txt not found!" - exit 1 -else - echo "canary.txt check ok" -fi -if test ! -d $INSTALL_DIR/lib; then - echo "$INSTALL_DIR/lib not found!" - exit 1 -else - echo "$INSTALL_DIR/lib check ok" -fi -if [ -z "$BSON_ONLY" ]; then - if test -f $INSTALL_DIR/lib/pkgconfig/libmongoc-1.0.pc; then - echo "libmongoc-1.0.pc found!" - exit 1 - else - echo "libmongoc-1.0.pc check ok" - fi - if test -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-1.0-config.cmake; then - echo "mongoc-1.0-config.cmake found!" - exit 1 - else - echo "mongoc-1.0-config.cmake check ok" - fi - if test -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-1.0-config-version.cmake; then - echo "mongoc-1.0-config-version.cmake found!" - exit 1 - else - echo "mongoc-1.0-config-version.cmake check ok" - fi - if test -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-targets.cmake; then - echo "mongoc-targets.cmake found!" - exit 1 - else - echo "mongoc-targets.cmake check ok" - fi -fi -if test -f $INSTALL_DIR/include/libbson-1.0/bson/bson.h; then - echo "bson/bson.h found!" - exit 1 -else - echo "bson/bson.h check ok" -fi -if test -f $INSTALL_DIR/include/libbson-1.0/bson.h; then - echo "bson.h found!" - exit 1 -else - echo "bson.h check ok" -fi -if test -d $INSTALL_DIR/include/libbson-1.0; then - echo "$INSTALL_DIR/include/libbson-1.0 found!" - exit 1 -else - echo "$INSTALL_DIR/include/libbson-1.0 check ok" -fi -if [ -z "$BSON_ONLY" ]; then - if test -f $INSTALL_DIR/include/libmongoc-1.0/mongoc/mongoc.h; then - echo "mongoc/mongoc.h found!" - exit 1 - else - echo "mongoc/mongoc.h check ok" - fi - if test -f $INSTALL_DIR/include/libmongoc-1.0/mongoc.h; then - echo "mongoc.h found!" - exit 1 - else - echo "mongoc.h check ok" - fi - if test -d $INSTALL_DIR/include/libmongoc-1.0; then - echo "$INSTALL_DIR/include/libmongoc-1.0 found!" - exit 1 - else - echo "$INSTALL_DIR/include/libmongoc-1.0 check ok" - fi -fi -if test -f $INSTALL_DIR/share/mongo-c-driver/uninstall-bson.sh; then - echo "uninstall-bson.sh found!" - exit 1 -else - echo "uninstall-bson.sh check ok" -fi -if test -f $INSTALL_DIR/share/mongo-c-driver/uninstall.sh; then - echo "uninstall.sh found!" - exit 1 -else - echo "uninstall.sh check ok" -fi -if test -d $INSTALL_DIR/share/mongo-c-driver; then - echo "$INSTALL_DIR/share/mongo-c-driver found!" - exit 1 -else - echo "$INSTALL_DIR/share/mongo-c-driver check ok" -fi diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/integration-tests.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/integration-tests.sh deleted file mode 100755 index 66f557548..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/integration-tests.sh +++ /dev/null @@ -1,201 +0,0 @@ -#! /bin/bash -# Start up mongo-orchestration (a server to spawn mongodb clusters) and set up a cluster. -# -# Specify the following environment variables: -# -# MONGODB_VERSION: latest, 4.2, 4.0, 3.6 -# TOPOLOGY: server, replica_set, sharded_cluster -# AUTH: auth, noauth -# AUTHSOURCE -# IPV4_ONLY: off, on -# SSL: openssl, darwinssl, winssl, nossl -# ORCHESTRATION_FILE: -# If this is not set, the file name is constructed from other options. -# OCSP: off, on -# REQUIRE_API_VERSION: set to a non-empty string to set the requireApiVersion parameter -# This is currently only supported for standalone servers -# LOAD_BALANCER: off, on -# -# This script may be run locally. -# - -set -o errexit # Exit the script with error if any of the commands fail - -: "${MONGODB_VERSION:="latest"}" -: "${LOAD_BALANCER:="off"}" - -DIR=$(dirname $0) -# mongoc/.evergreen/scripts -> drivers-evergreen-tools/.evergreen/download-mongodb.sh -. $DIR/../../../drivers-evergreen-tools/.evergreen/download-mongodb.sh - -get_distro -get_mongodb_download_url_for "$DISTRO" "$MONGODB_VERSION" -DRIVERS_TOOLS=./ download_and_extract "$MONGODB_DOWNLOAD_URL" "$EXTRACT" "$MONGOSH_DOWNLOAD_URL" "$EXTRACT_MONGOSH" - -OS=$(uname -s | tr '[:upper:]' '[:lower:]') - -AUTH=${AUTH:-noauth} -SSL=${SSL:-nossl} -TOPOLOGY=${TOPOLOGY:-server} -OCSP=${OCSP:-off} -REQUIRE_API_VERSION=${REQUIRE_API_VERSION} - -# If caller of script specifies an ORCHESTRATION_FILE, do not attempt to modify it. Otherwise construct it. -if [ -z "$ORCHESTRATION_FILE" ]; then - ORCHESTRATION_FILE="basic" - - if [ "$AUTH" = "auth" ]; then - ORCHESTRATION_FILE="auth" - fi - - if [ "$IPV4_ONLY" = "on" ]; then - ORCHESTRATION_FILE="${ORCHESTRATION_FILE}-ipv4-only" - fi - - if [ -n "$AUTHSOURCE" ]; then - ORCHESTRATION_FILE="${ORCHESTRATION_FILE}-${AUTHSOURCE}" - fi - - if [ "$SSL" != "nossl" ]; then - ORCHESTRATION_FILE="${ORCHESTRATION_FILE}-ssl" - fi - - if [ "$LOAD_BALANCER" = "on" ]; then - ORCHESTRATION_FILE="${ORCHESTRATION_FILE}-load-balancer" - fi -fi - -# Set up mongo orchestration home. -case "$OS" in - cygwin*) - export MONGO_ORCHESTRATION_HOME="c:/data/MO" - FULL_PATH=$(cygpath -m -a .) - ;; - *) - export MONGO_ORCHESTRATION_HOME=$(pwd)"/MO" - FULL_PATH=$(pwd) - ;; -esac -rm -rf "$MONGO_ORCHESTRATION_HOME" -mkdir -p "$MONGO_ORCHESTRATION_HOME/lib" -mkdir -p "$MONGO_ORCHESTRATION_HOME/db" - -# Replace ABSOLUTE_PATH_REPLACEMENT_TOKEN with path to mongo-c-driver. -find orchestration_configs -name \*.json | xargs perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|$FULL_PATH|g" - -# mongo-orchestration expects client.pem to be in MONGO_ORCHESTRATION_HOME. So always copy it. -cp -f src/libmongoc/tests/x509gen/* $MONGO_ORCHESTRATION_HOME/lib/ -# find print0 and xargs -0 not available on Solaris. Lets hope for good paths -find orchestration_configs -name \*.json | xargs perl -p -i -e "s|/tmp/orchestration-home|$MONGO_ORCHESTRATION_HOME/lib|g" - -export ORCHESTRATION_FILE="orchestration_configs/${TOPOLOGY}s/${ORCHESTRATION_FILE}.json" -export ORCHESTRATION_URL="http://localhost:8889/v1/${TOPOLOGY}s" - -export TMPDIR=$MONGO_ORCHESTRATION_HOME/db -echo From shell `date` > $MONGO_ORCHESTRATION_HOME/server.log - -command -V "${PYTHON3_BINARY:?}" >/dev/null - -# shellcheck source=/dev/null -. ../drivers-evergreen-tools/.evergreen/venv-utils.sh - -case "$OS" in - cygwin*) - # Python has problems with unix style paths in cygwin. Must use c:\\ paths - rm -rf /cygdrive/c/mongodb - cp -r mongodb /cygdrive/c/mongodb - echo "{ \"releases\": { \"default\": \"c:\\\\mongodb\\\\bin\" }}" > orchestration.config - - # Make sure MO is running latest version - venvcreate "${PYTHON3_BINARY}" venv - cd venv - rm -rf mongo-orchestration - git clone --depth 1 git@github.com:10gen/mongo-orchestration.git - cd mongo-orchestration - python -m pip install . - cd ../.. - nohup mongo-orchestration -f orchestration.config -e default --socket-timeout-ms=60000 --bind=127.0.0.1 --enable-majority-read-concern -s wsgiref start > $MONGO_ORCHESTRATION_HOME/out.log 2> $MONGO_ORCHESTRATION_HOME/err.log < /dev/null & - ;; - *) - echo "{ \"releases\": { \"default\": \"`pwd`/mongodb/bin\" } }" > orchestration.config - - venvcreate "${PYTHON3_BINARY}" venv - cd venv - rm -rf mongo-orchestration - # Make sure MO is running latest version - git clone --depth 1 git@github.com:10gen/mongo-orchestration.git - cd mongo-orchestration - # Our zSeries machines are static-provisioned, cache corruptions persist. - if [ $(uname -m) = "s390x" ]; then - echo "Disabling pip cache" - PIP_PARAM="--no-cache-dir" - fi - python -m pip $PIP_PARAM install . - cd ../.. - mongo-orchestration -f orchestration.config -e default --socket-timeout-ms=60000 --bind=127.0.0.1 --enable-majority-read-concern start > $MONGO_ORCHESTRATION_HOME/out.log 2> $MONGO_ORCHESTRATION_HOME/err.log < /dev/null & - ;; -esac - -echo "Waiting for mongo-orchestration to start..." -wait_for_mongo_orchestration() { - for i in $(seq 300); do - # Exit code 7: "Failed to connect to host". - if curl -s "localhost:$1" 1>|curl_mo.txt; test $? -ne 7; then - return 0 - else - sleep 1 - fi - done - echo "Could not detect mongo-orchestration on port $1" - return 1 -} -wait_for_mongo_orchestration 8889 -echo "Waiting for mongo-orchestration to start... done." - -python -m json.tool curl_mo.txt -sleep 5 -pwd -curl -s --data @"$ORCHESTRATION_FILE" "$ORCHESTRATION_URL" 1>|curl_mo.txt -python -m json.tool curl_mo.txt -sleep 15 - -if [ "$AUTH" = "auth" ]; then - MONGO_SHELL_CONNECTION_FLAGS="--username bob --password pwd123" -fi - -if [ -n "$AUTHSOURCE" ]; then - MONGO_SHELL_CONNECTION_FLAGS="${MONGO_SHELL_CONNECTION_FLAGS} --authenticationDatabase ${AUTHSOURCE}" -fi - -if [ "$OCSP" != "off" ]; then - MONGO_SHELL_CONNECTION_FLAGS="${MONGO_SHELL_CONNECTION_FLAGS} --host localhost --tls --tlsAllowInvalidCertificates" -elif [ "$SSL" != "nossl" ]; then - MONGO_SHELL_CONNECTION_FLAGS="${MONGO_SHELL_CONNECTION_FLAGS} --host localhost --ssl --sslCAFile=$MONGO_ORCHESTRATION_HOME/lib/ca.pem --sslPEMKeyFile=$MONGO_ORCHESTRATION_HOME/lib/client.pem" -fi - -if [ ! -z "$REQUIRE_API_VERSION" ]; then - MONGO_SHELL_CONNECTION_FLAGS="${MONGO_SHELL_CONNECTION_FLAGS} --apiVersion=1" - # Set the requireApiVersion parameter. - ./mongodb/bin/mongosh $MONGO_SHELL_CONNECTION_FLAGS $DIR/../etc/require-api-version.js -fi - -echo $MONGO_SHELL_CONNECTION_FLAGS - -# Create mo-expansion.yml. expansions.update expects the file to exist. -touch mo-expansion.yml - -if [ -z "$MONGO_CRYPT_SHARED_DOWNLOAD_URL" ]; then - echo "There is no crypt_shared library for distro='$DISTRO' and version='$MONGODB_VERSION'". -else - echo "Downloading crypt_shared package from $MONGO_CRYPT_SHARED_DOWNLOAD_URL" - download_and_extract_crypt_shared "$MONGO_CRYPT_SHARED_DOWNLOAD_URL" "$EXTRACT" "CRYPT_SHARED_LIB_PATH" - echo "CRYPT_SHARED_LIB_PATH: $CRYPT_SHARED_LIB_PATH" - if [ -z "$CRYPT_SHARED_LIB_PATH" ]; then - echo "CRYPT_SHARED_LIB_PATH must be assigned, but wasn't" 1>&2 # write to stderr" - exit 1 - fi -cat >>mo-expansion.yml < libbson-1.0.so.0 -# libbson-1.0.so.0 -> libbson-1.0.so.0.0.0 -# libbson-1.0.so.0.0.0 -if [ "$OS" != "darwin" ]; then - # From check-symlink.sh - check_symlink libbson-1.0.so libbson-1.0.so.0 - check_symlink libbson-1.0.so.0 libbson-1.0.so.0.0.0 - SONAME=$(objdump -p $INSTALL_DIR/lib/$LIB_SO|grep SONAME|awk '{print $2}') - EXPECTED_SONAME="libbson-1.0.so.0" - if [ "$SONAME" != "$EXPECTED_SONAME" ]; then - echo "SONAME should be $EXPECTED_SONAME, not $SONAME" - exit 1 - else - echo "library name check ok, SONAME=$SONAME" - fi -else - # Just test that the shared lib was installed. - if test ! -f $INSTALL_DIR/lib/$LIB_SO; then - echo "$LIB_SO missing!" - exit 1 - else - echo "$LIB_SO check ok" - fi -fi - -if test ! -f $INSTALL_DIR/lib/pkgconfig/libbson-1.0.pc; then - echo "libbson-1.0.pc missing!" - exit 1 -else - echo "libbson-1.0.pc check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-1.0-config.cmake; then - echo "bson-1.0-config.cmake missing!" - exit 1 -else - echo "bson-1.0-config.cmake check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-1.0-config-version.cmake; then - echo "bson-1.0-config-version.cmake missing!" - exit 1 -else - echo "bson-1.0-config-version.cmake check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-targets.cmake; then - echo "bson-targets.cmake missing!" - exit 1 -else - echo "bson-targets.cmake check ok" -fi - -if [ "$LINK_STATIC" ]; then - if test ! -f $INSTALL_DIR/lib/libbson-static-1.0.a; then - echo "libbson-static-1.0.a missing!" - exit 1 - else - echo "libbson-static-1.0.a check ok" - fi - if test ! -f $INSTALL_DIR/lib/pkgconfig/libbson-static-1.0.pc; then - echo "libbson-static-1.0.pc missing!" - exit 1 - else - echo "libbson-static-1.0.pc check ok" - fi -fi - -cd $SRCROOT - -if [ "$BUILD_SAMPLE_WITH_CMAKE" ]; then - # Test our CMake package config file with CMake's find_package command. - if [ "$BUILD_SAMPLE_WITH_CMAKE_DEPRECATED" ]; then - EXAMPLE_DIR=$SRCROOT/src/libbson/examples/cmake-deprecated/find_package - else - EXAMPLE_DIR=$SRCROOT/src/libbson/examples/cmake/find_package - fi - - if [ "$LINK_STATIC" ]; then - EXAMPLE_DIR="${EXAMPLE_DIR}_static" - fi - - cd $EXAMPLE_DIR - $CMAKE -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake . - $CMAKE --build . --parallel -else - # Test our pkg-config file. - export PKG_CONFIG_PATH=$INSTALL_DIR/lib/pkgconfig - cd $SRCROOT/src/libbson/examples - - if [ "$LINK_STATIC" ]; then - echo "pkg-config output:" - echo $(pkg-config --libs --cflags libbson-static-1.0) - sh compile-with-pkg-config-static.sh - else - echo "pkg-config output:" - echo $(pkg-config --libs --cflags libbson-1.0) - sh compile-with-pkg-config.sh - fi -fi - -if [ ! "$LINK_STATIC" ]; then - if [ "$OS" = "darwin" ]; then - export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib - else - export LD_LIBRARY_PATH=$INSTALL_DIR/lib - fi -fi - -echo "ldd hello_bson:" -$LDD hello_bson - -./hello_bson diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-mingw-bson.cmd b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-mingw-bson.cmd deleted file mode 100644 index 3a0f0c74e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-mingw-bson.cmd +++ /dev/null @@ -1,76 +0,0 @@ -echo on -echo - -set TAR=C:\cygwin\bin\tar -set CMAKE_MAKE_PROGRAM=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\mingw32-make.exe -set CC=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\gcc.exe -rem Ensure Cygwin executables like sh.exe are not in PATH -set "PATH=C:\cygwin\bin;C:\Windows\system32;C:\Windows;C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin;C:\mongoc;src\libbson;src\libmongoc;C:\Program Files\Git\cmd" -set LINK_STATIC=1 - -set SRCROOT=%CD% -set BUILD_DIR=%CD%\build-dir -rmdir /S /Q %BUILD_DIR% -mkdir %BUILD_DIR% - -set INSTALL_DIR=%CD%\install-dir -rmdir /S /Q %INSTALL_DIR% -mkdir %INSTALL_DIR% - -set PATH=%PATH%;%INSTALL_DIR%\bin - -cd %BUILD_DIR% -robocopy "%SRCROOT%" "%BUILD_DIR%" /E /XD ".git" "%BUILD_DIR%" "_build" "cmake-build" /NP /NFL /NDL - -rem Build libmongoc, with flags that the downstream R driver mongolite uses -%CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_CFLAGS="-pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake -DENABLE_STATIC=ON . -%CMAKE% --build . --parallel -if errorlevel 1 ( - exit /B 1 -) - -%CMAKE% --build . --target install -if errorlevel 1 ( - exit /B 1 -) - -set MINGW=1 -call ..\.evergreen\scripts\check-installed-files-bson.bat -if errorlevel 1 ( - exit /B 1 -) -set MINGW= - -if not exist %INSTALL_DIR%\lib\libbson-static-1.0.a ( - echo libbson-static-1.0.a missing! - exit /B 1 -) else ( - echo libbson-static-1.0.a check ok -) - -cd %SRCROOT% - -rem Test our pkg-config file -set EXAMPLE_DIR=%SRCROOT%\src\libbson\examples\ -cd %EXAMPLE_DIR% - -rem Proceed from here once we have pkg-config on Windows -exit /B 0 - -set PKG_CONFIG_PATH=%INSTALL_DIR%\lib\pkgconfig - -rem http://stackoverflow.com/questions/2323292 -for /f %%i in ('pkg-config --libs --cflags libbson-1.0') do set PKG_CONFIG_OUT=%%i - -echo PKG_CONFIG_OUT is %PKG_CONFIG_OUT% - -%CC% -o hello_bson hello_bson.c %PKG_CONFIG_OUT% - -rem Works on windows-64-vs2013-compile, VS 2013 is a.k.a. "Visual Studio 12" -rem And yes, they should've named the flag "dependencies". -"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\dumpbin.exe" /dependents Debug\hello_bson.exe - -rem Add DLLs to PATH -set PATH=%PATH%;%INSTALL_DIR%\bin - -Debug\hello_bson.exe %MONGODB_EXAMPLE_URI% diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-mingw.cmd b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-mingw.cmd deleted file mode 100644 index 2422dfc0f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-mingw.cmd +++ /dev/null @@ -1,76 +0,0 @@ -echo on -echo - -set CMAKE_FLAGS=-DENABLE_SSL=OPENSSL -DENABLE_SASL=CYRUS -set TAR=C:\cygwin\bin\tar -set CMAKE_MAKE_PROGRAM=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\mingw32-make.exe -set CC=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\gcc.exe -rem Ensure Cygwin executables like sh.exe are not in PATH -set "PATH=C:\cygwin\bin;C:\Windows\system32;C:\Windows;C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin;C:\mongoc;src\libbson;src\libmongoc;C:\Program Files\Git\cmd" - -set SRCROOT=%CD% -set BUILD_DIR=%CD%\build-dir -rmdir /S /Q %BUILD_DIR% -mkdir %BUILD_DIR% - -set INSTALL_DIR=%CD%\install-dir -rmdir /S /Q %INSTALL_DIR% -mkdir %INSTALL_DIR% - -set PATH=%PATH%;%INSTALL_DIR%\bin - -cd %BUILD_DIR% -robocopy "%SRCROOT%" "%BUILD_DIR%" /E /XD ".git" "%BUILD_DIR%" "_build" "cmake-build" /NP /NFL /NDL - -rem Build libmongoc, with flags that the downstream R driver mongolite uses -%CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_CFLAGS="-pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake %CMAKE_FLAGS% . -%CMAKE% --build . --parallel -if errorlevel 1 ( - exit /B 1 -) - -%CMAKE% --build . --target install -if errorlevel 1 ( - exit /B 1 -) - -set MINGW=1 -call ..\.evergreen\scripts\check-installed-files.bat -if errorlevel 1 ( - exit /B 1 -) -set MINGW= - -if not exist %INSTALL_DIR%\lib\libmongoc-static-1.0.a ( - echo libmongoc-static-1.0.a missing! - exit /B 1 -) else ( - echo libmongoc-static-1.0.a check ok -) - -cd %SRCROOT% - -rem Test our pkg-config file -set EXAMPLE_DIR=%SRCROOT%\src\libmongoc\examples\ -cd %EXAMPLE_DIR% - -rem Proceed from here once we have pkg-config on Windows -exit /B 0 - -set PKG_CONFIG_PATH=%INSTALL_DIR%\lib\pkgconfig - -rem http://stackoverflow.com/questions/2323292 -for /f %%i in ('pkg-config --libs --cflags libmongoc-1.0') do set PKG_CONFIG_OUT=%%i - -echo PKG_CONFIG_OUT is %PKG_CONFIG_OUT% - -%CC% -o hello_mongoc hello_mongoc.c %PKG_CONFIG_OUT% - -rem Works on windows-64-vs2013-compile, VS 2013 is a.k.a. "Visual Studio 12" -rem And yes, they should've named the flag "dependencies". -"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\dumpbin.exe" /dependents Debug\hello_mongoc.exe - -rem Add DLLs to PATH -set PATH=%PATH%;%INSTALL_DIR%\bin - -Debug\hello_mongoc.exe %MONGODB_EXAMPLE_URI% diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-msvc-bson.cmd b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-msvc-bson.cmd deleted file mode 100644 index bbd022291..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-msvc-bson.cmd +++ /dev/null @@ -1,56 +0,0 @@ -REM Supported/used environment variables: -REM LINK_STATIC Whether to statically link to libbson - -rem Ensure Cygwin executables like sh.exe are not in PATH -rem set PATH=C:\Windows\system32;C:\Windows - -echo on -echo - -set TAR=C:\cygwin\bin\tar - -set SRCROOT=%CD% -set BUILD_DIR=%CD%\build-dir -rmdir /S /Q %BUILD_DIR% -mkdir %BUILD_DIR% - -set INSTALL_DIR=%CD%\install-dir -rmdir /S /Q %INSTALL_DIR% -mkdir %INSTALL_DIR% - -set PATH=%PATH%;%INSTALL_DIR%\bin -rem Set path to dumpbin.exe and other VS tools. -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat" - -cd %BUILD_DIR% -robocopy "%SRCROOT%" "%BUILD_DIR%" /E /XD ".git" "%BUILD_DIR%" "_build" "cmake-build" /NP /NFL /NDL - -if "%LINK_STATIC%"=="1" ( - %CMAKE% -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DENABLE_TESTS=OFF . -) else ( - %CMAKE% -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DENABLE_TESTS=OFF -DENABLE_STATIC=OFF . -) - -%CMAKE% --build . --target ALL_BUILD --config "Debug" -- /m -%CMAKE% --build . --target INSTALL --config "Debug" -- /m - -call ..\.evergreen\scripts\check-installed-files-bson.bat -if errorlevel 1 ( - exit /B %errorlevel% -) - -rem Test our CMake package config file with CMake's find_package command. -set EXAMPLE_DIR=%SRCROOT%\src\libbson\examples\cmake\find_package - -if "%LINK_STATIC%"=="1" ( - set EXAMPLE_DIR="%EXAMPLE_DIR%_static" -) - -cd %EXAMPLE_DIR% -%CMAKE% -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake . -%CMAKE% --build . --target ALL_BUILD --config "Debug" -- /m - -rem Yes, they should've named it "dependencies". -dumpbin.exe /dependents Debug\hello_bson.exe - -Debug\hello_bson.exe diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-msvc.cmd b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-msvc.cmd deleted file mode 100644 index 4b1d7a57d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program-msvc.cmd +++ /dev/null @@ -1,99 +0,0 @@ -REM Supported/used environment variables: -REM LINK_STATIC Whether to statically link to libmongoc -REM ENABLE_SSL Enable SSL with Microsoft Secure Channel -REM ENABLE_SNAPPY Enable Snappy compression - -rem Ensure Cygwin executables like sh.exe are not in PATH -rem set PATH=C:\Windows\system32;C:\Windows - -echo on -echo - -set TAR=C:\cygwin\bin\tar - -set SRCROOT=%CD% -set BUILD_DIR=%CD%\build-dir -rmdir /S /Q %BUILD_DIR% -mkdir %BUILD_DIR% - -set INSTALL_DIR=%CD%\install-dir -rmdir /S /Q %INSTALL_DIR% -mkdir %INSTALL_DIR% - -set PATH=%PATH%;%INSTALL_DIR%\bin - -rem Set path to dumpbin.exe and other VS tools. -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" - -cd %BUILD_DIR% -robocopy "%SRCROOT%" "%BUILD_DIR%" /E /XD ".git" "%BUILD_DIR%" "_build" "cmake-build" /NP /NFL /NDL - -if "%ENABLE_SNAPPY%"=="1" ( - rem Enable Snappy - curl -sS --retry 5 -LO https://github.com/google/snappy/archive/1.1.7.tar.gz - %TAR% xzf 1.1.7.tar.gz - cd snappy-1.1.7 - %CMAKE% -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% . - %CMAKE% --build . --target ALL_BUILD --config "Debug" -- /m - %CMAKE% --build . --target INSTALL --config "Debug" -- /m - set SNAPPY_OPTION=-DENABLE_SNAPPY=ON -) else ( - set SNAPPY_OPTION=-DENABLE_SNAPPY=OFF -) - -cd %BUILD_DIR% -rem Build libmongoc -if "%ENABLE_SSL%"=="1" ( - %CMAKE% -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DENABLE_SSL=WINDOWS %ENABLE_SNAPPY_OPTION% . -) else ( - %CMAKE% -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DENABLE_SSL=OFF %ENABLE_SNAPPY_OPTION% . -) - -%CMAKE% --build . --target ALL_BUILD --config "Debug" -- /m -%CMAKE% --build . --target INSTALL --config "Debug" -- /m - -call ..\.evergreen\scripts\check-installed-files.bat -if errorlevel 1 ( - exit /B %errorlevel% -) - -rem Shim library around the DLL. -set SHIM=%INSTALL_DIR%\lib\mongoc-1.0.lib -if not exist %SHIM% ( - echo %SHIM% is missing! - exit /B 1 -) else ( - echo %SHIM% check ok -) - -if not exist %INSTALL_DIR%\lib\mongoc-static-1.0.lib ( - echo mongoc-static-1.0.lib missing! - exit /B 1 -) else ( - echo mongoc-static-1.0.lib check ok -) - -cd %SRCROOT% - -rem Test our CMake package config file with CMake's find_package command. -set EXAMPLE_DIR=%SRCROOT%\src\libmongoc\examples\cmake\find_package - -if "%LINK_STATIC%"=="1" ( - set EXAMPLE_DIR="%EXAMPLE_DIR%_static" -) - -cd %EXAMPLE_DIR% - -if "%ENABLE_SSL%"=="1" ( - cp ..\..\..\tests\x509gen\client.pem . - cp ..\..\..\tests\x509gen\ca.pem . - set MONGODB_EXAMPLE_URI="mongodb://localhost/?ssl=true&sslclientcertificatekeyfile=client.pem&sslcertificateauthorityfile=ca.pem&sslallowinvalidhostnames=true" -) - -%CMAKE% -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake . -%CMAKE% --build . --target ALL_BUILD --config "Debug" -- /m - -rem Yes, they should've named it "dependencies". -dumpbin.exe /dependents Debug\hello_mongoc.exe - -Debug\hello_mongoc.exe %MONGODB_EXAMPLE_URI% diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program.sh deleted file mode 100644 index bfed0982e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/link-sample-program.sh +++ /dev/null @@ -1,228 +0,0 @@ -#!/usr/bin/env bash -set -o errexit # Exit the script with error if any of the commands fail - -# Supported/used environment variables: -# LINK_STATIC Whether to statically link to libmongoc -# BUILD_SAMPLE_WITH_CMAKE Link program w/ CMake. Default: use pkg-config. -# BUILD_SAMPLE_WITH_CMAKE_DEPRECATED If BUILD_SAMPLE_WITH_CMAKE is set, then use deprecated CMake scripts instead. -# ENABLE_SSL Set -DENABLE_SSL -# ENABLE_SNAPPY Set -DENABLE_SNAPPY -# CMAKE Path to cmake executable. - - -echo "LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=$BUILD_SAMPLE_WITH_CMAKE_DEPRECATED" - -DIR=$(dirname $0) -. $DIR/find-cmake-latest.sh -CMAKE=$(find_cmake_latest) -. $DIR/check-symlink.sh - -# Get the kernel name, lowercased -OS=$(uname -s | tr '[:upper:]' '[:lower:]') -echo "OS: $OS" - -if [ "$OS" = "darwin" ]; then - SO=dylib - LIB_SO=libmongoc-1.0.0.dylib - LDD="otool -L" -else - SO=so - LIB_SO=libmongoc-1.0.so.0 - LDD=ldd -fi - -SRCROOT=`pwd` -SCRATCH_DIR=$(pwd)/.scratch -rm -rf "$SCRATCH_DIR" -mkdir -p "$SCRATCH_DIR" -cp -r -- "$SRCROOT"/* "$SCRATCH_DIR" - -BUILD_DIR=$SCRATCH_DIR/build-dir -rm -rf $BUILD_DIR -mkdir $BUILD_DIR - -INSTALL_DIR=$SCRATCH_DIR/install-dir -rm -rf $INSTALL_DIR -mkdir -p $INSTALL_DIR - -cd $BUILD_DIR - -if [ "$ENABLE_SNAPPY" ]; then - SNAPPY_CMAKE_OPTION="-DENABLE_SNAPPY=ON" -else - SNAPPY_CMAKE_OPTION="-DENABLE_SNAPPY=OFF" -fi - -if [ "$ENABLE_SSL" ]; then - if [ "$OS" = "darwin" ]; then - SSL_CMAKE_OPTION="-DENABLE_SSL:BOOL=DARWIN" - else - SSL_CMAKE_OPTION="-DENABLE_SSL:BOOL=OPENSSL" - fi -else - SSL_CMAKE_OPTION="-DENABLE_SSL:BOOL=OFF" -fi - - -if [ "$LINK_STATIC" ]; then - STATIC_CMAKE_OPTION="-DENABLE_STATIC=ON -DENABLE_TESTS=ON" -else - STATIC_CMAKE_OPTION="-DENABLE_STATIC=OFF -DENABLE_TESTS=OFF" -fi - -ZSTD="AUTO" - -# Allow reuse of ccache compilation results between different build directories. -export CCACHE_BASEDIR CCACHE_NOHASHDIR -CCACHE_BASEDIR="$SCRATCH_DIR" -CCACHE_NOHASHDIR=1 - -$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $SSL_CMAKE_OPTION $SNAPPY_CMAKE_OPTION $STATIC_CMAKE_OPTION -DENABLE_ZSTD=$ZSTD "$SCRATCH_DIR" -$CMAKE --build . --parallel -$CMAKE --build . --parallel --target install - -# Revert ccache options, they no longer apply. -unset CCACHE_BASEDIR CCACHE_NOHASHDIR - -ls -l $INSTALL_DIR/lib - -set +o xtrace - -# Check on Linux that libmongoc is installed into lib/ like: -# libmongoc-1.0.so -> libmongoc-1.0.so.0 -# libmongoc-1.0.so.0 -> libmongoc-1.0.so.0.0.0 -# libmongoc-1.0.so.0.0.0 -if [ "$OS" != "darwin" ]; then - # From check-symlink.sh - check_symlink libmongoc-1.0.so libmongoc-1.0.so.0 - check_symlink libmongoc-1.0.so.0 libmongoc-1.0.so.0.0.0 - SONAME=$(objdump -p $INSTALL_DIR/lib/$LIB_SO|grep SONAME|awk '{print $2}') - EXPECTED_SONAME="libmongoc-1.0.so.0" - if [ "$SONAME" != "$EXPECTED_SONAME" ]; then - echo "SONAME should be $EXPECTED_SONAME, not $SONAME" - exit 1 - else - echo "library name check ok, SONAME=$SONAME" - fi -else - # Just test that the shared lib was installed. - if test ! -f $INSTALL_DIR/lib/$LIB_SO; then - echo "$LIB_SO missing!" - exit 1 - else - echo "$LIB_SO check ok" - fi -fi - - -if test ! -f $INSTALL_DIR/lib/pkgconfig/libmongoc-1.0.pc; then - echo "libmongoc-1.0.pc missing!" - exit 1 -else - echo "libmongoc-1.0.pc check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-1.0-config.cmake; then - echo "mongoc-1.0-config.cmake missing!" - exit 1 -else - echo "mongoc-1.0-config.cmake check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-1.0-config-version.cmake; then - echo "mongoc-1.0-config-version.cmake missing!" - exit 1 -else - echo "mongoc-1.0-config-version.cmake check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-targets.cmake; then - echo "mongoc-targets.cmake missing!" - exit 1 -else - echo "mongoc-targets.cmake check ok" -fi - - -if [ "$LINK_STATIC" ]; then - if test ! -f $INSTALL_DIR/lib/libmongoc-static-1.0.a; then - echo "libmongoc-static-1.0.a missing!" - exit 1 - else - echo "libmongoc-static-1.0.a check ok" - fi - if test ! -f $INSTALL_DIR/lib/pkgconfig/libmongoc-static-1.0.pc; then - echo "libmongoc-static-1.0.pc missing!" - exit 1 - else - echo "libmongoc-static-1.0.pc check ok" - fi -else - if test -f $INSTALL_DIR/lib/libmongoc-static-1.0.a; then - echo "libmongoc-static-1.0.a shouldn't have been installed" - exit 1 - fi - if test -f $INSTALL_DIR/lib/libmongoc-1.0.a; then - echo "libmongoc-1.0.a shouldn't have been installed" - exit 1 - fi - if test -f $INSTALL_DIR/lib/pkgconfig/libmongoc-static-1.0.pc; then - echo "libmongoc-static-1.0.pc shouldn't have been installed" - exit 1 - fi -fi - -if [ "$OS" = "darwin" ]; then - if test -f $INSTALL_DIR/bin/mongoc-stat; then - echo "mongoc-stat shouldn't have been installed" - exit 1 - fi -else - if test ! -f $INSTALL_DIR/bin/mongoc-stat; then - echo "mongoc-stat missing!" - exit 1 - else - echo "mongoc-stat check ok" - fi -fi - -if [ "$BUILD_SAMPLE_WITH_CMAKE" ]; then - # Test our CMake package config file with CMake's find_package command. - if [ "$BUILD_SAMPLE_WITH_CMAKE_DEPRECATED" ]; then - EXAMPLE_DIR=$SRCROOT/src/libmongoc/examples/cmake-deprecated/find_package - else - EXAMPLE_DIR=$SRCROOT/src/libmongoc/examples/cmake/find_package - fi - - if [ "$LINK_STATIC" ]; then - EXAMPLE_DIR="${EXAMPLE_DIR}_static" - fi - - cd $EXAMPLE_DIR - $CMAKE -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake . - $CMAKE --build . -else - # Test our pkg-config file. - export PKG_CONFIG_PATH=$INSTALL_DIR/lib/pkgconfig - cd $SRCROOT/src/libmongoc/examples - - if [ "$LINK_STATIC" ]; then - echo "pkg-config output:" - echo $(pkg-config --libs --cflags libmongoc-static-1.0) - sh compile-with-pkg-config-static.sh - else - echo "pkg-config output:" - echo $(pkg-config --libs --cflags libmongoc-1.0) - sh compile-with-pkg-config.sh - fi -fi - -if [ ! "$LINK_STATIC" ]; then - if [ "$OS" = "darwin" ]; then - export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib - else - export LD_LIBRARY_PATH=$INSTALL_DIR/lib - fi -fi - -echo "ldd hello_mongoc:" -$LDD hello_mongoc - -./hello_mongoc diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/llvm-gcov.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/llvm-gcov.sh deleted file mode 100755 index 4e320d8c2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/llvm-gcov.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -exec llvm-cov gcov "$@" diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-auth-tests.sh b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-auth-tests.sh deleted file mode 100644 index 8196591fe..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-auth-tests.sh +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o pipefail - -set +o xtrace # Don't echo commands - -# shellcheck source=.evergreen/scripts/env-var-utils.sh -. "$(dirname "${BASH_SOURCE[0]}")/env-var-utils.sh" -. "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" paths - -declare script_dir -script_dir="$(to_absolute "$(dirname "${BASH_SOURCE[0]}")")" - -declare mongoc_dir -mongoc_dir="$(to_absolute "${script_dir}/../..")" - -declare install_dir="${mongoc_dir}/install-dir" -declare openssl_install_dir="${mongoc_dir}/openssl-install-dir" - -declare c_timeout="connectTimeoutMS=30000&serverSelectionTryOnce=false" - -declare sasl="OFF" -if grep -q "#define MONGOC_ENABLE_SASL 1" src/libmongoc/src/mongoc/mongoc-config.h; then - sasl="ON" -fi - -declare ssl="OFF" -if grep -q "#define MONGOC_ENABLE_SSL 1" src/libmongoc/src/mongoc/mongoc-config.h; then - ssl="ON" -fi - -# shellcheck source=.evergreen/scripts/add-build-dirs-to-paths.sh -. "${script_dir}/add-build-dirs-to-paths.sh" - -# shellcheck source=.evergreen/scripts/bypass-dlclose.sh -. "${script_dir}/bypass-dlclose.sh" - -declare ping -declare test_gssapi -declare ip_addr -case "${OSTYPE}" in -cygwin) - ping="./src/libmongoc/Debug/mongoc-ping.exe" - test_gssapi="./src/libmongoc/Debug/test-mongoc-gssapi.exe" - ip_addr="$(getent hosts "${auth_host:?}" | head -n 1 | awk '{print $1}')" - ;; - -darwin*) - ping="./src/libmongoc/mongoc-ping" - test_gssapi="./src/libmongoc/test-mongoc-gssapi" - ip_addr="$(dig "${auth_host:?}" +short | tail -1)" - ;; - -*) - ping="./src/libmongoc/mongoc-ping" - test_gssapi="./src/libmongoc/test-mongoc-gssapi" - ip_addr="$(getent hosts "${auth_host:?}" | head -n 1 | awk '{print $1}')" - ;; -esac -: "${ping:?}" -: "${test_gssapi:?}" -: "${ip_addr:?}" - -if command -v kinit >/dev/null && [[ -f /tmp/drivers.keytab ]]; then - kinit -k -t /tmp/drivers.keytab -p drivers@LDAPTEST.10GEN.CC || true -fi - -# Archlinux (which we use for testing various self-installed OpenSSL versions) -# stores their trust list under /etc/ca-certificates/extracted/. -# We need to copy it to our custom installed OpenSSL/LibreSSL trust store. -declare pem_file="/etc/ca-certificates/extracted/tls-ca-bundle.pem" -if [[ -f "${pem_file}" ]]; then - [[ ! -d "${install_dir}" ]] || cp -v "${pem_file}" "${install_dir}/cert.pem" - [[ ! -d "${install_dir}/ssl" ]] || cp -v "${pem_file}" "${install_dir}/ssl/cert.pem" - [[ ! -d "${openssl_install_dir}" ]] || cp -v "${pem_file}" "${openssl_install_dir}/cert.pem" - [[ ! -d "${openssl_install_dir}/ssl" ]] || cp -v "${pem_file}" "${openssl_install_dir}/ssl/cert.pem" -fi - -# Custom OpenSSL library may be installed. Only prepend to LD_LIBRARY_PATH when -# necessary to avoid conflicting with system binary requirements. -declare openssl_lib_prefix="${LD_LIBRARY_PATH:-}" -if [[ -d "${openssl_install_dir}" ]]; then - openssl_lib_prefix="${openssl_install_dir}/lib:${openssl_lib_prefix:-}" -fi - -# There may be additional certs required by auth tests. Direct OpenSSL to use -# the system cert directory if available. -[[ ! -d /etc/ssl/certs ]] || export SSL_CERT_DIR=/etc/ssl/certs - -ulimit -c unlimited || true - -if command -v ldd >/dev/null; then - LD_LIBRARY_PATH="${openssl_lib_prefix}" ldd "${ping}" | grep "libssl" || true - LD_LIBRARY_PATH="${openssl_lib_prefix}" ldd "${test_gssapi}" | grep "libssl" || true -elif command -v otool >/dev/null; then - # Try using otool on MacOS if ldd is not available. - LD_LIBRARY_PATH="${openssl_lib_prefix}" otool -L "${ping}" | grep "libssl" || true - LD_LIBRARY_PATH="${openssl_lib_prefix}" otool -L "${test_gssapi}" | grep "libssl" || true -fi - -if [[ "${ssl}" != "OFF" ]]; then - # FIXME: CDRIVER-2008 for the cygwin check - if [[ "${OSTYPE}" != "cygwin" ]]; then - echo "Authenticating using X.509" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "mongodb://CN=client,OU=kerneluser,O=10Gen,L=New York City,ST=New York,C=US@${auth_host}/?ssl=true&authMechanism=MONGODB-X509&sslClientCertificateKeyFile=src/libmongoc/tests/x509gen/ldaptest-client-key-and-cert.pem&sslCertificateAuthorityFile=src/libmongoc/tests/x509gen/ldaptest-ca-cert.crt&sslAllowInvalidHostnames=true&${c_timeout}" - fi - - echo "Connecting to Atlas Free Tier" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_free:?}&${c_timeout}" - echo "Connecting to Atlas Free Tier with SRV" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_free_srv:?}&${c_timeout}" - echo "Connecting to Atlas Replica Set" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_replset:?}&${c_timeout}" - echo "Connecting to Atlas Replica Set with SRV" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_replset_srv:?}${c_timeout}" - echo "Connecting to Atlas Sharded Cluster" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_shard:?}&${c_timeout}" - echo "Connecting to Atlas Sharded Cluster with SRV" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_shard_srv:?}${c_timeout}" - if [[ -z "${require_tls12:-}" ]]; then - echo "Connecting to Atlas with only TLS 1.1 enabled" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_tls11:?}&${c_timeout}" - echo "Connecting to Atlas with only TLS 1.1 enabled with SRV" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_tls11_srv:?}${c_timeout}" - fi - echo "Connecting to Atlas with only TLS 1.2 enabled" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_tls12:?}&${c_timeout}" - echo "Connecting to Atlas with only TLS 1.2 enabled with SRV" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_tls12_srv:?}${c_timeout}" - echo "Connecting to Atlas Serverless with SRV" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_serverless_srv:?}/?${c_timeout}" - echo "Connecting to Atlas Serverless" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_serverless:?}&${c_timeout}" -fi - -echo "Authenticating using PLAIN" -LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "mongodb://${auth_plain:?}@${auth_host}/?authMechanism=PLAIN&${c_timeout}" - -echo "Authenticating using default auth mechanism" -LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "mongodb://${auth_mongodbcr:?}@${auth_host}/mongodb-cr?${c_timeout}" - -if [[ "${sasl}" != "OFF" ]]; then - echo "Authenticating using GSSAPI" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "mongodb://${auth_gssapi:?}@${auth_host}/?authMechanism=GSSAPI&${c_timeout}" - - echo "Authenticating with CANONICALIZE_HOST_NAME" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "mongodb://${auth_gssapi:?}@${ip_addr}/?authMechanism=GSSAPI&authMechanismProperties=CANONICALIZE_HOST_NAME:true&${c_timeout}" - - declare ld_preload="${LD_PRELOAD:-}" - if [[ "${ASAN:-}" == "on" ]]; then - ld_preload="$(bypass_dlclose):${ld_preload}" - fi - - echo "Test threaded GSSAPI auth" - LD_LIBRARY_PATH="${openssl_lib_prefix}" MONGOC_TEST_GSSAPI_HOST="${auth_host}" MONGOC_TEST_GSSAPI_USER="${auth_gssapi}" LD_PRELOAD="${ld_preload:-}" "${test_gssapi}" - echo "Threaded GSSAPI auth OK" - - if [[ "${OSTYPE}" == "cygwin" ]]; then - echo "Authenticating using GSSAPI (service realm: LDAPTEST.10GEN.CC)" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "mongodb://${auth_crossrealm:?}@${auth_host}/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_REALM:LDAPTEST.10GEN.CC&${c_timeout}" - echo "Authenticating using GSSAPI (UTF-8 credentials)" - LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "mongodb://${auth_gssapi_utf8:?}@${auth_host}/?authMechanism=GSSAPI&${c_timeout}" - fi -fi diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-tests-mingw.bat b/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-tests-mingw.bat deleted file mode 100644 index 8512eff6e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-tests-mingw.bat +++ /dev/null @@ -1,17 +0,0 @@ -set PATH=C:\Windows\system32;C:\Windows;C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin;C:\mongo-c-driver\bin - -rem "make install" would work, except we run tests on different Evergreen hosts, -rem in different working directories, than where the driver was built. This -rem causes errors in "make install" like: -rem CMake Error at cmake_install cannot find -rem "C:/data/mci/d3ba3391950aca9119e841818a8884bc/mongoc/src/libbson/libbson-1.0.dll" -rem -rem So just copy files manually - -rmdir /Q /S C:\mongo-c-driver -md C:\mongo-c-driver -md C:\mongo-c-driver\bin -copy /Y libmongoc-1.0.dll C:\mongo-c-driver\bin -copy /Y src\libbson\libbson-1.0.dll C:\mongo-c-driver\bin - -.\src\libmongoc\test-libmongoc.exe --no-fork -d -F test-results.json --skip-tests .evergreen\etc\skip-tests.txt diff --git a/3rdparty/mongo-c-driver-1.26.2/.gitattributes b/3rdparty/mongo-c-driver-1.26.2/.gitattributes deleted file mode 100644 index 91d07ef39..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -tests/binary/* text eol=lf diff --git a/3rdparty/mongo-c-driver-1.26.2/.gitignore b/3rdparty/mongo-c-driver-1.26.2/.gitignore deleted file mode 100644 index eb5c2a8a0..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.gitignore +++ /dev/null @@ -1,40 +0,0 @@ -*.a -*.dylib -*.gcda -*.gcno -*.gz -*.o -*.lo -*.pc -*.so -*.so.* -.githooks -.scratch/ -cmake-build -cmake_install.cmake -CMakeCache.txt -CMakeFiles -CPackConfig.cmake -CPackSourceConfig.cmake -CTestTestfile.cmake -_build/ -dist_manifest.txt -test-results.json -VERSION_RELEASED -*.pyc - -# Windows things -*.sdf -*.sln -*.vcxproj* -.vs -Debug -install_manifest.txt -x64 - -# "dist" is produced during the release process -dist - -# `secrets-export.sh` is created by the drivers-evergreen-tools `setup_secrets.sh` script. -# Ignore this file to reduce risk of committing credentials during local development. -secrets-export.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.tsan-suppressions b/3rdparty/mongo-c-driver-1.26.2/.tsan-suppressions deleted file mode 100644 index 732650486..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/.tsan-suppressions +++ /dev/null @@ -1,2 +0,0 @@ -race:mongoc_counter* -race:_mongoc_handshake_freeze diff --git a/3rdparty/mongo-c-driver-1.26.2/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/CMakeLists.txt deleted file mode 100644 index edc5c5005..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/CMakeLists.txt +++ /dev/null @@ -1,628 +0,0 @@ -cmake_minimum_required (VERSION 3.15) - -list (INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/build/cmake") -# Defines BUILD_VERSION, which we use throughout: -include (BuildVersion) - -project ( - mongo-c-driver - LANGUAGES C - # BUILD_VERSION_SIMPLE is a CMake-compatible version number that omits suffixes - VERSION "${BUILD_VERSION_SIMPLE}" -) - -# Set MONGOC_MAJOR_VERSION, MONGOC_MINOR_VERSION, etc. -include (ParseVersion) -ParseVersion ("${BUILD_VERSION}" MONGOC) -# Defines additional similar variables: -include (LoadVersion) -file (WRITE VERSION_CURRENT "${BUILD_VERSION}") -LoadVersion (VERSION_CURRENT MONGOC) - -# Extended version attributes that CMake doesn't (yet) understand, which include -# the prerelease tag. Named here to match the variables generated by project() -set(mongo-c-driver_VERSION_PRERELEASE ${MONGOC_PRERELEASE_VERSION}) -set(mongo-c-driver_VERSION_FULL ${MONGOC_VERSION}) - -include(FeatureSummary) - -include (MongoSettings) -include (MongoPlatform) -include (GeneratePkgConfig) - -# Subcomponents: -mongo_bool_setting(ENABLE_MONGOC "Enable the build of libmongoc libraries (The MongoDB C database driver)") -mongo_bool_setting( - USE_SYSTEM_LIBBSON [[Use an existing libbson library (via find_package()) instead of building one from source]] - DEFAULT VALUE OFF - ADVANCED -) - -# Deprecated option "ENABLE_BSON" is gone, but old caches may rely on SYSTEM to -# disable the libbson build. Allow ENABLE_BSON=SYSTEM only if USE_SYSTEM_LIBBSON -# is also true, to allow both ENABLE_BSON=SYSTEM and USE_SYSTEM_LIBBSON=TRUE to -# simplify downstream build scripts -if(ENABLE_BSON STREQUAL "SYSTEM" AND NOT USE_SYSTEM_LIBBSON) - # User set ENABLE_BSON=SYSTEM, so they intend for us to build against an external - # libbson, but they didn't set USE_SYSTEM_LIBBSON=ON, so they are probably - # unaware of this change. Rather than miscompile, stop what we're doing: - message(FATAL_ERROR "ENABLE_BSON=SYSTEM is no longer supported. Use USE_SYSTEM_LIBBSON=ON for the same effect.") -endif() - -# Toggle static libraries: -mongo_setting( - ENABLE_STATIC "Enable building and installing static library archive artifacts" - OPTIONS ON OFF BUILD_ONLY - DEFAULT VALUE "ON" -) -# Toggle dynamic libraries: -mongo_bool_setting(ENABLE_SHARED "Enable building and installing dynamic library artifacts") - -# Toggle PIC -if(NOT WIN32) - mongo_bool_setting(ENABLE_PIC "Enable position-independent code when building static libraries (Not applicable on Windows)") -elseif(DEFINED ENABLE_PIC) - # We are on Windows, and ENABLE_PIC is defined. - message(STATUS "ENABLE_PIC=“${ENABLE_PIC}†has no effect on Windows (All Windows code is position-independent)") -else() - # We are on Windows, and ENABLE_PIC is not defined, which is normal -endif() - -# Dev mode checks: -mongo_bool_setting( - ENABLE_MAINTAINER_FLAGS "Enable stricter build-time checks" - DEFAULT VALUE OFF - DEVEL EVAL [[ - if(MSVC) - set(DEFAULT OFF) - else() - set(DEFAULT ON) - endif() - ]]) - -# Toggle instrumentation: -mongo_bool_setting(ENABLE_TRACING "Enable runtime tracing output in the built libmongoc (Very noisy!)" - DEFAULT VALUE OFF) -mongo_bool_setting(ENABLE_COVERAGE "Build code with coverage instrumentation" - DEFAULT VALUE OFF DEVEL VALUE ON) -mongo_bool_setting(ENABLE_DEBUG_ASSERTIONS "Build library with runtime debug assertions enabled" - DEFAULT VALUE OFF DEVEL VALUE ON) -# for MONGO_SANITIZE: -include(Sanitizers) - -# Toggle optional components: -mongo_bool_setting(ENABLE_TESTS "Build MongoDB C Driver tests") -mongo_bool_setting(ENABLE_EXAMPLES "Build MongoDB C Driver examples") -mongo_bool_setting(ENABLE_MAN_PAGES "Build the manual pages" DEFAULT VALUE OFF) -mongo_bool_setting(ENABLE_HTML_DOCS "Build the HTML documentation" DEFAULT VALUE OFF) -mongo_bool_setting(ENABLE_UNINSTALL "Generate an 'uninstall' script and an 'uninstall' build target") -mongo_bool_setting(ENABLE_SRV "Enable support for mongodb+srv URIs.") - -# Optional features that are ENABLED when necessary dependencies are found: -mongo_setting(ENABLE_SNAPPY "Enable Snappy compression support" - OPTIONS ON OFF AUTO - DEFAULT VALUE AUTO) -mongo_setting(ENABLE_ZSTD "Enable zstd compression support" - OPTIONS ON OFF AUTO - DEFAULT VALUE AUTO) -mongo_setting(ENABLE_ZLIB "Enable zlib compression support" - OPTIONS BUNDLED SYSTEM OFF - DEFAULT VALUE BUNDLED) -mongo_bool_setting(USE_BUNDLED_UTF8PROC "Enable building with utf8proc. Needed for SCRAM-SHA-256 authentication with non-ASCII passwords" - ADVANCED) -mongo_setting( - ENABLE_SSL [[Enable TLS connection and SCRAM authentication.]] - OPTIONS WINDOWS DARWIN OPENSSL LIBRESSL OFF AUTO - DEFAULT VALUE AUTO - VALIDATE CODE [[ - if(ENABLE_SSL STREQUAL "DARWIN" AND NOT APPLE) - message(WARNING "ENABLE_SSL=DARWIN is only supported on Apple platforms") - elseif(ENABLE_SSL STREQUAL "WINDOWS" AND NOT WIN32) - message(WARNING "ENABLE_SSL=WINDOWS is only supported on Windows platforms") - endif() - ]] -) -mongo_bool_setting( - ENABLE_SHM_COUNTERS "Enable memory performance counters" - DEFAULT EVAL [[ - set(DEFAULT OFF) - if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" OR (APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")) - set(DEFAULT ON) - endif() - ]] - VALIDATE CODE [[ - if(ENABLE_SHM_COUNTERS - AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" - AND NOT (APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")) - message(WARNING "ENABLE_SHM_COUNTERS=ON is only supported on Linux or ARM Darwin") - endif() - ]] -) - -mongo_setting( - ENABLE_SASL "Enable SASL authentication (Kerberos)" - OPTIONS CYRUS SSPI OFF AUTO - DEFAULT VALUE AUTO - VALIDATE CODE [[ - if(ENABLE_SASL STREQUAL "SSPI" AND NOT WIN32) - message(WARNING "ENABLE_SASL=SSPI is only supported on Windows platforms") - endif() - ]] -) - -mongo_setting(CYRUS_PLUGIN_PATH_PREFIX "An absolute path prefix to enable loading Cyrus SASL plugins on Windows" - TYPE STRING - VISIBLE_IF [[ENABLE_SASL STREQUAL "CYRUS" AND WIN32]] -) - -mongo_setting(ENABLE_CLIENT_SIDE_ENCRYPTION "Enable In-Use Encryption support. Requires additional support libraries." - OPTIONS ON OFF AUTO - DEFAULT VALUE AUTO) -mongo_setting(ENABLE_MONGODB_AWS_AUTH "Enable support for the MONGODB-AWS authentication mechanism" - OPTIONS ON OFF AUTO - DEFAULT VALUE AUTO - VALIDATE CODE [[ - if(NOT ENABLE_MONGODB_AWS_AUTH STREQUAL "ON") - return() - endif() - if(MSVC AND MSVC_VERSION LESS 1900) - message(FATAL_ERROR "Visual Studio 2015 or newer is required for ENABLE_MONGODB_AWS_AUTH=ON") - elseif(ENABLE_SSL STREQUAL "OFF") - message(FATAL_ERROR "ENABLE_MONGODB_AWS_AUTH=ON requires that ENABLE_SSL not be 'OFF'") - endif() - ]]) - -# Optional features that are DISABLED by default: -mongo_bool_setting(ENABLE_RDTSCP "Enable fast performance counters using the Intel RDTSCP instruction" - DEFAULT VALUE OFF) -mongo_bool_setting(ENABLE_APPLE_FRAMEWORK "Build libraries as Apple Frameworks on Darwin platforms" - DEFAULT VALUE OFF) -mongo_bool_setting( - ENABLE_CRYPTO_SYSTEM_PROFILE "Use system crypto profile" - DEFAULT VALUE OFF - VALIDATE CODE [[ - if(ENABLE_CRYPTO_SYSTEM_PROFILE AND NOT ENABLE_SSL STREQUAL "OPENSSL") - message(WARNING "ENABLE_CRYPTO_SYSTEM_PROFILE=TRUE is only applicable when ENABLE_SSL=OPENSSL") - endif() - ]] -) - -# Deprecated options: -mongo_bool_setting( - ENABLE_AUTOMATIC_INIT_AND_CLEANUP - "[Deprecated] Enable automatic initialization of the C driver library" - DEFAULT EVAL [[ - set(DEFAULT OFF) - if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - message(VERBOSE "For backwards compatibility, when using GCC the default of " - "ENABLE_AUTOMATIC_INIT_AND_CLEANUP is ON") - set(DEFAULT ON) - endif() - ]] - DEVEL VALUE OFF - VALIDATE CODE [[ - if(ENABLE_AUTOMATIC_INIT_AND_CLEANUP) - if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU") - message(WARNING "ENABLE_AUTOMATIC_INIT_AND_CLEANUP is only supported on GCC.") - endif() - message(DEPRECATION - "Enabling ENABLE_AUTOMATIC_INIT_AND_CLEANUP is deprecated and " - "may be removed in a future release") - endif() - ]] -) -mongo_bool_setting( - ENABLE_EXTRA_ALIGNMENT - "[Deprecated] Enable extra alignment on libbson types" - DEFAULT VALUE ON - DEVEL VALUE OFF - VALIDATE CODE [[ - if(ENABLE_EXTRA_ALIGNMENT AND MONGO_SANITIZE MATCHES "undefined") - message(WARNING "ENABLE_EXTRA_ALIGNMENT=“${ENABLE_EXTRA_ALIGNMENT}†will create conflicts with UndefinedBehaviorSanitizer") - endif() - ]] -) - -if(ENABLE_COVERAGE) - mongo_platform_link_options(--coverage) - mongo_platform_compile_options($) -endif() - -# Enable multi-threading: -set(THREADS_PREFER_PTHREAD_FLAG TRUE) -find_package(Threads REQUIRED) -mongo_platform_use_target(Threads::Threads) - -set_property(DIRECTORY APPEND PROPERTY pkg_config_LIBS ${CMAKE_THREAD_LIBS_INIT}) - -if(WIN32) - # Required for gethostbyname on Windows: - mongo_platform_link_libraries(ws2_32) -endif() - -# librt needed on linux for clock_gettime -find_library(RT_LIBRARY rt PATHS /usr/lib32) -if(RT_LIBRARY) - mongo_platform_link_libraries(${RT_LIBRARY}) - # Set required libraries for CHECK_FUNCTION_EXISTS - list(APPEND CMAKE_REQUIRED_LIBRARIES "${RT_LIBRARY}") - # Export the rt linkage as a pkg-config property: - get_filename_component(rt_dir "${RT_LIBRARY}" DIRECTORY) - set_property(DIRECTORY APPEND PROPERTY pkg_config_LIBS "-L${rt_dir}" -lrt) -endif() - -# On macOS Big Sur, libm resolves to the SDK's tbd file, like: -# /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd -# Not all consumers can easily link to a tbd file (notably golang will reject a tbd suffix by default) -# macOS includes libm as part of libSystem (along with libc). -# It does not need to be explicitly linked. -if(NOT APPLE) - find_library(M_LIBRARY m) - if(M_LIBRARY) - mongo_platform_link_libraries(${M_LIBRARY}) - endif() -endif() - -# Optionally enable C++ to do some C++-specific tests -include (CheckLanguage) -check_language (CXX) -if (CMAKE_CXX_COMPILER) - enable_language (CXX) - if (NOT CMAKE_CXX_STANDARD) - # Default to C++11 for purposes of testing. - set (CMAKE_CXX_STANDARD 11) - endif () -else () - message (STATUS "No CXX support") -endif () - -if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set (CMAKE_BUILD_TYPE "RelWithDebInfo") - message ( - STATUS "No CMAKE_BUILD_TYPE selected, defaulting to ${CMAKE_BUILD_TYPE}" - ) -endif () - -include (InstallRequiredSystemLibraries) -include (GNUInstallDirs) -include (CMakeDependentOption) - -include(MongoC-Warnings) - -# Enable "maintainer flags," which are supplementary but not mandatory. -# (As opposed to MongoC-Warnings.cmake, which defines "the code is broken" warnings) -if(ENABLE_MAINTAINER_FLAGS) - mongoc_add_warning_options( - gnu-like:-Werror - gnu-like:-pedantic - gnu-like:-Wall - gnu-like:-Wempty-body - gnu:not-gcc-lt7:-Wexpansion-to-defined - gnu-like:-Wformat - gnu-like:-Wformat-nonliteral - gnu-like:-Wformat-security - gnu-like:-Winit-self - gnu-like:-Wmissing-include-dirs - gnu-like:-Wredundant-decls - gnu-like:-Wshadow - gnu-like:lang-c:-Wstrict-prototypes - gnu-like:-Wswitch-default - gnu-like:-Wswitch-enum - gnu-like:-Wundef - gnu-like:-Wuninitialized - # Disabled, for now: - gnu-like:-Wno-strict-aliasing - ) -endif() - -# Enable CCache, if possible -include (CCache) - -# Link with LLD, if possible -if (NOT MSVC) - include (LLDLinker) -endif () - -if ( (ENABLE_BUILD_DEPENDECIES STREQUAL OFF) AND (NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) ) - set (ENABLE_BUILD_DEPENDECIES ON) -endif () - -mongo_pick(BSON_EXTRA_ALIGN 1 0 ENABLE_EXTRA_ALIGNMENT) - -mongo_pick(MONGOC_ENABLE_RDTSCP 1 0 ENABLE_RDTSCP) - -mongo_pick(MONGOC_ENABLE_STATIC_BUILD 1 0 ENABLE_STATIC) -mongo_pick(MONGOC_ENABLE_STATIC_INSTALL 1 0 - [[ENABLE_STATIC AND NOT ENABLE_STATIC STREQUAL "BUILD_ONLY"]]) - -if (USE_SYSTEM_LIBBSON) - # The input variable BSON_ROOT_DIR is respected for backwards compatibility, - # but you should use the standard CMAKE_PREFIX_PATH instead. - message (STATUS "Searching for libbson CMake packages") - find_package (bson-1.0 - "${PROJECT_VERSION}" - HINTS - ${BSON_ROOT_DIR}) - - if (NOT bson-1.0_FOUND) - message (FATAL_ERROR "System libbson not found") - endif () - - message (STATUS "libbson found version \"${bson-1.0_VERSION}\"") - message (STATUS "disabling test-libmongoc since using system libbson") - SET (ENABLE_TESTS OFF) - - set (USING_SYSTEM_BSON TRUE) - if (NOT TARGET mongo::bson_shared) - message (FATAL_ERROR "System libbson built without shared library target") - endif () - set (BSON_LIBRARIES mongo::bson_shared) - if (NOT TARGET mongo::bson_static) - message (FATAL_ERROR "System libbson built without static library target") - endif () - set (BSON_STATIC_LIBRARIES mongo::bson_static) -endif () - -set (BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR}) - -# Enable CTest -include (CTest) -if (BUILD_TESTING) - include (TestFixtures) -endif () - -# Ensure the default behavior: don't ignore RPATH settings. -set (CMAKE_SKIP_BUILD_RPATH OFF) - -# Ensure the default behavior: don't use the final install destination as the -# temporary RPATH for executables (ensure we can run tests and programs from -# the build directory). -set (CMAKE_BUILD_WITH_INSTALL_RPATH OFF) - -# Include any custom library paths in the final RPATH. -set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) - -# Install libs with names like @rpath/libmongoc-1.0.0.dylib, not bare names. -set (CMAKE_MACOSX_RPATH ON) - -# https://cmake.org/cmake/help/v3.11/policy/CMP0042.html -# Enable a CMake 3.0+ policy that sets CMAKE_MACOSX_RPATH by default, and -# silence a CMake 3.11 warning that the old behavior is deprecated. -cmake_policy (SET CMP0042 NEW) - -# By default, ensure conformance with a minimum C standard. -# Required extensions to the language (i.e. POSIX) are (re)enabled further below. -if (NOT DEFINED CMAKE_C_STANDARD) - set (CMAKE_C_STANDARD 99) -endif () -if (NOT DEFINED CMAKE_C_STANDARD_REQUIRED) - set (CMAKE_C_STANDARD_REQUIRED ON) -endif () -if (NOT DEFINED CMAKE_C_EXTENSIONS) - set (CMAKE_C_EXTENSIONS OFF) -endif () - -# https://man7.org/linux/man-pages/man7/feature_test_macros.7.html -# https://pubs.opengroup.org/onlinepubs/7908799/xsh/compilation.html -# Enable POSIX features up to POSIX.1-2008 plus the XSI extension and BSD-derived definitions. -# Both _BSD_SOURCE and _DEFAULT_SOURCE are defined for backwards-compatibility with glibc 2.19 and earlier. -# _BSD_SOURCE and _DEFAULT_SOURCE are required by `getpagesize`, `h_errno`, etc. -# _XOPEN_SOURCE=700 is required by `strnlen`, `strerror_l`, etc. -add_definitions (-D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_DEFAULT_SOURCE) -list (APPEND CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_DEFAULT_SOURCE) - -# Enable non-standard features on FreeBSD with __BSD_VISIBLE=1 -if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - add_definitions (-D__BSD_VISIBLE=1) - list (APPEND CMAKE_REQUIRED_DEFINITIONS -D__BSD_VISIBLE=1) -endif () - -# https://opensource.apple.com/source/Libc/Libc-1439.40.11/gen/compat.5.auto.html -# Non-POSIX extensions are required by `_SC_NPROCESSORS_ONLN`. -if (CMAKE_SYSTEM_NAME MATCHES "Darwin") - add_definitions (-D_DARWIN_C_SOURCE) - list (APPEND CMAKE_REQUIRED_DEFINITIONS -D_DARWIN_C_SOURCE) -endif () - -add_subdirectory (src/common) - -if (NOT USING_SYSTEM_BSON) - message (STATUS "Using bundled libbson") - - add_subdirectory (src/libbson) - # Defined in src/libbson/CMakeLists.txt - set (BSON_STATIC_LIBRARIES bson_static) - set (BSON_LIBRARIES bson_shared) - set (BSON_STATIC_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/libbson/src" "${PROJECT_BINARY_DIR}/src/libbson/src") - set (BSON_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/libbson/src" "${PROJECT_BINARY_DIR}/src/libbson/src") - set (BSON_STATIC_PUBLIC_DEFINITIONS "BSON_STATIC") -endif () - -if (MSVC) - add_definitions (-D_CRT_SECURE_NO_WARNINGS) -endif () - -if (ENABLE_MONGOC) - if (ENABLE_TESTS AND NOT MONGOC_ENABLE_STATIC_BUILD) - message (FATAL_ERROR "ENABLE_TESTS requires ENABLE_STATIC or ENABLE_STATIC_BUILD") - endif () - - set (SOURCE_DIR "${PROJECT_SOURCE_DIR}/") - - set (UTF8PROC_SOURCES - ${SOURCE_DIR}/src/utf8proc-2.8.0/utf8proc.c - ) - - set (ZLIB_SOURCES - ${SOURCE_DIR}/src/zlib-1.2.13/adler32.c - ${SOURCE_DIR}/src/zlib-1.2.13/crc32.c - ${SOURCE_DIR}/src/zlib-1.2.13/deflate.c - ${SOURCE_DIR}/src/zlib-1.2.13/infback.c - ${SOURCE_DIR}/src/zlib-1.2.13/inffast.c - ${SOURCE_DIR}/src/zlib-1.2.13/inflate.c - ${SOURCE_DIR}/src/zlib-1.2.13/inftrees.c - ${SOURCE_DIR}/src/zlib-1.2.13/trees.c - ${SOURCE_DIR}/src/zlib-1.2.13/zutil.c - ${SOURCE_DIR}/src/zlib-1.2.13/compress.c - ${SOURCE_DIR}/src/zlib-1.2.13/uncompr.c - ${SOURCE_DIR}/src/zlib-1.2.13/gzclose.c - ${SOURCE_DIR}/src/zlib-1.2.13/gzlib.c - ${SOURCE_DIR}/src/zlib-1.2.13/gzread.c - ${SOURCE_DIR}/src/zlib-1.2.13/gzwrite.c - ) - - set (CPACK_RESOURCE_FILE_LICENSE "${SOURCE_DIR}/COPYING") - - include (CPack) - - # Ensure the default behavior: don't ignore RPATH settings. - set (CMAKE_SKIP_BUILD_RPATH OFF) - - if (APPLE) - # Until CDRIVER-520. - add_definitions (-Wno-deprecated-declarations) - endif () - - set (KMS_MSG_SOURCES - ${SOURCE_DIR}/src/kms-message/src/hexlify.c - ${SOURCE_DIR}/src/kms-message/src/kms_b64.c - ${SOURCE_DIR}/src/kms-message/src/kms_caller_identity_request.c - ${SOURCE_DIR}/src/kms-message/src/kms_crypto_apple.c - ${SOURCE_DIR}/src/kms-message/src/kms_crypto_libcrypto.c - ${SOURCE_DIR}/src/kms-message/src/kms_crypto_none.c - ${SOURCE_DIR}/src/kms-message/src/kms_crypto_windows.c - ${SOURCE_DIR}/src/kms-message/src/kms_decrypt_request.c - ${SOURCE_DIR}/src/kms-message/src/kms_encrypt_request.c - ${SOURCE_DIR}/src/kms-message/src/kms_kmip_response_parser.c - ${SOURCE_DIR}/src/kms-message/src/kms_kv_list.c - ${SOURCE_DIR}/src/kms-message/src/kms_message.c - ${SOURCE_DIR}/src/kms-message/src/kms_port.c - ${SOURCE_DIR}/src/kms-message/src/kms_request.c - ${SOURCE_DIR}/src/kms-message/src/kms_request_opt.c - ${SOURCE_DIR}/src/kms-message/src/kms_request_str.c - ${SOURCE_DIR}/src/kms-message/src/kms_response.c - ${SOURCE_DIR}/src/kms-message/src/kms_response_parser.c - ${SOURCE_DIR}/src/kms-message/src/sort.c - ) - - if (NOT ENABLE_MONGODB_AWS_AUTH MATCHES "ON|OFF|AUTO") - message (FATAL_ERROR "ENABLE_MONGODB_AWS_AUTH option must be ON, AUTO, or OFF") - endif () - set (MONGOC_ENABLE_MONGODB_AWS_AUTH 0) - if (ENABLE_MONGODB_AWS_AUTH STREQUAL "AUTO") - if (MSVC AND MSVC_VERSION LESS 1900) - message (WARNING "MS Visual Studio too old for ENABLE_MONGODB_AWS_AUTH") - elseif (NOT ENABLE_SSL) - message (WARNING - "Option ENABLE_MONGODB_AWS_AUTH requires ENABLE_SSL not set to OFF" - ) - else () - set (MONGOC_ENABLE_MONGODB_AWS_AUTH 1) - endif () - elseif (ENABLE_MONGODB_AWS_AUTH) - if (MSVC AND MSVC_VERSION LESS 1900) - message (FATAL_ERROR "Use Visual Studio 2015 or higher for ENABLE_MONGODB_AWS_AUTH") - endif () - if (NOT ENABLE_SSL) - message (FATAL_ERROR - "Option ENABLE_MONGODB_AWS_AUTH requires ENABLE_SSL not set to OFF" - ) - endif () - set (MONGOC_ENABLE_MONGODB_AWS_AUTH 1) - endif () - - add_subdirectory (src/libmongoc) - - if (MONGOC_ENABLE_MONGODB_AWS_AUTH) - message (STATUS "Building with MONGODB-AWS auth support") - endif () - - if (ENABLE_MAN_PAGES STREQUAL ON OR ENABLE_HTML_DOCS STREQUAL ON) - find_package (Sphinx REQUIRED) - add_custom_target (doc - ALL - DEPENDS - $<$>:bson-doc> - $<$:mongoc-doc> - ) - endif () - - # sub-directory 'doc' was already included above - add_subdirectory (src) - # 'src/libbson' was already included, so 'src' will not include it directly - # 'src/kms-message' was already included if appropriate - # 'src/libmongoc' was already included, so 'src' will not include it directly -endif () - -install (FILES COPYING NEWS README.rst THIRD_PARTY_NOTICES - DESTINATION ${CMAKE_INSTALL_DATADIR}/mongo-c-driver -) - -if (ENABLE_UNINSTALL) - # Create uninstall program and associated uninstall target - # - # This needs to be last (after all other add_subdirectory calls) to ensure that - # the generated uninstall program is complete and correct - if (NOT ENABLE_MONGOC) - # Generate a different script name for uninstalling libbson only: - set (UNINSTALL_SCRIPT_NAME "uninstall-bson") - endif () - set (UNINSTALL_PROG_DIR "${CMAKE_INSTALL_DATADIR}/mongo-c-driver") - include (GenerateUninstaller) -endif () - -# Spit out some information regarding the generated build system -message (STATUS "Build files generated for:") -message (STATUS "\tbuild system: ${CMAKE_GENERATOR}") -if (CMAKE_GENERATOR_INSTANCE) - message (STATUS "\tinstance: ${CMAKE_GENERATOR_INSTANCE}") -endif () -if (CMAKE_GENERATOR_PLATFORM) - message (STATUS "\tinstance: ${CMAKE_GENERATOR_PLATFORM}") -endif () -if (CMAKE_GENERATOR_TOOLSET) - message (STATUS "\tinstance: ${CMAKE_GENERATOR_TOOLSET}") -endif () - -if (TARGET test-libmongoc) - # Generate a file that can be included by CTest to load and enumerate all of the - # tests defined by the test-libmongoc executable. Generate one for each - # configuration in case of multiconf generators. - string (CONFIGURE [=[ - set (TEST_LIBMONGOC_EXE [[$]]) - set (SRC_ROOT [[@PROJECT_SOURCE_DIR@]]) - set (IS_MULTICONF $) - if (NOT IS_MULTICONF OR CTEST_CONFIGURATION_TYPE STREQUAL "$") - # We are not in multi-conf, or the current config matches our config. - include ("${SRC_ROOT}/build/cmake/LoadTests.cmake") - elseif (NOT CTEST_CONFIGURATION_TYPE) - # We are in multi-conf, but no '-C' config was specified - message (WARNING "Specify a --build-config when using CTest with a multi-config build") - else () - # Do nothing. Not our config. - endif () - ]=] code @ONLY) - file (GENERATE - OUTPUT "${PROJECT_BINARY_DIR}/LoadTests-$.cmake" - CONTENT "${code}") - if (CMAKE_CONFIGURATION_TYPES) - foreach (conf IN LISTS CMAKE_CONFIGURATION_TYPES) - # Direct the generated CTest code to include() the file that loads the tests: - set_property ( - DIRECTORY - APPEND PROPERTY - TEST_INCLUDE_FILES "${PROJECT_BINARY_DIR}/LoadTests-${conf}.cmake") - endforeach () - else () - set_property ( - DIRECTORY - APPEND PROPERTY - TEST_INCLUDE_FILES "${PROJECT_BINARY_DIR}/LoadTests-${CMAKE_BUILD_TYPE}.cmake") - endif () -endif () - -if (CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND PROJECT_IS_TOP_LEVEL) - set (CMAKE_CROSS_CONFIGS "all") -endif () - -feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES) diff --git a/3rdparty/mongo-c-driver-1.26.2/Earthfile b/3rdparty/mongo-c-driver-1.26.2/Earthfile deleted file mode 100644 index e437e1c74..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/Earthfile +++ /dev/null @@ -1,299 +0,0 @@ -VERSION --arg-scope-and-set --pass-args 0.7 -LOCALLY - -# For target names, descriptions, and build parameters, run the "doc" Earthly subcommand. - -# Injects utilities into the environment -INIT: - COMMAND - COPY --chmod=755 tools/str.sh /usr/local/bin/str - -# PREP_CMAKE "warms up" the CMake installation cache for the current environment -PREP_CMAKE: - COMMAND - LET scratch=/opt/mongoc-cmake - # Copy the minimal amount that we need, as to avoid cache invalidation - COPY tools/use.sh tools/platform.sh tools/paths.sh tools/base.sh tools/download.sh \ - $scratch/tools/ - COPY .evergreen/scripts/find-cmake-version.sh \ - .evergreen/scripts/use-tools.sh \ - .evergreen/scripts/find-cmake-latest.sh \ - .evergreen/scripts/cmake.sh \ - $scratch/.evergreen/scripts/ - # "Install" a shim that runs our managed CMake executable: - RUN printf '#!/bin/sh\n /opt/mongoc-cmake/.evergreen/scripts/cmake.sh "$@"\n' \ - > /usr/local/bin/cmake && \ - chmod +x /usr/local/bin/cmake - # Executing any CMake command will warm the cache: - RUN cmake --version - -# version-current : -# Create the VERSION_CURRENT file using Git. This file is exported as an artifact at / -version-current: - # Run on Alpine, which does this work the fastest - FROM alpine:3.18 - # Install Python and Git, the only things required for this job: - RUN apk add git python3 - COPY --dir .git/ build/calc_release_version.py /s/ - # Calculate it: - RUN cd /s/ && \ - python calc_release_version.py --next-minor > VERSION_CURRENT - SAVE ARTIFACT /s/VERSION_CURRENT - -# BUILD_AND_INSTALL executes the mongo-c-driver build and installs it to a prefix -BUILD_AND_INSTALL: - COMMAND - # The configuration to be built - ARG config=RelWithDebInfo - # The prefix at which to install the built result - ARG install_prefix=/opt/mongo-c-driver - # Build configuration parameters. Will be case-normalized for CMake usage. - ARG --required sasl - ARG --required tls - LET source_dir=/opt/mongoc/source - LET build_dir=/opt/mongoc/build - COPY --dir \ - src/ \ - build/ \ - COPYING \ - CMakeLists.txt \ - README.rst \ - THIRD_PARTY_NOTICES \ - NEWS \ - "$source_dir" - COPY +version-current/ $source_dir - ENV CCACHE_HOME=/root/.cache/ccache - RUN cmake -S "$source_dir" -B "$build_dir" -G "Ninja Multi-Config" \ - -D ENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF \ - -D ENABLE_MAINTAINER_FLAGS=ON \ - -D ENABLE_SHM_COUNTERS=ON \ - -D ENABLE_EXTRA_ALIGNMENT=OFF \ - -D ENABLE_SASL=$(echo $sasl | str upper) \ - -D ENABLE_SNAPPY=ON \ - -D ENABLE_SRV=ON \ - -D ENABLE_ZLIB=BUNDLED \ - -D ENABLE_SSL=$(echo $tls | str upper) \ - -D ENABLE_COVERAGE=ON \ - -D ENABLE_DEBUG_ASSERTIONS=ON \ - -Werror - RUN --mount=type=cache,target=$CCACHE_HOME \ - env CCACHE_BASE="$source_dir" \ - cmake --build $build_dir --config $config - RUN cmake --install $build_dir --prefix="$install_prefix" --config $config - -alpine-base: - ARG --required version - FROM alpine:$version - # XXX: On Alpine, we just use the system's CMake. At time of writing, it is - # very up-to-date and much faster than building our own from source (since - # Kitware does not (yet) provide libmuslc builds of CMake) - RUN apk add cmake ninja-is-really-ninja gcc musl-dev g++ - DO +INIT - ARG --required tls - ARG --required sasl - IF str test "$sasl" -ieq "Cyrus" - RUN apk add cyrus-sasl-dev - END - IF str test "$tls" -ieq "LibreSSL" || str test $tls -ieq auto - RUN apk add libressl-dev - ELSE IF str test "$tls" -ieq "OpenSSL" - RUN apk add openssl-dev - END - -alpine-build-env-base: - ARG --required version - FROM +alpine-base --version=$version - RUN apk add snappy-dev ccache - -alpine-test-env-base: - ARG --required version - FROM +alpine-base --version=$version - RUN apk add snappy - -# alpine3.18-build-env : -# A build environment based on Alpine Linux version 3.18 -alpine3.18-build-env: - FROM +alpine-build-env-base --version=3.18 - -alpine3.18-test-env: - FROM +alpine-test-env-base --version=3.18 - -archlinux-base: - FROM archlinux - RUN pacman --sync --refresh --sysupgrade --noconfirm --quiet ninja gcc snappy - DO +INIT - ARG tls - # We don't install libsasl2 here, because it's pre-installed on Arch - IF str test "$tls" -ieq "LibreSSL" || str test $tls -ieq auto - RUN pacman --sync --refresh --sysupgrade --noconfirm --quiet libressl - END - IF str test "$tls" -ieq "OpenSSL" || str test $tls -ieq auto - RUN pacman --sync --refresh --sysupgrade --noconfirm --quiet openssl - END - -# archlinux-build-env : -# A build environment based on Arch Linux -archlinux-build-env: - FROM +archlinux-base - DO +PREP_CMAKE - RUN pacman --sync --refresh --sysupgrade --noconfirm --quiet ccache - -archlinux-test-env: - FROM +archlinux-base - DO +PREP_CMAKE - -ubuntu-base: - ARG --required version - FROM ubuntu:$version - RUN apt-get update && apt-get -y install curl build-essential - DO +INIT - ARG --required sasl - ARG --required tls - IF str test "$sasl" -ieq Cyrus - RUN apt-get update && apt-get -y install libsasl2-dev - END - IF str test "$tls" -ieq LibreSSL - RUN echo "Ubuntu does not support LibreSSL" && exit 1 - ELSE IF str test $tls -ieq OpenSSL || str test $tls -ieq auto - RUN apt-get update && apt-get -y install libssl-dev - END - -# u22-build-env : -# A build environment based on Ubuntu 22.04 -u22-build-env: - FROM +ubuntu-base --version=22.04 - # Build dependencies: - RUN apt-get update && apt-get -y install \ - ninja-build gcc ccache libsnappy-dev zlib1g-dev - DO +PREP_CMAKE - -u22-test-env: - FROM +ubuntu-base --version=22.04 - RUN apt-get update && apt-get -y install libsnappy1v5 libsasl2-2 ninja-build - DO +PREP_CMAKE - -env-warmup: - ARG --required env - BUILD +$env-build-env - BUILD +$env-test-env - -# build : -# Build libmongoc and libbson using the specified environment. -# -# The --env argument specifies the build environment, using “+${env}-build-env†-# as the build environment target. Refer to the list of targets for a list of -# available environments. -build: - # env is an argument - ARG --required env - FROM +$env-build-env - DO --pass-args +BUILD_AND_INSTALL - SAVE ARTIFACT /opt/mongoc/build/* /build-tree/ - SAVE ARTIFACT /opt/mongo-c-driver/* /root/ - -# test-example will build one of the libmongoc example projects using the build -# that comes from the +build target. -test-example: - ARG --required env - FROM +$env-test-env - # Grab the built - COPY +build/root /opt/mongo-c-driver - COPY --dir \ - src/libmongoc/examples/cmake \ - src/libmongoc/examples/cmake-deprecated \ - src/libmongoc/examples/hello_mongoc.c \ - /opt/mongoc-test/ - RUN cmake \ - -S /opt/mongoc-test/cmake/find_package \ - -B /bld \ - -G Ninja \ - -D CMAKE_PREFIX_PATH=/opt/mongo-c-driver - RUN cmake --build /bld - -# test-cxx-driver : -# Clone and build the mongo-cxx-driver project, using the current mongo-c-driver -# for the build. -# -# The “--test_mongocxx_ref†argument must be a clone-able Git ref. The driver source -# will be cloned at this point and built. -# -# The “--cxx_version_current†argument will be inserted into the VERSION_CURRENT -# file for the cxx-driver build. -test-cxx-driver: - ARG --required env - ARG --required test_mongocxx_ref - ARG cxx_version_current=0.0.0 - FROM +$env-build-env - COPY +build/root /opt/mongo-c-driver - LET source=/opt/mongo-cxx-driver/src - LET build=/opt/mongo-cxx-driver/bld - GIT CLONE --branch=$test_mongocxx_ref https://github.com/mongodb/mongo-cxx-driver.git $source - RUN echo $cxx_version_current > $source/build/VERSION_CURRENT - RUN cmake -S $source -B $build -G Ninja -D CMAKE_PREFIX_PATH=/opt/mongo-c-driver -D CMAKE_CXX_STANDARD=17 - ENV CCACHE_HOME=/root/.cache/ccache - ENV CCACHE_BASE=$source - RUN --mount=type=cache,target=$CCACHE_HOME cmake --build $build - -# Simultaneously builds and tests multiple different platforms -multibuild: - BUILD +test-example --env=u22 --env=archlinux --env=alpine3.18 \ - --sasl=Cyrus --sasl=off \ - --tls=OpenSSL --tls=off - # Note: At time of writing, Ubuntu does not support LibreSSL, so run those - # tests on a separate BUILD line that does not include Ubuntu: - BUILD +test-example --env=archlinux --env=alpine3.18 \ - --sasl=Cyrus --sasl=off \ - --tls=LibreSSL - -# test-vcpkg-classic : -# Builds src/libmongoc/examples/cmake/vcpkg by using vcpkg to download and -# install a mongo-c-driver build in "classic mode". *Does not* use the local -# mongo-c-driver repository. -test-vcpkg-classic: - FROM +vcpkg-base - RUN vcpkg install mongo-c-driver - RUN rm -rf _build && \ - make test-classic - -# test-vcpkg-manifest-mode : -# Builds src/libmongoc/examples/cmake/vcpkg by using vcpkg to download and -# install a mongo-c-driver package based on the content of a vcpkg.json manifest -# that is injected into the project. -test-vcpkg-manifest-mode: - FROM +vcpkg-base - RUN apk add jq - RUN jq -n ' { \ - name: "test-app", \ - version: "1.2.3", \ - dependencies: ["mongo-c-driver"], \ - }' > vcpkg.json && \ - cat vcpkg.json - RUN rm -rf _build && \ - make test-manifest-mode - -vcpkg-base: - FROM alpine:3.18 - RUN apk add cmake curl gcc g++ musl-dev ninja-is-really-ninja zip unzip tar \ - build-base git pkgconf perl bash linux-headers - ENV VCPKG_ROOT=/opt/vcpkg-git - ENV VCPKG_FORCE_SYSTEM_BINARIES=1 - GIT CLONE --branch=2023.06.20 https://github.com/microsoft/vcpkg $VCPKG_ROOT - RUN sh $VCPKG_ROOT/bootstrap-vcpkg.sh -disableMetrics && \ - install -spD -m 755 $VCPKG_ROOT/vcpkg /usr/local/bin/ - LET src_dir=/opt/mongoc-vcpkg-example - COPY src/libmongoc/examples/cmake/vcpkg/ $src_dir - WORKDIR $src_dir - -# run : -# Run one or more targets simultaneously. -# -# The “--targets†argument should be a single-string space-separated list of -# target names (not including a leading ‘+’) identifying targets to mark for -# execution. Targets will be executed concurrently. Other build arguments -# will be forwarded to the executed targets. -run: - LOCALLY - ARG --required targets - FOR __target IN $targets - BUILD +$__target - END diff --git a/3rdparty/mongo-c-driver-1.26.2/NEWS b/3rdparty/mongo-c-driver-1.26.2/NEWS deleted file mode 100644 index 903227c6b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/NEWS +++ /dev/null @@ -1,3571 +0,0 @@ -libmongoc 1.26.2 -================ - -Cyrus SASL: - - * Disable plugin loading with Cyrus SASL on Windows by default. To re-enable, set the CMake option `CYRUS_PLUGIN_PATH_PREFIX` to the absolute path prefix of the Cyrus SASL plugins. - -Fixes: - - * Fix possible hang if `mongoc_gridfs_file_readv` is called with a corrupt chunk with incomplete data. - * Fix assert with legacy exhaust cursor protocol when connected to server < 4.2. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - -libmongoc 1.26.1 -================ - -Fixes: - - * Fix 32-bit compile with 64-bit `time_t` - -Thanks to everyone who contributed to the development of this release. - - * Roberto C. Sánchez - - - -libmongoc 1.26.0 -================ - -New Features: - - * Support named KMS providers. - * Redirect retries in sharded clusters to another mongos if possible. - -Improvements: - - * Add `VERSION_CURRENT` file in source to ease building. - * Consider more errors retryable. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Jeremy Mikola - * Adrian Dole - * Kyle Kloberdanz - * Ezra Chung - * MongoCaleb - * Roberto C. Sánchez - * itrofimow - - - -libmongoc 1.25.4 -================ - -Fixes: - - * Restore support for Sphinx 1.7.6 for man page build. - -libmongoc 1.25.3 -================ - -Fixes: - - * Disable shared libmongoc targets if `ENABLE_SHARED=OFF` - * Fix documentation build with Python 3.9. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - -libmongoc 1.25.2 -================ - -Fixes: - - * Fix data race in `mongoc_cursor_get_host`. - * Accept discouraged timeout values for backwards compatibility. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Ezra Chung - * Kyle Kloberdanz - * Roberto C. Sánchez - -libmongoc 1.25.1 -================ - -Fixes: - - * Add back support for `BUILD_VERSION` CMake option. `BUILD_VERSION` was unintentionally removed in 1.25.0. - -libmongoc 1.25.0 -================ - -Fixes: - - * Send `recoveryToken` in transactions when connected to a load balancer. - -Improvements: - - * Remove optional dependency of libicu. - * Use OP_MSG exhaust for mongod >= 4.2. Enable exhaust cursors for mongos >= 7.1. - * Share cached credentials for SCRAM authentication among all clients to improve performance. - * Use polling monitoring in FaaS environments. - -Build Configuration: - - * Remove `ENABLE_SRV=AUTO`. Only support boolean values for `ENABLE_SRV`. - -Platform Support: - - * Support for macOS 10.14 is dropped. - * Support for Ubuntu 14.04 is dropped. - * Support for Debian 8.1 is dropped. - -Other: - - * The constructed source-distribution archive is no longer available as a - release artifact. Please instead use the per-release repository archive - attached to a GitHub release, or clone the repository at the desired release - tag. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Colby Pike - * Adrian Dole - * Roberto C. Sánchez - * Ezra Chung - * Joshua Siegel - * Kyle Kloberdanz - * Jeremy Mikola - -libmongoc 1.24.4 -================ - -Fixes: - * Fix build failure caused by missing `bson-dsl.h` install in libbson. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - -libmongoc 1.24.3 -================ - -Fixes: - - * Fix possible memory leak on SCRAM authentication failure. - * Fix possible recursive lock on network error in single-threaded client. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Jeremy Mikola - * Roberto C. Sánchez - -libmongoc 1.24.2 -================ - -Fixes: - - * Fix possible crash if thread creation fails. - * Fix possible assertion if `mongoc_cursor_new_from_command_reply_with_opts` is called with open cursor and no `serverId` option. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - -libmongoc 1.24.1 -================ - -Fixes: - - * Remove unnecessary assert in bulk API. May result in an abort when creating bulk operations with the `mongoc_bulk_operation_new` API intended for wrapping drivers. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - -libmongoc 1.24.0 -================ - -New Features: - - * Support MongoDB server version 7.0. - * Support updated Queryable Encryption protocol. - * Introduces backwards breaking changes to the Queryable Encryption protocol. Using Queryable Encryption now requires MongoDB server version 7.0+. - * Support new Queryable Encryption features. - * Add `mongoc_client_encryption_create_encrypted_collection` to automatically create data encryption keys when creating a new encrypted collection. - * Support new security features. - * Add ability to fetch KMS credentials automatically from Azure, GCP, and AWS environments. - * Support authentication with KMS AWS temporary credentials. - * Cache fetched AWS credentials. - * Support AWS IAM Roles for service accounts, EKS in particular. - * Retry operations if the connection handshake fails. - * Add index creation helper: `mongoc_collection_create_indexes_with_opts`. - -Fixes: - - * Fix default applied credentials for Kerberos with SSPI on Windows. - * Fix possible overcounting in Performance Counters used by `mongoc-stat`. - -Language Standard Support: - - * C89 support has been dropped. C99 is the default tested C standard. - -Platform Support: - - * Support for macOS 10.14 will be dropped in an upcoming release. - * Support for Ubuntu 14.04 will be dropped in an upcoming release. - * Support for Debian 8.1 will be dropped in an upcoming release. - -Build Configuration: - - * The `ENABLE_BSON` configure-time option has been removed. Build scripts that - used `ENABLE_BSON=SYSTEM` should be updated to use `USE_SYSTEM_LIBBSON=TRUE`. - If the build script needs to support building arbitrary versions of the C - driver, add both `ENABLE_BSON=SYSTEM` and `USE_SYSTEM_LIBBSON=TRUE`. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Ezra Chung - * Colby Pike - * Gil Alon - * Kyle Kloberdanz - * Jeremy Mikola - * Andreas Braun - * Kondaiah Valagonda - * Joshua Siegel - * Roberto C. Sánchez - * Romain Geissler @ Amadeus - * bisht2050 - * Adrian Dole - -libmongoc 1.23.5 -================ - -Fixes: - - * Fix potential crash due to insufficient memory when allocating performance counters. - * Fix compilation error on Android platforms due to missing `aligned_alloc`. - * Return an error if `RewrapManyDataKey` is invoked without a `provider` when a `masterKey` is given. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Romain Geissler @ Amadeus - - -libmongoc 1.23.4 -================ - -Fixes: - - * Fix possible failure to authenticate with MONGODB-X509 after network error. - -Thanks to everyone who contributed to the development of this release. - - * Andreas Braun - * Kevin Albertson - * Kyle Kloberdanz - - - -libmongoc 1.23.3 -================ - -Fixes: - - * Better handle malformed `hello` responses - * Handle `connectionId` of type `double`. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Gil Alon - * Kondaiah Valagonda - - - -libmongoc 1.23.2 -================ - -Bug fixes: - - * Fix compile on M1 macOS fails due to undeclared function (getpagesize) - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Kyle Kloberdanz - - -libmongoc 1.22.2 -================ - - * Fix connectivity to Atlas Data Lake - * Additional bugfixes from libbson 1.22.2 - -Thanks to everyone who contributed to the development of this release. - - * Andreas Braun - * Kevin Albertson - * Roberto C. Sánchez - - -libmongoc 1.23.1 -================ - -Bug fixes: - - * Fix connectivity to Atlas Data Lake - * Fix crash when dropping a malformed Queryable Encryption collection. - -Thanks to everyone who contributed to the development of this release. - - * Andreas Braun - * Kevin Albertson - - - -libmongoc 1.23.0 -================ - -Features: - - * Add on-demand Credentials Callback for CSFLE - * Support obtaining AWS credentials for CSFLE in the same way as for MONGODB-AWS - -Improvements: - - * Reducing Warnings of Misaligned Address of Over-Aligned Types - -Bug fixes: - - * Do not spawn mongocryptd if mongo_shared shared library is loaded. - -Thanks to everyone who contributed to the development of this release. - - * Ezra Chung - * Colby Pike - * Kevin Albertson - * Roberto C. Sánchez - - - -libmongoc 1.22.1 -================ - -Bug fixes: - - * Fix documentation build when using Sphinx 5.0 or newer - * Update patch release of libmongocrypt to 1.5.2: Fix a potential data - corruption bug in RewrapManyDataKey when rotating encrypted data encryption - keys backed by GCP or Azure key services. - - The following conditions will trigger this bug: - - A GCP-backed or Azure-backed data encryption key being rewrapped requires - fetching an access token for decryption of the data encryption key. - - The result of this bug is that the key material for all data encryption keys - being rewrapped is replaced by new randomly generated material, destroying - the original key material. - - To mitigate potential data corruption, upgrade to this version or higher - before using RewrapManyDataKey to rotate Azure-backed or GCP-backed data - encryption keys. A backup of the key vault collection should always be taken - before key rotation. - -Other: - - * Update to Fedora 37 for RPM builds - * Dependency build of libmongocrypt re-uses the libbson of the depending - libmongoc - -Thanks to everyone who contributed to the development of this release. - - * Ezra Chung - * Roberto C. Sánchez - * Kevin Albertson - - - -libmongoc 1.21.2 -================ - -Bug Fixes: - * Address vulnerability in bundled zlib by updating to 1.1.12. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Colby Pike - - - -libmongoc 1.22.0 -================ - -Bug fixes: - - * Do not auto decrypt before emitting CommandSucceeded events. - -Improvements: - - * Use OP_MSG if a server API version is requested. - -Features: - - * Add server connectionId to command monitoring events. - * Add support for the comment field to all helpers. - * Support mongo_shared shared library. - * Support pre-point-in-time change stream events. - * Support Queryable Encryption. - * Support 'let' option for multiple CRUD commands. - * Add Key Management API functions. - -Notes: - - * The 5.0-compat release (1.18.0) accidentally broke estimatedDocumentCount on views by changing its implementation to use aggregate and a $collStats stage instead of the count command. - * The new release is fixing estimatedDocumentCount on views by reverting back to using count in its implementation. - * Due to an oversight, the count command was omitted from the Stable API in server versions 5.0.0 - 5.0.8 and 5.1.0 - 5.3.1, so users of the Stable API with estimatedDocumentCount are recommended to upgrade their MongoDB clusters to 5.0.9 or 5.3.2 (if on Atlas) or set apiStrict: false when constructing their MongoClients. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Jeremy Mikola - * Colby Pike - * Ezra Chung - * Roberto C. Sánchez - * Jake Molnar - * Jesse Williamson - * Remi Collet - - - -libmongoc 1.21.1 -================ - -Bug Fixes: - * Use static decls for OpenSSL 1.1 polyfills - * Prevent possible crash in _mongoc_cursor_fetch_stream - -Thanks to everyone who contributed to the development of this release. - - * Jeremy Mikola - * Remi Collet - - - -libmongoc 1.21.0 -================ - -Bug Fixes: - * Addressed VS 2013 build failures due to missing C99 features. - -Features: - * Support conditional $merge and $out aggregation on secondaries. - * Bump minimum wire protocol version from 3 (MongoDB 3.0) to 6 (MongoDB 3.6). - * Bump maximum wire protocol version from 14 (MongoDB 5.1) to 15 (MongODB 5.2). - -Improvements: - * Update algorithm used for generation of OID values to reduce collisions. - -Thanks to everyone who contributed to the development of this release. - - * Ezra Chung - * Colby Pike - * Kevin Albertson - * Roberto C. Sánchez - * David CARLIER - * Jeremy Mikola - - - -libmongoc 1.20.1 -================ - -Bug fixes: - - * Fix bug where first hello command on a single-threaded client may not include full handshake. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - -libmongoc 1.20.0 -================ - -Features: - - * Improve multi-threaded performance of client pool. - * Support KMIP as a provider for Client-Side Field Level Encryption (CSFLE). - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Ezra Chung - * Colby Pike - * Jesse Williamson - * Jeremy Mikola - * Kaitlin Mahar - -mongo-c-driver 1.19.2 -===================== - -Announcing libmongoc 1.19.2. - -Bug fixes: - -* Fix assert on invalid URI options in client pools connected to load balanced clusters when a topology closed callback is registered. - -Thanks to everyone who contributed to the development of this release. - ---Kevin Albertson - -libmongoc 1.19.1 -================ - -It is my pleasure to announce libmongoc 1.19.1. - -Bug fixes: - - * Permit NULL platform argument in mongoc_handshake_data_append. - * Fix wire version check in server selection when maxStalenessSeconds is specified in read preferences. - * Fix assert on invalid URI options in client pools connected to load balanced clusters. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Ezra Chung - ---Kevin Albertson - - -mongo-c-driver 1.19.0 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.19.0 release. -This release adds full support for MongoDB 5.0 servers and MongoDB Atlas Serverless Instances. - -Features: - - * Add full support to connect to MongoDB Atlas Serverless Instances. - * Add support for snapshot reads on a session with mongoc_session_opts_set_snapshot. - * Support the new URI option loadBalanced to connect to a MongoDB cluster behind a TCP load balancer. - -Bug fixes: - - * Fix the uploadDate set on newly created GridFS files in the mongoc_gridfs_bucket_t API. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Jeremy Mikola - * Benjamin Rewis - * Andreas Braun - * Colby Pike - * Ezra Chung - * Roberto C. Sánchez - * Jesse Williamson - ---Kevin Albertson - - -mongo-c-driver 1.18.0 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.18.0 release. -This release adds partial support for MongoDB 5.0 servers. - -Features: - - * Introduces support to select an API version when connecting to a MongoDB instance. - * Supports Azure and Google Cloud Platform as Key Management Service (KMS) providers in Client-Side Field Level Encryption (CSFLE). - * Support "let" option in aggregate command. - * Support time series collections. - * Relax validation for insert and replace documents to support fields containing dots and dollars. - * Expose the reason operations fail document validation. - -Bug fixes: - - * Forward opts from mongoc_gridfs_bucket_find to underlying find operation. - * Fixes a possible hang when a limited size client pool is waiting for a client to become available in mongoc_client_pool_pop. - -Improvements - - * Deprecate API containing deprecated terminology. - * Use "hello" command for monitoring servers. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Roberto C. Sánchez - * Andreas Braun - * Clyde Bazile - * Benjamin Rewis - * Jeremy Mikola - * Andrew Witten - * Samantha Ritter - * samantharitter - * Fermín Galán Márquez - * David Carlier - * Colby Pike - * Josh Weinstein - * Pierre Mickael Gonzalo - -mongo-c-driver 1.18.0-alpha -=========================== - -It is my pleasure to announce the MongoDB C Driver 1.18.0-alpha. - -This is an unstable prerelease and is unsuitable for production applications. - -Features: - - * Introduces support to select an API version when connecting to a MongoDB instance. - * Supports Azure and Google Cloud Platform as Key Management Service (KMS) providers in Client-Side Field Level Encryption (CSFLE) - -Bug fixes: - - * Fixes a possible hang when a limited size client pool is waiting for a client to become available in mongoc_client_pool_pop. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Roberto C. Sánchez - * Clyde Bazile - * Andreas Braun - * Andrew Witten - * Samantha Ritter - * Benjamin Rewis - * Fermín Galán Márquez - * David Carlier - * Josh Weinstein - * Pierre Mickael Gonzalo - -mongo-c-driver 1.17.7 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.17.7. - -- Print correct error message when DNS resolution fails -- Mix time to avoid duplicate RAND_bytes for the same PIDs - -Thanks to everyone who contributed to the development of this release. - - * Andreas Braun - * Jeremy Mikola - ---Kevin Albertson - - -mongo-c-driver 1.17.6 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.17.6. - -Bug fixes: - - * Fix possible crash when speculative authentication fails with network error. - -Thanks to everyone who contributed to the development of this release. - - * Andreas Braun - ---Kevin Albertson - - -mongo-c-driver 1.17.5 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.17.5. - -Improvements: - - * Fix documentation regarding when to call mongoc_log_set_handler - -Thanks to everyone who contributed to the development of this release. - - * Clyde Bazile - * Fermín Galán Márquez - ---Kevin Albertson - - -mongo-c-driver 1.17.4 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.17.4. - -Bug fixes: - - * Fix crash on macOS on client pool shutdown. - * Fix spacing in extended JSON output for numberLong. - * Clear error in mongoc_collection_find_and_modify_with_opts on a successful retry. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Samantha Ritter - --- Kevin Albertson - - -mongo-c-driver 1.17.3 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.17.3. - -Bug fixes: - - * Do not send session ID on GSSAPI auth commands. - * Fix build against zlib when zlib is installed in non-standard location. - * Fix build when source directory path contains a space. - * Fix a platform-specific bug causing mongoc_client_pool_pop to block indefinitely if all clients are checked out. - * Fix a possible buffer overflow with hostnames resolving to IPv6 addresses on OpenSSL. - - -Thanks to everyone who contributed to the development of this release. - - * Roberto C. Sánchez - * Kevin Albertson - * Andrew Witten - * gonzalo - --- Kevin Albertson - - -mongo-c-driver 1.17.2 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.17.2. - -Bug fixes: - - * Stop the SRV polling thread when an SRV URI is used to connect to a deployment other than a sharded cluster. - -Thanks to everyone who contributed to the development of this release. - - * Roberto C. Sánchez - * Kevin Albertson - --- Kevin Albertson - - -mongo-c-driver 1.17.1 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.17.1. - -Bug fixes: - - * Fix SRV/TXT record lookup for DNS records exceeding 1024 bytes. - --- Kevin Albertson - - -mongo-c-driver 1.17.0 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.17.0 release. -This release adds support for MongoDB 4.4 servers. - -Features: - - * Support streamable server monitoring to reduce recovery time when the server topology changes. - * Support the MONGODB-AWS authentication mechanism. - * Support Online Certificate Status Protocol (OCSP). - * Support configuring hedged reads in read preferences. - * Reduce the number of round trips necessary for SCRAM and X509 authentication. - * Monitor servers in parallel when using a mongoc_client_pool_t instead of doing serial scans. - * Support the "hint" option in operations using the update, replace, delete, and findAndModify commands. - * Improve behavior for retryable writes. - * Improve resuming behavior of change streams on server errors. - * Remove restriction of 255 character collection namespaces. - -Bug fixes: - - * Fix criteria for resumable errors in change streams. - * Fix rare crashes when server is invalidated during authentication. - * Reject client session for mongoc_collection_estimated_document_count. - * Fix behavior of a SecondaryPreferred read preference for exhaust cursor operations against a sharded cluster. Prior to the fix, a nonzero maxStalenessSeconds would not trigger sending the read preference. - * Fix SRV polling. Prior to the fix, SRV polling did not properly apply newly discovered results. - * Fix checks for existing GridFS indexes to handle indexes created by the MongoDB shell. - * Fix possible use of invalidated streams during an unordered OP_QUERY bulk write, and when ending many pooled sessions at client destruction. - * Fix a crash when setting the crl_file TLS option for Secure Channel. - * Avoid emitting duplicate ServerChanged events when no change is observed during monitoring. - * Properly handle large SASL messages instead of erroring. - -Notes: - - * Deprecated "lib" prefixed artifacts are no longer produced when building on Windows. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Roberto C. Sánchez - * Andrew Witten - * Andreas Braun - * Clyde Bazile - * Josh Weinstein - --- Kevin Albertson - -mongo-c-driver 1.17.0 rc0 -========================= - -It is my pleasure to announce the MongoDB C Driver 1.17.0 rc0 release. -This release adds support for MongoDB 4.4 servers. - -Features: - - * Support streamable server monitoring to reduce recovery time when the server topology changes. - * Support tlsDisableCertificateRevocationCheck when built with Secure Channel. - -Bug fixes: - - * Fix criteria for resumable errors in change streams. - * Fix rare crashes when server is invalidated during authentication. - * Improve behavior when reaching out to OCSP responders for certificate revocation checking. - * Reject client session for mongoc_collection_estimated_document_count. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Andrew Witten - * Roberto C. Sánchez - * Clyde Bazile - --- Kevin Albertson - -mongo-c-driver 1.17.0 beta2 -=========================== - -It is my pleasure to announce the MongoDB C Driver 1.17.0 beta2 release. - -Features: - - * Support Online Certificate Status Protocol (OCSP) response caching. - * Support configuring hedged reads in read preferences. - * Reduce the number of round trips necessary for SCRAM and X509 authentication. - * Monitor servers in parallel when using a mongoc_client_pool_t instead of doing serial scans. - * Support OCSP on older versions of OpenSSL (1.0.1+). - -Bug fixes: - - * Fix behavior of a SecondaryPreferred read preference for exhaust cursor operations against a sharded cluster. Prior to the fix, a nonzero maxStalenessSeconds would not trigger sending the read preference. - * Fix SRV polling. Prior to the fix, SRV polling did not properly apply newly discovered results. - * Fix checks for existing GridFS indexes to handle indexes created by the MongoDB shell. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Roberto C. Sánchez - * Andreas Braun - * Clyde Bazile - * Josh Weinstein - --- Kevin Albertson - - -mongo-c-driver 1.17.0 beta -========================== - -It is my pleasure to announce the MongoDB C Driver 1.17.0 beta release. - -Features: - - * Support the MONGODB-AWS authentication mechanism. - * Support the Online Certificate Status Protocol (OCSP) for OpenSSL 1.1.0+, Secure Transport, and Secure Channel. - * Support the "hint" option in operations using the update, replace, delete, and findAndModify commands. - * Improve behavior for retryable writes. - * Improve resuming behavior of change streams on server errors. - * Remove an extra round trip for SCRAM authentication. - * Remove restriction of 255 character collection namespaces. - -Bug fixes: - - * Fix possible use of invalidated streams during an unordered OP_QUERY bulk write, and when ending many pooled sessions at client destruction. - * Fix a crash when setting the crl_file TLS option for Secure Channel. - * Avoid emitting duplicate ServerChanged events when no change is observed during monitoring. - * Properly handle large SASL messages instead of erroring. - -Notes: - - * Deprecated "lib" prefixed artifacts are no longer produced when building on Windows. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Roberto C. Sánchez - * Andreas Braun - * Clyde Bazile - * Jeremy Mikola - * Sara Golemon - --- Kevin Albertson - - -mongo-c-driver 1.16.1 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.16.1. - -Bug fixes: - - * Fix listed library dependency on mongoc_static target when building with libmongocrypt. - * Replace a call of free to bson_free. - * Vendor Sphinx basic theme and correctly list static files for docs. - * Fix a compilation warning introduced in 1.16.0. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - -Peace, - - Kevin Albertson - - -mongo-c-driver 1.16.0 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.16.0. - -Features: - - * Support Client-side Field Level Encryption. - * Support ability to pass an index hint to update operations. - * Add cmake export targets. - -Bug fixes: - * Fix a bug with Windows SSPI failing to authenticate with GSSAPI when using - pooled clients for certain operations. - * Fix behavior for bulk writes that retry to keep track of the successful server. - * Remove hard limit of 1024 characters for SRV response. - * Fix racy crash when using client pool against a sharded cluster if a server is invalidated shortly before a new socket is opened against it. - * Remove unnecessary library dependencies causing overlinking. - * Ensure server proof has been validated during SCRAM conversation. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Jeremy Mikola - * Clyde Bazile - * Andreas Braun - * Roberto C. Sánchez - * Samantha Ritter - * Isabel Atkinson - * Kaitlin Mahar - * Diego Barrios Romero - * Sara Golemon - * Vasil Velichkov - * EGuesnet - -Peace, - - Kevin Albertson - -mongo-c-driver 1.15.3 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.15.3. - -Bug fixes: - * Fix a hang on macOS when connecting to a server over TLS - * Add zstd as a dependency when libmongoc static library is compiled with zstd support - * Fix compilation on AIX 6.1 - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Samantha Ritter - * EGuesnet - -mongo-c-driver 1.15.2 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.15.2. - -Bug fixes: - * Prevent mongoc_transaction_opts_set_max_commit_time_ms from applying to subsequent transactions that should be using the default. - * Do not report the initial error if a retry for a change stream function (mongoc_collection_watch, mongoc_database_watch, or mongoc_client_watch) succeeds - -Thanks to everyone who contributed to the development of this release. - - * Andreas Braun - * Clyde Bazile - -Peace, - - Kevin Albertson - - -mongo-c-driver 1.15.1 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.15.1. - -Bug fixes: - * Fix change stream resume logic when no documents received - * Reduce the required cmake version to build with zstd support - * Minor fixes to mongos pinning logic - * Do not resume a change stream on NonResumableChangeStreamError - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Clyde Bazile - -Peace, - - Clyde Bazile - -mongo-c-driver 1.15.0 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.15.0. This release adds -support for MongoDB 4.2 features. - -Features: - - * Support for sharded transactions on MongoDB sharded clusters 4.2+. - * Add convenient transaction runner (mongoc_client_session_with_transaction), - which accepts a callback and performs appropriate retry logic. - * Add a new transaction option to specify maximum time to wait for a commit, - mongoc_transaction_opts_set_max_commit_time_ms. - * Add URI option "retryReads=true" safely and automatically retries certain - read operations if the server is a MongoDB 3.6+. - * Poll SRV records to mongos servers periodically. - * Keep connections alive after a primary stepdown detected. - * Standardizes URI options supported across all spec-compliant MongoDB drivers. - * "retryWrites" URI option now defaults to true (requires crypto for session - support). - * Send any aggregate with $out or $merge stage to a primary. - * Add the ability to specify an aggregate pipeline as an update document. - * Add a database aggregate helper, mongoc_database_aggregate. - * Add option for change streams, "startAfter". - * Add mongoc_change_stream_get_resume_token, which returns the resume token - which should be used to resume a change stream. - * Add support for zstd compression. - -Bug fixes: - * Correctly report an error in mongoc_change_stream_next if the resume token - (_id) is not a document. Previously, an error was only reported if the - field was missing. - * Fix mongoc_collection_update with MONGOC_UPDATE_MULTI_UPDATE, - mongoc_collection_remove, and mongoc_collection_delete when retryWrites - was enabled. They would fail previously. - * Command options are now correctly taken into account when batching bulk - writes for OP_QUERY. It was possible to exceed the maximum document size - before. - * Fix a crash if a multi-batch bulk write with OP_MSG errored on a batch. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Jeremy Mikola - * Haris Sheikh - * Samantha Ritter - * Isabel Atkinson - * Sara Golemon - * Clyde Bazile - * Roberto C. Sánchez - * Lior Kaplan - * pasniak - -Peace, - - Kevin Albertson - - -mongo-c-driver 1.14.1 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.14.1. - -Bug fixes: - - * Prohibit starting a transaction for pre-4.0 MongoDB servers. - * Prohibit starting a sharded transaction for pre-4.2 MongoDB servers. - -Thanks to everyone who contributed to the development of this release. - - * Jeremy Mikola - * Clyde Bazile - -Peace, - - Kevin Albertson - - -mongo-c-driver 1.14.0 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.14.0. - - -Features: - - * Support for OpenSSL 1.1.1 and its implementation of TLS v1.3. - * New function mongoc_stream_should_retry. - * New accessor mongoc_server_description_last_update_time. - * New method mongoc_client_reset to be called after forking. - -Bug fixes: - - * OP_MSG with unacknowledged writes (write concern of w:0) would serialize - incorrectly on big-endian platforms, causing writes to use the default - write concern of w:1. - * mongoc_collection_update_many and mongoc_collection_delete_many would fail - with the URI option retryWrites=true. - * In a transaction, the driver now properly ignores the readConcern configured - on a client, database, or collection: only the mongoc_transaction_opt_t's - readConcern is used. - * Remove timestamp from uninstall scripts to permit reproducible build. - * Setting mongoc_ssl_opt_t.pem_file or ca_file to a bad file path caused a - hang with Darwin SSL. - * Fix the ENABLE_SASL cmake option: - * Remove unnecessary GSSAPI value. It was equivalent to specifying ENABLE_SASL=CYRUS. - * ENABLE_SASL=AUTO now correctly chooses SSPI on Windows instead of CYRUS. - * The client pool failed to set proper apm callbacks for clients created - via try_pop(). - - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Roberto C. Sánchez - * Kevin Albertson - * Samantha Ritter - * Spencer McKenney - * Henrik Edin - * Jeremy Mikola - * Evgeni Dobranov - * Derick Rethans - * 平民·寻梦(Pingmin Fenlly Liu) - * David Carlier - * Gustaf Neumann - * Jeroen - * Jeroen Ooms - * Kaitlin Mahar - * Tomas Mozes - * Clyde Bazile - -Peace, - - Samantha Ritter - - -mongo-c-driver 1.13.1 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.13.1. - -Bug fixes: - - * mongoc_collection_update_many and mongoc_collection_delete_many would fail - with the URI option retryWrites=true. - * Remove timestamp from uninstall scripts to permit reproducible build. - * Add missing header files to the release tarball to fix compilation when - configuring with ENABLE_SASL=GSSAPI. - * Separate libmongoc and libbson uninstall scripts so they do not overwrite - each other. - * Fix running make install with DESTDIR. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * A. Jesse Jiryu Davis - * Henrik Edin - -Peace, - - Kevin Albertson - - -mongo-c-driver 1.13.0 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.13.0. - -Features: - - * Report a new error code, MONGOC_ERROR_GRIDFS_CORRUPT, when a chunk larger - than chunkSize is detected. Before, the driver had crashed with an assert. - * Restructure of install directory. All mongoc headers are under mongoc/ - and all bson headers are under bson/. The preferred way of including the - headers are mongoc/mongoc.h and bson/bson.h respectively. - Forwarding headers in the root are provided for backwards compatibility. - * The default CMake build type had been unspecified, now it is RelWithDebInfo. - * Support LibreSSL 2.7+. - -Bug fixes: - - * mongoc_collection_replace_one is now a correctly exported symbol. - * Fix multiple issues with readConcern and writeConcern inheritance. - * Fix rare crash with mongodb+srv URIs on Windows. - * mongoc_gridfs_create_file_from_stream ignored errors while writing chunks - to the server. - * The following functions should not have taken a "bypassDocumentValidation" - option in bson_t *opts, the option is now prohibited: - - mongoc_bulk_operation_insert_with_opts - - mongoc_bulk_operation_update_one_with_opts - - mongoc_bulk_operation_update_many_with_opts - - mongoc_bulk_operation_replace_one_with_opts - * The heartbeat-succeeded and heartbeat-failed events (part of SDAM - Monitoring) had uninitialized "duration" fields, they are now set correctly. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Roberto C. Sánchez - * Kevin Albertson - * Henrik Edin - * Spencer McKenney - * Jeremy Mikola - * Evgeni Dobranov - * Tomas Mozes - * Derick Rethans - * Gustaf Neumann - * Jeroen Ooms - * Kaitlin Mahar - -Peace, - - Kevin Albertson - - -mongo-c-driver 1.12.0 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.12.0. - -Features: - - * New function mongoc_client_session_in_transaction to check if a multi- - document transaction is started. - * New examples for change streams and transactions, improved guide for - migrating from mongoc_collection_count to mongoc_collection_count_documents - -Bug fixes: - - * Fix occasional crash in sharded queries - * Retry all retryable write concern errors - * mongoc_client_session_commit_transaction sets the correct error label when - the primary is unavailable - * mongoc_collection_find_with_opts had prohibited read preference "primary" - in a transaction - * mongoc_collection_aggregate had not inherited its mongoc_collection_t's - read preference; only an explicitly provided read preference was used. - * Allow unencoded delimiters in username/password if unambiguous - -Thanks to everyone who contributed to the development of this release. - - * Roberto C. Sánchez - * A. Jesse Jiryu Davis - * Kevin Albertson - * Spencer McKenney - * Evgeni Dobranov - * Jeremy Mikola - * 平民·寻梦(Pingmin Fenlly Liu) - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.11.0 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.11.0. This release adds -support for MongoDB 4.0 features. It includes the following additions and -improvements: - - * Multi-document transactions, see mongoc_client_session_start_transaction - * New function mongoc_error_has_label to check for specific error labels such - as "TransientTransactionError" or "UnknownTransactionCommitResult" in - error replies. - * New functions to subscribe to changes on an entire client or database: - - mongoc_client_watch - - mongoc_database_watch - * New option for change streams, "startAtOperationTime". - * mongoc_collection_count_with_opts is deprecated for two new functions: - - mongoc_collection_count_documents - - mongoc_collection_estimated_document_count - * Support for SCRAM-SHA-256 authentication, including support for non-ASCII - passwords using libicu is an optional dependency. - * Faster mongoc_database_get_collection_names_with_opts fetches only names, - not the entire collection metadata. - -Additional changes not specific to MongoDB 4.0: - - * All "destroy" functions such as mongoc_collection_destroy now ignore a NULL - argument. - * The driver now returns an error if you attempt to use "arrayFilters" in an - update with a MongoDB server older than 3.6. - * Update functions include a new "upsertedCount" field in the reply document. - * Replace MD5 with FNV-1a hash to generate ObjectIds (for FIPS compliance). - -Bug fixes: - - * Functions incorrectly marked with the "const" compiler attribute are now - marked as "pure", fixes build error when link-time optimization is enabled. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Kevin Albertson - * Evgeni Dobranov - * Spencer McKenney - * Jeremy Mikola - * Roberto C. Sánchez - * Remi Collet - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.10.3 -===================== - -No change since 1.10.2; released to keep pace with libbson's version. - --- A. Jesse Jiryu Davis - - -mongo-c-driver 1.10.2 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.10.2. This release fixes -the libbson and libmongoc installed library filenames and SONAMEs on Linux. -They had changed unintentionally with the switch to CMake in 1.10.0; they are -now consistent with 1.9.x and previous releases. Thanks to Roberto C. Sánchez -for the fix. - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.10.1 -===================== - -It is my pleasure to announce the MongoDB C Driver 1.10.1. This release fixes -the following bugs introduced in version 1.10.0: - - * Client sessions were not prohibited with unacknowledged write concern and - mongoc_bulk_operation_execute; now they are prohibited. Client sessions have - been prohibited with all other unacknowledged writes since 1.10. - * The "arrayFilters" update option, new in MongoDB 3.6 and supported since - libmongoc 1.9.0, was inadvertently prohibited by - mongoc_bulk_operation_update_one_with_opts and - mongoc_bulk_operation_update_many_with_opts in 1.10. The option is now - permitted again. - * The mongoc-stat tool for displaying shared counters was disabled on Linux - and not installed; it is now restored. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Jeremy Mikola - * Remi Collet - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.10.0 -===================== - -It is my pleasure to announce MongoDB C Driver 1.10.0. This version drops -support for MongoDB 2.6 and adds the following features and bugfixes: - - * libbson and libmongoc are now maintained in the mongo-c-driver repository, - although they are still built as separate libraries, and libbson can still - be used without libmongoc. - * Building libbson and libmongoc now requires CMake on all platforms. The - Autotools build scripts ("configure" and related scripts) have been deleted. - See the "installing" page for updated instructions, including the new - ENABLE_MONGOC option and changes to the ENABLE_BSON option. - * IPv6 is now fully supported and conforms to RFC-6555. If a hostname has both - IPv4 and IPv6 DNS records, the driver tries connecting with IPv6 first. If a - connection can't be established after 250ms then IPv4 is tried in parallel. - Whichever succeeds connection first cancels the other. The successful DNS - result is cached for 10 minutes. - * If CMake is configured with ENABLE_SSL=AUTO (the default), libmongoc now - uses native TLS libraries on Mac and Windows, and OpenSSL everywhere else. - Before, it would search for OpenSSL on all platforms and only use native - TLS on Mac and Windows as a fallback. - * The driver now handshakes SSL connections to multiple servers in a replica - set or sharded cluster in parallel, so long as it uses OpenSSL or Windows - SChannel. (SSL handshakes with Apple's Secure Transport are still serial.) - A larger receive buffer with SChannel increases performance over slow - connections. - * All functions that accept read concern now prohibit it, if MongoDB is too - old to support it (MongoDB 3.0). - * Client sessions are now prohibited with unacknowledged writes. - * mongoc_collection_find_and_modify_with_opts now prohibits write concern if - MongoDB is too old to support it (MongoDB 3.0). - * Other helper functions for commands that write, now prohibit write concern - if MongoDB is too old to support it (pre-3.4): - mongoc_client_read_write_command_with_opts - mongoc_client_write_command_with_opts - mongoc_collection_read_write_command_with_opts - mongoc_collection_write_command_with_opts - mongoc_database_read_write_command_with_opts - mongoc_database_write_command_with_opts - mongoc_collection_aggregate with $out - mongoc_collection_drop_index_with_opts - mongoc_collection_drop_with_opts - mongoc_collection_rename_with_opts - mongoc_database_drop_with_opts - Write concern behavior is unchanged for regular CRUD functions. - * Setting a negative writeConcern level of -2 or smaller, via the "opts" - parameter to functions that accept BSON options, is now prohibited. The - special "w" values -2 through -4 are only used internally. The deprecated - "w=-1" is still allowed, as a synonym for "w=0". - * The Kerberos URI option authMechanismProperties=CANONICALIZE_HOST_NAME:true - is now implemented with the Windows Kerberos provider, SSPI. - * This repository now includes GDB and LLDB customizations for pretty-printing - bson_t structs as JSON while debugging. See the "debugging" page. - * The internal preprocessor symbol HAVE_STRINGS_H has been renamed - BSON_HAVE_STRINGS_H. If you maintain a handwritten bson-config.h you must - rename this symbol. - * The following helper functions do not work with mongoc_client_session_t, - they are deprecated in favor of running MongoDB commands directly with a - function like mongoc_client_read_command_with_opts: - mongoc_client_get_server_status - mongoc_collection_stats - mongoc_collection_validate - * mongoc_cursor_is_alive is now deprecated for mongoc_cursor_more, which is - functionally equivalent. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Kevin Albertson - * Roberto C. Sánchez - * Jeremy Mikola - * Xiangyu Yao - * Jeroen Ooms - * Derick Rethans - * Kaitlin Mahar - * Pavithra Vetriselvan - * NotSpooky - * Iulian Rotaru - * Katherine Walker - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.9.5 -==================== - -It is my pleasure to announce mongo-c-driver 1.9.5. This release fixes the following bugs: - - * New change streams API functions were not marked extern "C" - * mongoc_collection_watch now accepts a pipeline argument as a BSON array, in - addition to accepting a BSON document with a "pipeline" array field - * Crashes in several change stream error handling paths - * Commands could return false with an empty bson_error_t after a replica set - reconfig - * Network error messages omitted the command name when using OP_MSG - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Kevin Albertson - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.9.4 -==================== - -It is my pleasure to announce mongo-c-driver 1.9.4. This release offers -compatibility with Sphinx 1.7.0 and above and fixes two bugs: - - * Ensure a change stream uses the proper session id while iterating - * Fix a rare crash in pooled mode when a replica set member was disconnected - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Kevin Albertson - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.9.3 -==================== - -It is my pleasure to announce mongo-c-driver 1.9.3. This version fixes a -session-management bug that could cause an authentication error while connected -to MongoDB 3.6+ and iterating a cursor, and it permits the $gleStats modifier -with mongoc_collection_aggregate. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Jeremy Mikola - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.9.2 -==================== - -No change since 1.9.1; released to keep pace with libbson's version number. - --- A. Jesse Jiryu Davis - - -mongo-c-driver 1.9.1 -==================== - -It is my pleasure to announce mongo-c-driver 1.9.1. This release fixes a bug -that caused session ID to be included in authentication and server monitoring -commands. Thanks to Jeremy Mikola for finding and fixing the issue. - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.9.0 -==================== - -It is my pleasure to announce mongo-c-driver 1.9.0. This version drops support -for MongoDB 2.4 and adds support for MongoDB 3.6 features: - - * New struct mongoc_change_stream_t to watch a collection for changes. - * New struct mongoc_client_session_t represents a MongoDB 3.6 session, - which supports causal consistency: you are guaranteed to read your writes - and to perform monotonic reads, even when reading from secondaries or in - a sharded cluster. - * New functions that accept flexible options as a BSON document. These - accept a "sessionId" option and any future options. In addition, the - two new "update" functions accept the "arrayFilters" option that is new - in MongoDB 3.6: - mongoc_collection_insert_one - mongoc_collection_insert_many - mongoc_collection_update_one - mongoc_collection_update_many - mongoc_collection_replace_one - mongoc_collection_delete_one - mongoc_collection_delete_many - mongoc_client_command_with_opts - mongoc_database_command_with_opts - mongoc_collection_command_with_opts - mongoc_client_find_databases_with_opts - mongoc_client_get_database_names_with_opts - mongoc_collection_create_bulk_operation_with_opts - mongoc_collection_find_indexes_with_opts - mongoc_database_find_collections_with_opts - mongoc_database_get_collection_names_with_opts - * New URI option "retryWrites=true" safely and automatically retries certain - write operations if the server is a MongoDB 3.6 replica set or sharded - cluster. - * Support for MongoDB OP_MSG wire protocol. - -Additional changes not specific to MongoDB 3.6: - - * Support for mongodb+srv URIs to query DNS for SRV and TXT records that - configure the connection to MongoDB. - * Support LibreSSL with CMake build - * The "minPoolSize" URI option is deprecated: it's confusing and not useful. - -Bug fixes: - - * mongoc_bulk_operation_execute did not always initialize "reply". - * Fix C99 pedantic warnings. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Jeremy Mikola - * Kevin Albertson - * Jeroen Ooms - * Iulian Rotaru - * Derick Rethans - * Graham Whitted - * Brian Moss - * Alex Masterov - * Michael Kuhn - * Sriharsha Vardhan - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.8.2 -==================== - -It is my pleasure to announce mongo-c-driver 1.8.2. This release fixes the -following bugs: - - * Remove option to bundle the Snappy compression library, it caused issues - for programs linking to libmongoc - * Fix pkg-config and CMake config file flags for programs that statically - link to libmongoc when libmongoc is statically linked to zLib - * The configure flag "--with-zlib=no" was ignored - Crash in authentication when username is NULL - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Derick Rethans - * Hannes Magnusson - * Jeremy Mikola - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.8.1 -==================== - -It is my pleasure to announce mongo-c-driver 1.8.1. This release fixes the -following bugs: - - * Remove a syntax error in the configure script that affects some shells. - * The configure script respects --with-zlib=system and --with-snappy=system. - * The internal mongoc_server_description_t struct is properly reinitialized - after a network error. - * Fix the encoding of this NEWS file. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Jeremy Mikola - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.8.0 -==================== - - * The zLib and Snappy compression libraries are bundled if not available. - Wire protocol compression is enabled on Windows. - * mongoc_collection_find_and_modify_with_opts now respects a "writeConcern" - field in the "extra" BSON document in its mongoc_find_and_modify_opts_t. - * The command functions mongoc_client_read_write_command_with_opts, - mongoc_database_read_write_command_with_opts, and - mongoc_collection_read_write_command_with_opts now ignore the "read_prefs" - parameter. - * mongoc_collection_create_index and mongoc_collection_create_index_with_opts - are both now deprecated. Use mongoc_database_write_command_with_opts - instead; a guide to creating an index using that function has been added. - * Use select, not WSAPoll, on Windows. - * Always mark a server "Unknown" after a network error (besides a timeout). - * mongoc_client_pool_t sends platform metadata to the server; before, only a - single mongoc_client_t did. - * New stream method mongoc_stream_timed_out. - * Wire version checks introduced in 1.8.0 will prevent the driver from - connecting to a future MongoDB server version if its wire protocol is - incompatible. - * New CMake option ENABLE_MAINTAINER_FLAGS. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Jeremy Mikola - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.7.0 -==================== - -It is my pleasure to announce mongo-c-driver 1.7.0. - -New features and bug fixes: - - * CMake build now installs .pc files for programs that link to libmongoc using - pkg-config. Both the CMake and Autotools build systems now install .cmake - files for programs that link to libmongoc using CMake. Linking to libmongoc - statically or dynamically is now much more convenient. See the new tutorial - section "Include and link libmongoc in your C program". - * New CMake option ENABLE_STATIC can be ON, OFF, or AUTO (the default) - * Minimum required CMake version has been increased to 3.1. - * CMake remains experimental on non-Windows platforms and issues a warning now - * Support for wire compression. - * Support for snappy and zlib. MongoDB 3.4 only supports snappy, while zlib - support is expected in MongoDB 3.6. - The enable, configure mongoc like so: - ./configure --with-snappy --with-zlib - * New functions: mongoc_uri_get_compressors & mongoc_uri_set_compressors, to - get and set compressor configuration on mongoc_uri_t - * Added support for comma separated "compressors" connection string option (e.g. - mongodb://localhost/?compressors=snappy,zlib) - * Added support for configuring zlib compression level in the connection string - (e.g. mongodb://localhost/?compressors=zlib&zlibcompressionlevel=8) - * Now requires the use of CMake config files for libbson to build libmongoc - with CMake - * Added pkg-config support for libressl. - * New function mongoc_uri_set_auth_mechanism to update the authentication - mechanism of a mongoc_uri_t after it is created from a string. - * New function mongoc_bulk_operation_insert_with_opts provides immediate - error checking. - * New function mongoc_uri_new_with_error provides a way to parse a connection - string, and retrieve the failure reason, if any. - * Support for MongoDB Connection String specification - * All connection string options are now represented by MONGOC_URI_xxx macros - * Paths to Unix Domain Sockets must be url encoded - * Repeated options now issue warnings - * Special characters in username, password and other values must be url encoded - * Unsupported connection string options now issue warnings - * Boolean values can now be represented as true/yes/y/t/1 and false/no/n/f/0. - * Case is now preserved in Unix domain paths. - * New function mongoc_cursor_error_document provides access to server's error - reply if a query or command fails. - * New function mongoc_write_concern_is_default determines whether any write - concern options have been set, and mongoc_read_concern_is_default checks if - read concern options are set. - * mongoc_gridfs_find_one_with_opts optimized to use limit 1. - -Thanks to everyone who contributed to the development of this release. - - * Hannes Magnusson - * A. Jesse Jiryu Davis - * David Golden - * Jeremy Mikola - * Bernard Spil - * Aleksander Melnikov - * Adam Seering - * Remi Collet - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.6.0 -==================== - -It is my pleasure to announce mongo-c-driver 1.6.0. - -New features and bug fixes: - - * Enterprise authentication on Windows now uses the native GSSAPI library; - Cyrus SASL is no longer required for enterprise auth on Windows. - * BSON documents are more thoroughly validated before insert or update. - * New function mongoc_uri_set_mechanism_properties to replace all the - authMechanismProperties on an existing URI. - * mongoc_uri_get_mechanism_properties asserts its inputs are not NULL. - * For consistency with other MongoDB drivers, mongoc_collection_save is - deprecated in favor of mongoc_collection_insert or mongoc_collection_update. - * The driver is now built and continuously tested with MinGW-W64 on Windows. - * Experimental support for HPUX. - * The correct operation ids are now passed to Command Monitoring callbacks. - * Fix a crash if the driver couldn't connect to the server to create an index. - * The documentation is ported from Mallard XML to ReStructured Text, the - HTML documentation is restyled, and numerous man page syntax errors fixed. - * Getter functions for options in mongoc_find_and_modify_opts_t: - * mongoc_find_and_modify_opts_get_bypass_document_validation - * mongoc_find_and_modify_opts_get_fields - * mongoc_find_and_modify_opts_get_flags - * mongoc_find_and_modify_opts_get_max_time_ms - * mongoc_find_and_modify_opts_get_sort - * mongoc_find_and_modify_opts_get_update - * All public functions now have the __cdecl calling convention on Windows. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Aleksander Melnikov - * Jeroen Ooms - * Brian McCarthy - * Jonathan Wang - * Peter Beckman - * Remi Collet - * Rockford Wei - * Alexey Ponomarev - * Christopher Wang - * David Golden - * Jeremy Mikola - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.5.5 -==================== - -It is my pleasure to announce mongo-c-driver 1.5.5. This release fixes bugs -parsing the localThresholdMS option from the MongoDB URI, and a crash in -mongoc_cursor_destroy if "query" or "filter" are invalid. Thanks to Jeremy -Mikola. - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.5.4 -==================== - -It is my pleasure to announce mongo-c-driver 1.5.4. This release fixes an error -in cursor iteration when a readConcern is set. Thanks to Jeremy Mikola and -Hannes Magnusson. - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.5.3 -==================== - -This release fixes a bug that prevented connecting to IPv4-only MongoDB servers -by hostname. - -https://jira.mongodb.org/browse/CDRIVER-1988 - -The driver has reverted to its 1.5.1 behavior: it connects to MongoDB over IPv6 -if given an IPv6 connection string like "mongodb://[::1]", and requires an IPv4 -connection when given a hostname like "mongodb://localhost". - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.5.2 -==================== - -It is my pleasure to announce mongo-c-driver 1.5.2. - -Thanks to everyone who contributed to the development of this release. - -New bug fixes: - * CDRIVER-1975 allow mixed $ and non-$ query ops. - * CDRIVER-1972 Support for ipv6 hostnames. - * CDRIVER-1971 Missing exports of mongoc_gridfs_file_set_*() functions. - * CDRIVER-1970 update define constants for "find" opts to be unique. - * CDRIVER-1964 Windows CA stores should be opened with read-only flag. - -Thanks to everyone who contributed to the development of this release. - - * Hannes Magnusson - * A. Jesse Jiryu Davis - * Alexey Ponomarev - * Peter Beckman - * Rockford Wei - -Peace, - - Hannes Magnusson - - -mongo-c-driver 1.5.1 -==================== - -It is my pleasure to announce mongo-c-driver 1.5.1. This is a bugfix release: - - * Fix SEGFAULT with performance counters on NUMA (thanks to Jonathan Wang). - * Prevent rare assertion error in mongoc_cluster_stream_for_server. - * Improve error messages from auth failure. - * Escape quotes when appending CFLAGS to handshake metadata. - * Fix OpenSSL header lookups in non-default paths. - * Fix build failure with LibreSSL. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Jeroen Ooms - * Jonathan Wang - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.5.0 -==================== - -It is my pleasure to announce mongo-c-driver 1.5.0. - -New features and bug fixes: - * MongoDB 3.4 Support - * New URI and read preference option, "maxStalenessSeconds" - * MongoDB Handshake - * writeConcern and readConcern enhancements - * Collation allows users to specify language-specific rules for string - comparison when sorting documents. See the code examples for - mongoc_client_read_command_with_opts, mongoc_collection_count_with_opts, - mongoc_collection_find_with_opts, and mongoc_index_opt_t, as well as the - "Setting Collation Order" section of the "Bulk Write Operations" guide. - * mongoc_collection_count_with_opts uses the collection's read preference if - none is passed in - * Improved TLS support - * Fixed LibreSSL (libssl) support - * Added LibreSSL (libtls) support - * Fixed Secure Channel build on VS 2010 - * OpenSSL now supports SNI (all others already do) - * Additional features for Application Performance Monitoring: - * mongoc_topology_description_has_writable_server - * mongoc_topology_description_has_readable_server - * New functions accept flexible options as a BSON document: - * mongoc_collection_find_with_opts - * mongoc_client_read_command_with_opts - * mongoc_client_write_command_with_opts - * mongoc_client_read_write_command_with_opts - * mongoc_database_read_command_with_opts - * mongoc_database_write_command_with_opts - * mongoc_database_read_write_command_with_opts - * mongoc_collection_read_command_with_opts - * mongoc_collection_write_command_with_opts - * mongoc_collection_read_write_command_with_opts - * mongoc_gridfs_find_with_opts - * mongoc_gridfs_find_one_with_opts - * mongoc_collection_find is now deprecated in favor of - mongoc_collection_find_with_opts. - * New helper function to include read concern in one of the above function's - options parameter: mongoc_read_concern_append. - * mongoc_client_command no longer applies the client's read preference and - read concern by default. Same change for mongoc_database_command and - mongoc_collection_command. - * mongoc_collection_count_with_opts now applies the collection's read - preference if no read preference is provided - * mongoc_collection_create_index and mongoc_collection_drop_index now apply - the collection's write concern. - * connectTimeoutMS timer now begins after DNS resolution, and resets - for each interface attempted (e.g., if the driver first tries IPv6, - then IPv4). - * New error code MONGOC_ERROR_DUPLICATE_KEY. - * mongoc_collection_find no longer treats the "filter" key specially in - queries - querying for a document with a key named "filter" is the same - now as any other key. - * The server description parameter to the following functions is "const": - * mongoc_server_description_host - * mongoc_server_description_id - * mongoc_server_description_ismaster - * mongoc_server_description_round_trip_time - * mongoc_server_description_type - * Exported symbols are no longer declared in separate export files. - This could break ABI with applications using clang, which previously - exported symbols from the internal private ABI. - * mongoc no longer crashes when multi roundtrip bulk operation fails. - * Added support for the new readConcernLevel "linearizable". - * Clients now check for misformatted "readPreferenceTags" in URI. - * New CMake option ENABLE_TRACING allows debug output, which before had only - been available with "configure --enable-tracing". - * Bugfix: "PossiblePrimary"-type replicas could be selected for reads - * Bugfixes: The random number generator used to select servers is now properly - seeded, and secondary queries are now properly distributed according to - localThresholdMS, not just to the lowest-latency secondary. - * mongoc_collection_insert, mongoc_collection_update, mongoc_collection_remove - consistently use domain MONGOC_ERROR_BSON, code MONGOC_ERROR_BSON_INVALID - if passed oversized BSON, and MONGOC_ERROR_COLLECTION for other errors. - mongoc_bulk_operation_execute continues to use MONGOC_ERROR_COMMAND for - all errors. - * If mongoc_client_pool_t fails to start its scanner thread in the background, - it logs and aborts instead of silently continuing, then failing to connect. - * The driver now updates its view of the whole topology with information from - each new connection handshake. - * mongoc_client_set_apm_callbacks can be used repeatedly to change or clear - the list of monitoring callbacks. - * Improved error reporting when the driver fails to reach the server. - -Deprecations: - * mongoc_collection_find is deprecated for mongoc_collection_find_with_opts. - -Removed configure flags: - * --enable-experimental has been removed. All previously experimental - features are now always on. - * The configure option "--enable-hardening" had had no effect. It is removed - in favor of system-wide compiler configuration. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Fiona Rowan - * Ian Boros - * Remi Collet - * Brian McCarthy - * Jeroen Ooms - * J. Rassi - * Christoph Schwarz - * Alexey Vorobeyev - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.4.2 -==================== - -It is my pleasure to announce mongo-c-driver 1.4.2. This release fixes bugs in -"minPoolSize" logic, see CDRIVER-1558 for details. - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.4.1 -==================== - -It is my pleasure to announce mongo-c-driver 1.4.1. This is a bugfix release: - - * mongoc_client_get_server_descriptions could return a list including NULLs - * Tailable cursors on MongoDB 3.2 only worked with MONGOC_QUERY_AWAIT_DATA - * Spurious warnings with MONGOC_DISABLE_SHM - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.4.0 -==================== - -It is my pleasure to announce the release of mongo-c-driver 1.4.0. - -TLS ---- - -The driver can now use the native TLS and crypto functions included in macOS -and Windows. OpenSSL is no longer required for TLS or authentication on Mac or -Windows. By default, OpenSSL is used if available, the default will switch in -version 2.0 to prefer native TLS. - -For native TLS on Mac: - - ./configure --enable-ssl=darwin - -For Windows: - - cmake "-DENABLE_SSL=WINDOWS" -G "Visual Studio 10 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" - -All of the TLS implementations now load the native default certificate store, -with OpenSSL on Windows falling back on the Windows native certificate store if -no other can be found. - -The "ca_dir" field on mongoc_ssl_opt_t is only supported by OpenSSL. All other -fields, including "pem_file", are supported by all implementations. - -A new field, "allow_invalid_hostname", has been added to mongoc_ssl_opt_t and is -preferred over the existing "allow_invalid_certificate" to disable hostname -verification. - -The driver now supports the latest OpenSSL 1.1 in addition to past versions. - -Application Performance Monitoring ----------------------------------- - -The driver implements the MongoDB Command Monitoring Spec. Applications can -record the duration and other details of every operation the driver performs on -the server. See "Introduction to Application Performance Monitoring" in the -docs. - -Error API ---------- - -New functions mongoc_client_set_error_api and mongoc_client_pool_set_error_api -allow applications to distinguish client and server errors. See the "Error -Reporting" doc. - -Unacknowledged Write Results ----------------------------- - -Unacknowledged writes (writes whose mongoc_write_concern_t "w" value is zero) -now reply with an empty document instead of one with nInserted: 0, nUpdated: 0, -and so on. - -Command functions now ignore the read preferences set on a client, database, -or collection. Instead, they use the mongoc_read_prefs_t passed in explicitly, -or default to "primary". This change was made to bring them in line with the -Server Selection Spec. These are the affected functions: - - * mongoc_client_command - * mongoc_client_command_simple - * mongoc_database_command - * mongoc_database_command_simple - * mongoc_collection_command - * mongoc_collection_command_simple - -On the other hand, the following command-specific helper functions now use the -collection's read preference: - - * mongoc_collection_count - * mongoc_collection_stats - -New functions to send maxTimeMS or any arbitrary options with findAndModify: - - * mongoc_find_and_modify_opts_set_max_time_ms - * mongoc_find_and_modify_opts_append - -New function to include a write concern with a generic command function -like mongoc_client_command_simple: - - * mongoc_write_concern_append - -Public API For Higher-Level Drivers ------------------------------------ - -New functions support language drivers (specifically the PHP and HHVM drivers) -using only the libmongoc public API: - - * mongoc_bulk_operation_get_hint - * mongoc_client_command_simple_with_server_id - * mongoc_client_get_server_description - * mongoc_client_get_server_description_by_id - * mongoc_client_get_server_descriptions - * mongoc_client_select_server - * mongoc_cursor_get_limit - * mongoc_cursor_new_from_command_reply - * mongoc_cursor_set_hint - * mongoc_cursor_set_limit - * mongoc_log_trace_disable - * mongoc_log_trace_enable - * mongoc_server_description_ismaster - * mongoc_server_description_round_trip_time - * mongoc_server_description_type - * mongoc_server_descriptions_destroy_all - * mongoc_uri_get_option_as_bool - * mongoc_uri_get_option_as_int32 - * mongoc_uri_get_option_as_utf8 - * mongoc_uri_option_is_bool - * mongoc_uri_option_is_int32 - * mongoc_uri_option_is_utf8 - * mongoc_uri_set_auth_source - * mongoc_uri_set_database - * mongoc_uri_set_option_as_bool - * mongoc_uri_set_option_as_int32 - * mongoc_uri_set_option_as_utf8 - * mongoc_uri_set_password - * mongoc_uri_set_read_concern - * mongoc_uri_set_read_prefs_t - * mongoc_uri_set_username - * mongoc_uri_set_write_concern - * mongoc_write_concern_is_acknowledged - * mongoc_write_concern_is_valid - * mongoc_write_concern_journal_is_set - -Now that these public APIs are available, the PHP drivers no longer define the -MONGOC_I_AM_A_DRIVER preprocessor symbol to access private APIs. The symbol is -removed from C Driver headers, and libmongoc-priv.so is no longer installed. - -Other Features --------------- - - * New connection string option "localThresholdMS". - * zSeries and POWER8 platform support. - * Performance enhancements, reduce allocation and copying in command code. - * All man page names now begin with "mongoc_" to avoid install conflicts. - * New function mongoc_gridfs_file_set_id. - -Deprecations ------------- - -Automatically calling mongoc_init and mongoc_cleanup is a GCC-specific feature -that is now deprecated, and will be removed in version 2. The driver should be -built with: - -./configure --disable-automatic-init-and-cleanup - -Or: - - cmake "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF" -G "Visual Studio 10 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" - -In this configuration, applications must explicitly init and cleanup libmongoc. - -Deprecated functions: - - * mongoc_write_concern_get_fsync - * mongoc_write_concern_set_fsync - -Notable Bug Fixes ------------------ - - * Logic bugs using tag sets to select replica set members with complex configs - * mongoc_client_get_database_names no longer filters out a replica set - member's "local" database. - * mongoc_client_get_gridfs now ensures the proper indexes on the files and - chunks collections. - * SecondaryPreferred fails if primary matches tags but secondaries don't. - * mongoc_collection_find_and_modify_with_opts can return true on - writeConcernError. - * mongoc_collection_validate doesn't always init "reply". - * The strings referred to by mongoc_ssl_opt_t, like pem_file and ca_file, are - now copied into the client or client pool by mongoc_client_set_ssl_opts or - mongoc_client_pool_set_ssl_opts, and need not be kept valid afterward. - * mongoc_collection_count_with_opts ignored flags and read_prefs. - * minPoolSize of 0 should mean "no minimum". - * mongoc_database_create_collection should always use the primary. - * The GSSAPI properties SERVICE_NAME and CANONICALIZE_HOST_NAME are now - properly parsed from the URI, see the "Authentication" doc for details. - * Comprehensive compatibility with various C standards and compilers. - -Acknowledgements ----------------- - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Ian Boros - * Fiona Rowan - * Jeremy Mikola - * Christoph Schwarz - * Mike Lloyd - * Remi Collet - * Jean-Bernard Jansen - * David Hatch - * Derick Rethans - * Brian Samek - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.3.5 -==================== - -It is my pleasure to announce mongo-c-driver 1.3.5. This release fixes a crash -in mongoc_cleanup when an allocator had been set with bson_mem_set_vtable, and -introduces a configure option MONGOC_NO_AUTOMATIC_GLOBALS which prevents code -built with GCC from automatically calling mongoc_init and mongoc_cleanup when -your code does not. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.3.4 -==================== - -It is my pleasure to announce the MongoDB C Driver 1.3.4. This release fixes a -security vulnerability: when a mongoc_client_t uses SSL and is disconnected, it -failed to re-verify the server certificate after reconnecting. This flaw affects -single clients, not pooled ones. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Remi Collet - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.3.3 -==================== - -It is my pleasure to announce MongoDB C Driver 1.3.3. This fixes a bug where -a slightly-oversized bulk write operation was not split into batches; instead, -it was sent whole to the server, which rejected it. - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.3.2 -==================== - -It is my pleasure to announce MongoDB C Driver 1.3.2. This is a bugfix release: - - * A socket is properly discarded after a network error from a command. - * mongoc_database_get_collection now copies the database's read preferences, - read concern, and write concern, instead of copying the client's. - * mongoc_cursor_t's private struct now allows a negative limit. - -Thanks to everyone who contributed to this release. - - * A. Jesse Jiryu Davis - * Jeremy Mikola - * Hannes Magnusson - -Peace, - - A. Jesse Jiryu Davis - - - -mongo-c-driver 1.3.1 -==================== - -It is my pleasure to announce MongoDB C Driver 1.3.1. This is a bugfix release: - - * mongoc_client_get_gridfs now copies the client's read preferences, read - concern, and write concern to the newly created mongoc_gridfs_t. Before - this fix, GridFS operations were always executed with the default config: - data was read from the primary, with the read concern level "local", and - written with write concern "acknowledged". Now, if you have configured any - of these options on the mongoc_client_t, they are respected by the - mongoc_gridfs_t. - * CMakeLists.txt now includes and installs the pkg-config files. - -Thanks to everyone who contributed to this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Christopher Wang - * Jean-Bernard Jansen - * Jeremy Mikola - * Jeroen Ooms - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.3.0 -==================== - -It is my pleasure to announce to you the release of the MongoDB C Driver 1.3.0. - -Changes since the release candidate 1.3.0-rc0: - - * Fix a cursor bug introduced on big-endian platforms in 1.3.0-beta0. - * Improve documentation for mongoc_host_list_t. - * Move private mongoc_host_list_t functions from public header. - * Refactor the build system to declare library version in one place. - -All new features and changes since the previous stable release, 1.2.1: - - * If the driver is compiled without SSL support but a URI with "ssl=true" - is passed to mongoc_client_new, mongoc_client_new_from_uri, or - mongoc_client_pool_new, the function logs an error and returns NULL. Before, - the driver would attempt a non-SSL connection. - * mongoc_collection_find_and_modify will now apply the mongoc_collection_t's - write_concern_t when talking to MongoDB 3.2. - * Support for MongoDB 3.2's "readConcern" feature for queries, counts, and - aggregations. The option "readConcernLevel" is now accepted in the MongoDB - URI. New struct mongoc_read_concern_t, and functions operating on it: - - mongoc_client_get_read_concern - - mongoc_client_set_read_concern - - mongoc_database_get_read_concern - - mongoc_database_set_read_concern - - mongoc_collection_get_read_concern - - mongoc_collection_set_read_concern - - mongoc_read_concern_copy - - mongoc_read_concern_destroy - - mongoc_read_concern_get_level - - mongoc_read_concern_new - - mongoc_read_concern_set_level - - mongoc_uri_get_read_concern - * Support for MongoDB 3.2's "bypassDocumentValidation" option for writes. - * New struct mongoc_bulk_write_flags_t and related functions: - - mongoc_bulk_operation_set_bypass_document_validation - * New struct mongoc_find_and_modify_opts_t and related functions: - - mongoc_find_and_modify_opts_new - - mongoc_find_and_modify_opts_destroy - - mongoc_find_and_modify_opts_set_sort - - mongoc_find_and_modify_opts_set_update - - mongoc_find_and_modify_opts_set_fields - - mongoc_find_and_modify_opts_set_flags - - mongoc_find_and_modify_opts_set_bypass_document_validation - - mongoc_collection_find_and_modify_with_opts - * New functions to copy database and collection handles: - - mongoc_collection_copy - - mongoc_database_copy - * Support for MongoDB 3.2 wire protocol: use commands in place of OP_QUERY, - OP_GETMORE, and OP_KILLCURSORS messages. - * To explain a query plan with MongoDB 3.2, you must now call the "explain" - command, instead of including the "$explain" key in a mongoc_collection_find - query. See the mongoc_collection_find documentation page for details. - * Configurable wait time on tailable cursors with MongoDB 3.2: - - mongoc_cursor_get_max_await_time_ms - - mongoc_cursor_set_max_await_time_ms - * Use electionId to detect a stale replica set primary during a network split. - * Disconnect from replica set members whose "me" field does not match the - connection address. - * The client side matching feature, mongoc_matcher_t and related functions, - are deprecated and scheduled for removal in version 2.0. - * New CMake options ENABLE_SSL, ENABLE_SASL, ENABLE_TESTS, and ENABLE_EXAMPLES. - * Use constant-time comparison when verifying credentials. - * Combine environment's CFLAGS with configure options when building. - * Improved man page output and "whatis" entries. - -There are extensive bugfixes and improvements in GridFS since 1.2.1, including: - - * Handle seeking, reading, and writing past the end of a GridFS file. - * If a GridFS chunk is missing, mongoc_gridfs_file_readv sets file->error to - domain MONGOC_ERROR_GRIDFS and a new code MONGOC_ERROR_GRIDFS_CHUNK_MISSING. - * Optimization for long seeks forward with mongoc_gridfs_file_seek. - -Other fixes since 1.2.1: - - * Memory leaks in mongoc_database_has_collection and mongoc_cursor_next. - * Report writeConcern failures from findAndModify and from legacy writes. - * Memory leak in mongoc_database_find_collections. - * Set OP_QUERY's nToReturn from the provided limit. - * Fix compiler warnings and errors, especially with Visual Studio 2015, - GCC 4.8, and IBM XL C. - * Bugs and typos in tutorial examples. - -Thanks to everyone who contributed to this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Kyle Suarez - * Jose Sebastian Battig - * Matt Cotter - * Claudio Canella - * alexeyvo - * Christopher Wang - * Flavio Medeiros - * Iago Rubio - * Jeremy Mikola - * Victor Leschuk - * Jason Carey - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.3.0-rc0 -======================== - -It is my pleasure to announce to you the first release candidate of MongoDB C -driver 1.3.0. It includes additive ABI changes and bugfixes, and support for -the upcoming MongoDB 3.2. It is compatible with MongoDB 2.4 and later. - -New features and changes since 1.3.0-beta0: - - * If the driver is compiled without SSL support but a URI with "ssl=true" - is passed to mongoc_client_new, mongoc_client_new_from_uri, or - mongoc_client_pool_new, the function logs an error and returns NULL. Before, - the driver would attempt a non-SSL connection. - * New functions to copy database and collection handles: - - mongoc_collection_copy - - mongoc_database_copy - * If a GridFS chunk is missing, mongoc_gridfs_file_readv sets file->error to - domain MONGOC_ERROR_GRIDFS and a new code MONGOC_ERROR_GRIDFS_CHUNK_MISSING. - * Use electionId to detect a stale replica set primary during a network split. - * Disconnect from replica set members whose "me" field does not match the - connection address. - * The client side matching feature, mongoc_matcher_t and related functions, - are deprecated and scheduled for removal in version 2.0. - * New CMake options ENABLE_SSL, ENABLE_SASL, ENABLE_TESTS, and ENABLE_EXAMPLES. - * The build system is refactored to declare the current version and latest - release in one place. - -Other fixes: - - * Memory leaks in mongoc_database_has_collection and mongoc_cursor_next. - * Report writeConcern failures from findAndModify and from legacy writes. - -Thanks to everyone who contributed to this release candidate. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Matt Cotter - * Claudio Canella - * Victor Leschuk - * Flavio Medeiros - * Christopher Wang - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.3.0-beta0 -========================== - -It is my pleasure to announce to you the beta of MongoDB C driver 1.3.0. -This beta includes additive ABI changes and bugfixes, and support for -the upcoming MongoDB 3.2. It is compatible with MongoDB 2.4 and later. - -New features and changes: - - * mongoc_collection_find_and_modify will now apply the mongoc_collection_t's - write_concern_t when talking to MongoDB 3.2. - * Support for MongoDB 3.2's "readConcern" feature for queries, counts, and - aggregations. The option "readConcernLevel" is now accepted in the MongoDB - URI. New struct mongoc_read_concern_t, and functions operating on it: - - mongoc_client_get_read_concern - - mongoc_client_set_read_concern - - mongoc_database_get_read_concern - - mongoc_database_set_read_concern - - mongoc_collection_get_read_concern - - mongoc_collection_set_read_concern - - mongoc_read_concern_copy - - mongoc_read_concern_destroy - - mongoc_read_concern_get_level - - mongoc_read_concern_new - - mongoc_read_concern_set_level - - mongoc_uri_get_read_concern - * Support for MongoDB 3.2's "bypassDocumentValidation" option for writes. - * New struct mongoc_bulk_write_flags_t and related functions: - - mongoc_bulk_operation_set_bypass_document_validation - * New struct mongoc_find_and_modify_opts_t and related functions: - - mongoc_find_and_modify_opts_new - - mongoc_find_and_modify_opts_destroy - - mongoc_find_and_modify_opts_set_sort - - mongoc_find_and_modify_opts_set_update - - mongoc_find_and_modify_opts_set_fields - - mongoc_find_and_modify_opts_set_flags - - mongoc_find_and_modify_opts_set_bypass_document_validation - - mongoc_collection_find_and_modify_with_opts - * Configurable wait time on tailable cursors with MongoDB 3.2: - - mongoc_cursor_get_max_await_time_ms - - mongoc_cursor_set_max_await_time_ms - * Support for MongoDB 3.2 wire protocol: use commands in place of OP_QUERY, - OP_GETMORE, and OP_KILLCURSORS messages. - * To explain a query plan with MongoDB 3.2, you must now call the "explain" - command, instead of including the "$explain" key in a mongoc_collection_find - query. See the mongoc_collection_find documentation page for details. - * Use constant-time comparison when verifying credentials. - * Combine environment's CFLAGS with configure options when building. - * Improved man page output and "whatis" entries. - -Extensive bugfixes and improvements in GridFS, including: - - * Handle seeking, reading, and writing past the end of a GridFS file. - * Optimization for long seeks forward with mongoc_gridfs_file_seek. - -Other fixes: - - * Memory leak in mongoc_database_find_collections. - * Set OP_QUERY's nToReturn from the provided limit. - * Fix compiler warnings and errors, especially with Visual Studio 2015, - GCC 4.8, and IBM XL C. - * Bugs and typos in tutorial examples - -Thanks to everyone who contributed to this beta release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Kyle Suarez - * Jose Sebastian Battig - * Jeremy Mikola - * Iago Rubio - * Matt Cotter - * alexeyvo - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.2.2 -==================== - -It is my pleasure to announce to you the MongoDB C driver 1.2.2. - -This release fixes a rare bug where the driver can direct reads to hidden -secondaries unintentionally. It also includes fixes and improvements to the -build system. - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.2.1 -==================== - -It is my pleasure to announce to you the MongoDB C driver 1.2.1. - -This release includes critical bugfixes for SSL connections with -mongoc_client_pool_t, and for Unix domain socket connections. - -The documentation is updated for a change introduced in version 1.2.0: -mongoc_client_set_ssl_opts and mongoc_client_pool_set_ssl_opts now configure -the driver to require an SSL connection to the server, even if "ssl=true" is -omitted from the MongoDB URI. Before, SSL options were ignored unless -"ssl=true" was included in the URI. - -The build instructions are improved, including the steps to build with OpenSSL -on OS X El Capitan. Build errors and warnings are fixed for clang in gnu99 -mode and MinGW. - -Thanks to everyone who contributed to this version of libmongoc. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Tamas Nagy - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.2.0 -==================== - -It is my pleasure to announce to you the MongoDB C driver 1.2.0. - -This is a stable release with additive ABI changes and bugfixes. It is -compatible with MongoDB version 2.4 and later. - -The following notes summarize changes since the previous stable release, -1.1.11, including changes in the 1.2.0 betas and release candidate. - -This version rewrites mongoc_client_t's internals to match two important new -specs for MongoDB drivers: the Server Discovery And Monitoring Spec and the -Server Selection Spec. The rewritten client has many advantages: - - * All replica set members or mongos servers are discovered and periodically - checked in parallel. The driver's performance is dramatically better and - more predictable with multi-server deployments, or with a flaky network, - or when some servers are slow or down. - * Clients from the same mongoc_client_pool_t share a background thread that - discovers and monitors all servers in parallel. - * Unnecessary round trips for server checks and pings are eliminated. - * Behavior is documented in the specs, and consistent with other drivers, - even in complex or unusual scenarios. - * The URI's "replicaSet" option is enforced: the driver now refuses to connect - to a server unless it is a member of a replica set with the correct setName. - * Many race conditions related to changing deployment conditions are fixed. - -To conform to the new specs, the client now accepts these options in the -MongoDB URI; see the mongoc_uri_t documentation for details: - - * heartbeatFrequencyMS - * serverSelectionTimeoutMS - * serverSelectionTryOnce - * socketCheckIntervalMS - -Other features: - - * All timeouts that can be configured in the URI now interpret 0 to mean "use - the default value for this timeout". - * The client's read preference can be configured in the URI with the new - options "readPreference" and "readPreferenceTags"; see the mongoc_uri_t - documentation. - * The new mongoc_uri_get_read_prefs_t function retrieves both the read mode - and tags from a mongoc_uri_t. - * New accessors mongoc_gridfs_file_get_id, mongoc_client_get_default_database, - and mongoc_bulk_operation_get_write_concern. - * Debug tracing can be controlled at runtime with mongoc_log_trace_enable and - mongoc_log_trace_disable. - * Set mongoc_client_pool_t's size with mongoc_client_pool_min_size() - and mongoc_client_pool_max_size(). - -Other changes: - - * Enable runtime asserts in release build. - * The libbson submodule's URL now uses the recommended https://, not git:// - * mongoc_client_kill_cursor is now deprecated and will be removed in 2.0. - * The write concern "w=-1" is documented as obsolete. - -These notable bugs have been fixed since 1.1.11: - - * The driver now uses the server's maxWireVersion to avoid an error and - extra round-trip when executing aggregations on MongoDB 2.4 and older. - * Much improved reporting of network errors, unavailable servers, and - authentication failure - * Off-by-one error in mongoc_gridfs_file_seek with mode SEEK_END - * The writeConcernErrors field of bulk results is properly formatted. - * A cursor with a server "hint" sets slaveOkay and / or $readPreference. - * Destroying an exhaust cursor must close its socket - * "wtimeoutms" was ignored for write concerns besides "majority". - * Bulk write operations might fail in mixed-version sharded clusters with - some pre-2.6 mongos servers. - * A variety of bugs and incorrect results in mongoc_bulk_operation_execute. - * Numerous compiler warnings and build failures on various platforms. - * Copious refinements to the documentation. - -Thanks to everyone who contributed to this version of libmongoc. - - * Jason Carey - * Samantha Ritter - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Kyle Suarez - * Jeremy Mikola - * Remi Collet - * Jose Sebastian Battig - * Derick Rethans - * Yuchen Xie - * Manuel Schoenlaub - * Sujan Dutta - * Lloyd Zhou - * rubicks - * Pawel Szczurko - * Yuval Hager - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.2.0-rc0 -======================== - -It is my pleasure to announce the release candidate of the MongoDB C driver -1.2.0. It includes features and bugfixes developed since 1.2.0-beta1. - -Notable bugs fixed: - - * Much improved reporting of network errors, unavailable servers, and - authentication failure - * Destroying an exhaust cursor must close its socket - * Various bugs in server reconnection logic - * mongoc_collection_aggregate returned invalid cursor after failure - * Wrong error message after failed network write on Sparc - * Missing JSON test files in release tarball - -Other changes: - - * Enable runtime asserts in release build. - * mongoc_client_kill_cursor is now deprecated and will be removed in - version 2.0. - -This release candidate also includes all bugfixes from 1.1.11. - -Version 1.2.0 final will be a stable release with additive ABI changes and -bugfixes. It is compatible with MongoDB version 2.4 and later. - -Thanks to everyone who contributed to this version of libmongoc. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Kyle Suarez - * rubicks - * Jose Sebastian Battig - * Jason Carey - * Remi Collet - * Yuval Hager - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.2.0-beta1 -========================== - -It is my pleasure to announce the second beta release of the MongoDB C driver -1.2.0. It includes features and bugfixes developed since 1.2.0-beta. - -New features: - - * Set mongoc_client_pool_t's size with mongoc_client_pool_min_size() - and mongoc_client_pool_max_size(). - * The write concern "w=-1" is now documented as obsolete. - * Abundant fixes and additions to the documentation, beyond those in the - previous beta. - -Notable bugs fixed: - - * Crashes and races in several replica set scenarios. - * The driver now uses the server's maxWireVersion to avoid an error and - extra round-trip when executing aggregations on MongoDB 2.4 and older. - * Fixed network error handling in multiple code paths. - * connectTimeoutMS limits the time the driver can spend reconnecting to - servers in single-threaded (non-pooled) mode with serverSelectionTryOnce. - -Version 1.2.0 final will be a stable release with additive ABI changes and -bugfixes. It is compatible with MongoDB version 2.4 and later. - -Thanks to everyone who contributed to this version of libmongoc. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Manuel Schoenlaub - * Kyle Suarez - * Remi Collet - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.2.0-beta -========================= - -It is my pleasure to announce to you the first beta release of the MongoDB C -driver 1.2.0. - -This release is a stable release with additive ABI changes and bugfixes. -It is compatible with MongoDB version 2.4 and later. - -Version 1.2.0 rewrites mongoc_client_t's internals to match two important new -specs for MongoDB drivers: the Server Discovery And Monitoring Spec and the -Server Selection Spec. The rewritten client has many advantages: - - * All replica set members or mongoses are discovered and periodically - checked in parallel. The driver's performance is dramatically better and - more predictable with multi-server deployments, or with a flaky network, - or when some servers are slow or down. - * Clients from the same mongoc_client_pool_t share a background thread that - discovers and monitors all servers in parallel. - * Unnecessary round trips for server checks and pings are eliminated. - * Behavior is documented in the specs, and consistent with other drivers, even - in complex or unusual scenarios. - * The URI's "replicaSet" option is enforced: the driver now refuses to connect - to a server unless it is a member of a replica set with the right setName. - * Many race conditions related to changing deployment conditions are fixed. - -To conform to the new specs, the client now accepts these options in the MongoDB -URI; see the mongoc_uri_t documentation for details: - - * heartbeatFrequencyMS - * serverSelectionTimeoutMS - * serverSelectionTryOnce - * socketCheckIntervalMS - -Other features: - - * All timeouts that can be configured in the URI now interpret 0 to mean "use - the default value for this timeout". - * The client's read preference can be configured in the URI with the new - options "readPreference" and "readPreferenceTags", see the mongoc_uri_t - documentation. - * The new mongoc_uri_get_read_prefs_t function retrieves both the read mode - and tags from a mongoc_uri_t. - * New accessors mongoc_gridfs_file_get_id, mongoc_client_get_default_database, - and mongoc_bulk_operation_get_write_concern. - * Debug tracing can be controlled at runtime with mongoc_log_trace_enable and - mongoc_log_trace_disable. - -Notable bugs fixed: - - * "wtimeoutms" was ignored for write concerns besides "majority". - * Bulk write operations might fail in mixed-version sharded clusters with - some pre-2.6 mongos servers. - * Normal operations were logged during startup and could not be silenced. - * A variety of bugs and incorrect results in mongoc_bulk_operation_execute. - * Numerous compiler warnings and build failures on various platforms. - * Copious refinements to the documentation. - -Thanks to everyone who contributed to this version of libmongoc. - - * A. Jesse Jiryu Davis - * Sujan Dutta - * Jason Carey - * Hannes Magnusson - * Jeremy Mikola - * Derick Rethans - * Samantha Ritter - * Yuchen Xie - * Lloyd Zhou - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.1.11 -===================== - -It is my pleasure to announce to you the MongoDB C driver 1.1.11. - -This is a patch release with bug fixes: - - * Undetected network errors when sending messages to the server - * Off-by-one error in mongoc_gridfs_file_seek with mode SEEK_END - * Memory leak parsing a URI that contains an invalid option - * The libbson submodule's URL now uses the recommended https://, not git:// - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Jason Carey - * Jose Sebastian Battig - * rubicks - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.1.10 -===================== - -It is my pleasure to announce to you the MongoDB C driver 1.1.10. - -This is a patch release with bug fixes: - - * Occasional crash reconnecting to replica set. - * Queries sent to recovering replica set members. - * Memory leak when calling ismaster on replica set members. - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - - * A. Jesse Jiryu Davis - * Daniil Zaitsev - * Jason Carey - * Jeremy Mikola - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.1.9 -==================== - -It is my pleasure to announce to you the MongoDB C driver 1.1.9. - -This release fixes a common crash in 1.1.8, which itself was introduced while -fixing a rare crash in 1.1.7. For further details: - -https://jira.mongodb.org/browse/CDRIVER-721 -https://jira.mongodb.org/browse/CDRIVER-695 - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.1.8 -==================== - -UPDATE: 1.1.8 suffered a severe new bug so I removed the release from GitHub: - -https://jira.mongodb.org/browse/CDRIVER-721 - -This is a patch release with bug fixes: - - * Crash freeing client after a replica set auth error. - * Compile error strict C89 mode. - -mongo-c-driver 1.1.7 -==================== - -It is my pleasure to announce to you the 1.1.7 release of the MongoDB C driver. - -This is a patch release with bug fixes: - - * Thread-safe use of Cyrus SASL library. - * Experimental support for building with CMake and SASL. - * Faster reconnection to replica set with some hosts down. - * Crash iterating a cursor after reconnecting to a replica set. - * Unchecked errors decoding invalid UTF-8 in MongoDB URIs. - * Fix error reporting from mongoc_client_get_database_names. - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - - * A. Jesse Jiryu Davis - * Jason Carey - * Hannes Magnusson - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.1.6 -==================== - -It is my pleasure to announce to you the 1.1.6 release of the MongoDB C driver. - -This is a patch release with performance enhancements and bug fixes: - - * mongoc_bulk_operation_execute now coalesces consecutive update operations - into a single message to a MongoDB 2.6+ server, yielding huge performance - gains. Same for remove operations. (Inserts were always coalesced.) - * Large numbers of insert operations are now properly batched according to - number of documents and total data size. - * GSSAPI / Kerberos auth now works. - * The driver no longer tries three times in vain to reconnect to a primary, - so socketTimeoutMS and connectTimeoutMS now behave *closer* to what you - expect for replica sets with down members. A full fix awaits 1.2.0. - -I snuck in a feature: - - * mongoc_matcher_t now supports basic subdocument and array matching - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - - * A. Jesse Jiryu Davis - * Jason Carey - * Kai Mast - * Matt Cotter - -Peace, - - A. Jesse Jiryu Davis - - -mongo-c-driver 1.1.5 -==================== - -It is my pleasure to announce to you the 1.1.5 release of the MongoDB C driver. - -This is a patch release with performance enhancements and bug fixes: - - * The fsync and j write concern flags now imply acknowledged writes - * Prevent using fsync or j with conflicting w=0 write concern - * Obey socket timeout consistently in TLS/SSL mode - * Return an error promptly after a network hangup in TLS mode - * Prevent crash using SSL in FIPS mode - * Always return NULL from mongoc_database_get_collection_names on error - * Fix version check for GCC 5 and future versions of Clang - * Fix warnings and errors building on various platforms - * Add configure flag to enable/disable shared memory performance counters - * Minor docs improvements and fix links from C Driver docs to Libbson docs - -With this release, Libbson abandons the convention that odd-numbered patch -versions indicate unstable releases. We switch to simple semantic versioning: -1.1.5 is a stable release with bug fixes since 1.1.4. During subsequent -development the version will be "1.1.6-dev". - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - - * A. Jesse Jiryu Davis - * Christian Hergert - * Jason Carey - * Jeremy Mikola - * Jeroen Ooms - * Hannes Magnusson - -Enjoy! - --- A. Jesse Jiryu Davis - - -mongo-c-driver 1.1.4 -==================== - -It is my pleasure to announce to you the 1.1.4 release of the MongoDB C driver. - -This release is a stable release with performance enhancements and bugfixes. - -Changes include: - * Fixed client pool concurrency issues - * Fixed some scenarios where replica sets would fail to reconnect on primary - step down. - * Improved write concern handling - * Validate port number in URI - * Various other fixes - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - - * Jason Carey - * Andrew Clayton - * A. Jesse Jiryu Davis - * Jeremy Mikola - -Enjoy! - --- Jason Carey - - -mongo-c-driver 1.1.2 -==================== - -It is my pleasure to announce to you the 1.1.2 release of the MongoDB C driver. - -This release is a stable release with performance enhancements and bugfixes. - -Changes include: - * Process connectTimeoutMS cast insensitively - * Addition of missing trace macros - * Improvement of internal error messages - * Fix a segfault in OpenSSL cleanup routines - * Fix for IPv6 support for replica sets - * Coalesce small vectorized TLS writes - * MinGW fixups - * Fix for a memory leak in get_database_names() - * Fixes for patching write concern through the bulk api - * Fix to normalize hostnames in uri parsing - * Fix for managing connections in the client pool - * Various other fixes - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - - * Andrew Clayton - * Denis Gladkikh - * Hannes Magnusson - * Jason Carey - * Jeremy Mikola - * mschoenlaub - * Samantha Ritter - * Tyler Brock - -Enjoy! - --- Jason Carey - - -mongo-c-driver 1.1.0 -==================== - -It is my pleasure to announce to you the 1.1.0 release of the MongoDB C driver. - -This release is a stable release with additive ABI changes and bugfixes. - -The below changes include some carried over from RC0. - -Changes include: - * RC0 - * ABI versioning for 1.1 versus 1.0 symbols - * additional geo index options - * authMechanismProperties in URI - * fixes for OS X Yosemite - * removal of replica set member limit - * SCRAM-SHA-1 SASL mechanism - * updated dependency on libbson 1.1 abi - * validation for bulk insert - * various memory leak fixes - * Fixes to documentation typos - * "How to Ask For Help" in the README - * Removed dependency on sasl for PLAIN authentication - * Use provided username, if available, for X.509 auth - * Fixed WriteConcern error reporting for some writes - * Check for closed sockets before attempting RPCs - * Fixes for gridfs file seek - * Fixes for mongoc_cursor_clone() - * Fixes for unix domain socket support - * Fixes for polling on win32 - * Improved warnings on failure to connect - * Addition of wired tiger options - * Fixes for examples - -Additions to the ABI include: - * support for extra option in count - - mongoc_collection_count_with_opts - * additional index options - - mongoc_index_opt_geo_get_default - - mongoc_index_opt_geo_init - - mongoc_index_opt_wt_get_default - - mongoc_index_opt_wt_init - * rand interface to seed and verify the strong random number generation needed - by some auth mechanisms - - mongoc_rand_seed - - mongoc_rand_add - - mongoc_rand_status - * URI additions to support more complicated auth credentials - - mongoc_uri_get_credentials - - mongoc_uri_get_mechanism_properties - * Support for cursor returning metadata crud operations - - mongoc_client_find_databases - - mongoc_collection_find_indexes - - mongoc_database_find_collections - * Kill cursor support - - mongoc_client_kill_cursor - * Various get/setters on cursor - - mongoc_cursor_get_batch_size - - mongoc_cursor_get_id - - mongoc_cursor_set_batch_size - * More socket/stream options - - mongoc_socket_check_closed - - mongoc_socket_inet_ntop - - mongoc_stream_check_closed - - mongoc_stream_write - -Additional Notes: - Existing complex index names may contain a zero instead of a type due to -a bug in mongoc_collection_keys_to_index_string. As a result those indexes may -be hard to drop from the driver as they have a name you would not expect. - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - - * Adam Midvidy - * aherlihy - * alexeyvo - * Christian Hergert - * Hannes Magnusson - * Jason Carey - * Jérôme Lebel - * Jesse Jiryu Davis - * lloydzhou - * Mark Benevenuto - * Paul Melnikow - * Samantha Ritter - * Shraya Ramani - * Spencer Jackson - * Tyler Brock - - -Enjoy! - --- Jason Carey - - -mongo-c-driver 1.1.0-rc0 -======================== - -It is my pleasure to announce to you the 1.1.0-rc0 release of the MongoDB C driver. - -This release is a release candidate with additive ABI changes and bugfixes. - -Changes include: - * ABI versioning for 1.1 versus 1.0 symbols - * additional geo index options - * authMechanismProperties in URI - * fixes for OS X Yosemite - * removal of replica set member limit - * SCRAM-SHA-1 SASL mechanism - * updated dependency on libbson 1.1 abi - * validation for bulk insert - * various memory leak fixes - -Additions to the ABI include: - * support for extra option in count - - mongoc_collection_count_with_opts - * extra index and collection info - - mongoc_collection_get_index_info - - mongoc_database_get_collection_info - * additional geo options - - mongoc_index_opt_geo_get_default - - mongoc_index_opt_geo_init - * rand interface to seed and verify the strong random number generation needed - by some auth mechanisms - - mongoc_rand_seed - - mongoc_rand_add - - mongoc_rand_status - * URI additions to support more complicated auth credentials - - mongoc_uri_get_credentials - - mongoc_uri_get_mechanism_properties - -Additional Notes: - Existing complex index names may contain a zero instead of a type due to -a bug in mongoc_collection_keys_to_index_string. As a result those indexes may -be hard to drop from the driver as they have a name you would not expect. - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - - * Adam Midvidy - * aherlihy - * alexeyvo - * Christian Hergert - * Jason Carey - * Jérôme Lebel - * Samantha Ritter - * Spencer Jackson - * Tyler Brock - - -Enjoy! - --- Jason Carey - - -mongo-c-driver 1.0.2 -==================== - -It is my pleasure to announce to you the 1.0.2 release of the MongoDB C driver. - -This release is a minor point release with no ABI changes and mostly small -bugfixes. - -Changes include: - * A variety of fixes for read preference based node selection - * Avoided inclusion of getLastError in 2.6 writeConcern - * Correct handling of pass through params for collection_aggregate - * Improved error reporting in socket connect - * Public MONGOC_DEFAULT_CONNECTTIMEOUTMS - -Thanks to everyone who contributed to the development of this point release for -libmongoc. - - * Adam Midvidy - * Christian Hergert - * Denis Gladkikh - * Jason Carey - * Jeremy Mikola - * Jérôme Lebel - * Tyler Brock - * Wisdom Omuya - --- Jason Carey - - -mongo-c-driver 1.0.0 -==================== - -It is my very distinct pleasure to announce to you the 1.0 release of -the MongoDB C driver! - -This is the culmination of just over a year of work and could not have -been done without the help of our wonderful community. - -Thanks to everyone who contributed to the development of this driver! - - * Christian Hergert - * Jason Carey - * Gary Murakami - * Christian Heckl - * Frank Watson Song - * Hannes Magnusson - * JeÌroÌ‚me Lebel - * Kyle Suarez - * Maga Napanga - * Michael Kuhn - * Vincent Giersch - * essentia44 - * yuqing - -Happy Hacking! - --- Christian Hergert - - -mongo-c-driver 0.98.2 -===================== - -One final step before our journey to 1.0! - -This is a relatively small release, adding some features needed for drivers -building on top of the C driver. - -A new libmongoc-priv.so library is installed that does not have symbols -hidden. You can access private headers via the -private.h variants. This -means you will need to recompile your project every time the library is -changed (if you use those private headers, as they are subject to change). - -A special thanks to Hannes Magnusson for patches in this release. - -See `git shortlog 0.98.0..0.98.2` for a list of all the changes. - --- Christian Hergert - - -mongo-c-driver 0.98.0 -===================== - -Another step in the rapidly approaching path to 1.0! - -This release is primarily a bugfix release and stablization effort as we -approach 1.0 of the MongoDB C driver. - -This release requires 0.98.0 of Libbson for improvements to the memory -management system. You can now setup custom memory allocators at the -start of the process. - -This is a RC release that with a few improvements will likely become 1.0. - -A special thanks to the following for patches in this cycle: - - * Kyle Suarez - * yuqing - -See `git shortlog 0.96.4..0.98.0` for a list of all the changes. - --- Christian Hergert - - -mongo-c-driver 0.96.4 -===================== - -Another incremental feature update and bugfix release! - -In this release, you will find the following changes: - - * build/mci.sh script for automatically building Debian packages, RPMs, and - Solaris packaging based on the host operating system. - * Various libbson improvements, now depending on 0.8.4. - * Alignment fixes for Solaris Studio C compiler via libbson. - * Addition of mongoc_gridfs_remove_by_filename() for removing a file from - gridfs by filename. - * client command functions can now take a fully qualified namespace. - * collections can now support names that indicate a command namespace. - * Commands will no longer fail if they do not contain an "ok" field. - * OP_QUERY will now set the slaveOk bit in the wire protocol if - * readPreferences are set to non-PRIMARY. - * Various documentation and build fixes. - -Thanks again to all the contributors, and happy hacking! - - -mongo-c-driver 0.96.2 -===================== - -Hot on the heels of 0.96.0 we would like to present mongo-c-driver 0.96.2! - -This is primarily a bugfix release. Included in this release are: - - * Ensure batchSize is used in cursor GETMORE operations with `aggregate`. - * Ensure enough buffer space is allocated for incoming RPC when buffering - from a stream. - * Require libbson 0.8.2 for more robust `bson_next_power_of_two()` when - using `size_t` and BCON compilation fix with C++. - * Handle cursor id's that are not 64-bit values in response from - `aggregate` command. - * Handle upsert on MongoDB < 2.6 when _id does not contain an `ObjectId`. - * Use 100 for default batchSize in `aggregate` command. - -Happy Hacking! - - -mongo-c-driver 0.96.0 -===================== - -It's that time again, time for another mongo-c-driver release! - -This release includes much new documentation, which can be found at -https://www.mongodb.com/docs/ecosystem/drivers/c/. - -Additionally, this release improves support for various exotic systems. -Solaris 10 is supported much better on SPARC and x86_64 based systems. - -Some workarounds for mixed-mode sharded-clusters have been added to improve -resiliency when rolling upgrades are performed. - -Build improvements have been added to help us detect SASL and SSL -implementations on platforms that do not support pkg-config. This should -simplify building for some of you. - -We've added some more logging to SASL authentication to help debug -authentication failures. - -A bug causing an abort() when SSL is used and a server is down has been fixed. - -We've renamed various _delete() functions to _remove() to provide consistency -with other MongoDB drivers. - -You can now specify SSL options for client pools. - --D_REENTRANT is always defined now on Solaris to help with errno detection. -This may not have been done before if using a non-GCC platform with pthreads. - -A bug was fixed where timeouts could have been 1000x longer than expected -due to failure to convert from microseconds to milliseconds. - -A bug was fixed with authentication in sharded cluster and replica set -scenarios. - -Happy Hacking! - - -mongo-c-driver 0.94.2 -===================== - -Hot on the heels of 0.94.0 is 0.94.2, a bugfix release. - -A bug has been fixed when using TLS streams and large result sets. - -In this release, we added support for Sun's C compiler (Sun Pro C) on Solaris. -This allows for builds on Solaris 10 with SPARC using the native toolchain. - -This release contains a couple of fixes in libbson as well. - -Keep those bug reports coming, and as always, Happy Hacking! - - -mongo-c-driver 0.94.0 -===================== - -The mongo-c-driver team is proud to announce the release of 0.94.0. This -release is a followup to the previous release adding more features to be found -in MongoDB 2.6. - -You will find some new API's, bug fixes, and more documentation. Under the -hood, 0.94.0 uses the new write-commands as part of MongoDB 2.6 when it -discovers it is communicating with a MongoDB server. There is now a bulk -operation API (See `mongoc-bulk-operation.h`). - -Helpers for common server commands have been added. You can find most of -them `mongoc-collection.h`. - -To simply using mongo-c-driver from Windows, we've included pre-built binaries -on the release page. - -Thanks to all of the contributors this release! - -Happy Hacking! - - -mongo-c-driver 0.92.0 -===================== - -The mongo-c-driver team is proud to announce the release of 0.92.0. This -release is the culimation of a few months work and has many bug fixes and -new features. It contains over 350 commits from 4 authors since the 0.90.0 -release. - -The mongo-c-driver release tarballs now contain a bundled copy of libbson. -If you do not have libbson installed or the system installed libbson is too -old, the bundled copy of libbson will be installed. - - * Revamped build system to simplify installation. - * Windows Vista and newer support. - * Various GridFS fixes and features. - * Kerberos support via cyrus-sasl. - * Various SSL improvements. - * Support for Solaris 11, FreeBSD 10, RHEL 5+, and SmartOS. - * A new client side expression matcher to perform basic query processing. - It can perform queries such as {'field': {'$in': [1,2,3]}}. See - mongoc_matcher_t for more information. - * A new socket abstraction for platform independent network sockets. - * A new mongoc-dump example for how to write a simple mongodump replacement. - * Counters can use rdtscp instruction on Core iX systems for very fast - counters. - * configure has new options. If in doubt, the defaults are sensible. - * --enable-coverage=yes|no - * --enable-debug=yes|no - * --enable-debug-symbols=yes|no - * --enable-hardening=yes|no - * --enable-optimizations=yes|no - * --enable-ssl=yes|no - * --enable-sasl=yes|no - * --enable-tracing=yes|no - * --with-libbson=auto|system|bundled - -mongo-c-driver 0.92.0 requires libbson 0.6.4 or newer. - -Happy Hacking! - - -Libmongoc 0.90.0 -================ - -This is the initial release of the new Libmongoc. We chose 0.90.0 for the -release version to differentiate ourselves from the, now legacy, version of -libmongoc. We will rapidly work towards reaching an API/ABI stable library fit -for a 1.0.0 release. - -Libmongoc is Apache licensed so it can be embedded in a multitude of scenarios. - -The API of 0.90.0 is completely different from the previous versions. We think -this allowed us to create a high-quality library that you will enjoy using in -your applications. - -Many outstanding bugs were closed in the process of creating Libbson 0.90.0. So -if you had a pet issue, please take a look to see if it was resolved as part of -this effort! - -Thanks, and enjoy developing your applications with libmongoc! diff --git a/3rdparty/mongo-c-driver-1.26.2/THIRD_PARTY_NOTICES b/3rdparty/mongo-c-driver-1.26.2/THIRD_PARTY_NOTICES deleted file mode 100644 index 609473902..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/THIRD_PARTY_NOTICES +++ /dev/null @@ -1,160 +0,0 @@ -The MongoDB C Driver uses third-party code distributed under different licenses. - -License notice for common-b64.c -------------------------------------------------------------------------------- - -ISC License - -Copyright: 1996, 1998 Internet Software Consortium - 1995 International Business Machines, Inc. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -Portions Copyright (c) 1995 by International Business Machines, Inc. - -International Business Machines, Inc. (hereinafter called IBM) grants -permission under its copyrights to use, copy, modify, and distribute this -Software with or without fee, provided that the above copyright notice and -all paragraphs of this notice appear in all copies, and that the name of IBM -not be used in connection with the marketing of any product incorporating -the Software or modifications thereof, without specific, written prior -permission. - -To the extent it has a right to do so, IBM grants an immunity from suit -under its patents, if any, for the use, sale or manufacture of products to -the extent that such products are used for performing Domain Name System -dynamic updates in TCP/IP networks by means of the Software. No immunity is -granted for any product per se or for any other function of any product. - -THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, -DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING -OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN -IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. - - -License notice for mongoc.css_t -------------------------------------------------------------------------------- - -MIT License - -Portions Copyright 2013 by Ignacy Sokolowski. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -License notice for zlib -------------------------------------------------------------------------------- -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.11, January 15th, 2017 - - Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 - (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). -*/ - -License notice for common-md5.c -------------------------------------------------------------------------------- - -ZLib License - -Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - -L. Peter Deutsch -ghost@aladdin.com - -License notice for utf8proc -------------------------------------------------------------------------------- - -**utf8proc** is a software package originally developed -by Jan Behrens and the rest of the Public Software Group, who -deserve nearly all of the credit for this library, that is now maintained by the Julia-language developers. Like the original utf8proc, -whose copyright and license statements are reproduced below, all new -work on the utf8proc library is licensed under the [MIT "expat" -license](http://opensource.org/licenses/MIT): - -*Copyright © 2014-2021 by Steven G. Johnson, Jiahao Chen, Tony Kelman, Jonas Fonseca, and other contributors listed in the git history.* - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/3rdparty/mongo-c-driver-1.26.2/VERSION_CURRENT b/3rdparty/mongo-c-driver-1.26.2/VERSION_CURRENT deleted file mode 100644 index c7c3f3333..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/VERSION_CURRENT +++ /dev/null @@ -1 +0,0 @@ -1.26.2 diff --git a/3rdparty/mongo-c-driver-1.26.2/build/bottle.py b/3rdparty/mongo-c-driver-1.26.2/build/bottle.py deleted file mode 100644 index 8b7fbe5d7..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/bottle.py +++ /dev/null @@ -1,3806 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -""" -Bottle is a fast and simple micro-framework for small web applications. It -offers request dispatching (Routes) with url parameter support, templates, -a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and -template engines - all in a single file and with no dependencies other than the -Python Standard Library. - -Homepage and documentation: http://bottlepy.org/ - -Copyright (c) 2016, Marcel Hellkamp. -License: MIT (see LICENSE for details) -""" - -from __future__ import with_statement - -__author__ = 'Marcel Hellkamp' -__version__ = '0.12.23' -__license__ = 'MIT' - -# The gevent server adapter needs to patch some modules before they are imported -# This is why we parse the commandline parameters here but handle them later -if __name__ == '__main__': - from optparse import OptionParser - _cmd_parser = OptionParser(usage="usage: %prog [options] package.module:app") - _opt = _cmd_parser.add_option - _opt("--version", action="store_true", help="show version number.") - _opt("-b", "--bind", metavar="ADDRESS", help="bind socket to ADDRESS.") - _opt("-s", "--server", default='wsgiref', help="use SERVER as backend.") - _opt("-p", "--plugin", action="append", help="install additional plugin/s.") - _opt("--debug", action="store_true", help="start server in debug mode.") - _opt("--reload", action="store_true", help="auto-reload on file changes.") - _cmd_options, _cmd_args = _cmd_parser.parse_args() - if _cmd_options.server and _cmd_options.server.startswith('gevent'): - import gevent.monkey; gevent.monkey.patch_all() - -import base64, cgi, email.utils, functools, hmac, itertools, mimetypes,\ - os, re, subprocess, sys, tempfile, threading, time, warnings, hashlib - -from datetime import date as datedate, datetime, timedelta -from tempfile import TemporaryFile -from traceback import format_exc, print_exc -from unicodedata import normalize - - -try: from simplejson import dumps as json_dumps, loads as json_lds -except ImportError: # pragma: no cover - try: from json import dumps as json_dumps, loads as json_lds - except ImportError: - try: from django.utils.simplejson import dumps as json_dumps, loads as json_lds - except ImportError: - def json_dumps(data): - raise ImportError("JSON support requires Python 2.6 or simplejson.") - json_lds = json_dumps - - - -# We now try to fix 2.5/2.6/3.1/3.2 incompatibilities. -# It ain't pretty but it works... Sorry for the mess. - -py = sys.version_info -py3k = py >= (3, 0, 0) -py25 = py < (2, 6, 0) -py31 = (3, 1, 0) <= py < (3, 2, 0) - -# Workaround for the missing "as" keyword in py3k. -def _e(): return sys.exc_info()[1] - -# Workaround for the "print is a keyword/function" Python 2/3 dilemma -# and a fallback for mod_wsgi (resticts stdout/err attribute access) -try: - _stdout, _stderr = sys.stdout.write, sys.stderr.write -except IOError: - _stdout = lambda x: sys.stdout.write(x) - _stderr = lambda x: sys.stderr.write(x) - -# Lots of stdlib and builtin differences. -if py3k: - import http.client as httplib - import _thread as thread - from urllib.parse import urljoin, SplitResult as UrlSplitResult - from urllib.parse import urlencode, quote as urlquote, unquote as urlunquote - urlunquote = functools.partial(urlunquote, encoding='latin1') - from http.cookies import SimpleCookie - if py >= (3, 3, 0): - from collections.abc import MutableMapping as DictMixin - from types import ModuleType as new_module - else: - from collections import MutableMapping as DictMixin - from imp import new_module - import pickle - from io import BytesIO - from configparser import ConfigParser - from inspect import getfullargspec - def getargspec(func): - spec = getfullargspec(func) - kwargs = makelist(spec[0]) + makelist(spec.kwonlyargs) - return kwargs, spec[1], spec[2], spec[3] - - basestring = str - unicode = str - json_loads = lambda s: json_lds(touni(s)) - callable = lambda x: hasattr(x, '__call__') - imap = map - def _raise(*a): raise a[0](a[1]).with_traceback(a[2]) -else: # 2.x - import httplib - import thread - from urlparse import urljoin, SplitResult as UrlSplitResult - from urllib import urlencode, quote as urlquote, unquote as urlunquote - from Cookie import SimpleCookie - from itertools import imap - import cPickle as pickle - from imp import new_module - from StringIO import StringIO as BytesIO - from ConfigParser import SafeConfigParser as ConfigParser - from inspect import getargspec - if py25: - msg = "Python 2.5 support may be dropped in future versions of Bottle." - warnings.warn(msg, DeprecationWarning) - from UserDict import DictMixin - def next(it): return it.next() - bytes = str - else: # 2.6, 2.7 - from collections import MutableMapping as DictMixin - unicode = unicode - json_loads = json_lds - eval(compile('def _raise(*a): raise a[0], a[1], a[2]', '', 'exec')) - -# Some helpers for string/byte handling -def tob(s, enc='utf8'): - return s.encode(enc) if isinstance(s, unicode) else bytes(s) -def touni(s, enc='utf8', err='strict'): - return s.decode(enc, err) if isinstance(s, bytes) else unicode(s) -tonat = touni if py3k else tob - -# 3.2 fixes cgi.FieldStorage to accept bytes (which makes a lot of sense). -# 3.1 needs a workaround. -if py31: - from io import TextIOWrapper - class NCTextIOWrapper(TextIOWrapper): - def close(self): pass # Keep wrapped buffer open. - - -# A bug in functools causes it to break if the wrapper is an instance method -def update_wrapper(wrapper, wrapped, *a, **ka): - try: functools.update_wrapper(wrapper, wrapped, *a, **ka) - except AttributeError: pass - - - -# These helpers are used at module level and need to be defined first. -# And yes, I know PEP-8, but sometimes a lower-case classname makes more sense. - -def depr(message, hard=False): - warnings.warn(message, DeprecationWarning, stacklevel=3) - -def makelist(data): # This is just to handy - if isinstance(data, (tuple, list, set, dict)): return list(data) - elif data: return [data] - else: return [] - - -class DictProperty(object): - ''' Property that maps to a key in a local dict-like attribute. ''' - def __init__(self, attr, key=None, read_only=False): - self.attr, self.key, self.read_only = attr, key, read_only - - def __call__(self, func): - functools.update_wrapper(self, func, updated=[]) - self.getter, self.key = func, self.key or func.__name__ - return self - - def __get__(self, obj, cls): - if obj is None: return self - key, storage = self.key, getattr(obj, self.attr) - if key not in storage: storage[key] = self.getter(obj) - return storage[key] - - def __set__(self, obj, value): - if self.read_only: raise AttributeError("Read-Only property.") - getattr(obj, self.attr)[self.key] = value - - def __delete__(self, obj): - if self.read_only: raise AttributeError("Read-Only property.") - del getattr(obj, self.attr)[self.key] - - -class cached_property(object): - ''' A property that is only computed once per instance and then replaces - itself with an ordinary attribute. Deleting the attribute resets the - property. ''' - - def __init__(self, func): - self.__doc__ = getattr(func, '__doc__') - self.func = func - - def __get__(self, obj, cls): - if obj is None: return self - value = obj.__dict__[self.func.__name__] = self.func(obj) - return value - - -class lazy_attribute(object): - ''' A property that caches itself to the class object. ''' - def __init__(self, func): - functools.update_wrapper(self, func, updated=[]) - self.getter = func - - def __get__(self, obj, cls): - value = self.getter(cls) - setattr(cls, self.__name__, value) - return value - - - - - - -############################################################################### -# Exceptions and Events ######################################################## -############################################################################### - - -class BottleException(Exception): - """ A base class for exceptions used by bottle. """ - pass - - - - - - -############################################################################### -# Routing ###################################################################### -############################################################################### - - -class RouteError(BottleException): - """ This is a base class for all routing related exceptions """ - - -class RouteReset(BottleException): - """ If raised by a plugin or request handler, the route is reset and all - plugins are re-applied. """ - -class RouterUnknownModeError(RouteError): pass - - -class RouteSyntaxError(RouteError): - """ The route parser found something not supported by this router. """ - - -class RouteBuildError(RouteError): - """ The route could not be built. """ - - -def _re_flatten(p): - ''' Turn all capturing groups in a regular expression pattern into - non-capturing groups. ''' - if '(' not in p: return p - return re.sub(r'(\\*)(\(\?P<[^>]+>|\((?!\?))', - lambda m: m.group(0) if len(m.group(1)) % 2 else m.group(1) + '(?:', p) - - -class Router(object): - ''' A Router is an ordered collection of route->target pairs. It is used to - efficiently match WSGI requests against a number of routes and return - the first target that satisfies the request. The target may be anything, - usually a string, ID or callable object. A route consists of a path-rule - and a HTTP method. - - The path-rule is either a static path (e.g. `/contact`) or a dynamic - path that contains wildcards (e.g. `/wiki/`). The wildcard syntax - and details on the matching order are described in docs:`routing`. - ''' - - default_pattern = '[^/]+' - default_filter = 're' - - #: The current CPython regexp implementation does not allow more - #: than 99 matching groups per regular expression. - _MAX_GROUPS_PER_PATTERN = 99 - - def __init__(self, strict=False): - self.rules = [] # All rules in order - self._groups = {} # index of regexes to find them in dyna_routes - self.builder = {} # Data structure for the url builder - self.static = {} # Search structure for static routes - self.dyna_routes = {} - self.dyna_regexes = {} # Search structure for dynamic routes - #: If true, static routes are no longer checked first. - self.strict_order = strict - self.filters = { - 're': lambda conf: - (_re_flatten(conf or self.default_pattern), None, None), - 'int': lambda conf: (r'-?\d+', int, lambda x: str(int(x))), - 'float': lambda conf: (r'-?[\d.]+', float, lambda x: str(float(x))), - 'path': lambda conf: (r'.+?', None, None)} - - def add_filter(self, name, func): - ''' Add a filter. The provided function is called with the configuration - string as parameter and must return a (regexp, to_python, to_url) tuple. - The first element is a string, the last two are callables or None. ''' - self.filters[name] = func - - rule_syntax = re.compile('(\\\\*)'\ - '(?:(?::([a-zA-Z_][a-zA-Z_0-9]*)?()(?:#(.*?)#)?)'\ - '|(?:<([a-zA-Z_][a-zA-Z_0-9]*)?(?::([a-zA-Z_]*)'\ - '(?::((?:\\\\.|[^\\\\>]+)+)?)?)?>))') - - def _itertokens(self, rule): - offset, prefix = 0, '' - for match in self.rule_syntax.finditer(rule): - prefix += rule[offset:match.start()] - g = match.groups() - if len(g[0])%2: # Escaped wildcard - prefix += match.group(0)[len(g[0]):] - offset = match.end() - continue - if prefix: - yield prefix, None, None - name, filtr, conf = g[4:7] if g[2] is None else g[1:4] - yield name, filtr or 'default', conf or None - offset, prefix = match.end(), '' - if offset <= len(rule) or prefix: - yield prefix+rule[offset:], None, None - - def add(self, rule, method, target, name=None): - ''' Add a new rule or replace the target for an existing rule. ''' - anons = 0 # Number of anonymous wildcards found - keys = [] # Names of keys - pattern = '' # Regular expression pattern with named groups - filters = [] # Lists of wildcard input filters - builder = [] # Data structure for the URL builder - is_static = True - - for key, mode, conf in self._itertokens(rule): - if mode: - is_static = False - if mode == 'default': mode = self.default_filter - mask, in_filter, out_filter = self.filters[mode](conf) - if not key: - pattern += '(?:%s)' % mask - key = 'anon%d' % anons - anons += 1 - else: - pattern += '(?P<%s>%s)' % (key, mask) - keys.append(key) - if in_filter: filters.append((key, in_filter)) - builder.append((key, out_filter or str)) - elif key: - pattern += re.escape(key) - builder.append((None, key)) - - self.builder[rule] = builder - if name: self.builder[name] = builder - - if is_static and not self.strict_order: - self.static.setdefault(method, {}) - self.static[method][self.build(rule)] = (target, None) - return - - try: - re_pattern = re.compile('^(%s)$' % pattern) - re_match = re_pattern.match - except re.error: - raise RouteSyntaxError("Could not add Route: %s (%s)" % (rule, _e())) - - if filters: - def getargs(path): - url_args = re_match(path).groupdict() - for name, wildcard_filter in filters: - try: - url_args[name] = wildcard_filter(url_args[name]) - except ValueError: - raise HTTPError(400, 'Path has wrong format.') - return url_args - elif re_pattern.groupindex: - def getargs(path): - return re_match(path).groupdict() - else: - getargs = None - - flatpat = _re_flatten(pattern) - whole_rule = (rule, flatpat, target, getargs) - - if (flatpat, method) in self._groups: - if DEBUG: - msg = 'Route <%s %s> overwrites a previously defined route' - warnings.warn(msg % (method, rule), RuntimeWarning) - self.dyna_routes[method][self._groups[flatpat, method]] = whole_rule - else: - self.dyna_routes.setdefault(method, []).append(whole_rule) - self._groups[flatpat, method] = len(self.dyna_routes[method]) - 1 - - self._compile(method) - - def _compile(self, method): - all_rules = self.dyna_routes[method] - comborules = self.dyna_regexes[method] = [] - maxgroups = self._MAX_GROUPS_PER_PATTERN - for x in range(0, len(all_rules), maxgroups): - some = all_rules[x:x+maxgroups] - combined = (flatpat for (_, flatpat, _, _) in some) - combined = '|'.join('(^%s$)' % flatpat for flatpat in combined) - combined = re.compile(combined).match - rules = [(target, getargs) for (_, _, target, getargs) in some] - comborules.append((combined, rules)) - - def build(self, _name, *anons, **query): - ''' Build an URL by filling the wildcards in a rule. ''' - builder = self.builder.get(_name) - if not builder: raise RouteBuildError("No route with that name.", _name) - try: - for i, value in enumerate(anons): query['anon%d'%i] = value - url = ''.join([f(query.pop(n)) if n else f for (n,f) in builder]) - return url if not query else url+'?'+urlencode(query) - except KeyError: - raise RouteBuildError('Missing URL argument: %r' % _e().args[0]) - - def match(self, environ): - ''' Return a (target, url_agrs) tuple or raise HTTPError(400/404/405). ''' - verb = environ['REQUEST_METHOD'].upper() - path = environ['PATH_INFO'] or '/' - target = None - if verb == 'HEAD': - methods = ['PROXY', verb, 'GET', 'ANY'] - else: - methods = ['PROXY', verb, 'ANY'] - - for method in methods: - if method in self.static and path in self.static[method]: - target, getargs = self.static[method][path] - return target, getargs(path) if getargs else {} - elif method in self.dyna_regexes: - for combined, rules in self.dyna_regexes[method]: - match = combined(path) - if match: - target, getargs = rules[match.lastindex - 1] - return target, getargs(path) if getargs else {} - - # No matching route found. Collect alternative methods for 405 response - allowed = set([]) - nocheck = set(methods) - for method in set(self.static) - nocheck: - if path in self.static[method]: - allowed.add(method) - for method in set(self.dyna_regexes) - allowed - nocheck: - for combined, rules in self.dyna_regexes[method]: - match = combined(path) - if match: - allowed.add(method) - if allowed: - allow_header = ",".join(sorted(allowed)) - raise HTTPError(405, "Method not allowed.", Allow=allow_header) - - # No matching route and no alternative method found. We give up - raise HTTPError(404, "Not found: " + repr(path)) - - - - - - -class Route(object): - ''' This class wraps a route callback along with route specific metadata and - configuration and applies Plugins on demand. It is also responsible for - turing an URL path rule into a regular expression usable by the Router. - ''' - - def __init__(self, app, rule, method, callback, name=None, - plugins=None, skiplist=None, **config): - #: The application this route is installed to. - self.app = app - #: The path-rule string (e.g. ``/wiki/:page``). - self.rule = rule - #: The HTTP method as a string (e.g. ``GET``). - self.method = method - #: The original callback with no plugins applied. Useful for introspection. - self.callback = callback - #: The name of the route (if specified) or ``None``. - self.name = name or None - #: A list of route-specific plugins (see :meth:`Bottle.route`). - self.plugins = plugins or [] - #: A list of plugins to not apply to this route (see :meth:`Bottle.route`). - self.skiplist = skiplist or [] - #: Additional keyword arguments passed to the :meth:`Bottle.route` - #: decorator are stored in this dictionary. Used for route-specific - #: plugin configuration and meta-data. - self.config = ConfigDict().load_dict(config, make_namespaces=True) - - def __call__(self, *a, **ka): - depr("Some APIs changed to return Route() instances instead of"\ - " callables. Make sure to use the Route.call method and not to"\ - " call Route instances directly.") #0.12 - return self.call(*a, **ka) - - @cached_property - def call(self): - ''' The route callback with all plugins applied. This property is - created on demand and then cached to speed up subsequent requests.''' - return self._make_callback() - - def reset(self): - ''' Forget any cached values. The next time :attr:`call` is accessed, - all plugins are re-applied. ''' - self.__dict__.pop('call', None) - - def prepare(self): - ''' Do all on-demand work immediately (useful for debugging).''' - self.call - - @property - def _context(self): - depr('Switch to Plugin API v2 and access the Route object directly.') #0.12 - return dict(rule=self.rule, method=self.method, callback=self.callback, - name=self.name, app=self.app, config=self.config, - apply=self.plugins, skip=self.skiplist) - - def all_plugins(self): - ''' Yield all Plugins affecting this route. ''' - unique = set() - for p in reversed(self.app.plugins + self.plugins): - if True in self.skiplist: break - name = getattr(p, 'name', False) - if name and (name in self.skiplist or name in unique): continue - if p in self.skiplist or type(p) in self.skiplist: continue - if name: unique.add(name) - yield p - - def _make_callback(self): - callback = self.callback - for plugin in self.all_plugins(): - try: - if hasattr(plugin, 'apply'): - api = getattr(plugin, 'api', 1) - context = self if api > 1 else self._context - callback = plugin.apply(callback, context) - else: - callback = plugin(callback) - except RouteReset: # Try again with changed configuration. - return self._make_callback() - if not callback is self.callback: - update_wrapper(callback, self.callback) - return callback - - def get_undecorated_callback(self): - ''' Return the callback. If the callback is a decorated function, try to - recover the original function. ''' - func = self.callback - func = getattr(func, '__func__' if py3k else 'im_func', func) - closure_attr = '__closure__' if py3k else 'func_closure' - while hasattr(func, closure_attr) and getattr(func, closure_attr): - func = getattr(func, closure_attr)[0].cell_contents - return func - - def get_callback_args(self): - ''' Return a list of argument names the callback (most likely) accepts - as keyword arguments. If the callback is a decorated function, try - to recover the original function before inspection. ''' - return getargspec(self.get_undecorated_callback())[0] - - def get_config(self, key, default=None): - ''' Lookup a config field and return its value, first checking the - route.config, then route.app.config.''' - for conf in (self.config, self.app.conifg): - if key in conf: return conf[key] - return default - - def __repr__(self): - cb = self.get_undecorated_callback() - return '<%s %r %r>' % (self.method, self.rule, cb) - - - - - - -############################################################################### -# Application Object ########################################################### -############################################################################### - - -class Bottle(object): - """ Each Bottle object represents a single, distinct web application and - consists of routes, callbacks, plugins, resources and configuration. - Instances are callable WSGI applications. - - :param catchall: If true (default), handle all exceptions. Turn off to - let debugging middleware handle exceptions. - """ - - def __init__(self, catchall=True, autojson=True): - - #: A :class:`ConfigDict` for app specific configuration. - self.config = ConfigDict() - self.config._on_change = functools.partial(self.trigger_hook, 'config') - self.config.meta_set('autojson', 'validate', bool) - self.config.meta_set('catchall', 'validate', bool) - self.config['catchall'] = catchall - self.config['autojson'] = autojson - - #: A :class:`ResourceManager` for application files - self.resources = ResourceManager() - - self.routes = [] # List of installed :class:`Route` instances. - self.router = Router() # Maps requests to :class:`Route` instances. - self.error_handler = {} - - # Core plugins - self.plugins = [] # List of installed plugins. - if self.config['autojson']: - self.install(JSONPlugin()) - self.install(TemplatePlugin()) - - #: If true, most exceptions are caught and returned as :exc:`HTTPError` - catchall = DictProperty('config', 'catchall') - - __hook_names = 'before_request', 'after_request', 'app_reset', 'config' - __hook_reversed = 'after_request' - - @cached_property - def _hooks(self): - return dict((name, []) for name in self.__hook_names) - - def add_hook(self, name, func): - ''' Attach a callback to a hook. Three hooks are currently implemented: - - before_request - Executed once before each request. The request context is - available, but no routing has happened yet. - after_request - Executed once after each request regardless of its outcome. - app_reset - Called whenever :meth:`Bottle.reset` is called. - ''' - if name in self.__hook_reversed: - self._hooks[name].insert(0, func) - else: - self._hooks[name].append(func) - - def remove_hook(self, name, func): - ''' Remove a callback from a hook. ''' - if name in self._hooks and func in self._hooks[name]: - self._hooks[name].remove(func) - return True - - def trigger_hook(self, __name, *args, **kwargs): - ''' Trigger a hook and return a list of results. ''' - return [hook(*args, **kwargs) for hook in self._hooks[__name][:]] - - def hook(self, name): - """ Return a decorator that attaches a callback to a hook. See - :meth:`add_hook` for details.""" - def decorator(func): - self.add_hook(name, func) - return func - return decorator - - def mount(self, prefix, app, **options): - ''' Mount an application (:class:`Bottle` or plain WSGI) to a specific - URL prefix. Example:: - - root_app.mount('/admin/', admin_app) - - :param prefix: path prefix or `mount-point`. If it ends in a slash, - that slash is mandatory. - :param app: an instance of :class:`Bottle` or a WSGI application. - - All other parameters are passed to the underlying :meth:`route` call. - ''' - if isinstance(app, basestring): - depr('Parameter order of Bottle.mount() changed.', True) # 0.10 - - segments = [p for p in prefix.split('/') if p] - if not segments: raise ValueError('Empty path prefix.') - path_depth = len(segments) - - def mountpoint_wrapper(): - try: - request.path_shift(path_depth) - rs = HTTPResponse([]) - def start_response(status, headerlist, exc_info=None): - if exc_info: - try: - _raise(*exc_info) - finally: - exc_info = None - rs.status = status - for name, value in headerlist: rs.add_header(name, value) - return rs.body.append - body = app(request.environ, start_response) - if body and rs.body: body = itertools.chain(rs.body, body) - rs.body = body or rs.body - return rs - finally: - request.path_shift(-path_depth) - - options.setdefault('skip', True) - options.setdefault('method', 'PROXY') - options.setdefault('mountpoint', {'prefix': prefix, 'target': app}) - options['callback'] = mountpoint_wrapper - - self.route('/%s/<:re:.*>' % '/'.join(segments), **options) - if not prefix.endswith('/'): - self.route('/' + '/'.join(segments), **options) - - def merge(self, routes): - ''' Merge the routes of another :class:`Bottle` application or a list of - :class:`Route` objects into this application. The routes keep their - 'owner', meaning that the :data:`Route.app` attribute is not - changed. ''' - if isinstance(routes, Bottle): - routes = routes.routes - for route in routes: - self.add_route(route) - - def install(self, plugin): - ''' Add a plugin to the list of plugins and prepare it for being - applied to all routes of this application. A plugin may be a simple - decorator or an object that implements the :class:`Plugin` API. - ''' - if hasattr(plugin, 'setup'): plugin.setup(self) - if not callable(plugin) and not hasattr(plugin, 'apply'): - raise TypeError("Plugins must be callable or implement .apply()") - self.plugins.append(plugin) - self.reset() - return plugin - - def uninstall(self, plugin): - ''' Uninstall plugins. Pass an instance to remove a specific plugin, a type - object to remove all plugins that match that type, a string to remove - all plugins with a matching ``name`` attribute or ``True`` to remove all - plugins. Return the list of removed plugins. ''' - removed, remove = [], plugin - for i, plugin in list(enumerate(self.plugins))[::-1]: - if remove is True or remove is plugin or remove is type(plugin) \ - or getattr(plugin, 'name', True) == remove: - removed.append(plugin) - del self.plugins[i] - if hasattr(plugin, 'close'): plugin.close() - if removed: self.reset() - return removed - - def reset(self, route=None): - ''' Reset all routes (force plugins to be re-applied) and clear all - caches. If an ID or route object is given, only that specific route - is affected. ''' - if route is None: routes = self.routes - elif isinstance(route, Route): routes = [route] - else: routes = [self.routes[route]] - for route in routes: route.reset() - if DEBUG: - for route in routes: route.prepare() - self.trigger_hook('app_reset') - - def close(self): - ''' Close the application and all installed plugins. ''' - for plugin in self.plugins: - if hasattr(plugin, 'close'): plugin.close() - self.stopped = True - - def run(self, **kwargs): - ''' Calls :func:`run` with the same parameters. ''' - run(self, **kwargs) - - def match(self, environ): - """ Search for a matching route and return a (:class:`Route` , urlargs) - tuple. The second value is a dictionary with parameters extracted - from the URL. Raise :exc:`HTTPError` (404/405) on a non-match.""" - return self.router.match(environ) - - def get_url(self, routename, **kargs): - """ Return a string that matches a named route """ - scriptname = request.environ.get('SCRIPT_NAME', '').strip('/') + '/' - location = self.router.build(routename, **kargs).lstrip('/') - return urljoin(urljoin('/', scriptname), location) - - def add_route(self, route): - ''' Add a route object, but do not change the :data:`Route.app` - attribute.''' - self.routes.append(route) - self.router.add(route.rule, route.method, route, name=route.name) - if DEBUG: route.prepare() - - def route(self, path=None, method='GET', callback=None, name=None, - apply=None, skip=None, **config): - """ A decorator to bind a function to a request URL. Example:: - - @app.route('/hello/:name') - def hello(name): - return 'Hello %s' % name - - The ``:name`` part is a wildcard. See :class:`Router` for syntax - details. - - :param path: Request path or a list of paths to listen to. If no - path is specified, it is automatically generated from the - signature of the function. - :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of - methods to listen to. (default: `GET`) - :param callback: An optional shortcut to avoid the decorator - syntax. ``route(..., callback=func)`` equals ``route(...)(func)`` - :param name: The name for this route. (default: None) - :param apply: A decorator or plugin or a list of plugins. These are - applied to the route callback in addition to installed plugins. - :param skip: A list of plugins, plugin classes or names. Matching - plugins are not installed to this route. ``True`` skips all. - - Any additional keyword arguments are stored as route-specific - configuration and passed to plugins (see :meth:`Plugin.apply`). - """ - if callable(path): path, callback = None, path - plugins = makelist(apply) - skiplist = makelist(skip) - def decorator(callback): - # TODO: Documentation and tests - if isinstance(callback, basestring): callback = load(callback) - for rule in makelist(path) or yieldroutes(callback): - for verb in makelist(method): - verb = verb.upper() - route = Route(self, rule, verb, callback, name=name, - plugins=plugins, skiplist=skiplist, **config) - self.add_route(route) - return callback - return decorator(callback) if callback else decorator - - def get(self, path=None, method='GET', **options): - """ Equals :meth:`route`. """ - return self.route(path, method, **options) - - def post(self, path=None, method='POST', **options): - """ Equals :meth:`route` with a ``POST`` method parameter. """ - return self.route(path, method, **options) - - def put(self, path=None, method='PUT', **options): - """ Equals :meth:`route` with a ``PUT`` method parameter. """ - return self.route(path, method, **options) - - def delete(self, path=None, method='DELETE', **options): - """ Equals :meth:`route` with a ``DELETE`` method parameter. """ - return self.route(path, method, **options) - - def error(self, code=500): - """ Decorator: Register an output handler for a HTTP error code""" - def wrapper(handler): - self.error_handler[int(code)] = handler - return handler - return wrapper - - def default_error_handler(self, res): - return tob(template(ERROR_PAGE_TEMPLATE, e=res)) - - def _handle(self, environ): - try: - - environ['bottle.app'] = self - request.bind(environ) - response.bind() - - path = environ['bottle.raw_path'] = environ['PATH_INFO'] - if py3k: - try: - environ['PATH_INFO'] = path.encode('latin1').decode('utf8') - except UnicodeError: - return HTTPError(400, 'Invalid path string. Expected UTF-8') - - try: - self.trigger_hook('before_request') - route, args = self.router.match(environ) - environ['route.handle'] = route - environ['bottle.route'] = route - environ['route.url_args'] = args - return route.call(**args) - finally: - self.trigger_hook('after_request') - - except HTTPResponse: - return _e() - except RouteReset: - route.reset() - return self._handle(environ) - except (KeyboardInterrupt, SystemExit, MemoryError): - raise - except Exception: - if not self.catchall: raise - stacktrace = format_exc() - environ['wsgi.errors'].write(stacktrace) - return HTTPError(500, "Internal Server Error", _e(), stacktrace) - - def _cast(self, out, peek=None): - """ Try to convert the parameter into something WSGI compatible and set - correct HTTP headers when possible. - Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like, - iterable of strings and iterable of unicodes - """ - - # Empty output is done here - if not out: - if 'Content-Length' not in response: - response['Content-Length'] = 0 - return [] - # Join lists of byte or unicode strings. Mixed lists are NOT supported - if isinstance(out, (tuple, list))\ - and isinstance(out[0], (bytes, unicode)): - out = out[0][0:0].join(out) # b'abc'[0:0] -> b'' - # Encode unicode strings - if isinstance(out, unicode): - out = out.encode(response.charset) - # Byte Strings are just returned - if isinstance(out, bytes): - if 'Content-Length' not in response: - response['Content-Length'] = len(out) - return [out] - # HTTPError or HTTPException (recursive, because they may wrap anything) - # TODO: Handle these explicitly in handle() or make them iterable. - if isinstance(out, HTTPError): - out.apply(response) - out = self.error_handler.get(out.status_code, self.default_error_handler)(out) - return self._cast(out) - if isinstance(out, HTTPResponse): - out.apply(response) - return self._cast(out.body) - - # File-like objects. - if hasattr(out, 'read'): - if 'wsgi.file_wrapper' in request.environ: - return request.environ['wsgi.file_wrapper'](out) - elif hasattr(out, 'close') or not hasattr(out, '__iter__'): - return WSGIFileWrapper(out) - - # Handle Iterables. We peek into them to detect their inner type. - try: - iout = iter(out) - first = next(iout) - while not first: - first = next(iout) - except StopIteration: - return self._cast('') - except HTTPResponse: - first = _e() - except (KeyboardInterrupt, SystemExit, MemoryError): - raise - except Exception: - if not self.catchall: raise - first = HTTPError(500, 'Unhandled exception', _e(), format_exc()) - - # These are the inner types allowed in iterator or generator objects. - if isinstance(first, HTTPResponse): - return self._cast(first) - elif isinstance(first, bytes): - new_iter = itertools.chain([first], iout) - elif isinstance(first, unicode): - encoder = lambda x: x.encode(response.charset) - new_iter = imap(encoder, itertools.chain([first], iout)) - else: - msg = 'Unsupported response type: %s' % type(first) - return self._cast(HTTPError(500, msg)) - if hasattr(out, 'close'): - new_iter = _closeiter(new_iter, out.close) - return new_iter - - def wsgi(self, environ, start_response): - """ The bottle WSGI-interface. """ - try: - out = self._cast(self._handle(environ)) - # rfc2616 section 4.3 - if response._status_code in (100, 101, 204, 304)\ - or environ['REQUEST_METHOD'] == 'HEAD': - if hasattr(out, 'close'): out.close() - out = [] - start_response(response._status_line, response.headerlist) - return out - except (KeyboardInterrupt, SystemExit, MemoryError): - raise - except Exception: - if not self.catchall: raise - err = '

    Critical error while processing request: %s

    ' \ - % html_escape(environ.get('PATH_INFO', '/')) - if DEBUG: - err += '

    Error:

    \n
    \n%s\n
    \n' \ - '

    Traceback:

    \n
    \n%s\n
    \n' \ - % (html_escape(repr(_e())), html_escape(format_exc())) - environ['wsgi.errors'].write(err) - headers = [('Content-Type', 'text/html; charset=UTF-8')] - start_response('500 INTERNAL SERVER ERROR', headers, sys.exc_info()) - return [tob(err)] - - def __call__(self, environ, start_response): - ''' Each instance of :class:'Bottle' is a WSGI application. ''' - return self.wsgi(environ, start_response) - - - - - - -############################################################################### -# HTTP and WSGI Tools ########################################################## -############################################################################### - -class BaseRequest(object): - """ A wrapper for WSGI environment dictionaries that adds a lot of - convenient access methods and properties. Most of them are read-only. - - Adding new attributes to a request actually adds them to the environ - dictionary (as 'bottle.request.ext.'). This is the recommended - way to store and access request-specific data. - """ - - __slots__ = ('environ') - - #: Maximum size of memory buffer for :attr:`body` in bytes. - MEMFILE_MAX = 102400 - - def __init__(self, environ=None): - """ Wrap a WSGI environ dictionary. """ - #: The wrapped WSGI environ dictionary. This is the only real attribute. - #: All other attributes actually are read-only properties. - self.environ = {} if environ is None else environ - self.environ['bottle.request'] = self - - @DictProperty('environ', 'bottle.app', read_only=True) - def app(self): - ''' Bottle application handling this request. ''' - raise RuntimeError('This request is not connected to an application.') - - @DictProperty('environ', 'bottle.route', read_only=True) - def route(self): - """ The bottle :class:`Route` object that matches this request. """ - raise RuntimeError('This request is not connected to a route.') - - @DictProperty('environ', 'route.url_args', read_only=True) - def url_args(self): - """ The arguments extracted from the URL. """ - raise RuntimeError('This request is not connected to a route.') - - @property - def path(self): - ''' The value of ``PATH_INFO`` with exactly one prefixed slash (to fix - broken clients and avoid the "empty path" edge case). ''' - return '/' + self.environ.get('PATH_INFO','').lstrip('/') - - @property - def method(self): - ''' The ``REQUEST_METHOD`` value as an uppercase string. ''' - return self.environ.get('REQUEST_METHOD', 'GET').upper() - - @DictProperty('environ', 'bottle.request.headers', read_only=True) - def headers(self): - ''' A :class:`WSGIHeaderDict` that provides case-insensitive access to - HTTP request headers. ''' - return WSGIHeaderDict(self.environ) - - def get_header(self, name, default=None): - ''' Return the value of a request header, or a given default value. ''' - return self.headers.get(name, default) - - @DictProperty('environ', 'bottle.request.cookies', read_only=True) - def cookies(self): - """ Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT - decoded. Use :meth:`get_cookie` if you expect signed cookies. """ - cookies = SimpleCookie(self.environ.get('HTTP_COOKIE','')).values() - return FormsDict((c.key, c.value) for c in cookies) - - def get_cookie(self, key, default=None, secret=None): - """ Return the content of a cookie. To read a `Signed Cookie`, the - `secret` must match the one used to create the cookie (see - :meth:`BaseResponse.set_cookie`). If anything goes wrong (missing - cookie or wrong signature), return a default value. """ - value = self.cookies.get(key) - if secret and value: - dec = cookie_decode(value, secret) # (key, value) tuple or None - return dec[1] if dec and dec[0] == key else default - return value or default - - @DictProperty('environ', 'bottle.request.query', read_only=True) - def query(self): - ''' The :attr:`query_string` parsed into a :class:`FormsDict`. These - values are sometimes called "URL arguments" or "GET parameters", but - not to be confused with "URL wildcards" as they are provided by the - :class:`Router`. ''' - get = self.environ['bottle.get'] = FormsDict() - pairs = _parse_qsl(self.environ.get('QUERY_STRING', '')) - for key, value in pairs: - get[key] = value - return get - - @DictProperty('environ', 'bottle.request.forms', read_only=True) - def forms(self): - """ Form values parsed from an `url-encoded` or `multipart/form-data` - encoded POST or PUT request body. The result is returned as a - :class:`FormsDict`. All keys and values are strings. File uploads - are stored separately in :attr:`files`. """ - forms = FormsDict() - for name, item in self.POST.allitems(): - if not isinstance(item, FileUpload): - forms[name] = item - return forms - - @DictProperty('environ', 'bottle.request.params', read_only=True) - def params(self): - """ A :class:`FormsDict` with the combined values of :attr:`query` and - :attr:`forms`. File uploads are stored in :attr:`files`. """ - params = FormsDict() - for key, value in self.query.allitems(): - params[key] = value - for key, value in self.forms.allitems(): - params[key] = value - return params - - @DictProperty('environ', 'bottle.request.files', read_only=True) - def files(self): - """ File uploads parsed from `multipart/form-data` encoded POST or PUT - request body. The values are instances of :class:`FileUpload`. - - """ - files = FormsDict() - for name, item in self.POST.allitems(): - if isinstance(item, FileUpload): - files[name] = item - return files - - @DictProperty('environ', 'bottle.request.json', read_only=True) - def json(self): - ''' If the ``Content-Type`` header is ``application/json``, this - property holds the parsed content of the request body. Only requests - smaller than :attr:`MEMFILE_MAX` are processed to avoid memory - exhaustion. ''' - ctype = self.environ.get('CONTENT_TYPE', '').lower().split(';')[0] - if ctype == 'application/json': - b = self._get_body_string() - if not b: - return None - return json_loads(b) - return None - - def _iter_body(self, read, bufsize): - maxread = max(0, self.content_length) - while maxread: - part = read(min(maxread, bufsize)) - if not part: break - yield part - maxread -= len(part) - - def _iter_chunked(self, read, bufsize): - err = HTTPError(400, 'Error while parsing chunked transfer body.') - rn, sem, bs = tob('\r\n'), tob(';'), tob('') - while True: - header = read(1) - while header[-2:] != rn: - c = read(1) - header += c - if not c: raise err - if len(header) > bufsize: raise err - size, _, _ = header.partition(sem) - try: - maxread = int(tonat(size.strip()), 16) - except ValueError: - raise err - if maxread == 0: break - buff = bs - while maxread > 0: - if not buff: - buff = read(min(maxread, bufsize)) - part, buff = buff[:maxread], buff[maxread:] - if not part: raise err - yield part - maxread -= len(part) - if read(2) != rn: - raise err - - @DictProperty('environ', 'bottle.request.body', read_only=True) - def _body(self): - body_iter = self._iter_chunked if self.chunked else self._iter_body - read_func = self.environ['wsgi.input'].read - body, body_size, is_temp_file = BytesIO(), 0, False - for part in body_iter(read_func, self.MEMFILE_MAX): - body.write(part) - body_size += len(part) - if not is_temp_file and body_size > self.MEMFILE_MAX: - body, tmp = TemporaryFile(mode='w+b'), body - body.write(tmp.getvalue()) - del tmp - is_temp_file = True - self.environ['wsgi.input'] = body - body.seek(0) - return body - - def _get_body_string(self): - ''' read body until content-length or MEMFILE_MAX into a string. Raise - HTTPError(413) on requests that are to large. ''' - clen = self.content_length - if clen > self.MEMFILE_MAX: - raise HTTPError(413, 'Request to large') - if clen < 0: clen = self.MEMFILE_MAX + 1 - data = self.body.read(clen) - if len(data) > self.MEMFILE_MAX: # Fail fast - raise HTTPError(413, 'Request to large') - return data - - @property - def body(self): - """ The HTTP request body as a seek-able file-like object. Depending on - :attr:`MEMFILE_MAX`, this is either a temporary file or a - :class:`io.BytesIO` instance. Accessing this property for the first - time reads and replaces the ``wsgi.input`` environ variable. - Subsequent accesses just do a `seek(0)` on the file object. """ - self._body.seek(0) - return self._body - - @property - def chunked(self): - ''' True if Chunked transfer encoding was. ''' - return 'chunked' in self.environ.get('HTTP_TRANSFER_ENCODING', '').lower() - - #: An alias for :attr:`query`. - GET = query - - @DictProperty('environ', 'bottle.request.post', read_only=True) - def POST(self): - """ The values of :attr:`forms` and :attr:`files` combined into a single - :class:`FormsDict`. Values are either strings (form values) or - instances of :class:`cgi.FieldStorage` (file uploads). - """ - post = FormsDict() - # We default to application/x-www-form-urlencoded for everything that - # is not multipart and take the fast path (also: 3.1 workaround) - if not self.content_type.startswith('multipart/'): - pairs = _parse_qsl(tonat(self._get_body_string(), 'latin1')) - for key, value in pairs: - post[key] = value - return post - - safe_env = {'QUERY_STRING':''} # Build a safe environment for cgi - for key in ('REQUEST_METHOD', 'CONTENT_TYPE', 'CONTENT_LENGTH'): - if key in self.environ: safe_env[key] = self.environ[key] - args = dict(fp=self.body, environ=safe_env, keep_blank_values=True) - if py31: - args['fp'] = NCTextIOWrapper(args['fp'], encoding='utf8', - newline='\n') - elif py3k: - args['encoding'] = 'utf8' - data = cgi.FieldStorage(**args) - self['_cgi.FieldStorage'] = data #http://bugs.python.org/issue18394#msg207958 - data = data.list or [] - for item in data: - if item.filename is None: - post[item.name] = item.value - else: - post[item.name] = FileUpload(item.file, item.name, - item.filename, item.headers) - return post - - @property - def url(self): - """ The full request URI including hostname and scheme. If your app - lives behind a reverse proxy or load balancer and you get confusing - results, make sure that the ``X-Forwarded-Host`` header is set - correctly. """ - return self.urlparts.geturl() - - @DictProperty('environ', 'bottle.request.urlparts', read_only=True) - def urlparts(self): - ''' The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. - The tuple contains (scheme, host, path, query_string and fragment), - but the fragment is always empty because it is not visible to the - server. ''' - env = self.environ - http = env.get('HTTP_X_FORWARDED_PROTO') or env.get('wsgi.url_scheme', 'http') - host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST') - if not host: - # HTTP 1.1 requires a Host-header. This is for HTTP/1.0 clients. - host = env.get('SERVER_NAME', '127.0.0.1') - port = env.get('SERVER_PORT') - if port and port != ('80' if http == 'http' else '443'): - host += ':' + port - path = urlquote(self.fullpath) - return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '') - - @property - def fullpath(self): - """ Request path including :attr:`script_name` (if present). """ - return urljoin(self.script_name, self.path.lstrip('/')) - - @property - def query_string(self): - """ The raw :attr:`query` part of the URL (everything in between ``?`` - and ``#``) as a string. """ - return self.environ.get('QUERY_STRING', '') - - @property - def script_name(self): - ''' The initial portion of the URL's `path` that was removed by a higher - level (server or routing middleware) before the application was - called. This script path is returned with leading and tailing - slashes. ''' - script_name = self.environ.get('SCRIPT_NAME', '').strip('/') - return '/' + script_name + '/' if script_name else '/' - - def path_shift(self, shift=1): - ''' Shift path segments from :attr:`path` to :attr:`script_name` and - vice versa. - - :param shift: The number of path segments to shift. May be negative - to change the shift direction. (default: 1) - ''' - script = self.environ.get('SCRIPT_NAME','/') - self['SCRIPT_NAME'], self['PATH_INFO'] = path_shift(script, self.path, shift) - - @property - def content_length(self): - ''' The request body length as an integer. The client is responsible to - set this header. Otherwise, the real length of the body is unknown - and -1 is returned. In this case, :attr:`body` will be empty. ''' - return int(self.environ.get('CONTENT_LENGTH') or -1) - - @property - def content_type(self): - ''' The Content-Type header as a lowercase-string (default: empty). ''' - return self.environ.get('CONTENT_TYPE', '').lower() - - @property - def is_xhr(self): - ''' True if the request was triggered by a XMLHttpRequest. This only - works with JavaScript libraries that support the `X-Requested-With` - header (most of the popular libraries do). ''' - requested_with = self.environ.get('HTTP_X_REQUESTED_WITH','') - return requested_with.lower() == 'xmlhttprequest' - - @property - def is_ajax(self): - ''' Alias for :attr:`is_xhr`. "Ajax" is not the right term. ''' - return self.is_xhr - - @property - def auth(self): - """ HTTP authentication data as a (user, password) tuple. This - implementation currently supports basic (not digest) authentication - only. If the authentication happened at a higher level (e.g. in the - front web-server or a middleware), the password field is None, but - the user field is looked up from the ``REMOTE_USER`` environ - variable. On any errors, None is returned. """ - basic = parse_auth(self.environ.get('HTTP_AUTHORIZATION','')) - if basic: return basic - ruser = self.environ.get('REMOTE_USER') - if ruser: return (ruser, None) - return None - - @property - def remote_route(self): - """ A list of all IPs that were involved in this request, starting with - the client IP and followed by zero or more proxies. This does only - work if all proxies support the ```X-Forwarded-For`` header. Note - that this information can be forged by malicious clients. """ - proxy = self.environ.get('HTTP_X_FORWARDED_FOR') - if proxy: return [ip.strip() for ip in proxy.split(',')] - remote = self.environ.get('REMOTE_ADDR') - return [remote] if remote else [] - - @property - def remote_addr(self): - """ The client IP as a string. Note that this information can be forged - by malicious clients. """ - route = self.remote_route - return route[0] if route else None - - def copy(self): - """ Return a new :class:`Request` with a shallow :attr:`environ` copy. """ - return Request(self.environ.copy()) - - def get(self, value, default=None): return self.environ.get(value, default) - def __getitem__(self, key): return self.environ[key] - def __delitem__(self, key): self[key] = ""; del(self.environ[key]) - def __iter__(self): return iter(self.environ) - def __len__(self): return len(self.environ) - def keys(self): return self.environ.keys() - def __setitem__(self, key, value): - """ Change an environ value and clear all caches that depend on it. """ - - if self.environ.get('bottle.request.readonly'): - raise KeyError('The environ dictionary is read-only.') - - self.environ[key] = value - todelete = () - - if key == 'wsgi.input': - todelete = ('body', 'forms', 'files', 'params', 'post', 'json') - elif key == 'QUERY_STRING': - todelete = ('query', 'params') - elif key.startswith('HTTP_'): - todelete = ('headers', 'cookies') - - for key in todelete: - self.environ.pop('bottle.request.'+key, None) - - def __repr__(self): - return '<%s: %s %s>' % (self.__class__.__name__, self.method, self.url) - - def __getattr__(self, name): - ''' Search in self.environ for additional user defined attributes. ''' - try: - var = self.environ['bottle.request.ext.%s'%name] - return var.__get__(self) if hasattr(var, '__get__') else var - except KeyError: - raise AttributeError('Attribute %r not defined.' % name) - - def __setattr__(self, name, value): - if name == 'environ': return object.__setattr__(self, name, value) - self.environ['bottle.request.ext.%s'%name] = value - - -def _hkey(key): - if '\n' in key or '\r' in key or '\0' in key: - raise ValueError("Header names must not contain control characters: %r" % key) - return key.title().replace('_', '-') - - -def _hval(value): - value = tonat(value) - if '\n' in value or '\r' in value or '\0' in value: - raise ValueError("Header value must not contain control characters: %r" % value) - return value - - - -class HeaderProperty(object): - def __init__(self, name, reader=None, writer=None, default=''): - self.name, self.default = name, default - self.reader, self.writer = reader, writer - self.__doc__ = 'Current value of the %r header.' % name.title() - - def __get__(self, obj, cls): - if obj is None: return self - value = obj.get_header(self.name, self.default) - return self.reader(value) if self.reader else value - - def __set__(self, obj, value): - obj[self.name] = self.writer(value) if self.writer else value - - def __delete__(self, obj): - del obj[self.name] - - -class BaseResponse(object): - """ Storage class for a response body as well as headers and cookies. - - This class does support dict-like case-insensitive item-access to - headers, but is NOT a dict. Most notably, iterating over a response - yields parts of the body and not the headers. - - :param body: The response body as one of the supported types. - :param status: Either an HTTP status code (e.g. 200) or a status line - including the reason phrase (e.g. '200 OK'). - :param headers: A dictionary or a list of name-value pairs. - - Additional keyword arguments are added to the list of headers. - Underscores in the header name are replaced with dashes. - """ - - default_status = 200 - default_content_type = 'text/html; charset=UTF-8' - - # Header blacklist for specific response codes - # (rfc2616 section 10.2.3 and 10.3.5) - bad_headers = { - 204: set(('Content-Type',)), - 304: set(('Allow', 'Content-Encoding', 'Content-Language', - 'Content-Length', 'Content-Range', 'Content-Type', - 'Content-Md5', 'Last-Modified'))} - - def __init__(self, body='', status=None, headers=None, **more_headers): - self._cookies = None - self._headers = {} - self.body = body - self.status = status or self.default_status - if headers: - if isinstance(headers, dict): - headers = headers.items() - for name, value in headers: - self.add_header(name, value) - if more_headers: - for name, value in more_headers.items(): - self.add_header(name, value) - - def copy(self, cls=None): - ''' Returns a copy of self. ''' - cls = cls or BaseResponse - assert issubclass(cls, BaseResponse) - copy = cls() - copy.status = self.status - copy._headers = dict((k, v[:]) for (k, v) in self._headers.items()) - if self._cookies: - copy._cookies = SimpleCookie() - copy._cookies.load(self._cookies.output(header='')) - return copy - - def __iter__(self): - return iter(self.body) - - def close(self): - if hasattr(self.body, 'close'): - self.body.close() - - @property - def status_line(self): - ''' The HTTP status line as a string (e.g. ``404 Not Found``).''' - return self._status_line - - @property - def status_code(self): - ''' The HTTP status code as an integer (e.g. 404).''' - return self._status_code - - def _set_status(self, status): - if isinstance(status, int): - code, status = status, _HTTP_STATUS_LINES.get(status) - elif ' ' in status: - status = status.strip() - code = int(status.split()[0]) - else: - raise ValueError('String status line without a reason phrase.') - if not 100 <= code <= 999: raise ValueError('Status code out of range.') - self._status_code = code - self._status_line = str(status or ('%d Unknown' % code)) - - def _get_status(self): - return self._status_line - - status = property(_get_status, _set_status, None, - ''' A writeable property to change the HTTP response status. It accepts - either a numeric code (100-999) or a string with a custom reason - phrase (e.g. "404 Brain not found"). Both :data:`status_line` and - :data:`status_code` are updated accordingly. The return value is - always a status string. ''') - del _get_status, _set_status - - @property - def headers(self): - ''' An instance of :class:`HeaderDict`, a case-insensitive dict-like - view on the response headers. ''' - hdict = HeaderDict() - hdict.dict = self._headers - return hdict - - def __contains__(self, name): return _hkey(name) in self._headers - def __delitem__(self, name): del self._headers[_hkey(name)] - def __getitem__(self, name): return self._headers[_hkey(name)][-1] - def __setitem__(self, name, value): self._headers[_hkey(name)] = [_hval(value)] - - def get_header(self, name, default=None): - ''' Return the value of a previously defined header. If there is no - header with that name, return a default value. ''' - return self._headers.get(_hkey(name), [default])[-1] - - def set_header(self, name, value): - ''' Create a new response header, replacing any previously defined - headers with the same name. ''' - self._headers[_hkey(name)] = [_hval(value)] - - def add_header(self, name, value): - ''' Add an additional response header, not removing duplicates. ''' - self._headers.setdefault(_hkey(name), []).append(_hval(value)) - - def iter_headers(self): - ''' Yield (header, value) tuples, skipping headers that are not - allowed with the current response status code. ''' - return self.headerlist - - @property - def headerlist(self): - """ WSGI conform list of (header, value) tuples. """ - out = [] - headers = list(self._headers.items()) - if 'Content-Type' not in self._headers: - headers.append(('Content-Type', [self.default_content_type])) - if self._status_code in self.bad_headers: - bad_headers = self.bad_headers[self._status_code] - headers = [h for h in headers if h[0] not in bad_headers] - out += [(name, val) for (name, vals) in headers for val in vals] - if self._cookies: - for c in self._cookies.values(): - out.append(('Set-Cookie', _hval(c.OutputString()))) - if py3k: - out = [(k, v.encode('utf8').decode('latin1')) for (k, v) in out] - return out - - content_type = HeaderProperty('Content-Type') - content_length = HeaderProperty('Content-Length', reader=int) - expires = HeaderProperty('Expires', - reader=lambda x: datetime.utcfromtimestamp(parse_date(x)), - writer=lambda x: http_date(x)) - - @property - def charset(self, default='UTF-8'): - """ Return the charset specified in the content-type header (default: utf8). """ - if 'charset=' in self.content_type: - return self.content_type.split('charset=')[-1].split(';')[0].strip() - return default - - def set_cookie(self, name, value, secret=None, **options): - ''' Create a new cookie or replace an old one. If the `secret` parameter is - set, create a `Signed Cookie` (described below). - - :param name: the name of the cookie. - :param value: the value of the cookie. - :param secret: a signature key required for signed cookies. - - Additionally, this method accepts all RFC 2109 attributes that are - supported by :class:`cookie.Morsel`, including: - - :param max_age: maximum age in seconds. (default: None) - :param expires: a datetime object or UNIX timestamp. (default: None) - :param domain: the domain that is allowed to read the cookie. - (default: current domain) - :param path: limits the cookie to a given path (default: current path) - :param secure: limit the cookie to HTTPS connections (default: off). - :param httponly: prevents client-side javascript to read this cookie - (default: off, requires Python 2.6 or newer). - - If neither `expires` nor `max_age` is set (default), the cookie will - expire at the end of the browser session (as soon as the browser - window is closed). - - Signed cookies may store any pickle-able object and are - cryptographically signed to prevent manipulation. Keep in mind that - cookies are limited to 4kb in most browsers. - - Warning: Signed cookies are not encrypted (the client can still see - the content) and not copy-protected (the client can restore an old - cookie). The main intention is to make pickling and unpickling - save, not to store secret information at client side. - ''' - if not self._cookies: - self._cookies = SimpleCookie() - - if secret: - value = touni(cookie_encode((name, value), secret)) - elif not isinstance(value, basestring): - raise TypeError('Secret key missing for non-string Cookie.') - - if len(value) > 4096: raise ValueError('Cookie value to long.') - self._cookies[name] = value - - for key, value in options.items(): - if key == 'max_age': - if isinstance(value, timedelta): - value = value.seconds + value.days * 24 * 3600 - if key == 'expires': - if isinstance(value, (datedate, datetime)): - value = value.timetuple() - elif isinstance(value, (int, float)): - value = time.gmtime(value) - value = time.strftime("%a, %d %b %Y %H:%M:%S GMT", value) - self._cookies[name][key.replace('_', '-')] = value - - def delete_cookie(self, key, **kwargs): - ''' Delete a cookie. Be sure to use the same `domain` and `path` - settings as used to create the cookie. ''' - kwargs['max_age'] = -1 - kwargs['expires'] = 0 - self.set_cookie(key, '', **kwargs) - - def __repr__(self): - out = '' - for name, value in self.headerlist: - out += '%s: %s\n' % (name.title(), value.strip()) - return out - - -def local_property(name=None): - if name: depr('local_property() is deprecated and will be removed.') #0.12 - ls = threading.local() - def fget(self): - try: return ls.var - except AttributeError: - raise RuntimeError("Request context not initialized.") - def fset(self, value): ls.var = value - def fdel(self): del ls.var - return property(fget, fset, fdel, 'Thread-local property') - - -class LocalRequest(BaseRequest): - ''' A thread-local subclass of :class:`BaseRequest` with a different - set of attributes for each thread. There is usually only one global - instance of this class (:data:`request`). If accessed during a - request/response cycle, this instance always refers to the *current* - request (even on a multithreaded server). ''' - bind = BaseRequest.__init__ - environ = local_property() - - -class LocalResponse(BaseResponse): - ''' A thread-local subclass of :class:`BaseResponse` with a different - set of attributes for each thread. There is usually only one global - instance of this class (:data:`response`). Its attributes are used - to build the HTTP response at the end of the request/response cycle. - ''' - bind = BaseResponse.__init__ - _status_line = local_property() - _status_code = local_property() - _cookies = local_property() - _headers = local_property() - body = local_property() - - -Request = BaseRequest -Response = BaseResponse - - -class HTTPResponse(Response, BottleException): - def __init__(self, body='', status=None, headers=None, **more_headers): - super(HTTPResponse, self).__init__(body, status, headers, **more_headers) - - def apply(self, response): - response._status_code = self._status_code - response._status_line = self._status_line - response._headers = self._headers - response._cookies = self._cookies - response.body = self.body - - -class HTTPError(HTTPResponse): - default_status = 500 - def __init__(self, status=None, body=None, exception=None, traceback=None, - **options): - self.exception = exception - self.traceback = traceback - super(HTTPError, self).__init__(body, status, **options) - - - - - -############################################################################### -# Plugins ###################################################################### -############################################################################### - -class PluginError(BottleException): pass - - -class JSONPlugin(object): - name = 'json' - api = 2 - - def __init__(self, json_dumps=json_dumps): - self.json_dumps = json_dumps - - def apply(self, callback, route): - dumps = self.json_dumps - if not dumps: return callback - def wrapper(*a, **ka): - try: - rv = callback(*a, **ka) - except HTTPError: - rv = _e() - - if isinstance(rv, dict): - #Attempt to serialize, raises exception on failure - json_response = dumps(rv) - #Set content type only if serialization succesful - response.content_type = 'application/json' - return json_response - elif isinstance(rv, HTTPResponse) and isinstance(rv.body, dict): - rv.body = dumps(rv.body) - rv.content_type = 'application/json' - return rv - - return wrapper - - -class TemplatePlugin(object): - ''' This plugin applies the :func:`view` decorator to all routes with a - `template` config parameter. If the parameter is a tuple, the second - element must be a dict with additional options (e.g. `template_engine`) - or default variables for the template. ''' - name = 'template' - api = 2 - - def apply(self, callback, route): - conf = route.config.get('template') - if isinstance(conf, (tuple, list)) and len(conf) == 2: - return view(conf[0], **conf[1])(callback) - elif isinstance(conf, str): - return view(conf)(callback) - else: - return callback - - -#: Not a plugin, but part of the plugin API. TODO: Find a better place. -class _ImportRedirect(object): - def __init__(self, name, impmask): - ''' Create a virtual package that redirects imports (see PEP 302). ''' - self.name = name - self.impmask = impmask - self.module = sys.modules.setdefault(name, new_module(name)) - self.module.__dict__.update({'__file__': __file__, '__path__': [], - '__all__': [], '__loader__': self}) - sys.meta_path.append(self) - - def find_module(self, fullname, path=None): - if '.' not in fullname: return - packname = fullname.rsplit('.', 1)[0] - if packname != self.name: return - return self - - def load_module(self, fullname): - if fullname in sys.modules: return sys.modules[fullname] - modname = fullname.rsplit('.', 1)[1] - realname = self.impmask % modname - __import__(realname) - module = sys.modules[fullname] = sys.modules[realname] - setattr(self.module, modname, module) - module.__loader__ = self - return module - - - - - - -############################################################################### -# Common Utilities ############################################################# -############################################################################### - - -class MultiDict(DictMixin): - """ This dict stores multiple values per key, but behaves exactly like a - normal dict in that it returns only the newest value for any given key. - There are special methods available to access the full list of values. - """ - - def __init__(self, *a, **k): - self.dict = dict((k, [v]) for (k, v) in dict(*a, **k).items()) - - def __len__(self): return len(self.dict) - def __iter__(self): return iter(self.dict) - def __contains__(self, key): return key in self.dict - def __delitem__(self, key): del self.dict[key] - def __getitem__(self, key): return self.dict[key][-1] - def __setitem__(self, key, value): self.append(key, value) - def keys(self): return self.dict.keys() - - if py3k: - def values(self): return (v[-1] for v in self.dict.values()) - def items(self): return ((k, v[-1]) for k, v in self.dict.items()) - def allitems(self): - return ((k, v) for k, vl in self.dict.items() for v in vl) - iterkeys = keys - itervalues = values - iteritems = items - iterallitems = allitems - - else: - def values(self): return [v[-1] for v in self.dict.values()] - def items(self): return [(k, v[-1]) for k, v in self.dict.items()] - def iterkeys(self): return self.dict.iterkeys() - def itervalues(self): return (v[-1] for v in self.dict.itervalues()) - def iteritems(self): - return ((k, v[-1]) for k, v in self.dict.iteritems()) - def iterallitems(self): - return ((k, v) for k, vl in self.dict.iteritems() for v in vl) - def allitems(self): - return [(k, v) for k, vl in self.dict.iteritems() for v in vl] - - def get(self, key, default=None, index=-1, type=None): - ''' Return the most recent value for a key. - - :param default: The default value to be returned if the key is not - present or the type conversion fails. - :param index: An index for the list of available values. - :param type: If defined, this callable is used to cast the value - into a specific type. Exception are suppressed and result in - the default value to be returned. - ''' - try: - val = self.dict[key][index] - return type(val) if type else val - except Exception: - pass - return default - - def append(self, key, value): - ''' Add a new value to the list of values for this key. ''' - self.dict.setdefault(key, []).append(value) - - def replace(self, key, value): - ''' Replace the list of values with a single value. ''' - self.dict[key] = [value] - - def getall(self, key): - ''' Return a (possibly empty) list of values for a key. ''' - return self.dict.get(key) or [] - - #: Aliases for WTForms to mimic other multi-dict APIs (Django) - getone = get - getlist = getall - - -class FormsDict(MultiDict): - ''' This :class:`MultiDict` subclass is used to store request form data. - Additionally to the normal dict-like item access methods (which return - unmodified data as native strings), this container also supports - attribute-like access to its values. Attributes are automatically de- - or recoded to match :attr:`input_encoding` (default: 'utf8'). Missing - attributes default to an empty string. ''' - - #: Encoding used for attribute values. - input_encoding = 'utf8' - #: If true (default), unicode strings are first encoded with `latin1` - #: and then decoded to match :attr:`input_encoding`. - recode_unicode = True - - def _fix(self, s, encoding=None): - if isinstance(s, unicode) and self.recode_unicode: # Python 3 WSGI - return s.encode('latin1').decode(encoding or self.input_encoding) - elif isinstance(s, bytes): # Python 2 WSGI - return s.decode(encoding or self.input_encoding) - else: - return s - - def decode(self, encoding=None): - ''' Returns a copy with all keys and values de- or recoded to match - :attr:`input_encoding`. Some libraries (e.g. WTForms) want a - unicode dictionary. ''' - copy = FormsDict() - enc = copy.input_encoding = encoding or self.input_encoding - copy.recode_unicode = False - for key, value in self.allitems(): - copy.append(self._fix(key, enc), self._fix(value, enc)) - return copy - - def getunicode(self, name, default=None, encoding=None): - ''' Return the value as a unicode string, or the default. ''' - try: - return self._fix(self[name], encoding) - except (UnicodeError, KeyError): - return default - - def __getattr__(self, name, default=unicode()): - # Without this guard, pickle generates a cryptic TypeError: - if name.startswith('__') and name.endswith('__'): - return super(FormsDict, self).__getattr__(name) - return self.getunicode(name, default=default) - -class HeaderDict(MultiDict): - """ A case-insensitive version of :class:`MultiDict` that defaults to - replace the old value instead of appending it. """ - - def __init__(self, *a, **ka): - self.dict = {} - if a or ka: self.update(*a, **ka) - - def __contains__(self, key): return _hkey(key) in self.dict - def __delitem__(self, key): del self.dict[_hkey(key)] - def __getitem__(self, key): return self.dict[_hkey(key)][-1] - def __setitem__(self, key, value): self.dict[_hkey(key)] = [_hval(value)] - def append(self, key, value): self.dict.setdefault(_hkey(key), []).append(_hval(value)) - def replace(self, key, value): self.dict[_hkey(key)] = [_hval(value)] - def getall(self, key): return self.dict.get(_hkey(key)) or [] - def get(self, key, default=None, index=-1): - return MultiDict.get(self, _hkey(key), default, index) - def filter(self, names): - for name in (_hkey(n) for n in names): - if name in self.dict: - del self.dict[name] - - -class WSGIHeaderDict(DictMixin): - ''' This dict-like class wraps a WSGI environ dict and provides convenient - access to HTTP_* fields. Keys and values are native strings - (2.x bytes or 3.x unicode) and keys are case-insensitive. If the WSGI - environment contains non-native string values, these are de- or encoded - using a lossless 'latin1' character set. - - The API will remain stable even on changes to the relevant PEPs. - Currently PEP 333, 444 and 3333 are supported. (PEP 444 is the only one - that uses non-native strings.) - ''' - #: List of keys that do not have a ``HTTP_`` prefix. - cgikeys = ('CONTENT_TYPE', 'CONTENT_LENGTH') - - def __init__(self, environ): - self.environ = environ - - def _ekey(self, key): - ''' Translate header field name to CGI/WSGI environ key. ''' - key = key.replace('-','_').upper() - if key in self.cgikeys: - return key - return 'HTTP_' + key - - def raw(self, key, default=None): - ''' Return the header value as is (may be bytes or unicode). ''' - return self.environ.get(self._ekey(key), default) - - def __getitem__(self, key): - return tonat(self.environ[self._ekey(key)], 'latin1') - - def __setitem__(self, key, value): - raise TypeError("%s is read-only." % self.__class__) - - def __delitem__(self, key): - raise TypeError("%s is read-only." % self.__class__) - - def __iter__(self): - for key in self.environ: - if key[:5] == 'HTTP_': - yield key[5:].replace('_', '-').title() - elif key in self.cgikeys: - yield key.replace('_', '-').title() - - def keys(self): return [x for x in self] - def __len__(self): return len(self.keys()) - def __contains__(self, key): return self._ekey(key) in self.environ - - - -class ConfigDict(dict): - ''' A dict-like configuration storage with additional support for - namespaces, validators, meta-data, on_change listeners and more. - - This storage is optimized for fast read access. Retrieving a key - or using non-altering dict methods (e.g. `dict.get()`) has no overhead - compared to a native dict. - ''' - __slots__ = ('_meta', '_on_change') - - class Namespace(DictMixin): - - def __init__(self, config, namespace): - self._config = config - self._prefix = namespace - - def __getitem__(self, key): - depr('Accessing namespaces as dicts is discouraged. ' - 'Only use flat item access: ' - 'cfg["names"]["pace"]["key"] -> cfg["name.space.key"]') #0.12 - return self._config[self._prefix + '.' + key] - - def __setitem__(self, key, value): - self._config[self._prefix + '.' + key] = value - - def __delitem__(self, key): - del self._config[self._prefix + '.' + key] - - def __iter__(self): - ns_prefix = self._prefix + '.' - for key in self._config: - ns, dot, name = key.rpartition('.') - if ns == self._prefix and name: - yield name - - def keys(self): return [x for x in self] - def __len__(self): return len(self.keys()) - def __contains__(self, key): return self._prefix + '.' + key in self._config - def __repr__(self): return '' % self._prefix - def __str__(self): return '' % self._prefix - - # Deprecated ConfigDict features - def __getattr__(self, key): - depr('Attribute access is deprecated.') #0.12 - if key not in self and key[0].isupper(): - self[key] = ConfigDict.Namespace(self._config, self._prefix + '.' + key) - if key not in self and key.startswith('__'): - raise AttributeError(key) - return self.get(key) - - def __setattr__(self, key, value): - if key in ('_config', '_prefix'): - self.__dict__[key] = value - return - depr('Attribute assignment is deprecated.') #0.12 - if hasattr(DictMixin, key): - raise AttributeError('Read-only attribute.') - if key in self and self[key] and isinstance(self[key], self.__class__): - raise AttributeError('Non-empty namespace attribute.') - self[key] = value - - def __delattr__(self, key): - if key in self: - val = self.pop(key) - if isinstance(val, self.__class__): - prefix = key + '.' - for key in self: - if key.startswith(prefix): - del self[prefix+key] - - def __call__(self, *a, **ka): - depr('Calling ConfDict is deprecated. Use the update() method.') #0.12 - self.update(*a, **ka) - return self - - def __init__(self, *a, **ka): - self._meta = {} - self._on_change = lambda name, value: None - if a or ka: - depr('Constructor does no longer accept parameters.') #0.12 - self.update(*a, **ka) - - def load_config(self, filename): - ''' Load values from an *.ini style config file. - - If the config file contains sections, their names are used as - namespaces for the values within. The two special sections - ``DEFAULT`` and ``bottle`` refer to the root namespace (no prefix). - ''' - conf = ConfigParser() - conf.read(filename) - for section in conf.sections(): - for key, value in conf.items(section): - if section not in ('DEFAULT', 'bottle'): - key = section + '.' + key - self[key] = value - return self - - def load_dict(self, source, namespace='', make_namespaces=False): - ''' Import values from a dictionary structure. Nesting can be used to - represent namespaces. - - >>> ConfigDict().load_dict({'name': {'space': {'key': 'value'}}}) - {'name.space.key': 'value'} - ''' - stack = [(namespace, source)] - while stack: - prefix, source = stack.pop() - if not isinstance(source, dict): - raise TypeError('Source is not a dict (r)' % type(key)) - for key, value in source.items(): - if not isinstance(key, basestring): - raise TypeError('Key is not a string (%r)' % type(key)) - full_key = prefix + '.' + key if prefix else key - if isinstance(value, dict): - stack.append((full_key, value)) - if make_namespaces: - self[full_key] = self.Namespace(self, full_key) - else: - self[full_key] = value - return self - - def update(self, *a, **ka): - ''' If the first parameter is a string, all keys are prefixed with this - namespace. Apart from that it works just as the usual dict.update(). - Example: ``update('some.namespace', key='value')`` ''' - prefix = '' - if a and isinstance(a[0], basestring): - prefix = a[0].strip('.') + '.' - a = a[1:] - for key, value in dict(*a, **ka).items(): - self[prefix+key] = value - - def setdefault(self, key, value): - if key not in self: - self[key] = value - return self[key] - - def __setitem__(self, key, value): - if not isinstance(key, basestring): - raise TypeError('Key has type %r (not a string)' % type(key)) - - value = self.meta_get(key, 'filter', lambda x: x)(value) - if key in self and self[key] is value: - return - self._on_change(key, value) - dict.__setitem__(self, key, value) - - def __delitem__(self, key): - dict.__delitem__(self, key) - - def clear(self): - for key in self: - del self[key] - - def meta_get(self, key, metafield, default=None): - ''' Return the value of a meta field for a key. ''' - return self._meta.get(key, {}).get(metafield, default) - - def meta_set(self, key, metafield, value): - ''' Set the meta field for a key to a new value. This triggers the - on-change handler for existing keys. ''' - self._meta.setdefault(key, {})[metafield] = value - if key in self: - self[key] = self[key] - - def meta_list(self, key): - ''' Return an iterable of meta field names defined for a key. ''' - return self._meta.get(key, {}).keys() - - # Deprecated ConfigDict features - def __getattr__(self, key): - depr('Attribute access is deprecated.') #0.12 - if key not in self and key[0].isupper(): - self[key] = self.Namespace(self, key) - if key not in self and key.startswith('__'): - raise AttributeError(key) - return self.get(key) - - def __setattr__(self, key, value): - if key in self.__slots__: - return dict.__setattr__(self, key, value) - depr('Attribute assignment is deprecated.') #0.12 - if hasattr(dict, key): - raise AttributeError('Read-only attribute.') - if key in self and self[key] and isinstance(self[key], self.Namespace): - raise AttributeError('Non-empty namespace attribute.') - self[key] = value - - def __delattr__(self, key): - if key in self: - val = self.pop(key) - if isinstance(val, self.Namespace): - prefix = key + '.' - for key in self: - if key.startswith(prefix): - del self[prefix+key] - - def __call__(self, *a, **ka): - depr('Calling ConfDict is deprecated. Use the update() method.') #0.12 - self.update(*a, **ka) - return self - - - -class AppStack(list): - """ A stack-like list. Calling it returns the head of the stack. """ - - def __call__(self): - """ Return the current default application. """ - return self[-1] - - def push(self, value=None): - """ Add a new :class:`Bottle` instance to the stack """ - if not isinstance(value, Bottle): - value = Bottle() - self.append(value) - return value - - -class WSGIFileWrapper(object): - - def __init__(self, fp, buffer_size=1024*64): - self.fp, self.buffer_size = fp, buffer_size - for attr in ('fileno', 'close', 'read', 'readlines', 'tell', 'seek'): - if hasattr(fp, attr): setattr(self, attr, getattr(fp, attr)) - - def __iter__(self): - buff, read = self.buffer_size, self.read - while True: - part = read(buff) - if not part: return - yield part - - -class _closeiter(object): - ''' This only exists to be able to attach a .close method to iterators that - do not support attribute assignment (most of itertools). ''' - - def __init__(self, iterator, close=None): - self.iterator = iterator - self.close_callbacks = makelist(close) - - def __iter__(self): - return iter(self.iterator) - - def close(self): - for func in self.close_callbacks: - func() - - -class ResourceManager(object): - ''' This class manages a list of search paths and helps to find and open - application-bound resources (files). - - :param base: default value for :meth:`add_path` calls. - :param opener: callable used to open resources. - :param cachemode: controls which lookups are cached. One of 'all', - 'found' or 'none'. - ''' - - def __init__(self, base='./', opener=open, cachemode='all'): - self.opener = open - self.base = base - self.cachemode = cachemode - - #: A list of search paths. See :meth:`add_path` for details. - self.path = [] - #: A cache for resolved paths. ``res.cache.clear()`` clears the cache. - self.cache = {} - - def add_path(self, path, base=None, index=None, create=False): - ''' Add a new path to the list of search paths. Return False if the - path does not exist. - - :param path: The new search path. Relative paths are turned into - an absolute and normalized form. If the path looks like a file - (not ending in `/`), the filename is stripped off. - :param base: Path used to absolutize relative search paths. - Defaults to :attr:`base` which defaults to ``os.getcwd()``. - :param index: Position within the list of search paths. Defaults - to last index (appends to the list). - - The `base` parameter makes it easy to reference files installed - along with a python module or package:: - - res.add_path('./resources/', __file__) - ''' - base = os.path.abspath(os.path.dirname(base or self.base)) - path = os.path.abspath(os.path.join(base, os.path.dirname(path))) - path += os.sep - if path in self.path: - self.path.remove(path) - if create and not os.path.isdir(path): - os.makedirs(path) - if index is None: - self.path.append(path) - else: - self.path.insert(index, path) - self.cache.clear() - return os.path.exists(path) - - def __iter__(self): - ''' Iterate over all existing files in all registered paths. ''' - search = self.path[:] - while search: - path = search.pop() - if not os.path.isdir(path): continue - for name in os.listdir(path): - full = os.path.join(path, name) - if os.path.isdir(full): search.append(full) - else: yield full - - def lookup(self, name): - ''' Search for a resource and return an absolute file path, or `None`. - - The :attr:`path` list is searched in order. The first match is - returend. Symlinks are followed. The result is cached to speed up - future lookups. ''' - if name not in self.cache or DEBUG: - for path in self.path: - fpath = os.path.join(path, name) - if os.path.isfile(fpath): - if self.cachemode in ('all', 'found'): - self.cache[name] = fpath - return fpath - if self.cachemode == 'all': - self.cache[name] = None - return self.cache[name] - - def open(self, name, mode='r', *args, **kwargs): - ''' Find a resource and return a file object, or raise IOError. ''' - fname = self.lookup(name) - if not fname: raise IOError("Resource %r not found." % name) - return self.opener(fname, mode=mode, *args, **kwargs) - - -class FileUpload(object): - - def __init__(self, fileobj, name, filename, headers=None): - ''' Wrapper for file uploads. ''' - #: Open file(-like) object (BytesIO buffer or temporary file) - self.file = fileobj - #: Name of the upload form field - self.name = name - #: Raw filename as sent by the client (may contain unsafe characters) - self.raw_filename = filename - #: A :class:`HeaderDict` with additional headers (e.g. content-type) - self.headers = HeaderDict(headers) if headers else HeaderDict() - - content_type = HeaderProperty('Content-Type') - content_length = HeaderProperty('Content-Length', reader=int, default=-1) - - def get_header(self, name, default=None): - """ Return the value of a header within the mulripart part. """ - return self.headers.get(name, default) - - @cached_property - def filename(self): - ''' Name of the file on the client file system, but normalized to ensure - file system compatibility. An empty filename is returned as 'empty'. - - Only ASCII letters, digits, dashes, underscores and dots are - allowed in the final filename. Accents are removed, if possible. - Whitespace is replaced by a single dash. Leading or tailing dots - or dashes are removed. The filename is limited to 255 characters. - ''' - fname = self.raw_filename - if not isinstance(fname, unicode): - fname = fname.decode('utf8', 'ignore') - fname = normalize('NFKD', fname).encode('ASCII', 'ignore').decode('ASCII') - fname = os.path.basename(fname.replace('\\', os.path.sep)) - fname = re.sub(r'[^a-zA-Z0-9-_.\s]', '', fname).strip() - fname = re.sub(r'[-\s]+', '-', fname).strip('.-') - return fname[:255] or 'empty' - - def _copy_file(self, fp, chunk_size=2**16): - read, write, offset = self.file.read, fp.write, self.file.tell() - while 1: - buf = read(chunk_size) - if not buf: break - write(buf) - self.file.seek(offset) - - def save(self, destination, overwrite=False, chunk_size=2**16): - ''' Save file to disk or copy its content to an open file(-like) object. - If *destination* is a directory, :attr:`filename` is added to the - path. Existing files are not overwritten by default (IOError). - - :param destination: File path, directory or file(-like) object. - :param overwrite: If True, replace existing files. (default: False) - :param chunk_size: Bytes to read at a time. (default: 64kb) - ''' - if isinstance(destination, basestring): # Except file-likes here - if os.path.isdir(destination): - destination = os.path.join(destination, self.filename) - if not overwrite and os.path.exists(destination): - raise IOError('File exists.') - with open(destination, 'wb') as fp: - self._copy_file(fp, chunk_size) - else: - self._copy_file(destination, chunk_size) - - - - - - -############################################################################### -# Application Helper ########################################################### -############################################################################### - - -def abort(code=500, text='Unknown Error.'): - """ Aborts execution and causes a HTTP error. """ - raise HTTPError(code, text) - - -def redirect(url, code=None): - """ Aborts execution and causes a 303 or 302 redirect, depending on - the HTTP protocol version. """ - if not code: - code = 303 if request.get('SERVER_PROTOCOL') == "HTTP/1.1" else 302 - res = response.copy(cls=HTTPResponse) - res.status = code - res.body = "" - res.set_header('Location', urljoin(request.url, url)) - raise res - - -def _file_iter_range(fp, offset, bytes, maxread=1024*1024): - ''' Yield chunks from a range in a file. No chunk is bigger than maxread.''' - fp.seek(offset) - while bytes > 0: - part = fp.read(min(bytes, maxread)) - if not part: break - bytes -= len(part) - yield part - - -def static_file(filename, root, mimetype='auto', download=False, charset='UTF-8'): - """ Open a file in a safe way and return :exc:`HTTPResponse` with status - code 200, 305, 403 or 404. The ``Content-Type``, ``Content-Encoding``, - ``Content-Length`` and ``Last-Modified`` headers are set if possible. - Special support for ``If-Modified-Since``, ``Range`` and ``HEAD`` - requests. - - :param filename: Name or path of the file to send. - :param root: Root path for file lookups. Should be an absolute directory - path. - :param mimetype: Defines the content-type header (default: guess from - file extension) - :param download: If True, ask the browser to open a `Save as...` dialog - instead of opening the file with the associated program. You can - specify a custom filename as a string. If not specified, the - original filename is used (default: False). - :param charset: The charset to use for files with a ``text/*`` - mime-type. (default: UTF-8) - """ - - root = os.path.abspath(root) + os.sep - filename = os.path.abspath(os.path.join(root, filename.strip('/\\'))) - headers = dict() - - if not filename.startswith(root): - return HTTPError(403, "Access denied.") - if not os.path.exists(filename) or not os.path.isfile(filename): - return HTTPError(404, "File does not exist.") - if not os.access(filename, os.R_OK): - return HTTPError(403, "You do not have permission to access this file.") - - if mimetype == 'auto': - mimetype, encoding = mimetypes.guess_type(filename) - if encoding: headers['Content-Encoding'] = encoding - - if mimetype: - if mimetype[:5] == 'text/' and charset and 'charset' not in mimetype: - mimetype += '; charset=%s' % charset - headers['Content-Type'] = mimetype - - if download: - download = os.path.basename(filename if download == True else download) - headers['Content-Disposition'] = 'attachment; filename="%s"' % download - - stats = os.stat(filename) - headers['Content-Length'] = clen = stats.st_size - lm = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(stats.st_mtime)) - headers['Last-Modified'] = lm - - ims = request.environ.get('HTTP_IF_MODIFIED_SINCE') - if ims: - ims = parse_date(ims.split(";")[0].strip()) - if ims is not None and ims >= int(stats.st_mtime): - headers['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()) - return HTTPResponse(status=304, **headers) - - body = '' if request.method == 'HEAD' else open(filename, 'rb') - - headers["Accept-Ranges"] = "bytes" - ranges = request.environ.get('HTTP_RANGE') - if 'HTTP_RANGE' in request.environ: - ranges = list(parse_range_header(request.environ['HTTP_RANGE'], clen)) - if not ranges: - return HTTPError(416, "Requested Range Not Satisfiable") - offset, end = ranges[0] - headers["Content-Range"] = "bytes %d-%d/%d" % (offset, end-1, clen) - headers["Content-Length"] = str(end-offset) - if body: body = _file_iter_range(body, offset, end-offset) - return HTTPResponse(body, status=206, **headers) - return HTTPResponse(body, **headers) - - - - - - -############################################################################### -# HTTP Utilities and MISC (TODO) ############################################### -############################################################################### - - -def debug(mode=True): - """ Change the debug level. - There is only one debug level supported at the moment.""" - global DEBUG - if mode: warnings.simplefilter('default') - DEBUG = bool(mode) - -def http_date(value): - if isinstance(value, (datedate, datetime)): - value = value.utctimetuple() - elif isinstance(value, (int, float)): - value = time.gmtime(value) - if not isinstance(value, basestring): - value = time.strftime("%a, %d %b %Y %H:%M:%S GMT", value) - return value - -def parse_date(ims): - """ Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch. """ - try: - ts = email.utils.parsedate_tz(ims) - return time.mktime(ts[:8] + (0,)) - (ts[9] or 0) - time.timezone - except (TypeError, ValueError, IndexError, OverflowError): - return None - -def parse_auth(header): - """ Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None""" - try: - method, data = header.split(None, 1) - if method.lower() == 'basic': - user, pwd = touni(base64.b64decode(tob(data))).split(':',1) - return user, pwd - except (KeyError, ValueError): - return None - -def parse_range_header(header, maxlen=0): - ''' Yield (start, end) ranges parsed from a HTTP Range header. Skip - unsatisfiable ranges. The end index is non-inclusive.''' - if not header or header[:6] != 'bytes=': return - ranges = [r.split('-', 1) for r in header[6:].split(',') if '-' in r] - for start, end in ranges: - try: - if not start: # bytes=-100 -> last 100 bytes - start, end = max(0, maxlen-int(end)), maxlen - elif not end: # bytes=100- -> all but the first 99 bytes - start, end = int(start), maxlen - else: # bytes=100-200 -> bytes 100-200 (inclusive) - start, end = int(start), min(int(end)+1, maxlen) - if 0 <= start < end <= maxlen: - yield start, end - except ValueError: - pass - -def _parse_qsl(qs): - r = [] - for pair in qs.split('&'): - if not pair: continue - nv = pair.split('=', 1) - if len(nv) != 2: nv.append('') - key = urlunquote(nv[0].replace('+', ' ')) - value = urlunquote(nv[1].replace('+', ' ')) - r.append((key, value)) - return r - -def _lscmp(a, b): - ''' Compares two strings in a cryptographically safe way: - Runtime is not affected by length of common prefix. ''' - return not sum(0 if x==y else 1 for x, y in zip(a, b)) and len(a) == len(b) - - -def cookie_encode(data, key): - ''' Encode and sign a pickle-able object. Return a (byte) string ''' - msg = base64.b64encode(pickle.dumps(data, -1)) - sig = base64.b64encode(hmac.new(tob(key), msg, digestmod=hashlib.md5).digest()) - return tob('!') + sig + tob('?') + msg - - -def cookie_decode(data, key): - ''' Verify and decode an encoded string. Return an object or None.''' - data = tob(data) - if cookie_is_encoded(data): - sig, msg = data.split(tob('?'), 1) - if _lscmp(sig[1:], base64.b64encode(hmac.new(tob(key), msg, digestmod=hashlib.md5).digest())): - return pickle.loads(base64.b64decode(msg)) - return None - - -def cookie_is_encoded(data): - ''' Return True if the argument looks like a encoded cookie.''' - return bool(data.startswith(tob('!')) and tob('?') in data) - - -def html_escape(string): - ''' Escape HTML special characters ``&<>`` and quotes ``'"``. ''' - return string.replace('&','&').replace('<','<').replace('>','>')\ - .replace('"','"').replace("'",''') - - -def html_quote(string): - ''' Escape and quote a string to be used as an HTTP attribute.''' - return '"%s"' % html_escape(string).replace('\n',' ')\ - .replace('\r',' ').replace('\t',' ') - - -def yieldroutes(func): - """ Return a generator for routes that match the signature (name, args) - of the func parameter. This may yield more than one route if the function - takes optional keyword arguments. The output is best described by example:: - - a() -> '/a' - b(x, y) -> '/b//' - c(x, y=5) -> '/c/' and '/c//' - d(x=5, y=6) -> '/d' and '/d/' and '/d//' - """ - path = '/' + func.__name__.replace('__','/').lstrip('/') - spec = getargspec(func) - argc = len(spec[0]) - len(spec[3] or []) - path += ('/<%s>' * argc) % tuple(spec[0][:argc]) - yield path - for arg in spec[0][argc:]: - path += '/<%s>' % arg - yield path - - -def path_shift(script_name, path_info, shift=1): - ''' Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa. - - :return: The modified paths. - :param script_name: The SCRIPT_NAME path. - :param script_name: The PATH_INFO path. - :param shift: The number of path fragments to shift. May be negative to - change the shift direction. (default: 1) - ''' - if shift == 0: return script_name, path_info - pathlist = path_info.strip('/').split('/') - scriptlist = script_name.strip('/').split('/') - if pathlist and pathlist[0] == '': pathlist = [] - if scriptlist and scriptlist[0] == '': scriptlist = [] - if shift > 0 and shift <= len(pathlist): - moved = pathlist[:shift] - scriptlist = scriptlist + moved - pathlist = pathlist[shift:] - elif shift < 0 and shift >= -len(scriptlist): - moved = scriptlist[shift:] - pathlist = moved + pathlist - scriptlist = scriptlist[:shift] - else: - empty = 'SCRIPT_NAME' if shift < 0 else 'PATH_INFO' - raise AssertionError("Cannot shift. Nothing left from %s" % empty) - new_script_name = '/' + '/'.join(scriptlist) - new_path_info = '/' + '/'.join(pathlist) - if path_info.endswith('/') and pathlist: new_path_info += '/' - return new_script_name, new_path_info - - -def auth_basic(check, realm="private", text="Access denied"): - ''' Callback decorator to require HTTP auth (basic). - TODO: Add route(check_auth=...) parameter. ''' - def decorator(func): - @functools.wraps(func) - def wrapper(*a, **ka): - user, password = request.auth or (None, None) - if user is None or not check(user, password): - err = HTTPError(401, text) - err.add_header('WWW-Authenticate', 'Basic realm="%s"' % realm) - return err - return func(*a, **ka) - return wrapper - return decorator - - -# Shortcuts for common Bottle methods. -# They all refer to the current default application. - -def make_default_app_wrapper(name): - ''' Return a callable that relays calls to the current default app. ''' - @functools.wraps(getattr(Bottle, name)) - def wrapper(*a, **ka): - return getattr(app(), name)(*a, **ka) - return wrapper - -route = make_default_app_wrapper('route') -get = make_default_app_wrapper('get') -post = make_default_app_wrapper('post') -put = make_default_app_wrapper('put') -delete = make_default_app_wrapper('delete') -error = make_default_app_wrapper('error') -mount = make_default_app_wrapper('mount') -hook = make_default_app_wrapper('hook') -install = make_default_app_wrapper('install') -uninstall = make_default_app_wrapper('uninstall') -url = make_default_app_wrapper('get_url') - - - - - - - -############################################################################### -# Server Adapter ############################################################### -############################################################################### - - -class ServerAdapter(object): - quiet = False - def __init__(self, host='127.0.0.1', port=8080, **options): - self.options = options - self.host = host - self.port = int(port) - - def run(self, handler): # pragma: no cover - pass - - def __repr__(self): - args = ', '.join(['%s=%s'%(k,repr(v)) for k, v in self.options.items()]) - return "%s(%s)" % (self.__class__.__name__, args) - - -class CGIServer(ServerAdapter): - quiet = True - def run(self, handler): # pragma: no cover - from wsgiref.handlers import CGIHandler - def fixed_environ(environ, start_response): - environ.setdefault('PATH_INFO', '') - return handler(environ, start_response) - CGIHandler().run(fixed_environ) - - -class FlupFCGIServer(ServerAdapter): - def run(self, handler): # pragma: no cover - import flup.server.fcgi - self.options.setdefault('bindAddress', (self.host, self.port)) - flup.server.fcgi.WSGIServer(handler, **self.options).run() - - -class WSGIRefServer(ServerAdapter): - def run(self, app): # pragma: no cover - from wsgiref.simple_server import WSGIRequestHandler, WSGIServer - from wsgiref.simple_server import make_server - import socket - - class FixedHandler(WSGIRequestHandler): - def address_string(self): # Prevent reverse DNS lookups please. - return self.client_address[0] - def log_request(*args, **kw): - if not self.quiet: - return WSGIRequestHandler.log_request(*args, **kw) - - handler_cls = self.options.get('handler_class', FixedHandler) - server_cls = self.options.get('server_class', WSGIServer) - - if ':' in self.host: # Fix wsgiref for IPv6 addresses. - if getattr(server_cls, 'address_family') == socket.AF_INET: - class server_cls(server_cls): - address_family = socket.AF_INET6 - - srv = make_server(self.host, self.port, app, server_cls, handler_cls) - srv.serve_forever() - - -class CherryPyServer(ServerAdapter): - def run(self, handler): # pragma: no cover - depr("The wsgi server part of cherrypy was split into a new " - "project called 'cheroot'. Use the 'cheroot' server " - "adapter instead of cherrypy.") - from cherrypy import wsgiserver # This will fail for CherryPy >= 9 - - self.options['bind_addr'] = (self.host, self.port) - self.options['wsgi_app'] = handler - - certfile = self.options.get('certfile') - if certfile: - del self.options['certfile'] - keyfile = self.options.get('keyfile') - if keyfile: - del self.options['keyfile'] - - server = wsgiserver.CherryPyWSGIServer(**self.options) - if certfile: - server.ssl_certificate = certfile - if keyfile: - server.ssl_private_key = keyfile - - try: - server.start() - finally: - server.stop() - - -class CherootServer(ServerAdapter): - def run(self, handler): # pragma: no cover - from cheroot import wsgi - from cheroot.ssl import builtin - self.options['bind_addr'] = (self.host, self.port) - self.options['wsgi_app'] = handler - certfile = self.options.pop('certfile', None) - keyfile = self.options.pop('keyfile', None) - chainfile = self.options.pop('chainfile', None) - server = wsgi.Server(**self.options) - if certfile and keyfile: - server.ssl_adapter = builtin.BuiltinSSLAdapter( - certfile, keyfile, chainfile) - try: - server.start() - finally: - server.stop() - - -class WaitressServer(ServerAdapter): - def run(self, handler): - from waitress import serve - serve(handler, host=self.host, port=self.port) - - -class PasteServer(ServerAdapter): - def run(self, handler): # pragma: no cover - from paste import httpserver - from paste.translogger import TransLogger - handler = TransLogger(handler, setup_console_handler=(not self.quiet)) - httpserver.serve(handler, host=self.host, port=str(self.port), - **self.options) - - -class MeinheldServer(ServerAdapter): - def run(self, handler): - from meinheld import server - server.listen((self.host, self.port)) - server.run(handler) - - -class FapwsServer(ServerAdapter): - """ Extremely fast webserver using libev. See http://www.fapws.org/ """ - def run(self, handler): # pragma: no cover - import fapws._evwsgi as evwsgi - from fapws import base, config - port = self.port - if float(config.SERVER_IDENT[-2:]) > 0.4: - # fapws3 silently changed its API in 0.5 - port = str(port) - evwsgi.start(self.host, port) - # fapws3 never releases the GIL. Complain upstream. I tried. No luck. - if 'BOTTLE_CHILD' in os.environ and not self.quiet: - _stderr("WARNING: Auto-reloading does not work with Fapws3.\n") - _stderr(" (Fapws3 breaks python thread support)\n") - evwsgi.set_base_module(base) - def app(environ, start_response): - environ['wsgi.multiprocess'] = False - return handler(environ, start_response) - evwsgi.wsgi_cb(('', app)) - evwsgi.run() - - -class TornadoServer(ServerAdapter): - """ The super hyped asynchronous server by facebook. Untested. """ - def run(self, handler): # pragma: no cover - import tornado.wsgi, tornado.httpserver, tornado.ioloop - container = tornado.wsgi.WSGIContainer(handler) - server = tornado.httpserver.HTTPServer(container) - server.listen(port=self.port,address=self.host) - tornado.ioloop.IOLoop.instance().start() - - -class AppEngineServer(ServerAdapter): - """ Adapter for Google App Engine. """ - quiet = True - def run(self, handler): - from google.appengine.ext.webapp import util - # A main() function in the handler script enables 'App Caching'. - # Lets makes sure it is there. This _really_ improves performance. - module = sys.modules.get('__main__') - if module and not hasattr(module, 'main'): - module.main = lambda: util.run_wsgi_app(handler) - util.run_wsgi_app(handler) - - -class TwistedServer(ServerAdapter): - """ Untested. """ - def run(self, handler): - from twisted.web import server, wsgi - from twisted.python.threadpool import ThreadPool - from twisted.internet import reactor - thread_pool = ThreadPool() - thread_pool.start() - reactor.addSystemEventTrigger('after', 'shutdown', thread_pool.stop) - factory = server.Site(wsgi.WSGIResource(reactor, thread_pool, handler)) - reactor.listenTCP(self.port, factory, interface=self.host) - reactor.run() - - -class DieselServer(ServerAdapter): - """ Untested. """ - def run(self, handler): - from diesel.protocols.wsgi import WSGIApplication - app = WSGIApplication(handler, port=self.port) - app.run() - - -class GeventServer(ServerAdapter): - """ Untested. Options: - - * `fast` (default: False) uses libevent's http server, but has some - issues: No streaming, no pipelining, no SSL. - * See gevent.wsgi.WSGIServer() documentation for more options. - """ - def run(self, handler): - from gevent import pywsgi, local - if not isinstance(threading.local(), local.local): - msg = "Bottle requires gevent.monkey.patch_all() (before import)" - raise RuntimeError(msg) - if self.options.pop('fast', None): - depr('The "fast" option has been deprecated and removed by Gevent.') - if self.quiet: - self.options['log'] = None - address = (self.host, self.port) - server = pywsgi.WSGIServer(address, handler, **self.options) - if 'BOTTLE_CHILD' in os.environ: - import signal - signal.signal(signal.SIGINT, lambda s, f: server.stop()) - server.serve_forever() - - -class GeventSocketIOServer(ServerAdapter): - def run(self,handler): - from socketio import server - address = (self.host, self.port) - server.SocketIOServer(address, handler, **self.options).serve_forever() - - -class GunicornServer(ServerAdapter): - """ Untested. See http://gunicorn.org/configure.html for options. """ - def run(self, handler): - from gunicorn.app.base import Application - - config = {'bind': "%s:%d" % (self.host, int(self.port))} - config.update(self.options) - - class GunicornApplication(Application): - def init(self, parser, opts, args): - return config - - def load(self): - return handler - - GunicornApplication().run() - - -class EventletServer(ServerAdapter): - """ Untested """ - def run(self, handler): - from eventlet import wsgi, listen - try: - wsgi.server(listen((self.host, self.port)), handler, - log_output=(not self.quiet)) - except TypeError: - # Fallback, if we have old version of eventlet - wsgi.server(listen((self.host, self.port)), handler) - - -class RocketServer(ServerAdapter): - """ Untested. """ - def run(self, handler): - from rocket import Rocket - server = Rocket((self.host, self.port), 'wsgi', { 'wsgi_app' : handler }) - server.start() - - -class BjoernServer(ServerAdapter): - """ Fast server written in C: https://github.com/jonashaag/bjoern """ - def run(self, handler): - from bjoern import run - run(handler, self.host, self.port) - - -class AutoServer(ServerAdapter): - """ Untested. """ - adapters = [WaitressServer, PasteServer, TwistedServer, CherryPyServer, - CherootServer, WSGIRefServer] - - def run(self, handler): - for sa in self.adapters: - try: - return sa(self.host, self.port, **self.options).run(handler) - except ImportError: - pass - -server_names = { - 'cgi': CGIServer, - 'flup': FlupFCGIServer, - 'wsgiref': WSGIRefServer, - 'waitress': WaitressServer, - 'cherrypy': CherryPyServer, - 'cheroot': CherootServer, - 'paste': PasteServer, - 'fapws3': FapwsServer, - 'tornado': TornadoServer, - 'gae': AppEngineServer, - 'twisted': TwistedServer, - 'diesel': DieselServer, - 'meinheld': MeinheldServer, - 'gunicorn': GunicornServer, - 'eventlet': EventletServer, - 'gevent': GeventServer, - 'geventSocketIO':GeventSocketIOServer, - 'rocket': RocketServer, - 'bjoern' : BjoernServer, - 'auto': AutoServer, -} - - - - - - -############################################################################### -# Application Control ########################################################## -############################################################################### - - -def load(target, **namespace): - """ Import a module or fetch an object from a module. - - * ``package.module`` returns `module` as a module object. - * ``pack.mod:name`` returns the module variable `name` from `pack.mod`. - * ``pack.mod:func()`` calls `pack.mod.func()` and returns the result. - - The last form accepts not only function calls, but any type of - expression. Keyword arguments passed to this function are available as - local variables. Example: ``import_string('re:compile(x)', x='[a-z]')`` - """ - module, target = target.split(":", 1) if ':' in target else (target, None) - if module not in sys.modules: __import__(module) - if not target: return sys.modules[module] - if target.isalnum(): return getattr(sys.modules[module], target) - package_name = module.split('.')[0] - namespace[package_name] = sys.modules[package_name] - return eval('%s.%s' % (module, target), namespace) - - -def load_app(target): - """ Load a bottle application from a module and make sure that the import - does not affect the current default application, but returns a separate - application object. See :func:`load` for the target parameter. """ - global NORUN; NORUN, nr_old = True, NORUN - try: - tmp = default_app.push() # Create a new "default application" - rv = load(target) # Import the target module - return rv if callable(rv) else tmp - finally: - default_app.remove(tmp) # Remove the temporary added default application - NORUN = nr_old - -_debug = debug -def run(app=None, server='wsgiref', host='127.0.0.1', port=8080, - interval=1, reloader=False, quiet=False, plugins=None, - debug=None, **kargs): - """ Start a server instance. This method blocks until the server terminates. - - :param app: WSGI application or target string supported by - :func:`load_app`. (default: :func:`default_app`) - :param server: Server adapter to use. See :data:`server_names` keys - for valid names or pass a :class:`ServerAdapter` subclass. - (default: `wsgiref`) - :param host: Server address to bind to. Pass ``0.0.0.0`` to listens on - all interfaces including the external one. (default: 127.0.0.1) - :param port: Server port to bind to. Values below 1024 require root - privileges. (default: 8080) - :param reloader: Start auto-reloading server? (default: False) - :param interval: Auto-reloader interval in seconds (default: 1) - :param quiet: Suppress output to stdout and stderr? (default: False) - :param options: Options passed to the server adapter. - """ - if NORUN: return - if reloader and not os.environ.get('BOTTLE_CHILD'): - try: - lockfile = None - fd, lockfile = tempfile.mkstemp(prefix='bottle.', suffix='.lock') - os.close(fd) # We only need this file to exist. We never write to it - while os.path.exists(lockfile): - args = [sys.executable] + sys.argv - environ = os.environ.copy() - environ['BOTTLE_CHILD'] = 'true' - environ['BOTTLE_LOCKFILE'] = lockfile - p = subprocess.Popen(args, env=environ) - while p.poll() is None: # Busy wait... - os.utime(lockfile, None) # I am alive! - time.sleep(interval) - if p.poll() != 3: - if os.path.exists(lockfile): os.unlink(lockfile) - sys.exit(p.poll()) - except KeyboardInterrupt: - pass - finally: - if os.path.exists(lockfile): - os.unlink(lockfile) - return - - try: - if debug is not None: _debug(debug) - app = app or default_app() - if isinstance(app, basestring): - app = load_app(app) - if not callable(app): - raise ValueError("Application is not callable: %r" % app) - - for plugin in plugins or []: - app.install(plugin) - - if server in server_names: - server = server_names.get(server) - if isinstance(server, basestring): - server = load(server) - if isinstance(server, type): - server = server(host=host, port=port, **kargs) - if not isinstance(server, ServerAdapter): - raise ValueError("Unknown or unsupported server: %r" % server) - - server.quiet = server.quiet or quiet - if not server.quiet: - _stderr("Bottle v%s server starting up (using %s)...\n" % (__version__, repr(server))) - _stderr("Listening on http://%s:%d/\n" % (server.host, server.port)) - _stderr("Hit Ctrl-C to quit.\n\n") - - if reloader: - lockfile = os.environ.get('BOTTLE_LOCKFILE') - bgcheck = FileCheckerThread(lockfile, interval) - with bgcheck: - server.run(app) - if bgcheck.status == 'reload': - sys.exit(3) - else: - server.run(app) - except KeyboardInterrupt: - pass - except (SystemExit, MemoryError): - raise - except: - if not reloader: raise - if not getattr(server, 'quiet', quiet): - print_exc() - time.sleep(interval) - sys.exit(3) - - - -class FileCheckerThread(threading.Thread): - ''' Interrupt main-thread as soon as a changed module file is detected, - the lockfile gets deleted or gets to old. ''' - - def __init__(self, lockfile, interval): - threading.Thread.__init__(self) - self.lockfile, self.interval = lockfile, interval - #: Is one of 'reload', 'error' or 'exit' - self.status = None - - def run(self): - exists = os.path.exists - mtime = lambda path: os.stat(path).st_mtime - files = dict() - - for module in list(sys.modules.values()): - path = getattr(module, '__file__', '') or '' - if path[-4:] in ('.pyo', '.pyc'): path = path[:-1] - if path and exists(path): files[path] = mtime(path) - - while not self.status: - if not exists(self.lockfile)\ - or mtime(self.lockfile) < time.time() - self.interval - 5: - self.status = 'error' - thread.interrupt_main() - for path, lmtime in list(files.items()): - if not exists(path) or mtime(path) > lmtime: - self.status = 'reload' - thread.interrupt_main() - break - time.sleep(self.interval) - - def __enter__(self): - self.start() - - def __exit__(self, exc_type, exc_val, exc_tb): - if not self.status: self.status = 'exit' # silent exit - self.join() - return exc_type is not None and issubclass(exc_type, KeyboardInterrupt) - - - - - -############################################################################### -# Template Adapters ############################################################ -############################################################################### - - -class TemplateError(HTTPError): - def __init__(self, message): - HTTPError.__init__(self, 500, message) - - -class BaseTemplate(object): - """ Base class and minimal API for template adapters """ - extensions = ['tpl','html','thtml','stpl'] - settings = {} #used in prepare() - defaults = {} #used in render() - - def __init__(self, source=None, name=None, lookup=[], encoding='utf8', **settings): - """ Create a new template. - If the source parameter (str or buffer) is missing, the name argument - is used to guess a template filename. Subclasses can assume that - self.source and/or self.filename are set. Both are strings. - The lookup, encoding and settings parameters are stored as instance - variables. - The lookup parameter stores a list containing directory paths. - The encoding parameter should be used to decode byte strings or files. - The settings parameter contains a dict for engine-specific settings. - """ - self.name = name - self.source = source.read() if hasattr(source, 'read') else source - self.filename = source.filename if hasattr(source, 'filename') else None - self.lookup = [os.path.abspath(x) for x in lookup] - self.encoding = encoding - self.settings = self.settings.copy() # Copy from class variable - self.settings.update(settings) # Apply - if not self.source and self.name: - self.filename = self.search(self.name, self.lookup) - if not self.filename: - raise TemplateError('Template %s not found.' % repr(name)) - if not self.source and not self.filename: - raise TemplateError('No template specified.') - self.prepare(**self.settings) - - @classmethod - def search(cls, name, lookup=[]): - """ Search name in all directories specified in lookup. - First without, then with common extensions. Return first hit. """ - if not lookup: - depr('The template lookup path list should not be empty.') #0.12 - lookup = ['.'] - - if os.path.isabs(name) and os.path.isfile(name): - depr('Absolute template path names are deprecated.') #0.12 - return os.path.abspath(name) - - for spath in lookup: - spath = os.path.abspath(spath) + os.sep - fname = os.path.abspath(os.path.join(spath, name)) - if not fname.startswith(spath): continue - if os.path.isfile(fname): return fname - for ext in cls.extensions: - if os.path.isfile('%s.%s' % (fname, ext)): - return '%s.%s' % (fname, ext) - - @classmethod - def global_config(cls, key, *args): - ''' This reads or sets the global settings stored in class.settings. ''' - if args: - cls.settings = cls.settings.copy() # Make settings local to class - cls.settings[key] = args[0] - else: - return cls.settings[key] - - def prepare(self, **options): - """ Run preparations (parsing, caching, ...). - It should be possible to call this again to refresh a template or to - update settings. - """ - raise NotImplementedError - - def render(self, *args, **kwargs): - """ Render the template with the specified local variables and return - a single byte or unicode string. If it is a byte string, the encoding - must match self.encoding. This method must be thread-safe! - Local variables may be provided in dictionaries (args) - or directly, as keywords (kwargs). - """ - raise NotImplementedError - - -class MakoTemplate(BaseTemplate): - def prepare(self, **options): - from mako.template import Template - from mako.lookup import TemplateLookup - options.update({'input_encoding':self.encoding}) - options.setdefault('format_exceptions', bool(DEBUG)) - lookup = TemplateLookup(directories=self.lookup, **options) - if self.source: - self.tpl = Template(self.source, lookup=lookup, **options) - else: - self.tpl = Template(uri=self.name, filename=self.filename, lookup=lookup, **options) - - def render(self, *args, **kwargs): - for dictarg in args: kwargs.update(dictarg) - _defaults = self.defaults.copy() - _defaults.update(kwargs) - return self.tpl.render(**_defaults) - - -class CheetahTemplate(BaseTemplate): - def prepare(self, **options): - from Cheetah.Template import Template - self.context = threading.local() - self.context.vars = {} - options['searchList'] = [self.context.vars] - if self.source: - self.tpl = Template(source=self.source, **options) - else: - self.tpl = Template(file=self.filename, **options) - - def render(self, *args, **kwargs): - for dictarg in args: kwargs.update(dictarg) - self.context.vars.update(self.defaults) - self.context.vars.update(kwargs) - out = str(self.tpl) - self.context.vars.clear() - return out - - -class Jinja2Template(BaseTemplate): - def prepare(self, filters=None, tests=None, globals={}, **kwargs): - from jinja2 import Environment, FunctionLoader - if 'prefix' in kwargs: # TODO: to be removed after a while - raise RuntimeError('The keyword argument `prefix` has been removed. ' - 'Use the full jinja2 environment name line_statement_prefix instead.') - self.env = Environment(loader=FunctionLoader(self.loader), **kwargs) - if filters: self.env.filters.update(filters) - if tests: self.env.tests.update(tests) - if globals: self.env.globals.update(globals) - if self.source: - self.tpl = self.env.from_string(self.source) - else: - self.tpl = self.env.get_template(self.filename) - - def render(self, *args, **kwargs): - for dictarg in args: kwargs.update(dictarg) - _defaults = self.defaults.copy() - _defaults.update(kwargs) - return self.tpl.render(**_defaults) - - def loader(self, name): - fname = self.search(name, self.lookup) - if not fname: return - with open(fname, "rb") as f: - return f.read().decode(self.encoding) - - -class SimpleTemplate(BaseTemplate): - - def prepare(self, escape_func=html_escape, noescape=False, syntax=None, **ka): - self.cache = {} - enc = self.encoding - self._str = lambda x: touni(x, enc) - self._escape = lambda x: escape_func(touni(x, enc)) - self.syntax = syntax - if noescape: - self._str, self._escape = self._escape, self._str - - @cached_property - def co(self): - return compile(self.code, self.filename or '', 'exec') - - @cached_property - def code(self): - source = self.source - if not source: - with open(self.filename, 'rb') as f: - source = f.read() - try: - source, encoding = touni(source), 'utf8' - except UnicodeError: - depr('Template encodings other than utf8 are no longer supported.') #0.11 - source, encoding = touni(source, 'latin1'), 'latin1' - parser = StplParser(source, encoding=encoding, syntax=self.syntax) - code = parser.translate() - self.encoding = parser.encoding - return code - - def _rebase(self, _env, _name=None, **kwargs): - if _name is None: - depr('Rebase function called without arguments.' - ' You were probably looking for {{base}}?', True) #0.12 - _env['_rebase'] = (_name, kwargs) - - def _include(self, _env, _name=None, **kwargs): - if _name is None: - depr('Rebase function called without arguments.' - ' You were probably looking for {{base}}?', True) #0.12 - env = _env.copy() - env.update(kwargs) - if _name not in self.cache: - self.cache[_name] = self.__class__(name=_name, lookup=self.lookup) - return self.cache[_name].execute(env['_stdout'], env) - - def execute(self, _stdout, kwargs): - env = self.defaults.copy() - env.update(kwargs) - env.update({'_stdout': _stdout, '_printlist': _stdout.extend, - 'include': functools.partial(self._include, env), - 'rebase': functools.partial(self._rebase, env), '_rebase': None, - '_str': self._str, '_escape': self._escape, 'get': env.get, - 'setdefault': env.setdefault, 'defined': env.__contains__ }) - eval(self.co, env) - if env.get('_rebase'): - subtpl, rargs = env.pop('_rebase') - rargs['base'] = ''.join(_stdout) #copy stdout - del _stdout[:] # clear stdout - return self._include(env, subtpl, **rargs) - return env - - def render(self, *args, **kwargs): - """ Render the template using keyword arguments as local variables. """ - env = {}; stdout = [] - for dictarg in args: env.update(dictarg) - env.update(kwargs) - self.execute(stdout, env) - return ''.join(stdout) - - -class StplSyntaxError(TemplateError): pass - - -class StplParser(object): - ''' Parser for stpl templates. ''' - _re_cache = {} #: Cache for compiled re patterns - # This huge pile of voodoo magic splits python code into 8 different tokens. - # 1: All kinds of python strings (trust me, it works) - _re_tok = '([urbURB]?(?:\'\'(?!\')|""(?!")|\'{6}|"{6}' \ - '|\'(?:[^\\\\\']|\\\\.)+?\'|"(?:[^\\\\"]|\\\\.)+?"' \ - '|\'{3}(?:[^\\\\]|\\\\.|\\n)+?\'{3}' \ - '|"{3}(?:[^\\\\]|\\\\.|\\n)+?"{3}))' - _re_inl = _re_tok.replace('|\\n','') # We re-use this string pattern later - # 2: Comments (until end of line, but not the newline itself) - _re_tok += '|(#.*)' - # 3,4: Open and close grouping tokens - _re_tok += '|([\\[\\{\\(])' - _re_tok += '|([\\]\\}\\)])' - # 5,6: Keywords that start or continue a python block (only start of line) - _re_tok += '|^([ \\t]*(?:if|for|while|with|try|def|class)\\b)' \ - '|^([ \\t]*(?:elif|else|except|finally)\\b)' - # 7: Our special 'end' keyword (but only if it stands alone) - _re_tok += '|((?:^|;)[ \\t]*end[ \\t]*(?=(?:%(block_close)s[ \\t]*)?\\r?$|;|#))' - # 8: A customizable end-of-code-block template token (only end of line) - _re_tok += '|(%(block_close)s[ \\t]*(?=\\r?$))' - # 9: And finally, a single newline. The 10th token is 'everything else' - _re_tok += '|(\\r?\\n)' - - # Match the start tokens of code areas in a template - _re_split = '(?m)^[ \t]*(\\\\?)((%(line_start)s)|(%(block_start)s))(%%?)' - # Match inline statements (may contain python strings) - _re_inl = '(?m)%%(inline_start)s((?:%s|[^\'"\n]*?)+)%%(inline_end)s' % _re_inl - _re_tok = '(?m)' + _re_tok - - default_syntax = '<% %> % {{ }}' - - def __init__(self, source, syntax=None, encoding='utf8'): - self.source, self.encoding = touni(source, encoding), encoding - self.set_syntax(syntax or self.default_syntax) - self.code_buffer, self.text_buffer = [], [] - self.lineno, self.offset = 1, 0 - self.indent, self.indent_mod = 0, 0 - self.paren_depth = 0 - - def get_syntax(self): - ''' Tokens as a space separated string (default: <% %> % {{ }}) ''' - return self._syntax - - def set_syntax(self, syntax): - self._syntax = syntax - self._tokens = syntax.split() - if not syntax in self._re_cache: - names = 'block_start block_close line_start inline_start inline_end' - etokens = map(re.escape, self._tokens) - pattern_vars = dict(zip(names.split(), etokens)) - patterns = (self._re_split, self._re_tok, self._re_inl) - patterns = [re.compile(p%pattern_vars) for p in patterns] - self._re_cache[syntax] = patterns - self.re_split, self.re_tok, self.re_inl = self._re_cache[syntax] - - syntax = property(get_syntax, set_syntax) - - def translate(self): - if self.offset: raise RuntimeError('Parser is a one time instance.') - while True: - m = self.re_split.search(self.source[self.offset:]) - if m: - text = self.source[self.offset:self.offset+m.start()] - self.text_buffer.append(text) - self.offset += m.end() - if m.group(1): # New escape syntax - line, sep, _ = self.source[self.offset:].partition('\n') - self.text_buffer.append(m.group(2)+m.group(5)+line+sep) - self.offset += len(line+sep)+1 - continue - elif m.group(5): # Old escape syntax - depr('Escape code lines with a backslash.') #0.12 - line, sep, _ = self.source[self.offset:].partition('\n') - self.text_buffer.append(m.group(2)+line+sep) - self.offset += len(line+sep)+1 - continue - self.flush_text() - self.read_code(multiline=bool(m.group(4))) - else: break - self.text_buffer.append(self.source[self.offset:]) - self.flush_text() - return ''.join(self.code_buffer) - - def read_code(self, multiline): - code_line, comment = '', '' - while True: - m = self.re_tok.search(self.source[self.offset:]) - if not m: - code_line += self.source[self.offset:] - self.offset = len(self.source) - self.write_code(code_line.strip(), comment) - return - code_line += self.source[self.offset:self.offset+m.start()] - self.offset += m.end() - _str, _com, _po, _pc, _blk1, _blk2, _end, _cend, _nl = m.groups() - if (code_line or self.paren_depth > 0) and (_blk1 or _blk2): # a if b else c - code_line += _blk1 or _blk2 - continue - if _str: # Python string - code_line += _str - elif _com: # Python comment (up to EOL) - comment = _com - if multiline and _com.strip().endswith(self._tokens[1]): - multiline = False # Allow end-of-block in comments - elif _po: # open parenthesis - self.paren_depth += 1 - code_line += _po - elif _pc: # close parenthesis - if self.paren_depth > 0: - # we could check for matching parentheses here, but it's - # easier to leave that to python - just check counts - self.paren_depth -= 1 - code_line += _pc - elif _blk1: # Start-block keyword (if/for/while/def/try/...) - code_line, self.indent_mod = _blk1, -1 - self.indent += 1 - elif _blk2: # Continue-block keyword (else/elif/except/...) - code_line, self.indent_mod = _blk2, -1 - elif _end: # The non-standard 'end'-keyword (ends a block) - self.indent -= 1 - elif _cend: # The end-code-block template token (usually '%>') - if multiline: multiline = False - else: code_line += _cend - else: # \n - self.write_code(code_line.strip(), comment) - self.lineno += 1 - code_line, comment, self.indent_mod = '', '', 0 - if not multiline: - break - - def flush_text(self): - text = ''.join(self.text_buffer) - del self.text_buffer[:] - if not text: return - parts, pos, nl = [], 0, '\\\n'+' '*self.indent - for m in self.re_inl.finditer(text): - prefix, pos = text[pos:m.start()], m.end() - if prefix: - parts.append(nl.join(map(repr, prefix.splitlines(True)))) - if prefix.endswith('\n'): parts[-1] += nl - parts.append(self.process_inline(m.group(1).strip())) - if pos < len(text): - prefix = text[pos:] - lines = prefix.splitlines(True) - if lines[-1].endswith('\\\\\n'): lines[-1] = lines[-1][:-3] - elif lines[-1].endswith('\\\\\r\n'): lines[-1] = lines[-1][:-4] - parts.append(nl.join(map(repr, lines))) - code = '_printlist((%s,))' % ', '.join(parts) - self.lineno += code.count('\n')+1 - self.write_code(code) - - def process_inline(self, chunk): - if chunk[0] == '!': return '_str(%s)' % chunk[1:] - return '_escape(%s)' % chunk - - def write_code(self, line, comment=''): - line, comment = self.fix_backward_compatibility(line, comment) - code = ' ' * (self.indent+self.indent_mod) - code += line.lstrip() + comment + '\n' - self.code_buffer.append(code) - - def fix_backward_compatibility(self, line, comment): - parts = line.strip().split(None, 2) - if parts and parts[0] in ('include', 'rebase'): - depr('The include and rebase keywords are functions now.') #0.12 - if len(parts) == 1: return "_printlist([base])", comment - elif len(parts) == 2: return "_=%s(%r)" % tuple(parts), comment - else: return "_=%s(%r, %s)" % tuple(parts), comment - if self.lineno <= 2 and not line.strip() and 'coding' in comment: - m = re.match(r"#.*coding[:=]\s*([-\w.]+)", comment) - if m: - depr('PEP263 encoding strings in templates are deprecated.') #0.12 - enc = m.group(1) - self.source = self.source.encode(self.encoding).decode(enc) - self.encoding = enc - return line, comment.replace('coding','coding*') - return line, comment - - -def template(*args, **kwargs): - ''' - Get a rendered template as a string iterator. - You can use a name, a filename or a template string as first parameter. - Template rendering arguments can be passed as dictionaries - or directly (as keyword arguments). - ''' - tpl = args[0] if args else None - adapter = kwargs.pop('template_adapter', SimpleTemplate) - lookup = kwargs.pop('template_lookup', TEMPLATE_PATH) - tplid = (id(lookup), tpl) - if tplid not in TEMPLATES or DEBUG: - settings = kwargs.pop('template_settings', {}) - if isinstance(tpl, adapter): - TEMPLATES[tplid] = tpl - if settings: TEMPLATES[tplid].prepare(**settings) - elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl: - TEMPLATES[tplid] = adapter(source=tpl, lookup=lookup, **settings) - else: - TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings) - if not TEMPLATES[tplid]: - abort(500, 'Template (%s) not found' % tpl) - for dictarg in args[1:]: kwargs.update(dictarg) - return TEMPLATES[tplid].render(kwargs) - -mako_template = functools.partial(template, template_adapter=MakoTemplate) -cheetah_template = functools.partial(template, template_adapter=CheetahTemplate) -jinja2_template = functools.partial(template, template_adapter=Jinja2Template) - - -def view(tpl_name, **defaults): - ''' Decorator: renders a template for a handler. - The handler can control its behavior like that: - - - return a dict of template vars to fill out the template - - return something other than a dict and the view decorator will not - process the template, but return the handler result as is. - This includes returning a HTTPResponse(dict) to get, - for instance, JSON with autojson or other castfilters. - ''' - def decorator(func): - @functools.wraps(func) - def wrapper(*args, **kwargs): - result = func(*args, **kwargs) - if isinstance(result, (dict, DictMixin)): - tplvars = defaults.copy() - tplvars.update(result) - return template(tpl_name, **tplvars) - elif result is None: - return template(tpl_name, **defaults) - return result - return wrapper - return decorator - -mako_view = functools.partial(view, template_adapter=MakoTemplate) -cheetah_view = functools.partial(view, template_adapter=CheetahTemplate) -jinja2_view = functools.partial(view, template_adapter=Jinja2Template) - - - - - - -############################################################################### -# Constants and Globals ######################################################## -############################################################################### - - -TEMPLATE_PATH = ['./', './views/'] -TEMPLATES = {} -DEBUG = False -NORUN = False # If set, run() does nothing. Used by load_app() - -#: A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found') -HTTP_CODES = httplib.responses -HTTP_CODES[418] = "I'm a teapot" # RFC 2324 -HTTP_CODES[422] = "Unprocessable Entity" # RFC 4918 -HTTP_CODES[428] = "Precondition Required" -HTTP_CODES[429] = "Too Many Requests" -HTTP_CODES[431] = "Request Header Fields Too Large" -HTTP_CODES[511] = "Network Authentication Required" -_HTTP_STATUS_LINES = dict((k, '%d %s'%(k,v)) for (k,v) in HTTP_CODES.items()) - -#: The default template used for error pages. Override with @error() -ERROR_PAGE_TEMPLATE = """ -%%try: - %%from %s import DEBUG, HTTP_CODES, request, touni - - - - Error: {{e.status}} - - - -

    Error: {{e.status}}

    -

    Sorry, the requested URL {{repr(request.url)}} - caused an error:

    -
    {{e.body}}
    - %%if DEBUG and e.exception: -

    Exception:

    -
    {{repr(e.exception)}}
    - %%end - %%if DEBUG and e.traceback: -

    Traceback:

    -
    {{e.traceback}}
    - %%end - - -%%except ImportError: - ImportError: Could not generate the error page. Please add bottle to - the import path. -%%end -""" % __name__ - -#: A thread-safe instance of :class:`LocalRequest`. If accessed from within a -#: request callback, this instance always refers to the *current* request -#: (even on a multithreaded server). -request = LocalRequest() - -#: A thread-safe instance of :class:`LocalResponse`. It is used to change the -#: HTTP response for the *current* request. -response = LocalResponse() - -#: A thread-safe namespace. Not used by Bottle. -local = threading.local() - -# Initialize app stack (create first empty Bottle app) -# BC: 0.6.4 and needed for run() -app = default_app = AppStack() -app.push() - -#: A virtual package that redirects import statements. -#: Example: ``import bottle.ext.sqlite`` actually imports `bottle_sqlite`. -ext = _ImportRedirect('bottle.ext' if __name__ == '__main__' else __name__+".ext", 'bottle_%s').module - -if __name__ == '__main__': - opt, args, parser = _cmd_options, _cmd_args, _cmd_parser - if opt.version: - _stdout('Bottle %s\n'%__version__) - sys.exit(0) - if not args: - parser.print_help() - _stderr('\nError: No application specified.\n') - sys.exit(1) - - sys.path.insert(0, '.') - sys.modules.setdefault('bottle', sys.modules['__main__']) - - host, port = (opt.bind or 'localhost'), 8080 - if ':' in host and host.rfind(']') < host.rfind(':'): - host, port = host.rsplit(':', 1) - host = host.strip('[]') - - run(args[0], host=host, port=int(port), server=opt.server, - reloader=opt.reload, plugins=opt.plugin, debug=opt.debug) - - - - -# THE END diff --git a/3rdparty/mongo-c-driver-1.26.2/build/calc_release_version.py b/3rdparty/mongo-c-driver-1.26.2/build/calc_release_version.py deleted file mode 100644 index 044a5ab5f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/calc_release_version.py +++ /dev/null @@ -1,403 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# -# Copyright 2018-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -""" -A script that calculates the release version number (based on the current Git -branch and/or recent tags in history) to assign to a tarball generated from the -current Git commit. - -This script needs to remain compatible with its target platforms, which currently -includes RHEL 6, which uses Python 2.6! -""" - -# XXX NOTE XXX NOTE XXX NOTE XXX -# After modifying this script it is advisable to execute the self-tests in this directory: -# - calc_release_version_selftest.sh -# - calc_release_version_selftest.py -# XXX NOTE XXX NOTE XXX NOTE XXX - -# pyright: reportTypeCommentUsage=false - -import datetime -import errno -import re -import subprocess -import optparse # No 'argparse' on Python 2.6 -import sys - - -class Version: - def __init__(self, s): - pat = r'(\d+)\.(\d+)\.(\d+)(\-\S+)?' - match = re.match(pat, s) - assert match, "Unrecognized version string %s" % s - self.major, self.minor, self.micro = ( - map(int, (match.group(1), match.group(2), match.group(3)))) - - if match.group(4): - self.prerelease = match.group(4)[1:] - else: - self.prerelease = '' - - def __lt__(self, other): - if self.major != other.major: - return self.major < other.major - if self.minor != other.minor: - return self.minor < other.minor - if self.micro != other.micro: - return self.micro < other.micro - if self.prerelease != other.prerelease: - if self.prerelease != '' and other.prerelease == '': - # Consider a prerelease less than non-prerelease. - return True - # For simplicity, compare prerelease versions lexicographically. - return self.prerelease < other.prerelease - - # Versions are equal. - return False - - def __eq__(self, other): - self_tuple = self.major, self.minor, self.micro, self.prerelease - other_tuple = other.major, other.minor, other.micro, other.prerelease - return self_tuple == other_tuple - - -def parse_version(ver): - return Version(ver) - - -parser = optparse.OptionParser(description=__doc__) -parser.add_option("--debug", "-d", action="store_true", help="Enable debug output") -parser.add_option("--previous", "-p", action="store_true", help="Calculate the previous version instead of the current") -parser.add_option("--next-minor", action="store_true", help="Calculate the next minor version instead of the current") -args, pos = parser.parse_args() -assert not pos, "No positional arguments are expected" - - -_DEBUG = args.debug # type: bool - - -def debug(msg): # type: (str) -> None - if _DEBUG: - sys.stderr.write(msg) - sys.stderr.write("\n") - sys.stderr.flush() - - -debug("Debugging output enabled.") - -# This option indicates we are to determine the previous release version -PREVIOUS = args.previous # type: bool -# This options indicates to output the next minor release version -NEXT_MINOR = args.next_minor # type: bool - -# fmt: off - -PREVIOUS_TAG_RE = re.compile('(?P(?P[0-9]+)\\.(?P[0-9]+)' - '\\.(?P[0-9]+)(?:-(?P.*))?)') -RELEASE_TAG_RE = re.compile('(?P(?P[0-9]+)\\.(?P[0-9]+)' - '\\.(?P[0-9]+)(?:-(?P.*))?)') -RELEASE_BRANCH_RE = re.compile('(?:(?:refs/remotes/)?origin/)?(?Pr' - '(?P[0-9]+)\\.(?P[0-9]+))') - - -def check_output(args): # type: (list[str]) -> str - """ - Delegates to subprocess.check_output() if it is available, otherwise - provides a reasonable facsimile. - """ - debug('Run command: {0}'.format(args)) - try: - proc = subprocess.Popen(args, stdout=subprocess.PIPE) - except OSError as e: - suppl = '' - if e.errno == errno.ENOENT: - suppl = 'Does the executable “{0}†not exist?'.format(args[0]) - raise RuntimeError("Failed to execute subprocess {0}: {1} [{2}]".format(args, e, suppl)) - out = proc.communicate()[0] - ret = proc.poll() - if ret: - raise subprocess.CalledProcessError(ret, args[0]) - - # git isn't guaranteed to always return UTF-8, but for our purposes - # this should be fine as tags and hashes should be ASCII only. - out = out.decode('utf-8') - - return out - - -def check_head_tag(): # type: () -> str | None - """ - Checks the current HEAD to see if it has been tagged with a tag that matches - the pattern for a release tag. Returns release version calculated from the - tag, or None if there is no matching tag associated with HEAD. - """ - - found_tag = False - version_str = '0.0.0' - version_parsed = parse_version(version_str) - - # have git tell us if any tags that look like release tags point at HEAD; - # based on our policy, a commit should never have more than one release tag - tags = check_output(['git', 'tag', '--points-at', 'HEAD', '--list', '1.*']).split() - tag = '' - if len(tags) == 1: - tag = tags[0] - elif len(tags) > 1: - raise Exception('Expected 1 or 0 tags on HEAD, got: {}'.format(tags)) - - release_tag_match = RELEASE_TAG_RE.match(tag) - if release_tag_match: - new_version_str = release_tag_match.group('ver') - new_version_parsed = parse_version(new_version_str) - if new_version_parsed > version_parsed: # type: ignore - debug('HEAD release tag: ' + new_version_str) - version_str = new_version_str - version_parsed = new_version_parsed - found_tag = True - - if found_tag: - debug('Calculated version: ' + version_str) - return version_str - - return None - -def get_next_minor(prerelease_marker): # type: (str) -> str - """ - get_next_minor does the following: - - Inspect the branches that fit the convention for a release branch. - - Choose the latest and increment the minor version. - - Append .0 to form the new version (e.g., r1.21 becomes 1.22.0) - - Append a pre-release marker. (e.g. 1.22.0 becomes 1.22.0-20220201+gitf6e6a7025d) - """ - - version_str = '0.0.0' - version_parsed = parse_version(version_str) - - version_new = {} - # Use refs (not branches) to get local branches plus remote branches - refs = check_output(['git', 'show-ref']).splitlines() - for ref in refs: - release_branch_match = RELEASE_BRANCH_RE.match(ref.split()[1]) - if release_branch_match: - # Construct a candidate version from this branch name - version_new['major'] = int(release_branch_match.group('vermaj')) - version_new['minor'] = int(release_branch_match.group('vermin')) + 1 - version_new['patch'] = 0 - version_new['prerelease'] = prerelease_marker - new_version_str = str(version_new['major']) + '.' + \ - str(version_new['minor']) + '.' + \ - str(version_new['patch']) + '-' + \ - version_new['prerelease'] - new_version_parsed = parse_version(new_version_str) - if new_version_parsed > version_parsed: # type: ignore - version_str = new_version_str - version_parsed = new_version_parsed - debug('Found new best version "' + version_str \ - + '" based on branch "' \ - + release_branch_match.group('brname') + '"') - return version_str - -def get_branch_tags(active_branch_name): # type: (str) -> list[str] - """ - Returns a list of tags corresponding to the current branch, which must not - be master. If the specified branch is a release branch then return all tags - based on the major/minor X.Y release version. If the specified branch is - neither master nor a release branch, then walk backwards in history until - the first tag matching the glob '1.*' and return that tag. - """ - - if active_branch_name == 'master': - raise Exception('this method is not meant to be called while on "master"') - - release_branch_match = RELEASE_BRANCH_RE.match(active_branch_name) - if release_branch_match: - # This is a release branch, so look for tags only on this branch - tag_glob = release_branch_match.group('vermaj') + '.' \ - + release_branch_match.group('vermin') + '.*' - return check_output(['git', 'tag', '--list', tag_glob]).splitlines() - - # Not a release branch, so look for the most recent tag in history - commits = check_output(['git', 'log', '--pretty=format:%H', '--no-merges']) - tags_by_obj = get_object_tags() - for commit in commits.splitlines(): - got = tags_by_obj.get(commit) - if got: - return got - # No tags - return [] - - -def iter_tag_lines(): - """ - Generate a list of pairs of strings, where the first is a commit hash, and - the second is a tag that is associated with that commit. Duplicate commits - are possible. - """ - output = check_output(['git', 'tag', '--list', '1.*', '--format=%(*objectname)|%(tag)']) - lines = output.splitlines() - for l in lines: - obj, tag = l.split('|', 1) - if tag: - yield obj, tag - - -def get_object_tags(): # type: () -> dict[str, list[str]] - """ - Obtain a mapping between commit hashes and a list of tags that point to - that commit. Untagged commits will not be included in the resulting map. - """ - ret = {} # type: dict[str, list[str]] - for obj, tag in iter_tag_lines(): - ret.setdefault(obj, []).append(tag) - return ret - - -def process_and_sort_tags(tags): # type: (list[str]) -> list[str] - """ - Given a string (as returned from get_branch_tags), return a sorted list of - zero or more tags (sorted based on the Version comparison) which meet - the following criteria: - - a final release tag (i.e., 1.x.y without any pre-release suffix) - - a pre-release tag which is not superseded by a release tag (i.e., - 1.x.y-preX iff 1.x.y does not already exist) - """ - - processed_and_sorted_tags = [] # type: list[str] - if not tags or len(tags) == 0: - return processed_and_sorted_tags - - # find all the final release tags - for tag in tags: - release_tag_match = RELEASE_TAG_RE.match(tag) - if release_tag_match and not release_tag_match.group('verpre'): - processed_and_sorted_tags.append(tag) - # collect together final release tags and pre-release tags for - # versions that have not yet had a final release - for tag in tags: - tag_parts = tag.split('-') - if len(tag_parts) >= 2 and tag_parts[0] not in processed_and_sorted_tags: - processed_and_sorted_tags.append(tag) - processed_and_sorted_tags.sort(key=Version) # type: ignore - - return processed_and_sorted_tags - -def main(): - """ - The algorithm is roughly: - - - Is the --next-minor flag passed? If "yes", then return the next minor - release with a pre-release marker. - - Is the current HEAD associated with a tag that looks like a release - version? - - If "yes" then use that as the version - - If "no" then is the current branch master? - - If "yes" the current branch is master, then return the next minor - release with a pre-release marker. - - If "no" the current branch is not master, then determine the most - recent tag in history; strip any pre-release marker, increment the - patch version, and append a new pre-release marker - """ - - version_str = '0.0.0' - version_parsed = parse_version(version_str) - head_commit_short = check_output(['git', 'rev-parse', '--revs-only', - '--short=10', 'HEAD^{commit}']).strip() - prerelease_marker = datetime.date.today().strftime('%Y%m%d') \ - + '+git' + head_commit_short - - if NEXT_MINOR: - debug('Calculating next minor release') - return get_next_minor(prerelease_marker) - - head_tag_ver = check_head_tag() - if head_tag_ver: - return head_tag_ver - - active_branch_name = check_output(['git', 'rev-parse', - '--abbrev-ref', 'HEAD']).strip() - debug('Calculating release version for branch: ' + active_branch_name) - if active_branch_name == 'master': - return get_next_minor(prerelease_marker) - - branch_tags = get_branch_tags(active_branch_name) - tags = process_and_sort_tags(branch_tags) - - tag = tags[-1] if len(tags) > 0 else '' - # at this point the RE match is redundant, but convenient for accessing - # the components of the version string - release_tag_match = RELEASE_TAG_RE.match(tag) - if release_tag_match: - version_new = {} - version_new['major'] = int(release_tag_match.group('vermaj')) - version_new['minor'] = int(release_tag_match.group('vermin')) - version_new['patch'] = int(release_tag_match.group('verpatch')) + 1 - version_new['prerelease'] = prerelease_marker - new_version_str = str(version_new['major']) + '.' + \ - str(version_new['minor']) + '.' + \ - str(version_new['patch']) + '-' + \ - version_new['prerelease'] - new_version_parsed = parse_version(new_version_str) - if new_version_parsed > version_parsed: # type: ignore - version_str = new_version_str - version_parsed = new_version_parsed - debug('Found new best version "' + version_str \ - + '" from tag "' + release_tag_match.group('ver') + '"') - - return version_str - -def previous(rel_ver): # type: (str) -> str - """ - Given a release version, find the previous version based on the latest Git - tag that is strictly a lower version than the given release version. - """ - debug('Calculating previous release version (option -p was specified).') - version_str = '0.0.0' - version_parsed = parse_version(version_str) - rel_ver_str = rel_ver - rel_ver_parsed = parse_version(rel_ver_str) - tags = check_output(['git', 'tag', '--list', '1.*']).splitlines() - processed_and_sorted_tags = process_and_sort_tags(tags) - for tag in processed_and_sorted_tags: - previous_tag_match = PREVIOUS_TAG_RE.match(tag) - if previous_tag_match: - version_new = {} - version_new['major'] = int(previous_tag_match.group('vermaj')) - version_new['minor'] = int(previous_tag_match.group('vermin')) - version_new['patch'] = int(previous_tag_match.group('verpatch')) - version_new['prerelease'] = previous_tag_match.group('verpre') - new_version_str = str(version_new['major']) + '.' + \ - str(version_new['minor']) + '.' + \ - str(version_new['patch']) - if version_new['prerelease'] is not None: - new_version_str += '-' + version_new['prerelease'] - new_version_parsed = parse_version(new_version_str) - if new_version_parsed < rel_ver_parsed and new_version_parsed > version_parsed: # type: ignore - version_str = new_version_str - version_parsed = new_version_parsed - debug('Found new best version "' + version_str \ - + '" from tag "' + tag + '"') - - return version_str - -if __name__ == "__main__": - RELEASE_VER = previous(main()) if PREVIOUS else main() - - debug('Final calculated release version:') - print(RELEASE_VER) diff --git a/3rdparty/mongo-c-driver-1.26.2/build/calc_release_version_selftest.py b/3rdparty/mongo-c-driver-1.26.2/build/calc_release_version_selftest.py deleted file mode 100644 index ac01f7f0a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/calc_release_version_selftest.py +++ /dev/null @@ -1,17 +0,0 @@ -import unittest -import calc_release_version - - -class TestVersionSort(unittest.TestCase): - def test_version_sort(self): - # At time of writing, `input_tags` is the output of `git tag -l "1.*"`: - input_tags = ["1.0.0", "1.0.2", "1.1.0", "1.1.0-rc0", "1.1.10", "1.1.11", "1.1.2", "1.1.4", "1.1.5", "1.1.6", "1.1.7", "1.1.8", "1.1.9", "1.10.0", "1.10.1", "1.10.2", "1.10.3", "1.11.0", "1.12.0", "1.13.0", "1.13.1", "1.14.0", "1.14.1", "1.15.0", "1.15.1", "1.15.2", "1.15.3", "1.16.0", "1.16.1", "1.16.2", "1.17.0", "1.17.0-beta", "1.17.0-beta2", "1.17.0-rc0", "1.17.1", "1.17.2", "1.17.3", "1.17.4", "1.17.5", "1.17.6", "1.17.7", "1.18.0", "1.18.0-alpha", "1.18.0-alpha2", "1.19.0", "1.19.1", "1.19.2", "1.2.0", "1.2.0-beta", "1.2.0-beta1", "1.2.0-rc0", "1.2.1", "1.2.2", "1.2.3", "1.2.4", "1.20.0", "1.20.1", "1.21.0", "1.21.1", "1.21.2", "1.22.0", "1.22.0-beta0", "1.22.1", "1.22.2", "1.23.0", - "1.23.1", "1.23.2", "1.23.3", "1.23.4", "1.23.5", "1.24.0", "1.24.1", "1.24.2", "1.24.3", "1.24.4", "1.3.0", "1.3.0-beta0", "1.3.0-rc0", "1.3.1", "1.3.2", "1.3.3", "1.3.4", "1.3.5", "1.3.6", "1.4.0", "1.4.0-beta0", "1.4.0-beta1", "1.4.1", "1.4.2", "1.4.3", "1.5.0", "1.5.0-rc0", "1.5.0-rc1", "1.5.0-rc2", "1.5.0-rc3", "1.5.0-rc4", "1.5.0-rc6", "1.5.1", "1.5.2", "1.5.3", "1.5.4", "1.5.5", "1.6.0", "1.6.0-rc0", "1.6.1", "1.6.2", "1.6.3", "1.7.0", "1.7.0-rc0", "1.7.0-rc1", "1.7.0-rc2", "1.8.0", "1.8.0-rc0", "1.8.0-rc1", "1.8.1", "1.8.2", "1.9.0", "1.9.0+dfsg", "1.9.0-rc0", "1.9.0-rc1", "1.9.1", "1.9.2", "1.9.2+dfsg", "1.9.3", "1.9.3+dfsg", "1.9.4", "1.9.4+dfsg", "1.9.5", "1.9.5+dfsg"] - expected_tags = ['1.0.0', '1.0.2', '1.1.0-rc0', '1.1.0', '1.1.2', '1.1.4', '1.1.5', '1.1.6', '1.1.7', '1.1.8', '1.1.9', '1.1.10', '1.1.11', '1.2.0-beta', '1.2.0-beta1', '1.2.0-rc0', '1.2.0', '1.2.1', '1.2.2', '1.2.3', '1.2.4', '1.3.0-beta0', '1.3.0-rc0', '1.3.0', '1.3.1', '1.3.2', '1.3.3', '1.3.4', '1.3.5', '1.3.6', '1.4.0-beta0', '1.4.0-beta1', '1.4.0', '1.4.1', '1.4.2', '1.4.3', '1.5.0-rc0', '1.5.0-rc1', '1.5.0-rc2', '1.5.0-rc3', '1.5.0-rc4', '1.5.0-rc6', '1.5.0', '1.5.1', '1.5.2', '1.5.3', '1.5.4', '1.5.5', '1.6.0-rc0', '1.6.0', '1.6.1', '1.6.2', '1.6.3', '1.7.0-rc0', '1.7.0-rc1', '1.7.0-rc2', '1.7.0', '1.8.0-rc0', '1.8.0-rc1', '1.8.0', '1.8.1', '1.8.2', '1.9.0-rc0', '1.9.0-rc1', - '1.9.0', '1.9.0+dfsg', '1.9.1', '1.9.2', '1.9.2+dfsg', '1.9.3', '1.9.3+dfsg', '1.9.4', '1.9.4+dfsg', '1.9.5', '1.9.5+dfsg', '1.10.0', '1.10.1', '1.10.2', '1.10.3', '1.11.0', '1.12.0', '1.13.0', '1.13.1', '1.14.0', '1.14.1', '1.15.0', '1.15.1', '1.15.2', '1.15.3', '1.16.0', '1.16.1', '1.16.2', '1.17.0-beta', '1.17.0-beta2', '1.17.0-rc0', '1.17.0', '1.17.1', '1.17.2', '1.17.3', '1.17.4', '1.17.5', '1.17.6', '1.17.7', '1.18.0-alpha', '1.18.0-alpha2', '1.18.0', '1.19.0', '1.19.1', '1.19.2', '1.20.0', '1.20.1', '1.21.0', '1.21.1', '1.21.2', '1.22.0-beta0', '1.22.0', '1.22.1', '1.22.2', '1.23.0', '1.23.1', '1.23.2', '1.23.3', '1.23.4', '1.23.5', '1.24.0', '1.24.1', '1.24.2', '1.24.3', '1.24.4'] - got_tags = sorted(input_tags, key=calc_release_version.Version) - self.assertEqual(got_tags, expected_tags) - - -if __name__ == "__main__": - unittest.main() diff --git a/3rdparty/mongo-c-driver-1.26.2/build/calc_release_version_selftest.sh b/3rdparty/mongo-c-driver-1.26.2/build/calc_release_version_selftest.sh deleted file mode 100755 index 60f8ad0dd..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/calc_release_version_selftest.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# calc_release_version_selftest.sh is used to test output of calc_release_version.py. -# run with: -# cd build -# ./calc_release_version_selftest.sh - -set -o errexit -set -o pipefail - -function assert_eq () { - a="$1" - b="$2" - if [[ "$a" != "$b" ]]; then - echo "Assertion failed: $a != $b" - # Print caller - caller - exit 1 - fi -} - -SAVED_REF=$(git rev-parse HEAD) - -function cleanup () { - [[ -e calc_release_version_test.py ]] && rm calc_release_version_test.py - git checkout $SAVED_REF --quiet -} - -trap cleanup EXIT - -: ${PYTHON_INTERP:=python} -if [[ -z $(command -v "${PYTHON_INTERP}") ]]; then - echo "Python interpreter '${PYTHON_INTERP}' is not valid." - echo "Set the PYTHON_INTERP environment variable to a valid interpreter." - exit 1 -fi - -# copy calc_release_version.py to a separate file not tracked by git so it does not change on `git checkout` -cp calc_release_version.py calc_release_version_test.py - -echo "Test a tagged commit ... begin" -{ - git checkout 1.23.4 --quiet - got=$("${PYTHON_INTERP}" calc_release_version_test.py --debug) - assert_eq "$got" "1.23.4" - got=$("${PYTHON_INTERP}" calc_release_version_test.py --debug -p) - assert_eq "$got" "1.23.3" - git checkout - --quiet -} -echo "Test a tagged commit ... end" - -DATE=$(date +%Y%m%d) -echo "Test an untagged commit ... begin" -{ - # 42a818429d6d586a6abf22367ac6fea1e9ce3f2c is commit before 1.23.4 - git checkout 42a818429d6d586a6abf22367ac6fea1e9ce3f2c --quiet - got=$("${PYTHON_INTERP}" calc_release_version_test.py --debug) - assert_eq "$got" "1.23.4-$DATE+git42a818429d" - got=$("${PYTHON_INTERP}" calc_release_version_test.py --debug -p) - assert_eq "$got" "1.23.4" - git checkout - --quiet -} -echo "Test an untagged commit ... end" - -echo "Test next minor version ... begin" -{ - CURRENT_SHORTREF=$(git rev-parse --revs-only --short=10 HEAD) - got=$("${PYTHON_INTERP}" calc_release_version_test.py --debug --next-minor) - # XXX NOTE XXX NOTE XXX - # If you find yourself looking at this line because the assertion below - # failed, then it is probably because a new major/minor release was made. - # Update the expected output to represent the correct next version. - # XXX NOTE XXX NOTE XXX - assert_eq "$got" "1.25.0-$DATE+git$CURRENT_SHORTREF" - got=$("${PYTHON_INTERP}" calc_release_version_test.py --debug --next-minor -p) - # XXX NOTE XXX NOTE XXX - # If you find yourself looking at this line because the assertion below - # failed, then it is probably because a new major/minor release was made. - # Update the expected output to represent the correct next version. - # XXX NOTE XXX NOTE XXX - assert_eq "$got" "1.24.4" -} -echo "Test next minor version ... end" - -echo "All tests passed" diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/.gitignore b/3rdparty/mongo-c-driver-1.26.2/build/cmake/.gitignore deleted file mode 100644 index 399ab1518..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -libmongoc-1.0-config.cmake -libmongoc-1.0-config-version.cmake -libmongoc-static-1.0-config.cmake -libmongoc-static-1.0-config-version.cmake diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/BuildVersion.cmake b/3rdparty/mongo-c-driver-1.26.2/build/cmake/BuildVersion.cmake deleted file mode 100644 index 18d29a0c2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/BuildVersion.cmake +++ /dev/null @@ -1,55 +0,0 @@ -include_guard(GLOBAL) - -include(MongoSettings) - -# We use Python to calculate the BUILD_VERSION value -find_package(Python COMPONENTS Interpreter) - -set(_CALC_VERSION_PY "${CMAKE_CURRENT_LIST_DIR}/../calc_release_version.py") - -#[[ - Attempts to find the current build version string. If VERSION_CURRENT exists - in the current source directory, uses that. Otherwise, runs calc_release_version.py - to compute the version from the Git history. - - The computed build version is set in the parent scope according to `outvar`. -]] -function(compute_build_version outvar) - list(APPEND CMAKE_MESSAGE_CONTEXT ${CMAKE_CURRENT_FUNCTION}) - # If it is present, defer to the VERSION_CURRENT file: - set(ver_cur_file "${CMAKE_CURRENT_SOURCE_DIR}/VERSION_CURRENT") - if(EXISTS "${ver_cur_file}") - message(DEBUG "Using existing VERSION_CURRENT file as BUILD_VERSION [${ver_cur_file}]") - file(READ "${ver_cur_file}" version) - set("${outvar}" "${version}" PARENT_SCOPE) - return() - endif() - # Otherwise, we require Python: - if(NOT TARGET Python::Interpreter) - message(WARNING "No default build version could be calculated (Python was not found)") - set("${outvar}" "0.0.0-unknown+no-python-found") - return() - endif() - get_target_property(py Python::Interpreter IMPORTED_LOCATION) - message(STATUS "Computing the current release version...") - execute_process( - COMMAND "${py}" "${_CALC_VERSION_PY}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - OUTPUT_VARIABLE output - RESULT_VARIABLE retc - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(retc) - message(FATAL_ERROR "Computing the build version failed! [${retc}]:\n${out}") - endif() - message(DEBUG "calc_release_version.py returned output: “${output}â€") - set("${outvar}" "${output}" PARENT_SCOPE) -endfunction() - -# Compute the BUILD_VERSION if it is not already defined: -if(NOT DEFINED BUILD_VERSION) - compute_build_version(BUILD_VERSION) -endif() - -# Set a BUILD_VERSION_SIMPLE, which is just a three-number-triple that CMake understands -string (REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+).*$" "\\1" BUILD_VERSION_SIMPLE "${BUILD_VERSION}") diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/CCache.cmake b/3rdparty/mongo-c-driver-1.26.2/build/cmake/CCache.cmake deleted file mode 100644 index 6ecf296e4..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/CCache.cmake +++ /dev/null @@ -1,44 +0,0 @@ -#[[ - This module enables Ccache support by inserting a ccache executable as - the compiler launcher for C and C++ if there is a ccache executable availbale - on the system. - - Ccache support will be automatically enabled if it is found on the system. - Ccache can be forced on or off by setting the MONGO_USE_CCACHE CMake option to - ON or OFF. -]] - -# Find and enable ccache for compiling -find_program (CCACHE_EXECUTABLE ccache) - -if (CCACHE_EXECUTABLE AND NOT DEFINED MONGO_USE_CCACHE) - message (STATUS "Found Ccache: ${CCACHE_EXECUTABLE}") - execute_process( - COMMAND "${CCACHE_EXECUTABLE}" --version - OUTPUT_VARIABLE _out - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - set (_enable TRUE) - # Avoid spurious "ccache.conf: No such file or directory" errors due to - # ccache being invoked in parallel, which was patched in ccache version 3.4.3. - if (_out MATCHES "^ccache version ([0-9]+\\.[0-9]+\\.[0-9]+)") - set (_version "${CMAKE_MATCH_1}") - message (STATUS "Detected Ccache version: ${_version}") - if (_version VERSION_LESS "3.4.3") - message (STATUS "Not using Ccache: Detected Ccache version ${_version} " - "is less than 3.4.3, which may lead to spurious failures " - "when run in parallel. See https://github.com/ccache/ccache/issues/260 " - "for more information.") - set (_enable FALSE) - endif () - else () - message (STATUS "Note: Unable to automatically detect Ccache from from output: [[${_out}]]") - endif () - option (MONGO_USE_CCACHE "Use Ccache when compiling" "${_enable}") -endif () - -if (MONGO_USE_CCACHE) - message (STATUS "Compiling with Ccache enabled. Disable by setting MONGO_USE_CCACHE to OFF") - set (CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}") - set (CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}") -endif () diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/FindLibreSSL.cmake b/3rdparty/mongo-c-driver-1.26.2/build/cmake/FindLibreSSL.cmake deleted file mode 100644 index 4134c3ac3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/FindLibreSSL.cmake +++ /dev/null @@ -1,236 +0,0 @@ -#[=======================================================================[ - -Copyright (c) 2019 John Norrbin - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -FindLibreSSL ------------- - -Find the LibreSSL encryption library. - -Optional Components -^^^^^^^^^^^^^^^^^^^ - -This module supports two optional components: SSL and TLS. Both -components have associated imported targets, as described below. - -Imported Targets -^^^^^^^^^^^^^^^^ - -This module defines the following imported targets: - -LibreSSL::Crypto - The LibreSSL crypto library, if found. - -LibreSSL::SSL - The LibreSSL ssl library, if found. Requires and includes LibreSSL::Crypto automatically. - -LibreSSL::TLS - The LibreSSL tls library, if found. Requires and includes LibreSSL::SSL and LibreSSL::Crypto automatically. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module will set the following variables in your project: - -LIBRESSL_FOUND - System has the LibreSSL library. If no components are requested it only requires the crypto library. -LIBRESSL_INCLUDE_DIR - The LibreSSL include directory. -LIBRESSL_CRYPTO_LIBRARY - The LibreSSL crypto library. -LIBRESSL_SSL_LIBRARY - The LibreSSL SSL library. -LIBRESSL_TLS_LIBRARY - The LibreSSL TLS library. -LIBRESSL_LIBRARIES - All LibreSSL libraries. -LIBRESSL_VERSION - This is set to $major.$minor.$revision (e.g. 2.6.8). - -Hints -^^^^^ - -Set LIBRESSL_ROOT_DIR to the root directory of an LibreSSL installation. - -XXX: Note! This file differs somewhat from the upstream FindLibreSSL and has -been modified with fixes used by mongo-c-driver. Such differences are noted -where they appear. - -]=======================================================================] - -INCLUDE(FindPackageHandleStandardArgs) - -# Set Hints -set(_LIBRESSL_ROOT_HINTS - ${LIBRESSL_ROOT_DIR} - ENV LIBRESSL_ROOT_DIR -) - -# Set Paths -if (WIN32) - file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles) - set(_LIBRESSL_ROOT_PATHS - "${_programfiles}/LibreSSL" - ) - unset(_programfiles) -else() - set(_LIBRESSL_ROOT_PATHS - "/usr/local/" - ) -endif() - -# Combine -set(_LIBRESSL_ROOT_HINTS_AND_PATHS - HINTS ${_LIBRESSL_ROOT_HINTS} - PATHS ${_LIBRESSL_ROOT_PATHS} - # XXX: Changed from upstream FindLibreSSL: - # Some platforms (e.g. Arch) install LibreSSL in a qualified path so as not to - # collide with OpenSSL. Add path suffixies that match such distributions - PATH_SUFFIXES - include - lib - libressl - libressl/include - libressl/lib -) - -# Find Include Path -find_path(LIBRESSL_INCLUDE_DIR - NAMES - tls.h - ${_LIBRESSL_ROOT_HINTS_AND_PATHS} -) - -# Find Crypto Library -find_library(LIBRESSL_CRYPTO_LIBRARY - NAMES - libcrypto - crypto - NAMES_PER_DIR - ${_LIBRESSL_ROOT_HINTS_AND_PATHS} -) - -# Find SSL Library -find_library(LIBRESSL_SSL_LIBRARY - NAMES - libssl - ssl - NAMES_PER_DIR - ${_LIBRESSL_ROOT_HINTS_AND_PATHS} -) - -# Find TLS Library -find_library(LIBRESSL_TLS_LIBRARY - NAMES - libtls - tls - NAMES_PER_DIR - ${_LIBRESSL_ROOT_HINTS_AND_PATHS} -) - -# Set Libraries -set(LIBRESSL_LIBRARIES ${LIBRESSL_CRYPTO_LIBRARY} ${LIBRESSL_SSL_LIBRARY} ${LIBRESSL_TLS_LIBRARY}) - -# Mark Variables As Advanced -mark_as_advanced(LIBRESSL_INCLUDE_DIR LIBRESSL_LIBRARIES LIBRESSL_CRYPTO_LIBRARY LIBRESSL_SSL_LIBRARY LIBRESSL_TLS_LIBRARY) - -# Find Version File -if(LIBRESSL_INCLUDE_DIR AND EXISTS "${LIBRESSL_INCLUDE_DIR}/openssl/opensslv.h") - - # Get Version From File - file(STRINGS "${LIBRESSL_INCLUDE_DIR}/openssl/opensslv.h" OPENSSLV.H REGEX "#define LIBRESSL_VERSION_TEXT[ \t]+\".*\"") - # XXX: The above line differs from upstream FindLibreSSL, which does not contain the "\t" regex element. - # Newer LibreSSL uses a tab character at this point in the file, which otherwise causes the above - # regex to fail. Newer LibreSSL versions ship full config-file packages, with will remove the - # need to use this file. - - # Match Version String - string(REGEX REPLACE ".*\".*([0-9]+)\\.([0-9]+)\\.([0-9]+)\"" "\\1;\\2;\\3" LIBRESSL_VERSION_LIST "${OPENSSLV.H}") - - # Split Parts - list(GET LIBRESSL_VERSION_LIST 0 LIBRESSL_VERSION_MAJOR) - list(GET LIBRESSL_VERSION_LIST 1 LIBRESSL_VERSION_MINOR) - list(GET LIBRESSL_VERSION_LIST 2 LIBRESSL_VERSION_REVISION) - - # Set Version String - set(LIBRESSL_VERSION "${LIBRESSL_VERSION_MAJOR}.${LIBRESSL_VERSION_MINOR}.${LIBRESSL_VERSION_REVISION}") - -endif() - -# Set Find Package Arguments -find_package_handle_standard_args(LibreSSL - REQUIRED_VARS - LIBRESSL_CRYPTO_LIBRARY - LIBRESSL_INCLUDE_DIR - VERSION_VAR - LIBRESSL_VERSION - HANDLE_COMPONENTS - FAIL_MESSAGE - "Could NOT find LibreSSL, try setting the path to LibreSSL using the LIBRESSL_ROOT_DIR environment variable" -) - -# LibreSSL Found -if(LIBRESSL_FOUND) - - # Set LibreSSL::Crypto - if(NOT TARGET LibreSSL::Crypto AND EXISTS "${LIBRESSL_CRYPTO_LIBRARY}") - - # Add Library - add_library(LibreSSL::Crypto UNKNOWN IMPORTED) - - # Set Properties - set_target_properties( - LibreSSL::Crypto - PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${LIBRESSL_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${LIBRESSL_CRYPTO_LIBRARY}" - ) - - endif() # LibreSSL::Crypto - - # Set LibreSSL::SSL - if(NOT TARGET LibreSSL::SSL AND EXISTS "${LIBRESSL_SSL_LIBRARY}") - - # Add Library - add_library(LibreSSL::SSL UNKNOWN IMPORTED) - - # Set Properties - set_target_properties( - LibreSSL::SSL - PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${LIBRESSL_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${LIBRESSL_SSL_LIBRARY}" - INTERFACE_LINK_LIBRARIES LibreSSL::Crypto - ) - - endif() # LibreSSL::SSL - - # Set LibreSSL::TLS - if(NOT TARGET LibreSSL::TLS AND EXISTS "${LIBRESSL_TLS_LIBRARY}") - add_library(LibreSSL::TLS UNKNOWN IMPORTED) - set_target_properties( - LibreSSL::TLS - PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${LIBRESSL_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${LIBRESSL_TLS_LIBRARY}" - INTERFACE_LINK_LIBRARIES LibreSSL::SSL - ) - - endif() # LibreSSL::TLS - -endif(LIBRESSL_FOUND) diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/GenerateUninstaller.cmake b/3rdparty/mongo-c-driver-1.26.2/build/cmake/GenerateUninstaller.cmake deleted file mode 100644 index a9822d349..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/GenerateUninstaller.cmake +++ /dev/null @@ -1,271 +0,0 @@ -cmake_policy(VERSION 3.15) - -if(NOT CMAKE_SCRIPT_MODE_FILE) - # We are being included from within a project, so we should generate the install rules - # The script name is "uninstall" by default: - if(NOT DEFINED UNINSTALL_SCRIPT_NAME) - set(UNINSTALL_SCRIPT_NAME "uninstall") - endif() - # We need a directory where we should install the script: - if(NOT UNINSTALL_PROG_DIR) - message(SEND_ERROR "We require an UNINSTALL_PROG_DIR to be defined") - endif() - # Platform dependent values: - if(WIN32) - set(_script_ext "cmd") - set(_script_runner cmd.exe /c) - else() - set(_script_ext "sh") - set(_script_runner sh -e -u) - endif() - # The script filename and path: - set(_script_filename "${UNINSTALL_SCRIPT_NAME}.${_script_ext}") - get_filename_component(_uninstaller_script "${CMAKE_CURRENT_BINARY_DIR}/${_script_filename}" ABSOLUTE) - # Code that will do the work at install-time: - string(CONFIGURE [==[ - function(__generate_uninstall) - set(UNINSTALL_IS_WIN32 "@WIN32@") - set(UNINSTALL_WRITE_FILE "@_uninstaller_script@") - set(UNINSTALL_SCRIPT_SELF "@UNINSTALL_PROG_DIR@/@_script_filename@") - include("@CMAKE_CURRENT_LIST_FILE@") - endfunction() - __generate_uninstall() - ]==] code @ONLY ESCAPE_QUOTES) - install(CODE "${code}") - # Add a rule to install that file: - install( - FILES "${_uninstaller_script}" - DESTINATION "${UNINSTALL_PROG_DIR}" - PERMISSIONS - OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE - ) - - # If applicable, generate an "uninstall" target to run the uninstaller: - if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR OR PROJECT_IS_TOP_LEVEL) - add_custom_target( - uninstall - COMMAND ${_script_runner} "${_uninstaller_script}" - COMMENT Uninstalling... - ) - endif() - # Stop here: The rest of the file is for install-time - return() -endif() - -# We get here if running in script mode (e.g. at CMake install-time) -if(NOT DEFINED CMAKE_INSTALL_MANIFEST_FILES) - message(FATAL_ERROR "This file is only for use with CMake's install(CODE/SCRIPT) command") -endif() -if(NOT DEFINED UNINSTALL_WRITE_FILE) - message(FATAL_ERROR "Expected a variable “UNINSTALL_WRITE_FILE†to be defined") -endif() - -# Clear out the uninstall script before we begin writing: -file(WRITE "${UNINSTALL_WRITE_FILE}" "") - -# Append a line to the uninstall script file. Single quotes will be replaced with doubles, -# and an appropriate newline will be added. -function(append_line line) - string(REPLACE "'" "\"" line "${line}") - file(APPEND "${UNINSTALL_WRITE_FILE}" "${line}\n") -endfunction() - -# The copyright header: -set(header [[ -Mongo C Driver uninstall program, generated with CMake - -Copyright 2018-present MongoDB, Inc. - -Licensed under the Apache License, Version 2.0 (the \"License\"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an \"AS IS\" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -]]) -string(STRIP header "${header}") -string(REPLACE "\n" ";" header_lines "${header}") - -# Prefix for the Batch script: -set(bat_preamble [[ -call :init - -:print -nul - if ERRORLEVEL 0 ( - call :print "- ok" - ) else ( - call :print "- skipped (non-empty?)" - ) -) else ( - call :print " - skipped: not present" -) -echo( -exit /b - -:init -setlocal EnableDelayedExpansion -setlocal EnableExtensions -if /i "%~dp0" NEQ "%TEMP%\" ( - set tmpfile=%TEMP%\mongoc-%~nx0 - copy "%~f0" "!tmpfile!" >nul - call "!tmpfile!" & del "!tmpfile!" - exit /b -) -]]) - -# Prefix for the shell script: -set(sh_preamble [[ -set -eu - -__rmfile() { - set -eu - abs=$__prefix/$1 - printf "Remove file %s: " "$abs" - if test -f "$abs" || test -L "$abs" - then - rm -- "$abs" - echo "ok" - else - echo "skipped: not present" - fi -} - -__rmdir() { - set -eu - abs=$__prefix/$1 - printf "Remove directory %s: " "$abs" - if test -d "$abs" - then - list=$(ls --almost-all "$abs") - if test "$list" = "" - then - rmdir -- "$abs" - echo "ok" - else - echo "skipped: not empty" - fi - else - echo "skipped: not present" - fi -} -]]) - -# Convert the install prefix to an absolute path with the native path format: -get_filename_component(install_prefix "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) -file(TO_NATIVE_PATH "${install_prefix}" install_prefix) -# Handling DESTDIR requires careful handling of root path redirection: -set(root_path) -set(relative_prefix "${install_prefix}") -if(COMMAND cmake_path) - cmake_path(GET install_prefix ROOT_PATH root_path) - cmake_path(GET install_prefix RELATIVE_PART relative_prefix) -endif() - -# The first lines that will be written to the script: -set(init_lines) - -if(UNINSTALL_IS_WIN32) - # Comment the header: - list(TRANSFORM header_lines PREPEND "rem ") - # Add the preamble - list(APPEND init_lines - "@echo off" - "${header_lines}" - "${bat_preamble}" - "if \"%DESTDIR%\"==\"\" (" - " set __prefix=${install_prefix}" - ") else (" - " set __prefix=!DESTDIR!\\${relative_prefix}" - ")" - "") - set(__rmfile "call :rmfile") - set(__rmdir "call :rmdir") -else() - # Comment the header: - list(TRANSFORM header_lines PREPEND "# * ") - # Add the preamble - list(APPEND init_lines - "#!/bin/sh" - "${header_lines}" - "${sh_preamble}" - "__prefix=\${DESTDIR:-}${install_prefix}" - "") - set(__rmfile "__rmfile") - set(__rmdir "__rmdir") -endif() - -# Add the first lines to the file: -string(REPLACE ";" "\n" init "${init_lines}") -append_line("${init}") - -# Generate a "remove a file" command -function(add_rmfile filename) - file(TO_NATIVE_PATH "${filename}" native) - append_line("${__rmfile} '${native}'") -endfunction() - -# Generate a "remove a directory" command -function(add_rmdir dirname) - file(TO_NATIVE_PATH "${dirname}" native) - append_line("${__rmdir} '${native}'") -endfunction() - -set(script_self "${install_prefix}/${UNINSTALL_SCRIPT_SELF}") -set(dirs_to_remove) -foreach(installed IN LISTS CMAKE_INSTALL_MANIFEST_FILES script_self) - # Get the relative path from the prefix (the uninstaller will fix it up later) - file(RELATIVE_PATH relpath "${install_prefix}" "${installed}") - # Add a removal: - add_rmfile("${relpath}") - # Climb the path and collect directories: - while("1") - get_filename_component(installed "${installed}" DIRECTORY) - file(TO_NATIVE_PATH "${installed}" installed) - get_filename_component(parent "${installed}" DIRECTORY) - file(TO_NATIVE_PATH "${parent}" parent) - # Don't account for the prefix or direct children of the prefix: - if(installed STREQUAL install_prefix OR parent STREQUAL install_prefix) - break() - endif() - # Keep track of this directory for later: - list(APPEND dirs_to_remove "${installed}") - endwhile() -endforeach() - -# Now generate commands to remove (empty) directories: -list(REMOVE_DUPLICATES dirs_to_remove) -# Order them by depth so that we remove subdirectories before their parents: -list(SORT dirs_to_remove ORDER DESCENDING) -foreach(dir IN LISTS dirs_to_remove) - file(RELATIVE_PATH relpath "${install_prefix}" "${dir}") - add_rmdir("${relpath}") -endforeach() - -message(STATUS "Generated uninstaller: ${UNINSTALL_WRITE_FILE}") diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/LegacyPackage.cmake b/3rdparty/mongo-c-driver-1.26.2/build/cmake/LegacyPackage.cmake deleted file mode 100644 index 2cbf10964..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/LegacyPackage.cmake +++ /dev/null @@ -1,31 +0,0 @@ -include (CMakePackageConfigHelpers) - -# These aren't pkg-config files, they're CMake package configuration files. -function (install_package_config_file prefix) - foreach (suffix "config.cmake") - configure_package_config_file ( - ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}-${prefix}-${suffix}.in - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${prefix}-${suffix} - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${prefix} - ) - - install ( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${prefix}-${suffix} - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${prefix} - ) - endforeach () - write_basic_package_version_file( - ${PROJECT_NAME}-${prefix}-config-version.cmake - VERSION "${PROJECT_VERSION}" - COMPATIBILITY SameMajorVersion - ) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${prefix}-config-version.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${prefix}) -endfunction () - -install_package_config_file ("1.0") - -if (ENABLE_STATIC) - install_package_config_file ("static-1.0") -endif () diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/MongoC-Warnings.cmake b/3rdparty/mongo-c-driver-1.26.2/build/cmake/MongoC-Warnings.cmake deleted file mode 100644 index 0f5c3398c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/MongoC-Warnings.cmake +++ /dev/null @@ -1,82 +0,0 @@ -#[[ - This file sets warning options for the directories in which it is include()'d - - These warnings are intended to be ported to each supported platform, and - especially for high-value warnings that are very likely to catch latent bugs - early in the process before the code is even run. -]] - -#[[ - Define additional compile options, conditional on the compiler being used. - Each option should be prefixed by `gnu:`, `clang:`, `msvc:`, or `gnu-like:`. - Those options will be conditionally enabled for GCC, Clang, or MSVC. - - These options are attached to the source directory and its children. -]] -function (mongoc_add_warning_options) - list(APPEND CMAKE_MESSAGE_CONTEXT ${CMAKE_CURRENT_FUNCTION}) - # Conditional prefixes: - set(cond/gnu $) - set(cond/llvm-clang $) - set(cond/apple-clang $) - set(cond/clang $) - set(cond/gnu-like $) - set(cond/msvc $) - set(cond/lang-c $) - # "Old" GNU is GCC < 5, which is missing several warning options - set(cond/gcc-lt5 $,5>>) - set(cond/gcc-lt7 $,7>>) - # Process options: - foreach (opt IN LISTS ARGV) - # Replace prefixes. Matches right-most first: - while (opt MATCHES "(.*)(^|:)([a-z0-9-]+):(.*)") - set(before "${CMAKE_MATCH_1}${CMAKE_MATCH_2}") - set(prefix "${CMAKE_MATCH_3}") - set(suffix "${CMAKE_MATCH_4}") - message(TRACE "Substitution: prefix “${prefix}†in “${opt}â€, suffix is “${suffix}â€") - set(cond "cond/${prefix}") - set(not 0) - if(prefix MATCHES "^not-(.*)") - set(cond "cond/${CMAKE_MATCH_1}") - set(not 1) - endif() - if(DEFINED "${cond}") - set(expr "${${cond}}") - if(not) - set(expr "$") - endif() - set(opt "$<${expr}:${suffix}>") - else () - message (SEND_ERROR "Unknown option prefix to ${CMAKE_CURRENT_FUNCTION}(): “${prefix}†in “${opt}â€") - break() - endif () - set(opt "${before}${opt}") - message(TRACE "Become: ${opt}") - endwhile () - add_compile_options("${opt}") - endforeach () -endfunction () - -set (is_c_lang "$") - -# These below warnings should always be unconditional hard errors, as the code is -# almost definitely broken -mongoc_add_warning_options ( - # Implicit function or variable declarations - gnu-like:lang-c:-Werror=implicit msvc:/we4013 msvc:/we4431 - # Missing return types/statements - gnu-like:-Werror=return-type msvc:/we4716 - # Incompatible pointer types - gnu-like:lang-c:not-gcc-lt5:-Werror=incompatible-pointer-types msvc:/we4113 - # Integral/pointer conversions - gnu-like:lang-c:not-gcc-lt5:-Werror=int-conversion msvc:/we4047 - # Discarding qualifiers - gnu:lang-c:not-gcc-lt5:-Werror=discarded-qualifiers - clang:lang-c:-Werror=ignored-qualifiers - msvc:/we4090 - # Definite use of uninitialized value - gnu-like:-Werror=uninitialized msvc:/we4700 - - # Aside: Disable CRT insecurity warnings - msvc:/D_CRT_SECURE_NO_WARNINGS - ) diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/Sanitizers.cmake b/3rdparty/mongo-c-driver-1.26.2/build/cmake/Sanitizers.cmake deleted file mode 100644 index 7a740d8b0..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/Sanitizers.cmake +++ /dev/null @@ -1,42 +0,0 @@ -include (CheckCSourceCompiles) -include (CMakePushCheckState) -include (MongoSettings) - -mongo_setting ( - MONGO_SANITIZE "Semicolon/comma-separated list of sanitizers to apply when building" - DEFAULT - DEVEL EVAL [[ - if(NOT MSVC) - set(DEFAULT "address,undefined") - endif() - ]]) - -# Replace commas with semicolons for the genex -string(REPLACE ";" "," _sanitize "${MONGO_SANITIZE}") - -if (_sanitize) - string (MAKE_C_IDENTIFIER "HAVE_SANITIZE_${_sanitize}" ident) - string (TOUPPER "${ident}" varname) - set (flag "-fsanitize=${_sanitize}") - - cmake_push_check_state () - set (CMAKE_REQUIRED_FLAGS "${flag}") - set (CMAKE_REQUIRED_LIBRARIES "${flag}") - check_c_source_compiles ([[ - #include - - int main (void) { - puts ("Hello, world!"); - return 0; - } - ]] "${varname}") - cmake_pop_check_state () - - if (NOT "${${varname}}") - message (SEND_ERROR "Requested sanitizer option '${flag}' is not supported by the compiler+linker") - else () - message (STATUS "Enabling sanitizers: ${flag}") - mongo_platform_compile_options ($) - mongo_platform_link_options (${flag}) - endif () -endif () diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/libbson-1.0-config.cmake.in b/3rdparty/mongo-c-driver-1.26.2/build/cmake/libbson-1.0-config.cmake.in deleted file mode 100644 index 95db4c140..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/libbson-1.0-config.cmake.in +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if(NOT libbson-1.0_FIND_QUIETLY) - message(WARNING "This CMake package is deprecated. Prefer instead to use the \"bson-1.0\" package and link to mongo::bson_shared.") -endif() - -set (BSON_MAJOR_VERSION @libbson_VERSION_MAJOR@) -set (BSON_MINOR_VERSION @libbson_VERSION_MINOR@) -set (BSON_MICRO_VERSION @libbson_VERSION_PATCH@) -set (BSON_VERSION @libbson_VERSION@) -set (BSON_VERSION_FULL @libbson_VERSION_FULL@) - -include(CMakeFindDependencyMacro) -find_dependency(bson-1.0) - -set (BSON_LIBRARY mongo::bson_shared) -set (BSON_LIBRARIES mongo::bson_shared) diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/libbson-static-1.0-config.cmake.in b/3rdparty/mongo-c-driver-1.26.2/build/cmake/libbson-static-1.0-config.cmake.in deleted file mode 100644 index 95a5f301d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/libbson-static-1.0-config.cmake.in +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if(NOT libbson-static-1.0_FIND_QUIETLY) - message(WARNING "This CMake package is deprecated. Prefer instead to use the \"bson-1.0\" package and link to mongo::bson_static.") -endif() - -set (BSON_STATIC_MAJOR_VERSION @libbson_VERSION_MAJOR@) -set (BSON_STATIC_MINOR_VERSION @libbson_VERSION_MINOR@) -set (BSON_STATIC_MICRO_VERSION @libbson_VERSION_PATCH@) -set (BSON_STATIC_VERSION @libbson_VERSION@) -set (BSON_STATIC_VERSION_FULL @libbson_VERSION_FULL@) - -include(CMakeFindDependencyMacro) -find_dependency(bson-1.0) - -set (BSON_STATIC_LIBRARY mongo::bson_static) -set (BSON_STATIC_LIBRARIES mongo::bson_static) diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/libmongoc-1.0-config.cmake.in b/3rdparty/mongo-c-driver-1.26.2/build/cmake/libmongoc-1.0-config.cmake.in deleted file mode 100644 index a06840883..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/libmongoc-1.0-config.cmake.in +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if(NOT libmongoc-1.0_FIND_QUIETLY) - message(WARNING "This CMake package is deprecated. Prefer instead to use the \"mongoc-1.0\" package and link to mongo::mongoc_shared.") -endif() - -set (MONGOC_MAJOR_VERSION @libmongoc_VERSION_MAJOR@) -set (MONGOC_MINOR_VERSION @libmongoc_VERSION_MINOR@) -set (MONGOC_MICRO_VERSION @libmongoc_VERSION_PATCH@) -set (MONGOC_VERSION @libmongoc_VERSION@) -set (MONGOC_VERSION_FULL @libmongoc_VERSION_FULL@) - -include(CMakeFindDependencyMacro) -find_dependency (mongoc-1.0) - -set(MONGOC_LIBRARY mongo::mongoc_shared) -set(MONGOC_LIBRARIES mongo::mongoc_shared) diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/libmongoc-static-1.0-config.cmake.in b/3rdparty/mongo-c-driver-1.26.2/build/cmake/libmongoc-static-1.0-config.cmake.in deleted file mode 100644 index bec316368..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/libmongoc-static-1.0-config.cmake.in +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if(NOT libmongoc-static-1.0_FIND_QUIETLY) - message(WARNING "This CMake package is deprecated. Prefer instead to use the \"mongoc-1.0\" package and link to mongo::mongoc_static.") -endif() - -set (MONGOC_STATIC_MAJOR_VERSION @libmongoc_VERSION_MAJOR@) -set (MONGOC_STATIC_MINOR_VERSION @libmongoc_VERSION_MINOR@) -set (MONGOC_STATIC_MICRO_VERSION @libmongoc_VERSION_PATCH@) -set (MONGOC_STATIC_VERSION @libmongoc_VERSION@) -set (MONGOC_STATIC_VERSION_FULL @libmongoc_VERSION_FULL@) - -include(CMakeFindDependencyMacro) -find_dependency (mongoc-1.0) - -set(MONGOC_STATIC_LIBRARY mongo::mongoc_static) -set(MONGOC_STATIC_LIBRARIES mongo::mongoc_static) diff --git a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-functions.h.template b/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-functions.h.template deleted file mode 100644 index db858a281..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-functions.h.template +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef FUTURE_FUNCTIONS_H -#define FUTURE_FUNCTIONS_H - -#include "future-value.h" -#include "future.h" -#include "mongoc/mongoc-bulk-operation.h" - -{{ header_comment }} - -{% for F in future_functions %} -future_t * -{{ F|future_function_name }} ( -{% for P in F.params %} - {{ P.type_name }} {{ P.name }}{% if not loop.last %},{% endif %}{% endfor %} -); - -{% endfor %} - -#endif /* FUTURE_FUNCTIONS_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/build/opts_templates/mongoc-opts-private.h.template b/3rdparty/mongo-c-driver-1.26.2/build/opts_templates/mongoc-opts-private.h.template deleted file mode 100644 index beaee81b2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/opts_templates/mongoc-opts-private.h.template +++ /dev/null @@ -1,54 +0,0 @@ -#include "mongoc-prelude.h" - -#ifndef MONGOC_OPTS_H -#define MONGOC_OPTS_H - -#include - -#include "mongoc-client-session.h" -#include "mongoc-bulk-operation-private.h" -#include "mongoc-opts-helpers-private.h" - -{{ header_comment }} - -{% for struct_type, description in opts_structs.items() %} -{% if not description.generate_code %}{% continue %}{% endif %} -typedef struct _{{ struct_type }} { -{% for opt_name, info in description.items() %} -{% if info['type'] == 'utf8' %} -{% set the_type = 'const char *' %} -{% elif info['type'] in ('document', 'array') %} -{% set the_type = 'bson_t' %} -{% elif info['type'] == 'timestamp' %} -{% set the_type = 'mongoc_timestamp_t' %} -{% else %} -{% set the_type = info['type'] %} -{% endif %} -{% set the_name = info.get('field', opt_name) %} -{% set space = '' if the_type.endswith('*') else ' ' %} - {{ the_type }}{{ space }}{{ the_name }}; -{% if info.check_set %} - bool {{ the_name }}_is_set; -{% endif %} -{% endfor %} -{% if not description.is_shared %} - bson_t extra; -{% endif %} -} {{ struct_type }}; - -{% endfor %} -{% for struct_type, description in opts_structs.items() %} -{% if description.is_shared or not description.generate_code %}{% continue %}{% endif %} -{% set struct_name = struct_type.split('_t', -1)[0] %} -bool -_{{ struct_name }}_parse ( - mongoc_client_t *client, - const bson_t *opts, - {{ struct_type }} *{{ struct_name }}, - bson_error_t *error); - -void -_{{ struct_name }}_cleanup ({{ struct_type }} *{{ struct_name }}); - -{% endfor %} -#endif /* MONGOC_OPTS_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/conf.py b/3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/conf.py deleted file mode 100644 index dfed27af2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/conf.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- -from docutils import nodes -import os -import sys - -# Import common docs config. -this_path = os.path.dirname(__file__) -sys.path.append(os.path.normpath(os.path.join(this_path, '../'))) - -from mongoc_common import * - -version = release = os.environ.get('VERSION_RELEASED') -if not release: - raise RuntimeError('Set the "VERSION_RELEASED" environment variable') - -# -- General configuration ------------------------------------------------ -templates_path = ['_templates'] -source_suffix = '.rst' -master_doc = 'index' - -# General information about the project. -project = u'mongoc.org' -copyright = u'2017, MongoDB, Inc' -author = u'MongoDB, Inc' -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = False - - -# Support :download-link:`bson` or :download-link:`mongoc`. -def download_link(typ, rawtext, text, lineno, inliner, options={}, content=[]): - if text == "mongoc": - lib = "mongo-c-driver" - else: - raise ValueError( - "download link must be mongoc, not \"%s\"" % text) - - title = "%s-%s" % (lib, version) - url = ("https://github.com/mongodb/mongo-c-driver/releases/tag/%(version)s") % { - "version": version - } - - pnode = nodes.reference(title, title, internal=False, refuri=url) - return [pnode], [] - -def setup(app): - mongoc_common_setup(app) - - app.add_role('download-link', download_link) - -# -- Options for HTML output ---------------------------------------------- - -html_theme = 'furo' -html_title = html_shorttitle = 'MongoDB C Driver %s' % version -# html_favicon = None -html_use_smartypants = False -html_show_sourcelink = False -html_use_index = False - -html_sidebars = { - '**': [] -} - -# Note: http://www.sphinx-doc.org/en/1.5.1/config.html#confval-html_copy_source -# This will degrade the Javascript quicksearch if we ever use it. -html_copy_source = False diff --git a/3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/index.rst b/3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/index.rst deleted file mode 100644 index 962982bd8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/index.rst +++ /dev/null @@ -1,40 +0,0 @@ -MongoDB C Driver -================ - -**A Cross Platform MongoDB Client Library for C** - -The MongoDB C Driver, also known as "libmongoc", is a library for using MongoDB from C applications, and for writing MongoDB drivers in higher-level languages. - -It depends on `libbson `_ to generate and parse BSON documents, the native data format of MongoDB. - -Download --------- - -Latest release: :download-link:`mongoc` - -Documentation -------------- - -`Installation `_ - -`Tutorial `_ - -`libmongoc reference `_ - -`libbson reference `_ - -How To Ask For Help -------------------- - -For help using the driver: `MongoDB Community Forums `_. - -To file a bug or feature request: `MongoDB Jira Issue Tracker `_. - -Documentation for Older Versions --------------------------------- - -.. toctree:: - :titlesonly: - - libmongoc-releases - libbson-releases diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/auth-ssl.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/auth-ssl.json deleted file mode 100644 index 9636f2055..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/auth-ssl.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "auth_key": "secret", - "id": "repl0", - "login": "bob", - "password": "pwd123", - "members": [ - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27017, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "tags": { - "ordinal": "one", - "dc": "ny" - } - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27018, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "tags": { - "ordinal": "two", - "dc": "pa" - } - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27019, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "arbiterOnly": true - } - } - ], - "sslParams": { - "sslMode": "requireSSL", - "sslPEMKeyFile": "/tmp/orchestration-home/server.pem", - "sslCAFile": "/tmp/orchestration-home/ca.pem", - "sslAllowInvalidCertificates": true, - "sslWeakCertificateValidation" : true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/auth-thisDB-ssl.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/auth-thisDB-ssl.json deleted file mode 100644 index 2b96cfd53..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/auth-thisDB-ssl.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "auth_key": "secret", - "id": "repl0", - "login": "bob", - "password": "pwd123", - "authSource": "thisDB", - "members": [ - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27017, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "tags": { - "ordinal": "one", - "dc": "ny" - } - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27018, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "tags": { - "ordinal": "two", - "dc": "pa" - } - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27019, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "arbiterOnly": true - } - } - ], - "sslParams": { - "sslMode": "requireSSL", - "sslPEMKeyFile": "/tmp/orchestration-home/server.pem", - "sslCAFile": "/tmp/orchestration-home/ca.pem", - "sslAllowInvalidCertificates": true, - "sslWeakCertificateValidation" : true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/auth.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/auth.json deleted file mode 100644 index 79e2d982b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/auth.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "auth_key": "secret", - "id": "repl0", - "login": "bob", - "members": [ - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27017, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "tags": { - "ordinal": "one", - "dc": "ny" - } - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27018, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "tags": { - "ordinal": "two", - "dc": "pa" - } - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27019, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "arbiterOnly": true - } - } - ], - "password": "pwd123" -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/basic-ssl.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/basic-ssl.json deleted file mode 100644 index 2c0ff03f2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/basic-ssl.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "id": "repl0", - "members": [ - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27017, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "tags": { - "ordinal": "one", - "dc": "ny" - } - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27018, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "tags": { - "ordinal": "two", - "dc": "pa" - } - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27019, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "arbiterOnly": true - } - } - ], - "sslParams": { - "sslMode": "requireSSL", - "sslPEMKeyFile": "/tmp/orchestration-home/server.pem", - "sslCAFile": "/tmp/orchestration-home/ca.pem", - "sslAllowInvalidCertificates": true, - "sslWeakCertificateValidation" : true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/basic.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/basic.json deleted file mode 100644 index 05a8f8e04..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/replica_sets/basic.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "id": "repl0", - "members": [ - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27017, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "tags": { - "ordinal": "one", - "dc": "ny" - } - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27018, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "tags": { - "ordinal": "two", - "dc": "pa" - } - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27019, - "setParameter" : { "enableTestCommands": 1 } - }, - "rsParams": { - "arbiterOnly": true - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/auth-aws.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/auth-aws.json deleted file mode 100644 index 8e09d49eb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/auth-aws.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "id": "standalone-aws", - "auth_key": "secret", - "login": "bob", - "name": "mongod", - "password": "pwd123", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017, - "setParameter": {"enableTestCommands": 1, "authenticationMechanisms": "MONGODB-AWS,SCRAM-SHA-256,SCRAM-SHA-1"} - } -} \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/auth-ssl.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/auth-ssl.json deleted file mode 100644 index 57f5be948..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/auth-ssl.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id" : "standalonessl", - "name": "mongod", - "login": "bob", - "password": "pwd123", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017 - }, - "sslParams": { - "sslMode": "requireSSL", - "sslPEMKeyFile": "/tmp/orchestration-home/server.pem", - "sslCAFile": "/tmp/orchestration-home/ca.pem", - "sslAllowInvalidCertificates": true, - "sslWeakCertificateValidation" : true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/auth.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/auth.json deleted file mode 100644 index 25ba95078..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/auth.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "id": "standalone", - "auth_key": "secret", - "login": "bob", - "name": "mongod", - "password": "pwd123", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017 - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/basic-ipv4-only.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/basic-ipv4-only.json deleted file mode 100644 index 687a6c109..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/basic-ipv4-only.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "mongod", - "procParams": { - "ipv6": false, - "logappend": true, - "port": 27017 - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/basic-ssl.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/basic-ssl.json deleted file mode 100644 index edabc3997..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/basic-ssl.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id" : "standalonenoauthssl", - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017 - }, - "sslParams": { - "sslMode": "requireSSL", - "sslPEMKeyFile": "/tmp/orchestration-home/server.pem", - "sslCAFile": "/tmp/orchestration-home/ca.pem", - "sslAllowInvalidCertificates": true, - "sslWeakCertificateValidation" : true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/basic.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/basic.json deleted file mode 100644 index da0ef6c73..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/basic.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017 - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/ecdsa-basic-tls-ocsp-disableStapling.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/ecdsa-basic-tls-ocsp-disableStapling.json deleted file mode 100644 index b879d93c0..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/ecdsa-basic-tls-ocsp-disableStapling.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id" : "standalonenoauthssl", - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017, - "setParameter": {"failpoint.disableStapling":"{\"mode\":\"alwaysOn\"}}"} - }, - "sslParams": { - "sslOnNormalPorts": true, - "sslPEMKeyFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/ecdsa/server.pem", - "sslCAFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/ecdsa/ca.pem", - "sslWeakCertificateValidation" : true, - "sslAllowInvalidCertificates": true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json deleted file mode 100644 index 03bf38eec..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id" : "standalonenoauthssl", - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017, - "setParameter": {"failpoint.disableStapling":"{\"mode\":\"alwaysOn\"}}"} - }, - "sslParams": { - "sslOnNormalPorts": true, - "sslPEMKeyFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/ecdsa/server-mustStaple.pem", - "sslCAFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/ecdsa/ca.pem", - "sslWeakCertificateValidation" : true, - "sslAllowInvalidCertificates": true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/ecdsa-basic-tls-ocsp-mustStaple.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/ecdsa-basic-tls-ocsp-mustStaple.json deleted file mode 100644 index 64dcf3769..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/ecdsa-basic-tls-ocsp-mustStaple.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id" : "standalonenoauthssl", - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017, - "setParameter": {"ocspEnabled": true} - }, - "sslParams": { - "sslOnNormalPorts": true, - "sslPEMKeyFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/ecdsa/server-mustStaple.pem", - "sslCAFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/ecdsa/ca.pem", - "sslWeakCertificateValidation" : true, - "sslAllowInvalidCertificates": true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/mmapv1.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/mmapv1.json deleted file mode 100644 index 273156c7c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/mmapv1.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "storageEngine": "mmapv1", - "port": 27017 - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/rsa-basic-tls-ocsp-disableStapling.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/rsa-basic-tls-ocsp-disableStapling.json deleted file mode 100644 index f6ca3a20b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/rsa-basic-tls-ocsp-disableStapling.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id" : "standalonenoauthssl", - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017, - "setParameter": {"failpoint.disableStapling":"{\"mode\":\"alwaysOn\"}}"} - }, - "sslParams": { - "sslOnNormalPorts": true, - "sslPEMKeyFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/rsa/server.pem", - "sslCAFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/rsa/ca.pem", - "sslWeakCertificateValidation" : true, - "sslAllowInvalidCertificates": true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/rsa-basic-tls-ocsp-mustStaple-disableStapling.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/rsa-basic-tls-ocsp-mustStaple-disableStapling.json deleted file mode 100644 index 243a512c8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/rsa-basic-tls-ocsp-mustStaple-disableStapling.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id" : "standalonenoauthssl", - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017, - "setParameter": {"failpoint.disableStapling":"{\"mode\":\"alwaysOn\"}}"} - }, - "sslParams": { - "sslOnNormalPorts": true, - "sslPEMKeyFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/rsa/server-mustStaple.pem", - "sslCAFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/rsa/ca.pem", - "sslWeakCertificateValidation" : true, - "sslAllowInvalidCertificates": true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/rsa-basic-tls-ocsp-mustStaple.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/rsa-basic-tls-ocsp-mustStaple.json deleted file mode 100644 index 9d54d5a9e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/rsa-basic-tls-ocsp-mustStaple.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id" : "standalonenoauthssl", - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017, - "setParameter": {"ocspEnabled": true} - }, - "sslParams": { - "sslOnNormalPorts": true, - "sslPEMKeyFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/rsa/server-mustStaple.pem", - "sslCAFile": "ABSOLUTE_PATH_REPLACEMENT_TOKEN/.evergreen/ocsp/rsa/ca.pem", - "sslWeakCertificateValidation" : true, - "sslAllowInvalidCertificates": true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/snappy-zlib-zstd.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/snappy-zlib-zstd.json deleted file mode 100644 index 73313462d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/snappy-zlib-zstd.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "mongod", - "procParams": { - "networkMessageCompressors": "snappy,zlib,zstd", - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017 - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/snappy.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/snappy.json deleted file mode 100644 index ef5563091..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/snappy.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "mongod", - "procParams": { - "networkMessageCompressors": "snappy", - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017 - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/versioned-api-testing.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/versioned-api-testing.json deleted file mode 100644 index f69a9db65..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/versioned-api-testing.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "id": "versioned-api-testing", - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017, - "setParameter": { - "enableTestCommands": 1, - "acceptApiVersion2": 1 - } - } -} \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/wiredtiger.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/wiredtiger.json deleted file mode 100644 index ed0c916b6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/wiredtiger.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "mongod", - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "storageEngine": "wiredTiger", - "port": 27017 - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/zlib.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/zlib.json deleted file mode 100644 index 45c07f086..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/zlib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "mongod", - "procParams": { - "networkMessageCompressors": "zlib", - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017 - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/zstd.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/zstd.json deleted file mode 100644 index ab8ea1a5a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/servers/zstd.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "mongod", - "procParams": { - "networkMessageCompressors": "zstd", - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "logappend": true, - "port": 27017 - } - } - \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth-load-balancer.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth-load-balancer.json deleted file mode 100644 index 7d40ac419..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth-load-balancer.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "id": "shard_cluster_1", - "login": "bob", - "password": "pwd123", - "auth_key": "secret", - "shards": [ - { - "id": "sh01", - "shardParams": { - "members": [ - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27217 - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27218 - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27219 - } - } - ] - } - } - ], - "routers": [ - { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27017, - "setParameter": { - "loadBalancerPort": 27050 - } - }, - { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27018, - "setParameter": { - "loadBalancerPort": 27051 - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth-ssl-load-balancer.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth-ssl-load-balancer.json deleted file mode 100644 index 68acd7f83..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth-ssl-load-balancer.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "id": "shard_cluster_1", - "login": "bob", - "password": "pwd123", - "auth_key": "secret", - "shards": [ - { - "id": "sh01", - "shardParams": { - "members": [ - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27217 - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27218 - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27219 - } - } - ] - } - } - ], - "routers": [ - { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27017, - "setParameter": { - "loadBalancerPort": 27050 - } - }, - { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27018, - "setParameter": { - "loadBalancerPort": 27051 - } - } - ], - "sslParams": { - "sslOnNormalPorts": true, - "sslPEMKeyFile": "/tmp/orchestration-home/server.pem", - "sslCAFile": "/tmp/orchestration-home/ca.pem", - "sslWeakCertificateValidation" : true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth-ssl.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth-ssl.json deleted file mode 100644 index e25ff21e9..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth-ssl.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "id": "shard_cluster_1", - "login": "bob", - "password": "pwd123", - "auth_key": "secret", - "shards": [ - { - "id": "sh01", - "shardParams": { - "members": [{ - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "setParameter" : { "enableTestCommands": 1 }, - "port": 27217 - } - }] - } - }, - { - "id": "sh02", - "shardParams": { - "members": [{ - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "setParameter" : { "enableTestCommands": 1 }, - "port": 27218 - } - }] - } - } - ], - "routers": [ - { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "setParameter" : { "enableTestCommands": 1 }, - "port": 27017 - }, - { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "setParameter" : { "enableTestCommands": 1 }, - "port": 27018 - } - ], - "sslParams": { - "sslOnNormalPorts": true, - "sslPEMKeyFile": "/tmp/orchestration-home/server.pem", - "sslCAFile": "/tmp/orchestration-home/ca.pem", - "sslWeakCertificateValidation" : true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth.json deleted file mode 100644 index f5dfbdf2c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/auth.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "id": "shard_cluster_1", - "login": "bob", - "password": "pwd123", - "auth_key": "secret", - "shards": [ - { - "id": "sh01", - "shardParams": { - "members": [ - { - "procParams": { - "shardsvr": true, - "port": 27217 - } - }, - { - "procParams": { - "shardsvr": true, - "port": 27218 - } - } - ] - } - }, - { - "id": "sh02", - "shardParams": { - "members": [ - { - "procParams": { - "shardsvr": true, - "port": 27219 - } - }, - { - "procParams": { - "shardsvr": true, - "port": 27220 - } - } - ] - } - } - ], - "routers": [ - { - "port": 27017, - "ipv6": true, - "bind_ip": "127.0.0.1,::1" - }, - { - "port": 27018, - "ipv6": true, - "bind_ip": "127.0.0.1,::1" - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic-load-balancer.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic-load-balancer.json deleted file mode 100644 index 0642bf3e1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic-load-balancer.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "id": "shard_cluster_1", - "shards": [ - { - "id": "sh01", - "shardParams": { - "members": [ - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27217 - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27218 - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27219 - } - } - ] - } - } - ], - "routers": [ - { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27017, - "setParameter": { - "loadBalancerPort": 27050 - } - }, - { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27018, - "setParameter": { - "loadBalancerPort": 27051 - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic-ssl-load-balancer.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic-ssl-load-balancer.json deleted file mode 100644 index dc6be68fc..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic-ssl-load-balancer.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "id": "shard_cluster_1", - "shards": [ - { - "id": "sh01", - "shardParams": { - "members": [ - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27217 - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27218 - } - }, - { - "procParams": { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "shardsvr": true, - "port": 27219 - } - } - ] - } - } - ], - "routers": [ - { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27017, - "setParameter": { - "loadBalancerPort": 27050 - } - }, - { - "ipv6": true, - "bind_ip": "127.0.0.1,::1", - "port": 27018, - "setParameter": { - "loadBalancerPort": 27051 - } - } - ], - "sslParams": { - "sslOnNormalPorts": true, - "sslPEMKeyFile": "/tmp/orchestration-home/server.pem", - "sslCAFile": "/tmp/orchestration-home/ca.pem", - "sslWeakCertificateValidation" : true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic-ssl.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic-ssl.json deleted file mode 100644 index 7e4458b61..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic-ssl.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "id": "shard_cluster_1", - "shards": [ - { - "id": "sh01", - "shardParams": { - "members": [ - { - "procParams": { - "shardsvr": true, - "port": 27217 - } - }, - { - "procParams": { - "shardsvr": true, - "port": 27218 - } - } - ] - } - }, - { - "id": "sh02", - "shardParams": { - "members": [ - { - "procParams": { - "shardsvr": true, - "port": 27219 - } - }, - { - "procParams": { - "shardsvr": true, - "port": 27220 - } - } - ] - } - } - ], - "routers": [ - { - "port": 27017, - "ipv6": true, - "bind_ip": "127.0.0.1,::1" - }, - { - "port": 27018, - "ipv6": true, - "bind_ip": "127.0.0.1,::1" - } - ], - "sslParams": { - "sslMode": "requireSSL", - "sslPEMKeyFile": "/tmp/orchestration-home/server.pem", - "sslCAFile": "/tmp/orchestration-home/ca.pem", - "sslAllowInvalidCertificates": true, - "sslWeakCertificateValidation" : true - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic.json b/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic.json deleted file mode 100644 index 31f88e0a1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/orchestration_configs/sharded_clusters/basic.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "id": "shard_cluster_1", - "shards": [ - { - "id": "sh01", - "shardParams": { - "members": [ - { - "procParams": { - "shardsvr": true, - "port": 27217 - } - }, - { - "procParams": { - "shardsvr": true, - "port": 27218 - } - } - ] - } - }, - { - "id": "sh02", - "shardParams": { - "members": [ - { - "procParams": { - "shardsvr": true, - "port": 27219 - } - }, - { - "procParams": { - "shardsvr": true, - "port": 27220 - } - } - ] - } - } - ], - "routers": [ - { - "port": 27017, - "ipv6": true, - "bind_ip": "127.0.0.1,::1" - }, - { - "port": 27018, - "ipv6": true, - "bind_ip": "127.0.0.1,::1" - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/poetry.lock b/3rdparty/mongo-c-driver-1.26.2/poetry.lock deleted file mode 100644 index f084febf6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/poetry.lock +++ /dev/null @@ -1,815 +0,0 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. - -[[package]] -name = "alabaster" -version = "0.7.13" -description = "A configurable sidebar-enabled Sphinx theme" -optional = false -python-versions = ">=3.6" -files = [ - {file = "alabaster-0.7.13-py3-none-any.whl", hash = "sha256:1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3"}, - {file = "alabaster-0.7.13.tar.gz", hash = "sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2"}, -] - -[[package]] -name = "babel" -version = "2.12.1" -description = "Internationalization utilities" -optional = false -python-versions = ">=3.7" -files = [ - {file = "Babel-2.12.1-py3-none-any.whl", hash = "sha256:b4246fb7677d3b98f501a39d43396d3cafdc8eadb045f4a31be01863f655c610"}, - {file = "Babel-2.12.1.tar.gz", hash = "sha256:cc2d99999cd01d44420ae725a21c9e3711b3aadc7976d6147f622d8581963455"}, -] - -[package.dependencies] -pytz = {version = ">=2015.7", markers = "python_version < \"3.9\""} - -[[package]] -name = "beautifulsoup4" -version = "4.12.2" -description = "Screen-scraping library" -optional = false -python-versions = ">=3.6.0" -files = [ - {file = "beautifulsoup4-4.12.2-py3-none-any.whl", hash = "sha256:bd2520ca0d9d7d12694a53d44ac482d181b4ec1888909b035a3dbf40d0f57d4a"}, - {file = "beautifulsoup4-4.12.2.tar.gz", hash = "sha256:492bbc69dca35d12daac71c4db1bfff0c876c00ef4a2ffacce226d4638eb72da"}, -] - -[package.dependencies] -soupsieve = ">1.2" - -[package.extras] -html5lib = ["html5lib"] -lxml = ["lxml"] - -[[package]] -name = "certifi" -version = "2023.7.22" -description = "Python package for providing Mozilla's CA Bundle." -optional = false -python-versions = ">=3.6" -files = [ - {file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"}, - {file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"}, -] - -[[package]] -name = "charset-normalizer" -version = "3.1.0" -description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -optional = false -python-versions = ">=3.7.0" -files = [ - {file = "charset-normalizer-3.1.0.tar.gz", hash = "sha256:34e0a2f9c370eb95597aae63bf85eb5e96826d81e3dcf88b8886012906f509b5"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:e0ac8959c929593fee38da1c2b64ee9778733cdf03c482c9ff1d508b6b593b2b"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d7fc3fca01da18fbabe4625d64bb612b533533ed10045a2ac3dd194bfa656b60"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:04eefcee095f58eaabe6dc3cc2262f3bcd776d2c67005880894f447b3f2cb9c1"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:20064ead0717cf9a73a6d1e779b23d149b53daf971169289ed2ed43a71e8d3b0"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1435ae15108b1cb6fffbcea2af3d468683b7afed0169ad718451f8db5d1aff6f"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c84132a54c750fda57729d1e2599bb598f5fa0344085dbde5003ba429a4798c0"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:75f2568b4189dda1c567339b48cba4ac7384accb9c2a7ed655cd86b04055c795"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:11d3bcb7be35e7b1bba2c23beedac81ee893ac9871d0ba79effc7fc01167db6c"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:891cf9b48776b5c61c700b55a598621fdb7b1e301a550365571e9624f270c203"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:5f008525e02908b20e04707a4f704cd286d94718f48bb33edddc7d7b584dddc1"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:b06f0d3bf045158d2fb8837c5785fe9ff9b8c93358be64461a1089f5da983137"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:49919f8400b5e49e961f320c735388ee686a62327e773fa5b3ce6721f7e785ce"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:22908891a380d50738e1f978667536f6c6b526a2064156203d418f4856d6e86a"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-win32.whl", hash = "sha256:12d1a39aa6b8c6f6248bb54550efcc1c38ce0d8096a146638fd4738e42284448"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:65ed923f84a6844de5fd29726b888e58c62820e0769b76565480e1fdc3d062f8"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9a3267620866c9d17b959a84dd0bd2d45719b817245e49371ead79ed4f710d19"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6734e606355834f13445b6adc38b53c0fd45f1a56a9ba06c2058f86893ae8017"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f8303414c7b03f794347ad062c0516cee0e15f7a612abd0ce1e25caf6ceb47df"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aaf53a6cebad0eae578f062c7d462155eada9c172bd8c4d250b8c1d8eb7f916a"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3dc5b6a8ecfdc5748a7e429782598e4f17ef378e3e272eeb1340ea57c9109f41"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e1b25e3ad6c909f398df8921780d6a3d120d8c09466720226fc621605b6f92b1"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ca564606d2caafb0abe6d1b5311c2649e8071eb241b2d64e75a0d0065107e62"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b82fab78e0b1329e183a65260581de4375f619167478dddab510c6c6fb04d9b6"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bd7163182133c0c7701b25e604cf1611c0d87712e56e88e7ee5d72deab3e76b5"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:11d117e6c63e8f495412d37e7dc2e2fff09c34b2d09dbe2bee3c6229577818be"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:cf6511efa4801b9b38dc5546d7547d5b5c6ef4b081c60b23e4d941d0eba9cbeb"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:abc1185d79f47c0a7aaf7e2412a0eb2c03b724581139193d2d82b3ad8cbb00ac"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:cb7b2ab0188829593b9de646545175547a70d9a6e2b63bf2cd87a0a391599324"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-win32.whl", hash = "sha256:c36bcbc0d5174a80d6cccf43a0ecaca44e81d25be4b7f90f0ed7bcfbb5a00909"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:cca4def576f47a09a943666b8f829606bcb17e2bc2d5911a46c8f8da45f56755"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0c95f12b74681e9ae127728f7e5409cbbef9cd914d5896ef238cc779b8152373"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fca62a8301b605b954ad2e9c3666f9d97f63872aa4efcae5492baca2056b74ab"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ac0aa6cd53ab9a31d397f8303f92c42f534693528fafbdb997c82bae6e477ad9"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c3af8e0f07399d3176b179f2e2634c3ce9c1301379a6b8c9c9aeecd481da494f"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a5fc78f9e3f501a1614a98f7c54d3969f3ad9bba8ba3d9b438c3bc5d047dd28"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:628c985afb2c7d27a4800bfb609e03985aaecb42f955049957814e0491d4006d"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:74db0052d985cf37fa111828d0dd230776ac99c740e1a758ad99094be4f1803d"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:1e8fcdd8f672a1c4fc8d0bd3a2b576b152d2a349782d1eb0f6b8e52e9954731d"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:04afa6387e2b282cf78ff3dbce20f0cc071c12dc8f685bd40960cc68644cfea6"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:dd5653e67b149503c68c4018bf07e42eeed6b4e956b24c00ccdf93ac79cdff84"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d2686f91611f9e17f4548dbf050e75b079bbc2a82be565832bc8ea9047b61c8c"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-win32.whl", hash = "sha256:4155b51ae05ed47199dc5b2a4e62abccb274cee6b01da5b895099b61b1982974"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:322102cdf1ab682ecc7d9b1c5eed4ec59657a65e1c146a0da342b78f4112db23"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e633940f28c1e913615fd624fcdd72fdba807bf53ea6925d6a588e84e1151531"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:3a06f32c9634a8705f4ca9946d667609f52cf130d5548881401f1eb2c39b1e2c"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7381c66e0561c5757ffe616af869b916c8b4e42b367ab29fedc98481d1e74e14"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3573d376454d956553c356df45bb824262c397c6e26ce43e8203c4c540ee0acb"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e89df2958e5159b811af9ff0f92614dabf4ff617c03a4c1c6ff53bf1c399e0e1"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:78cacd03e79d009d95635e7d6ff12c21eb89b894c354bd2b2ed0b4763373693b"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:de5695a6f1d8340b12a5d6d4484290ee74d61e467c39ff03b39e30df62cf83a0"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1c60b9c202d00052183c9be85e5eaf18a4ada0a47d188a83c8f5c5b23252f649"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:f645caaf0008bacf349875a974220f1f1da349c5dbe7c4ec93048cdc785a3326"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:ea9f9c6034ea2d93d9147818f17c2a0860d41b71c38b9ce4d55f21b6f9165a11"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:80d1543d58bd3d6c271b66abf454d437a438dff01c3e62fdbcd68f2a11310d4b"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:73dc03a6a7e30b7edc5b01b601e53e7fc924b04e1835e8e407c12c037e81adbd"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6f5c2e7bc8a4bf7c426599765b1bd33217ec84023033672c1e9a8b35eaeaaaf8"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-win32.whl", hash = "sha256:12a2b561af122e3d94cdb97fe6fb2bb2b82cef0cdca131646fdb940a1eda04f0"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:3160a0fd9754aab7d47f95a6b63ab355388d890163eb03b2d2b87ab0a30cfa59"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:38e812a197bf8e71a59fe55b757a84c1f946d0ac114acafaafaf21667a7e169e"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6baf0baf0d5d265fa7944feb9f7451cc316bfe30e8df1a61b1bb08577c554f31"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8f25e17ab3039b05f762b0a55ae0b3632b2e073d9c8fc88e89aca31a6198e88f"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3747443b6a904001473370d7810aa19c3a180ccd52a7157aacc264a5ac79265e"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b116502087ce8a6b7a5f1814568ccbd0e9f6cfd99948aa59b0e241dc57cf739f"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d16fd5252f883eb074ca55cb622bc0bee49b979ae4e8639fff6ca3ff44f9f854"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21fa558996782fc226b529fdd2ed7866c2c6ec91cee82735c98a197fae39f706"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6f6c7a8a57e9405cad7485f4c9d3172ae486cfef1344b5ddd8e5239582d7355e"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:ac3775e3311661d4adace3697a52ac0bab17edd166087d493b52d4f4f553f9f0"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:10c93628d7497c81686e8e5e557aafa78f230cd9e77dd0c40032ef90c18f2230"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:6f4f4668e1831850ebcc2fd0b1cd11721947b6dc7c00bf1c6bd3c929ae14f2c7"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:0be65ccf618c1e7ac9b849c315cc2e8a8751d9cfdaa43027d4f6624bd587ab7e"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:53d0a3fa5f8af98a1e261de6a3943ca631c526635eb5817a87a59d9a57ebf48f"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-win32.whl", hash = "sha256:a04f86f41a8916fe45ac5024ec477f41f886b3c435da2d4e3d2709b22ab02af1"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:830d2948a5ec37c386d3170c483063798d7879037492540f10a475e3fd6f244b"}, - {file = "charset_normalizer-3.1.0-py3-none-any.whl", hash = "sha256:3d9098b479e78c85080c98e1e35ff40b4a31d8953102bb0fd7d1b6f8a2111a3d"}, -] - -[[package]] -name = "clang-format" -version = "16.0.0" -description = "Clang-Format is an LLVM-based code formatting tool" -optional = false -python-versions = "*" -files = [ - {file = "clang-format-16.0.0.tar.gz", hash = "sha256:f8dd028e10e1fe18d3598fcdf04b265d46c07d695c43504ea2fba9e74287766e"}, - {file = "clang_format-16.0.0-py2.py3-none-macosx_10_9_universal2.whl", hash = "sha256:f887f8c8ab6975e4cd6f414512277fcd7f3fe8a3d21292010164c4ae31654c91"}, - {file = "clang_format-16.0.0-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d32ca4a847e9e25c935fb187097ba4943ce52515688a85c8a745699db4991505"}, - {file = "clang_format-16.0.0-py2.py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:47a1d563305ba6317706b9ab47e53144d807c261ae7a861db624435b499d709f"}, - {file = "clang_format-16.0.0-py2.py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9878cd8ad0b831b4126f027241f677a24f76c821780d449c35c81f5ad5273a3e"}, - {file = "clang_format-16.0.0-py2.py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7eab6bed7e26d4fbcba39ea828ebde417a9f24839dc0f9d4dab49e63e7c962bb"}, - {file = "clang_format-16.0.0-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:36302cacb9cfcc5032e4f60df454c35e2bd214ef7e65070ccda8d17373b33012"}, - {file = "clang_format-16.0.0-py2.py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:55e7f4869fb720e6adf8ccb65867d0256f4fdad65152c05b0268bf4204636574"}, - {file = "clang_format-16.0.0-py2.py3-none-musllinux_1_1_i686.whl", hash = "sha256:e0edd52e64a100aa7e88c56099ff5754a2b3a61ea6e53148fe41866de0383dd1"}, - {file = "clang_format-16.0.0-py2.py3-none-musllinux_1_1_ppc64le.whl", hash = "sha256:ace775ea2a77e73952039bd4defa5de909f47d7a3b8fd4e8281b5f266597bb71"}, - {file = "clang_format-16.0.0-py2.py3-none-musllinux_1_1_s390x.whl", hash = "sha256:40c0aafde1c2dc3ae4227695017df436fc4fd693f63e897a4d14195d148da4a6"}, - {file = "clang_format-16.0.0-py2.py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:d8bb97f027179638c1913b0a0cb59ce250fce8750c8588d971a160f1c70a3969"}, - {file = "clang_format-16.0.0-py2.py3-none-win32.whl", hash = "sha256:8c345961090b2471d9d9c66fefee7084d4665189909a2d875f7279a3a68a09fb"}, - {file = "clang_format-16.0.0-py2.py3-none-win_amd64.whl", hash = "sha256:e43113f7fcd25c1de4ccb81658748e4b4edcea74b66b73ffb18d6d5d018ab623"}, -] - -[[package]] -name = "colorama" -version = "0.4.6" -description = "Cross-platform colored terminal text." -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -files = [ - {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, - {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, -] - -[[package]] -name = "docutils" -version = "0.19" -description = "Docutils -- Python Documentation Utilities" -optional = false -python-versions = ">=3.7" -files = [ - {file = "docutils-0.19-py3-none-any.whl", hash = "sha256:5e1de4d849fee02c63b040a4a3fd567f4ab104defd8a5511fbbc24a8a017efbc"}, - {file = "docutils-0.19.tar.gz", hash = "sha256:33995a6753c30b7f577febfc2c50411fec6aac7f7ffeb7c4cfe5991072dcf9e6"}, -] - -[[package]] -name = "furo" -version = "2023.7.26" -description = "A clean customisable Sphinx documentation theme." -optional = false -python-versions = ">=3.7" -files = [ - {file = "furo-2023.7.26-py3-none-any.whl", hash = "sha256:1c7936929ec57c5ddecc7c85f07fa8b2ce536b5c89137764cca508be90e11efd"}, - {file = "furo-2023.7.26.tar.gz", hash = "sha256:257f63bab97aa85213a1fa24303837a3c3f30be92901ec732fea74290800f59e"}, -] - -[package.dependencies] -beautifulsoup4 = "*" -pygments = ">=2.7" -sphinx = ">=6.0,<8.0" -sphinx-basic-ng = "*" - -[[package]] -name = "git-url-parse" -version = "1.2.2" -description = "git-url-parse - A simple GIT URL parser." -optional = false -python-versions = "*" -files = [ - {file = "git-url-parse-1.2.2.tar.gz", hash = "sha256:7b5f4e3aeb1d693afeee67a3bd4ac063f7206c2e8e46e559f0da0da98445f117"}, - {file = "git_url_parse-1.2.2-py2-none-any.whl", hash = "sha256:9353ff40d69488ff2299b27f40e0350ad87bd5348ea6ea09a1895eda9e5733de"}, - {file = "git_url_parse-1.2.2-py3-none-any.whl", hash = "sha256:4655ee22f1d8bf7a1eb1066c1da16529b186966c6d8331f7f55686a76a9f7aef"}, -] - -[package.dependencies] -pbr = "*" - -[[package]] -name = "idna" -version = "3.4" -description = "Internationalized Domain Names in Applications (IDNA)" -optional = false -python-versions = ">=3.5" -files = [ - {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, - {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, -] - -[[package]] -name = "imagesize" -version = "1.4.1" -description = "Getting image size from png/jpeg/jpeg2000/gif file" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -files = [ - {file = "imagesize-1.4.1-py2.py3-none-any.whl", hash = "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b"}, - {file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"}, -] - -[[package]] -name = "importlib-metadata" -version = "6.8.0" -description = "Read metadata from Python packages" -optional = false -python-versions = ">=3.8" -files = [ - {file = "importlib_metadata-6.8.0-py3-none-any.whl", hash = "sha256:3ebb78df84a805d7698245025b975d9d67053cd94c79245ba4b3eb694abe68bb"}, - {file = "importlib_metadata-6.8.0.tar.gz", hash = "sha256:dbace7892d8c0c4ac1ad096662232f831d4e64f4c4545bd53016a3e9d4654743"}, -] - -[package.dependencies] -zipp = ">=0.5" - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -perf = ["ipython"] -testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] - -[[package]] -name = "jinja2" -version = "3.1.2" -description = "A very fast and expressive template engine." -optional = false -python-versions = ">=3.7" -files = [ - {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, - {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, -] - -[package.dependencies] -MarkupSafe = ">=2.0" - -[package.extras] -i18n = ["Babel (>=2.7)"] - -[[package]] -name = "livereload" -version = "2.6.3" -description = "Python LiveReload is an awesome tool for web developers" -optional = false -python-versions = "*" -files = [ - {file = "livereload-2.6.3-py2.py3-none-any.whl", hash = "sha256:ad4ac6f53b2d62bb6ce1a5e6e96f1f00976a32348afedcb4b6d68df2a1d346e4"}, - {file = "livereload-2.6.3.tar.gz", hash = "sha256:776f2f865e59fde56490a56bcc6773b6917366bce0c267c60ee8aaf1a0959869"}, -] - -[package.dependencies] -six = "*" -tornado = {version = "*", markers = "python_version > \"2.7\""} - -[[package]] -name = "markupsafe" -version = "2.1.3" -description = "Safely add untrusted strings to HTML/XML markup." -optional = false -python-versions = ">=3.7" -files = [ - {file = "MarkupSafe-2.1.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:cd0f502fe016460680cd20aaa5a76d241d6f35a1c3350c474bac1273803893fa"}, - {file = "MarkupSafe-2.1.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e09031c87a1e51556fdcb46e5bd4f59dfb743061cf93c4d6831bf894f125eb57"}, - {file = "MarkupSafe-2.1.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:68e78619a61ecf91e76aa3e6e8e33fc4894a2bebe93410754bd28fce0a8a4f9f"}, - {file = "MarkupSafe-2.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65c1a9bcdadc6c28eecee2c119465aebff8f7a584dd719facdd9e825ec61ab52"}, - {file = "MarkupSafe-2.1.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:525808b8019e36eb524b8c68acdd63a37e75714eac50e988180b169d64480a00"}, - {file = "MarkupSafe-2.1.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:962f82a3086483f5e5f64dbad880d31038b698494799b097bc59c2edf392fce6"}, - {file = "MarkupSafe-2.1.3-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:aa7bd130efab1c280bed0f45501b7c8795f9fdbeb02e965371bbef3523627779"}, - {file = "MarkupSafe-2.1.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c9c804664ebe8f83a211cace637506669e7890fec1b4195b505c214e50dd4eb7"}, - {file = "MarkupSafe-2.1.3-cp310-cp310-win32.whl", hash = "sha256:10bbfe99883db80bdbaff2dcf681dfc6533a614f700da1287707e8a5d78a8431"}, - {file = "MarkupSafe-2.1.3-cp310-cp310-win_amd64.whl", hash = "sha256:1577735524cdad32f9f694208aa75e422adba74f1baee7551620e43a3141f559"}, - {file = "MarkupSafe-2.1.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:ad9e82fb8f09ade1c3e1b996a6337afac2b8b9e365f926f5a61aacc71adc5b3c"}, - {file = "MarkupSafe-2.1.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3c0fae6c3be832a0a0473ac912810b2877c8cb9d76ca48de1ed31e1c68386575"}, - {file = "MarkupSafe-2.1.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b076b6226fb84157e3f7c971a47ff3a679d837cf338547532ab866c57930dbee"}, - {file = "MarkupSafe-2.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bfce63a9e7834b12b87c64d6b155fdd9b3b96191b6bd334bf37db7ff1fe457f2"}, - {file = "MarkupSafe-2.1.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:338ae27d6b8745585f87218a3f23f1512dbf52c26c28e322dbe54bcede54ccb9"}, - {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e4dd52d80b8c83fdce44e12478ad2e85c64ea965e75d66dbeafb0a3e77308fcc"}, - {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:df0be2b576a7abbf737b1575f048c23fb1d769f267ec4358296f31c2479db8f9"}, - {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac"}, - {file = "MarkupSafe-2.1.3-cp311-cp311-win32.whl", hash = "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb"}, - {file = "MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686"}, - {file = "MarkupSafe-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2"}, - {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b"}, - {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707"}, - {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca379055a47383d02a5400cb0d110cef0a776fc644cda797db0c5696cfd7e18e"}, - {file = "MarkupSafe-2.1.3-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:b7ff0f54cb4ff66dd38bebd335a38e2c22c41a8ee45aa608efc890ac3e3931bc"}, - {file = "MarkupSafe-2.1.3-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:c011a4149cfbcf9f03994ec2edffcb8b1dc2d2aede7ca243746df97a5d41ce48"}, - {file = "MarkupSafe-2.1.3-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:56d9f2ecac662ca1611d183feb03a3fa4406469dafe241673d521dd5ae92a155"}, - {file = "MarkupSafe-2.1.3-cp37-cp37m-win32.whl", hash = "sha256:8758846a7e80910096950b67071243da3e5a20ed2546e6392603c096778d48e0"}, - {file = "MarkupSafe-2.1.3-cp37-cp37m-win_amd64.whl", hash = "sha256:787003c0ddb00500e49a10f2844fac87aa6ce977b90b0feaaf9de23c22508b24"}, - {file = "MarkupSafe-2.1.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:2ef12179d3a291be237280175b542c07a36e7f60718296278d8593d21ca937d4"}, - {file = "MarkupSafe-2.1.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:2c1b19b3aaacc6e57b7e25710ff571c24d6c3613a45e905b1fde04d691b98ee0"}, - {file = "MarkupSafe-2.1.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8afafd99945ead6e075b973fefa56379c5b5c53fd8937dad92c662da5d8fd5ee"}, - {file = "MarkupSafe-2.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8c41976a29d078bb235fea9b2ecd3da465df42a562910f9022f1a03107bd02be"}, - {file = "MarkupSafe-2.1.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d080e0a5eb2529460b30190fcfcc4199bd7f827663f858a226a81bc27beaa97e"}, - {file = "MarkupSafe-2.1.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:69c0f17e9f5a7afdf2cc9fb2d1ce6aabdb3bafb7f38017c0b77862bcec2bbad8"}, - {file = "MarkupSafe-2.1.3-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:504b320cd4b7eff6f968eddf81127112db685e81f7e36e75f9f84f0df46041c3"}, - {file = "MarkupSafe-2.1.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:42de32b22b6b804f42c5d98be4f7e5e977ecdd9ee9b660fda1a3edf03b11792d"}, - {file = "MarkupSafe-2.1.3-cp38-cp38-win32.whl", hash = "sha256:ceb01949af7121f9fc39f7d27f91be8546f3fb112c608bc4029aef0bab86a2a5"}, - {file = "MarkupSafe-2.1.3-cp38-cp38-win_amd64.whl", hash = "sha256:1b40069d487e7edb2676d3fbdb2b0829ffa2cd63a2ec26c4938b2d34391b4ecc"}, - {file = "MarkupSafe-2.1.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:8023faf4e01efadfa183e863fefde0046de576c6f14659e8782065bcece22198"}, - {file = "MarkupSafe-2.1.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6b2b56950d93e41f33b4223ead100ea0fe11f8e6ee5f641eb753ce4b77a7042b"}, - {file = "MarkupSafe-2.1.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9dcdfd0eaf283af041973bff14a2e143b8bd64e069f4c383416ecd79a81aab58"}, - {file = "MarkupSafe-2.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e"}, - {file = "MarkupSafe-2.1.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:282c2cb35b5b673bbcadb33a585408104df04f14b2d9b01d4c345a3b92861c2c"}, - {file = "MarkupSafe-2.1.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:ab4a0df41e7c16a1392727727e7998a467472d0ad65f3ad5e6e765015df08636"}, - {file = "MarkupSafe-2.1.3-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:7ef3cb2ebbf91e330e3bb937efada0edd9003683db6b57bb108c4001f37a02ea"}, - {file = "MarkupSafe-2.1.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:0a4e4a1aff6c7ac4cd55792abf96c915634c2b97e3cc1c7129578aa68ebd754e"}, - {file = "MarkupSafe-2.1.3-cp39-cp39-win32.whl", hash = "sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2"}, - {file = "MarkupSafe-2.1.3-cp39-cp39-win_amd64.whl", hash = "sha256:3fd4abcb888d15a94f32b75d8fd18ee162ca0c064f35b11134be77050296d6ba"}, - {file = "MarkupSafe-2.1.3.tar.gz", hash = "sha256:af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad"}, -] - -[[package]] -name = "packaging" -version = "23.1" -description = "Core utilities for Python packages" -optional = false -python-versions = ">=3.7" -files = [ - {file = "packaging-23.1-py3-none-any.whl", hash = "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61"}, - {file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"}, -] - -[[package]] -name = "pbr" -version = "5.11.1" -description = "Python Build Reasonableness" -optional = false -python-versions = ">=2.6" -files = [ - {file = "pbr-5.11.1-py2.py3-none-any.whl", hash = "sha256:567f09558bae2b3ab53cb3c1e2e33e726ff3338e7bae3db5dc954b3a44eef12b"}, - {file = "pbr-5.11.1.tar.gz", hash = "sha256:aefc51675b0b533d56bb5fd1c8c6c0522fe31896679882e1c4c63d5e4a0fccb3"}, -] - -[[package]] -name = "pydantic" -version = "1.10.7" -description = "Data validation and settings management using python type hints" -optional = false -python-versions = ">=3.7" -files = [ - {file = "pydantic-1.10.7-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e79e999e539872e903767c417c897e729e015872040e56b96e67968c3b918b2d"}, - {file = "pydantic-1.10.7-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:01aea3a42c13f2602b7ecbbea484a98169fb568ebd9e247593ea05f01b884b2e"}, - {file = "pydantic-1.10.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:516f1ed9bc2406a0467dd777afc636c7091d71f214d5e413d64fef45174cfc7a"}, - {file = "pydantic-1.10.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ae150a63564929c675d7f2303008d88426a0add46efd76c3fc797cd71cb1b46f"}, - {file = "pydantic-1.10.7-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:ecbbc51391248116c0a055899e6c3e7ffbb11fb5e2a4cd6f2d0b93272118a209"}, - {file = "pydantic-1.10.7-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:f4a2b50e2b03d5776e7f21af73e2070e1b5c0d0df255a827e7c632962f8315af"}, - {file = "pydantic-1.10.7-cp310-cp310-win_amd64.whl", hash = "sha256:a7cd2251439988b413cb0a985c4ed82b6c6aac382dbaff53ae03c4b23a70e80a"}, - {file = "pydantic-1.10.7-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:68792151e174a4aa9e9fc1b4e653e65a354a2fa0fed169f7b3d09902ad2cb6f1"}, - {file = "pydantic-1.10.7-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:dfe2507b8ef209da71b6fb5f4e597b50c5a34b78d7e857c4f8f3115effaef5fe"}, - {file = "pydantic-1.10.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10a86d8c8db68086f1e30a530f7d5f83eb0685e632e411dbbcf2d5c0150e8dcd"}, - {file = "pydantic-1.10.7-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d75ae19d2a3dbb146b6f324031c24f8a3f52ff5d6a9f22f0683694b3afcb16fb"}, - {file = "pydantic-1.10.7-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:464855a7ff7f2cc2cf537ecc421291b9132aa9c79aef44e917ad711b4a93163b"}, - {file = "pydantic-1.10.7-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:193924c563fae6ddcb71d3f06fa153866423ac1b793a47936656e806b64e24ca"}, - {file = "pydantic-1.10.7-cp311-cp311-win_amd64.whl", hash = "sha256:b4a849d10f211389502059c33332e91327bc154acc1845f375a99eca3afa802d"}, - {file = "pydantic-1.10.7-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:cc1dde4e50a5fc1336ee0581c1612215bc64ed6d28d2c7c6f25d2fe3e7c3e918"}, - {file = "pydantic-1.10.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e0cfe895a504c060e5d36b287ee696e2fdad02d89e0d895f83037245218a87fe"}, - {file = "pydantic-1.10.7-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:670bb4683ad1e48b0ecb06f0cfe2178dcf74ff27921cdf1606e527d2617a81ee"}, - {file = "pydantic-1.10.7-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:950ce33857841f9a337ce07ddf46bc84e1c4946d2a3bba18f8280297157a3fd1"}, - {file = "pydantic-1.10.7-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:c15582f9055fbc1bfe50266a19771bbbef33dd28c45e78afbe1996fd70966c2a"}, - {file = "pydantic-1.10.7-cp37-cp37m-win_amd64.whl", hash = "sha256:82dffb306dd20bd5268fd6379bc4bfe75242a9c2b79fec58e1041fbbdb1f7914"}, - {file = "pydantic-1.10.7-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:8c7f51861d73e8b9ddcb9916ae7ac39fb52761d9ea0df41128e81e2ba42886cd"}, - {file = "pydantic-1.10.7-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:6434b49c0b03a51021ade5c4daa7d70c98f7a79e95b551201fff682fc1661245"}, - {file = "pydantic-1.10.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:64d34ab766fa056df49013bb6e79921a0265204c071984e75a09cbceacbbdd5d"}, - {file = "pydantic-1.10.7-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:701daea9ffe9d26f97b52f1d157e0d4121644f0fcf80b443248434958fd03dc3"}, - {file = "pydantic-1.10.7-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:cf135c46099ff3f919d2150a948ce94b9ce545598ef2c6c7bf55dca98a304b52"}, - {file = "pydantic-1.10.7-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b0f85904f73161817b80781cc150f8b906d521fa11e3cdabae19a581c3606209"}, - {file = "pydantic-1.10.7-cp38-cp38-win_amd64.whl", hash = "sha256:9f6f0fd68d73257ad6685419478c5aece46432f4bdd8d32c7345f1986496171e"}, - {file = "pydantic-1.10.7-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c230c0d8a322276d6e7b88c3f7ce885f9ed16e0910354510e0bae84d54991143"}, - {file = "pydantic-1.10.7-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:976cae77ba6a49d80f461fd8bba183ff7ba79f44aa5cfa82f1346b5626542f8e"}, - {file = "pydantic-1.10.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7d45fc99d64af9aaf7e308054a0067fdcd87ffe974f2442312372dfa66e1001d"}, - {file = "pydantic-1.10.7-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d2a5ebb48958754d386195fe9e9c5106f11275867051bf017a8059410e9abf1f"}, - {file = "pydantic-1.10.7-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:abfb7d4a7cd5cc4e1d1887c43503a7c5dd608eadf8bc615413fc498d3e4645cd"}, - {file = "pydantic-1.10.7-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:80b1fab4deb08a8292d15e43a6edccdffa5377a36a4597bb545b93e79c5ff0a5"}, - {file = "pydantic-1.10.7-cp39-cp39-win_amd64.whl", hash = "sha256:d71e69699498b020ea198468e2480a2f1e7433e32a3a99760058c6520e2bea7e"}, - {file = "pydantic-1.10.7-py3-none-any.whl", hash = "sha256:0cd181f1d0b1d00e2b705f1bf1ac7799a2d938cce3376b8007df62b29be3c2c6"}, - {file = "pydantic-1.10.7.tar.gz", hash = "sha256:cfc83c0678b6ba51b0532bea66860617c4cd4251ecf76e9846fa5a9f3454e97e"}, -] - -[package.dependencies] -typing-extensions = ">=4.2.0" - -[package.extras] -dotenv = ["python-dotenv (>=0.10.4)"] -email = ["email-validator (>=1.0.3)"] - -[[package]] -name = "pygments" -version = "2.15.1" -description = "Pygments is a syntax highlighting package written in Python." -optional = false -python-versions = ">=3.7" -files = [ - {file = "Pygments-2.15.1-py3-none-any.whl", hash = "sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1"}, - {file = "Pygments-2.15.1.tar.gz", hash = "sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c"}, -] - -[package.extras] -plugins = ["importlib-metadata"] - -[[package]] -name = "pytz" -version = "2023.3" -description = "World timezone definitions, modern and historical" -optional = false -python-versions = "*" -files = [ - {file = "pytz-2023.3-py2.py3-none-any.whl", hash = "sha256:a151b3abb88eda1d4e34a9814df37de2a80e301e68ba0fd856fb9b46bfbbbffb"}, - {file = "pytz-2023.3.tar.gz", hash = "sha256:1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588"}, -] - -[[package]] -name = "pyyaml" -version = "5.3.1" -description = "YAML parser and emitter for Python" -optional = false -python-versions = "*" -files = [ - {file = "PyYAML-5.3.1-cp27-cp27m-win32.whl", hash = "sha256:74809a57b329d6cc0fdccee6318f44b9b8649961fa73144a98735b0aaf029f1f"}, - {file = "PyYAML-5.3.1-cp27-cp27m-win_amd64.whl", hash = "sha256:240097ff019d7c70a4922b6869d8a86407758333f02203e0fc6ff79c5dcede76"}, - {file = "PyYAML-5.3.1-cp35-cp35m-win32.whl", hash = "sha256:4f4b913ca1a7319b33cfb1369e91e50354d6f07a135f3b901aca02aa95940bd2"}, - {file = "PyYAML-5.3.1-cp35-cp35m-win_amd64.whl", hash = "sha256:cc8955cfbfc7a115fa81d85284ee61147059a753344bc51098f3ccd69b0d7e0c"}, - {file = "PyYAML-5.3.1-cp36-cp36m-win32.whl", hash = "sha256:7739fc0fa8205b3ee8808aea45e968bc90082c10aef6ea95e855e10abf4a37b2"}, - {file = "PyYAML-5.3.1-cp36-cp36m-win_amd64.whl", hash = "sha256:69f00dca373f240f842b2931fb2c7e14ddbacd1397d57157a9b005a6a9942648"}, - {file = "PyYAML-5.3.1-cp37-cp37m-win32.whl", hash = "sha256:d13155f591e6fcc1ec3b30685d50bf0711574e2c0dfffd7644babf8b5102ca1a"}, - {file = "PyYAML-5.3.1-cp37-cp37m-win_amd64.whl", hash = "sha256:73f099454b799e05e5ab51423c7bcf361c58d3206fa7b0d555426b1f4d9a3eaf"}, - {file = "PyYAML-5.3.1-cp38-cp38-win32.whl", hash = "sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97"}, - {file = "PyYAML-5.3.1-cp38-cp38-win_amd64.whl", hash = "sha256:95f71d2af0ff4227885f7a6605c37fd53d3a106fcab511b8860ecca9fcf400ee"}, - {file = "PyYAML-5.3.1-cp39-cp39-win32.whl", hash = "sha256:ad9c67312c84def58f3c04504727ca879cb0013b2517c85a9a253f0cb6380c0a"}, - {file = "PyYAML-5.3.1-cp39-cp39-win_amd64.whl", hash = "sha256:6034f55dab5fea9e53f436aa68fa3ace2634918e8b5994d82f3621c04ff5ed2e"}, - {file = "PyYAML-5.3.1.tar.gz", hash = "sha256:b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d"}, -] - -[[package]] -name = "requests" -version = "2.31.0" -description = "Python HTTP for Humans." -optional = false -python-versions = ">=3.7" -files = [ - {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"}, - {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"}, -] - -[package.dependencies] -certifi = ">=2017.4.17" -charset-normalizer = ">=2,<4" -idna = ">=2.5,<4" -urllib3 = ">=1.21.1,<3" - -[package.extras] -socks = ["PySocks (>=1.5.6,!=1.5.7)"] -use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] - -[[package]] -name = "shrub-py" -version = "3.0.4" -description = "Library for creating evergreen configurations" -optional = false -python-versions = ">3.6.1" -files = [ - {file = "shrub.py-3.0.4-py3-none-any.whl", hash = "sha256:57d783e3cfe85573906c330a7612ade7eadca8b7c41006bdc75d0faf0b835300"}, - {file = "shrub.py-3.0.4.tar.gz", hash = "sha256:17890e04c4c05437708247b13d70a7d9a8c80de1b159e757889787eed3919b41"}, -] - -[package.dependencies] -git-url-parse = ">=1,<2" -pydantic = ">=1.8,<2.0" -PyYaml = ">=5.1,<6.0" -typing-extensions = ">=4,<5" - -[[package]] -name = "six" -version = "1.16.0" -description = "Python 2 and 3 compatibility utilities" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, -] - -[[package]] -name = "snowballstemmer" -version = "2.2.0" -description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." -optional = false -python-versions = "*" -files = [ - {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, - {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, -] - -[[package]] -name = "soupsieve" -version = "2.4.1" -description = "A modern CSS selector implementation for Beautiful Soup." -optional = false -python-versions = ">=3.7" -files = [ - {file = "soupsieve-2.4.1-py3-none-any.whl", hash = "sha256:1c1bfee6819544a3447586c889157365a27e10d88cde3ad3da0cf0ddf646feb8"}, - {file = "soupsieve-2.4.1.tar.gz", hash = "sha256:89d12b2d5dfcd2c9e8c22326da9d9aa9cb3dfab0a83a024f05704076ee8d35ea"}, -] - -[[package]] -name = "sphinx" -version = "7.1.1" -description = "Python documentation generator" -optional = false -python-versions = ">=3.8" -files = [ - {file = "sphinx-7.1.1-py3-none-any.whl", hash = "sha256:4e6c5ea477afa0fb90815210fd1312012e1d7542589ab251ac9b53b7c0751bce"}, - {file = "sphinx-7.1.1.tar.gz", hash = "sha256:59b8e391f0768a96cd233e8300fe7f0a8dc2f64f83dc2a54336a9a84f428ff4e"}, -] - -[package.dependencies] -alabaster = ">=0.7,<0.8" -babel = ">=2.9" -colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} -docutils = ">=0.18.1,<0.21" -imagesize = ">=1.3" -importlib-metadata = {version = ">=4.8", markers = "python_version < \"3.10\""} -Jinja2 = ">=3.0" -packaging = ">=21.0" -Pygments = ">=2.13" -requests = ">=2.25.0" -snowballstemmer = ">=2.0" -sphinxcontrib-applehelp = "*" -sphinxcontrib-devhelp = "*" -sphinxcontrib-htmlhelp = ">=2.0.0" -sphinxcontrib-jsmath = "*" -sphinxcontrib-qthelp = "*" -sphinxcontrib-serializinghtml = ">=1.1.5" - -[package.extras] -docs = ["sphinxcontrib-websupport"] -lint = ["docutils-stubs", "flake8 (>=3.5.0)", "flake8-simplify", "isort", "mypy (>=0.990)", "ruff", "sphinx-lint", "types-requests"] -test = ["cython", "filelock", "html5lib", "pytest (>=4.6)"] - -[[package]] -name = "sphinx-autobuild" -version = "2021.3.14" -description = "Rebuild Sphinx documentation on changes, with live-reload in the browser." -optional = false -python-versions = ">=3.6" -files = [ - {file = "sphinx-autobuild-2021.3.14.tar.gz", hash = "sha256:de1ca3b66e271d2b5b5140c35034c89e47f263f2cd5db302c9217065f7443f05"}, - {file = "sphinx_autobuild-2021.3.14-py3-none-any.whl", hash = "sha256:8fe8cbfdb75db04475232f05187c776f46f6e9e04cacf1e49ce81bdac649ccac"}, -] - -[package.dependencies] -colorama = "*" -livereload = "*" -sphinx = "*" - -[package.extras] -test = ["pytest", "pytest-cov"] - -[[package]] -name = "sphinx-basic-ng" -version = "1.0.0b2" -description = "A modern skeleton for Sphinx themes." -optional = false -python-versions = ">=3.7" -files = [ - {file = "sphinx_basic_ng-1.0.0b2-py3-none-any.whl", hash = "sha256:eb09aedbabfb650607e9b4b68c9d240b90b1e1be221d6ad71d61c52e29f7932b"}, - {file = "sphinx_basic_ng-1.0.0b2.tar.gz", hash = "sha256:9ec55a47c90c8c002b5960c57492ec3021f5193cb26cebc2dc4ea226848651c9"}, -] - -[package.dependencies] -sphinx = ">=4.0" - -[package.extras] -docs = ["furo", "ipython", "myst-parser", "sphinx-copybutton", "sphinx-inline-tabs"] - -[[package]] -name = "sphinx-design" -version = "0.5.0" -description = "A sphinx extension for designing beautiful, view size responsive web components." -optional = false -python-versions = ">=3.8" -files = [ - {file = "sphinx_design-0.5.0-py3-none-any.whl", hash = "sha256:1af1267b4cea2eedd6724614f19dcc88fe2e15aff65d06b2f6252cee9c4f4c1e"}, - {file = "sphinx_design-0.5.0.tar.gz", hash = "sha256:e8e513acea6f92d15c6de3b34e954458f245b8e761b45b63950f65373352ab00"}, -] - -[package.dependencies] -sphinx = ">=5,<8" - -[package.extras] -code-style = ["pre-commit (>=3,<4)"] -rtd = ["myst-parser (>=1,<3)"] -testing = ["myst-parser (>=1,<3)", "pytest (>=7.1,<8.0)", "pytest-cov", "pytest-regressions"] -theme-furo = ["furo (>=2023.7.0,<2023.8.0)"] -theme-pydata = ["pydata-sphinx-theme (>=0.13.0,<0.14.0)"] -theme-rtd = ["sphinx-rtd-theme (>=1.0,<2.0)"] -theme-sbt = ["sphinx-book-theme (>=1.0,<2.0)"] - -[[package]] -name = "sphinxcontrib-applehelp" -version = "1.0.4" -description = "sphinxcontrib-applehelp is a Sphinx extension which outputs Apple help books" -optional = false -python-versions = ">=3.8" -files = [ - {file = "sphinxcontrib-applehelp-1.0.4.tar.gz", hash = "sha256:828f867945bbe39817c210a1abfd1bc4895c8b73fcaade56d45357a348a07d7e"}, - {file = "sphinxcontrib_applehelp-1.0.4-py3-none-any.whl", hash = "sha256:29d341f67fb0f6f586b23ad80e072c8e6ad0b48417db2bde114a4c9746feb228"}, -] - -[package.extras] -lint = ["docutils-stubs", "flake8", "mypy"] -test = ["pytest"] - -[[package]] -name = "sphinxcontrib-devhelp" -version = "1.0.2" -description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp document." -optional = false -python-versions = ">=3.5" -files = [ - {file = "sphinxcontrib-devhelp-1.0.2.tar.gz", hash = "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4"}, - {file = "sphinxcontrib_devhelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e"}, -] - -[package.extras] -lint = ["docutils-stubs", "flake8", "mypy"] -test = ["pytest"] - -[[package]] -name = "sphinxcontrib-htmlhelp" -version = "2.0.1" -description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files" -optional = false -python-versions = ">=3.8" -files = [ - {file = "sphinxcontrib-htmlhelp-2.0.1.tar.gz", hash = "sha256:0cbdd302815330058422b98a113195c9249825d681e18f11e8b1f78a2f11efff"}, - {file = "sphinxcontrib_htmlhelp-2.0.1-py3-none-any.whl", hash = "sha256:c38cb46dccf316c79de6e5515e1770414b797162b23cd3d06e67020e1d2a6903"}, -] - -[package.extras] -lint = ["docutils-stubs", "flake8", "mypy"] -test = ["html5lib", "pytest"] - -[[package]] -name = "sphinxcontrib-jsmath" -version = "1.0.1" -description = "A sphinx extension which renders display math in HTML via JavaScript" -optional = false -python-versions = ">=3.5" -files = [ - {file = "sphinxcontrib-jsmath-1.0.1.tar.gz", hash = "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8"}, - {file = "sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl", hash = "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178"}, -] - -[package.extras] -test = ["flake8", "mypy", "pytest"] - -[[package]] -name = "sphinxcontrib-qthelp" -version = "1.0.3" -description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp document." -optional = false -python-versions = ">=3.5" -files = [ - {file = "sphinxcontrib-qthelp-1.0.3.tar.gz", hash = "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72"}, - {file = "sphinxcontrib_qthelp-1.0.3-py2.py3-none-any.whl", hash = "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6"}, -] - -[package.extras] -lint = ["docutils-stubs", "flake8", "mypy"] -test = ["pytest"] - -[[package]] -name = "sphinxcontrib-serializinghtml" -version = "1.1.5" -description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)." -optional = false -python-versions = ">=3.5" -files = [ - {file = "sphinxcontrib-serializinghtml-1.1.5.tar.gz", hash = "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952"}, - {file = "sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl", hash = "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd"}, -] - -[package.extras] -lint = ["docutils-stubs", "flake8", "mypy"] -test = ["pytest"] - -[[package]] -name = "tornado" -version = "6.3.2" -description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed." -optional = false -python-versions = ">= 3.8" -files = [ - {file = "tornado-6.3.2-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:c367ab6c0393d71171123ca5515c61ff62fe09024fa6bf299cd1339dc9456829"}, - {file = "tornado-6.3.2-cp38-abi3-macosx_10_9_x86_64.whl", hash = "sha256:b46a6ab20f5c7c1cb949c72c1994a4585d2eaa0be4853f50a03b5031e964fc7c"}, - {file = "tornado-6.3.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c2de14066c4a38b4ecbbcd55c5cc4b5340eb04f1c5e81da7451ef555859c833f"}, - {file = "tornado-6.3.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:05615096845cf50a895026f749195bf0b10b8909f9be672f50b0fe69cba368e4"}, - {file = "tornado-6.3.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5b17b1cf5f8354efa3d37c6e28fdfd9c1c1e5122f2cb56dac121ac61baa47cbe"}, - {file = "tornado-6.3.2-cp38-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:29e71c847a35f6e10ca3b5c2990a52ce38b233019d8e858b755ea6ce4dcdd19d"}, - {file = "tornado-6.3.2-cp38-abi3-musllinux_1_1_i686.whl", hash = "sha256:834ae7540ad3a83199a8da8f9f2d383e3c3d5130a328889e4cc991acc81e87a0"}, - {file = "tornado-6.3.2-cp38-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:6a0848f1aea0d196a7c4f6772197cbe2abc4266f836b0aac76947872cd29b411"}, - {file = "tornado-6.3.2-cp38-abi3-win32.whl", hash = "sha256:7efcbcc30b7c654eb6a8c9c9da787a851c18f8ccd4a5a3a95b05c7accfa068d2"}, - {file = "tornado-6.3.2-cp38-abi3-win_amd64.whl", hash = "sha256:0c325e66c8123c606eea33084976c832aa4e766b7dff8aedd7587ea44a604cdf"}, - {file = "tornado-6.3.2.tar.gz", hash = "sha256:4b927c4f19b71e627b13f3db2324e4ae660527143f9e1f2e2fb404f3a187e2ba"}, -] - -[[package]] -name = "types-docutils" -version = "0.20.0.1" -description = "Typing stubs for docutils" -optional = false -python-versions = "*" -files = [ - {file = "types-docutils-0.20.0.1.tar.gz", hash = "sha256:f682b5459a1e6e28208742adb0be8573d1ecbddd442f00d202b0278c1c4418a2"}, - {file = "types_docutils-0.20.0.1-py3-none-any.whl", hash = "sha256:6b17cbe57cb282158feb41d154cddaeabc16f1d6cff3c7308bd3056f42aa7cd2"}, -] - -[[package]] -name = "typing-extensions" -version = "4.5.0" -description = "Backported and Experimental Type Hints for Python 3.7+" -optional = false -python-versions = ">=3.7" -files = [ - {file = "typing_extensions-4.5.0-py3-none-any.whl", hash = "sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4"}, - {file = "typing_extensions-4.5.0.tar.gz", hash = "sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb"}, -] - -[[package]] -name = "urllib3" -version = "2.0.2" -description = "HTTP library with thread-safe connection pooling, file post, and more." -optional = false -python-versions = ">=3.7" -files = [ - {file = "urllib3-2.0.2-py3-none-any.whl", hash = "sha256:d055c2f9d38dc53c808f6fdc8eab7360b6fdbbde02340ed25cfbcd817c62469e"}, - {file = "urllib3-2.0.2.tar.gz", hash = "sha256:61717a1095d7e155cdb737ac7bb2f4324a858a1e2e6466f6d03ff630ca68d3cc"}, -] - -[package.extras] -brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] -secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17.1.0)", "urllib3-secure-extra"] -socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] -zstd = ["zstandard (>=0.18.0)"] - -[[package]] -name = "yamlordereddictloader" -version = "0.4.0" -description = "YAML loader and dump for PyYAML allowing to keep keys order." -optional = false -python-versions = "*" -files = [ - {file = "yamlordereddictloader-0.4.0.tar.gz", hash = "sha256:7f30f0b99ea3f877f7cb340c570921fa9d639b7f69cba18be051e27f8de2080e"}, -] - -[package.dependencies] -pyyaml = "*" - -[[package]] -name = "zipp" -version = "3.16.2" -description = "Backport of pathlib-compatible object wrapper for zip files" -optional = false -python-versions = ">=3.8" -files = [ - {file = "zipp-3.16.2-py3-none-any.whl", hash = "sha256:679e51dd4403591b2d6838a48de3d283f3d188412a9782faadf845f298736ba0"}, - {file = "zipp-3.16.2.tar.gz", hash = "sha256:ebc15946aa78bd63458992fc81ec3b6f7b1e92d51c35e6de1c3804e73b799147"}, -] - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] - -[metadata] -lock-version = "2.0" -python-versions = "^3.8" -content-hash = "988ecd1a64ead7772507ce3b2b42abd56d088d0752babb8458b3f7de67594e48" diff --git a/3rdparty/mongo-c-driver-1.26.2/pyproject.toml b/3rdparty/mongo-c-driver-1.26.2/pyproject.toml deleted file mode 100644 index 9a5fa5ad2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/pyproject.toml +++ /dev/null @@ -1,41 +0,0 @@ -[tool.poetry] -name = "mongo-c-driver" -version = "0.0.0" -description = "A Python project for mongo-c-driver codebase development" -authors = [] -packages = [ - { include = "config_generator", from = ".evergreen/" } -] - -[tool.poetry.dependencies] -python = "^3.8" - -[tool.poetry.scripts] -"mc-evg-generate" = "config_generator.generate:main" - -[tool.poetry.group.docs] -optional = true - -[tool.poetry.group.docs.dependencies] -sphinx = "^7.1.1" -furo = "^2023.5.20" -sphinx-design = "^0.5.0" - -[tool.poetry.group.dev] -optional = true - -[tool.poetry.group.dev.dependencies] -clang-format = "16" -sphinx-autobuild = "^2021.3.14" -shrub-py = "3.0.4" -yamlordereddictloader = "^0.4.0" -types-docutils = "^0.20.0.1" - -# XXX: These dependencies are only to force certain versions of transitive requirements, -# but are not required otherwise. -[tool.poetry.group.ext.dependencies] -pyyaml = "<5.4" - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" diff --git a/3rdparty/mongo-c-driver-1.26.2/src/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/CMakeLists.txt deleted file mode 100644 index 56f4596df..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# sub-directory 'libbson' was already included at the top-level -# sub-directory 'libmongoc' was already included at the top-level -# sub-directory 'kms-message' was already included at the top-level - -# Copy zconf.h.in to zconf.h, used by zlib -configure_file ( - "${SOURCE_DIR}/src/zlib-1.2.13/zconf.h.in" - "${CMAKE_BINARY_DIR}/src/zlib-1.2.13/zconf.h" - COPYONLY -) - -if (CMAKE_CXX_COMPILER) - # Add a C++ source file that will #include the main C headers. This "library" - # does nothing other than validate that the C headers are valid C++ headers. - add_library (mongoc-cxx-check STATIC cpp-check.cpp) - if (TARGET mongoc_static) - target_link_libraries (mongoc-cxx-check PRIVATE mongoc_static) - else () - target_link_libraries (mongoc-cxx-check PRIVATE mongoc_shared) - endif () -endif () diff --git a/3rdparty/mongo-c-driver-1.26.2/src/common/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/common/CMakeLists.txt deleted file mode 100644 index 81c61c5bb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/common/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ - -set (MONGOC_ENABLE_DEBUG_ASSERTIONS 0) - -if (ENABLE_DEBUG_ASSERTIONS) - set (MONGOC_ENABLE_DEBUG_ASSERTIONS 1) -endif () - -include (MongoC-Warnings) - -configure_file ( - "${PROJECT_SOURCE_DIR}/src/common/common-config.h.in" - "${PROJECT_BINARY_DIR}/src/common/common-config.h" -) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/common/bson-dsl.h b/3rdparty/mongo-c-driver-1.26.2/src/common/bson-dsl.h deleted file mode 100644 index 84d757008..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/common/bson-dsl.h +++ /dev/null @@ -1,1386 +0,0 @@ -#include "common-prelude.h" - -#ifndef BSON_BSON_DSL_H_INCLUDED -#define BSON_BSON_DSL_H_INCLUDED - -/** - * @file bson-dsl.h - * @brief Define a C-preprocessor DSL for working with BSON objects - * - * This file defines an embedded DSL for working with BSON objects consisely and - * correctly. - * - * For more information about using this DSL, refer to `bson-dsl.md`. - */ - -#include "bson/bson.h" - -enum { - /// Toggle this value to enable/disable debug output for all bsonDSL - /// operations (printed to stderr). You can also set a constant - /// BSON_DSL_DEBUG within the scope of a DSL command to selectively debug - /// only the commands within that scope. - BSON_DSL_DEBUG = 0 -}; - -#define _bson_thread_local \ - BSON_IF_GNU_LIKE (__thread) BSON_IF_MSVC (__declspec (thread)) - -#define _bson_comdat \ - BSON_IF_WINDOWS (__declspec (selectany)) \ - BSON_IF_POSIX (__attribute__ ((weak))) - -#ifdef __GNUC__ -// GCC has a bug handling pragma statements that disable warnings within complex -// nested macro expansions. If we're GCC, just disable -Wshadow outright: -BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\"")) -#endif - -#define _bsonDSL_disableWarnings() \ - if (1) { \ - BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic push");) \ - BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\"");) \ - } else \ - ((void) 0) - -#define _bsonDSL_restoreWarnings() \ - if (1) { \ - BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic pop");) \ - } else \ - ((void) 0) - -/** - * @brief Parse the given BSON document. - * - * @param doc A bson_t object to walk. (Not a pointer) - */ -#define bsonParse(Document, ...) \ - _bsonDSL_begin ("bsonParse(%s)", _bsonDSL_str (Document)); \ - _bsonDSL_disableWarnings (); \ - bsonParseError = NULL; \ - BSON_MAYBE_UNUSED bool _bvHalt = false; \ - BSON_MAYBE_UNUSED const bool _bvContinue = false; \ - BSON_MAYBE_UNUSED const bool _bvBreak = false; \ - _bsonDSL_eval (_bsonParse ((Document), __VA_ARGS__)); \ - _bsonDSL_restoreWarnings (); \ - _bsonDSL_end - -/** - * @brief Visit each element of a BSON document - */ -#define bsonVisitEach(Document, ...) \ - _bsonDSL_begin ("bsonVisitEach(%s)", _bsonDSL_str (Document)); \ - _bsonDSL_disableWarnings (); \ - BSON_MAYBE_UNUSED bool _bvHalt = false; \ - _bsonDSL_eval (_bsonVisitEach ((Document), __VA_ARGS__)); \ - _bsonDSL_restoreWarnings (); \ - _bsonDSL_end - -#define bsonBuildContext (*_bsonBuildContextThreadLocalPtr) -#define bsonVisitContext (*_bsonVisitContextThreadLocalPtr) -#define bsonVisitIter (bsonVisitContext.iter) - -/// Begin any function-like macro by opening a new scope and writing a debug -/// message. -#define _bsonDSL_begin(Str, ...) \ - if (true) { \ - _bsonDSLDebug (Str, __VA_ARGS__); \ - ++_bson_dsl_indent - -/// End a function-like macro scope. -#define _bsonDSL_end \ - --_bson_dsl_indent; \ - } \ - else ((void) 0) - -/** - * @brief Expands to a call to bson_append_{Kind}, with the three first - * arguments filled in by the DSL context variables. - */ -#define _bsonBuildAppendArgs \ - bsonBuildContext.doc, bsonBuildContext.key, bsonBuildContext.key_len - -/** - * The _bsonDocOperation_XYZ macros handle the top-level bsonBuild() - * items, and any nested doc() items, with XYZ being the doc-building - * subcommand. - */ -#define _bsonDocOperation(Command, _ignore, _count) \ - if (!bsonBuildError) { \ - _bsonDocOperation_##Command; \ - if (bsonBuildError) { \ - _bsonDSLDebug ("Stopping doc() due to bsonBuildError: [%s]", \ - bsonBuildError); \ - } \ - } - -#define _bsonValueOperation(P) _bsonValueOperation_##P - -/// key-value pair with explicit key length -#define _bsonDocOperation_kvl(String, Len, Element) \ - _bsonDSL_begin ("\"%s\" => [%s]", String, _bsonDSL_strElide (30, Element)); \ - const char *_bbString = (String); \ - const uint64_t length = (Len); \ - if (bson_in_range_unsigned (int, length)) { \ - _bbCtx.key = _bbString; \ - _bbCtx.key_len = (int) length; \ - _bsonValueOperation (Element); \ - } else { \ - bsonBuildError = "Out-of-range key string length value"; \ - } \ - _bsonDSL_end - -/// Key-value pair with a C-string -#define _bsonDocOperation_kv(String, Element) \ - _bsonDocOperation_kvl ((String), strlen ((String)), Element) - -/// Execute arbitrary code -#define _bsonDocOperation_do(...) \ - _bsonDSL_begin ("do(%s)", _bsonDSL_strElide (30, __VA_ARGS__)); \ - do { \ - __VA_ARGS__; \ - } while (0); \ - if (bsonBuildError) { \ - _bsonDSLDebug ("do() set bsonBuildError: [%s]", bsonBuildError); \ - } \ - _bsonDSL_end - -/// We must defer expansion of the nested doc() to allow "recursive" evaluation -#define _bsonValueOperation_doc \ - _bsonValueOperationDeferred_doc _bsonDSL_nothing () -#define _bsonArrayOperation_doc(...) _bsonArrayAppendValue (doc (__VA_ARGS__)) - -#define _bsonValueOperationDeferred_doc(...) \ - _bsonDSL_begin ("doc(%s)", _bsonDSL_strElide (30, __VA_ARGS__)); \ - /* Write to this variable as the child: */ \ - bson_t _bbChildDoc = BSON_INITIALIZER; \ - if (!bson_append_document_begin (_bsonBuildAppendArgs, &_bbChildDoc)) { \ - bsonBuildError = \ - "Error while initializing child document: " _bsonDSL_str ( \ - __VA_ARGS__); \ - } else { \ - _bsonBuildAppend (_bbChildDoc, __VA_ARGS__); \ - if (!bsonBuildError) { \ - if (!bson_append_document_end (bsonBuildContext.doc, &_bbChildDoc)) { \ - bsonBuildError = \ - "Error while finalizing document: " _bsonDSL_str (__VA_ARGS__); \ - } \ - } \ - } \ - _bsonDSL_end - -/// We must defer expansion of the nested array() to allow "recursive" -/// evaluation -#define _bsonValueOperation_array \ - _bsonValueOperationDeferred_array _bsonDSL_nothing () -#define _bsonArrayOperation_array(...) \ - _bsonArrayAppendValue (array (__VA_ARGS__)) - -#define _bsonValueOperationDeferred_array(...) \ - _bsonDSL_begin ("array(%s)", _bsonDSL_strElide (30, __VA_ARGS__)); \ - /* Write to this variable as the child array: */ \ - bson_t _bbArray = BSON_INITIALIZER; \ - if (!bson_append_array_begin (_bsonBuildAppendArgs, &_bbArray)) { \ - bsonBuildError = \ - "Error while initializing child array: " _bsonDSL_str (__VA_ARGS__); \ - } else { \ - _bsonBuildArray (_bbArray, __VA_ARGS__); \ - if (!bsonBuildError) { \ - if (!bson_append_array_end (bsonBuildContext.doc, &_bbArray)) { \ - bsonBuildError = \ - "Error while finalizing child array: " _bsonDSL_str ( \ - __VA_ARGS__); \ - } \ - } else { \ - _bsonDSLDebug ("Got bsonBuildError: [%s]", bsonBuildError); \ - } \ - } \ - _bsonDSL_end - -/// Append a UTF-8 string with an explicit length -#define _bsonValueOperation_utf8_w_len(String, Len) \ - if (!bson_append_utf8 (_bsonBuildAppendArgs, (String), (int) (Len))) { \ - bsonBuildError = \ - "Error while appending utf8 string: " _bsonDSL_str (String); \ - } else \ - ((void) 0) -#define _bsonArrayOperation_utf8_w_len(X) _bsonArrayAppendValue (utf8_w_len (X)) - -/// Append a "cstr" as UTF-8 -#define _bsonValueOperation_cstr(String) \ - _bsonValueOperation_utf8_w_len ((String), strlen (String)) -#define _bsonArrayOperation_cstr(X) _bsonArrayAppendValue (cstr (X)) - -/// Append an int32 -#define _bsonValueOperation_int32(Integer) \ - if (!bson_append_int32 (_bsonBuildAppendArgs, (Integer))) { \ - bsonBuildError = \ - "Error while appending int32(" _bsonDSL_str (Integer) ")"; \ - } else \ - ((void) 0) -#define _bsonArrayOperation_int32(X) _bsonArrayAppendValue (int32 (X)) - -/// Append an int64 -#define _bsonValueOperation_int64(Integer) \ - if (!bson_append_int64 (_bsonBuildAppendArgs, (Integer))) { \ - bsonBuildError = \ - "Error while appending int64(" _bsonDSL_str (Integer) ")"; \ - } else \ - ((void) 0) -#define _bsonArrayOperation_int64(X) _bsonArrayAppendValue (int64 (X)) - -/// Append the value referenced by a given iterator -#define _bsonValueOperation_iterValue(Iter) \ - if (!bson_append_iter (_bsonBuildAppendArgs, &(Iter))) { \ - bsonBuildError = \ - "Error while appending iterValue(" _bsonDSL_str (Iter) ")"; \ - } else \ - ((void) 0) -#define _bsonArrayOperation_iterValue(X) _bsonArrayAppendValue (iterValue (X)) - -/// Append the BSON document referenced by the given pointer -#define _bsonValueOperation_bson(Doc) \ - if (!bson_append_document (_bsonBuildAppendArgs, &(Doc))) { \ - bsonBuildError = \ - "Error while appending subdocument: bson(" _bsonDSL_str (Doc) ")"; \ - } else \ - ((void) 0) -#define _bsonArrayOperation_bson(X) _bsonArrayAppendValue (bson (X)) - -/// Append the BSON document referenced by the given pointer as an array -#define _bsonValueOperation_bsonArray(Arr) \ - if (!bson_append_array (_bsonBuildAppendArgs, &(Arr))) { \ - bsonBuildError = "Error while appending subdocument array: " \ - "bsonArray(" _bsonDSL_str (Arr) ")"; \ - } else \ - ((void) 0) -#define _bsonArrayOperation_bsonArray(X) _bsonArrayAppendValue (bsonArray (X)) - -#define _bsonValueOperation_bool(b) \ - if (!bson_append_bool (_bsonBuildAppendArgs, (b))) { \ - bsonBuildError = "Error while appending bool(" _bsonDSL_str (b) ")"; \ - } else \ - ((void) 0) -#define _bsonArrayOperation_bool(X) _bsonArrayAppendValue (bool (X)) -#define _bsonValueOperation__Bool(b) _bsonValueOperation_bool (b) -#define _bsonArrayOperation__Bool(X) _bsonArrayAppendValue (_Bool (X)) - -#define _bsonValueOperation_null \ - if (!bson_append_null (_bsonBuildAppendArgs)) { \ - bsonBuildError = "Error while appending a null"; \ - } else \ - ((void) 0) -#define _bsonArrayOperation_null _bsonValueOperation (null) - -#define _bsonArrayOperation_value(X) _bsonArrayAppendValue (value (X)) - -#define _bsonValueOperation_value(Value) \ - _bsonDSL_begin ("value(%s)", _bsonDSL_str (Value)); \ - if (!bson_append_value (_bsonBuildAppendArgs, &(Value))) { \ - bsonBuildError = \ - "Error while appending value(" _bsonDSL_str (Value) ")"; \ - } \ - _bsonDSL_end - -/// Insert the given BSON document into the parent document in-place -#define _bsonDocOperation_insert(OtherBSON, Pred) \ - _bsonDSL_begin ("Insert other document: [%s]", _bsonDSL_str (OtherBSON)); \ - const bool _bvHalt = false; /* Required for _bsonVisitEach() */ \ - _bsonVisitEach ( \ - OtherBSON, \ - if (Pred, then (do (_bsonDocOperation_iterElement (bsonVisitIter))))); \ - _bsonDSL_end - -#define _bsonDocOperation_insertFromIter(Iter, Pred) \ - _bsonDSL_begin ("Insert document from iterator: [%s]", \ - _bsonDSL_str (Iter)); \ - bson_t _bbDocFromIter = _bson_dsl_iter_as_doc (&(Iter)); \ - if (_bbDocFromIter.len == 0) { \ - _bsonDSLDebug ( \ - "NOTE: Skipping insert of non-document value from iterator"); \ - } else { \ - _bsonDocOperation_insert (_bbDocFromIter, Pred); \ - } \ - _bsonDSL_end - -#define _bsonDocOperation_iterElement(Iter) \ - _bsonDSL_begin ("Insert element from bson_iter_t [%s]", \ - _bsonDSL_str (Iter)); \ - bson_iter_t _bbIter = (Iter); \ - _bsonDocOperation_kvl (bson_iter_key (&_bbIter), \ - bson_iter_key_len (&_bbIter), \ - iterValue (_bbIter)); \ - _bsonDSL_end - -/// Insert the given BSON document into the parent array. Keys of the given -/// document are discarded and it is treated as an array of values. -#define _bsonArrayOperation_insert(OtherArr, Pred) \ - _bsonDSL_begin ("Insert other array: [%s]", _bsonDSL_str (OtherArr)); \ - _bsonVisitEach ( \ - OtherArr, \ - if (Pred, then (do (_bsonArrayOperation_iterValue (bsonVisitIter))))); \ - _bsonDSL_end - -#define _bsonArrayAppendValue(ValueOperation) \ - _bsonDSL_begin ("[%d] => [%s]", \ - (int) bsonBuildContext.index, \ - _bsonDSL_strElide (30, ValueOperation)); \ - /* Set the doc key to the array index as a string: */ \ - _bsonBuild_setKeyToArrayIndex (bsonBuildContext.index); \ - /* Append a value: */ \ - _bsonValueOperation_##ValueOperation; \ - /* Increment the array index: */ \ - ++_bbCtx.index; \ - _bsonDSL_end - - -#define _bsonDocOperationIfThen_then _bsonBuildAppendWithCurrentContext -#define _bsonDocOperationIfElse_else _bsonBuildAppendWithCurrentContext - -#define _bsonDocOperationIfThenElse(Condition, Then, Else) \ - if ((Condition)) { \ - _bsonDSLDebug ("Taking TRUE branch: [%s]", _bsonDSL_str (Then)); \ - _bsonDocOperationIfThen_##Then; \ - } else { \ - _bsonDSLDebug ("Taking FALSE branch: [%s]", _bsonDSL_str (Else)); \ - _bsonDocOperationIfElse_##Else; \ - } - -#define _bsonDocOperationIfThen(Condition, Then) \ - if ((Condition)) { \ - _bsonDSLDebug ("Taking TRUE branch: [%s]", _bsonDSL_str (Then)); \ - _bsonDocOperationIfThen_##Then; \ - } - -#define _bsonDocOperation_if(Condition, ...) \ - _bsonDSL_begin ("Conditional append on [%s]", _bsonDSL_str (Condition)); \ - /* Pick a sub-macro depending on if there are one or two args */ \ - _bsonDSL_ifElse (_bsonDSL_hasComma (__VA_ARGS__), \ - _bsonDocOperationIfThenElse, \ - _bsonDocOperationIfThen) (Condition, __VA_ARGS__); \ - _bsonDSL_end - -#define _bsonArrayOperationIfThen_then _bsonBuildArrayWithCurrentContext -#define _bsonArrayOperationIfElse_else _bsonBuildArrayWithCurrentContext - -#define _bsonArrayOperationIfThenElse(Condition, Then, Else) \ - if ((Condition)) { \ - _bsonDSLDebug ("Taking TRUE branch: [%s]", _bsonDSL_str (Then)); \ - _bsonArrayOperationIfThen_##Then; \ - } else { \ - _bsonDSLDebug ("Taking FALSE branch: [%s]", _bsonDSL_str (Else)); \ - _bsonArrayOperationIfElse_##Else; \ - } - -#define _bsonArrayOperationIfThen(Condition, Then) \ - if ((Condition)) { \ - _bsonDSLDebug ("Taking TRUE branch: [%s]", _bsonDSL_str (Then)); \ - _bsonArrayOperationIfThen_##Then; \ - } - -#define _bsonArrayOperation_if(Condition, ...) \ - _bsonDSL_begin ("Conditional value on [%s]", _bsonDSL_str (Condition)); \ - /* Pick a sub-macro depending on if there are one or two args */ \ - _bsonDSL_ifElse (_bsonDSL_hasComma (__VA_ARGS__), \ - _bsonArrayOperationIfThenElse, \ - _bsonArrayOperationIfThen) (Condition, __VA_ARGS__); \ - _bsonDSL_end - -#define _bsonValueOperationIf_then(X) _bsonValueOperation_##X -#define _bsonValueOperationIf_else(X) _bsonValueOperation_##X - -#define _bsonValueOperation_if(Condition, Then, Else) \ - if ((Condition)) { \ - _bsonDSLDebug ("Taking TRUE branch: [%s]", _bsonDSL_str (Then)); \ - _bsonValueOperationIf_##Then; \ - } else { \ - _bsonDSLDebug ("Taking FALSE branch: [%s]", _bsonDSL_str (Else)); \ - _bsonValueOperationIf_##Else; \ - } - -#define _bsonBuild_setKeyToArrayIndex(Idx) \ - _bbCtx.key_len = bson_snprintf (_bbCtx.index_key_str, \ - sizeof _bbCtx.index_key_str, \ - "%d", \ - (int) _bbCtx.index); \ - _bbCtx.key = _bbCtx.index_key_str - -/// Handle an element of array() -#define _bsonArrayOperation(Element, _nil, _count) \ - if (!bsonBuildError) { \ - _bsonArrayOperation_##Element; \ - } - -#define _bsonBuildAppendWithCurrentContext(...) \ - _bsonDSL_mapMacro (_bsonDocOperation, ~, __VA_ARGS__) - -#define _bsonBuildArrayWithCurrentContext(...) \ - _bsonDSL_mapMacro (_bsonArrayOperation, ~, __VA_ARGS__) - -#define _bsonDSL_Type_double BSON_TYPE_DOUBLE -#define _bsonDSL_Type_utf8 BSON_TYPE_UTF8 -#define _bsonDSL_Type_doc BSON_TYPE_DOCUMENT -#define _bsonDSL_Type_array BSON_TYPE_ARRAY -#define _bsonDSL_Type_binary BSON_TYPE_BINARY -#define _bsonDSL_Type_undefined BSON_TYPE_UNDEFINED -#define _bsonDSL_Type_oid BSON_TYPE_OID -#define _bsonDSL_Type_bool BSON_TYPE_BOOL -// ("bool" may be spelled _Bool due to macro expansion:) -#define _bsonDSL_Type__Bool BSON_TYPE_BOOL -#define _bsonDSL_Type_date_time BSON_TYPE_DATE_TIME -#define _bsonDSL_Type_null BSON_TYPE_NULL -#define _bsonDSL_Type_regex BSON_TYPE_REGEX -#define _bsonDSL_Type_dbpointer BSON_TYPE_DBPOINTER -#define _bsonDSL_Type_code BSON_TYPE_CODE -#define _bsonDSL_Type_codewscope BSON_TYPE_CODEWSCOPE -#define _bsonDSL_Type_int32 BSON_TYPE_INT32 -#define _bsonDSL_Type_timestamp BSON_TYPE_TIMESTAMP -#define _bsonDSL_Type_int64 BSON_TYPE_INT64 -#define _bsonDSL_Type_decimal128 BSON_TYPE_DECIMAL128 - -#define _bsonDSL_Type_string __NOTE__No_type_named__string__did_you_mean__utf8 - -#define _bsonVisitOperation_halt _bvHalt = true - -#define _bsonVisitOperation_if(Predicate, ...) \ - _bsonDSL_begin ("if(%s)", _bsonDSL_str (Predicate)); \ - _bsonDSL_ifElse (_bsonDSL_hasComma (__VA_ARGS__), \ - _bsonVisit_ifThenElse, \ - _bsonVisit_ifThen) (Predicate, __VA_ARGS__); \ - _bsonDSL_end - -#define _bsonVisit_ifThenElse(Predicate, Then, Else) \ - if (bsonPredicate (Predicate)) { \ - _bsonDSLDebug ("then:"); \ - _bsonVisit_ifThen_##Then; \ - } else { \ - _bsonDSLDebug ("else:"); \ - _bsonVisit_ifElse_##Else; \ - } - -#define _bsonVisit_ifThen(Predicate, Then) \ - if (bsonPredicate (Predicate)) { \ - _bsonDSLDebug ("then:"); \ - _bsonVisit_ifThen_##Then; \ - } else { \ - _bsonDSLDebug ("[else nothing]"); \ - } - -#define _bsonVisit_ifThen_then _bsonVisit_applyOps -#define _bsonVisit_ifElse_else _bsonVisit_applyOps - -#define _bsonVisitOperation_storeBool(Dest) \ - _bsonDSL_begin ("storeBool(%s)", _bsonDSL_str (Dest)); \ - (Dest) = bson_iter_as_bool (&bsonVisitIter); \ - _bsonDSL_end - -#define _bsonVisitOperation_storeStrRef(Dest) \ - _bsonDSL_begin ("storeStrRef(%s)", _bsonDSL_str (Dest)); \ - (Dest) = bson_iter_utf8 (&bsonVisitIter, NULL); \ - _bsonDSL_end - -#define _bsonVisitOperation_storeStrDup(Dest) \ - _bsonDSL_begin ("storeStrDup(%s)", _bsonDSL_str (Dest)); \ - (Dest) = bson_iter_dup_utf8 (&bsonVisitIter, NULL); \ - _bsonDSL_end - -#define _bsonVisitOperation_storeDocDup(Dest) \ - _bsonDSL_begin ("storeDocDup(%s)", _bsonDSL_str (Dest)); \ - bson_t _bvDoc = BSON_INITIALIZER; \ - _bson_dsl_iter_as_doc (&_bvDoc, &bsonVisitIter); \ - if (_bvDoc.len) { \ - bson_copy_to (&_bvDoc, &(Dest)); \ - } \ - _bsonDSL_end - -#define _bsonVisitOperation_storeDocRef(Dest) \ - _bsonDSL_begin ("storeDocRef(%s)", _bsonDSL_str (Dest)); \ - _bson_dsl_iter_as_doc (&(Dest), &bsonVisitIter); \ - _bsonDSL_end - -#define _bsonVisitOperation_storeDocDupPtr(Dest) \ - _bsonDSL_begin ("storeDocDupPtr(%s)", _bsonDSL_str (Dest)); \ - bson_t _bvDoc = BSON_INITIALIZER; \ - _bson_dsl_iter_as_doc (&_bvDoc, &bsonVisitIter); \ - if (_bvDoc.len) { \ - (Dest) = bson_copy (&_bvDoc); \ - } \ - _bsonDSL_end - -#define _bsonVisitOperation_storeInt32(Dest) \ - _bsonDSL_begin ("storeInt32(%s)", _bsonDSL_str (Dest)); \ - (Dest) = bson_iter_int32 (&bsonVisitIter); \ - _bsonDSL_end - -#define _bsonVisitOperation_do(...) \ - _bsonDSL_begin ("do: %s", _bsonDSL_strElide (30, __VA_ARGS__)); \ - do { \ - __VA_ARGS__; \ - } while (0); \ - _bsonDSL_end - -#define _bsonVisitOperation_appendTo(BSON) \ - _bsonDSL_begin ("appendTo(%s)", _bsonDSL_str (BSON)); \ - if (!bson_append_iter (&(BSON), \ - bson_iter_key (&bsonVisitIter), \ - (int) bson_iter_key_len (&bsonVisitIter), \ - &bsonVisitIter)) { \ - bsonParseError = "Error in appendTo(" _bsonDSL_str (BSON) ")"; \ - } \ - _bsonDSL_end - -#define _bsonVisitCase_when(Pred, ...) \ - _bsonDSL_begin ("when: [%s]", _bsonDSL_str (Pred)); \ - _bvCaseMatched = _bsonPredicate (Pred); \ - if (_bvCaseMatched) { \ - _bsonVisit_applyOps (__VA_ARGS__); \ - } \ - _bsonDSL_end - -#define _bsonVisitCase_else(...) \ - _bsonDSL_begin ("else:%s", ""); \ - _bvCaseMatched = true; \ - _bsonVisit_applyOps (__VA_ARGS__); \ - _bsonDSL_end - -#define _bsonVisitCase(Pair, _nil, _count) \ - if (!_bvCaseMatched) { \ - _bsonVisitCase_##Pair; \ - } else \ - ((void) 0); - -#define _bsonVisitOperation_case(...) \ - _bsonDSL_begin ("case:%s", ""); \ - BSON_MAYBE_UNUSED bool _bvCaseMatched = false; \ - _bsonDSL_mapMacro (_bsonVisitCase, ~, __VA_ARGS__); \ - _bsonDSL_end - -#define _bsonVisitOperation_append \ - _bsonVisitOneApplyDeferred_append _bsonDSL_nothing () -#define _bsonVisitOneApplyDeferred_append(Doc, ...) \ - _bsonDSL_begin ("append to [%s] : %s", \ - _bsonDSL_str (Doc), \ - _bsonDSL_strElide (30, __VA_ARGS__)); \ - _bsonBuildAppend (Doc, __VA_ARGS__); \ - if (bsonBuildError) { \ - bsonParseError = bsonBuildError; \ - } \ - _bsonDSL_end - -#define _bsonVisitEach(Doc, ...) \ - _bsonDSL_begin ("visitEach(%s)", _bsonDSL_str (Doc)); \ - do { \ - /* Reset the context */ \ - struct _bsonVisitContext_t _bvCtx = { \ - .doc = &(Doc), \ - .parent = _bsonVisitContextThreadLocalPtr, \ - .index = 0, \ - }; \ - _bsonVisitContextThreadLocalPtr = &_bvCtx; \ - bsonParseError = NULL; \ - /* Iterate over each element of the document */ \ - if (!bson_iter_init (&_bvCtx.iter, &(Doc))) { \ - bsonParseError = "Invalid BSON data [a]"; \ - } \ - BSON_MAYBE_UNUSED bool _bvBreak = false; \ - BSON_MAYBE_UNUSED bool _bvContinue = false; \ - while (bson_iter_next (&_bvCtx.iter) && !_bvHalt && !bsonParseError && \ - !_bvBreak) { \ - _bvContinue = false; \ - _bsonVisit_applyOps (__VA_ARGS__); \ - ++_bvCtx.index; \ - } \ - if (bsonVisitIter.err_off) { \ - bsonParseError = "Invalid BSON data [b]"; \ - } \ - /* Restore the dsl context */ \ - _bsonVisitContextThreadLocalPtr = _bvCtx.parent; \ - } while (0); \ - _bsonDSL_end - -#define _bsonVisitOperation_visitEach \ - _bsonVisitOperation_visitEachDeferred _bsonDSL_nothing () -#define _bsonVisitOperation_visitEachDeferred(...) \ - _bsonDSL_begin ("visitEach:%s", ""); \ - do { \ - const uint8_t *data; \ - uint32_t len; \ - bson_type_t typ = bson_iter_type_unsafe (&bsonVisitIter); \ - if (typ == BSON_TYPE_ARRAY) \ - bson_iter_array (&bsonVisitIter, &len, &data); \ - else if (typ == BSON_TYPE_DOCUMENT) \ - bson_iter_document (&bsonVisitIter, &len, &data); \ - else { \ - _bsonDSLDebug ("(Skipping visitEach() of non-array/document value)"); \ - break; \ - } \ - bson_t inner; \ - BSON_ASSERT (bson_init_static (&inner, data, len)); \ - _bsonVisitEach (inner, __VA_ARGS__); \ - } while (0); \ - _bsonDSL_end - -#define _bsonVisitOperation_nop _bsonDSLDebug ("[nop]") -#define _bsonVisitOperation_parse(...) \ - do { \ - const uint8_t *data; \ - uint32_t len; \ - bson_type_t typ = bson_iter_type (&bsonVisitIter); \ - if (typ == BSON_TYPE_ARRAY) \ - bson_iter_array (&bsonVisitIter, &len, &data); \ - else if (typ == BSON_TYPE_DOCUMENT) \ - bson_iter_document (&bsonVisitIter, &len, &data); \ - else { \ - _bsonDSLDebug ("Ignoring parse() for non-document/array value"); \ - break; \ - } \ - bson_t inner; \ - BSON_ASSERT (bson_init_static (&inner, data, len)); \ - _bsonParse (inner, __VA_ARGS__); \ - } while (0); - -#define _bsonVisitOperation_continue _bvContinue = true -#define _bsonVisitOperation_break _bvBreak = _bvContinue = true -#define _bsonVisitOperation_require(Predicate) \ - _bsonDSL_begin ("require(%s)", _bsonDSL_str (Predicate)); \ - if (!bsonPredicate (Predicate)) { \ - bsonParseError = \ - "Element requirement failed: " _bsonDSL_str (Predicate); \ - } \ - _bsonDSL_end - -#define _bsonVisitOperation_error(S) bsonParseError = (S) -#define _bsonVisitOperation_errorf(S, ...) \ - (bsonParseError = _bson_dsl_errorf (&(S), __VA_ARGS__)) -#define _bsonVisitOperation_dupPath(S) \ - _bsonDSL_begin ("dupPath(%s)", _bsonDSL_str (S)); \ - _bson_dsl_dupPath (&(S)); \ - _bsonDSL_end - -#define _bsonVisit_applyOp(P, _const, _count) \ - do { \ - if (!_bvContinue && !_bvHalt && !bsonParseError) { \ - _bsonVisitOperation_##P; \ - } \ - } while (0); - -#define _bsonParse(Doc, ...) \ - do { \ - BSON_MAYBE_UNUSED const bson_t *_bpDoc = &(Doc); \ - /* Keep track of which elements have been visited based on their index*/ \ - uint64_t _bpVisitBits_static[4] = {0}; \ - BSON_MAYBE_UNUSED uint64_t *_bpVisitBits = _bpVisitBits_static; \ - BSON_MAYBE_UNUSED size_t _bpNumVisitBitInts = \ - sizeof _bpVisitBits_static / sizeof (uint64_t); \ - BSON_MAYBE_UNUSED bool _bpFoundElement = false; \ - _bsonParse_applyOps (__VA_ARGS__); \ - /* We may have allocated for visit bits */ \ - if (_bpVisitBits != _bpVisitBits_static) { \ - bson_free (_bpVisitBits); \ - } \ - } while (0) - -#define _bsonParse_applyOps(...) \ - _bsonDSL_mapMacro (_bsonParse_applyOp, ~, __VA_ARGS__) - -/// Parse one entry referrenced by the context iterator -#define _bsonParse_applyOp(P, _nil, Counter) \ - do { \ - if (!_bvHalt && !bsonParseError) { \ - _bsonParseOperation_##P; \ - } \ - } while (0); - -#define _bsonParseMarkVisited(Index) \ - if (1) { \ - const size_t nth_int = Index / 64u; \ - const size_t nth_bit = Index % 64u; \ - while (nth_int >= _bpNumVisitBitInts) { \ - /* Say that five times, fast: */ \ - size_t new_num_visit_bit_ints = _bpNumVisitBitInts * 2u; \ - uint64_t *new_visit_bit_ints = \ - bson_malloc0 (sizeof (uint64_t) * new_num_visit_bit_ints); \ - memcpy (new_visit_bit_ints, \ - _bpVisitBits, \ - sizeof (uint64_t) * _bpNumVisitBitInts); \ - if (_bpVisitBits != _bpVisitBits_static) { \ - bson_free (_bpVisitBits); \ - } \ - _bpVisitBits = new_visit_bit_ints; \ - _bpNumVisitBitInts = new_num_visit_bit_ints; \ - } \ - \ - _bpVisitBits[nth_int] |= (UINT64_C (1) << nth_bit); \ - } else \ - ((void) 0) - -#define _bsonParseDidVisitNth(Index) \ - _bsonParseDidVisitNth_1 (Index / 64u, Index % 64u) -#define _bsonParseDidVisitNth_1(NthInt, NthBit) \ - (NthInt < _bpNumVisitBitInts && \ - (_bpVisitBits[NthInt] & (UINT64_C (1) << NthBit))) - -#define _bsonParseOperation_find(Predicate, ...) \ - _bsonDSL_begin ("find(%s)", _bsonDSL_str (Predicate)); \ - _bpFoundElement = false; \ - _bsonVisitEach ( \ - *_bpDoc, \ - if (Predicate, \ - then (do (_bsonParseMarkVisited (bsonVisitContext.index); \ - _bpFoundElement = true), \ - __VA_ARGS__, \ - break))); \ - if (!_bpFoundElement && !bsonParseError) { \ - _bsonDSLDebug ("[not found]"); \ - } \ - _bsonDSL_end - -#define _bsonParseOperation_require(Predicate, ...) \ - _bsonDSL_begin ("require(%s)", _bsonDSL_str (Predicate)); \ - _bpFoundElement = false; \ - _bsonVisitEach ( \ - *_bpDoc, \ - if (Predicate, \ - then (do (_bsonParseMarkVisited (bsonVisitContext.index); \ - _bpFoundElement = true), \ - __VA_ARGS__, \ - break))); \ - if (!_bpFoundElement && !bsonParseError) { \ - bsonParseError = \ - "Failed to find a required element: " _bsonDSL_str (Predicate); \ - } \ - _bsonDSL_end - -#define _bsonParseOperation_visitOthers(...) \ - _bsonDSL_begin ("visitOthers(%s)", _bsonDSL_strElide (30, __VA_ARGS__)); \ - _bsonVisitEach ( \ - *_bpDoc, \ - if (not(eval (_bsonParseDidVisitNth (bsonVisitContext.index))), \ - then (__VA_ARGS__))); \ - _bsonDSL_end - -#define bsonPredicate(P) _bsonPredicate _bsonDSL_nothing () (P) -#define _bsonPredicate(P) _bsonPredicate_Condition_##P - -#define _bsonPredicate_Condition_ \ - __NOTE__Missing_name_for_a_predicate_expression - -#define _bsonPredicate_Condition_allOf(...) \ - (1 _bsonDSL_mapMacro (_bsonPredicateAnd, ~, __VA_ARGS__)) -#define _bsonPredicate_Condition_anyOf(...) \ - (0 _bsonDSL_mapMacro (_bsonPredicateOr, ~, __VA_ARGS__)) -#define _bsonPredicate_Condition_not(...) \ - (!(0 _bsonDSL_mapMacro (_bsonPredicateOr, ~, __VA_ARGS__))) -#define _bsonPredicateAnd(Pred, _ignore, _ignore1) \ - &&_bsonPredicate _bsonDSL_nothing () (Pred) -#define _bsonPredicateOr(Pred, _ignore, _ignore2) \ - || _bsonPredicate _bsonDSL_nothing () (Pred) - -#define _bsonPredicate_Condition_eval(X) (X) - -#define _bsonPredicate_Condition_key(...) \ - (_bson_dsl_key_is_anyof (bson_iter_key (&bsonVisitIter), \ - bson_iter_key_len (&bsonVisitIter), \ - true /* case senstive */, \ - __VA_ARGS__, \ - NULL)) - -#define _bsonPredicate_Condition_iKey(...) \ - (_bson_dsl_key_is_anyof (bson_iter_key (&bsonVisitIter), \ - bson_iter_key_len (&bsonVisitIter), \ - false /* case insenstive */, \ - __VA_ARGS__, \ - NULL)) - -#define _bsonPredicate_Condition_type(Type) \ - (bson_iter_type (&bsonVisitIter) == _bsonDSL_Type_##Type) - -#define _bsonPredicate_Condition_keyWithType(Key, Type) \ - (_bsonPredicate_Condition_allOf _bsonDSL_nothing () (key (Key), type (Type))) - -#define _bsonPredicate_Condition_iKeyWithType(Key, Type) \ - (_bsonPredicate_Condition_allOf _bsonDSL_nothing () (iKey (Key), \ - type (Type))) - -#define _bsonPredicate_Condition_lastElement \ - (_bson_dsl_iter_is_last_element (&bsonVisitIter)) - -#define _bsonPredicate_Condition_isNumeric \ - BSON_ITER_HOLDS_NUMBER (&bsonVisitIter) - -#define _bsonPredicate_Condition_1 1 -#define _bsonPredicate_Condition_0 0 -#define _bsonPredicate_Condition_true true -#define _bsonPredicate_Condition_false false - -#define _bsonPredicate_Condition_isTrue (bson_iter_as_bool (&bsonVisitIter)) -#define _bsonPredicate_Condition_isFalse (!bson_iter_as_bool (&bsonVisitIter)) -#define _bsonPredicate_Condition_empty \ - (_bson_dsl_is_empty_bson (&bsonVisitIter)) - -#define _bsonPredicate_Condition_strEqual(S) (_bson_dsl_test_strequal (S, true)) -#define _bsonPredicate_Condition_iStrEqual(S) \ - (_bson_dsl_test_strequal (S, false)) - -#define _bsonPredicate_Condition_eq(Type, Value) \ - (_bsonPredicate_Condition_type (Type) && bsonAs (Type) == Value) - -#define _bsonParseOperation_else _bsonParse_deferredElse _bsonDSL_nothing () -#define _bsonParse_deferredElse(...) \ - if (!_bpFoundElement) { \ - _bsonDSL_begin ("else:%s", ""); \ - _bsonParse_applyOps (__VA_ARGS__); \ - _bsonDSL_end; \ - } else \ - ((void) 0) - -#define _bsonParseOperation_do(...) \ - _bsonDSL_begin ("do: %s", _bsonDSL_strElide (30, __VA_ARGS__)); \ - do { \ - __VA_ARGS__; \ - } while (0); \ - _bsonDSL_end - -#define _bsonParseOperation_halt _bvHalt = true - -#define _bsonParseOperation_error(S) bsonParseError = (S) -#define _bsonParseOperation_errorf(S, ...) \ - (bsonParseError = _bson_dsl_errorf (&(S), __VA_ARGS__)) - -/// Perform conditional parsing -#define _bsonParseOperation_if(Condition, ...) \ - _bsonDSL_begin ("if(%s)", _bsonDSL_str (Condition)); \ - /* Pick a sub-macro depending on if there are one or two args */ \ - _bsonDSL_ifElse (_bsonDSL_hasComma (__VA_ARGS__), \ - _bsonParse_ifThenElse, \ - _bsonParse_ifThen) (Condition, __VA_ARGS__); \ - _bsonDSL_end - -#define _bsonParse_ifThen_then _bsonParse_applyOps -#define _bsonParse_ifElse_else _bsonParse_applyOps - -#define _bsonParse_ifThenElse(Condition, Then, Else) \ - if ((Condition)) { \ - _bsonDSLDebug ("then:"); \ - _bsonParse_ifThen_##Then; \ - } else { \ - _bsonDSLDebug ("else:"); \ - _bsonParse_ifElse_##Else; \ - } - -#define _bsonParse_ifThen(Condition, Then) \ - if ((Condition)) { \ - _bsonDSLDebug ("%s", _bsonDSL_str (Then)); \ - _bsonParse_ifThen_##Then; \ - } else { \ - _bsonDSLDebug ("[else nothing]"); \ - } - -#define _bsonParseOperation_append \ - _bsonParseOperationDeferred_append _bsonDSL_nothing () -#define _bsonParseOperationDeferred_append(Doc, ...) \ - _bsonDSL_begin ("append to [%s] : %s", \ - _bsonDSL_str (Doc), \ - _bsonDSL_strElide (30, __VA_ARGS__)); \ - _bsonBuildAppend (Doc, __VA_ARGS__); \ - if (bsonBuildError) { \ - bsonParseError = bsonBuildError; \ - } \ - _bsonDSL_end - -#define _bsonVisit_applyOps _bsonVisit_applyOpsDeferred _bsonDSL_nothing () -#define _bsonVisit_applyOpsDeferred(...) \ - do { \ - _bsonDSL_mapMacro (_bsonVisit_applyOp, ~, __VA_ARGS__); \ - } while (0); - -#define bsonBuildArray(BSON, ...) \ - _bsonDSL_begin ("bsonBuildArray(%s, %s)", \ - _bsonDSL_str (BSON), \ - _bsonDSL_strElide (30, __VA_ARGS__)); \ - _bsonDSL_eval (_bsonBuildArray (BSON, __VA_ARGS__)); \ - _bsonDSL_end - -#define _bsonBuildArray(BSON, ...) \ - do { \ - _bsonDSL_disableWarnings (); \ - struct _bsonBuildContext_t _bbCtx = { \ - .doc = &(BSON), \ - .parent = _bsonBuildContextThreadLocalPtr, \ - .index = 0, \ - }; \ - _bsonBuildContextThreadLocalPtr = &_bbCtx; \ - _bsonBuildArrayWithCurrentContext (__VA_ARGS__); \ - _bsonBuildContextThreadLocalPtr = _bbCtx.parent; \ - _bsonDSL_restoreWarnings (); \ - } while (0) - -/** - * @brief Build a BSON document by appending to an existing bson_t document - * - * @param Pointer The document upon which to append - * @param ... The Document elements to append to the document - */ -#define bsonBuildAppend(BSON, ...) \ - _bsonDSL_eval (_bsonBuildAppend (BSON, __VA_ARGS__)) -#define _bsonBuildAppend(BSON, ...) \ - _bsonDSL_begin ("Appending to document '%s'", _bsonDSL_str (BSON)); \ - _bsonDSL_disableWarnings (); \ - /* Save the dsl context */ \ - struct _bsonBuildContext_t _bbCtx = { \ - .doc = &(BSON), \ - .parent = _bsonBuildContextThreadLocalPtr, \ - }; \ - /* Reset the context */ \ - _bsonBuildContextThreadLocalPtr = &_bbCtx; \ - bsonBuildError = NULL; \ - _bsonBuildAppendWithCurrentContext (__VA_ARGS__); \ - /* Restore the dsl context */ \ - _bsonBuildContextThreadLocalPtr = _bbCtx.parent; \ - _bsonDSL_restoreWarnings (); \ - _bsonDSL_end - -/** - * @brief Build a new BSON document and assign the value into the given - * pointer. - */ -#define bsonBuild(BSON, ...) \ - _bsonDSL_begin ("Build a new document for '%s'", _bsonDSL_str (BSON)); \ - bson_t *_bbDest = &(BSON); \ - bson_init (_bbDest); \ - bsonBuildAppend (*_bbDest, __VA_ARGS__); \ - _bsonDSL_end - -/** - * @brief Declare a variable and build it with the BSON DSL @see bsonBuild - */ -#define bsonBuildDecl(Variable, ...) \ - bson_t Variable = BSON_INITIALIZER; \ - bsonBuild (Variable, __VA_ARGS__) - - -struct _bsonBuildContext_t { - /// The document that is being built - bson_t *doc; - /// The key that is pending an append - const char *key; - /// The length of the string given in 'key' - int key_len; - /// The index of the array being built (if applicable) - size_t index; - /// A buffer for formatting key strings - char index_key_str[16]; - /// The parent context (if building a sub-document) - struct _bsonBuildContext_t *parent; -}; - -/// A pointer to the current thread's bsonBuild context -_bson_thread_local _bson_comdat struct _bsonBuildContext_t - *_bsonBuildContextThreadLocalPtr = NULL; - -struct _bsonVisitContext_t { - const bson_t *doc; - bson_iter_t iter; - const struct _bsonVisitContext_t *parent; - size_t index; -}; - -/// A pointer to the current thread's bsonVisit/bsonParse context -_bson_thread_local _bson_comdat struct _bsonVisitContext_t const - *_bsonVisitContextThreadLocalPtr = NULL; - -/** - * @brief The most recent error from a bsonBuild() DSL command. - * - * If NULL, no error occurred. Users can assign a value to this string to - * indicate failure. - */ -_bson_thread_local _bson_comdat const char *bsonBuildError = NULL; - -/** - * @brief The most recent error from a buildVisit() or bsonParse() DSL command. - * - * If NULL, no error occurred. Users can assign a value to this string to - * indicate an error. - * - * If this string becomes non-NULL, the current bsonVisit()/bsonParse() will - * halt and return. - * - * Upon entering a new bsonVisit()/bsonParse(), this will be reset to NULL. - */ -_bson_thread_local _bson_comdat const char *bsonParseError = NULL; - -#define _bsonDSLDebug(...) \ - _bson_dsl_debug (BSON_DSL_DEBUG, __FILE__, __LINE__, BSON_FUNC, __VA_ARGS__) - - -static BSON_INLINE bool -_bson_dsl_test_strequal (const char *string, bool case_sensitive) -{ - bson_iter_t it = bsonVisitIter; - if (bson_iter_type (&it) == BSON_TYPE_UTF8) { - uint32_t len; - const char *s = bson_iter_utf8 (&it, &len); - if (len != (uint32_t) strlen (string)) { - return false; - } - if (case_sensitive) { - return memcmp (string, s, len) == 0; - } else { - return bson_strcasecmp (string, s) == 0; - } - } - return false; -} - -static BSON_INLINE bool -_bson_dsl_key_is_anyof (const char *key, - const size_t keylen, - int case_sensitive, - ...) -{ - va_list va; - va_start (va, case_sensitive); - const char *str; - while ((str = va_arg (va, const char *))) { - size_t str_len = strlen (str); - if (str_len != keylen) { - continue; - } - if (case_sensitive) { - if (memcmp (str, key, str_len) == 0) { - va_end (va); - return true; - } - } else { - if (bson_strcasecmp (str, key) == 0) { - va_end (va); - return true; - } - } - } - va_end (va); - return false; -} - -static BSON_INLINE void -_bson_dsl_iter_as_doc (bson_t *into, const bson_iter_t *it) -{ - uint32_t len = 0; - const uint8_t *dataptr = NULL; - if (BSON_ITER_HOLDS_ARRAY (it)) { - bson_iter_array (it, &len, &dataptr); - } else if (BSON_ITER_HOLDS_DOCUMENT (it)) { - bson_iter_document (it, &len, &dataptr); - } - if (dataptr) { - BSON_ASSERT (bson_init_static (into, dataptr, len)); - } -} - -static BSON_INLINE bool -_bson_dsl_is_empty_bson (const bson_iter_t *it) -{ - bson_t d = BSON_INITIALIZER; - _bson_dsl_iter_as_doc (&d, it); - return d.len == 5; // Empty documents/arrays have byte-size of five -} - -static BSON_INLINE bool -_bson_dsl_iter_is_last_element (const bson_iter_t *it) -{ - bson_iter_t dup = *it; - return !bson_iter_next (&dup) && dup.err_off == 0; -} - -_bson_thread_local _bson_comdat int _bson_dsl_indent = 0; - -static BSON_INLINE void BSON_GNUC_PRINTF (5, 6) - _bson_dsl_debug (bool do_debug, - const char *file, - int line, - const char *func, - const char *string, - ...) -{ - if (do_debug) { - fprintf (stderr, "%s:%d: [%s] bson_dsl: ", file, line, func); - for (int i = 0; i < _bson_dsl_indent; ++i) { - fputs (" ", stderr); - } - va_list va; - va_start (va, string); - vfprintf (stderr, string, va); - va_end (va); - fputc ('\n', stderr); - fflush (stderr); - } -} - -static BSON_INLINE char *BSON_GNUC_PRINTF (2, 3) - _bson_dsl_errorf (char **const into, const char *const fmt, ...) -{ - if (*into) { - bson_free (*into); - *into = NULL; - } - va_list args; - va_start (args, fmt); - *into = bson_strdupv_printf (fmt, args); - va_end (args); - return *into; -} - -static BSON_INLINE void -_bson_dsl_dupPath (char **into) -{ - if (*into) { - bson_free (*into); - *into = NULL; - } - char *acc = bson_strdup (""); - for (const struct _bsonVisitContext_t *ctx = &bsonVisitContext; ctx; - ctx = ctx->parent) { - char *prev = acc; - if (ctx->parent && BSON_ITER_HOLDS_ARRAY (&ctx->parent->iter)) { - // We're an array element - acc = bson_strdup_printf ("[%d]%s", (int) ctx->index, prev); - } else { - // We're a document element - acc = bson_strdup_printf (".%s%s", bson_iter_key (&ctx->iter), prev); - } - bson_free (prev); - } - *into = bson_strdup_printf ("$%s", acc); - bson_free (acc); -} - -static BSON_INLINE const char * -_bsonVisitIterAs_cstr (void) -{ - return bson_iter_utf8 (&bsonVisitIter, NULL); -} - -static BSON_INLINE int32_t -_bsonVisitIterAs_int32 (void) -{ - return bson_iter_int32 (&bsonVisitIter); -} - -static BSON_INLINE bool -_bsonVisitIterAs_bool (void) -{ - return bson_iter_as_bool (&bsonVisitIter); -} - -static BSON_INLINE bool -_bsonVisitIterAs__Bool (void) -{ - return _bsonVisitIterAs_bool (); -} - -#define bsonAs(Type) _bsonDSL_paste (_bsonVisitIterAs_, Type) () - -/// Convert the given argument into a string without inhibitting macro expansion -#define _bsonDSL_str(...) _bsonDSL_str_1 (__VA_ARGS__) -// Empty quotes "" are to ensure a string appears. Old MSVC has a bug -// where empty #__VA_ARGS__ just vanishes. -#define _bsonDSL_str_1(...) "" #__VA_ARGS__ - -#define _bsonDSL_strElide(MaxLen, ...) \ - (strlen (_bsonDSL_str (__VA_ARGS__)) > (MaxLen) \ - ? "[...]" \ - : _bsonDSL_str (__VA_ARGS__)) - -/// Paste two tokens: -#define _bsonDSL_paste(a, ...) _bsonDSL_paste_impl (a, __VA_ARGS__) -#define _bsonDSL_paste_impl(a, ...) a##__VA_ARGS__ - -/// Paste three tokens: -#define _bsonDSL_paste3(a, b, c) _bsonDSL_paste (a, _bsonDSL_paste (b, c)) -/// Paste four tokens: -#define _bsonDSL_paste4(a, b, c, d) \ - _bsonDSL_paste (a, _bsonDSL_paste3 (b, c, d)) - -// clang-format off - -/// Now we need a MAP() macro. This idiom is common, but fairly opaque. Below is -/// some crazy preprocessor trickery to implement it. Fortunately, once we have -/// MAP(), the remainder of this file is straightforward. This implementation -/// isn't the simplest one possible, but is one that supports the old -/// non-compliant MSVC preprocessor. - -/* Expands to nothing. Used to defer a function-like macro and to ignore arguments */ -#define _bsonDSL_nothing(...) - -/// Expand to the 64th argument. See below for why this is useful. -#define _bsonDSL_pick64th(\ - _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ - _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \ - _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \ - _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \ - _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \ - _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \ - _61, _62, _63, ...) \ - _63 - -/** - * @brief Expands to 1 if the given arguments contain any top-level commas, zero otherwise. - * - * There is an expansion of __VA_ARGS__, followed by 62 '1' arguments, followed - * by single '0'. If __VA_ARGS__ contains no commas, pick64th() will return the - * single zero. If __VA_ARGS__ contains any top-level commas, the series of ones - * will shift to the right and pick64th will return one of those ones. (This only - * works __VA_ARGS__ contains fewer than 62 commas, which is a somewhat reasonable - * limit.) The _bsonDSL_nothing() is a workaround for MSVC's bad preprocessor that - * expands __VA_ARGS__ incorrectly. - * - * If we have __VA_OPT__, this can be a lot simpler. - */ -#define _bsonDSL_hasComma(...) \ - _bsonDSL_pick64th \ - _bsonDSL_nothing() (__VA_ARGS__, \ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, ~) - -/** - * Expands to a single comma if "invoked" as a function-like macro. - * (This will make sense, I promise.) - */ -#define _bsonDSL_commaIfRHSHasParens(...) , - -/** - * @brief Expand to 1 if given no arguments, otherwise 0. - * - * This could be done much more simply using __VA_OPT__, but we need to work on - * older compilers. - */ -#define _bsonDSL_isEmpty(...) \ - _bsonDSL_isEmpty_1(\ - /* Expands to '1' if __VA_ARGS__ contains any top-level commas */ \ - _bsonDSL_hasComma(__VA_ARGS__), \ - /* Expands to '1' if __VA_ARGS__ begins with a parenthesis, because \ - * that will cause an "invocation" of _bsonDSL_commaIfRHSHasParens, \ - * which immediately expands to a single comma. */ \ - _bsonDSL_hasComma(_bsonDSL_commaIfRHSHasParens __VA_ARGS__), \ - /* Expands to '1' if __VA_ARGS__ expands to a function-like macro name \ - * that then expands to anything containing a top-level comma */ \ - _bsonDSL_hasComma(__VA_ARGS__ ()), \ - /* Expands to '1' if __VA_ARGS__ expands to nothing. */ \ - _bsonDSL_hasComma(_bsonDSL_commaIfRHSHasParens __VA_ARGS__ ())) - -/** - * A helper for isEmpty(): If given (0, 0, 0, 1), expands as: - * - first: _bsonDSL_hasComma(_bsonDSL_isEmpty_CASE_0001) - * - then: _bsonDSL_hasComma(,) - * - then: 1 - * Given any other aruments: - * - first: _bsonDSL_hasComma(_bsonDSL_isEmpty_CASE_) - * - then: 0 - */ -#define _bsonDSL_isEmpty_1(_1, _2, _3, _4) \ - _bsonDSL_hasComma(_bsonDSL_paste(_bsonDSL_isEmpty_CASE_, _bsonDSL_paste4(_1, _2, _3, _4))) -#define _bsonDSL_isEmpty_CASE_0001 , - -/** - * @brief Expand to the first argument if `Cond` is 1, the second argument if `Cond` is 0 - */ -#define _bsonDSL_ifElse(Cond, IfTrue, IfFalse) \ - /* Suppress expansion of the two branches by using the '#' operator */ \ - _bsonDSL_nothing(#IfTrue, #IfFalse) \ - /* Concat the cond 1/0 with a prefix macro: */ \ - _bsonDSL_paste(_bsonDSL_ifElse_PICK_, Cond)(IfTrue, IfFalse) - -#define _bsonDSL_ifElse_PICK_1(IfTrue, IfFalse) \ - /* Expand the first operand, throw away the second */ \ - IfTrue _bsonDSL_nothing(#IfFalse) -#define _bsonDSL_ifElse_PICK_0(IfTrue, IfFalse) \ - /* Expand to the second operand, throw away the first */ \ - IfFalse _bsonDSL_nothing(#IfTrue) - -#ifdef _MSC_VER -// MSVC's "traditional" preprocessor requires many more expansion passes, -// but GNU and Clang are very slow when evaluating hugely nested expansions -// and generate massive macro expansion backtraces. -#define _bsonDSL_eval_1(...) __VA_ARGS__ -#define _bsonDSL_eval_2(...) _bsonDSL_eval_1(_bsonDSL_eval_1(_bsonDSL_eval_1(_bsonDSL_eval_1(_bsonDSL_eval_1(__VA_ARGS__))))) -#define _bsonDSL_eval_4(...) _bsonDSL_eval_2(_bsonDSL_eval_2(_bsonDSL_eval_2(_bsonDSL_eval_2(_bsonDSL_eval_2(__VA_ARGS__))))) -#define _bsonDSL_eval_8(...) _bsonDSL_eval_4(_bsonDSL_eval_4(_bsonDSL_eval_4(_bsonDSL_eval_4(_bsonDSL_eval_4(__VA_ARGS__))))) -#define _bsonDSL_eval_16(...) _bsonDSL_eval_8(_bsonDSL_eval_8(_bsonDSL_eval_8(_bsonDSL_eval_8(_bsonDSL_eval_8(__VA_ARGS__))))) -#define _bsonDSL_eval(...) _bsonDSL_eval_16(_bsonDSL_eval_16(_bsonDSL_eval_16(_bsonDSL_eval_16(_bsonDSL_eval_16(__VA_ARGS__))))) -#else -// Each level of "eval" applies double the expansions of the previous level. -#define _bsonDSL_eval_1(...) __VA_ARGS__ -#define _bsonDSL_eval_2(...) _bsonDSL_eval_1(_bsonDSL_eval_1(__VA_ARGS__)) -#define _bsonDSL_eval_4(...) _bsonDSL_eval_2(_bsonDSL_eval_2(__VA_ARGS__)) -#define _bsonDSL_eval_8(...) _bsonDSL_eval_4(_bsonDSL_eval_4(__VA_ARGS__)) -#define _bsonDSL_eval_16(...) _bsonDSL_eval_8(_bsonDSL_eval_8(__VA_ARGS__)) -#define _bsonDSL_eval_32(...) _bsonDSL_eval_16(_bsonDSL_eval_16(__VA_ARGS__)) -#define _bsonDSL_eval(...) _bsonDSL_eval_32(__VA_ARGS__) -#endif - -/** - * Finally, the Map() macro that allows us to do the magic, which we've been - * building up to all along. - * - * The dance with mapMacro_first, mapMacro_final, and _bsonDSL_nothing - * conditional on argument count is to prevent warnings from pre-C99 about - * passing no arguments to the '...' parameters. Yet again, if we had C99 and - * __VA_OPT__ this would be simpler. - */ -#define _bsonDSL_mapMacro(Action, Constant, ...) \ - /* Pick our first action based on the content of '...': */ \ - _bsonDSL_ifElse( \ - /* If given no arguments: */\ - _bsonDSL_isEmpty(__VA_ARGS__), \ - /* expand to _bsonDSL_nothing */ \ - _bsonDSL_nothing, \ - /* Otherwise, expand to mapMacro_first: */ \ - _bsonDSL_mapMacro_first) \ - /* Now "invoke" the chosen macro: */ \ - _bsonDSL_nothing() (Action, Constant, __VA_ARGS__) - -#define _bsonDSL_mapMacro_first(Action, Constant, ...) \ - /* Select our next step based on whether we have one or more arguments: */ \ - _bsonDSL_ifElse( \ - /* If '...' contains more than one argument (has a top-level comma): */ \ - _bsonDSL_hasComma(__VA_ARGS__), \ - /* Begin the mapMacro loop with mapMacro_A: */ \ - _bsonDSL_mapMacro_A, \ - /* Otherwise skip to the final step of the loop: */ \ - _bsonDSL_mapMacro_final) \ - /* Invoke the chosen macro, setting the counter to zero: */ \ - _bsonDSL_nothing() (Action, Constant, 0, __VA_ARGS__) - -/// Handle the last expansion in a mapMacro sequence. -#define _bsonDSL_mapMacro_final(Action, Constant, Counter, FinalElement) \ - Action(FinalElement, Constant, Counter) - -/** - * mapMacro_A and mapMacro_B are identical and just invoke each other. - */ -#define _bsonDSL_mapMacro_A(Action, Constant, Counter, Head, ...) \ - /* First evaluate the action once: */ \ - Action(Head, Constant, Counter) \ - /* Pick our next step: */ \ - _bsonDSL_ifElse( \ - /* If '...' contains more than one argument (has a top-level comma): */ \ - _bsonDSL_hasComma(__VA_ARGS__), \ - /* Jump to the other mapMacro: */ \ - _bsonDSL_mapMacro_B, \ - /* Otherwise go to mapMacro_final */ \ - _bsonDSL_mapMacro_final) \ - /* Invoke the next step of the map: */ \ - _bsonDSL_nothing() (Action, Constant, Counter + 1, __VA_ARGS__) - -#define _bsonDSL_mapMacro_B(Action, Constant, Counter, Head, ...) \ - Action(Head, Constant, Counter) \ - _bsonDSL_ifElse(_bsonDSL_hasComma(__VA_ARGS__), _bsonDSL_mapMacro_A, _bsonDSL_mapMacro_final) \ - _bsonDSL_nothing() (Action, Constant, Counter + 1, __VA_ARGS__) - -// clang-format on - - -#endif // BSON_BSON_DSL_H_INCLUDED diff --git a/3rdparty/mongo-c-driver-1.26.2/src/common/common-macros-private.h b/3rdparty/mongo-c-driver-1.26.2/src/common/common-macros-private.h deleted file mode 100644 index 360a0f51e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/common/common-macros-private.h +++ /dev/null @@ -1,15 +0,0 @@ - -#include "common-prelude.h" - -#ifndef MONGO_C_DRIVER_COMMON_MACROS_H -#define MONGO_C_DRIVER_COMMON_MACROS_H - -/* Test only assert. Is a noop unless -DENABLE_DEBUG_ASSERTIONS=ON is set - * during configuration */ -#if defined(MONGOC_ENABLE_DEBUG_ASSERTIONS) && defined(BSON_OS_UNIX) -#define MONGOC_DEBUG_ASSERT(statement) BSON_ASSERT (statement) -#else -#define MONGOC_DEBUG_ASSERT(statement) ((void) 0) -#endif - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/common/common-md5-private.h b/3rdparty/mongo-c-driver-1.26.2/src/common/common-md5-private.h deleted file mode 100644 index 4feadb931..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/common/common-md5-private.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2018-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "common-prelude.h" - -#ifndef COMMON_MD5_PRIVATE_H -#define COMMON_MD5_PRIVATE_H - -#include "bson/bson.h" - -BSON_BEGIN_DECLS - -#define mcommon_md5_init COMMON_NAME (md5_init) -#define mcommon_md5_append COMMON_NAME (md5_append) -#define mcommon_md5_finish COMMON_NAME (md5_finish) - -void -mcommon_md5_init (bson_md5_t *pms); -void -mcommon_md5_append (bson_md5_t *pms, const uint8_t *data, uint32_t nbytes); -void -mcommon_md5_finish (bson_md5_t *pms, uint8_t digest[16]); - -BSON_END_DECLS - -#endif /* COMMON_MD5_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/common/common-thread.c b/3rdparty/mongo-c-driver-1.26.2/src/common/common-thread.c deleted file mode 100644 index 037a6490b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/common/common-thread.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "common-thread-private.h" - -#include - -#if defined(BSON_OS_UNIX) -int -mcommon_thread_create (bson_thread_t *thread, - BSON_THREAD_FUN_TYPE (func), - void *arg) -{ - BSON_ASSERT_PARAM (thread); - BSON_ASSERT_PARAM (func); - BSON_ASSERT (arg || true); // optional. - return pthread_create (thread, NULL, func, arg); -} -int -mcommon_thread_join (bson_thread_t thread) -{ - return pthread_join (thread, NULL); -} - -#if defined(MONGOC_ENABLE_DEBUG_ASSERTIONS) && defined(BSON_OS_UNIX) -bool -mcommon_mutex_is_locked (bson_mutex_t *mutex) -{ - return mutex->valid_tid && - pthread_equal (pthread_self (), mutex->lock_owner); -} -#endif - -#else -int -mcommon_thread_create (bson_thread_t *thread, - BSON_THREAD_FUN_TYPE (func), - void *arg) -{ - BSON_ASSERT_PARAM (thread); - BSON_ASSERT_PARAM (func); - BSON_ASSERT (arg || true); // optional. - - *thread = (HANDLE) _beginthreadex (NULL, 0, func, arg, 0, NULL); - if (0 == *thread) { - return errno; - } - return 0; -} -int -mcommon_thread_join (bson_thread_t thread) -{ - int ret; - - /* zero indicates success for WaitForSingleObject. */ - ret = WaitForSingleObject (thread, INFINITE); - if (WAIT_OBJECT_0 != ret) { - return ret; - } - /* zero indicates failure for CloseHandle. */ - ret = CloseHandle (thread); - if (0 == ret) { - return 1; - } - return 0; -} -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/kms-message/README.md b/3rdparty/mongo-c-driver-1.26.2/src/kms-message/README.md deleted file mode 100644 index 2155f5f74..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/kms-message/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# kms-message -Library used to generate requests for: -- Amazon Web Services Key Management Service (KMS) -- Azure Key Vault - -This library is *not* a complete implementation of a KMS client, it only -implements the request format. - -## Testing kms-message -- `test_kms_request` tests HTTP request generation and response parsing, but does not require internet or use any live servers. -- `test_kms_azure_online` makes live requests, and has additional requirements (must have working credentials). - -### Requirements -- A complete installation of the C driver. (libbson is needed for parsing JSON, and libmongoc is used for creating TLS streams). See http://mongoc.org/libmongoc/current/installing.html for installation instructions. For macOS, `brew install mongo-c-driver` will suffice. -- An Azure key vault, and a service principal with an access policy allowing encrypt / decrypt key operations. The following environment variables must be set: - - AZURE_TENANT_ID - - AZURE_CLIENT_ID - - AZURE_CLIENT_SECRET - - AZURE_KEY_URL (e.g. `https://key-vault-kevinalbs.vault.azure.net/keys/test-key/9e1159e6ee5b447ba17e850b779bf652`) - -### Building -Configure and build with cmake: -``` -mkdir cmake-build -cd cmake-build -cmake .. -cmake --build . --target all -``` - -If the C driver is installed in a non-default location, specify the location with `-DCMAKE_PREFIX_PATH=...`. - -To build tests with verbose (and insecure) tracing, define `TEST_TRACING_INSECURE` in compiler flags by specifying `-DCMAKE_C_FLAGS="-DTEST_TRACING_INSECURE"` on cmake configuration. - -Recommended: compile tests with address sanitizer (use a relatively new gcc / clang compiler) by specifying `-fsanitize=address` in the C flags. This can be done by specifygin `-DCMAKE_C_FLAGS="-fsanitize=address"` as an option to cmake. Enable leak detection with the environment variable `ASAN_OPTIONS='detect_leaks=1'. Example: - -``` -cd cmake-build -cmake -DCMAKE_C_FLAGS="-fsanitize=address -DTEST_TRACING_INSECURE" -export ASAN_OPTIONS='detect_leaks=1' -./cmake-build/kms-message/test_kms_azure_online -``` diff --git a/3rdparty/mongo-c-driver-1.26.2/src/kms-message/src/kms_kmip_request.c b/3rdparty/mongo-c-driver-1.26.2/src/kms-message/src/kms_kmip_request.c deleted file mode 100644 index c59bff7c5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/kms-message/src/kms_kmip_request.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2021-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "kms_message/kms_kmip_request.h" - -#include "kms_message_private.h" -#include "kms_kmip_reader_writer_private.h" - -#include -#include - -static void -copy_writer_buffer (kms_request_t *req, kmip_writer_t *writer) -{ - const uint8_t *buf; - size_t buflen; - - buf = kmip_writer_get_buffer (writer, &buflen); - req->kmip.data = malloc (buflen); - memcpy (req->kmip.data, buf, buflen); - req->kmip.len = (uint32_t) buflen; -} - -kms_request_t * -kms_kmip_request_register_secretdata_new (void *reserved, - const uint8_t *data, - size_t len) -{ - /* - Create a KMIP Register request with a 96 byte SecretData of this form: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - kmip_writer_t *writer; - kms_request_t *req; - - req = calloc (1, sizeof (kms_request_t)); - req->provider = KMS_REQUEST_PROVIDER_KMIP; - - if (len != KMS_KMIP_REQUEST_SECRETDATA_LENGTH) { - KMS_ERROR (req, - "expected SecretData length of %d, got %" PRIu32, - KMS_KMIP_REQUEST_SECRETDATA_LENGTH, - len); - return req; - } - - writer = kmip_writer_new (); - kmip_writer_begin_struct (writer, KMIP_TAG_RequestMessage); - - kmip_writer_begin_struct (writer, KMIP_TAG_RequestHeader); - kmip_writer_begin_struct (writer, KMIP_TAG_ProtocolVersion); - kmip_writer_write_integer (writer, KMIP_TAG_ProtocolVersionMajor, 1); - kmip_writer_write_integer (writer, KMIP_TAG_ProtocolVersionMinor, 0); - kmip_writer_close_struct (writer); /* KMIP_TAG_ProtocolVersion */ - kmip_writer_write_integer (writer, KMIP_TAG_BatchCount, 1); - kmip_writer_close_struct (writer); /* KMIP_TAG_RequestHeader */ - - kmip_writer_begin_struct (writer, KMIP_TAG_BatchItem); - /* 0x03 == Register */ - kmip_writer_write_enumeration (writer, KMIP_TAG_Operation, 0x03); - kmip_writer_begin_struct (writer, KMIP_TAG_RequestPayload); - /* 0x07 == SecretData */ - kmip_writer_write_enumeration (writer, KMIP_TAG_ObjectType, 0x07); - kmip_writer_begin_struct (writer, KMIP_TAG_TemplateAttribute); - // Add required Cryptographic Usage Mask attribute. - { - kmip_writer_begin_struct (writer, KMIP_TAG_Attribute); - const char *cryptographicUsageMaskStr = "Cryptographic Usage Mask"; - kmip_writer_write_string (writer, - KMIP_TAG_AttributeName, - cryptographicUsageMaskStr, - strlen (cryptographicUsageMaskStr)); - // Use 0 because the Secret Data object is not used in cryptographic - // operations on the KMIP server. - kmip_writer_write_integer (writer, KMIP_TAG_AttributeValue, 0); - kmip_writer_close_struct (writer); - } - kmip_writer_close_struct (writer); /* KMIP_TAG_TemplateAttribute */ - kmip_writer_begin_struct (writer, KMIP_TAG_SecretData); - /* 0x02 = Seed */ - kmip_writer_write_enumeration (writer, KMIP_TAG_SecretDataType, 0x02); - kmip_writer_begin_struct (writer, KMIP_TAG_KeyBlock); - /* 0x02 = Opaque */ - kmip_writer_write_enumeration (writer, KMIP_TAG_KeyFormatType, 0x02); - kmip_writer_begin_struct (writer, KMIP_TAG_KeyValue); - kmip_writer_write_bytes ( - writer, KMIP_TAG_KeyMaterial, (const char *) data, len); - kmip_writer_close_struct (writer); /* KMIP_TAG_KeyValue */ - kmip_writer_close_struct (writer); /* KMIP_TAG_KeyBlock */ - kmip_writer_close_struct (writer); /* KMIP_TAG_SecretData */ - kmip_writer_close_struct (writer); /* KMIP_TAG_RequestPayload */ - kmip_writer_close_struct (writer); /* KMIP_TAG_BatchItem */ - kmip_writer_close_struct (writer); /* KMIP_TAG_RequestMessage */ - - copy_writer_buffer (req, writer); - kmip_writer_destroy (writer); - return req; -} - -kms_request_t * -kms_kmip_request_activate_new (void *reserved, const char *unique_identifer) -{ - /* - Create a KMIP Activate request of this form: - - - - - - - - - - - - - - - - */ - - kmip_writer_t *writer; - kms_request_t *req; - - req = calloc (1, sizeof (kms_request_t)); - req->provider = KMS_REQUEST_PROVIDER_KMIP; - - writer = kmip_writer_new (); - kmip_writer_begin_struct (writer, KMIP_TAG_RequestMessage); - - kmip_writer_begin_struct (writer, KMIP_TAG_RequestHeader); - kmip_writer_begin_struct (writer, KMIP_TAG_ProtocolVersion); - kmip_writer_write_integer (writer, KMIP_TAG_ProtocolVersionMajor, 1); - kmip_writer_write_integer (writer, KMIP_TAG_ProtocolVersionMinor, 0); - kmip_writer_close_struct (writer); /* KMIP_TAG_ProtocolVersion */ - kmip_writer_write_integer (writer, KMIP_TAG_BatchCount, 1); - kmip_writer_close_struct (writer); /* KMIP_TAG_RequestHeader */ - - kmip_writer_begin_struct (writer, KMIP_TAG_BatchItem); - /* 0x0A == Get */ - kmip_writer_write_enumeration (writer, KMIP_TAG_Operation, 0x12); - kmip_writer_begin_struct (writer, KMIP_TAG_RequestPayload); - kmip_writer_write_string (writer, - KMIP_TAG_UniqueIdentifier, - unique_identifer, - strlen (unique_identifer)); - kmip_writer_close_struct (writer); /* KMIP_TAG_RequestPayload */ - kmip_writer_close_struct (writer); /* KMIP_TAG_BatchItem */ - kmip_writer_close_struct (writer); /* KMIP_TAG_RequestMessage */ - - copy_writer_buffer (req, writer); - kmip_writer_destroy (writer); - return req; -} - -kms_request_t * -kms_kmip_request_get_new (void *reserved, const char *unique_identifer) -{ - /* - Create a KMIP Get request of this form: - - - - - - - - - - - - - - - - */ - - kmip_writer_t *writer; - kms_request_t *req; - - req = calloc (1, sizeof (kms_request_t)); - req->provider = KMS_REQUEST_PROVIDER_KMIP; - - writer = kmip_writer_new (); - kmip_writer_begin_struct (writer, KMIP_TAG_RequestMessage); - - kmip_writer_begin_struct (writer, KMIP_TAG_RequestHeader); - kmip_writer_begin_struct (writer, KMIP_TAG_ProtocolVersion); - kmip_writer_write_integer (writer, KMIP_TAG_ProtocolVersionMajor, 1); - kmip_writer_write_integer (writer, KMIP_TAG_ProtocolVersionMinor, 0); - kmip_writer_close_struct (writer); /* KMIP_TAG_ProtocolVersion */ - kmip_writer_write_integer (writer, KMIP_TAG_BatchCount, 1); - kmip_writer_close_struct (writer); /* KMIP_TAG_RequestHeader */ - - kmip_writer_begin_struct (writer, KMIP_TAG_BatchItem); - /* 0x0A == Get */ - kmip_writer_write_enumeration (writer, KMIP_TAG_Operation, 0x0A); - kmip_writer_begin_struct (writer, KMIP_TAG_RequestPayload); - kmip_writer_write_string (writer, - KMIP_TAG_UniqueIdentifier, - unique_identifer, - strlen (unique_identifer)); - /* 0x01 = Raw */ - kmip_writer_close_struct (writer); /* KMIP_TAG_RequestPayload */ - kmip_writer_close_struct (writer); /* KMIP_TAG_BatchItem */ - kmip_writer_close_struct (writer); /* KMIP_TAG_RequestMessage */ - - /* Copy the KMIP writer buffer to a KMIP request. */ - copy_writer_buffer (req, writer); - kmip_writer_destroy (writer); - return req; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/kms-message/src/kms_kmip_response.c b/3rdparty/mongo-c-driver-1.26.2/src/kms-message/src/kms_kmip_response.c deleted file mode 100644 index b4dc2c6fe..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/kms-message/src/kms_kmip_response.c +++ /dev/null @@ -1,323 +0,0 @@ -#include "kms_message/kms_kmip_response.h" - -#include "kms_message_private.h" -#include "kms_kmip_reader_writer_private.h" -#include "kms_kmip_result_reason_private.h" -#include "kms_kmip_result_status_private.h" - -#include -#include -#include /* CHAR_BIT */ - -static bool -check_and_require_kmip (kms_response_t *res) -{ - if (res->provider != KMS_REQUEST_PROVIDER_KMIP) { - KMS_ERROR (res, "Function requires KMIP request"); - return false; - } - return true; -} - -/* -Example of an error message: - - - - - - - - - - - - - - - - -*/ -static bool -kms_kmip_response_ok (kms_response_t *res) -{ - kmip_reader_t *reader = NULL; - size_t pos; - size_t len; - uint32_t result_status; - uint32_t result_reason = 0; - const char *result_message = ""; - uint32_t result_message_len = 0; - bool ok = false; - - reader = kmip_reader_new (res->kmip.data, res->kmip.len); - - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_ResponseMessage)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_ResponseMessage)); - goto fail; - } - - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_BatchItem)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_BatchItem)); - goto fail; - } - - /* Look for optional Result Reason. */ - if (kmip_reader_find (reader, - KMIP_TAG_ResultReason, - KMIP_ITEM_TYPE_Enumeration, - &pos, - &len)) { - if (!kmip_reader_read_enumeration (reader, &result_reason)) { - KMS_ERROR (res, "unable to read result reason value"); - goto fail; - } - } - - /* Look for optional Result Message. */ - if (kmip_reader_find (reader, - KMIP_TAG_ResultMessage, - KMIP_ITEM_TYPE_TextString, - &pos, - &len)) { - if (!kmip_reader_read_string ( - reader, (uint8_t **) &result_message, len)) { - KMS_ERROR (res, "unable to read result message value"); - goto fail; - } - result_message_len = (uint32_t) len; - } - - /* Look for required Result Status. */ - if (!kmip_reader_find (reader, - KMIP_TAG_ResultStatus, - KMIP_ITEM_TYPE_Enumeration, - &pos, - &len)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_ResultStatus)); - goto fail; - } - - if (!kmip_reader_read_enumeration (reader, &result_status)) { - KMS_ERROR (res, "unable to read result status value"); - goto fail; - } - - if (result_status != KMIP_RESULT_STATUS_OperationSuccess) { - KMS_ERROR (res, - "KMIP response error. Result Status (%" PRIu32 - "): %s. Result Reason (%" PRIu32 "): %s. Result Message: %.*s", - result_status, - kmip_result_status_to_string (result_status), - result_reason, - kmip_result_reason_to_string (result_reason), - result_message_len, - result_message); - goto fail; - } - - ok = true; -fail: - kmip_reader_destroy (reader); - return ok; -} - -/* -Example of a successful response to a Register request: - - - - - - - - - - - - - - - - - - */ -char * -kms_kmip_response_get_unique_identifier (kms_response_t *res) -{ - kmip_reader_t *reader = NULL; - size_t pos; - size_t len; - char *uid = NULL; - kms_request_str_t *nullterminated = NULL; - - if (!check_and_require_kmip (res)) { - goto fail; - } - - if (!kms_kmip_response_ok (res)) { - goto fail; - } - - reader = kmip_reader_new (res->kmip.data, res->kmip.len); - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_ResponseMessage)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_ResponseMessage)); - goto fail; - } - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_BatchItem)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_BatchItem)); - goto fail; - } - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_ResponsePayload)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_ResponsePayload)); - goto fail; - } - if (!kmip_reader_find (reader, - KMIP_TAG_UniqueIdentifier, - KMIP_ITEM_TYPE_TextString, - &pos, - &len)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_UniqueIdentifier)); - goto fail; - } - - if (!kmip_reader_read_string (reader, (uint8_t **) &uid, len)) { - KMS_ERROR (res, "unable to read unique identifier"); - goto fail; - } - - KMS_ASSERT (len <= SSIZE_MAX); - nullterminated = kms_request_str_new_from_chars (uid, (ssize_t) len); - -fail: - kmip_reader_destroy (reader); - return kms_request_str_detach (nullterminated); -} - -/* -Example of a successful response to a Get request: - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ -uint8_t * -kms_kmip_response_get_secretdata (kms_response_t *res, size_t *secretdatalen) -{ - kmip_reader_t *reader = NULL; - size_t pos; - size_t len; - uint8_t *secretdata = NULL; - uint8_t *tmp; - - if (!check_and_require_kmip (res)) { - goto fail; - } - - if (!kms_kmip_response_ok (res)) { - goto fail; - } - - reader = kmip_reader_new (res->kmip.data, res->kmip.len); - - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_ResponseMessage)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_ResponseMessage)); - goto fail; - } - - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_BatchItem)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_BatchItem)); - goto fail; - } - - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_ResponsePayload)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_ResponsePayload)); - goto fail; - } - - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_SecretData)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_SecretData)); - goto fail; - } - - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_KeyBlock)) { - KMS_ERROR ( - res, "unable to find tag: %s", kmip_tag_to_string (KMIP_TAG_KeyBlock)); - goto fail; - } - - if (!kmip_reader_find_and_recurse (reader, KMIP_TAG_KeyValue)) { - KMS_ERROR ( - res, "unable to find tag: %s", kmip_tag_to_string (KMIP_TAG_KeyValue)); - goto fail; - } - - if (!kmip_reader_find (reader, - KMIP_TAG_KeyMaterial, - KMIP_ITEM_TYPE_ByteString, - &pos, - &len)) { - KMS_ERROR (res, - "unable to find tag: %s", - kmip_tag_to_string (KMIP_TAG_KeyMaterial)); - goto fail; - } - - if (!kmip_reader_read_bytes (reader, &tmp, len)) { - KMS_ERROR (res, "unable to read secretdata bytes"); - goto fail; - } - secretdata = malloc (len); - memcpy (secretdata, tmp, len); - *secretdatalen = len; - -fail: - kmip_reader_destroy (reader); - return secretdata; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/.gitignore b/3rdparty/mongo-c-driver-1.26.2/src/libbson/.gitignore deleted file mode 100644 index d1b5f6118..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/.gitignore +++ /dev/null @@ -1,69 +0,0 @@ -*~ -*.a -aclocal.m4 -AUTHORS -autom4te.cache -ChangeLog -CMakeFiles -CMakeCache.txt -compile -config.* -!config.yml -configure -depcomp -.deps -.dirstamp -*.exe -INSTALL -install-sh -*.la -.libs -libtool -libbson-1.0.so* -*.lo -ltmain.sh -Makefile -Makefile.in -missing -*.o -*.pc -README -stamp-h1 -*.swp -test-libbson -test.log -test-results.json -.DS_Store -xcuserdata -tags -.lvimrc -doc/installing.page -doc/version.page -.coverage.lcov -coverage -*.gcda -*.gcno -CPackConfig.cmake -CPackSourceConfig.cmake -CTestTestfile.cmake -cmake_install.cmake - -# CMake artifacts -libbson-1.0-config-version.cmake -libbson-1.0-config.cmake -libbson-static-1.0-config-version.cmake -libbson-static-1.0-config.cmake -bson/bson-1.0-config-version.cmake -bson/bson-1.0-config.cmake -bson/bson-targets.cmake - -# Example binaries -bcon-col-view -bcon-speed -bson-check-depth -bson-depth -bson-metrics -bson-streaming-reader -bson-to-json -bson-validate -json-to-bson diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libbson/CMakeLists.txt deleted file mode 100644 index e3eaca4ff..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/CMakeLists.txt +++ /dev/null @@ -1,420 +0,0 @@ - -# .d8888b. 888 -# d88P Y88b 888 -# Y88b. 888 -# "Y888b. .d88b. 888888 888 888 88888b. -# "Y88b. d8P Y8b 888 888 888 888 "88b -# "888 88888888 888 888 888 888 888 -# Y88b d88P Y8b. Y88b. Y88b 888 888 d88P -# "Y8888P" "Y8888 "Y888 "Y88888 88888P" -# 888 -# 888 -# 888 - -cmake_minimum_required (VERSION 3.15) - -project (libbson - LANGUAGES C - # Inherit the version from mongo-c-driver - VERSION "${PROJECT_VERSION}" - DESCRIPTION "The libbson BSON serialization library" -) - -# These values are inherited from the mongo-c-driver parent. These are named as to -# match the CMake variables generated by project(). -set(libbson_VERSION_PRERELEASE ${mongo-c-driver_VERSION_PRERELEASE}) -set(libbson_VERSION_FULL ${mongo-c-driver_VERSION_FULL}) - -# Don't export symbols implicitly -set(CMAKE_C_VISIBILITY_PRESET hidden) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) - -# A tag attached to libbson artifacts, denoting the *major* API version, used to -# potentially co-locate additional future major versions. -set (BSON_API_VERSION 1.0) - -if (APPLE) - cmake_policy (SET CMP0042 OLD) -endif () - - -# .d8888b. 888 888 d8b -# d88P Y88b 888 888 Y8P -# Y88b. 888 888 -# "Y888b. .d88b. 888888 888888 888 88888b. .d88b. .d8888b -# "Y88b. d8P Y8b 888 888 888 888 "88b d88P"88b 88K -# "888 88888888 888 888 888 888 888 888 888 "Y8888b. -# Y88b d88P Y8b. Y88b. Y88b. 888 888 888 Y88b 888 X88 -# "Y8888P" "Y8888 "Y888 "Y888 888 888 888 "Y88888 88888P' -# 888 -# Y8b d88P -# "Y88P" - -# libbson-specific configuration settings. Note that we inherit all settings -# from the parent! - -mongo_setting( - BSON_OUTPUT_BASENAME "Set the output basename for the libbson library" - TYPE STRING - DEFAULT VALUE "bson" -) -# Control over what components are installed: -mongo_bool_setting( - ENABLE_STATIC_LIBBSON_INSTALL "Install static libbson" - VISIBLE_IF ENABLE_STATIC) -mongo_bool_setting( - ENABLE_SHARED_LIBBSON_INSTALL "Install shared libbson" - VISIBLE_IF ENABLE_SHARED) - - -# .d8888b. 888 888 -# d88P Y88b 888 888 -# 888 888 888 888 -# 888 88888b. .d88b. .d8888b 888 888 .d8888b -# 888 888 "88b d8P Y8b d88P" 888 .88P 88K -# 888 888 888 888 88888888 888 888888K "Y8888b. -# Y88b d88P 888 888 Y8b. Y88b. 888 "88b X88 -# "Y8888P" 888 888 "Y8888 "Y8888P 888 888 88888P' - -# Configure-time platform checks. These start as regular CMake booleans, but are -# converted to 0/1 values (with mongo_bool01) so that they can be inserted into -# bson-config.h as preprocessor values. We cannot use #cmakedefine01, as we need -# to keep compatibility with an external Autotools-generated library configuration - -include (CheckFunctionExists) -include (CheckIncludeFile) -include (CheckStructHasMember) -include (CheckSymbolExists) -include (TestBigEndian) -include (InstallRequiredSystemLibraries) -include (CheckIncludeFiles) - -# See https://public.kitware.com/Bug/view.php?id=15659 -check_symbol_exists (snprintf stdio.h BSON_HAVE_SNPRINTF) -mongo_bool01 (BSON_HAVE_SNPRINTF BSON_HAVE_SNPRINTF) -check_struct_has_member ("struct timespec" tv_sec time.h BSON_HAVE_TIMESPEC) -mongo_bool01 (BSON_HAVE_TIMESPEC BSON_HAVE_TIMESPEC) -check_symbol_exists (gmtime_r time.h BSON_HAVE_GMTIME_R) -mongo_bool01 (BSON_HAVE_GMTIME_R BSON_HAVE_GMTIME_R) -check_function_exists (rand_r BSON_HAVE_RAND_R) -mongo_bool01 (BSON_HAVE_RAND_R BSON_HAVE_RAND_R) -check_include_file (strings.h BSON_HAVE_STRINGS_H) -mongo_bool01 (BSON_HAVE_STRINGS_H BSON_HAVE_STRINGS_H) -check_symbol_exists (strlcpy string.h BSON_HAVE_STRLCPY) -mongo_bool01 (BSON_HAVE_STRLCPY BSON_HAVE_STRLCPY) -check_include_file (stdbool.h BSON_HAVE_STDBOOL_H) -mongo_bool01 (BSON_HAVE_STDBOOL_H BSON_HAVE_STDBOOL_H) -check_symbol_exists (clock_gettime time.h BSON_HAVE_CLOCK_GETTIME) -mongo_bool01 (BSON_HAVE_CLOCK_GETTIME BSON_HAVE_CLOCK_GETTIME) -check_symbol_exists (strnlen string.h BSON_HAVE_STRNLEN) -mongo_bool01 (BSON_HAVE_STRNLEN BSON_HAVE_STRNLEN) -test_big_endian (BSON_BIG_ENDIAN) - -if (WIN32) - set (BSON_OS 2) -else () - set (BSON_OS 1) -endif () - -if (BSON_BIG_ENDIAN) - set (BSON_BYTE_ORDER 4321) -else () - set (BSON_BYTE_ORDER 1234) -endif () - -configure_file ( - "${PROJECT_SOURCE_DIR}/src/bson/bson-config.h.in" - "${PROJECT_BINARY_DIR}/src/bson/bson-config.h" -) - -configure_file ( - "${PROJECT_SOURCE_DIR}/src/bson/bson-version.h.in" - "${PROJECT_BINARY_DIR}/src/bson/bson-version.h" -) - -if (ENABLE_APPLE_FRAMEWORK) - configure_file ( - "${PROJECT_SOURCE_DIR}/src/bson/modules/module.modulemap.in" - "${PROJECT_BINARY_DIR}/src/bson/modules/module.modulemap" - ) -endif () - -# 8888888b. .d888 d8b d8b 888 d8b -# 888 "Y88b d88P" Y8P Y8P 888 Y8P -# 888 888 888 888 -# 888 888 .d88b. 888888 888 88888b. 888 888888 888 .d88b. 88888b. .d8888b -# 888 888 d8P Y8b 888 888 888 "88b 888 888 888 d88""88b 888 "88b 88K -# 888 888 88888888 888 888 888 888 888 888 888 888 888 888 888 "Y8888b. -# 888 .d88P Y8b. 888 888 888 888 888 Y88b. 888 Y88..88P 888 888 X88 -# 8888888P" "Y8888 888 888 888 888 888 "Y888 888 "Y88P" 888 888 88888P' - -# Base INTERFACE library propagates in-build-tree requirements for using libbson -add_library(_libbson_build_interface INTERFACE) -# Header directories required for libbson in-source -target_include_directories(_libbson_build_interface INTERFACE - # The default src/ - src/ - # The generated src/ - ${PROJECT_BINARY_DIR}/src/ - # The source directories of the common lib: - ${mongo-c-driver_SOURCE_DIR}/src/common/ - # Generated: - ${mongo-c-driver_BINARY_DIR}/src/common/ - ) -target_link_libraries(_libbson_build_interface INTERFACE mongo::detail::c_platform) - -# Collect all source files -file(GLOB_RECURSE all_sources CONFIGURE_DEPENDS - src/*.c src/*.h - # Include common library source files within libbson itself (names - # will be mangled with MCOMMON_NAME_PREFIX) - "${mongo-c-driver_SOURCE_DIR}/src/common/*.c" - ) - -# List of the primary BSON library targets that we are building -set(bson_libs) - -if(ENABLE_STATIC) - add_library(bson_static STATIC ${all_sources}) - list(APPEND bson_libs bson_static) - # Define `BSON_STATIC` when building to suppress the annotation __declspec(dllexport). - # This prevents consumers of bson_static from exporting the symbols. - target_compile_definitions(bson_static PRIVATE BSON_STATIC) - # When consumers link against bson_static, suppress the annotation __declspec(dllimport), - # since those symbols will be available immediately at the link step: - target_compile_definitions(bson_static INTERFACE BSON_STATIC) - - if(ENABLE_PIC) - # User wants static libs to use PIC code. - set_property(TARGET bson_static PROPERTY POSITION_INDEPENDENT_CODE TRUE) - endif() -endif() - -if(ENABLE_SHARED) - add_library(bson_shared SHARED ${all_sources}) - if(WIN32) - # Add resource-definition script for Windows shared library (.dll). - configure_file(libbson.rc.in libbson.rc) - target_sources(bson_shared PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/libbson.rc) - endif() - list(APPEND bson_libs bson_shared) -endif() - -if(NOT bson_libs) - message(FATAL_ERROR "Neither bson_shared nor bson_static is going to be built. Did you mean to enable at least one of them?") -endif() - -# Set target properties for the libraries. -mongo_target_requirements( - ${bson_libs} - LINK_LIBRARIES - PUBLIC - # Build-local requirements: - $ - # Include in the install interface explicitly: - mongo::detail::c_platform - COMPILE_DEFINITIONS - PRIVATE - # Tell headers that they are part of compilation: - BSON_COMPILATION - # Enable NaN parsing in jsonsl - JSONSL_PARSE_NAN - # Set the name mangling scheme for the common libraries - MCOMMON_NAME_PREFIX=_bson_mcommon - COMPILE_OPTIONS - PRIVATE - # Macro constant INFINITY triggers constant arithmetic overflow warnings in - # VS 2013, but VS 2013 doesn't support inline warning suppression. - # Remove once support for VS 2013 is dropped. - $<$,$>:/wd4756> -) - -set_target_properties(${bson_libs} PROPERTIES - VERSION "0.0.0" - SOVERSION "0" - OUTPUT_NAME "${BSON_OUTPUT_BASENAME}-${BSON_API_VERSION}" -) -if(TARGET bson_static) - set_property(TARGET bson_static PROPERTY OUTPUT_NAME "${BSON_OUTPUT_BASENAME}-static-${BSON_API_VERSION}") -endif() - -if (ENABLE_APPLE_FRAMEWORK) - set_target_properties(bson_shared PROPERTIES - FRAMEWORK TRUE - MACOSX_FRAMEWORK_BUNDLE_VERSION ${MONGOC_VERSION} - MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${MONGOC_VERSION} - MACOSX_FRAMEWORK_IDENTIFIER org.mongodb.bson - OUTPUT_NAME "${BSON_OUTPUT_BASENAME}" - PUBLIC_HEADER "${HEADERS}" - ) -endif () - - -# 8888888888 888 -# 888 888 -# 888 888 -# 8888888 888 888 8888b. 88888b.d88b. 88888b. 888 .d88b. .d8888b -# 888 `Y8bd8P' "88b 888 "888 "88b 888 "88b 888 d8P Y8b 88K -# 888 X88K .d888888 888 888 888 888 888 888 88888888 "Y8888b. -# 888 .d8""8b. 888 888 888 888 888 888 d88P 888 Y8b. X88 -# 8888888888 888 888 "Y888888 888 888 888 88888P" 888 "Y8888 88888P' -# 888 -# 888 -# 888 - -function (add_example bin src) - set (BSON_EXAMPLE_SOURCES ${PROJECT_SOURCE_DIR}/${src}) - add_executable (${bin} ${BSON_EXAMPLE_SOURCES}) - - # Link against the shared lib like normal apps - if(TARGET bson_shared) - target_link_libraries (${bin} bson_shared) - elseif(TARGET bson_static) - target_link_libraries (${bin} bson_static) - else() - return() - endif() -endfunction () - -if (ENABLE_EXAMPLES) - add_example (bcon-col-view examples/bcon-col-view.c) - add_example (bcon-speed examples/bcon-speed.c) - add_example (bson-metrics examples/bson-metrics.c) - if (NOT WIN32) - target_link_libraries (bson-metrics m) - add_example (bson-streaming-reader examples/bson-streaming-reader.c) - endif () - add_example (bson-to-json examples/bson-to-json.c) - add_example (bson-validate examples/bson-validate.c) - add_example (json-to-bson examples/json-to-bson.c) - add_example (bson-check-depth examples/bson-check-depth.c) - add_example (creating examples/creating.c) -endif () # ENABLE_EXAMPLES - - -# 8888888 888 888 888 -# 888 888 888 888 -# 888 888 888 888 -# 888 88888b. .d8888b 888888 8888b. 888 888 -# 888 888 "88b 88K 888 "88b 888 888 -# 888 888 888 "Y8888b. 888 .d888888 888 888 -# 888 888 888 X88 Y88b. 888 888 888 888 -# 8888888 888 888 88888P' "Y888 "Y888888 888 888 - -set (BSON_HEADER_INSTALL_DIR - "${CMAKE_INSTALL_INCLUDEDIR}/libbson-${BSON_API_VERSION}" -) -function(install_export_target target) - # Tell pkg-config where the headers are going: - set_property(TARGET ${target} APPEND PROPERTY pkg_config_INCLUDE_DIRECTORIES "${BSON_HEADER_INSTALL_DIR}") - # Install the target: - install( - TARGETS "${target}" - # Important: We generate a unique export set for this target alone. - EXPORT "${target}-targets" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - INCLUDES DESTINATION "${BSON_HEADER_INSTALL_DIR}" - FRAMEWORK DESTINATION "${CMAKE_INSTALL_BINDIR}" - ) - # Install the unique export set into a file that is qualified by the name of - # the target itself. The main config-file package will search for the - # possibly-installed exported targets for the known targets. See: bson-config.cmake - install( - EXPORT "${target}-targets" - NAMESPACE mongo:: - FILE "${target}-targets.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/bson-${BSON_API_VERSION}" - ) -endfunction() - -if(ENABLE_STATIC_LIBBSON_INSTALL AND TARGET bson_static) - install_export_target(bson_static) - mongo_generate_pkg_config(bson_static FILENAME libbson-static-1.0.pc INSTALL) -endif() -if(ENABLE_SHARED_LIBBSON_INSTALL AND TARGET bson_shared) - install_export_target(bson_shared) - mongo_generate_pkg_config(bson_shared FILENAME libbson-1.0.pc INSTALL) -endif() - -# Install all headers by doing a recursive directory-install. -install( - DIRECTORY - # Trailing "/" requests directory contents, not the dir itself: - src/bson/ - # Also get the generated dir: - ${PROJECT_BINARY_DIR}/src/bson/ - DESTINATION "${BSON_HEADER_INSTALL_DIR}/bson" - # Only grab the *public* headers. - FILES_MATCHING - PATTERN "*.h" - PATTERN "*-private.h" EXCLUDE - # Installed separately below: - PATTERN "forwarding" EXCLUDE - # Don't generate an empty "modules" directory - PATTERN "modules" EXCLUDE - ) - -# The forwarding header is for compatibility with `#include `, so it goes at the top-level: -install(FILES src/bson/forwarding/bson.h DESTINATION "${BSON_HEADER_INSTALL_DIR}") - -if (ENABLE_APPLE_FRAMEWORK) - install ( - FILES "${PROJECT_BINARY_DIR}/src/bson/modules/module.modulemap" - DESTINATION "${CMAKE_INSTALL_BINDIR}/bson.framework/Modules/" - ) -endif () - -# Generate the config-file package -include (CMakePackageConfigHelpers) -write_basic_package_version_file ( - "${CMAKE_CURRENT_BINARY_DIR}/bson/bson-${BSON_API_VERSION}-config-version.cmake" - VERSION ${BSON_VERSION} - COMPATIBILITY AnyNewerVersion -) - -configure_file (src/bson-config.cmake - "${CMAKE_CURRENT_BINARY_DIR}/bson/bson-${BSON_API_VERSION}-config.cmake" - COPYONLY -) - -install ( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/bson/bson-${BSON_API_VERSION}-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/bson/bson-${BSON_API_VERSION}-config-version.cmake" - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/bson-${BSON_API_VERSION} - COMPONENT - Devel -) - -# Install the base targets. (Prior targets were installed above) -install (EXPORT bson-targets - NAMESPACE mongo:: - FILE bson-targets.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/bson-${BSON_API_VERSION} -) - -include (LegacyPackage) -include (CPack) - -# 8888888b. -# 888 "Y88b -# 888 888 -# 888 888 .d88b. .d8888b .d8888b -# 888 888 d88""88b d88P" 88K -# 888 888 888 888 888 "Y8888b. -# 888 .d88P Y88..88P Y88b. X88 -# 8888888P" "Y88P" "Y8888P 88888P' - -if (ENABLE_MAN_PAGES OR ENABLE_HTML_DOCS) - find_package (Sphinx REQUIRED) - add_subdirectory (doc) - add_custom_target (bson-doc - ALL - DEPENDS - $<$:bson-man> - $<$:bson-html> - ) -endif () diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/NEWS b/3rdparty/mongo-c-driver-1.26.2/src/libbson/NEWS deleted file mode 100644 index 49a78ce94..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/NEWS +++ /dev/null @@ -1,2000 +0,0 @@ -libbson 1.26.2 -============== - -Fixes: - - * Fix iteration in `bson_strfreev`. - -Thanks to everyone who contributed to the development of this release. - - * Ezra Chung - -libbson 1.26.1 -============== - -Fixes: - - * Use aligned alloc for `bson_array_builder_t` - -Thanks to everyone who contributed to the development of this release. - - * 0x1 Louis - -libbson 1.26.0 -============== - -No changes since 1.25.4. Version incremented to match the libmongoc version. - -libbson 1.25.4 -============== - -Fixes: - - * Restore support for Sphinx 1.7.6 for man page build. - - -libbson 1.25.3 -============== - -No changes since 1.25.2. Version incremented to match the libmongoc version. - -libbson 1.25.2 -============== - -Fixes: - - * Fix conversion warning with GCC 12. - * Include -pthread in pkg-config Libs. - -Thanks to everyone who contributed to the development of this release. - - * Calvin Buckley - * Kevin Albertson - * Roland Hieber - -libbson 1.25.1 -============== - -Fixes: - - * The `BUILD_VERSION` CMake option was restored. - * Fixes to some format strings in trace logs. - * Allow mongoc_buffer_t to be larger than INT_MAX. - -Thanks to everyone who contributed to the development of this release: - - * Adrian Dole - * Kevin Albertson - * Roberto C. Sánchez - -libbson 1.25.0 -============== - -New Features: - - * Add `bson_array_builder_t`. - -Platform Support: - - * Support for macOS 10.14 is dropped. - * Support for Ubuntu 14.04 is dropped. - * Support for Debian 8.1 is dropped. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Colby Pike - * Adrian Dole - * Roberto C. Sánchez - * Ezra Chung - * Joshua Siegel - - -libbson 1.24.4 -============== - -Fixes: - * Fix libmongoc build failure caused by missing install of `bson-dsl.h`. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - -libbson 1.24.3 -============== - -Fixes: - - * Fix parsing of `[ { $code: ... } ]` or `[{$dbPointer: ...}]`. - * Improve detection Fix use of `strerror_l`. - * Fix possible overflow parsing Decimal128 in extJSON with very large exponents. - -Thanks to everyone who contributed to the development of this release. - - * Joshua Siegel - * Ezra Chung - -libbson 1.24.2 -============== - -No changes since 1.24.1. Version incremented to match the libmongoc version. - -libbson 1.24.1 -============== - -No changes since 1.24.0. Version incremented to match the libmongoc version. - -libbson 1.24.0 -============== - -New Features: - - * Add extended JSON helpers for top-level BSON arrays `bson_array_as_canonical_extended_json` and `bson_array_as_relaxed_extended_json`. - -Language Standard Support: - - * C89 support has been dropped. C99 is the default tested C standard. - -Platform Support: - - * Support for macOS 10.14 will be dropped in an upcoming release. - * Support for Ubuntu 14.04 will be dropped in an upcoming release. - * Support for Debian 8.1 will be dropped in an upcoming release. - -Thanks to everyone who contributed to the development of this release. - - * Ezra Chung - * Kevin Albertson - * Colby Pike - * Joshua Siegel - * Jeroen Ooms - * Jean-Marc Le Roux - * Kyle Kloberdanz - * bisht2050 - * gopukrishnasIBM - * Charles Pritchard - -libbson 1.23.5 -============== - -No changes since 1.23.3. Version incremented to match the libmongoc version. - - -libbson 1.23.4 -============== - -No changes since 1.23.3. Version incremented to match the libmongoc version. - - -libbson 1.23.3 -============== - -Fix: - - * Don't use `aligned_alloc()` on Windows - -Thanks to everyone who contributed to the development of this release. - - * Jeroen Ooms - - - -libbson 1.23.2 -============== - -No changes since 1.23.1. Version incremented to match the libmongoc version. - --- Kevin Albertson - - -libbson 1.22.2 -============== - -Bug fixes: - -- Fix link errors related to atomic operations on RISC-V -- Fix compile-time errors due to type conflicts on some platforms. - -Thanks to everyone who contributed to the development of this release. - - * Ezra Chung - * Roberto C. Sánchez - - -libbson 1.23.1 -============== - -No changes since 1.23.0. Version incremented to match the libmongoc version. - - -libbson 1.23.0 -============== - -Improvements: - - * Reducing Warnings of Misaligned Address of Over-Aligned Types - -Thanks to everyone who contributed to the development of this release. - - * Ezra Chung - * Kevin Albertson - * Colby Pike - - - -libbson 1.22.1 -============== - -No changes since 1.22.0. Version incremented to match the libmongoc version. - ---Colby Pike - -libbson 1.21.2 -============== - -Announcing libbson 1.21.2. - -No changes since 1.21.1; release to keep pace with libmongoc's version. - --- Ezra Chung - -libbson 1.22.0-beta0 -==================== - -Bug fixes: - - * Fix BSON_ASSERT triggered by invalid JavaScript/JSON. - - -Thanks to everyone who contributed to the development of this release. - - * Colby Pike - * Ezra Chung - * Jesse Williamson - * MonkeybreadSoftware - - - -libbson 1.21.1 -============== - -Announcing libbson 1.21.1 - -No changes since 1.21.0; release to keep pace with libmongoc's version. - ---Jesse Williamson - - - -libbson 1.21.0 -============== - -Bug Fixes: - * Addressed VS 2013 build failures due to missing C99 features. - -Improvements: - * Addressed -Wstrict-prototype warnings in bson-atomic.h. - * Addressed incompatible pointer warnings in bson-atomic.h on GCC 4.8.5. - -Thanks to everyone who contributed to the development of this release. - - * Ezra Chung - * Kevin Albertson - * Colby Pike - * Pau Espin Pedrol - * Ryan Schmidt - - - -libbson 1.20.1 -============== - -Bug fixes: - - * Fix implicit declarations causing build failures on macOS. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Ryan Schmidt - -libbson 1.20.0 -============== - -Features: - - * Improve atomics API. - -Thanks to everyone who contributed to the development of this release. - - * Colby Pike - * Kevin Albertson - * Roberto C. Sánchez - * Ezra Chung - -libbson 1.19.2 -============== - -Announcing libbson 1.19.2. - -No changes since 1.19.1; release to keep pace with libmongoc's version. - ---Kevin Albertson - -libbson 1.19.1 -============== - -It is my pleasure to announce libbson 1.19.1. - -Bug fixes: - - * Fix string handling in BSON keys and regular expressions. - ---Kevin Albertson - - -libbson 1.19.0 -============== - -It is my pleasure to announce libbson 1.18.0. - -No changes since 1.18.0; release to keep pace with libmongoc's version. - ---Kevin Albertson - -libbson 1.18.0 -============== - -It is my pleasure to announce libbson 1.18.0. - -Features: - - * Add BSON to JSON encoder that limits encoded string length. - * Support parsing $uuid into a binary UUID. - * Relax validation for insert and replace documents to support fields containing dots and dollars. - -Improvements: - - * Add trailing space after base64 JSON field for consistency. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Roberto C. Sánchez - * Jeremy Mikola - * Andreas Braun - * Benjamin Rewis - * Richard Donkin - * David Korczynski - * Josh Weinstein - * David Carlier - * Andrew Witten - * Tim Gates - ---Kevin Albertson - -libbson 1.18.0-alpha -==================== - -It is my pleasure to announce libbson 1.18.0-alpha. - -This is an unstable prerelease and is unsuitable for production applications. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Roberto C. Sánchez - * Benjamin Rewis - * Richard Donkin - * Andreas Braun - * Tim Gates - * Andrew Witten - * David Carlier - * David Korczynski - * Josh Weinstein - ---Kevin Albertson - -libbson 1.17.7 -============== - -It is my pleasure to announce libbson 1.17.7. - -No changes since 1.17.6; release to keep pace with libmongoc's version. - ---Kevin Albertson - - -libbson 1.17.6 -============== - -It is my pleasure to announce libbson 1.17.6. - -No changes since 1.17.5; release to keep pace with libmongoc's version. - --- Kevin Albertson - - -libbson 1.17.5 -============== - -It is my pleasure to announce libbson 1.17.5. - -Bug fixes: - - * Remove unnecessary dependency of libm for static libbson on macOS - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - ---Kevin Albertson - - -libbson 1.17.4 -============== - -It is my pleasure to announce libbson 1.17.4. - -No changes since 1.17.3; release to keep pace with libmongoc's version. - --- Kevin Albertson - - -libbson 1.17.3 -============== - -No changes since 1.17.2; release to keep pace with libmongoc's version. - --- Kevin Albertson - - -libbson 1.17.2 -============== - -No changes since 1.17.1; release to keep pace with libmongoc's version. - --- Kevin Albertson - - -libbson 1.17.1 -============== - -No changes since 1.17.0; release to keep pace with libmongoc's version. - --- Kevin Albertson - - -libbson 1.17.0 -============== - -It is my pleasure to announce libbson 1.17.0. - -Features: - - * Add the cmake option ENABLE_PIC to build static libraries with position independent code. - -Bug fixes: - - * Fix possible int32 overflow when comparing and constructing large bson_t's. - * Fix pedantic compiler warnings. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Richard Donkin - * Roberto C. Sánchez - * Josh Weinstein - --- Kevin Albertson - - -libbson 1.17.0 rc0 -================== - -It is my pleasure to announce libbson 1.17.0 rc0. - -No changes since 1.17.0 beta2; release to keep pace with libmongoc's version. - --- Kevin Albertson - - -libbson 1.17.0 beta2 -==================== - -It is my pleasure to announce libbson 1.17.0 beta2. - -Features: - - * Fix pedantic compiler warnings. - * Improve assertion error messages. - -Bug fixes: - - * Fix possible int32 overflow when comparing and constructing large bson_t's. - -Thanks to everyone who contributed to the development of this release. - - * Richard Donkin - * Roberto C. Sánchez - * Josh Weinstein - * Kevin Albertson - --- Kevin Albertson - - -libbson 1.17.0 beta -=================== - -It is my pleasure to announce libbson 1.17.0 beta. - -Features: - - * Add the cmake option ENABLE_PIC to build static libraries with position independent code. - -Notes: - - * Deprecated "lib" prefixed artifacts are no longer produced when building on Windows. - -Thanks to everyone who contributed to the development of this release. - - * Roberto C. Sánchez - * Kevin Albertson - * Jeroen Ooms - --- Kevin Albertson - - -libbson 1.16.1 -============== - -It is my pleasure to announce libbson 1.16.1. - -Features: - - * Add bson_isspace, a safer isspace alternative. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - -Peace, - - Kevin Albertson - - -libbson 1.16.0 -============== - -It is my pleasure to announce libbson 1.16.0. - -Bug fixes: - - * Fix crash if an empty BSON binary value is copied and then appended. - * Fix out-of-bounds read when parsing JSON. - * Fix out-of-bounds read when parsing base64. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Roberto C. Sánchez - * Clyde Bazile - * Diego Barrios Romero - * Vasil Velichkov - -Peace, - - Kevin Albertson - -libbson 1.15.3 -============== - -It is my pleasure to announce libbson 1.15.3. - -No changes since 1.15.2; release to keep pace with libmongoc's version. - --- Kevin Albertson - -libbson 1.15.2 -============== - -It is my pleasure to announce libbson 1.15.2. - -No changes since 1.15.1; release to keep pace with libmongoc's version. - --- Kevin Albertson - -libbson 1.15.1 -============== - -No change since 1.15.0; released to keep pace with libmongoc's version. - --- Clyde Bazile - - -libbson 1.15.0 -============== - -No change since 1.14.1; released to keep pace with libmongoc's version. - --- Kevin Albertson - -libbson 1.14.1 -============== - -It is my pleasure to announce libbson 1.14.1. - -Bug fixes: - - * Remove unnecessary dependencies from pkg-config. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - -Peace, - - Kevin Albertson - - -libbson 1.14.0 -============== - -It is my pleasure to announce libbson 1.14.0. - -Features: - - * ObjectIDs are generated in compliance with the driver ObjectID spec. - * Add a bson_copy_to_excluding_noinit variant taking a va_list. - * Add example of validating BSON nesting depth with bson_visitor_t. - -Bug fixes: - - * Relaxed JSON pads datetime milliseconds with spaces instead of zeroes. - - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Roberto C. Sánchez - * A. Jesse Jiryu Davis - * Henrik Edin - * Jeroen - * Gustaf Neumann - * Scott Gayou - * Spencer McKenney - * Samantha Ritter - -Peace, - - Samantha Ritter - - -libbson 1.13.1 -============== - -It is my pleasure to announce libbson 1.13.1. - -Bug fixes: - - * Separate libmongoc and libbson uninstall scripts so they do not overwrite - each other. - -Thanks to everyone who contributed to the development of this release. - - * Kevin Albertson - * Henrik Edin - -Peace, - - Kevin Albertson - - -libbson 1.13.0 -============== - -It is my pleasure to announce libbson 1.13.0. - -Features: - - * New functions to save and restore progress of a bson_iter_t: - bson_iter_key_len, bson_iter_offset, and bson_iter_init_from_data_at_offset - * Additional functions bson_iter_overwrite_date_time, bson_iter_overwrite_oid, - and bson_iter_overwrite_timestamp. All fixed-length BSON values can now be - updated in place. - -Bug fixes: - - * Fix crash when iterating corrupt BSON. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Roberto C. Sánchez - * Kevin Albertson - * Henrik Edin - * Gustaf Neumann - * Scott Gayou - * Spencer McKenney - -Peace, - - Kevin Albertson - - -libbson 1.12.0 -============== - -It is my pleasure to announce libbson 1.12.0. This release deprecates all -MD5-related public APIs; they will be removed in the next major release. - -Bug fixes: - - * Properly handle zero-length BSON binary values - * Fix crash parsing Base64-encoded data in JSON when using libbson without - libmongoc - -Thanks to everyone who contributed to the development of this release. - - * Roberto C. Sánchez - * A. Jesse Jiryu Davis - * Kevin Albertson - -Peace, - - A. Jesse Jiryu Davis - - -libbson 1.11.0 -============== - -It is my pleasure to announce libbson 1.11.0. This version adds the following -features and improvements: - - * All "destroy" functions such as bson_destroy or bson_reader_destroy now - ignore a NULL argument. - * Replace MD5 with FNV-1a hash to generate ObjectIds (for FIPS compliance). - -Bug fixes: - - * Functions incorrectly marked with the "const" compiler attribute are now - marked as "pure", fixes build error when link-time optimization is enabled. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Kevin Albertson - * Roberto C. Sánchez - -Peace, - - A. Jesse Jiryu Davis - - -libbson 1.10.3 -============== - -It is my pleasure to announce libbson 1.10.3. This release fixes a crash when -parsing binary data from JSON if using libbson as a standalone library, without -calling mongoc_init. - -Peace, - - A. Jesse Jiryu Davis - - -libbson 1.10.2 -============== - -No change since 1.10.1; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -libbson 1.10.1 -============== - -No change since 1.10.0; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -libbson 1.10.0 -============== - -It is my pleasure to announce libbson 1.10.0. This version adds the following -features: - - * libbson and libmongoc are now maintained in the mongo-c-driver repository, - although they are still built as separate libraries, and libbson can still - be used without libmongoc. - * Building libbson and libmongoc now requires CMake on all platforms. The - Autotools build scripts ("configure" and related scripts) have been deleted. - See the "installing" page for updated instructions. - * Additional functions for strings of known length (not necessarily null- - terminated): - bson_iter_find_w_len - bson_iter_init_find_w_len - bson_append_regex_w_len - bson_decimal128_from_string_w_len - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Roberto C. Sánchez - * Xiangyu Yao - * Kevin Albertson - * Mansuro - * Petr PísaÅ™ - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.9.5 -============= - -No change since 1.9.4; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.9.4 -============= - -It is my pleasure to announce Libbson-1.9.4. This release offers compatibility -with Sphinx 1.7.0 and later. - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.9.3 -============= - -No change since 1.9.2; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.9.2 -============= - -It is my pleasure to announce Libbson-1.9.2. This release completes reverting a -changed macro definition that broke API compatibility. The revert in 1.9.1 did -not completely fix the BC break. Thanks to Petr PísaÅ™ for finding and fixing the -mistake. - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.9.1 -============= - -It is my pleasure to announce Libbson-1.9.1. This release reverts a changed -macro definition that broke API compatibility, and fixes an off-by-one error -in bson_append_regex that resulted in corrupt BSON. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Derick Rethans - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.9.0 -============= - -It is my pleasure to announce Libbson-1.9.0. - -New features and bugfixes: - - * Fix Autotools syntax for OpenBSD and any platform lacking stdint.h. - * Fix Android NDK incompatibilities. - * Fix a one-byte write past the end of a buffer in bson_decimal128_to_string. - * Avoid reading past the end of a string that contains UTF-8 multibyte NIL. - * Fix some pedantic warnings in C99 mode. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Kevin Albertson - * Jean-Marc Le Roux - * Jeremy Mikola - * Dimitri Gence - * Hannes Magnusson - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.8.2 -============= - -No change since 1.8.1; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.8.1 -============= - -It is my pleasure to announce libbson-1.8.1. This release removes a syntax -error in the configure script that affects some shells, and fixes the encoding -of this NEWS file. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Jeremy Mikola - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.8.0 -============= - -It is my pleasure to announce Libbson-1.8.0. - -New features and bugfixes: - - * Make symbols bson_get_major_version, bson_get_minor_version, - bson_get_micro_version, bson_get_version, and bson_check_version available - to C++ programs. - * New CMake option ENABLE_MAINTAINER_FLAGS. - * Crash iterating over invalid code with scope. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Jeremy Mikola - * Kevin Albertson - * Michael Kuhn - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.7.0 -============= - - * Changes to JSON encoding and decoding: - * New functions bson_as_canonical_extended_json and - bson_as_relaxed_extended_json convert BSON to canonical and relaxed - extended JSON according to MongoDB Extended JSON Spec. - Output for the existing bson_as_json function has not been changed. - * When parsing JSON type wrappers like "$timestamp", any missing or extra - keys are an error. - * The JSON format for BSON regular expressions is now "$regularExpression": - {"pattern": "...", "options": "..."}. The old format {"$regex": "...", - "$options": "..."} is still parsed. - * The JSON format for BSON binary elements is now "$binary": {"base64": - "...", "subType": "..."}. The old format {"$binary": "...", "$type": - "..."} is still parsed. - * BSON dates can be parsed from "$date" as an ISO8601 date or "$numberLong" - as milliseconds since the epoch: "t": {"$date": {"$numberLong": "1234"}}. - Dates can no longer be formatted as raw integers. bson_as_json writes a - BSON date after 1970 as "$date" with an ISO8601 string, and dates before - 1970 as negative milliseconds wrapped in "$numberLong". - bson_as_canonical_extended_json always writes dates with "$numberLong". - bson_as_relaxed_extended_json always writes dates with "$date". - * The non-numbers NaN, Infinity, and -Infinity are now recognized (regardless - of case) when parsing JSON. - * CMake build now installs .pc files for programs that link to libbson using - pkg-config. Both the CMake and Autotools build systems now install .cmake - files for programs that link to libbson using CMake. Linking to libbson - statically or dynamically is now much more convenient. - * New CMake option, "ENABLE_STATIC", defaults to ON. - * Minimum required CMake version has been increased to 3.1. - * CMake remains experimental on non-Windows platforms and issues a warning now - * New functions - * bson_strcasecmp, a portable equivalent of strcasecmp. - * bson_iter_as_double, cast the current value to double. - * bson_iter_init_from_data, creates an iterator from BSON string. - * bson_validate_with_error, checks a document like bson_validate does but - also reports which key was invalid - * New convenience macros - * BSON_ITER_HOLDS_INT, checks if iterator holds int32 or int64 - * BSON_ITER_HOLDS_NUMBER, checks if iterator holds int32, int64 or double - * Raised BSON recursion limit to 200 - - -Libbson-1.6.0 -============= - -It is my pleasure to announce libbson-1.6.0. - -New features and bug fixes: - - * Use jsonsl instead of libyajl as our JSON parsing library, parse JSON more - strictly, fix minor parsing bugs. - * Extended JSON documents like '{"$code": "...", "$scope": {}}' are now parsed - into BSON "code" elements. - * ISO8601 dates now allow years from 0000 to 9999 inclusive. Before, years - before 1970 were prohibited. - * BSON floats and ints are now distinguished in JSON output. - * The library is now built and continuously tested with MinGW-W64 on Windows. - * The documentation is ported from Mallard XML to ReStructured Text, the - HTML documentation is restyled, and numerous man page syntax errors fixed. - * All public functions now have the __cdecl calling convention on Windows. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Aleksander Melnikov - * Remi Collet - -Peace, - - A. Jesse Jiryu Davis - - -libbson-1.5.5 -============= - -No change since 1.5.4; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.5.4 -============= - -No change since 1.5.3; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.5.3 -============= - -No change since 1.5.2; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.5.2 -============= - -This is a patch release that fixes a build error with MinGW on Windows. - - -Libbson-1.5.1 -============= - -No change since 1.5.0; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.5.2 -============= - -It is my pleasure to announce Libbson-1.5.2. - -New bug fixes: - - * CDRIVER-1982 fix ifdef for strerror_s with mingw. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - -Peace, - - Hannes Magnusson - - -Libbson-1.5.1 -============= - -No change since 1.5.0; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.5.0 -============= - -It is my pleasure to announce Libbson-1.5.0. - -New features and bug fixes: - - * New BSON Type, Decimal128 (bson_decimal128_t) along with the following - new functions and helpers: - * bson_decimal128_to_string() - * bson_decimal128_from_string() - * bson_iter_decimal128() - * bson_iter_overwrite_decimal128() - * BSON_ITER_HOLDS_DECIMAL128() - * bson_append_decimal128() - * BSON_APPEND_DECIMAL128() - * BCON_DECIMAL128() - See the documentations for further details. - * bson_validate and bson_iter_next now validate that BSON boolean values are - 0 or 1. Before, any non-zero value was considered true. - * bson_append_code_with_scope now preserves the "code with scope" type - if scope is an empty, non-NULL BSON document. - * BSON "code" and "code with scope" types are properly translated to and from - JSON of the form '{"$code": "...", "$scope": {...}}'. - * bson_json_reader functions now always validate UTF-8. - * JSON parsing now preserves integer width. - * bson_strtoll now matches stroll: it detects range errors, and when - parsing octal it stops at non-octal digits and returns what it parsed - instead of setting errno. - * New flag BSON_VALIDATE_EMPTY_KEYS causes bson_validate to fail if a document - contains zero-length field names. - * The configure option "--enable-hardening" had had no effect. It is removed - in favor of system-wide compiler configuration. - -Thanks to everyone who contributed to the development of this release. - - * Hannes Magnusson - * A. Jesse Jiryu Davis - * Fiona Rowan - * Brian Samek - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.4.1 -============= - -This release improves the HTML documentation's Makefile. - --- A. Jesse Jiryu Davis - - -Libbson-1.4.0 -============= - -It is my pleasure to announce Libbson-1.4.0. - -New features and bug fixes: - - * bson_reader_reset seeks to the beginning of a BSON buffer. - * bson_steal efficiently transfers contents from one bson_t to another. - * Fix Windows compile error with BSON_EXTRA_ALIGN disabled. - * Potential buffer overrun in bson_strndup. - * bson_oid_to_string optimization for MS Visual Studio - * bson_oid_is_valid accepts uppercase hex characters. - * bson_json_reader_read aborted on some invalid Extended JSON documents. - * All man page names now begin with "bson_" to avoid install conflicts. - * Error messages sometimes truncated at 63 chars. - -This release tentatively supports the new BSON decimal type when built with -"./configure --enable-experimental-features", or with -"cmake -DENABLE_EXPERIMENTAL_FEATURES=ON", but this feature may change -between now and libbson 1.5. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Jeremy Mikola - * David Hatch - * Ian Boros - * Fiona Rowan - * Shane Harvey - * Runar Buvik - * Raymond Jacobson - * ReadmeCritic - * Mike Lloyd - * Derick Rethans - * Maverick Chan - -Peace, - - A. Jesse Jiryu Davis - -Libbson-1.3.5 -============= - -No change since 1.3.4; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.3.4 -============= - -No change since 1.3.3; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.3.3 -============= - -No change since 1.3.2; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.3.2 -============= - -This is a patch release with a fix for the build system: - - * man pages couldn't be built from a distribution tarball. - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.3.1 -============= - -It is my pleasure to announce Libbson-1.3.1. This is a bugfix release: - - * bson_strnlen is off by one on Windows. - * BSON_HAVE_STRNLEN config check used incorrectly. - * Incompatibility with older CMake versions. - * Wrong-sized allocation in bson_json_reader_new. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Alex Bishop - * Jeroen Ooms - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.3.0 -============= - -It is my pleasure to announce to you the release of Libbson-1.3.0. Since the -release candidate 1.3.0-rc0, the only changes have been fixes for compiler -warnings and errors on various platforms. - -All changes since the previous stable release, 1.2.1: - - * Fix potential crash in bson_strncpy on Windows. - * Parse DBRefs correctly from JSON. - * CMake option to disable building tests: "cmake -DENABLE_TESTS:BOOL=OFF". - * Refactor the build system to declare library version in one place. - * Fix compiler warnings and errors, especially with Visual Studio 2015 - and IBM XL C. - * Combine environment's CFLAGS with configure options when building. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Mark Benvenuto - * Petr PísaÅ™ - * xpol - * Jose Sebastian Battig - * Jeroen Ooms - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.3.0-rc0 -================= - -It is my pleasure to announce to you first release candidate of Libbson-1.3.0. - -Changes since 1.3.0-beta0: - - * Parse DBRefs correctly from JSON. - * CMake option to disable building tests: "cmake -DENABLE_TESTS:BOOL=OFF". - * Fix build warnings on some platforms, and refactor the build system. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Jose Sebastian Battig - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.3.0-beta0 -=================== - -It is my pleasure to announce to you the beta release of Libbson-1.3.0. - -Changes since the previous stable release, 1.2.1: - - * Fix potential crash in bson_strncpy on Windows. - * Fix compiler warnings and errors, especially with Visual Studio 2015 - and IBM XL C. - * Combine environment's CFLAGS with configure options when building. - -Thanks to everyone who contributed to the development of this release. - - * Hannes Magnusson - * A. Jesse Jiryu Davis - * Jeroen Ooms - * Petr PísaÅ™ - * xpol - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.2.1 -============= - -It is my pleasure to announce to you the release of Libbson-1.2.1. - -Changes since the previous stable release, 1.2.0 are solely in the content -and format of documentation. - -Peace, - - A. Jesse Jiryu Davis - - -Libbson-1.2.0 -============= - -It is my pleasure to announce to you the release of Libbson-1.2.0. - -Changes since the previous stable release, 1.1.11: - - * Add bson_mem_restore_vtable(), the inverse of bson_mem_set_vtable(). - * Enable runtime asserts in release build. - * Fixed compiler warnings and build failures on various platforms. - * Improvements to the formatting and contents of the documentation. - -Thanks to everyone who contributed to the development of this release. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Jason Carey - * Kyle Suarez - * Derick Rethans - * David Hatch - -Peace, - - A. Jesse Jiryu Davis - - -Libbson 1.2.0-rc0 -================== - -It is my pleasure to announce to you the release candidate of Libbson-1.2.0. - -Changes: - - * Merge changes from 1.1.11. - * Enable runtime asserts in release build. - -Thanks to everyone who contributed to the development of this release candidate. - - * A. Jesse Jiryu Davis - * Hannes Magnusson - * Kyle Suarez - * Jason Carey - --- A. Jesse Jiryu Davis - - -Libbson 1.2.0-beta -================== - -It is my pleasure to announce to you the beta of Libbson-1.2.0. - -This release adds the bson_mem_restore_vtable() function to undo the effect -of bson_mem_set_vtable(). - -Thanks to everyone who contributed to the development of this beta. - - * Jason Carey - * Hannes Magnusson - - -Libbson-1.1.11 -============== - -It is my pleasure to announce to you the release of Libbson-1.1.11. - -This is a patch release with improvements to the documentation: - - * Document bson streaming reads with an example, - bson-streaming-reader.c. - * Document callback function types bson_reader_destroy_func_t and - bson_reader_read_func_t. - -Thanks to Kyle Suarez for his contributions to this version of Libbson. - --- A. Jesse Jiryu Davis - - -Libbson-1.1.10 -============== - -No change since 1.1.9; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.1.9 -============= - -This is a patch release with a fix for the build system: - - * "./configure --enable-coverage" works now. - --- A. Jesse Jiryu Davis - - -Libbson-1.1.8 -============= - -No change since 1.1.7; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson-1.1.7 -============= - -It is my pleasure to announce to you the release of Libbson-1.1.7. - -This is a patch release with bug fixes: - - * Unchecked error in bson_utf8_escape_for_json caused unbounded memory growth - and a crash. - * Nicer floating-point formatting in bson_as_json. - * Link error with CMake on Mac. - -Thanks to everyone who contributed to this version of Libbson. - - * A. Jesse Jiryu Davis - * Jason Carey - * Jeroen Ooms - * Hannes Magnusson - * Hendrik Dahlkamp - --- A. Jesse Jiryu Davis - - -Libbson-1.1.6 -============= - -No change since 1.1.5; released to keep pace with libmongoc's version. - --- A. Jesse Jiryu Davis - - -Libbson 1.1.5 -============= - -It is my pleasure to announce to you the release of Libbson-1.1.5. - -This is a patch release with small bug fixes: - - * Fix link error "missing __sync_add_and_fetch_4" in GCC on i386 - - the functions bson_atomic_int_add and bson_atomic_int64_add are now - compiled and exported if needed in i386 mode - * Fix version check for GCC 5 and future versions of Clang - * Fix warnings and errors building on various platforms - -With this release, Libbson abandons the convention that odd-numbered patch -versions indicate unstable releases. We switch to simple semantic versioning: -1.1.5 is a stable release with bug fixes since 1.1.4. During subsequent -development the version will be "1.1.6-dev". - -Thanks to everyone who contributed to this version of Libbson. - - * A. Jesse Jiryu Davis - * Christian Hergert - * Jason Carey - * Hannes Magnusson - * Paul Melnikow - --- A. Jesse Jiryu Davis - -Libbson 1.1.4 -============= - -It is my pleasure to announce to you the release of Libbson-1.1.4. - -This release is a minor patch release with one bug fix for bson_iter_timeval - -Thanks to everyone who contributed to the development of this release candidate for -Libbson. - - * Jason Carey - * A. Jesse Jiryu Davis - * Vladimir Zidar - --- Jason Carey - -Libbson 1.1.2 -============= - -It is my pleasure to announce to you the release of Libbson-1.1.2. - -This release is a minor patch release with one bug fix for mingw. - -* sscanf_s doesn't exist for mingw. - --- Jason Carey - -Libbson 1.1.0 -============= - -It is my pleasure to announce to you the release of Libbson-1.1.0. - -This release is a stable release with some ABI additions and bugfixes. - -The below changes include the changes mentioned in the rc0. - -ABI/API changes include: - * RC0 - * Deprecation of bson_copy_to_excluding - * Addition of bson_copy_to_excluding_noinit - * Removal of MIN, MAX and ABS macros in favor of BSON_MIN, BSON_MAX and - BSON_ABS. Note this is a breaking source level change if you relied on - these from bson.h. Also note that this is not a breaking ABI change. - * Addition of BSON_ERROR_BUFFER_SIZE macro - -Other changes include: - * RC0 - * Addition of a versioned ABI for the libbson shared library - * fixed bson_get_monotonic_time fallback when a system monotonic clock can not - be found. Formerly failed to compile with an incorrect call to - bson_gettimeofday - * Allow the "dbref" convention in bson_validate when BSON_VALIDATE_DOLLAR_KEYS - is present - * Support for ISO-8601 or $numberLong dates in bson <-> json parsing - * Quiet various compiler warnings - -Thanks to everyone who contributed to the development of this release candidate for -Libbson. - - * Adam Midvidy - * Christian Hergert - * Daniel Colchete - * Ivan Suvorov - * Hannes Magnusson - * Jason Carey - * Jérôme Lebel - * Samantha Ritter - --- Jason Carey - -Libbson 1.1.0-rc0 -================= - -It is my pleasure to announce to you the release of Libbson-1.1.0-rc0. - -This release is a release candidate release with some ABI additions and bugfixes. - -ABI changes include: - * Deprecation of bson_copy_to_excluding - * Addition of bson_copy_to_excluding_noinit - -Other changes include: - * Addition of a versioned ABI for the libbson shared library - * fixed bson_get_monotonic_time fallback when a system monotonic clock can not - be found. Formerly failed to compile with an incorrect call to - bson_gettimeofday - * Allow the "dbref" convention in bson_validate when BSON_VALIDATE_DOLLAR_KEYS - is present - * Support for ISO-8601 or $numberLong dates in bson <-> json parsing - * Quiet various compiler warnings - -Thanks to everyone who contributed to the development of this release candidate for -Libbson. - - * Adam Midvidy - * Christian Hergert - * Daniel Colchete - * Ivan Suvorov - * Jason Carey - * Jérôme Lebel - --- Jason Carey - -Libbson 1.0.2 -============= - -It is my pleasure to announce to you the release of Libbson-1.0.2. - -This release is a minor point release with no ABI changes and mostly small -bugfixes. - -Changes include: - * bson_init_from_json supports top level arrays - * fixes for bson_strerror_r - * fix for timeouts on OS X - * house cleaning for various integer types - -Thanks to everyone who contributed to the development of this point release for -Libbson. - - * Adam Midvidy - * Christian Hergert - * Jason Carey - * Jérôme Lebel - * Tyler Brock - --- Jason Carey - -Libbson 1.0.0 -============= - -It is my very distinct pleasure to announce to you the release of -Libbson-1.0.0! - -This is the culmination of just over a year of work and could not have been -done without the help of our wonderful community. - -Thanks to everyone who contributed to the development of Libbson! - - * Christian Hergert - * Jason Carey - * Jose Sebastian Battig - * Maxim Zakharov - * Jérôme Lebel - * Itay Neeman - * Mike Manilone - * Michael Kuhn - * Kyle Suarez - * Josh Blum - * Jason Choy - * mntmnt7@gmail.com - * Tyler Brock - * Stefan Kaes - * Paul Melnikow - * Matt Cotter - * Gary J. Murakami - * Toon Schoenmakers - * Máximo Cuadros - * Michael Whittaker - * Kota Yamaguchi - * Justin Case - * Jeff Yemin - * Ivan Suvorov - * Hannes Magnusson - * Eric Daniels - * Anil Kumar - * A. Jesse Jiryu Davis - -Happy Hacking! - --- Christian Hergert - - -Libbson 0.98.0 -============== - -One more step closer to a 1.0! - -This release has a few fixes as we near the finish line of a 1.0 release. -We have bumped the version to 0.98.0 to sync up with MongoDB C driver, which -is the primary consumer of this library. - -This release includes a new memory callback vtable to help in embedding -situations that have their own custom allocator such as various language -runtimes. - -A few compilation fixes for various C++ compilers have also been included. - -A special thanks to: - - * Itay Neeman - * Michael Whittaker - -Happy Hacking! - --- Christian - - -Libbson 0.8.4 -============= - -Another incremental release with a couple of new functions and bugfixes. - -In this release you will find the following changes: - - * Alignment fixes for Solaris Studio C compiler. - * RPM and Debian packaging helpers. - * bson_gettimeofday() has dropped the deprecated timezone field used - when calling posix gettimeofday(). This eases portability concerns. - It is technically an ABI break, but since the field was never set, - in reality it shouldn't be an issue. - * Multi-byte optimizations for bson_oid_to_string() have been disabled - on non-x86 based platforms. This should aid in architecture portability. - * The JSON parser can now support $numberLong. - * bson_ascii_strtoll() has been added, which is a portable strtoll() - implementation. This is primarily useful for Windows users and is - used by the JSON parser. - * A bug was fixed in bson_iter_find_descendent() where the wrong field - could be matched if it's prefix matched the query. - * bson_array_as_json() has been added to convert a bson_t as a top-level - array. - -Thanks to: - * Kyle Suarez - * Itay Neeman - -Happy Hacking! - - -Libbson 0.8.2 -============= - -A bugfix release is here as a follow up to 0.8.0. - -In this release you will find the following changes: - - * A fix for BCON when used from C++. - * Change bson_next_power_of_two() to accept size_t. This should not be - an ABI break since it is static inline. - -Happy Hacking! - - -Libbson 0.8.0 -============= - -It's that time again, time for another Libbson release! - -This cycle includes much, much more documentation for your perusing. There is -much more cross-referencing and structure for your navigation pleasure. - -We've improved support for Libbson on a few more exotic platforms. SPARC -support is looking pretty good these days. - -You'll also find some new examples in this release to help you get started a -bit faster. If there is something you'd like to see, just ask! - -There are a few ABI breaks this cycle, as we are well on the road to a 1.0 and -would like things as clean as possible. I anticipate a few more during the next -couple of cycles, but we will try to keep them to a minimum. With that said, -you *WILL* need to recompile your application against 0.8.0. - -Happy Hacking! - - -Libbson 0.6.8 -============= - -Quickly following up on the 0.6.6 release is 0.6.8. This release contains -a couple of bugfixes and more support for older architectures. - -On big-endian systems, bson_append_date_time() was not properly converting -to little-endian. This is now fixed. - -We've added support for Sun Pro C Compiler on Solaris 10 and 11. This includes -support for SPARC systems as well as x86_64. In particular, intrinsics were -added for the Solaris/SPARC/SunProC combination. If you are running SunProC -on a non-Solaris platform, a fallback path will be used which is slower than -native support for atomics. Additionally, bson_gettimeofday() does not fully -support timezones under SunProC as struct timezone is not defined. - -Libbson will now check for GLibc 2.19 to remove various warnings with both -_GNU_SOURCE and _BSD_SOURCE defined. - -Happy Hacking! - - -Libbson 0.6.6 -============= - -Another release for your hacking pleasure! - -First off, note that there are two ABI breaks as part of this release. We -felt they were important as they will help us stablize towards a 1.0 release. -It is recommended that you recompile against this version of libbson. - -Lots of small fixes went into this release to help get things building better -on various platforms. Windows support should be improved and many warnings have -been cleaned up. - -The signature of bson_realloc_func has changed to allow for context to be -provided. This should help in situations where a pointer to the memory pool is -required. - -bson_destroy_with_steal() has been added so that you can steal a buffer instead -of freeing it when bson_destroy() is called. - -bson_new_from_buffer() has been added so that you can provide your own realloc -function to manage the underlying buffer. This will be useful for bindings that -want to integrate their memory manager for bson documents. - -bson_value_t is a new container type that can hold any bson type. - -I'd like to thank everyone who contributed to this release. - - Gary Murakami - Jason Carey - Jose Sebastian Battig - Máximo Cuadros - Paul Melnikow - Stefan Kaes - -Happy hacking! - -Libbson 0.6.4 -============= - -This is just a followup release of libbson as we work towards stablizing for -the new mongo-c-driver release. In fact, it only includes build work and a -new macro, bson_clear(). - -Happy hacking! - - -Libbson 0.6.2 -============= - -A new Libbson release is already here as a follow up to the 0.6.0 release. - -This release includes a few build and installation fixes. In particular, - - * Windows build fixes - * CMake build fixes - * C++ build fixes. - -The monotonic clock is now more accurately calculated on Windows as well. -If you'd like to build on Windows, check out the section in README.md for -information on how to do so. - -Happy hacking! - - -Libbson 0.6.0 -============= - -Many changes have gone into this release! - -TL;DR - - * C99 types (from C89). - * JSON parsing. - * Lots of Operating System support, including Windows. - * Parallel Test Suite. - * Revamped build system. - * A couple ABI breaks. - -First off, 0.6.0 has gone through a significant amount of build system cleanup. -This should simplify using libbson as a submodule for those that wish to do so. -For example, the mongo-c-driver now does this using autotools. - -Windows Vista and higher is now supported as a build target through the use of -cmake. See README.md for the instructions. Other platforms should continue to -use autotools. - -The test suite has been improved and more tests added. We now generate random -seeds on every run to help catch more errors with additional fuzzing passes. -By default, the test suite will run all tests in parallel with subprocesses. -This should speed up execution of `make test' for contributors. - -bson_string_t went through an ABI break to support power-of-two growth. - -JSON parsing has been added through the bson_json_reader_t type. You can also -now use bson_init_from_json() for a simplified interface. - -Types were revamped to appear to be using C99 types. If C99 types are -available, they will be used. If not, they will be emulated. This means you -can just go on using uint64_t and similar. We even use bool now. - -Many functions have been made portable to deal with inconsistencies with Win32. - -This release has been tested on the following operating systems: - - * RedHat Enterprise 5, 6, and 7 beta. - * CentOS 6.5 - * Ubuntu 12.04 LTS - * Fedora 20 - * Windows 7 - * FreeBSD 10 - * DragonFly BSD - * Solaris 11 - * SmartOS - * mingw64 - -Thanks again and enjoy using libbson! - -Libbson 0.4.0 -============= - -This release includes a few bug fixes and copious documentation. Additionally, -we improved our fuzz testing and found a couple issues in the process. It is -suggested that everyone upgrade their installations to 0.4.0. - -We have been busy adding a lot of documentation that we hope you will like. -Many `man' pages have been added for various API endpoints and structures. If -you use vim, remember that you can jump to the documentation with k -while on a symbol. - -Thanks and enjoy using libbson! - -Libbson 0.2.4 -============= - -This release includes some more performance improvements and bug fixes. - -It contains an important fix for dealing with invalid string lengths that could -cause an integer overflow when checking to see if the string length fits within -the end of the buffer. - -There is preliminary support for Solaris on x86_64 and SPARC. - -Generating OIDs is now simpler with the use of bson_context_get_default(). This -function will return a thread-safe generic bson_context_t implementation. -Alternatively, you may pass NULL to bson_oid_init() for the context and the -default context is automatically used. - -The fuzz tests now use srand() with a 32-bit integer derived from /dev/urandom. - -Endianess conversions are now performed by __builtin_bswap*() functions when -available with the GCC compiler. - -Endianness conversions for the double type are now properly handled on -big-endian systems. - -bson_reinit() has been added to cleanup code that needs to destroy and then -initialize a bson_t. - -Validation of Code with Scope fields was absent from bson_validate(). This is -now supported. - -Libbson 0.2.2 -============= - -This release includes a few performance improvements and bug fixes. - -The bson_t structure is more efficient when growing allocated buffers. -The use of memalign() was unnecessary for allocated bson_t structures -and has therefore been removed. Performance sensitive allocations now -use bson_malloc() instead of calloc() and initialize fields directly. -Stack alignment of bson_t is now enforced through compiler intrinsics. - -The unit tests can now support running inside of valgrind to check for -various memory leaks. Simply defing VALGRIND=valgrind when running -`make test`. - -Enjoy libbson-0.2.2! - - -Libbson 0.2.0 -============= - -This is the initial release of Libbson. It has not yet reached API and ABI -maturity and is therefore subject to change without notice. Developers are -encouraged to start using Libbson as we journey on the road to 1.0, where ABI -stability will be guaranteed. - -Libbson is Apache 2.0 licensed so that it can be embedded in a multitude of -scenarios. This means that we try hard to not rely on external libraries. -Therefore, Libbson contains useful routines to help in portability as well -as BSON support. - -Libbson is the basis of a new MongoDB C driver that will follow shortly. - -Please see the doc/ directory for documentation on how to use Libbson. We -would love for you to contribute to Libbson, whether that is code, -documentation or packaging. diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/bson-metrics.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/bson-metrics.c deleted file mode 100644 index 2cd4acd6d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/bson-metrics.c +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * This program will scan each BSON document contained in the provided files - * and print metrics to STDOUT. - */ - -#include -#include -#include - -#define MAX_RECURSION 100 - -static double -dtimeofday (void) -{ - struct timeval timeval; - bson_gettimeofday (&timeval); - return (timeval.tv_sec + timeval.tv_usec * 0.000001); -} - -typedef struct { - uint64_t count; - char *description; -} bson_type_metrics_t; - -typedef struct { - uint64_t doc_count; - uint64_t element_count; - uint64_t doc_size_max; - uint64_t key_size_tally; - uint64_t utf8_size_tally; - uint32_t depth; - bson_type_metrics_t bson_type_metrics[256]; -} bson_metrics_state_t; - -static bson_metrics_state_t initial_state = { - 0L, - 0L, - 0L, - 0L, - 0L, - 0L, - {{/* BSON_TYPE_EOD = 0x00 */ 0L, "End of document"}, - {/* BSON_TYPE_DOUBLE = 0x01 */ 0L, "Floating point"}, - {/* BSON_TYPE_UTF8 = 0x02 */ 0L, "UTF-8 string"}, - {/* BSON_TYPE_DOCUMENT = 0x03 */ 0L, "Embedded document"}, - {/* BSON_TYPE_ARRAY = 0x04 */ 0L, "Array"}, - {/* BSON_TYPE_BINARY = 0x05 */ 0L, "Binary data"}, - {/* BSON_TYPE_UNDEFINED = 0x06 */ 0L, "Undefined - Deprecated"}, - {/* BSON_TYPE_OID = 0x07 */ 0L, "ObjectId"}, - {/* BSON_TYPE_BOOL = 0x08 */ 0L, "Boolean"}, - {/* BSON_TYPE_DATE_TIME = 0x09 */ 0L, "UTC datetime"}, - {/* BSON_TYPE_NULL = 0x0A */ 0L, "Null value"}, - {/* BSON_TYPE_REGEX = 0x0B */ 0L, "Regular expression"}, - {/* BSON_TYPE_DBPOINTER = 0x0C */ 0L, "DBPointer - Deprecated"}, - {/* BSON_TYPE_CODE = 0x0D */ 0L, "JavaScript code"}, - {/* BSON_TYPE_SYMBOL = 0x0E */ 0L, "Symbol - Deprecated"}, - {/* BSON_TYPE_CODEWSCOPE = 0x0F */ 0L, "JavaScript code w/ scope"}, - {/* BSON_TYPE_INT32 = 0x10 */ 0L, "32-bit Integer"}, - {/* BSON_TYPE_TIMESTAMP = 0x11 */ 0L, "Timestamp"}, - {/* BSON_TYPE_INT64 = 0x12 */ 0L, "64-bit Integer"}, - {0L, NULL}}}; - -static bson_metrics_state_t state; - -static int -compar_bson_type_metrics (const void *a, const void *b) -{ - const uint64_t a_count = ((bson_type_metrics_t *) a)->count; - const uint64_t b_count = ((bson_type_metrics_t *) b)->count; - if (a_count == b_count) { - return 0; - } - return a_count < b_count ? -1 : 1; -} - -/* - * Forward declarations. - */ -static bool -bson_metrics_visit_array (const bson_iter_t *iter, - const char *key, - const bson_t *v_array, - void *data); -static bool -bson_metrics_visit_document (const bson_iter_t *iter, - const char *key, - const bson_t *v_document, - void *data); - -static bool -bson_metrics_visit_utf8 (const bson_iter_t *iter, - const char *key, - size_t v_utf8_len, - const char *v_utf8, - void *data) -{ - bson_metrics_state_t *s = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - BSON_UNUSED (v_utf8); - - s->utf8_size_tally += v_utf8_len; - - return false; -} - -static bool -bson_metrics_visit_before (const bson_iter_t *iter, const char *key, void *data) -{ - bson_metrics_state_t *s = data; - bson_type_t btype; - ++s->element_count; - s->key_size_tally += strlen (key); /* TODO - filter out array keys(?) */ - btype = bson_iter_type (iter); - ++s->bson_type_metrics[btype].count; - - return false; -} - -static const bson_visitor_t bson_metrics_visitors = { - bson_metrics_visit_before, - NULL, /* visit_after */ - NULL, /* visit_corrupt */ - NULL, /* visit_double */ - bson_metrics_visit_utf8, - bson_metrics_visit_document, - bson_metrics_visit_array, - NULL, /* visit_binary */ - NULL, /* visit_undefined */ - NULL, /* visit_oid */ - NULL, /* visit_bool */ - NULL, /* visit_date_time */ - NULL, /* visit_null */ - NULL, /* visit_regex */ - NULL, /* visit_dbpointer */ - NULL, /* visit_code */ - NULL, /* visit_symbol */ - NULL, /* visit_codewscope */ - NULL, /* visit_int32 */ - NULL, /* visit_timestamp */ - NULL, /* visit_int64 */ - NULL, /* visit_maxkey */ - NULL, /* visit_minkey */ -}; - -static bool -bson_metrics_visit_document (const bson_iter_t *iter, - const char *key, - const bson_t *v_document, - void *data) -{ - bson_metrics_state_t *s = data; - bson_iter_t child; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - if (s->depth >= MAX_RECURSION) { - fprintf (stderr, "Invalid document, max recursion reached.\n"); - return true; - } - - if (bson_iter_init (&child, v_document)) { - s->depth++; - bson_iter_visit_all (&child, &bson_metrics_visitors, data); - s->depth--; - } - - return false; -} - -static bool -bson_metrics_visit_array (const bson_iter_t *iter, - const char *key, - const bson_t *v_array, - void *data) -{ - bson_metrics_state_t *s = data; - bson_iter_t child; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - if (s->depth >= MAX_RECURSION) { - fprintf (stderr, "Invalid document, max recursion reached.\n"); - return true; - } - - if (bson_iter_init (&child, v_array)) { - s->depth++; - bson_iter_visit_all (&child, &bson_metrics_visitors, data); - s->depth--; - } - - return false; -} - -static void -bson_metrics (const bson_t *bson, size_t *length, void *data) -{ - bson_iter_t iter; - bson_metrics_state_t *s = data; - - BSON_UNUSED (length); - - ++s->doc_count; - - if (bson_iter_init (&iter, bson)) { - bson_iter_visit_all (&iter, &bson_metrics_visitors, data); - } -} - -int -main (int argc, char *argv[]) -{ - bson_reader_t *reader; - const bson_t *b; - bson_error_t error; - const char *filename; - int i, j; - double dtime_before, dtime_after, dtime_delta; - uint64_t aggregate_count; - off_t mark; - - /* - * Print program usage if no arguments are provided. - */ - if (argc == 1) { - fprintf (stderr, "usage: %s FILE...\n", argv[0]); - return 1; - } - - /* - * Process command line arguments expecting each to be a filename. - */ - printf ("["); - for (i = 1; i < argc; i++) { - if (i > 1) - printf (","); - filename = argv[i]; - - /* - * Initialize a new reader for this file descriptor. - */ - if (!(reader = bson_reader_new_from_file (filename, &error))) { - fprintf ( - stderr, "Failed to open \"%s\": %s\n", filename, error.message); - continue; - } - - state = initial_state; - dtime_before = dtimeofday (); - mark = 0; - while ((b = bson_reader_read (reader, NULL))) { - off_t pos = bson_reader_tell (reader); - state.doc_size_max = BSON_MAX (pos - mark, state.doc_size_max); - mark = pos; - bson_metrics (b, NULL, &state); - } - dtime_after = dtimeofday (); - dtime_delta = BSON_MAX (dtime_after - dtime_before, 0.000001); - state.bson_type_metrics[BSON_TYPE_MAXKEY].description = "Max key"; - state.bson_type_metrics[BSON_TYPE_MINKEY].description = "Min key"; - aggregate_count = state.bson_type_metrics[BSON_TYPE_DOCUMENT].count + - state.bson_type_metrics[BSON_TYPE_ARRAY].count; - qsort (state.bson_type_metrics, - 256, - sizeof (bson_type_metrics_t), - compar_bson_type_metrics); - - printf ("\n {\n"); - printf (" \"file\": \"%s\",\n", filename); - printf (" \"secs\": %.2f,\n", dtime_delta); - printf (" \"docs_per_sec\": %" PRIu64 ",\n", - (uint64_t) floor (state.doc_count / dtime_delta)); - printf (" \"docs\": %" PRIu64 ",\n", state.doc_count); - printf (" \"elements\": %" PRIu64 ",\n", state.element_count); - printf (" \"elements_per_doc\": %" PRIu64 ",\n", - (uint64_t) floor ((double) state.element_count / - (double) BSON_MAX (state.doc_count, 1))); - printf (" \"aggregates\": %" PRIu64 ",\n", aggregate_count); - printf (" \"aggregates_per_doc\": %" PRIu64 ",\n", - (uint64_t) floor ((double) aggregate_count / - (double) BSON_MAX (state.doc_count, 1))); - printf (" \"degree\": %" PRIu64 ",\n", - (uint64_t) floor ( - (double) state.element_count / - ((double) BSON_MAX (state.doc_count + aggregate_count, 1)))); - printf (" \"doc_size_max\": %" PRIu64 ",\n", state.doc_size_max); - printf (" \"doc_size_average\": %" PRIu64 ",\n", - (uint64_t) floor ((double) bson_reader_tell (reader) / - (double) BSON_MAX (state.doc_count, 1))); - printf (" \"key_size_average\": %" PRIu64 ",\n", - (uint64_t) floor ((double) state.key_size_tally / - (double) BSON_MAX (state.element_count, 1))); - printf (" \"string_size_average\": %" PRIu64 ",\n", - (uint64_t) floor ( - (double) state.utf8_size_tally / - (double) BSON_MAX ( - state.bson_type_metrics[BSON_TYPE_UTF8].count, 1))); - printf (" \"percent_by_type\": {\n"); - for (j = 0; state.bson_type_metrics[j].count > 0; j++) { - bson_type_metrics_t bson_type_metrics = state.bson_type_metrics[j]; - printf (" \"%s\": %" PRIu64 ",\n", - bson_type_metrics.description, - (uint64_t) floor ((double) bson_type_metrics.count * 100.0 / - (double) BSON_MAX (state.element_count, 1))); - } - printf (" }\n"); - printf (" }"); - - /* - * Cleanup after our reader, which closes the file descriptor. - */ - bson_reader_destroy (reader); - } - printf ("\n]\n"); - - return 0; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake-deprecated/find_package/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake-deprecated/find_package/CMakeLists.txt deleted file mode 100644 index 4d31e5df9..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake-deprecated/find_package/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Demonstrates how to use the CMake 'find_package' mechanism to locate -# and build against libbson. - -cmake_minimum_required (VERSION 2.8) - -if (APPLE) - cmake_policy (SET CMP0042 OLD) -endif () - -project (hello_bson LANGUAGES C) - -# NOTE: For this to work, the CMAKE_PREFIX_PATH variable must be set to point to -# the directory that was used as the argument to CMAKE_INSTALL_PREFIX when -# building libbson. -# -- sphinx-include-start -- -# Specify the minimum version you require. -find_package (libbson-1.0 1.7 REQUIRED) - -message (STATUS " libbson found version \"${BSON_VERSION}\"") -message (STATUS " libbson include path \"${BSON_INCLUDE_DIRS}\"") -message (STATUS " libbson libraries \"${BSON_LIBRARIES}\"") - -# The "hello_bson.c" sample program is shared among four tests. -add_executable (hello_bson ../../hello_bson.c) -target_include_directories (hello_bson PRIVATE ${BSON_INCLUDE_DIRS}) -target_link_libraries (hello_bson PRIVATE ${BSON_LIBRARIES}) -target_compile_definitions (hello_bson PRIVATE ${BSON_DEFINITIONS}) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake-deprecated/find_package_static/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake-deprecated/find_package_static/CMakeLists.txt deleted file mode 100644 index e7142762b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake-deprecated/find_package_static/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Demonstrates how to use the CMake 'find_package' mechanism to locate -# and build against libbson. - -cmake_minimum_required (VERSION 2.8) - -if (APPLE) - cmake_policy (SET CMP0042 OLD) -endif () - -project (hello_bson LANGUAGES C) - -# NOTE: For this to work, the CMAKE_PREFIX_PATH variable must be set to point to -# the directory that was used as the argument to CMAKE_INSTALL_PREFIX when -# building libbson. -# -- sphinx-include-start -- -# Specify the minimum version you require. -find_package (libbson-static-1.0 1.7 REQUIRED) - -message (STATUS " libbson-static found version \"${BSON_STATIC_VERSION}\"") -message (STATUS " libbson-static include path \"${BSON_STATIC_INCLUDE_DIRS}\"") -message (STATUS " libbson-static libraries \"${BSON_STATIC_LIBRARIES}\"") - -# The "hello_bson.c" sample program is shared among four tests. -add_executable (hello_bson ../../hello_bson.c) -target_include_directories (hello_bson PRIVATE ${BSON_STATIC_INCLUDE_DIRS}) -target_link_libraries (hello_bson PRIVATE ${BSON_STATIC_LIBRARIES}) -target_compile_definitions (hello_bson PRIVATE ${BSON_STATIC_DEFINITIONS}) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake/.gitignore b/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake/.gitignore deleted file mode 100644 index b17dd527c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -CMakeCache.txt -CMakeFiles -Makefile -cmake_install.cmake -hello_bson -build diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake/find_package/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake/find_package/CMakeLists.txt deleted file mode 100644 index 6765ad684..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake/find_package/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Demonstrates how to use the CMake 'find_package' mechanism to locate -# and build against libbson. - -cmake_minimum_required (VERSION 3.0) - -if (APPLE) - cmake_policy (SET CMP0042 OLD) -endif () - -project (hello_bson LANGUAGES C) - -# NOTE: For this to work, the CMAKE_PREFIX_PATH variable must be set to point to -# the directory that was used as the argument to CMAKE_INSTALL_PREFIX when -# building libbson. -# -- sphinx-include-start -- -# Specify the minimum version you require. -find_package (bson-1.0 1.7 REQUIRED) - -# The "hello_bson.c" sample program is shared among four tests. -add_executable (hello_bson ../../hello_bson.c) -target_link_libraries (hello_bson PRIVATE mongo::bson_shared) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake/find_package_static/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake/find_package_static/CMakeLists.txt deleted file mode 100644 index 0a2b2172f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/cmake/find_package_static/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Demonstrates how to use the CMake 'find_package' mechanism to locate -# and build against libbson. - -cmake_minimum_required (VERSION 2.8) - -if (APPLE) - cmake_policy (SET CMP0042 OLD) -endif () - -project (hello_bson LANGUAGES C) - -# NOTE: For this to work, the CMAKE_PREFIX_PATH variable must be set to point to -# the directory that was used as the argument to CMAKE_INSTALL_PREFIX when -# building libbson. -# -- sphinx-include-start -- -# Specify the minimum version you require. -find_package (bson-1.0 1.7 REQUIRED) - -# The "hello_bson.c" sample program is shared among four tests. -add_executable (hello_bson ../../hello_bson.c) -target_link_libraries (hello_bson PRIVATE mongo::bson_static) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/compile-with-pkg-config-static.sh b/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/compile-with-pkg-config-static.sh deleted file mode 100644 index 312363440..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/compile-with-pkg-config-static.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -set -o errexit # Exit the script with error if any of the commands fail - -# -- sphinx-include-start -- -gcc -o hello_bson hello_bson.c $(pkg-config --libs --cflags libbson-static-1.0) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/compile-with-pkg-config.sh b/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/compile-with-pkg-config.sh deleted file mode 100644 index 5fff22b32..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/examples/compile-with-pkg-config.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -set -o errexit # Exit the script with error if any of the commands fail - -# -- sphinx-include-start -- -gcc -o hello_bson hello_bson.c $(pkg-config --libs --cflags libbson-1.0) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/fuzz/fuzz_test_libbson.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/fuzz/fuzz_test_libbson.c deleted file mode 100644 index 9ad6f5c34..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/fuzz/fuzz_test_libbson.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include -#include - -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - char *nt = malloc(size+1); - memcpy(nt, data, size); - nt[size] = '\0'; - bson_error_t error; - - bson_t b; - if (bson_init_from_json(&b, nt, -1, &error)) { - bson_destroy(&b); - } - - free(nt); - return 0; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/libbson.rc.in b/3rdparty/mongo-c-driver-1.26.2/src/libbson/libbson.rc.in deleted file mode 100644 index 98478f2fa..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/libbson.rc.in +++ /dev/null @@ -1,46 +0,0 @@ -// Defines Version Information to include in DLL on Windows. -// Refer: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource -#include // Defines VS_VERSION_INFO -#define BSON_COMPILATION // Tell bson-version.h it is part of compilation. -#include // Defines BSON_MAJOR_VERSION and other version macros. -#undef BSON_COMPILATION - -#define BSON_OUTPUT_BASENAME "@BSON_OUTPUT_BASENAME@" -#define BSON_API_VERSION "@BSON_API_VERSION@" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION BSON_MAJOR_VERSION,BSON_MINOR_VERSION,BSON_MICRO_VERSION,0 - PRODUCTVERSION BSON_MAJOR_VERSION,BSON_MINOR_VERSION,BSON_MICRO_VERSION,0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0L -#endif - // Set FILEOS to VOS_UNKNOWN. There is no documented value for 64-bit builds. - FILEOS VOS_UNKNOWN - FILETYPE VFT_DLL - // Set FILESUBTYPE to VFT2_UNKNOWN. There is no applicable value. - FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN - // Use langID `0409` for "US English". Use charsetID `04b0` for "Unicode" - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "MongoDB, Inc" - VALUE "FileDescription", "A BSON Library for C" - VALUE "FileVersion", BSON_VERSION_S - VALUE "InternalName", BSON_OUTPUT_BASENAME "-" BSON_API_VERSION - VALUE "OriginalFilename", BSON_OUTPUT_BASENAME "-" BSON_API_VERSION ".dll" - VALUE "ProductName", "MongoDB C Driver" - VALUE "ProductVersion", BSON_VERSION_S - VALUE "LegalCopyright", "Copyright (C) 2013-present MongoDB, Inc." - END - END - BLOCK "VarFileInfo" - BEGIN - // Use langID `0x0409` for "U.S. English". Use charsetID `1200` for "Unicode". - VALUE "Translation", 0x409, 1200 - END -END diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson-config.cmake b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson-config.cmake deleted file mode 100644 index 388681f30..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson-config.cmake +++ /dev/null @@ -1,13 +0,0 @@ -include(CMakeFindDependencyMacro) -find_dependency(Threads) # Required for Threads::Threads - -# Import common targets first: -include("${CMAKE_CURRENT_LIST_DIR}/bson-targets.cmake") - -# Now import the targets of each link-kind that's available. Only the targets of -# libbson libraries that were actually installed alongside this file will be -# imported. -file(GLOB target_files "${CMAKE_CURRENT_LIST_DIR}/bson_*-targets.cmake") -foreach(inc IN LISTS target_files) - include("${inc}") -endforeach() diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/.gitignore b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/.gitignore deleted file mode 100644 index d151f69a7..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -bson-config.h -bson-stdint.h -bson-version.h -.dirstamp diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bcon.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bcon.c deleted file mode 100644 index 53ae80fe9..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bcon.c +++ /dev/null @@ -1,1017 +0,0 @@ -/* - * @file bcon.c - * @brief BCON (BSON C Object Notation) Implementation - */ - -/* Copyright 2009-2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "bcon.h" -#include - -/* These stack manipulation macros are used to manage append recursion in - * bcon_append_ctx_va(). They take care of some awkward dereference rules (the - * real bson object isn't in the stack, but accessed by pointer) and add in run - * time asserts to make sure we don't blow the stack in either direction */ - -#define STACK_ELE(_delta, _name) (ctx->stack[(_delta) + ctx->n]._name) - -#define STACK_BSON(_delta) \ - (((_delta) + ctx->n) == 0 ? bson : &STACK_ELE (_delta, bson)) - -#define STACK_ITER(_delta) \ - (((_delta) + ctx->n) == 0 ? &root_iter : &STACK_ELE (_delta, iter)) - -#define STACK_BSON_PARENT STACK_BSON (-1) -#define STACK_BSON_CHILD STACK_BSON (0) - -#define STACK_ITER_PARENT STACK_ITER (-1) -#define STACK_ITER_CHILD STACK_ITER (0) - -#define STACK_I STACK_ELE (0, i) -#define STACK_IS_ARRAY STACK_ELE (0, is_array) - -#define STACK_PUSH_ARRAY(statement) \ - do { \ - BSON_ASSERT (ctx->n < (BCON_STACK_MAX - 1)); \ - ctx->n++; \ - STACK_I = 0; \ - STACK_IS_ARRAY = 1; \ - statement; \ - } while (0) - -#define STACK_PUSH_DOC(statement) \ - do { \ - BSON_ASSERT (ctx->n < (BCON_STACK_MAX - 1)); \ - ctx->n++; \ - STACK_IS_ARRAY = 0; \ - statement; \ - } while (0) - -#define STACK_POP_ARRAY(statement) \ - do { \ - BSON_ASSERT (STACK_IS_ARRAY); \ - BSON_ASSERT (ctx->n != 0); \ - statement; \ - ctx->n--; \ - } while (0) - -#define STACK_POP_DOC(statement) \ - do { \ - BSON_ASSERT (!STACK_IS_ARRAY); \ - BSON_ASSERT (ctx->n != 0); \ - statement; \ - ctx->n--; \ - } while (0) - -/* This is a landing pad union for all of the types we can process with bcon. - * We need actual storage for this to capture the return value of va_arg, which - * takes multiple calls to get everything we need for some complex types */ -typedef union bcon_append { - char *UTF8; - double DOUBLE; - bson_t *DOCUMENT; - bson_t *ARRAY; - bson_t *BCON; - - struct { - bson_subtype_t subtype; - uint8_t *binary; - uint32_t length; - } BIN; - - bson_oid_t *OID; - bool BOOL; - int64_t DATE_TIME; - - struct { - char *regex; - char *flags; - } REGEX; - - struct { - char *collection; - bson_oid_t *oid; - } DBPOINTER; - - const char *CODE; - - char *SYMBOL; - - struct { - const char *js; - bson_t *scope; - } CODEWSCOPE; - - int32_t INT32; - - struct { - uint32_t timestamp; - uint32_t increment; - } TIMESTAMP; - - int64_t INT64; - bson_decimal128_t *DECIMAL128; - const bson_iter_t *ITER; -} bcon_append_t; - -/* same as bcon_append_t. Some extra symbols and varying types that handle the - * differences between bson_append and bson_iter */ -typedef union bcon_extract { - bson_type_t TYPE; - bson_iter_t *ITER; - const char *key; - const char **UTF8; - double *DOUBLE; - bson_t *DOCUMENT; - bson_t *ARRAY; - - struct { - bson_subtype_t *subtype; - const uint8_t **binary; - uint32_t *length; - } BIN; - - const bson_oid_t **OID; - bool *BOOL; - int64_t *DATE_TIME; - - struct { - const char **regex; - const char **flags; - } REGEX; - - struct { - const char **collection; - const bson_oid_t **oid; - } DBPOINTER; - - const char **CODE; - - const char **SYMBOL; - - struct { - const char **js; - bson_t *scope; - } CODEWSCOPE; - - int32_t *INT32; - - struct { - uint32_t *timestamp; - uint32_t *increment; - } TIMESTAMP; - - int64_t *INT64; - bson_decimal128_t *DECIMAL128; -} bcon_extract_t; - -static const char *gBconMagic = "BCON_MAGIC"; -static const char *gBconeMagic = "BCONE_MAGIC"; - -const char * -bson_bcon_magic (void) -{ - return gBconMagic; -} - - -const char * -bson_bcone_magic (void) -{ - return gBconeMagic; -} - -static void -_noop (void) -{ -} - -/* appends val to the passed bson object. Meant to be a super simple dispatch - * table */ -static void -_bcon_append_single (bson_t *bson, - bcon_type_t type, - const char *key, - bcon_append_t *val) -{ - switch ((int) type) { - case BCON_TYPE_UTF8: - BSON_ASSERT (bson_append_utf8 (bson, key, -1, val->UTF8, -1)); - break; - case BCON_TYPE_DOUBLE: - BSON_ASSERT (bson_append_double (bson, key, -1, val->DOUBLE)); - break; - case BCON_TYPE_BIN: { - BSON_ASSERT (bson_append_binary ( - bson, key, -1, val->BIN.subtype, val->BIN.binary, val->BIN.length)); - break; - } - case BCON_TYPE_UNDEFINED: - BSON_ASSERT (bson_append_undefined (bson, key, -1)); - break; - case BCON_TYPE_OID: - BSON_ASSERT (bson_append_oid (bson, key, -1, val->OID)); - break; - case BCON_TYPE_BOOL: - BSON_ASSERT (bson_append_bool (bson, key, -1, (bool) val->BOOL)); - break; - case BCON_TYPE_DATE_TIME: - BSON_ASSERT (bson_append_date_time (bson, key, -1, val->DATE_TIME)); - break; - case BCON_TYPE_NULL: - BSON_ASSERT (bson_append_null (bson, key, -1)); - break; - case BCON_TYPE_REGEX: { - BSON_ASSERT ( - bson_append_regex (bson, key, -1, val->REGEX.regex, val->REGEX.flags)); - break; - } - case BCON_TYPE_DBPOINTER: { - BSON_ASSERT (bson_append_dbpointer ( - bson, key, -1, val->DBPOINTER.collection, val->DBPOINTER.oid)); - break; - } - case BCON_TYPE_CODE: - BSON_ASSERT (bson_append_code (bson, key, -1, val->CODE)); - break; - case BCON_TYPE_SYMBOL: - BSON_ASSERT (bson_append_symbol (bson, key, -1, val->SYMBOL, -1)); - break; - case BCON_TYPE_CODEWSCOPE: - BSON_ASSERT (bson_append_code_with_scope ( - bson, key, -1, val->CODEWSCOPE.js, val->CODEWSCOPE.scope)); - break; - case BCON_TYPE_INT32: - BSON_ASSERT (bson_append_int32 (bson, key, -1, val->INT32)); - break; - case BCON_TYPE_TIMESTAMP: { - BSON_ASSERT (bson_append_timestamp ( - bson, key, -1, val->TIMESTAMP.timestamp, val->TIMESTAMP.increment)); - break; - } - case BCON_TYPE_INT64: - BSON_ASSERT (bson_append_int64 (bson, key, -1, val->INT64)); - break; - case BCON_TYPE_DECIMAL128: - BSON_ASSERT (bson_append_decimal128 (bson, key, -1, val->DECIMAL128)); - break; - case BCON_TYPE_MAXKEY: - BSON_ASSERT (bson_append_maxkey (bson, key, -1)); - break; - case BCON_TYPE_MINKEY: - BSON_ASSERT (bson_append_minkey (bson, key, -1)); - break; - case BCON_TYPE_ARRAY: { - BSON_ASSERT (bson_append_array (bson, key, -1, val->ARRAY)); - break; - } - case BCON_TYPE_DOCUMENT: { - BSON_ASSERT (bson_append_document (bson, key, -1, val->DOCUMENT)); - break; - } - case BCON_TYPE_ITER: - BSON_ASSERT (bson_append_iter (bson, key, -1, val->ITER)); - break; - default: - BSON_ASSERT (0); - break; - } -} - -#define CHECK_TYPE(_type) \ - do { \ - if (bson_iter_type (iter) != (_type)) { \ - return false; \ - } \ - } while (0) - -/* extracts the value under the iterator and writes it to val. returns false - * if the iterator type doesn't match the token type. - * - * There are two magic tokens: - * - * BCONE_SKIP - - * Let's us verify that a key has a type, without caring about its value. - * This allows for wider declarative BSON verification - * - * BCONE_ITER - - * Returns the underlying iterator. This could allow for more complicated, - * procedural verification (if a parameter could have multiple types). - * */ -static bool -_bcon_extract_single (const bson_iter_t *iter, - bcon_type_t type, - bcon_extract_t *val) -{ - switch ((int) type) { - case BCON_TYPE_UTF8: - CHECK_TYPE (BSON_TYPE_UTF8); - *val->UTF8 = bson_iter_utf8 (iter, NULL); - break; - case BCON_TYPE_DOUBLE: - CHECK_TYPE (BSON_TYPE_DOUBLE); - *val->DOUBLE = bson_iter_double (iter); - break; - case BCON_TYPE_BIN: - CHECK_TYPE (BSON_TYPE_BINARY); - bson_iter_binary ( - iter, val->BIN.subtype, val->BIN.length, val->BIN.binary); - break; - case BCON_TYPE_UNDEFINED: - CHECK_TYPE (BSON_TYPE_UNDEFINED); - break; - case BCON_TYPE_OID: - CHECK_TYPE (BSON_TYPE_OID); - *val->OID = bson_iter_oid (iter); - break; - case BCON_TYPE_BOOL: - CHECK_TYPE (BSON_TYPE_BOOL); - *val->BOOL = bson_iter_bool (iter); - break; - case BCON_TYPE_DATE_TIME: - CHECK_TYPE (BSON_TYPE_DATE_TIME); - *val->DATE_TIME = bson_iter_date_time (iter); - break; - case BCON_TYPE_NULL: - CHECK_TYPE (BSON_TYPE_NULL); - break; - case BCON_TYPE_REGEX: - CHECK_TYPE (BSON_TYPE_REGEX); - *val->REGEX.regex = bson_iter_regex (iter, val->REGEX.flags); - - break; - case BCON_TYPE_DBPOINTER: - CHECK_TYPE (BSON_TYPE_DBPOINTER); - bson_iter_dbpointer ( - iter, NULL, val->DBPOINTER.collection, val->DBPOINTER.oid); - break; - case BCON_TYPE_CODE: - CHECK_TYPE (BSON_TYPE_CODE); - *val->CODE = bson_iter_code (iter, NULL); - break; - case BCON_TYPE_SYMBOL: - CHECK_TYPE (BSON_TYPE_SYMBOL); - *val->SYMBOL = bson_iter_symbol (iter, NULL); - break; - case BCON_TYPE_CODEWSCOPE: { - const uint8_t *buf; - uint32_t len; - - CHECK_TYPE (BSON_TYPE_CODEWSCOPE); - - *val->CODEWSCOPE.js = bson_iter_codewscope (iter, NULL, &len, &buf); - - BSON_ASSERT (bson_init_static (val->CODEWSCOPE.scope, buf, len)); - break; - } - case BCON_TYPE_INT32: - CHECK_TYPE (BSON_TYPE_INT32); - *val->INT32 = bson_iter_int32 (iter); - break; - case BCON_TYPE_TIMESTAMP: - CHECK_TYPE (BSON_TYPE_TIMESTAMP); - bson_iter_timestamp ( - iter, val->TIMESTAMP.timestamp, val->TIMESTAMP.increment); - break; - case BCON_TYPE_INT64: - CHECK_TYPE (BSON_TYPE_INT64); - *val->INT64 = bson_iter_int64 (iter); - break; - case BCON_TYPE_DECIMAL128: - CHECK_TYPE (BSON_TYPE_DECIMAL128); - BSON_ASSERT (bson_iter_decimal128 (iter, val->DECIMAL128)); - break; - case BCON_TYPE_MAXKEY: - CHECK_TYPE (BSON_TYPE_MAXKEY); - break; - case BCON_TYPE_MINKEY: - CHECK_TYPE (BSON_TYPE_MINKEY); - break; - case BCON_TYPE_ARRAY: { - const uint8_t *buf; - uint32_t len; - - CHECK_TYPE (BSON_TYPE_ARRAY); - - bson_iter_array (iter, &len, &buf); - - BSON_ASSERT (bson_init_static (val->ARRAY, buf, len)); - break; - } - case BCON_TYPE_DOCUMENT: { - const uint8_t *buf; - uint32_t len; - - CHECK_TYPE (BSON_TYPE_DOCUMENT); - - bson_iter_document (iter, &len, &buf); - - BSON_ASSERT (bson_init_static (val->DOCUMENT, buf, len)); - break; - } - case BCON_TYPE_SKIP: - CHECK_TYPE (val->TYPE); - break; - case BCON_TYPE_ITER: - memcpy (val->ITER, iter, sizeof *iter); - break; - default: - BSON_ASSERT (0); - break; - } - - return true; -} - -/* Consumes ap, storing output values into u and returning the type of the - * captured token. - * - * The basic workflow goes like this: - * - * 1. Look at the current arg. It will be a char * - * a. If it's a NULL, we're done processing. - * b. If it's BCON_MAGIC (a symbol with storage in this module) - * I. The next token is the type - * II. The type specifies how many args to eat and their types - * c. Otherwise it's either recursion related or a raw string - * I. If the first byte is '{', '}', '[', or ']' pass back an - * appropriate recursion token - * II. If not, just call it a UTF8 token and pass that back - */ -static bcon_type_t -_bcon_append_tokenize (va_list *ap, bcon_append_t *u) -{ - char *mark; - bcon_type_t type; - - mark = va_arg (*ap, char *); - - BSON_ASSERT (mark != BCONE_MAGIC); - - if (mark == NULL) { - type = BCON_TYPE_END; - } else if (mark == BCON_MAGIC) { - type = va_arg (*ap, bcon_type_t); - - switch ((int) type) { - case BCON_TYPE_UTF8: - u->UTF8 = va_arg (*ap, char *); - break; - case BCON_TYPE_DOUBLE: - u->DOUBLE = va_arg (*ap, double); - break; - case BCON_TYPE_DOCUMENT: - u->DOCUMENT = va_arg (*ap, bson_t *); - break; - case BCON_TYPE_ARRAY: - u->ARRAY = va_arg (*ap, bson_t *); - break; - case BCON_TYPE_BIN: - u->BIN.subtype = va_arg (*ap, bson_subtype_t); - u->BIN.binary = va_arg (*ap, uint8_t *); - u->BIN.length = va_arg (*ap, uint32_t); - break; - case BCON_TYPE_UNDEFINED: - break; - case BCON_TYPE_OID: - u->OID = va_arg (*ap, bson_oid_t *); - break; - case BCON_TYPE_BOOL: - u->BOOL = va_arg (*ap, int); - break; - case BCON_TYPE_DATE_TIME: - u->DATE_TIME = va_arg (*ap, int64_t); - break; - case BCON_TYPE_NULL: - break; - case BCON_TYPE_REGEX: - u->REGEX.regex = va_arg (*ap, char *); - u->REGEX.flags = va_arg (*ap, char *); - break; - case BCON_TYPE_DBPOINTER: - u->DBPOINTER.collection = va_arg (*ap, char *); - u->DBPOINTER.oid = va_arg (*ap, bson_oid_t *); - break; - case BCON_TYPE_CODE: - u->CODE = va_arg (*ap, char *); - break; - case BCON_TYPE_SYMBOL: - u->SYMBOL = va_arg (*ap, char *); - break; - case BCON_TYPE_CODEWSCOPE: - u->CODEWSCOPE.js = va_arg (*ap, char *); - u->CODEWSCOPE.scope = va_arg (*ap, bson_t *); - break; - case BCON_TYPE_INT32: - u->INT32 = va_arg (*ap, int32_t); - break; - case BCON_TYPE_TIMESTAMP: - u->TIMESTAMP.timestamp = va_arg (*ap, uint32_t); - u->TIMESTAMP.increment = va_arg (*ap, uint32_t); - break; - case BCON_TYPE_INT64: - u->INT64 = va_arg (*ap, int64_t); - break; - case BCON_TYPE_DECIMAL128: - u->DECIMAL128 = va_arg (*ap, bson_decimal128_t *); - break; - case BCON_TYPE_MAXKEY: - break; - case BCON_TYPE_MINKEY: - break; - case BCON_TYPE_BCON: - u->BCON = va_arg (*ap, bson_t *); - break; - case BCON_TYPE_ITER: - u->ITER = va_arg (*ap, const bson_iter_t *); - break; - default: - BSON_ASSERT (0); - break; - } - } else { - switch (mark[0]) { - case '{': - type = BCON_TYPE_DOC_START; - break; - case '}': - type = BCON_TYPE_DOC_END; - break; - case '[': - type = BCON_TYPE_ARRAY_START; - break; - case ']': - type = BCON_TYPE_ARRAY_END; - break; - - default: - type = BCON_TYPE_UTF8; - u->UTF8 = mark; - break; - } - } - - return type; -} - - -/* Consumes ap, storing output values into u and returning the type of the - * captured token. - * - * The basic workflow goes like this: - * - * 1. Look at the current arg. It will be a char * - * a. If it's a NULL, we're done processing. - * b. If it's BCONE_MAGIC (a symbol with storage in this module) - * I. The next token is the type - * II. The type specifies how many args to eat and their types - * c. Otherwise it's either recursion related or a raw string - * I. If the first byte is '{', '}', '[', or ']' pass back an - * appropriate recursion token - * II. If not, just call it a UTF8 token and pass that back - */ -static bcon_type_t -_bcon_extract_tokenize (va_list *ap, bcon_extract_t *u) -{ - char *mark; - bcon_type_t type; - - mark = va_arg (*ap, char *); - - BSON_ASSERT (mark != BCON_MAGIC); - - if (mark == NULL) { - type = BCON_TYPE_END; - } else if (mark == BCONE_MAGIC) { - type = va_arg (*ap, bcon_type_t); - - switch ((int) type) { - case BCON_TYPE_UTF8: - u->UTF8 = va_arg (*ap, const char **); - break; - case BCON_TYPE_DOUBLE: - u->DOUBLE = va_arg (*ap, double *); - break; - case BCON_TYPE_DOCUMENT: - u->DOCUMENT = va_arg (*ap, bson_t *); - break; - case BCON_TYPE_ARRAY: - u->ARRAY = va_arg (*ap, bson_t *); - break; - case BCON_TYPE_BIN: - u->BIN.subtype = va_arg (*ap, bson_subtype_t *); - u->BIN.binary = va_arg (*ap, const uint8_t **); - u->BIN.length = va_arg (*ap, uint32_t *); - break; - case BCON_TYPE_UNDEFINED: - break; - case BCON_TYPE_OID: - u->OID = va_arg (*ap, const bson_oid_t **); - break; - case BCON_TYPE_BOOL: - u->BOOL = va_arg (*ap, bool *); - break; - case BCON_TYPE_DATE_TIME: - u->DATE_TIME = va_arg (*ap, int64_t *); - break; - case BCON_TYPE_NULL: - break; - case BCON_TYPE_REGEX: - u->REGEX.regex = va_arg (*ap, const char **); - u->REGEX.flags = va_arg (*ap, const char **); - break; - case BCON_TYPE_DBPOINTER: - u->DBPOINTER.collection = va_arg (*ap, const char **); - u->DBPOINTER.oid = va_arg (*ap, const bson_oid_t **); - break; - case BCON_TYPE_CODE: - u->CODE = va_arg (*ap, const char **); - break; - case BCON_TYPE_SYMBOL: - u->SYMBOL = va_arg (*ap, const char **); - break; - case BCON_TYPE_CODEWSCOPE: - u->CODEWSCOPE.js = va_arg (*ap, const char **); - u->CODEWSCOPE.scope = va_arg (*ap, bson_t *); - break; - case BCON_TYPE_INT32: - u->INT32 = va_arg (*ap, int32_t *); - break; - case BCON_TYPE_TIMESTAMP: - u->TIMESTAMP.timestamp = va_arg (*ap, uint32_t *); - u->TIMESTAMP.increment = va_arg (*ap, uint32_t *); - break; - case BCON_TYPE_INT64: - u->INT64 = va_arg (*ap, int64_t *); - break; - case BCON_TYPE_DECIMAL128: - u->DECIMAL128 = va_arg (*ap, bson_decimal128_t *); - break; - case BCON_TYPE_MAXKEY: - break; - case BCON_TYPE_MINKEY: - break; - case BCON_TYPE_SKIP: - u->TYPE = va_arg (*ap, bson_type_t); - break; - case BCON_TYPE_ITER: - u->ITER = va_arg (*ap, bson_iter_t *); - break; - default: - BSON_ASSERT (0); - break; - } - } else { - switch (mark[0]) { - case '{': - type = BCON_TYPE_DOC_START; - break; - case '}': - type = BCON_TYPE_DOC_END; - break; - case '[': - type = BCON_TYPE_ARRAY_START; - break; - case ']': - type = BCON_TYPE_ARRAY_END; - break; - - default: - type = BCON_TYPE_RAW; - u->key = mark; - break; - } - } - - return type; -} - - -/* This trivial utility function is useful for concatenating a bson object onto - * the end of another, ignoring the keys from the source bson object and - * continuing to use and increment the keys from the source. It's only useful - * when called from bcon_append_ctx_va */ -static void -_bson_concat_array (bson_t *dest, const bson_t *src, bcon_append_ctx_t *ctx) -{ - bson_iter_t iter; - const char *key; - char i_str[16]; - bool r; - - r = bson_iter_init (&iter, src); - - if (!r) { - fprintf (stderr, "Invalid BSON document, possible memory coruption.\n"); - return; - } - - STACK_I--; - - while (bson_iter_next (&iter)) { - bson_uint32_to_string (STACK_I, &key, i_str, sizeof i_str); - STACK_I++; - - BSON_ASSERT (bson_append_iter (dest, key, -1, &iter)); - } -} - - -/* Append_ctx_va consumes the va_list until NULL is found, appending into bson - * as tokens are found. It can receive or return an in-progress bson object - * via the ctx param. It can also operate on the middle of a va_list, and so - * can be wrapped inside of another varargs function. - * - * Note that passing in a va_list that isn't perferectly formatted for BCON - * ingestion will almost certainly result in undefined behavior - * - * The workflow relies on the passed ctx object, which holds a stack of bson - * objects, along with metadata (if the emedded layer is an array, and which - * element it is on if so). We iterate, generating tokens from the va_list, - * until we reach an END token. If any errors occur, we just blow up (the - * var_args stuff is already incredibly fragile to mistakes, and we have no way - * of introspecting, so just don't screw it up). - * - * There are also a few STACK_* macros in here which manipulate ctx that are - * defined up top. - * */ -void -bcon_append_ctx_va (bson_t *bson, bcon_append_ctx_t *ctx, va_list *ap) -{ - bcon_type_t type; - const char *key; - char i_str[16]; - - bcon_append_t u = {0}; - - while (1) { - if (STACK_IS_ARRAY) { - bson_uint32_to_string (STACK_I, &key, i_str, sizeof i_str); - STACK_I++; - } else { - type = _bcon_append_tokenize (ap, &u); - - if (type == BCON_TYPE_END) { - return; - } - - if (type == BCON_TYPE_DOC_END) { - STACK_POP_DOC ( - bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD)); - continue; - } - - if (type == BCON_TYPE_BCON) { - bson_concat (STACK_BSON_CHILD, u.BCON); - continue; - } - - BSON_ASSERT (type == BCON_TYPE_UTF8); - - key = u.UTF8; - } - - type = _bcon_append_tokenize (ap, &u); - BSON_ASSERT (type != BCON_TYPE_END); - - switch ((int) type) { - case BCON_TYPE_BCON: - BSON_ASSERT (STACK_IS_ARRAY); - _bson_concat_array (STACK_BSON_CHILD, u.BCON, ctx); - - break; - case BCON_TYPE_DOC_START: - STACK_PUSH_DOC (bson_append_document_begin ( - STACK_BSON_PARENT, key, -1, STACK_BSON_CHILD)); - break; - case BCON_TYPE_DOC_END: - STACK_POP_DOC ( - bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD)); - break; - case BCON_TYPE_ARRAY_START: - STACK_PUSH_ARRAY (bson_append_array_begin ( - STACK_BSON_PARENT, key, -1, STACK_BSON_CHILD)); - break; - case BCON_TYPE_ARRAY_END: - STACK_POP_ARRAY ( - bson_append_array_end (STACK_BSON_PARENT, STACK_BSON_CHILD)); - break; - default: - _bcon_append_single (STACK_BSON_CHILD, type, key, &u); - - break; - } - } -} - - -/* extract_ctx_va consumes the va_list until NULL is found, extracting values - * as tokens are found. It can receive or return an in-progress bson object - * via the ctx param. It can also operate on the middle of a va_list, and so - * can be wrapped inside of another varargs function. - * - * Note that passing in a va_list that isn't perferectly formatted for BCON - * ingestion will almost certainly result in undefined behavior - * - * The workflow relies on the passed ctx object, which holds a stack of iterator - * objects, along with metadata (if the emedded layer is an array, and which - * element it is on if so). We iterate, generating tokens from the va_list, - * until we reach an END token. If any errors occur, we just blow up (the - * var_args stuff is already incredibly fragile to mistakes, and we have no way - * of introspecting, so just don't screw it up). - * - * There are also a few STACK_* macros in here which manipulate ctx that are - * defined up top. - * - * The function returns true if all tokens could be successfully matched, false - * otherwise. - * */ -bool -bcon_extract_ctx_va (bson_t *bson, bcon_extract_ctx_t *ctx, va_list *ap) -{ - bcon_type_t type; - const char *key; - bson_iter_t root_iter; - bson_iter_t current_iter; - char i_str[16]; - - bcon_extract_t u = {0}; - - BSON_ASSERT (bson_iter_init (&root_iter, bson)); - - while (1) { - if (STACK_IS_ARRAY) { - bson_uint32_to_string (STACK_I, &key, i_str, sizeof i_str); - STACK_I++; - } else { - type = _bcon_extract_tokenize (ap, &u); - - if (type == BCON_TYPE_END) { - return true; - } - - if (type == BCON_TYPE_DOC_END) { - STACK_POP_DOC (_noop ()); - continue; - } - - BSON_ASSERT (type == BCON_TYPE_RAW); - - key = u.key; - } - - type = _bcon_extract_tokenize (ap, &u); - BSON_ASSERT (type != BCON_TYPE_END); - - if (type == BCON_TYPE_DOC_END) { - STACK_POP_DOC (_noop ()); - } else if (type == BCON_TYPE_ARRAY_END) { - STACK_POP_ARRAY (_noop ()); - } else { - memcpy (¤t_iter, STACK_ITER_CHILD, sizeof current_iter); - - if (!bson_iter_find (¤t_iter, key)) { - return false; - } - - switch ((int) type) { - case BCON_TYPE_DOC_START: - - if (bson_iter_type (¤t_iter) != BSON_TYPE_DOCUMENT) { - return false; - } - - STACK_PUSH_DOC ( - bson_iter_recurse (¤t_iter, STACK_ITER_CHILD)); - break; - case BCON_TYPE_ARRAY_START: - - if (bson_iter_type (¤t_iter) != BSON_TYPE_ARRAY) { - return false; - } - - STACK_PUSH_ARRAY ( - bson_iter_recurse (¤t_iter, STACK_ITER_CHILD)); - break; - default: - - if (!_bcon_extract_single (¤t_iter, type, &u)) { - return false; - } - - break; - } - } - } -} - -void -bcon_extract_ctx_init (bcon_extract_ctx_t *ctx) -{ - ctx->n = 0; - ctx->stack[0].is_array = false; -} - -bool -bcon_extract (bson_t *bson, ...) -{ - va_list ap; - bcon_extract_ctx_t ctx; - bool r; - - bcon_extract_ctx_init (&ctx); - - va_start (ap, bson); - - r = bcon_extract_ctx_va (bson, &ctx, &ap); - - va_end (ap); - - return r; -} - - -void -bcon_append (bson_t *bson, ...) -{ - va_list ap; - bcon_append_ctx_t ctx; - - bcon_append_ctx_init (&ctx); - - va_start (ap, bson); - - bcon_append_ctx_va (bson, &ctx, &ap); - - va_end (ap); -} - - -void -bcon_append_ctx (bson_t *bson, bcon_append_ctx_t *ctx, ...) -{ - va_list ap; - - va_start (ap, ctx); - - bcon_append_ctx_va (bson, ctx, &ap); - - va_end (ap); -} - - -void -bcon_extract_ctx (bson_t *bson, bcon_extract_ctx_t *ctx, ...) -{ - va_list ap; - - va_start (ap, ctx); - - bcon_extract_ctx_va (bson, ctx, &ap); - - va_end (ap); -} - -void -bcon_append_ctx_init (bcon_append_ctx_t *ctx) -{ - ctx->n = 0; - ctx->stack[0].is_array = 0; -} - - -bson_t * -bcon_new (void *unused, ...) -{ - va_list ap; - bcon_append_ctx_t ctx; - bson_t *bson; - - bcon_append_ctx_init (&ctx); - - bson = bson_new (); - - va_start (ap, unused); - - bcon_append_ctx_va (bson, &ctx, &ap); - - va_end (ap); - - return bson; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bcon.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bcon.h deleted file mode 100644 index 80b5a489b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bcon.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * @file bcon.h - * @brief BCON (BSON C Object Notation) Declarations - */ - -#include - -/* Copyright 2009-2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BCON_H_ -#define BCON_H_ - -#include "bson.h" - - -BSON_BEGIN_DECLS - - -#define BCON_STACK_MAX 100 - -#define BCON_ENSURE_DECLARE(fun, type) \ - static BSON_INLINE type bcon_ensure_##fun (type _t) \ - { \ - return _t; \ - } - -#define BCON_ENSURE(fun, val) bcon_ensure_##fun (val) - -#define BCON_ENSURE_STORAGE(fun, val) bcon_ensure_##fun (&(val)) - -BCON_ENSURE_DECLARE (const_char_ptr, const char *) -BCON_ENSURE_DECLARE (const_char_ptr_ptr, const char **) -BCON_ENSURE_DECLARE (double, double) -BCON_ENSURE_DECLARE (double_ptr, double *) -BCON_ENSURE_DECLARE (const_bson_ptr, const bson_t *) -BCON_ENSURE_DECLARE (bson_ptr, bson_t *) -BCON_ENSURE_DECLARE (subtype, bson_subtype_t) -BCON_ENSURE_DECLARE (subtype_ptr, bson_subtype_t *) -BCON_ENSURE_DECLARE (const_uint8_ptr, const uint8_t *) -BCON_ENSURE_DECLARE (const_uint8_ptr_ptr, const uint8_t **) -BCON_ENSURE_DECLARE (uint32, uint32_t) -BCON_ENSURE_DECLARE (uint32_ptr, uint32_t *) -BCON_ENSURE_DECLARE (const_oid_ptr, const bson_oid_t *) -BCON_ENSURE_DECLARE (const_oid_ptr_ptr, const bson_oid_t **) -BCON_ENSURE_DECLARE (int32, int32_t) -BCON_ENSURE_DECLARE (int32_ptr, int32_t *) -BCON_ENSURE_DECLARE (int64, int64_t) -BCON_ENSURE_DECLARE (int64_ptr, int64_t *) -BCON_ENSURE_DECLARE (const_decimal128_ptr, const bson_decimal128_t *) -BCON_ENSURE_DECLARE (bool, bool) -BCON_ENSURE_DECLARE (bool_ptr, bool *) -BCON_ENSURE_DECLARE (bson_type, bson_type_t) -BCON_ENSURE_DECLARE (bson_iter_ptr, bson_iter_t *) -BCON_ENSURE_DECLARE (const_bson_iter_ptr, const bson_iter_t *) - -#define BCON_UTF8(_val) \ - BCON_MAGIC, BCON_TYPE_UTF8, BCON_ENSURE (const_char_ptr, (_val)) -#define BCON_DOUBLE(_val) \ - BCON_MAGIC, BCON_TYPE_DOUBLE, BCON_ENSURE (double, (_val)) -#define BCON_DOCUMENT(_val) \ - BCON_MAGIC, BCON_TYPE_DOCUMENT, BCON_ENSURE (const_bson_ptr, (_val)) -#define BCON_ARRAY(_val) \ - BCON_MAGIC, BCON_TYPE_ARRAY, BCON_ENSURE (const_bson_ptr, (_val)) -#define BCON_BIN(_subtype, _binary, _length) \ - BCON_MAGIC, BCON_TYPE_BIN, BCON_ENSURE (subtype, (_subtype)), \ - BCON_ENSURE (const_uint8_ptr, (_binary)), \ - BCON_ENSURE (uint32, (_length)) -#define BCON_UNDEFINED BCON_MAGIC, BCON_TYPE_UNDEFINED -#define BCON_OID(_val) \ - BCON_MAGIC, BCON_TYPE_OID, BCON_ENSURE (const_oid_ptr, (_val)) -#define BCON_BOOL(_val) BCON_MAGIC, BCON_TYPE_BOOL, BCON_ENSURE (bool, (_val)) -#define BCON_DATE_TIME(_val) \ - BCON_MAGIC, BCON_TYPE_DATE_TIME, BCON_ENSURE (int64, (_val)) -#define BCON_NULL BCON_MAGIC, BCON_TYPE_NULL -#define BCON_REGEX(_regex, _flags) \ - BCON_MAGIC, BCON_TYPE_REGEX, BCON_ENSURE (const_char_ptr, (_regex)), \ - BCON_ENSURE (const_char_ptr, (_flags)) -#define BCON_DBPOINTER(_collection, _oid) \ - BCON_MAGIC, BCON_TYPE_DBPOINTER, \ - BCON_ENSURE (const_char_ptr, (_collection)), \ - BCON_ENSURE (const_oid_ptr, (_oid)) -#define BCON_CODE(_val) \ - BCON_MAGIC, BCON_TYPE_CODE, BCON_ENSURE (const_char_ptr, (_val)) -#define BCON_SYMBOL(_val) \ - BCON_MAGIC, BCON_TYPE_SYMBOL, BCON_ENSURE (const_char_ptr, (_val)) -#define BCON_CODEWSCOPE(_js, _scope) \ - BCON_MAGIC, BCON_TYPE_CODEWSCOPE, BCON_ENSURE (const_char_ptr, (_js)), \ - BCON_ENSURE (const_bson_ptr, (_scope)) -#define BCON_INT32(_val) \ - BCON_MAGIC, BCON_TYPE_INT32, BCON_ENSURE (int32, (_val)) -#define BCON_TIMESTAMP(_timestamp, _increment) \ - BCON_MAGIC, BCON_TYPE_TIMESTAMP, BCON_ENSURE (int32, (_timestamp)), \ - BCON_ENSURE (int32, (_increment)) -#define BCON_INT64(_val) \ - BCON_MAGIC, BCON_TYPE_INT64, BCON_ENSURE (int64, (_val)) -#define BCON_DECIMAL128(_val) \ - BCON_MAGIC, BCON_TYPE_DECIMAL128, BCON_ENSURE (const_decimal128_ptr, (_val)) -#define BCON_MAXKEY BCON_MAGIC, BCON_TYPE_MAXKEY -#define BCON_MINKEY BCON_MAGIC, BCON_TYPE_MINKEY -#define BCON(_val) \ - BCON_MAGIC, BCON_TYPE_BCON, BCON_ENSURE (const_bson_ptr, (_val)) -#define BCON_ITER(_val) \ - BCON_MAGIC, BCON_TYPE_ITER, BCON_ENSURE (const_bson_iter_ptr, (_val)) - -#define BCONE_UTF8(_val) \ - BCONE_MAGIC, BCON_TYPE_UTF8, BCON_ENSURE_STORAGE (const_char_ptr_ptr, (_val)) -#define BCONE_DOUBLE(_val) \ - BCONE_MAGIC, BCON_TYPE_DOUBLE, BCON_ENSURE_STORAGE (double_ptr, (_val)) -#define BCONE_DOCUMENT(_val) \ - BCONE_MAGIC, BCON_TYPE_DOCUMENT, BCON_ENSURE_STORAGE (bson_ptr, (_val)) -#define BCONE_ARRAY(_val) \ - BCONE_MAGIC, BCON_TYPE_ARRAY, BCON_ENSURE_STORAGE (bson_ptr, (_val)) -#define BCONE_BIN(subtype, binary, length) \ - BCONE_MAGIC, BCON_TYPE_BIN, BCON_ENSURE_STORAGE (subtype_ptr, (subtype)), \ - BCON_ENSURE_STORAGE (const_uint8_ptr_ptr, (binary)), \ - BCON_ENSURE_STORAGE (uint32_ptr, (length)) -#define BCONE_UNDEFINED BCONE_MAGIC, BCON_TYPE_UNDEFINED -#define BCONE_OID(_val) \ - BCONE_MAGIC, BCON_TYPE_OID, BCON_ENSURE_STORAGE (const_oid_ptr_ptr, (_val)) -#define BCONE_BOOL(_val) \ - BCONE_MAGIC, BCON_TYPE_BOOL, BCON_ENSURE_STORAGE (bool_ptr, (_val)) -#define BCONE_DATE_TIME(_val) \ - BCONE_MAGIC, BCON_TYPE_DATE_TIME, BCON_ENSURE_STORAGE (int64_ptr, (_val)) -#define BCONE_NULL BCONE_MAGIC, BCON_TYPE_NULL -#define BCONE_REGEX(_regex, _flags) \ - BCONE_MAGIC, BCON_TYPE_REGEX, \ - BCON_ENSURE_STORAGE (const_char_ptr_ptr, (_regex)), \ - BCON_ENSURE_STORAGE (const_char_ptr_ptr, (_flags)) -#define BCONE_DBPOINTER(_collection, _oid) \ - BCONE_MAGIC, BCON_TYPE_DBPOINTER, \ - BCON_ENSURE_STORAGE (const_char_ptr_ptr, (_collection)), \ - BCON_ENSURE_STORAGE (const_oid_ptr_ptr, (_oid)) -#define BCONE_CODE(_val) \ - BCONE_MAGIC, BCON_TYPE_CODE, BCON_ENSURE_STORAGE (const_char_ptr_ptr, (_val)) -#define BCONE_SYMBOL(_val) \ - BCONE_MAGIC, BCON_TYPE_SYMBOL, \ - BCON_ENSURE_STORAGE (const_char_ptr_ptr, (_val)) -#define BCONE_CODEWSCOPE(_js, _scope) \ - BCONE_MAGIC, BCON_TYPE_CODEWSCOPE, \ - BCON_ENSURE_STORAGE (const_char_ptr_ptr, (_js)), \ - BCON_ENSURE_STORAGE (bson_ptr, (_scope)) -#define BCONE_INT32(_val) \ - BCONE_MAGIC, BCON_TYPE_INT32, BCON_ENSURE_STORAGE (int32_ptr, (_val)) -#define BCONE_TIMESTAMP(_timestamp, _increment) \ - BCONE_MAGIC, BCON_TYPE_TIMESTAMP, \ - BCON_ENSURE_STORAGE (int32_ptr, (_timestamp)), \ - BCON_ENSURE_STORAGE (int32_ptr, (_increment)) -#define BCONE_INT64(_val) \ - BCONE_MAGIC, BCON_TYPE_INT64, BCON_ENSURE_STORAGE (int64_ptr, (_val)) -#define BCONE_DECIMAL128(_val) \ - BCONE_MAGIC, BCON_TYPE_DECIMAL128, \ - BCON_ENSURE_STORAGE (const_decimal128_ptr, (_val)) -#define BCONE_MAXKEY BCONE_MAGIC, BCON_TYPE_MAXKEY -#define BCONE_MINKEY BCONE_MAGIC, BCON_TYPE_MINKEY -#define BCONE_SKIP(_val) \ - BCONE_MAGIC, BCON_TYPE_SKIP, BCON_ENSURE (bson_type, (_val)) -#define BCONE_ITER(_val) \ - BCONE_MAGIC, BCON_TYPE_ITER, BCON_ENSURE_STORAGE (bson_iter_ptr, (_val)) - -#define BCON_MAGIC bson_bcon_magic () -#define BCONE_MAGIC bson_bcone_magic () - -typedef enum { - BCON_TYPE_UTF8, - BCON_TYPE_DOUBLE, - BCON_TYPE_DOCUMENT, - BCON_TYPE_ARRAY, - BCON_TYPE_BIN, - BCON_TYPE_UNDEFINED, - BCON_TYPE_OID, - BCON_TYPE_BOOL, - BCON_TYPE_DATE_TIME, - BCON_TYPE_NULL, - BCON_TYPE_REGEX, - BCON_TYPE_DBPOINTER, - BCON_TYPE_CODE, - BCON_TYPE_SYMBOL, - BCON_TYPE_CODEWSCOPE, - BCON_TYPE_INT32, - BCON_TYPE_TIMESTAMP, - BCON_TYPE_INT64, - BCON_TYPE_DECIMAL128, - BCON_TYPE_MAXKEY, - BCON_TYPE_MINKEY, - BCON_TYPE_BCON, - BCON_TYPE_ARRAY_START, - BCON_TYPE_ARRAY_END, - BCON_TYPE_DOC_START, - BCON_TYPE_DOC_END, - BCON_TYPE_END, - BCON_TYPE_RAW, - BCON_TYPE_SKIP, - BCON_TYPE_ITER, - BCON_TYPE_ERROR, -} bcon_type_t; - -typedef struct bcon_append_ctx_frame { - int i; - bool is_array; - bson_t bson; -} bcon_append_ctx_frame_t; - -typedef struct bcon_extract_ctx_frame { - int i; - bool is_array; - bson_iter_t iter; -} bcon_extract_ctx_frame_t; - -typedef struct _bcon_append_ctx_t { - bcon_append_ctx_frame_t stack[BCON_STACK_MAX]; - int n; -} bcon_append_ctx_t; - -typedef struct _bcon_extract_ctx_t { - bcon_extract_ctx_frame_t stack[BCON_STACK_MAX]; - int n; -} bcon_extract_ctx_t; - -BSON_EXPORT (void) -bcon_append (bson_t *bson, ...) BSON_GNUC_NULL_TERMINATED; -BSON_EXPORT (void) -bcon_append_ctx (bson_t *bson, - bcon_append_ctx_t *ctx, - ...) BSON_GNUC_NULL_TERMINATED; -BSON_EXPORT (void) -bcon_append_ctx_va (bson_t *bson, bcon_append_ctx_t *ctx, va_list *va); -BSON_EXPORT (void) -bcon_append_ctx_init (bcon_append_ctx_t *ctx); - -BSON_EXPORT (void) -bcon_extract_ctx_init (bcon_extract_ctx_t *ctx); - -BSON_EXPORT (void) -bcon_extract_ctx (bson_t *bson, - bcon_extract_ctx_t *ctx, - ...) BSON_GNUC_NULL_TERMINATED; - -BSON_EXPORT (bool) -bcon_extract_ctx_va (bson_t *bson, bcon_extract_ctx_t *ctx, va_list *ap); - -BSON_EXPORT (bool) -bcon_extract (bson_t *bson, ...) BSON_GNUC_NULL_TERMINATED; - -BSON_EXPORT (bool) -bcon_extract_va (bson_t *bson, - bcon_extract_ctx_t *ctx, - ...) BSON_GNUC_NULL_TERMINATED; - -BSON_EXPORT (bson_t *) -bcon_new (void *unused, ...) BSON_GNUC_NULL_TERMINATED; - -/** - * The bcon_..() functions are all declared with __attribute__((sentinel)). - * - * From GCC manual for "sentinel": "A valid NULL in this context is defined as - * zero with any pointer type. If your system defines the NULL macro with an - * integer type then you need to add an explicit cast." - * Case in point: GCC on Solaris (at least) - */ -#define BCON_APPEND(_bson, ...) \ - bcon_append ((_bson), __VA_ARGS__, (void *) NULL) -#define BCON_APPEND_CTX(_bson, _ctx, ...) \ - bcon_append_ctx ((_bson), (_ctx), __VA_ARGS__, (void *) NULL) - -#define BCON_EXTRACT(_bson, ...) \ - bcon_extract ((_bson), __VA_ARGS__, (void *) NULL) - -#define BCON_EXTRACT_CTX(_bson, _ctx, ...) \ - bcon_extract ((_bson), (_ctx), __VA_ARGS__, (void *) NULL) - -#define BCON_NEW(...) bcon_new (NULL, __VA_ARGS__, (void *) NULL) - -BSON_EXPORT (const char *) -bson_bcon_magic (void) BSON_GNUC_PURE; -BSON_EXPORT (const char *) -bson_bcone_magic (void) BSON_GNUC_PURE; - - -BSON_END_DECLS - - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-atomic.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-atomic.c deleted file mode 100644 index bb8eefcf8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-atomic.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#ifdef BSON_OS_UNIX -/* For sched_yield() */ -#include -#endif - -int32_t -bson_atomic_int_add (volatile int32_t *p, int32_t n) -{ - return n + bson_atomic_int32_fetch_add ((DECL_ATOMIC_INTEGRAL_INT32 *) p, - n, - bson_memory_order_seq_cst); -} - -int64_t -bson_atomic_int64_add (volatile int64_t *p, int64_t n) -{ - return n + bson_atomic_int64_fetch_add (p, n, bson_memory_order_seq_cst); -} - -void -bson_thrd_yield (void) -{ - BSON_IF_WINDOWS (SwitchToThread ();) - BSON_IF_POSIX (sched_yield ();) -} - -void -bson_memory_barrier (void) -{ - bson_atomic_thread_fence (); -} - -/** - * Some platforms do not support compiler intrinsics for atomic operations. - * We emulate that here using a spin lock and regular arithmetic operations - */ -static int8_t gEmulAtomicLock = 0; - -static void -_lock_emul_atomic (void) -{ - int i; - if (bson_atomic_int8_compare_exchange_weak ( - &gEmulAtomicLock, 0, 1, bson_memory_order_acquire) == 0) { - /* Successfully took the spinlock */ - return; - } - /* Failed. Try taking ten more times, then begin sleeping. */ - for (i = 0; i < 10; ++i) { - if (bson_atomic_int8_compare_exchange_weak ( - &gEmulAtomicLock, 0, 1, bson_memory_order_acquire) == 0) { - /* Succeeded in taking the lock */ - return; - } - } - /* Still don't have the lock. Spin and yield */ - while (bson_atomic_int8_compare_exchange_weak ( - &gEmulAtomicLock, 0, 1, bson_memory_order_acquire) != 0) { - bson_thrd_yield (); - } -} - -static void -_unlock_emul_atomic (void) -{ - int64_t rv = bson_atomic_int8_exchange ( - &gEmulAtomicLock, 0, bson_memory_order_release); - BSON_ASSERT (rv == 1 && "Released atomic lock while not holding it"); -} - -int64_t -_bson_emul_atomic_int64_fetch_add (volatile int64_t *p, - int64_t n, - enum bson_memory_order _unused) -{ - int64_t ret; - - BSON_UNUSED (_unused); - - _lock_emul_atomic (); - ret = *p; - *p += n; - _unlock_emul_atomic (); - return ret; -} - -int64_t -_bson_emul_atomic_int64_exchange (volatile int64_t *p, - int64_t n, - enum bson_memory_order _unused) -{ - int64_t ret; - - BSON_UNUSED (_unused); - - _lock_emul_atomic (); - ret = *p; - *p = n; - _unlock_emul_atomic (); - return ret; -} - -int64_t -_bson_emul_atomic_int64_compare_exchange_strong (volatile int64_t *p, - int64_t expect_value, - int64_t new_value, - enum bson_memory_order _unused) -{ - int64_t ret; - - BSON_UNUSED (_unused); - - _lock_emul_atomic (); - ret = *p; - if (ret == expect_value) { - *p = new_value; - } - _unlock_emul_atomic (); - return ret; -} - -int64_t -_bson_emul_atomic_int64_compare_exchange_weak (volatile int64_t *p, - int64_t expect_value, - int64_t new_value, - enum bson_memory_order order) -{ - /* We're emulating. We can't do a weak version. */ - return _bson_emul_atomic_int64_compare_exchange_strong ( - p, expect_value, new_value, order); -} - - -int32_t -_bson_emul_atomic_int32_fetch_add (volatile int32_t *p, - int32_t n, - enum bson_memory_order _unused) -{ - int32_t ret; - - BSON_UNUSED (_unused); - - _lock_emul_atomic (); - ret = *p; - *p += n; - _unlock_emul_atomic (); - return ret; -} - -int32_t -_bson_emul_atomic_int32_exchange (volatile int32_t *p, - int32_t n, - enum bson_memory_order _unused) -{ - int32_t ret; - - BSON_UNUSED (_unused); - - _lock_emul_atomic (); - ret = *p; - *p = n; - _unlock_emul_atomic (); - return ret; -} - -int32_t -_bson_emul_atomic_int32_compare_exchange_strong (volatile int32_t *p, - int32_t expect_value, - int32_t new_value, - enum bson_memory_order _unused) -{ - int32_t ret; - - BSON_UNUSED (_unused); - - _lock_emul_atomic (); - ret = *p; - if (ret == expect_value) { - *p = new_value; - } - _unlock_emul_atomic (); - return ret; -} - -int32_t -_bson_emul_atomic_int32_compare_exchange_weak (volatile int32_t *p, - int32_t expect_value, - int32_t new_value, - enum bson_memory_order order) -{ - /* We're emulating. We can't do a weak version. */ - return _bson_emul_atomic_int32_compare_exchange_strong ( - p, expect_value, new_value, order); -} - - -int -_bson_emul_atomic_int_fetch_add (volatile int *p, - int n, - enum bson_memory_order _unused) -{ - int ret; - - BSON_UNUSED (_unused); - - _lock_emul_atomic (); - ret = *p; - *p += n; - _unlock_emul_atomic (); - return ret; -} - -int -_bson_emul_atomic_int_exchange (volatile int *p, - int n, - enum bson_memory_order _unused) -{ - int ret; - - BSON_UNUSED (_unused); - - _lock_emul_atomic (); - ret = *p; - *p = n; - _unlock_emul_atomic (); - return ret; -} - -int -_bson_emul_atomic_int_compare_exchange_strong (volatile int *p, - int expect_value, - int new_value, - enum bson_memory_order _unused) -{ - int ret; - - BSON_UNUSED (_unused); - - _lock_emul_atomic (); - ret = *p; - if (ret == expect_value) { - *p = new_value; - } - _unlock_emul_atomic (); - return ret; -} - -int -_bson_emul_atomic_int_compare_exchange_weak (volatile int *p, - int expect_value, - int new_value, - enum bson_memory_order order) -{ - /* We're emulating. We can't do a weak version. */ - return _bson_emul_atomic_int_compare_exchange_strong ( - p, expect_value, new_value, order); -} - -void * -_bson_emul_atomic_ptr_exchange (void *volatile *p, - void *n, - enum bson_memory_order _unused) -{ - void *ret; - - BSON_UNUSED (_unused); - - _lock_emul_atomic (); - ret = *p; - *p = n; - _unlock_emul_atomic (); - return ret; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-atomic.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-atomic.h deleted file mode 100644 index a28c0be65..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-atomic.h +++ /dev/null @@ -1,780 +0,0 @@ -/* - * Copyright 2013-2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_ATOMIC_H -#define BSON_ATOMIC_H - - -#include -#include -#include - -#ifdef _MSC_VER -#include -#endif - - -BSON_BEGIN_DECLS - -enum bson_memory_order { - bson_memory_order_seq_cst, - bson_memory_order_acquire, - bson_memory_order_release, - bson_memory_order_relaxed, - bson_memory_order_acq_rel, - bson_memory_order_consume, -}; - -#if defined(_M_ARM) /* MSVC memorder atomics are only avail on ARM */ -#define MSVC_MEMORDER_SUFFIX(X) X -#else -#define MSVC_MEMORDER_SUFFIX(X) -#endif - -#if defined(USE_LEGACY_GCC_ATOMICS) || \ - (!defined(__clang__) && __GNUC__ == 4) || defined(__xlC__) -#define BSON_USE_LEGACY_GCC_ATOMICS -#else -#undef BSON_USE_LEGACY_GCC_ATOMICS -#endif - -/* Not all GCC-like compilers support the current __atomic built-ins. Older - * GCC (pre-5) used different built-ins named with the __sync prefix. When - * compiling with such older GCC versions, it is necessary to use the applicable - * functions, which requires redefining BSON_IF_GNU_LIKE and defining the - * additional BSON_IF_GNU_LEGACY_ATOMICS macro here. */ -#ifdef BSON_USE_LEGACY_GCC_ATOMICS -#undef BSON_IF_GNU_LIKE -#define BSON_IF_GNU_LIKE(...) -#define BSON_IF_MSVC(...) -#define BSON_IF_GNU_LEGACY_ATOMICS(...) __VA_ARGS__ -#else -#define BSON_IF_GNU_LEGACY_ATOMICS(...) -#endif - -/* CDRIVER-4229 zSeries with gcc 4.8.4 produces illegal instructions for int and - * int32 atomic intrinsics. */ -#if defined(__s390__) || defined(__s390x__) || defined(__zarch__) -#define BSON_EMULATE_INT32 -#define BSON_EMULATE_INT -#endif - -/* CDRIVER-4264 Contrary to documentation, VS 2013 targeting x86 does not - * correctly/consistently provide _InterlockedPointerExchange. */ -#if defined(_MSC_VER) && _MSC_VER < 1900 && defined(_M_IX86) -#define BSON_EMULATE_PTR -#endif - -#define DEF_ATOMIC_OP( \ - MSVC_Intrinsic, GNU_Intrinsic, GNU_Legacy_Intrinsic, Order, ...) \ - do { \ - switch (Order) { \ - case bson_memory_order_acq_rel: \ - BSON_IF_MSVC (return MSVC_Intrinsic (__VA_ARGS__);) \ - BSON_IF_GNU_LIKE ( \ - return GNU_Intrinsic (__VA_ARGS__, __ATOMIC_ACQ_REL);) \ - BSON_IF_GNU_LEGACY_ATOMICS ( \ - return GNU_Legacy_Intrinsic (__VA_ARGS__);) \ - case bson_memory_order_seq_cst: \ - BSON_IF_MSVC (return MSVC_Intrinsic (__VA_ARGS__);) \ - BSON_IF_GNU_LIKE ( \ - return GNU_Intrinsic (__VA_ARGS__, __ATOMIC_SEQ_CST);) \ - BSON_IF_GNU_LEGACY_ATOMICS ( \ - return GNU_Legacy_Intrinsic (__VA_ARGS__);) \ - case bson_memory_order_acquire: \ - BSON_IF_MSVC ( \ - return BSON_CONCAT (MSVC_Intrinsic, \ - MSVC_MEMORDER_SUFFIX (_acq)) (__VA_ARGS__);) \ - BSON_IF_GNU_LIKE ( \ - return GNU_Intrinsic (__VA_ARGS__, __ATOMIC_ACQUIRE);) \ - BSON_IF_GNU_LEGACY_ATOMICS ( \ - return GNU_Legacy_Intrinsic (__VA_ARGS__);) \ - case bson_memory_order_consume: \ - BSON_IF_MSVC ( \ - return BSON_CONCAT (MSVC_Intrinsic, \ - MSVC_MEMORDER_SUFFIX (_acq)) (__VA_ARGS__);) \ - BSON_IF_GNU_LIKE ( \ - return GNU_Intrinsic (__VA_ARGS__, __ATOMIC_CONSUME);) \ - BSON_IF_GNU_LEGACY_ATOMICS ( \ - return GNU_Legacy_Intrinsic (__VA_ARGS__);) \ - case bson_memory_order_release: \ - BSON_IF_MSVC ( \ - return BSON_CONCAT (MSVC_Intrinsic, \ - MSVC_MEMORDER_SUFFIX (_rel)) (__VA_ARGS__);) \ - BSON_IF_GNU_LIKE ( \ - return GNU_Intrinsic (__VA_ARGS__, __ATOMIC_RELEASE);) \ - BSON_IF_GNU_LEGACY_ATOMICS ( \ - return GNU_Legacy_Intrinsic (__VA_ARGS__);) \ - case bson_memory_order_relaxed: \ - BSON_IF_MSVC ( \ - return BSON_CONCAT (MSVC_Intrinsic, \ - MSVC_MEMORDER_SUFFIX (_nf)) (__VA_ARGS__);) \ - BSON_IF_GNU_LIKE ( \ - return GNU_Intrinsic (__VA_ARGS__, __ATOMIC_RELAXED);) \ - BSON_IF_GNU_LEGACY_ATOMICS ( \ - return GNU_Legacy_Intrinsic (__VA_ARGS__);) \ - default: \ - BSON_UNREACHABLE ("Invalid bson_memory_order value"); \ - } \ - } while (0) - - -#define DEF_ATOMIC_CMPEXCH_STRONG( \ - VCSuffix1, VCSuffix2, GNU_MemOrder, Ptr, ExpectActualVar, NewValue) \ - do { \ - BSON_IF_MSVC (ExpectActualVar = BSON_CONCAT3 ( \ - _InterlockedCompareExchange, VCSuffix1, VCSuffix2) ( \ - Ptr, NewValue, ExpectActualVar);) \ - BSON_IF_GNU_LIKE ( \ - (void) __atomic_compare_exchange_n (Ptr, \ - &ExpectActualVar, \ - NewValue, \ - false, /* Not weak */ \ - GNU_MemOrder, \ - GNU_MemOrder);) \ - BSON_IF_GNU_LEGACY_ATOMICS ( \ - __typeof__ (ExpectActualVar) _val; \ - _val = __sync_val_compare_and_swap (Ptr, ExpectActualVar, NewValue); \ - ExpectActualVar = _val;) \ - } while (0) - - -#define DEF_ATOMIC_CMPEXCH_WEAK( \ - VCSuffix1, VCSuffix2, GNU_MemOrder, Ptr, ExpectActualVar, NewValue) \ - do { \ - BSON_IF_MSVC (ExpectActualVar = BSON_CONCAT3 ( \ - _InterlockedCompareExchange, VCSuffix1, VCSuffix2) ( \ - Ptr, NewValue, ExpectActualVar);) \ - BSON_IF_GNU_LIKE ( \ - (void) __atomic_compare_exchange_n (Ptr, \ - &ExpectActualVar, \ - NewValue, \ - true, /* Yes weak */ \ - GNU_MemOrder, \ - GNU_MemOrder);) \ - BSON_IF_GNU_LEGACY_ATOMICS ( \ - __typeof__ (ExpectActualVar) _val; \ - _val = __sync_val_compare_and_swap (Ptr, ExpectActualVar, NewValue); \ - ExpectActualVar = _val;) \ - } while (0) - - -#define DECL_ATOMIC_INTEGRAL(NamePart, Type, VCIntrinSuffix) \ - static BSON_INLINE Type bson_atomic_##NamePart##_fetch_add ( \ - Type volatile *a, Type addend, enum bson_memory_order ord) \ - { \ - DEF_ATOMIC_OP (BSON_CONCAT (_InterlockedExchangeAdd, VCIntrinSuffix), \ - __atomic_fetch_add, \ - __sync_fetch_and_add, \ - ord, \ - a, \ - addend); \ - } \ - \ - static BSON_INLINE Type bson_atomic_##NamePart##_fetch_sub ( \ - Type volatile *a, Type subtrahend, enum bson_memory_order ord) \ - { \ - /* MSVC doesn't have a subtract intrinsic, so just reuse addition */ \ - BSON_IF_MSVC ( \ - return bson_atomic_##NamePart##_fetch_add (a, -subtrahend, ord);) \ - BSON_IF_GNU_LIKE ( \ - DEF_ATOMIC_OP (~, __atomic_fetch_sub, ~, ord, a, subtrahend);) \ - BSON_IF_GNU_LEGACY_ATOMICS ( \ - DEF_ATOMIC_OP (~, ~, __sync_fetch_and_sub, ord, a, subtrahend);) \ - } \ - \ - static BSON_INLINE Type bson_atomic_##NamePart##_fetch ( \ - Type volatile const *a, enum bson_memory_order order) \ - { \ - /* MSVC doesn't have a load intrinsic, so just add zero */ \ - BSON_IF_MSVC (return bson_atomic_##NamePart##_fetch_add ( \ - (Type volatile *) a, 0, order);) \ - /* GNU doesn't want RELEASE order for the fetch operation, so we can't \ - * just use DEF_ATOMIC_OP. */ \ - BSON_IF_GNU_LIKE (switch (order) { \ - case bson_memory_order_release: /* Fall back to seqcst */ \ - case bson_memory_order_acq_rel: /* Fall back to seqcst */ \ - case bson_memory_order_seq_cst: \ - return __atomic_load_n (a, __ATOMIC_SEQ_CST); \ - case bson_memory_order_acquire: \ - return __atomic_load_n (a, __ATOMIC_ACQUIRE); \ - case bson_memory_order_consume: \ - return __atomic_load_n (a, __ATOMIC_CONSUME); \ - case bson_memory_order_relaxed: \ - return __atomic_load_n (a, __ATOMIC_RELAXED); \ - default: \ - BSON_UNREACHABLE ("Invalid bson_memory_order value"); \ - }) \ - BSON_IF_GNU_LEGACY_ATOMICS ({ \ - __sync_synchronize (); \ - return *a; \ - }) \ - } \ - \ - static BSON_INLINE Type bson_atomic_##NamePart##_exchange ( \ - Type volatile *a, Type value, enum bson_memory_order ord) \ - { \ - BSON_IF_MSVC ( \ - DEF_ATOMIC_OP (BSON_CONCAT (_InterlockedExchange, VCIntrinSuffix), \ - ~, \ - ~, \ - ord, \ - a, \ - value);) \ - /* GNU doesn't want CONSUME order for the exchange operation, so we \ - * cannot use DEF_ATOMIC_OP. */ \ - BSON_IF_GNU_LIKE (switch (ord) { \ - case bson_memory_order_acq_rel: \ - return __atomic_exchange_n (a, value, __ATOMIC_ACQ_REL); \ - case bson_memory_order_release: \ - return __atomic_exchange_n (a, value, __ATOMIC_RELEASE); \ - case bson_memory_order_seq_cst: \ - return __atomic_exchange_n (a, value, __ATOMIC_SEQ_CST); \ - case bson_memory_order_consume: /* Fall back to acquire */ \ - case bson_memory_order_acquire: \ - return __atomic_exchange_n (a, value, __ATOMIC_ACQUIRE); \ - case bson_memory_order_relaxed: \ - return __atomic_exchange_n (a, value, __ATOMIC_RELAXED); \ - default: \ - BSON_UNREACHABLE ("Invalid bson_memory_order value"); \ - }) \ - BSON_IF_GNU_LEGACY_ATOMICS ( \ - return __sync_val_compare_and_swap (a, *a, value);) \ - } \ - \ - static BSON_INLINE Type bson_atomic_##NamePart##_compare_exchange_strong ( \ - Type volatile *a, \ - Type expect, \ - Type new_value, \ - enum bson_memory_order ord) \ - { \ - Type actual = expect; \ - switch (ord) { \ - case bson_memory_order_release: \ - case bson_memory_order_acq_rel: \ - case bson_memory_order_seq_cst: \ - DEF_ATOMIC_CMPEXCH_STRONG ( \ - VCIntrinSuffix, , __ATOMIC_SEQ_CST, a, actual, new_value); \ - break; \ - case bson_memory_order_acquire: \ - DEF_ATOMIC_CMPEXCH_STRONG (VCIntrinSuffix, \ - MSVC_MEMORDER_SUFFIX (_acq), \ - __ATOMIC_ACQUIRE, \ - a, \ - actual, \ - new_value); \ - break; \ - case bson_memory_order_consume: \ - DEF_ATOMIC_CMPEXCH_STRONG (VCIntrinSuffix, \ - MSVC_MEMORDER_SUFFIX (_acq), \ - __ATOMIC_CONSUME, \ - a, \ - actual, \ - new_value); \ - break; \ - case bson_memory_order_relaxed: \ - DEF_ATOMIC_CMPEXCH_STRONG (VCIntrinSuffix, \ - MSVC_MEMORDER_SUFFIX (_nf), \ - __ATOMIC_RELAXED, \ - a, \ - actual, \ - new_value); \ - break; \ - default: \ - BSON_UNREACHABLE ("Invalid bson_memory_order value"); \ - } \ - return actual; \ - } \ - \ - static BSON_INLINE Type bson_atomic_##NamePart##_compare_exchange_weak ( \ - Type volatile *a, \ - Type expect, \ - Type new_value, \ - enum bson_memory_order ord) \ - { \ - Type actual = expect; \ - switch (ord) { \ - case bson_memory_order_release: \ - case bson_memory_order_acq_rel: \ - case bson_memory_order_seq_cst: \ - DEF_ATOMIC_CMPEXCH_WEAK ( \ - VCIntrinSuffix, , __ATOMIC_SEQ_CST, a, actual, new_value); \ - break; \ - case bson_memory_order_acquire: \ - DEF_ATOMIC_CMPEXCH_WEAK (VCIntrinSuffix, \ - MSVC_MEMORDER_SUFFIX (_acq), \ - __ATOMIC_ACQUIRE, \ - a, \ - actual, \ - new_value); \ - break; \ - case bson_memory_order_consume: \ - DEF_ATOMIC_CMPEXCH_WEAK (VCIntrinSuffix, \ - MSVC_MEMORDER_SUFFIX (_acq), \ - __ATOMIC_CONSUME, \ - a, \ - actual, \ - new_value); \ - break; \ - case bson_memory_order_relaxed: \ - DEF_ATOMIC_CMPEXCH_WEAK (VCIntrinSuffix, \ - MSVC_MEMORDER_SUFFIX (_nf), \ - __ATOMIC_RELAXED, \ - a, \ - actual, \ - new_value); \ - break; \ - default: \ - BSON_UNREACHABLE ("Invalid bson_memory_order value"); \ - } \ - return actual; \ - } - -#define DECL_ATOMIC_STDINT(Name, VCSuffix) \ - DECL_ATOMIC_INTEGRAL (Name, Name##_t, VCSuffix) - -#if defined(_MSC_VER) || defined(BSON_USE_LEGACY_GCC_ATOMICS) -/* MSVC and GCC require built-in types (not typedefs) for their atomic - * intrinsics. */ -#if defined(_MSC_VER) -#define DECL_ATOMIC_INTEGRAL_INT8 char -#define DECL_ATOMIC_INTEGRAL_INT32 long -#define DECL_ATOMIC_INTEGRAL_INT long -#else -#define DECL_ATOMIC_INTEGRAL_INT8 signed char -#define DECL_ATOMIC_INTEGRAL_INT32 int -#define DECL_ATOMIC_INTEGRAL_INT int -#endif -DECL_ATOMIC_INTEGRAL (int8, DECL_ATOMIC_INTEGRAL_INT8, 8) -DECL_ATOMIC_INTEGRAL (int16, short, 16) -#if !defined(BSON_EMULATE_INT32) -DECL_ATOMIC_INTEGRAL (int32, DECL_ATOMIC_INTEGRAL_INT32, ) -#endif -#if !defined(BSON_EMULATE_INT) -DECL_ATOMIC_INTEGRAL (int, DECL_ATOMIC_INTEGRAL_INT, ) -#endif -#else -/* Other compilers that we support provide generic intrinsics */ -DECL_ATOMIC_STDINT (int8, 8) -DECL_ATOMIC_STDINT (int16, 16) -#if !defined(BSON_EMULATE_INT32) -DECL_ATOMIC_STDINT (int32, ) -#endif -#if !defined(BSON_EMULATE_INT) -DECL_ATOMIC_INTEGRAL (int, int, ) -#endif -#endif - -#ifndef DECL_ATOMIC_INTEGRAL_INT32 -#define DECL_ATOMIC_INTEGRAL_INT32 int32_t -#endif - -BSON_EXPORT (int64_t) -_bson_emul_atomic_int64_fetch_add (int64_t volatile *val, - int64_t v, - enum bson_memory_order); -BSON_EXPORT (int64_t) -_bson_emul_atomic_int64_exchange (int64_t volatile *val, - int64_t v, - enum bson_memory_order); -BSON_EXPORT (int64_t) -_bson_emul_atomic_int64_compare_exchange_strong (int64_t volatile *val, - int64_t expect_value, - int64_t new_value, - enum bson_memory_order); - -BSON_EXPORT (int64_t) -_bson_emul_atomic_int64_compare_exchange_weak (int64_t volatile *val, - int64_t expect_value, - int64_t new_value, - enum bson_memory_order); - -BSON_EXPORT (int32_t) -_bson_emul_atomic_int32_fetch_add (int32_t volatile *val, - int32_t v, - enum bson_memory_order); -BSON_EXPORT (int32_t) -_bson_emul_atomic_int32_exchange (int32_t volatile *val, - int32_t v, - enum bson_memory_order); -BSON_EXPORT (int32_t) -_bson_emul_atomic_int32_compare_exchange_strong (int32_t volatile *val, - int32_t expect_value, - int32_t new_value, - enum bson_memory_order); - -BSON_EXPORT (int32_t) -_bson_emul_atomic_int32_compare_exchange_weak (int32_t volatile *val, - int32_t expect_value, - int32_t new_value, - enum bson_memory_order); - -BSON_EXPORT (int) -_bson_emul_atomic_int_fetch_add (int volatile *val, - int v, - enum bson_memory_order); -BSON_EXPORT (int) -_bson_emul_atomic_int_exchange (int volatile *val, - int v, - enum bson_memory_order); -BSON_EXPORT (int) -_bson_emul_atomic_int_compare_exchange_strong (int volatile *val, - int expect_value, - int new_value, - enum bson_memory_order); - -BSON_EXPORT (int) -_bson_emul_atomic_int_compare_exchange_weak (int volatile *val, - int expect_value, - int new_value, - enum bson_memory_order); - -BSON_EXPORT (void *) -_bson_emul_atomic_ptr_exchange (void *volatile *val, - void *v, - enum bson_memory_order); - -BSON_EXPORT (void) -bson_thrd_yield (void); - -#if (defined(_MSC_VER) && !defined(_M_IX86)) || (defined(__LP64__) && __LP64__) -/* (64-bit intrinsics are only available in x64) */ -#ifdef _MSC_VER -DECL_ATOMIC_INTEGRAL (int64, __int64, 64) -#else -DECL_ATOMIC_STDINT (int64, 64) -#endif -#else -static BSON_INLINE int64_t -bson_atomic_int64_fetch (const int64_t volatile *val, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int64_fetch_add ( - (int64_t volatile *) val, 0, order); -} - -static BSON_INLINE int64_t -bson_atomic_int64_fetch_add (int64_t volatile *val, - int64_t v, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int64_fetch_add (val, v, order); -} - -static BSON_INLINE int64_t -bson_atomic_int64_fetch_sub (int64_t volatile *val, - int64_t v, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int64_fetch_add (val, -v, order); -} - -static BSON_INLINE int64_t -bson_atomic_int64_exchange (int64_t volatile *val, - int64_t v, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int64_exchange (val, v, order); -} - -static BSON_INLINE int64_t -bson_atomic_int64_compare_exchange_strong (int64_t volatile *val, - int64_t expect_value, - int64_t new_value, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int64_compare_exchange_strong ( - val, expect_value, new_value, order); -} - -static BSON_INLINE int64_t -bson_atomic_int64_compare_exchange_weak (int64_t volatile *val, - int64_t expect_value, - int64_t new_value, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int64_compare_exchange_weak ( - val, expect_value, new_value, order); -} -#endif - -#if defined(BSON_EMULATE_INT32) -static BSON_INLINE int32_t -bson_atomic_int32_fetch (const int32_t volatile *val, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int32_fetch_add ( - (int32_t volatile *) val, 0, order); -} - -static BSON_INLINE int32_t -bson_atomic_int32_fetch_add (int32_t volatile *val, - int32_t v, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int32_fetch_add (val, v, order); -} - -static BSON_INLINE int32_t -bson_atomic_int32_fetch_sub (int32_t volatile *val, - int32_t v, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int32_fetch_add (val, -v, order); -} - -static BSON_INLINE int32_t -bson_atomic_int32_exchange (int32_t volatile *val, - int32_t v, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int32_exchange (val, v, order); -} - -static BSON_INLINE int32_t -bson_atomic_int32_compare_exchange_strong (int32_t volatile *val, - int32_t expect_value, - int32_t new_value, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int32_compare_exchange_strong ( - val, expect_value, new_value, order); -} - -static BSON_INLINE int32_t -bson_atomic_int32_compare_exchange_weak (int32_t volatile *val, - int32_t expect_value, - int32_t new_value, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int32_compare_exchange_weak ( - val, expect_value, new_value, order); -} -#endif /* BSON_EMULATE_INT32 */ - -#if defined(BSON_EMULATE_INT) -static BSON_INLINE int -bson_atomic_int_fetch (const int volatile *val, enum bson_memory_order order) -{ - return _bson_emul_atomic_int_fetch_add ((int volatile *) val, 0, order); -} - -static BSON_INLINE int -bson_atomic_int_fetch_add (int volatile *val, - int v, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int_fetch_add (val, v, order); -} - -static BSON_INLINE int -bson_atomic_int_fetch_sub (int volatile *val, - int v, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int_fetch_add (val, -v, order); -} - -static BSON_INLINE int -bson_atomic_int_exchange (int volatile *val, - int v, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int_exchange (val, v, order); -} - -static BSON_INLINE int -bson_atomic_int_compare_exchange_strong (int volatile *val, - int expect_value, - int new_value, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int_compare_exchange_strong ( - val, expect_value, new_value, order); -} - -static BSON_INLINE int -bson_atomic_int_compare_exchange_weak (int volatile *val, - int expect_value, - int new_value, - enum bson_memory_order order) -{ - return _bson_emul_atomic_int_compare_exchange_weak ( - val, expect_value, new_value, order); -} -#endif /* BSON_EMULATE_INT */ - -static BSON_INLINE void * -bson_atomic_ptr_exchange (void *volatile *ptr, - void *new_value, - enum bson_memory_order ord) -{ -#if defined(BSON_EMULATE_PTR) - return _bson_emul_atomic_ptr_exchange (ptr, new_value, ord); -#elif defined(BSON_USE_LEGACY_GCC_ATOMICS) - /* The older __sync_val_compare_and_swap also takes oldval */ - DEF_ATOMIC_OP (_InterlockedExchangePointer, - , - __sync_val_compare_and_swap, - ord, - ptr, - *ptr, - new_value); -#else - DEF_ATOMIC_OP ( - _InterlockedExchangePointer, __atomic_exchange_n, , ord, ptr, new_value); -#endif -} - -static BSON_INLINE void * -bson_atomic_ptr_compare_exchange_strong (void *volatile *ptr, - void *expect, - void *new_value, - enum bson_memory_order ord) -{ - switch (ord) { - case bson_memory_order_release: - case bson_memory_order_acq_rel: - case bson_memory_order_seq_cst: - DEF_ATOMIC_CMPEXCH_STRONG ( - Pointer, , __ATOMIC_SEQ_CST, ptr, expect, new_value); - return expect; - case bson_memory_order_relaxed: - DEF_ATOMIC_CMPEXCH_STRONG (Pointer, - MSVC_MEMORDER_SUFFIX (_nf), - __ATOMIC_RELAXED, - ptr, - expect, - new_value); - return expect; - case bson_memory_order_consume: - DEF_ATOMIC_CMPEXCH_STRONG (Pointer, - MSVC_MEMORDER_SUFFIX (_acq), - __ATOMIC_CONSUME, - ptr, - expect, - new_value); - return expect; - case bson_memory_order_acquire: - DEF_ATOMIC_CMPEXCH_STRONG (Pointer, - MSVC_MEMORDER_SUFFIX (_acq), - __ATOMIC_ACQUIRE, - ptr, - expect, - new_value); - return expect; - default: - BSON_UNREACHABLE ("Invalid bson_memory_order value"); - } -} - - -static BSON_INLINE void * -bson_atomic_ptr_compare_exchange_weak (void *volatile *ptr, - void *expect, - void *new_value, - enum bson_memory_order ord) -{ - switch (ord) { - case bson_memory_order_release: - case bson_memory_order_acq_rel: - case bson_memory_order_seq_cst: - DEF_ATOMIC_CMPEXCH_WEAK ( - Pointer, , __ATOMIC_SEQ_CST, ptr, expect, new_value); - return expect; - case bson_memory_order_relaxed: - DEF_ATOMIC_CMPEXCH_WEAK (Pointer, - MSVC_MEMORDER_SUFFIX (_nf), - __ATOMIC_RELAXED, - ptr, - expect, - new_value); - return expect; - case bson_memory_order_consume: - DEF_ATOMIC_CMPEXCH_WEAK (Pointer, - MSVC_MEMORDER_SUFFIX (_acq), - __ATOMIC_CONSUME, - ptr, - expect, - new_value); - return expect; - case bson_memory_order_acquire: - DEF_ATOMIC_CMPEXCH_WEAK (Pointer, - MSVC_MEMORDER_SUFFIX (_acq), - __ATOMIC_ACQUIRE, - ptr, - expect, - new_value); - return expect; - default: - BSON_UNREACHABLE ("Invalid bson_memory_order value"); - } -} - - -static BSON_INLINE void * -bson_atomic_ptr_fetch (void *volatile const *ptr, enum bson_memory_order ord) -{ - return bson_atomic_ptr_compare_exchange_strong ( - (void *volatile *) ptr, NULL, NULL, ord); -} - -#undef DECL_ATOMIC_STDINT -#undef DECL_ATOMIC_INTEGRAL -#undef DEF_ATOMIC_OP -#undef DEF_ATOMIC_CMPEXCH_STRONG -#undef DEF_ATOMIC_CMPEXCH_WEAK -#undef MSVC_MEMORDER_SUFFIX - -/** - * @brief Generate a full-fence memory barrier at the call site. - */ -static BSON_INLINE void -bson_atomic_thread_fence (void) -{ - BSON_IF_MSVC (MemoryBarrier ();) - BSON_IF_GNU_LIKE (__sync_synchronize ();) - BSON_IF_GNU_LEGACY_ATOMICS (__sync_synchronize ();) -} - -#ifdef BSON_USE_LEGACY_GCC_ATOMICS -#undef BSON_IF_GNU_LIKE -#define BSON_IF_GNU_LIKE(...) __VA_ARGS__ -#endif -#undef BSON_IF_GNU_LEGACY_ATOMICS -#undef BSON_USE_LEGACY_GCC_ATOMICS - -BSON_GNUC_DEPRECATED_FOR ("bson_atomic_thread_fence") -BSON_EXPORT (void) bson_memory_barrier (void); - -BSON_GNUC_DEPRECATED_FOR ("bson_atomic_int_fetch_add") -BSON_EXPORT (int32_t) bson_atomic_int_add (volatile int32_t *p, int32_t n); - -BSON_GNUC_DEPRECATED_FOR ("bson_atomic_int64_fetch_add") -BSON_EXPORT (int64_t) bson_atomic_int64_add (volatile int64_t *p, int64_t n); - - -#undef BSON_EMULATE_PTR -#undef BSON_EMULATE_INT32 -#undef BSON_EMULATE_INT - -BSON_END_DECLS - - -#endif /* BSON_ATOMIC_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-cmp.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-cmp.h deleted file mode 100644 index 8db9ed950..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-cmp.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright 2022 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_CMP_H -#define BSON_CMP_H - - -#include /* ssize_t */ -#include /* BSON_CONCAT */ - -#include -#include -#include - - -BSON_BEGIN_DECLS - - -/* Based on the "Safe Integral Comparisons" proposal merged in C++20: - * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0586r2.html - * - * Due to lack of type deduction in C, relational comparison functions (e.g. - * `cmp_less`) are defined in sets of four "functions" according to the - * signedness of each value argument, e.g.: - * - bson_cmp_less_ss (signed-value, signed-value) - * - bson_cmp_less_uu (unsigned-value, unsigned-value) - * - bson_cmp_less_su (signed-value, unsigned-value) - * - bson_cmp_less_us (unsigned-value, signed-value) - * - * Similarly, the `in_range` function is defined as a set of two "functions" - * according to the signedness of the value argument: - * - bson_in_range_signed (Type, signed-value) - * - bson_in_range_unsigned (Type, unsigned-value) - * - * The user must take care to use the correct signedness for the provided - * argument(s). Enabling compiler warnings for implicit sign conversions is - * recommended. - */ - - -#define BSON_CMP_SET(op, ss, uu, su, us) \ - static BSON_INLINE bool BSON_CONCAT3 (bson_cmp_, op, _ss) (int64_t t, \ - int64_t u) \ - { \ - return (ss); \ - } \ - \ - static BSON_INLINE bool BSON_CONCAT3 (bson_cmp_, op, _uu) (uint64_t t, \ - uint64_t u) \ - { \ - return (uu); \ - } \ - \ - static BSON_INLINE bool BSON_CONCAT3 (bson_cmp_, op, _su) (int64_t t, \ - uint64_t u) \ - { \ - return (su); \ - } \ - \ - static BSON_INLINE bool BSON_CONCAT3 (bson_cmp_, op, _us) (uint64_t t, \ - int64_t u) \ - { \ - return (us); \ - } - -BSON_CMP_SET (equal, - t == u, - t == u, - t < 0 ? false : (uint64_t) (t) == u, - u < 0 ? false : t == (uint64_t) (u)) - -BSON_CMP_SET (not_equal, - !bson_cmp_equal_ss (t, u), - !bson_cmp_equal_uu (t, u), - !bson_cmp_equal_su (t, u), - !bson_cmp_equal_us (t, u)) - -BSON_CMP_SET (less, - t < u, - t < u, - t < 0 ? true : (uint64_t) (t) < u, - u < 0 ? false : t < (uint64_t) (u)) - -BSON_CMP_SET (greater, - bson_cmp_less_ss (u, t), - bson_cmp_less_uu (u, t), - bson_cmp_less_us (u, t), - bson_cmp_less_su (u, t)) - -BSON_CMP_SET (less_equal, - !bson_cmp_greater_ss (t, u), - !bson_cmp_greater_uu (t, u), - !bson_cmp_greater_su (t, u), - !bson_cmp_greater_us (t, u)) - -BSON_CMP_SET (greater_equal, - !bson_cmp_less_ss (t, u), - !bson_cmp_less_uu (t, u), - !bson_cmp_less_su (t, u), - !bson_cmp_less_us (t, u)) - -#undef BSON_CMP_SET - - -/* Return true if the given value is within the range of the corresponding - * signed type. The suffix must match the signedness of the given value. */ -#define BSON_IN_RANGE_SET_SIGNED(Type, min, max) \ - static BSON_INLINE bool BSON_CONCAT3 (bson_in_range, _##Type, _signed) ( \ - int64_t value) \ - { \ - return bson_cmp_greater_equal_ss (value, min) && \ - bson_cmp_less_equal_ss (value, max); \ - } \ - \ - static BSON_INLINE bool BSON_CONCAT3 (bson_in_range, _##Type, _unsigned) ( \ - uint64_t value) \ - { \ - return bson_cmp_greater_equal_us (value, min) && \ - bson_cmp_less_equal_us (value, max); \ - } - -/* Return true if the given value is within the range of the corresponding - * unsigned type. The suffix must match the signedness of the given value. */ -#define BSON_IN_RANGE_SET_UNSIGNED(Type, max) \ - static BSON_INLINE bool BSON_CONCAT3 (bson_in_range, _##Type, _signed) ( \ - int64_t value) \ - { \ - return bson_cmp_greater_equal_su (value, 0u) && \ - bson_cmp_less_equal_su (value, max); \ - } \ - \ - static BSON_INLINE bool BSON_CONCAT3 (bson_in_range, _##Type, _unsigned) ( \ - uint64_t value) \ - { \ - return bson_cmp_less_equal_uu (value, max); \ - } - -BSON_IN_RANGE_SET_SIGNED (signed_char, SCHAR_MIN, SCHAR_MAX) -BSON_IN_RANGE_SET_SIGNED (short, SHRT_MIN, SHRT_MAX) -BSON_IN_RANGE_SET_SIGNED (int, INT_MIN, INT_MAX) -BSON_IN_RANGE_SET_SIGNED (long, LONG_MIN, LONG_MAX) -BSON_IN_RANGE_SET_SIGNED (long_long, LLONG_MIN, LLONG_MAX) - -BSON_IN_RANGE_SET_UNSIGNED (unsigned_char, UCHAR_MAX) -BSON_IN_RANGE_SET_UNSIGNED (unsigned_short, USHRT_MAX) -BSON_IN_RANGE_SET_UNSIGNED (unsigned_int, UINT_MAX) -BSON_IN_RANGE_SET_UNSIGNED (unsigned_long, ULONG_MAX) -BSON_IN_RANGE_SET_UNSIGNED (unsigned_long_long, ULLONG_MAX) - -BSON_IN_RANGE_SET_SIGNED (int8_t, INT8_MIN, INT8_MAX) -BSON_IN_RANGE_SET_SIGNED (int16_t, INT16_MIN, INT16_MAX) -BSON_IN_RANGE_SET_SIGNED (int32_t, INT32_MIN, INT32_MAX) -BSON_IN_RANGE_SET_SIGNED (int64_t, INT64_MIN, INT64_MAX) - -BSON_IN_RANGE_SET_UNSIGNED (uint8_t, UINT8_MAX) -BSON_IN_RANGE_SET_UNSIGNED (uint16_t, UINT16_MAX) -BSON_IN_RANGE_SET_UNSIGNED (uint32_t, UINT32_MAX) -BSON_IN_RANGE_SET_UNSIGNED (uint64_t, UINT64_MAX) - -BSON_IN_RANGE_SET_SIGNED (ssize_t, SSIZE_MIN, SSIZE_MAX) -BSON_IN_RANGE_SET_UNSIGNED (size_t, SIZE_MAX) - -#undef BSON_IN_RANGE_SET_SIGNED -#undef BSON_IN_RANGE_SET_UNSIGNED - - -/* Return true if the value with *signed* type is in the representable range of - * Type and false otherwise. */ -#define bson_in_range_signed(Type, value) \ - BSON_CONCAT3 (bson_in_range, _##Type, _signed) (value) - -/* Return true if the value with *unsigned* type is in the representable range - * of Type and false otherwise. */ -#define bson_in_range_unsigned(Type, value) \ - BSON_CONCAT3 (bson_in_range, _##Type, _unsigned) (value) - - -BSON_END_DECLS - - -#endif /* BSON_CMP_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-compat.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-compat.h deleted file mode 100644 index 5f8e092f2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-compat.h +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_COMPAT_H -#define BSON_COMPAT_H - - -#if defined(__MINGW32__) -#if defined(__USE_MINGW_ANSI_STDIO) -#if __USE_MINGW_ANSI_STDIO < 1 -#error "__USE_MINGW_ANSI_STDIO > 0 is required for correct PRI* macros" -#endif -#else -#define __USE_MINGW_ANSI_STDIO 1 -#endif -#endif - -#include -#include - - -#ifdef BSON_OS_WIN32 -#if defined(_WIN32_WINNT) && (_WIN32_WINNT < 0x0600) -#undef _WIN32_WINNT -#endif -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#endif -#ifndef NOMINMAX -#define NOMINMAX -#endif -#include -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN -#else -#include -#endif -#include -#include -#endif - - -#ifdef BSON_OS_UNIX -#include -#include -#endif - - -#include - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -BSON_BEGIN_DECLS - -#if !defined(_MSC_VER) || (_MSC_VER >= 1800) -#include -#endif -#ifdef _MSC_VER -#ifndef __cplusplus -/* benign redefinition of type */ -#pragma warning(disable : 4142) -#ifndef _SSIZE_T_DEFINED -#define _SSIZE_T_DEFINED -typedef SSIZE_T ssize_t; -#endif -#ifndef _SIZE_T_DEFINED -#define _SIZE_T_DEFINED -typedef SIZE_T size_t; -#endif -#pragma warning(default : 4142) -#else -/* - * MSVC++ does not include ssize_t, just size_t. - * So we need to synthesize that as well. - */ -#pragma warning(disable : 4142) -#ifndef _SSIZE_T_DEFINED -#define _SSIZE_T_DEFINED -typedef SSIZE_T ssize_t; -#endif -#pragma warning(default : 4142) -#endif -#ifndef PRIi32 -#define PRIi32 "d" -#endif -#ifndef PRId32 -#define PRId32 "d" -#endif -#ifndef PRIu32 -#define PRIu32 "u" -#endif -#ifndef PRIi64 -#define PRIi64 "I64i" -#endif -#ifndef PRId64 -#define PRId64 "I64i" -#endif -#ifndef PRIu64 -#define PRIu64 "I64u" -#endif -#endif - -/* Derive the maximum representable value of signed integer type T using the - * formula 2^(N - 1) - 1 where N is the number of bits in type T. This assumes - * T is represented using two's complement. */ -#define BSON_NUMERIC_LIMITS_MAX_SIGNED(T) \ - ((T) ((((size_t) 0x01u) << (sizeof (T) * (size_t) CHAR_BIT - 1u)) - 1u)) - -/* Derive the minimum representable value of signed integer type T as one less - * than the negation of its maximum representable value. This assumes T is - * represented using two's complement. */ -#define BSON_NUMERIC_LIMITS_MIN_SIGNED(T, max) ((T) ((-(max)) - 1)) - -/* Derive the maximum representable value of unsigned integer type T by flipping - * all its bits to 1. */ -#define BSON_NUMERIC_LIMITS_MAX_UNSIGNED(T) ((T) (~((T) 0))) - -#ifndef SSIZE_MAX -#define SSIZE_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED (ssize_t) -#endif - -#ifndef SSIZE_MIN -#define SSIZE_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED (ssize_t, SSIZE_MAX) -#endif - -#if defined(__MINGW32__) && !defined(INIT_ONCE_STATIC_INIT) -#define INIT_ONCE_STATIC_INIT RTL_RUN_ONCE_INIT -typedef RTL_RUN_ONCE INIT_ONCE; -#endif - -#ifdef BSON_HAVE_STDBOOL_H -#include -#elif !defined(__bool_true_false_are_defined) -#ifndef __cplusplus -typedef signed char bool; -#define false 0 -#define true 1 -#endif -#define __bool_true_false_are_defined 1 -#endif - - -#if defined(__GNUC__) -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) -#define bson_sync_synchronize() __sync_synchronize () -#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || \ - defined(__i686__) || defined(__x86_64__) -#define bson_sync_synchronize() asm volatile ("mfence" ::: "memory") -#else -#define bson_sync_synchronize() asm volatile ("sync" ::: "memory") -#endif -#elif defined(_MSC_VER) -#define bson_sync_synchronize() MemoryBarrier () -#endif - - -#if !defined(va_copy) && defined(__va_copy) -#define va_copy(dst, src) __va_copy (dst, src) -#endif - - -#if !defined(va_copy) -#define va_copy(dst, src) ((dst) = (src)) -#endif - - -#ifdef _MSC_VER -/** Expands the arguments if compiling with MSVC, otherwise empty */ -#define BSON_IF_MSVC(...) __VA_ARGS__ -/** Expands the arguments if compiling with GCC or Clang, otherwise empty */ -#define BSON_IF_GNU_LIKE(...) -#elif defined(__GNUC__) || defined(__clang__) -/** Expands the arguments if compiling with MSVC, otherwise empty */ -#define BSON_IF_MSVC(...) -/** Expands the arguments if compiling with GCC or Clang, otherwise empty */ -#define BSON_IF_GNU_LIKE(...) __VA_ARGS__ -#endif - -#ifdef BSON_OS_WIN32 -/** Expands the arguments if compiling for Windows, otherwise empty */ -#define BSON_IF_WINDOWS(...) __VA_ARGS__ -/** Expands the arguments if compiling for POSIX, otherwise empty */ -#define BSON_IF_POSIX(...) -#elif defined(BSON_OS_UNIX) -/** Expands the arguments if compiling for Windows, otherwise empty */ -#define BSON_IF_WINDOWS(...) -/** Expands the arguments if compiling for POSIX, otherwise empty */ -#define BSON_IF_POSIX(...) __VA_ARGS__ -#endif - - -BSON_END_DECLS - - -#endif /* BSON_COMPAT_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-config.h.in b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-config.h.in deleted file mode 100644 index 2849d0206..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-config.h.in +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2018-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#if !defined(BSON_INSIDE) && !defined(BSON_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef BSON_CONFIG_H -#define BSON_CONFIG_H - -/* - * Define to 1234 for Little Endian, 4321 for Big Endian. - */ -#define BSON_BYTE_ORDER @BSON_BYTE_ORDER@ - - -/* - * Define to 1 if you have stdbool.h - */ -#define BSON_HAVE_STDBOOL_H @BSON_HAVE_STDBOOL_H@ -#if BSON_HAVE_STDBOOL_H != 1 -# undef BSON_HAVE_STDBOOL_H -#endif - - -/* - * Define to 1 for POSIX-like systems, 2 for Windows. - */ -#define BSON_OS @BSON_OS@ - - -/* - * Define to 1 if you have clock_gettime() available. - */ -#define BSON_HAVE_CLOCK_GETTIME @BSON_HAVE_CLOCK_GETTIME@ -#if BSON_HAVE_CLOCK_GETTIME != 1 -# undef BSON_HAVE_CLOCK_GETTIME -#endif - - -/* - * Define to 1 if you have strings.h available on your platform. - */ -#define BSON_HAVE_STRINGS_H @BSON_HAVE_STRINGS_H@ -#if BSON_HAVE_STRINGS_H != 1 -# undef BSON_HAVE_STRINGS_H -#endif - - -/* - * Define to 1 if you have strnlen available on your platform. - */ -#define BSON_HAVE_STRNLEN @BSON_HAVE_STRNLEN@ -#if BSON_HAVE_STRNLEN != 1 -# undef BSON_HAVE_STRNLEN -#endif - - -/* - * Define to 1 if you have snprintf available on your platform. - */ -#define BSON_HAVE_SNPRINTF @BSON_HAVE_SNPRINTF@ -#if BSON_HAVE_SNPRINTF != 1 -# undef BSON_HAVE_SNPRINTF -#endif - - -/* - * Define to 1 if you have gmtime_r available on your platform. - */ -#define BSON_HAVE_GMTIME_R @BSON_HAVE_GMTIME_R@ -#if BSON_HAVE_GMTIME_R != 1 -# undef BSON_HAVE_GMTIME_R -#endif - - -/* - * Define to 1 if you have struct timespec available on your platform. - */ -#define BSON_HAVE_TIMESPEC @BSON_HAVE_TIMESPEC@ -#if BSON_HAVE_TIMESPEC != 1 -# undef BSON_HAVE_TIMESPEC -#endif - - -/* - * Define to 1 if you want extra aligned types in libbson - */ -#define BSON_EXTRA_ALIGN @BSON_EXTRA_ALIGN@ -#if BSON_EXTRA_ALIGN != 1 -# undef BSON_EXTRA_ALIGN -#endif - - -/* - * Define to 1 if you have rand_r available on your platform. - */ -#define BSON_HAVE_RAND_R @BSON_HAVE_RAND_R@ -#if BSON_HAVE_RAND_R != 1 -# undef BSON_HAVE_RAND_R -#endif - - -/* - * Define to 1 if you have strlcpy available on your platform. - */ -#define BSON_HAVE_STRLCPY @BSON_HAVE_STRLCPY@ -#if BSON_HAVE_STRLCPY != 1 -# undef BSON_HAVE_STRLCPY -#endif - -#endif /* BSON_CONFIG_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-error.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-error.c deleted file mode 100644 index 0c6257b1e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-error.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include - -#include -#include -#include -#include -#include -#include - -// See `bson_strerror_r()` definition below. -#if !defined(_WIN32) && !defined(__APPLE__) -#include // uselocale() -#endif - - -/* - *-------------------------------------------------------------------------- - * - * bson_set_error -- - * - * Initializes @error using the parameters specified. - * - * @domain is an application specific error domain which should - * describe which module initiated the error. Think of this as the - * exception type. - * - * @code is the @domain specific error code. - * - * @format is used to generate the format string. It uses vsnprintf() - * internally so the format should match what you would use there. - * - * Parameters: - * @error: A #bson_error_t. - * @domain: The error domain. - * @code: The error code. - * @format: A printf style format string. - * - * Returns: - * None. - * - * Side effects: - * @error is initialized. - * - *-------------------------------------------------------------------------- - */ - -void -bson_set_error (bson_error_t *error, /* OUT */ - uint32_t domain, /* IN */ - uint32_t code, /* IN */ - const char *format, /* IN */ - ...) /* IN */ -{ - va_list args; - - if (error) { - error->domain = domain; - error->code = code; - - va_start (args, format); - bson_vsnprintf (error->message, sizeof error->message, format, args); - va_end (args); - - error->message[sizeof error->message - 1] = '\0'; - } -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_strerror_r -- - * - * This is a reentrant safe macro for strerror. - * - * The resulting string may be stored in @buf. - * - * Returns: - * A pointer to a static string or @buf. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -char * -bson_strerror_r (int err_code, /* IN */ - char *buf BSON_MAYBE_UNUSED, /* IN */ - size_t buflen BSON_MAYBE_UNUSED) /* IN */ -{ - static const char *unknown_msg = "Unknown error"; - char *ret = NULL; - -#if defined(_WIN32) - // Windows does not provide `strerror_l` or `strerror_r`, but it does - // unconditionally provide `strerror_s`. - if (strerror_s (buf, buflen, err_code) != 0) { - ret = buf; - } -#elif defined(_AIX) - // AIX does not provide strerror_l, and its strerror_r isn't glibc's. - // But it does provide a glibc compatible one called __linux_strerror_r - ret = __linux_strerror_r (err_code, buf, buflen); -#elif defined(__APPLE__) - // Apple does not provide `strerror_l`, but it does unconditionally provide - // the XSI-compliant `strerror_r`, but only when compiling with Apple Clang. - // GNU extensions may still be a problem if we are being compiled with GCC on - // Apple. Avoid the compatibility headaches with GNU extensions and the musl - // library by assuming the implementation will not cause UB when reading the - // error message string even when `strerror_r` fails, as encouraged (but not - // required) by the POSIX spec (see: - // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html#tag_16_574_08). - (void) strerror_r (err_code, buf, buflen); -#elif defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700 - // The behavior (of `strerror_l`) is undefined if the locale argument to - // `strerror_l()` is the special locale object LC_GLOBAL_LOCALE or is not a - // valid locale object handle. - locale_t locale = uselocale ((locale_t) 0); - // No need to test for error (it can only be [EINVAL]). - if (locale == LC_GLOBAL_LOCALE) { - // Only use our own locale if a thread-local locale was not already set. - // This is just to satisfy `strerror_l`. We do NOT want to unconditionally - // set a thread-local locale. - locale = newlocale (LC_MESSAGES_MASK, "C", (locale_t) 0); - } - BSON_ASSERT (locale != LC_GLOBAL_LOCALE); - - // Avoid `strerror_r` compatibility headaches with GNU extensions and the - // musl library by using `strerror_l` instead. Furthermore, `strerror_r` is - // scheduled to be marked as obsolete in favor of `strerror_l` in the - // upcoming POSIX Issue 8 (see: - // https://www.austingroupbugs.net/view.php?id=655). - // - // POSIX Spec: since strerror_l() is required to return a string for some - // errors, an application wishing to check for all error situations should - // set errno to 0, then call strerror_l(), then check errno. - if (locale != (locale_t) 0) { - errno = 0; - ret = strerror_l (err_code, locale); - - if (errno != 0) { - ret = NULL; - } - - freelocale (locale); - } else { - // Could not obtain a valid `locale_t` object to satisfy `strerror_l`. - // Fallback to `bson_strncpy` below. - } -#elif defined(_GNU_SOURCE) - // Unlikely, but continue supporting use of GNU extension in cases where the - // C Driver is being built without _XOPEN_SOURCE=700. - ret = strerror_r (err_code, buf, buflen); -#else -#error "Unable to find a supported strerror_r candidate" -#endif - - if (!ret) { - bson_strncpy (buf, unknown_msg, buflen); - ret = buf; - } - - return ret; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-error.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-error.h deleted file mode 100644 index 7bfb21bf4..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-error.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_ERROR_H -#define BSON_ERROR_H - - -#include -#include -#include - - -BSON_BEGIN_DECLS - - -#define BSON_ERROR_JSON 1 -#define BSON_ERROR_READER 2 -#define BSON_ERROR_INVALID 3 - - -BSON_EXPORT (void) -bson_set_error (bson_error_t *error, - uint32_t domain, - uint32_t code, - const char *format, - ...) BSON_GNUC_PRINTF (4, 5); -BSON_EXPORT (char *) -bson_strerror_r (int err_code, char *buf, size_t buflen); - - -BSON_END_DECLS - - -#endif /* BSON_ERROR_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-iso8601-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-iso8601-private.h deleted file mode 100644 index f76cb56a3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-iso8601-private.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_ISO8601_PRIVATE_H -#define BSON_ISO8601_PRIVATE_H - - -#include -#include -#include - - -BSON_BEGIN_DECLS - -bool -_bson_iso8601_date_parse (const char *str, - int32_t len, - int64_t *out, - bson_error_t *error); - -/** - * _bson_iso8601_date_format: - * @msecs_since_epoch: A positive number of milliseconds since Jan 1, 1970. - * @str: The string to append the ISO8601-formatted to. - * - * Appends a date formatted like "2012-12-24T12:15:30.500Z" to @str. - */ -void -_bson_iso8601_date_format (int64_t msecs_since_epoch, bson_string_t *str); - -BSON_END_DECLS - - -#endif /* BSON_ISO8601_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-iso8601.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-iso8601.c deleted file mode 100644 index 2161f85dc..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-iso8601.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include -#include - - -static bool -get_tok (const char *terminals, - const char **ptr, - int32_t *remaining, - const char **out, - int32_t *out_len) -{ - const char *terminal; - bool found_terminal = false; - - if (!*remaining) { - *out = ""; - *out_len = 0; - } - - *out = *ptr; - *out_len = -1; - - for (; *remaining && !found_terminal; - (*ptr)++, (*remaining)--, (*out_len)++) { - for (terminal = terminals; *terminal; terminal++) { - if (**ptr == *terminal) { - found_terminal = true; - break; - } - } - } - - if (!found_terminal) { - (*out_len)++; - } - - return found_terminal; -} - -static bool -digits_only (const char *str, int32_t len) -{ - int i; - - for (i = 0; i < len; i++) { - if (!isdigit (str[i])) { - return false; - } - } - - return true; -} - -static bool -parse_num (const char *str, - int32_t len, - int32_t digits, - int32_t min, - int32_t max, - int32_t *out) -{ - int i; - int magnitude = 1; - int32_t value = 0; - - if ((digits >= 0 && len != digits) || !digits_only (str, len)) { - return false; - } - - for (i = 1; i <= len; i++, magnitude *= 10) { - value += (str[len - i] - '0') * magnitude; - } - - if (value < min || value > max) { - return false; - } - - *out = value; - - return true; -} - -bool -_bson_iso8601_date_parse (const char *str, - int32_t len, - int64_t *out, - bson_error_t *error) -{ - const char *ptr; - int32_t remaining = len; - - const char *year_ptr = NULL; - const char *month_ptr = NULL; - const char *day_ptr = NULL; - const char *hour_ptr = NULL; - const char *min_ptr = NULL; - const char *sec_ptr = NULL; - const char *millis_ptr = NULL; - const char *tz_ptr = NULL; - - int32_t year_len = 0; - int32_t month_len = 0; - int32_t day_len = 0; - int32_t hour_len = 0; - int32_t min_len = 0; - int32_t sec_len = 0; - int32_t millis_len = 0; - int32_t tz_len = 0; - - int32_t year; - int32_t month; - int32_t day; - int32_t hour; - int32_t min; - int32_t sec = 0; - int64_t millis = 0; - int32_t tz_adjustment = 0; - - struct bson_tm posix_date = {0}; - -#define DATE_PARSE_ERR(msg) \ - bson_set_error (error, \ - BSON_ERROR_JSON, \ - BSON_JSON_ERROR_READ_INVALID_PARAM, \ - "Could not parse \"%s\" as date: " msg, \ - str); \ - return false - -#define DEFAULT_DATE_PARSE_ERR \ - DATE_PARSE_ERR ("use ISO8601 format yyyy-mm-ddThh:mm plus timezone, either" \ - " \"Z\" or like \"+0500\"") - - ptr = str; - - /* we have to match at least yyyy-mm-ddThh:mm */ - if (!(get_tok ("-", &ptr, &remaining, &year_ptr, &year_len) && - get_tok ("-", &ptr, &remaining, &month_ptr, &month_len) && - get_tok ("T", &ptr, &remaining, &day_ptr, &day_len) && - get_tok (":", &ptr, &remaining, &hour_ptr, &hour_len) && - get_tok (":+-Z", &ptr, &remaining, &min_ptr, &min_len))) { - DEFAULT_DATE_PARSE_ERR; - } - - /* if the minute has a ':' at the end look for seconds */ - if (min_ptr[min_len] == ':') { - if (remaining < 2) { - DATE_PARSE_ERR ("reached end of date while looking for seconds"); - } - - get_tok (".+-Z", &ptr, &remaining, &sec_ptr, &sec_len); - - if (!sec_len) { - DATE_PARSE_ERR ("minute ends in \":\" seconds is required"); - } - } - - /* if we had a second and it is followed by a '.' look for milliseconds */ - if (sec_len && sec_ptr[sec_len] == '.') { - if (remaining < 2) { - DATE_PARSE_ERR ("reached end of date while looking for milliseconds"); - } - - get_tok ("+-Z", &ptr, &remaining, &millis_ptr, &millis_len); - - if (!millis_len) { - DATE_PARSE_ERR ("seconds ends in \".\", milliseconds is required"); - } - } - - /* backtrack by 1 to put ptr on the timezone */ - ptr--; - remaining++; - - get_tok ("", &ptr, &remaining, &tz_ptr, &tz_len); - - if (!parse_num (year_ptr, year_len, 4, -9999, 9999, &year)) { - DATE_PARSE_ERR ("year must be an integer"); - } - - /* values are as in struct tm */ - year -= 1900; - - if (!parse_num (month_ptr, month_len, 2, 1, 12, &month)) { - DATE_PARSE_ERR ("month must be an integer"); - } - - /* values are as in struct tm */ - month -= 1; - - if (!parse_num (day_ptr, day_len, 2, 1, 31, &day)) { - DATE_PARSE_ERR ("day must be an integer"); - } - - if (!parse_num (hour_ptr, hour_len, 2, 0, 23, &hour)) { - DATE_PARSE_ERR ("hour must be an integer"); - } - - if (!parse_num (min_ptr, min_len, 2, 0, 59, &min)) { - DATE_PARSE_ERR ("minute must be an integer"); - } - - if (sec_len && !parse_num (sec_ptr, sec_len, 2, 0, 60, &sec)) { - DATE_PARSE_ERR ("seconds must be an integer"); - } - - if (tz_len > 0) { - if (tz_ptr[0] == 'Z' && tz_len == 1) { - /* valid */ - } else if (tz_ptr[0] == '+' || tz_ptr[0] == '-') { - int32_t tz_hour; - int32_t tz_min; - - if (tz_len != 5 || !digits_only (tz_ptr + 1, 4)) { - DATE_PARSE_ERR ("could not parse timezone"); - } - - if (!parse_num (tz_ptr + 1, 2, -1, -23, 23, &tz_hour)) { - DATE_PARSE_ERR ("timezone hour must be at most 23"); - } - - if (!parse_num (tz_ptr + 3, 2, -1, 0, 59, &tz_min)) { - DATE_PARSE_ERR ("timezone minute must be at most 59"); - } - - /* we inflect the meaning of a 'positive' timezone. Those are hours - * we have to subtract, and vice versa */ - tz_adjustment = - (tz_ptr[0] == '-' ? 1 : -1) * ((tz_min * 60) + (tz_hour * 60 * 60)); - - if (!(tz_adjustment > -86400 && tz_adjustment < 86400)) { - DATE_PARSE_ERR ("timezone offset must be less than 24 hours"); - } - } else { - DATE_PARSE_ERR ("timezone is required"); - } - } - - if (millis_len > 0) { - int i; - int magnitude; - millis = 0; - - if (millis_len > 3 || !digits_only (millis_ptr, millis_len)) { - DATE_PARSE_ERR ("milliseconds must be an integer"); - } - - for (i = 1, magnitude = 1; i <= millis_len; i++, magnitude *= 10) { - millis += (millis_ptr[millis_len - i] - '0') * magnitude; - } - - if (millis_len == 1) { - millis *= 100; - } else if (millis_len == 2) { - millis *= 10; - } - - if (millis < 0 || millis > 1000) { - DATE_PARSE_ERR ("milliseconds must be at least 0 and less than 1000"); - } - } - - posix_date.tm_sec = sec; - posix_date.tm_min = min; - posix_date.tm_hour = hour; - posix_date.tm_mday = day; - posix_date.tm_mon = month; - posix_date.tm_year = year; - posix_date.tm_wday = 0; - posix_date.tm_yday = 0; - - millis = 1000 * _bson_timegm (&posix_date) + millis; - millis += tz_adjustment * 1000; - *out = millis; - - return true; -} - - -void -_bson_iso8601_date_format (int64_t msec_since_epoch, bson_string_t *str) -{ - time_t t; - int64_t msecs_part; - char buf[64]; - - msecs_part = msec_since_epoch % 1000; - t = (time_t) (msec_since_epoch / 1000); - -#ifdef BSON_HAVE_GMTIME_R - { - struct tm posix_date; - gmtime_r (&t, &posix_date); - strftime (buf, sizeof buf, "%Y-%m-%dT%H:%M:%S", &posix_date); - } -#elif defined(_MSC_VER) - { - /* Windows gmtime_s is thread-safe */ - struct tm time_buf; - gmtime_s (&time_buf, &t); - strftime (buf, sizeof buf, "%Y-%m-%dT%H:%M:%S", &time_buf); - } -#else - strftime (buf, sizeof buf, "%Y-%m-%dT%H:%M:%S", gmtime (&t)); -#endif - - if (msecs_part) { - bson_string_append_printf (str, "%s.%03" PRId64 "Z", buf, msecs_part); - } else { - bson_string_append (str, buf); - bson_string_append_c (str, 'Z'); - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-iter.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-iter.h deleted file mode 100644 index 22af2e45d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-iter.h +++ /dev/null @@ -1,561 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_ITER_H -#define BSON_ITER_H - - -#include "bson.h" -#include -#include -#include - - -BSON_BEGIN_DECLS - - -#define BSON_ITER_HOLDS_DOUBLE(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_DOUBLE) - -#define BSON_ITER_HOLDS_UTF8(iter) (bson_iter_type ((iter)) == BSON_TYPE_UTF8) - -#define BSON_ITER_HOLDS_DOCUMENT(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_DOCUMENT) - -#define BSON_ITER_HOLDS_ARRAY(iter) (bson_iter_type ((iter)) == BSON_TYPE_ARRAY) - -#define BSON_ITER_HOLDS_BINARY(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_BINARY) - -#define BSON_ITER_HOLDS_UNDEFINED(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_UNDEFINED) - -#define BSON_ITER_HOLDS_OID(iter) (bson_iter_type ((iter)) == BSON_TYPE_OID) - -#define BSON_ITER_HOLDS_BOOL(iter) (bson_iter_type ((iter)) == BSON_TYPE_BOOL) - -#define BSON_ITER_HOLDS_DATE_TIME(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_DATE_TIME) - -#define BSON_ITER_HOLDS_NULL(iter) (bson_iter_type ((iter)) == BSON_TYPE_NULL) - -#define BSON_ITER_HOLDS_REGEX(iter) (bson_iter_type ((iter)) == BSON_TYPE_REGEX) - -#define BSON_ITER_HOLDS_DBPOINTER(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_DBPOINTER) - -#define BSON_ITER_HOLDS_CODE(iter) (bson_iter_type ((iter)) == BSON_TYPE_CODE) - -#define BSON_ITER_HOLDS_SYMBOL(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_SYMBOL) - -#define BSON_ITER_HOLDS_CODEWSCOPE(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_CODEWSCOPE) - -#define BSON_ITER_HOLDS_INT32(iter) (bson_iter_type ((iter)) == BSON_TYPE_INT32) - -#define BSON_ITER_HOLDS_TIMESTAMP(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_TIMESTAMP) - -#define BSON_ITER_HOLDS_INT64(iter) (bson_iter_type ((iter)) == BSON_TYPE_INT64) - -#define BSON_ITER_HOLDS_DECIMAL128(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_DECIMAL128) - -#define BSON_ITER_HOLDS_MAXKEY(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_MAXKEY) - -#define BSON_ITER_HOLDS_MINKEY(iter) \ - (bson_iter_type ((iter)) == BSON_TYPE_MINKEY) - -#define BSON_ITER_HOLDS_INT(iter) \ - (BSON_ITER_HOLDS_INT32 (iter) || BSON_ITER_HOLDS_INT64 (iter)) - -#define BSON_ITER_HOLDS_NUMBER(iter) \ - (BSON_ITER_HOLDS_INT (iter) || BSON_ITER_HOLDS_DOUBLE (iter)) - -#define BSON_ITER_IS_KEY(iter, key) \ - (0 == strcmp ((key), bson_iter_key ((iter)))) - - -BSON_EXPORT (const bson_value_t *) -bson_iter_value (bson_iter_t *iter); - - -/** - * bson_iter_utf8_len_unsafe: - * @iter: a bson_iter_t. - * - * Returns the length of a string currently pointed to by @iter. This performs - * no validation so the is responsible for knowing the BSON is valid. Calling - * bson_validate() is one way to do this ahead of time. - */ -static BSON_INLINE uint32_t -bson_iter_utf8_len_unsafe (const bson_iter_t *iter) -{ - uint32_t raw; - memcpy (&raw, iter->raw + iter->d1, sizeof (raw)); - - const uint32_t native = BSON_UINT32_FROM_LE (raw); - - int32_t len; - memcpy (&len, &native, sizeof (len)); - - return len <= 0 ? 0u : (uint32_t) (len - 1); -} - - -BSON_EXPORT (void) -bson_iter_array (const bson_iter_t *iter, - uint32_t *array_len, - const uint8_t **array); - - -BSON_EXPORT (void) -bson_iter_binary (const bson_iter_t *iter, - bson_subtype_t *subtype, - uint32_t *binary_len, - const uint8_t **binary); - - -BSON_EXPORT (const char *) -bson_iter_code (const bson_iter_t *iter, uint32_t *length); - - -/** - * bson_iter_code_unsafe: - * @iter: A bson_iter_t. - * @length: A location for the length of the resulting string. - * - * Like bson_iter_code() but performs no integrity checks. - * - * Returns: A string that should not be modified or freed. - */ -static BSON_INLINE const char * -bson_iter_code_unsafe (const bson_iter_t *iter, uint32_t *length) -{ - *length = bson_iter_utf8_len_unsafe (iter); - return (const char *) (iter->raw + iter->d2); -} - - -BSON_EXPORT (const char *) -bson_iter_codewscope (const bson_iter_t *iter, - uint32_t *length, - uint32_t *scope_len, - const uint8_t **scope); - - -BSON_EXPORT (void) -bson_iter_dbpointer (const bson_iter_t *iter, - uint32_t *collection_len, - const char **collection, - const bson_oid_t **oid); - - -BSON_EXPORT (void) -bson_iter_document (const bson_iter_t *iter, - uint32_t *document_len, - const uint8_t **document); - - -BSON_EXPORT (double) -bson_iter_double (const bson_iter_t *iter); - -BSON_EXPORT (double) -bson_iter_as_double (const bson_iter_t *iter); - -/** - * bson_iter_double_unsafe: - * @iter: A bson_iter_t. - * - * Similar to bson_iter_double() but does not perform an integrity checking. - * - * Returns: A double. - */ -static BSON_INLINE double -bson_iter_double_unsafe (const bson_iter_t *iter) -{ - double val; - - memcpy (&val, iter->raw + iter->d1, sizeof (val)); - return BSON_DOUBLE_FROM_LE (val); -} - - -BSON_EXPORT (bool) -bson_iter_init (bson_iter_t *iter, const bson_t *bson); - -BSON_EXPORT (bool) -bson_iter_init_from_data (bson_iter_t *iter, - const uint8_t *data, - size_t length); - - -BSON_EXPORT (bool) -bson_iter_init_find (bson_iter_t *iter, const bson_t *bson, const char *key); - - -BSON_EXPORT (bool) -bson_iter_init_find_w_len (bson_iter_t *iter, - const bson_t *bson, - const char *key, - int keylen); - - -BSON_EXPORT (bool) -bson_iter_init_find_case (bson_iter_t *iter, - const bson_t *bson, - const char *key); - -BSON_EXPORT (bool) -bson_iter_init_from_data_at_offset (bson_iter_t *iter, - const uint8_t *data, - size_t length, - uint32_t offset, - uint32_t keylen); - -BSON_EXPORT (int32_t) -bson_iter_int32 (const bson_iter_t *iter); - - -/** - * bson_iter_int32_unsafe: - * @iter: A bson_iter_t. - * - * Similar to bson_iter_int32() but with no integrity checking. - * - * Returns: A 32-bit signed integer. - */ -static BSON_INLINE int32_t -bson_iter_int32_unsafe (const bson_iter_t *iter) -{ - uint32_t raw; - memcpy (&raw, iter->raw + iter->d1, sizeof (raw)); - - const uint32_t native = BSON_UINT32_FROM_LE (raw); - - int32_t res; - memcpy (&res, &native, sizeof (res)); - return res; -} - - -BSON_EXPORT (int64_t) -bson_iter_int64 (const bson_iter_t *iter); - - -BSON_EXPORT (int64_t) -bson_iter_as_int64 (const bson_iter_t *iter); - - -/** - * bson_iter_int64_unsafe: - * @iter: a bson_iter_t. - * - * Similar to bson_iter_int64() but without integrity checking. - * - * Returns: A 64-bit signed integer. - */ -static BSON_INLINE int64_t -bson_iter_int64_unsafe (const bson_iter_t *iter) -{ - uint64_t raw; - memcpy (&raw, iter->raw + iter->d1, sizeof (raw)); - - const uint64_t native = BSON_UINT64_FROM_LE (raw); - - int64_t res; - memcpy (&res, &native, sizeof (res)); - return res; -} - - -BSON_EXPORT (bool) -bson_iter_find (bson_iter_t *iter, const char *key); - - -BSON_EXPORT (bool) -bson_iter_find_w_len (bson_iter_t *iter, const char *key, int keylen); - - -BSON_EXPORT (bool) -bson_iter_find_case (bson_iter_t *iter, const char *key); - - -BSON_EXPORT (bool) -bson_iter_find_descendant (bson_iter_t *iter, - const char *dotkey, - bson_iter_t *descendant); - - -BSON_EXPORT (bool) -bson_iter_next (bson_iter_t *iter); - - -BSON_EXPORT (const bson_oid_t *) -bson_iter_oid (const bson_iter_t *iter); - - -/** - * bson_iter_oid_unsafe: - * @iter: A #bson_iter_t. - * - * Similar to bson_iter_oid() but performs no integrity checks. - * - * Returns: A #bson_oid_t that should not be modified or freed. - */ -static BSON_INLINE const bson_oid_t * -bson_iter_oid_unsafe (const bson_iter_t *iter) -{ - return (const bson_oid_t *) (iter->raw + iter->d1); -} - - -BSON_EXPORT (bool) -bson_iter_decimal128 (const bson_iter_t *iter, bson_decimal128_t *dec); - - -/** - * bson_iter_decimal128_unsafe: - * @iter: A #bson_iter_t. - * - * Similar to bson_iter_decimal128() but performs no integrity checks. - * - * Returns: A #bson_decimal128_t. - */ -static BSON_INLINE void -bson_iter_decimal128_unsafe (const bson_iter_t *iter, bson_decimal128_t *dec) -{ - uint64_t low_le; - uint64_t high_le; - - memcpy (&low_le, iter->raw + iter->d1, sizeof (low_le)); - memcpy (&high_le, iter->raw + iter->d1 + 8, sizeof (high_le)); - - dec->low = BSON_UINT64_FROM_LE (low_le); - dec->high = BSON_UINT64_FROM_LE (high_le); -} - - -BSON_EXPORT (const char *) -bson_iter_key (const bson_iter_t *iter); - -BSON_EXPORT (uint32_t) -bson_iter_key_len (const bson_iter_t *iter); - - -/** - * bson_iter_key_unsafe: - * @iter: A bson_iter_t. - * - * Similar to bson_iter_key() but performs no integrity checking. - * - * Returns: A string that should not be modified or freed. - */ -static BSON_INLINE const char * -bson_iter_key_unsafe (const bson_iter_t *iter) -{ - return (const char *) (iter->raw + iter->key); -} - - -BSON_EXPORT (const char *) -bson_iter_utf8 (const bson_iter_t *iter, uint32_t *length); - - -/** - * bson_iter_utf8_unsafe: - * - * Similar to bson_iter_utf8() but performs no integrity checking. - * - * Returns: A string that should not be modified or freed. - */ -static BSON_INLINE const char * -bson_iter_utf8_unsafe (const bson_iter_t *iter, size_t *length) -{ - *length = bson_iter_utf8_len_unsafe (iter); - return (const char *) (iter->raw + iter->d2); -} - - -BSON_EXPORT (char *) -bson_iter_dup_utf8 (const bson_iter_t *iter, uint32_t *length); - - -BSON_EXPORT (int64_t) -bson_iter_date_time (const bson_iter_t *iter); - - -BSON_EXPORT (time_t) -bson_iter_time_t (const bson_iter_t *iter); - - -/** - * bson_iter_time_t_unsafe: - * @iter: A bson_iter_t. - * - * Similar to bson_iter_time_t() but performs no integrity checking. - * - * Returns: A time_t containing the number of seconds since UNIX epoch - * in UTC. - */ -static BSON_INLINE time_t -bson_iter_time_t_unsafe (const bson_iter_t *iter) -{ - return (time_t) (bson_iter_int64_unsafe (iter) / 1000); -} - - -BSON_EXPORT (void) -bson_iter_timeval (const bson_iter_t *iter, struct timeval *tv); - - -/** - * bson_iter_timeval_unsafe: - * @iter: A bson_iter_t. - * @tv: A struct timeval. - * - * Similar to bson_iter_timeval() but performs no integrity checking. - */ -static BSON_INLINE void -bson_iter_timeval_unsafe (const bson_iter_t *iter, struct timeval *tv) -{ - int64_t value = bson_iter_int64_unsafe (iter); -#ifdef BSON_OS_WIN32 - tv->tv_sec = (long) (value / 1000); - tv->tv_usec = (long) (value % 1000) * 1000; -#else - tv->tv_sec = (time_t) (value / 1000); - tv->tv_usec = (suseconds_t) (value % 1000) * 1000; -#endif -} - - -BSON_EXPORT (void) -bson_iter_timestamp (const bson_iter_t *iter, - uint32_t *timestamp, - uint32_t *increment); - - -BSON_EXPORT (bool) -bson_iter_bool (const bson_iter_t *iter); - - -/** - * bson_iter_bool_unsafe: - * @iter: A bson_iter_t. - * - * Similar to bson_iter_bool() but performs no integrity checking. - * - * Returns: true or false. - */ -static BSON_INLINE bool -bson_iter_bool_unsafe (const bson_iter_t *iter) -{ - char val; - - memcpy (&val, iter->raw + iter->d1, 1); - return !!val; -} - - -BSON_EXPORT (bool) -bson_iter_as_bool (const bson_iter_t *iter); - - -BSON_EXPORT (const char *) -bson_iter_regex (const bson_iter_t *iter, const char **options); - - -BSON_EXPORT (const char *) -bson_iter_symbol (const bson_iter_t *iter, uint32_t *length); - - -BSON_EXPORT (bson_type_t) -bson_iter_type (const bson_iter_t *iter); - - -/** - * bson_iter_type_unsafe: - * @iter: A bson_iter_t. - * - * Similar to bson_iter_type() but performs no integrity checking. - * - * Returns: A bson_type_t. - */ -static BSON_INLINE bson_type_t -bson_iter_type_unsafe (const bson_iter_t *iter) -{ - return (bson_type_t) (iter->raw + iter->type)[0]; -} - - -BSON_EXPORT (bool) -bson_iter_recurse (const bson_iter_t *iter, bson_iter_t *child); - - -BSON_EXPORT (void) -bson_iter_overwrite_int32 (bson_iter_t *iter, int32_t value); - - -BSON_EXPORT (void) -bson_iter_overwrite_int64 (bson_iter_t *iter, int64_t value); - - -BSON_EXPORT (void) -bson_iter_overwrite_double (bson_iter_t *iter, double value); - - -BSON_EXPORT (void) -bson_iter_overwrite_decimal128 (bson_iter_t *iter, - const bson_decimal128_t *value); - - -BSON_EXPORT (void) -bson_iter_overwrite_bool (bson_iter_t *iter, bool value); - - -BSON_EXPORT (void) -bson_iter_overwrite_oid (bson_iter_t *iter, const bson_oid_t *value); - - -BSON_EXPORT (void) -bson_iter_overwrite_timestamp (bson_iter_t *iter, - uint32_t timestamp, - uint32_t increment); - - -BSON_EXPORT (void) -bson_iter_overwrite_date_time (bson_iter_t *iter, int64_t value); - - -BSON_EXPORT (bool) -bson_iter_visit_all (bson_iter_t *iter, - const bson_visitor_t *visitor, - void *data); - -BSON_EXPORT (uint32_t) -bson_iter_offset (bson_iter_t *iter); - - -BSON_END_DECLS - - -#endif /* BSON_ITER_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-json.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-json.c deleted file mode 100644 index c6624b716..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-json.c +++ /dev/null @@ -1,2563 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include - -#include "bson.h" -#include -#include -#include -#include - -#include "common-b64-private.h" -#include "jsonsl/jsonsl.h" - -#ifdef _WIN32 -#include -#include -#endif - -#ifndef _MSC_VER -#include -#endif - -#ifdef _MSC_VER -#define SSCANF sscanf_s -#else -#define SSCANF sscanf -#endif - -#define STACK_MAX 100 -#define BSON_JSON_DEFAULT_BUF_SIZE (1 << 14) -#define AT_LEAST_0(x) ((x) >= 0 ? (x) : 0) - - -#define READ_STATE_ENUM(ENUM) BSON_JSON_##ENUM, -#define GENERATE_STRING(STRING) #STRING, - -#define FOREACH_READ_STATE(RS) \ - RS (REGULAR) \ - RS (DONE) \ - RS (ERROR) \ - RS (IN_START_MAP) \ - RS (IN_BSON_TYPE) \ - RS (IN_BSON_TYPE_DATE_NUMBERLONG) \ - RS (IN_BSON_TYPE_DATE_ENDMAP) \ - RS (IN_BSON_TYPE_TIMESTAMP_STARTMAP) \ - RS (IN_BSON_TYPE_TIMESTAMP_VALUES) \ - RS (IN_BSON_TYPE_TIMESTAMP_ENDMAP) \ - RS (IN_BSON_TYPE_REGEX_STARTMAP) \ - RS (IN_BSON_TYPE_REGEX_VALUES) \ - RS (IN_BSON_TYPE_REGEX_ENDMAP) \ - RS (IN_BSON_TYPE_BINARY_VALUES) \ - RS (IN_BSON_TYPE_BINARY_ENDMAP) \ - RS (IN_BSON_TYPE_SCOPE_STARTMAP) \ - RS (IN_BSON_TYPE_DBPOINTER_STARTMAP) \ - RS (IN_SCOPE) \ - RS (IN_DBPOINTER) - -typedef enum { FOREACH_READ_STATE (READ_STATE_ENUM) } bson_json_read_state_t; - -static const char *read_state_names[] = {FOREACH_READ_STATE (GENERATE_STRING)}; - -#define BSON_STATE_ENUM(ENUM) BSON_JSON_LF_##ENUM, - -#define FOREACH_BSON_STATE(BS) \ - /* legacy {$regex: "...", $options: "..."} */ \ - BS (REGEX) \ - BS (OPTIONS) \ - /* modern $regularExpression: {pattern: "...", options: "..."} */ \ - BS (REGULAR_EXPRESSION_PATTERN) \ - BS (REGULAR_EXPRESSION_OPTIONS) \ - BS (CODE) \ - BS (SCOPE) \ - BS (OID) \ - BS (BINARY) \ - BS (TYPE) \ - BS (DATE) \ - BS (TIMESTAMP_T) \ - BS (TIMESTAMP_I) \ - BS (UNDEFINED) \ - BS (MINKEY) \ - BS (MAXKEY) \ - BS (INT32) \ - BS (INT64) \ - BS (DOUBLE) \ - BS (DECIMAL128) \ - BS (DBPOINTER) \ - BS (SYMBOL) \ - BS (UUID) - -typedef enum { - FOREACH_BSON_STATE (BSON_STATE_ENUM) -} bson_json_read_bson_state_t; - -static const char *bson_state_names[] = {FOREACH_BSON_STATE (GENERATE_STRING)}; - -typedef struct { - uint8_t *buf; - size_t n_bytes; - size_t len; -} bson_json_buf_t; - - -typedef enum { - BSON_JSON_FRAME_INITIAL = 0, - BSON_JSON_FRAME_ARRAY, - BSON_JSON_FRAME_DOC, - BSON_JSON_FRAME_SCOPE, - BSON_JSON_FRAME_DBPOINTER, -} bson_json_frame_type_t; - - -typedef struct { - int i; - bson_json_frame_type_t type; - bson_t bson; -} bson_json_stack_frame_t; - - -typedef union { - struct { - bool has_pattern; - bool has_options; - bool is_legacy; - } regex; - struct { - bool has_oid; - bson_oid_t oid; - } oid; - struct { - bool has_binary; - bool has_subtype; - bson_subtype_t type; - bool is_legacy; - } binary; - struct { - bool has_date; - int64_t date; - } date; - struct { - bool has_t; - bool has_i; - uint32_t t; - uint32_t i; - } timestamp; - struct { - bool has_undefined; - } undefined; - struct { - bool has_minkey; - } minkey; - struct { - bool has_maxkey; - } maxkey; - struct { - int32_t value; - } v_int32; - struct { - int64_t value; - } v_int64; - struct { - double value; - } v_double; - struct { - bson_decimal128_t value; - } v_decimal128; -} bson_json_bson_data_t; - - -/* collect info while parsing a {$code: "...", $scope: {...}} object */ -typedef struct { - bool has_code; - bool has_scope; - bool in_scope; - bson_json_buf_t key_buf; - bson_json_buf_t code_buf; -} bson_json_code_t; - - -static void -_bson_json_code_cleanup (bson_json_code_t *code_data) -{ - bson_free (code_data->key_buf.buf); - bson_free (code_data->code_buf.buf); -} - - -typedef struct { - bson_t *bson; - bson_json_stack_frame_t stack[STACK_MAX]; - int n; - const char *key; - bson_json_buf_t key_buf; - bson_json_buf_t unescaped; - bson_json_read_state_t read_state; - bson_json_read_bson_state_t bson_state; - bson_type_t bson_type; - bson_json_buf_t bson_type_buf[3]; - bson_json_bson_data_t bson_type_data; - bson_json_code_t code_data; - bson_json_buf_t dbpointer_key; -} bson_json_reader_bson_t; - - -typedef struct { - void *data; - bson_json_reader_cb cb; - bson_json_destroy_cb dcb; - uint8_t *buf; - size_t buf_size; - size_t bytes_read; - size_t bytes_parsed; - bool all_whitespace; -} bson_json_reader_producer_t; - - -struct _bson_json_reader_t { - bson_json_reader_producer_t producer; - bson_json_reader_bson_t bson; - jsonsl_t json; - ssize_t json_text_pos; - bool should_reset; - ssize_t advance; - bson_json_buf_t tok_accumulator; - bson_error_t *error; -}; - - -typedef struct { - int fd; - bool do_close; -} bson_json_reader_handle_fd_t; - - -/* forward decl */ -static void -_bson_json_save_map_key (bson_json_reader_bson_t *bson, - const uint8_t *val, - size_t len); - - -static void -_noop (void) -{ -} - -#define STACK_ELE(_delta, _name) (bson->stack[(_delta) + bson->n]._name) -#define STACK_BSON(_delta) \ - (((_delta) + bson->n) == 0 ? bson->bson : &STACK_ELE (_delta, bson)) -#define STACK_BSON_PARENT STACK_BSON (-1) -#define STACK_BSON_CHILD STACK_BSON (0) -#define STACK_I STACK_ELE (0, i) -#define STACK_FRAME_TYPE STACK_ELE (0, type) -#define STACK_IS_INITIAL (STACK_FRAME_TYPE == BSON_JSON_FRAME_INITIAL) -#define STACK_IS_ARRAY (STACK_FRAME_TYPE == BSON_JSON_FRAME_ARRAY) -#define STACK_IS_DOC (STACK_FRAME_TYPE == BSON_JSON_FRAME_DOC) -#define STACK_IS_SCOPE (STACK_FRAME_TYPE == BSON_JSON_FRAME_SCOPE) -#define STACK_IS_DBPOINTER (STACK_FRAME_TYPE == BSON_JSON_FRAME_DBPOINTER) -#define FRAME_TYPE_HAS_BSON(_type) \ - ((_type) == BSON_JSON_FRAME_SCOPE || (_type) == BSON_JSON_FRAME_DBPOINTER) -#define STACK_HAS_BSON FRAME_TYPE_HAS_BSON (STACK_FRAME_TYPE) -#define STACK_PUSH(frame_type) \ - do { \ - if (bson->n >= (STACK_MAX - 1)) { \ - return; \ - } \ - bson->n++; \ - if (STACK_HAS_BSON) { \ - if (FRAME_TYPE_HAS_BSON (frame_type)) { \ - bson_reinit (STACK_BSON_CHILD); \ - } else { \ - bson_destroy (STACK_BSON_CHILD); \ - } \ - } else if (FRAME_TYPE_HAS_BSON (frame_type)) { \ - bson_init (STACK_BSON_CHILD); \ - } \ - STACK_FRAME_TYPE = frame_type; \ - } while (0) -#define STACK_PUSH_ARRAY(statement) \ - do { \ - STACK_PUSH (BSON_JSON_FRAME_ARRAY); \ - STACK_I = 0; \ - if (bson->n != 0) { \ - statement; \ - } \ - } while (0) -#define STACK_PUSH_DOC(statement) \ - do { \ - STACK_PUSH (BSON_JSON_FRAME_DOC); \ - if (bson->n != 0) { \ - statement; \ - } \ - } while (0) -#define STACK_PUSH_SCOPE \ - do { \ - STACK_PUSH (BSON_JSON_FRAME_SCOPE); \ - bson->code_data.in_scope = true; \ - } while (0) -#define STACK_PUSH_DBPOINTER \ - do { \ - STACK_PUSH (BSON_JSON_FRAME_DBPOINTER); \ - } while (0) -#define STACK_POP_ARRAY(statement) \ - do { \ - if (!STACK_IS_ARRAY) { \ - return; \ - } \ - if (bson->n < 0) { \ - return; \ - } \ - if (bson->n > 0) { \ - statement; \ - } \ - bson->n--; \ - } while (0) -#define STACK_POP_DOC(statement) \ - do { \ - if (STACK_IS_ARRAY) { \ - return; \ - } \ - if (bson->n < 0) { \ - return; \ - } \ - if (bson->n > 0) { \ - statement; \ - } \ - bson->n--; \ - } while (0) -#define STACK_POP_SCOPE \ - do { \ - STACK_POP_DOC (_noop ()); \ - bson->code_data.in_scope = false; \ - } while (0); -#define STACK_POP_DBPOINTER STACK_POP_DOC (_noop ()) -#define BASIC_CB_PREAMBLE \ - const char *key; \ - size_t len; \ - bson_json_reader_bson_t *bson = &reader->bson; \ - _bson_json_read_fixup_key (bson); \ - key = bson->key; \ - len = bson->key_buf.len; -#define BASIC_CB_BAIL_IF_NOT_NORMAL(_type) \ - if (bson->read_state != BSON_JSON_REGULAR) { \ - _bson_json_read_set_error (reader, \ - "Invalid read of %s in state %s", \ - (_type), \ - read_state_names[bson->read_state]); \ - return; \ - } else if (!key) { \ - _bson_json_read_set_error (reader, \ - "Invalid read of %s without key in state %s", \ - (_type), \ - read_state_names[bson->read_state]); \ - return; \ - } -#define HANDLE_OPTION(_selection_statement, _key, _type, _state) \ - _selection_statement (len == strlen (_key) && \ - strncmp ((const char *) val, (_key), len) == 0) \ - { \ - if (bson->bson_type && bson->bson_type != (_type)) { \ - _bson_json_read_set_error (reader, \ - "Invalid key \"%s\". Looking for values " \ - "for type \"%s\", got \"%s\"", \ - (_key), \ - _bson_json_type_name (bson->bson_type), \ - _bson_json_type_name (_type)); \ - return; \ - } \ - bson->bson_type = (_type); \ - bson->bson_state = (_state); \ - } - - -bson_json_opts_t * -bson_json_opts_new (bson_json_mode_t mode, int32_t max_len) -{ - bson_json_opts_t *opts; - - opts = (bson_json_opts_t *) bson_malloc (sizeof *opts); - *opts = (bson_json_opts_t){ - .mode = mode, - .max_len = max_len, - .is_outermost_array = false, - }; - - return opts; -} - -void -bson_json_opts_destroy (bson_json_opts_t *opts) -{ - bson_free (opts); -} - -static void -_bson_json_read_set_error (bson_json_reader_t *reader, const char *fmt, ...) - BSON_GNUC_PRINTF (2, 3); - - -static void -_bson_json_read_set_error (bson_json_reader_t *reader, /* IN */ - const char *fmt, /* IN */ - ...) -{ - va_list ap; - - if (reader->error) { - reader->error->domain = BSON_ERROR_JSON; - reader->error->code = BSON_JSON_ERROR_READ_INVALID_PARAM; - va_start (ap, fmt); - bson_vsnprintf ( - reader->error->message, sizeof reader->error->message, fmt, ap); - va_end (ap); - reader->error->message[sizeof reader->error->message - 1] = '\0'; - } - - reader->bson.read_state = BSON_JSON_ERROR; - jsonsl_stop (reader->json); -} - - -static void -_bson_json_read_corrupt (bson_json_reader_t *reader, const char *fmt, ...) - BSON_GNUC_PRINTF (2, 3); - - -static void -_bson_json_read_corrupt (bson_json_reader_t *reader, /* IN */ - const char *fmt, /* IN */ - ...) -{ - va_list ap; - - if (reader->error) { - reader->error->domain = BSON_ERROR_JSON; - reader->error->code = BSON_JSON_ERROR_READ_CORRUPT_JS; - va_start (ap, fmt); - bson_vsnprintf ( - reader->error->message, sizeof reader->error->message, fmt, ap); - va_end (ap); - reader->error->message[sizeof reader->error->message - 1] = '\0'; - } - - reader->bson.read_state = BSON_JSON_ERROR; - jsonsl_stop (reader->json); -} - - -static void -_bson_json_buf_ensure (bson_json_buf_t *buf, /* IN */ - size_t len) /* IN */ -{ - if (buf->n_bytes < len) { - bson_free (buf->buf); - - buf->n_bytes = bson_next_power_of_two (len); - buf->buf = bson_malloc (buf->n_bytes); - } -} - - -static void -_bson_json_buf_set (bson_json_buf_t *buf, const void *from, size_t len) -{ - _bson_json_buf_ensure (buf, len + 1); - memcpy (buf->buf, from, len); - buf->buf[len] = '\0'; - buf->len = len; -} - - -static void -_bson_json_buf_append (bson_json_buf_t *buf, const void *from, size_t len) -{ - size_t len_with_null = len + 1; - - if (buf->len == 0) { - _bson_json_buf_ensure (buf, len_with_null); - } else if (buf->n_bytes < buf->len + len_with_null) { - buf->n_bytes = bson_next_power_of_two (buf->len + len_with_null); - buf->buf = bson_realloc (buf->buf, buf->n_bytes); - } - - memcpy (buf->buf + buf->len, from, len); - buf->len += len; - buf->buf[buf->len] = '\0'; -} - - -static const char * -_bson_json_type_name (bson_type_t type) -{ - switch (type) { - case BSON_TYPE_EOD: - return "end of document"; - case BSON_TYPE_DOUBLE: - return "double"; - case BSON_TYPE_UTF8: - return "utf-8"; - case BSON_TYPE_DOCUMENT: - return "document"; - case BSON_TYPE_ARRAY: - return "array"; - case BSON_TYPE_BINARY: - return "binary"; - case BSON_TYPE_UNDEFINED: - return "undefined"; - case BSON_TYPE_OID: - return "objectid"; - case BSON_TYPE_BOOL: - return "bool"; - case BSON_TYPE_DATE_TIME: - return "datetime"; - case BSON_TYPE_NULL: - return "null"; - case BSON_TYPE_REGEX: - return "regex"; - case BSON_TYPE_DBPOINTER: - return "dbpointer"; - case BSON_TYPE_CODE: - return "code"; - case BSON_TYPE_SYMBOL: - return "symbol"; - case BSON_TYPE_CODEWSCOPE: - return "code with scope"; - case BSON_TYPE_INT32: - return "int32"; - case BSON_TYPE_TIMESTAMP: - return "timestamp"; - case BSON_TYPE_INT64: - return "int64"; - case BSON_TYPE_DECIMAL128: - return "decimal128"; - case BSON_TYPE_MAXKEY: - return "maxkey"; - case BSON_TYPE_MINKEY: - return "minkey"; - default: - return ""; - } -} - - -static void -_bson_json_read_fixup_key (bson_json_reader_bson_t *bson) /* IN */ -{ - bson_json_read_state_t rs = bson->read_state; - - if (bson->n >= 0 && STACK_IS_ARRAY && rs == BSON_JSON_REGULAR) { - _bson_json_buf_ensure (&bson->key_buf, 12); - bson->key_buf.len = bson_uint32_to_string ( - STACK_I, &bson->key, (char *) bson->key_buf.buf, 12); - STACK_I++; - } -} - - -static void -_bson_json_read_null (bson_json_reader_t *reader) -{ - BASIC_CB_PREAMBLE; - BASIC_CB_BAIL_IF_NOT_NORMAL ("null"); - - bson_append_null (STACK_BSON_CHILD, key, (int) len); -} - - -static void -_bson_json_read_boolean (bson_json_reader_t *reader, /* IN */ - int val) /* IN */ -{ - BASIC_CB_PREAMBLE; - - if (bson->read_state == BSON_JSON_IN_BSON_TYPE && - bson->bson_state == BSON_JSON_LF_UNDEFINED) { - bson->bson_type_data.undefined.has_undefined = true; - return; - } - - BASIC_CB_BAIL_IF_NOT_NORMAL ("boolean"); - - bson_append_bool (STACK_BSON_CHILD, key, (int) len, val); -} - - -/* sign is -1 or 1 */ -static void -_bson_json_read_integer (bson_json_reader_t *reader, uint64_t val, int64_t sign) -{ - bson_json_read_state_t rs; - bson_json_read_bson_state_t bs; - - BASIC_CB_PREAMBLE; - - if (sign == 1 && val > INT64_MAX) { - _bson_json_read_set_error ( - reader, "Number \"%" PRIu64 "\" is out of range", val); - - return; - } else if (sign == -1 && val > ((uint64_t) INT64_MAX + 1)) { - _bson_json_read_set_error ( - reader, "Number \"-%" PRIu64 "\" is out of range", val); - - return; - } - - rs = bson->read_state; - bs = bson->bson_state; - - if (rs == BSON_JSON_REGULAR) { - BASIC_CB_BAIL_IF_NOT_NORMAL ("integer"); - - if (val <= INT32_MAX || (sign == -1 && val <= (uint64_t) INT32_MAX + 1)) { - bson_append_int32 ( - STACK_BSON_CHILD, key, (int) len, (int) (val * sign)); - } else if (sign == -1) { -#if defined(_WIN32) && !defined(__MINGW32__) - // Unary negation of unsigned integer is deliberate. -#pragma warning(suppress : 4146) - bson_append_int64 (STACK_BSON_CHILD, key, (int) len, (int64_t) -val); -#else - bson_append_int64 (STACK_BSON_CHILD, key, (int) len, (int64_t) -val); -#endif // defined(_WIN32) && !defined(__MINGW32__) - } else { - bson_append_int64 (STACK_BSON_CHILD, key, (int) len, (int64_t) val); - } - } else if (rs == BSON_JSON_IN_BSON_TYPE || - rs == BSON_JSON_IN_BSON_TYPE_TIMESTAMP_VALUES) { - switch (bs) { - case BSON_JSON_LF_DATE: - bson->bson_type_data.date.has_date = true; - bson->bson_type_data.date.date = sign * val; - break; - case BSON_JSON_LF_TIMESTAMP_T: - if (sign == -1) { - _bson_json_read_set_error ( - reader, "Invalid timestamp value: \"-%" PRIu64 "\"", val); - return; - } - - bson->bson_type_data.timestamp.has_t = true; - bson->bson_type_data.timestamp.t = (uint32_t) val; - break; - case BSON_JSON_LF_TIMESTAMP_I: - if (sign == -1) { - _bson_json_read_set_error ( - reader, "Invalid timestamp value: \"-%" PRIu64 "\"", val); - return; - } - - bson->bson_type_data.timestamp.has_i = true; - bson->bson_type_data.timestamp.i = (uint32_t) val; - break; - case BSON_JSON_LF_MINKEY: - if (sign == -1) { - _bson_json_read_set_error ( - reader, "Invalid MinKey value: \"-%" PRIu64 "\"", val); - return; - } else if (val != 1) { - _bson_json_read_set_error ( - reader, "Invalid MinKey value: \"%" PRIu64 "\"", val); - } - - bson->bson_type_data.minkey.has_minkey = true; - break; - case BSON_JSON_LF_MAXKEY: - if (sign == -1) { - _bson_json_read_set_error ( - reader, "Invalid MinKey value: \"-%" PRIu64 "\"", val); - return; - } else if (val != 1) { - _bson_json_read_set_error ( - reader, "Invalid MinKey value: \"%" PRIu64 "\"", val); - } - - bson->bson_type_data.maxkey.has_maxkey = true; - break; - case BSON_JSON_LF_INT32: - case BSON_JSON_LF_INT64: - _bson_json_read_set_error ( - reader, - "Invalid state for integer read: %s, " - "expected number as quoted string like \"123\"", - bson_state_names[bs]); - break; - case BSON_JSON_LF_REGEX: - case BSON_JSON_LF_OPTIONS: - case BSON_JSON_LF_REGULAR_EXPRESSION_PATTERN: - case BSON_JSON_LF_REGULAR_EXPRESSION_OPTIONS: - case BSON_JSON_LF_CODE: - case BSON_JSON_LF_SCOPE: - case BSON_JSON_LF_OID: - case BSON_JSON_LF_BINARY: - case BSON_JSON_LF_TYPE: - case BSON_JSON_LF_UUID: - case BSON_JSON_LF_UNDEFINED: - case BSON_JSON_LF_DOUBLE: - case BSON_JSON_LF_DECIMAL128: - case BSON_JSON_LF_DBPOINTER: - case BSON_JSON_LF_SYMBOL: - default: - _bson_json_read_set_error (reader, - "Unexpected integer %s%" PRIu64 - " in type \"%s\"", - sign == -1 ? "-" : "", - val, - _bson_json_type_name (bson->bson_type)); - } - } else { - _bson_json_read_set_error (reader, - "Unexpected integer %s%" PRIu64 - " in state \"%s\"", - sign == -1 ? "-" : "", - val, - read_state_names[rs]); - } -} - - -static bool -_bson_json_parse_double (bson_json_reader_t *reader, - const char *val, - size_t vlen, - double *d) -{ - errno = 0; - *d = strtod (val, NULL); - -#ifdef _MSC_VER - const double pos_inf = INFINITY; - const double neg_inf = -pos_inf; - - /* Microsoft's strtod parses "NaN", "Infinity", "-Infinity" as 0 */ - if (*d == 0.0) { - if (!_strnicmp (val, "nan", vlen)) { - *d = NAN; - return true; - } else if (!_strnicmp (val, "infinity", vlen)) { - *d = pos_inf; - return true; - } else if (!_strnicmp (val, "-infinity", vlen)) { - *d = neg_inf; - return true; - } - } - - if ((*d == HUGE_VAL || *d == -HUGE_VAL) && errno == ERANGE) { - _bson_json_read_set_error ( - reader, "Number \"%.*s\" is out of range", (int) vlen, val); - - return false; - } -#else - /* not MSVC - set err on overflow, but avoid err for infinity */ - if ((*d == HUGE_VAL || *d == -HUGE_VAL) && errno == ERANGE && - strncasecmp (val, "infinity", vlen) && - strncasecmp (val, "-infinity", vlen)) { - _bson_json_read_set_error ( - reader, "Number \"%.*s\" is out of range", (int) vlen, val); - - return false; - } - -#endif /* _MSC_VER */ - return true; -} - - -static void -_bson_json_read_double (bson_json_reader_t *reader, /* IN */ - double val) /* IN */ -{ - BASIC_CB_PREAMBLE; - BASIC_CB_BAIL_IF_NOT_NORMAL ("double"); - - if (!bson_append_double (STACK_BSON_CHILD, key, (int) len, val)) { - _bson_json_read_set_error (reader, "Cannot append double value %g", val); - } -} - - -static bool -_bson_json_read_int64_or_set_error (bson_json_reader_t *reader, /* IN */ - const unsigned char *val, /* IN */ - size_t vlen, /* IN */ - int64_t *v64) /* OUT */ -{ - bson_json_reader_bson_t *bson = &reader->bson; - char *endptr = NULL; - - _bson_json_read_fixup_key (bson); - errno = 0; - *v64 = bson_ascii_strtoll ((const char *) val, &endptr, 10); - - if (((*v64 == INT64_MIN) || (*v64 == INT64_MAX)) && (errno == ERANGE)) { - _bson_json_read_set_error (reader, "Number \"%s\" is out of range", val); - return false; - } - - if (endptr != ((const char *) val + vlen)) { - _bson_json_read_set_error (reader, "Number \"%s\" is invalid", val); - return false; - } - - return true; -} - -static bool -_unhexlify_uuid (const char *uuid, uint8_t *out, size_t max) -{ - unsigned int byte; - size_t x = 0; - int i = 0; - - BSON_ASSERT (strlen (uuid) == 32); - - while (SSCANF (&uuid[i], "%2x", &byte) == 1) { - if (x >= max) { - return false; - } - - out[x++] = (uint8_t) byte; - i += 2; - } - - return i == 32; -} - -/* parse a value for "base64", "subType", legacy "$binary" or "$type", or - * "$uuid" */ -static void -_bson_json_parse_binary_elem (bson_json_reader_t *reader, - const char *val_w_null, - size_t vlen) -{ - bson_json_read_bson_state_t bs; - bson_json_bson_data_t *data; - int binary_len; - - BASIC_CB_PREAMBLE; - - bs = bson->bson_state; - data = &bson->bson_type_data; - - if (bs == BSON_JSON_LF_BINARY) { - data->binary.has_binary = true; - binary_len = mcommon_b64_pton (val_w_null, NULL, 0); - if (binary_len < 0) { - _bson_json_read_set_error ( - reader, - "Invalid input string \"%s\", looking for base64-encoded binary", - val_w_null); - } - - _bson_json_buf_ensure (&bson->bson_type_buf[0], (size_t) binary_len + 1); - if (mcommon_b64_pton (val_w_null, - bson->bson_type_buf[0].buf, - (size_t) binary_len + 1) < 0) { - _bson_json_read_set_error ( - reader, - "Invalid input string \"%s\", looking for base64-encoded binary", - val_w_null); - } - - bson->bson_type_buf[0].len = (size_t) binary_len; - } else if (bs == BSON_JSON_LF_TYPE) { - data->binary.has_subtype = true; - - if (SSCANF (val_w_null, "%02x", &data->binary.type) != 1) { - if (!data->binary.is_legacy || data->binary.has_binary) { - /* misformatted subtype, like {$binary: {base64: "", subType: "x"}}, - * or legacy {$binary: "", $type: "x"} */ - _bson_json_read_set_error ( - reader, - "Invalid input string \"%s\", looking for binary subtype", - val_w_null); - } else { - /* actually a query operator: {x: {$type: "array"}}*/ - bson->read_state = BSON_JSON_REGULAR; - STACK_PUSH_DOC (bson_append_document_begin ( - STACK_BSON_PARENT, key, (int) len, STACK_BSON_CHILD)); - - bson_append_utf8 (STACK_BSON_CHILD, - "$type", - 5, - (const char *) val_w_null, - (int) vlen); - } - } - } else if (bs == BSON_JSON_LF_UUID) { - int nread = 0; - char uuid[33]; - - data->binary.has_binary = true; - data->binary.has_subtype = true; - data->binary.type = BSON_SUBTYPE_UUID; - - /* Validate the UUID and extract relevant portions */ - /* We can't use %x here as it allows +, -, and 0x prefixes */ -#ifdef _MSC_VER - SSCANF (val_w_null, - "%8c-%4c-%4c-%4c-%12c%n", - &uuid[0], - 8, - &uuid[8], - 4, - &uuid[12], - 4, - &uuid[16], - 4, - &uuid[20], - 12, - &nread); -#else - SSCANF (val_w_null, - "%8c-%4c-%4c-%4c-%12c%n", - &uuid[0], - &uuid[8], - &uuid[12], - &uuid[16], - &uuid[20], - &nread); -#endif - - uuid[32] = '\0'; - - if (nread != 36 || val_w_null[nread] != '\0') { - _bson_json_read_set_error (reader, - "Invalid input string \"%s\", looking for " - "a dash-separated UUID string", - val_w_null); - - return; - } - - binary_len = 16; - _bson_json_buf_ensure (&bson->bson_type_buf[0], (size_t) binary_len + 1); - - if (!_unhexlify_uuid ( - &uuid[0], bson->bson_type_buf[0].buf, (size_t) binary_len)) { - _bson_json_read_set_error (reader, - "Invalid input string \"%s\", looking for " - "a dash-separated UUID string", - val_w_null); - } - - bson->bson_type_buf[0].len = (size_t) binary_len; - } -} - -static bool -_bson_json_allow_embedded_nulls (bson_json_reader_t const *reader) -{ - const bson_json_read_state_t read_state = reader->bson.read_state; - const bson_json_read_bson_state_t bson_state = reader->bson.bson_state; - - if (read_state == BSON_JSON_IN_BSON_TYPE_REGEX_VALUES) { - if (bson_state == BSON_JSON_LF_REGULAR_EXPRESSION_PATTERN || - bson_state == BSON_JSON_LF_REGULAR_EXPRESSION_OPTIONS) { - /* Prohibit embedded NULL bytes for canonical extended regex: - * { $regularExpression: { pattern: "pattern", options: "options" } } - */ - return false; - } - } - - if (read_state == BSON_JSON_IN_BSON_TYPE) { - if (bson_state == BSON_JSON_LF_REGEX || - bson_state == BSON_JSON_LF_OPTIONS) { - /* Prohibit embedded NULL bytes for legacy regex: - * { $regex: "pattern", $options: "options" } */ - return false; - } - } - - /* Embedded nulls are okay in any other context */ - return true; -} - -static void -_bson_json_read_string (bson_json_reader_t *reader, /* IN */ - const unsigned char *val, /* IN */ - size_t vlen) /* IN */ -{ - bson_json_read_state_t rs; - bson_json_read_bson_state_t bs; - const bool allow_null = _bson_json_allow_embedded_nulls (reader); - - BASIC_CB_PREAMBLE; - - rs = bson->read_state; - bs = bson->bson_state; - - if (!bson_utf8_validate ((const char *) val, vlen, allow_null)) { - _bson_json_read_corrupt (reader, "invalid bytes in UTF8 string"); - return; - } - - if (rs == BSON_JSON_REGULAR) { - BASIC_CB_BAIL_IF_NOT_NORMAL ("string"); - bson_append_utf8 ( - STACK_BSON_CHILD, key, (int) len, (const char *) val, (int) vlen); - } else if (rs == BSON_JSON_IN_BSON_TYPE_SCOPE_STARTMAP || - rs == BSON_JSON_IN_BSON_TYPE_DBPOINTER_STARTMAP) { - _bson_json_read_set_error (reader, - "Invalid read of \"%s\" in state \"%s\"", - val, - read_state_names[rs]); - } else if (rs == BSON_JSON_IN_BSON_TYPE_BINARY_VALUES) { - const char *val_w_null; - _bson_json_buf_set (&bson->bson_type_buf[2], val, vlen); - val_w_null = (const char *) bson->bson_type_buf[2].buf; - - _bson_json_parse_binary_elem (reader, val_w_null, vlen); - } else if (rs == BSON_JSON_IN_BSON_TYPE || - rs == BSON_JSON_IN_BSON_TYPE_TIMESTAMP_VALUES || - rs == BSON_JSON_IN_BSON_TYPE_REGEX_VALUES || - rs == BSON_JSON_IN_BSON_TYPE_DATE_NUMBERLONG) { - const char *val_w_null; - _bson_json_buf_set (&bson->bson_type_buf[2], val, vlen); - val_w_null = (const char *) bson->bson_type_buf[2].buf; - - switch (bs) { - case BSON_JSON_LF_REGEX: - bson->bson_type_data.regex.is_legacy = true; - /* FALL THROUGH */ - case BSON_JSON_LF_REGULAR_EXPRESSION_PATTERN: - bson->bson_type_data.regex.has_pattern = true; - _bson_json_buf_set (&bson->bson_type_buf[0], val, vlen); - break; - case BSON_JSON_LF_OPTIONS: - bson->bson_type_data.regex.is_legacy = true; - /* FALL THROUGH */ - case BSON_JSON_LF_REGULAR_EXPRESSION_OPTIONS: - bson->bson_type_data.regex.has_options = true; - _bson_json_buf_set (&bson->bson_type_buf[1], val, vlen); - break; - case BSON_JSON_LF_OID: - - if (vlen != 24) { - goto BAD_PARSE; - } - - bson->bson_type_data.oid.has_oid = true; - bson_oid_init_from_string (&bson->bson_type_data.oid.oid, val_w_null); - break; - case BSON_JSON_LF_BINARY: - case BSON_JSON_LF_TYPE: - bson->bson_type_data.binary.is_legacy = true; - /* FALL THROUGH */ - case BSON_JSON_LF_UUID: - _bson_json_parse_binary_elem (reader, val_w_null, vlen); - break; - case BSON_JSON_LF_INT32: { - int64_t v64; - if (!_bson_json_read_int64_or_set_error (reader, val, vlen, &v64)) { - /* the error is set, return and let the reader exit */ - return; - } - - if (v64 < INT32_MIN || v64 > INT32_MAX) { - goto BAD_PARSE; - } - - if (bson->read_state == BSON_JSON_IN_BSON_TYPE) { - bson->bson_type_data.v_int32.value = (int32_t) v64; - } else { - goto BAD_PARSE; - } - } break; - case BSON_JSON_LF_INT64: { - int64_t v64; - if (!_bson_json_read_int64_or_set_error (reader, val, vlen, &v64)) { - /* the error is set, return and let the reader exit */ - return; - } - - if (bson->read_state == BSON_JSON_IN_BSON_TYPE) { - bson->bson_type_data.v_int64.value = v64; - } else if (bson->read_state == - BSON_JSON_IN_BSON_TYPE_DATE_NUMBERLONG) { - bson->bson_type_data.date.has_date = true; - bson->bson_type_data.date.date = v64; - } else { - goto BAD_PARSE; - } - } break; - case BSON_JSON_LF_DOUBLE: { - if (!_bson_json_parse_double (reader, - (const char *) val, - vlen, - &bson->bson_type_data.v_double.value)) { - /* the error is set, return and let the reader exit */ - return; - } - } break; - case BSON_JSON_LF_DATE: { - int64_t v64; - - if (!_bson_iso8601_date_parse ( - (char *) val, (int) vlen, &v64, reader->error)) { - jsonsl_stop (reader->json); - } else { - bson->bson_type_data.date.has_date = true; - bson->bson_type_data.date.date = v64; - } - } break; - case BSON_JSON_LF_DECIMAL128: { - bson_decimal128_t decimal128; - - if (bson_decimal128_from_string (val_w_null, &decimal128) && - bson->read_state == BSON_JSON_IN_BSON_TYPE) { - bson->bson_type_data.v_decimal128.value = decimal128; - } else { - goto BAD_PARSE; - } - } break; - case BSON_JSON_LF_CODE: - _bson_json_buf_set (&bson->code_data.code_buf, val, vlen); - break; - case BSON_JSON_LF_SYMBOL: - bson_append_symbol ( - STACK_BSON_CHILD, key, (int) len, (const char *) val, (int) vlen); - break; - case BSON_JSON_LF_SCOPE: - case BSON_JSON_LF_TIMESTAMP_T: - case BSON_JSON_LF_TIMESTAMP_I: - case BSON_JSON_LF_UNDEFINED: - case BSON_JSON_LF_MINKEY: - case BSON_JSON_LF_MAXKEY: - case BSON_JSON_LF_DBPOINTER: - default: - goto BAD_PARSE; - } - - return; - BAD_PARSE: - _bson_json_read_set_error (reader, - "Invalid input string \"%s\", looking for %s", - val_w_null, - bson_state_names[bs]); - } else { - _bson_json_read_set_error ( - reader, "Invalid state to look for string: %s", read_state_names[rs]); - } -} - - -static void -_bson_json_read_start_map (bson_json_reader_t *reader) /* IN */ -{ - BASIC_CB_PREAMBLE; - - if (bson->read_state == BSON_JSON_IN_BSON_TYPE) { - switch (bson->bson_state) { - case BSON_JSON_LF_DATE: - bson->read_state = BSON_JSON_IN_BSON_TYPE_DATE_NUMBERLONG; - break; - case BSON_JSON_LF_BINARY: - bson->read_state = BSON_JSON_IN_BSON_TYPE_BINARY_VALUES; - break; - case BSON_JSON_LF_TYPE: - /* special case, we started parsing {$type: {$numberInt: "2"}} and we - * expected a legacy Binary format. now we see the second "{", so - * backtrack and parse $type query operator. */ - bson->read_state = BSON_JSON_IN_START_MAP; - BSON_ASSERT (bson_in_range_unsigned (int, len)); - STACK_PUSH_DOC (bson_append_document_begin ( - STACK_BSON_PARENT, key, (int) len, STACK_BSON_CHILD)); - _bson_json_save_map_key (bson, (const uint8_t *) "$type", 5); - break; - case BSON_JSON_LF_CODE: - case BSON_JSON_LF_DECIMAL128: - case BSON_JSON_LF_DOUBLE: - case BSON_JSON_LF_INT32: - case BSON_JSON_LF_INT64: - case BSON_JSON_LF_MAXKEY: - case BSON_JSON_LF_MINKEY: - case BSON_JSON_LF_OID: - case BSON_JSON_LF_OPTIONS: - case BSON_JSON_LF_REGEX: - /** - * NOTE: A read_state of BSON_JSON_IN_BSON_TYPE is used when "$regex" is - * found, but BSON_JSON_IN_BSON_TYPE_REGEX_STARTMAP is used for - * "$regularExpression", which will instead go to a below 'if else' branch - * instead of this switch statement. They're both called "regex" in their - * respective enumerators, but they behave differently when parsing. - */ - // fallthrough - case BSON_JSON_LF_REGULAR_EXPRESSION_OPTIONS: - case BSON_JSON_LF_REGULAR_EXPRESSION_PATTERN: - case BSON_JSON_LF_SYMBOL: - case BSON_JSON_LF_UNDEFINED: - case BSON_JSON_LF_UUID: - // These special keys do not expect objects as their values. Fail. - _bson_json_read_set_error ( - reader, - "Unexpected nested object value for \"%s\" key", - reader->bson.unescaped.buf); - break; - case BSON_JSON_LF_DBPOINTER: - case BSON_JSON_LF_SCOPE: - case BSON_JSON_LF_TIMESTAMP_I: - case BSON_JSON_LF_TIMESTAMP_T: - default: - // These special LF keys aren't handled with BSON_JSON_IN_BSON_TYPE - BSON_UNREACHABLE ( - "These LF values are handled with a different read_state"); - } - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_TIMESTAMP_STARTMAP) { - bson->read_state = BSON_JSON_IN_BSON_TYPE_TIMESTAMP_VALUES; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_SCOPE_STARTMAP) { - bson->read_state = BSON_JSON_IN_SCOPE; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_DBPOINTER_STARTMAP) { - bson->read_state = BSON_JSON_IN_DBPOINTER; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_REGEX_STARTMAP) { - bson->read_state = BSON_JSON_IN_BSON_TYPE_REGEX_VALUES; - } else { - bson->read_state = BSON_JSON_IN_START_MAP; - } - - /* silence some warnings */ - (void) len; - (void) key; -} - - -static bool -_is_known_key (const char *key, size_t len) -{ - bool ret; - -#define IS_KEY(k) (len == strlen (k) && (0 == memcmp (k, key, len))) - - ret = (IS_KEY ("$regularExpression") || IS_KEY ("$regex") || - IS_KEY ("$options") || IS_KEY ("$code") || IS_KEY ("$scope") || - IS_KEY ("$oid") || IS_KEY ("$binary") || IS_KEY ("$type") || - IS_KEY ("$date") || IS_KEY ("$undefined") || IS_KEY ("$maxKey") || - IS_KEY ("$minKey") || IS_KEY ("$timestamp") || - IS_KEY ("$numberInt") || IS_KEY ("$numberLong") || - IS_KEY ("$numberDouble") || IS_KEY ("$numberDecimal") || - IS_KEY ("$numberInt") || IS_KEY ("$numberLong") || - IS_KEY ("$numberDouble") || IS_KEY ("$numberDecimal") || - IS_KEY ("$dbPointer") || IS_KEY ("$symbol") || IS_KEY ("$uuid")); - -#undef IS_KEY - - return ret; -} - -static void -_bson_json_save_map_key (bson_json_reader_bson_t *bson, - const uint8_t *val, - size_t len) -{ - _bson_json_buf_set (&bson->key_buf, val, len); - bson->key = (const char *) bson->key_buf.buf; -} - - -static void -_bson_json_read_code_or_scope_key (bson_json_reader_bson_t *bson, - bool is_scope, - const uint8_t *val, - size_t len) -{ - bson_json_code_t *code = &bson->code_data; - - if (code->in_scope) { - /* we're reading something weirdly nested, e.g. we just read "$code" in - * "$scope: {x: {$code: {}}}". just create the subdoc within the scope. */ - bson->read_state = BSON_JSON_REGULAR; - STACK_PUSH_DOC (bson_append_document_begin (STACK_BSON_PARENT, - bson->key, - (int) bson->key_buf.len, - STACK_BSON_CHILD)); - _bson_json_save_map_key (bson, val, len); - } else { - if (!bson->code_data.key_buf.len) { - /* save the key, e.g. {"key": {"$code": "return x", "$scope":{"x":1}}}, - * in case it is overwritten while parsing scope sub-object */ - _bson_json_buf_set ( - &bson->code_data.key_buf, bson->key, bson->key_buf.len); - } - - if (is_scope) { - bson->bson_type = BSON_TYPE_CODEWSCOPE; - bson->read_state = BSON_JSON_IN_BSON_TYPE_SCOPE_STARTMAP; - bson->bson_state = BSON_JSON_LF_SCOPE; - bson->code_data.has_scope = true; - } else { - bson->bson_type = BSON_TYPE_CODE; - bson->bson_state = BSON_JSON_LF_CODE; - bson->code_data.has_code = true; - } - } -} - - -static void -_bson_json_bad_key_in_type (bson_json_reader_t *reader, /* IN */ - const uint8_t *val) /* IN */ -{ - bson_json_reader_bson_t *bson = &reader->bson; - - _bson_json_read_set_error ( - reader, - "Invalid key \"%s\". Looking for values for type \"%s\"", - val, - _bson_json_type_name (bson->bson_type)); -} - - -static void -_bson_json_read_map_key (bson_json_reader_t *reader, /* IN */ - const uint8_t *val, /* IN */ - size_t len) /* IN */ -{ - bson_json_reader_bson_t *bson = &reader->bson; - - if (!bson_utf8_validate ((const char *) val, len, false /* allow null */)) { - _bson_json_read_corrupt (reader, "invalid bytes in UTF8 string"); - return; - } - - if (bson->read_state == BSON_JSON_IN_START_MAP) { - if (len > 0 && val[0] == '$' && _is_known_key ((const char *) val, len) && - bson->n >= 0 /* key is in subdocument */) { - bson->read_state = BSON_JSON_IN_BSON_TYPE; - bson->bson_type = (bson_type_t) 0; - memset (&bson->bson_type_data, 0, sizeof bson->bson_type_data); - } else { - bson->read_state = BSON_JSON_REGULAR; - STACK_PUSH_DOC (bson_append_document_begin (STACK_BSON_PARENT, - bson->key, - (int) bson->key_buf.len, - STACK_BSON_CHILD)); - } - } else if (bson->read_state == BSON_JSON_IN_SCOPE) { - /* we've read "key" in {$code: "", $scope: {key: ""}}*/ - bson->read_state = BSON_JSON_REGULAR; - STACK_PUSH_SCOPE; - _bson_json_save_map_key (bson, val, len); - } else if (bson->read_state == BSON_JSON_IN_DBPOINTER) { - /* we've read "$ref" or "$id" in {$dbPointer: {$ref: ..., $id: ...}} */ - bson->read_state = BSON_JSON_REGULAR; - STACK_PUSH_DBPOINTER; - _bson_json_save_map_key (bson, val, len); - } - - if (bson->read_state == BSON_JSON_IN_BSON_TYPE) { - HANDLE_OPTION (if, "$regex", BSON_TYPE_REGEX, BSON_JSON_LF_REGEX) - HANDLE_OPTION (else if, "$options", BSON_TYPE_REGEX, BSON_JSON_LF_OPTIONS) - HANDLE_OPTION (else if, "$oid", BSON_TYPE_OID, BSON_JSON_LF_OID) - HANDLE_OPTION (else if, "$binary", BSON_TYPE_BINARY, BSON_JSON_LF_BINARY) - HANDLE_OPTION (else if, "$type", BSON_TYPE_BINARY, BSON_JSON_LF_TYPE) - HANDLE_OPTION (else if, "$uuid", BSON_TYPE_BINARY, BSON_JSON_LF_UUID) - HANDLE_OPTION (else if, "$date", BSON_TYPE_DATE_TIME, BSON_JSON_LF_DATE) - HANDLE_OPTION ( - else if, "$undefined", BSON_TYPE_UNDEFINED, BSON_JSON_LF_UNDEFINED) - HANDLE_OPTION (else if, "$minKey", BSON_TYPE_MINKEY, BSON_JSON_LF_MINKEY) - HANDLE_OPTION (else if, "$maxKey", BSON_TYPE_MAXKEY, BSON_JSON_LF_MAXKEY) - HANDLE_OPTION (else if, "$numberInt", BSON_TYPE_INT32, BSON_JSON_LF_INT32) - HANDLE_OPTION ( - else if, "$numberLong", BSON_TYPE_INT64, BSON_JSON_LF_INT64) - HANDLE_OPTION ( - else if, "$numberDouble", BSON_TYPE_DOUBLE, BSON_JSON_LF_DOUBLE) - HANDLE_OPTION (else if, "$symbol", BSON_TYPE_SYMBOL, BSON_JSON_LF_SYMBOL) - HANDLE_OPTION (else if, - "$numberDecimal", - BSON_TYPE_DECIMAL128, - BSON_JSON_LF_DECIMAL128) - else if (!strcmp ("$timestamp", (const char *) val)) - { - bson->bson_type = BSON_TYPE_TIMESTAMP; - bson->read_state = BSON_JSON_IN_BSON_TYPE_TIMESTAMP_STARTMAP; - } - else if (!strcmp ("$regularExpression", (const char *) val)) - { - bson->bson_type = BSON_TYPE_REGEX; - bson->read_state = BSON_JSON_IN_BSON_TYPE_REGEX_STARTMAP; - } - else if (!strcmp ("$dbPointer", (const char *) val)) - { - /* start parsing "key": {"$dbPointer": {...}}, save "key" for later */ - _bson_json_buf_set ( - &bson->dbpointer_key, bson->key, bson->key_buf.len); - - bson->bson_type = BSON_TYPE_DBPOINTER; - bson->read_state = BSON_JSON_IN_BSON_TYPE_DBPOINTER_STARTMAP; - } - else if (!strcmp ("$code", (const char *) val)) - { - _bson_json_read_code_or_scope_key ( - bson, false /* is_scope */, val, len); - } - else if (!strcmp ("$scope", (const char *) val)) - { - _bson_json_read_code_or_scope_key ( - bson, true /* is_scope */, val, len); - } - else - { - _bson_json_bad_key_in_type (reader, val); - } - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_DATE_NUMBERLONG) { - HANDLE_OPTION (if, "$numberLong", BSON_TYPE_DATE_TIME, BSON_JSON_LF_INT64) - else - { - _bson_json_bad_key_in_type (reader, val); - } - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_TIMESTAMP_VALUES) { - HANDLE_OPTION (if, "t", BSON_TYPE_TIMESTAMP, BSON_JSON_LF_TIMESTAMP_T) - HANDLE_OPTION ( - else if, "i", BSON_TYPE_TIMESTAMP, BSON_JSON_LF_TIMESTAMP_I) - else - { - _bson_json_bad_key_in_type (reader, val); - } - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_REGEX_VALUES) { - HANDLE_OPTION (if, - "pattern", - BSON_TYPE_REGEX, - BSON_JSON_LF_REGULAR_EXPRESSION_PATTERN) - HANDLE_OPTION (else if, - "options", - BSON_TYPE_REGEX, - BSON_JSON_LF_REGULAR_EXPRESSION_OPTIONS) - else - { - _bson_json_bad_key_in_type (reader, val); - } - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_BINARY_VALUES) { - HANDLE_OPTION (if, "base64", BSON_TYPE_BINARY, BSON_JSON_LF_BINARY) - HANDLE_OPTION (else if, "subType", BSON_TYPE_BINARY, BSON_JSON_LF_TYPE) - else - { - _bson_json_bad_key_in_type (reader, val); - } - } else { - _bson_json_save_map_key (bson, val, len); - } -} - - -static void -_bson_json_read_append_binary (bson_json_reader_t *reader, /* IN */ - bson_json_reader_bson_t *bson) /* IN */ -{ - bson_json_bson_data_t *data = &bson->bson_type_data; - - if (data->binary.is_legacy) { - if (!data->binary.has_binary) { - _bson_json_read_set_error ( - reader, - "Missing \"$binary\" after \"$type\" reading type \"binary\""); - return; - } else if (!data->binary.has_subtype) { - _bson_json_read_set_error ( - reader, - "Missing \"$type\" after \"$binary\" reading type \"binary\""); - return; - } - } else { - if (!data->binary.has_binary) { - _bson_json_read_set_error ( - reader, - "Missing \"base64\" after \"subType\" reading type \"binary\""); - return; - } else if (!data->binary.has_subtype) { - _bson_json_read_set_error ( - reader, - "Missing \"subType\" after \"base64\" reading type \"binary\""); - return; - } - } - - if (!bson_append_binary (STACK_BSON_CHILD, - bson->key, - (int) bson->key_buf.len, - data->binary.type, - bson->bson_type_buf[0].buf, - (uint32_t) bson->bson_type_buf[0].len)) { - _bson_json_read_set_error (reader, "Error storing binary data"); - } -} - - -static void -_bson_json_read_append_regex (bson_json_reader_t *reader, /* IN */ - bson_json_reader_bson_t *bson) /* IN */ -{ - bson_json_bson_data_t *data = &bson->bson_type_data; - if (data->regex.is_legacy) { - if (!data->regex.has_pattern) { - _bson_json_read_set_error (reader, - "Missing \"$regex\" after \"$options\""); - return; - } - } else if (!data->regex.has_pattern) { - _bson_json_read_set_error ( - reader, "Missing \"pattern\" after \"options\" in regular expression"); - return; - } else if (!data->regex.has_options) { - _bson_json_read_set_error ( - reader, "Missing \"options\" after \"pattern\" in regular expression"); - return; - } - - if (!bson_append_regex (STACK_BSON_CHILD, - bson->key, - (int) bson->key_buf.len, - (char *) bson->bson_type_buf[0].buf, - (char *) bson->bson_type_buf[1].buf)) { - _bson_json_read_set_error (reader, "Error storing regex"); - } -} - - -static void -_bson_json_read_append_code (bson_json_reader_t *reader, /* IN */ - bson_json_reader_bson_t *bson) /* IN */ -{ - bson_json_code_t *code_data; - char *code = NULL; - bson_t *scope = NULL; - bool r; - - code_data = &bson->code_data; - - BSON_ASSERT (!code_data->in_scope); - - if (!code_data->has_code) { - _bson_json_read_set_error (reader, "Missing $code after $scope"); - return; - } - - code = (char *) code_data->code_buf.buf; - - if (code_data->has_scope) { - scope = STACK_BSON (1); - } - - /* creates BSON "code" elem, or "code with scope" if scope is not NULL */ - r = bson_append_code_with_scope (STACK_BSON_CHILD, - (const char *) code_data->key_buf.buf, - (int) code_data->key_buf.len, - code, - scope); - - if (!r) { - _bson_json_read_set_error (reader, "Error storing Javascript code"); - } - - /* keep the buffer but truncate it */ - code_data->key_buf.len = 0; - code_data->has_code = code_data->has_scope = false; -} - - -static void -_bson_json_read_append_dbpointer (bson_json_reader_t *reader, /* IN */ - bson_json_reader_bson_t *bson) /* IN */ -{ - bson_t *db_pointer; - bson_iter_t iter; - const char *ns = NULL; - const bson_oid_t *oid = NULL; - bool r; - - BSON_ASSERT (reader->bson.dbpointer_key.buf); - - db_pointer = STACK_BSON (1); - if (!bson_iter_init (&iter, db_pointer)) { - _bson_json_read_set_error (reader, "Error storing DBPointer"); - return; - } - - while (bson_iter_next (&iter)) { - if (!strcmp (bson_iter_key (&iter), "$id")) { - if (!BSON_ITER_HOLDS_OID (&iter)) { - _bson_json_read_set_error ( - reader, "$dbPointer.$id must be like {\"$oid\": ...\"}"); - return; - } - - oid = bson_iter_oid (&iter); - } else if (!strcmp (bson_iter_key (&iter), "$ref")) { - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - _bson_json_read_set_error ( - reader, - "$dbPointer.$ref must be a string like \"db.collection\""); - return; - } - - ns = bson_iter_utf8 (&iter, NULL); - } else { - _bson_json_read_set_error (reader, - "$dbPointer contains invalid key: \"%s\"", - bson_iter_key (&iter)); - return; - } - } - - if (!oid || !ns) { - _bson_json_read_set_error (reader, - "$dbPointer requires both $id and $ref"); - return; - } - - r = bson_append_dbpointer (STACK_BSON_CHILD, - (char *) reader->bson.dbpointer_key.buf, - (int) reader->bson.dbpointer_key.len, - ns, - oid); - - if (!r) { - _bson_json_read_set_error (reader, "Error storing DBPointer"); - } -} - - -static void -_bson_json_read_append_oid (bson_json_reader_t *reader, /* IN */ - bson_json_reader_bson_t *bson) /* IN */ -{ - if (!bson_append_oid (STACK_BSON_CHILD, - bson->key, - (int) bson->key_buf.len, - &bson->bson_type_data.oid.oid)) { - _bson_json_read_set_error (reader, "Error storing ObjectId"); - } -} - - -static void -_bson_json_read_append_date_time (bson_json_reader_t *reader, /* IN */ - bson_json_reader_bson_t *bson) /* IN */ -{ - if (!bson_append_date_time (STACK_BSON_CHILD, - bson->key, - (int) bson->key_buf.len, - bson->bson_type_data.date.date)) { - _bson_json_read_set_error (reader, "Error storing datetime"); - } -} - - -static void -_bson_json_read_append_timestamp (bson_json_reader_t *reader, /* IN */ - bson_json_reader_bson_t *bson) /* IN */ -{ - if (!bson->bson_type_data.timestamp.has_t) { - _bson_json_read_set_error ( - reader, "Missing t after $timestamp in BSON_TYPE_TIMESTAMP"); - return; - } else if (!bson->bson_type_data.timestamp.has_i) { - _bson_json_read_set_error ( - reader, "Missing i after $timestamp in BSON_TYPE_TIMESTAMP"); - return; - } - - bson_append_timestamp (STACK_BSON_CHILD, - bson->key, - (int) bson->key_buf.len, - bson->bson_type_data.timestamp.t, - bson->bson_type_data.timestamp.i); -} - - -static void -_bad_extended_json (bson_json_reader_t *reader) -{ - _bson_json_read_corrupt (reader, "Invalid MongoDB extended JSON"); -} - - -static void -_bson_json_read_end_map (bson_json_reader_t *reader) /* IN */ -{ - bson_json_reader_bson_t *bson = &reader->bson; - bool r = true; - - if (bson->read_state == BSON_JSON_IN_START_MAP) { - bson->read_state = BSON_JSON_REGULAR; - STACK_PUSH_DOC (bson_append_document_begin (STACK_BSON_PARENT, - bson->key, - (int) bson->key_buf.len, - STACK_BSON_CHILD)); - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_SCOPE_STARTMAP) { - bson->read_state = BSON_JSON_REGULAR; - STACK_PUSH_SCOPE; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_DBPOINTER_STARTMAP) { - /* we've read last "}" in "{$dbPointer: {$id: ..., $ref: ...}}" */ - _bson_json_read_append_dbpointer (reader, bson); - bson->read_state = BSON_JSON_REGULAR; - return; - } - - if (bson->read_state == BSON_JSON_IN_BSON_TYPE) { - if (!bson->key) { - /* invalid, like {$numberLong: "1"} at the document top level */ - _bad_extended_json (reader); - return; - } - - bson->read_state = BSON_JSON_REGULAR; - switch (bson->bson_type) { - case BSON_TYPE_REGEX: - _bson_json_read_append_regex (reader, bson); - break; - case BSON_TYPE_CODE: - case BSON_TYPE_CODEWSCOPE: - /* we've read the closing "}" in "{$code: ..., $scope: ...}" */ - _bson_json_read_append_code (reader, bson); - break; - case BSON_TYPE_OID: - _bson_json_read_append_oid (reader, bson); - break; - case BSON_TYPE_BINARY: - _bson_json_read_append_binary (reader, bson); - break; - case BSON_TYPE_DATE_TIME: - _bson_json_read_append_date_time (reader, bson); - break; - case BSON_TYPE_UNDEFINED: - r = bson_append_undefined ( - STACK_BSON_CHILD, bson->key, (int) bson->key_buf.len); - break; - case BSON_TYPE_MINKEY: - r = bson_append_minkey ( - STACK_BSON_CHILD, bson->key, (int) bson->key_buf.len); - break; - case BSON_TYPE_MAXKEY: - r = bson_append_maxkey ( - STACK_BSON_CHILD, bson->key, (int) bson->key_buf.len); - break; - case BSON_TYPE_INT32: - r = bson_append_int32 (STACK_BSON_CHILD, - bson->key, - (int) bson->key_buf.len, - bson->bson_type_data.v_int32.value); - break; - case BSON_TYPE_INT64: - r = bson_append_int64 (STACK_BSON_CHILD, - bson->key, - (int) bson->key_buf.len, - bson->bson_type_data.v_int64.value); - break; - case BSON_TYPE_DOUBLE: - r = bson_append_double (STACK_BSON_CHILD, - bson->key, - (int) bson->key_buf.len, - bson->bson_type_data.v_double.value); - break; - case BSON_TYPE_DECIMAL128: - r = bson_append_decimal128 (STACK_BSON_CHILD, - bson->key, - (int) bson->key_buf.len, - &bson->bson_type_data.v_decimal128.value); - break; - case BSON_TYPE_DBPOINTER: - /* shouldn't set type to DBPointer unless inside $dbPointer: {...} */ - _bson_json_read_set_error ( - reader, - "Internal error: shouldn't be in state BSON_TYPE_DBPOINTER"); - break; - case BSON_TYPE_SYMBOL: - break; - case BSON_TYPE_EOD: - case BSON_TYPE_UTF8: - case BSON_TYPE_DOCUMENT: - case BSON_TYPE_ARRAY: - case BSON_TYPE_BOOL: - case BSON_TYPE_NULL: - case BSON_TYPE_TIMESTAMP: - default: - _bson_json_read_set_error ( - reader, - "Internal error: can't parse JSON wrapper for type \"%s\"", - _bson_json_type_name (bson->bson_type)); - break; - } - - if (!r) { - _bson_json_read_set_error ( - reader, - "Cannot append value at end of JSON object for key %s", - bson->key); - } - - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_TIMESTAMP_VALUES) { - if (!bson->key) { - _bad_extended_json (reader); - return; - } - - bson->read_state = BSON_JSON_IN_BSON_TYPE_TIMESTAMP_ENDMAP; - _bson_json_read_append_timestamp (reader, bson); - return; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_REGEX_VALUES) { - if (!bson->key) { - _bad_extended_json (reader); - return; - } - - bson->read_state = BSON_JSON_IN_BSON_TYPE_REGEX_ENDMAP; - _bson_json_read_append_regex (reader, bson); - return; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_BINARY_VALUES) { - if (!bson->key) { - _bad_extended_json (reader); - return; - } - - bson->read_state = BSON_JSON_IN_BSON_TYPE_BINARY_ENDMAP; - _bson_json_read_append_binary (reader, bson); - return; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_TIMESTAMP_ENDMAP) { - bson->read_state = BSON_JSON_REGULAR; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_REGEX_ENDMAP) { - bson->read_state = BSON_JSON_REGULAR; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_BINARY_ENDMAP) { - bson->read_state = BSON_JSON_REGULAR; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_DATE_NUMBERLONG) { - if (!bson->key) { - _bad_extended_json (reader); - return; - } - - bson->read_state = BSON_JSON_IN_BSON_TYPE_DATE_ENDMAP; - - _bson_json_read_append_date_time (reader, bson); - return; - } else if (bson->read_state == BSON_JSON_IN_BSON_TYPE_DATE_ENDMAP) { - bson->read_state = BSON_JSON_REGULAR; - } else if (bson->read_state == BSON_JSON_REGULAR) { - if (STACK_IS_SCOPE) { - bson->read_state = BSON_JSON_IN_BSON_TYPE; - bson->bson_type = BSON_TYPE_CODE; - STACK_POP_SCOPE; - } else if (STACK_IS_DBPOINTER) { - bson->read_state = BSON_JSON_IN_BSON_TYPE_DBPOINTER_STARTMAP; - STACK_POP_DBPOINTER; - } else { - STACK_POP_DOC ( - bson_append_document_end (STACK_BSON_PARENT, STACK_BSON_CHILD)); - } - - if (bson->n == -1) { - bson->read_state = BSON_JSON_DONE; - } - } else if (bson->read_state == BSON_JSON_IN_SCOPE) { - /* empty $scope */ - BSON_ASSERT (bson->code_data.has_scope); - STACK_PUSH_SCOPE; - STACK_POP_SCOPE; - bson->read_state = BSON_JSON_IN_BSON_TYPE; - bson->bson_type = BSON_TYPE_CODE; - } else if (bson->read_state == BSON_JSON_IN_DBPOINTER) { - /* empty $dbPointer??? */ - _bson_json_read_set_error (reader, "Empty $dbPointer"); - } else { - _bson_json_read_set_error ( - reader, "Invalid state \"%s\"", read_state_names[bson->read_state]); - } -} - - -static void -_bson_json_read_start_array (bson_json_reader_t *reader) /* IN */ -{ - const char *key; - size_t len; - bson_json_reader_bson_t *bson = &reader->bson; - - if (bson->read_state != BSON_JSON_REGULAR) { - _bson_json_read_set_error (reader, - "Invalid read of \"[\" in state \"%s\"", - read_state_names[bson->read_state]); - return; - } - - if (bson->n == -1) { - STACK_PUSH_ARRAY (_noop ()); - } else { - _bson_json_read_fixup_key (bson); - key = bson->key; - len = bson->key_buf.len; - - STACK_PUSH_ARRAY (bson_append_array_begin ( - STACK_BSON_PARENT, key, (int) len, STACK_BSON_CHILD)); - } -} - - -static void -_bson_json_read_end_array (bson_json_reader_t *reader) /* IN */ -{ - bson_json_reader_bson_t *bson = &reader->bson; - - if (bson->read_state != BSON_JSON_REGULAR) { - _bson_json_read_set_error (reader, - "Invalid read of \"]\" in state \"%s\"", - read_state_names[bson->read_state]); - return; - } - - STACK_POP_ARRAY ( - bson_append_array_end (STACK_BSON_PARENT, STACK_BSON_CHILD)); - if (bson->n == -1) { - bson->read_state = BSON_JSON_DONE; - } -} - - -/* put unescaped text in reader->bson.unescaped, or set reader->error. - * json_text has length len and it is not null-terminated. */ -static bool -_bson_json_unescape (bson_json_reader_t *reader, - struct jsonsl_state_st *state, - const char *json_text, - ssize_t len) -{ - bson_json_reader_bson_t *reader_bson; - jsonsl_error_t err; - - reader_bson = &reader->bson; - - /* add 1 for NULL */ - _bson_json_buf_ensure (&reader_bson->unescaped, (size_t) len + 1); - - /* length of unescaped str is always <= len */ - reader_bson->unescaped.len = jsonsl_util_unescape ( - json_text, (char *) reader_bson->unescaped.buf, (size_t) len, NULL, &err); - - if (err != JSONSL_ERROR_SUCCESS) { - bson_set_error (reader->error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CORRUPT_JS, - "error near position %d: \"%s\"", - (int) state->pos_begin, - jsonsl_strerror (err)); - return false; - } - - reader_bson->unescaped.buf[reader_bson->unescaped.len] = '\0'; - - return true; -} - - -/* read the buffered JSON plus new data, and fill out @len with its length */ -static const char * -_get_json_text (jsonsl_t json, /* IN */ - struct jsonsl_state_st *state, /* IN */ - const char *buf /* IN */, - ssize_t *len /* OUT */) -{ - bson_json_reader_t *reader; - ssize_t bytes_available; - - reader = (bson_json_reader_t *) json->data; - - BSON_ASSERT (state->pos_cur > state->pos_begin); - - *len = (ssize_t) (state->pos_cur - state->pos_begin); - - bytes_available = buf - json->base; - - if (*len <= bytes_available) { - /* read directly from stream, not from saved JSON */ - return buf - (size_t) *len; - } else { - /* combine saved text with new data from the jsonsl_t */ - ssize_t append = buf - json->base; - - if (append > 0) { - _bson_json_buf_append ( - &reader->tok_accumulator, buf - append, (size_t) append); - } - - return (const char *) reader->tok_accumulator.buf; - } -} - - -static void -_push_callback (jsonsl_t json, - jsonsl_action_t action, - struct jsonsl_state_st *state, - const char *buf) -{ - bson_json_reader_t *reader = (bson_json_reader_t *) json->data; - - BSON_UNUSED (action); - BSON_UNUSED (buf); - - switch (state->type) { - case JSONSL_T_STRING: - case JSONSL_T_HKEY: - case JSONSL_T_SPECIAL: - case JSONSL_T_UESCAPE: - reader->json_text_pos = state->pos_begin; - break; - case JSONSL_T_OBJECT: - _bson_json_read_start_map (reader); - break; - case JSONSL_T_LIST: - _bson_json_read_start_array (reader); - break; - default: - break; - } -} - - -static void -_pop_callback (jsonsl_t json, - jsonsl_action_t action, - struct jsonsl_state_st *state, - const char *buf) -{ - bson_json_reader_t *reader; - bson_json_reader_bson_t *reader_bson; - ssize_t len; - double d; - const char *obj_text; - - BSON_UNUSED (action); - - reader = (bson_json_reader_t *) json->data; - reader_bson = &reader->bson; - - switch (state->type) { - case JSONSL_T_HKEY: - case JSONSL_T_STRING: - obj_text = _get_json_text (json, state, buf, &len); - BSON_ASSERT (obj_text[0] == '"'); - - /* remove start/end quotes, replace backslash-escapes, null-terminate */ - /* you'd think it would be faster to check if state->nescapes > 0 first, - * but tests show no improvement */ - if (!_bson_json_unescape (reader, state, obj_text + 1, len - 1)) { - /* reader->error is set */ - jsonsl_stop (json); - break; - } - - if (state->type == JSONSL_T_HKEY) { - _bson_json_read_map_key ( - reader, reader_bson->unescaped.buf, reader_bson->unescaped.len); - } else { - _bson_json_read_string ( - reader, reader_bson->unescaped.buf, reader_bson->unescaped.len); - } - break; - case JSONSL_T_OBJECT: - _bson_json_read_end_map (reader); - break; - case JSONSL_T_LIST: - _bson_json_read_end_array (reader); - break; - case JSONSL_T_SPECIAL: - obj_text = _get_json_text (json, state, buf, &len); - if (state->special_flags & JSONSL_SPECIALf_NUMNOINT) { - if (_bson_json_parse_double (reader, obj_text, (size_t) len, &d)) { - _bson_json_read_double (reader, d); - } - } else if (state->special_flags & JSONSL_SPECIALf_NUMERIC) { - /* jsonsl puts the unsigned value in state->nelem */ - _bson_json_read_integer ( - reader, - state->nelem, - state->special_flags & JSONSL_SPECIALf_SIGNED ? -1 : 1); - } else if (state->special_flags & JSONSL_SPECIALf_BOOLEAN) { - _bson_json_read_boolean (reader, obj_text[0] == 't' ? 1 : 0); - } else if (state->special_flags & JSONSL_SPECIALf_NULL) { - _bson_json_read_null (reader); - } - break; - default: - break; - } - - reader->json_text_pos = -1; - reader->tok_accumulator.len = 0; -} - - -static int -_error_callback (jsonsl_t json, - jsonsl_error_t err, - struct jsonsl_state_st *state, - char *errat) -{ - bson_json_reader_t *reader = (bson_json_reader_t *) json->data; - - BSON_UNUSED (state); - - if (err == JSONSL_ERROR_CANT_INSERT && *errat == '{') { - /* start the next document */ - reader->should_reset = true; - reader->advance = errat - json->base; - return 0; - } - - bson_set_error (reader->error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CORRUPT_JS, - "Got parse error at \"%c\", position %d: \"%s\"", - *errat, - (int) json->pos, - jsonsl_strerror (err)); - - return 0; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_json_reader_read -- - * - * Read the next json document from @reader and write its value - * into @bson. @bson will be allocated as part of this process. - * - * @bson MUST be initialized before calling this function as it - * will not be initialized automatically. The reasoning for this - * is so that you can chain together bson_json_reader_t with - * other components like bson_writer_t. - * - * Returns: - * 1 if successful and data was read. - * 0 if successful and no data was read. - * -1 if there was an error and @error is set. - * - * Side effects: - * @error may be set. - * - *-------------------------------------------------------------------------- - */ - -int -bson_json_reader_read (bson_json_reader_t *reader, /* IN */ - bson_t *bson, /* IN */ - bson_error_t *error) /* OUT */ -{ - bson_json_reader_producer_t *p; - ssize_t start_pos; - ssize_t r; - ssize_t buf_offset; - ssize_t accum; - bson_error_t error_tmp; - int ret = 0; - - BSON_ASSERT (reader); - BSON_ASSERT (bson); - - p = &reader->producer; - - reader->bson.bson = bson; - reader->bson.n = -1; - reader->bson.read_state = BSON_JSON_REGULAR; - reader->error = error ? error : &error_tmp; - memset (reader->error, 0, sizeof (bson_error_t)); - - for (;;) { - start_pos = reader->json->pos; - - if (p->bytes_read > 0) { - /* leftover data from previous JSON doc in the stream */ - r = p->bytes_read; - } else { - /* read a chunk of bytes by executing the callback */ - r = p->cb (p->data, p->buf, p->buf_size); - } - - if (r < 0) { - if (error) { - bson_set_error (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CB_FAILURE, - "reader cb failed"); - } - ret = -1; - goto cleanup; - } else if (r == 0) { - break; - } else { - ret = 1; - p->bytes_read = (size_t) r; - - jsonsl_feed (reader->json, (const jsonsl_char_t *) p->buf, (size_t) r); - - if (reader->should_reset) { - /* end of a document */ - jsonsl_reset (reader->json); - reader->should_reset = false; - - /* advance past already-parsed data */ - memmove (p->buf, p->buf + reader->advance, r - reader->advance); - p->bytes_read -= reader->advance; - ret = 1; - goto cleanup; - } - - if (reader->error->domain) { - ret = -1; - goto cleanup; - } - - /* accumulate a key or string value */ - if (reader->json_text_pos != -1) { - if (bson_cmp_less_su (reader->json_text_pos, reader->json->pos)) { - BSON_ASSERT ( - bson_in_range_unsigned (ssize_t, reader->json->pos)); - accum = BSON_MIN ( - (ssize_t) reader->json->pos - reader->json_text_pos, r); - /* if this chunk stopped mid-token, buf_offset is how far into - * our current chunk the token begins. */ - buf_offset = AT_LEAST_0 (reader->json_text_pos - start_pos); - _bson_json_buf_append (&reader->tok_accumulator, - p->buf + buf_offset, - (size_t) accum); - } - } - - p->bytes_read = 0; - } - } - -cleanup: - if (ret == 1 && reader->bson.read_state != BSON_JSON_DONE) { - /* data ended in the middle */ - _bson_json_read_corrupt (reader, "%s", "Incomplete JSON"); - return -1; - } - - return ret; -} - - -bson_json_reader_t * -bson_json_reader_new (void *data, /* IN */ - bson_json_reader_cb cb, /* IN */ - bson_json_destroy_cb dcb, /* IN */ - bool allow_multiple, /* unused */ - size_t buf_size) /* IN */ -{ - bson_json_reader_t *r; - bson_json_reader_producer_t *p; - - BSON_UNUSED (allow_multiple); - - r = BSON_ALIGNED_ALLOC0 (bson_json_reader_t); - r->json = jsonsl_new (STACK_MAX); - r->json->error_callback = _error_callback; - r->json->action_callback_PUSH = _push_callback; - r->json->action_callback_POP = _pop_callback; - r->json->data = r; - r->json_text_pos = -1; - jsonsl_enable_all_callbacks (r->json); - - p = &r->producer; - - p->data = data; - p->cb = cb; - p->dcb = dcb; - p->buf_size = buf_size ? buf_size : BSON_JSON_DEFAULT_BUF_SIZE; - p->buf = bson_malloc (p->buf_size); - - return r; -} - - -void -bson_json_reader_destroy (bson_json_reader_t *reader) /* IN */ -{ - int i; - bson_json_reader_producer_t *p; - bson_json_reader_bson_t *b; - - if (!reader) { - return; - } - - p = &reader->producer; - b = &reader->bson; - - if (reader->producer.dcb) { - reader->producer.dcb (reader->producer.data); - } - - bson_free (p->buf); - bson_free (b->key_buf.buf); - bson_free (b->unescaped.buf); - bson_free (b->dbpointer_key.buf); - - /* destroy each bson_t initialized in parser stack frames */ - for (i = 1; i < STACK_MAX; i++) { - if (b->stack[i].type == BSON_JSON_FRAME_INITIAL) { - /* highest the stack grew */ - break; - } - - if (FRAME_TYPE_HAS_BSON (b->stack[i].type)) { - bson_destroy (&b->stack[i].bson); - } - } - - for (i = 0; i < 3; i++) { - bson_free (b->bson_type_buf[i].buf); - } - - _bson_json_code_cleanup (&b->code_data); - - jsonsl_destroy (reader->json); - bson_free (reader->tok_accumulator.buf); - bson_free (reader); -} - - -void -bson_json_opts_set_outermost_array (bson_json_opts_t *opts, - bool is_outermost_array) -{ - opts->is_outermost_array = is_outermost_array; -} - - -typedef struct { - const uint8_t *data; - size_t len; - size_t bytes_parsed; -} bson_json_data_reader_t; - - -static ssize_t -_bson_json_data_reader_cb (void *_ctx, uint8_t *buf, size_t len) -{ - size_t bytes; - bson_json_data_reader_t *ctx = (bson_json_data_reader_t *) _ctx; - - if (!ctx->data) { - return -1; - } - - bytes = BSON_MIN (len, ctx->len - ctx->bytes_parsed); - - memcpy (buf, ctx->data + ctx->bytes_parsed, bytes); - - ctx->bytes_parsed += bytes; - - return bytes; -} - - -bson_json_reader_t * -bson_json_data_reader_new (bool allow_multiple, /* IN */ - size_t size) /* IN */ -{ - bson_json_data_reader_t *dr = bson_malloc0 (sizeof *dr); - - return bson_json_reader_new ( - dr, &_bson_json_data_reader_cb, &bson_free, allow_multiple, size); -} - - -void -bson_json_data_reader_ingest (bson_json_reader_t *reader, /* IN */ - const uint8_t *data, /* IN */ - size_t len) /* IN */ -{ - bson_json_data_reader_t *ctx = - (bson_json_data_reader_t *) reader->producer.data; - - ctx->data = data; - ctx->len = len; - ctx->bytes_parsed = 0; -} - - -bson_t * -bson_new_from_json (const uint8_t *data, /* IN */ - ssize_t len, /* IN */ - bson_error_t *error) /* OUT */ -{ - bson_json_reader_t *reader; - bson_t *bson; - int r; - - BSON_ASSERT (data); - - if (len < 0) { - len = (ssize_t) strlen ((const char *) data); - } - - bson = bson_new (); - reader = bson_json_data_reader_new (false, BSON_JSON_DEFAULT_BUF_SIZE); - bson_json_data_reader_ingest (reader, data, len); - r = bson_json_reader_read (reader, bson, error); - bson_json_reader_destroy (reader); - - if (r == 0) { - bson_set_error (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Empty JSON string"); - } - - if (r != 1) { - bson_destroy (bson); - return NULL; - } - - return bson; -} - - -bool -bson_init_from_json (bson_t *bson, /* OUT */ - const char *data, /* IN */ - ssize_t len, /* IN */ - bson_error_t *error) /* OUT */ -{ - bson_json_reader_t *reader; - int r; - - BSON_ASSERT (bson); - BSON_ASSERT (data); - - if (len < 0) { - len = strlen (data); - } - - bson_init (bson); - - reader = bson_json_data_reader_new (false, BSON_JSON_DEFAULT_BUF_SIZE); - bson_json_data_reader_ingest (reader, (const uint8_t *) data, len); - r = bson_json_reader_read (reader, bson, error); - bson_json_reader_destroy (reader); - - if (r == 0) { - bson_set_error (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Empty JSON string"); - } - - if (r != 1) { - bson_destroy (bson); - return false; - } - - return true; -} - - -static void -_bson_json_reader_handle_fd_destroy (void *handle) /* IN */ -{ - bson_json_reader_handle_fd_t *fd = handle; - - if (fd) { - if ((fd->fd != -1) && fd->do_close) { -#ifdef _WIN32 - _close (fd->fd); -#else - close (fd->fd); -#endif - } - bson_free (fd); - } -} - - -static ssize_t -_bson_json_reader_handle_fd_read (void *handle, /* IN */ - uint8_t *buf, /* IN */ - size_t len) /* IN */ -{ - bson_json_reader_handle_fd_t *fd = handle; - ssize_t ret = -1; - - if (fd && (fd->fd != -1)) { - again: -#ifdef BSON_OS_WIN32 - ret = _read (fd->fd, buf, (unsigned int) len); -#else - ret = read (fd->fd, buf, len); -#endif - if ((ret == -1) && (errno == EAGAIN)) { - goto again; - } - } - - return ret; -} - - -bson_json_reader_t * -bson_json_reader_new_from_fd (int fd, /* IN */ - bool close_on_destroy) /* IN */ -{ - bson_json_reader_handle_fd_t *handle; - - BSON_ASSERT (fd != -1); - - handle = bson_malloc0 (sizeof *handle); - handle->fd = fd; - handle->do_close = close_on_destroy; - - return bson_json_reader_new (handle, - _bson_json_reader_handle_fd_read, - _bson_json_reader_handle_fd_destroy, - true, - BSON_JSON_DEFAULT_BUF_SIZE); -} - - -bson_json_reader_t * -bson_json_reader_new_from_file (const char *path, /* IN */ - bson_error_t *error) /* OUT */ -{ - char errmsg_buf[BSON_ERROR_BUFFER_SIZE]; - char *errmsg; - int fd = -1; - - BSON_ASSERT (path); - -#ifdef BSON_OS_WIN32 - _sopen_s (&fd, path, (_O_RDONLY | _O_BINARY), _SH_DENYNO, _S_IREAD); -#else - fd = open (path, O_RDONLY); -#endif - - if (fd == -1) { - errmsg = bson_strerror_r (errno, errmsg_buf, sizeof errmsg_buf); - bson_set_error ( - error, BSON_ERROR_READER, BSON_ERROR_READER_BADFD, "%s", errmsg); - return NULL; - } - - return bson_json_reader_new_from_fd (fd, true); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-json.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-json.h deleted file mode 100644 index 9efc8c344..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-json.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_JSON_H -#define BSON_JSON_H - - -#include "bson.h" - - -BSON_BEGIN_DECLS - - -typedef struct _bson_json_reader_t bson_json_reader_t; - - -typedef enum { - BSON_JSON_ERROR_READ_CORRUPT_JS = 1, - BSON_JSON_ERROR_READ_INVALID_PARAM, - BSON_JSON_ERROR_READ_CB_FAILURE, -} bson_json_error_code_t; - - -/** - * BSON_MAX_LEN_UNLIMITED - * - * Denotes unlimited length limit when converting BSON to JSON. - */ -#define BSON_MAX_LEN_UNLIMITED -1 - -/** - * bson_json_mode_t: - * - * This enumeration contains the different modes to serialize BSON into extended - * JSON. - */ -typedef enum { - BSON_JSON_MODE_LEGACY, - BSON_JSON_MODE_CANONICAL, - BSON_JSON_MODE_RELAXED, -} bson_json_mode_t; - - -BSON_EXPORT (bson_json_opts_t *) -bson_json_opts_new (bson_json_mode_t mode, int32_t max_len); -BSON_EXPORT (void) -bson_json_opts_destroy (bson_json_opts_t *opts); -BSON_EXPORT (void) -bson_json_opts_set_outermost_array (bson_json_opts_t *opts, - bool is_outermost_array); - -typedef ssize_t (*bson_json_reader_cb) (void *handle, - uint8_t *buf, - size_t count); -typedef void (*bson_json_destroy_cb) (void *handle); - - -BSON_EXPORT (bson_json_reader_t *) -bson_json_reader_new (void *data, - bson_json_reader_cb cb, - bson_json_destroy_cb dcb, - bool allow_multiple, - size_t buf_size); -BSON_EXPORT (bson_json_reader_t *) -bson_json_reader_new_from_fd (int fd, bool close_on_destroy); -BSON_EXPORT (bson_json_reader_t *) -bson_json_reader_new_from_file (const char *filename, bson_error_t *error); -BSON_EXPORT (void) -bson_json_reader_destroy (bson_json_reader_t *reader); -BSON_EXPORT (int) -bson_json_reader_read (bson_json_reader_t *reader, - bson_t *bson, - bson_error_t *error); -BSON_EXPORT (bson_json_reader_t *) -bson_json_data_reader_new (bool allow_multiple, size_t size); -BSON_EXPORT (void) -bson_json_data_reader_ingest (bson_json_reader_t *reader, - const uint8_t *data, - size_t len); - - -BSON_END_DECLS - - -#endif /* BSON_JSON_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-keys.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-keys.c deleted file mode 100644 index 0f3f73553..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-keys.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include -#include - - -static const char *gUint32Strs[] = { - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", - "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", - "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", - "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", - "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", - "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", - "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", - "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", - "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", - "99", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", - "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", - "121", "122", "123", "124", "125", "126", "127", "128", "129", "130", "131", - "132", "133", "134", "135", "136", "137", "138", "139", "140", "141", "142", - "143", "144", "145", "146", "147", "148", "149", "150", "151", "152", "153", - "154", "155", "156", "157", "158", "159", "160", "161", "162", "163", "164", - "165", "166", "167", "168", "169", "170", "171", "172", "173", "174", "175", - "176", "177", "178", "179", "180", "181", "182", "183", "184", "185", "186", - "187", "188", "189", "190", "191", "192", "193", "194", "195", "196", "197", - "198", "199", "200", "201", "202", "203", "204", "205", "206", "207", "208", - "209", "210", "211", "212", "213", "214", "215", "216", "217", "218", "219", - "220", "221", "222", "223", "224", "225", "226", "227", "228", "229", "230", - "231", "232", "233", "234", "235", "236", "237", "238", "239", "240", "241", - "242", "243", "244", "245", "246", "247", "248", "249", "250", "251", "252", - "253", "254", "255", "256", "257", "258", "259", "260", "261", "262", "263", - "264", "265", "266", "267", "268", "269", "270", "271", "272", "273", "274", - "275", "276", "277", "278", "279", "280", "281", "282", "283", "284", "285", - "286", "287", "288", "289", "290", "291", "292", "293", "294", "295", "296", - "297", "298", "299", "300", "301", "302", "303", "304", "305", "306", "307", - "308", "309", "310", "311", "312", "313", "314", "315", "316", "317", "318", - "319", "320", "321", "322", "323", "324", "325", "326", "327", "328", "329", - "330", "331", "332", "333", "334", "335", "336", "337", "338", "339", "340", - "341", "342", "343", "344", "345", "346", "347", "348", "349", "350", "351", - "352", "353", "354", "355", "356", "357", "358", "359", "360", "361", "362", - "363", "364", "365", "366", "367", "368", "369", "370", "371", "372", "373", - "374", "375", "376", "377", "378", "379", "380", "381", "382", "383", "384", - "385", "386", "387", "388", "389", "390", "391", "392", "393", "394", "395", - "396", "397", "398", "399", "400", "401", "402", "403", "404", "405", "406", - "407", "408", "409", "410", "411", "412", "413", "414", "415", "416", "417", - "418", "419", "420", "421", "422", "423", "424", "425", "426", "427", "428", - "429", "430", "431", "432", "433", "434", "435", "436", "437", "438", "439", - "440", "441", "442", "443", "444", "445", "446", "447", "448", "449", "450", - "451", "452", "453", "454", "455", "456", "457", "458", "459", "460", "461", - "462", "463", "464", "465", "466", "467", "468", "469", "470", "471", "472", - "473", "474", "475", "476", "477", "478", "479", "480", "481", "482", "483", - "484", "485", "486", "487", "488", "489", "490", "491", "492", "493", "494", - "495", "496", "497", "498", "499", "500", "501", "502", "503", "504", "505", - "506", "507", "508", "509", "510", "511", "512", "513", "514", "515", "516", - "517", "518", "519", "520", "521", "522", "523", "524", "525", "526", "527", - "528", "529", "530", "531", "532", "533", "534", "535", "536", "537", "538", - "539", "540", "541", "542", "543", "544", "545", "546", "547", "548", "549", - "550", "551", "552", "553", "554", "555", "556", "557", "558", "559", "560", - "561", "562", "563", "564", "565", "566", "567", "568", "569", "570", "571", - "572", "573", "574", "575", "576", "577", "578", "579", "580", "581", "582", - "583", "584", "585", "586", "587", "588", "589", "590", "591", "592", "593", - "594", "595", "596", "597", "598", "599", "600", "601", "602", "603", "604", - "605", "606", "607", "608", "609", "610", "611", "612", "613", "614", "615", - "616", "617", "618", "619", "620", "621", "622", "623", "624", "625", "626", - "627", "628", "629", "630", "631", "632", "633", "634", "635", "636", "637", - "638", "639", "640", "641", "642", "643", "644", "645", "646", "647", "648", - "649", "650", "651", "652", "653", "654", "655", "656", "657", "658", "659", - "660", "661", "662", "663", "664", "665", "666", "667", "668", "669", "670", - "671", "672", "673", "674", "675", "676", "677", "678", "679", "680", "681", - "682", "683", "684", "685", "686", "687", "688", "689", "690", "691", "692", - "693", "694", "695", "696", "697", "698", "699", "700", "701", "702", "703", - "704", "705", "706", "707", "708", "709", "710", "711", "712", "713", "714", - "715", "716", "717", "718", "719", "720", "721", "722", "723", "724", "725", - "726", "727", "728", "729", "730", "731", "732", "733", "734", "735", "736", - "737", "738", "739", "740", "741", "742", "743", "744", "745", "746", "747", - "748", "749", "750", "751", "752", "753", "754", "755", "756", "757", "758", - "759", "760", "761", "762", "763", "764", "765", "766", "767", "768", "769", - "770", "771", "772", "773", "774", "775", "776", "777", "778", "779", "780", - "781", "782", "783", "784", "785", "786", "787", "788", "789", "790", "791", - "792", "793", "794", "795", "796", "797", "798", "799", "800", "801", "802", - "803", "804", "805", "806", "807", "808", "809", "810", "811", "812", "813", - "814", "815", "816", "817", "818", "819", "820", "821", "822", "823", "824", - "825", "826", "827", "828", "829", "830", "831", "832", "833", "834", "835", - "836", "837", "838", "839", "840", "841", "842", "843", "844", "845", "846", - "847", "848", "849", "850", "851", "852", "853", "854", "855", "856", "857", - "858", "859", "860", "861", "862", "863", "864", "865", "866", "867", "868", - "869", "870", "871", "872", "873", "874", "875", "876", "877", "878", "879", - "880", "881", "882", "883", "884", "885", "886", "887", "888", "889", "890", - "891", "892", "893", "894", "895", "896", "897", "898", "899", "900", "901", - "902", "903", "904", "905", "906", "907", "908", "909", "910", "911", "912", - "913", "914", "915", "916", "917", "918", "919", "920", "921", "922", "923", - "924", "925", "926", "927", "928", "929", "930", "931", "932", "933", "934", - "935", "936", "937", "938", "939", "940", "941", "942", "943", "944", "945", - "946", "947", "948", "949", "950", "951", "952", "953", "954", "955", "956", - "957", "958", "959", "960", "961", "962", "963", "964", "965", "966", "967", - "968", "969", "970", "971", "972", "973", "974", "975", "976", "977", "978", - "979", "980", "981", "982", "983", "984", "985", "986", "987", "988", "989", - "990", "991", "992", "993", "994", "995", "996", "997", "998", "999"}; - - -/* - *-------------------------------------------------------------------------- - * - * bson_uint32_to_string -- - * - * Converts @value to a string. - * - * If @value is from 0 to 1000, it will use a constant string in the - * data section of the library. - * - * If not, a string will be formatted using @str and snprintf(). This - * is much slower, of course and therefore we try to optimize it out. - * - * @strptr will always be set. It will either point to @str or a - * constant string. You will want to use this as your key. - * - * Parameters: - * @value: A #uint32_t to convert to string. - * @strptr: (out): A pointer to the resulting string. - * @str: (out): Storage for a string made with snprintf. - * @size: Size of @str. - * - * Returns: - * The number of bytes in the resulting string excluding the NULL - * terminator. If the output requires more than @size bytes, then @size - * bytes are written and the result is the number of bytes required - * (excluding the NULL terminator) - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -size_t -bson_uint32_to_string (uint32_t value, /* IN */ - const char **strptr, /* OUT */ - char *str, /* OUT */ - size_t size) /* IN */ -{ - if (value < 1000) { - *strptr = gUint32Strs[value]; - - if (value < 10) { - return 1; - } else if (value < 100) { - return 2; - } else { - return 3; - } - } - - *strptr = str; - - return bson_snprintf (str, size, "%u", value); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-macros.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-macros.h deleted file mode 100644 index d566713a6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-macros.h +++ /dev/null @@ -1,394 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_MACROS_H -#define BSON_MACROS_H - - -#include - -#ifdef __cplusplus -#include -#endif - -#include - - -#if BSON_OS == 1 -#define BSON_OS_UNIX -#elif BSON_OS == 2 -#define BSON_OS_WIN32 -#else -#error "Unknown operating system." -#endif - - -#ifdef __cplusplus -#define BSON_BEGIN_DECLS extern "C" { -#define BSON_END_DECLS } -#else -#define BSON_BEGIN_DECLS -#define BSON_END_DECLS -#endif - - -#if defined(__GNUC__) -#define BSON_GNUC_CHECK_VERSION(major, minor) \ - ((__GNUC__ > (major)) || \ - ((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor)))) -#else -#define BSON_GNUC_CHECK_VERSION(major, minor) 0 -#endif - - -#if defined(__GNUC__) -#define BSON_GNUC_IS_VERSION(major, minor) \ - ((__GNUC__ == (major)) && (__GNUC_MINOR__ == (minor))) -#else -#define BSON_GNUC_IS_VERSION(major, minor) 0 -#endif - - -/* Decorate public functions: - * - if BSON_STATIC, we're compiling a static libbson or a program - * that uses libbson as a static library. Don't decorate functions. - * - else if BSON_COMPILATION, we're compiling a shared libbson, mark - * public functions for export from the shared lib - * - else, we're compiling a program that uses libbson as a shared library, - * mark public functions as DLL imports for Microsoft Visual C - */ - -#ifdef _MSC_VER -/* - * Microsoft Visual C - */ -#ifdef BSON_STATIC -#define BSON_API -#elif defined(BSON_COMPILATION) -#define BSON_API __declspec (dllexport) -#else -#define BSON_API __declspec (dllimport) -#endif -#define BSON_CALL __cdecl - -#elif defined(__GNUC__) -/* - * GCC - */ -#ifdef BSON_STATIC -#define BSON_API -#elif defined(BSON_COMPILATION) -#define BSON_API __attribute__ ((visibility ("default"))) -#else -#define BSON_API -#endif -#define BSON_CALL - -#else -/* - * Other compilers - */ -#define BSON_API -#define BSON_CALL - -#endif - -#define BSON_EXPORT(type) BSON_API type BSON_CALL - - -#ifdef MIN -#define BSON_MIN MIN -#elif defined(__cplusplus) -#define BSON_MIN(a, b) ((std::min) (a, b)) -#elif defined(_MSC_VER) -#define BSON_MIN(a, b) ((a) < (b) ? (a) : (b)) -#else -#define BSON_MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif - - -#ifdef MAX -#define BSON_MAX MAX -#elif defined(__cplusplus) -#define BSON_MAX(a, b) ((std::max) (a, b)) -#elif defined(_MSC_VER) -#define BSON_MAX(a, b) ((a) > (b) ? (a) : (b)) -#else -#define BSON_MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - - -#ifdef ABS -#define BSON_ABS ABS -#else -#define BSON_ABS(a) (((a) < 0) ? ((a) * -1) : (a)) -#endif - -#if defined(__cplusplus) && (__cplusplus >= 201103L || defined(_MSVC_LANG)) -#define BSON_ALIGNOF(expr) alignof (expr) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L -#define BSON_ALIGNOF(expr) _Alignof (expr) -#else -#if defined(_MSC_VER) -#define BSON_ALIGNOF(expr) __alignof (expr) -#else -#define BSON_ALIGNOF(expr) __alignof__ (expr) -#endif -#endif // __STDC_VERSION__ >= 201112L - -#ifdef _MSC_VER -// __declspec (align (_N)) only permits integer literals as _N. -#ifdef _WIN64 -#define BSON_ALIGN_OF_PTR 8 -#else -#define BSON_ALIGN_OF_PTR 4 -#endif -#else -#define BSON_ALIGN_OF_PTR (BSON_ALIGNOF (void *)) -#endif - -#ifdef BSON_EXTRA_ALIGN -#if defined(_MSC_VER) -#define BSON_ALIGNED_BEGIN(_N) __declspec (align (_N)) -#define BSON_ALIGNED_END(_N) -#else -#define BSON_ALIGNED_BEGIN(_N) -#define BSON_ALIGNED_END(_N) __attribute__ ((aligned (_N))) -#endif -#else -#if defined(_MSC_VER) -#define BSON_ALIGNED_BEGIN(_N) __declspec (align (BSON_ALIGN_OF_PTR)) -#define BSON_ALIGNED_END(_N) -#else -#define BSON_ALIGNED_BEGIN(_N) -#define BSON_ALIGNED_END(_N) \ - __attribute__ (( \ - aligned ((_N) > BSON_ALIGN_OF_PTR ? BSON_ALIGN_OF_PTR : (_N)))) -#endif -#endif - - -#define bson_str_empty(s) (!s[0]) -#define bson_str_empty0(s) (!s || !s[0]) - - -#if defined(_MSC_VER) -#define BSON_FUNC __FUNCTION__ -#else -#define BSON_FUNC __func__ -#endif - -#define BSON_ASSERT(test) \ - do { \ - if (!(BSON_LIKELY (test))) { \ - fprintf (stderr, \ - "%s:%d %s(): precondition failed: %s\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - #test); \ - abort (); \ - } \ - } while (0) - -/** - * @brief Assert the expression `Assertion`, and evaluates to `Value` on - * success. - */ -#define BSON_ASSERT_INLINE(Assertion, Value) \ - ((void) ((Assertion) ? (0) \ - : ((fprintf (stderr, \ - "%s:%d %s(): Assertion '%s' failed", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - #Assertion), \ - abort ()), \ - 0)), \ - Value) - -/** - * @brief Assert that the given pointer is non-NULL, while also evaluating to - * that pointer. - * - * Can be used to inline assertions with a pointer dereference: - * - * ``` - * foo* f = get_foo(); - * bar* b = BSON_ASSERT_PTR_INLINE(f)->bar_value; - * ``` - */ -#define BSON_ASSERT_PTR_INLINE(Pointer) \ - BSON_ASSERT_INLINE ((Pointer) != NULL, (Pointer)) - -/* Used for asserting parameters to provide a more precise error message */ -#define BSON_ASSERT_PARAM(param) \ - do { \ - if ((BSON_UNLIKELY (param == NULL))) { \ - fprintf (stderr, \ - "The parameter: %s, in function %s, cannot be NULL\n", \ - #param, \ - BSON_FUNC); \ - abort (); \ - } \ - } while (0) - -/* obsolete macros, preserved for compatibility */ -#define BSON_STATIC_ASSERT(s) BSON_STATIC_ASSERT_ (s, __LINE__) -#define BSON_STATIC_ASSERT_JOIN(a, b) BSON_STATIC_ASSERT_JOIN2 (a, b) -#define BSON_STATIC_ASSERT_JOIN2(a, b) a##b -#define BSON_STATIC_ASSERT_(s, l) \ - typedef char BSON_STATIC_ASSERT_JOIN (static_assert_test_, \ - __LINE__)[(s) ? 1 : -1] - -/* modern macros */ -#define BSON_STATIC_ASSERT2(_name, _s) \ - BSON_STATIC_ASSERT2_ (_s, __LINE__, _name) -#define BSON_STATIC_ASSERT_JOIN3(_a, _b, _name) \ - BSON_STATIC_ASSERT_JOIN4 (_a, _b, _name) -#define BSON_STATIC_ASSERT_JOIN4(_a, _b, _name) _a##_b##_name -#define BSON_STATIC_ASSERT2_(_s, _l, _name) \ - typedef char BSON_STATIC_ASSERT_JOIN3 ( \ - static_assert_test_, __LINE__, _name)[(_s) ? 1 : -1] - - -#if defined(__GNUC__) -#define BSON_GNUC_PURE __attribute__ ((pure)) -#define BSON_GNUC_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) -#else -#define BSON_GNUC_PURE -#define BSON_GNUC_WARN_UNUSED_RESULT -#endif - - -#if BSON_GNUC_CHECK_VERSION(4, 0) && !defined(_WIN32) -#define BSON_GNUC_NULL_TERMINATED __attribute__ ((sentinel)) -#define BSON_GNUC_INTERNAL __attribute__ ((visibility ("hidden"))) -#else -#define BSON_GNUC_NULL_TERMINATED -#define BSON_GNUC_INTERNAL -#endif - - -#if defined(__GNUC__) -#define BSON_LIKELY(x) __builtin_expect (!!(x), 1) -#define BSON_UNLIKELY(x) __builtin_expect (!!(x), 0) -#else -#define BSON_LIKELY(v) v -#define BSON_UNLIKELY(v) v -#endif - - -#if defined(__clang__) -#define BSON_GNUC_PRINTF(f, v) __attribute__ ((format (printf, f, v))) -#elif BSON_GNUC_CHECK_VERSION(4, 4) -#define BSON_GNUC_PRINTF(f, v) __attribute__ ((format (gnu_printf, f, v))) -#else -#define BSON_GNUC_PRINTF(f, v) -#endif - - -#if defined(__LP64__) || defined(_LP64) -#define BSON_WORD_SIZE 64 -#else -#define BSON_WORD_SIZE 32 -#endif - - -#if defined(_MSC_VER) -#define BSON_INLINE __inline -#else -#define BSON_INLINE __inline__ -#endif - - -#ifdef _MSC_VER -#define BSON_ENSURE_ARRAY_PARAM_SIZE(_n) -#define BSON_TYPEOF decltype -#else -#define BSON_ENSURE_ARRAY_PARAM_SIZE(_n) static (_n) -#define BSON_TYPEOF typeof -#endif - - -#if BSON_GNUC_CHECK_VERSION(3, 1) -#define BSON_GNUC_DEPRECATED __attribute__ ((__deprecated__)) -#else -#define BSON_GNUC_DEPRECATED -#endif - -#define BSON_CONCAT_IMPL(a, ...) a##__VA_ARGS__ -#define BSON_CONCAT(a, ...) BSON_CONCAT_IMPL (a, __VA_ARGS__) -#define BSON_CONCAT3(a, b, c) BSON_CONCAT (a, BSON_CONCAT (b, c)) -#define BSON_CONCAT4(a, b, c, d) \ - BSON_CONCAT (BSON_CONCAT (a, b), BSON_CONCAT (c, d)) - -#if BSON_GNUC_CHECK_VERSION(4, 5) -#define BSON_GNUC_DEPRECATED_FOR(f) \ - __attribute__ ((deprecated ("Use " #f " instead"))) -#else -#define BSON_GNUC_DEPRECATED_FOR(f) BSON_GNUC_DEPRECATED -#endif - -/** - * @brief String-ify the given argument - */ -#define BSON_STR(...) #__VA_ARGS__ - -/** - * @brief Mark the attached declared entity as "possibly-unused." - * - * Does nothing on MSVC. - */ -#if defined(__GNUC__) || defined(__clang__) -#define BSON_MAYBE_UNUSED __attribute__ ((unused)) -#else -#define BSON_MAYBE_UNUSED /* Nothing for other compilers */ -#endif - -/** - * @brief Mark a point in the code as unreachable. If the point is reached, the - * program will abort with an error message. - * - * @param What A string to include in the error message if this point is ever - * executed. - */ -#define BSON_UNREACHABLE(What) \ - do { \ - fprintf (stderr, \ - "%s:%d %s(): Unreachable code reached: %s\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - What); \ - abort (); \ - } while (0) - -/** - * @brief Silence warnings for deliberately unused variables or parameters. - * - * @param expr An unused variable or parameter. - * - */ -#define BSON_UNUSED(expr) \ - do { \ - (void) (expr); \ - } while (0) - -#endif /* BSON_MACROS_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-md5.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-md5.c deleted file mode 100644 index 5c736cfc3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-md5.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -#include -#include "common-md5-private.h" - - -void -bson_md5_init (bson_md5_t *pms) -{ - mcommon_md5_init (pms); -} - - -void -bson_md5_append (bson_md5_t *pms, const uint8_t *data, uint32_t nbytes) -{ - mcommon_md5_append (pms, data, nbytes); -} - -void -bson_md5_finish (bson_md5_t *pms, uint8_t digest[16]) -{ - mcommon_md5_finish (pms, digest); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-md5.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-md5.h deleted file mode 100644 index 46ca8b984..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-md5.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgement in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - L. Peter Deutsch - ghost@aladdin.com - - */ -/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */ -/* - Independent implementation of MD5 (RFC 1321). - - This code implements the MD5 Algorithm defined in RFC 1321, whose - text is available at - http://www.ietf.org/rfc/rfc1321.txt - The code is derived from the text of the RFC, including the test suite - (section A.5) but excluding the rest of Appendix A. It does not include - any code or documentation that is identified in the RFC as being - copyrighted. - - The original and principal author of md5.h is L. Peter Deutsch - . Other authors are noted in the change history - that follows (in reverse chronological order): - - 2002-04-13 lpd Removed support for non-ANSI compilers; removed - references to Ghostscript; clarified derivation from RFC 1321; - now handles byte order either statically or dynamically. - 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. - 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); - added conditionalization for C++ compilation from Martin - Purschke . - 1999-05-03 lpd Original version. - */ - - -/* - * The following MD5 implementation has been modified to use types as - * specified in libbson. - */ - -#include - - -#ifndef BSON_MD5_H -#define BSON_MD5_H - - -#include - - -BSON_BEGIN_DECLS - - -typedef struct { - uint32_t count[2]; /* message length in bits, lsw first */ - uint32_t abcd[4]; /* digest buffer */ - uint8_t buf[64]; /* accumulate block */ -} bson_md5_t; - - -BSON_EXPORT (void) -bson_md5_init (bson_md5_t *pms) BSON_GNUC_DEPRECATED; -BSON_EXPORT (void) -bson_md5_append (bson_md5_t *pms, - const uint8_t *data, - uint32_t nbytes) BSON_GNUC_DEPRECATED; -BSON_EXPORT (void) -bson_md5_finish (bson_md5_t *pms, uint8_t digest[16]) BSON_GNUC_DEPRECATED; - - -BSON_END_DECLS - - -#endif /* BSON_MD5_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-memory.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-memory.c deleted file mode 100644 index 03bc4dd59..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-memory.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include - -#include -#include -#include - - -// Ensure size of exported structs are stable. -BSON_STATIC_ASSERT2 (bson_mem_vtable_t, - sizeof (bson_mem_vtable_t) == sizeof (void *) * 8u); - - -// For compatibility with C standards prior to C11. -static void * -_aligned_alloc_impl (size_t alignment, size_t num_bytes) -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \ - !defined(_WIN32) && !defined(__ANDROID__) && !defined(_AIX) -{ - return aligned_alloc (alignment, num_bytes); -} -#elif defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L -{ - void *mem = NULL; - - // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425. - BSON_MAYBE_UNUSED int ret = posix_memalign (&mem, alignment, num_bytes); - - return mem; -} -#else -{ - // Fallback to simple malloc even if it does not satisfy alignment - // requirements. Note: Visual C++ _aligned_malloc requires using - // _aligned_free instead of free and modifies errno on failure, both of which - // breaks symmetry with C11 aligned_alloc, so it is deliberately not used. - BSON_UNUSED (alignment); - return malloc (num_bytes); -} -#endif - - -static bson_mem_vtable_t gMemVtable = {.malloc = malloc, - .calloc = calloc, - .realloc = realloc, - .free = free, - .aligned_alloc = _aligned_alloc_impl, - .padding = {0}}; - - -/* - *-------------------------------------------------------------------------- - * - * bson_malloc -- - * - * Allocates @num_bytes of memory and returns a pointer to it. If - * malloc failed to allocate the memory, abort() is called. - * - * Libbson does not try to handle OOM conditions as it is beyond the - * scope of this library to handle so appropriately. - * - * Parameters: - * @num_bytes: The number of bytes to allocate. - * - * Returns: - * A pointer if successful; otherwise abort() is called and this - * function will never return. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void * -bson_malloc (size_t num_bytes) /* IN */ -{ - void *mem = NULL; - - if (BSON_LIKELY (num_bytes)) { - if (BSON_UNLIKELY (!(mem = gMemVtable.malloc (num_bytes)))) { - fprintf (stderr, - "Failure to allocate memory in bson_malloc(). errno: %d.\n", - errno); - abort (); - } - } - - return mem; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_malloc0 -- - * - * Like bson_malloc() except the memory is zeroed first. This is - * similar to calloc() except that abort() is called in case of - * failure to allocate memory. - * - * Parameters: - * @num_bytes: The number of bytes to allocate. - * - * Returns: - * A pointer if successful; otherwise abort() is called and this - * function will never return. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void * -bson_malloc0 (size_t num_bytes) /* IN */ -{ - void *mem = NULL; - - if (BSON_LIKELY (num_bytes)) { - if (BSON_UNLIKELY (!(mem = gMemVtable.calloc (1, num_bytes)))) { - fprintf (stderr, - "Failure to allocate memory in bson_malloc0(). errno: %d.\n", - errno); - abort (); - } - } - - return mem; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_aligned_alloc -- - * - * Allocates @num_bytes of memory with an alignment of @alignment and - * returns a pointer to it. If malloc failed to allocate the memory, - * abort() is called. - * - * Libbson does not try to handle OOM conditions as it is beyond the - * scope of this library to handle so appropriately. - * - * Parameters: - * @alignment: The alignment of the allocated bytes of memory. - * @num_bytes: The number of bytes to allocate. - * - * Returns: - * A pointer if successful; otherwise abort() is called and this - * function will never return. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void * -bson_aligned_alloc (size_t alignment /* IN */, size_t num_bytes /* IN */) -{ - void *mem = NULL; - - if (BSON_LIKELY (num_bytes)) { - if (BSON_UNLIKELY ( - !(mem = gMemVtable.aligned_alloc (alignment, num_bytes)))) { - fprintf (stderr, - "Failure to allocate memory in bson_aligned_alloc()\n"); - abort (); - } - } - - return mem; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_aligned_alloc0 -- - * - * Like bson_aligned_alloc() except the memory is zeroed after allocation - * for convenience. - * - * Parameters: - * @alignment: The alignment of the allocated bytes of memory. - * @num_bytes: The number of bytes to allocate. - * - * Returns: - * A pointer if successful; otherwise abort() is called and this - * function will never return. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void * -bson_aligned_alloc0 (size_t alignment /* IN */, size_t num_bytes /* IN */) -{ - void *mem = NULL; - - if (BSON_LIKELY (num_bytes)) { - if (BSON_UNLIKELY ( - !(mem = gMemVtable.aligned_alloc (alignment, num_bytes)))) { - fprintf (stderr, - "Failure to allocate memory in bson_aligned_alloc0()\n"); - abort (); - } - memset (mem, 0, num_bytes); - } - - return mem; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_realloc -- - * - * This function behaves similar to realloc() except that if there is - * a failure abort() is called. - * - * Parameters: - * @mem: The memory to realloc, or NULL. - * @num_bytes: The size of the new allocation or 0 to free. - * - * Returns: - * The new allocation if successful; otherwise abort() is called and - * this function never returns. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void * -bson_realloc (void *mem, /* IN */ - size_t num_bytes) /* IN */ -{ - /* - * Not all platforms are guaranteed to free() the memory if a call to - * realloc() with a size of zero occurs. Windows, Linux, and FreeBSD do, - * however, OS X does not. - */ - if (BSON_UNLIKELY (num_bytes == 0)) { - gMemVtable.free (mem); - return NULL; - } - - mem = gMemVtable.realloc (mem, num_bytes); - - if (BSON_UNLIKELY (!mem)) { - fprintf (stderr, - "Failure to re-allocate memory in bson_realloc(). errno: %d.\n", - errno); - abort (); - } - - return mem; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_realloc_ctx -- - * - * This wraps bson_realloc and provides a compatible api for similar - * functions with a context - * - * Parameters: - * @mem: The memory to realloc, or NULL. - * @num_bytes: The size of the new allocation or 0 to free. - * @ctx: Ignored - * - * Returns: - * The new allocation if successful; otherwise abort() is called and - * this function never returns. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - - -void * -bson_realloc_ctx (void *mem, /* IN */ - size_t num_bytes, /* IN */ - void *ctx) /* IN */ -{ - BSON_UNUSED (ctx); - - return bson_realloc (mem, num_bytes); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_free -- - * - * Frees @mem using the underlying allocator. - * - * Currently, this only calls free() directly, but that is subject to - * change. - * - * Parameters: - * @mem: An allocation to free. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -bson_free (void *mem) /* IN */ -{ - gMemVtable.free (mem); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_zero_free -- - * - * Frees @mem using the underlying allocator. @size bytes of @mem will - * be zeroed before freeing the memory. This is useful in scenarios - * where @mem contains passwords or other sensitive information. - * - * Parameters: - * @mem: An allocation to free. - * @size: The number of bytes in @mem. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -bson_zero_free (void *mem, /* IN */ - size_t size) /* IN */ -{ - if (BSON_LIKELY (mem)) { - memset (mem, 0, size); - gMemVtable.free (mem); - } -} - - -static void * -_aligned_alloc_as_malloc (size_t alignment, size_t num_bytes) -{ - BSON_UNUSED (alignment); - - return gMemVtable.malloc (num_bytes); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_mem_set_vtable -- - * - * This function will change our allocation vtable. - * - * It is imperative that this is called at the beginning of the - * process before any memory has been allocated by the default - * allocator. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -bson_mem_set_vtable (const bson_mem_vtable_t *vtable) -{ - BSON_ASSERT (vtable); - - if (!vtable->malloc || !vtable->calloc || !vtable->realloc || - !vtable->free) { - fprintf (stderr, - "Failure to install BSON vtable, " - "missing functions.\n"); - return; - } - - gMemVtable = *vtable; - - // Backwards compatibility with code prior to addition of aligned_alloc. - if (!gMemVtable.aligned_alloc) { - gMemVtable.aligned_alloc = _aligned_alloc_as_malloc; - } -} - -void -bson_mem_restore_vtable (void) -{ - bson_mem_vtable_t vtable = {.malloc = malloc, - .calloc = calloc, - .realloc = realloc, - .free = free, - .aligned_alloc = _aligned_alloc_impl, - .padding = {0}}; - - bson_mem_set_vtable (&vtable); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-memory.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-memory.h deleted file mode 100644 index 99470701e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-memory.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_MEMORY_H -#define BSON_MEMORY_H - - -#include -#include - - -BSON_BEGIN_DECLS - - -typedef void *(*bson_realloc_func) (void *mem, size_t num_bytes, void *ctx); - - -typedef struct _bson_mem_vtable_t { - void *(*malloc) (size_t num_bytes); - void *(*calloc) (size_t n_members, size_t num_bytes); - void *(*realloc) (void *mem, size_t num_bytes); - void (*free) (void *mem); - void *(*aligned_alloc) (size_t alignment, size_t num_bytes); - void *padding[3]; -} bson_mem_vtable_t; - - -BSON_EXPORT (void) -bson_mem_set_vtable (const bson_mem_vtable_t *vtable); -BSON_EXPORT (void) -bson_mem_restore_vtable (void); -BSON_EXPORT (void *) -bson_malloc (size_t num_bytes); -BSON_EXPORT (void *) -bson_malloc0 (size_t num_bytes); -BSON_EXPORT (void *) -bson_aligned_alloc (size_t alignment, size_t num_bytes); -BSON_EXPORT (void *) -bson_aligned_alloc0 (size_t alignment, size_t num_bytes); -BSON_EXPORT (void *) -bson_realloc (void *mem, size_t num_bytes); -BSON_EXPORT (void *) -bson_realloc_ctx (void *mem, size_t num_bytes, void *ctx); -BSON_EXPORT (void) -bson_free (void *mem); -BSON_EXPORT (void) -bson_zero_free (void *mem, size_t size); - - -#define BSON_ALIGNED_ALLOC(T) \ - ((T *) (bson_aligned_alloc (BSON_ALIGNOF (T), sizeof (T)))) -#define BSON_ALIGNED_ALLOC0(T) \ - ((T *) (bson_aligned_alloc0 (BSON_ALIGNOF (T), sizeof (T)))) - - -BSON_END_DECLS - - -#endif /* BSON_MEMORY_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-oid.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-oid.c deleted file mode 100644 index 8834d7d36..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-oid.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include -#include -#include -#include - -#include -#include -#include - - -/* - * This table contains an array of two character pairs for every possible - * uint8_t. It is used as a lookup table when encoding a bson_oid_t - * to hex formatted ASCII. Performing two characters at a time roughly - * reduces the number of operations by one-half. - */ -BSON_MAYBE_UNUSED static const uint16_t gHexCharPairs[] = { -#if BSON_BYTE_ORDER == BSON_BIG_ENDIAN - 12336, 12337, 12338, 12339, 12340, 12341, 12342, 12343, 12344, 12345, 12385, - 12386, 12387, 12388, 12389, 12390, 12592, 12593, 12594, 12595, 12596, 12597, - 12598, 12599, 12600, 12601, 12641, 12642, 12643, 12644, 12645, 12646, 12848, - 12849, 12850, 12851, 12852, 12853, 12854, 12855, 12856, 12857, 12897, 12898, - 12899, 12900, 12901, 12902, 13104, 13105, 13106, 13107, 13108, 13109, 13110, - 13111, 13112, 13113, 13153, 13154, 13155, 13156, 13157, 13158, 13360, 13361, - 13362, 13363, 13364, 13365, 13366, 13367, 13368, 13369, 13409, 13410, 13411, - 13412, 13413, 13414, 13616, 13617, 13618, 13619, 13620, 13621, 13622, 13623, - 13624, 13625, 13665, 13666, 13667, 13668, 13669, 13670, 13872, 13873, 13874, - 13875, 13876, 13877, 13878, 13879, 13880, 13881, 13921, 13922, 13923, 13924, - 13925, 13926, 14128, 14129, 14130, 14131, 14132, 14133, 14134, 14135, 14136, - 14137, 14177, 14178, 14179, 14180, 14181, 14182, 14384, 14385, 14386, 14387, - 14388, 14389, 14390, 14391, 14392, 14393, 14433, 14434, 14435, 14436, 14437, - 14438, 14640, 14641, 14642, 14643, 14644, 14645, 14646, 14647, 14648, 14649, - 14689, 14690, 14691, 14692, 14693, 14694, 24880, 24881, 24882, 24883, 24884, - 24885, 24886, 24887, 24888, 24889, 24929, 24930, 24931, 24932, 24933, 24934, - 25136, 25137, 25138, 25139, 25140, 25141, 25142, 25143, 25144, 25145, 25185, - 25186, 25187, 25188, 25189, 25190, 25392, 25393, 25394, 25395, 25396, 25397, - 25398, 25399, 25400, 25401, 25441, 25442, 25443, 25444, 25445, 25446, 25648, - 25649, 25650, 25651, 25652, 25653, 25654, 25655, 25656, 25657, 25697, 25698, - 25699, 25700, 25701, 25702, 25904, 25905, 25906, 25907, 25908, 25909, 25910, - 25911, 25912, 25913, 25953, 25954, 25955, 25956, 25957, 25958, 26160, 26161, - 26162, 26163, 26164, 26165, 26166, 26167, 26168, 26169, 26209, 26210, 26211, - 26212, 26213, 26214 -#else - 12336, 12592, 12848, 13104, 13360, 13616, 13872, 14128, 14384, 14640, 24880, - 25136, 25392, 25648, 25904, 26160, 12337, 12593, 12849, 13105, 13361, 13617, - 13873, 14129, 14385, 14641, 24881, 25137, 25393, 25649, 25905, 26161, 12338, - 12594, 12850, 13106, 13362, 13618, 13874, 14130, 14386, 14642, 24882, 25138, - 25394, 25650, 25906, 26162, 12339, 12595, 12851, 13107, 13363, 13619, 13875, - 14131, 14387, 14643, 24883, 25139, 25395, 25651, 25907, 26163, 12340, 12596, - 12852, 13108, 13364, 13620, 13876, 14132, 14388, 14644, 24884, 25140, 25396, - 25652, 25908, 26164, 12341, 12597, 12853, 13109, 13365, 13621, 13877, 14133, - 14389, 14645, 24885, 25141, 25397, 25653, 25909, 26165, 12342, 12598, 12854, - 13110, 13366, 13622, 13878, 14134, 14390, 14646, 24886, 25142, 25398, 25654, - 25910, 26166, 12343, 12599, 12855, 13111, 13367, 13623, 13879, 14135, 14391, - 14647, 24887, 25143, 25399, 25655, 25911, 26167, 12344, 12600, 12856, 13112, - 13368, 13624, 13880, 14136, 14392, 14648, 24888, 25144, 25400, 25656, 25912, - 26168, 12345, 12601, 12857, 13113, 13369, 13625, 13881, 14137, 14393, 14649, - 24889, 25145, 25401, 25657, 25913, 26169, 12385, 12641, 12897, 13153, 13409, - 13665, 13921, 14177, 14433, 14689, 24929, 25185, 25441, 25697, 25953, 26209, - 12386, 12642, 12898, 13154, 13410, 13666, 13922, 14178, 14434, 14690, 24930, - 25186, 25442, 25698, 25954, 26210, 12387, 12643, 12899, 13155, 13411, 13667, - 13923, 14179, 14435, 14691, 24931, 25187, 25443, 25699, 25955, 26211, 12388, - 12644, 12900, 13156, 13412, 13668, 13924, 14180, 14436, 14692, 24932, 25188, - 25444, 25700, 25956, 26212, 12389, 12645, 12901, 13157, 13413, 13669, 13925, - 14181, 14437, 14693, 24933, 25189, 25445, 25701, 25957, 26213, 12390, 12646, - 12902, 13158, 13414, 13670, 13926, 14182, 14438, 14694, 24934, 25190, 25446, - 25702, 25958, 26214 -#endif -}; - - -void -bson_oid_init_sequence (bson_oid_t *oid, /* OUT */ - bson_context_t *context) /* IN */ -{ - uint32_t now = (uint32_t) (time (NULL)); - - if (!context) { - context = bson_context_get_default (); - } - - now = BSON_UINT32_TO_BE (now); - memcpy (&oid->bytes[0], &now, sizeof (now)); - _bson_context_set_oid_seq64 (context, oid); -} - - -void -bson_oid_init (bson_oid_t *oid, /* OUT */ - bson_context_t *context) /* IN */ -{ - uint32_t now = (uint32_t) (time (NULL)); - - BSON_ASSERT (oid); - - if (!context) { - context = bson_context_get_default (); - } - - now = BSON_UINT32_TO_BE (now); - memcpy (&oid->bytes[0], &now, sizeof (now)); - _bson_context_set_oid_rand (context, oid); - _bson_context_set_oid_seq32 (context, oid); -} - - -void -bson_oid_init_from_data (bson_oid_t *oid, /* OUT */ - const uint8_t *data) /* IN */ -{ - BSON_ASSERT (oid); - BSON_ASSERT (data); - - memcpy (oid, data, 12); -} - - -void -bson_oid_init_from_string (bson_oid_t *oid, /* OUT */ - const char *str) /* IN */ -{ - BSON_ASSERT (oid); - BSON_ASSERT (str); - - bson_oid_init_from_string_unsafe (oid, str); -} - - -time_t -bson_oid_get_time_t (const bson_oid_t *oid) /* IN */ -{ - BSON_ASSERT (oid); - - return bson_oid_get_time_t_unsafe (oid); -} - - -void -bson_oid_to_string (const bson_oid_t *oid, /* IN */ - char str[BSON_ENSURE_ARRAY_PARAM_SIZE (25)]) /* OUT */ -{ -#if !defined(__i386__) && !defined(__x86_64__) && !defined(_M_IX86) && \ - !defined(_M_X64) - BSON_ASSERT (oid); - BSON_ASSERT (str); - - bson_snprintf (str, - 25, - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - oid->bytes[0], - oid->bytes[1], - oid->bytes[2], - oid->bytes[3], - oid->bytes[4], - oid->bytes[5], - oid->bytes[6], - oid->bytes[7], - oid->bytes[8], - oid->bytes[9], - oid->bytes[10], - oid->bytes[11]); -#else - uint16_t *dst; - uint8_t *id = (uint8_t *) oid; - - BSON_ASSERT (oid); - BSON_ASSERT (str); - - dst = (uint16_t *) (void *) str; - dst[0] = gHexCharPairs[id[0]]; - dst[1] = gHexCharPairs[id[1]]; - dst[2] = gHexCharPairs[id[2]]; - dst[3] = gHexCharPairs[id[3]]; - dst[4] = gHexCharPairs[id[4]]; - dst[5] = gHexCharPairs[id[5]]; - dst[6] = gHexCharPairs[id[6]]; - dst[7] = gHexCharPairs[id[7]]; - dst[8] = gHexCharPairs[id[8]]; - dst[9] = gHexCharPairs[id[9]]; - dst[10] = gHexCharPairs[id[10]]; - dst[11] = gHexCharPairs[id[11]]; - str[24] = '\0'; -#endif -} - - -uint32_t -bson_oid_hash (const bson_oid_t *oid) /* IN */ -{ - BSON_ASSERT (oid); - - return bson_oid_hash_unsafe (oid); -} - - -int -bson_oid_compare (const bson_oid_t *oid1, /* IN */ - const bson_oid_t *oid2) /* IN */ -{ - BSON_ASSERT (oid1); - BSON_ASSERT (oid2); - - return bson_oid_compare_unsafe (oid1, oid2); -} - - -bool -bson_oid_equal (const bson_oid_t *oid1, /* IN */ - const bson_oid_t *oid2) /* IN */ -{ - BSON_ASSERT (oid1); - BSON_ASSERT (oid2); - - return bson_oid_equal_unsafe (oid1, oid2); -} - - -void -bson_oid_copy (const bson_oid_t *src, /* IN */ - bson_oid_t *dst) /* OUT */ -{ - BSON_ASSERT (src); - BSON_ASSERT (dst); - - bson_oid_copy_unsafe (src, dst); -} - - -bool -bson_oid_is_valid (const char *str, /* IN */ - size_t length) /* IN */ -{ - size_t i; - - BSON_ASSERT (str); - - if ((length == 25) && (str[24] == '\0')) { - length = 24; - } - - if (length == 24) { - for (i = 0; i < length; i++) { - switch (str[i]) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - break; - default: - return false; - } - } - return true; - } - - return false; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-private.h deleted file mode 100644 index 121a5ff2f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-private.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_PRIVATE_H -#define BSON_PRIVATE_H - - -#include -#include -#include - - -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -#define BEGIN_IGNORE_DEPRECATIONS \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#define END_IGNORE_DEPRECATIONS _Pragma ("GCC diagnostic pop") -#elif defined(__clang__) -#define BEGIN_IGNORE_DEPRECATIONS \ - _Pragma ("clang diagnostic push") \ - _Pragma ("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#define END_IGNORE_DEPRECATIONS _Pragma ("clang diagnostic pop") -#else -#define BEGIN_IGNORE_DEPRECATIONS -#define END_IGNORE_DEPRECATIONS -#endif - - -BSON_BEGIN_DECLS - - -typedef enum { - BSON_FLAG_NONE = 0, - BSON_FLAG_INLINE = (1 << 0), - BSON_FLAG_STATIC = (1 << 1), - BSON_FLAG_RDONLY = (1 << 2), - BSON_FLAG_CHILD = (1 << 3), - BSON_FLAG_IN_CHILD = (1 << 4), - BSON_FLAG_NO_FREE = (1 << 5), -} bson_flags_t; - - -#ifdef BSON_MEMCHECK -#define BSON_INLINE_DATA_SIZE (120 - sizeof (char *)) -#else -#define BSON_INLINE_DATA_SIZE 120 -#endif - - -BSON_ALIGNED_BEGIN (128) -typedef struct { - bson_flags_t flags; - uint32_t len; -#ifdef BSON_MEMCHECK - char *canary; -#endif - uint8_t data[BSON_INLINE_DATA_SIZE]; -} bson_impl_inline_t BSON_ALIGNED_END (128); - - -BSON_STATIC_ASSERT2 (impl_inline_t, sizeof (bson_impl_inline_t) == 128); - - -BSON_ALIGNED_BEGIN (128) -typedef struct { - bson_flags_t flags; /* flags describing the bson_t */ - /* len is part of the public bson_t declaration. It is not - * exposed through an accessor function. Plus, it's redundant since - * BSON self describes the length in the first four bytes of the - * buffer. */ - uint32_t len; /* length of bson document in bytes */ - bson_t *parent; /* parent bson if a child */ - uint32_t depth; /* Subdocument depth. */ - uint8_t **buf; /* pointer to buffer pointer */ - size_t *buflen; /* pointer to buffer length */ - size_t offset; /* our offset inside *buf */ - uint8_t *alloc; /* buffer that we own. */ - size_t alloclen; /* length of buffer that we own. */ - bson_realloc_func realloc; /* our realloc implementation */ - void *realloc_func_ctx; /* context for our realloc func */ -} bson_impl_alloc_t BSON_ALIGNED_END (128); - - -BSON_STATIC_ASSERT2 (impl_alloc_t, sizeof (bson_impl_alloc_t) <= 128); - - -#define BSON_REGEX_OPTIONS_SORTED "ilmsux" - -BSON_END_DECLS - - -#endif /* BSON_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-string.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-string.c deleted file mode 100644 index 958fd1066..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-string.c +++ /dev/null @@ -1,821 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include - -#include -#include -#include -#include -#include - -#ifdef BSON_HAVE_STRINGS_H -#include -#else -#include -#endif - -/* - *-------------------------------------------------------------------------- - * - * bson_string_new -- - * - * Create a new bson_string_t. - * - * bson_string_t is a power-of-2 allocation growing string. Every - * time data is appended the next power of two size is chosen for - * the allocation. Pretty standard stuff. - * - * It is UTF-8 aware through the use of bson_string_append_unichar(). - * The proper UTF-8 character sequence will be used. - * - * Parameters: - * @str: a string to copy or NULL. - * - * Returns: - * A newly allocated bson_string_t that should be freed with - * bson_string_free(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bson_string_t * -bson_string_new (const char *str) /* IN */ -{ - bson_string_t *ret; - - ret = bson_malloc0 (sizeof *ret); - ret->len = str ? (int) strlen (str) : 0; - ret->alloc = ret->len + 1; - - if (!bson_is_power_of_two (ret->alloc)) { - ret->alloc = (uint32_t) bson_next_power_of_two ((size_t) ret->alloc); - } - - BSON_ASSERT (ret->alloc >= 1); - - ret->str = bson_malloc (ret->alloc); - - if (str) { - memcpy (ret->str, str, ret->len); - } - - ret->str[ret->len] = '\0'; - - return ret; -} - -char * -bson_string_free (bson_string_t *string, /* IN */ - bool free_segment) /* IN */ -{ - char *ret = NULL; - - if (!string) { - return NULL; - } - - if (!free_segment) { - ret = string->str; - } else { - bson_free (string->str); - } - - bson_free (string); - - return ret; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_string_append -- - * - * Append the UTF-8 string @str to @string. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -bson_string_append (bson_string_t *string, /* IN */ - const char *str) /* IN */ -{ - uint32_t len; - - BSON_ASSERT (string); - BSON_ASSERT (str); - - len = (uint32_t) strlen (str); - - if ((string->alloc - string->len - 1) < len) { - string->alloc += len; - if (!bson_is_power_of_two (string->alloc)) { - string->alloc = - (uint32_t) bson_next_power_of_two ((size_t) string->alloc); - } - string->str = bson_realloc (string->str, string->alloc); - } - - memcpy (string->str + string->len, str, len); - string->len += len; - string->str[string->len] = '\0'; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_string_append_c -- - * - * Append the ASCII character @c to @string. - * - * Do not use this if you are working with UTF-8 sequences, - * use bson_string_append_unichar(). - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -bson_string_append_c (bson_string_t *string, /* IN */ - char c) /* IN */ -{ - char cc[2]; - - BSON_ASSERT (string); - - if (BSON_UNLIKELY (string->alloc == (string->len + 1))) { - cc[0] = c; - cc[1] = '\0'; - bson_string_append (string, cc); - return; - } - - string->str[string->len++] = c; - string->str[string->len] = '\0'; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_string_append_unichar -- - * - * Append the bson_unichar_t @unichar to the string @string. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -bson_string_append_unichar (bson_string_t *string, /* IN */ - bson_unichar_t unichar) /* IN */ -{ - uint32_t len; - char str[8]; - - BSON_ASSERT (string); - BSON_ASSERT (unichar); - - bson_utf8_from_unichar (unichar, str, &len); - - if (len <= 6) { - str[len] = '\0'; - bson_string_append (string, str); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_string_append_printf -- - * - * Format a string according to @format and append it to @string. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -bson_string_append_printf (bson_string_t *string, const char *format, ...) -{ - va_list args; - char *ret; - - BSON_ASSERT (string); - BSON_ASSERT (format); - - va_start (args, format); - ret = bson_strdupv_printf (format, args); - va_end (args); - bson_string_append (string, ret); - bson_free (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_string_truncate -- - * - * Truncate the string @string to @len bytes. - * - * The underlying memory will be released via realloc() down to - * the minimum required size specified by @len. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -bson_string_truncate (bson_string_t *string, /* IN */ - uint32_t len) /* IN */ -{ - uint32_t alloc; - - BSON_ASSERT (string); - BSON_ASSERT (len < INT_MAX); - - alloc = len + 1; - - if (alloc < 16) { - alloc = 16; - } - - if (!bson_is_power_of_two (alloc)) { - alloc = (uint32_t) bson_next_power_of_two ((size_t) alloc); - } - - string->str = bson_realloc (string->str, alloc); - string->alloc = alloc; - string->len = len; - - string->str[string->len] = '\0'; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_strdup -- - * - * Portable strdup(). - * - * Returns: - * A newly allocated string that should be freed with bson_free(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -char * -bson_strdup (const char *str) /* IN */ -{ - long len; - char *out; - - if (!str) { - return NULL; - } - - len = (long) strlen (str); - out = bson_malloc (len + 1); - - if (!out) { - return NULL; - } - - memcpy (out, str, len + 1); - - return out; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_strdupv_printf -- - * - * Like bson_strdup_printf() but takes a va_list. - * - * Returns: - * A newly allocated string that should be freed with bson_free(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -char * -bson_strdupv_printf (const char *format, /* IN */ - va_list args) /* IN */ -{ - va_list my_args; - char *buf; - int len = 32; - int n; - - BSON_ASSERT (format); - - buf = bson_malloc0 (len); - - while (true) { - va_copy (my_args, args); - n = bson_vsnprintf (buf, len, format, my_args); - va_end (my_args); - - if (n > -1 && n < len) { - return buf; - } - - if (n > -1) { - len = n + 1; - } else { - len *= 2; - } - - buf = bson_realloc (buf, len); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_strdup_printf -- - * - * Convenience function that formats a string according to @format - * and returns a copy of it. - * - * Returns: - * A newly created string that should be freed with bson_free(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -char * -bson_strdup_printf (const char *format, /* IN */ - ...) /* IN */ -{ - va_list args; - char *ret; - - BSON_ASSERT (format); - - va_start (args, format); - ret = bson_strdupv_printf (format, args); - va_end (args); - - return ret; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_strndup -- - * - * A portable strndup(). - * - * Returns: - * A newly allocated string that should be freed with bson_free(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -char * -bson_strndup (const char *str, /* IN */ - size_t n_bytes) /* IN */ -{ - char *ret; - - BSON_ASSERT (str); - - ret = bson_malloc (n_bytes + 1); - bson_strncpy (ret, str, n_bytes + 1); - - return ret; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_strfreev -- - * - * Frees each string in a NULL terminated array of strings. - * This also frees the underlying array. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -bson_strfreev (char **str) /* IN */ -{ - if (str) { - for (char **ptr = str; *ptr != NULL; ++ptr) { - bson_free (*ptr); - } - - bson_free (str); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_strnlen -- - * - * A portable strnlen(). - * - * Returns: - * The length of @s up to @maxlen. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -size_t -bson_strnlen (const char *s, /* IN */ - size_t maxlen) /* IN */ -{ -#ifdef BSON_HAVE_STRNLEN - return strnlen (s, maxlen); -#else - size_t i; - - for (i = 0; i < maxlen; i++) { - if (s[i] == '\0') { - return i; - } - } - - return maxlen; -#endif -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_strncpy -- - * - * A portable strncpy. - * - * Copies @src into @dst, which must be @size bytes or larger. - * The result is guaranteed to be \0 terminated. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -bson_strncpy (char *dst, /* IN */ - const char *src, /* IN */ - size_t size) /* IN */ -{ - if (size == 0) { - return; - } - -/* Prefer strncpy_s for MSVC, or strlcpy, which has additional checks and only - * adds one trailing \0 */ -#ifdef _MSC_VER - strncpy_s (dst, size, src, _TRUNCATE); -#elif defined(BSON_HAVE_STRLCPY) - strlcpy (dst, src, size); -#else - strncpy (dst, src, size); - dst[size - 1] = '\0'; -#endif -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_vsnprintf -- - * - * A portable vsnprintf. - * - * If more than @size bytes are required (exluding the null byte), - * then @size bytes will be written to @string and the return value - * is the number of bytes required. - * - * This function will always return a NULL terminated string. - * - * Returns: - * The number of bytes required for @format excluding the null byte. - * - * Side effects: - * @str is initialized with the formatted string. - * - *-------------------------------------------------------------------------- - */ - -int -bson_vsnprintf (char *str, /* IN */ - size_t size, /* IN */ - const char *format, /* IN */ - va_list ap) /* IN */ -{ -#ifdef _MSC_VER - int r = -1; - - BSON_ASSERT (str); - - if (size == 0) { - return 0; - } - - r = _vsnprintf_s (str, size, _TRUNCATE, format, ap); - if (r == -1) { - r = _vscprintf (format, ap); - } - - str[size - 1] = '\0'; - - return r; -#else - int r; - - BSON_ASSERT (str); - - if (size == 0) { - return 0; - } - - r = vsnprintf (str, size, format, ap); - str[size - 1] = '\0'; - return r; -#endif -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_snprintf -- - * - * A portable snprintf. - * - * If @format requires more than @size bytes, then @size bytes are - * written and the result is the number of bytes required (excluding - * the null byte). - * - * This function will always return a NULL terminated string. - * - * Returns: - * The number of bytes required for @format. - * - * Side effects: - * @str is initialized. - * - *-------------------------------------------------------------------------- - */ - -int -bson_snprintf (char *str, /* IN */ - size_t size, /* IN */ - const char *format, /* IN */ - ...) -{ - int r; - va_list ap; - - BSON_ASSERT (str); - - va_start (ap, format); - r = bson_vsnprintf (str, size, format, ap); - va_end (ap); - - return r; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_ascii_strtoll -- - * - * A portable strtoll. - * - * Convert a string to a 64-bit signed integer according to the given - * @base, which must be 16, 10, or 8. Leading whitespace will be ignored. - * - * If base is 0 is passed in, the base is inferred from the string's - * leading characters. Base-16 numbers start with "0x" or "0X", base-8 - * numbers start with "0", base-10 numbers start with a digit from 1 to 9. - * - * If @e is not NULL, it will be assigned the address of the first invalid - * character of @s, or its null terminating byte if the entire string was - * valid. - * - * If an invalid value is encountered, errno will be set to EINVAL and - * zero will be returned. If the number is out of range, errno is set to - * ERANGE and LLONG_MAX or LLONG_MIN is returned. - * - * Returns: - * The result of the conversion. - * - * Side effects: - * errno will be set on error. - * - *-------------------------------------------------------------------------- - */ - -int64_t -bson_ascii_strtoll (const char *s, char **e, int base) -{ - char *tok = (char *) s; - char *digits_start; - char c; - int64_t number = 0; - int64_t sign = 1; - int64_t cutoff; - int64_t cutlim; - - errno = 0; - - if (!s) { - errno = EINVAL; - return 0; - } - - c = *tok; - - while (bson_isspace (c)) { - c = *++tok; - } - - if (c == '-') { - sign = -1; - c = *++tok; - } else if (c == '+') { - c = *++tok; - } else if (!isdigit (c)) { - errno = EINVAL; - return 0; - } - - /* from here down, inspired by NetBSD's strtoll */ - if ((base == 0 || base == 16) && c == '0' && - (tok[1] == 'x' || tok[1] == 'X')) { - tok += 2; - c = *tok; - base = 16; - } - - if (base == 0) { - base = c == '0' ? 8 : 10; - } - - /* Cutoff is the greatest magnitude we'll be able to multiply by base without - * range error. If the current number is past cutoff and we see valid digit, - * fail. If the number is *equal* to cutoff, then the next digit must be less - * than cutlim, otherwise fail. - */ - cutoff = sign == -1 ? INT64_MIN : INT64_MAX; - cutlim = (int) (cutoff % base); - cutoff /= base; - if (sign == -1) { - if (cutlim > 0) { - cutlim -= base; - cutoff += 1; - } - cutlim = -cutlim; - } - - digits_start = tok; - - while ((c = *tok)) { - if (isdigit (c)) { - c -= '0'; - } else if (isalpha (c)) { - c -= isupper (c) ? 'A' - 10 : 'a' - 10; - } else { - /* end of number string */ - break; - } - - if (c >= base) { - break; - } - - if (sign == -1) { - if (number < cutoff || (number == cutoff && c > cutlim)) { - number = INT64_MIN; - errno = ERANGE; - break; - } else { - number *= base; - number -= c; - } - } else { - if (number > cutoff || (number == cutoff && c > cutlim)) { - number = INT64_MAX; - errno = ERANGE; - break; - } else { - number *= base; - number += c; - } - } - - tok++; - } - - /* did we parse any digits at all? */ - if (e != NULL && tok > digits_start) { - *e = tok; - } - - return number; -} - - -int -bson_strcasecmp (const char *s1, const char *s2) -{ -#ifdef BSON_OS_WIN32 - return _stricmp (s1, s2); -#else - return strcasecmp (s1, s2); -#endif -} - - -bool -bson_isspace (int c) -{ - return c >= -1 && c <= 255 && isspace (c); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-string.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-string.h deleted file mode 100644 index 467a4567c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-string.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_STRING_H -#define BSON_STRING_H - - -#include - -#include -#include - - -BSON_BEGIN_DECLS - - -typedef struct { - char *str; - uint32_t len; - uint32_t alloc; -} bson_string_t; - - -BSON_EXPORT (bson_string_t *) -bson_string_new (const char *str); -BSON_EXPORT (char *) -bson_string_free (bson_string_t *string, bool free_segment); -BSON_EXPORT (void) -bson_string_append (bson_string_t *string, const char *str); -BSON_EXPORT (void) -bson_string_append_c (bson_string_t *string, char str); -BSON_EXPORT (void) -bson_string_append_unichar (bson_string_t *string, bson_unichar_t unichar); -BSON_EXPORT (void) -bson_string_append_printf (bson_string_t *string, const char *format, ...) - BSON_GNUC_PRINTF (2, 3); -BSON_EXPORT (void) -bson_string_truncate (bson_string_t *string, uint32_t len); -BSON_EXPORT (char *) -bson_strdup (const char *str); -BSON_EXPORT (char *) -bson_strdup_printf (const char *format, ...) BSON_GNUC_PRINTF (1, 2); -BSON_EXPORT (char *) -bson_strdupv_printf (const char *format, va_list args) BSON_GNUC_PRINTF (1, 0); -BSON_EXPORT (char *) -bson_strndup (const char *str, size_t n_bytes); -BSON_EXPORT (void) -bson_strncpy (char *dst, const char *src, size_t size); -BSON_EXPORT (int) -bson_vsnprintf (char *str, size_t size, const char *format, va_list ap) - BSON_GNUC_PRINTF (3, 0); -BSON_EXPORT (int) -bson_snprintf (char *str, size_t size, const char *format, ...) - BSON_GNUC_PRINTF (3, 4); -BSON_EXPORT (void) -bson_strfreev (char **strv); -BSON_EXPORT (size_t) -bson_strnlen (const char *s, size_t maxlen); -BSON_EXPORT (int64_t) -bson_ascii_strtoll (const char *str, char **endptr, int base); -BSON_EXPORT (int) -bson_strcasecmp (const char *s1, const char *s2); -BSON_EXPORT (bool) -bson_isspace (int c); - - -BSON_END_DECLS - - -#endif /* BSON_STRING_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-timegm.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-timegm.c deleted file mode 100644 index cea7b2f51..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-timegm.c +++ /dev/null @@ -1,815 +0,0 @@ -/* -** The original version of this file is in the public domain, so clarified as of -** 1996-06-05 by Arthur David Olson. -*/ - -/* -** Leap second handling from Bradley White. -** POSIX-style TZ environment variable handling from Guy Harris. -** Updated to use int64_t's instead of system-dependent definitions of int64_t -** and struct tm by A. Jesse Jiryu Davis for MongoDB, Inc. -*/ - -#include -#include -#include - -#include "errno.h" -#include "string.h" -#include /* for INT64_MAX and INT64_MIN */ - -/* Unlike 's isdigit, this also works if c < 0 | c > UCHAR_MAX. */ -#define is_digit(c) ((unsigned) (c) - '0' <= 9) - -#if 2 < __GNUC__ + (96 <= __GNUC_MINOR__) -#define ATTRIBUTE_CONST __attribute__ ((const)) -#define ATTRIBUTE_PURE __attribute__ ((__pure__)) -#define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) -#else -#define ATTRIBUTE_CONST /* empty */ -#define ATTRIBUTE_PURE /* empty */ -#define ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - -#if !defined _Noreturn && \ - (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112) -#if 2 < __GNUC__ + (8 <= __GNUC_MINOR__) -#define _Noreturn __attribute__ ((__noreturn__)) -#else -#define _Noreturn -#endif -#endif - -#if !defined(__STDC_VERSION__) && !defined restrict -#define restrict /* empty */ -#endif - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunknown-pragmas" -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wshift-negative-value" -#endif - -/* The minimum and maximum finite time values. */ -static int64_t const time_t_min = INT64_MIN; -static int64_t const time_t_max = INT64_MAX; - -#ifdef __clang__ -#pragma clang diagnostic pop -#pragma clang diagnostic pop -#endif - -#ifndef TZ_MAX_TIMES -#define TZ_MAX_TIMES 2000 -#endif /* !defined TZ_MAX_TIMES */ - -#ifndef TZ_MAX_TYPES -/* This must be at least 17 for Europe/Samara and Europe/Vilnius. */ -#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ -#endif /* !defined TZ_MAX_TYPES */ - -#ifndef TZ_MAX_CHARS -#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ - /* (limited by what unsigned chars can hold) */ -#endif /* !defined TZ_MAX_CHARS */ - -#ifndef TZ_MAX_LEAPS -#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ -#endif /* !defined TZ_MAX_LEAPS */ - -#define SECSPERMIN 60 -#define MINSPERHOUR 60 -#define HOURSPERDAY 24 -#define DAYSPERWEEK 7 -#define DAYSPERNYEAR 365 -#define DAYSPERLYEAR 366 -#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) -#define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY) -#define MONSPERYEAR 12 - -#define TM_SUNDAY 0 -#define TM_MONDAY 1 -#define TM_TUESDAY 2 -#define TM_WEDNESDAY 3 -#define TM_THURSDAY 4 -#define TM_FRIDAY 5 -#define TM_SATURDAY 6 - -#define TM_JANUARY 0 -#define TM_FEBRUARY 1 -#define TM_MARCH 2 -#define TM_APRIL 3 -#define TM_MAY 4 -#define TM_JUNE 5 -#define TM_JULY 6 -#define TM_AUGUST 7 -#define TM_SEPTEMBER 8 -#define TM_OCTOBER 9 -#define TM_NOVEMBER 10 -#define TM_DECEMBER 11 - -#define TM_YEAR_BASE 1900 - -#define EPOCH_YEAR 1970 -#define EPOCH_WDAY TM_THURSDAY - -#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) - -/* -** Since everything in isleap is modulo 400 (or a factor of 400), we know that -** isleap(y) == isleap(y % 400) -** and so -** isleap(a + b) == isleap((a + b) % 400) -** or -** isleap(a + b) == isleap(a % 400 + b % 400) -** This is true even if % means modulo rather than Fortran remainder -** (which is allowed by C89 but not C99). -** We use this to avoid addition overflow problems. -*/ - -#define isleap_sum(a, b) isleap ((a) % 400 + (b) % 400) - -#ifndef TZ_ABBR_MAX_LEN -#define TZ_ABBR_MAX_LEN 16 -#endif /* !defined TZ_ABBR_MAX_LEN */ - -#ifndef TZ_ABBR_CHAR_SET -#define TZ_ABBR_CHAR_SET \ - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._" -#endif /* !defined TZ_ABBR_CHAR_SET */ - -#ifndef TZ_ABBR_ERR_CHAR -#define TZ_ABBR_ERR_CHAR '_' -#endif /* !defined TZ_ABBR_ERR_CHAR */ - -#ifndef WILDABBR -/* -** Someone might make incorrect use of a time zone abbreviation: -** 1. They might reference tzname[0] before calling tzset (explicitly -** or implicitly). -** 2. They might reference tzname[1] before calling tzset (explicitly -** or implicitly). -** 3. They might reference tzname[1] after setting to a time zone -** in which Daylight Saving Time is never observed. -** 4. They might reference tzname[0] after setting to a time zone -** in which Standard Time is never observed. -** 5. They might reference tm.TM_ZONE after calling offtime. -** What's best to do in the above cases is open to debate; -** for now, we just set things up so that in any of the five cases -** WILDABBR is used. Another possibility: initialize tzname[0] to the -** string "tzname[0] used before set", and similarly for the other cases. -** And another: initialize tzname[0] to "ERA", with an explanation in the -** manual page of what this "time zone abbreviation" means (doing this so -** that tzname[0] has the "normal" length of three characters). -*/ -#define WILDABBR " " -#endif /* !defined WILDABBR */ - -#ifdef TM_ZONE -static const char wildabbr[] = WILDABBR; -static const char gmt[] = "GMT"; -#endif - -struct ttinfo { /* time type information */ - int_fast32_t tt_gmtoff; /* UT offset in seconds */ - int tt_isdst; /* used to set tm_isdst */ - int tt_abbrind; /* abbreviation list index */ - int tt_ttisstd; /* true if transition is std time */ - int tt_ttisgmt; /* true if transition is UT */ -}; - -struct lsinfo { /* leap second information */ - int64_t ls_trans; /* transition time */ - int_fast64_t ls_corr; /* correction to apply */ -}; - -#define BIGGEST(a, b) (((a) > (b)) ? (a) : (b)) - -#ifdef TZNAME_MAX -#define MY_TZNAME_MAX TZNAME_MAX -#endif /* defined TZNAME_MAX */ -#ifndef TZNAME_MAX -#define MY_TZNAME_MAX 255 -#endif /* !defined TZNAME_MAX */ - -struct state { - int leapcnt; - int timecnt; - int typecnt; - int charcnt; - int goback; - int goahead; - int64_t ats[TZ_MAX_TIMES]; - unsigned char types[TZ_MAX_TIMES]; - struct ttinfo ttis[TZ_MAX_TYPES]; - char chars[BIGGEST (TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))]; - struct lsinfo lsis[TZ_MAX_LEAPS]; - int defaulttype; /* for early times or if no transitions */ -}; - -struct rule { - int r_type; /* type of rule--see below */ - int r_day; /* day number of rule */ - int r_week; /* week number of rule */ - int r_mon; /* month number of rule */ - int_fast32_t r_time; /* transition time of rule */ -}; - -#define JULIAN_DAY 0 /* Jn - Julian day */ -#define DAY_OF_YEAR 1 /* n - day of year */ -#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ - -/* -** Prototypes for static functions. -*/ - -static void -gmtload (struct state *const sp); -static struct bson_tm * -gmtsub (const int64_t *const timep, - const int_fast32_t offset, - struct bson_tm *const tmp); -static int64_t -increment_overflow (int64_t *const ip, int64_t j); -static int64_t -leaps_thru_end_of (const int64_t y) ATTRIBUTE_PURE; -static int64_t -increment_overflow32 (int_fast32_t *const lp, int64_t const m); -static int64_t -normalize_overflow32 (int_fast32_t *const tensptr, - int64_t *const unitsptr, - const int64_t base); -static int64_t -normalize_overflow (int64_t *const tensptr, - int64_t *const unitsptr, - const int64_t base); -static int64_t -time1 (struct bson_tm *const tmp, - struct bson_tm *(*const funcp) (const int64_t *, - int_fast32_t, - struct bson_tm *), - const int_fast32_t offset); -static int64_t -time2 (struct bson_tm *const tmp, - struct bson_tm *(*const funcp) (const int64_t *, - int_fast32_t, - struct bson_tm *), - const int_fast32_t offset, - int64_t *const okayp); -static int64_t -time2sub (struct bson_tm *const tmp, - struct bson_tm *(*const funcp) (const int64_t *, - int_fast32_t, - struct bson_tm *), - const int_fast32_t offset, - int64_t *const okayp, - const int64_t do_norm_secs); -static struct bson_tm * -timesub (const int64_t *const timep, - const int_fast32_t offset, - const struct state *const sp, - struct bson_tm *const tmp); -static int64_t -tmcomp (const struct bson_tm *const atmp, const struct bson_tm *const btmp); - -static struct state gmtmem; -#define gmtptr (&gmtmem) - -static int gmt_is_set; - -static const int mon_lengths[2][MONSPERYEAR] = { - {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; - -static const int year_lengths[2] = {DAYSPERNYEAR, DAYSPERLYEAR}; - -static void -gmtload (struct state *const sp) -{ - memset (sp, 0, sizeof (struct state)); - sp->typecnt = 1; - sp->charcnt = 4; - sp->chars[0] = 'G'; - sp->chars[1] = 'M'; - sp->chars[2] = 'T'; -} - -/* -** gmtsub is to gmtime as localsub is to localtime. -*/ - -static struct bson_tm * -gmtsub (const int64_t *const timep, - const int_fast32_t offset, - struct bson_tm *const tmp) -{ - struct bson_tm *result; - - if (!gmt_is_set) { - gmt_is_set = true; - gmtload (gmtptr); - } - result = timesub (timep, offset, gmtptr, tmp); -#ifdef TM_ZONE - /* - ** Could get fancy here and deliver something such as - ** "UT+xxxx" or "UT-xxxx" if offset is non-zero, - ** but this is no time for a treasure hunt. - */ - tmp->TM_ZONE = offset ? wildabbr : gmtptr ? gmtptr->chars : gmt; -#endif /* defined TM_ZONE */ - return result; -} - -/* -** Return the number of leap years through the end of the given year -** where, to make the math easy, the answer for year zero is defined as zero. -*/ - -static int64_t -leaps_thru_end_of (const int64_t y) -{ - return (y >= 0) ? (y / 4 - y / 100 + y / 400) - : -(leaps_thru_end_of (-(y + 1)) + 1); -} - -static struct bson_tm * -timesub (const int64_t *const timep, - const int_fast32_t offset, - const struct state *const sp, - struct bson_tm *const tmp) -{ - const struct lsinfo *lp; - int64_t tdays; - int64_t idays; /* unsigned would be so 2003 */ - int_fast64_t rem; - int64_t y; - const int (*ip)[MONSPERYEAR]; - int_fast64_t corr; - int64_t hit; - int64_t i; - - corr = 0; - hit = 0; - i = (sp == NULL) ? 0 : sp->leapcnt; - while (--i >= 0) { - lp = &sp->lsis[i]; - if (*timep >= lp->ls_trans) { - if (*timep == lp->ls_trans) { - hit = ((i == 0 && lp->ls_corr > 0) || - lp->ls_corr > sp->lsis[i - 1].ls_corr); - if (hit) - while (i > 0 && - sp->lsis[i].ls_trans == sp->lsis[i - 1].ls_trans + 1 && - sp->lsis[i].ls_corr == sp->lsis[i - 1].ls_corr + 1) { - ++hit; - --i; - } - } - corr = lp->ls_corr; - break; - } - } - y = EPOCH_YEAR; - tdays = *timep / SECSPERDAY; - rem = *timep - tdays * SECSPERDAY; - while (tdays < 0 || tdays >= year_lengths[isleap (y)]) { - int64_t newy; - int64_t tdelta; - int64_t idelta; - int64_t leapdays; - - tdelta = tdays / DAYSPERLYEAR; - idelta = tdelta; - if (idelta == 0) - idelta = (tdays < 0) ? -1 : 1; - newy = y; - if (increment_overflow (&newy, idelta)) - return NULL; - leapdays = leaps_thru_end_of (newy - 1) - leaps_thru_end_of (y - 1); - tdays -= ((int64_t) newy - y) * DAYSPERNYEAR; - tdays -= leapdays; - y = newy; - } - { - int_fast32_t seconds; - - seconds = (int_fast32_t) (tdays * SECSPERDAY); - tdays = seconds / SECSPERDAY; - rem += seconds - tdays * SECSPERDAY; - } - /* - ** Given the range, we can now fearlessly cast... - */ - idays = (int64_t) tdays; - rem += offset - corr; - while (rem < 0) { - rem += SECSPERDAY; - --idays; - } - while (rem >= SECSPERDAY) { - rem -= SECSPERDAY; - ++idays; - } - while (idays < 0) { - if (increment_overflow (&y, -1)) - return NULL; - idays += year_lengths[isleap (y)]; - } - while (idays >= year_lengths[isleap (y)]) { - idays -= year_lengths[isleap (y)]; - if (increment_overflow (&y, 1)) - return NULL; - } - tmp->tm_year = y; - if (increment_overflow (&tmp->tm_year, -TM_YEAR_BASE)) - return NULL; - tmp->tm_yday = idays; - /* - ** The "extra" mods below avoid overflow problems. - */ - tmp->tm_wday = - EPOCH_WDAY + - ((y - EPOCH_YEAR) % DAYSPERWEEK) * (DAYSPERNYEAR % DAYSPERWEEK) + - leaps_thru_end_of (y - 1) - leaps_thru_end_of (EPOCH_YEAR - 1) + idays; - tmp->tm_wday %= DAYSPERWEEK; - if (tmp->tm_wday < 0) - tmp->tm_wday += DAYSPERWEEK; - tmp->tm_hour = (int64_t) (rem / SECSPERHOUR); - rem %= SECSPERHOUR; - tmp->tm_min = (int64_t) (rem / SECSPERMIN); - /* - ** A positive leap second requires a special - ** representation. This uses "... ??:59:60" et seq. - */ - tmp->tm_sec = (int64_t) (rem % SECSPERMIN) + hit; - ip = mon_lengths + (isleap (y) ? 1 : 0); - tmp->tm_mon = 0; - while (idays >= (*ip)[tmp->tm_mon]) { - idays -= (*ip)[tmp->tm_mon++]; - BSON_ASSERT (tmp->tm_mon < MONSPERYEAR); - } - tmp->tm_mday = (int64_t) (idays + 1); - tmp->tm_isdst = 0; -#ifdef TM_GMTOFF - tmp->TM_GMTOFF = offset; -#endif /* defined TM_GMTOFF */ - return tmp; -} - -/* -** Adapted from code provided by Robert Elz, who writes: -** The "best" way to do mktime I think is based on an idea of Bob -** Kridle's (so its said...) from a long time ago. -** It does a binary search of the int64_t space. Since int64_t's are -** just 32 bits, its a max of 32 iterations (even at 64 bits it -** would still be very reasonable). -*/ - -#ifndef WRONG -#define WRONG (-1) -#endif /* !defined WRONG */ - -/* -** Normalize logic courtesy Paul Eggert. -*/ - -static int64_t -increment_overflow (int64_t *const ip, int64_t j) -{ - int64_t const i = *ip; - - /* - ** If i >= 0 there can only be overflow if i + j > INT_MAX - ** or if j > INT_MAX - i; given i >= 0, INT_MAX - i cannot overflow. - ** If i < 0 there can only be overflow if i + j < INT_MIN - ** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow. - */ - if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i)) - return true; - *ip += j; - return false; -} - -static int64_t -increment_overflow32 (int_fast32_t *const lp, int64_t const m) -{ - int_fast32_t const l = *lp; - - if ((l >= 0) ? (m > INT_FAST32_MAX - l) : (m < INT_FAST32_MIN - l)) - return true; - *lp += (int_fast32_t) m; - return false; -} - -static int64_t -normalize_overflow (int64_t *const tensptr, - int64_t *const unitsptr, - const int64_t base) -{ - int64_t tensdelta; - - tensdelta = - (*unitsptr >= 0) ? (*unitsptr / base) : (-1 - (-1 - *unitsptr) / base); - *unitsptr -= tensdelta * base; - return increment_overflow (tensptr, tensdelta); -} - -static int64_t -normalize_overflow32 (int_fast32_t *const tensptr, - int64_t *const unitsptr, - const int64_t base) -{ - int64_t tensdelta; - - tensdelta = - (*unitsptr >= 0) ? (*unitsptr / base) : (-1 - (-1 - *unitsptr) / base); - *unitsptr -= tensdelta * base; - return increment_overflow32 (tensptr, tensdelta); -} - -static int64_t -tmcomp (const struct bson_tm *const atmp, const struct bson_tm *const btmp) -{ - int64_t result; - - if (atmp->tm_year != btmp->tm_year) - return atmp->tm_year < btmp->tm_year ? -1 : 1; - if ((result = (atmp->tm_mon - btmp->tm_mon)) == 0 && - (result = (atmp->tm_mday - btmp->tm_mday)) == 0 && - (result = (atmp->tm_hour - btmp->tm_hour)) == 0 && - (result = (atmp->tm_min - btmp->tm_min)) == 0) - result = atmp->tm_sec - btmp->tm_sec; - return result; -} - -static int64_t -time2sub (struct bson_tm *const tmp, - struct bson_tm *(*const funcp) (const int64_t *, - int_fast32_t, - struct bson_tm *), - const int_fast32_t offset, - int64_t *const okayp, - const int64_t do_norm_secs) -{ - const struct state *sp; - int64_t dir; - int64_t i, j; - int64_t saved_seconds; - int_fast32_t li; - int64_t lo; - int64_t hi; - int_fast32_t y; - int64_t newt; - int64_t t; - struct bson_tm yourtm, mytm; - - *okayp = false; - yourtm = *tmp; - if (do_norm_secs) { - if (normalize_overflow (&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN)) - return WRONG; - } - if (normalize_overflow (&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR)) - return WRONG; - if (normalize_overflow (&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY)) - return WRONG; - y = (int_fast32_t) yourtm.tm_year; - if (normalize_overflow32 (&y, &yourtm.tm_mon, MONSPERYEAR)) - return WRONG; - /* - ** Turn y into an actual year number for now. - ** It is converted back to an offset from TM_YEAR_BASE later. - */ - if (increment_overflow32 (&y, TM_YEAR_BASE)) - return WRONG; - while (yourtm.tm_mday <= 0) { - if (increment_overflow32 (&y, -1)) - return WRONG; - li = y + (1 < yourtm.tm_mon); - yourtm.tm_mday += year_lengths[isleap (li)]; - } - while (yourtm.tm_mday > DAYSPERLYEAR) { - li = y + (1 < yourtm.tm_mon); - yourtm.tm_mday -= year_lengths[isleap (li)]; - if (increment_overflow32 (&y, 1)) - return WRONG; - } - for (;;) { - i = mon_lengths[isleap (y)][yourtm.tm_mon]; - if (yourtm.tm_mday <= i) - break; - yourtm.tm_mday -= i; - if (++yourtm.tm_mon >= MONSPERYEAR) { - yourtm.tm_mon = 0; - if (increment_overflow32 (&y, 1)) - return WRONG; - } - } - if (increment_overflow32 (&y, -TM_YEAR_BASE)) - return WRONG; - yourtm.tm_year = y; - if (yourtm.tm_year != y) - return WRONG; - if (yourtm.tm_sec >= 0 && yourtm.tm_sec < SECSPERMIN) - saved_seconds = 0; - else if (y + TM_YEAR_BASE < EPOCH_YEAR) { - /* - ** We can't set tm_sec to 0, because that might push the - ** time below the minimum representable time. - ** Set tm_sec to 59 instead. - ** This assumes that the minimum representable time is - ** not in the same minute that a leap second was deleted from, - ** which is a safer assumption than using 58 would be. - */ - if (increment_overflow (&yourtm.tm_sec, 1 - SECSPERMIN)) - return WRONG; - saved_seconds = yourtm.tm_sec; - yourtm.tm_sec = SECSPERMIN - 1; - } else { - saved_seconds = yourtm.tm_sec; - yourtm.tm_sec = 0; - } - /* - ** Do a binary search. - */ - lo = INT64_MIN; - hi = INT64_MAX; - - for (;;) { - t = lo / 2 + hi / 2; - if (t < lo) - t = lo; - else if (t > hi) - t = hi; - if ((*funcp) (&t, offset, &mytm) == NULL) { - /* - ** Assume that t is too extreme to be represented in - ** a struct bson_tm; arrange things so that it is less - ** extreme on the next pass. - */ - dir = (t > 0) ? 1 : -1; - } else - dir = tmcomp (&mytm, &yourtm); - if (dir != 0) { - if (t == lo) { - if (t == time_t_max) - return WRONG; - ++t; - ++lo; - } else if (t == hi) { - if (t == time_t_min) - return WRONG; - --t; - --hi; - } - if (lo > hi) - return WRONG; - if (dir > 0) - hi = t; - else - lo = t; - continue; - } - if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) - break; - /* - ** Right time, wrong type. - ** Hunt for right time, right type. - ** It's okay to guess wrong since the guess - ** gets checked. - */ - sp = (const struct state *) gmtptr; - if (sp == NULL) - return WRONG; - for (i = sp->typecnt - 1; i >= 0; --i) { - if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) - continue; - for (j = sp->typecnt - 1; j >= 0; --j) { - if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) - continue; - newt = t + sp->ttis[j].tt_gmtoff - sp->ttis[i].tt_gmtoff; - if ((*funcp) (&newt, offset, &mytm) == NULL) - continue; - if (tmcomp (&mytm, &yourtm) != 0) - continue; - if (mytm.tm_isdst != yourtm.tm_isdst) - continue; - /* - ** We have a match. - */ - t = newt; - goto label; - } - } - return WRONG; - } -label: - newt = t + saved_seconds; - if ((newt < t) != (saved_seconds < 0)) - return WRONG; - t = newt; - if ((*funcp) (&t, offset, tmp)) - *okayp = true; - return t; -} - -static int64_t -time2 (struct bson_tm *const tmp, - struct bson_tm *(*const funcp) (const int64_t *, - int_fast32_t, - struct bson_tm *), - const int_fast32_t offset, - int64_t *const okayp) -{ - int64_t t; - - /* - ** First try without normalization of seconds - ** (in case tm_sec contains a value associated with a leap second). - ** If that fails, try with normalization of seconds. - */ - t = time2sub (tmp, funcp, offset, okayp, false); - return *okayp ? t : time2sub (tmp, funcp, offset, okayp, true); -} - -static int64_t -time1 (struct bson_tm *const tmp, - struct bson_tm *(*const funcp) (const int64_t *, - int_fast32_t, - struct bson_tm *), - const int_fast32_t offset) -{ - int64_t t; - const struct state *sp; - int64_t samei, otheri; - int64_t sameind, otherind; - int64_t i; - int64_t nseen; - int64_t seen[TZ_MAX_TYPES]; - int64_t types[TZ_MAX_TYPES]; - int64_t okay; - - if (tmp == NULL) { - errno = EINVAL; - return WRONG; - } - if (tmp->tm_isdst > 1) - tmp->tm_isdst = 1; - t = time2 (tmp, funcp, offset, &okay); - if (okay) - return t; - if (tmp->tm_isdst < 0) -#ifdef PCTS - /* - ** POSIX Conformance Test Suite code courtesy Grant Sullivan. - */ - tmp->tm_isdst = 0; /* reset to std and try again */ -#else - return t; -#endif /* !defined PCTS */ - /* - ** We're supposed to assume that somebody took a time of one type - ** and did some math on it that yielded a "struct tm" that's bad. - ** We try to divine the type they started from and adjust to the - ** type they need. - */ - sp = (const struct state *) gmtptr; - if (sp == NULL) - return WRONG; - for (i = 0; i < sp->typecnt; ++i) - seen[i] = false; - nseen = 0; - for (i = sp->timecnt - 1; i >= 0; --i) - if (!seen[sp->types[i]]) { - seen[sp->types[i]] = true; - types[nseen++] = sp->types[i]; - } - for (sameind = 0; sameind < nseen; ++sameind) { - samei = types[sameind]; - if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) - continue; - for (otherind = 0; otherind < nseen; ++otherind) { - otheri = types[otherind]; - if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) - continue; - tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - t = time2 (tmp, funcp, offset, &okay); - if (okay) - return t; - tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - } - } - return WRONG; -} - -int64_t -_bson_timegm (struct bson_tm *const tmp) -{ - if (tmp != NULL) - tmp->tm_isdst = 0; - return time1 (tmp, gmtsub, 0L); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-types.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-types.h deleted file mode 100644 index fd62cec2a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-types.h +++ /dev/null @@ -1,567 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - - -#ifndef BSON_TYPES_H -#define BSON_TYPES_H - - -#include -#include - -#include -#include -#include -#include - -BSON_BEGIN_DECLS - - -/* - *-------------------------------------------------------------------------- - * - * bson_unichar_t -- - * - * bson_unichar_t provides an unsigned 32-bit type for containing - * unicode characters. When iterating UTF-8 sequences, this should - * be used to avoid losing the high-bits of non-ascii characters. - * - * See also: - * bson_string_append_unichar() - * - *-------------------------------------------------------------------------- - */ - -typedef uint32_t bson_unichar_t; - - -/** - * @brief Flags configuring the creation of a bson_context_t - */ -typedef enum { - /** Use default options */ - BSON_CONTEXT_NONE = 0, - /* Deprecated: Generating new OIDs from a bson_context_t is always - thread-safe */ - BSON_CONTEXT_THREAD_SAFE = (1 << 0), - /* Deprecated: Does nothing and is ignored */ - BSON_CONTEXT_DISABLE_HOST_CACHE = (1 << 1), - /* Call getpid() instead of remembering the result of getpid() when using the - context */ - BSON_CONTEXT_DISABLE_PID_CACHE = (1 << 2), - /* Deprecated: Does nothing */ - BSON_CONTEXT_USE_TASK_ID = (1 << 3), -} bson_context_flags_t; - - -/** - * bson_context_t: - * - * This structure manages context for the bson library. It handles - * configuration for thread-safety and other performance related requirements. - * Consumers will create a context and may use multiple under a variety of - * situations. - * - * If your program calls fork(), you should initialize a new bson_context_t - * using bson_context_init(). - * - * If you are using threading, it is suggested that you use a bson_context_t - * per thread for best performance. Alternatively, you can initialize the - * bson_context_t with BSON_CONTEXT_THREAD_SAFE, although a performance penalty - * will be incurred. - * - * Many functions will require that you provide a bson_context_t such as OID - * generation. - * - * This structure is opaque in that you cannot see the contents of the - * structure. However, it is stack allocatable in that enough padding is - * provided in _bson_context_t to hold the structure. - */ -typedef struct _bson_context_t bson_context_t; - -/** - * bson_json_opts_t: - * - * This structure is used to pass options for serializing BSON into extended - * JSON to the respective serialization methods. - * - * max_len can be either a non-negative integer, or BSON_MAX_LEN_UNLIMITED to - * set no limit for serialization length. - */ -typedef struct _bson_json_opts_t bson_json_opts_t; - - -/** - * bson_t: - * - * This structure manages a buffer whose contents are a properly formatted - * BSON document. You may perform various transforms on the BSON documents. - * Additionally, it can be iterated over using bson_iter_t. - * - * See bson_iter_init() for iterating the contents of a bson_t. - * - * When building a bson_t structure using the various append functions, - * memory allocations may occur. That is performed using power of two - * allocations and realloc(). - * - * See http://bsonspec.org for the BSON document spec. - * - * This structure is meant to fit in two sequential 64-byte cachelines. - */ -#ifdef BSON_MEMCHECK -BSON_ALIGNED_BEGIN (128) typedef struct _bson_t { - uint32_t flags; /* Internal flags for the bson_t. */ - uint32_t len; /* Length of BSON data. */ - char *canary; /* For leak checks. */ - uint8_t padding[120 - sizeof (char *)]; -} bson_t BSON_ALIGNED_END (128); -#else -BSON_ALIGNED_BEGIN (128) typedef struct _bson_t { - uint32_t flags; /* Internal flags for the bson_t. */ - uint32_t len; /* Length of BSON data. */ - uint8_t padding[120]; /* Padding for stack allocation. */ -} bson_t BSON_ALIGNED_END (128); -#endif - -/** - * BSON_INITIALIZER: - * - * This macro can be used to initialize a #bson_t structure on the stack - * without calling bson_init(). - * - * |[ - * bson_t b = BSON_INITIALIZER; - * ]| - */ -#ifdef BSON_MEMCHECK -#define BSON_INITIALIZER \ - { \ - 3, 5, bson_malloc (1), {5}, \ - } -#else -#define BSON_INITIALIZER \ - { \ - 3, 5, \ - { \ - 5 \ - } \ - } -#endif - - -BSON_STATIC_ASSERT2 (bson_t, sizeof (bson_t) == 128); - - -/** - * bson_oid_t: - * - * This structure contains the binary form of a BSON Object Id as specified - * on http://bsonspec.org. If you would like the bson_oid_t in string form - * see bson_oid_to_string() or bson_oid_to_string_r(). - */ -typedef struct { - uint8_t bytes[12]; -} bson_oid_t; - -BSON_STATIC_ASSERT2 (oid_t, sizeof (bson_oid_t) == 12); - -/** - * bson_decimal128_t: - * - * @high The high-order bytes of the decimal128. This field contains sign, - * combination bits, exponent, and part of the coefficient continuation. - * @low The low-order bytes of the decimal128. This field contains the second - * part of the coefficient continuation. - * - * This structure is a boxed type containing the value for the BSON decimal128 - * type. The structure stores the 128 bits such that they correspond to the - * native format for the IEEE decimal128 type, if it is implemented. - **/ -typedef struct { -#if BSON_BYTE_ORDER == BSON_LITTLE_ENDIAN - uint64_t low; - uint64_t high; -#elif BSON_BYTE_ORDER == BSON_BIG_ENDIAN - uint64_t high; - uint64_t low; -#endif -} bson_decimal128_t; - - -/** - * bson_validate_flags_t: - * - * This enumeration is used for validation of BSON documents. It allows - * selective control on what you wish to validate. - * - * %BSON_VALIDATE_NONE: No additional validation occurs. - * %BSON_VALIDATE_UTF8: Check that strings are valid UTF-8. - * %BSON_VALIDATE_DOLLAR_KEYS: Check that keys do not start with $. - * %BSON_VALIDATE_DOT_KEYS: Check that keys do not contain a period. - * %BSON_VALIDATE_UTF8_ALLOW_NULL: Allow NUL bytes in UTF-8 text. - * %BSON_VALIDATE_EMPTY_KEYS: Prohibit zero-length field names - */ -typedef enum { - BSON_VALIDATE_NONE = 0, - BSON_VALIDATE_UTF8 = (1 << 0), - BSON_VALIDATE_DOLLAR_KEYS = (1 << 1), - BSON_VALIDATE_DOT_KEYS = (1 << 2), - BSON_VALIDATE_UTF8_ALLOW_NULL = (1 << 3), - BSON_VALIDATE_EMPTY_KEYS = (1 << 4), -} bson_validate_flags_t; - - -/** - * bson_type_t: - * - * This enumeration contains all of the possible types within a BSON document. - * Use bson_iter_type() to fetch the type of a field while iterating over it. - */ -typedef enum { - BSON_TYPE_EOD = 0x00, - BSON_TYPE_DOUBLE = 0x01, - BSON_TYPE_UTF8 = 0x02, - BSON_TYPE_DOCUMENT = 0x03, - BSON_TYPE_ARRAY = 0x04, - BSON_TYPE_BINARY = 0x05, - BSON_TYPE_UNDEFINED = 0x06, - BSON_TYPE_OID = 0x07, - BSON_TYPE_BOOL = 0x08, - BSON_TYPE_DATE_TIME = 0x09, - BSON_TYPE_NULL = 0x0A, - BSON_TYPE_REGEX = 0x0B, - BSON_TYPE_DBPOINTER = 0x0C, - BSON_TYPE_CODE = 0x0D, - BSON_TYPE_SYMBOL = 0x0E, - BSON_TYPE_CODEWSCOPE = 0x0F, - BSON_TYPE_INT32 = 0x10, - BSON_TYPE_TIMESTAMP = 0x11, - BSON_TYPE_INT64 = 0x12, - BSON_TYPE_DECIMAL128 = 0x13, - BSON_TYPE_MAXKEY = 0x7F, - BSON_TYPE_MINKEY = 0xFF, -} bson_type_t; - - -/** - * bson_subtype_t: - * - * This enumeration contains the various subtypes that may be used in a binary - * field. See http://bsonspec.org for more information. - */ -typedef enum { - BSON_SUBTYPE_BINARY = 0x00, - BSON_SUBTYPE_FUNCTION = 0x01, - BSON_SUBTYPE_BINARY_DEPRECATED = 0x02, - BSON_SUBTYPE_UUID_DEPRECATED = 0x03, - BSON_SUBTYPE_UUID = 0x04, - BSON_SUBTYPE_MD5 = 0x05, - BSON_SUBTYPE_ENCRYPTED = 0x06, - BSON_SUBTYPE_COLUMN = 0x07, - BSON_SUBTYPE_SENSITIVE = 0x08, - BSON_SUBTYPE_USER = 0x80, -} bson_subtype_t; - - -/* - *-------------------------------------------------------------------------- - * - * bson_value_t -- - * - * A boxed type to contain various bson_type_t types. - * - * See also: - * bson_value_copy() - * bson_value_destroy() - * - *-------------------------------------------------------------------------- - */ - -BSON_ALIGNED_BEGIN (8) -typedef struct _bson_value_t { - bson_type_t value_type; - int32_t padding; - union { - bson_oid_t v_oid; - int64_t v_int64; - int32_t v_int32; - int8_t v_int8; - double v_double; - bool v_bool; - int64_t v_datetime; - struct { - uint32_t timestamp; - uint32_t increment; - } v_timestamp; - struct { - char *str; - uint32_t len; - } v_utf8; - struct { - uint8_t *data; - uint32_t data_len; - } v_doc; - struct { - uint8_t *data; - uint32_t data_len; - bson_subtype_t subtype; - } v_binary; - struct { - char *regex; - char *options; - } v_regex; - struct { - char *collection; - uint32_t collection_len; - bson_oid_t oid; - } v_dbpointer; - struct { - char *code; - uint32_t code_len; - } v_code; - struct { - char *code; - uint8_t *scope_data; - uint32_t code_len; - uint32_t scope_len; - } v_codewscope; - struct { - char *symbol; - uint32_t len; - } v_symbol; - bson_decimal128_t v_decimal128; - } value; -} bson_value_t BSON_ALIGNED_END (8); - - -/** - * bson_iter_t: - * - * This structure manages iteration over a bson_t structure. It keeps track - * of the location of the current key and value within the buffer. Using the - * various functions to get the value of the iter will read from these - * locations. - * - * This structure is safe to discard on the stack. No cleanup is necessary - * after using it. - */ -BSON_ALIGNED_BEGIN (128) -typedef struct { - const uint8_t *raw; /* The raw buffer being iterated. */ - uint32_t len; /* The length of raw. */ - uint32_t off; /* The offset within the buffer. */ - uint32_t type; /* The offset of the type byte. */ - uint32_t key; /* The offset of the key byte. */ - uint32_t d1; /* The offset of the first data byte. */ - uint32_t d2; /* The offset of the second data byte. */ - uint32_t d3; /* The offset of the third data byte. */ - uint32_t d4; /* The offset of the fourth data byte. */ - uint32_t next_off; /* The offset of the next field. */ - uint32_t err_off; /* The offset of the error. */ - bson_value_t value; /* Internal value for various state. */ -} bson_iter_t BSON_ALIGNED_END (128); - - -/** - * bson_reader_t: - * - * This structure is used to iterate over a sequence of BSON documents. It - * allows for them to be iterated with the possibility of no additional - * memory allocations under certain circumstances such as reading from an - * incoming mongo packet. - */ - -BSON_ALIGNED_BEGIN (BSON_ALIGN_OF_PTR) -typedef struct { - uint32_t type; - /*< private >*/ -} bson_reader_t BSON_ALIGNED_END (BSON_ALIGN_OF_PTR); - - -/** - * bson_visitor_t: - * - * This structure contains a series of pointers that can be executed for - * each field of a BSON document based on the field type. - * - * For example, if an int32 field is found, visit_int32 will be called. - * - * When visiting each field using bson_iter_visit_all(), you may provide a - * data pointer that will be provided with each callback. This might be useful - * if you are marshaling to another language. - * - * You may pre-maturely stop the visitation of fields by returning true in your - * visitor. Returning false will continue visitation to further fields. - */ -BSON_ALIGNED_BEGIN (8) -typedef struct { - /* run before / after descending into a document */ - bool (*visit_before) (const bson_iter_t *iter, const char *key, void *data); - bool (*visit_after) (const bson_iter_t *iter, const char *key, void *data); - /* corrupt BSON, or unsupported type and visit_unsupported_type not set */ - void (*visit_corrupt) (const bson_iter_t *iter, void *data); - /* normal bson field callbacks */ - bool (*visit_double) (const bson_iter_t *iter, - const char *key, - double v_double, - void *data); - bool (*visit_utf8) (const bson_iter_t *iter, - const char *key, - size_t v_utf8_len, - const char *v_utf8, - void *data); - bool (*visit_document) (const bson_iter_t *iter, - const char *key, - const bson_t *v_document, - void *data); - bool (*visit_array) (const bson_iter_t *iter, - const char *key, - const bson_t *v_array, - void *data); - bool (*visit_binary) (const bson_iter_t *iter, - const char *key, - bson_subtype_t v_subtype, - size_t v_binary_len, - const uint8_t *v_binary, - void *data); - /* normal field with deprecated "Undefined" BSON type */ - bool (*visit_undefined) (const bson_iter_t *iter, - const char *key, - void *data); - bool (*visit_oid) (const bson_iter_t *iter, - const char *key, - const bson_oid_t *v_oid, - void *data); - bool (*visit_bool) (const bson_iter_t *iter, - const char *key, - bool v_bool, - void *data); - bool (*visit_date_time) (const bson_iter_t *iter, - const char *key, - int64_t msec_since_epoch, - void *data); - bool (*visit_null) (const bson_iter_t *iter, const char *key, void *data); - bool (*visit_regex) (const bson_iter_t *iter, - const char *key, - const char *v_regex, - const char *v_options, - void *data); - bool (*visit_dbpointer) (const bson_iter_t *iter, - const char *key, - size_t v_collection_len, - const char *v_collection, - const bson_oid_t *v_oid, - void *data); - bool (*visit_code) (const bson_iter_t *iter, - const char *key, - size_t v_code_len, - const char *v_code, - void *data); - bool (*visit_symbol) (const bson_iter_t *iter, - const char *key, - size_t v_symbol_len, - const char *v_symbol, - void *data); - bool (*visit_codewscope) (const bson_iter_t *iter, - const char *key, - size_t v_code_len, - const char *v_code, - const bson_t *v_scope, - void *data); - bool (*visit_int32) (const bson_iter_t *iter, - const char *key, - int32_t v_int32, - void *data); - bool (*visit_timestamp) (const bson_iter_t *iter, - const char *key, - uint32_t v_timestamp, - uint32_t v_increment, - void *data); - bool (*visit_int64) (const bson_iter_t *iter, - const char *key, - int64_t v_int64, - void *data); - bool (*visit_maxkey) (const bson_iter_t *iter, const char *key, void *data); - bool (*visit_minkey) (const bson_iter_t *iter, const char *key, void *data); - /* if set, called instead of visit_corrupt when an apparently valid BSON - * includes an unrecognized field type (reading future version of BSON) */ - void (*visit_unsupported_type) (const bson_iter_t *iter, - const char *key, - uint32_t type_code, - void *data); - bool (*visit_decimal128) (const bson_iter_t *iter, - const char *key, - const bson_decimal128_t *v_decimal128, - void *data); - - void *padding[7]; -} bson_visitor_t BSON_ALIGNED_END (8); - -#define BSON_ERROR_BUFFER_SIZE 504 - -BSON_ALIGNED_BEGIN (8) -typedef struct _bson_error_t { - uint32_t domain; - uint32_t code; - char message[BSON_ERROR_BUFFER_SIZE]; -} bson_error_t BSON_ALIGNED_END (8); - - -BSON_STATIC_ASSERT2 (error_t, sizeof (bson_error_t) == 512); - - -/** - * bson_next_power_of_two: - * @v: A 32-bit unsigned integer of required bytes. - * - * Determines the next larger power of two for the value of @v - * in a constant number of operations. - * - * It is up to the caller to guarantee this will not overflow. - * - * Returns: The next power of 2 from @v. - */ -static BSON_INLINE size_t -bson_next_power_of_two (size_t v) -{ - v--; - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; -#if BSON_WORD_SIZE == 64 - v |= v >> 32; -#endif - v++; - - return v; -} - - -static BSON_INLINE bool -bson_is_power_of_two (uint32_t v) -{ - return ((v != 0) && ((v & (v - 1)) == 0)); -} - - -BSON_END_DECLS - - -#endif /* BSON_TYPES_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-utf8.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-utf8.c deleted file mode 100644 index ac7a1bddf..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-utf8.c +++ /dev/null @@ -1,459 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include -#include -#include - - -/* - *-------------------------------------------------------------------------- - * - * _bson_utf8_get_sequence -- - * - * Determine the sequence length of the first UTF-8 character in - * @utf8. The sequence length is stored in @seq_length and the mask - * for the first character is stored in @first_mask. - * - * Returns: - * None. - * - * Side effects: - * @seq_length is set. - * @first_mask is set. - * - *-------------------------------------------------------------------------- - */ - -static BSON_INLINE void -_bson_utf8_get_sequence (const char *utf8, /* IN */ - uint8_t *seq_length, /* OUT */ - uint8_t *first_mask) /* OUT */ -{ - unsigned char c = *(const unsigned char *) utf8; - uint8_t m; - uint8_t n; - - /* - * See the following[1] for a description of what the given multi-byte - * sequences will be based on the bits set of the first byte. We also need - * to mask the first byte based on that. All subsequent bytes are masked - * against 0x3F. - * - * [1] http://www.joelonsoftware.com/articles/Unicode.html - */ - - if ((c & 0x80) == 0) { - n = 1; - m = 0x7F; - } else if ((c & 0xE0) == 0xC0) { - n = 2; - m = 0x1F; - } else if ((c & 0xF0) == 0xE0) { - n = 3; - m = 0x0F; - } else if ((c & 0xF8) == 0xF0) { - n = 4; - m = 0x07; - } else { - n = 0; - m = 0; - } - - *seq_length = n; - *first_mask = m; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_utf8_validate -- - * - * Validates that @utf8 is a valid UTF-8 string. Note that we only - * support UTF-8 characters which have sequence length less than or equal - * to 4 bytes (RFC 3629). - * - * If @allow_null is true, then \0 is allowed within @utf8_len bytes - * of @utf8. Generally, this is bad practice since the main point of - * UTF-8 strings is that they can be used with strlen() and friends. - * However, some languages such as Python can send UTF-8 encoded - * strings with NUL's in them. - * - * Parameters: - * @utf8: A UTF-8 encoded string. - * @utf8_len: The length of @utf8 in bytes. - * @allow_null: If \0 is allowed within @utf8, excluding trailing \0. - * - * Returns: - * true if @utf8 is valid UTF-8. otherwise false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -bson_utf8_validate (const char *utf8, /* IN */ - size_t utf8_len, /* IN */ - bool allow_null) /* IN */ -{ - bson_unichar_t c; - uint8_t first_mask; - uint8_t seq_length; - size_t i; - size_t j; - - BSON_ASSERT (utf8); - - for (i = 0; i < utf8_len; i += seq_length) { - _bson_utf8_get_sequence (&utf8[i], &seq_length, &first_mask); - - /* - * Ensure we have a valid multi-byte sequence length. - */ - if (!seq_length) { - return false; - } - - /* - * Ensure we have enough bytes left. - */ - if ((utf8_len - i) < seq_length) { - return false; - } - - /* - * Also calculate the next char as a unichar so we can - * check code ranges for non-shortest form. - */ - c = utf8[i] & first_mask; - - /* - * Check the high-bits for each additional sequence byte. - */ - for (j = i + 1; j < (i + seq_length); j++) { - c = (c << 6) | (utf8[j] & 0x3F); - if ((utf8[j] & 0xC0) != 0x80) { - return false; - } - } - - /* - * Check for NULL bytes afterwards. - * - * Hint: if you want to optimize this function, starting here to do - * this in the same pass as the data above would probably be a good - * idea. You would add a branch into the inner loop, but save possibly - * on cache-line bouncing on larger strings. Just a thought. - */ - if (!allow_null) { - for (j = 0; j < seq_length; j++) { - if (((i + j) > utf8_len) || !utf8[i + j]) { - return false; - } - } - } - - /* - * Code point won't fit in utf-16, not allowed. - */ - if (c > 0x0010FFFF) { - return false; - } - - /* - * Byte is in reserved range for UTF-16 high-marks - * for surrogate pairs. - */ - if ((c & 0xFFFFF800) == 0xD800) { - return false; - } - - /* - * Check non-shortest form unicode. - */ - switch (seq_length) { - case 1: - if (c <= 0x007F) { - continue; - } - return false; - - case 2: - if ((c >= 0x0080) && (c <= 0x07FF)) { - continue; - } else if (c == 0) { - /* Two-byte representation for NULL. */ - if (!allow_null) { - return false; - } - continue; - } - return false; - - case 3: - if (((c >= 0x0800) && (c <= 0x0FFF)) || - ((c >= 0x1000) && (c <= 0xFFFF))) { - continue; - } - return false; - - case 4: - if (((c >= 0x10000) && (c <= 0x3FFFF)) || - ((c >= 0x40000) && (c <= 0xFFFFF)) || - ((c >= 0x100000) && (c <= 0x10FFFF))) { - continue; - } - return false; - - default: - return false; - } - } - - return true; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_utf8_escape_for_json -- - * - * Allocates a new string matching @utf8 except that special - * characters in JSON will be escaped. The resulting string is also - * UTF-8 encoded. - * - * Both " and \ characters will be escaped. Additionally, if a NUL - * byte is found before @utf8_len bytes, it will be converted to the - * two byte UTF-8 sequence. - * - * Parameters: - * @utf8: A UTF-8 encoded string. - * @utf8_len: The length of @utf8 in bytes or -1 if NUL terminated. - * - * Returns: - * A newly allocated string that should be freed with bson_free(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -char * -bson_utf8_escape_for_json (const char *utf8, /* IN */ - ssize_t utf8_len) /* IN */ -{ - bson_unichar_t c; - bson_string_t *str; - bool length_provided = true; - const char *end; - - BSON_ASSERT (utf8); - - str = bson_string_new (NULL); - - if (utf8_len < 0) { - length_provided = false; - utf8_len = strlen (utf8); - } - - end = utf8 + utf8_len; - - while (utf8 < end) { - c = bson_utf8_get_char (utf8); - - switch (c) { - case '\\': - case '"': - bson_string_append_c (str, '\\'); - bson_string_append_unichar (str, c); - break; - case '\b': - bson_string_append (str, "\\b"); - break; - case '\f': - bson_string_append (str, "\\f"); - break; - case '\n': - bson_string_append (str, "\\n"); - break; - case '\r': - bson_string_append (str, "\\r"); - break; - case '\t': - bson_string_append (str, "\\t"); - break; - default: - if (c < ' ') { - bson_string_append_printf (str, "\\u%04x", (unsigned) c); - } else { - bson_string_append_unichar (str, c); - } - break; - } - - if (c) { - utf8 = bson_utf8_next_char (utf8); - } else { - if (length_provided && !*utf8) { - /* we escaped nil as '\u0000', now advance past it */ - utf8++; - } else { - /* invalid UTF-8 */ - bson_string_free (str, true); - return NULL; - } - } - } - - return bson_string_free (str, false); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_utf8_get_char -- - * - * Fetches the next UTF-8 character from the UTF-8 sequence. - * - * Parameters: - * @utf8: A string containing validated UTF-8. - * - * Returns: - * A 32-bit bson_unichar_t reprsenting the multi-byte sequence. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bson_unichar_t -bson_utf8_get_char (const char *utf8) /* IN */ -{ - bson_unichar_t c; - uint8_t mask; - uint8_t num; - int i; - - BSON_ASSERT (utf8); - - _bson_utf8_get_sequence (utf8, &num, &mask); - c = (*utf8) & mask; - - for (i = 1; i < num; i++) { - c = (c << 6) | (utf8[i] & 0x3F); - } - - return c; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_utf8_next_char -- - * - * Returns an incremented pointer to the beginning of the next - * multi-byte sequence in @utf8. - * - * Parameters: - * @utf8: A string containing validated UTF-8. - * - * Returns: - * An incremented pointer in @utf8. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const char * -bson_utf8_next_char (const char *utf8) /* IN */ -{ - uint8_t mask; - uint8_t num; - - BSON_ASSERT (utf8); - - _bson_utf8_get_sequence (utf8, &num, &mask); - - return utf8 + num; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_utf8_from_unichar -- - * - * Converts the unichar to a sequence of utf8 bytes and stores those - * in @utf8. The number of bytes in the sequence are stored in @len. - * - * Parameters: - * @unichar: A bson_unichar_t. - * @utf8: A location for the multi-byte sequence. - * @len: A location for number of bytes stored in @utf8. - * - * Returns: - * None. - * - * Side effects: - * @utf8 is set. - * @len is set. - * - *-------------------------------------------------------------------------- - */ - -void -bson_utf8_from_unichar (bson_unichar_t unichar, /* IN */ - char utf8[BSON_ENSURE_ARRAY_PARAM_SIZE (6)], /* OUT */ - uint32_t *len) /* OUT */ -{ - BSON_ASSERT (utf8); - BSON_ASSERT (len); - - if (unichar <= 0x7F) { - utf8[0] = unichar; - *len = 1; - } else if (unichar <= 0x7FF) { - *len = 2; - utf8[0] = 0xC0 | ((unichar >> 6) & 0x3F); - utf8[1] = 0x80 | ((unichar) &0x3F); - } else if (unichar <= 0xFFFF) { - *len = 3; - utf8[0] = 0xE0 | ((unichar >> 12) & 0xF); - utf8[1] = 0x80 | ((unichar >> 6) & 0x3F); - utf8[2] = 0x80 | ((unichar) &0x3F); - } else if (unichar <= 0x1FFFFF) { - *len = 4; - utf8[0] = 0xF0 | ((unichar >> 18) & 0x7); - utf8[1] = 0x80 | ((unichar >> 12) & 0x3F); - utf8[2] = 0x80 | ((unichar >> 6) & 0x3F); - utf8[3] = 0x80 | ((unichar) &0x3F); - } else { - *len = 0; - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-value.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-value.c deleted file mode 100644 index 63f43a0c0..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-value.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include - - -void -bson_value_copy (const bson_value_t *src, /* IN */ - bson_value_t *dst) /* OUT */ -{ - BSON_ASSERT (src); - BSON_ASSERT (dst); - - dst->value_type = src->value_type; - - switch (src->value_type) { - case BSON_TYPE_DOUBLE: - dst->value.v_double = src->value.v_double; - break; - case BSON_TYPE_UTF8: - dst->value.v_utf8.len = src->value.v_utf8.len; - dst->value.v_utf8.str = bson_malloc (src->value.v_utf8.len + 1); - memcpy ( - dst->value.v_utf8.str, src->value.v_utf8.str, dst->value.v_utf8.len); - dst->value.v_utf8.str[dst->value.v_utf8.len] = '\0'; - break; - case BSON_TYPE_DOCUMENT: - case BSON_TYPE_ARRAY: - dst->value.v_doc.data_len = src->value.v_doc.data_len; - dst->value.v_doc.data = bson_malloc (src->value.v_doc.data_len); - memcpy (dst->value.v_doc.data, - src->value.v_doc.data, - dst->value.v_doc.data_len); - break; - case BSON_TYPE_BINARY: - dst->value.v_binary.subtype = src->value.v_binary.subtype; - dst->value.v_binary.data_len = src->value.v_binary.data_len; - dst->value.v_binary.data = bson_malloc (src->value.v_binary.data_len); - if (dst->value.v_binary.data_len) { - memcpy (dst->value.v_binary.data, - src->value.v_binary.data, - dst->value.v_binary.data_len); - } - break; - case BSON_TYPE_OID: - bson_oid_copy (&src->value.v_oid, &dst->value.v_oid); - break; - case BSON_TYPE_BOOL: - dst->value.v_bool = src->value.v_bool; - break; - case BSON_TYPE_DATE_TIME: - dst->value.v_datetime = src->value.v_datetime; - break; - case BSON_TYPE_REGEX: - dst->value.v_regex.regex = bson_strdup (src->value.v_regex.regex); - dst->value.v_regex.options = bson_strdup (src->value.v_regex.options); - break; - case BSON_TYPE_DBPOINTER: - dst->value.v_dbpointer.collection_len = - src->value.v_dbpointer.collection_len; - dst->value.v_dbpointer.collection = - bson_malloc (src->value.v_dbpointer.collection_len + 1); - memcpy (dst->value.v_dbpointer.collection, - src->value.v_dbpointer.collection, - dst->value.v_dbpointer.collection_len); - dst->value.v_dbpointer.collection[dst->value.v_dbpointer.collection_len] = - '\0'; - bson_oid_copy (&src->value.v_dbpointer.oid, &dst->value.v_dbpointer.oid); - break; - case BSON_TYPE_CODE: - dst->value.v_code.code_len = src->value.v_code.code_len; - dst->value.v_code.code = bson_malloc (src->value.v_code.code_len + 1); - memcpy (dst->value.v_code.code, - src->value.v_code.code, - dst->value.v_code.code_len); - dst->value.v_code.code[dst->value.v_code.code_len] = '\0'; - break; - case BSON_TYPE_SYMBOL: - dst->value.v_symbol.len = src->value.v_symbol.len; - dst->value.v_symbol.symbol = bson_malloc (src->value.v_symbol.len + 1); - memcpy (dst->value.v_symbol.symbol, - src->value.v_symbol.symbol, - dst->value.v_symbol.len); - dst->value.v_symbol.symbol[dst->value.v_symbol.len] = '\0'; - break; - case BSON_TYPE_CODEWSCOPE: - dst->value.v_codewscope.code_len = src->value.v_codewscope.code_len; - dst->value.v_codewscope.code = - bson_malloc (src->value.v_codewscope.code_len + 1); - memcpy (dst->value.v_codewscope.code, - src->value.v_codewscope.code, - dst->value.v_codewscope.code_len); - dst->value.v_codewscope.code[dst->value.v_codewscope.code_len] = '\0'; - dst->value.v_codewscope.scope_len = src->value.v_codewscope.scope_len; - dst->value.v_codewscope.scope_data = - bson_malloc (src->value.v_codewscope.scope_len); - memcpy (dst->value.v_codewscope.scope_data, - src->value.v_codewscope.scope_data, - dst->value.v_codewscope.scope_len); - break; - case BSON_TYPE_INT32: - dst->value.v_int32 = src->value.v_int32; - break; - case BSON_TYPE_TIMESTAMP: - dst->value.v_timestamp.timestamp = src->value.v_timestamp.timestamp; - dst->value.v_timestamp.increment = src->value.v_timestamp.increment; - break; - case BSON_TYPE_INT64: - dst->value.v_int64 = src->value.v_int64; - break; - case BSON_TYPE_DECIMAL128: - dst->value.v_decimal128 = src->value.v_decimal128; - break; - case BSON_TYPE_UNDEFINED: - case BSON_TYPE_NULL: - case BSON_TYPE_MAXKEY: - case BSON_TYPE_MINKEY: - break; - case BSON_TYPE_EOD: - default: - BSON_ASSERT (false); - return; - } -} - - -void -bson_value_destroy (bson_value_t *value) /* IN */ -{ - if (!value) { - return; - } - - switch (value->value_type) { - case BSON_TYPE_UTF8: - bson_free (value->value.v_utf8.str); - break; - case BSON_TYPE_DOCUMENT: - case BSON_TYPE_ARRAY: - bson_free (value->value.v_doc.data); - break; - case BSON_TYPE_BINARY: - bson_free (value->value.v_binary.data); - break; - case BSON_TYPE_REGEX: - bson_free (value->value.v_regex.regex); - bson_free (value->value.v_regex.options); - break; - case BSON_TYPE_DBPOINTER: - bson_free (value->value.v_dbpointer.collection); - break; - case BSON_TYPE_CODE: - bson_free (value->value.v_code.code); - break; - case BSON_TYPE_SYMBOL: - bson_free (value->value.v_symbol.symbol); - break; - case BSON_TYPE_CODEWSCOPE: - bson_free (value->value.v_codewscope.code); - bson_free (value->value.v_codewscope.scope_data); - break; - case BSON_TYPE_DOUBLE: - case BSON_TYPE_UNDEFINED: - case BSON_TYPE_OID: - case BSON_TYPE_BOOL: - case BSON_TYPE_DATE_TIME: - case BSON_TYPE_NULL: - case BSON_TYPE_INT32: - case BSON_TYPE_TIMESTAMP: - case BSON_TYPE_INT64: - case BSON_TYPE_DECIMAL128: - case BSON_TYPE_MAXKEY: - case BSON_TYPE_MINKEY: - case BSON_TYPE_EOD: - default: - break; - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-version.h.in b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-version.h.in deleted file mode 100644 index 618369995..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson-version.h.in +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#if !defined(BSON_INSIDE) && !defined(BSON_COMPILATION) -#error "Only can be included directly." -#endif - -// clang-format off - -#ifndef BSON_VERSION_H -#define BSON_VERSION_H - - -/** - * BSON_MAJOR_VERSION: - * - * BSON major version component (e.g. 1 if %BSON_VERSION is 1.2.3) - */ -#define BSON_MAJOR_VERSION (@libbson_VERSION_MAJOR@) - - -/** - * BSON_MINOR_VERSION: - * - * BSON minor version component (e.g. 2 if %BSON_VERSION is 1.2.3) - */ -#define BSON_MINOR_VERSION (@libbson_VERSION_MINOR@) - - -/** - * BSON_MICRO_VERSION: - * - * BSON micro version component (e.g. 3 if %BSON_VERSION is 1.2.3) - */ -#define BSON_MICRO_VERSION (@libbson_VERSION_PATCH@) - - -/** - * BSON_PRERELEASE_VERSION: - * - * BSON prerelease version component (e.g. pre if %BSON_VERSION is 1.2.3-pre) - */ -#define BSON_PRERELEASE_VERSION (@libbson_VERSION_PRERELEASE@) - -/** - * BSON_VERSION: - * - * BSON version. - */ -#define BSON_VERSION (@libbson_VERSION_FULL@) - - -/** - * BSON_VERSION_S: - * - * BSON version, encoded as a string, useful for printing and - * concatenation. - */ -#define BSON_VERSION_S "@libbson_VERSION_FULL@" - - -/** - * BSON_VERSION_HEX: - * - * BSON version, encoded as an hexadecimal number, useful for - * integer comparisons. - */ -#define BSON_VERSION_HEX (BSON_MAJOR_VERSION << 24 | \ - BSON_MINOR_VERSION << 16 | \ - BSON_MICRO_VERSION << 8) - - -/** - * BSON_CHECK_VERSION: - * @major: required major version - * @minor: required minor version - * @micro: required micro version - * - * Compile-time version checking. Evaluates to %TRUE if the version - * of BSON is greater than or equal to the required one. - */ -#define BSON_CHECK_VERSION(major,minor,micro) \ - (BSON_MAJOR_VERSION > (major) || \ - (BSON_MAJOR_VERSION == (major) && BSON_MINOR_VERSION > (minor)) || \ - (BSON_MAJOR_VERSION == (major) && BSON_MINOR_VERSION == (minor) && \ - BSON_MICRO_VERSION >= (micro))) - -#endif /* BSON_VERSION_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson.c deleted file mode 100644 index e1e530a0a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson.c +++ /dev/null @@ -1,3992 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "bson.h" -#include -#include -#include -#include -#include - -#include "common-b64-private.h" - -#include -#include - - -#ifndef BSON_MAX_RECURSION -#define BSON_MAX_RECURSION 200 -#endif - - -typedef enum { - BSON_VALIDATE_PHASE_START, - BSON_VALIDATE_PHASE_TOP, - BSON_VALIDATE_PHASE_LF_REF_KEY, - BSON_VALIDATE_PHASE_LF_REF_UTF8, - BSON_VALIDATE_PHASE_LF_ID_KEY, - BSON_VALIDATE_PHASE_LF_DB_KEY, - BSON_VALIDATE_PHASE_LF_DB_UTF8, - BSON_VALIDATE_PHASE_NOT_DBREF, -} bson_validate_phase_t; - - -/* - * Structures. - */ -typedef struct { - bson_validate_flags_t flags; - ssize_t err_offset; - bson_validate_phase_t phase; - bson_error_t error; -} bson_validate_state_t; - - -typedef struct { - uint32_t count; - bool keys; - ssize_t *err_offset; - uint32_t depth; - bson_string_t *str; - bson_json_mode_t mode; - int32_t max_len; - bool max_len_reached; -} bson_json_state_t; - - -/* - * Forward declarations. - */ -static bool -_bson_as_json_visit_array (const bson_iter_t *iter, - const char *key, - const bson_t *v_array, - void *data); -static bool -_bson_as_json_visit_document (const bson_iter_t *iter, - const char *key, - const bson_t *v_document, - void *data); -static char * -_bson_as_json_visit_all (const bson_t *bson, - size_t *length, - bson_json_mode_t mode, - int32_t max_len, - bool is_outermost_array); - -/* - * Globals. - */ -static const uint8_t gZero; - -/* - *-------------------------------------------------------------------------- - * - * _bson_impl_inline_grow -- - * - * Document growth implementation for documents that currently - * contain stack based buffers. The document may be switched to - * a malloc based buffer. - * - * Returns: - * true if successful; otherwise false indicating BSON_MAX_SIZE overflow. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_bson_impl_inline_grow (bson_impl_inline_t *impl, /* IN */ - size_t size) /* IN */ -{ - bson_impl_alloc_t *alloc = (bson_impl_alloc_t *) impl; - uint8_t *data; - size_t req; - - if (((size_t) impl->len + size) <= sizeof impl->data) { - return true; - } - - req = bson_next_power_of_two (impl->len + size); - - if (req <= BSON_MAX_SIZE) { - data = bson_malloc (req); - - memcpy (data, impl->data, impl->len); -#ifdef BSON_MEMCHECK - bson_free (impl->canary); -#endif - alloc->flags &= ~BSON_FLAG_INLINE; - alloc->parent = NULL; - alloc->depth = 0; - alloc->buf = &alloc->alloc; - alloc->buflen = &alloc->alloclen; - alloc->offset = 0; - alloc->alloc = data; - alloc->alloclen = req; - alloc->realloc = bson_realloc_ctx; - alloc->realloc_func_ctx = NULL; - - return true; - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _bson_impl_alloc_grow -- - * - * Document growth implementation for documents containing malloc - * based buffers. - * - * Returns: - * true if successful; otherwise false indicating BSON_MAX_SIZE overflow. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_bson_impl_alloc_grow (bson_impl_alloc_t *impl, /* IN */ - size_t size) /* IN */ -{ - size_t req; - - /* - * Determine how many bytes we need for this document in the buffer - * including necessary trailing bytes for parent documents. - */ - req = (impl->offset + impl->len + size + impl->depth); - - if (req <= *impl->buflen) { - return true; - } - - req = bson_next_power_of_two (req); - - if ((req <= BSON_MAX_SIZE) && impl->realloc) { - *impl->buf = impl->realloc (*impl->buf, req, impl->realloc_func_ctx); - *impl->buflen = req; - return true; - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _bson_grow -- - * - * Grows the bson_t structure to be large enough to contain @size - * bytes. - * - * Returns: - * true if successful, false if the size would overflow. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_bson_grow (bson_t *bson, /* IN */ - uint32_t size) /* IN */ -{ - if ((bson->flags & BSON_FLAG_INLINE)) { - return _bson_impl_inline_grow ((bson_impl_inline_t *) bson, size); - } - - return _bson_impl_alloc_grow ((bson_impl_alloc_t *) bson, size); -} - - -/* - *-------------------------------------------------------------------------- - * - * _bson_data -- - * - * A helper function to return the contents of the bson document - * taking into account the polymorphic nature of bson_t. - * - * Returns: - * A buffer which should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static BSON_INLINE uint8_t * -_bson_data (const bson_t *bson) /* IN */ -{ - if ((bson->flags & BSON_FLAG_INLINE)) { - return ((bson_impl_inline_t *) bson)->data; - } else { - bson_impl_alloc_t *impl = (bson_impl_alloc_t *) bson; - return (*impl->buf) + impl->offset; - } -} - - -/* - *-------------------------------------------------------------------------- - * - * _bson_encode_length -- - * - * Helper to encode the length of the bson_t in the first 4 bytes - * of the bson document. Little endian format is used as specified - * by bsonspec. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static BSON_INLINE void -_bson_encode_length (bson_t *bson) /* IN */ -{ -#if BSON_BYTE_ORDER == BSON_LITTLE_ENDIAN - memcpy (_bson_data (bson), &bson->len, sizeof (bson->len)); -#else - uint32_t length_le = BSON_UINT32_TO_LE (bson->len); - memcpy (_bson_data (bson), &length_le, sizeof (length_le)); -#endif -} - - -/* - *-------------------------------------------------------------------------- - * - * _bson_append_va -- - * - * Appends the length,buffer pairs to the bson_t. @n_bytes is an - * optimization to perform one array growth rather than many small - * growths. - * - * @bson: A bson_t - * @n_bytes: The number of bytes to append to the document. - * @n_pairs: The number of length,buffer pairs. - * @first_len: Length of first buffer. - * @first_data: First buffer. - * @args: va_list of additional tuples. - * - * Returns: - * true if the bytes were appended successfully. - * false if it bson would overflow BSON_MAX_SIZE. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static BSON_INLINE bool -_bson_append_va (bson_t *bson, /* IN */ - uint32_t n_bytes, /* IN */ - uint32_t n_pairs, /* IN */ - uint32_t first_len, /* IN */ - const uint8_t *first_data, /* IN */ - va_list args) /* IN */ -{ - const uint8_t *data; - uint32_t data_len; - uint8_t *buf; - - BSON_ASSERT (!(bson->flags & BSON_FLAG_IN_CHILD)); - BSON_ASSERT (!(bson->flags & BSON_FLAG_RDONLY)); - - if (BSON_UNLIKELY (!_bson_grow (bson, n_bytes))) { - return false; - } - - data = first_data; - data_len = first_len; - - buf = _bson_data (bson) + bson->len - 1; - - do { - n_pairs--; - /* data may be NULL if data_len is 0. memcpy is not safe to call with - * NULL. */ - if (BSON_LIKELY (data_len != 0 && data != NULL)) { - memcpy (buf, data, data_len); - bson->len += data_len; - buf += data_len; - } else if (BSON_UNLIKELY (data_len != 0 && data == NULL)) { - /* error, user appending NULL with non-zero length. */ - return false; - } - - if (n_pairs) { - data_len = va_arg (args, uint32_t); - data = va_arg (args, const uint8_t *); - } - } while (n_pairs); - - _bson_encode_length (bson); - - *buf = '\0'; - - return true; -} - - -/* - *-------------------------------------------------------------------------- - * - * _bson_append -- - * - * Variadic function to append length,buffer pairs to a bson_t. If the - * append would cause the bson_t to overflow a 32-bit length, it will - * return false and no append will have occurred. - * - * Parameters: - * @bson: A bson_t. - * @n_pairs: Number of length,buffer pairs. - * @n_bytes: the total number of bytes being appended. - * @first_len: Length of first buffer. - * @first_data: First buffer. - * - * Returns: - * true if successful; otherwise false indicating BSON_MAX_SIZE overflow. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_bson_append (bson_t *bson, /* IN */ - uint32_t n_pairs, /* IN */ - uint32_t n_bytes, /* IN */ - uint32_t first_len, /* IN */ - const uint8_t *first_data, /* IN */ - ...) -{ - va_list args; - bool ok; - - BSON_ASSERT (n_pairs); - BSON_ASSERT (first_len); - BSON_ASSERT (first_data); - - /* - * Check to see if this append would overflow 32-bit signed integer. I know - * what you're thinking. BSON uses a signed 32-bit length field? Yeah. It - * does. - */ - if (BSON_UNLIKELY (n_bytes > (BSON_MAX_SIZE - bson->len))) { - return false; - } - - va_start (args, first_data); - ok = _bson_append_va (bson, n_bytes, n_pairs, first_len, first_data, args); - va_end (args); - - return ok; -} - -static BSON_INLINE bool -_string_contains_null (const char *str, size_t len) -{ - for (; len; ++str, --len) { - if (*str == 0) { - return true; - } - } - return false; -} - -#define HANDLE_KEY_LENGTH(key, key_length) \ - do { \ - if (key_length < 0) { \ - key_length = (int) strlen (key); \ - } else { \ - /* Necessary to validate embedded NULL is not present in key. */ \ - if (_string_contains_null (key, key_length)) { \ - return false; \ - } \ - } \ - } while (0) - -/* - *-------------------------------------------------------------------------- - * - * _bson_append_bson_begin -- - * - * Begin appending a subdocument or subarray to the document using - * the key provided by @key. - * - * If @key_length is < 0, then strlen() will be called on @key - * to determine the length. - * - * @key_type MUST be either BSON_TYPE_DOCUMENT or BSON_TYPE_ARRAY. - * - * Returns: - * true if successful; otherwise false indicating BSON_MAX_SIZE overflow. - * - * Side effects: - * @child is initialized if true is returned. - * - *-------------------------------------------------------------------------- - */ - -static bool -_bson_append_bson_begin (bson_t *bson, /* IN */ - const char *key, /* IN */ - int key_length, /* IN */ - bson_type_t child_type, /* IN */ - bson_t *child) /* OUT */ -{ - const uint8_t type = child_type; - const uint8_t empty[5] = {5}; - bson_impl_alloc_t *aparent = (bson_impl_alloc_t *) bson; - bson_impl_alloc_t *achild = (bson_impl_alloc_t *) child; - - BSON_ASSERT (!(bson->flags & BSON_FLAG_RDONLY)); - BSON_ASSERT (!(bson->flags & BSON_FLAG_IN_CHILD)); - BSON_ASSERT (key); - BSON_ASSERT ((child_type == BSON_TYPE_DOCUMENT) || - (child_type == BSON_TYPE_ARRAY)); - BSON_ASSERT (child); - - HANDLE_KEY_LENGTH (key, key_length); - - /* - * If the parent is an inline bson_t, then we need to convert - * it to a heap allocated buffer. This makes extending buffers - * of child bson documents much simpler logic, as they can just - * realloc the *buf pointer. - */ - if ((bson->flags & BSON_FLAG_INLINE)) { - BSON_ASSERT (bson->len <= 120); - if (!_bson_grow (bson, 128 - bson->len)) { - return false; - } - BSON_ASSERT (!(bson->flags & BSON_FLAG_INLINE)); - } - - /* - * Append the type and key for the field. - */ - if (!_bson_append (bson, - 4, - (1 + key_length + 1 + 5), - 1, - &type, - key_length, - key, - 1, - &gZero, - 5, - empty)) { - return false; - } - - /* - * Mark the document as working on a child document so that no - * further modifications can happen until the caller has called - * bson_append_{document,array}_end(). - */ - bson->flags |= BSON_FLAG_IN_CHILD; - - /* - * Initialize the child bson_t structure and point it at the parents - * buffers. This allows us to realloc directly from the child without - * walking up to the parent bson_t. - */ - achild->flags = (BSON_FLAG_CHILD | BSON_FLAG_NO_FREE | BSON_FLAG_STATIC); - - if ((bson->flags & BSON_FLAG_CHILD)) { - achild->depth = ((bson_impl_alloc_t *) bson)->depth + 1; - } else { - achild->depth = 1; - } - - achild->parent = bson; - achild->buf = aparent->buf; - achild->buflen = aparent->buflen; - achild->offset = aparent->offset + aparent->len - 1 - 5; - achild->len = 5; - achild->alloc = NULL; - achild->alloclen = 0; - achild->realloc = aparent->realloc; - achild->realloc_func_ctx = aparent->realloc_func_ctx; - - return true; -} - - -/* - *-------------------------------------------------------------------------- - * - * _bson_append_bson_end -- - * - * Complete a call to _bson_append_bson_begin. - * - * Returns: - * true if successful. - * - * Side effects: - * @child is destroyed and no longer valid after calling this - * function. - * - *-------------------------------------------------------------------------- - */ - -static bool -_bson_append_bson_end (bson_t *bson, /* IN */ - bson_t *child) /* IN */ -{ - BSON_ASSERT (bson); - BSON_ASSERT ((bson->flags & BSON_FLAG_IN_CHILD)); - BSON_ASSERT (!(child->flags & BSON_FLAG_IN_CHILD)); - - /* - * Unmark the IN_CHILD flag. - */ - bson->flags &= ~BSON_FLAG_IN_CHILD; - - /* - * Now that we are done building the sub-document, add the size to the - * parent, not including the default 5 byte empty document already added. - */ - bson->len = (bson->len + child->len - 5); - - /* - * Ensure we have a \0 byte at the end and proper length encoded at - * the beginning of the document. - */ - _bson_data (bson)[bson->len - 1] = '\0'; - _bson_encode_length (bson); - - return true; -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_array_begin -- - * - * Start appending a new array. - * - * Use @child to append to the data area for the given field. - * - * It is a programming error to call any other bson function on - * @bson until bson_append_array_end() has been called. It is - * valid to call bson_append*() functions on @child. - * - * This function is useful to allow building nested documents using - * a single buffer owned by the top-level bson document. - * - * Returns: - * true if successful; otherwise false and @child is invalid. - * - * Side effects: - * @child is initialized if true is returned. - * - *-------------------------------------------------------------------------- - */ - -bool -bson_append_array_begin (bson_t *bson, /* IN */ - const char *key, /* IN */ - int key_length, /* IN */ - bson_t *child) /* IN */ -{ - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (child); - - return _bson_append_bson_begin ( - bson, key, key_length, BSON_TYPE_ARRAY, child); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_array_end -- - * - * Complete a call to bson_append_array_begin(). - * - * It is safe to append other fields to @bson after calling this - * function. - * - * Returns: - * true if successful. - * - * Side effects: - * @child is invalid after calling this function. - * - *-------------------------------------------------------------------------- - */ - -bool -bson_append_array_end (bson_t *bson, /* IN */ - bson_t *child) /* IN */ -{ - BSON_ASSERT (bson); - BSON_ASSERT (child); - - return _bson_append_bson_end (bson, child); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_document_begin -- - * - * Start appending a new document. - * - * Use @child to append to the data area for the given field. - * - * It is a programming error to call any other bson function on - * @bson until bson_append_document_end() has been called. It is - * valid to call bson_append*() functions on @child. - * - * This function is useful to allow building nested documents using - * a single buffer owned by the top-level bson document. - * - * Returns: - * true if successful; otherwise false and @child is invalid. - * - * Side effects: - * @child is initialized if true is returned. - * - *-------------------------------------------------------------------------- - */ -bool -bson_append_document_begin (bson_t *bson, /* IN */ - const char *key, /* IN */ - int key_length, /* IN */ - bson_t *child) /* IN */ -{ - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (child); - - return _bson_append_bson_begin ( - bson, key, key_length, BSON_TYPE_DOCUMENT, child); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_document_end -- - * - * Complete a call to bson_append_document_begin(). - * - * It is safe to append new fields to @bson after calling this - * function, if true is returned. - * - * Returns: - * true if successful; otherwise false indicating BSON_MAX_SIZE overflow. - * - * Side effects: - * @child is destroyed and invalid after calling this function. - * - *-------------------------------------------------------------------------- - */ - -bool -bson_append_document_end (bson_t *bson, /* IN */ - bson_t *child) /* IN */ -{ - BSON_ASSERT (bson); - BSON_ASSERT (child); - - return _bson_append_bson_end (bson, child); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_array -- - * - * Append an array to @bson. - * - * Generally, bson_append_array_begin() will result in faster code - * since few buffers need to be malloced. - * - * Returns: - * true if successful; otherwise false indicating BSON_MAX_SIZE overflow. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -bson_append_array (bson_t *bson, /* IN */ - const char *key, /* IN */ - int key_length, /* IN */ - const bson_t *array) /* IN */ -{ - static const uint8_t type = BSON_TYPE_ARRAY; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (array); - - HANDLE_KEY_LENGTH (key, key_length); - - /* - * Let's be a bit pedantic and ensure the array has properly formatted key - * names. We will verify this simply by checking the first element for "0" - * if the array is non-empty. - */ - if (array && !bson_empty (array)) { - bson_iter_t iter; - - if (bson_iter_init (&iter, array) && bson_iter_next (&iter)) { - if (0 != strcmp ("0", bson_iter_key (&iter))) { - fprintf (stderr, - "%s(): invalid array detected. first element of array " - "parameter is not \"0\".\n", - BSON_FUNC); - } - } - } - - return _bson_append (bson, - 4, - (1 + key_length + 1 + array->len), - 1, - &type, - key_length, - key, - 1, - &gZero, - array->len, - _bson_data (array)); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_binary -- - * - * Append binary data to @bson. The field will have the - * BSON_TYPE_BINARY type. - * - * Parameters: - * @subtype: the BSON Binary Subtype. See bsonspec.org for more - * information. - * @binary: a pointer to the raw binary data. - * @length: the size of @binary in bytes. - * - * Returns: - * true if successful; otherwise false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -bson_append_binary (bson_t *bson, /* IN */ - const char *key, /* IN */ - int key_length, /* IN */ - bson_subtype_t subtype, /* IN */ - const uint8_t *binary, /* IN */ - uint32_t length) /* IN */ -{ - static const uint8_t type = BSON_TYPE_BINARY; - uint32_t length_le; - uint32_t deprecated_length_le; - uint8_t subtype8 = 0; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - subtype8 = subtype; - - if (subtype == BSON_SUBTYPE_BINARY_DEPRECATED) { - length_le = BSON_UINT32_TO_LE (length + 4); - deprecated_length_le = BSON_UINT32_TO_LE (length); - - return _bson_append (bson, - 7, - (1 + key_length + 1 + 4 + 1 + 4 + length), - 1, - &type, - key_length, - key, - 1, - &gZero, - 4, - &length_le, - 1, - &subtype8, - 4, - &deprecated_length_le, - length, - binary); - } else { - length_le = BSON_UINT32_TO_LE (length); - - return _bson_append (bson, - 6, - (1 + key_length + 1 + 4 + 1 + length), - 1, - &type, - key_length, - key, - 1, - &gZero, - 4, - &length_le, - 1, - &subtype8, - length, - binary); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_bool -- - * - * Append a new field to @bson with the name @key. The value is - * a boolean indicated by @value. - * - * Returns: - * true if successful; otherwise false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -bson_append_bool (bson_t *bson, /* IN */ - const char *key, /* IN */ - int key_length, /* IN */ - bool value) /* IN */ -{ - static const uint8_t type = BSON_TYPE_BOOL; - uint8_t abyte = !!value; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - return _bson_append (bson, - 4, - (1 + key_length + 1 + 1), - 1, - &type, - key_length, - key, - 1, - &gZero, - 1, - &abyte); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_code -- - * - * Append a new field to @bson containing javascript code. - * - * @javascript MUST be a zero terminated UTF-8 string. It MUST NOT - * containing embedded \0 characters. - * - * Returns: - * true if successful; otherwise false. - * - * Side effects: - * None. - * - * See also: - * bson_append_code_with_scope(). - * - *-------------------------------------------------------------------------- - */ - -bool -bson_append_code (bson_t *bson, /* IN */ - const char *key, /* IN */ - int key_length, /* IN */ - const char *javascript) /* IN */ -{ - static const uint8_t type = BSON_TYPE_CODE; - uint32_t length; - uint32_t length_le; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (javascript); - - HANDLE_KEY_LENGTH (key, key_length); - - length = (int) strlen (javascript) + 1; - length_le = BSON_UINT32_TO_LE (length); - - return _bson_append (bson, - 5, - (1 + key_length + 1 + 4 + length), - 1, - &type, - key_length, - key, - 1, - &gZero, - 4, - &length_le, - length, - javascript); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_code_with_scope -- - * - * Append a new field to @bson containing javascript code with - * supplied scope. - * - * Returns: - * true if successful; otherwise false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -bson_append_code_with_scope (bson_t *bson, /* IN */ - const char *key, /* IN */ - int key_length, /* IN */ - const char *javascript, /* IN */ - const bson_t *scope) /* IN */ -{ - static const uint8_t type = BSON_TYPE_CODEWSCOPE; - uint32_t codews_length_le; - uint32_t codews_length; - uint32_t js_length_le; - uint32_t js_length; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (javascript); - - if (scope == NULL) { - return bson_append_code (bson, key, key_length, javascript); - } - - HANDLE_KEY_LENGTH (key, key_length); - - js_length = (int) strlen (javascript) + 1; - js_length_le = BSON_UINT32_TO_LE (js_length); - - codews_length = 4 + 4 + js_length + scope->len; - codews_length_le = BSON_UINT32_TO_LE (codews_length); - - return _bson_append (bson, - 7, - (1 + key_length + 1 + 4 + 4 + js_length + scope->len), - 1, - &type, - key_length, - key, - 1, - &gZero, - 4, - &codews_length_le, - 4, - &js_length_le, - js_length, - javascript, - scope->len, - _bson_data (scope)); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_dbpointer -- - * - * This BSON data type is DEPRECATED. - * - * Append a BSON dbpointer field to @bson. - * - * Returns: - * true if successful; otherwise false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -bson_append_dbpointer (bson_t *bson, /* IN */ - const char *key, /* IN */ - int key_length, /* IN */ - const char *collection, /* IN */ - const bson_oid_t *oid) -{ - static const uint8_t type = BSON_TYPE_DBPOINTER; - uint32_t length; - uint32_t length_le; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (collection); - BSON_ASSERT (oid); - - HANDLE_KEY_LENGTH (key, key_length); - - length = (int) strlen (collection) + 1; - length_le = BSON_UINT32_TO_LE (length); - - return _bson_append (bson, - 6, - (1 + key_length + 1 + 4 + length + 12), - 1, - &type, - key_length, - key, - 1, - &gZero, - 4, - &length_le, - length, - collection, - 12, - oid); -} - - -/* - *-------------------------------------------------------------------------- - * - * bson_append_document -- - * - * Append a new field to @bson containing a BSON document. - * - * In general, using bson_append_document_begin() results in faster - * code and less memory fragmentation. - * - * Returns: - * true if successful; otherwise false. - * - * Side effects: - * None. - * - * See also: - * bson_append_document_begin(). - * - *-------------------------------------------------------------------------- - */ - -bool -bson_append_document (bson_t *bson, /* IN */ - const char *key, /* IN */ - int key_length, /* IN */ - const bson_t *value) /* IN */ -{ - static const uint8_t type = BSON_TYPE_DOCUMENT; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (value); - - HANDLE_KEY_LENGTH (key, key_length); - - return _bson_append (bson, - 4, - (1 + key_length + 1 + value->len), - 1, - &type, - key_length, - key, - 1, - &gZero, - value->len, - _bson_data (value)); -} - - -bool -bson_append_double (bson_t *bson, const char *key, int key_length, double value) -{ - static const uint8_t type = BSON_TYPE_DOUBLE; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - -#if BSON_BYTE_ORDER == BSON_BIG_ENDIAN - value = BSON_DOUBLE_TO_LE (value); -#endif - - return _bson_append (bson, - 4, - (1 + key_length + 1 + 8), - 1, - &type, - key_length, - key, - 1, - &gZero, - 8, - &value); -} - - -bool -bson_append_int32 (bson_t *bson, const char *key, int key_length, int32_t value) -{ - static const uint8_t type = BSON_TYPE_INT32; - uint32_t value_le; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - value_le = BSON_UINT32_TO_LE (value); - - return _bson_append (bson, - 4, - (1 + key_length + 1 + 4), - 1, - &type, - key_length, - key, - 1, - &gZero, - 4, - &value_le); -} - - -bool -bson_append_int64 (bson_t *bson, const char *key, int key_length, int64_t value) -{ - static const uint8_t type = BSON_TYPE_INT64; - uint64_t value_le; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - value_le = BSON_UINT64_TO_LE (value); - - return _bson_append (bson, - 4, - (1 + key_length + 1 + 8), - 1, - &type, - key_length, - key, - 1, - &gZero, - 8, - &value_le); -} - - -bool -bson_append_decimal128 (bson_t *bson, - const char *key, - int key_length, - const bson_decimal128_t *value) -{ - static const uint8_t type = BSON_TYPE_DECIMAL128; - uint64_t value_le[2]; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (value); - - HANDLE_KEY_LENGTH (key, key_length); - - value_le[0] = BSON_UINT64_TO_LE (value->low); - value_le[1] = BSON_UINT64_TO_LE (value->high); - - return _bson_append (bson, - 4, - (1 + key_length + 1 + 16), - 1, - &type, - key_length, - key, - 1, - &gZero, - 16, - value_le); -} - - -bool -bson_append_iter (bson_t *bson, - const char *key, - int key_length, - const bson_iter_t *iter) -{ - bool ret = false; - - BSON_ASSERT (bson); - BSON_ASSERT (iter); - - if (!key) { - key = bson_iter_key (iter); - key_length = -1; - } - - switch (bson_iter_type_unsafe (iter)) { - case BSON_TYPE_EOD: - return false; - case BSON_TYPE_DOUBLE: - ret = bson_append_double (bson, key, key_length, bson_iter_double (iter)); - break; - case BSON_TYPE_UTF8: { - uint32_t len = 0; - const char *str; - - str = bson_iter_utf8 (iter, &len); - ret = bson_append_utf8 (bson, key, key_length, str, len); - } break; - case BSON_TYPE_DOCUMENT: { - const uint8_t *buf = NULL; - uint32_t len = 0; - bson_t doc; - - bson_iter_document (iter, &len, &buf); - - if (bson_init_static (&doc, buf, len)) { - ret = bson_append_document (bson, key, key_length, &doc); - bson_destroy (&doc); - } - } break; - case BSON_TYPE_ARRAY: { - const uint8_t *buf = NULL; - uint32_t len = 0; - bson_t doc; - - bson_iter_array (iter, &len, &buf); - - if (bson_init_static (&doc, buf, len)) { - ret = bson_append_array (bson, key, key_length, &doc); - bson_destroy (&doc); - } - } break; - case BSON_TYPE_BINARY: { - const uint8_t *binary = NULL; - bson_subtype_t subtype = BSON_SUBTYPE_BINARY; - uint32_t len = 0; - - bson_iter_binary (iter, &subtype, &len, &binary); - ret = bson_append_binary (bson, key, key_length, subtype, binary, len); - } break; - case BSON_TYPE_UNDEFINED: - ret = bson_append_undefined (bson, key, key_length); - break; - case BSON_TYPE_OID: - ret = bson_append_oid (bson, key, key_length, bson_iter_oid (iter)); - break; - case BSON_TYPE_BOOL: - ret = bson_append_bool (bson, key, key_length, bson_iter_bool (iter)); - break; - case BSON_TYPE_DATE_TIME: - ret = bson_append_date_time ( - bson, key, key_length, bson_iter_date_time (iter)); - break; - case BSON_TYPE_NULL: - ret = bson_append_null (bson, key, key_length); - break; - case BSON_TYPE_REGEX: { - const char *regex; - const char *options; - - regex = bson_iter_regex (iter, &options); - ret = bson_append_regex (bson, key, key_length, regex, options); - } break; - case BSON_TYPE_DBPOINTER: { - const bson_oid_t *oid; - uint32_t len; - const char *collection; - - bson_iter_dbpointer (iter, &len, &collection, &oid); - ret = bson_append_dbpointer (bson, key, key_length, collection, oid); - } break; - case BSON_TYPE_CODE: { - uint32_t len; - const char *code; - - code = bson_iter_code (iter, &len); - ret = bson_append_code (bson, key, key_length, code); - } break; - case BSON_TYPE_SYMBOL: { - uint32_t len; - const char *symbol; - - symbol = bson_iter_symbol (iter, &len); - ret = bson_append_symbol (bson, key, key_length, symbol, len); - } break; - case BSON_TYPE_CODEWSCOPE: { - const uint8_t *scope = NULL; - uint32_t scope_len = 0; - uint32_t len = 0; - const char *javascript = NULL; - bson_t doc; - - javascript = bson_iter_codewscope (iter, &len, &scope_len, &scope); - - if (bson_init_static (&doc, scope, scope_len)) { - ret = bson_append_code_with_scope ( - bson, key, key_length, javascript, &doc); - bson_destroy (&doc); - } - } break; - case BSON_TYPE_INT32: - ret = bson_append_int32 (bson, key, key_length, bson_iter_int32 (iter)); - break; - case BSON_TYPE_TIMESTAMP: { - uint32_t ts; - uint32_t inc; - - bson_iter_timestamp (iter, &ts, &inc); - ret = bson_append_timestamp (bson, key, key_length, ts, inc); - } break; - case BSON_TYPE_INT64: - ret = bson_append_int64 (bson, key, key_length, bson_iter_int64 (iter)); - break; - case BSON_TYPE_DECIMAL128: { - bson_decimal128_t dec; - - if (!bson_iter_decimal128 (iter, &dec)) { - return false; - } - - ret = bson_append_decimal128 (bson, key, key_length, &dec); - } break; - case BSON_TYPE_MAXKEY: - ret = bson_append_maxkey (bson, key, key_length); - break; - case BSON_TYPE_MINKEY: - ret = bson_append_minkey (bson, key, key_length); - break; - default: - break; - } - - return ret; -} - - -bool -bson_append_maxkey (bson_t *bson, const char *key, int key_length) -{ - static const uint8_t type = BSON_TYPE_MAXKEY; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - return _bson_append ( - bson, 3, (1 + key_length + 1), 1, &type, key_length, key, 1, &gZero); -} - - -bool -bson_append_minkey (bson_t *bson, const char *key, int key_length) -{ - static const uint8_t type = BSON_TYPE_MINKEY; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - return _bson_append ( - bson, 3, (1 + key_length + 1), 1, &type, key_length, key, 1, &gZero); -} - - -bool -bson_append_null (bson_t *bson, const char *key, int key_length) -{ - static const uint8_t type = BSON_TYPE_NULL; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - return _bson_append ( - bson, 3, (1 + key_length + 1), 1, &type, key_length, key, 1, &gZero); -} - - -bool -bson_append_oid (bson_t *bson, - const char *key, - int key_length, - const bson_oid_t *value) -{ - static const uint8_t type = BSON_TYPE_OID; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (value); - - HANDLE_KEY_LENGTH (key, key_length); - - return _bson_append (bson, - 4, - (1 + key_length + 1 + 12), - 1, - &type, - key_length, - key, - 1, - &gZero, - 12, - value); -} - - -/* - *-------------------------------------------------------------------------- - * - * _bson_append_regex_options_sorted -- - * - * Helper to append regex options to a buffer in a sorted order. - * Any duplicate or unsupported options will be ignored. - * - * Parameters: - * @buffer: Buffer to which sorted options will be appended - * @options: Regex options - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static BSON_INLINE void -_bson_append_regex_options_sorted (bson_string_t *buffer, /* IN */ - const char *options) /* IN */ -{ - const char *c; - - for (c = BSON_REGEX_OPTIONS_SORTED; *c; c++) { - if (strchr (options, *c)) { - bson_string_append_c (buffer, *c); - } - } -} - - -bool -bson_append_regex (bson_t *bson, - const char *key, - int key_length, - const char *regex, - const char *options) -{ - return bson_append_regex_w_len (bson, key, key_length, regex, -1, options); -} - - -bool -bson_append_regex_w_len (bson_t *bson, - const char *key, - int key_length, - const char *regex, - int regex_length, - const char *options) -{ - static const uint8_t type = BSON_TYPE_REGEX; - bson_string_t *options_sorted; - bool r; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - if (regex_length < 0) { - regex_length = (int) strlen (regex); - } else { - /* Necessary to validate embedded NULL is not present in key. */ - if (_string_contains_null (regex, regex_length)) { - return false; - } - } - - if (!regex) { - regex = ""; - } - - if (!options) { - options = ""; - } - - options_sorted = bson_string_new (NULL); - - _bson_append_regex_options_sorted (options_sorted, options); - - r = _bson_append ( - bson, - 6, - (1 + key_length + 1 + regex_length + 1 + options_sorted->len + 1), - 1, - &type, - key_length, - key, - 1, - &gZero, - regex_length, - regex, - 1, - &gZero, - options_sorted->len + 1, - options_sorted->str); - - bson_string_free (options_sorted, true); - - return r; -} - - -bool -bson_append_utf8 ( - bson_t *bson, const char *key, int key_length, const char *value, int length) -{ - static const uint8_t type = BSON_TYPE_UTF8; - uint32_t length_le; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - if (BSON_UNLIKELY (!value)) { - return bson_append_null (bson, key, key_length); - } - - HANDLE_KEY_LENGTH (key, key_length); - - if (BSON_UNLIKELY (length < 0)) { - length = (int) strlen (value); - } - - length_le = BSON_UINT32_TO_LE (length + 1); - - return _bson_append (bson, - 6, - (1 + key_length + 1 + 4 + length + 1), - 1, - &type, - key_length, - key, - 1, - &gZero, - 4, - &length_le, - length, - value, - 1, - &gZero); -} - - -bool -bson_append_symbol ( - bson_t *bson, const char *key, int key_length, const char *value, int length) -{ - static const uint8_t type = BSON_TYPE_SYMBOL; - uint32_t length_le; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - if (!value) { - return bson_append_null (bson, key, key_length); - } - - HANDLE_KEY_LENGTH (key, key_length); - - if (length < 0) { - length = (int) strlen (value); - } - - length_le = BSON_UINT32_TO_LE (length + 1); - - return _bson_append (bson, - 6, - (1 + key_length + 1 + 4 + length + 1), - 1, - &type, - key_length, - key, - 1, - &gZero, - 4, - &length_le, - length, - value, - 1, - &gZero); -} - - -bool -bson_append_time_t (bson_t *bson, const char *key, int key_length, time_t value) -{ -#ifdef BSON_OS_WIN32 - struct timeval tv = {(long) value, 0}; -#else - struct timeval tv = {value, 0}; -#endif - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - return bson_append_timeval (bson, key, key_length, &tv); -} - - -bool -bson_append_timestamp (bson_t *bson, - const char *key, - int key_length, - uint32_t timestamp, - uint32_t increment) -{ - static const uint8_t type = BSON_TYPE_TIMESTAMP; - uint64_t value; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - value = ((((uint64_t) timestamp) << 32) | ((uint64_t) increment)); - value = BSON_UINT64_TO_LE (value); - - return _bson_append (bson, - 4, - (1 + key_length + 1 + 8), - 1, - &type, - key_length, - key, - 1, - &gZero, - 8, - &value); -} - - -bool -bson_append_now_utc (bson_t *bson, const char *key, int key_length) -{ - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (key_length >= -1); - - return bson_append_time_t (bson, key, key_length, time (NULL)); -} - - -bool -bson_append_date_time (bson_t *bson, - const char *key, - int key_length, - int64_t value) -{ - static const uint8_t type = BSON_TYPE_DATE_TIME; - uint64_t value_le; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - value_le = BSON_UINT64_TO_LE (value); - - return _bson_append (bson, - 4, - (1 + key_length + 1 + 8), - 1, - &type, - key_length, - key, - 1, - &gZero, - 8, - &value_le); -} - - -bool -bson_append_timeval (bson_t *bson, - const char *key, - int key_length, - struct timeval *value) -{ - uint64_t unix_msec; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (value); - - unix_msec = - (((uint64_t) value->tv_sec) * 1000UL) + (value->tv_usec / 1000UL); - return bson_append_date_time (bson, key, key_length, unix_msec); -} - - -bool -bson_append_undefined (bson_t *bson, const char *key, int key_length) -{ - static const uint8_t type = BSON_TYPE_UNDEFINED; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - HANDLE_KEY_LENGTH (key, key_length); - - return _bson_append ( - bson, 3, (1 + key_length + 1), 1, &type, key_length, key, 1, &gZero); -} - - -bool -bson_append_value (bson_t *bson, - const char *key, - int key_length, - const bson_value_t *value) -{ - bson_t local; - bool ret = false; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - BSON_ASSERT (value); - - switch (value->value_type) { - case BSON_TYPE_DOUBLE: - ret = bson_append_double (bson, key, key_length, value->value.v_double); - break; - case BSON_TYPE_UTF8: - ret = bson_append_utf8 (bson, - key, - key_length, - value->value.v_utf8.str, - value->value.v_utf8.len); - break; - case BSON_TYPE_DOCUMENT: - if (bson_init_static ( - &local, value->value.v_doc.data, value->value.v_doc.data_len)) { - ret = bson_append_document (bson, key, key_length, &local); - bson_destroy (&local); - } - break; - case BSON_TYPE_ARRAY: - if (bson_init_static ( - &local, value->value.v_doc.data, value->value.v_doc.data_len)) { - ret = bson_append_array (bson, key, key_length, &local); - bson_destroy (&local); - } - break; - case BSON_TYPE_BINARY: - ret = bson_append_binary (bson, - key, - key_length, - value->value.v_binary.subtype, - value->value.v_binary.data, - value->value.v_binary.data_len); - break; - case BSON_TYPE_UNDEFINED: - ret = bson_append_undefined (bson, key, key_length); - break; - case BSON_TYPE_OID: - ret = bson_append_oid (bson, key, key_length, &value->value.v_oid); - break; - case BSON_TYPE_BOOL: - ret = bson_append_bool (bson, key, key_length, value->value.v_bool); - break; - case BSON_TYPE_DATE_TIME: - ret = - bson_append_date_time (bson, key, key_length, value->value.v_datetime); - break; - case BSON_TYPE_NULL: - ret = bson_append_null (bson, key, key_length); - break; - case BSON_TYPE_REGEX: - ret = bson_append_regex (bson, - key, - key_length, - value->value.v_regex.regex, - value->value.v_regex.options); - break; - case BSON_TYPE_DBPOINTER: - ret = bson_append_dbpointer (bson, - key, - key_length, - value->value.v_dbpointer.collection, - &value->value.v_dbpointer.oid); - break; - case BSON_TYPE_CODE: - ret = bson_append_code (bson, key, key_length, value->value.v_code.code); - break; - case BSON_TYPE_SYMBOL: - ret = bson_append_symbol (bson, - key, - key_length, - value->value.v_symbol.symbol, - value->value.v_symbol.len); - break; - case BSON_TYPE_CODEWSCOPE: - if (bson_init_static (&local, - value->value.v_codewscope.scope_data, - value->value.v_codewscope.scope_len)) { - ret = bson_append_code_with_scope ( - bson, key, key_length, value->value.v_codewscope.code, &local); - bson_destroy (&local); - } - break; - case BSON_TYPE_INT32: - ret = bson_append_int32 (bson, key, key_length, value->value.v_int32); - break; - case BSON_TYPE_TIMESTAMP: - ret = bson_append_timestamp (bson, - key, - key_length, - value->value.v_timestamp.timestamp, - value->value.v_timestamp.increment); - break; - case BSON_TYPE_INT64: - ret = bson_append_int64 (bson, key, key_length, value->value.v_int64); - break; - case BSON_TYPE_DECIMAL128: - ret = bson_append_decimal128 ( - bson, key, key_length, &(value->value.v_decimal128)); - break; - case BSON_TYPE_MAXKEY: - ret = bson_append_maxkey (bson, key, key_length); - break; - case BSON_TYPE_MINKEY: - ret = bson_append_minkey (bson, key, key_length); - break; - case BSON_TYPE_EOD: - default: - break; - } - - return ret; -} - - -void -bson_init (bson_t *bson) -{ - bson_impl_inline_t *impl = (bson_impl_inline_t *) bson; - - BSON_ASSERT (bson); - -#ifdef BSON_MEMCHECK - impl->canary = bson_malloc (1); -#endif - impl->flags = BSON_FLAG_INLINE | BSON_FLAG_STATIC; - impl->len = 5; - impl->data[0] = 5; - impl->data[1] = 0; - impl->data[2] = 0; - impl->data[3] = 0; - impl->data[4] = 0; -} - - -void -bson_reinit (bson_t *bson) -{ - uint8_t *data; - - BSON_ASSERT (bson); - - data = _bson_data (bson); - - bson->len = 5; - - data[0] = 5; - data[1] = 0; - data[2] = 0; - data[3] = 0; - data[4] = 0; -} - - -bool -bson_init_static (bson_t *bson, const uint8_t *data, size_t length) -{ - bson_impl_alloc_t *impl = (bson_impl_alloc_t *) bson; - uint32_t len_le; - - BSON_ASSERT (bson); - BSON_ASSERT (data); - - if ((length < 5) || (length > BSON_MAX_SIZE)) { - return false; - } - - memcpy (&len_le, data, sizeof (len_le)); - - if ((size_t) BSON_UINT32_FROM_LE (len_le) != length) { - return false; - } - - if (data[length - 1]) { - return false; - } - - impl->flags = BSON_FLAG_STATIC | BSON_FLAG_RDONLY; - impl->len = (uint32_t) length; - impl->parent = NULL; - impl->depth = 0; - impl->buf = &impl->alloc; - impl->buflen = &impl->alloclen; - impl->offset = 0; - impl->alloc = (uint8_t *) data; - impl->alloclen = length; - impl->realloc = NULL; - impl->realloc_func_ctx = NULL; - - return true; -} - - -bson_t * -bson_new (void) -{ - bson_impl_inline_t *impl; - bson_t *bson; - - bson = BSON_ALIGNED_ALLOC (bson_t); - - impl = (bson_impl_inline_t *) bson; - impl->flags = BSON_FLAG_INLINE; - impl->len = 5; -#ifdef BSON_MEMCHECK - impl->canary = bson_malloc (1); -#endif - impl->data[0] = 5; - impl->data[1] = 0; - impl->data[2] = 0; - impl->data[3] = 0; - impl->data[4] = 0; - - return bson; -} - - -bson_t * -bson_sized_new (size_t size) -{ - bson_impl_alloc_t *impl_a; - bson_t *b; - - BSON_ASSERT (size <= BSON_MAX_SIZE); - - { - b = BSON_ALIGNED_ALLOC (bson_t); - impl_a = (bson_impl_alloc_t *) b; - } - - if (size <= BSON_INLINE_DATA_SIZE) { - bson_init (b); - b->flags &= ~BSON_FLAG_STATIC; - } else { - impl_a->flags = BSON_FLAG_NONE; - impl_a->len = 5; - impl_a->parent = NULL; - impl_a->depth = 0; - impl_a->buf = &impl_a->alloc; - impl_a->buflen = &impl_a->alloclen; - impl_a->offset = 0; - impl_a->alloclen = BSON_MAX (5, size); - impl_a->alloc = bson_malloc (impl_a->alloclen); - impl_a->alloc[0] = 5; - impl_a->alloc[1] = 0; - impl_a->alloc[2] = 0; - impl_a->alloc[3] = 0; - impl_a->alloc[4] = 0; - impl_a->realloc = bson_realloc_ctx; - impl_a->realloc_func_ctx = NULL; - } - - return b; -} - - -bson_t * -bson_new_from_data (const uint8_t *data, size_t length) -{ - uint32_t len_le; - bson_t *bson; - - BSON_ASSERT (data); - - if ((length < 5) || (length > BSON_MAX_SIZE) || data[length - 1]) { - return NULL; - } - - memcpy (&len_le, data, sizeof (len_le)); - - if (length != (size_t) BSON_UINT32_FROM_LE (len_le)) { - return NULL; - } - - bson = bson_sized_new (length); - memcpy (_bson_data (bson), data, length); - bson->len = (uint32_t) length; - - return bson; -} - - -bson_t * -bson_new_from_buffer (uint8_t **buf, - size_t *buf_len, - bson_realloc_func realloc_func, - void *realloc_func_ctx) -{ - bson_impl_alloc_t *impl; - uint32_t len_le; - uint32_t length; - bson_t *bson; - - BSON_ASSERT (buf); - BSON_ASSERT (buf_len); - - if (!realloc_func) { - realloc_func = bson_realloc_ctx; - } - - bson = BSON_ALIGNED_ALLOC0 (bson_t); - impl = (bson_impl_alloc_t *) bson; - - if (!*buf) { - length = 5; - len_le = BSON_UINT32_TO_LE (length); - *buf_len = 5; - *buf = realloc_func (*buf, *buf_len, realloc_func_ctx); - memcpy (*buf, &len_le, sizeof (len_le)); - (*buf)[4] = '\0'; - } else { - if ((*buf_len < 5) || (*buf_len > BSON_MAX_SIZE)) { - bson_free (bson); - return NULL; - } - - memcpy (&len_le, *buf, sizeof (len_le)); - length = BSON_UINT32_FROM_LE (len_le); - } - - if ((*buf)[length - 1]) { - bson_free (bson); - return NULL; - } - - impl->flags = BSON_FLAG_NO_FREE; - impl->len = length; - impl->buf = buf; - impl->buflen = buf_len; - impl->realloc = realloc_func; - impl->realloc_func_ctx = realloc_func_ctx; - - return bson; -} - - -bson_t * -bson_copy (const bson_t *bson) -{ - const uint8_t *data; - - BSON_ASSERT (bson); - - data = _bson_data (bson); - return bson_new_from_data (data, bson->len); -} - - -void -bson_copy_to (const bson_t *src, bson_t *dst) -{ - const uint8_t *data; - bson_impl_alloc_t *adst; - size_t len; - - BSON_ASSERT (src); - BSON_ASSERT (dst); - - if ((src->flags & BSON_FLAG_INLINE)) { -#ifdef BSON_MEMCHECK - dst->len = src->len; - dst->canary = bson_malloc (1); - memcpy (dst->padding, src->padding, sizeof dst->padding); -#else - memcpy (dst, src, sizeof *dst); -#endif - dst->flags = (BSON_FLAG_STATIC | BSON_FLAG_INLINE); - return; - } - - data = _bson_data (src); - len = bson_next_power_of_two ((size_t) src->len); - - adst = (bson_impl_alloc_t *) dst; - adst->flags = BSON_FLAG_STATIC; - adst->len = src->len; - adst->parent = NULL; - adst->depth = 0; - adst->buf = &adst->alloc; - adst->buflen = &adst->alloclen; - adst->offset = 0; - adst->alloc = bson_malloc (len); - adst->alloclen = len; - adst->realloc = bson_realloc_ctx; - adst->realloc_func_ctx = NULL; - memcpy (adst->alloc, data, src->len); -} - - -static bool -should_ignore (const char *first_exclude, va_list args, const char *name) -{ - bool ret = false; - const char *exclude = first_exclude; - va_list args_copy; - - va_copy (args_copy, args); - - do { - if (!strcmp (name, exclude)) { - ret = true; - break; - } - } while ((exclude = va_arg (args_copy, const char *))); - - va_end (args_copy); - - return ret; -} - - -void -bson_copy_to_excluding_noinit_va (const bson_t *src, - bson_t *dst, - const char *first_exclude, - va_list args) -{ - bson_iter_t iter; - - if (bson_iter_init (&iter, src)) { - while (bson_iter_next (&iter)) { - if (!should_ignore (first_exclude, args, bson_iter_key (&iter))) { - if (!bson_append_iter (dst, NULL, 0, &iter)) { - /* - * This should not be able to happen since we are copying - * from within a valid bson_t. - */ - BSON_ASSERT (false); - return; - } - } - } - } -} - - -void -bson_copy_to_excluding (const bson_t *src, - bson_t *dst, - const char *first_exclude, - ...) -{ - va_list args; - - BSON_ASSERT (src); - BSON_ASSERT (dst); - BSON_ASSERT (first_exclude); - - bson_init (dst); - - va_start (args, first_exclude); - bson_copy_to_excluding_noinit_va (src, dst, first_exclude, args); - va_end (args); -} - -void -bson_copy_to_excluding_noinit (const bson_t *src, - bson_t *dst, - const char *first_exclude, - ...) -{ - va_list args; - - BSON_ASSERT (src); - BSON_ASSERT (dst); - BSON_ASSERT (first_exclude); - - va_start (args, first_exclude); - bson_copy_to_excluding_noinit_va (src, dst, first_exclude, args); - va_end (args); -} - -void -bson_destroy (bson_t *bson) -{ - if (!bson) { - return; - } - - if (!(bson->flags & - (BSON_FLAG_RDONLY | BSON_FLAG_INLINE | BSON_FLAG_NO_FREE))) { - bson_free (*((bson_impl_alloc_t *) bson)->buf); - } - -#ifdef BSON_MEMCHECK - if (bson->flags & BSON_FLAG_INLINE) { - bson_free (bson->canary); - } -#endif - - if (!(bson->flags & BSON_FLAG_STATIC)) { - bson_free (bson); - } -} - - -uint8_t * -bson_reserve_buffer (bson_t *bson, uint32_t size) -{ - if (bson->flags & - (BSON_FLAG_CHILD | BSON_FLAG_IN_CHILD | BSON_FLAG_RDONLY)) { - return NULL; - } - - if (!_bson_grow (bson, size)) { - return NULL; - } - - if (bson->flags & BSON_FLAG_INLINE) { - /* bson_grow didn't spill over */ - ((bson_impl_inline_t *) bson)->len = size; - } else { - ((bson_impl_alloc_t *) bson)->len = size; - } - - return _bson_data (bson); -} - - -bool -bson_steal (bson_t *dst, bson_t *src) -{ - bson_impl_inline_t *src_inline; - bson_impl_inline_t *dst_inline; - bson_impl_alloc_t *alloc; - - BSON_ASSERT (dst); - BSON_ASSERT (src); - - bson_init (dst); - - if (src->flags & (BSON_FLAG_CHILD | BSON_FLAG_IN_CHILD | BSON_FLAG_RDONLY)) { - return false; - } - - if (src->flags & BSON_FLAG_INLINE) { - src_inline = (bson_impl_inline_t *) src; - dst_inline = (bson_impl_inline_t *) dst; - dst_inline->len = src_inline->len; - memcpy (dst_inline->data, src_inline->data, sizeof src_inline->data); - - /* for consistency, src is always invalid after steal, even if inline */ - src->len = 0; -#ifdef BSON_MEMCHECK - bson_free (src->canary); -#endif - } else { -#ifdef BSON_MEMCHECK - bson_free (dst->canary); -#endif - memcpy (dst, src, sizeof (bson_t)); - alloc = (bson_impl_alloc_t *) dst; - alloc->flags |= BSON_FLAG_STATIC; - alloc->buf = &alloc->alloc; - alloc->buflen = &alloc->alloclen; - } - - if (!(src->flags & BSON_FLAG_STATIC)) { - bson_free (src); - } else { - /* src is invalid after steal */ - src->len = 0; - } - - return true; -} - - -uint8_t * -bson_destroy_with_steal (bson_t *bson, bool steal, uint32_t *length) -{ - uint8_t *ret = NULL; - - BSON_ASSERT (bson); - - if (length) { - *length = bson->len; - } - - if (!steal) { - bson_destroy (bson); - return NULL; - } - - if ((bson->flags & - (BSON_FLAG_CHILD | BSON_FLAG_IN_CHILD | BSON_FLAG_RDONLY))) { - /* Do nothing */ - } else if ((bson->flags & BSON_FLAG_INLINE)) { - bson_impl_inline_t *inl; - - inl = (bson_impl_inline_t *) bson; - ret = bson_malloc (bson->len); - memcpy (ret, inl->data, bson->len); - } else { - bson_impl_alloc_t *alloc; - - alloc = (bson_impl_alloc_t *) bson; - ret = *alloc->buf; - *alloc->buf = NULL; - } - - bson_destroy (bson); - - return ret; -} - - -const uint8_t * -bson_get_data (const bson_t *bson) -{ - BSON_ASSERT (bson); - - return _bson_data (bson); -} - - -uint32_t -bson_count_keys (const bson_t *bson) -{ - uint32_t count = 0; - bson_iter_t iter; - - BSON_ASSERT (bson); - - if (bson_iter_init (&iter, bson)) { - while (bson_iter_next (&iter)) { - count++; - } - } - - return count; -} - - -bool -bson_has_field (const bson_t *bson, const char *key) -{ - bson_iter_t iter; - bson_iter_t child; - - BSON_ASSERT (bson); - BSON_ASSERT (key); - - if (NULL != strchr (key, '.')) { - return (bson_iter_init (&iter, bson) && - bson_iter_find_descendant (&iter, key, &child)); - } - - return bson_iter_init_find (&iter, bson, key); -} - - -int -bson_compare (const bson_t *bson, const bson_t *other) -{ - const uint8_t *data1; - const uint8_t *data2; - size_t len1; - size_t len2; - int64_t ret; - - data1 = _bson_data (bson) + 4; - len1 = bson->len - 4; - - data2 = _bson_data (other) + 4; - len2 = other->len - 4; - - if (len1 == len2) { - return memcmp (data1, data2, len1); - } - - ret = memcmp (data1, data2, BSON_MIN (len1, len2)); - - if (ret == 0) { - ret = (int64_t) len1 - (int64_t) len2; - } - - return (ret < 0) ? -1 : (ret > 0); -} - - -bool -bson_equal (const bson_t *bson, const bson_t *other) -{ - return !bson_compare (bson, other); -} - - -static bool -_bson_as_json_visit_utf8 (const bson_iter_t *iter, - const char *key, - size_t v_utf8_len, - const char *v_utf8, - void *data) -{ - bson_json_state_t *state = data; - char *escaped; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - escaped = bson_utf8_escape_for_json (v_utf8, v_utf8_len); - - if (escaped) { - bson_string_append (state->str, "\""); - bson_string_append (state->str, escaped); - bson_string_append (state->str, "\""); - bson_free (escaped); - return false; - } - - return true; -} - - -static bool -_bson_as_json_visit_int32 (const bson_iter_t *iter, - const char *key, - int32_t v_int32, - void *data) -{ - bson_json_state_t *state = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - if (state->mode == BSON_JSON_MODE_CANONICAL) { - bson_string_append_printf ( - state->str, "{ \"$numberInt\" : \"%" PRId32 "\" }", v_int32); - } else { - bson_string_append_printf (state->str, "%" PRId32, v_int32); - } - - return false; -} - - -static bool -_bson_as_json_visit_int64 (const bson_iter_t *iter, - const char *key, - int64_t v_int64, - void *data) -{ - bson_json_state_t *state = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - if (state->mode == BSON_JSON_MODE_CANONICAL) { - bson_string_append_printf ( - state->str, "{ \"$numberLong\" : \"%" PRId64 "\" }", v_int64); - } else { - bson_string_append_printf (state->str, "%" PRId64, v_int64); - } - - return false; -} - - -static bool -_bson_as_json_visit_decimal128 (const bson_iter_t *iter, - const char *key, - const bson_decimal128_t *value, - void *data) -{ - bson_json_state_t *state = data; - char decimal128_string[BSON_DECIMAL128_STRING]; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - bson_decimal128_to_string (value, decimal128_string); - - bson_string_append (state->str, "{ \"$numberDecimal\" : \""); - bson_string_append (state->str, decimal128_string); - bson_string_append (state->str, "\" }"); - - return false; -} - - -static bool -_bson_as_json_visit_double (const bson_iter_t *iter, - const char *key, - double v_double, - void *data) -{ - bson_json_state_t *state = data; - bson_string_t *str = state->str; - uint32_t start_len; - bool legacy; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - /* Determine if legacy (i.e. unwrapped) output should be used. Relaxed mode - * will use this for nan and inf values, which we check manually since old - * platforms may not have isinf or isnan. */ - legacy = state->mode == BSON_JSON_MODE_LEGACY || - (state->mode == BSON_JSON_MODE_RELAXED && - !(v_double != v_double || v_double * 0 != 0)); - - if (!legacy) { - bson_string_append (state->str, "{ \"$numberDouble\" : \""); - } - - if (!legacy && v_double != v_double) { - bson_string_append (str, "NaN"); - } else if (!legacy && v_double * 0 != 0) { - if (v_double > 0) { - bson_string_append (str, "Infinity"); - } else { - bson_string_append (str, "-Infinity"); - } - } else { - start_len = str->len; - bson_string_append_printf (str, "%.20g", v_double); - - /* ensure trailing ".0" to distinguish "3" from "3.0" */ - if (strspn (&str->str[start_len], "0123456789-") == - str->len - start_len) { - bson_string_append (str, ".0"); - } - } - - if (!legacy) { - bson_string_append (state->str, "\" }"); - } - - return false; -} - - -static bool -_bson_as_json_visit_undefined (const bson_iter_t *iter, - const char *key, - void *data) -{ - bson_json_state_t *state = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - bson_string_append (state->str, "{ \"$undefined\" : true }"); - - return false; -} - - -static bool -_bson_as_json_visit_null (const bson_iter_t *iter, const char *key, void *data) -{ - bson_json_state_t *state = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - bson_string_append (state->str, "null"); - - return false; -} - - -static bool -_bson_as_json_visit_oid (const bson_iter_t *iter, - const char *key, - const bson_oid_t *oid, - void *data) -{ - bson_json_state_t *state = data; - char str[25]; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - bson_oid_to_string (oid, str); - bson_string_append (state->str, "{ \"$oid\" : \""); - bson_string_append (state->str, str); - bson_string_append (state->str, "\" }"); - - return false; -} - - -static bool -_bson_as_json_visit_binary (const bson_iter_t *iter, - const char *key, - bson_subtype_t v_subtype, - size_t v_binary_len, - const uint8_t *v_binary, - void *data) -{ - bson_json_state_t *state = data; - size_t b64_len; - char *b64; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - b64_len = mcommon_b64_ntop_calculate_target_size (v_binary_len); - b64 = bson_malloc0 (b64_len); - BSON_ASSERT (mcommon_b64_ntop (v_binary, v_binary_len, b64, b64_len) != -1); - - if (state->mode == BSON_JSON_MODE_CANONICAL || - state->mode == BSON_JSON_MODE_RELAXED) { - bson_string_append (state->str, "{ \"$binary\" : { \"base64\" : \""); - bson_string_append (state->str, b64); - bson_string_append (state->str, "\", \"subType\" : \""); - bson_string_append_printf (state->str, "%02x", v_subtype); - bson_string_append (state->str, "\" } }"); - } else { - bson_string_append (state->str, "{ \"$binary\" : \""); - bson_string_append (state->str, b64); - bson_string_append (state->str, "\", \"$type\" : \""); - bson_string_append_printf (state->str, "%02x", v_subtype); - bson_string_append (state->str, "\" }"); - } - - bson_free (b64); - - return false; -} - - -static bool -_bson_as_json_visit_bool (const bson_iter_t *iter, - const char *key, - bool v_bool, - void *data) -{ - bson_json_state_t *state = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - bson_string_append (state->str, v_bool ? "true" : "false"); - - return false; -} - - -static bool -_bson_as_json_visit_date_time (const bson_iter_t *iter, - const char *key, - int64_t msec_since_epoch, - void *data) -{ - bson_json_state_t *state = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - if (state->mode == BSON_JSON_MODE_CANONICAL || - (state->mode == BSON_JSON_MODE_RELAXED && msec_since_epoch < 0)) { - bson_string_append (state->str, "{ \"$date\" : { \"$numberLong\" : \""); - bson_string_append_printf (state->str, "%" PRId64, msec_since_epoch); - bson_string_append (state->str, "\" } }"); - } else if (state->mode == BSON_JSON_MODE_RELAXED) { - bson_string_append (state->str, "{ \"$date\" : \""); - _bson_iso8601_date_format (msec_since_epoch, state->str); - bson_string_append (state->str, "\" }"); - } else { - bson_string_append (state->str, "{ \"$date\" : "); - bson_string_append_printf (state->str, "%" PRId64, msec_since_epoch); - bson_string_append (state->str, " }"); - } - - return false; -} - - -static bool -_bson_as_json_visit_regex (const bson_iter_t *iter, - const char *key, - const char *v_regex, - const char *v_options, - void *data) -{ - bson_json_state_t *state = data; - char *escaped; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - escaped = bson_utf8_escape_for_json (v_regex, -1); - if (!escaped) { - return true; - } - - if (state->mode == BSON_JSON_MODE_CANONICAL || - state->mode == BSON_JSON_MODE_RELAXED) { - bson_string_append (state->str, - "{ \"$regularExpression\" : { \"pattern\" : \""); - bson_string_append (state->str, escaped); - bson_string_append (state->str, "\", \"options\" : \""); - _bson_append_regex_options_sorted (state->str, v_options); - bson_string_append (state->str, "\" } }"); - } else { - bson_string_append (state->str, "{ \"$regex\" : \""); - bson_string_append (state->str, escaped); - bson_string_append (state->str, "\", \"$options\" : \""); - _bson_append_regex_options_sorted (state->str, v_options); - bson_string_append (state->str, "\" }"); - } - - bson_free (escaped); - - return false; -} - - -static bool -_bson_as_json_visit_timestamp (const bson_iter_t *iter, - const char *key, - uint32_t v_timestamp, - uint32_t v_increment, - void *data) -{ - bson_json_state_t *state = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - bson_string_append (state->str, "{ \"$timestamp\" : { \"t\" : "); - bson_string_append_printf (state->str, "%u", v_timestamp); - bson_string_append (state->str, ", \"i\" : "); - bson_string_append_printf (state->str, "%u", v_increment); - bson_string_append (state->str, " } }"); - - return false; -} - - -static bool -_bson_as_json_visit_dbpointer (const bson_iter_t *iter, - const char *key, - size_t v_collection_len, - const char *v_collection, - const bson_oid_t *v_oid, - void *data) -{ - bson_json_state_t *state = data; - char *escaped; - char str[25]; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - BSON_UNUSED (v_collection_len); - - escaped = bson_utf8_escape_for_json (v_collection, -1); - if (!escaped) { - return true; - } - - if (state->mode == BSON_JSON_MODE_CANONICAL || - state->mode == BSON_JSON_MODE_RELAXED) { - bson_string_append (state->str, "{ \"$dbPointer\" : { \"$ref\" : \""); - bson_string_append (state->str, escaped); - bson_string_append (state->str, "\""); - - if (v_oid) { - bson_oid_to_string (v_oid, str); - bson_string_append (state->str, ", \"$id\" : { \"$oid\" : \""); - bson_string_append (state->str, str); - bson_string_append (state->str, "\" }"); - } - - bson_string_append (state->str, " } }"); - } else { - bson_string_append (state->str, "{ \"$ref\" : \""); - bson_string_append (state->str, escaped); - bson_string_append (state->str, "\""); - - if (v_oid) { - bson_oid_to_string (v_oid, str); - bson_string_append (state->str, ", \"$id\" : \""); - bson_string_append (state->str, str); - bson_string_append (state->str, "\""); - } - - bson_string_append (state->str, " }"); - } - - bson_free (escaped); - - return false; -} - - -static bool -_bson_as_json_visit_minkey (const bson_iter_t *iter, - const char *key, - void *data) -{ - bson_json_state_t *state = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - bson_string_append (state->str, "{ \"$minKey\" : 1 }"); - - return false; -} - - -static bool -_bson_as_json_visit_maxkey (const bson_iter_t *iter, - const char *key, - void *data) -{ - bson_json_state_t *state = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - bson_string_append (state->str, "{ \"$maxKey\" : 1 }"); - - return false; -} - - -static bool -_bson_as_json_visit_before (const bson_iter_t *iter, - const char *key, - void *data) -{ - bson_json_state_t *state = data; - char *escaped; - - BSON_UNUSED (iter); - - if (state->max_len_reached) { - return true; - } - - if (state->count) { - bson_string_append (state->str, ", "); - } - - if (state->keys) { - escaped = bson_utf8_escape_for_json (key, -1); - if (escaped) { - bson_string_append (state->str, "\""); - bson_string_append (state->str, escaped); - bson_string_append (state->str, "\" : "); - bson_free (escaped); - } else { - return true; - } - } - - state->count++; - - return false; -} - - -static bool -_bson_as_json_visit_after (const bson_iter_t *iter, const char *key, void *data) -{ - bson_json_state_t *state = data; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - if (state->max_len == BSON_MAX_LEN_UNLIMITED) { - return false; - } - - if (bson_cmp_greater_equal_us (state->str->len, state->max_len)) { - state->max_len_reached = true; - - if (bson_cmp_greater_us (state->str->len, state->max_len)) { - BSON_ASSERT (bson_in_range_signed (uint32_t, state->max_len)); - /* Truncate string to maximum length */ - bson_string_truncate (state->str, (uint32_t) state->max_len); - } - - return true; - } - - return false; -} - - -static void -_bson_as_json_visit_corrupt (const bson_iter_t *iter, void *data) -{ - *(((bson_json_state_t *) data)->err_offset) = iter->off; -} - - -static bool -_bson_as_json_visit_code (const bson_iter_t *iter, - const char *key, - size_t v_code_len, - const char *v_code, - void *data) -{ - bson_json_state_t *state = data; - char *escaped; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - escaped = bson_utf8_escape_for_json (v_code, v_code_len); - if (!escaped) { - return true; - } - - bson_string_append (state->str, "{ \"$code\" : \""); - bson_string_append (state->str, escaped); - bson_string_append (state->str, "\" }"); - bson_free (escaped); - - return false; -} - - -static bool -_bson_as_json_visit_symbol (const bson_iter_t *iter, - const char *key, - size_t v_symbol_len, - const char *v_symbol, - void *data) -{ - bson_json_state_t *state = data; - char *escaped; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - escaped = bson_utf8_escape_for_json (v_symbol, v_symbol_len); - if (!escaped) { - return true; - } - - if (state->mode == BSON_JSON_MODE_CANONICAL || - state->mode == BSON_JSON_MODE_RELAXED) { - bson_string_append (state->str, "{ \"$symbol\" : \""); - bson_string_append (state->str, escaped); - bson_string_append (state->str, "\" }"); - } else { - bson_string_append (state->str, "\""); - bson_string_append (state->str, escaped); - bson_string_append (state->str, "\""); - } - - bson_free (escaped); - - return false; -} - - -static bool -_bson_as_json_visit_codewscope (const bson_iter_t *iter, - const char *key, - size_t v_code_len, - const char *v_code, - const bson_t *v_scope, - void *data) -{ - bson_json_state_t *state = data; - char *code_escaped; - char *scope; - int32_t max_scope_len = BSON_MAX_LEN_UNLIMITED; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - code_escaped = bson_utf8_escape_for_json (v_code, v_code_len); - if (!code_escaped) { - return true; - } - - bson_string_append (state->str, "{ \"$code\" : \""); - bson_string_append (state->str, code_escaped); - bson_string_append (state->str, "\", \"$scope\" : "); - - bson_free (code_escaped); - - /* Encode scope with the same mode */ - if (state->max_len != BSON_MAX_LEN_UNLIMITED) { - BSON_ASSERT (bson_in_range_unsigned (int32_t, state->str->len)); - max_scope_len = BSON_MAX (0, state->max_len - (int32_t) state->str->len); - } - - scope = _bson_as_json_visit_all ( - v_scope, NULL, state->mode, max_scope_len, false); - - if (!scope) { - return true; - } - - bson_string_append (state->str, scope); - bson_string_append (state->str, " }"); - - bson_free (scope); - - return false; -} - - -static const bson_visitor_t bson_as_json_visitors = { - _bson_as_json_visit_before, _bson_as_json_visit_after, - _bson_as_json_visit_corrupt, _bson_as_json_visit_double, - _bson_as_json_visit_utf8, _bson_as_json_visit_document, - _bson_as_json_visit_array, _bson_as_json_visit_binary, - _bson_as_json_visit_undefined, _bson_as_json_visit_oid, - _bson_as_json_visit_bool, _bson_as_json_visit_date_time, - _bson_as_json_visit_null, _bson_as_json_visit_regex, - _bson_as_json_visit_dbpointer, _bson_as_json_visit_code, - _bson_as_json_visit_symbol, _bson_as_json_visit_codewscope, - _bson_as_json_visit_int32, _bson_as_json_visit_timestamp, - _bson_as_json_visit_int64, _bson_as_json_visit_maxkey, - _bson_as_json_visit_minkey, NULL, /* visit_unsupported_type */ - _bson_as_json_visit_decimal128, -}; - - -static bool -_bson_as_json_visit_document (const bson_iter_t *iter, - const char *key, - const bson_t *v_document, - void *data) -{ - bson_json_state_t *state = data; - bson_json_state_t child_state = {0, true, state->err_offset}; - bson_iter_t child; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - if (state->depth >= BSON_MAX_RECURSION) { - bson_string_append (state->str, "{ ... }"); - return false; - } - - if (bson_iter_init (&child, v_document)) { - child_state.str = bson_string_new ("{ "); - child_state.depth = state->depth + 1; - child_state.mode = state->mode; - child_state.max_len = BSON_MAX_LEN_UNLIMITED; - if (state->max_len != BSON_MAX_LEN_UNLIMITED) { - BSON_ASSERT (bson_in_range_unsigned (int32_t, state->str->len)); - child_state.max_len = - BSON_MAX (0, state->max_len - (int32_t) state->str->len); - } - - child_state.max_len_reached = child_state.max_len == 0; - - if (bson_iter_visit_all (&child, &bson_as_json_visitors, &child_state)) { - if (child_state.max_len_reached) { - bson_string_append (state->str, child_state.str->str); - } - - bson_string_free (child_state.str, true); - - /* If max_len was reached, we return a success state to ensure that - * VISIT_AFTER is still called - */ - return !child_state.max_len_reached; - } - - bson_string_append (child_state.str, " }"); - bson_string_append (state->str, child_state.str->str); - bson_string_free (child_state.str, true); - } - - return false; -} - - -static bool -_bson_as_json_visit_array (const bson_iter_t *iter, - const char *key, - const bson_t *v_array, - void *data) -{ - bson_json_state_t *state = data; - bson_json_state_t child_state = {0, false, state->err_offset}; - bson_iter_t child; - - BSON_UNUSED (iter); - BSON_UNUSED (key); - - if (state->depth >= BSON_MAX_RECURSION) { - bson_string_append (state->str, "{ ... }"); - return false; - } - - if (bson_iter_init (&child, v_array)) { - child_state.str = bson_string_new ("[ "); - child_state.depth = state->depth + 1; - child_state.mode = state->mode; - child_state.max_len = BSON_MAX_LEN_UNLIMITED; - if (state->max_len != BSON_MAX_LEN_UNLIMITED) { - BSON_ASSERT (bson_in_range_unsigned (int32_t, state->str->len)); - child_state.max_len = - BSON_MAX (0, state->max_len - (int32_t) state->str->len); - } - - child_state.max_len_reached = child_state.max_len == 0; - - if (bson_iter_visit_all (&child, &bson_as_json_visitors, &child_state)) { - if (child_state.max_len_reached) { - bson_string_append (state->str, child_state.str->str); - } - - bson_string_free (child_state.str, true); - - /* If max_len was reached, we return a success state to ensure that - * VISIT_AFTER is still called - */ - return !child_state.max_len_reached; - } - - bson_string_append (child_state.str, " ]"); - bson_string_append (state->str, child_state.str->str); - bson_string_free (child_state.str, true); - } - - return false; -} - - -static char * -_bson_as_json_visit_all (const bson_t *bson, - size_t *length, - bson_json_mode_t mode, - int32_t max_len, - bool is_outermost_array) -{ - bson_json_state_t state; - bson_iter_t iter; - ssize_t err_offset = -1; - int32_t remaining; - - BSON_ASSERT (bson); - - if (length) { - *length = 0; - } - - if (bson_empty0 (bson)) { - if (length) { - *length = 3; - } - - return bson_strdup (is_outermost_array ? "[ ]" : "{ }"); - } - - if (!bson_iter_init (&iter, bson)) { - return NULL; - } - - state.count = 0; - state.keys = !is_outermost_array; - state.str = bson_string_new (is_outermost_array ? "[ " : "{ "); - state.depth = 0; - state.err_offset = &err_offset; - state.mode = mode; - state.max_len = max_len; - state.max_len_reached = false; - - if ((bson_iter_visit_all (&iter, &bson_as_json_visitors, &state) || - err_offset != -1) && - !state.max_len_reached) { - /* - * We were prematurely exited due to corruption or failed visitor. - */ - bson_string_free (state.str, true); - if (length) { - *length = 0; - } - return NULL; - } - - /* Append closing space and } separately, in case we hit the max in between. - */ - remaining = state.max_len - state.str->len; - if (state.max_len == BSON_MAX_LEN_UNLIMITED || remaining > 1) { - bson_string_append (state.str, is_outermost_array ? " ]" : " }"); - } else if (remaining == 1) { - bson_string_append (state.str, " "); - } - - if (length) { - *length = state.str->len; - } - - return bson_string_free (state.str, false); -} - - -char * -bson_as_json_with_opts (const bson_t *bson, - size_t *length, - const bson_json_opts_t *opts) -{ - return _bson_as_json_visit_all ( - bson, length, opts->mode, opts->max_len, opts->is_outermost_array); -} - - -char * -bson_as_canonical_extended_json (const bson_t *bson, size_t *length) -{ - const bson_json_opts_t opts = { - BSON_JSON_MODE_CANONICAL, BSON_MAX_LEN_UNLIMITED, false}; - return bson_as_json_with_opts (bson, length, &opts); -} - - -char * -bson_as_json (const bson_t *bson, size_t *length) -{ - const bson_json_opts_t opts = { - BSON_JSON_MODE_LEGACY, BSON_MAX_LEN_UNLIMITED, false}; - return bson_as_json_with_opts (bson, length, &opts); -} - - -char * -bson_as_relaxed_extended_json (const bson_t *bson, size_t *length) -{ - const bson_json_opts_t opts = { - BSON_JSON_MODE_RELAXED, BSON_MAX_LEN_UNLIMITED, false}; - return bson_as_json_with_opts (bson, length, &opts); -} - - -char * -bson_array_as_json (const bson_t *bson, size_t *length) -{ - const bson_json_opts_t opts = { - BSON_JSON_MODE_LEGACY, BSON_MAX_LEN_UNLIMITED, true}; - return bson_as_json_with_opts (bson, length, &opts); -} - - -char * -bson_array_as_relaxed_extended_json (const bson_t *bson, size_t *length) -{ - const bson_json_opts_t opts = { - BSON_JSON_MODE_RELAXED, BSON_MAX_LEN_UNLIMITED, true}; - return bson_as_json_with_opts (bson, length, &opts); -} - - -char * -bson_array_as_canonical_extended_json (const bson_t *bson, size_t *length) -{ - const bson_json_opts_t opts = { - BSON_JSON_MODE_CANONICAL, BSON_MAX_LEN_UNLIMITED, true}; - return bson_as_json_with_opts (bson, length, &opts); -} - - -#define VALIDATION_ERR(_flag, _msg, ...) \ - bson_set_error (&state->error, BSON_ERROR_INVALID, _flag, _msg, __VA_ARGS__) - -static bool -_bson_iter_validate_utf8 (const bson_iter_t *iter, - const char *key, - size_t v_utf8_len, - const char *v_utf8, - void *data) -{ - bson_validate_state_t *state = data; - bool allow_null; - - if ((state->flags & BSON_VALIDATE_UTF8)) { - allow_null = !!(state->flags & BSON_VALIDATE_UTF8_ALLOW_NULL); - - if (!bson_utf8_validate (v_utf8, v_utf8_len, allow_null)) { - state->err_offset = iter->off; - VALIDATION_ERR ( - BSON_VALIDATE_UTF8, "invalid utf8 string for key \"%s\"", key); - return true; - } - } - - if ((state->flags & BSON_VALIDATE_DOLLAR_KEYS)) { - if (state->phase == BSON_VALIDATE_PHASE_LF_REF_UTF8) { - state->phase = BSON_VALIDATE_PHASE_LF_ID_KEY; - } else if (state->phase == BSON_VALIDATE_PHASE_LF_DB_UTF8) { - state->phase = BSON_VALIDATE_PHASE_NOT_DBREF; - } - } - - return false; -} - - -static void -_bson_iter_validate_corrupt (const bson_iter_t *iter, void *data) -{ - bson_validate_state_t *state = data; - - state->err_offset = iter->err_off; - VALIDATION_ERR (BSON_VALIDATE_NONE, "%s", "corrupt BSON"); -} - - -static bool -_bson_iter_validate_before (const bson_iter_t *iter, - const char *key, - void *data) -{ - bson_validate_state_t *state = data; - - if ((state->flags & BSON_VALIDATE_EMPTY_KEYS)) { - if (key[0] == '\0') { - state->err_offset = iter->off; - VALIDATION_ERR (BSON_VALIDATE_EMPTY_KEYS, "%s", "empty key"); - return true; - } - } - - if ((state->flags & BSON_VALIDATE_DOLLAR_KEYS)) { - if (key[0] == '$') { - if (state->phase == BSON_VALIDATE_PHASE_LF_REF_KEY && - strcmp (key, "$ref") == 0) { - state->phase = BSON_VALIDATE_PHASE_LF_REF_UTF8; - } else if (state->phase == BSON_VALIDATE_PHASE_LF_ID_KEY && - strcmp (key, "$id") == 0) { - state->phase = BSON_VALIDATE_PHASE_LF_DB_KEY; - } else if (state->phase == BSON_VALIDATE_PHASE_LF_DB_KEY && - strcmp (key, "$db") == 0) { - state->phase = BSON_VALIDATE_PHASE_LF_DB_UTF8; - } else { - state->err_offset = iter->off; - VALIDATION_ERR (BSON_VALIDATE_DOLLAR_KEYS, - "keys cannot begin with \"$\": \"%s\"", - key); - return true; - } - } else if (state->phase == BSON_VALIDATE_PHASE_LF_ID_KEY || - state->phase == BSON_VALIDATE_PHASE_LF_REF_UTF8 || - state->phase == BSON_VALIDATE_PHASE_LF_DB_UTF8) { - state->err_offset = iter->off; - VALIDATION_ERR (BSON_VALIDATE_DOLLAR_KEYS, - "invalid key within DBRef subdocument: \"%s\"", - key); - return true; - } else { - state->phase = BSON_VALIDATE_PHASE_NOT_DBREF; - } - } - - if ((state->flags & BSON_VALIDATE_DOT_KEYS)) { - if (strstr (key, ".")) { - state->err_offset = iter->off; - VALIDATION_ERR ( - BSON_VALIDATE_DOT_KEYS, "keys cannot contain \".\": \"%s\"", key); - return true; - } - } - - return false; -} - - -static bool -_bson_iter_validate_codewscope (const bson_iter_t *iter, - const char *key, - size_t v_code_len, - const char *v_code, - const bson_t *v_scope, - void *data) -{ - bson_validate_state_t *state = data; - size_t offset = 0; - - BSON_UNUSED (key); - BSON_UNUSED (v_code_len); - BSON_UNUSED (v_code); - - if (!bson_validate (v_scope, state->flags, &offset)) { - state->err_offset = iter->off + offset; - VALIDATION_ERR (BSON_VALIDATE_NONE, "%s", "corrupt code-with-scope"); - return false; - } - - return true; -} - - -static bool -_bson_iter_validate_document (const bson_iter_t *iter, - const char *key, - const bson_t *v_document, - void *data); - - -static const bson_visitor_t bson_validate_funcs = { - _bson_iter_validate_before, - NULL, /* visit_after */ - _bson_iter_validate_corrupt, - NULL, /* visit_double */ - _bson_iter_validate_utf8, - _bson_iter_validate_document, - _bson_iter_validate_document, /* visit_array */ - NULL, /* visit_binary */ - NULL, /* visit_undefined */ - NULL, /* visit_oid */ - NULL, /* visit_bool */ - NULL, /* visit_date_time */ - NULL, /* visit_null */ - NULL, /* visit_regex */ - NULL, /* visit_dbpoint */ - NULL, /* visit_code */ - NULL, /* visit_symbol */ - _bson_iter_validate_codewscope, -}; - - -static bool -_bson_iter_validate_document (const bson_iter_t *iter, - const char *key, - const bson_t *v_document, - void *data) -{ - bson_validate_state_t *state = data; - bson_iter_t child; - bson_validate_phase_t phase = state->phase; - - BSON_UNUSED (key); - - if (!bson_iter_init (&child, v_document)) { - state->err_offset = iter->off; - return true; - } - - if (state->phase == BSON_VALIDATE_PHASE_START) { - state->phase = BSON_VALIDATE_PHASE_TOP; - } else { - state->phase = BSON_VALIDATE_PHASE_LF_REF_KEY; - } - - (void) bson_iter_visit_all (&child, &bson_validate_funcs, state); - - if (state->phase == BSON_VALIDATE_PHASE_LF_ID_KEY || - state->phase == BSON_VALIDATE_PHASE_LF_REF_UTF8 || - state->phase == BSON_VALIDATE_PHASE_LF_DB_UTF8) { - if (state->err_offset <= 0) { - state->err_offset = iter->off; - } - - return true; - } - - state->phase = phase; - - return false; -} - - -static void -_bson_validate_internal (const bson_t *bson, bson_validate_state_t *state) -{ - bson_iter_t iter; - - state->err_offset = -1; - state->phase = BSON_VALIDATE_PHASE_START; - memset (&state->error, 0, sizeof state->error); - - if (!bson_iter_init (&iter, bson)) { - state->err_offset = 0; - VALIDATION_ERR (BSON_VALIDATE_NONE, "%s", "corrupt BSON"); - } else { - _bson_iter_validate_document (&iter, NULL, bson, state); - } -} - - -bool -bson_validate (const bson_t *bson, bson_validate_flags_t flags, size_t *offset) -{ - bson_validate_state_t state; - - state.flags = flags; - _bson_validate_internal (bson, &state); - - if (state.err_offset > 0 && offset) { - *offset = (size_t) state.err_offset; - } - - return state.err_offset < 0; -} - - -bool -bson_validate_with_error (const bson_t *bson, - bson_validate_flags_t flags, - bson_error_t *error) -{ - bson_validate_state_t state; - - state.flags = flags; - _bson_validate_internal (bson, &state); - - if (state.err_offset > 0 && error) { - memcpy (error, &state.error, sizeof *error); - } - - return state.err_offset < 0; -} - - -bool -bson_concat (bson_t *dst, const bson_t *src) -{ - BSON_ASSERT (dst); - BSON_ASSERT (src); - - if (!bson_empty (src)) { - return _bson_append ( - dst, 1, src->len - 5, src->len - 5, _bson_data (src) + 4); - } - - return true; -} - -struct _bson_array_builder_t { - uint32_t index; - bson_t bson; -}; - -bson_array_builder_t * -bson_array_builder_new (void) -{ - bson_array_builder_t *bab = BSON_ALIGNED_ALLOC0 (bson_array_builder_t); - bson_init (&bab->bson); - return bab; -} - -// `bson_array_builder_append_impl` generates the next key index, calls -// `append_fn`, and may update the tracked next index. -#define bson_array_builder_append_impl(append_fn, ...) \ - if (1) { \ - BSON_ASSERT_PARAM (bab); \ - const char *key; \ - char buf[16]; \ - size_t key_length = \ - bson_uint32_to_string (bab->index, &key, buf, sizeof buf); \ - /* Expect enough room in `buf` for key string. UINT32_MAX is 10 digits. \ - * With the NULL terminator, 11 is expected maximum number of \ - * characters. */ \ - BSON_ASSERT (key_length < sizeof buf); \ - bool ok = append_fn (&bab->bson, key, (int) key_length, __VA_ARGS__); \ - if (ok) { \ - bab->index += 1; \ - } \ - return ok; \ - } else \ - (void) 0 - -#define bson_array_builder_append_impl_noargs(append_fn) \ - if (1) { \ - BSON_ASSERT_PARAM (bab); \ - const char *key; \ - char buf[16]; \ - size_t key_length = \ - bson_uint32_to_string (bab->index, &key, buf, sizeof buf); \ - /* Expect enough room in `buf` for key string. UINT32_MAX is 10 digits. \ - * With the NULL terminator, 11 is expected maximum number of \ - * characters. */ \ - BSON_ASSERT (key_length < sizeof buf); \ - bool ok = append_fn (&bab->bson, key, (int) key_length); \ - if (ok) { \ - bab->index += 1; \ - } \ - return ok; \ - } else \ - (void) 0 - -bool -bson_array_builder_append_value (bson_array_builder_t *bab, - const bson_value_t *value) -{ - bson_array_builder_append_impl (bson_append_value, value); -} - -bool -bson_array_builder_append_array (bson_array_builder_t *bab, const bson_t *array) -{ - bson_array_builder_append_impl (bson_append_array, array); -} - - -bool -bson_array_builder_append_binary (bson_array_builder_t *bab, - bson_subtype_t subtype, - const uint8_t *binary, - uint32_t length) -{ - bson_array_builder_append_impl (bson_append_binary, subtype, binary, length); -} - - -bool -bson_array_builder_append_bool (bson_array_builder_t *bab, bool value) -{ - bson_array_builder_append_impl (bson_append_bool, value); -} - - -bool -bson_array_builder_append_code (bson_array_builder_t *bab, - const char *javascript) -{ - bson_array_builder_append_impl (bson_append_code, javascript); -} - - -bool -bson_array_builder_append_code_with_scope (bson_array_builder_t *bab, - const char *javascript, - const bson_t *scope) -{ - bson_array_builder_append_impl ( - bson_append_code_with_scope, javascript, scope); -} - - -bool -bson_array_builder_append_dbpointer (bson_array_builder_t *bab, - const char *collection, - const bson_oid_t *oid) -{ - bson_array_builder_append_impl (bson_append_dbpointer, collection, oid); -} - - -bool -bson_array_builder_append_double (bson_array_builder_t *bab, double value) -{ - bson_array_builder_append_impl (bson_append_double, value); -} - - -bool -bson_array_builder_append_document (bson_array_builder_t *bab, - const bson_t *value) -{ - bson_array_builder_append_impl (bson_append_document, value); -} - - -bool -bson_array_builder_append_document_begin (bson_array_builder_t *bab, - bson_t *child) -{ - bson_array_builder_append_impl (bson_append_document_begin, child); -} - - -bool -bson_array_builder_append_document_end (bson_array_builder_t *bab, - bson_t *child) -{ - return bson_append_document_end (&bab->bson, child); -} - - -bool -bson_array_builder_append_int32 (bson_array_builder_t *bab, int32_t value) -{ - bson_array_builder_append_impl (bson_append_int32, value); -} - - -bool -bson_array_builder_append_int64 (bson_array_builder_t *bab, int64_t value) -{ - bson_array_builder_append_impl (bson_append_int64, value); -} - - -bool -bson_array_builder_append_decimal128 (bson_array_builder_t *bab, - const bson_decimal128_t *value) -{ - bson_array_builder_append_impl (bson_append_decimal128, value); -} - - -bool -bson_array_builder_append_iter (bson_array_builder_t *bab, - const bson_iter_t *iter) -{ - bson_array_builder_append_impl (bson_append_iter, iter); -} - - -bool -bson_array_builder_append_minkey (bson_array_builder_t *bab) -{ - bson_array_builder_append_impl_noargs (bson_append_minkey); -} - - -bool -bson_array_builder_append_maxkey (bson_array_builder_t *bab) -{ - bson_array_builder_append_impl_noargs (bson_append_maxkey); -} - - -bool -bson_array_builder_append_null (bson_array_builder_t *bab) -{ - bson_array_builder_append_impl_noargs (bson_append_null); -} - - -bool -bson_array_builder_append_oid (bson_array_builder_t *bab, const bson_oid_t *oid) -{ - bson_array_builder_append_impl (bson_append_oid, oid); -} - - -bool -bson_array_builder_append_regex (bson_array_builder_t *bab, - const char *regex, - const char *options) -{ - bson_array_builder_append_impl (bson_append_regex, regex, options); -} - - -bool -bson_array_builder_append_regex_w_len (bson_array_builder_t *bab, - const char *regex, - int regex_length, - const char *options) -{ - bson_array_builder_append_impl ( - bson_append_regex_w_len, regex, regex_length, options); -} - - -bool -bson_array_builder_append_utf8 (bson_array_builder_t *bab, - const char *value, - int length) -{ - bson_array_builder_append_impl (bson_append_utf8, value, length); -} - - -bool -bson_array_builder_append_symbol (bson_array_builder_t *bab, - const char *value, - int length) -{ - bson_array_builder_append_impl (bson_append_symbol, value, length); -} - - -bool -bson_array_builder_append_time_t (bson_array_builder_t *bab, time_t value) -{ - bson_array_builder_append_impl (bson_append_time_t, value); -} - - -bool -bson_array_builder_append_timeval (bson_array_builder_t *bab, - struct timeval *value) -{ - bson_array_builder_append_impl (bson_append_timeval, value); -} - - -bool -bson_array_builder_append_date_time (bson_array_builder_t *bab, int64_t value) -{ - bson_array_builder_append_impl (bson_append_date_time, value); -} - - -bool -bson_array_builder_append_now_utc (bson_array_builder_t *bab) -{ - bson_array_builder_append_impl_noargs (bson_append_now_utc); -} - - -bool -bson_array_builder_append_timestamp (bson_array_builder_t *bab, - uint32_t timestamp, - uint32_t increment) -{ - bson_array_builder_append_impl (bson_append_timestamp, timestamp, increment); -} - - -bool -bson_array_builder_append_undefined (bson_array_builder_t *bab) -{ - bson_array_builder_append_impl_noargs (bson_append_undefined); -} - - -bool -bson_array_builder_append_array_builder_begin (bson_array_builder_t *bab, - bson_array_builder_t **child) -{ - bson_array_builder_append_impl (bson_append_array_builder_begin, child); -} - -bool -bson_array_builder_append_array_builder_end (bson_array_builder_t *bab, - bson_array_builder_t *child) -{ - return bson_append_array_builder_end (&bab->bson, child); -} - - -bool -bson_array_builder_build (bson_array_builder_t *bab, bson_t *out) -{ - BSON_ASSERT_PARAM (bab); - BSON_ASSERT_PARAM (out); - if (!bson_steal (out, &bab->bson)) { - return false; - } - bson_init (&bab->bson); - bab->index = 0; - return true; -} - -void -bson_array_builder_destroy (bson_array_builder_t *bab) -{ - if (!bab) { - return; - } - bson_destroy (&bab->bson); - bson_free (bab); -} - -bool -bson_append_array_builder_begin (bson_t *bson, - const char *key, - int key_length, - bson_array_builder_t **child) -{ - BSON_ASSERT_PARAM (bson); - BSON_ASSERT_PARAM (key); - BSON_ASSERT_PARAM (child); - *child = bson_array_builder_new (); - return bson_append_array_begin (bson, key, key_length, &(*child)->bson); -} - -bool -bson_append_array_builder_end (bson_t *bson, bson_array_builder_t *child) -{ - bool ok = bson_append_array_end (bson, &child->bson); - bson_array_builder_destroy (child); - return ok; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson.h deleted file mode 100644 index 88a2f706c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/bson.h +++ /dev/null @@ -1,1393 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef BSON_H -#define BSON_H - -#define BSON_INSIDE - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef BSON_INSIDE - - -BSON_BEGIN_DECLS - - -/** - * bson_empty: - * @b: a bson_t. - * - * Checks to see if @b is an empty BSON document. An empty BSON document is - * a 5 byte document which contains the length (4 bytes) and a single NUL - * byte indicating end of fields. - */ -#define bson_empty(b) (((b)->len == 5) || !bson_get_data ((b))[4]) - - -/** - * bson_empty0: - * - * Like bson_empty() but treats NULL the same as an empty bson_t document. - */ -#define bson_empty0(b) (!(b) || bson_empty (b)) - - -/** - * bson_clear: - * - * Easily free a bson document and set it to NULL. Use like: - * - * bson_t *doc = bson_new(); - * bson_clear (&doc); - * BSON_ASSERT (doc == NULL); - */ -#define bson_clear(bptr) \ - do { \ - if (*(bptr)) { \ - bson_destroy (*(bptr)); \ - *(bptr) = NULL; \ - } \ - } while (0) - - -/** - * BSON_MAX_SIZE: - * - * The maximum size in bytes of a BSON document. - */ -#define BSON_MAX_SIZE ((size_t) ((1U << 31) - 1)) - - -#define BSON_APPEND_ARRAY(b, key, val) \ - bson_append_array (b, key, (int) strlen (key), val) - -#define BSON_APPEND_ARRAY_BEGIN(b, key, child) \ - bson_append_array_begin (b, key, (int) strlen (key), child) - -#define BSON_APPEND_BINARY(b, key, subtype, val, len) \ - bson_append_binary (b, key, (int) strlen (key), subtype, val, len) - -#define BSON_APPEND_BOOL(b, key, val) \ - bson_append_bool (b, key, (int) strlen (key), val) - -#define BSON_APPEND_CODE(b, key, val) \ - bson_append_code (b, key, (int) strlen (key), val) - -#define BSON_APPEND_CODE_WITH_SCOPE(b, key, val, scope) \ - bson_append_code_with_scope (b, key, (int) strlen (key), val, scope) - -#define BSON_APPEND_DBPOINTER(b, key, coll, oid) \ - bson_append_dbpointer (b, key, (int) strlen (key), coll, oid) - -#define BSON_APPEND_DOCUMENT_BEGIN(b, key, child) \ - bson_append_document_begin (b, key, (int) strlen (key), child) - -#define BSON_APPEND_DOUBLE(b, key, val) \ - bson_append_double (b, key, (int) strlen (key), val) - -#define BSON_APPEND_DOCUMENT(b, key, val) \ - bson_append_document (b, key, (int) strlen (key), val) - -#define BSON_APPEND_INT32(b, key, val) \ - bson_append_int32 (b, key, (int) strlen (key), val) - -#define BSON_APPEND_INT64(b, key, val) \ - bson_append_int64 (b, key, (int) strlen (key), val) - -#define BSON_APPEND_MINKEY(b, key) \ - bson_append_minkey (b, key, (int) strlen (key)) - -#define BSON_APPEND_DECIMAL128(b, key, val) \ - bson_append_decimal128 (b, key, (int) strlen (key), val) - -#define BSON_APPEND_MAXKEY(b, key) \ - bson_append_maxkey (b, key, (int) strlen (key)) - -#define BSON_APPEND_NULL(b, key) bson_append_null (b, key, (int) strlen (key)) - -#define BSON_APPEND_OID(b, key, val) \ - bson_append_oid (b, key, (int) strlen (key), val) - -#define BSON_APPEND_REGEX(b, key, val, opt) \ - bson_append_regex (b, key, (int) strlen (key), val, opt) - -#define BSON_APPEND_UTF8(b, key, val) \ - bson_append_utf8 (b, key, (int) strlen (key), val, (int) strlen (val)) - -#define BSON_APPEND_SYMBOL(b, key, val) \ - bson_append_symbol (b, key, (int) strlen (key), val, (int) strlen (val)) - -#define BSON_APPEND_TIME_T(b, key, val) \ - bson_append_time_t (b, key, (int) strlen (key), val) - -#define BSON_APPEND_TIMEVAL(b, key, val) \ - bson_append_timeval (b, key, (int) strlen (key), val) - -#define BSON_APPEND_DATE_TIME(b, key, val) \ - bson_append_date_time (b, key, (int) strlen (key), val) - -#define BSON_APPEND_TIMESTAMP(b, key, val, inc) \ - bson_append_timestamp (b, key, (int) strlen (key), val, inc) - -#define BSON_APPEND_UNDEFINED(b, key) \ - bson_append_undefined (b, key, (int) strlen (key)) - -#define BSON_APPEND_VALUE(b, key, val) \ - bson_append_value (b, key, (int) strlen (key), (val)) - - -/** - * bson_new: - * - * Allocates a new bson_t structure. Call the various bson_append_*() - * functions to add fields to the bson. You can iterate the bson_t at any - * time using a bson_iter_t and bson_iter_init(). - * - * Returns: A newly allocated bson_t that should be freed with bson_destroy(). - */ -BSON_EXPORT (bson_t *) -bson_new (void); - - -BSON_EXPORT (bson_t *) -bson_new_from_json (const uint8_t *data, ssize_t len, bson_error_t *error); - - -BSON_EXPORT (bool) -bson_init_from_json (bson_t *bson, - const char *data, - ssize_t len, - bson_error_t *error); - - -/** - * bson_init_static: - * @b: A pointer to a bson_t. - * @data: The data buffer to use. - * @length: The length of @data. - * - * Initializes a bson_t using @data and @length. This is ideal if you would - * like to use a stack allocation for your bson and do not need to grow the - * buffer. @data must be valid for the life of @b. - * - * Returns: true if initialized successfully; otherwise false. - */ -BSON_EXPORT (bool) -bson_init_static (bson_t *b, const uint8_t *data, size_t length); - - -/** - * bson_init: - * @b: A pointer to a bson_t. - * - * Initializes a bson_t for use. This function is useful to those that want a - * stack allocated bson_t. The usefulness of a stack allocated bson_t is - * marginal as the target buffer for content will still require heap - * allocations. It can help reduce heap fragmentation on allocators that do - * not employ SLAB/magazine semantics. - * - * You must call bson_destroy() with @b to release resources when you are done - * using @b. - */ -BSON_EXPORT (void) -bson_init (bson_t *b); - - -/** - * bson_reinit: - * @b: (inout): A bson_t. - * - * This is equivalent to calling bson_destroy() and bson_init() on a #bson_t. - * However, it will try to persist the existing malloc'd buffer if one exists. - * This is useful in cases where you want to reduce malloc overhead while - * building many documents. - */ -BSON_EXPORT (void) -bson_reinit (bson_t *b); - - -/** - * bson_new_from_data: - * @data: A buffer containing a serialized bson document. - * @length: The length of the document in bytes. - * - * Creates a new bson_t structure using the data provided. @data should contain - * at least @length bytes that can be copied into the new bson_t structure. - * - * Returns: A newly allocated bson_t that should be freed with bson_destroy(). - * If the first four bytes (little-endian) of data do not match @length, - * then NULL will be returned. - */ -BSON_EXPORT (bson_t *) -bson_new_from_data (const uint8_t *data, size_t length); - - -/** - * bson_new_from_buffer: - * @buf: A pointer to a buffer containing a serialized bson document. - * @buf_len: The length of the buffer in bytes. - * @realloc_fun: a realloc like function - * @realloc_fun_ctx: a context for the realloc function - * - * Creates a new bson_t structure using the data provided. @buf should contain - * a bson document, or null pointer should be passed for new allocations. - * - * Returns: A newly allocated bson_t that should be freed with bson_destroy(). - * The underlying buffer will be used and not be freed in destroy. - */ -BSON_EXPORT (bson_t *) -bson_new_from_buffer (uint8_t **buf, - size_t *buf_len, - bson_realloc_func realloc_func, - void *realloc_func_ctx); - - -/** - * bson_sized_new: - * @size: A size_t containing the number of bytes to allocate. - * - * This will allocate a new bson_t with enough bytes to hold a buffer - * sized @size. @size must be smaller than INT_MAX bytes. - * - * Returns: A newly allocated bson_t that should be freed with bson_destroy(). - */ -BSON_EXPORT (bson_t *) -bson_sized_new (size_t size); - - -/** - * bson_copy: - * @bson: A bson_t. - * - * Copies @bson into a newly allocated bson_t. You must call bson_destroy() - * when you are done with the resulting value to free its resources. - * - * Returns: A newly allocated bson_t that should be free'd with bson_destroy() - */ -BSON_EXPORT (bson_t *) -bson_copy (const bson_t *bson); - - -/** - * bson_copy_to: - * @src: The source bson_t. - * @dst: The destination bson_t. - * - * Initializes @dst and copies the content from @src into @dst. - */ -BSON_EXPORT (void) -bson_copy_to (const bson_t *src, bson_t *dst); - - -/** - * bson_copy_to_excluding: - * @src: A bson_t. - * @dst: A bson_t to initialize and copy into. - * @first_exclude: First field name to exclude. - * - * Copies @src into @dst excluding any field that is provided. - * This is handy for situations when you need to remove one or - * more fields in a bson_t. Note that bson_init() will be called - * on dst. - */ -BSON_EXPORT (void) -bson_copy_to_excluding (const bson_t *src, - bson_t *dst, - const char *first_exclude, - ...) BSON_GNUC_NULL_TERMINATED - BSON_GNUC_DEPRECATED_FOR (bson_copy_to_excluding_noinit); - -/** - * bson_copy_to_excluding_noinit: - * @src: A bson_t. - * @dst: A bson_t to initialize and copy into. - * @first_exclude: First field name to exclude. - * - * The same as bson_copy_to_excluding, but does not call bson_init() - * on the dst. This version should be preferred in new code, but the - * old function is left for backwards compatibility. - */ -BSON_EXPORT (void) -bson_copy_to_excluding_noinit (const bson_t *src, - bson_t *dst, - const char *first_exclude, - ...) BSON_GNUC_NULL_TERMINATED; - -BSON_EXPORT (void) -bson_copy_to_excluding_noinit_va (const bson_t *src, - bson_t *dst, - const char *first_exclude, - va_list args); - - -/** - * bson_destroy: - * @bson: A bson_t. - * - * Frees the resources associated with @bson. - */ -BSON_EXPORT (void) -bson_destroy (bson_t *bson); - -BSON_EXPORT (uint8_t *) -bson_reserve_buffer (bson_t *bson, uint32_t size); - -BSON_EXPORT (bool) -bson_steal (bson_t *dst, bson_t *src); - - -/** - * bson_destroy_with_steal: - * @bson: A #bson_t. - * @steal: If ownership of the data buffer should be transferred to caller. - * @length: (out): location for the length of the buffer. - * - * Destroys @bson similar to calling bson_destroy() except that the underlying - * buffer will be returned and ownership transferred to the caller if @steal - * is non-zero. - * - * If length is non-NULL, the length of @bson will be stored in @length. - * - * It is a programming error to call this function with any bson that has - * been initialized static, or is being used to create a subdocument with - * functions such as bson_append_document_begin() or bson_append_array_begin(). - * - * Returns: a buffer owned by the caller if @steal is true. Otherwise NULL. - * If there was an error, NULL is returned. - */ -BSON_EXPORT (uint8_t *) -bson_destroy_with_steal (bson_t *bson, bool steal, uint32_t *length); - - -/** - * bson_get_data: - * @bson: A bson_t. - * - * Fetched the data buffer for @bson of @bson->len bytes in length. - * - * Returns: A buffer that should not be modified or freed. - */ -BSON_EXPORT (const uint8_t *) -bson_get_data (const bson_t *bson); - - -/** - * bson_count_keys: - * @bson: A bson_t. - * - * Counts the number of elements found in @bson. - */ -BSON_EXPORT (uint32_t) -bson_count_keys (const bson_t *bson); - - -/** - * bson_has_field: - * @bson: A bson_t. - * @key: The key to lookup. - * - * Checks to see if @bson contains a field named @key. - * - * This function is case-sensitive. - * - * Returns: true if @key exists in @bson; otherwise false. - */ -BSON_EXPORT (bool) -bson_has_field (const bson_t *bson, const char *key); - - -/** - * bson_compare: - * @bson: A bson_t. - * @other: A bson_t. - * - * Compares @bson to @other in a qsort() style comparison. - * See qsort() for information on how this function works. - * - * Returns: Less than zero, zero, or greater than zero. - */ -BSON_EXPORT (int) -bson_compare (const bson_t *bson, const bson_t *other); - -/* - * bson_equal: - * @bson: A bson_t. - * @other: A bson_t. - * - * Checks to see if @bson and @other are equal. - * - * Returns: true if equal; otherwise false. - */ -BSON_EXPORT (bool) -bson_equal (const bson_t *bson, const bson_t *other); - - -/** - * bson_validate: - * @bson: A bson_t. - * @offset: A location for the error offset. - * - * Validates a BSON document by walking through the document and inspecting - * the fields for valid content. - * - * Returns: true if @bson is valid; otherwise false and @offset is set. - */ -BSON_EXPORT (bool) -bson_validate (const bson_t *bson, bson_validate_flags_t flags, size_t *offset); - - -/** - * bson_validate_with_error: - * @bson: A bson_t. - * @error: A location for the error info. - * - * Validates a BSON document by walking through the document and inspecting - * the fields for valid content. - * - * Returns: true if @bson is valid; otherwise false and @error is filled out. - */ -BSON_EXPORT (bool) -bson_validate_with_error (const bson_t *bson, - bson_validate_flags_t flags, - bson_error_t *error); - - -/** - * bson_as_json_with_opts: - * @bson: A bson_t. - * @length: A location for the string length, or NULL. - * @opts: A bson_t_json_opts_t defining options for the conversion - * - * Creates a new string containing @bson in the selected JSON format, - * conforming to the MongoDB Extended JSON Spec: - * - * github.com/mongodb/specifications/blob/master/source/extended-json.rst - * - * The caller is responsible for freeing the resulting string. If @length is - * non-NULL, then the length of the resulting string will be placed in @length. - * - * See https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/ for - * more information on extended JSON. - * - * Returns: A newly allocated string that should be freed with bson_free(). - */ -BSON_EXPORT (char *) -bson_as_json_with_opts (const bson_t *bson, - size_t *length, - const bson_json_opts_t *opts); - - -/** - * bson_as_canonical_extended_json: - * @bson: A bson_t. - * @length: A location for the string length, or NULL. - * - * Creates a new string containing @bson in canonical extended JSON format, - * conforming to the MongoDB Extended JSON Spec: - * - * github.com/mongodb/specifications/blob/master/source/extended-json.rst - * - * The caller is responsible for freeing the resulting string. If @length is - * non-NULL, then the length of the resulting string will be placed in @length. - * - * See https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/ for - * more information on extended JSON. - * - * Returns: A newly allocated string that should be freed with bson_free(). - */ -BSON_EXPORT (char *) -bson_as_canonical_extended_json (const bson_t *bson, size_t *length); - - -/** - * bson_as_json: - * @bson: A bson_t. - * @length: A location for the string length, or NULL. - * - * Creates a new string containing @bson in libbson's legacy JSON format. - * Superseded by bson_as_canonical_extended_json and - * bson_as_relaxed_extended_json. The caller is - * responsible for freeing the resulting string. If @length is non-NULL, then - * the length of the resulting string will be placed in @length. - * - * Returns: A newly allocated string that should be freed with bson_free(). - */ -BSON_EXPORT (char *) -bson_as_json (const bson_t *bson, size_t *length); - - -/** - * bson_as_relaxed_extended_json: - * @bson: A bson_t. - * @length: A location for the string length, or NULL. - * - * Creates a new string containing @bson in relaxed extended JSON format, - * conforming to the MongoDB Extended JSON Spec: - * - * github.com/mongodb/specifications/blob/master/source/extended-json.rst - * - * The caller is responsible for freeing the resulting string. If @length is - * non-NULL, then the length of the resulting string will be placed in @length. - * - * See https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/ for - * more information on extended JSON. - * - * Returns: A newly allocated string that should be freed with bson_free(). - */ -BSON_EXPORT (char *) -bson_as_relaxed_extended_json (const bson_t *bson, size_t *length); - - -/* like bson_as_json() but for outermost arrays. */ -BSON_EXPORT (char *) bson_array_as_json (const bson_t *bson, size_t *length); - - -/* like bson_as_relaxed_extended_json() but for outermost arrays. */ -BSON_EXPORT (char *) -bson_array_as_relaxed_extended_json (const bson_t *bson, size_t *length); - - -/* like bson_as_canonical_extended_json() but for outermost arrays. */ -BSON_EXPORT (char *) -bson_array_as_canonical_extended_json (const bson_t *bson, size_t *length); - -// bson_array_builder_t defines an API for building arrays. -// BSON arrays require sequential numeric keys "0", "1", "2", ... -typedef struct _bson_array_builder_t bson_array_builder_t; - -// bson_array_builder_new may be used to build a top-level BSON array. Example: -// `[1,2,3]`. -// To append an array field to a document (Example: `{ "field": [1,2,3] }`), use -// `bson_append_array_builder_begin`. -BSON_EXPORT (bson_array_builder_t *) bson_array_builder_new (void); - -// bson_array_builder_build initializes and moves BSON data to `out`. -// `bab` may be reused and will start appending a new array at index "0". -BSON_EXPORT (bool) -bson_array_builder_build (bson_array_builder_t *bab, bson_t *out); - -BSON_EXPORT (void) -bson_array_builder_destroy (bson_array_builder_t *bab); - -BSON_EXPORT (bool) -bson_append_value (bson_t *bson, - const char *key, - int key_length, - const bson_value_t *value); - -#define BSON_APPEND_VALUE(b, key, val) \ - bson_append_value (b, key, (int) strlen (key), (val)) - -BSON_EXPORT (bool) -bson_array_builder_append_value (bson_array_builder_t *bab, - const bson_value_t *value); - -/** - * bson_append_array: - * @bson: A bson_t. - * @key: The key for the field. - * @array: A bson_t containing the array. - * - * Appends a BSON array to @bson. BSON arrays are like documents where the - * key is the string version of the index. For example, the first item of the - * array would have the key "0". The second item would have the index "1". - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_array (bson_t *bson, - const char *key, - int key_length, - const bson_t *array); - -#define BSON_APPEND_ARRAY(b, key, val) \ - bson_append_array (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_array (bson_array_builder_t *bab, - const bson_t *array); - -/** - * bson_append_binary: - * @bson: A bson_t to append. - * @key: The key for the field. - * @subtype: The bson_subtype_t of the binary. - * @binary: The binary buffer to append. - * @length: The length of @binary. - * - * Appends a binary buffer to the BSON document. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_binary (bson_t *bson, - const char *key, - int key_length, - bson_subtype_t subtype, - const uint8_t *binary, - uint32_t length); - -#define BSON_APPEND_BINARY(b, key, subtype, val, len) \ - bson_append_binary (b, key, (int) strlen (key), subtype, val, len) - -BSON_EXPORT (bool) -bson_array_builder_append_binary (bson_array_builder_t *bab, - bson_subtype_t subtype, - const uint8_t *binary, - uint32_t length); - -/** - * bson_append_bool: - * @bson: A bson_t. - * @key: The key for the field. - * @value: The boolean value. - * - * Appends a new field to @bson of type BSON_TYPE_BOOL. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_bool (bson_t *bson, const char *key, int key_length, bool value); - -#define BSON_APPEND_BOOL(b, key, val) \ - bson_append_bool (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_bool (bson_array_builder_t *bab, bool value); - -/** - * bson_append_code: - * @bson: A bson_t. - * @key: The key for the document. - * @javascript: JavaScript code to be executed. - * - * Appends a field of type BSON_TYPE_CODE to the BSON document. @javascript - * should contain a script in javascript to be executed. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_code (bson_t *bson, - const char *key, - int key_length, - const char *javascript); - -#define BSON_APPEND_CODE(b, key, val) \ - bson_append_code (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_code (bson_array_builder_t *bab, - const char *javascript); - -/** - * bson_append_code_with_scope: - * @bson: A bson_t. - * @key: The key for the document. - * @javascript: JavaScript code to be executed. - * @scope: A bson_t containing the scope for @javascript. - * - * Appends a field of type BSON_TYPE_CODEWSCOPE to the BSON document. - * @javascript should contain a script in javascript to be executed. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_code_with_scope (bson_t *bson, - const char *key, - int key_length, - const char *javascript, - const bson_t *scope); - -#define BSON_APPEND_CODE_WITH_SCOPE(b, key, val, scope) \ - bson_append_code_with_scope (b, key, (int) strlen (key), val, scope) - -BSON_EXPORT (bool) -bson_array_builder_append_code_with_scope (bson_array_builder_t *bab, - const char *javascript, - const bson_t *scope); - -/** - * bson_append_dbpointer: - * @bson: A bson_t. - * @key: The key for the field. - * @collection: The collection name. - * @oid: The oid to the reference. - * - * Appends a new field of type BSON_TYPE_DBPOINTER. This datum type is - * deprecated in the BSON spec and should not be used in new code. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_dbpointer (bson_t *bson, - const char *key, - int key_length, - const char *collection, - const bson_oid_t *oid); - -#define BSON_APPEND_DBPOINTER(b, key, coll, oid) \ - bson_append_dbpointer (b, key, (int) strlen (key), coll, oid) - -BSON_EXPORT (bool) -bson_array_builder_append_dbpointer (bson_array_builder_t *bab, - const char *collection, - const bson_oid_t *oid); - -/** - * bson_append_double: - * @bson: A bson_t. - * @key: The key for the field. - * - * Appends a new field to @bson of the type BSON_TYPE_DOUBLE. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_double (bson_t *bson, - const char *key, - int key_length, - double value); - -#define BSON_APPEND_DOUBLE(b, key, val) \ - bson_append_double (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_double (bson_array_builder_t *bab, double value); - -/** - * bson_append_document: - * @bson: A bson_t. - * @key: The key for the field. - * @value: A bson_t containing the subdocument. - * - * Appends a new field to @bson of the type BSON_TYPE_DOCUMENT. - * The documents contents will be copied into @bson. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_document (bson_t *bson, - const char *key, - int key_length, - const bson_t *value); - -#define BSON_APPEND_DOCUMENT(b, key, val) \ - bson_append_document (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_document (bson_array_builder_t *bab, - const bson_t *value); - -/** - * bson_append_document_begin: - * @bson: A bson_t. - * @key: The key for the field. - * @key_length: The length of @key in bytes not including NUL or -1 - * if @key_length is NUL terminated. - * @child: A location to an uninitialized bson_t. - * - * Appends a new field named @key to @bson. The field is, however, - * incomplete. @child will be initialized so that you may add fields to the - * child document. Child will use a memory buffer owned by @bson and - * therefore grow the parent buffer as additional space is used. This allows - * a single malloc'd buffer to be used when building documents which can help - * reduce memory fragmentation. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_document_begin (bson_t *bson, - const char *key, - int key_length, - bson_t *child); - -#define BSON_APPEND_DOCUMENT_BEGIN(b, key, child) \ - bson_append_document_begin (b, key, (int) strlen (key), child) - -BSON_EXPORT (bool) -bson_array_builder_append_document_begin (bson_array_builder_t *bab, - bson_t *child); - -/** - * bson_append_document_end: - * @bson: A bson_t. - * @child: A bson_t supplied to bson_append_document_begin(). - * - * Finishes the appending of a document to a @bson. @child is considered - * disposed after this call and should not be used any further. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_document_end (bson_t *bson, bson_t *child); - -BSON_EXPORT (bool) -bson_array_builder_append_document_end (bson_array_builder_t *bab, - bson_t *child); - - -/** - * bson_append_array_begin: - * @bson: A bson_t. - * @key: The key for the field. - * @key_length: The length of @key in bytes not including NUL or -1 - * if @key_length is NUL terminated. - * @child: A location to an uninitialized bson_t. - * - * Appends a new field named @key to @bson. The field is, however, - * incomplete. @child will be initialized so that you may add fields to the - * child array. Child will use a memory buffer owned by @bson and - * therefore grow the parent buffer as additional space is used. This allows - * a single malloc'd buffer to be used when building arrays which can help - * reduce memory fragmentation. - * - * The type of @child will be BSON_TYPE_ARRAY and therefore the keys inside - * of it MUST be "0", "1", etc. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_array_begin (bson_t *bson, - const char *key, - int key_length, - bson_t *child); - -#define BSON_APPEND_ARRAY_BEGIN(b, key, child) \ - bson_append_array_begin (b, key, (int) strlen (key), child) - -/** - * bson_append_array_end: - * @bson: A bson_t. - * @child: A bson_t supplied to bson_append_array_begin(). - * - * Finishes the appending of a array to a @bson. @child is considered - * disposed after this call and should not be used any further. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_array_end (bson_t *bson, bson_t *child); - - -/** - * bson_append_int32: - * @bson: A bson_t. - * @key: The key for the field. - * @value: The int32_t 32-bit integer value. - * - * Appends a new field of type BSON_TYPE_INT32 to @bson. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_int32 (bson_t *bson, - const char *key, - int key_length, - int32_t value); - -#define BSON_APPEND_INT32(b, key, val) \ - bson_append_int32 (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_int32 (bson_array_builder_t *bab, int32_t value); - -/** - * bson_append_int64: - * @bson: A bson_t. - * @key: The key for the field. - * @value: The int64_t 64-bit integer value. - * - * Appends a new field of type BSON_TYPE_INT64 to @bson. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_int64 (bson_t *bson, - const char *key, - int key_length, - int64_t value); - -#define BSON_APPEND_INT64(b, key, val) \ - bson_append_int64 (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_int64 (bson_array_builder_t *bab, int64_t value); - -/** - * bson_append_decimal128: - * @bson: A bson_t. - * @key: The key for the field. - * @value: The bson_decimal128_t decimal128 value. - * - * Appends a new field of type BSON_TYPE_DECIMAL128 to @bson. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_decimal128 (bson_t *bson, - const char *key, - int key_length, - const bson_decimal128_t *value); - -#define BSON_APPEND_DECIMAL128(b, key, val) \ - bson_append_decimal128 (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_decimal128 (bson_array_builder_t *bab, - const bson_decimal128_t *value); - -/** - * bson_append_iter: - * @bson: A bson_t to append to. - * @key: The key name or %NULL to take current key from @iter. - * @key_length: The key length or -1 to use strlen(). - * @iter: The iter located on the position of the element to append. - * - * Appends a new field to @bson that is equivalent to the field currently - * pointed to by @iter. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_iter (bson_t *bson, - const char *key, - int key_length, - const bson_iter_t *iter); - -#define BSON_APPEND_ITER(b, key, val) \ - bson_append_iter (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_iter (bson_array_builder_t *bab, - const bson_iter_t *iter); - -/** - * bson_append_minkey: - * @bson: A bson_t. - * @key: The key for the field. - * - * Appends a new field of type BSON_TYPE_MINKEY to @bson. This is a special - * type that compares lower than all other possible BSON element values. - * - * See http://bsonspec.org for more information on this type. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_minkey (bson_t *bson, const char *key, int key_length); - -#define BSON_APPEND_MINKEY(b, key) \ - bson_append_minkey (b, key, (int) strlen (key)) - -BSON_EXPORT (bool) -bson_array_builder_append_minkey (bson_array_builder_t *bab); - -/** - * bson_append_maxkey: - * @bson: A bson_t. - * @key: The key for the field. - * - * Appends a new field of type BSON_TYPE_MAXKEY to @bson. This is a special - * type that compares higher than all other possible BSON element values. - * - * See http://bsonspec.org for more information on this type. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_maxkey (bson_t *bson, const char *key, int key_length); - -#define BSON_APPEND_MAXKEY(b, key) \ - bson_append_maxkey (b, key, (int) strlen (key)) - -BSON_EXPORT (bool) -bson_array_builder_append_maxkey (bson_array_builder_t *bab); - -/** - * bson_append_null: - * @bson: A bson_t. - * @key: The key for the field. - * - * Appends a new field to @bson with NULL for the value. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_null (bson_t *bson, const char *key, int key_length); - -#define BSON_APPEND_NULL(b, key) bson_append_null (b, key, (int) strlen (key)) - -BSON_EXPORT (bool) -bson_array_builder_append_null (bson_array_builder_t *bab); - -/** - * bson_append_oid: - * @bson: A bson_t. - * @key: The key for the field. - * @oid: bson_oid_t. - * - * Appends a new field to the @bson of type BSON_TYPE_OID using the contents of - * @oid. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_oid (bson_t *bson, - const char *key, - int key_length, - const bson_oid_t *oid); - -#define BSON_APPEND_OID(b, key, val) \ - bson_append_oid (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_oid (bson_array_builder_t *bab, - const bson_oid_t *oid); - -/** - * bson_append_regex: - * @bson: A bson_t. - * @key: The key of the field. - * @regex: The regex to append to the bson. - * @options: Options for @regex. - * - * Appends a new field to @bson of type BSON_TYPE_REGEX. @regex should - * be the regex string. @options should contain the options for the regex. - * - * Valid options for @options are: - * - * 'i' for case-insensitive. - * 'm' for multiple matching. - * 'x' for verbose mode. - * 'l' to make \w and \W locale dependent. - * 's' for dotall mode ('.' matches everything) - * 'u' to make \w and \W match unicode. - * - * For more detailed information about BSON regex elements, see bsonspec.org. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_regex (bson_t *bson, - const char *key, - int key_length, - const char *regex, - const char *options); - -#define BSON_APPEND_REGEX(b, key, val, opt) \ - bson_append_regex (b, key, (int) strlen (key), val, opt) - -BSON_EXPORT (bool) -bson_array_builder_append_regex (bson_array_builder_t *bab, - const char *regex, - const char *options); - -/** - * bson_append_regex: - * @bson: A bson_t. - * @key: The key of the field. - * @key_length: The length of the key string. - * @regex: The regex to append to the bson. - * @regex_length: The length of the regex string. - * @options: Options for @regex. - * - * Appends a new field to @bson of type BSON_TYPE_REGEX. @regex should - * be the regex string. @options should contain the options for the regex. - * - * Valid options for @options are: - * - * 'i' for case-insensitive. - * 'm' for multiple matching. - * 'x' for verbose mode. - * 'l' to make \w and \W locale dependent. - * 's' for dotall mode ('.' matches everything) - * 'u' to make \w and \W match unicode. - * - * For more detailed information about BSON regex elements, see bsonspec.org. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_regex_w_len (bson_t *bson, - const char *key, - int key_length, - const char *regex, - int regex_length, - const char *options); - -BSON_EXPORT (bool) -bson_array_builder_append_regex_w_len (bson_array_builder_t *bab, - const char *regex, - int regex_length, - const char *options); - -/** - * bson_append_utf8: - * @bson: A bson_t. - * @key: The key for the field. - * @value: A UTF-8 encoded string. - * @length: The length of @value or -1 if it is NUL terminated. - * - * Appends a new field to @bson using @key as the key and @value as the UTF-8 - * encoded value. - * - * It is the callers responsibility to ensure @value is valid UTF-8. You can - * use bson_utf8_validate() to perform this check. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_utf8 (bson_t *bson, - const char *key, - int key_length, - const char *value, - int length); - -#define BSON_APPEND_UTF8(b, key, val) \ - bson_append_utf8 (b, key, (int) strlen (key), val, (int) strlen (val)) - -BSON_EXPORT (bool) -bson_array_builder_append_utf8 (bson_array_builder_t *bab, - const char *value, - int length); - -/** - * bson_append_symbol: - * @bson: A bson_t. - * @key: The key for the field. - * @value: The symbol as a string. - * @length: The length of @value or -1 if NUL-terminated. - * - * Appends a new field to @bson of type BSON_TYPE_SYMBOL. This BSON type is - * deprecated and should not be used in new code. - * - * See http://bsonspec.org for more information on this type. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_symbol (bson_t *bson, - const char *key, - int key_length, - const char *value, - int length); - -#define BSON_APPEND_SYMBOL(b, key, val) \ - bson_append_symbol (b, key, (int) strlen (key), val, (int) strlen (val)) - -BSON_EXPORT (bool) -bson_array_builder_append_symbol (bson_array_builder_t *bab, - const char *value, - int length); - -/** - * bson_append_time_t: - * @bson: A bson_t. - * @key: The key for the field. - * @value: A time_t. - * - * Appends a BSON_TYPE_DATE_TIME field to @bson using the time_t @value for the - * number of seconds since UNIX epoch in UTC. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_time_t (bson_t *bson, - const char *key, - int key_length, - time_t value); - -#define BSON_APPEND_TIME_T(b, key, val) \ - bson_append_time_t (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_time_t (bson_array_builder_t *bab, time_t value); - -/** - * bson_append_timeval: - * @bson: A bson_t. - * @key: The key for the field. - * @value: A struct timeval containing the date and time. - * - * Appends a BSON_TYPE_DATE_TIME field to @bson using the struct timeval - * provided. The time is persisted in milliseconds since the UNIX epoch in UTC. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_timeval (bson_t *bson, - const char *key, - int key_length, - struct timeval *value); - -#define BSON_APPEND_TIMEVAL(b, key, val) \ - bson_append_timeval (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_timeval (bson_array_builder_t *bab, - struct timeval *value); - -/** - * bson_append_date_time: - * @bson: A bson_t. - * @key: The key for the field. - * @key_length: The length of @key in bytes or -1 if \0 terminated. - * @value: The number of milliseconds elapsed since UNIX epoch. - * - * Appends a new field to @bson of type BSON_TYPE_DATE_TIME. - * - * Returns: true if successful; otherwise false. - */ -BSON_EXPORT (bool) -bson_append_date_time (bson_t *bson, - const char *key, - int key_length, - int64_t value); - -#define BSON_APPEND_DATE_TIME(b, key, val) \ - bson_append_date_time (b, key, (int) strlen (key), val) - -BSON_EXPORT (bool) -bson_array_builder_append_date_time (bson_array_builder_t *bab, int64_t value); - -/** - * bson_append_now_utc: - * @bson: A bson_t. - * @key: The key for the field. - * @key_length: The length of @key or -1 if it is NULL terminated. - * - * Appends a BSON_TYPE_DATE_TIME field to @bson using the current time in UTC - * as the field value. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_now_utc (bson_t *bson, const char *key, int key_length); - -#define BSON_APPEND_NOW_UTC(b, key) \ - bson_append_now_utc (b, key, (int) strlen (key)) - -BSON_EXPORT (bool) -bson_array_builder_append_now_utc (bson_array_builder_t *bab); - -/** - * bson_append_timestamp: - * @bson: A bson_t. - * @key: The key for the field. - * @timestamp: 4 byte timestamp. - * @increment: 4 byte increment for timestamp. - * - * Appends a field of type BSON_TYPE_TIMESTAMP to @bson. This is a special type - * used by MongoDB replication and sharding. If you need generic time and date - * fields use bson_append_time_t() or bson_append_timeval(). - * - * Setting @increment and @timestamp to zero has special semantics. See - * http://bsonspec.org for more information on this field type. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_timestamp (bson_t *bson, - const char *key, - int key_length, - uint32_t timestamp, - uint32_t increment); - -#define BSON_APPEND_TIMESTAMP(b, key, val, inc) \ - bson_append_timestamp (b, key, (int) strlen (key), val, inc) - -BSON_EXPORT (bool) -bson_array_builder_append_timestamp (bson_array_builder_t *bab, - uint32_t timestamp, - uint32_t increment); - -/** - * bson_append_undefined: - * @bson: A bson_t. - * @key: The key for the field. - * - * Appends a field of type BSON_TYPE_UNDEFINED. This type is deprecated in the - * spec and should not be used for new code. However, it is provided for those - * needing to interact with legacy systems. - * - * Returns: true if successful; false if append would overflow max size. - */ -BSON_EXPORT (bool) -bson_append_undefined (bson_t *bson, const char *key, int key_length); - -#define BSON_APPEND_UNDEFINED(b, key) \ - bson_append_undefined (b, key, (int) strlen (key)) - -BSON_EXPORT (bool) -bson_array_builder_append_undefined (bson_array_builder_t *bab); - -BSON_EXPORT (bool) -bson_concat (bson_t *dst, const bson_t *src); - -BSON_EXPORT (bool) -bson_append_array_builder_begin (bson_t *bson, - const char *key, - int key_length, - bson_array_builder_t **child); - -#define BSON_APPEND_ARRAY_BUILDER_BEGIN(b, key, child) \ - bson_append_array_builder_begin (b, key, (int) strlen (key), child) - -BSON_EXPORT (bool) -bson_array_builder_append_array_builder_begin (bson_array_builder_t *bab, - bson_array_builder_t **child); - -BSON_EXPORT (bool) -bson_append_array_builder_end (bson_t *bson, bson_array_builder_t *child); - -BSON_EXPORT (bool) -bson_array_builder_append_array_builder_end (bson_array_builder_t *bab, - bson_array_builder_t *child); - - -BSON_END_DECLS - - -#endif /* BSON_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/forwarding/bson.h b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/forwarding/bson.h deleted file mode 100644 index cfe6d0682..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/forwarding/bson.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2018-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Including bson.h is superseded. Use bson/bson.h instead. */ -#include "bson/bson.h" \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/modules/module.modulemap.in b/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/modules/module.modulemap.in deleted file mode 100644 index 7c087d2b3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/src/bson/modules/module.modulemap.in +++ /dev/null @@ -1,5 +0,0 @@ -framework module bson [system] { - umbrella header "bson.h" - - export * -} \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-atomic.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-atomic.c deleted file mode 100644 index 3f5d80332..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-atomic.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "TestSuite.h" - -#define ATOMIC(Kind, Operation) BSON_CONCAT4 (bson_atomic_, Kind, _, Operation) - - -#define TEST_KIND_WITH_MEMORDER(Kind, TypeName, MemOrder, Assert) \ - do { \ - int i; \ - TypeName got; \ - TypeName value = 0; \ - got = ATOMIC (Kind, fetch) (&value, MemOrder); \ - Assert (got, ==, 0); \ - got = ATOMIC (Kind, fetch_add) (&value, 42, MemOrder); \ - Assert (got, ==, 0); \ - Assert (value, ==, 42); \ - got = ATOMIC (Kind, fetch_sub) (&value, 7, MemOrder); \ - Assert (got, ==, 42); \ - Assert (value, ==, 35); \ - got = ATOMIC (Kind, exchange) (&value, 77, MemOrder); \ - Assert (got, ==, 35); \ - Assert (value, ==, 77); \ - /* Compare-exchange fail: */ \ - got = ATOMIC (Kind, compare_exchange_strong) (&value, 4, 9, MemOrder); \ - Assert (got, ==, 77); \ - Assert (value, ==, 77); \ - /* Compare-exchange succeed: */ \ - got = ATOMIC (Kind, compare_exchange_strong) (&value, 77, 9, MemOrder); \ - Assert (got, ==, 77); \ - Assert (value, ==, 9); \ - /* Compare-exchange fail: */ \ - got = ATOMIC (Kind, compare_exchange_weak) (&value, 8, 12, MemOrder); \ - Assert (got, ==, 9); \ - Assert (value, ==, 9); \ - /* Compare-exchange-weak succeed: */ \ - /* 'weak' may fail spuriously, so it must *eventually* succeed */ \ - for (i = 0; i < 10000 && value != 53; ++i) { \ - got = ATOMIC (Kind, compare_exchange_weak) (&value, 9, 53, MemOrder); \ - Assert (got, ==, 9); \ - } \ - /* Check that it evenutally succeeded */ \ - Assert (value, ==, 53); \ - } while (0) - -#define TEST_INTEGER_KIND(Kind, TypeName, Assert) \ - do { \ - TEST_KIND_WITH_MEMORDER ( \ - Kind, TypeName, bson_memory_order_relaxed, Assert); \ - TEST_KIND_WITH_MEMORDER ( \ - Kind, TypeName, bson_memory_order_acq_rel, Assert); \ - TEST_KIND_WITH_MEMORDER ( \ - Kind, TypeName, bson_memory_order_acquire, Assert); \ - TEST_KIND_WITH_MEMORDER ( \ - Kind, TypeName, bson_memory_order_release, Assert); \ - TEST_KIND_WITH_MEMORDER ( \ - Kind, TypeName, bson_memory_order_consume, Assert); \ - TEST_KIND_WITH_MEMORDER ( \ - Kind, TypeName, bson_memory_order_seq_cst, Assert); \ - } while (0) - - -static void -test_integers (void) -{ - TEST_INTEGER_KIND (int64, int64_t, ASSERT_CMPINT64); - TEST_INTEGER_KIND (int32, int32_t, ASSERT_CMPINT32); - TEST_INTEGER_KIND (int16, int16_t, ASSERT_CMPINT); - TEST_INTEGER_KIND (int8, int8_t, ASSERT_CMPINT); - TEST_INTEGER_KIND (int, int, ASSERT_CMPINT); -} - - -static void -test_pointers (void) -{ - int u = 12; - int v = 9; - int w = 91; - int *ptr = &v; - int *other; - int *prev; - other = bson_atomic_ptr_fetch ((void *) &ptr, bson_memory_order_relaxed); - ASSERT_CMPVOID (other, ==, ptr); - prev = - bson_atomic_ptr_exchange ((void *) &other, &u, bson_memory_order_relaxed); - ASSERT_CMPVOID (prev, ==, &v); - ASSERT_CMPVOID (other, ==, &u); - prev = bson_atomic_ptr_compare_exchange_strong ( - (void *) &other, &v, &w, bson_memory_order_relaxed); - ASSERT_CMPVOID (prev, ==, &u); - ASSERT_CMPVOID (other, ==, &u); - prev = bson_atomic_ptr_compare_exchange_strong ( - (void *) &other, &u, &w, bson_memory_order_relaxed); - ASSERT_CMPVOID (prev, ==, &u); - ASSERT_CMPVOID (other, ==, &w); -} - - -static void -test_thread_fence (void) -{ - bson_atomic_thread_fence (); -} - -static void -test_thrd_yield (void) -{ - bson_thrd_yield (); -} - -void -test_atomic_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/atomic/integers", test_integers); - TestSuite_Add (suite, "/atomic/pointers", test_pointers); - TestSuite_Add (suite, "/atomic/thread_fence", test_thread_fence); - TestSuite_Add (suite, "/atomic/thread_yield", test_thrd_yield); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson-cmp.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson-cmp.c deleted file mode 100644 index fd922305d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson-cmp.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright 2022 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "TestSuite.h" - -#include - -static void -test_bson_cmp_equal (void) -{ - BSON_ASSERT (bson_cmp_equal_ss (0, 0)); - BSON_ASSERT (!bson_cmp_equal_ss (0, -1)); - BSON_ASSERT (!bson_cmp_equal_ss (0, 1)); - BSON_ASSERT (!bson_cmp_equal_ss (-1, 0)); - BSON_ASSERT (bson_cmp_equal_ss (-1, -1)); - BSON_ASSERT (!bson_cmp_equal_ss (-1, 1)); - BSON_ASSERT (!bson_cmp_equal_ss (1, 0)); - BSON_ASSERT (!bson_cmp_equal_ss (1, -1)); - BSON_ASSERT (bson_cmp_equal_ss (1, 1)); - - BSON_ASSERT (bson_cmp_equal_uu (0u, 0u)); - BSON_ASSERT (!bson_cmp_equal_uu (0u, 1u)); - BSON_ASSERT (!bson_cmp_equal_uu (1u, 0u)); - BSON_ASSERT (bson_cmp_equal_uu (1u, 1u)); - - BSON_ASSERT (bson_cmp_equal_su (0, 0u)); - BSON_ASSERT (!bson_cmp_equal_su (0, 1u)); - BSON_ASSERT (!bson_cmp_equal_su (-1, 0u)); - BSON_ASSERT (!bson_cmp_equal_su (-1, 1u)); - BSON_ASSERT (!bson_cmp_equal_su (1, 0u)); - BSON_ASSERT (bson_cmp_equal_su (1, 1u)); - - BSON_ASSERT (bson_cmp_equal_us (0u, 0)); - BSON_ASSERT (!bson_cmp_equal_us (0u, -1)); - BSON_ASSERT (!bson_cmp_equal_us (0u, 1)); - BSON_ASSERT (!bson_cmp_equal_us (1u, 0)); - BSON_ASSERT (!bson_cmp_equal_us (1u, -1)); - BSON_ASSERT (bson_cmp_equal_us (1u, 1)); -} - -static void -test_bson_cmp_not_equal (void) -{ - BSON_ASSERT (!bson_cmp_not_equal_ss (0, 0)); - BSON_ASSERT (bson_cmp_not_equal_ss (0, -1)); - BSON_ASSERT (bson_cmp_not_equal_ss (0, 1)); - BSON_ASSERT (bson_cmp_not_equal_ss (-1, 0)); - BSON_ASSERT (!bson_cmp_not_equal_ss (-1, -1)); - BSON_ASSERT (bson_cmp_not_equal_ss (-1, 1)); - BSON_ASSERT (bson_cmp_not_equal_ss (1, 0)); - BSON_ASSERT (bson_cmp_not_equal_ss (1, -1)); - BSON_ASSERT (!bson_cmp_not_equal_ss (1, 1)); - - BSON_ASSERT (!bson_cmp_not_equal_uu (0u, 0u)); - BSON_ASSERT (bson_cmp_not_equal_uu (0u, 1u)); - BSON_ASSERT (bson_cmp_not_equal_uu (1u, 0u)); - BSON_ASSERT (!bson_cmp_not_equal_uu (1u, 1u)); - - BSON_ASSERT (!bson_cmp_not_equal_su (0, 0u)); - BSON_ASSERT (bson_cmp_not_equal_su (0, 1u)); - BSON_ASSERT (bson_cmp_not_equal_su (-1, 0u)); - BSON_ASSERT (bson_cmp_not_equal_su (-1, 1u)); - BSON_ASSERT (bson_cmp_not_equal_su (1, 0u)); - BSON_ASSERT (!bson_cmp_not_equal_su (1, 1u)); - - BSON_ASSERT (!bson_cmp_not_equal_us (0u, 0)); - BSON_ASSERT (bson_cmp_not_equal_us (0u, -1)); - BSON_ASSERT (bson_cmp_not_equal_us (0u, 1)); - BSON_ASSERT (bson_cmp_not_equal_us (1u, 0)); - BSON_ASSERT (bson_cmp_not_equal_us (1u, -1)); - BSON_ASSERT (!bson_cmp_not_equal_us (1u, 1)); -} - -static void -test_bson_cmp_less (void) -{ - BSON_ASSERT (!bson_cmp_less_ss (0, 0)); - BSON_ASSERT (!bson_cmp_less_ss (0, -1)); - BSON_ASSERT (bson_cmp_less_ss (0, 1)); - BSON_ASSERT (bson_cmp_less_ss (-1, 0)); - BSON_ASSERT (!bson_cmp_less_ss (-1, -1)); - BSON_ASSERT (bson_cmp_less_ss (-1, 1)); - BSON_ASSERT (!bson_cmp_less_ss (1, 0)); - BSON_ASSERT (!bson_cmp_less_ss (1, -1)); - BSON_ASSERT (!bson_cmp_less_ss (1, 1)); - - BSON_ASSERT (!bson_cmp_less_uu (0u, 0u)); - BSON_ASSERT (bson_cmp_less_uu (0u, 1u)); - BSON_ASSERT (!bson_cmp_less_uu (1u, 0u)); - BSON_ASSERT (!bson_cmp_less_uu (1u, 1u)); - - BSON_ASSERT (!bson_cmp_less_su (0, 0u)); - BSON_ASSERT (bson_cmp_less_su (0, 1u)); - BSON_ASSERT (bson_cmp_less_su (-1, 0u)); - BSON_ASSERT (bson_cmp_less_su (-1, 1u)); - BSON_ASSERT (!bson_cmp_less_su (1, 0u)); - BSON_ASSERT (!bson_cmp_less_su (1, 1u)); - - BSON_ASSERT (!bson_cmp_less_us (0u, 0)); - BSON_ASSERT (!bson_cmp_less_us (0u, -1)); - BSON_ASSERT (bson_cmp_less_us (0u, 1)); - BSON_ASSERT (!bson_cmp_less_us (1u, 0)); - BSON_ASSERT (!bson_cmp_less_us (1u, -1)); - BSON_ASSERT (!bson_cmp_less_us (1u, 1)); -} - -static void -test_bson_cmp_greater (void) -{ - BSON_ASSERT (!bson_cmp_greater_ss (0, 0)); - BSON_ASSERT (bson_cmp_greater_ss (0, -1)); - BSON_ASSERT (!bson_cmp_greater_ss (0, 1)); - BSON_ASSERT (!bson_cmp_greater_ss (-1, 0)); - BSON_ASSERT (!bson_cmp_greater_ss (-1, -1)); - BSON_ASSERT (!bson_cmp_greater_ss (-1, 1)); - BSON_ASSERT (bson_cmp_greater_ss (1, 0)); - BSON_ASSERT (bson_cmp_greater_ss (1, -1)); - BSON_ASSERT (!bson_cmp_greater_ss (1, 1)); - - BSON_ASSERT (!bson_cmp_greater_uu (0u, 0u)); - BSON_ASSERT (!bson_cmp_greater_uu (0u, 1u)); - BSON_ASSERT (bson_cmp_greater_uu (1u, 0u)); - BSON_ASSERT (!bson_cmp_greater_uu (1u, 1u)); - - BSON_ASSERT (!bson_cmp_greater_su (0, 0u)); - BSON_ASSERT (!bson_cmp_greater_su (0, 1u)); - BSON_ASSERT (!bson_cmp_greater_su (-1, 0u)); - BSON_ASSERT (!bson_cmp_greater_su (-1, 1u)); - BSON_ASSERT (bson_cmp_greater_su (1, 0u)); - BSON_ASSERT (!bson_cmp_greater_su (1, 1u)); - - BSON_ASSERT (!bson_cmp_greater_us (0u, 0)); - BSON_ASSERT (bson_cmp_greater_us (0u, -1)); - BSON_ASSERT (!bson_cmp_greater_us (0u, 1)); - BSON_ASSERT (bson_cmp_greater_us (1u, 0)); - BSON_ASSERT (bson_cmp_greater_us (1u, -1)); - BSON_ASSERT (!bson_cmp_greater_us (1u, 1)); -} - -static void -test_bson_cmp_less_equal (void) -{ - BSON_ASSERT (bson_cmp_less_equal_ss (0, 0)); - BSON_ASSERT (!bson_cmp_less_equal_ss (0, -1)); - BSON_ASSERT (bson_cmp_less_equal_ss (0, 1)); - BSON_ASSERT (bson_cmp_less_equal_ss (-1, 0)); - BSON_ASSERT (bson_cmp_less_equal_ss (-1, -1)); - BSON_ASSERT (bson_cmp_less_equal_ss (-1, 1)); - BSON_ASSERT (!bson_cmp_less_equal_ss (1, 0)); - BSON_ASSERT (!bson_cmp_less_equal_ss (1, -1)); - BSON_ASSERT (bson_cmp_less_equal_ss (1, 1)); - - BSON_ASSERT (bson_cmp_less_equal_uu (0u, 0u)); - BSON_ASSERT (bson_cmp_less_equal_uu (0u, 1u)); - BSON_ASSERT (!bson_cmp_less_equal_uu (1u, 0u)); - BSON_ASSERT (bson_cmp_less_equal_uu (1u, 1u)); - - BSON_ASSERT (bson_cmp_less_equal_su (0, 0u)); - BSON_ASSERT (bson_cmp_less_equal_su (0, 1u)); - BSON_ASSERT (bson_cmp_less_equal_su (-1, 0u)); - BSON_ASSERT (bson_cmp_less_equal_su (-1, 1u)); - BSON_ASSERT (!bson_cmp_less_equal_su (1, 0u)); - BSON_ASSERT (bson_cmp_less_equal_su (1, 1u)); - - BSON_ASSERT (bson_cmp_less_equal_us (0u, 0)); - BSON_ASSERT (!bson_cmp_less_equal_us (0u, -1)); - BSON_ASSERT (bson_cmp_less_equal_us (0u, 1)); - BSON_ASSERT (!bson_cmp_less_equal_us (1u, 0)); - BSON_ASSERT (!bson_cmp_less_equal_us (1u, -1)); - BSON_ASSERT (bson_cmp_less_equal_us (1u, 1)); -} - -static void -test_bson_cmp_greater_equal (void) -{ - BSON_ASSERT (bson_cmp_greater_equal_ss (0, 0)); - BSON_ASSERT (bson_cmp_greater_equal_ss (0, -1)); - BSON_ASSERT (!bson_cmp_greater_equal_ss (0, 1)); - BSON_ASSERT (!bson_cmp_greater_equal_ss (-1, 0)); - BSON_ASSERT (bson_cmp_greater_equal_ss (-1, -1)); - BSON_ASSERT (!bson_cmp_greater_equal_ss (-1, 1)); - BSON_ASSERT (bson_cmp_greater_equal_ss (1, 0)); - BSON_ASSERT (bson_cmp_greater_equal_ss (1, -1)); - BSON_ASSERT (bson_cmp_greater_equal_ss (1, 1)); - - BSON_ASSERT (bson_cmp_greater_equal_uu (0u, 0u)); - BSON_ASSERT (!bson_cmp_greater_equal_uu (0u, 1u)); - BSON_ASSERT (bson_cmp_greater_equal_uu (1u, 0u)); - BSON_ASSERT (bson_cmp_greater_equal_uu (1u, 1u)); - - BSON_ASSERT (bson_cmp_greater_equal_su (0, 0u)); - BSON_ASSERT (!bson_cmp_greater_equal_su (0, 1u)); - BSON_ASSERT (!bson_cmp_greater_equal_su (-1, 0u)); - BSON_ASSERT (!bson_cmp_greater_equal_su (-1, 1u)); - BSON_ASSERT (bson_cmp_greater_equal_su (1, 0u)); - BSON_ASSERT (bson_cmp_greater_equal_su (1, 1u)); - - BSON_ASSERT (bson_cmp_greater_equal_us (0u, 0)); - BSON_ASSERT (bson_cmp_greater_equal_us (0u, -1)); - BSON_ASSERT (!bson_cmp_greater_equal_us (0u, 1)); - BSON_ASSERT (bson_cmp_greater_equal_us (1u, 0)); - BSON_ASSERT (bson_cmp_greater_equal_us (1u, -1)); - BSON_ASSERT (bson_cmp_greater_equal_us (1u, 1)); -} - -/* Sanity check: ensure ssize_t limits are as expected relative to size_t. */ -BSON_STATIC_ASSERT2 (ssize_t_size_min_check, SSIZE_MIN + 1 == -SSIZE_MAX); -BSON_STATIC_ASSERT2 (ssize_t_size_max_check, (size_t) SSIZE_MAX <= SIZE_MAX); - -static void -test_bson_in_range (void) -{ - const int64_t int8_min = INT8_MIN; - const int64_t int8_max = INT8_MAX; - const int64_t int32_min = INT32_MIN; - const int64_t int32_max = INT32_MAX; - - const uint64_t uint8_max = UINT8_MAX; - const uint64_t uint32_max = UINT32_MAX; - - const ssize_t ssize_min = SSIZE_MIN; - const ssize_t ssize_max = SSIZE_MAX; - - BSON_ASSERT (!bson_in_range_signed (int8_t, int8_min - 1)); - BSON_ASSERT (bson_in_range_signed (int8_t, int8_min)); - BSON_ASSERT (bson_in_range_signed (int8_t, 0)); - BSON_ASSERT (bson_in_range_signed (int8_t, int8_max)); - BSON_ASSERT (!bson_in_range_signed (int8_t, int8_max + 1)); - - BSON_ASSERT (bson_in_range_unsigned (int8_t, 0u)); - BSON_ASSERT (bson_in_range_unsigned (int8_t, (uint64_t) int8_max)); - BSON_ASSERT (!bson_in_range_unsigned (int8_t, (uint64_t) (int8_max + 1))); - - BSON_ASSERT (!bson_in_range_signed (uint8_t, int8_min - 1)); - BSON_ASSERT (!bson_in_range_signed (uint8_t, int8_min)); - BSON_ASSERT (bson_in_range_signed (uint8_t, 0)); - BSON_ASSERT (bson_in_range_signed (uint8_t, int8_max)); - BSON_ASSERT (bson_in_range_signed (uint8_t, int8_max + 1)); - BSON_ASSERT (bson_in_range_signed (uint8_t, (int64_t) uint8_max)); - BSON_ASSERT (!bson_in_range_signed (uint8_t, (int64_t) uint8_max + 1)); - - BSON_ASSERT (bson_in_range_unsigned (uint8_t, 0u)); - BSON_ASSERT (bson_in_range_unsigned (uint8_t, uint8_max)); - BSON_ASSERT (!bson_in_range_unsigned (uint8_t, uint8_max + 1u)); - - BSON_ASSERT (!bson_in_range_signed (int32_t, int32_min - 1)); - BSON_ASSERT (bson_in_range_signed (int32_t, int32_min)); - BSON_ASSERT (bson_in_range_signed (int32_t, 0)); - BSON_ASSERT (bson_in_range_signed (int32_t, int32_max)); - BSON_ASSERT (!bson_in_range_signed (int32_t, int32_max + 1)); - - BSON_ASSERT (bson_in_range_unsigned (int32_t, 0u)); - BSON_ASSERT (bson_in_range_unsigned (int32_t, (uint64_t) int32_max)); - BSON_ASSERT (!bson_in_range_unsigned (int32_t, (uint64_t) (int32_max + 1))); - - BSON_ASSERT (!bson_in_range_signed (uint32_t, int32_min - 1)); - BSON_ASSERT (!bson_in_range_signed (uint32_t, int32_min)); - BSON_ASSERT (bson_in_range_signed (uint32_t, 0)); - BSON_ASSERT (bson_in_range_signed (uint32_t, int32_max)); - BSON_ASSERT (bson_in_range_signed (uint32_t, int32_max + 1)); - BSON_ASSERT (bson_in_range_signed (uint32_t, (int64_t) uint32_max)); - BSON_ASSERT (!bson_in_range_signed (uint32_t, (int64_t) uint32_max + 1)); - - BSON_ASSERT (bson_in_range_unsigned (uint32_t, 0u)); - BSON_ASSERT (bson_in_range_unsigned (uint32_t, uint32_max)); - BSON_ASSERT (!bson_in_range_unsigned (uint32_t, uint32_max + 1u)); - - BSON_ASSERT (bson_in_range_signed (ssize_t, ssize_min)); - BSON_ASSERT (bson_in_range_signed (ssize_t, 0)); - BSON_ASSERT (bson_in_range_signed (ssize_t, ssize_max)); - - BSON_ASSERT (bson_in_range_unsigned (ssize_t, 0u)); - BSON_ASSERT (bson_in_range_unsigned (ssize_t, (size_t) ssize_max)); - BSON_ASSERT (!bson_in_range_unsigned (ssize_t, (size_t) ssize_max + 1u)); - - BSON_ASSERT (!bson_in_range_signed (size_t, ssize_min)); - BSON_ASSERT (bson_in_range_signed (size_t, 0)); - BSON_ASSERT (bson_in_range_signed (size_t, ssize_max)); - - BSON_ASSERT (bson_in_range_unsigned (size_t, 0u)); - BSON_ASSERT (bson_in_range_unsigned (size_t, (size_t) ssize_max)); - BSON_ASSERT (bson_in_range_unsigned (size_t, (size_t) ssize_max + 1u)); -} - -void -test_bson_cmp_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/bson/cmp/equal", test_bson_cmp_equal); - TestSuite_Add (suite, "/bson/cmp/not_equal", test_bson_cmp_not_equal); - TestSuite_Add (suite, "/bson/cmp/less", test_bson_cmp_less); - TestSuite_Add (suite, "/bson/cmp/greater", test_bson_cmp_greater); - TestSuite_Add (suite, "/bson/cmp/less_equal", test_bson_cmp_less_equal); - TestSuite_Add ( - suite, "/bson/cmp/greater_equal", test_bson_cmp_greater_equal); - TestSuite_Add (suite, "/bson/cmp/in_range", test_bson_in_range); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson-error.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson-error.c deleted file mode 100644 index c58ff5199..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson-error.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "TestSuite.h" - - -static void -test_bson_error_basic (void) -{ - bson_error_t error; - - bson_set_error (&error, 123, 456, "%s %u", "localhost", 27017); - BSON_ASSERT (!strcmp (error.message, "localhost 27017")); - ASSERT_CMPINT (error.domain, ==, 123); - ASSERT_CMPINT (error.code, ==, 456); -} - - -void -test_bson_error_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/bson/error/basic", test_bson_error_basic); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson-version.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson-version.c deleted file mode 100644 index 9ea90d820..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson-version.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -#include "TestSuite.h" - -static void -test_bson_version (void) -{ - ASSERT_CMPINT (bson_get_major_version (), ==, BSON_MAJOR_VERSION); - ASSERT_CMPINT (bson_get_minor_version (), ==, BSON_MINOR_VERSION); - ASSERT_CMPINT (bson_get_micro_version (), ==, BSON_MICRO_VERSION); - ASSERT_CMPSTR (bson_get_version (), BSON_VERSION_S); - - ASSERT (bson_check_version ( - BSON_MAJOR_VERSION, BSON_MINOR_VERSION, BSON_MICRO_VERSION)); - - ASSERT (!bson_check_version ( - BSON_MAJOR_VERSION, BSON_MINOR_VERSION + 1, BSON_MICRO_VERSION)); -} - -void -test_bson_version_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/bson/version", test_bson_version); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson.c deleted file mode 100644 index 0e14aa53f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-bson.c +++ /dev/null @@ -1,3452 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include - -#include - -#include "TestSuite.h" -#include "test-conveniences.h" - -/* CDRIVER-2460 ensure the unused old BSON_ASSERT_STATIC macro still compiles */ -BSON_STATIC_ASSERT (1 == 1); - - -static bson_t * -get_bson (const char *filename) -{ - ssize_t len; - uint8_t buf[4096]; - bson_t *b; - char real_filename[256]; - int fd; - - bson_snprintf ( - real_filename, sizeof real_filename, BSON_BINARY_DIR "/%s", filename); - - real_filename[sizeof real_filename - 1] = '\0'; - - if (-1 == (fd = bson_open (real_filename, O_RDONLY))) { - fprintf (stderr, "Failed to bson_open: %s\n", real_filename); - abort (); - } - len = bson_read (fd, buf, sizeof buf); - BSON_ASSERT (len > 0); - b = bson_new_from_data (buf, (uint32_t) len); - bson_close (fd); - - return b; -} - - -static void -test_bson_new (void) -{ - bson_t *b; - - b = bson_new (); - ASSERT_CMPUINT32 (b->len, ==, (uint32_t) 5); - bson_destroy (b); - - b = bson_sized_new (32); - ASSERT_CMPUINT32 (b->len, ==, (uint32_t) 5); - bson_destroy (b); -} - - -static void -test_bson_alloc (void) -{ - static const uint8_t empty_bson[] = {5, 0, 0, 0, 0}; - bson_t *b; - - b = bson_new (); - ASSERT_CMPUINT32 (b->len, ==, (uint32_t) 5); - BSON_ASSERT ((b->flags & BSON_FLAG_INLINE)); - BSON_ASSERT (!(b->flags & BSON_FLAG_CHILD)); - BSON_ASSERT (!(b->flags & BSON_FLAG_STATIC)); - BSON_ASSERT (!(b->flags & BSON_FLAG_NO_FREE)); - bson_destroy (b); - - /* - * This checks that we fit in the inline buffer size. - */ - b = bson_sized_new (44); - ASSERT_CMPUINT32 (b->len, ==, (uint32_t) 5); - BSON_ASSERT ((b->flags & BSON_FLAG_INLINE)); - bson_destroy (b); - - /* - * Make sure we grow to next power of 2. - */ - b = bson_sized_new (121); - ASSERT_CMPUINT32 (b->len, ==, (uint32_t) 5); - BSON_ASSERT (!(b->flags & BSON_FLAG_INLINE)); - bson_destroy (b); - - /* - * Make sure we grow to next power of 2. - */ - b = bson_sized_new (129); - ASSERT_CMPUINT32 (b->len, ==, (uint32_t) 5); - BSON_ASSERT (!(b->flags & BSON_FLAG_INLINE)); - bson_destroy (b); - - b = bson_new_from_data (empty_bson, sizeof empty_bson); - ASSERT_CMPUINT32 (b->len, ==, (uint32_t) sizeof empty_bson); - BSON_ASSERT ((b->flags & BSON_FLAG_INLINE)); - BSON_ASSERT (!memcmp (bson_get_data (b), empty_bson, sizeof empty_bson)); - bson_destroy (b); -} - - -static void -BSON_ASSERT_BSON_EQUAL (const bson_t *a, const bson_t *b) -{ - const uint8_t *data1 = bson_get_data (a); - const uint8_t *data2 = bson_get_data (b); - uint32_t i; - - if (!bson_equal (a, b)) { - for (i = 0; i < BSON_MAX (a->len, b->len); i++) { - if (i >= a->len) { - printf ("a is too short len=%u\n", a->len); - abort (); - } else if (i >= b->len) { - printf ("b is too short len=%u\n", b->len); - abort (); - } - if (data1[i] != data2[i]) { - printf ("a[%u](0x%02x,%u) != b[%u](0x%02x,%u)\n", - i, - data1[i], - data1[i], - i, - data2[i], - data2[i]); - abort (); - } - } - } -} - - -static void -BSON_ASSERT_BSON_EQUAL_FILE (const bson_t *b, const char *filename) -{ - bson_t *b2 = get_bson (filename); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b2); -} - - -static void -test_bson_append_utf8 (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - b2 = get_bson ("test11.bson"); - BSON_ASSERT (bson_append_utf8 (b, "hello", -1, "world", -1)); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_symbol (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - b2 = get_bson ("test32.bson"); - BSON_ASSERT (bson_append_symbol (b, "hello", -1, "world", -1)); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_null (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_null (b, "hello", -1)); - b2 = get_bson ("test18.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_bool (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_bool (b, "bool", -1, true)); - b2 = get_bson ("test19.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_double (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_double (b, "double", -1, 123.4567)); - b2 = get_bson ("test20.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_document (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - b2 = bson_new (); - BSON_ASSERT (bson_append_document (b, "document", -1, b2)); - bson_destroy (b2); - b2 = get_bson ("test21.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_oid (void) -{ - bson_oid_t oid; - bson_t *b; - bson_t *b2; - - bson_oid_init_from_string (&oid, "1234567890abcdef1234abcd"); - - b = bson_new (); - BSON_ASSERT (bson_append_oid (b, "oid", -1, &oid)); - b2 = get_bson ("test22.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_array (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - b2 = bson_new (); - BSON_ASSERT (bson_append_utf8 (b2, "0", -1, "hello", -1)); - BSON_ASSERT (bson_append_utf8 (b2, "1", -1, "world", -1)); - BSON_ASSERT (bson_append_array (b, "array", -1, b2)); - bson_destroy (b2); - b2 = get_bson ("test23.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_binary (void) -{ - const static uint8_t binary[] = {'1', '2', '3', '4'}; - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT ( - bson_append_binary (b, "binary", -1, BSON_SUBTYPE_USER, binary, 4)); - b2 = get_bson ("test24.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_binary_deprecated (void) -{ - const static uint8_t binary[] = {'1', '2', '3', '4'}; - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_binary ( - b, "binary", -1, BSON_SUBTYPE_BINARY_DEPRECATED, binary, 4)); - b2 = get_bson ("binary_deprecated.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_time_t (void) -{ - bson_t *b; - bson_t *b2; - time_t t; - - t = 1234567890; - - b = bson_new (); - BSON_ASSERT (bson_append_time_t (b, "time_t", -1, t)); - b2 = get_bson ("test26.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_timeval (void) -{ - struct timeval tv = {0}; - bson_t *b; - bson_t *b2; - - tv.tv_sec = 1234567890; - tv.tv_usec = 0; - - b = bson_new (); - BSON_ASSERT (bson_append_timeval (b, "time_t", -1, &tv)); - b2 = get_bson ("test26.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_undefined (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_undefined (b, "undefined", -1)); - b2 = get_bson ("test25.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_regex (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_regex (b, "regex", -1, "^abcd", "ilx")); - b2 = get_bson ("test27.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_regex_w_len (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_regex_w_len (b, "regex", -1, "^abcd", 5, "ilx")); - b2 = get_bson ("test27.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); - - b = bson_new (); - BSON_ASSERT (bson_append_regex_w_len (b, "regex", -1, "^abcd", -1, "ilx")); - b2 = get_bson ("test27.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); - - b = bson_new (); - BSON_ASSERT ( - bson_append_regex_w_len (b, "regex", -1, "^abcd ", 5, "ilx")); - b2 = get_bson ("test27.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_code (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_code (b, "code", -1, "var a = {};")); - b2 = get_bson ("test29.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_code_with_scope (void) -{ - const uint8_t *scope_buf = NULL; - uint32_t scopelen = 0; - uint32_t len = 0; - bson_iter_t iter; - bool r; - const char *code = NULL; - bson_t *b; - bson_t *b2; - bson_t *scope; - bson_error_t err; - bool eof; - bson_reader_t *reader; - const bson_t *ticket_bson; - uint8_t malformed_data[] = { - 0x00, - 0x00, - 0x00, - 0x00, /* length of doc (set below) */ - 0x0F, /* code_w_s type */ - 0x00, /* empty key */ - 0x10, - 0x00, - 0x00, - 0x00, /* code_w_s length (needs to be > 14 for initial */ - /* validation so give a non-empty scope doc) */ - 0x00, - 0x00, - 0x00, - 0x00, /* invalid string length (must have trailing \0) */ - 0x08, - 0x00, - 0x00, - 0x00, /* scope doc length */ - 0x08, - 0x00, - 0x00, /* "" : false */ - 0x00, /* end of scope doc */ - 0x00 /* end of doc */ - }; - - /* Test with NULL bson, which converts to just CODE type. */ - b = bson_new (); - BSON_ASSERT ( - bson_append_code_with_scope (b, "code", -1, "var a = {};", NULL)); - b2 = get_bson ("test30.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - r = bson_iter_init_find (&iter, b, "code"); - BSON_ASSERT (r); - BSON_ASSERT (BSON_ITER_HOLDS_CODE (&iter)); /* Not codewscope */ - bson_destroy (b); - bson_destroy (b2); - - /* Empty scope is still CODEWSCOPE. */ - b = bson_new (); - scope = bson_new (); - BSON_ASSERT ( - bson_append_code_with_scope (b, "code", -1, "var a = {};", scope)); - b2 = get_bson ("code_w_empty_scope.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - r = bson_iter_init_find (&iter, b, "code"); - BSON_ASSERT (r); - BSON_ASSERT (BSON_ITER_HOLDS_CODEWSCOPE (&iter)); - bson_destroy (b); - bson_destroy (b2); - bson_destroy (scope); - - /* Test with non-empty scope */ - b = bson_new (); - scope = bson_new (); - BSON_ASSERT (bson_append_utf8 (scope, "foo", -1, "bar", -1)); - BSON_ASSERT ( - bson_append_code_with_scope (b, "code", -1, "var a = {};", scope)); - b2 = get_bson ("test31.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - r = bson_iter_init_find (&iter, b, "code"); - BSON_ASSERT (r); - BSON_ASSERT (BSON_ITER_HOLDS_CODEWSCOPE (&iter)); - code = bson_iter_codewscope (&iter, &len, &scopelen, &scope_buf); - BSON_ASSERT (len == 11); - BSON_ASSERT (scopelen == scope->len); - BSON_ASSERT (!strcmp (code, "var a = {};")); - bson_destroy (b); - bson_destroy (b2); - bson_destroy (scope); - - /* CDRIVER-2269 Test with a malformed zero length code string */ - malformed_data[0] = (uint8_t) sizeof (malformed_data); - b = bson_new_from_data (malformed_data, sizeof (malformed_data)); - BSON_ASSERT (b); - BSON_ASSERT (bson_iter_init (&iter, b)); - BSON_ASSERT (!bson_iter_next (&iter)); - bson_destroy (b); - - /* CDRIVER-2269 Test with malformed BSON from ticket */ - reader = - bson_reader_new_from_file (BSON_BINARY_DIR "/cdriver2269.bson", &err); - - BSON_ASSERT (reader); - ticket_bson = bson_reader_read (reader, &eof); - BSON_ASSERT (ticket_bson); - BSON_ASSERT (bson_iter_init (&iter, ticket_bson)); - BSON_ASSERT (!bson_iter_next (&iter)); - bson_reader_destroy (reader); -} - - -static void -test_bson_append_dbpointer (void) -{ - bson_oid_t oid; - bson_t *b; - bson_t *b2; - uint8_t malformed_data[] = { - 0x0C, - 0x00, - 0x00, - 0x00, /* document length (12) */ - 0x0C, /* dbpointer type */ - 0x00, /* empty string key */ - 0x04, - 0x00, - 0x00, - 0x00, /* string length (4). This is OOB. */ - 0x00, /* empty string */ - 0x00 /* end of document */ - }; - size_t error_offset = 0; - - b = bson_new (); - bson_oid_init_from_string (&oid, "0123abcd0123abcd0123abcd"); - BSON_ASSERT (bson_append_dbpointer (b, "dbpointer", -1, "foo", &oid)); - b2 = get_bson ("test28.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); - - b = bson_new_from_data (malformed_data, sizeof (malformed_data)); - BSON_ASSERT (b); - BSON_ASSERT (!bson_validate (b, BSON_VALIDATE_NONE, &error_offset)); - BSON_ASSERT (error_offset == 6); - bson_destroy (b); -} - - -static void -test_bson_append_int32 (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_int32 (b, "a", -1, -123)); - BSON_ASSERT (bson_append_int32 (b, "c", -1, 0)); - BSON_ASSERT (bson_append_int32 (b, "b", -1, 123)); - b2 = get_bson ("test33.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_int64 (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_int64 (b, "a", -1, 100000000000000ULL)); - b2 = get_bson ("test34.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_decimal128 (void) -{ - bson_t *b; - bson_t *b2; - bson_decimal128_t value; - value.high = 0; - value.low = 1; - - b = bson_new (); - BSON_ASSERT (bson_append_decimal128 (b, "a", -1, &value)); - b2 = get_bson ("test58.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_iter (void) -{ - bson_iter_t iter; - bool r; - bson_t b; - bson_t c; - - bson_init (&b); - bson_append_int32 (&b, "a", 1, 1); - bson_append_int32 (&b, "b", 1, 2); - bson_append_int32 (&b, "c", 1, 3); - bson_append_utf8 (&b, "d", 1, "hello", 5); - - bson_init (&c); - - r = bson_iter_init_find (&iter, &b, "a"); - BSON_ASSERT (r); - r = bson_append_iter (&c, NULL, 0, &iter); - BSON_ASSERT (r); - - r = bson_iter_init_find (&iter, &b, "c"); - BSON_ASSERT (r); - r = bson_append_iter (&c, NULL, 0, &iter); - BSON_ASSERT (r); - - r = bson_iter_init_find (&iter, &b, "d"); - BSON_ASSERT (r); - r = bson_append_iter (&c, "world", -1, &iter); - BSON_ASSERT (r); - - bson_iter_init (&iter, &c); - r = bson_iter_next (&iter); - BSON_ASSERT (r); - ASSERT_CMPSTR ("a", bson_iter_key (&iter)); - ASSERT_CMPINT (BSON_TYPE_INT32, ==, bson_iter_type (&iter)); - ASSERT_CMPINT (1, ==, bson_iter_int32 (&iter)); - r = bson_iter_next (&iter); - BSON_ASSERT (r); - ASSERT_CMPSTR ("c", bson_iter_key (&iter)); - ASSERT_CMPINT (BSON_TYPE_INT32, ==, bson_iter_type (&iter)); - ASSERT_CMPINT (3, ==, bson_iter_int32 (&iter)); - r = bson_iter_next (&iter); - BSON_ASSERT (r); - ASSERT_CMPINT (BSON_TYPE_UTF8, ==, bson_iter_type (&iter)); - ASSERT_CMPSTR ("world", bson_iter_key (&iter)); - ASSERT_CMPSTR ("hello", bson_iter_utf8 (&iter, NULL)); - - bson_destroy (&b); - bson_destroy (&c); -} - - -static void -test_bson_append_timestamp (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_timestamp (b, "timestamp", -1, 1234, 9876)); - b2 = get_bson ("test35.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_maxkey (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_maxkey (b, "maxkey", -1)); - b2 = get_bson ("test37.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_minkey (void) -{ - bson_t *b; - bson_t *b2; - - b = bson_new (); - BSON_ASSERT (bson_append_minkey (b, "minkey", -1)); - b2 = get_bson ("test36.bson"); - BSON_ASSERT_BSON_EQUAL (b, b2); - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_append_general (void) -{ - uint8_t bytes[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0x23, 0x45}; - bson_oid_t oid; - bson_t *bson; - bson_t *array; - bson_t *subdoc; - - bson = bson_new (); - BSON_ASSERT (bson_append_int32 (bson, "int", -1, 1)); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test1.bson"); - bson_destroy (bson); - - bson = bson_new (); - BSON_ASSERT (bson_append_int64 (bson, "int64", -1, 1)); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test2.bson"); - bson_destroy (bson); - - bson = bson_new (); - BSON_ASSERT (bson_append_double (bson, "double", -1, 1.123)); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test3.bson"); - bson_destroy (bson); - - bson = bson_new (); - BSON_ASSERT (bson_append_utf8 (bson, "string", -1, "some string", -1)); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test5.bson"); - bson_destroy (bson); - - bson = bson_new (); - array = bson_new (); - BSON_ASSERT (bson_append_int32 (array, "0", -1, 1)); - BSON_ASSERT (bson_append_int32 (array, "1", -1, 2)); - BSON_ASSERT (bson_append_int32 (array, "2", -1, 3)); - BSON_ASSERT (bson_append_int32 (array, "3", -1, 4)); - BSON_ASSERT (bson_append_int32 (array, "4", -1, 5)); - BSON_ASSERT (bson_append_int32 (array, "5", -1, 6)); - BSON_ASSERT (bson_append_array (bson, "array[int]", -1, array)); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test6.bson"); - bson_destroy (array); - bson_destroy (bson); - - bson = bson_new (); - array = bson_new (); - BSON_ASSERT (bson_append_double (array, "0", -1, 1.123)); - BSON_ASSERT (bson_append_double (array, "1", -1, 2.123)); - BSON_ASSERT (bson_append_array (bson, "array[double]", -1, array)); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test7.bson"); - bson_destroy (array); - bson_destroy (bson); - - bson = bson_new (); - subdoc = bson_new (); - BSON_ASSERT (bson_append_int32 (subdoc, "int", -1, 1)); - BSON_ASSERT (bson_append_document (bson, "document", -1, subdoc)); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test8.bson"); - bson_destroy (subdoc); - bson_destroy (bson); - - bson = bson_new (); - BSON_ASSERT (bson_append_null (bson, "null", -1)); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test9.bson"); - bson_destroy (bson); - - bson = bson_new (); - BSON_ASSERT (bson_append_regex (bson, "regex", -1, "1234", "i")); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test10.bson"); - bson_destroy (bson); - - bson = bson_new (); - BSON_ASSERT (bson_append_utf8 (bson, "hello", -1, "world", -1)); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test11.bson"); - bson_destroy (bson); - - bson = bson_new (); - array = bson_new (); - BSON_ASSERT (bson_append_utf8 (array, "0", -1, "awesome", -1)); - BSON_ASSERT (bson_append_double (array, "1", -1, 5.05)); - BSON_ASSERT (bson_append_int32 (array, "2", -1, 1986)); - BSON_ASSERT (bson_append_array (bson, "BSON", -1, array)); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test12.bson"); - bson_destroy (bson); - bson_destroy (array); - - bson = bson_new (); - memcpy (&oid, bytes, sizeof oid); - BSON_ASSERT (bson_append_oid (bson, "_id", -1, &oid)); - subdoc = bson_new (); - BSON_ASSERT (bson_append_oid (subdoc, "_id", -1, &oid)); - array = bson_new (); - BSON_ASSERT (bson_append_utf8 (array, "0", -1, "1", -1)); - BSON_ASSERT (bson_append_utf8 (array, "1", -1, "2", -1)); - BSON_ASSERT (bson_append_utf8 (array, "2", -1, "3", -1)); - BSON_ASSERT (bson_append_utf8 (array, "3", -1, "4", -1)); - BSON_ASSERT (bson_append_array (subdoc, "tags", -1, array)); - bson_destroy (array); - BSON_ASSERT (bson_append_utf8 (subdoc, "text", -1, "asdfanother", -1)); - array = bson_new (); - BSON_ASSERT (bson_append_utf8 (array, "name", -1, "blah", -1)); - BSON_ASSERT (bson_append_document (subdoc, "source", -1, array)); - bson_destroy (array); - BSON_ASSERT (bson_append_document (bson, "document", -1, subdoc)); - bson_destroy (subdoc); - array = bson_new (); - BSON_ASSERT (bson_append_utf8 (array, "0", -1, "source", -1)); - BSON_ASSERT (bson_append_array (bson, "type", -1, array)); - bson_destroy (array); - array = bson_new (); - BSON_ASSERT (bson_append_utf8 (array, "0", -1, "server_created_at", -1)); - BSON_ASSERT (bson_append_array (bson, "missing", -1, array)); - bson_destroy (array); - BSON_ASSERT_BSON_EQUAL_FILE (bson, "test17.bson"); - bson_destroy (bson); -} - - -static void -test_bson_append_deep (void) -{ - bson_t *a; - bson_t *tmp; - int i; - - a = bson_new (); - - for (i = 0; i < 100; i++) { - tmp = a; - a = bson_new (); - BSON_ASSERT (bson_append_document (a, "a", -1, tmp)); - bson_destroy (tmp); - } - - BSON_ASSERT_BSON_EQUAL_FILE (a, "test38.bson"); - - bson_destroy (a); -} - - -static void -test_bson_validate_dbref (void) -{ - size_t offset; - bson_t dbref, child, child2; - - /* should fail, $ref without an $id */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should fail, $ref with non id field */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - BSON_APPEND_UTF8 (&child, "extra", "field"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should fail, $ref with $id at the top */ - { - bson_init (&dbref); - BSON_APPEND_UTF8 (&dbref, "$ref", "foo"); - BSON_APPEND_UTF8 (&dbref, "$id", "bar"); - - BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should fail, $ref with $id not first keys */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "extra", "field"); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - BSON_APPEND_UTF8 (&child, "$id", "bar"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should fail, $ref with $db */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - BSON_APPEND_UTF8 (&child, "$db", "bar"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should fail, non-string $ref with $id */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_INT32 (&child, "$ref", 1); - BSON_APPEND_UTF8 (&child, "$id", "bar"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should fail, non-string $ref with nothing */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_INT32 (&child, "$ref", 1); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should fail, $ref with $id with non-string $db */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - BSON_APPEND_UTF8 (&child, "$id", "bar"); - BSON_APPEND_INT32 (&child, "$db", 1); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should fail, $ref with $id with non-string $db with stuff after */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - BSON_APPEND_UTF8 (&child, "$id", "bar"); - BSON_APPEND_INT32 (&child, "$db", 1); - BSON_APPEND_UTF8 (&child, "extra", "field"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should fail, $ref with $id with stuff, then $db */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - BSON_APPEND_UTF8 (&child, "$id", "bar"); - BSON_APPEND_UTF8 (&child, "extra", "field"); - BSON_APPEND_UTF8 (&child, "$db", "baz"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should succeed, $ref with $id */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - BSON_APPEND_UTF8 (&child, "$id", "bar"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should succeed, $ref with nested dbref $id */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - BSON_APPEND_DOCUMENT_BEGIN (&child, "$id", &child2); - BSON_APPEND_UTF8 (&child2, "$ref", "foo2"); - BSON_APPEND_UTF8 (&child2, "$id", "bar2"); - BSON_APPEND_UTF8 (&child2, "$db", "baz2"); - bson_append_document_end (&child, &child2); - BSON_APPEND_UTF8 (&child, "$db", "baz"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should succeed, $ref with $id and $db */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - BSON_APPEND_UTF8 (&child, "$id", "bar"); - BSON_APPEND_UTF8 (&child, "$db", "baz"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } - - /* should succeed, $ref with $id and $db and trailing */ - { - bson_init (&dbref); - BSON_APPEND_DOCUMENT_BEGIN (&dbref, "dbref", &child); - BSON_APPEND_UTF8 (&child, "$ref", "foo"); - BSON_APPEND_UTF8 (&child, "$id", "bar"); - BSON_APPEND_UTF8 (&child, "$db", "baz"); - BSON_APPEND_UTF8 (&child, "extra", "field"); - bson_append_document_end (&dbref, &child); - - BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); - - bson_destroy (&dbref); - } -} - - -/* BSON spec requires bool value to be exactly 0 or 1 */ -static void -test_bson_validate_bool (void) -{ - /* {"b": true}, with implicit NULL at end */ - uint8_t data[] = "\x09\x00\x00\x00\x08\x62\x00\x01"; - bson_t bson; - bson_iter_t iter; - size_t err_offset = 0; - - ASSERT (bson_init_static (&bson, data, sizeof data)); - ASSERT (bson_validate (&bson, BSON_VALIDATE_NONE, &err_offset)); - ASSERT (bson_iter_init (&iter, &bson)); - ASSERT (bson_iter_next (&iter)); - ASSERT (BSON_ITER_HOLDS_BOOL (&iter)); - ASSERT (bson_iter_bool (&iter)); - - /* replace boolean value 1 with 255 */ - ASSERT (data[7] == '\x01'); - data[7] = (uint8_t) '\xff'; - - ASSERT (bson_init_static (&bson, data, 9)); - ASSERT (!bson_validate (&bson, BSON_VALIDATE_NONE, &err_offset)); - ASSERT_CMPSIZE_T (err_offset, ==, (size_t) 7); - - ASSERT (bson_iter_init (&iter, &bson)); - ASSERT (!bson_iter_next (&iter)); -} - - -/* BSON spec requires the deprecated DBPointer's value to be NULL-termed */ -static void -test_bson_validate_dbpointer (void) -{ - /* { "a": DBPointer(ObjectId(...), Collection="b") }, implicit NULL at end */ - uint8_t data[] = "\x1A\x00\x00\x00\x0C\x61\x00\x02\x00\x00\x00\x62\x00" - "\x56\xE1\xFC\x72\xE0\xC9\x17\xE9\xC4\x71\x41\x61"; - - bson_t bson; - bson_iter_t iter; - size_t err_offset = 0; - uint32_t collection_len; - const char *collection; - const bson_oid_t *oid; - - ASSERT (bson_init_static (&bson, data, sizeof data)); - ASSERT (bson_validate (&bson, BSON_VALIDATE_NONE, &err_offset)); - ASSERT (bson_iter_init (&iter, &bson)); - ASSERT (bson_iter_next (&iter)); - ASSERT (BSON_ITER_HOLDS_DBPOINTER (&iter)); - bson_iter_dbpointer (&iter, &collection_len, &collection, &oid); - ASSERT_CMPSTR (collection, "b"); - ASSERT_CMPINT (collection_len, ==, 1); - - /* replace the NULL terminator of "b" with 255 */ - ASSERT (data[12] == '\0'); - data[12] = (uint8_t) '\xff'; - - ASSERT (bson_init_static (&bson, data, sizeof data)); - ASSERT (!bson_validate (&bson, BSON_VALIDATE_NONE, &err_offset)); - ASSERT_CMPSIZE_T (err_offset, ==, (size_t) 12); - - ASSERT (bson_iter_init (&iter, &bson)); - ASSERT (!bson_iter_next (&iter)); -} - - -static void -test_bson_validate (void) -{ - char filename[64]; - size_t offset; - bson_t *b; - int i; - bson_error_t error; - - for (i = 1; i <= 38; i++) { - bson_snprintf (filename, sizeof filename, "test%u.bson", i); - b = get_bson (filename); - BSON_ASSERT (bson_validate (b, BSON_VALIDATE_NONE, &offset)); - bson_destroy (b); - } - - b = get_bson ("codewscope.bson"); - BSON_ASSERT (bson_validate (b, BSON_VALIDATE_NONE, &offset)); - bson_destroy (b); - - b = get_bson ("empty_key.bson"); - BSON_ASSERT (bson_validate (b, - BSON_VALIDATE_NONE | BSON_VALIDATE_UTF8 | - BSON_VALIDATE_DOLLAR_KEYS | - BSON_VALIDATE_DOT_KEYS, - &offset)); - bson_destroy (b); - -#define VALIDATE_TEST(_filename, _flags, _offset, _flag, _msg) \ - b = get_bson (_filename); \ - BSON_ASSERT (!bson_validate (b, _flags, &offset)); \ - ASSERT_CMPSIZE_T (offset, ==, (size_t) _offset); \ - BSON_ASSERT (!bson_validate_with_error (b, _flags, &error)); \ - ASSERT_ERROR_CONTAINS (error, BSON_ERROR_INVALID, _flag, _msg); \ - bson_destroy (b) - - VALIDATE_TEST ("overflow2.bson", - BSON_VALIDATE_NONE, - 9, - BSON_VALIDATE_NONE, - "corrupt BSON"); - VALIDATE_TEST ("trailingnull.bson", - BSON_VALIDATE_NONE, - 14, - BSON_VALIDATE_NONE, - "corrupt BSON"); - VALIDATE_TEST ("dollarquery.bson", - BSON_VALIDATE_DOLLAR_KEYS | BSON_VALIDATE_DOT_KEYS, - 4, - BSON_VALIDATE_DOLLAR_KEYS, - "keys cannot begin with \"$\": \"$query\""); - VALIDATE_TEST ("dotquery.bson", - BSON_VALIDATE_DOLLAR_KEYS | BSON_VALIDATE_DOT_KEYS, - 4, - BSON_VALIDATE_DOT_KEYS, - "keys cannot contain \".\": \"abc.def\""); - VALIDATE_TEST ("overflow3.bson", - BSON_VALIDATE_NONE, - 9, - BSON_VALIDATE_NONE, - "corrupt BSON"); - /* same outcome as above, despite different flags */ - VALIDATE_TEST ("overflow3.bson", - BSON_VALIDATE_UTF8, - 9, - BSON_VALIDATE_NONE, - "corrupt BSON"); - VALIDATE_TEST ("overflow4.bson", - BSON_VALIDATE_NONE, - 9, - BSON_VALIDATE_NONE, - "corrupt BSON"); - VALIDATE_TEST ("empty_key.bson", - BSON_VALIDATE_EMPTY_KEYS, - 4, - BSON_VALIDATE_EMPTY_KEYS, - "empty key"); - VALIDATE_TEST ( - "test40.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ( - "test41.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ( - "test42.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ( - "test43.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ( - "test44.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ( - "test45.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ( - "test46.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ( - "test47.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ( - "test48.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ( - "test49.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ("test50.bson", - BSON_VALIDATE_NONE, - 10, - BSON_VALIDATE_NONE, - "corrupt code-with-scope"); - VALIDATE_TEST ("test51.bson", - BSON_VALIDATE_NONE, - 10, - BSON_VALIDATE_NONE, - "corrupt code-with-scope"); - VALIDATE_TEST ( - "test52.bson", BSON_VALIDATE_NONE, 9, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ( - "test53.bson", BSON_VALIDATE_NONE, 6, BSON_VALIDATE_NONE, "corrupt BSON"); - VALIDATE_TEST ("test54.bson", - BSON_VALIDATE_NONE, - 12, - BSON_VALIDATE_NONE, - "corrupt BSON"); - VALIDATE_TEST ( - "test59.bson", BSON_VALIDATE_NONE, 9, BSON_VALIDATE_NONE, "corrupt BSON"); - - /* DBRef validation */ - b = BCON_NEW ("my_dbref", - "{", - "$ref", - BCON_UTF8 ("collection"), - "$id", - BCON_INT32 (1), - "}"); - BSON_ASSERT (bson_validate_with_error (b, BSON_VALIDATE_NONE, &error)); - BSON_ASSERT ( - bson_validate_with_error (b, BSON_VALIDATE_DOLLAR_KEYS, &error)); - bson_destroy (b); - - /* needs "$ref" before "$id" */ - b = BCON_NEW ("my_dbref", "{", "$id", BCON_INT32 (1), "}"); - BSON_ASSERT (bson_validate_with_error (b, BSON_VALIDATE_NONE, &error)); - BSON_ASSERT ( - !bson_validate_with_error (b, BSON_VALIDATE_DOLLAR_KEYS, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_INVALID, - BSON_VALIDATE_DOLLAR_KEYS, - "keys cannot begin with \"$\": \"$id\""); - bson_destroy (b); - - /* two $refs */ - b = BCON_NEW ("my_dbref", - "{", - "$ref", - BCON_UTF8 ("collection"), - "$ref", - BCON_UTF8 ("collection"), - "}"); - BSON_ASSERT (bson_validate_with_error (b, BSON_VALIDATE_NONE, &error)); - BSON_ASSERT ( - !bson_validate_with_error (b, BSON_VALIDATE_DOLLAR_KEYS, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_INVALID, - BSON_VALIDATE_DOLLAR_KEYS, - "keys cannot begin with \"$\": \"$ref\""); - bson_destroy (b); - - /* must not contain invalid key like "extra" */ - b = BCON_NEW ("my_dbref", - "{", - "$ref", - BCON_UTF8 ("collection"), - "extra", - BCON_INT32 (2), - "$id", - BCON_INT32 (1), - "}"); - BSON_ASSERT (bson_validate_with_error (b, BSON_VALIDATE_NONE, &error)); - BSON_ASSERT ( - !bson_validate_with_error (b, BSON_VALIDATE_DOLLAR_KEYS, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_INVALID, - BSON_VALIDATE_DOLLAR_KEYS, - "invalid key within DBRef subdocument: \"extra\""); - bson_destroy (b); - -#undef VALIDATE_TEST -} - - -static void -test_bson_init (void) -{ - bson_t b; - char key[12]; - int i; - - bson_init (&b); - BSON_ASSERT ((b.flags & BSON_FLAG_INLINE)); - BSON_ASSERT ((b.flags & BSON_FLAG_STATIC)); - BSON_ASSERT (!(b.flags & BSON_FLAG_RDONLY)); - for (i = 0; i < 100; i++) { - bson_snprintf (key, sizeof key, "%d", i); - BSON_ASSERT (bson_append_utf8 (&b, key, -1, "bar", -1)); - } - BSON_ASSERT (!(b.flags & BSON_FLAG_INLINE)); - bson_destroy (&b); -} - - -static void -test_bson_init_static (void) -{ - static const uint8_t data[5] = {5}; - bson_t b; - - ASSERT (bson_init_static (&b, data, sizeof data)); - BSON_ASSERT ((b.flags & BSON_FLAG_RDONLY)); - bson_destroy (&b); -} - - -static void -test_bson_new_from_buffer (void) -{ - bson_t *b; - uint8_t *buf = bson_malloc0 (5); - size_t len = 5; - uint32_t len_le = BSON_UINT32_TO_LE (5); - - memcpy (buf, &len_le, sizeof (len_le)); - - b = bson_new_from_buffer (&buf, &len, bson_realloc_ctx, NULL); - - BSON_ASSERT (b->flags & BSON_FLAG_NO_FREE); - BSON_ASSERT (len == 5); - BSON_ASSERT (b->len == 5); - - bson_append_utf8 (b, "hello", -1, "world", -1); - - BSON_ASSERT (len == 32); - BSON_ASSERT (b->len == 22); - - bson_destroy (b); - - bson_free (buf); - - buf = NULL; - len = 0; - - b = bson_new_from_buffer (&buf, &len, bson_realloc_ctx, NULL); - - BSON_ASSERT (b->flags & BSON_FLAG_NO_FREE); - BSON_ASSERT (len == 5); - BSON_ASSERT (b->len == 5); - - bson_destroy (b); - bson_free (buf); -} - - -static void -test_bson_utf8_key (void) -{ -/* euro currency symbol */ -#define EU "\xe2\x82\xac" -#define FIVE_EUROS EU EU EU EU EU - uint32_t length; - bson_iter_t iter; - const char *str; - bson_t *b; - size_t offset; - - b = get_bson ("eurokey.bson"); - BSON_ASSERT (bson_validate (b, BSON_VALIDATE_NONE, &offset)); - BSON_ASSERT (bson_iter_init (&iter, b)); - BSON_ASSERT (bson_iter_next (&iter)); - BSON_ASSERT (!strcmp (bson_iter_key (&iter), FIVE_EUROS)); - str = bson_iter_utf8 (&iter, &length); - BSON_ASSERT (str); - BSON_ASSERT (length == 15); /* 5 3-byte sequences. */ - BSON_ASSERT (!strcmp (str, FIVE_EUROS)); - bson_destroy (b); -} - - -static void -test_bson_new_1mm (void) -{ - bson_t *b; - int i; - - for (i = 0; i < 1000000; i++) { - b = bson_new (); - bson_destroy (b); - } -} - - -static void -test_bson_init_1mm (void) -{ - bson_t b; - int i; - - for (i = 0; i < 1000000; i++) { - bson_init (&b); - bson_destroy (&b); - } -} - - -static void -test_bson_build_child (void) -{ - bson_t b; - bson_t child; - bson_t *b2; - bson_t *child2; - - bson_init (&b); - BSON_ASSERT (bson_append_document_begin (&b, "foo", -1, &child)); - BSON_ASSERT (bson_append_utf8 (&child, "bar", -1, "baz", -1)); - BSON_ASSERT (bson_append_document_end (&b, &child)); - - b2 = bson_new (); - child2 = bson_new (); - BSON_ASSERT (bson_append_utf8 (child2, "bar", -1, "baz", -1)); - BSON_ASSERT (bson_append_document (b2, "foo", -1, child2)); - bson_destroy (child2); - - BSON_ASSERT (b.len == b2->len); - BSON_ASSERT_BSON_EQUAL (&b, b2); - - bson_destroy (&b); - bson_destroy (b2); -} - - -static void -test_bson_build_child_array (void) -{ - bson_t b; - bson_t child; - bson_t *b2; - bson_t *child2; - - bson_init (&b); - BSON_ASSERT (bson_append_array_begin (&b, "foo", -1, &child)); - BSON_ASSERT (bson_append_utf8 (&child, "0", -1, "baz", -1)); - BSON_ASSERT (bson_append_array_end (&b, &child)); - - b2 = bson_new (); - child2 = bson_new (); - BSON_ASSERT (bson_append_utf8 (child2, "0", -1, "baz", -1)); - BSON_ASSERT (bson_append_array (b2, "foo", -1, child2)); - bson_destroy (child2); - - BSON_ASSERT (b.len == b2->len); - BSON_ASSERT_BSON_EQUAL (&b, b2); - - bson_destroy (&b); - bson_destroy (b2); -} - - -static void -test_bson_build_child_deep_1 (bson_t *b, int *count) -{ - bson_t child; - - (*count)++; - - BSON_ASSERT (bson_append_document_begin (b, "b", -1, &child)); - BSON_ASSERT (!(b->flags & BSON_FLAG_INLINE)); - BSON_ASSERT ((b->flags & BSON_FLAG_IN_CHILD)); - BSON_ASSERT (!(child.flags & BSON_FLAG_INLINE)); - BSON_ASSERT ((child.flags & BSON_FLAG_STATIC)); - BSON_ASSERT ((child.flags & BSON_FLAG_CHILD)); - - if (*count < 100) { - test_bson_build_child_deep_1 (&child, count); - } else { - BSON_ASSERT (bson_append_int32 (&child, "b", -1, 1234)); - } - - BSON_ASSERT (bson_append_document_end (b, &child)); - BSON_ASSERT (!(b->flags & BSON_FLAG_IN_CHILD)); -} - - -static void -test_bson_build_child_deep (void) -{ - union { - bson_t b; - bson_impl_alloc_t a; - } u; - int count = 0; - - bson_init (&u.b); - BSON_ASSERT ((u.b.flags & BSON_FLAG_INLINE)); - test_bson_build_child_deep_1 (&u.b, &count); - BSON_ASSERT (!(u.b.flags & BSON_FLAG_INLINE)); - BSON_ASSERT ((u.b.flags & BSON_FLAG_STATIC)); - BSON_ASSERT (!(u.b.flags & BSON_FLAG_NO_FREE)); - BSON_ASSERT (!(u.b.flags & BSON_FLAG_RDONLY)); - BSON_ASSERT (bson_validate (&u.b, BSON_VALIDATE_NONE, NULL)); - BSON_ASSERT (((bson_impl_alloc_t *) &u.b)->alloclen == 1024); - BSON_ASSERT_BSON_EQUAL_FILE (&u.b, "test39.bson"); - bson_destroy (&u.b); -} - - -static void -test_bson_build_child_deep_no_begin_end_1 (bson_t *b, int *count) -{ - bson_t child; - - (*count)++; - - bson_init (&child); - if (*count < 100) { - test_bson_build_child_deep_1 (&child, count); - } else { - BSON_ASSERT (bson_append_int32 (&child, "b", -1, 1234)); - } - BSON_ASSERT (bson_append_document (b, "b", -1, &child)); - bson_destroy (&child); -} - - -static void -test_bson_build_child_deep_no_begin_end (void) -{ - union { - bson_t b; - bson_impl_alloc_t a; - } u; - - int count = 0; - - bson_init (&u.b); - test_bson_build_child_deep_no_begin_end_1 (&u.b, &count); - BSON_ASSERT (bson_validate (&u.b, BSON_VALIDATE_NONE, NULL)); - BSON_ASSERT (u.a.alloclen == 1024); - BSON_ASSERT_BSON_EQUAL_FILE (&u.b, "test39.bson"); - bson_destroy (&u.b); -} - - -static void -test_bson_count_keys (void) -{ - bson_t b; - - bson_init (&b); - BSON_ASSERT (bson_append_int32 (&b, "0", -1, 0)); - BSON_ASSERT (bson_append_int32 (&b, "1", -1, 1)); - BSON_ASSERT (bson_append_int32 (&b, "2", -1, 2)); - ASSERT_CMPINT (bson_count_keys (&b), ==, 3); - bson_destroy (&b); -} - - -static void -test_bson_copy (void) -{ - bson_t b; - bson_t *c; - - bson_init (&b); - BSON_ASSERT (bson_append_int32 (&b, "foobar", -1, 1234)); - c = bson_copy (&b); - BSON_ASSERT_BSON_EQUAL (&b, c); - bson_destroy (c); - bson_destroy (&b); -} - - -static void -test_bson_copy_to (void) -{ - bson_t b; - bson_t c; - int i; - - /* - * Test inline structure copy. - */ - bson_init (&b); - BSON_ASSERT (bson_append_int32 (&b, "foobar", -1, 1234)); - bson_copy_to (&b, &c); - BSON_ASSERT_BSON_EQUAL (&b, &c); - bson_destroy (&c); - bson_destroy (&b); - - /* - * Test malloced copy. - */ - bson_init (&b); - for (i = 0; i < 1000; i++) { - BSON_ASSERT (bson_append_int32 (&b, "foobar", -1, 1234)); - } - bson_copy_to (&b, &c); - BSON_ASSERT_BSON_EQUAL (&b, &c); - bson_destroy (&c); - bson_destroy (&b); -} - - -static void -test_bson_copy_to_excluding_noinit (void) -{ - bson_iter_t iter; - bool r; - bson_t b; - bson_t c; - int i; - - bson_init (&b); - bson_append_int32 (&b, "a", 1, 1); - bson_append_int32 (&b, "b", 1, 2); - - bson_init (&c); - bson_copy_to_excluding_noinit (&b, &c, "b", NULL); - r = bson_iter_init_find (&iter, &c, "a"); - BSON_ASSERT (r); - r = bson_iter_init_find (&iter, &c, "b"); - BSON_ASSERT (!r); - - i = bson_count_keys (&b); - ASSERT_CMPINT (i, ==, 2); - - i = bson_count_keys (&c); - ASSERT_CMPINT (i, ==, 1); - - bson_destroy (&b); - bson_destroy (&c); -} - - -static void -test_bson_append_overflow (void) -{ - const char *key = "a"; - uint32_t len; - bson_t b; - - len = BSON_MAX_SIZE; - len -= 4; /* len */ - len -= 1; /* type */ - len -= 1; /* value */ - len -= 1; /* end byte */ - - bson_init (&b); - BSON_ASSERT (!bson_append_bool (&b, key, len, true)); - bson_destroy (&b); -} - - -static void -test_bson_initializer (void) -{ - bson_t b = BSON_INITIALIZER; - - BSON_ASSERT (bson_empty (&b)); - bson_append_bool (&b, "foo", -1, true); - BSON_ASSERT (!bson_empty (&b)); - bson_destroy (&b); -} - - -static void -test_bson_concat (void) -{ - bson_t a = BSON_INITIALIZER; - bson_t b = BSON_INITIALIZER; - bson_t c = BSON_INITIALIZER; - - bson_append_int32 (&a, "abc", 3, 1); - bson_append_int32 (&b, "def", 3, 1); - bson_concat (&a, &b); - - bson_append_int32 (&c, "abc", 3, 1); - bson_append_int32 (&c, "def", 3, 1); - - BSON_ASSERT (0 == bson_compare (&c, &a)); - - bson_destroy (&a); - bson_destroy (&b); - bson_destroy (&c); -} - - -static void -test_bson_reinit (void) -{ - bson_t b = BSON_INITIALIZER; - int i; - - for (i = 0; i < 1000; i++) { - bson_append_int32 (&b, "", 0, i); - } - - bson_reinit (&b); - - for (i = 0; i < 1000; i++) { - bson_append_int32 (&b, "", 0, i); - } - - bson_destroy (&b); -} - - -static void -test_bson_macros (void) -{ - const uint8_t data[] = {1, 2, 3, 4}; - bson_t b = BSON_INITIALIZER; - bson_t ar = BSON_INITIALIZER; - bson_decimal128_t dec; - bson_oid_t oid; - struct timeval tv; - time_t t; - - dec.high = 0x3040000000000000ULL; - dec.low = 0x0ULL; - - t = time (NULL); -#ifdef BSON_OS_WIN32 - tv.tv_sec = (long) t; -#else - tv.tv_sec = t; -#endif - tv.tv_usec = 0; - - bson_oid_init (&oid, NULL); - - BSON_APPEND_ARRAY (&b, "0", &ar); - BSON_APPEND_BINARY (&b, "1", 0, data, sizeof data); - BSON_APPEND_BOOL (&b, "2", true); - BSON_APPEND_CODE (&b, "3", "function(){}"); - BSON_APPEND_CODE_WITH_SCOPE (&b, "4", "function(){}", &ar); - BSON_APPEND_DOUBLE (&b, "6", 123.45); - BSON_APPEND_DOCUMENT (&b, "7", &ar); - BSON_APPEND_INT32 (&b, "8", 123); - BSON_APPEND_INT64 (&b, "9", 456); - BSON_APPEND_MINKEY (&b, "10"); - BSON_APPEND_MAXKEY (&b, "11"); - BSON_APPEND_NULL (&b, "12"); - BSON_APPEND_OID (&b, "13", &oid); - BSON_APPEND_REGEX (&b, "14", "^abc", "i"); - BSON_APPEND_UTF8 (&b, "15", "utf8"); - BSON_APPEND_SYMBOL (&b, "16", "symbol"); - BSON_APPEND_TIME_T (&b, "17", t); - BSON_APPEND_TIMEVAL (&b, "18", &tv); - BSON_APPEND_DATE_TIME (&b, "19", 123); - BSON_APPEND_TIMESTAMP (&b, "20", 123, 0); - BSON_APPEND_UNDEFINED (&b, "21"); - BSON_APPEND_DECIMAL128 (&b, "22", &dec); - - bson_destroy (&b); - bson_destroy (&ar); -} - - -static void -test_bson_clear (void) -{ - bson_t *doc = NULL; - - bson_clear (&doc); - BSON_ASSERT (doc == NULL); - - doc = bson_new (); - BSON_ASSERT (doc != NULL); - bson_clear (&doc); - BSON_ASSERT (doc == NULL); -} - - -static void -bloat (bson_t *b) -{ - uint32_t i; - char buf[16]; - const char *key; - - for (i = 0; i < 100; i++) { - bson_uint32_to_string (i, &key, buf, sizeof buf); - BSON_APPEND_UTF8 (b, key, "long useless value foo bar baz quux quizzle"); - } - - /* spilled over */ - ASSERT (!(b->flags & BSON_FLAG_INLINE)); -} - - -static void -test_bson_steal (void) -{ - bson_t stack_alloced; - bson_t *heap_alloced; - bson_t dst; - uint8_t *alloc; - uint8_t *buf; - size_t len; - uint32_t len_le; - - /* inline, stack-allocated */ - bson_init (&stack_alloced); - BSON_APPEND_INT32 (&stack_alloced, "a", 1); - ASSERT (bson_steal (&dst, &stack_alloced)); - ASSERT (bson_has_field (&dst, "a")); - ASSERT (dst.flags & BSON_FLAG_INLINE); - /* src was invalidated */ - ASSERT (!bson_validate (&stack_alloced, BSON_VALIDATE_NONE, 0)); - bson_destroy (&dst); - - /* spilled over, stack-allocated */ - bson_init (&stack_alloced); - bloat (&stack_alloced); - alloc = ((bson_impl_alloc_t *) &stack_alloced)->alloc; - ASSERT (bson_steal (&dst, &stack_alloced)); - /* data was transferred */ - ASSERT (alloc == ((bson_impl_alloc_t *) &dst)->alloc); - ASSERT (bson_has_field (&dst, "99")); - ASSERT (!(dst.flags & BSON_FLAG_INLINE)); - ASSERT (!bson_validate (&stack_alloced, BSON_VALIDATE_NONE, 0)); - bson_destroy (&dst); - - /* inline, heap-allocated */ - heap_alloced = bson_new (); - BSON_APPEND_INT32 (heap_alloced, "a", 1); - ASSERT (bson_steal (&dst, heap_alloced)); - ASSERT (bson_has_field (&dst, "a")); - ASSERT (dst.flags & BSON_FLAG_INLINE); - bson_destroy (&dst); - - /* spilled over, heap-allocated */ - heap_alloced = bson_new (); - bloat (heap_alloced); - alloc = ((bson_impl_alloc_t *) heap_alloced)->alloc; - ASSERT (bson_steal (&dst, heap_alloced)); - /* data was transferred */ - ASSERT (alloc == ((bson_impl_alloc_t *) &dst)->alloc); - ASSERT (bson_has_field (&dst, "99")); - ASSERT (!(dst.flags & BSON_FLAG_INLINE)); - bson_destroy (&dst); - - /* test stealing from a bson created with bson_new_from_buffer */ - buf = bson_malloc0 (5); - len = 5; - len_le = BSON_UINT32_TO_LE (5); - memcpy (buf, &len_le, sizeof (len_le)); - heap_alloced = bson_new_from_buffer (&buf, &len, bson_realloc_ctx, NULL); - ASSERT (bson_steal (&dst, heap_alloced)); - ASSERT (dst.flags & BSON_FLAG_NO_FREE); - ASSERT (dst.flags & BSON_FLAG_STATIC); - ASSERT (((bson_impl_alloc_t *) &dst)->realloc == bson_realloc_ctx); - ASSERT (((bson_impl_alloc_t *) &dst)->realloc_func_ctx == NULL); - bson_destroy (&dst); - bson_free (buf); -} - -static void -BSON_ASSERT_KEY_AND_VALUE (const bson_t *bson) -{ - bson_iter_t iter; - - ASSERT (bson_iter_init_find (&iter, bson, "key")); - ASSERT (BSON_ITER_HOLDS_UTF8 (&iter)); - ASSERT_CMPSTR ("value", bson_iter_utf8 (&iter, NULL)); -} - - -static void -test_bson_reserve_buffer (void) -{ - bson_t src = BSON_INITIALIZER; - bson_t stack_alloced; - bson_t *heap_alloced; - uint8_t *buf; - - /* inline, stack-allocated */ - bson_init (&stack_alloced); - BSON_APPEND_UTF8 (&src, "key", "value"); - ASSERT ((buf = bson_reserve_buffer (&stack_alloced, src.len))); - ASSERT_CMPUINT32 (src.len, ==, stack_alloced.len); - ASSERT (stack_alloced.flags & BSON_FLAG_INLINE); - memcpy (buf, ((bson_impl_inline_t *) &src)->data, src.len); - /* data was transferred */ - BSON_ASSERT_KEY_AND_VALUE (&stack_alloced); - bson_destroy (&stack_alloced); - - /* spilled over, stack-allocated */ - bloat (&src); - bson_init (&stack_alloced); - ASSERT ((buf = bson_reserve_buffer (&stack_alloced, src.len))); - ASSERT_CMPUINT32 (src.len, ==, stack_alloced.len); - ASSERT (!(stack_alloced.flags & BSON_FLAG_INLINE)); - memcpy (buf, ((bson_impl_alloc_t *) &src)->alloc, src.len); - BSON_ASSERT_KEY_AND_VALUE (&stack_alloced); - ASSERT (bson_has_field (&stack_alloced, "99")); - bson_destroy (&src); - bson_destroy (&stack_alloced); - - /* inline, heap-allocated */ - heap_alloced = bson_new (); - bson_init (&src); - BSON_APPEND_UTF8 (&src, "key", "value"); - ASSERT ((buf = bson_reserve_buffer (heap_alloced, src.len))); - ASSERT_CMPUINT32 (src.len, ==, heap_alloced->len); - ASSERT (heap_alloced->flags & BSON_FLAG_INLINE); - memcpy (buf, ((bson_impl_inline_t *) &src)->data, src.len); - BSON_ASSERT_KEY_AND_VALUE (heap_alloced); - bson_destroy (heap_alloced); - - /* spilled over, heap-allocated */ - heap_alloced = bson_new (); - bloat (&src); - ASSERT ((buf = bson_reserve_buffer (heap_alloced, src.len))); - ASSERT_CMPUINT32 (src.len, ==, heap_alloced->len); - ASSERT (!(heap_alloced->flags & BSON_FLAG_INLINE)); - memcpy (buf, ((bson_impl_alloc_t *) &src)->alloc, src.len); - BSON_ASSERT_KEY_AND_VALUE (heap_alloced); - ASSERT (bson_has_field (heap_alloced, "99")); - - bson_destroy (&src); - bson_destroy (heap_alloced); -} - - -static void -test_bson_reserve_buffer_errors (void) -{ - bson_t bson = BSON_INITIALIZER; - bson_t child; - uint8_t data[5] = {0}; - uint32_t len_le; - - /* too big */ - ASSERT (!bson_reserve_buffer (&bson, (uint32_t) (INT32_MAX - bson.len - 1))); - - /* make a static bson, it refuses bson_reserve_buffer since it's read-only */ - bson_destroy (&bson); - len_le = BSON_UINT32_TO_LE (5); - memcpy (data, &len_le, sizeof (len_le)); - ASSERT (bson_init_static (&bson, data, sizeof data)); - ASSERT (!bson_reserve_buffer (&bson, 10)); - - /* parent's and child's buffers are locked */ - bson_init (&bson); - BSON_APPEND_DOCUMENT_BEGIN (&bson, "child", &child); - ASSERT (!bson_reserve_buffer (&bson, 10)); - ASSERT (!bson_reserve_buffer (&child, 10)); - /* unlock parent's buffer */ - bson_append_document_end (&bson, &child); - ASSERT (bson_reserve_buffer (&bson, 10)); - - bson_destroy (&bson); -} - - -static void -test_bson_destroy_with_steal (void) -{ - bson_t *b1; - bson_t b2; - uint32_t len = 0; - uint8_t *data; - int i; - - b1 = bson_new (); - for (i = 0; i < 100; i++) { - BSON_APPEND_INT32 (b1, "some-key", i); - } - - data = bson_destroy_with_steal (b1, true, &len); - BSON_ASSERT (data); - BSON_ASSERT (len == 1405); - bson_free (data); - data = NULL; - - bson_init (&b2); - len = 0; - for (i = 0; i < 100; i++) { - BSON_APPEND_INT32 (&b2, "some-key", i); - } - BSON_ASSERT (!bson_destroy_with_steal (&b2, false, &len)); - BSON_ASSERT (len == 1405); - - bson_init (&b2); - BSON_ASSERT (!bson_destroy_with_steal (&b2, false, NULL)); - - bson_init (&b2); - data = bson_destroy_with_steal (&b2, true, &len); - BSON_ASSERT (data); - BSON_ASSERT (len == 5); - bson_free (data); - data = NULL; -} - - -static void -test_bson_has_field (void) -{ - bson_t *b; - bool r; - - b = BCON_NEW ("foo", "[", "{", "bar", BCON_INT32 (1), "}", "]"); - - r = bson_has_field (b, "foo"); - BSON_ASSERT (r); - - r = bson_has_field (b, "foo.0"); - BSON_ASSERT (r); - - r = bson_has_field (b, "foo.0.bar"); - BSON_ASSERT (r); - - r = bson_has_field (b, "0"); - BSON_ASSERT (!r); - - r = bson_has_field (b, "bar"); - BSON_ASSERT (!r); - - r = bson_has_field (b, "0.bar"); - BSON_ASSERT (!r); - - bson_destroy (b); -} - - -static void -test_next_power_of_two (void) -{ - size_t s; - - s = 3; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 4); - - s = 4; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 4); - - s = 33; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 64); - - s = 91; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 128); - - s = 939524096UL; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 1073741824); - - s = 1073741824UL; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 1073741824UL); - -#if BSON_WORD_SIZE == 64 - s = 4294967296LL; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 4294967296LL); - - s = 4294967297LL; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 8589934592LL); - - s = 17179901952LL; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 34359738368LL); - - s = 9223372036854775807ULL; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 9223372036854775808ULL); - - s = 36028795806651656ULL; - s = bson_next_power_of_two (s); - BSON_ASSERT (s == 36028797018963968ULL); -#endif -} - - -void -visit_corrupt (const bson_iter_t *iter, void *data) -{ - BSON_UNUSED (iter); - - *((bool *) data) = true; -} - - -static void -test_bson_visit_invalid_field (void) -{ - /* key is invalid utf-8 char: {"\x80": 1} */ - const char data[] = "\x0c\x00\x00\x00\x10\x80\x00\x01\x00\x00\x00\x00"; - bson_t b; - bson_iter_t iter; - bson_visitor_t visitor = {0}; - bool visited = false; - - visitor.visit_corrupt = visit_corrupt; - BSON_ASSERT (bson_init_static (&b, (const uint8_t *) data, sizeof data - 1)); - BSON_ASSERT (bson_iter_init (&iter, &b)); - BSON_ASSERT (!bson_iter_visit_all (&iter, &visitor, (void *) &visited)); - BSON_ASSERT (visited); -} - - -typedef struct { - bool visited; - const char *key; - uint32_t type_code; -} unsupported_type_test_data_t; - - -void -visit_unsupported_type (const bson_iter_t *iter, - const char *key, - uint32_t type_code, - void *data) -{ - unsupported_type_test_data_t *context; - - BSON_UNUSED (iter); - - context = (unsupported_type_test_data_t *) data; - context->visited = true; - context->key = key; - context->type_code = type_code; -} - - -static void -test_bson_visit_unsupported_type (void) -{ - /* {k: 1}, but instead of BSON type 0x10 (int32), use unknown type 0x33 */ - const char data[] = "\x0c\x00\x00\x00\x33k\x00\x01\x00\x00\x00\x00"; - bson_t b; - bson_iter_t iter; - unsupported_type_test_data_t context = {0}; - bson_visitor_t visitor = {0}; - - visitor.visit_unsupported_type = visit_unsupported_type; - - BSON_ASSERT (bson_init_static (&b, (const uint8_t *) data, sizeof data - 1)); - BSON_ASSERT (bson_iter_init (&iter, &b)); - BSON_ASSERT (!bson_iter_visit_all (&iter, &visitor, (void *) &context)); - BSON_ASSERT (!bson_iter_next (&iter)); - BSON_ASSERT (context.visited); - BSON_ASSERT (!strcmp (context.key, "k")); - BSON_ASSERT (context.type_code == '\x33'); -} - - -static void -test_bson_visit_unsupported_type_bad_key (void) -{ - /* key is invalid utf-8 char, '\x80' */ - const char data[] = "\x0c\x00\x00\x00\x33\x80\x00\x01\x00\x00\x00\x00"; - bson_t b; - bson_iter_t iter; - unsupported_type_test_data_t context = {0}; - bson_visitor_t visitor = {0}; - - visitor.visit_unsupported_type = visit_unsupported_type; - - BSON_ASSERT (bson_init_static (&b, (const uint8_t *) data, sizeof data - 1)); - BSON_ASSERT (bson_iter_init (&iter, &b)); - BSON_ASSERT (!bson_iter_visit_all (&iter, &visitor, (void *) &context)); - BSON_ASSERT (!bson_iter_next (&iter)); - - /* unsupported type error wasn't reported, because the bson is corrupt */ - BSON_ASSERT (!context.visited); -} - - -static void -test_bson_visit_unsupported_type_empty_key (void) -{ - /* {"": 1}, but instead of BSON type 0x10 (int32), use unknown type 0x33 */ - const char data[] = "\x0b\x00\x00\x00\x33\x00\x01\x00\x00\x00\x00"; - bson_t b; - bson_iter_t iter; - unsupported_type_test_data_t context = {0}; - bson_visitor_t visitor = {0}; - - visitor.visit_unsupported_type = visit_unsupported_type; - - BSON_ASSERT (bson_init_static (&b, (const uint8_t *) data, sizeof data - 1)); - BSON_ASSERT (bson_iter_init (&iter, &b)); - BSON_ASSERT (!bson_iter_visit_all (&iter, &visitor, (void *) &context)); - BSON_ASSERT (!bson_iter_next (&iter)); - BSON_ASSERT (context.visited); - BSON_ASSERT (!strcmp (context.key, "")); - BSON_ASSERT (context.type_code == '\x33'); -} - - -static void -test_bson_subtype_2 (void) -{ - bson_t b; - /* taken from BSON Corpus Tests */ - const char ok[] = "\x13\x00\x00\x00\x05\x78\x00\x06\x00\x00\x00\x02\x02\x00" - "\x00\x00\xff\xff\x00"; - - /* Deprecated subtype 0x02 includes a redundant length inside the binary - * payload. Check that we validate this length. - */ - const char len_too_long[] = "\x13\x00\x00\x00\x05\x78\x00\x06\x00\x00\x00" - "\x02\x03\x00\x00\x00\xFF\xFF\x00"; - const char len_too_short[] = "\x13\x00\x00\x00\x05\x78\x00\x06\x00\x00\x00" - "\x02\x01\x00\x00\x00\xFF\xFF\x00"; - const char len_negative[] = "\x13\x00\x00\x00\x05\x78\x00\x06\x00\x00\x00" - "\x02\xFF\xFF\xFF\xFF\xFF\xFF\x00"; - - bson_t *bson_ok = BCON_NEW ("x", BCON_BIN (2, (uint8_t *) "\xff\xff", 2)); - - BSON_ASSERT (bson_init_static (&b, (uint8_t *) ok, sizeof (ok) - 1)); - BSON_ASSERT (bson_validate (&b, BSON_VALIDATE_NONE, 0)); - BSON_ASSERT (0 == bson_compare (&b, bson_ok)); - - BSON_ASSERT (bson_init_static ( - &b, (uint8_t *) len_too_long, sizeof (len_too_long) - 1)); - BSON_ASSERT (!bson_validate (&b, BSON_VALIDATE_NONE, 0)); - - BSON_ASSERT (bson_init_static ( - &b, (uint8_t *) len_too_short, sizeof (len_too_short) - 1)); - BSON_ASSERT (!bson_validate (&b, BSON_VALIDATE_NONE, 0)); - - BSON_ASSERT (bson_init_static ( - &b, (uint8_t *) len_negative, sizeof (len_negative) - 1)); - BSON_ASSERT (!bson_validate (&b, BSON_VALIDATE_NONE, 0)); - - bson_destroy (bson_ok); -} - -/* CDRIVER-2455 Off-by-one error while appending regex */ -void -test_bson_regex_lengths (void) -{ - bson_t new = BSON_INITIALIZER; - bson_oid_t oid; - - bson_oid_init_from_string (&oid, "1234567890abcdef12345678"); - bson_append_oid (&new, "0123456", -1, &oid); - - bson_append_regex (&new, - "0_________1_________2_________3___4", - -1, - "0_________1_________2_________3_________4_________5___4", - "i"); - - ASSERT (new.len == 121); - ASSERT (new.flags &BSON_FLAG_STATIC); - ASSERT (!(new.flags &BSON_FLAG_INLINE)); - - bson_destroy (&new); -} - -void -test_bson_empty_binary (void) -{ - uint8_t data = 0xAB; - bson_t test; - const bson_value_t *value; - bson_value_t copy; - bson_iter_t iter; - - bson_init (&test); - bson_append_binary (&test, "test", 4, BSON_SUBTYPE_BINARY, &data, 0); - BSON_ASSERT (bson_iter_init_find (&iter, &test, "test")); - value = bson_iter_value (&iter); - /* CDRIVER-2569, this would memcpy (0 bytes) to a NULL destination. */ - bson_value_copy (value, ©); - - bson_value_destroy (©); - bson_destroy (&test); -} - -void -test_bson_iter_key_len (void) -{ - bson_t *bson = bson_with_all_types (); - bson_iter_t iter; - - BSON_ASSERT (bson_iter_init (&iter, bson)); - while (bson_iter_next (&iter)) { - ASSERT_WITH_MSG (strlen (bson_iter_key (&iter)) == - bson_iter_key_len (&iter), - "iter_key_len differs from real key length. got %d but " - "expected %d for key %s\n", - bson_iter_key_len (&iter), - (int) strlen (bson_iter_key (&iter)), - bson_iter_key (&iter)); - } -} - - -void -test_bson_iter_init_from_data_at_offset (void) -{ - bson_t *bson = bson_with_all_types (); - /* zero out iter, since bson_iter_init doesn't zero out iter->value. */ - bson_iter_t iter = {0}; - - BSON_ASSERT (bson_iter_init (&iter, bson)); - ASSERT_CMPINT (bson_iter_offset (&iter), ==, 0); - while (bson_iter_next (&iter)) { - const uint8_t *data = bson_get_data (bson); - int keylen = bson_iter_key_len (&iter); - uint32_t offset = bson_iter_offset (&iter); - bson_iter_t recreated = {0}; - - BSON_ASSERT (bson_iter_init_from_data_at_offset ( - &recreated, data, bson->len, offset, keylen)); - if (memcmp ((void *) &iter, (void *) &recreated, sizeof (bson_iter_t)) != - 0) { - int i; - bson_iter_t *iters[] = {&iter, &recreated}; - fprintf (stderr, - "recreated iterator does not match initial iterator:\n"); - for (i = 0; i < 2; i++) { - fprintf (stderr, "iter %d: ", i); - fprintf (stderr, - "len=%d, off=%d, type=%d, key=%d, d1=%d, d2=%d, " - "d3=%d, d4=%d, next_off=%d, err_off=%d\n", - iters[i]->len, - iters[i]->off, - iters[i]->type, - iters[i]->key, - iters[i]->d1, - iters[i]->d2, - iters[i]->d3, - iters[i]->d4, - iters[i]->next_off, - iters[i]->err_off); - } - ASSERT (false); - } - } -} - -static void -_check_null_binary (bson_t *bson, bool is_legacy) -{ - const bson_value_t *original; - bson_value_t copy; - bson_iter_t iter; - - BSON_UNUSED (is_legacy); - - BSON_ASSERT (bson_iter_init_find (&iter, bson, "binary")); - BSON_ASSERT (BSON_ITER_HOLDS_BINARY (&iter)); - original = bson_iter_value (&iter); - ASSERT_CMPINT (original->value.v_binary.data_len, ==, 0); - /* Because v_binary.data points to the BSON buffer, data is not NULL */ - BSON_ASSERT (original->value.v_binary.data != NULL); - /* But copying it results in a NULL value because it is empty, even if is - * legacy binary, (which appends the length in the data payload when - * appending). */ - bson_value_copy (original, ©); - BSON_ASSERT (copy.value.v_binary.data_len == 0); - BSON_ASSERT (copy.value.v_binary.data == NULL); - bson_value_destroy (©); -} - -/* Check the behavior of what happens when that bson binary value is NULL. */ -static void -_binary_null_handling (bool is_legacy) -{ - bson_value_t val; - bson_t *bson; - bson_error_t error; - bson_subtype_t subtype = BSON_SUBTYPE_BINARY; - - if (is_legacy) { - subtype = BSON_SUBTYPE_BINARY_DEPRECATED; - } - - bson = bson_new (); - BSON_ASSERT (bson_append_binary (bson, "binary", -1, subtype, NULL, 0)); - _check_null_binary (bson, is_legacy); - bson_destroy (bson); - - /* Appending NULL with non-zero length is an error */ - bson = bson_new (); - BSON_ASSERT (!bson_append_binary (bson, "binary", -1, subtype, NULL, 1)); - bson_destroy (bson); - - bson = bson_new (); - val.value_type = BSON_TYPE_BINARY; - val.value.v_binary.subtype = subtype; - val.value.v_binary.data = NULL; - val.value.v_binary.data_len = 0; - BSON_ASSERT (bson_append_value (bson, "binary", -1, &val)); - _check_null_binary (bson, is_legacy); - bson_destroy (bson); - - bson = BCON_NEW ("binary", BCON_BIN (subtype, NULL, 0)); - _check_null_binary (bson, is_legacy); - bson_destroy (bson); - - bson = bson_new_from_json ( - (uint8_t *) "{\"binary\": { \"$binary\": { \"subType\": \"00\", " - "\"base64\": \"\" } } }", - -1, - &error); - ASSERT_OR_PRINT (bson, error); - _check_null_binary (bson, is_legacy); - bson_destroy (bson); -} - -static void -test_bson_binary_null_handling (void) -{ - _binary_null_handling (false /* is legacy */); - _binary_null_handling (true /* is legacy */); -} - -static void -test_bson_append_null_from_utf8_or_symbol (void) -{ - bson_t bson; - bson_iter_t iter; - - bson_init (&bson); - bson_append_utf8 (&bson, "from_utf8", -1, NULL, 0); - bson_append_symbol (&bson, "from_symbol", -1, NULL, 0); - bson_iter_init (&iter, &bson); - BSON_ASSERT (bson_iter_next (&iter)); - BSON_ASSERT (BSON_ITER_HOLDS_NULL (&iter)); - BSON_ASSERT (bson_iter_next (&iter)); - BSON_ASSERT (BSON_ITER_HOLDS_NULL (&iter)); - bson_destroy (&bson); -} - -static void -test_bson_as_json_string (void) -{ - bson_t *all_types; - char *actual; - const char *expected = - "{ \"double\" : { \"$numberDouble\" : \"1.0\" }, \"string\" : " - "\"string_example\", \"document\" : { \"x\" : \"y\" }, \"document\" : [ " - "\"x\" ], \"binary\" : { \"$binary\" : { \"base64\" : \"ZGF0YQ==\", " - "\"subType\" : \"00\" } }, \"undefined\" : { \"$undefined\" : true }, " - "\"oid\" : { \"$oid\" : \"000000000000000000000000\" }, \"bool\" : true, " - "\"datetime\" : { \"$date\" : { \"$numberLong\" : \"123\" } }, \"null\" " - ": null, \"regex\" : { \"$regularExpression\" : { \"pattern\" : \"a+\", " - "\"options\" : \"\" } }, \"dbpointer\" : { \"$dbPointer\" : { \"$ref\" : " - "\"collection\", \"$id\" : { \"$oid\" : \"000000000000000000000000\" } } " - "}, \"code\" : { \"$code\" : \"var x = 1;\" }, \"symbol\" : { " - "\"$symbol\" : \"symbol_example\" }, \"code\" : { \"$code\" : \"var x = " - "1;\" }, \"code_w_scope\" : { \"$code\" : \"var x = 1;\", \"$scope\" : { " - "} }, \"int32\" : { \"$numberInt\" : \"1\" }, \"timestamp\" : { " - "\"$timestamp\" : { \"t\" : 2, \"i\" : 3 } }, \"int64\" : { " - "\"$numberLong\" : \"4\" }, \"decimal128\" : { \"$numberDecimal\" : " - "\"1.23456789\" }, \"minkey\" : { \"$minKey\" : 1 }, \"maxkey\" : { " - "\"$maxKey\" : 1 }, \"\" : { \"$numberInt\" : \"-1\" } }"; - - all_types = bson_with_all_types (); - actual = bson_as_canonical_extended_json (all_types, NULL); - - for (size_t i = 0u; i < strlen (expected); i++) { - if (expected[i] != actual[i]) { - test_error ("character mismatch at %zu. Expected: %s, got %s", - i, - expected, - actual); - } - } - - bson_free (actual); -} - -#define JSON_STRING(...) #__VA_ARGS__ -#define TMP_BSON_FROM_JSON(...) tmp_bson (JSON_STRING (__VA_ARGS__)) - -/** - * @brief Test the parsing component of the BSON EDSL - */ -static void -test_bson_dsl_parse (void) -{ - // Do nothing: - bsonParse (*TMP_BSON_FROM_JSON ({}), do ()); - BSON_ASSERT (!bsonParseError); - - // Generate an error - bsonParse (*TMP_BSON_FROM_JSON ({}), error ("failed 1")); - ASSERT_CMPSTR (bsonParseError, "failed 1"); - - // Error is reset on each entry - bsonParse (*TMP_BSON_FROM_JSON ({}), do ()); - BSON_ASSERT (!bsonParseError); - - // Find an element - bson_t *simple_foo_bar = TMP_BSON_FROM_JSON ({"foo" : "bar"}); - bool found = false; - bsonParse (*simple_foo_bar, find (key ("foo"), do (found = true))); - BSON_ASSERT (found); - - // Store a reference to the string - const char *found_string = NULL; - bsonParse (*simple_foo_bar, find (key ("foo"), storeStrRef (found_string))); - ASSERT_CMPSTR (found_string, "bar"); - - // We can fail to find too - found = false; - bool not_found = false; - bsonParse (*simple_foo_bar, - find (key ("bad"), do (found = true)), - else (do (not_found = true))); - BSON_ASSERT (!found); - BSON_ASSERT (not_found); - - // We can find two items - int32_t a = 0, b = 0; - bsonParse (*TMP_BSON_FROM_JSON ({"foo" : 1729, "bar" : 42}), - find (key ("foo"), do (a = bsonAs (int32))), - find (key ("bar"), do (b = bsonAs (int32)))); - ASSERT_CMPINT (a, ==, 1729); - ASSERT_CMPINT (b, ==, 42); - - // Wrong types are zeroed - a = 91; - found = false; - bsonParse (*TMP_BSON_FROM_JSON ({"foo" : "string"}), - find (key ("foo"), do (found = true; a = bsonAs (int32)))); - BSON_ASSERT (found); - ASSERT_CMPINT (a, ==, 0); - - // Nested errors do not continue - found = false; - bsonParse (*TMP_BSON_FROM_JSON ({"foo" : null, "bar" : null}), - find (key ("foo"), error ("got foo")), - find (key ("bar"), do (found = true))); - ASSERT_CMPSTR (bsonParseError, "got foo"); - BSON_ASSERT (!found); - - // Halting does not continue - found = false; - bsonParse (*TMP_BSON_FROM_JSON ({"foo" : null, "bar" : null}), - find (key ("foo"), halt), - find (key ("bar"), do (found = true))); - BSON_ASSERT (!bsonParseError); - BSON_ASSERT (!found); - - // "if" will branch - a = 812; - b = 0; - bsonParse (*TMP_BSON_FROM_JSON ({"foo" : 1, "bar" : 2}), - if (a == 812, - then (find (key ("foo"), do (b = bsonAs (int32)))), - else (find (key ("bar"), do (b = bsonAs (int32)))))); - ASSERT_CMPINT (b, ==, 1); - a = 4; - bsonParse (*TMP_BSON_FROM_JSON ({"foo" : 1, "bar" : 2}), - if (a == 812, - then (find (key ("foo"), do (b = bsonAs (int32)))), - else (find (key ("bar"), do (b = bsonAs (int32)))))); - ASSERT_CMPINT (b, ==, 2); - - bson_t tmp = BSON_INITIALIZER; - for (int i = 0; i < 1024; ++i) { - BSON_APPEND_BOOL (&tmp, ".", true); - } - BSON_APPEND_BOOL (&tmp, "final", true); - int unvisited = 0; - bsonParse (tmp, find (key ("final"), nop), visitOthers (do (++unvisited))); - ASSERT_CMPINT (unvisited, ==, 1024); - bson_destroy (&tmp); -} - -static void -test_bson_dsl_visit (void) -{ - // Count elements - int count = 0; - bsonVisitEach (*TMP_BSON_FROM_JSON ({"foo" : 1, "bar" : 1}), do (++count)); - ASSERT_CMPINT (count, ==, 2); - - // Branch on keys - int foo_val = 0; - int bar_val = 0; - bsonVisitEach (*TMP_BSON_FROM_JSON ({"foo" : 61, "bar" : 951}), - if (key ("foo"), then (do (foo_val = bsonAs (int32)))), - if (key ("bar"), then (do (bar_val = bsonAs (int32))))); - ASSERT_CMPINT (foo_val, ==, 61); - ASSERT_CMPINT (bar_val, ==, 951); - - // Store reference to subdocs - bson_t subdoc; - bsonVisitEach (*TMP_BSON_FROM_JSON ({"foo" : {"bar" : 42}}), - storeDocRef (subdoc)); - bar_val = 0; - bsonVisitEach (subdoc, do (bar_val = bsonAs (int32))); - ASSERT_CMPINT (bar_val, ==, 42); - - // Visit subdocs directly - const char *baz_str = NULL; - char *path = NULL; - bsonVisitEach ( - *TMP_BSON_FROM_JSON ({"foo" : {"bar" : {"baz" : "baz_string"}}}), - visitEach (visitEach (storeStrRef (baz_str), dupPath (path)))); - ASSERT_CMPSTR (baz_str, "baz_string"); - ASSERT_CMPSTR (path, "$.foo.bar.baz"); - bson_free (path); -} - -static void -test_bson_dsl_predicate (void) -{ - bson_t *document = TMP_BSON_FROM_JSON ({ - "number1" : 1, - "number2" : 2.1, - "zero" : 0, - "string" : "hello", - "doc" : {"hello" : null}, - "null" : null, - "empty_string" : "", - "empty_array" : [], - "empty_doc" : {}, - "with_last" : {"a" : null, "b" : "lastElement"}, - "unhandled" : 12 - }); - bool saw_other = false; - bsonParse ( // - *document, - require (key ("number1"), // - require (type (int32)), - require (isNumeric), - require (isTrue)), - require (key ("number2"), // - require (isNumeric), - require (type (double)), - require (isTrue)), - require (key ("zero"), // - require (isFalse)), - require (key ("string"), // - require (type (utf8)), - require (strEqual ("hello")), - require (not(strEqual ("goodbye"))), - require (iStrEqual ("HELLO")), - require (not(iStrEqual ("GOODBYE")))), - require (key ("doc"), - require (type (doc)), - require (not(empty)), - visitEach (require (key ("hello")), require (type (null)))), - require (key ("null"), require (type (null))), - require (key ("empty_string"), require (type (utf8))), - require (key ("empty_array"), require (type (array)), require (empty)), - require (key ("empty_doc"), require (type (doc)), require (empty)), - require ( - key ("with_last"), - require (type (doc)), - visitEach (if (lastElement, - then (require (key ("b")), require (type (utf8))), - else (require (key ("a")), require (type (null)))))), - require ( - key ("with_last"), - visitEach (case (when (key ("a"), require (type (null))), - when (key ("b"), require (strEqual ("lastElement"))), - else (do (abort ()))))), - require (key ("string"), - case (when (strEqual ("goodbye"), do (abort ())), - when (strEqual ("hello"), nop), - // Not eached since the prior case matched: - when (strEqual ("hello"), do (abort ())), - else (do (abort ())))), - visitOthers (if (key ("unhandled"), - then (do (saw_other = true)), - else (do (abort ()))))); - BSON_ASSERT (saw_other); -} - -static void -do_assert_bson_equal (const bson_t *actual, - const bson_t *expected, - const char *file, - int line) -{ - char *actual_str = bson_as_canonical_extended_json (actual, NULL); - ASSERT (actual_str); - char *expected_str = bson_as_canonical_extended_json (expected, NULL); - ASSERT (expected_str); - if (strcmp (actual_str, expected_str) != 0) { - test_error ("%s:%d: BSON documents are not equal:\n Expected: %s\n " - "Actual: %s\n", - file, - line, - expected_str, - actual_str); - } - bson_free (actual_str); - bson_free (expected_str); -} - -#define ASSERT_BSON_EQUAL(Actual, ...) \ - do_assert_bson_equal ( \ - &(Actual), TMP_BSON_FROM_JSON (__VA_ARGS__), __FILE__, __LINE__) - -#define ASSERT_BSON_EQUAL_BSON(Actual, Expected) \ - do_assert_bson_equal (&(Actual), &(Expected), __FILE__, __LINE__) - -static void -test_bson_dsl_build (void) -{ - // Create a very simple empty document - bsonBuildDecl (doc, do ()); - BSON_ASSERT (!bsonBuildError); - ASSERT_BSON_EQUAL (doc, {}); - bson_destroy (&doc); - - bsonBuild (doc, kv ("foo", cstr ("bar"))); - ASSERT_BSON_EQUAL (doc, {"foo" : "bar"}); - bson_destroy (&doc); - - bsonBuild (doc, kv ("foo", int32 (92))); - ASSERT_BSON_EQUAL (doc, {"foo" : 92}); - bson_destroy (&doc); - - bsonBuild (doc, kvl ("hello", 1, int32 (9))); - ASSERT_BSON_EQUAL (doc, {"h" : 9}); - bson_destroy (&doc); - - // Conditional insert - bsonBuild ( - doc, if (0, then (kv ("never", null)), else (kv ("truth", int32 (1))))); - ASSERT_BSON_EQUAL (doc, {"truth" : 1}); - bson_destroy (&doc); - - // Insert a subdoc - bson_t *subdoc = - TMP_BSON_FROM_JSON ({"child" : [ 1, 2, 3 ], "other" : null}); - - bsonBuild (doc, kv ("subdoc", doc (insert (*subdoc, true)))); - ASSERT_BSON_EQUAL (doc, - {"subdoc" : {"child" : [ 1, 2, 3 ], "other" : null}}); - bson_destroy (&doc); - - // Conditional insert - bsonBuild (doc, kv ("subdoc", doc (insert (*subdoc, key ("other"))))); - ASSERT_BSON_EQUAL (doc, {"subdoc" : {"other" : null}}); - bson_destroy (&doc); - - // Nested DSL docs - bsonBuild (doc, - kv ("top", - doc (kv ("inner1", array ()), - kv ("inner2", null), - kv ("inner3", array (int32 (1), int32 (2), int32 (3))), - insert (*subdoc, true), - kv ("inner4", doc (kv ("innermost", int32 (42))))))); - ASSERT_BSON_EQUAL (doc, { - "top" : { - "inner1" : [], - "inner2" : null, - "inner3" : [ 1, 2, 3 ], - "child" : [ 1, 2, 3 ], - "other" : null, - "inner4" : {"innermost" : 42} - } - }); - - // Do not destroy doc, but append to it - bsonBuildAppend (doc, kv ("anotherTop", null)); - ASSERT_BSON_EQUAL (doc, { - "top" : { - "inner1" : [], - "inner2" : null, - "inner3" : [ 1, 2, 3 ], - "child" : [ 1, 2, 3 ], - "other" : null, - "inner4" : {"innermost" : 42} - }, - "anotherTop" : null - }); - bson_destroy (&doc); -} - -static void -test_bson_with_duplicate_keys (void) -{ - bson_t with_dups = BSON_INITIALIZER; - - // Assert bson_t can be constructed with duplicate keys. - { - BSON_ASSERT (BSON_APPEND_INT32 (&with_dups, "duplicate", 1)); - BSON_ASSERT (BSON_APPEND_INT32 (&with_dups, "duplicate", 2)); - } - - // Assert bson_iter_find locates the first duplicate. - { - bson_iter_t iter; - BSON_ASSERT (bson_iter_init (&iter, &with_dups)); - BSON_ASSERT (bson_iter_find (&iter, "duplicate")); - ASSERT_CMPINT32 (bson_iter_int32 (&iter), ==, 1); - } - - // Assert bson_iter_find_case locates the first duplicate. - { - bson_iter_t iter; - BSON_ASSERT (bson_iter_init (&iter, &with_dups)); - BSON_ASSERT (bson_iter_find_case (&iter, "dUpLiCaTe")); - ASSERT_CMPINT32 (bson_iter_int32 (&iter), ==, 1); - } - - // Assert bson_iter_find_w_len locates the first duplicate. - { - bson_iter_t iter; - BSON_ASSERT (bson_iter_init (&iter, &with_dups)); - BSON_ASSERT (bson_iter_find_w_len (&iter, "duplicate", 9)); - ASSERT_CMPINT32 (bson_iter_int32 (&iter), ==, 1); - } - - // Assert bson_iter_find_descendant locates the first duplicate. - { - bson_iter_t iter; - BSON_ASSERT (bson_iter_init (&iter, &with_dups)); - BSON_ASSERT (bson_iter_find_descendant (&iter, "duplicate", &iter)); - ASSERT_CMPINT32 (bson_iter_int32 (&iter), ==, 1); - } - - // Assert that bson_as_relaxed_extended_json preserves duplicate keys. - { - char *json_str = - bson_as_relaxed_extended_json (&with_dups, NULL /* length */); - ASSERT_CMPSTR (json_str, "{ \"duplicate\" : 1, \"duplicate\" : 2 }"); - bson_free (json_str); - } - - // Assert that bson_init_from_json preserves duplicate keys. - { - bson_t from_json; - bson_error_t error; - ASSERT_OR_PRINT ( - bson_init_from_json ( - &from_json, "{ \"duplicate\" : 1, \"duplicate\" : 2 }", -1, &error), - error); - BSON_ASSERT_BSON_EQUAL (&with_dups, &from_json); - } - - bson_destroy (&with_dups); -} - -static void -test_bson_uint32_to_string (void) -{ - // Test a value < 1000. - { - char buf[16] = {0}; - const char *strptr; - size_t got = bson_uint32_to_string (123, &strptr, buf, sizeof buf); - ASSERT_CMPSIZE_T (got, ==, 3); - ASSERT_CMPSTR (strptr, "123"); - // Values < 1000 return a static string. Expect the input buffer is not - // used. - ASSERT_CMPSTR (buf, ""); - } - - // Test a value >= 1000. - { - char buf[16] = {0}; - const char *strptr; - size_t got = bson_uint32_to_string (1000, &strptr, buf, sizeof buf); - ASSERT_CMPSIZE_T (got, ==, 4); - ASSERT_CMPSTR (strptr, "1000"); - // Expect the input buffer is used. - ASSERT_CMPSTR (buf, "1000"); - } - - // Test when input buffer is too small. - { - char buf[4] = {0}; - const char *strptr; - size_t got = bson_uint32_to_string (1000, &strptr, buf, sizeof buf); - // Expect the returned value is the number of required bytes excluding the - // NULL terminator. - ASSERT_CMPSIZE_T (got, ==, 4); - // Expect only three characters are written. - ASSERT_CMPSTR (strptr, "100"); - // Expect the input buffer is used. - ASSERT_CMPSTR (buf, "100"); - } -} - -static void -test_bson_array_builder (void) -{ - // Build a top-level array. - { - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_int32 (bab, 1)); - ASSERT (bson_array_builder_append_int32 (bab, 2)); - bson_t b; - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ 1, 2 ]); - bson_array_builder_destroy (bab); - bson_destroy (&b); - } - - // Build a top-level, heap allocated array. - { - char *large_str = bson_malloc0 (64); - for (size_t i = 0; i < 64 - 1; i++) { - large_str[i] = '.'; - } - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_utf8 (bab, large_str, -1)); - ASSERT (bson_array_builder_append_utf8 ( - bab, large_str, -1)); // heap allocates. - ASSERT (bson_array_builder_append_utf8 (bab, large_str, -1)); - bson_t *expect = BCON_NEW ("0", - BCON_UTF8 (large_str), - "1", - BCON_UTF8 (large_str), - "2", - BCON_UTF8 (large_str)); - bson_t b; - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL_BSON (b, *expect); - bson_destroy (expect); - bson_array_builder_destroy (bab); - bson_destroy (&b); - bson_free (large_str); - } - - // Build a nested array. - { - bson_t *b = bson_new (); - bson_array_builder_t *child; - ASSERT (BSON_APPEND_ARRAY_BUILDER_BEGIN (b, "array", &child)); - ASSERT (bson_array_builder_append_int32 (child, 1)); - ASSERT (bson_array_builder_append_int32 (child, 2)); - ASSERT (bson_append_array_builder_end (b, child)); - ASSERT_BSON_EQUAL (*b, {"array" : [ 1, 2 ]}); - bson_destroy (b); - } - - // Reuse a `bson_array_builder`. - { - bson_array_builder_t *bab = bson_array_builder_new (); - - ASSERT (bson_array_builder_append_int32 (bab, 1)); - ASSERT (bson_array_builder_append_int32 (bab, 2)); - bson_t b; - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ 1, 2 ]); - bson_destroy (&b); - // Reuse to build another array. - ASSERT (bson_array_builder_append_int32 (bab, 3)); - ASSERT (bson_array_builder_append_int32 (bab, 4)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ 3, 4 ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - // Test each bson_array_builder_append_* function. - { - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - bson_value_t v = {.value_type = BSON_TYPE_INT32, - .value = {.v_int32 = 1}}; - ASSERT (bson_array_builder_append_value (bab, &v)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [1]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_array ( - bab, TMP_BSON_FROM_JSON ([ 1, 2 ]))); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [[ 1, 2 ]]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_binary ( - bab, BSON_SUBTYPE_BINARY, (const uint8_t *) "A", 1)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL ( - b, [ {"$binary" : {"base64" : "QQ==", "subType" : "00"}} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_bool (bab, true)); - ASSERT (bson_array_builder_build (bab, &b)); - // Use string literal for expectation instead of `ASSERT_BSON_EQUAL` - // macro, since `true` may be replaced by `1` in preprocessing. - ASSERT_BSON_EQUAL_BSON (b, *tmp_bson ("[true]")); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_code (bab, "A")); - ASSERT (bson_array_builder_build (bab, &b)); - // Use document string: `{ "0": ... , "1": ... }` instead of array - // string: `[ ... , ... ]` for expectation. Parsing the array string - // `[{ "$code": ... }]` results in incorrect BSON. See CDRIVER-4678. - ASSERT_BSON_EQUAL (b, {"0" : {"$code" : "A"}}); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_code_with_scope ( - bab, "A", TMP_BSON_FROM_JSON ({"B" : 1}))); - ASSERT (bson_array_builder_build (bab, &b)); - // Use document string: `{ "0": ... , "1": ... }` instead of array - // string: `[ ... , ... ]` for expectation. Parsing the array string - // `[{ "$code": ... }]` results in incorrect BSON. See CDRIVER-4678. - ASSERT_BSON_EQUAL (b, {"0" : {"$code" : "A", "$scope" : {"B" : 1}}}); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - bson_oid_t oid; - bson_oid_init_from_string (&oid, "FFFFFFFFFFFFFFFFFFFFFFFF"); - ASSERT (bson_array_builder_append_dbpointer (bab, "E", &oid)); - ASSERT (bson_array_builder_build (bab, &b)); - // Use document string: `{ "0": ... , "1": ... }` instead of array - // string: `[ ... , ... ]` for expectation. Parsing the array string - // `[{ "$dbPointer": ... }]` results in incorrect BSON. See - // CDRIVER-4678. - ASSERT_BSON_EQUAL (b, { - "0" : { - "$dbPointer" : - {"$ref" : "E", - "$id" : {"$oid" : "ffffffffffffffffffffffff"}} - } - }); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_double (bab, 1.0)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$numberDouble" : "1.0"} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_document ( - bab, TMP_BSON_FROM_JSON ({"A" : 1}))); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"A" : {"$numberInt" : "1"}} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - bson_t child; - ASSERT (bson_array_builder_append_document_begin (bab, &child)); - ASSERT (BSON_APPEND_INT32 (&child, "A", 1)); - ASSERT (bson_array_builder_append_document_end (bab, &child)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"A" : {"$numberInt" : "1"}} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_int32 (bab, 1)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [1]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_int64 (bab, 1)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$numberLong" : "1"} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - bson_decimal128_t d128; - ASSERT (bson_decimal128_from_string ("1.0", &d128)); - ASSERT (bson_array_builder_append_decimal128 (bab, &d128)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$numberDecimal" : "1.0"} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - { - bson_t *b = TMP_BSON_FROM_JSON ({"A" : 1}); - bson_iter_t iter; - ASSERT (bson_iter_init_find (&iter, b, "A")); - ASSERT (bson_array_builder_append_iter (bab, &iter)); - } - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [1]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_minkey (bab)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$minKey" : 1} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_maxkey (bab)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$maxKey" : 1} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_null (bab)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [null]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - bson_oid_t oid; - bson_oid_init_from_string (&oid, "FFFFFFFFFFFFFFFFFFFFFFFF"); - ASSERT (bson_array_builder_append_oid (bab, &oid)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$oid" : "ffffffffffffffffffffffff"} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_regex (bab, "A", "i")); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL ( - b, [ {"$regularExpression" : {"pattern" : "A", "options" : "i"}} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_regex_w_len (bab, "A", 1, "i")); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL ( - b, [ {"$regularExpression" : {"pattern" : "A", "options" : "i"}} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_utf8 (bab, "A", 1)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, ["A"]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_symbol (bab, "A", 1)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$symbol" : "A"} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - time_t t = {0}; - ASSERT (bson_array_builder_append_time_t (bab, t)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$date" : {"$numberLong" : "0"}} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - struct timeval t = {0}; - ASSERT (bson_array_builder_append_timeval (bab, &t)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$date" : {"$numberLong" : "0"}} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_date_time (bab, 1)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$date" : {"$numberLong" : "1"}} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_now_utc (bab)); - ASSERT (bson_array_builder_build (bab, &b)); - // Check that one element exists of the expected type. Do not check - // exact value. - ASSERT_CMPUINT32 (bson_count_keys (&b), ==, 1); - bson_iter_t iter; - ASSERT (bson_iter_init_find (&iter, &b, "0")); - ASSERT_CMPINT ( - (int) bson_iter_type (&iter), ==, (int) BSON_TYPE_DATE_TIME); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_timestamp (bab, 1, 2)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [ {"$timestamp" : {"t" : 1, "i" : 2}} ]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - ASSERT (bson_array_builder_append_undefined (bab)); - ASSERT (bson_array_builder_build (bab, &b)); - // Use string literal for expectation instead of `ASSERT_BSON_EQUAL` - // macro, since `true` may be replaced by `1` in preprocessing. - ASSERT_BSON_EQUAL_BSON (b, *tmp_bson ("[{'$undefined' : true}]")); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - - { - bson_t b; - bson_array_builder_t *bab = bson_array_builder_new (); - bson_array_builder_t *child; - ASSERT (bson_array_builder_append_array_builder_begin (bab, &child)); - ASSERT (bson_array_builder_append_int32 (child, 1)); - ASSERT (bson_array_builder_append_int32 (child, 2)); - ASSERT (bson_array_builder_append_array_builder_end (bab, child)); - ASSERT (bson_array_builder_build (bab, &b)); - ASSERT_BSON_EQUAL (b, [[ 1, 2 ]]); - bson_destroy (&b); - bson_array_builder_destroy (bab); - } - } -} - -void -test_bson_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/bson/new", test_bson_new); - TestSuite_Add (suite, "/bson/new_from_buffer", test_bson_new_from_buffer); - TestSuite_Add (suite, "/bson/init", test_bson_init); - TestSuite_Add (suite, "/bson/init_static", test_bson_init_static); - TestSuite_Add (suite, "/bson/basic", test_bson_alloc); - TestSuite_Add (suite, "/bson/append_overflow", test_bson_append_overflow); - TestSuite_Add (suite, "/bson/append_array", test_bson_append_array); - TestSuite_Add (suite, "/bson/append_binary", test_bson_append_binary); - TestSuite_Add (suite, - "/bson/append_binary_deprecated", - test_bson_append_binary_deprecated); - TestSuite_Add (suite, "/bson/append_bool", test_bson_append_bool); - TestSuite_Add (suite, "/bson/append_code", test_bson_append_code); - TestSuite_Add ( - suite, "/bson/append_code_with_scope", test_bson_append_code_with_scope); - TestSuite_Add (suite, "/bson/append_dbpointer", test_bson_append_dbpointer); - TestSuite_Add (suite, "/bson/append_document", test_bson_append_document); - TestSuite_Add (suite, "/bson/append_double", test_bson_append_double); - TestSuite_Add (suite, "/bson/append_int32", test_bson_append_int32); - TestSuite_Add (suite, "/bson/append_int64", test_bson_append_int64); - TestSuite_Add ( - suite, "/bson/append_decimal128", test_bson_append_decimal128); - TestSuite_Add (suite, "/bson/append_iter", test_bson_append_iter); - TestSuite_Add (suite, "/bson/append_maxkey", test_bson_append_maxkey); - TestSuite_Add (suite, "/bson/append_minkey", test_bson_append_minkey); - TestSuite_Add (suite, "/bson/append_null", test_bson_append_null); - TestSuite_Add (suite, "/bson/append_oid", test_bson_append_oid); - TestSuite_Add (suite, "/bson/append_regex", test_bson_append_regex); - TestSuite_Add ( - suite, "/bson/append_regex_w_len", test_bson_append_regex_w_len); - TestSuite_Add (suite, "/bson/append_utf8", test_bson_append_utf8); - TestSuite_Add (suite, "/bson/append_symbol", test_bson_append_symbol); - TestSuite_Add (suite, "/bson/append_time_t", test_bson_append_time_t); - TestSuite_Add (suite, "/bson/append_timestamp", test_bson_append_timestamp); - TestSuite_Add (suite, "/bson/append_timeval", test_bson_append_timeval); - TestSuite_Add (suite, "/bson/append_undefined", test_bson_append_undefined); - TestSuite_Add (suite, "/bson/append_general", test_bson_append_general); - TestSuite_Add (suite, "/bson/append_deep", test_bson_append_deep); - TestSuite_Add (suite, "/bson/utf8_key", test_bson_utf8_key); - TestSuite_Add (suite, "/bson/validate", test_bson_validate); - TestSuite_Add (suite, "/bson/validate/dbref", test_bson_validate_dbref); - TestSuite_Add (suite, "/bson/validate/bool", test_bson_validate_bool); - TestSuite_Add ( - suite, "/bson/validate/dbpointer", test_bson_validate_dbpointer); - TestSuite_Add (suite, "/bson/new_1mm", test_bson_new_1mm); - TestSuite_Add (suite, "/bson/init_1mm", test_bson_init_1mm); - TestSuite_Add (suite, "/bson/build_child", test_bson_build_child); - TestSuite_Add (suite, "/bson/build_child_deep", test_bson_build_child_deep); - TestSuite_Add (suite, - "/bson/build_child_deep_no_begin_end", - test_bson_build_child_deep_no_begin_end); - TestSuite_Add ( - suite, "/bson/build_child_array", test_bson_build_child_array); - TestSuite_Add (suite, "/bson/count", test_bson_count_keys); - TestSuite_Add (suite, "/bson/copy", test_bson_copy); - TestSuite_Add (suite, "/bson/copy_to", test_bson_copy_to); - TestSuite_Add (suite, - "/bson/copy_to_excluding_noinit", - test_bson_copy_to_excluding_noinit); - TestSuite_Add (suite, "/bson/initializer", test_bson_initializer); - TestSuite_Add (suite, "/bson/concat", test_bson_concat); - TestSuite_Add (suite, "/bson/reinit", test_bson_reinit); - TestSuite_Add (suite, "/bson/macros", test_bson_macros); - TestSuite_Add (suite, "/bson/clear", test_bson_clear); - TestSuite_Add (suite, "/bson/steal", test_bson_steal); - TestSuite_Add (suite, "/bson/reserve_buffer", test_bson_reserve_buffer); - TestSuite_Add ( - suite, "/bson/reserve_buffer/errors", test_bson_reserve_buffer_errors); - TestSuite_Add ( - suite, "/bson/destroy_with_steal", test_bson_destroy_with_steal); - TestSuite_Add (suite, "/bson/has_field", test_bson_has_field); - TestSuite_Add ( - suite, "/bson/visit_invalid_field", test_bson_visit_invalid_field); - TestSuite_Add ( - suite, "/bson/unsupported_type", test_bson_visit_unsupported_type); - TestSuite_Add (suite, - "/bson/unsupported_type/bad_key", - test_bson_visit_unsupported_type_bad_key); - TestSuite_Add (suite, - "/bson/unsupported_type/empty_key", - test_bson_visit_unsupported_type_empty_key); - TestSuite_Add (suite, "/bson/binary_subtype_2", test_bson_subtype_2); - TestSuite_Add (suite, "/bson/regex_length", test_bson_regex_lengths); - TestSuite_Add (suite, "/util/next_power_of_two", test_next_power_of_two); - TestSuite_Add (suite, "/bson/empty_binary", test_bson_empty_binary); - TestSuite_Add (suite, "/bson/iter/key_len", test_bson_iter_key_len); - TestSuite_Add (suite, - "/bson/iter/init_from_data_at_offset", - test_bson_iter_init_from_data_at_offset); - TestSuite_Add ( - suite, "/bson/value/null_handling", test_bson_binary_null_handling); - TestSuite_Add (suite, - "/bson/append_null_from_utf8_or_symbol", - test_bson_append_null_from_utf8_or_symbol); - TestSuite_Add (suite, "/bson/as_json_string", test_bson_as_json_string); - - TestSuite_Add (suite, "/bson/dsl/predicate", test_bson_dsl_predicate); - TestSuite_Add (suite, "/bson/dsl/parse", test_bson_dsl_parse); - TestSuite_Add (suite, "/bson/dsl/visit", test_bson_dsl_visit); - TestSuite_Add (suite, "/bson/dsl/build", test_bson_dsl_build); - TestSuite_Add ( - suite, "/bson/with_duplicate_keys", test_bson_with_duplicate_keys); - TestSuite_Add (suite, "/bson/uint32_to_string", test_bson_uint32_to_string); - TestSuite_Add (suite, "/bson/array_builder", test_bson_array_builder); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-clock.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-clock.c deleted file mode 100644 index 830d70c1d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-clock.c +++ /dev/null @@ -1,25 +0,0 @@ -#include - -#include "TestSuite.h" - - -static void -test_get_monotonic_time (void) -{ - int64_t t; - int64_t t2; - - t = bson_get_monotonic_time (); - t2 = bson_get_monotonic_time (); - BSON_ASSERT (t); - BSON_ASSERT (t2); - ASSERT_CMPINT64 (t, <=, t2); -} - - -void -test_clock_install (TestSuite *suite) -{ - TestSuite_Add ( - suite, "/bson/clock/get_monotonic_time", test_get_monotonic_time); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-decimal128.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-decimal128.c deleted file mode 100644 index f80c4e6c7..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-decimal128.c +++ /dev/null @@ -1,815 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "TestSuite.h" - - -/* - *---------------------------------------------------------------------------- - * decimal128_to_string tests - * - * The following tests confirm functionality of the decimal128_to_string - *function. - * - * All decimal test data is generated using the Intel Decimal Floating-Point - * Math Library's bid128_from_string routine. - * - *---------------------------------------------------------------------------- - */ - - -#define DECIMAL128_FROM_ULLS(dec, h, l) \ - do { \ - (dec).high = (h); \ - (dec).low = (l); \ - } while (0); - - -static void -test_decimal128_to_string__infinity (void) -{ - bson_decimal128_t positive_infinity; - bson_decimal128_t negative_infinity; - char bid_string[BSON_DECIMAL128_STRING]; - - DECIMAL128_FROM_ULLS (positive_infinity, 0x7800000000000000, 0); - DECIMAL128_FROM_ULLS (negative_infinity, 0xf800000000000000, 0); - - bson_decimal128_to_string (&positive_infinity, bid_string); - BSON_ASSERT (!strcmp (bid_string, "Infinity")); - - bson_decimal128_to_string (&negative_infinity, bid_string); - BSON_ASSERT (!strcmp (bid_string, "-Infinity")); -} - - -static void -test_decimal128_to_string__nan (void) -{ - bson_decimal128_t dec_pnan; - bson_decimal128_t dec_nnan; - bson_decimal128_t dec_psnan; - bson_decimal128_t dec_nsnan; - bson_decimal128_t dec_payload_nan; - - /* All the above should just be NaN. */ - char bid_string[BSON_DECIMAL128_STRING]; - - DECIMAL128_FROM_ULLS (dec_pnan, 0x7c00000000000000, 0); - DECIMAL128_FROM_ULLS (dec_nnan, 0xfc00000000000000, 0); - DECIMAL128_FROM_ULLS (dec_psnan, 0x7e00000000000000, 0); - DECIMAL128_FROM_ULLS (dec_nsnan, 0xfe00000000000000, 0); - DECIMAL128_FROM_ULLS (dec_payload_nan, 0x7e00000000000000, 12); - - bson_decimal128_to_string (&dec_pnan, bid_string); - BSON_ASSERT (!strcmp (bid_string, "NaN")); - - bson_decimal128_to_string (&dec_nnan, bid_string); - BSON_ASSERT (!strcmp (bid_string, "NaN")); - - bson_decimal128_to_string (&dec_psnan, bid_string); - BSON_ASSERT (!strcmp (bid_string, "NaN")); - - bson_decimal128_to_string (&dec_nsnan, bid_string); - BSON_ASSERT (!strcmp (bid_string, "NaN")); - - bson_decimal128_to_string (&dec_payload_nan, bid_string); - BSON_ASSERT (!strcmp (bid_string, "NaN")); -} - - -static void -test_decimal128_to_string__regular (void) -{ - char bid_string[BSON_DECIMAL128_STRING]; - bson_decimal128_t one; - bson_decimal128_t zero; - bson_decimal128_t two; - bson_decimal128_t negative_one; - bson_decimal128_t negative_zero; - bson_decimal128_t tenth; - bson_decimal128_t smallest_regular; - bson_decimal128_t largest_regular; - bson_decimal128_t trailing_zeros; - bson_decimal128_t all_digits; - bson_decimal128_t full_house; - - DECIMAL128_FROM_ULLS (one, 0x3040000000000000, 0x0000000000000001); - DECIMAL128_FROM_ULLS (zero, 0x3040000000000000, 0x0000000000000000); - DECIMAL128_FROM_ULLS (two, 0x3040000000000000, 0x0000000000000002); - DECIMAL128_FROM_ULLS (negative_one, 0xb040000000000000, 0x0000000000000001); - DECIMAL128_FROM_ULLS (negative_zero, 0xb040000000000000, 0x0000000000000000); - DECIMAL128_FROM_ULLS ( - tenth, 0x303e000000000000, 0x0000000000000001); /* 0.1 */ - /* 0.001234 */ - DECIMAL128_FROM_ULLS ( - smallest_regular, 0x3034000000000000, 0x00000000000004d2); - /* 12345789012 */ - DECIMAL128_FROM_ULLS ( - largest_regular, 0x3040000000000000, 0x0000001cbe991a14); - /* 0.00123400000 */ - DECIMAL128_FROM_ULLS ( - trailing_zeros, 0x302a000000000000, 0x00000000075aef40); - /* 0.1234567890123456789012345678901234 */ - DECIMAL128_FROM_ULLS (all_digits, 0x2ffc3cde6fff9732, 0xde825cd07e96aff2); - - /* 5192296858534827628530496329220095 */ - DECIMAL128_FROM_ULLS (full_house, 0x3040ffffffffffff, 0xffffffffffffffff); - - bson_decimal128_to_string (&one, bid_string); - BSON_ASSERT (!strcmp ("1", bid_string)); - - bson_decimal128_to_string (&zero, bid_string); - BSON_ASSERT (!strcmp ("0", bid_string)); - - bson_decimal128_to_string (&two, bid_string); - BSON_ASSERT (!strcmp ("2", bid_string)); - - bson_decimal128_to_string (&negative_one, bid_string); - BSON_ASSERT (!strcmp ("-1", bid_string)); - - bson_decimal128_to_string (&negative_zero, bid_string); - BSON_ASSERT (!strcmp ("-0", bid_string)); - - bson_decimal128_to_string (&tenth, bid_string); - BSON_ASSERT (!strcmp ("0.1", bid_string)); - - bson_decimal128_to_string (&smallest_regular, bid_string); - BSON_ASSERT (!strcmp ("0.001234", bid_string)); - - bson_decimal128_to_string (&largest_regular, bid_string); - BSON_ASSERT (!strcmp ("123456789012", bid_string)); - - bson_decimal128_to_string (&trailing_zeros, bid_string); - BSON_ASSERT (!strcmp ("0.00123400000", bid_string)); - - bson_decimal128_to_string (&all_digits, bid_string); - BSON_ASSERT (!strcmp ("0.1234567890123456789012345678901234", bid_string)); - - bson_decimal128_to_string (&full_house, bid_string); - BSON_ASSERT (!strcmp ("5192296858534827628530496329220095", bid_string)); -} - - -static void -test_decimal128_to_string__scientific (void) -{ - char bid_string[BSON_DECIMAL128_STRING]; - - bson_decimal128_t huge; /* 1.000000000000000000000000000000000E+6144 */ - bson_decimal128_t tiny; /* 1E-6176 */ - bson_decimal128_t neg_tiny; /* -1E-6176 */ - bson_decimal128_t large; /* 9.999987654321E+112 */ - bson_decimal128_t largest; /* 9.999999999999999999999999999999999E+6144 */ - bson_decimal128_t tiniest; /* 9.999999999999999999999999999999999E-6143 */ - bson_decimal128_t trailing_zero; /* 1.050E9 */ - bson_decimal128_t one_trailing_zero; /* 1.050E4 */ - bson_decimal128_t move_decimal; /* 105 */ - bson_decimal128_t move_decimal_after; /* 1.05E3 */ - bson_decimal128_t trailing_zero_no_decimal; /* 1E3 */ - - DECIMAL128_FROM_ULLS (huge, 0x5ffe314dc6448d93, 0x38c15b0a00000000); - DECIMAL128_FROM_ULLS (tiny, 0x0000000000000000, 0x0000000000000001); - DECIMAL128_FROM_ULLS (neg_tiny, 0x8000000000000000, 0x0000000000000001); - DECIMAL128_FROM_ULLS (large, 0x3108000000000000, 0x000009184db63eb1); - DECIMAL128_FROM_ULLS (largest, 0x5fffed09bead87c0, 0x378d8e63ffffffff); - DECIMAL128_FROM_ULLS (tiniest, 0x0001ed09bead87c0, 0x378d8e63ffffffff); - DECIMAL128_FROM_ULLS (trailing_zero, 0x304c000000000000, 0x000000000000041a); - DECIMAL128_FROM_ULLS ( - one_trailing_zero, 0x3042000000000000, 0x000000000000041a); - DECIMAL128_FROM_ULLS (move_decimal, 0x3040000000000000, 0x0000000000000069); - DECIMAL128_FROM_ULLS ( - move_decimal_after, 0x3042000000000000, 0x0000000000000069); - DECIMAL128_FROM_ULLS ( - trailing_zero_no_decimal, 0x3046000000000000, 0x0000000000000001); - - bson_decimal128_to_string (&huge, bid_string); - BSON_ASSERT ( - !strcmp ("1.000000000000000000000000000000000E+6144", bid_string)); - - bson_decimal128_to_string (&tiny, bid_string); - BSON_ASSERT (!strcmp ("1E-6176", bid_string)); - - bson_decimal128_to_string (&neg_tiny, bid_string); - BSON_ASSERT (!strcmp ("-1E-6176", bid_string)); - - bson_decimal128_to_string (&neg_tiny, bid_string); - BSON_ASSERT (!strcmp ("-1E-6176", bid_string)); - - bson_decimal128_to_string (&large, bid_string); - BSON_ASSERT (!strcmp ("9.999987654321E+112", bid_string)); - - bson_decimal128_to_string (&largest, bid_string); - BSON_ASSERT ( - !strcmp ("9.999999999999999999999999999999999E+6144", bid_string)); - - bson_decimal128_to_string (&tiniest, bid_string); - BSON_ASSERT ( - !strcmp ("9.999999999999999999999999999999999E-6143", bid_string)); - - bson_decimal128_to_string (&trailing_zero, bid_string); - BSON_ASSERT (!strcmp ("1.050E+9", bid_string)); - - bson_decimal128_to_string (&one_trailing_zero, bid_string); - BSON_ASSERT (!strcmp ("1.050E+4", bid_string)); - - bson_decimal128_to_string (&move_decimal, bid_string); - BSON_ASSERT (!strcmp ("105", bid_string)); - - bson_decimal128_to_string (&move_decimal_after, bid_string); - BSON_ASSERT (!strcmp ("1.05E+3", bid_string)); - - bson_decimal128_to_string (&trailing_zero_no_decimal, bid_string); - BSON_ASSERT (!strcmp ("1E+3", bid_string)); -} - - -static void -test_decimal128_to_string__zeros (void) -{ - char bid_string[BSON_DECIMAL128_STRING]; - - bson_decimal128_t zero; /* 0 */ - bson_decimal128_t pos_exp_zero; /* 0E+300 */ - bson_decimal128_t neg_exp_zero; /* 0E-600 */ - - DECIMAL128_FROM_ULLS (zero, 0x3040000000000000, 0x0000000000000000); - DECIMAL128_FROM_ULLS (pos_exp_zero, 0x3298000000000000, 0x0000000000000000); - DECIMAL128_FROM_ULLS (neg_exp_zero, 0x2b90000000000000, 0x0000000000000000); - - bson_decimal128_to_string (&zero, bid_string); - BSON_ASSERT (!strcmp ("0", bid_string)); - - bson_decimal128_to_string (&pos_exp_zero, bid_string); - BSON_ASSERT (!strcmp ("0E+300", bid_string)); - - bson_decimal128_to_string (&neg_exp_zero, bid_string); - BSON_ASSERT (!strcmp ("0E-600", bid_string)); -} - - -#define IS_NAN(dec) (dec).high == 0x7c00000000000000ull - - -static void -test_decimal128_from_string__invalid_inputs (void) -{ - bson_decimal128_t dec; - - bson_decimal128_from_string (".", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string (".e", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("invalid", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("in", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("i", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("E02", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("..1", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("1abcede", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("1.24abc", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("1.24abcE+02", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("1.24E+02abc2d", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("E+02", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("e+02", &dec); - BSON_ASSERT (IS_NAN (dec)); - - bson_decimal128_from_string_w_len (".", 1, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len (".e", 2, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("", 0, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("invalid", 7, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("in", 2, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("i", 1, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("E02", 3, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("..1", 3, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("1abcede", 7, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("1.24abc", 7, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("1.24abcE+02", 11, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("1.24E+02abc2d", 13, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("E+02", 4, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("e+02", 4, &dec); - BSON_ASSERT (IS_NAN (dec)); -} - - -static void -test_decimal128_from_string__nan (void) -{ - bson_decimal128_t dec; - - bson_decimal128_from_string ("NaN", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("+NaN", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("-NaN", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("-nan", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("1e", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("+nan", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("nan", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("Nan", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("+Nan", &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string ("-Nan", &dec); - BSON_ASSERT (IS_NAN (dec)); - - bson_decimal128_from_string_w_len ("NaN", 3, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("+NaN", 4, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("-NaN", 4, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("-nan", 4, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("1e", 2, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("+nan", 4, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("nan", 3, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("Nan", 3, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("+Nan", 4, &dec); - BSON_ASSERT (IS_NAN (dec)); - bson_decimal128_from_string_w_len ("-Nan", 4, &dec); - BSON_ASSERT (IS_NAN (dec)); -} - - -#define IS_PINFINITY(dec) (dec).high == 0x7800000000000000 -#define IS_NINFINITY(dec) (dec).high == 0xf800000000000000 - - -static void -test_decimal128_from_string__infinity (void) -{ - bson_decimal128_t dec; - - bson_decimal128_from_string ("Infinity", &dec); - BSON_ASSERT (IS_PINFINITY (dec)); - bson_decimal128_from_string ("+Infinity", &dec); - BSON_ASSERT (IS_PINFINITY (dec)); - bson_decimal128_from_string ("+Inf", &dec); - BSON_ASSERT (IS_PINFINITY (dec)); - bson_decimal128_from_string ("-Inf", &dec); - BSON_ASSERT (IS_NINFINITY (dec)); - bson_decimal128_from_string ("-Infinity", &dec); - BSON_ASSERT (IS_NINFINITY (dec)); - - bson_decimal128_from_string_w_len ("Infinity", 8, &dec); - BSON_ASSERT (IS_PINFINITY (dec)); - bson_decimal128_from_string_w_len ("+Infinity", 9, &dec); - BSON_ASSERT (IS_PINFINITY (dec)); - bson_decimal128_from_string_w_len ("+Inf", 4, &dec); - BSON_ASSERT (IS_PINFINITY (dec)); - bson_decimal128_from_string_w_len ("-Inf", 4, &dec); - BSON_ASSERT (IS_NINFINITY (dec)); - bson_decimal128_from_string_w_len ("-Infinity", 9, &dec); - BSON_ASSERT (IS_NINFINITY (dec)); -} - - -static bool -decimal128_equal (bson_decimal128_t *dec, uint64_t high, uint64_t low) -{ - bson_decimal128_t test; - DECIMAL128_FROM_ULLS (test, high, low); - return memcmp (dec, &test, sizeof (*dec)) == 0; -} - -static void -test_decimal128_from_string__simple (void) -{ - bson_decimal128_t one; - bson_decimal128_t negative_one; - bson_decimal128_t zero; - bson_decimal128_t negative_zero; - bson_decimal128_t number; - bson_decimal128_t number_two; - bson_decimal128_t negative_number; - bson_decimal128_t fractional_number; - bson_decimal128_t leading_zeros; - bson_decimal128_t leading_insignificant_zeros; - - bson_decimal128_from_string ("1", &one); - bson_decimal128_from_string ("-1", &negative_one); - bson_decimal128_from_string ("0", &zero); - bson_decimal128_from_string ("-0", &negative_zero); - bson_decimal128_from_string ("12345678901234567", &number); - bson_decimal128_from_string ("989898983458", &number_two); - bson_decimal128_from_string ("-12345678901234567", &negative_number); - - bson_decimal128_from_string ("0.12345", &fractional_number); - bson_decimal128_from_string ("0.0012345", &leading_zeros); - - bson_decimal128_from_string ("00012345678901234567", - &leading_insignificant_zeros); - - BSON_ASSERT ( - decimal128_equal (&one, 0x3040000000000000, 0x0000000000000001)); - BSON_ASSERT ( - decimal128_equal (&negative_one, 0xb040000000000000, 0x0000000000000001)); - BSON_ASSERT ( - decimal128_equal (&zero, 0x3040000000000000, 0x0000000000000000)); - BSON_ASSERT (decimal128_equal ( - &negative_zero, 0xb040000000000000, 0x0000000000000000)); - BSON_ASSERT ( - decimal128_equal (&number, 0x3040000000000000, 0x002bdc545d6b4b87)); - BSON_ASSERT ( - decimal128_equal (&number_two, 0x3040000000000000, 0x000000e67a93c822)); - BSON_ASSERT (decimal128_equal ( - &negative_number, 0xb040000000000000, 0x002bdc545d6b4b87)); - BSON_ASSERT (decimal128_equal ( - &fractional_number, 0x3036000000000000, 0x0000000000003039)); - BSON_ASSERT (decimal128_equal ( - &leading_zeros, 0x3032000000000000, 0x0000000000003039)); - BSON_ASSERT (decimal128_equal ( - &leading_insignificant_zeros, 0x3040000000000000, 0x002bdc545d6b4b87)); - - - bson_decimal128_from_string_w_len ("1", 1, &one); - bson_decimal128_from_string_w_len ("-1", 2, &negative_one); - bson_decimal128_from_string_w_len ("0", 1, &zero); - bson_decimal128_from_string_w_len ("-0", 2, &negative_zero); - bson_decimal128_from_string_w_len ("12345678901234567", 17, &number); - bson_decimal128_from_string_w_len ("989898983458", 12, &number_two); - bson_decimal128_from_string_w_len ( - "-12345678901234567", 18, &negative_number); - - bson_decimal128_from_string_w_len ("0.12345", 7, &fractional_number); - bson_decimal128_from_string_w_len ("0.0012345", 9, &leading_zeros); - - bson_decimal128_from_string_w_len ( - "00012345678901234567", 20, &leading_insignificant_zeros); - - BSON_ASSERT ( - decimal128_equal (&one, 0x3040000000000000, 0x0000000000000001)); - BSON_ASSERT ( - decimal128_equal (&negative_one, 0xb040000000000000, 0x0000000000000001)); - BSON_ASSERT ( - decimal128_equal (&zero, 0x3040000000000000, 0x0000000000000000)); - BSON_ASSERT (decimal128_equal ( - &negative_zero, 0xb040000000000000, 0x0000000000000000)); - BSON_ASSERT ( - decimal128_equal (&number, 0x3040000000000000, 0x002bdc545d6b4b87)); - BSON_ASSERT ( - decimal128_equal (&number_two, 0x3040000000000000, 0x000000e67a93c822)); - BSON_ASSERT (decimal128_equal ( - &negative_number, 0xb040000000000000, 0x002bdc545d6b4b87)); - BSON_ASSERT (decimal128_equal ( - &fractional_number, 0x3036000000000000, 0x0000000000003039)); - BSON_ASSERT (decimal128_equal ( - &leading_zeros, 0x3032000000000000, 0x0000000000003039)); - BSON_ASSERT (decimal128_equal ( - &leading_insignificant_zeros, 0x3040000000000000, 0x002bdc545d6b4b87)); -} - - -static void -test_decimal128_from_string__scientific (void) -{ - bson_decimal128_t ten; - bson_decimal128_t ten_again; - bson_decimal128_t one; - bson_decimal128_t huge_exp; - bson_decimal128_t tiny_exp; - bson_decimal128_t fractional; - bson_decimal128_t trailing_zeros; - - bson_decimal128_from_string ("10e0", &ten); - bson_decimal128_from_string ("1e1", &ten_again); - bson_decimal128_from_string ("10e-1", &one); - - BSON_ASSERT ( - decimal128_equal (&ten, 0x3040000000000000, 0x000000000000000a)); - BSON_ASSERT ( - decimal128_equal (&ten_again, 0x3042000000000000, 0x0000000000000001)); - BSON_ASSERT ( - decimal128_equal (&one, 0x303e000000000000, 0x000000000000000a)); - - bson_decimal128_from_string ("12345678901234567e6111", &huge_exp); - bson_decimal128_from_string ("1e-6176", &tiny_exp); - - BSON_ASSERT ( - decimal128_equal (&huge_exp, 0x5ffe000000000000, 0x002bdc545d6b4b87)); - BSON_ASSERT ( - decimal128_equal (&tiny_exp, 0x0000000000000000, 0x0000000000000001)); - - bson_decimal128_from_string ("-100E-10", &fractional); - bson_decimal128_from_string ("10.50E8", &trailing_zeros); - - BSON_ASSERT ( - decimal128_equal (&fractional, 0xb02c000000000000, 0x0000000000000064)); - BSON_ASSERT (decimal128_equal ( - &trailing_zeros, 0x304c000000000000, 0x000000000000041a)); - - - bson_decimal128_from_string_w_len ("10e0", 4, &ten); - bson_decimal128_from_string_w_len ("1e1", 3, &ten_again); - bson_decimal128_from_string_w_len ("10e-1", 5, &one); - - BSON_ASSERT ( - decimal128_equal (&ten, 0x3040000000000000, 0x000000000000000a)); - BSON_ASSERT ( - decimal128_equal (&ten_again, 0x3042000000000000, 0x0000000000000001)); - BSON_ASSERT ( - decimal128_equal (&one, 0x303e000000000000, 0x000000000000000a)); - - bson_decimal128_from_string_w_len ("12345678901234567e6111", 22, &huge_exp); - bson_decimal128_from_string_w_len ("1e-6176", 7, &tiny_exp); - - BSON_ASSERT ( - decimal128_equal (&huge_exp, 0x5ffe000000000000, 0x002bdc545d6b4b87)); - BSON_ASSERT ( - decimal128_equal (&tiny_exp, 0x0000000000000000, 0x0000000000000001)); - - bson_decimal128_from_string_w_len ("-100E-10", 8, &fractional); - bson_decimal128_from_string_w_len ("10.50E8", 7, &trailing_zeros); - - BSON_ASSERT ( - decimal128_equal (&fractional, 0xb02c000000000000, 0x0000000000000064)); - BSON_ASSERT (decimal128_equal ( - &trailing_zeros, 0x304c000000000000, 0x000000000000041a)); -} - - -static void -test_decimal128_from_string__large (void) -{ - bson_decimal128_t large; - bson_decimal128_t all_digits; - bson_decimal128_t largest; - bson_decimal128_t tiniest; - bson_decimal128_t full_house; - - bson_decimal128_from_string ("12345689012345789012345", &large); - bson_decimal128_from_string ("1234567890123456789012345678901234", - &all_digits); - bson_decimal128_from_string ("9.999999999999999999999999999999999E+6144", - &largest); - bson_decimal128_from_string ("9.999999999999999999999999999999999E-6143", - &tiniest); - bson_decimal128_from_string ("5.192296858534827628530496329220095E+33", - &full_house); - - BSON_ASSERT ( - decimal128_equal (&large, 0x304000000000029d, 0x42da3a76f9e0d979)); - BSON_ASSERT ( - decimal128_equal (&all_digits, 0x30403cde6fff9732, 0xde825cd07e96aff2)); - BSON_ASSERT ( - decimal128_equal (&largest, 0x5fffed09bead87c0, 0x378d8e63ffffffff)); - BSON_ASSERT ( - decimal128_equal (&tiniest, 0x0001ed09bead87c0, 0x378d8e63ffffffff)); - BSON_ASSERT ( - decimal128_equal (&full_house, 0x3040ffffffffffff, 0xffffffffffffffff)); - - - bson_decimal128_from_string_w_len ("12345689012345789012345", -1, &large); - bson_decimal128_from_string_w_len ( - "1234567890123456789012345678901234", -1, &all_digits); - bson_decimal128_from_string_w_len ( - "9.999999999999999999999999999999999E+6144", -1, &largest); - bson_decimal128_from_string_w_len ( - "9.999999999999999999999999999999999E-6143", -1, &tiniest); - bson_decimal128_from_string_w_len ( - "5.192296858534827628530496329220095E+33", -1, &full_house); - - BSON_ASSERT ( - decimal128_equal (&large, 0x304000000000029d, 0x42da3a76f9e0d979)); - BSON_ASSERT ( - decimal128_equal (&all_digits, 0x30403cde6fff9732, 0xde825cd07e96aff2)); - BSON_ASSERT ( - decimal128_equal (&largest, 0x5fffed09bead87c0, 0x378d8e63ffffffff)); - BSON_ASSERT ( - decimal128_equal (&tiniest, 0x0001ed09bead87c0, 0x378d8e63ffffffff)); - BSON_ASSERT ( - decimal128_equal (&full_house, 0x3040ffffffffffff, 0xffffffffffffffff)); -} - - -static void -test_decimal128_from_string__exponent_normalization (void) -{ - bson_decimal128_t trailing_zeros; - bson_decimal128_t one_normalize; - bson_decimal128_t no_normalize; - bson_decimal128_t a_disaster; - - bson_decimal128_from_string ("1000000000000000000000000000000000000000", - &trailing_zeros); - bson_decimal128_from_string ("10000000000000000000000000000000000", - &one_normalize); - bson_decimal128_from_string ("1000000000000000000000000000000000", - &no_normalize); - bson_decimal128_from_string ( - "100000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "0000000000000000000000000000000000", - &a_disaster); - - BSON_ASSERT (decimal128_equal ( - &trailing_zeros, 0x304c314dc6448d93, 0x38c15b0a00000000)); - BSON_ASSERT (decimal128_equal ( - &one_normalize, 0x3042314dc6448d93, 0x38c15b0a00000000)); - BSON_ASSERT ( - decimal128_equal (&no_normalize, 0x3040314dc6448d93, 0x38c15b0a00000000)); - BSON_ASSERT ( - decimal128_equal (&a_disaster, 0x37cc314dc6448d93, 0x38c15b0a00000000)); - - - bson_decimal128_from_string_w_len ( - "1000000000000000000000000000000000000000", -1, &trailing_zeros); - bson_decimal128_from_string_w_len ( - "10000000000000000000000000000000000", -1, &one_normalize); - bson_decimal128_from_string_w_len ( - "1000000000000000000000000000000000", -1, &no_normalize); - bson_decimal128_from_string_w_len ( - "100000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000" - "0000000000000000000000000000000000", - -1, - &a_disaster); - - BSON_ASSERT (decimal128_equal ( - &trailing_zeros, 0x304c314dc6448d93, 0x38c15b0a00000000)); - BSON_ASSERT (decimal128_equal ( - &one_normalize, 0x3042314dc6448d93, 0x38c15b0a00000000)); - BSON_ASSERT ( - decimal128_equal (&no_normalize, 0x3040314dc6448d93, 0x38c15b0a00000000)); - BSON_ASSERT ( - decimal128_equal (&a_disaster, 0x37cc314dc6448d93, 0x38c15b0a00000000)); -} - - -static void -test_decimal128_from_string__zeros (void) -{ - bson_decimal128_t zero; - bson_decimal128_t exponent_zero; - bson_decimal128_t large_exponent; - bson_decimal128_t negative_zero; - - bson_decimal128_from_string ("0", &zero); - bson_decimal128_from_string ("0e-611", &exponent_zero); - bson_decimal128_from_string ("0e+6000", &large_exponent); - bson_decimal128_from_string ("-0e-1", &negative_zero); - - BSON_ASSERT ( - decimal128_equal (&zero, 0x3040000000000000, 0x0000000000000000)); - BSON_ASSERT (decimal128_equal ( - &exponent_zero, 0x2b7a000000000000, 0x0000000000000000)); - BSON_ASSERT (decimal128_equal ( - &large_exponent, 0x5f20000000000000, 0x0000000000000000)); - BSON_ASSERT (decimal128_equal ( - &negative_zero, 0xb03e000000000000, 0x0000000000000000)); - - - bson_decimal128_from_string_w_len ("0", 1, &zero); - bson_decimal128_from_string_w_len ("0e-611", -1, &exponent_zero); - bson_decimal128_from_string_w_len ("0e+6000", 7, &large_exponent); - bson_decimal128_from_string_w_len ("-0e-1", 5, &negative_zero); - - BSON_ASSERT ( - decimal128_equal (&zero, 0x3040000000000000, 0x0000000000000000)); - BSON_ASSERT (decimal128_equal ( - &exponent_zero, 0x2b7a000000000000, 0x0000000000000000)); - BSON_ASSERT (decimal128_equal ( - &large_exponent, 0x5f20000000000000, 0x0000000000000000)); - BSON_ASSERT (decimal128_equal ( - &negative_zero, 0xb03e000000000000, 0x0000000000000000)); -} - -static void -test_decimal128_from_string_w_len__special (void) -{ - bson_decimal128_t number; - bson_decimal128_t number_two; - bson_decimal128_t negative_number; - - /* These strings have more bytes than the length indicates. */ - bson_decimal128_from_string_w_len ("12345678901234567abcd", 17, &number); - bson_decimal128_from_string_w_len ("989898983458abcd", 12, &number_two); - bson_decimal128_from_string_w_len ( - "-12345678901234567abcd", 18, &negative_number); - - BSON_ASSERT ( - decimal128_equal (&number, 0x3040000000000000, 0x002bdc545d6b4b87)); - BSON_ASSERT ( - decimal128_equal (&number_two, 0x3040000000000000, 0x000000e67a93c822)); - BSON_ASSERT (decimal128_equal ( - &negative_number, 0xb040000000000000, 0x002bdc545d6b4b87)); -} - -void -test_decimal128_install (TestSuite *suite) -{ - TestSuite_Add (suite, - "/bson/decimal128/to_string/infinity", - test_decimal128_to_string__infinity); - TestSuite_Add ( - suite, "/bson/decimal128/to_string/nan", test_decimal128_to_string__nan); - TestSuite_Add (suite, - "/bson/decimal128/to_string/regular", - test_decimal128_to_string__regular); - TestSuite_Add (suite, - "/bson/decimal128/to_string/scientific", - test_decimal128_to_string__scientific); - TestSuite_Add (suite, - "/bson/decimal128/to_string/zero", - test_decimal128_to_string__zeros); - TestSuite_Add (suite, - "/bson/decimal128/from_string/invalid", - test_decimal128_from_string__invalid_inputs); - TestSuite_Add (suite, - "/bson/decimal128/from_string/nan", - test_decimal128_from_string__nan); - TestSuite_Add (suite, - "/bson/decimal128/from_string/infinity", - test_decimal128_from_string__infinity); - TestSuite_Add (suite, - "/bson/decimal128/from_string/basic", - test_decimal128_from_string__simple); - TestSuite_Add (suite, - "/bson/decimal128/from_string/scientific", - test_decimal128_from_string__scientific); - TestSuite_Add (suite, - "/bson/decimal128/from_string/large", - test_decimal128_from_string__large); - TestSuite_Add (suite, - "/bson/decimal128/from_string/exponent_normalization", - test_decimal128_from_string__exponent_normalization); - TestSuite_Add (suite, - "/bson/decimal128/from_string/zero", - test_decimal128_from_string__zeros); - TestSuite_Add (suite, - "/bson/decimal128/from_string/with_length", - test_decimal128_from_string_w_len__special); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-json.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-json.c deleted file mode 100644 index abf754782..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-json.c +++ /dev/null @@ -1,3980 +0,0 @@ -/* required on old Windows for rand_s to be defined */ -#define _CRT_RAND_S - -#include -#include - -#include "TestSuite.h" -#include "test-conveniences.h" - -static ssize_t -test_bson_json_read_cb_helper (void *string, uint8_t *buf, size_t len) -{ - size_t str_size = strlen ((char *) string); - if (str_size) { - memcpy (buf, string, BSON_MIN (str_size, len)); - return str_size; - } else { - return 0; - } -} - -static void -test_bson_json_allow_multiple (void) -{ - int32_t one; - bson_error_t error; - bson_json_reader_t *reader; - bson_t bson; - const char *collection; - const bson_oid_t *oid; - bson_oid_t oid_expected; - int i; - /* nested JSON tests code that reuses parser stack frames, CDRIVER-2524 */ - char *multiple_json = - "{\"a\": 1}" - "{\"b\": {\"$dbPointer\": " - " {\"$ref\": \"c\", \"$id\": {\"$oid\": \"12341234123412abcdababcd\"}}}}" - "{\"c\": {\"x\": 1}}"; - - bson_oid_init_from_string (&oid_expected, "12341234123412abcdababcd"); - - for (i = 0; i < 2; i++) { - reader = bson_json_reader_new (multiple_json, - &test_bson_json_read_cb_helper, - NULL, - i == 1 /* allow_multiple */, - 0); - - BSON_ASSERT (reader); - - /* read first json */ - bson_init (&bson); - ASSERT_CMPINT (1, ==, bson_json_reader_read (reader, &bson, &error)); - BCON_EXTRACT (&bson, "a", BCONE_INT32 (one)); - ASSERT_CMPINT (1, ==, one); - - /* read second json */ - bson_reinit (&bson); - ASSERT_CMPINT (1, ==, bson_json_reader_read (reader, &bson, &error)); - BCON_EXTRACT (&bson, "b", BCONE_DBPOINTER (collection, oid)); - ASSERT_CMPSTR (collection, "c"); - BSON_ASSERT (0 == bson_oid_compare (oid, &oid_expected)); - - /* read third json */ - bson_reinit (&bson); - ASSERT_CMPINT (1, ==, bson_json_reader_read (reader, &bson, &error)); - BCON_EXTRACT (&bson, "c", BCONE_INT32 (one)); - ASSERT_CMPINT (1, ==, one); - - /* surprisingly, the reader begins at the start of the string again */ - bson_reinit (&bson); - ASSERT_CMPINT (1, ==, bson_json_reader_read (reader, &bson, &error)); - BCON_EXTRACT (&bson, "a", BCONE_INT32 (one)); - ASSERT_CMPINT (1, ==, one); - - bson_json_reader_destroy (reader); - bson_destroy (&bson); - } -} - - -static void -test_bson_as_json_x1000 (void) -{ - bson_oid_t oid; - bson_decimal128_t decimal128; - bson_t *b; - bson_t *b2; - char *str; - size_t len; - int i; - - decimal128.high = 0x3040000000000000ULL; - decimal128.low = 0x000000000000000B; - bson_oid_init_from_string (&oid, "123412341234abcdabcdabcd"); - - b = bson_new (); - BSON_ASSERT (bson_append_utf8 (b, "utf8", -1, "bar", -1)); - BSON_ASSERT (bson_append_int32 (b, "int32", -1, 1234)); - BSON_ASSERT (bson_append_int64 (b, "int64", -1, 4321)); - BSON_ASSERT (bson_append_double (b, "double", -1, 123.4)); - BSON_ASSERT (bson_append_undefined (b, "undefined", -1)); - BSON_ASSERT (bson_append_null (b, "null", -1)); - BSON_ASSERT (bson_append_oid (b, "oid", -1, &oid)); - BSON_ASSERT (bson_append_bool (b, "true", -1, true)); - BSON_ASSERT (bson_append_bool (b, "false", -1, false)); - BSON_ASSERT (bson_append_time_t (b, "date", -1, time (NULL))); - BSON_ASSERT ( - bson_append_timestamp (b, "timestamp", -1, (uint32_t) time (NULL), 1234)); - BSON_ASSERT (bson_append_regex (b, "regex", -1, "^abcd", "xi")); - BSON_ASSERT ( - bson_append_dbpointer (b, "dbpointer", -1, "mycollection", &oid)); - BSON_ASSERT (bson_append_minkey (b, "minkey", -1)); - BSON_ASSERT (bson_append_maxkey (b, "maxkey", -1)); - BSON_ASSERT (bson_append_symbol (b, "symbol", -1, "var a = {};", -1)); - BSON_ASSERT (bson_append_decimal128 (b, "decimal128", -1, &decimal128)); - - b2 = bson_new (); - BSON_ASSERT (bson_append_int32 (b2, "0", -1, 60)); - BSON_ASSERT (bson_append_document (b, "document", -1, b2)); - BSON_ASSERT (bson_append_array (b, "array", -1, b2)); - - { - const uint8_t binary[] = {0, 1, 2, 3, 4}; - BSON_ASSERT (bson_append_binary ( - b, "binary", -1, BSON_SUBTYPE_BINARY, binary, sizeof binary)); - } - - for (i = 0; i < 1000; i++) { - str = bson_as_json (b, &len); - bson_free (str); - } - - bson_destroy (b); - bson_destroy (b2); -} - - -static void -test_bson_as_json_multi (void) -{ - bson_t *b; - char *str; - size_t len; - - b = bson_new (); - - { - bson_oid_t oid; - bson_oid_init_from_string (&oid, "57e193d7a9cc81b4027498b5"); - BSON_ASSERT (bson_append_oid (b, "_id", -1, &oid)); - } - - BSON_ASSERT (bson_append_symbol (b, "Symbol", -1, "symbol", -1)); - BSON_ASSERT (bson_append_utf8 (b, "String", -1, "string", -1)); - BSON_ASSERT (bson_append_int32 (b, "Int32", -1, 42)); - BSON_ASSERT (bson_append_int64 (b, "Int64", -1, 42)); - BSON_ASSERT (bson_append_double (b, "Double", -1, -1.0)); - - { - const uint8_t binary[] = {0xa3, - 0x4c, - 0x38, - 0xf7, - 0xc3, - 0xab, - 0xed, - 0xc8, - 0xa3, - 0x78, - 0x14, - 0xa9, - 0x92, - 0xab, - 0x8d, - 0xb6}; - BSON_ASSERT (bson_append_binary ( - b, "Binary", -1, BSON_SUBTYPE_UUID_DEPRECATED, binary, sizeof binary)); - } - - { - const uint8_t binary[] = {1, 2, 3, 4, 5}; - BSON_ASSERT (bson_append_binary ( - b, "BinaryUserDefined", -1, BSON_SUBTYPE_USER, binary, sizeof binary)); - } - - BSON_ASSERT (bson_append_code (b, "Code", -1, "function() {}")); - - { - bson_t *scope = bson_new (); - BSON_ASSERT (bson_append_code_with_scope ( - b, "CodeWithScope", -1, "function() {}", scope)); - bson_destroy (scope); - } - - { - bson_t *document = bson_new (); - BSON_ASSERT (bson_append_utf8 (document, "foo", -1, "bar", -1)); - BSON_ASSERT (bson_append_document (b, "Subdocument", -1, document)); - bson_destroy (document); - } - - { - bson_t *array = bson_new (); - BSON_ASSERT (bson_append_int32 (array, "0", -1, 1)); - BSON_ASSERT (bson_append_int32 (array, "1", -1, 2)); - BSON_ASSERT (bson_append_int32 (array, "2", -1, 3)); - BSON_ASSERT (bson_append_int32 (array, "3", -1, 4)); - BSON_ASSERT (bson_append_int32 (array, "4", -1, 5)); - BSON_ASSERT (bson_append_array (b, "Array", -1, array)); - bson_destroy (array); - } - - BSON_ASSERT (bson_append_timestamp (b, "Timestamp", -1, 42, 1)); - BSON_ASSERT (bson_append_regex (b, "Regex", -1, "pattern", "")); - BSON_ASSERT (bson_append_date_time (b, "DatetimeEpoch", -1, 0)); - BSON_ASSERT (bson_append_date_time ( - b, "DatetimePositive", -1, (int64_t) 2147483647LL)); - BSON_ASSERT (bson_append_date_time ( - b, "DatetimeNegative", -1, (int64_t) -2147483648LL)); - BSON_ASSERT (bson_append_bool (b, "True", -1, true)); - BSON_ASSERT (bson_append_bool (b, "False", -1, false)); - - { - bson_oid_t oid; - bson_oid_init_from_string (&oid, "57e193d7a9cc81b4027498b1"); - BSON_ASSERT ( - bson_append_dbpointer (b, "DBPointer", -1, "collection", &oid)); - } - - { - bson_oid_t oid; - bson_t *dbref = bson_new (); - bson_oid_init_from_string (&oid, "57fd71e96e32ab4225b723fb"); - BSON_ASSERT (bson_append_utf8 (dbref, "$ref", -1, "collection", -1)); - BSON_ASSERT (bson_append_oid (dbref, "$id", -1, &oid)); - BSON_ASSERT (bson_append_utf8 (dbref, "$db", -1, "database", -1)); - BSON_ASSERT (bson_append_document (b, "DBRef", -1, dbref)); - bson_destroy (dbref); - } - - BSON_ASSERT (bson_append_minkey (b, "Minkey", -1)); - BSON_ASSERT (bson_append_maxkey (b, "Maxkey", -1)); - BSON_ASSERT (bson_append_null (b, "Null", -1)); - BSON_ASSERT (bson_append_undefined (b, "Undefined", -1)); - - { - bson_decimal128_t decimal128; - decimal128.high = 0x3040000000000000ULL; - decimal128.low = 0x000000000000000B; - BSON_ASSERT (bson_append_decimal128 (b, "Decimal128", -1, &decimal128)); - } - - str = bson_as_json (b, &len); - - /* Based on multi-type-deprecated.json from BSON Corpus Tests. */ - ASSERT_CMPSTR ( - str, - "{" - " \"_id\" : { \"$oid\" : \"57e193d7a9cc81b4027498b5\" }," - " \"Symbol\" : \"symbol\"," - " \"String\" : \"string\"," - " \"Int32\" : 42," - " \"Int64\" : 42," - " \"Double\" : -1.0," - " \"Binary\" : { \"$binary\" : \"o0w498Or7cijeBSpkquNtg==\", \"$type\" : " - "\"03\" }," - " \"BinaryUserDefined\" : { \"$binary\" : \"AQIDBAU=\", \"$type\" : " - "\"80\" }," - " \"Code\" : { \"$code\" : \"function() {}\" }," - " \"CodeWithScope\" : { \"$code\" : \"function() {}\", \"$scope\" : { } " - "}," - " \"Subdocument\" : { \"foo\" : \"bar\" }," - " \"Array\" : [ 1, 2, 3, 4, 5 ]," - " \"Timestamp\" : { \"$timestamp\" : { \"t\" : 42, \"i\" : 1 } }," - " \"Regex\" : { \"$regex\" : \"pattern\", \"$options\" : \"\" }," - " \"DatetimeEpoch\" : { \"$date\" : 0 }," - " \"DatetimePositive\" : { \"$date\" : 2147483647 }," - " \"DatetimeNegative\" : { \"$date\" : -2147483648 }," - " \"True\" : true," - " \"False\" : false," - " \"DBPointer\" : { \"$ref\" : \"collection\", \"$id\" : " - "\"57e193d7a9cc81b4027498b1\" }," - " \"DBRef\" : { \"$ref\" : \"collection\", \"$id\" : { \"$oid\" : " - "\"57fd71e96e32ab4225b723fb\" }, \"$db\" : \"database\" }," - " \"Minkey\" : { \"$minKey\" : 1 }," - " \"Maxkey\" : { \"$maxKey\" : 1 }," - " \"Null\" : null," - " \"Undefined\" : { \"$undefined\" : true }," - " \"Decimal128\" : { \"$numberDecimal\" : \"11\" } }"); - - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_string (void) -{ - size_t len; - bson_t *b; - char *str; - - b = bson_new (); - BSON_ASSERT (bson_append_utf8 (b, "foo", -1, "bar", -1)); - str = bson_as_json (b, &len); - BSON_ASSERT (len == 17); - BSON_ASSERT (!strcmp ("{ \"foo\" : \"bar\" }", str)); - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_int32 (void) -{ - size_t len; - bson_t *b; - char *str; - - b = bson_new (); - BSON_ASSERT (bson_append_int32 (b, "foo", -1, 1234)); - str = bson_as_json (b, &len); - BSON_ASSERT (len == 16); - BSON_ASSERT (!strcmp ("{ \"foo\" : 1234 }", str)); - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_int64 (void) -{ - size_t len; - bson_t *b; - char *str; - - b = bson_new (); - BSON_ASSERT (bson_append_int64 (b, "foo", -1, 341234123412341234ULL)); - str = bson_as_json (b, &len); - BSON_ASSERT (len == 30); - BSON_ASSERT (!strcmp ("{ \"foo\" : 341234123412341234 }", str)); - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_double (void) -{ - size_t len; - bson_t *b; - char *str; - char *expected; - - b = bson_new (); - BSON_ASSERT (bson_append_double (b, "foo", -1, 123.5)); - BSON_ASSERT (bson_append_double (b, "bar", -1, 3)); - BSON_ASSERT (bson_append_double (b, "baz", -1, -1)); - BSON_ASSERT (bson_append_double (b, "quux", -1, 0.03125)); - BSON_ASSERT (bson_append_double (b, "huge", -1, 1e99)); - str = bson_as_json (b, &len); - - expected = bson_strdup_printf ("{" - " \"foo\" : 123.5," - " \"bar\" : 3.0," - " \"baz\" : -1.0," - " \"quux\" : 0.03125," - " \"huge\" : %.20g }", - 1e99); - - ASSERT_CMPSTR (str, expected); - - bson_free (expected); - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_double_nonfinite (void) -{ - size_t len; - bson_t *b; - char *str; - char *expected; - - const double pos_inf = INFINITY; - const double neg_inf = -pos_inf; - - b = bson_new (); - BSON_ASSERT (bson_append_double (b, "nan", -1, NAN)); - BSON_ASSERT (bson_append_double (b, "pos_inf", -1, pos_inf)); - BSON_ASSERT (bson_append_double (b, "neg_inf", -1, neg_inf)); - str = bson_as_json (b, &len); - - expected = bson_strdup_printf ("{" - " \"nan\" : %.20g," - " \"pos_inf\" : %.20g," - " \"neg_inf\" : %.20g }", - NAN, - pos_inf, - neg_inf); - - ASSERT_CMPSTR (str, expected); - - bson_free (expected); - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_decimal128 (void) -{ - size_t len; - bson_t *b; - char *str; - bson_decimal128_t decimal128; - decimal128.high = 0x3040000000000000ULL; - decimal128.low = 0x000000000000000B; - - b = bson_new (); - BSON_ASSERT (bson_append_decimal128 (b, "decimal128", -1, &decimal128)); - str = bson_as_json (b, &len); - ASSERT_CMPSTR (str, - "{ " - "\"decimal128\" : { \"$numberDecimal\" : \"11\" }" - " }"); - - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_code (void) -{ - bson_t code = BSON_INITIALIZER; - bson_t scope = BSON_INITIALIZER; - char *str; - - BSON_ASSERT (bson_append_code (&code, "c", -1, "function () {}")); - str = bson_as_json (&code, NULL); - ASSERT_CMPSTR (str, "{ \"c\" : { \"$code\" : \"function () {}\" } }"); - - bson_free (str); - bson_reinit (&code); - - /* empty scope */ - BSON_ASSERT ( - BSON_APPEND_CODE_WITH_SCOPE (&code, "c", "function () {}", &scope)); - str = bson_as_json (&code, NULL); - ASSERT_CMPSTR ( - str, "{ \"c\" : { \"$code\" : \"function () {}\", \"$scope\" : { } } }"); - - bson_free (str); - bson_reinit (&code); - - BSON_APPEND_INT32 (&scope, "x", 1); - BSON_ASSERT ( - BSON_APPEND_CODE_WITH_SCOPE (&code, "c", "function () {}", &scope)); - str = bson_as_json (&code, NULL); - ASSERT_CMPSTR (str, - "{ \"c\" : { \"$code\" : \"function () {}\", \"$scope\" " - ": { \"x\" : 1 } } }"); - - bson_free (str); - bson_reinit (&code); - - /* test that embedded quotes are backslash-escaped */ - BSON_ASSERT (BSON_APPEND_CODE (&code, "c", "return \"a\"")); - str = bson_as_json (&code, NULL); - - /* hard to read, this is { "c" : { "$code" : "return \"a\"" } } */ - ASSERT_CMPSTR (str, "{ \"c\" : { \"$code\" : \"return \\\"a\\\"\" } }"); - - bson_free (str); - bson_destroy (&code); - bson_destroy (&scope); -} - - -static void -test_bson_as_json_date_time (void) -{ - bson_t *b; - char *str; - size_t len; - - b = bson_new (); - BSON_ASSERT (bson_append_date_time (b, "epoch", -1, 0)); - BSON_ASSERT (bson_append_date_time (b, "negative", -1, -123456000)); - BSON_ASSERT (bson_append_date_time (b, "positive", -1, 123456000)); - str = bson_as_json (b, &len); - - ASSERT_CMPSTR (str, - "{" - " \"epoch\" : { \"$date\" : 0 }," - " \"negative\" : { \"$date\" : -123456000 }," - " \"positive\" : { \"$date\" : 123456000 } }"); - - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_regex (void) -{ - bson_t *b; - char *str; - size_t len; - - b = bson_new (); - BSON_ASSERT (bson_append_regex (b, "regex", -1, "^abcd", "xi")); - BSON_ASSERT (bson_append_regex (b, "escaping", -1, "^\"", "")); - BSON_ASSERT (bson_append_regex (b, "ordered", -1, "^abcd", "ilmsux")); - BSON_ASSERT (bson_append_regex (b, "unordered", -1, "^abcd", "xusmli")); - BSON_ASSERT (bson_append_regex (b, "duplicate", -1, "^abcd", "mmiii")); - BSON_ASSERT (bson_append_regex (b, "unsupported", -1, "^abcd", "jkmlvz")); - str = bson_as_json (b, &len); - - ASSERT_CMPSTR (str, - "{" - " \"regex\" : { \"$regex\" : \"^abcd\", \"$options\" " - ": \"ix\" }," - " \"escaping\" : { \"$regex\" : \"^\\\"\", \"$options\" " - ": \"\" }," - " \"ordered\" : { \"$regex\" : \"^abcd\", \"$options\" " - ": \"ilmsux\" }," - " \"unordered\" : { \"$regex\" : \"^abcd\", \"$options\" " - ": \"ilmsux\" }," - " \"duplicate\" : { \"$regex\" : \"^abcd\", \"$options\" " - ": \"im\" }," - " \"unsupported\" : { \"$regex\" : \"^abcd\", \"$options\" " - ": \"lm\" } }"); - - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_symbol (void) -{ - bson_t *b; - char *str; - size_t len; - - b = bson_new (); - BSON_ASSERT (bson_append_symbol (b, "symbol", -1, "foo", -1)); - BSON_ASSERT (bson_append_symbol (b, "escaping", -1, "\"bar\"", -1)); - str = bson_as_json (b, &len); - - ASSERT_CMPSTR (str, - "{" - " \"symbol\" : \"foo\"," - " \"escaping\" : \"\\\"bar\\\"\" }"); - - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_utf8 (void) -{ -/* euro currency symbol */ -#define EU "\xe2\x82\xac" -#define FIVE_EUROS EU EU EU EU EU - size_t len; - bson_t *b; - char *str; - - b = bson_new (); - BSON_ASSERT (bson_append_utf8 (b, FIVE_EUROS, -1, FIVE_EUROS, -1)); - str = bson_as_json (b, &len); - BSON_ASSERT (!strcmp (str, "{ \"" FIVE_EUROS "\" : \"" FIVE_EUROS "\" }")); - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_json_dbpointer (void) -{ - bson_oid_t oid; - bson_t *b; - char *str; - size_t len; - - bson_oid_init_from_string (&oid, "12341234123412abcdababcd"); - - b = bson_new (); - BSON_ASSERT (bson_append_dbpointer (b, "dbpointer", -1, "collection", &oid)); - BSON_ASSERT (bson_append_dbpointer (b, "escaping", -1, "\"coll\"", &oid)); - str = bson_as_json (b, &len); - - ASSERT_CMPSTR (str, - "{" - " \"dbpointer\" : { \"$ref\" : \"collection\", \"$id\" " - ": \"12341234123412abcdababcd\" }," - " \"escaping\" : { \"$ref\" : \"\\\"coll\\\"\", \"$id\" " - ": \"12341234123412abcdababcd\" } }"); - - bson_free (str); - bson_destroy (b); -} - - -static void -test_bson_as_canonical_extended_json_dbpointer (void) -{ - bson_oid_t oid; - bson_t *b; - size_t len; - char *str; - - bson_oid_init_from_string (&oid, "12341234123412abcdababcd"); - b = bson_new (); - BSON_ASSERT (BSON_APPEND_DBPOINTER (b, "p", "coll", &oid)); - str = bson_as_canonical_extended_json (b, &len); - ASSERT_CMPJSON (str, - "{ \"p\" : { \"$dbPointer\" : { \"$ref\" : " - "\"coll\", \"$id\" : { \"$oid\" : " - "\"12341234123412abcdababcd\" } } } }"); - - bson_destroy (b); -} - - -static void -test_bson_as_json_stack_overflow (void) -{ - uint8_t *buf; - bson_t b; - size_t buflen = 1024 * 1024 * 17; - char *str; - int fd; - ssize_t r; - - buf = bson_malloc0 (buflen); - - fd = bson_open (BSON_BINARY_DIR "/stackoverflow.bson", O_RDONLY); - BSON_ASSERT (-1 != fd); - - r = bson_read (fd, buf, buflen); - BSON_ASSERT (r == 16777220); - - r = bson_init_static (&b, buf, 16777220); - BSON_ASSERT (r); - - str = bson_as_json (&b, NULL); - BSON_ASSERT (str); - - r = !!strstr (str, "..."); - BSON_ASSERT (r); - - bson_free (str); - bson_destroy (&b); - bson_free (buf); -} - - -static void -test_bson_corrupt (void) -{ - uint8_t *buf; - bson_t b; - size_t buflen = 1024; - char *str; - int fd; - ssize_t r; - - buf = bson_malloc0 (buflen); - - fd = bson_open (BSON_BINARY_DIR "/test55.bson", O_RDONLY); - BSON_ASSERT (-1 != fd); - - r = bson_read (fd, buf, buflen); - BSON_ASSERT (r == 24); - - r = bson_init_static (&b, buf, (uint32_t) r); - BSON_ASSERT (r); - - str = bson_as_json (&b, NULL); - BSON_ASSERT (!str); - - bson_destroy (&b); - bson_free (buf); -} - -static void -test_bson_corrupt_utf8 (void) -{ - uint8_t *buf; - bson_t b; - size_t buflen = 1024; - char *str; - int fd; - ssize_t r; - - buf = bson_malloc0 (buflen); - - fd = bson_open (BSON_BINARY_DIR "/test56.bson", O_RDONLY); - BSON_ASSERT (-1 != fd); - - r = bson_read (fd, buf, buflen); - BSON_ASSERT (r == 42); - - r = bson_init_static (&b, buf, (uint32_t) r); - BSON_ASSERT (r); - - str = bson_as_json (&b, NULL); - BSON_ASSERT (!str); - - bson_destroy (&b); - bson_free (buf); -} - -static void -test_bson_corrupt_binary (void) -{ - uint8_t *buf; - bson_t b; - size_t buflen = 1024; - char *str; - int fd; - ssize_t r; - - buf = bson_malloc0 (buflen); - - fd = bson_open (BSON_BINARY_DIR "/test57.bson", O_RDONLY); - BSON_ASSERT (-1 != fd); - - r = bson_read (fd, buf, buflen); - BSON_ASSERT (r == 26); - - r = bson_init_static (&b, buf, (uint32_t) r); - BSON_ASSERT (r); - - str = bson_as_json (&b, NULL); - BSON_ASSERT (!str); - - bson_destroy (&b); - bson_free (buf); -} - -#if !defined(BSON_HAVE_RAND_R) && !defined(_WIN32) -static int -rand_r (unsigned int *seed) -{ - srand (*seed); - return rand (); -} -#endif - -#ifdef _WIN32 -#define RAND_R rand_s -#else -#define RAND_R rand_r -#endif - -static char * -rand_str (size_t maxlen, - unsigned int *seed /* IN / OUT */, - char *buf /* IN / OUT */) -{ - size_t len = RAND_R (seed) % (maxlen - 1); - size_t i; - - for (i = 0; i < len; i++) { - buf[i] = (char) ('a' + i % 26); - } - - buf[len] = '\0'; - return buf; -} - -/* test with random buffer sizes to ensure we parse whole keys and values when - * reads pause and resume in the middle of tokens */ -static void -test_bson_json_read_buffering (void) -{ - bson_t **bsons; - char *json_tmp; - bson_string_t *json; - bson_error_t error; - bson_t bson_out = BSON_INITIALIZER; - int i; - unsigned int seed = 42; - int n_docs, docs_idx; - int n_elems, elem_idx; - char key[25]; - char val[25]; - bson_json_reader_t *reader; - int r; - - json = bson_string_new (NULL); - - /* parse between 1 and 10 JSON objects */ - for (n_docs = 1; n_docs < 10; n_docs++) { - /* do 50 trials */ - for (i = 0; i < 50; i++) { - bsons = bson_malloc (n_docs * sizeof (bson_t *)); - for (docs_idx = 0; docs_idx < n_docs; docs_idx++) { - /* a BSON document with up to 10 strings and numbers */ - bsons[docs_idx] = bson_new (); - n_elems = RAND_R (&seed) % 5; - for (elem_idx = 0; elem_idx < n_elems; elem_idx++) { - bson_append_utf8 (bsons[docs_idx], - rand_str (sizeof key, &seed, key), - -1, - rand_str (sizeof val, &seed, val), - -1); - - bson_append_int32 (bsons[docs_idx], - rand_str (sizeof key, &seed, key), - -1, - RAND_R (&seed) % INT32_MAX); - } - - /* append the BSON document's JSON representation to "json" */ - json_tmp = bson_as_json (bsons[docs_idx], NULL); - BSON_ASSERT (json_tmp); - bson_string_append (json, json_tmp); - bson_free (json_tmp); - } - - reader = bson_json_data_reader_new ( - true /* "allow_multiple" is unused */, - (size_t) RAND_R (&seed) % 100 /* bufsize*/); - - bson_json_data_reader_ingest ( - reader, (uint8_t *) json->str, json->len); - - for (docs_idx = 0; docs_idx < n_docs; docs_idx++) { - bson_reinit (&bson_out); - r = bson_json_reader_read (reader, &bson_out, &error); - if (r == -1) { - fprintf (stderr, "%s\n", error.message); - abort (); - } - - BSON_ASSERT (r); - bson_eq_bson (&bson_out, bsons[docs_idx]); - } - - /* finished parsing */ - ASSERT_CMPINT ( - 0, ==, bson_json_reader_read (reader, &bson_out, &error)); - - bson_json_reader_destroy (reader); - bson_string_truncate (json, 0); - - for (docs_idx = 0; docs_idx < n_docs; docs_idx++) { - bson_destroy (bsons[docs_idx]); - } - - bson_free (bsons); - } - } - - bson_string_free (json, true); - bson_destroy (&bson_out); -} - -static void -_test_bson_json_read_compare (const char *json, int size, ...) -{ - bson_error_t error = {0}; - bson_json_reader_t *reader; - va_list ap; - int r; - bson_t *compare; - bson_t bson = BSON_INITIALIZER; - - reader = bson_json_data_reader_new ((size == 1), size); - bson_json_data_reader_ingest (reader, (uint8_t *) json, strlen (json)); - - va_start (ap, size); - - while ((r = bson_json_reader_read (reader, &bson, &error))) { - if (r == -1) { - fprintf (stderr, "%s\n", error.message); - abort (); - } - - compare = va_arg (ap, bson_t *); - - BSON_ASSERT (compare); - - bson_eq_bson (&bson, compare); - - bson_destroy (compare); - - bson_reinit (&bson); - } - - va_end (ap); - - bson_json_reader_destroy (reader); - bson_destroy (&bson); -} - -static void -test_bson_json_read (void) -{ - char *json = bson_strdup_printf ( - "%s { \"after\": \"b\" } { \"twice\" : true }", json_with_all_types ()); - - bson_oid_t oid; - bson_t *first, *second, *third; - - bson_oid_init_from_string (&oid, "000000000000000000000000"); - - first = bson_copy (bson_with_all_types ()); - second = BCON_NEW ("after", "b"); - third = BCON_NEW ("twice", BCON_BOOL (true)); - - _test_bson_json_read_compare (json, 5, first, second, third, NULL); - bson_free (json); -} - -static void -test_bson_json_read_invalid_base64 (void) -{ - const char *bad_json = "{ \"x\": { \"$binary\": {\"subType\": \"00\", " - "\"base64\": \"\x30\x30\x30\x30\xcd\x8d\x79\" }}}"; - bson_error_t error = {0}; - - BSON_ASSERT (!bson_new_from_json ((uint8_t *) bad_json, -1, &error)); - ASSERT_ERROR_CONTAINS ( - error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Invalid input string \"\x30\x30\x30\x30\xcd\x8d\x79\", looking for " - "base64-encoded binary"); -} - -static void -test_bson_json_read_raw_utf8 (void) -{ - bson_t *bson; - bson_iter_t iter; - - bson = bson_new_from_json ( - (const uint8_t *) "{\"" EU "\": \"" EU "\"}", -1, NULL); - ASSERT (bson); - ASSERT (bson_iter_init_find (&iter, bson, EU)); - ASSERT_CMPSTR (bson_iter_key (&iter), EU); - ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), EU); - ASSERT (!bson_iter_next (&iter)); - - bson_destroy (bson); -} - -static void -test_bson_json_read_corrupt_utf8 (void) -{ - const char *bad_key = "{ \"\x80\" : \"a\"}"; - const char *bad_value = "{ \"a\" : \"\x80\"}"; - bson_error_t error = {0}; - - BSON_ASSERT (!bson_new_from_json ((uint8_t *) bad_key, -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CORRUPT_JS, - "invalid bytes in UTF8 string"); - - memset (&error, 0, sizeof error); - - BSON_ASSERT (!bson_new_from_json ((uint8_t *) bad_value, -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CORRUPT_JS, - "invalid bytes in UTF8 string"); -} - - -/* exercise early exit from _bson_as_json_visit_document/array, CDRIVER-2541 */ -static void -test_bson_json_read_corrupt_document (void) -{ - /* like {a: {a: "\x80"}}, the value is invalid UTF-8 */ - const char bad_doc[] = "\x16\x00\x00\x00" /* length */ - "\x03\x61\x00" /* subdoc field with key "a" */ - "\x0e\x00\x00\x00" /* length of subdoc in bytes */ - "\x02\x61\x00\x02\x00\x00\x00\x80\x00" /* a: "\x80" */ - "\x00"; /* terminator */ - - /* like {a: ["\x80"]}, the inner value is invalid UTF-8 */ - const char bad_array[] = "\x16\x00\x00\x00" /* length */ - "\x04\x61\x00" /* array field with key "a" */ - "\x0e\x00\x00\x00" /* length of array in bytes */ - "\x02\x30\x00" /* key "0" */ - "\x02\x00\x00\x00\x80\x00" /* string "\x80" */ - "\x00"; /* terminator */ - - bson_t bson; - BSON_ASSERT ( - bson_init_static (&bson, (uint8_t *) bad_doc, sizeof (bad_doc))); - BSON_ASSERT (!bson_as_json (&bson, NULL)); - BSON_ASSERT ( - bson_init_static (&bson, (uint8_t *) bad_array, sizeof (bad_array))); - BSON_ASSERT (!bson_as_json (&bson, NULL)); -} - - -static void -test_bson_json_read_decimal128 (void) -{ - const char *json = "{ \"decimal\" : { \"$numberDecimal\" : \"123.5\" }}"; - bson_decimal128_t dec; - bson_t *doc; - - bson_decimal128_from_string ("123.5", &dec); - doc = BCON_NEW ("decimal", BCON_DECIMAL128 (&dec)); - - _test_bson_json_read_compare (json, 5, doc, NULL); -} - - -static void -test_bson_json_read_dbpointer (void) -{ - bson_t b; - bson_error_t error; - bool r; - - /* must have both $ref and $id, $id must be ObjectId */ - const char *invalid[] = { - "{\"p\": {\"$dbPointer\": {\"$ref\": \"db.collection\"}}", - "$dbPointer requires both $id and $ref", - - "{\"p\": {\"$dbPointer\": {\"$ref\": \"db.collection\", \"$id\": 1}}", - "$dbPointer.$id must be like {\"$oid\": ...\"}", - - "{\"p\": {\"$dbPointer\": {\"$id\": {" - "\"$oid\": \"57e193d7a9cc81b4027498b1\"}}}}", - "$dbPointer requires both $id and $ref", - - "{\"p\": {\"$dbPointer\": {}}}", - "Empty $dbPointer", - - NULL}; - - const char **p; - - for (p = invalid; *p; p += 2) { - r = bson_init_from_json (&b, *p, -1, &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS ( - error, BSON_ERROR_JSON, BSON_JSON_ERROR_READ_INVALID_PARAM, *(p + 1)); - } -} - - -static void -test_bson_json_read_legacy_regex (void) -{ - bson_t b; - bson_error_t error; - bool r; - const char *pattern; - const char *flags; - - r = bson_init_from_json ( - &b, "{\"a\": {\"$regex\": \"abc\", \"$options\": \"ix\"}}", -1, &error); - ASSERT_OR_PRINT (r, error); - BCON_EXTRACT (&b, "a", BCONE_REGEX (pattern, flags)); - ASSERT_CMPSTR (pattern, "abc"); - ASSERT_CMPSTR (flags, "ix"); - - bson_destroy (&b); - - r = bson_init_from_json (&b, "{\"a\": {\"$regex\": \"abc\"}}", -1, &error); - ASSERT_OR_PRINT (r, error); - BCON_EXTRACT (&b, "a", BCONE_REGEX (pattern, flags)); - ASSERT_CMPSTR (pattern, "abc"); - ASSERT_CMPSTR (flags, ""); - - bson_destroy (&b); - - r = bson_init_from_json (&b, "{\"a\": {\"$options\": \"ix\"}}", -1, &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Missing \"$regex\" after \"$options\""); -} - - -static void -test_bson_json_read_regex_options_order (void) -{ - bson_t b; - bson_error_t error; - bool r; - const char *pattern; - const char *flags; - - r = bson_init_from_json ( - &b, "{\"a\": {\"$regex\": \"\", \"$options\": \"ism\"}}", -1, &error); - ASSERT_OR_PRINT (r, error); - BCON_EXTRACT (&b, "a", BCONE_REGEX (pattern, flags)); - ASSERT_CMPSTR (flags, "ims"); - - bson_destroy (&b); - - r = bson_init_from_json ( - &b, "{\"a\": {\"$regex\": \"\", \"$options\": \"misl\"}}", -1, &error); - ASSERT_OR_PRINT (r, error); - BCON_EXTRACT (&b, "a", BCONE_REGEX (pattern, flags)); - ASSERT_CMPSTR (flags, "ilms"); - - bson_destroy (&b); -} - - -static void -test_bson_json_read_binary (void) -{ - bson_error_t error; - bson_t b; - bool r; - bson_subtype_t subtype; - uint32_t len; - const uint8_t *binary; - - r = bson_init_from_json ( - &b, - "{\"b\": {\"$binary\": {\"base64\": \"Zm9v\", \"subType\": \"05\"}}}", - -1, - &error); - ASSERT_OR_PRINT (r, error); - - BCON_EXTRACT (&b, "b", BCONE_BIN (subtype, binary, len)); - ASSERT_CMPINT ((int) subtype, ==, 5); - ASSERT_CMPUINT32 (len, ==, (uint32_t) 3); - ASSERT_CMPSTR ((const char *) binary, "foo"); - - bson_destroy (&b); - - r = bson_init_from_json ( - &b, - "{\"b\": {\"$binary\": {\"subType\": \"05\", \"base64\": \"Zm9v\"}}}", - -1, - &error); - ASSERT_OR_PRINT (r, error); - BCON_EXTRACT (&b, "b", BCONE_BIN (subtype, binary, len)); - ASSERT_CMPINT ((int) subtype, ==, 5); - ASSERT_CMPUINT32 (len, ==, (uint32_t) 3); - ASSERT_CMPSTR ((const char *) binary, "foo"); - - bson_destroy (&b); - - /* no base64 */ - r = bson_init_from_json ( - &b, "{\"b\": {\"$binary\": {\"subType\": \"5\"}}}", -1, &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Missing \"base64\" after \"subType\""); - - memset (&error, 0, sizeof error); - - /* no subType */ - r = bson_init_from_json ( - &b, "{\"b\": {\"$binary\": {\"base64\": \"Zm9v\"}}}", -1, &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Missing \"subType\" after \"base64\""); -} - - -static void -test_bson_json_read_legacy_binary (void) -{ - const char *jsons[] = {"{\"x\": {\"$binary\": \"Zm9v\", \"$type\": \"05\"}}", - "{\"x\": {\"$type\": \"05\", \"$binary\": \"Zm9v\"}}", - NULL}; - - const char **json; - bson_error_t error; - bson_t b; - bool r; - bson_subtype_t subtype; - uint32_t len; - const uint8_t *binary; - - for (json = jsons; *json; json++) { - r = bson_init_from_json (&b, *json, -1, &error); - - ASSERT_OR_PRINT (r, error); - BCON_EXTRACT (&b, "x", BCONE_BIN (subtype, binary, len)); - ASSERT_CMPINT ((int) subtype, ==, 5); - ASSERT_CMPUINT32 (len, ==, (uint32_t) 3); - ASSERT_CMPSTR ((const char *) binary, "foo"); - - bson_destroy (&b); - } -} - - -static void -test_json_reader_new_from_file (void) -{ - const char *path = BSON_JSON_DIR "/test.json"; - const char *bar; - const bson_oid_t *oid; - bson_oid_t oid_expected; - int32_t one; - bson_t bson = BSON_INITIALIZER; - bson_json_reader_t *reader; - bson_error_t error; - - reader = bson_json_reader_new_from_file (path, &error); - BSON_ASSERT (reader); - - /* read two documents */ - ASSERT_CMPINT (1, ==, bson_json_reader_read (reader, &bson, &error)); - - BCON_EXTRACT (&bson, "foo", BCONE_UTF8 (bar), "a", BCONE_INT32 (one)); - ASSERT_CMPSTR ("bar", bar); - ASSERT_CMPINT (1, ==, one); - - bson_reinit (&bson); - ASSERT_CMPINT (1, ==, bson_json_reader_read (reader, &bson, &error)); - - BCON_EXTRACT (&bson, "_id", BCONE_OID (oid)); - bson_oid_init_from_string (&oid_expected, "aabbccddeeff001122334455"); - BSON_ASSERT (bson_oid_equal (&oid_expected, oid)); - - bson_destroy (&bson); - bson_json_reader_destroy (reader); -} - -static void -test_json_reader_new_from_bad_path (void) -{ - const char *bad_path = BSON_JSON_DIR "/does-not-exist"; - bson_json_reader_t *reader; - bson_error_t error; - - reader = bson_json_reader_new_from_file (bad_path, &error); - BSON_ASSERT (!reader); - ASSERT_CMPINT (BSON_ERROR_READER, ==, error.domain); - ASSERT_CMPINT (BSON_ERROR_READER_BADFD, ==, error.code); -} - -static void -test_bson_json_error (const char *json, int domain, bson_json_error_code_t code) -{ - bson_error_t error; - bson_t *bson; - - bson = bson_new_from_json ((const uint8_t *) json, strlen (json), &error); - - BSON_ASSERT (!bson); - BSON_ASSERT (error.domain == domain); - BSON_ASSERT (error.code == code); -} - -static void -test_bson_json_read_empty (void) -{ - bson_error_t error; - bson_t *bson_ptr; - bson_t bson; - - bson_ptr = bson_new_from_json ((uint8_t *) "", 0, &error); - BSON_ASSERT (!bson_ptr); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Empty JSON string"); - - memset (&error, 0, sizeof error); - bson_init_from_json (&bson, "", 0, &error); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Empty JSON string"); -} - -static void -test_bson_json_read_missing_complex (void) -{ - const char *json = "{ \n\ - \"foo\" : { \n\ - \"$options\" : \"ism\"\n\ - }\n\ - }"; - - test_bson_json_error ( - json, BSON_ERROR_JSON, BSON_JSON_ERROR_READ_INVALID_PARAM); -} - -static void -test_bson_json_read_invalid_binary (void) -{ - bson_error_t error; - const char *json = - "{ " - " \"bin\" : { \"$binary\" : \"invalid\", \"$type\" : \"80\" } }"; - bson_t b; - bool r; - - r = bson_init_from_json (&b, json, -1, &error); - BSON_ASSERT (!r); -} - -static void -test_bson_json_read_invalid_json (void) -{ - const char *json = "{ \n\ - \"foo\" : { \n\ - }"; - bson_t *b; - - test_bson_json_error ( - json, BSON_ERROR_JSON, BSON_JSON_ERROR_READ_CORRUPT_JS); - - b = bson_new_from_json ((uint8_t *) "1", 1, NULL); - BSON_ASSERT (!b); - - b = bson_new_from_json ((uint8_t *) "*", 1, NULL); - BSON_ASSERT (!b); - - b = bson_new_from_json ((uint8_t *) "", 0, NULL); - BSON_ASSERT (!b); - - b = bson_new_from_json ((uint8_t *) "asdfasdf", -1, NULL); - BSON_ASSERT (!b); - - b = bson_new_from_json ((uint8_t *) "{\"a\":*}", -1, NULL); - BSON_ASSERT (!b); -} - -static ssize_t -test_bson_json_read_bad_cb_helper (void *_ctx, uint8_t *buf, size_t len) -{ - BSON_UNUSED (_ctx); - BSON_UNUSED (buf); - BSON_UNUSED (len); - - return -1; -} - -static void -test_bson_json_read_bad_cb (void) -{ - bson_error_t error; - bson_json_reader_t *reader; - int r; - bson_t bson = BSON_INITIALIZER; - - reader = bson_json_reader_new ( - NULL, &test_bson_json_read_bad_cb_helper, NULL, false, 0); - - r = bson_json_reader_read (reader, &bson, &error); - - BSON_ASSERT (r == -1); - BSON_ASSERT (error.domain == BSON_ERROR_JSON); - BSON_ASSERT (error.code == BSON_JSON_ERROR_READ_CB_FAILURE); - - bson_json_reader_destroy (reader); - bson_destroy (&bson); -} - -static ssize_t -test_bson_json_read_invalid_helper (void *ctx, uint8_t *buf, size_t len) -{ - BSON_UNUSED (ctx); - BSON_ASSERT (len); - *buf = 0x80; /* no UTF-8 sequence can start with 0x80 */ - return 1; -} - -static void -test_bson_json_read_invalid (void) -{ - bson_error_t error; - bson_json_reader_t *reader; - int r; - bson_t bson = BSON_INITIALIZER; - - reader = bson_json_reader_new ( - NULL, test_bson_json_read_invalid_helper, NULL, false, 0); - - r = bson_json_reader_read (reader, &bson, &error); - - BSON_ASSERT (r == -1); - BSON_ASSERT (error.domain == BSON_ERROR_JSON); - BSON_ASSERT (error.code == BSON_JSON_ERROR_READ_CORRUPT_JS); - - bson_json_reader_destroy (reader); - bson_destroy (&bson); -} - -static void -test_bson_json_number_long (void) -{ - bson_error_t error; - bson_iter_t iter; - bson_t b; - bool r; - - r = bson_init_from_json ( - &b, "{\"key\": {\"$numberLong\": \"4611686018427387904\"}}", -1, &error); - if (!r) - fprintf (stderr, "%s\n", error.message); - BSON_ASSERT (r); - BSON_ASSERT (bson_iter_init (&iter, &b)); - BSON_ASSERT (bson_iter_find (&iter, "key")); - BSON_ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - BSON_ASSERT (bson_iter_int64 (&iter) == 4611686018427387904LL); - bson_destroy (&b); - - BSON_ASSERT (!bson_init_from_json ( - &b, "{\"key\": {\"$numberLong\": \"461168601abcd\"}}", -1, &error)); - BSON_ASSERT (!bson_init_from_json ( - &b, "{\"key\": {\"$numberLong\": \"461168601abcd\"}}", -1, &error)); - - /* INT64_MAX */ - r = bson_init_from_json ( - &b, "{\"x\": {\"$numberLong\": \"9223372036854775807\"}}", -1, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - ASSERT_CMPINT64 (bson_iter_int64 (&iter), ==, (int64_t) INT64_MAX); - bson_destroy (&b); - - /* INT64_MIN */ - r = bson_init_from_json ( - &b, "{\"x\": {\"$numberLong\": \"-9223372036854775808\"}}", -1, &error); - ASSERT_OR_PRINT (r, error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - ASSERT_CMPINT64 (bson_iter_int64 (&iter), ==, (int64_t) INT64_MIN); - bson_destroy (&b); - - /* INT64_MAX + 1 */ - r = bson_init_from_json ( - &b, "{\"x\": {\"$numberLong\": \"9223372036854775808\"}}", -1, &error); - - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Number \"9223372036854775808\" is out of range"); - - memset (&error, 0, sizeof error); - - /* INT64_MIN - 1 */ - r = bson_init_from_json ( - &b, "{\"x\": {\"$numberLong\": \"-9223372036854775809\"}}", -1, &error); - - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Number \"-9223372036854775809\" is out of range"); - - memset (&error, 0, sizeof error); - - r = bson_init_from_json ( - &b, "{\"x\": {\"$numberLong\": \"10000000000000000000\"}}", -1, &error); - - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Number \"10000000000000000000\" is out of range"); - - memset (&error, 0, sizeof error); - - /* INT64_MIN - 2 */ - r = bson_init_from_json (&b, "{\"x\": -10000000000000000000}", -1, &error); - - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Number \"-10000000000000000000\" is out of range"); -} - -static void -test_bson_json_number_long_zero (void) -{ - bson_error_t error; - bson_iter_t iter; - const char *json = "{ \"key\": { \"$numberLong\": \"0\" }}"; - bson_t b; - bool r; - - r = bson_init_from_json (&b, json, -1, &error); - if (!r) - fprintf (stderr, "%s\n", error.message); - BSON_ASSERT (r); - BSON_ASSERT (bson_iter_init (&iter, &b)); - BSON_ASSERT (bson_iter_find (&iter, "key")); - BSON_ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - BSON_ASSERT (bson_iter_int64 (&iter) == 0); - bson_destroy (&b); -} - -static void -test_bson_json_code (void) -{ - const char *json_code = "{\"a\": {\"$code\": \"b\"}}"; - bson_t *bson_code = BCON_NEW ("a", BCON_CODE ("b")); - - const char *json_code_w_nulls = "{\"a\": {\"$code\": \"b\\u0000c\\u0000\"}}"; - bson_t *bson_code_w_nulls = BCON_NEW ("a", BCON_CODE ("b\0c\0")); - - const char *json_code_w_scope = "{\"a\": {\"$code\": \"b\", " - " \"$scope\": {\"var\": 1}}}"; - bson_t *scope1 = BCON_NEW ("var", BCON_INT32 (1)); - bson_t *bson_code_w_scope = BCON_NEW ("a", BCON_CODEWSCOPE ("b", scope1)); - - const char *json_code_w_scope_special = - "{\"a\": {\"$code\": \"b\", " - " \"$scope\": {\"var2\": {\"$numberLong\": \"2\"}}}}"; - bson_t *scope2 = BCON_NEW ("var2", BCON_INT64 (2)); - bson_t *bson_code_w_scope_special = - BCON_NEW ("a", BCON_CODEWSCOPE ("b", scope2)); - - const char *json_2_codes_w_scope = - "{\"a\": {\"$code\": \"b\", " - " \"$scope\": {\"var\": 1}}," - " \"c\": {\"$code\": \"d\", " - " \"$scope\": {\"var2\": {\"$numberLong\": \"2\"}}}}"; - bson_t *bson_2_codes_w_scope = BCON_NEW ( - "a", BCON_CODEWSCOPE ("b", scope1), "c", BCON_CODEWSCOPE ("d", scope2)); - - const char *json_code_then_regular = - "{\"a\": {\"$code\": \"b\", " - " \"$scope\": {\"var\": 1}}," - " \"c\": {\"key1\": \"value\", " - " \"subdoc\": {\"key2\": \"value2\"}}}"; - - bson_t *bson_code_then_regular = BCON_NEW ("a", - BCON_CODEWSCOPE ("b", scope1), - "c", - "{", - "key1", - BCON_UTF8 ("value"), - "subdoc", - "{", - "key2", - BCON_UTF8 ("value2"), - "}", - "}"); - - const char *json_code_w_scope_reverse = "{\"a\": {\"$scope\": {\"var\": 1}, " - " \"$code\": \"b\"}}"; - bson_t *bson_code_w_scope_reverse = - BCON_NEW ("a", BCON_CODEWSCOPE ("b", scope1)); - - const char *json_code_w_scope_nest = "{\"a\": {\"$code\": \"b\", " - " \"$scope\": {\"var\": {}}}}"; - bson_t *scope3 = BCON_NEW ("var", "{", "}"); - bson_t *bson_code_w_scope_nest = - BCON_NEW ("a", BCON_CODEWSCOPE ("b", scope3)); - - const char *json_code_w_scope_nest_deep = - "{\"a\": {\"$code\": \"b\", " - " \"$scope\": {\"arr\": [1, 2], \"d\": {}," - " \"n\": {\"$numberLong\": \"1\"}," - " \"d2\": {\"x\": 1, \"d3\": {\"z\": 3}}}}}"; - - bson_t *scope_deep = BCON_NEW ("arr", - "[", - BCON_INT32 (1), - BCON_INT32 (2), - "]", - "d", - "{", - "}", - "n", - BCON_INT64 (1), - "d2", - "{", - "x", - BCON_INT32 (1), - "d3", - "{", - "z", - BCON_INT32 (3), - "}", - "}"); - - bson_t *bson_code_w_scope_nest_deep = - BCON_NEW ("a", BCON_CODEWSCOPE ("b", scope_deep)); - - const char *json_code_w_empty_scope = "{\"a\": {\"$code\": \"b\", " - " \"$scope\": {}}}"; - bson_t *empty = bson_new (); - bson_t *bson_code_w_empty_scope = - BCON_NEW ("a", BCON_CODEWSCOPE ("b", empty)); - - const char *json_code_in_scope = - "{\"a\": {\"$code\": \"b\", " - " \"$scope\": {\"x\": {\"$code\": \"c\"}}}}"; - - bson_t *code_in_scope = BCON_NEW ("x", "{", "$code", BCON_UTF8 ("c"), "}"); - bson_t *bson_code_in_scope = - BCON_NEW ("a", BCON_CODEWSCOPE ("b", code_in_scope)); - - typedef struct { - const char *json; - bson_t *expected_bson; - } code_test_t; - - code_test_t tests[] = { - {json_code, bson_code}, - {json_code_w_nulls, bson_code_w_nulls}, - {json_code_w_scope, bson_code_w_scope}, - {json_code_w_scope_special, bson_code_w_scope_special}, - {json_code_then_regular, bson_code_then_regular}, - {json_2_codes_w_scope, bson_2_codes_w_scope}, - {json_code_w_scope_reverse, bson_code_w_scope_reverse}, - {json_code_w_scope_nest, bson_code_w_scope_nest}, - {json_code_w_scope_nest_deep, bson_code_w_scope_nest_deep}, - {json_code_w_empty_scope, bson_code_w_empty_scope}, - {json_code_in_scope, bson_code_in_scope}, - }; - - int n_tests = sizeof (tests) / sizeof (code_test_t); - int i; - bson_t b; - bool r; - bson_error_t error; - - for (i = 0; i < n_tests; i++) { - r = bson_init_from_json (&b, tests[i].json, -1, &error); - if (!r) { - fprintf (stderr, "%s\n", error.message); - } - - BSON_ASSERT (r); - bson_eq_bson (&b, tests[i].expected_bson); - bson_destroy (&b); - } - - for (i = 0; i < n_tests; i++) { - bson_destroy (tests[i].expected_bson); - } - - bson_destroy (scope1); - bson_destroy (scope2); - bson_destroy (scope3); - bson_destroy (scope_deep); - bson_destroy (code_in_scope); - bson_destroy (empty); -} - -static void -test_bson_json_code_errors (void) -{ - bson_error_t error; - bson_t b; - bool r; - size_t i; - - typedef struct { - const char *json; - const char *error_message; - } code_error_test_t; - - code_error_test_t tests[] = { - {"{\"a\": {\"$scope\": {}}", "Missing $code after $scope"}, - {"{\"a\": {\"$scope\": {}, \"$x\": 1}", "Invalid key \"$x\""}, - {"{\"a\": {\"$scope\": {\"a\": 1}}", "Missing $code after $scope"}, - {"{\"a\": {\"$code\": \"\", \"$scope\": \"a\"}}", - "Invalid read of \"a\""}, - {"{\"a\": {\"$code\": \"\", \"$scope\": 1}}", - "Unexpected integer 1 in state \"IN_BSON_TYPE_SCOPE_STARTMAP\""}, - {"{\"a\": {\"$code\": \"\", \"$scope\": []}}", "Invalid read of \"[\""}, - {"{\"a\": {\"$code\": \"\", \"x\": 1}}", - "Invalid key \"x\". Looking for values for type \"code\""}, - {"{\"a\": {\"$code\": \"\", \"$x\": 1}}", "Invalid key \"$x\""}, - {"{\"a\": {\"$code\": \"\", \"$numberLong\": \"1\"}}", - "Invalid key \"$numberLong\""}, - }; - - for (i = 0; i < sizeof (tests) / (sizeof (code_error_test_t)); i++) { - r = bson_init_from_json (&b, tests[i].json, -1, &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - tests[i].error_message); - } -} - -static const bson_oid_t * -oid_zero (void) -{ - static bool initialized = false; - static bson_oid_t oid; - - if (!initialized) { - bson_oid_init_from_string (&oid, "000000000000000000000000"); - initialized = true; - } - - return &oid; -} - -static void -test_bson_json_dbref (void) -{ - bson_error_t error; - - const char *json_with_objectid_id = - "{ \"key\": {" - "\"$ref\": \"collection\"," - "\"$id\": {\"$oid\": \"000000000000000000000000\"}}}"; - - bson_t *bson_with_objectid_id = BCON_NEW ("key", - "{", - "$ref", - BCON_UTF8 ("collection"), - "$id", - BCON_OID (oid_zero ()), - "}"); - - const char *json_with_int_id = "{ \"key\": {" - "\"$ref\": \"collection\"," - "\"$id\": 1}}"; - - bson_t *bson_with_int_id = BCON_NEW ( - "key", "{", "$ref", BCON_UTF8 ("collection"), "$id", BCON_INT32 (1), "}"); - - const char *json_with_subdoc_id = "{ \"key\": {" - "\"$ref\": \"collection\"," - "\"$id\": {\"a\": 1}}}"; - - bson_t *bson_with_subdoc_id = BCON_NEW ("key", - "{", - "$ref", - BCON_UTF8 ("collection"), - "$id", - "{", - "a", - BCON_INT32 (1), - "}", - "}"); - - const char *json_with_metadata = "{ \"key\": {" - "\"$ref\": \"collection\"," - "\"$id\": 1," - "\"meta\": true}}"; - - bson_t *bson_with_metadata = BCON_NEW ("key", - "{", - "$ref", - BCON_UTF8 ("collection"), - "$id", - BCON_INT32 (1), - "meta", - BCON_BOOL (true), - "}"); - - const char *json_with_db = "{ \"key\": {" - "\"$ref\": \"collection\"," - "\"$id\": 1," - "\"$db\": \"database\"}}"; - - bson_t *bson_with_db = BCON_NEW ("key", - "{", - "$ref", - BCON_UTF8 ("collection"), - "$id", - BCON_INT32 (1), - "$db", - BCON_UTF8 ("database"), - "}"); - - /* Note: the following examples are not valid DBRefs but are intended to test - * that the Extended JSON parser leaves such documents as-is. */ - const char *json_with_missing_ref = "{\"key\": {\"$id\": 1}}"; - - bson_t *bson_with_missing_ref = - BCON_NEW ("key", "{", "$id", BCON_INT32 (1), "}"); - - const char *json_with_missing_id = "{\"key\": {\"$ref\": \"collection\"}}"; - - bson_t *bson_with_missing_id = - BCON_NEW ("key", "{", "$ref", BCON_UTF8 ("collection"), "}"); - - const char *json_with_int_ref = "{\"key\": {\"$ref\": 1, \"$id\": 1}}"; - - bson_t *bson_with_int_ref = - BCON_NEW ("key", "{", "$ref", BCON_INT32 (1), "$id", BCON_INT32 (1), "}"); - - const char *json_with_int_db = "{ \"key\": {" - "\"$ref\": \"collection\"," - "\"$id\": 1," - "\"$db\": 1}}"; - - bson_t *bson_with_int_db = BCON_NEW ("key", - "{", - "$ref", - BCON_UTF8 ("collection"), - "$id", - BCON_INT32 (1), - "$db", - BCON_INT32 (1), - "}"); - - bson_t b; - bool r; - - typedef struct { - const char *json; - bson_t *expected_bson; - } dbref_test_t; - - dbref_test_t tests[] = { - {json_with_objectid_id, bson_with_objectid_id}, - {json_with_int_id, bson_with_int_id}, - {json_with_subdoc_id, bson_with_subdoc_id}, - {json_with_metadata, bson_with_metadata}, - {json_with_db, bson_with_db}, - {json_with_missing_ref, bson_with_missing_ref}, - {json_with_missing_id, bson_with_missing_id}, - {json_with_int_ref, bson_with_int_ref}, - {json_with_int_db, bson_with_int_db}, - }; - - int n_tests = sizeof (tests) / sizeof (dbref_test_t); - int i; - - for (i = 0; i < n_tests; i++) { - r = bson_init_from_json (&b, tests[i].json, -1, &error); - if (!r) { - fprintf (stderr, "%s\n", error.message); - } - - BSON_ASSERT (r); - bson_eq_bson (&b, tests[i].expected_bson); - bson_destroy (&b); - } - - for (i = 0; i < n_tests; i++) { - bson_destroy (tests[i].expected_bson); - } -} - -static void -test_bson_json_uescape (void) -{ - bson_error_t error; - bson_t b; - bool r; - - const char *euro = "{ \"euro\": \"\\u20AC\"}"; - bson_t *bson_euro = BCON_NEW ("euro", BCON_UTF8 ("\xE2\x82\xAC")); - - const char *crlf = "{ \"crlf\": \"\\r\\n\"}"; - bson_t *bson_crlf = BCON_NEW ("crlf", BCON_UTF8 ("\r\n")); - - const char *quote = "{ \"quote\": \"\\\"\"}"; - bson_t *bson_quote = BCON_NEW ("quote", BCON_UTF8 ("\"")); - - const char *backslash = "{ \"backslash\": \"\\\\\"}"; - bson_t *bson_backslash = BCON_NEW ("backslash", BCON_UTF8 ("\\")); - - const char *empty = "{ \"\": \"\"}"; - bson_t *bson_empty = BCON_NEW ("", BCON_UTF8 ("")); - - const char *escapes = "{ \"escapes\": \"\\f\\b\\t\"}"; - bson_t *bson_escapes = BCON_NEW ("escapes", BCON_UTF8 ("\f\b\t")); - - const char *nil_byte = "{ \"nil\": \"\\u0000\"}"; - bson_t *bson_nil_byte = bson_new (); /* we'll append "\0" to it, below */ - - typedef struct { - const char *json; - bson_t *expected_bson; - } uencode_test_t; - - uencode_test_t tests[] = { - {euro, bson_euro}, - {crlf, bson_crlf}, - {quote, bson_quote}, - {backslash, bson_backslash}, - {empty, bson_empty}, - {escapes, bson_escapes}, - {nil_byte, bson_nil_byte}, - }; - - int n_tests = sizeof (tests) / sizeof (uencode_test_t); - int i; - - bson_append_utf8 (bson_nil_byte, "nil", -1, "\0", 1); - - for (i = 0; i < n_tests; i++) { - r = bson_init_from_json (&b, tests[i].json, -1, &error); - - if (!r) { - fprintf (stderr, "%s\n", error.message); - } - - BSON_ASSERT (r); - bson_eq_bson (&b, tests[i].expected_bson); - bson_destroy (&b); - } - - for (i = 0; i < n_tests; i++) { - bson_destroy (tests[i].expected_bson); - } -} - -static void -test_bson_json_uescape_key (void) -{ - bson_error_t error; - bson_t b; - bool r; - - bson_t *bson_euro = BCON_NEW ("\xE2\x82\xAC", BCON_UTF8 ("euro")); - - r = bson_init_from_json (&b, "{ \"\\u20AC\": \"euro\"}", -1, &error); - BSON_ASSERT (r); - bson_eq_bson (&b, bson_euro); - - bson_destroy (&b); - bson_destroy (bson_euro); -} - -static void -test_bson_json_uescape_bad (void) -{ - bson_error_t error; - bson_t b; - bool r; - - r = bson_init_from_json (&b, "{ \"bad\": \"\\u1\"}", -1, &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CORRUPT_JS, - "UESCAPE_TOOSHORT"); -} - - -static void -test_bson_json_int32 (void) -{ - bson_t b; - bson_iter_t iter; - bson_error_t error; - - /* INT32_MAX */ - ASSERT_OR_PRINT ( - bson_init_from_json (&b, "{ \"x\": 2147483647 }", -1, &error), error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_INT32 (&iter)); - ASSERT_CMPINT32 (bson_iter_int32 (&iter), ==, (int32_t) 2147483647LL); - bson_destroy (&b); - - /* INT32_MIN */ - ASSERT_OR_PRINT ( - bson_init_from_json (&b, "{ \"x\": -2147483648 }", -1, &error), error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_INT32 (&iter)); - ASSERT_CMPINT32 (bson_iter_int32 (&iter), ==, (int32_t) -2147483648LL); - bson_destroy (&b); - - /* INT32_MAX + 1 */ - ASSERT_OR_PRINT ( - bson_init_from_json (&b, "{ \"x\": 2147483648 }", -1, &error), error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - ASSERT_CMPINT64 (bson_iter_int64 (&iter), ==, (int64_t) 2147483648LL); - bson_destroy (&b); - - /* INT32_MIN - 1 */ - ASSERT_OR_PRINT ( - bson_init_from_json (&b, "{ \"x\": -2147483649 }", -1, &error), error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - ASSERT_CMPINT64 (bson_iter_int64 (&iter), ==, (int64_t) -2147483649LL); - bson_destroy (&b); -} - - -static void -test_bson_json_int64 (void) -{ - bson_t b; - bson_iter_t iter; - bson_error_t error; - - /* INT64_MAX */ - ASSERT_OR_PRINT ( - bson_init_from_json (&b, "{ \"x\": 9223372036854775807 }", -1, &error), - error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - ASSERT_CMPINT64 ( - bson_iter_int64 (&iter), ==, (int64_t) 9223372036854775807LL); - bson_destroy (&b); - - /* INT64_MIN */ - ASSERT_OR_PRINT ( - bson_init_from_json (&b, "{ \"x\": -9223372036854775808 }", -1, &error), - error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - ASSERT_CMPINT64 (bson_iter_int64 (&iter), ==, (int64_t) INT64_MIN); - bson_destroy (&b); - - /* INT64_MAX + 1 */ - BSON_ASSERT ( - !bson_init_from_json (&b, "{ \"x\": 9223372036854775808 }", -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Number \"9223372036854775808\" is out of range"); - - memset (&error, 0, sizeof error); - - /* INT64_MIN - 1 */ - BSON_ASSERT ( - !bson_init_from_json (&b, "{ \"x\": -9223372036854775809 }", -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Number \"-9223372036854775809\" is out of range"); - - memset (&error, 0, sizeof error); - - BSON_ASSERT ( - !bson_init_from_json (&b, "{ \"x\": 10000000000000000000 }", -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Number \"10000000000000000000\" is out of range"); - - memset (&error, 0, sizeof error); - - /* INT64_MIN - 2 */ - BSON_ASSERT (!bson_init_from_json ( - &b, "{ \"x\": -10000000000000000000 }", -1, &error)); - - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Number \"-10000000000000000000\" is out of range"); -} - - -static void -test_bson_json_double (void) -{ - bson_t b; - bson_error_t error; - bson_iter_t iter; - - ASSERT_OR_PRINT (bson_init_from_json (&b, "{ \"x\": 1 }", -1, &error), - error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_INT32 (&iter)); - ASSERT_CMPINT32 (bson_iter_int32 (&iter), ==, (int32_t) 1); - bson_destroy (&b); - - ASSERT_OR_PRINT ( - bson_init_from_json (&b, "{ \"x\": 4294967296 }", -1, &error), error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - ASSERT_CMPINT64 (bson_iter_int64 (&iter), ==, (int64_t) 4294967296); - bson_destroy (&b); - - ASSERT_OR_PRINT (bson_init_from_json (&b, "{ \"x\": 1.0 }", -1, &error), - error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_DOUBLE (&iter)); - ASSERT_CMPDOUBLE (bson_iter_double (&iter), ==, 1.0); - bson_destroy (&b); - - ASSERT_OR_PRINT (bson_init_from_json (&b, "{ \"x\": 0.0 }", -1, &error), - error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_DOUBLE (&iter)); - ASSERT_CMPDOUBLE (bson_iter_double (&iter), ==, 0.0); - bson_destroy (&b); - - ASSERT_OR_PRINT (bson_init_from_json (&b, "{ \"x\": -0.0 }", -1, &error), - error); - - BSON_ASSERT (bson_iter_init_find (&iter, &b, "x")); - BSON_ASSERT (BSON_ITER_HOLDS_DOUBLE (&iter)); - ASSERT_CMPDOUBLE (bson_iter_double (&iter), ==, 0.0); - -/* check that "x" is -0.0. signbit not available on Solaris, FreeBSD, or VS 2010 - */ -#if !defined(__sun) && !defined(__FreeBSD__) && \ - (!defined(_MSC_VER) || (_MSC_VER >= 1800)) - BSON_ASSERT (signbit (bson_iter_double (&iter))); -#endif - - bson_destroy (&b); -} - - -static void -test_bson_json_double_overflow (void) -{ - const char *nums[] = {"2e400", "-2e400", NULL}; - const char **p; - char *j; - bson_error_t error; - bson_t b; - - for (p = nums; *p; p++) { - j = bson_strdup_printf ("{ \"d\" : %s }", *p); - BSON_ASSERT (!bson_init_from_json (&b, j, -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "out of range"); - - bson_free (j); - memset (&error, 0, sizeof error); - - /* same test with canonical Extended JSON */ - j = bson_strdup_printf ("{ \"d\" : { \"$numberDouble\" : \"%s\" } }", *p); - BSON_ASSERT (!bson_init_from_json (&b, j, -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "out of range"); - - bson_free (j); - } -} - - -static void -test_bson_json_nan (void) -{ - bson_error_t error; - bson_t b; - double d; - - /* should parse any capitalization of NaN */ - const char *jsons[] = {"{ \"d\": NaN }", - "{ \"d\": nAn }", - "{ \"d\": {\"$numberDouble\": \"NaN\" } }", - "{ \"d\": {\"$numberDouble\": \"nAn\" } }", - NULL}; - - /* test our patch to JSONSL that updates its state while parsing "n..." */ - const char *bad[] = {"{ \"d\": NaNn }", - "{ \"d\": nul }", - "{ \"d\": nulll }", - "{ \"d\": nulll }", - "{ \"d\": foo }", - "{ \"d\": NULL }", - "{ \"d\": nall }", - NULL}; - - const char *partial[] = {"{ \"d\": nu", "{ \"d\": na", "{ \"d\": n", NULL}; - const char **j; - - for (j = jsons; *j; j++) { - BSON_ASSERT (bson_init_from_json (&b, *j, -1, &error)); - BSON_ASSERT (BCON_EXTRACT (&b, "d", BCONE_DOUBLE (d))); - BSON_ASSERT (d != d); - bson_destroy (&b); - } - - for (j = bad; *j; j++) { - BSON_ASSERT (!bson_init_from_json (&b, *j, -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CORRUPT_JS, - "Got parse error at"); - memset (&error, 0, sizeof error); - } - - for (j = partial; *j; j++) { - BSON_ASSERT (!bson_init_from_json (&b, *j, -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CORRUPT_JS, - "Incomplete JSON"); - memset (&error, 0, sizeof error); - } -} - -static void -test_bson_json_infinity (void) -{ - bson_error_t error; - bson_t b; - double d; - - /* should parse any capitalization of Infinity */ - const char *infs[] = {"{ \"d\": Infinity }", - "{ \"d\": infinity }", - "{ \"d\": inFINIty }", - NULL}; - - const char *negs[] = {"{ \"d\": -Infinity }", - "{ \"d\": -infinity }", - "{ \"d\": -inFINIty }", - NULL}; - - const char *bad[] = {"{ \"d\": Infinityy }", - "{ \"d\": Infinit }", - "{ \"d\": -Infinityy }", - "{ \"d\": -Infinit }", - "{ \"d\": infinityy }", - "{ \"d\": infinit }", - "{ \"d\": -infinityy }", - "{ \"d\": -infinit }", - NULL}; - - const char *partial[] = {"{ \"d\": In", "{ \"d\": I", "{ \"d\": i", NULL}; - const char **j; - - for (j = infs; *j; j++) { - BSON_ASSERT (bson_init_from_json (&b, *j, -1, &error)); - BSON_ASSERT (BCON_EXTRACT (&b, "d", BCONE_DOUBLE (d))); - /* Infinite */ - BSON_ASSERT (d == d && ((d - d) != (d - d))); - bson_destroy (&b); - } - - for (j = negs; *j; j++) { - BSON_ASSERT (bson_init_from_json (&b, *j, -1, &error)); - BSON_ASSERT (BCON_EXTRACT (&b, "d", BCONE_DOUBLE (d))); - /* Infinite */ - BSON_ASSERT (d == d && ((d - d) != (d - d))); - BSON_ASSERT (d < 0); - bson_destroy (&b); - } - - for (j = bad; *j; j++) { - BSON_ASSERT (!bson_init_from_json (&b, *j, -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CORRUPT_JS, - "Got parse error at"); - memset (&error, 0, sizeof error); - } - - for (j = partial; *j; j++) { - BSON_ASSERT (!bson_init_from_json (&b, *j, -1, &error)); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CORRUPT_JS, - "Incomplete JSON"); - memset (&error, 0, sizeof error); - } -} - - -static void -test_bson_json_null (void) -{ - bson_error_t error; - bson_t b; - - const char *json = "{ \"x\": null }"; - BSON_ASSERT (bson_init_from_json (&b, json, -1, &error)); - BSON_ASSERT (BCON_EXTRACT (&b, "x", BCONE_NULL)); - bson_destroy (&b); -} - - -static void -test_bson_json_empty_final_object (void) -{ - const char *json = "{\"a\": {\"b\": {}}}"; - bson_t *bson = BCON_NEW ("a", "{", "b", "{", "}", "}"); - bson_t b; - bool r; - bson_error_t error; - - r = bson_init_from_json (&b, json, -1, &error); - if (!r) { - fprintf (stderr, "%s\n", error.message); - } - - BSON_ASSERT (r); - bson_eq_bson (&b, bson); - - bson_destroy (&b); - bson_destroy (bson); -} - -static void -test_bson_json_number_decimal (void) -{ - bson_error_t error; - bson_iter_t iter; - bson_decimal128_t decimal128; - const char *json = "{ \"key\" : { \"$numberDecimal\": \"11\" }}"; - bson_t b; - bool r; - - r = bson_init_from_json (&b, json, -1, &error); - if (!r) - fprintf (stderr, "%s\n", error.message); - BSON_ASSERT (r); - BSON_ASSERT (bson_iter_init (&iter, &b)); - BSON_ASSERT (bson_iter_find (&iter, "key")); - BSON_ASSERT (BSON_ITER_HOLDS_DECIMAL128 (&iter)); - bson_iter_decimal128 (&iter, &decimal128); - BSON_ASSERT (decimal128.low == 11); - BSON_ASSERT (decimal128.high == 0x3040000000000000ULL); - bson_destroy (&b); -} - -static void -test_bson_json_inc (void) -{ - /* test that reproduces a bug with special mode checking. Specifically, - * mistaking '$inc' for '$id' - * - * From https://github.com/mongodb/mongo-c-driver/issues/62 - */ - bson_error_t error; - const char *json = "{ \"$inc\" : { \"ref\" : 1 } }"; - bson_t b; - bool r; - - r = bson_init_from_json (&b, json, -1, &error); - if (!r) - fprintf (stderr, "%s\n", error.message); - BSON_ASSERT (r); - bson_destroy (&b); -} - -static void -test_bson_json_array (void) -{ - bson_error_t error; - const char *json = "[ 0, 1, 2, 3 ]"; - bson_t b, compare; - bool r; - - bson_init (&compare); - bson_append_int32 (&compare, "0", 1, 0); - bson_append_int32 (&compare, "1", 1, 1); - bson_append_int32 (&compare, "2", 1, 2); - bson_append_int32 (&compare, "3", 1, 3); - - r = bson_init_from_json (&b, json, -1, &error); - if (!r) - fprintf (stderr, "%s\n", error.message); - BSON_ASSERT (r); - - bson_eq_bson (&b, &compare); - bson_destroy (&compare); - bson_destroy (&b); -} - -static void -test_bson_json_array_single (void) -{ - bson_error_t error; - const char *json = "[ 0 ]"; - bson_t b, compare; - bool r; - - bson_init (&compare); - bson_append_int32 (&compare, "0", 1, 0); - - r = bson_init_from_json (&b, json, -1, &error); - if (!r) - fprintf (stderr, "%s\n", error.message); - BSON_ASSERT (r); - - bson_eq_bson (&b, &compare); - bson_destroy (&compare); - bson_destroy (&b); -} - -static void -test_bson_json_array_int64 (void) -{ - bson_error_t error; - const char *json = "[ { \"$numberLong\" : \"123\" }," - " { \"$numberLong\" : \"42\" } ]"; - bson_t b, compare; - bool r; - - bson_init (&compare); - bson_append_int64 (&compare, "0", 1, 123); - bson_append_int64 (&compare, "1", 1, 42); - - r = bson_init_from_json (&b, json, -1, &error); - if (!r) - fprintf (stderr, "%s\n", error.message); - BSON_ASSERT (r); - - bson_eq_bson (&b, &compare); - bson_destroy (&compare); - bson_destroy (&b); -} - -static void -test_bson_json_array_subdoc (void) -{ - bson_error_t error; - const char *json = "[ { \"a\" : 123 } ]"; - bson_t b, compare, subdoc; - bool r; - - bson_init (&compare); - bson_init (&subdoc); - bson_append_int32 (&subdoc, "a", 1, 123); - bson_append_document (&compare, "0", 1, &subdoc); - - r = bson_init_from_json (&b, json, -1, &error); - if (!r) - fprintf (stderr, "%s\n", error.message); - BSON_ASSERT (r); - - bson_eq_bson (&b, &compare); - bson_destroy (&subdoc); - bson_destroy (&compare); - bson_destroy (&b); -} - -static void -test_bson_json_merge_multiple (void) -{ - bson_error_t error; - bson_t *b = bson_new_from_json ( - (const uint8_t *) "{\"a\" : 1}, {\"b\" : 2}", -1, &error); - ASSERT_OR_PRINT (b, error); - - bson_t *compare = bson_new_from_json ( - (const uint8_t *) BSON_STR ({"a" : 1, "b" : 2}), -1, &error); - - bson_eq_bson (b, compare); - bson_destroy (b); - bson_destroy (compare); -} - -static void -test_bson_json_extra_chars (void) -{ - bson_error_t error; - { - bson_t *b = - bson_new_from_json ((const uint8_t *) "{\"a\": 1}abc", -1, &error); - ASSERT (b == NULL); - ASSERT_ERROR_CONTAINS (error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_CORRUPT_JS, - "Got parse error at \"a\""); - } - - { - bson_t *b = bson_new_from_json ( - (const uint8_t *) "{\"a\" : 1}{abc,[],{},123", -1, &error); - ASSERT_OR_PRINT (b, error); - - bson_t *compare = - bson_new_from_json ((const uint8_t *) "{\"a\" : 1}", -1, &error); - - bson_eq_bson (b, compare); - bson_destroy (b); - bson_destroy (compare); - } -} - -static void -test_bson_json_date_check (const char *json, int64_t value) -{ - bson_error_t error = {0}; - bson_t b, compare; - bool r; - - bson_init (&compare); - - BSON_APPEND_DATE_TIME (&compare, "dt", value); - - r = bson_init_from_json (&b, json, -1, &error); - - if (!r) { - fprintf (stderr, "%s\n", error.message); - } - - BSON_ASSERT (r); - - bson_eq_bson (&b, &compare); - bson_destroy (&compare); - bson_destroy (&b); -} - - -static void -test_bson_json_date_error (const char *json, const char *msg) -{ - bson_error_t error = {0}; - bson_t b; - bool r; - r = bson_init_from_json (&b, json, -1, &error); - if (r) { - fprintf (stderr, "parsing %s should fail\n", json); - } - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS ( - error, BSON_ERROR_JSON, BSON_JSON_ERROR_READ_INVALID_PARAM, msg); -} - -static void -test_bson_json_date (void) -{ - /* to make a timestamp, "python3 -m pip install iso8601" and in Python 3: - * iso8601.parse_date("2016-12-13T12:34:56.123Z").timestamp() * 1000 - */ - test_bson_json_date_check ( - "{ \"dt\" : { \"$date\" : \"2016-12-13T12:34:56.123Z\" } }", - 1481632496123); - test_bson_json_date_check ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T00:00:00.000Z\" } }", 0); - test_bson_json_date_check ( - "{ \"dt\" : { \"$date\" : \"1969-12-31T16:00:00.000-0800\" } }", 0); - - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:00.000+01:00\" } }", - "Could not parse"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:30:\" } }", - "reached end of date while looking for seconds"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:+01:00\" } }", - "seconds is required"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:30:00.\" } }", - "reached end of date while looking for milliseconds"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:00.+01:00\" } }", - "milliseconds is required"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"foo-01-01T00:00:00.000Z\" } }", - "year must be an integer"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-foo-01T00:00:00.000Z\" } }", - "month must be an integer"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-fooT00:00:00.000Z\" } }", - "day must be an integer"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01Tfoo:00:00.000Z\" } }", - "hour must be an integer"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T00:foo:00.000Z\" } }", - "minute must be an integer"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T00:00:foo.000Z\" } }", - "seconds must be an integer"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:00.000\" } }", - "timezone is required"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:00.000X\" } }", - "timezone is required"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:00.000+1\" } }", - "could not parse timezone"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:00.000+xx00\" } }", - "could not parse timezone"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:00.000+2400\" } }", - "timezone hour must be at most 23"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:00.000-2400\" } }", - "timezone hour must be at most 23"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:00.000+0060\" } }", - "timezone minute must be at most 59"); - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : \"1970-01-01T01:00:00.000-0060\" } }", - "timezone minute must be at most 59"); -} - - -static void -test_bson_json_date_legacy (void) -{ - test_bson_json_date_check ("{ \"dt\" : { \"$date\" : 0 } }", 0); - test_bson_json_date_check ("{ \"dt\" : { \"$date\" : 1356351330500 } }", - 1356351330500); - test_bson_json_date_check ("{ \"dt\" : { \"$date\" : -62135593139000 } }", - -62135593139000); - - /* INT64_MAX */ - test_bson_json_date_check ( - "{ \"dt\" : { \"$date\" : 9223372036854775807 } }", INT64_MAX); - - /* INT64_MIN */ - test_bson_json_date_check ( - "{ \"dt\" : { \"$date\" : -9223372036854775808 } }", INT64_MIN); - - /* INT64_MAX + 1 */ - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : 9223372036854775808 } }", - "Number \"9223372036854775808\" is out of range"); - - /* INT64_MIN - 1 */ - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : -9223372036854775809 } }", - "Number \"-9223372036854775809\" is out of range"); - - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : 10000000000000000000 } }", - "Number \"10000000000000000000\" is out of range"); - - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : -10000000000000000000 } }", - "Number \"-10000000000000000000\" is out of range"); -} - - -static void -test_bson_json_date_numberlong (void) -{ - test_bson_json_date_check ( - "{ \"dt\" : { \"$date\" : {\"$numberLong\": \"0\" } } }", 0); - test_bson_json_date_check ( - "{ \"dt\" : { \"$date\" : {\"$numberLong\": \"1356351330500\" } } }", - 1356351330500); - test_bson_json_date_check ( - "{ \"dt\" : { \"$date\" : { \"$numberLong\" : \"-62135593139000\" } } }", - -62135593139000); - - /* INT64_MAX */ - test_bson_json_date_check ("{ \"dt\" : { \"$date\" : { \"$numberLong\" " - ": \"9223372036854775807\" } } }", - INT64_MAX); - - /* INT64_MIN */ - test_bson_json_date_check ("{ \"dt\" : { \"$date\" : { \"$numberLong\" " - ": \"-9223372036854775808\" } } }", - INT64_MIN); - - /* INT64_MAX + 1 */ - test_bson_json_date_error ("{ \"dt\" : { \"$date\" : { \"$numberLong\" " - ": \"9223372036854775808\" } } }", - "Number \"9223372036854775808\" is out of range"); - - /* INT64_MIN - 1 */ - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : { \"$numberLong\" " - ": \"-9223372036854775809\" } } }", - "Number \"-9223372036854775809\" is out of range"); - - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : { \"$numberLong\" " - ": \"10000000000000000000\" } } }", - "Number \"10000000000000000000\" is out of range"); - - test_bson_json_date_error ( - "{ \"dt\" : { \"$date\" : { \"$numberLong\" " - ": \"-10000000000000000000\" } } }", - "Number \"-10000000000000000000\" is out of range"); -} - - -static void -test_bson_json_timestamp (void) -{ - bson_error_t error = {0}; - bson_t b, compare; - bool r; - - bson_init (&compare); - - BSON_APPEND_TIMESTAMP ( - &compare, "ts", (uint32_t) 1486785977, (uint32_t) 1234); - - r = bson_init_from_json ( - &b, - "{\"ts\": {\"$timestamp\": {\"t\": 1486785977, \"i\": 1234}}}", - -1, - &error); - - if (!r) { - fprintf (stderr, "%s\n", error.message); - } - - BSON_ASSERT (r); - - bson_eq_bson (&b, &compare); - bson_destroy (&compare); - bson_destroy (&b); -} - - -static void -test_bson_array_as_legacy_json (void) -{ - bson_t d = BSON_INITIALIZER; - size_t len; - char *str; - - str = bson_array_as_json (&d, &len); - ASSERT_CMPSTR (str, "[ ]"); - ASSERT_CMPSIZE_T (len, ==, 3u); - bson_free (str); - - BSON_APPEND_INT32 (&d, "0", 1); - str = bson_array_as_json (&d, &len); - ASSERT_CMPSTR (str, "[ 1 ]"); - ASSERT_CMPSIZE_T (len, ==, 5u); - bson_free (str); - - /* test corrupted bson */ - BSON_APPEND_UTF8 (&d, "1", "\x80"); /* bad UTF-8 */ - str = bson_array_as_json (&d, &len); - BSON_ASSERT (!str); - BSON_ASSERT (!len); - - bson_destroy (&d); -} - -static void -test_bson_array_as_relaxed_json (void) -{ - bson_t d = BSON_INITIALIZER; - size_t len; - char *str; - - str = bson_array_as_relaxed_extended_json (&d, &len); - ASSERT_CMPSTR (str, "[ ]"); - ASSERT_CMPSIZE_T (len, ==, 3u); - bson_free (str); - - BSON_APPEND_INT32 (&d, "0", 1); - str = bson_array_as_relaxed_extended_json (&d, &len); - ASSERT_CMPSTR (str, "[ 1 ]"); - ASSERT_CMPSIZE_T (len, ==, 5u); - bson_free (str); - - /* test corrupted bson */ - BSON_APPEND_UTF8 (&d, "1", "\x80"); /* bad UTF-8 */ - str = bson_array_as_relaxed_extended_json (&d, &len); - BSON_ASSERT (!str); - BSON_ASSERT (!len); - - bson_destroy (&d); -} - -static void -test_bson_array_as_canonical_json (void) -{ - bson_t d = BSON_INITIALIZER; - size_t len; - char *str; - - str = bson_array_as_canonical_extended_json (&d, &len); - ASSERT_CMPSTR (str, "[ ]"); - ASSERT_CMPSIZE_T (len, ==, 3u); - bson_free (str); - - BSON_APPEND_INT32 (&d, "0", 1); - str = bson_array_as_canonical_extended_json (&d, &len); - ASSERT_CMPSTR (str, "[ { \"$numberInt\" : \"1\" } ]"); - ASSERT_CMPSIZE_T (len, ==, 26u); - bson_free (str); - - /* test corrupted bson */ - BSON_APPEND_UTF8 (&d, "1", "\x80"); /* bad UTF-8 */ - str = bson_array_as_canonical_extended_json (&d, &len); - BSON_ASSERT (!str); - BSON_ASSERT (!len); - - bson_destroy (&d); -} - -static void -test_bson_as_json_spacing (void) -{ - bson_t d = BSON_INITIALIZER; - size_t len; - char *str; - - str = bson_as_json (&d, &len); - BSON_ASSERT (0 == strcmp (str, "{ }")); - BSON_ASSERT (len == 3); - bson_free (str); - - BSON_APPEND_INT32 (&d, "a", 1); - str = bson_as_json (&d, &len); - BSON_ASSERT (0 == strcmp (str, "{ \"a\" : 1 }")); - BSON_ASSERT (len == 11); - bson_free (str); - - bson_destroy (&d); -} - - -static void -test_bson_json_errors (void) -{ - typedef const char *test_bson_json_error_t[2]; - test_bson_json_error_t tests[] = { - {"{\"x\": {\"$numberLong\": 1}}", - "Invalid state for integer read: INT64"}, - {"{\"x\": {\"$binary\": 1}}", "Unexpected integer 1 in type \"binary\""}, - {"{\"x\": {\"$numberInt\": true}}", - "Invalid read of boolean in state IN_BSON_TYPE"}, - {"{\"x\": {\"$dbPointer\": true}}", - "Invalid read of boolean in state IN_BSON_TYPE_DBPOINTER_STARTMAP"}, - {"[{\"$code\": {}}]", "Unexpected nested object value for \"$code\" key"}, - {"{\"x\": {\"$numberInt\": \"8589934592\"}}", - "Invalid input string \"8589934592\", looking for INT32"}, - {0}, - }; - - bson_error_t error; - test_bson_json_error_t *p; - - for (p = tests; *(p[0]); p++) { - BSON_ASSERT (!bson_new_from_json ((const uint8_t *) (*p)[0], -1, &error)); - ASSERT_ERROR_CONTAINS ( - error, BSON_ERROR_JSON, BSON_JSON_ERROR_READ_INVALID_PARAM, (*p)[1]); - } -} - - -static void -test_bson_integer_width (void) -{ - const char *sd = "{\"v\":-1234567890123, \"x\":12345678901234}"; - char *match; - bson_error_t err; - bson_t *bs = bson_new_from_json ((const uint8_t *) sd, strlen (sd), &err); - - match = bson_as_json (bs, 0); - ASSERT_CMPSTR (match, "{ \"v\" : -1234567890123, \"x\" : 12345678901234 }"); - - bson_free (match); - bson_destroy (bs); -} - - -static void -test_bson_json_null_in_str (void) -{ - const char bad_json[] = "{\"a\":\"\0\"}"; - const char cdriver2305[] = "{\"\0"; - bson_error_t err; - ASSERT (!bson_new_from_json ( - (const uint8_t *) bad_json, sizeof (bad_json) - 1, &err)); - ASSERT_ERROR_CONTAINS ( - err, BSON_ERROR_JSON, BSON_JSON_ERROR_READ_CORRUPT_JS, "Got parse error"); - memset (&err, 0, sizeof err); - ASSERT (!bson_new_from_json ( - (const uint8_t *) cdriver2305, sizeof (cdriver2305) - 1, &err)); - ASSERT_ERROR_CONTAINS ( - err, BSON_ERROR_JSON, BSON_JSON_ERROR_READ_CORRUPT_JS, "Got parse error"); -} - -static char * -_single_to_double (const char *json) -{ - char *copy; - char *to_ret = copy = bson_malloc (strlen (json) + 1); - strcpy (copy, json); - while (*copy) { - if (*copy == '\'') { - *copy = '\"'; - } else { - copy++; - } - } - return to_ret; -} - -static void -_test_json_produces_multiple (const char *json_in, int err_expected, ...) -{ - bson_t bson_in = BSON_INITIALIZER; - bson_t *bson_expected; - bson_error_t err = {0}; - int ret; - va_list ap; - char *json = _single_to_double (json_in); - bson_json_reader_t *reader = - bson_json_data_reader_new (false /* ignored */, 512 /* buffer size */); - - va_start (ap, err_expected); - - bson_json_data_reader_ingest (reader, (uint8_t *) json, strlen (json)); - while ((ret = bson_json_reader_read (reader, &bson_in, &err)) == 1) { - bson_expected = va_arg (ap, bson_t *); - if (!bson_expected) { - fprintf (stderr, "Extra bson documents returned for input %s\n", json); - abort (); - } - if (bson_compare (&bson_in, bson_expected) != 0) { - char *expect = bson_as_json (bson_expected, NULL); - char *in = bson_as_json (&bson_in, NULL); - fprintf ( - stderr, "Got %s, but expected %s for input %s\n", expect, in, json); - bson_free (expect); - bson_free (in); - abort (); - } - bson_destroy (bson_expected); - bson_reinit (&bson_in); - } - - if (ret == 0) { - ASSERT (!err_expected); - } else { - ASSERT_OR_PRINT (err_expected, err); - } - - if (va_arg (ap, bson_t *) != NULL) { - fprintf (stderr, "Not all bson docs matched for input %s\n", json); - abort (); - } - - va_end (ap); - - bson_json_reader_destroy (reader); - bson_destroy (&bson_in); - bson_free (json); -} - -#define TEST_JSON_PRODUCES_MULTIPLE(_json, _has_err, ...) \ - _test_json_produces_multiple (_json, _has_err, __VA_ARGS__, NULL); - -static void -test_bson_as_json_multi_object (void) -{ - /* Test malformed documents that produce errors */ - TEST_JSON_PRODUCES_MULTIPLE ("[],[{''", 1, NULL); - - TEST_JSON_PRODUCES_MULTIPLE ("{},[{''", 1, NULL); - - - /* Test the desired multiple document behavior */ - TEST_JSON_PRODUCES_MULTIPLE ("{'a': 1} {'b': 1}", - 0, - BCON_NEW ("a", BCON_INT32 (1)), - BCON_NEW ("b", BCON_INT32 (1))); - - TEST_JSON_PRODUCES_MULTIPLE ( - "{}{}{}", 0, bson_new (), bson_new (), bson_new ()); - - /* Test strange behavior we may consider changing */ - - /* Combines both documents into one? */ - TEST_JSON_PRODUCES_MULTIPLE ( - "{'a': 1}, {'b': 1}", - 0, - BCON_NEW ("a", BCON_INT32 (1), "b", BCON_INT32 (1))); - - TEST_JSON_PRODUCES_MULTIPLE ( - "{},{'a': 1}", 0, BCON_NEW ("a", BCON_INT32 (1))); - - TEST_JSON_PRODUCES_MULTIPLE ( - "{},{},{'a': 1}", 0, BCON_NEW ("a", BCON_INT32 (1))); - - TEST_JSON_PRODUCES_MULTIPLE ( - "[],{'a': 1}", 0, BCON_NEW ("a", BCON_INT32 (1))); - - /* We support a root level array */ - TEST_JSON_PRODUCES_MULTIPLE ("[]", 0, bson_new ()); - - TEST_JSON_PRODUCES_MULTIPLE ( - "[{'x': 0}]", 0, BCON_NEW ("0", "{", "x", BCON_INT32 (0), "}")); - - /* Yet this fails */ - TEST_JSON_PRODUCES_MULTIPLE ("[],[{'a': 1}]", 1, NULL); -} - -static void -test_bson_as_json_with_opts (bson_t *bson, - bson_json_mode_t mode, - int max_len, - const char *expected) -{ - bson_json_opts_t *opts = bson_json_opts_new (mode, max_len); - size_t json_len; - char *str = bson_as_json_with_opts (bson, &json_len, opts); - - ASSERT_CMPSTR (str, expected); - ASSERT_CMPSIZE_T (json_len, ==, strlen (expected)); - - if (max_len != BSON_MAX_LEN_UNLIMITED) { - ASSERT (bson_in_range_signed (size_t, max_len)); - ASSERT_CMPSIZE_T (json_len, <=, (size_t) max_len); - } - - bson_free (str); - bson_json_opts_destroy (opts); -} - -char * -truncate_string (const char *str, size_t len) -{ - char *truncated; - - truncated = (char *) bson_malloc0 (len + 1); - strncpy (truncated, str, len); - truncated[len] = '\0'; - - return truncated; -} - -static void -run_bson_as_json_with_opts_tests (bson_t *bson, - bson_json_mode_t mode, - const char *expected) -{ - const size_t ulen = strlen (expected); - char *truncated; - - BSON_ASSERT (bson_in_range_unsigned (int, ulen)); - const int len = (int) ulen; - - /* Test with 0 length (empty string). */ - test_bson_as_json_with_opts (bson, mode, 0, ""); - - BSON_ASSERT (INT_MAX - 2 >= len); - - /* Test with a limit that does not truncate the string. */ - test_bson_as_json_with_opts (bson, mode, len + 2, expected); - - /* Test with unlimited length. */ - test_bson_as_json_with_opts (bson, mode, BSON_MAX_LEN_UNLIMITED, expected); - - /* Test every possible limit from 0 to length. */ - for (int i = 0; i < len; i++) { - truncated = truncate_string (expected, (size_t) i); - test_bson_as_json_with_opts (bson, mode, i, truncated); - bson_free (truncated); - } -} - -static void -test_bson_as_json_with_opts_double (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_DOUBLE (b, "v", 1.0)); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$numberDouble\" : \"1.0\" } }"); - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_RELAXED, "{ \"v\" : 1.0 }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_utf8 (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_UTF8 (b, "v", "abcdef")); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_CANONICAL, "{ \"v\" : \"abcdef\" }"); - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_RELAXED, "{ \"v\" : \"abcdef\" }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_document (void) -{ - bson_t *b; - bson_t nested; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_DOCUMENT_BEGIN (b, "v", &nested)); - BSON_ASSERT (BSON_APPEND_UTF8 (&nested, "v", "abcdef")); - BSON_ASSERT (bson_append_document_end (b, &nested)); - BSON_ASSERT (BSON_APPEND_UTF8 (b, "w", "abcdef")); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"v\" : \"abcdef\" }, \"w\" : \"abcdef\" }"); - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : { \"v\" : \"abcdef\" }, \"w\" : \"abcdef\" }"); - - bson_destroy (b); - bson_destroy (&nested); -} - -static void -test_bson_as_json_with_opts_array (void) -{ - bson_t *b; - bson_t nested; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_ARRAY_BEGIN (b, "v", &nested)); - BSON_ASSERT (BSON_APPEND_UTF8 (&nested, "0", "abcdef")); - BSON_ASSERT (bson_append_array_end (b, &nested)); - BSON_ASSERT (BSON_APPEND_UTF8 (b, "w", "abcdef")); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : [ \"abcdef\" ], \"w\" : \"abcdef\" }"); - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : [ \"abcdef\" ], \"w\" : \"abcdef\" }"); - - bson_destroy (b); - bson_destroy (&nested); -} - -static void -test_bson_as_json_with_opts_binary (void) -{ - const uint8_t data[] = {1, 2, 3, 4}; - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_BINARY (b, "v", 0, data, sizeof data)); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$binary\" : { \"base64\" : " - "\"AQIDBA==\", \"subType\" : \"00\" } } }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : { \"$binary\" : { \"base64\" : " - "\"AQIDBA==\", \"subType\" : \"00\" } } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_undefined (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_UNDEFINED (b, "v")); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_RELAXED, "{ \"v\" : { \"$undefined\" : true } }"); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_CANONICAL, "{ \"v\" : { \"$undefined\" : true } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_oid (void) -{ - bson_oid_t oid; - bson_t *b; - - bson_oid_init_from_string (&oid, "12341234123412abcdababcd"); - b = bson_new (); - BSON_ASSERT (BSON_APPEND_OID (b, "v", &oid)); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : { \"$oid\" : \"12341234123412abcdababcd\" } }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$oid\" : \"12341234123412abcdababcd\" } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_bool (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_BOOL (b, "v", false)); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_RELAXED, "{ \"v\" : false }"); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_CANONICAL, "{ \"v\" : false }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_date_time (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_DATE_TIME (b, "v", 1602572588123)); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : { \"$date\" : \"2020-10-13T07:03:08.123Z\" } }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$date\" : { \"$numberLong\" : \"1602572588123\" } } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_null (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_NULL (b, "v")); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_RELAXED, "{ \"v\" : null }"); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_CANONICAL, "{ \"v\" : null }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_regex (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_REGEX (b, "v", "^abc", "i")); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : { \"$regularExpression\" : { \"pattern\" : \"^abc\", " - "\"options\" : \"i\" } } }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$regularExpression\" : { \"pattern\" : \"^abc\", " - "\"options\" : \"i\" } } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_dbpointer (void) -{ - bson_oid_t oid; - bson_t *b; - - bson_oid_init_from_string (&oid, "12341234123412abcdababcd"); - b = bson_new (); - BSON_ASSERT (BSON_APPEND_DBPOINTER (b, "v", "coll", &oid)); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : { \"$dbPointer\" : { \"$ref\" : \"coll\", \"$id\" : { " - "\"$oid\" : \"12341234123412abcdababcd\" } } } }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$dbPointer\" : { \"$ref\" : \"coll\", \"$id\" : { " - "\"$oid\" : \"12341234123412abcdababcd\" } } } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_code (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_CODE (b, "v", "function(){}")); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : { \"$code\" : \"function(){}\" } }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$code\" : \"function(){}\" } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_symbol (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_SYMBOL (b, "v", "symbol")); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_RELAXED, "{ \"v\" : { \"$symbol\" : \"symbol\" } }"); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_CANONICAL, "{ \"v\" : { \"$symbol\" : \"symbol\" } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_codewscope (void) -{ - bson_t *b; - bson_t *scope; - - scope = bson_new (); - BSON_ASSERT (BSON_APPEND_UTF8 (scope, "v", "abcdef")); - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_CODE_WITH_SCOPE (b, "v", "function(){}", scope)); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : { \"$code\" : \"function(){}\", " - "\"$scope\" : { \"v\" : \"abcdef\" } } }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$code\" : \"function(){}\", " - "\"$scope\" : { \"v\" : \"abcdef\" } } }"); - - bson_destroy (b); - bson_destroy (scope); -} - -static void -test_bson_as_json_with_opts_int32 (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_INT32 (b, "v", 461394000)); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_RELAXED, "{ \"v\" : 461394000 }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$numberInt\" : \"461394000\" } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_int64 (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_INT64 (b, "v", 461394000)); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_RELAXED, "{ \"v\" : 461394000 }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$numberLong\" : \"461394000\" } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_timestamp (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_TIMESTAMP (b, "v", 461394000, 2)); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : { \"$timestamp\" : { \"t\" : 461394000, \"i\" : 2 } } }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$timestamp\" : { \"t\" : 461394000, \"i\" : 2 } } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_minkey (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_MINKEY (b, "v")); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_RELAXED, "{ \"v\" : { \"$minKey\" : 1 } }"); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_CANONICAL, "{ \"v\" : { \"$minKey\" : 1 } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_maxkey (void) -{ - bson_t *b; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_MAXKEY (b, "v")); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_RELAXED, "{ \"v\" : { \"$maxKey\" : 1 } }"); - - run_bson_as_json_with_opts_tests ( - b, BSON_JSON_MODE_CANONICAL, "{ \"v\" : { \"$maxKey\" : 1 } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_decimal128 (void) -{ - bson_t *b; - bson_decimal128_t dec; - - dec.high = 0x3040ffffffffffffULL; - dec.low = 0xffffffffffffffffULL; - - b = bson_new (); - BSON_ASSERT (BSON_APPEND_DECIMAL128 (b, "v", &dec)); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_RELAXED, - "{ \"v\" : { \"$numberDecimal\" : " - "\"5192296858534827628530496329220095\" } }"); - - run_bson_as_json_with_opts_tests ( - b, - BSON_JSON_MODE_CANONICAL, - "{ \"v\" : { \"$numberDecimal\" : " - "\"5192296858534827628530496329220095\" } }"); - - bson_destroy (b); -} - -static void -test_bson_as_json_with_opts_all_types (void) -{ - char *full_canonical; - char *full_relaxed; - bson_oid_t oid; - bson_decimal128_t decimal128; - bson_t b; - bson_t scope; - - decimal128.high = 0x3040000000000000ULL; - decimal128.low = 0x000000000000000B; - bson_oid_init_from_string (&oid, "123412341234abcdabcdabcd"); - - bson_init (&scope); - BCON_APPEND (&scope, "x", BCON_INT32 (1)); - - bson_init (&b); - BCON_APPEND (&b, "double", BCON_DOUBLE (123.0)); - BCON_APPEND (&b, "utf8", "bar"); - BCON_APPEND (&b, "document", "{", "x", BCON_INT32 (1), "}"); - BCON_APPEND (&b, "array", "[", BCON_INT32 (1), "]"); - BCON_APPEND ( - &b, "binary", BCON_BIN (BSON_SUBTYPE_BINARY, (uint8_t *) "abc", 3)); - BCON_APPEND (&b, "undefined", BCON_UNDEFINED); - BCON_APPEND (&b, "oid", BCON_OID (&oid)); - BCON_APPEND (&b, "false", BCON_BOOL (false)); - BCON_APPEND (&b, "true", BCON_BOOL (true)); - BCON_APPEND (&b, "date", BCON_DATE_TIME (time (NULL))); - BCON_APPEND (&b, "null", BCON_NULL); - BCON_APPEND (&b, "regex", BCON_REGEX ("^abcd", "xi")); - BCON_APPEND (&b, "dbpointer", BCON_DBPOINTER ("mycollection", &oid)); - BCON_APPEND (&b, "code", BCON_CODE ("code")); - BCON_APPEND (&b, "symbol", BCON_SYMBOL ("symbol")); - BCON_APPEND (&b, "codewscope", BCON_CODEWSCOPE ("code", &scope)); - BCON_APPEND (&b, "int32", BCON_INT32 (1234)); - BCON_APPEND (&b, "timestamp", BCON_TIMESTAMP ((uint32_t) time (NULL), 1234)); - BCON_APPEND (&b, "int64", BCON_INT64 (4321)); - BCON_APPEND (&b, "decimal128", BCON_DECIMAL128 (&decimal128)); - BCON_APPEND (&b, "minkey", BCON_MINKEY); - BCON_APPEND (&b, "maxkey", BCON_MAXKEY); - - full_canonical = bson_as_canonical_extended_json (&b, NULL); - full_relaxed = bson_as_relaxed_extended_json (&b, NULL); - - run_bson_as_json_with_opts_tests (&b, BSON_JSON_MODE_RELAXED, full_relaxed); - run_bson_as_json_with_opts_tests ( - &b, BSON_JSON_MODE_CANONICAL, full_canonical); - - bson_free (full_canonical); - bson_free (full_relaxed); - - bson_destroy (&b); - bson_destroy (&scope); -} - -static void -test_decimal128_overflowing_exponent (void) -{ - { - bson_decimal128_t decimal128; - BSON_ASSERT (!bson_decimal128_from_string ("0E+2147483648", &decimal128)); - } - - { - bson_decimal128_t decimal128; - BSON_ASSERT (!bson_decimal128_from_string ("0E-2147483649", &decimal128)); - } - - { - bson_decimal128_t decimal128; - BSON_ASSERT ( - !bson_decimal128_from_string ("-0E+2147483648", &decimal128)); - } - { - bson_decimal128_t decimal128; - BSON_ASSERT ( - !bson_decimal128_from_string ("-0E-2147483649", &decimal128)); - } - { - bson_error_t error; - const char *degenerate_extjson = - "{\"d\" : {\"$numberDecimal\" : \"0E+2147483648\"}}"; - - BSON_ASSERT (!bson_new_from_json ( - (const uint8_t *) degenerate_extjson, -1, &error)); - ASSERT_ERROR_CONTAINS ( - error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Invalid input string \"0E+2147483648\", looking for DECIMAL128"); - } - - { - bson_error_t error; - const char *degenerate_extjson = - "{\"d\" : {\"$numberDecimal\" : \"0E-2147483649\"}}"; - - BSON_ASSERT (!bson_new_from_json ( - (const uint8_t *) degenerate_extjson, -1, &error)); - ASSERT_ERROR_CONTAINS ( - error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Invalid input string \"0E-2147483649\", looking for DECIMAL128"); - } - - { - bson_error_t error; - const char *degenerate_extjson = - "{\"d\" : {\"$numberDecimal\" : \"-0E+2147483648\"}}"; - - BSON_ASSERT (!bson_new_from_json ( - (const uint8_t *) degenerate_extjson, -1, &error)); - ASSERT_ERROR_CONTAINS ( - error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Invalid input string \"-0E+2147483648\", looking for DECIMAL128"); - } - - { - bson_error_t error; - const char *degenerate_extjson = - "{\"d\" : {\"$numberDecimal\" : \"-0E-2147483649\"}}"; - - BSON_ASSERT (!bson_new_from_json ( - (const uint8_t *) degenerate_extjson, -1, &error)); - ASSERT_ERROR_CONTAINS ( - error, - BSON_ERROR_JSON, - BSON_JSON_ERROR_READ_INVALID_PARAM, - "Invalid input string \"-0E-2147483649\", looking for DECIMAL128"); - } - - { - bson_decimal128_t decimal128; - BSON_ASSERT ( - !bson_decimal128_from_string ("0E+99999999999999999999", &decimal128)); - } - { - bson_decimal128_t decimal128; - BSON_ASSERT ( - !bson_decimal128_from_string ("0E-99999999999999999999", &decimal128)); - } -} - -static void -test_parse_array (void) -{ - { - bson_t *b1; - { - const char *json = BSON_STR ([ {"$code" : "A"} ]); - bson_error_t error; - b1 = bson_new_from_json ((const uint8_t *) json, -1, &error); - ASSERT_OR_PRINT (b1, error); - } - - bson_t *b2; - { - const char *json = BSON_STR ({"0" : {"$code" : "A"}}); - bson_error_t error; - b2 = bson_new_from_json ((const uint8_t *) json, -1, &error); - ASSERT_OR_PRINT (b2, error); - } - - ASSERT (bson_equal (b1, b2)); - bson_destroy (b2); - bson_destroy (b1); - } - - { - bson_t *b1; - { - const char *json = BSON_STR ([ {"$code" : "A"}, {"$code" : "B"} ]); - bson_error_t error; - b1 = bson_new_from_json ((const uint8_t *) json, -1, &error); - ASSERT_OR_PRINT (b1, error); - } - - bson_t *b2; - { - const char *json = - BSON_STR ({"0" : {"$code" : "A"}}, {"1" : {"$code" : "B"}}); - bson_error_t error; - b2 = bson_new_from_json ((const uint8_t *) json, -1, &error); - ASSERT_OR_PRINT (b2, error); - } - - ASSERT (bson_equal (b1, b2)); - bson_destroy (b2); - bson_destroy (b1); - } - - { - bson_t *b1; - { - const char *json = BSON_STR ([ { - "$dbPointer" : - {"$ref" : "foo", - "$id" : {"$oid" : "01234567890abcdef0123456"}} - } ]); - bson_error_t error; - b1 = bson_new_from_json ((const uint8_t *) json, -1, &error); - ASSERT_OR_PRINT (b1, error); - } - - bson_t *b2; - { - const char *json = BSON_STR ({ - "0" : { - "$dbPointer" : { - "$ref" : "foo", - "$id" : {"$oid" : "01234567890abcdef0123456"} - } - } - }); - bson_error_t error; - b2 = bson_new_from_json ((const uint8_t *) json, -1, &error); - ASSERT_OR_PRINT (b2, error); - } - - ASSERT (bson_equal (b1, b2)); - bson_destroy (b2); - bson_destroy (b1); - } - - { - bson_t *b1; - { - const char *json = BSON_STR ([ - { - "$dbPointer" : { - "$ref" : "foo", - "$id" : {"$oid" : "01234567890abcdef0123456"} - } - }, - { - "$dbPointer" : { - "$ref" : "foo", - "$id" : {"$oid" : "01234567890abcdef0123456"} - } - } - ]); - bson_error_t error; - b1 = bson_new_from_json ((const uint8_t *) json, -1, &error); - ASSERT_OR_PRINT (b1, error); - } - - bson_t *b2; - { - const char *json = BSON_STR ( - { - "0" : { - "$dbPointer" : { - "$ref" : "foo", - "$id" : {"$oid" : "01234567890abcdef0123456"} - } - } - }, - { - "1" : { - "$dbPointer" : { - "$ref" : "foo", - "$id" : {"$oid" : "01234567890abcdef0123456"} - } - } - }); - - bson_error_t error; - b2 = bson_new_from_json ((const uint8_t *) json, -1, &error); - ASSERT_OR_PRINT (b2, error); - } - - ASSERT (bson_equal (b1, b2)); - bson_destroy (b2); - bson_destroy (b1); - } -} - -void -test_json_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/bson/as_json/x1000", test_bson_as_json_x1000); - TestSuite_Add (suite, "/bson/as_json/multi", test_bson_as_json_multi); - TestSuite_Add (suite, "/bson/as_json/string", test_bson_as_json_string); - TestSuite_Add (suite, "/bson/as_json/int32", test_bson_as_json_int32); - TestSuite_Add (suite, "/bson/as_json/int64", test_bson_as_json_int64); - TestSuite_Add (suite, "/bson/as_json/double", test_bson_as_json_double); - TestSuite_Add (suite, - "/bson/as_json/double/nonfinite", - test_bson_as_json_double_nonfinite); - TestSuite_Add (suite, "/bson/as_json/code", test_bson_as_json_code); - TestSuite_Add ( - suite, "/bson/as_json/date_time", test_bson_as_json_date_time); - TestSuite_Add (suite, "/bson/as_json/regex", test_bson_as_json_regex); - TestSuite_Add (suite, "/bson/as_json/symbol", test_bson_as_json_symbol); - TestSuite_Add (suite, "/bson/as_json/utf8", test_bson_as_json_utf8); - TestSuite_Add ( - suite, "/bson/as_json/dbpointer", test_bson_as_json_dbpointer); - TestSuite_Add (suite, - "/bson/as_canonical_extended_json/dbpointer", - test_bson_as_canonical_extended_json_dbpointer); - TestSuite_Add ( - suite, "/bson/as_json/stack_overflow", test_bson_as_json_stack_overflow); - TestSuite_Add (suite, "/bson/as_json/corrupt", test_bson_corrupt); - TestSuite_Add (suite, "/bson/as_json/corrupt_utf8", test_bson_corrupt_utf8); - TestSuite_Add ( - suite, "/bson/as_json/corrupt_binary", test_bson_corrupt_binary); - TestSuite_Add (suite, "/bson/as_json_spacing", test_bson_as_json_spacing); - TestSuite_Add ( - suite, "/bson/array_as_legacy_json", test_bson_array_as_legacy_json); - TestSuite_Add ( - suite, "/bson/array_as_relaxed_json", test_bson_array_as_relaxed_json); - TestSuite_Add (suite, - "/bson/array_as_canonical_json", - test_bson_array_as_canonical_json); - TestSuite_Add ( - suite, "/bson/json/allow_multiple", test_bson_json_allow_multiple); - TestSuite_Add ( - suite, "/bson/json/read/buffering", test_bson_json_read_buffering); - TestSuite_Add (suite, "/bson/json/read", test_bson_json_read); - TestSuite_Add (suite, "/bson/json/inc", test_bson_json_inc); - TestSuite_Add (suite, "/bson/json/array", test_bson_json_array); - TestSuite_Add ( - suite, "/bson/json/array/single", test_bson_json_array_single); - TestSuite_Add (suite, "/bson/json/array/int64", test_bson_json_array_int64); - TestSuite_Add ( - suite, "/bson/json/array/subdoc", test_bson_json_array_subdoc); - TestSuite_Add (suite, "/bson/json/date", test_bson_json_date); - TestSuite_Add (suite, "/bson/json/date/legacy", test_bson_json_date_legacy); - TestSuite_Add ( - suite, "/bson/json/date/long", test_bson_json_date_numberlong); - TestSuite_Add (suite, "/bson/json/timestamp", test_bson_json_timestamp); - TestSuite_Add (suite, "/bson/json/read/empty", test_bson_json_read_empty); - TestSuite_Add (suite, - "/bson/json/read/missing_complex", - test_bson_json_read_missing_complex); - TestSuite_Add (suite, - "/bson/json/read/invalid_binary", - test_bson_json_read_invalid_binary); - TestSuite_Add ( - suite, "/bson/json/read/invalid_json", test_bson_json_read_invalid_json); - TestSuite_Add (suite, "/bson/json/read/bad_cb", test_bson_json_read_bad_cb); - TestSuite_Add ( - suite, "/bson/json/read/invalid", test_bson_json_read_invalid); - TestSuite_Add (suite, - "/bson/json/read/invalid_base64", - test_bson_json_read_invalid_base64); - TestSuite_Add ( - suite, "/bson/json/read/raw_utf8", test_bson_json_read_raw_utf8); - TestSuite_Add ( - suite, "/bson/json/read/corrupt_utf8", test_bson_json_read_corrupt_utf8); - TestSuite_Add (suite, - "/bson/json/read/corrupt_document", - test_bson_json_read_corrupt_document); - TestSuite_Add ( - suite, "/bson/json/read/decimal128", test_bson_json_read_decimal128); - TestSuite_Add ( - suite, "/bson/json/read/dbpointer", test_bson_json_read_dbpointer); - TestSuite_Add ( - suite, "/bson/json/read/legacy_regex", test_bson_json_read_legacy_regex); - TestSuite_Add (suite, - "/bson/json/read/regex_options_order", - test_bson_json_read_regex_options_order); - TestSuite_Add (suite, "/bson/json/read/binary", test_bson_json_read_binary); - TestSuite_Add (suite, - "/bson/json/read/legacy_binary", - test_bson_json_read_legacy_binary); - TestSuite_Add ( - suite, "/bson/json/read/file", test_json_reader_new_from_file); - TestSuite_Add ( - suite, "/bson/json/read/bad_path", test_json_reader_new_from_bad_path); - TestSuite_Add ( - suite, "/bson/json/read/$numberLong", test_bson_json_number_long); - TestSuite_Add (suite, - "/bson/json/read/$numberLong/zero", - test_bson_json_number_long_zero); - TestSuite_Add (suite, "/bson/json/read/code", test_bson_json_code); - TestSuite_Add ( - suite, "/bson/json/read/code/errors", test_bson_json_code_errors); - TestSuite_Add (suite, "/bson/json/read/dbref", test_bson_json_dbref); - TestSuite_Add (suite, "/bson/json/read/uescape", test_bson_json_uescape); - TestSuite_Add ( - suite, "/bson/json/read/uescape/key", test_bson_json_uescape_key); - TestSuite_Add ( - suite, "/bson/json/read/uescape/bad", test_bson_json_uescape_bad); - TestSuite_Add (suite, "/bson/json/read/int32", test_bson_json_int32); - TestSuite_Add (suite, "/bson/json/read/int64", test_bson_json_int64); - TestSuite_Add (suite, "/bson/json/read/double", test_bson_json_double); - TestSuite_Add ( - suite, "/bson/json/read/double/overflow", test_bson_json_double_overflow); - TestSuite_Add (suite, "/bson/json/read/double/nan", test_bson_json_nan); - TestSuite_Add ( - suite, "/bson/json/read/double/infinity", test_bson_json_infinity); - TestSuite_Add (suite, "/bson/json/read/null", test_bson_json_null); - TestSuite_Add ( - suite, "/bson/json/read/empty_final", test_bson_json_empty_final_object); - TestSuite_Add ( - suite, "/bson/as_json/decimal128", test_bson_as_json_decimal128); - TestSuite_Add ( - suite, "/bson/json/read/$numberDecimal", test_bson_json_number_decimal); - TestSuite_Add (suite, "/bson/json/errors", test_bson_json_errors); - TestSuite_Add (suite, "/bson/integer/width", test_bson_integer_width); - TestSuite_Add ( - suite, "/bson/json/read/null_in_str", test_bson_json_null_in_str); - TestSuite_Add ( - suite, "/bson/json/read/merge_multiple", test_bson_json_merge_multiple); - TestSuite_Add ( - suite, "/bson/json/read/extra_chars", test_bson_json_extra_chars); - TestSuite_Add ( - suite, "/bson/as_json/multi_object", test_bson_as_json_multi_object); - TestSuite_Add (suite, - "/bson/as_json_with_opts/double", - test_bson_as_json_with_opts_double); - TestSuite_Add ( - suite, "/bson/as_json_with_opts/utf8", test_bson_as_json_with_opts_utf8); - TestSuite_Add (suite, - "/bson/as_json_with_opts/document", - test_bson_as_json_with_opts_document); - TestSuite_Add (suite, - "/bson/as_json_with_opts/array", - test_bson_as_json_with_opts_array); - TestSuite_Add (suite, - "/bson/as_json_with_opts/binary", - test_bson_as_json_with_opts_binary); - TestSuite_Add (suite, - "/bson/as_json_with_opts/undefined", - test_bson_as_json_with_opts_undefined); - TestSuite_Add ( - suite, "/bson/as_json_with_opts/oid", test_bson_as_json_with_opts_oid); - TestSuite_Add ( - suite, "/bson/as_json_with_opts/bool", test_bson_as_json_with_opts_bool); - TestSuite_Add (suite, - "/bson/as_json_with_opts/date_time", - test_bson_as_json_with_opts_date_time); - TestSuite_Add ( - suite, "/bson/as_json_with_opts/null", test_bson_as_json_with_opts_null); - TestSuite_Add (suite, - "/bson/as_json_with_opts/regex", - test_bson_as_json_with_opts_regex); - TestSuite_Add (suite, - "/bson/as_json_with_opts/dbpointer", - test_bson_as_json_with_opts_dbpointer); - TestSuite_Add ( - suite, "/bson/as_json_with_opts/code", test_bson_as_json_with_opts_code); - TestSuite_Add (suite, - "/bson/as_json_with_opts/symbol", - test_bson_as_json_with_opts_symbol); - TestSuite_Add (suite, - "/bson/as_json_with_opts/codewscope", - test_bson_as_json_with_opts_codewscope); - TestSuite_Add (suite, - "/bson/as_json_with_opts/int32", - test_bson_as_json_with_opts_int32); - TestSuite_Add (suite, - "/bson/as_json_with_opts/int64", - test_bson_as_json_with_opts_int64); - TestSuite_Add (suite, - "/bson/as_json_with_opts/timestamp", - test_bson_as_json_with_opts_timestamp); - TestSuite_Add (suite, - "/bson/as_json_with_opts/minkey", - test_bson_as_json_with_opts_minkey); - TestSuite_Add (suite, - "/bson/as_json_with_opts/maxkey", - test_bson_as_json_with_opts_maxkey); - TestSuite_Add (suite, - "/bson/as_json_with_opts/decimal128", - test_bson_as_json_with_opts_decimal128); - TestSuite_Add (suite, - "/bson/as_json_with_opts/all_types", - test_bson_as_json_with_opts_all_types); - TestSuite_Add (suite, "/bson/parse_array", test_parse_array); - TestSuite_Add (suite, - "/bson/decimal128_overflowing_exponent", - test_decimal128_overflowing_exponent); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-string.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-string.c deleted file mode 100644 index 8efd004b3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-string.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "TestSuite.h" - - -static void -test_bson_string_new (void) -{ - bson_string_t *str; - char *s; - - str = bson_string_new (NULL); - s = bson_string_free (str, false); - BSON_ASSERT (s); - BSON_ASSERT (!strcmp (s, "")); - bson_free (s); - - str = bson_string_new (""); - s = bson_string_free (str, false); - BSON_ASSERT (s); - BSON_ASSERT (!*s); - BSON_ASSERT (0 == strcmp (s, "")); - bson_free (s); - - str = bson_string_new ("abcdef"); - s = bson_string_free (str, false); - BSON_ASSERT (s); - BSON_ASSERT (!strcmp (s, "abcdef")); - bson_free (s); - - str = bson_string_new (""); - s = bson_string_free (str, true); - BSON_ASSERT (!s); -} - - -static void -test_bson_string_append (void) -{ - bson_string_t *str; - char *s; - - str = bson_string_new (NULL); - bson_string_append (str, "christian was here"); - bson_string_append (str, "\n"); - s = bson_string_free (str, false); - BSON_ASSERT (s); - BSON_ASSERT (!strcmp (s, "christian was here\n")); - bson_free (s); - - str = bson_string_new (">>>"); - bson_string_append (str, "^^^"); - bson_string_append (str, "<<<"); - s = bson_string_free (str, false); - BSON_ASSERT (s); - BSON_ASSERT (!strcmp (s, ">>>^^^<<<")); - bson_free (s); -} - - -static void -test_bson_string_append_c (void) -{ - bson_string_t *str; - char *s; - - str = bson_string_new (NULL); - bson_string_append_c (str, 'c'); - bson_string_append_c (str, 'h'); - bson_string_append_c (str, 'r'); - bson_string_append_c (str, 'i'); - bson_string_append_c (str, 's'); - s = bson_string_free (str, false); - BSON_ASSERT (s); - BSON_ASSERT (!strcmp (s, "chris")); - bson_free (s); -} - - -static void -test_bson_string_append_printf (void) -{ - bson_string_t *str; - - str = bson_string_new ("abcd "); - bson_string_append_printf (str, "%d %d %d", 1, 2, 3); - BSON_ASSERT (!strcmp (str->str, "abcd 1 2 3")); - bson_string_truncate (str, 2); - BSON_ASSERT (!strcmp (str->str, "ab")); - bson_string_free (str, true); -} - - -static void -test_bson_string_append_unichar (void) -{ - static const unsigned char test1[] = {0xe2, 0x82, 0xac, 0}; - bson_string_t *str; - char *s; - - str = bson_string_new (NULL); - bson_string_append_unichar (str, 0x20AC); - s = bson_string_free (str, false); - BSON_ASSERT (s); - BSON_ASSERT (!strcmp (s, (const char *) test1)); - bson_free (s); -} - - -static void -test_bson_strdup_printf (void) -{ - char *s; - - s = bson_strdup_printf ("%s:%u", "localhost", 27017); - BSON_ASSERT (!strcmp (s, "localhost:27017")); - bson_free (s); -} - - -static void -test_bson_strdup (void) -{ - char *s; - - s = bson_strdup ("localhost:27017"); - BSON_ASSERT (!strcmp (s, "localhost:27017")); - bson_free (s); -} - - -static void -test_bson_strndup (void) -{ - char *s; - - s = bson_strndup ("asdf", 2); - BSON_ASSERT (!strcmp (s, "as")); - bson_free (s); - - s = bson_strndup ("asdf", 10); - BSON_ASSERT (!strcmp (s, "asdf")); - bson_free (s); - - /* Some tests where we truncate to size n-1, n, n+1 */ - s = bson_strndup ("asdf", 3); - BSON_ASSERT (!strcmp (s, "asd")); - bson_free (s); - - s = bson_strndup ("asdf", 4); - BSON_ASSERT (!strcmp (s, "asdf")); - bson_free (s); - - s = bson_strndup ("asdf", 5); - BSON_ASSERT (!strcmp (s, "asdf")); - bson_free (s); -} - - -static void -test_bson_strnlen (void) -{ - char *s = "test"; - - ASSERT_CMPINT ((int) strlen (s), ==, (int) bson_strnlen (s, 100)); -} - - -typedef struct { - const char *str; - int base; - int64_t rv; - const char *remaining; - int _errno; -} strtoll_test; - - -static void -test_bson_ascii_strtoll (void) -{ -#ifdef END -#undef END -#endif -#define END "" - int64_t rv; - int i; - char *endptr; - strtoll_test tests[] = { - /* input, base, expected output, # of chars parsed, expected errno */ - {"1", 10, 1, END, 0}, - {"+1", 10, 1, END, 0}, - {"-1", 10, -1, END, 0}, - {"0", 10, 0, END, 0}, - {"0 ", 10, 0, " ", 0}, - {" 0 ", 10, 0, " ", 0}, - {" 0", 10, 0, END, 0}, - {" 0\"", 10, 0, "\"", 0}, - {"0l", 10, 0, "l", 0}, - {"0l ", 10, 0, "l ", 0}, - {"0u", 10, 0, "u", 0}, - {"0u ", 10, 0, "u ", 0}, - {"0L", 10, 0, "L", 0}, - {"0L ", 10, 0, "L ", 0}, - {"0U", 10, 0, "U", 0}, - {"0U ", 10, 0, "U ", 0}, - {"-0", 10, 0, END, 0}, - {"+0", 10, 0, END, 0}, - {"010", 8, 8, END, 0}, - /* stroll "takes as many characters as possible to form a valid base-n - * integer", so it ignores "8" and returns 0 */ - {"08", 0, 0, "8", 0}, - {"010", 10, 10, END, 0}, - {"010", 8, 8, END, 0}, - {"010", 0, 8, END, 0}, - {"68719476736", 10, 68719476736, END, 0}, - {"-68719476736", 10, -68719476736, END, 0}, - {"+68719476736", 10, 68719476736, END, 0}, - {" 68719476736 ", 10, 68719476736, " ", 0}, - {" 68719476736 ", 0, 68719476736, " ", 0}, - {" -68719476736 ", 10, -68719476736, " ", 0}, - {" -68719476736 ", 0, -68719476736, " ", 0}, - {" 4611686018427387904LL", 10, 4611686018427387904LL, "LL", 0}, - {" -4611686018427387904LL ", 10, -4611686018427387904LL, "LL ", 0}, - {"0x1000000000", 16, 68719476736, END, 0}, - {"0x1000000000", 0, 68719476736, END, 0}, - {"-0x1000000000", 16, -68719476736, END, 0}, - {"-0x1000000000", 0, -68719476736, END, 0}, - {"+0x1000000000", 16, 68719476736, END, 0}, - {"+0x1000000000", 0, 68719476736, END, 0}, - {"01234", 8, 668, END, 0}, - {"01234", 0, 668, END, 0}, - {"-01234", 8, -668, END, 0}, - {"-01234", 0, -668, END, 0}, - {"+01234", 8, 668, END, 0}, - {"+01234", 0, 668, END, 0}, - {"9223372036854775807", 10, INT64_MAX, END, 0}, - {"-9223372036854775808", 10, INT64_MIN, END, 0}, - {"9223372036854775808", 10, INT64_MAX, "8", ERANGE}, /* LLONG_MAX+1 */ - {"-9223372036854775809", 10, INT64_MIN, "9", ERANGE}, /* LLONG_MIN-1 */ - {"18446744073709551615", 10, INT64_MAX, "5", ERANGE}, /* 2*LLONG_MAX+1 */ - {"-18446744073709551618", 10, INT64_MIN, "8", ERANGE}, /* 2*LLONG_MIN-1 */ - {NULL}}; - - for (i = 0; tests[i].str; i++) { - errno = 0; - - rv = bson_ascii_strtoll (tests[i].str, &endptr, tests[i].base); - ASSERT_CMPINT64 (rv, ==, tests[i].rv); - ASSERT_CMPINT (errno, ==, tests[i]._errno); - ASSERT_CMPSTR (endptr, tests[i].remaining); - } -#undef END -} - - -static void -test_bson_strncpy (void) -{ - char buf[5]; - - bson_strncpy (buf, "foo", sizeof buf); - ASSERT_CMPSTR ("foo", buf); - bson_strncpy (buf, "foobar", sizeof buf); - ASSERT_CMPSTR ("foob", buf); - /* CDRIVER-2596 make sure strncpy with size 0 doesn't write to buf[-1] */ - bson_strncpy (buf + 1, "z", 0); - ASSERT_CMPSTR ("foob", buf); -} - - -static void -test_bson_snprintf (void) -{ - char buf[] = "ab"; - - /* CDRIVER-2595 make sure snprintf with size 0 doesn't write to buf[-1] */ - ASSERT_CMPINT (bson_snprintf (buf + 1, 0, "%d", 1), ==, 0); - ASSERT_CMPSTR (buf, "ab"); -} - - -static void -test_bson_strcasecmp (void) -{ - BSON_ASSERT (!bson_strcasecmp ("FoO", "foo")); - BSON_ASSERT (bson_strcasecmp ("Foa", "foo") < 0); - BSON_ASSERT (bson_strcasecmp ("FoZ", "foo") > 0); -} - - -void -test_string_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/bson/string/new", test_bson_string_new); - TestSuite_Add (suite, "/bson/string/append", test_bson_string_append); - TestSuite_Add (suite, "/bson/string/append_c", test_bson_string_append_c); - TestSuite_Add ( - suite, "/bson/string/append_printf", test_bson_string_append_printf); - TestSuite_Add ( - suite, "/bson/string/append_unichar", test_bson_string_append_unichar); - TestSuite_Add (suite, "/bson/string/strdup", test_bson_strdup); - TestSuite_Add (suite, "/bson/string/strdup_printf", test_bson_strdup_printf); - TestSuite_Add (suite, "/bson/string/strndup", test_bson_strndup); - TestSuite_Add (suite, "/bson/string/ascii_strtoll", test_bson_ascii_strtoll); - TestSuite_Add (suite, "/bson/string/strncpy", test_bson_strncpy); - TestSuite_Add (suite, "/bson/string/snprintf", test_bson_snprintf); - TestSuite_Add (suite, "/bson/string/strnlen", test_bson_strnlen); - TestSuite_Add (suite, "/bson/string/strcasecmp", test_bson_strcasecmp); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-utf8.c b/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-utf8.c deleted file mode 100644 index 14fe08d18..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libbson/tests/test-utf8.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "TestSuite.h" - - -static void -test_bson_utf8_validate (void) -{ - static const unsigned char test1[] = { - 0xe2, 0x82, 0xac, ' ', 0xe2, 0x82, 0xac, ' ', 0xe2, 0x82, 0xac, 0}; - static const unsigned char test2[] = {0xc0, 0x80, 0}; - static const unsigned char out_of_bound[] = { - 0xfd, 0x9f, 0xb0, 0x80, 0x80, 0x80, 0}; - static const unsigned char bad[] = {0xed, 0xa0, 0xa5, 0}; - - BSON_ASSERT (bson_utf8_validate ("asdf", 4, false)); - BSON_ASSERT (bson_utf8_validate ("asdf", 4, true)); - BSON_ASSERT (bson_utf8_validate ("asdf", 5, true)); - BSON_ASSERT (!bson_utf8_validate ("asdf", 5, false)); - - BSON_ASSERT (bson_utf8_validate ((const char *) test1, 11, true)); - BSON_ASSERT (bson_utf8_validate ((const char *) test1, 11, false)); - BSON_ASSERT (bson_utf8_validate ((const char *) test1, 12, true)); - BSON_ASSERT (!bson_utf8_validate ((const char *) test1, 12, false)); - - BSON_ASSERT (bson_utf8_validate ((const char *) test2, 2, true)); - BSON_ASSERT (!bson_utf8_validate ((const char *) test2, 2, false)); - - /* - * This character is allowed in 6-byte-sequence UTF-8 standard but seen as - * out of bound in 4-byte-sequence UTF-8 standard (RFC 3629). - */ - BSON_ASSERT (!bson_utf8_validate ((const char *) out_of_bound, 1, true)); - BSON_ASSERT (!bson_utf8_validate ((const char *) out_of_bound, 1, false)); - - /* - * Some UTF-8 code points are prohibited to match the constraints of - * the UTF-16 character encoding (RFC 3629). - */ - BSON_ASSERT (!bson_utf8_validate ((const char *) bad, 1, true)); - BSON_ASSERT (!bson_utf8_validate ((const char *) bad, 1, false)); -} - - -static void -test_bson_utf8_escape_for_json (void) -{ - char *str; - char *unescaped = "\x0e"; - - str = bson_utf8_escape_for_json ("my\0key", 6); - BSON_ASSERT (0 == memcmp (str, "my\\u0000key", 7)); - bson_free (str); - - str = bson_utf8_escape_for_json ("my\"key", 6); - BSON_ASSERT (0 == memcmp (str, "my\\\"key", 8)); - bson_free (str); - - str = bson_utf8_escape_for_json ("my\\key", 6); - BSON_ASSERT (0 == memcmp (str, "my\\\\key", 8)); - bson_free (str); - - str = bson_utf8_escape_for_json ("\\\"\\\"", -1); - BSON_ASSERT (0 == memcmp (str, "\\\\\\\"\\\\\\\"", 9)); - bson_free (str); - - str = bson_utf8_escape_for_json (unescaped, -1); - BSON_ASSERT (0 == memcmp (str, "\\u000e", 7)); - bson_free (str); -} - - -static void -test_bson_utf8_invalid (void) -{ - /* no UTF-8 sequence can start with 0x80 */ - static const unsigned char bad[] = {0x80, 0}; - - BSON_ASSERT (!bson_utf8_validate ((const char *) bad, 1, true)); - BSON_ASSERT (!bson_utf8_validate ((const char *) bad, 1, false)); - BSON_ASSERT (!bson_utf8_escape_for_json ((const char *) bad, 1)); -} - - -static void -test_bson_utf8_nil (void) -{ - static const unsigned char test[] = {'a', 0, 'b', 0}; - char *str; - - BSON_ASSERT (bson_utf8_validate ((const char *) test, 3, true)); - BSON_ASSERT (!bson_utf8_validate ((const char *) test, 3, false)); - - /* no length provided, stop at first nil */ - str = bson_utf8_escape_for_json ((const char *) test, -1); - ASSERT_CMPSTR ("a", str); - bson_free (str); - - str = bson_utf8_escape_for_json ((const char *) test, 3); - ASSERT_CMPSTR ("a\\u0000b", str); - bson_free (str); -} - - -static void -test_bson_utf8_get_char (void) -{ - static const char *test1 = "asdf"; - static const unsigned char test2[] = { - 0xe2, 0x82, 0xac, ' ', 0xe2, 0x82, 0xac, ' ', 0xe2, 0x82, 0xac, 0}; - const char *c; - - c = test1; - BSON_ASSERT (bson_utf8_get_char (c) == 'a'); - c = bson_utf8_next_char (c); - BSON_ASSERT (bson_utf8_get_char (c) == 's'); - c = bson_utf8_next_char (c); - BSON_ASSERT (bson_utf8_get_char (c) == 'd'); - c = bson_utf8_next_char (c); - BSON_ASSERT (bson_utf8_get_char (c) == 'f'); - c = bson_utf8_next_char (c); - BSON_ASSERT (!*c); - - c = (const char *) test2; - BSON_ASSERT (bson_utf8_get_char (c) == 0x20AC); - c = bson_utf8_next_char (c); - BSON_ASSERT (c == (const char *) test2 + 3); - BSON_ASSERT (bson_utf8_get_char (c) == ' '); - c = bson_utf8_next_char (c); - BSON_ASSERT (bson_utf8_get_char (c) == 0x20AC); - c = bson_utf8_next_char (c); - BSON_ASSERT (bson_utf8_get_char (c) == ' '); - c = bson_utf8_next_char (c); - BSON_ASSERT (bson_utf8_get_char (c) == 0x20AC); - c = bson_utf8_next_char (c); - BSON_ASSERT (!*c); -} - - -static void -test_bson_utf8_from_unichar (void) -{ - static const char test1[] = {'a'}; - static const unsigned char test2[] = {0xc3, 0xbf}; - static const unsigned char test3[] = {0xe2, 0x82, 0xac}; - uint32_t len; - char str[6]; - - /* - * First possible sequence of a certain length. - */ - bson_utf8_from_unichar (0, str, &len); - BSON_ASSERT (len == 1); - bson_utf8_from_unichar (0x00000080, str, &len); - BSON_ASSERT (len == 2); - bson_utf8_from_unichar (0x00000800, str, &len); - BSON_ASSERT (len == 3); - bson_utf8_from_unichar (0x00010000, str, &len); - BSON_ASSERT (len == 4); - - /* - * Last possible sequence of a certain length. - */ - bson_utf8_from_unichar (0x0000007F, str, &len); - BSON_ASSERT (len == 1); - bson_utf8_from_unichar (0x000007FF, str, &len); - BSON_ASSERT (len == 2); - bson_utf8_from_unichar (0x0000FFFF, str, &len); - BSON_ASSERT (len == 3); - bson_utf8_from_unichar (0x0010FFFF, str, &len); - BSON_ASSERT (len == 4); - - /* - * Other interesting values. - */ - bson_utf8_from_unichar (0x0000D7FF, str, &len); - BSON_ASSERT (len == 3); - bson_utf8_from_unichar (0x0000E000, str, &len); - BSON_ASSERT (len == 3); - bson_utf8_from_unichar (0x0000FFFD, str, &len); - BSON_ASSERT (len == 3); - bson_utf8_from_unichar (0x0010EFFF, str, &len); - BSON_ASSERT (len == 4); - bson_utf8_from_unichar (0x00110000, str, &len); - BSON_ASSERT (len == 4); - - bson_utf8_from_unichar ('a', str, &len); - BSON_ASSERT (len == 1); - BSON_ASSERT (!memcmp (test1, str, 1)); - - bson_utf8_from_unichar (0xFF, str, &len); - BSON_ASSERT (len == 2); - BSON_ASSERT (!memcmp ((const char *) test2, str, 2)); - - bson_utf8_from_unichar (0x20AC, str, &len); - BSON_ASSERT (len == 3); - BSON_ASSERT (!memcmp ((const char *) test3, str, 3)); -} - - -static void -test_bson_utf8_non_shortest (void) -{ - static const char *tests[] = { - "\xE0\x80\x80", /* Non-shortest form representation of U+0000 */ - "\xF0\x80\x80\x80", /* Non-shortest form representation of U+0000 */ - - "\xE0\x83\xBF", /* Non-shortest form representation of U+00FF */ - "\xF0\x80\x83\xBF", /* Non-shortest form representation of U+00FF */ - - "\xF0\x80\xA3\x80", /* Non-shortest form representation of U+08C0 */ - - NULL}; - static const char *valid_tests[] = { - "\xC0\x80", /* Non-shortest form representation of U+0000. - * This is how \0 should be encoded. Special casing - * to allow for use in things like strlen(). */ - - NULL}; - int i; - - for (i = 0; tests[i]; i++) { - if (bson_utf8_validate (tests[i], strlen (tests[i]), false)) { - fprintf (stderr, "non-shortest form failure, test %d\n", i); - BSON_ASSERT (false); - } - } - - for (i = 0; valid_tests[i]; i++) { - if (!bson_utf8_validate (valid_tests[i], strlen (valid_tests[i]), true)) { - fprintf (stderr, "non-shortest form failure, valid_tests %d\n", i); - BSON_ASSERT (false); - } - } -} - - -void -test_utf8_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/bson/utf8/validate", test_bson_utf8_validate); - TestSuite_Add (suite, "/bson/utf8/invalid", test_bson_utf8_invalid); - TestSuite_Add (suite, "/bson/utf8/nil", test_bson_utf8_nil); - TestSuite_Add ( - suite, "/bson/utf8/escape_for_json", test_bson_utf8_escape_for_json); - TestSuite_Add ( - suite, "/bson/utf8/get_char_next_char", test_bson_utf8_get_char); - TestSuite_Add ( - suite, "/bson/utf8/from_unichar", test_bson_utf8_from_unichar); - TestSuite_Add ( - suite, "/bson/utf8/non_shortest", test_bson_utf8_non_shortest); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/.gitignore b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/.gitignore deleted file mode 100644 index cd9a9c49c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/.gitignore +++ /dev/null @@ -1,50 +0,0 @@ -# CMake artifacts -libmongoc-1.0-config-version.cmake -libmongoc-1.0-config.cmake -libmongoc-static-1.0-config-version.cmake -libmongoc-static-1.0-config.cmake -mongoc/mongoc-1.0-config.cmake -mongoc/mongoc-1.0-config-version.cmake -mongoc/mongoc-targets.cmake - -# Test program for mongoc_get_accept_args in CMakeLists.txt -accept_test1.c - -# Example binaries -aggregation1 -basic-aggregation -bulk-collation -bulk1 -bulk2 -bulk3 -bulk4 -bulk5 -bulk6 -common-operations -example-client -example-collection-watch -example-command-monitoring -example-command-with-opts -example-manage-collection-indexes -example-gridfs -example-gridfs-bucket -example-pool -example-resume -example-scram -example-sdam-monitoring -example-session -example-start-at-optime -example-transaction -example-update -fam -find-and-modify -hello_mongoc -mongoc-dump -mongoc-ping -mongoc-stat -mongoc-tail - -# Test binaries -test-libmongoc -test-mongoc-gssapi -test-mongoc-cache diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/CMakeLists.txt deleted file mode 100644 index 3070c43ac..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/CMakeLists.txt +++ /dev/null @@ -1,1371 +0,0 @@ -cmake_minimum_required (VERSION 3.15) - -project (libmongoc - LANGUAGES C - # Inherit the version from mongo-c-driver - VERSION "${PROJECT_VERSION}" - DESCRIPTION "The MongoDB C Database Driver library" -) - -# These values are inherited from the mongo-c-driver parent. These are named as to -# match the CMake variables generated by project(). -set(libmongoc_VERSION_PRERELEASE ${mongo-c-driver_VERSION_PRERELEASE}) -set(libmongoc_VERSION_FULL ${mongo-c-driver_VERSION_FULL}) - -set (MONGOC_API_VERSION 1.0) - -include (CheckSchedGetCPU) -include (CheckStructHasMember) -include (CheckSymbolExists) -include (CheckTypeSize) -include (CMakePushCheckState) -include (InstallRequiredSystemLibraries) - -message (STATUS "libmongoc version (from VERSION_CURRENT file): ${MONGOC_VERSION}") - -set (MONGOC_API_VERSION 1.0) -set (MONGOC_TARGETS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/mongoc-${MONGOC_API_VERSION}") - -# Defaults. -set (MONGOC_ENABLE_COMPRESSION 0) -set (MONGOC_ENABLE_COMPRESSION_SNAPPY 0) -set (MONGOC_ENABLE_COMPRESSION_ZLIB 0) -set (MONGOC_ENABLE_COMPRESSION_ZSTD 0) - -# Definition for mongoc-config.h: -mongo_pick(MONGOC_ENABLE_SRV 1 0 ENABLE_SRV) - -set (MONGOC_OUTPUT_BASENAME "mongoc" CACHE STRING "Output mongoc library base name") - -if (NOT ENABLE_ZLIB MATCHES "SYSTEM|AUTO|BUNDLED|OFF") - message (FATAL_ERROR - "ENABLE_ZLIB option must be SYSTEM, BUNDLED, AUTO, or OFF" - ) -endif () - -if (NOT ENABLE_ZSTD MATCHES "ON|AUTO|OFF") - message (FATAL_ERROR "ENABLE_ZSTD option must be ON, AUTO, or OFF") -endif () - -set (ZLIB_INCLUDE_DIRS "") -if (ENABLE_ZLIB MATCHES "SYSTEM|AUTO") - message (STATUS "Searching for zlib CMake packages") - include (FindZLIB) - if (ZLIB_FOUND) - message (STATUS " zlib found version \"${ZLIB_VERSION_STRING}\"") - message (STATUS " zlib include path \"${ZLIB_INCLUDE_DIRS}\"") - message (STATUS " zlib libraries \"${ZLIB_LIBRARIES}\"") - else () - if (ENABLE_ZLIB STREQUAL "SYSTEM") - message (FATAL_ERROR - "Unable to find system zlib package. Either specify the zlib \ - location by setting ZLIB_ROOT, or else set ENABLE_ZLIB=BUNDLED or \ - set ENABLE_ZLIB=OFF." - ) - endif () - set (ZLIB_LIBRARIES "") - endif () -endif () - -if ( (ENABLE_ZLIB STREQUAL "BUNDLED") - OR (ENABLE_ZLIB STREQUAL "AUTO" AND NOT ZLIB_FOUND) ) - message (STATUS "Enabling zlib compression (bundled)") - add_library (zlib_obj OBJECT "${ZLIB_SOURCES}") - set_property (TARGET zlib_obj PROPERTY POSITION_INDEPENDENT_CODE TRUE) - # This tells the bundled zlib where to find its generated headers - target_include_directories (zlib_obj - BEFORE PUBLIC - "${SOURCE_DIR}/src/zlib-1.2.13" - "${CMAKE_BINARY_DIR}/src/zlib-1.2.13" - ) - # Disable all warnings for compiling Zlib - target_compile_options (zlib_obj PRIVATE -w) - set (SOURCES ${SOURCES} $) - # This tells mongoc_shared/mongoc_static where to find generated zlib headers - set ( - ZLIB_INCLUDE_DIRS - "${SOURCE_DIR}/src/zlib-1.2.13" - "${CMAKE_BINARY_DIR}/src/zlib-1.2.13" - ) -endif () - -if (NOT ENABLE_ZLIB STREQUAL "OFF") - # At this point the system zlib was found, or the bundled library was used - include (CheckIncludeFiles) - check_include_files ("unistd.h" HAVE_UNISTD_H) - check_include_files ("stdarg.h" HAVE_STDARG_H) - if (HAVE_UNISTD_H) - add_definitions (-DHAVE_UNISTD_H) - endif () - if (HAVE_STDARG_H) - add_definitions (-DHAVE_STDARG_H) - endif () - set (MONGOC_ENABLE_COMPRESSION 1) - set (MONGOC_ENABLE_COMPRESSION_ZLIB 1) -else () - message (STATUS "Disabling zlib compression") -endif () - -if (NOT ENABLE_ZSTD STREQUAL OFF) - message (STATUS "Searching for compression library zstd") - find_package(PkgConfig) - pkg_check_modules (ZSTD libzstd) - - if (NOT ZSTD_FOUND) - if (ENABLE_ZSTD MATCHES "ON") - message (FATAL_ERROR " Not found") - else () - message (STATUS " Not found") - endif () - # The compression format below this version isn't supported. See SERVER-43070 - elseif (${ZSTD_VERSION} VERSION_LESS "0.8.0") - if (ENABLE_ZSTD MATCHES "ON") - message (FATAL_ERROR "Detected zstd version ${ZSTD_VERSION} but version 0.8.0 required") - else () - message (STATUS "Detected zstd version ${ZSTD_VERSION} but version 0.8.0 required") - endif () - else () - message (STATUS " Found zstd version ${ZSTD_VERSION} in ${ZSTD_INCLUDE_DIRS}") - set (MONGOC_ENABLE_COMPRESSION 1) - set (MONGOC_ENABLE_COMPRESSION_ZSTD 1) - - include_directories (${ZSTD_INCLUDE_DIRS}) - link_directories (${ZSTD_LIBRARY_DIRS}) - set (MONGOC_ZSTD_LIBRARIES ${ZSTD_LINK_LIBRARIES}) - endif() -endif() - -add_library(_mongoc-dependencies INTERFACE) -add_library(mongo::detail::c_dependencies ALIAS _mongoc-dependencies) -target_link_libraries(_mongoc-dependencies INTERFACE mongo::detail::c_platform) -install(TARGETS _mongoc-dependencies EXPORT mongoc-targets) -set_property(TARGET _mongoc-dependencies PROPERTY EXPORT_NAME detail::c_dependencies) - -# d888888b db .d8888. -# `~~88~~' 88 88' YP -# 88 88 `8bo. -# 88 88 `Y8b. -# 88 88booo. db 8D -# YP Y88888P `8888Y' - -# Pick the TLS library to use. -function(_pick_which_tls_lib ssl_opt) - # Initial value, if not later set: - set_property(DIRECTORY PROPERTY _mongoc-tls-backend OFF) - if(ssl_opt STREQUAL "AUTO") - # Try to pick one automatically - _auto_pick_tls_lib() - elseif(ssl_opt) - # The user named a TLS library specifically. Use that one: - _use_named_tls_lib("${ssl_opt}") - else() - # User has disabled TLS selection - endif() -endfunction() - -# Attempt to automatically find and use a TLS library for the current platform -function(_auto_pick_tls_lib) - if(WIN32) - # Windows has SecureChannel - _use_named_tls_lib(WINDOWS) - elseif(APPLE) - # Apple has SecureTransport - _use_named_tls_lib(DARWIN) - else() - # Try to find one of the common open-source TLS libraries - find_package(OpenSSL) - if(OpenSSL_FOUND) - _use_named_tls_lib(OPENSSL) - else() - # No OpenSSL. What about LibreSSL? - find_package(LibreSSL) - if(LibreSSL_FOUND) - _use_named_tls_lib(LIBRESSL) - endif() - endif() - endif() -endfunction() - -# Per-backend link libs/options: -set(SecureTransport/LINK_LIBRARIES "-framework CoreFoundation" "-framework Security") -set(SecureTransport/pkg_config_LIBS -framework Corefoundation -framework Security) -set(SecureChannel/LINK_LIBRARIES secur32.lib crypt32.lib Bcrypt.lib) -set(SecureChannel/pkg_config_LIBS ${SecureChannel/LINK_LIBRARIES}) -set(LibreSSL/LINK_LIBRARIES LibreSSL::TLS LibreSSL::Crypto) -set(LibreSSL/pkg_config_LIBS -ltls -lcrypto) -set(OpenSSL/LINK_LIBRARIES OpenSSL::SSL OpenSSL::Crypto $<$:crypt32.lib>) -set(OpenSSL/pkg_config_LIBS -lssl -lcrypto $<$:crypt32.lib>) -# Use *exactly* the TLS library identified by the given name, which is one of -# `OPENSSL`, `LIBRESSL`, `DARWIN`, or `WINDOWS`. -function(_use_named_tls_lib libname) - # Use this property to track what package we import for our TLS libraries: - set_property(DIRECTORY PROPERTY _mongoc-tls-package NO) - if(libname STREQUAL "OPENSSL") - find_package(OpenSSL REQUIRED) - set(backend OpenSSL) - set_property(DIRECTORY PROPERTY _mongoc-tls-package OpenSSL) - elseif(libname STREQUAL "LIBRESSL") - find_package(LibreSSL REQUIRED) - set(backend LibreSSL) - install( - FILES "${mongo-c-driver_SOURCE_DIR}/build/cmake/FindLibreSSL.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/mongoc-${MONGOC_API_VERSION}/3rdParty" - ) - set_property(DIRECTORY PROPERTY _mongoc-tls-package LibreSSL) - elseif(libname STREQUAL "DARWIN") - set(backend SecureTransport) - elseif(libname STREQUAL "WINDOWS") - set(backend SecureChannel) - else() - message(FATAL_ERROR "Unknown TLS library requested: “${libname}â€") - endif() - add_library(_mongoc-tls_backend INTERFACE) - install(TARGETS _mongoc-tls_backend EXPORT mongoc-targets) - target_link_libraries(_mongoc-dependencies INTERFACE _mongoc-tls_backend) - set_property(TARGET _mongoc-tls_backend PROPERTY EXPORT_NAME detail::c_tls_backend) - target_link_libraries(_mongoc-tls_backend INTERFACE ${${backend}/LINK_LIBRARIES}) - target_link_options(_mongoc-tls_backend INTERFACE ${${backend}/LINK_OPTIONS}) - set_property(DIRECTORY PROPERTY _mongoc-tls-backend "${backend}") -endfunction() - -_pick_which_tls_lib("${ENABLE_SSL}") -# This property will be set by _pick_which_tls_lib: -get_directory_property(TLS_BACKEND _mongoc-tls-backend) -message(STATUS "libmongoc TLS : ${TLS_BACKEND}") -# Used by *-config.cmake to do a find_dependency(): -get_directory_property(TLS_IMPORT_PACKAGE _mongoc-tls-package) -set_package_properties( - OpenSSL PROPERTIES - DESCRIPTION "the standard open-source implementation of TLS, X509, and more" - TYPE OPTIONAL - PURPOSE "Provides a cryptography and TLS backend" -) -set_package_properties( - LibreSSL PROPERTIES - DESCRIPTION "an alternative implementation of the OpenSSL interface, created by the OpenBSD project" - TYPE OPTIONAL - PURPOSE "Provides a cryptography and TLS backend" -) - -mongo_bool01(MONGOC_ENABLE_SSL [[TLS_BACKEND]]) -mongo_bool01(MONGOC_ENABLE_SSL_SECURE_CHANNEL [[TLS_BACKEND STREQUAL "SecureChannel"]]) -mongo_bool01(MONGOC_ENABLE_SSL_SECURE_TRANSPORT [[TLS_BACKEND STREQUAL "SecureTransport"]]) -mongo_bool01(MONGOC_ENABLE_SSL_OPENSSL [[TLS_BACKEND STREQUAL "OpenSSL"]]) -mongo_bool01(MONGOC_ENABLE_SSL_LIBRESSL [[TLS_BACKEND STREQUAL "LibreSSL"]]) - -mongo_bool01(MONGOC_ENABLE_CRYPTO [[TLS_BACKEND]]) -mongo_bool01(MONGOC_ENABLE_CRYPTO_LIBCRYPTO [[MONGOC_ENABLE_SSL_OPENSSL OR MONGOC_ENABLE_SSL_LIBRESSL]]) -mongo_bool01(MONGOC_ENABLE_CRYPTO_CNG [[MONGOC_ENABLE_SSL_SECURE_CHANNEL]]) -mongo_bool01(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO [[MONGOC_ENABLE_SSL_SECURE_TRANSPORT]]) -mongo_bool01(MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE [[ENABLE_CRYPTO_SYSTEM_PROFILE]]) -add_feature_info("TLS" "${MONGOC_ENABLE_SSL}" "for secure network communication (${TLS_BACKEND})") -add_feature_info("Cryptography" "${MONGOC_ENABLE_CRYPTO}" "cryptographic primitives (${TLS_BACKEND})") - -include(CMakePushCheckState) -include(CheckSymbolExists) -if(TLS_BACKEND STREQUAL "OpenSSL") - # Check for newer OpenSSL string functions - cmake_push_check_state() - list(APPEND CMAKE_REQUIRED_LIBRARIES OpenSSL::SSL OpenSSL::Crypto) - check_symbol_exists( - ASN1_STRING_get0_data - "openssl/asn1.h" - HAVE_ASN1_STRING_GET0_DATA - ) - cmake_pop_check_state() -endif() -mongo_bool01(MONGOC_HAVE_ASN1_STRING_GET0_DATA [[HAVE_ASN1_STRING_GET0_DATA]]) - -if(ENABLE_CRYPTO_SYSTEM_PROFILE AND NOT MONGOC_ENABLE_SSL_OPENSSL) - message (FATAL_ERROR "ENABLE_CRYPTO_SYSTEM_PROFILE is only available with OpenSSL") -endif() - -set(_aws_feature_desc "authenticate with MongoDB servers using credentials from AWS instance metadata") -if(ENABLE_MONGODB_AWS_AUTH) - # We may want AWS auth - if(NOT MONGOC_ENABLE_SSL) - # No TLS libs - if(ENABLE_MONGODB_AWS_AUTH STREQUAL "AUTO") - # Okay: Just turn it off - message(STATUS "Note: AWS Authentication was disabled automatically because no TLS library is found/enabled") - set(_enable_aws_auth FALSE) - add_feature_info("AWS Authentication" OFF "${_aws_feature_desc}. (Disabled automatically: No TLS backend available)") - else() - # Bad - message(FATAL_ERROR "MongoDB AWS Authentication requires a TLS library, no TLS library was found/enabled") - endif() - endif() - set(_enable_aws_auth TRUE) - add_feature_info("AWS Authentication" ON "${_aws_feature_desc}") -else() - # AWS Auth is explicitly disabled - set(_enable_aws_auth FALSE) - add_feature_info("AWS Authentication" OFF "${_aws_feature_desc}. (Manually disabled)") -endif() - -# .d8888. .d8b. .d8888. db -# 88' YP d8' `8b 88' YP 88 -# `8bo. 88ooo88 `8bo. 88 -# `Y8b. 88~~~88 `Y8b. 88 -# db 8D 88 88 db 8D 88booo. -# `8888Y' YP YP `8888Y' Y88888P - -function(_pick_sasl sasl) - if(sasl STREQUAL "AUTO") - if(WIN32) - # On Windows: Use SSPI - _use_sasl("SSPI") - else() - # Other platforms: Use Cyrus (aka libsasl2) - find_package(SASL2 2.0) - if(SASL2_FOUND) - # Found it - _use_sasl("CYRUS") - else() - # Nope. That's okay, just turn SASL off - set_property(DIRECTORY PROPERTY _mongoc-sasl-backend NOTFOUND) - endif() - endif() - elseif(sasl) - _use_sasl("${sasl}") - else() - set_property(DIRECTORY PROPERTY _mongoc-sasl-backend OFF) - endif() -endfunction() - -# Use the named SASL library. Must be either "CYRUS" or "SSPI" -function(_use_sasl libname) - add_library(_mongoc-sasl_backend INTERFACE) - set_property(TARGET _mongoc-sasl_backend PROPERTY EXPORT_NAME detail::c_sasl_backend) - target_link_libraries(_mongoc-dependencies INTERFACE _mongoc-sasl_backend) - install(TARGETS _mongoc-sasl_backend EXPORT mongoc-targets) - if(libname STREQUAL "SSPI") - target_link_libraries(_mongoc-sasl_backend INTERFACE secur32.lib crypt32.lib Shlwapi.lib) - set(backend "SSPI") - elseif(libname STREQUAL "CYRUS") - find_package(SASL2 2.0 REQUIRED) - target_link_libraries(_mongoc-sasl_backend INTERFACE SASL2::SASL2) - install(FILES "${mongo-c-driver_SOURCE_DIR}/build/cmake/FindSASL2.cmake" DESTINATION "${MONGOC_TARGETS_INSTALL_DIR}/3rdParty") - set(backend "Cyrus") - else() - message(FATAL_ERROR "Unknown SASL backend “${libname}â€") - endif() - set_property(DIRECTORY PROPERTY _mongoc-sasl-backend "${backend}") -endfunction() - -_pick_sasl("${ENABLE_SASL}") -# Variable is used here, as well as within the mongoc-config.cmake template: -get_directory_property(SASL_BACKEND _mongoc-sasl-backend) -message(STATUS "Using SASL backend : ${SASL_BACKEND}") -set_package_properties(SASL2 PROPERTIES - DESCRIPTION "Cyrus implementation of SASL" - TYPE OPTIONAL - PURPOSE "Provides libmongoc SASL authentication support" - ) - -if(SASL_BACKEND STREQUAL "Cyrus") - cmake_push_check_state() - list(APPEND CMAKE_REQUIRED_LIBRARIES SASL2::SASL2) - check_symbol_exists( - sasl_client_done - sasl/sasl.h - SASL2_HAVE_SASL_CLIENT_DONE - ) - cmake_pop_check_state() -endif() - -mongo_bool01(MONGOC_HAVE_SASL_CLIENT_DONE [[SASL2_HAVE_SASL_CLIENT_DONE]]) -mongo_bool01(MONGOC_ENABLE_SASL_SSPI [[SASL_BACKEND STREQUAL "SSPI"]]) -mongo_bool01(MONGOC_ENABLE_SASL_CYRUS [[SASL_BACKEND STREQUAL "Cyrus"]]) -mongo_bool01(MONGOC_ENABLE_SASL [[MONGOC_ENABLE_SASL_SSPI OR MONGOC_ENABLE_SASL_CYRUS]]) -add_feature_info( - "SASL Authentication" - "${MONGOC_ENABLE_SASL}" - "authenticate with MongoDB servers using SASL: “Simple Authentication and Security Layer†(${SASL_BACKEND})" -) - -if (ENABLE_AUTOMATIC_INIT_AND_CLEANUP) - set (MONGOC_NO_AUTOMATIC_GLOBALS 0) -else () - set (MONGOC_NO_AUTOMATIC_GLOBALS 1) -endif () - -if (WIN32) - SET (CMAKE_EXTRA_INCLUDE_FILES "ws2tcpip.h") -else () - SET (CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h") -endif () -CHECK_TYPE_SIZE (socklen_t HAVE_SOCKLEN) -SET (CMAKE_EXTRA_INCLUDE_FILES) - -if (HAVE_SOCKLEN) - set (MONGOC_HAVE_SOCKLEN 1) - set (MONGOC_SOCKET_ARG3 "socklen_t") -else () - set (MONGOC_HAVE_SOCKLEN 0) - set (MONGOC_SOCKET_ARG3 "int") -endif () - -# Find name resolution libaries. Also sets definitions used in configure_file(): -include(ResSearch) - -function (mongoc_get_accept_args ARG2 ARG3) - SET (VAR 0) - foreach (ARG2_VAL "struct sockaddr" "void") - foreach (ARG3_VAL "socklen_t" "size_t" "int") - - MATH (EXPR VAR "${VAR}+1") - - FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/accept_test${VAR}.c - "#include - #include - - int main () - { - int a = 0; - ${ARG2_VAL} *b = 0; - ${ARG3_VAL} *c = 0; - accept (a, b, c); - return 0; - } - ") - - TRY_COMPILE (RES ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/accept_test${VAR}.c CMAKE_FLAGS - "-Werror -DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'" OUTPUT_VARIABLE LOG2) - - if (RES) - message ( - STATUS - "Detected parameters: accept (int, ${ARG2_VAL} *, ${ARG3_VAL} *)") - - set (${ARG2} ${ARG2_VAL} PARENT_SCOPE) - set (${ARG3} ${ARG3_VAL} PARENT_SCOPE) - return () - endif () - - endforeach () - endforeach () - -endfunction () - -# Reasonable defaults. -set (MONGOC_SOCKET_ARG2 "struct sockaddr") -set (MONGOC_SOCKET_ARG3 "socklen_t") - -if (NOT WIN32) - mongoc_get_accept_args (MONGOC_SOCKET_ARG2 MONGOC_SOCKET_ARG3) -endif () - -set (MONGOC_CC ${CMAKE_C_COMPILER}) -set (MONGOC_USER_SET_CFLAGS ${CMAKE_C_FLAGS}) -set (MONGOC_USER_SET_LDFLAGS ${CMAKE_EXE_LINKER_FLAGS}) - -if (ENABLE_TRACING) - set (MONGOC_TRACE 1) -else () - set (MONGOC_TRACE 0) -endif () - -# Sets SNAPPY_LIBRARIES and SNAPPY_INCLUDE_DIRS. -include (FindSnappy) -if (SNAPPY_INCLUDE_DIRS) - set (MONGOC_ENABLE_COMPRESSION 1) - include_directories ("${SNAPPY_INCLUDE_DIRS}") -endif () - -mongo_bool01 (MONGOC_ENABLE_SHM_COUNTERS ENABLE_SHM_COUNTERS) - -# Configure In-Use Encryption -set (MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION 0) -if (NOT ENABLE_CLIENT_SIDE_ENCRYPTION MATCHES "AUTO|ON|OFF") - message (FATAL_ERROR, "ENABLE_CLIENT_SIDE_ENCRYPTION option must be AUTO, ON, or OFF") -endif () - -if (NOT MONGOC_ENABLE_SSL) - if (ENABLE_CLIENT_SIDE_ENCRYPTION STREQUAL ON) - message (FATAL_ERROR "SSL disabled, but is required for Client-Side Field Level Encryption support.") - elseif (ENABLE_CLIENT_SIDE_ENCRYPTION STREQUAL AUTO) - message (STATUS "SSL disabled. Configuring without Client-Side Field Level Encryption support.") - endif () -elseif (NOT ENABLE_CLIENT_SIDE_ENCRYPTION STREQUAL OFF) - message (STATUS "Searching for libmongocrypt") - if (ENABLE_CLIENT_SIDE_ENCRYPTION STREQUAL ON) - # do not suppress log output if find_package cannot find libmongocrypt - find_package (mongocrypt) - elseif (ENABLE_CLIENT_SIDE_ENCRYPTION STREQUAL AUTO) - find_package (mongocrypt QUIET) - endif () - - if (mongocrypt_FOUND AND "${mongocrypt_VERSION}" VERSION_LESS 1.8.0) - message (STATUS " libmongocrypt found at ${mongocrypt_DIR}") - message (STATUS " libmongocrypt version ${mongocrypt_VERSION} found") - message (STATUS " libmongocrypt version 1.8.0 is required to enable Client-Side Field Level Encryption Support.") - set (REQUIRED_MONGOCRYPT_VERSION_FOUND OFF) - elseif (mongocrypt_FOUND) - set (REQUIRED_MONGOCRYPT_VERSION_FOUND ON) - else () - set (REQUIRED_MONGOCRYPT_VERSION_FOUND OFF) - endif () - - if (REQUIRED_MONGOCRYPT_VERSION_FOUND) - set (LIBMONGOCRYPT_TARGET mongo::mongocrypt) - get_target_property (LIBMONGOCRYPT_RUNTIME_LIBRARY mongo::mongocrypt LOCATION) - get_filename_component(LIBMONGOCRYPT_LIBRARY_LOCATION ${LIBMONGOCRYPT_RUNTIME_LIBRARY} DIRECTORY) - find_library (LIBMONGOCRYPT_LIBRARY NAMES mongocrypt PATHS ${LIBMONGOCRYPT_LIBRARY_LOCATION}) - get_target_property (LIBMONGOCRYPT_INCLUDE_DIRECTORIES mongo::mongocrypt INTERFACE_INCLUDE_DIRECTORIES) - message (STATUS " libmongocrypt found at ${LIBMONGOCRYPT_LIBRARY}") - message (STATUS " libmongocrypt include path ${LIBMONGOCRYPT_INCLUDE_DIRECTORIES}") - message (STATUS " libmongocrypt version ${mongocrypt_VERSION}") - set (MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION 1) - elseif (ENABLE_CLIENT_SIDE_ENCRYPTION STREQUAL ON) - message (FATAL_ERROR "Required library (libmongocrypt) not found.") - else () - message (STATUS "libmongocrypt not found. Configuring without Client-Side Field Level Encryption support.") - endif () -endif () - -CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" ss_family "sys/socket.h" MONGOC_HAVE_SS_FAMILY) -if (NOT MONGOC_HAVE_SS_FAMILY) - set (MONGOC_HAVE_SS_FAMILY 0) -else () - set (MONGOC_HAVE_SS_FAMILY 1) -endif () - - -set (SOURCES ${SOURCES} - ${PROJECT_SOURCE_DIR}/src/mongoc/mcd-azure.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mcd-rpc.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-aggregate.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-apm.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-array.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-async.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-async-cmd.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-buffer.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-bulk-operation.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-change-stream.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-client.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-client-pool.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-client-side-encryption.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cluster.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cluster-aws.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cluster-sasl.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-collection.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-compression.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-counters.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-crypt.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor-array.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor-cmd.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor-change-stream.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor-cmd-deprecated.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor-find.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor-find-cmd.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor-find-opquery.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor-legacy.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor-array.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-database.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-error.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-deprioritized-servers.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-flags.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-find-and-modify.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-generation-map.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-init.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs-bucket.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs-bucket-file.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs-file.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-list.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-page.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-list.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-handshake.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-host-list.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-http.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-index.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-init.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-interrupt.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-list.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-linux-distro-scanner.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-log.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-matcher.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-matcher-op.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-memcmp.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cmd.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-opcode.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-optional.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-opts-helpers.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-opts.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-queue.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-read-concern.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-read-prefs.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-rpc.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-server-api.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-server-description.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-server-stream.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-client-session.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-server-monitor.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-set.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-shared.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-socket.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-buffered.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-file.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-gridfs.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-gridfs-download.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-gridfs-upload.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-socket.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-timeout.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-topology.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-topology-background-monitoring.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-topology-description.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-topology-description-apm.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-topology-scanner.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-ts-pool.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-uri.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-util.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-version-functions.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-write-command.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-write-concern.c - ${PROJECT_SOURCE_DIR}/src/mongoc/service-gcp.c - ${PROJECT_SOURCE_DIR}/../../src/common/common-b64.c - ${PROJECT_SOURCE_DIR}/../../src/common/common-md5.c - ${PROJECT_SOURCE_DIR}/../../src/common/common-thread.c - - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-crypto.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-scram.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-tls.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-ssl.c - - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-crypto-openssl.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-rand-openssl.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-tls-libressl.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-libressl.c - - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-crypto-cng.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-rand-cng.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-tls-secure-channel.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-secure-channel.c - - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-crypto-common-crypto.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-rand-common-crypto.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-tls-secure-transport.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-secure-transport.c - - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-crypto-openssl.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-rand-openssl.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-tls-openssl.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-tls-openssl-bio.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-openssl.c - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-ocsp-cache.c -) - -set (HEADERS - ${PROJECT_BINARY_DIR}/src/mongoc/mongoc-config.h - ${PROJECT_BINARY_DIR}/src/mongoc/mongoc-version.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-apm.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-bulk-operation.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-change-stream.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-client.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-client-pool.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-client-side-encryption.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-collection.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-database.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-error.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-flags.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-find-and-modify.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs-bucket.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs-file.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-page.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-list.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-handshake.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-host-list.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-init.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-index.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-iovec.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-log.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-macros.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-matcher.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-opcode.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-optional.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-prelude.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-read-concern.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-read-prefs.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-server-api.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-server-description.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-client-session.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-sleep.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-socket.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-tls-libressl.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-tls-openssl.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-buffered.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-file.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-gridfs.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-socket.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-topology-description.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-uri.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-version-functions.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-write-concern.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-rand.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-tls.h - ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-ssl.h -) - -set (HEADERS_FORWARDING - ${PROJECT_SOURCE_DIR}/src/mongoc/forwarding/mongoc.h -) - -configure_file ( - "${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-config.h.in" - "${PROJECT_BINARY_DIR}/src/mongoc/mongoc-config.h" -) - -configure_file ( - "${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-version.h.in" - "${PROJECT_BINARY_DIR}/src/mongoc/mongoc-version.h" -) - -if (ENABLE_APPLE_FRAMEWORK) - configure_file ( - "${PROJECT_SOURCE_DIR}/src/mongoc/modules/module.modulemap.in" - "${PROJECT_BINARY_DIR}/src/mongoc/modules/module.modulemap" - ) -endif () - -if (MONGOC_ENABLE_SASL) - set (SOURCES ${SOURCES} ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-sasl.c) - if (MONGOC_ENABLE_SASL_CYRUS) - message (STATUS "Compiling against Cyrus SASL") - set (SOURCES ${SOURCES} ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cluster-cyrus.c) - set (SOURCES ${SOURCES} ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cyrus.c) - elseif (MONGOC_ENABLE_SASL_SSPI) - message (STATUS "Compiling against Windows SSPI") - set (SOURCES ${SOURCES} ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cluster-sspi.c) - set (SOURCES ${SOURCES} ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-sspi.c) - endif () -else () - message (STATUS "SASL disabled") -endif () - -set (LIBRARIES - ${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY} -) -set (STATIC_LIBRARIES - ${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY} -) - -# utf8proc configuration -find_package(Utf8Proc REQUIRED) -set(UTF8PROC_INCLUDE_DIRS, "") -if (USE_BUNDLED_UTF8PROC) - set ( - UTF8PROC_INCLUDE_DIRS - "${SOURCE_DIR}/src/utf8proc-2.8.0" - ) - list(APPEND SOURCES $) -else() - target_link_libraries(_mongoc-dependencies INTERFACE utf8proc) -endif() - -if(ENABLE_SRV) - # Interface target defined by ResSearch.cmake: - if(NOT TARGET mongo::detail::c_resolve) - message(SEND_ERROR "ENABLE_SRV is “${ENABLE_SRV}â€, but we were unable to find a name resolution library") - endif() - target_link_libraries(_mongoc-dependencies INTERFACE mongo::detail::c_resolve) -endif() - -if (MONGOC_ENABLE_MONGODB_AWS_AUTH) - # Disable warnings on bundled kms_message source files. - set_source_files_properties (${KMS_MSG_SOURCES} PROPERTIES COMPILE_FLAGS -w) - set (SOURCES ${SOURCES} ${KMS_MSG_SOURCES}) - - set (KMS_MSG_DEFINITIONS KMS_MSG_STATIC KMS_MESSAGE_ENABLE_CRYPTO) - include (TestBigEndian) - TEST_BIG_ENDIAN (KMS_BIG_ENDIAN) - if (KMS_BIG_ENDIAN) - set (KMS_MSG_DEFINITIONS ${KMS_MSG_DEFINITIONS} KMS_MESSAGE_BIG_ENDIAN) - else () - set (KMS_MSG_DEFINITIONS ${KMS_MSG_DEFINITIONS} KMS_MESSAGE_LITTLE_ENDIAN) - endif () - - if (MONGOC_ENABLE_CRYPTO_CNG) - set (KMS_MSG_DEFINITIONS ${KMS_MSG_DEFINITIONS} KMS_MESSAGE_ENABLE_CRYPTO_CNG) - elseif (MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO) - set (KMS_MSG_DEFINITIONS ${KMS_MSG_DEFINITIONS} KMS_MESSAGE_ENABLE_CRYPTO_COMMON_CRYPTO) - elseif(MONGOC_ENABLE_CRYPTO_LIBCRYPTO) - set (KMS_MSG_DEFINITIONS ${KMS_MSG_DEFINITIONS} KMS_MESSAGE_ENABLE_CRYPTO_LIBCRYPTO) - else () - message (FATAL_ERROR "MONGODB-AWS requires a crypto library") - endif() -endif () - -if (MONGOC_ENABLE_STATIC_BUILD) - add_library (mcd_rpc STATIC EXCLUDE_FROM_ALL ${PROJECT_SOURCE_DIR}/src/mongoc/mcd-rpc.c) - target_include_directories (mcd_rpc PUBLIC ${PROJECT_SOURCE_DIR}/src) - target_link_libraries (mcd_rpc PUBLIC ${BSON_STATIC_LIBRARIES}) - if (NOT WIN32 AND ENABLE_PIC) - target_compile_options (mcd_rpc PUBLIC -fPIC) - endif () - target_compile_definitions (mcd_rpc PUBLIC ${BSON_STATIC_PUBLIC_DEFINITIONS}) - set_target_properties (mcd_rpc PROPERTIES OUTPUT_NAME "mcd-rpc") -endif () - -set_property( - SOURCE ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cyrus.c - APPEND PROPERTY COMPILE_DEFINITIONS - "MONGOC_CYRUS_PLUGIN_PATH_PREFIX=$,NULL,\"${CYRUS_PLUGIN_PATH_PREFIX}\">" -) - -if (ENABLE_SHARED) - add_library (mongoc_shared SHARED ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) - if(WIN32) - # Add resource-definition script for Windows shared library (.dll). - configure_file(libmongoc.rc.in libmongoc.rc) - target_sources(mongoc_shared PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/libmongoc.rc) - endif() - set_target_properties (mongoc_shared PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidden) - target_link_libraries (mongoc_shared PRIVATE ${LIBRARIES} PUBLIC ${BSON_LIBRARIES} mongo::detail::c_dependencies) - target_include_directories (mongoc_shared PRIVATE ${ZLIB_INCLUDE_DIRS}) - target_include_directories (mongoc_shared PRIVATE ${UTF8PROC_INCLUDE_DIRS}) - target_include_directories (mongoc_shared PRIVATE ${LIBMONGOCRYPT_INCLUDE_DIRECTORIES}) - if (MONGOC_ENABLE_MONGODB_AWS_AUTH) - target_include_directories (mongoc_shared PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../kms-message/src") - if (APPLE) - set_target_properties (mongoc_shared PROPERTIES LINK_FLAGS "-Wl,-unexported_symbols_list,\"${CMAKE_CURRENT_SOURCE_DIR}/../../build/cmake/libmongoc-hidden-symbols.txt\"") - elseif (UNIX) - set_target_properties (mongoc_shared PROPERTIES LINK_FLAGS "-Wl,--version-script=\"${CMAKE_CURRENT_SOURCE_DIR}/../../build/cmake/libmongoc-hidden-symbols.map\"") - endif () - - endif () - target_compile_definitions (mongoc_shared - PRIVATE - MONGOC_COMPILATION - ${KMS_MSG_DEFINITIONS} - MCOMMON_NAME_PREFIX=_mongoc_mcommon - ) - - if (USE_BUNDLED_UTF8PROC) - target_compile_definitions (mongoc_shared PRIVATE UTF8PROC_STATIC) - endif () - - # Several directories in the source and build trees contain headers we would like - # include via relative reference, but they all end up in the same install path - target_include_directories ( - mongoc_shared - PUBLIC - $ - $ - $ - $ - $ - $ - $ - ) - - set_target_properties (mongoc_shared PROPERTIES - OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}-${MONGOC_API_VERSION}" - VERSION 0.0.0 - SOVERSION 0 - pkg_config_REQUIRES "libbson-1.0" - ) - mongo_generate_pkg_config(mongoc_shared INSTALL RENAME libmongoc-${MONGOC_API_VERSION}.pc) - - if (ENABLE_APPLE_FRAMEWORK) - set_target_properties (mongoc_shared PROPERTIES - FRAMEWORK TRUE - MACOSX_FRAMEWORK_BUNDLE_VERSION ${MONGOC_VERSION} - MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${MONGOC_VERSION} - MACOSX_FRAMEWORK_IDENTIFIER org.mongodb.mongoc - OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}" - PUBLIC_HEADER "${HEADERS}" - ) - endif () # ENABLE_APPLE_FRAMEWORK - - add_executable (mongoc-stat ${PROJECT_SOURCE_DIR}/../../src/tools/mongoc-stat.c) - target_link_libraries (mongoc-stat mongoc_shared ${LIBRARIES}) - - # mongoc-stat works if shared memory performance counters are enabled. - if (ENABLE_SHM_COUNTERS) - install (TARGETS mongoc-stat - EXPORT mongoc_targets - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") - endif () # ENABLE_SHM_COUNTERS - -endif () # ENABLE_SHARED - -if (MONGOC_ENABLE_STATIC_BUILD) - add_library (mongoc_static STATIC ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) - target_link_libraries (mongoc_static PUBLIC ${STATIC_LIBRARIES} ${BSON_STATIC_LIBRARIES} mongo::detail::c_dependencies) - if (NOT WIN32 AND ENABLE_PIC) - target_compile_options (mongoc_static PUBLIC -fPIC) - message (STATUS "Adding -fPIC to compilation of mongoc_static components") - endif () - if(ENABLE_SRV AND RESOLVE_LIB_NAME) - # The static library needs to link to the resolver in pkg-config: - set_property(TARGET mongoc_static APPEND PROPERTY pkg_config_LIBS "-l${RESOLVE_LIB_NAME}") - endif() - if(SASL_BACKEND STREQUAL "Cyrus") - set_property(TARGET mongoc_static APPEND PROPERTY pkg_config_LIBS "-lsasl2") - endif() - - set_property(TARGET mongoc_static APPEND PROPERTY pkg_config_LIBS ${${TLS_BACKEND}/pkg_config_LIBS}) - target_include_directories (mongoc_static PRIVATE ${ZLIB_INCLUDE_DIRS}) - target_include_directories (mongoc_static PRIVATE ${UTF8PROC_INCLUDE_DIRS}) - target_include_directories (mongoc_static PRIVATE ${LIBMONGOCRYPT_INCLUDE_DIRECTORIES}) - if (MONGOC_ENABLE_MONGODB_AWS_AUTH) - target_include_directories (mongoc_static PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../kms-message/src") - endif () - target_compile_definitions (mongoc_static - PUBLIC - MONGOC_STATIC - ${BSON_STATIC_PUBLIC_DEFINITIONS} - PRIVATE - MONGOC_COMPILATION - ${KMS_MSG_DEFINITIONS} - MCOMMON_NAME_PREFIX=_mongoc_mcommon - ) - if (USE_BUNDLED_UTF8PROC) - target_compile_definitions (mongoc_static PRIVATE UTF8PROC_STATIC) - endif () - # Several directories in the source and build trees contain headers we would like - # include via relative reference, but they all end up in the same install path - target_include_directories ( - mongoc_static - PUBLIC - $ - $ - $ - $ - $ - $ - $ - ) - set_target_properties (mongoc_static PROPERTIES - VERSION 0.0.0 - OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}-static-${MONGOC_API_VERSION}" - pkg_config_REQUIRES "libbson-static-1.0" - ) - if(MONGOC_ENABLE_STATIC_INSTALL) - mongo_generate_pkg_config (mongoc_static FILENAME libmongoc-static-${MONGOC_API_VERSION}.pc INSTALL) - endif() -endif () - - -set (test-libmongoc-sources - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/corpus-test.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/corpus-test.h - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-atomic.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-b64.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-bson.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-bcon-basic.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-bcon-extract.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-bson-cmp.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-bson-corpus.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-bson-error.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-bson-version.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-bson.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-clock.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-decimal128.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-endian.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-iso8601.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-iter.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-json.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-oid.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-reader.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-string.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-utf8.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-value.c - ${PROJECT_SOURCE_DIR}/../../src/libbson/tests/test-writer.c - ${PROJECT_SOURCE_DIR}/tests/bsonutil/bson-match.c - ${PROJECT_SOURCE_DIR}/tests/bsonutil/bson-parser.c - ${PROJECT_SOURCE_DIR}/tests/bsonutil/bson-val.c - ${PROJECT_SOURCE_DIR}/tests/debug-stream.c - ${PROJECT_SOURCE_DIR}/tests/json-test-monitoring.c - ${PROJECT_SOURCE_DIR}/tests/json-test-operations.c - ${PROJECT_SOURCE_DIR}/tests/json-test.c - ${PROJECT_SOURCE_DIR}/tests/mock_server/future-functions.c - ${PROJECT_SOURCE_DIR}/tests/mock_server/future-value.c - ${PROJECT_SOURCE_DIR}/tests/mock_server/future.c - ${PROJECT_SOURCE_DIR}/tests/mock_server/mock-rs.c - ${PROJECT_SOURCE_DIR}/tests/mock_server/mock-server.c - ${PROJECT_SOURCE_DIR}/tests/mock_server/request.c - ${PROJECT_SOURCE_DIR}/tests/mock_server/sync-queue.c - ${PROJECT_SOURCE_DIR}/tests/test-conveniences.c - ${PROJECT_SOURCE_DIR}/tests/test-happy-eyeballs.c - ${PROJECT_SOURCE_DIR}/tests/test-libmongoc.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-aggregate.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-array.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-async.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-aws.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-background-monitoring.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-buffer.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-bulk.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-change-stream.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-client-pool.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-client-session.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-client.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-cluster.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-cmd.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-collection-find-with-opts.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-collection-find.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-collection.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-command-monitoring.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-connection-uri.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-counters.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-crud.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-cursor.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-database.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-dns.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-error.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-exhaust.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-find-and-modify.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-generation-map.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-gridfs-bucket.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-gridfs-file-page.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-gridfs.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-handshake.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-hedged-reads.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-http.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-interrupt.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-linux-distro-scanner.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-list.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-loadbalanced.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-log.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-long-namespace.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-matcher.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-max-staleness.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-mongohouse.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-mongos-pinning.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-opts.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-primary-stepdown.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-queue.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-read-concern.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-read-prefs.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-read-write-concern.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-retryability-helpers.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-retryable-reads.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-retryable-writes.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-sample-commands.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-scram.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-sdam-monitoring.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-sdam.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-server-description.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-server-selection-errors.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-server-selection.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-server-stream.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-set.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-shared.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-socket.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-speculative-auth.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-ssl.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-stream.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-streamable-hello.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-thread.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-timeout.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-topology-description.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-topology-reconcile.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-topology-scanner.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-topology.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-transactions.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-ts-pool.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-uri.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-usleep.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-util.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-version.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-versioned-api.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-with-transaction.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-write-commands.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-write-concern.c - ${PROJECT_SOURCE_DIR}/tests/test-mcd-azure-imds.c - ${PROJECT_SOURCE_DIR}/tests/test-service-gcp.c - ${PROJECT_SOURCE_DIR}/tests/test-mcd-integer.c - ${PROJECT_SOURCE_DIR}/tests/test-mcd-rpc.c - ${PROJECT_SOURCE_DIR}/tests/TestSuite.c - ${PROJECT_SOURCE_DIR}/tests/unified/operation.c - ${PROJECT_SOURCE_DIR}/tests/unified/entity-map.c - ${PROJECT_SOURCE_DIR}/tests/unified/result.c - ${PROJECT_SOURCE_DIR}/tests/unified/runner.c - ${PROJECT_SOURCE_DIR}/tests/unified/test-diagnostics.c - ${PROJECT_SOURCE_DIR}/tests/unified/util.c -) - -if (MONGOC_ENABLE_SSL) - set (test-libmongoc-sources ${test-libmongoc-sources} - ${PROJECT_SOURCE_DIR}/tests/ssl-test.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-client-side-encryption.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-stream-tls-error.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-stream-tls.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-x509.c - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-ocsp-cache.c - ) -endif () - -if (MONGOC_ENABLE_SASL_CYRUS) - set (test-libmongoc-sources ${test-libmongoc-sources} - ${PROJECT_SOURCE_DIR}/tests/test-mongoc-cyrus.c - ) -endif () - -if (ENABLE_TESTS) - add_library (test-libmongoc-lib STATIC ${test-libmongoc-sources}) - if (MSVC AND MSVC_VERSION VERSION_LESS 1900) - message (STATUS "Disabling warning C4756 for VS 2013 and older") - # Macro constant INFINITY triggers constant arithmetic overflow warnings in - # VS 2013, but VS 2013 doesn't support inline warning suppression. - # Remove once support for VS 2013 is dropped. - target_compile_options(test-libmongoc-lib PRIVATE /wd4756) - endif () - target_link_libraries (test-libmongoc-lib PUBLIC mongoc_static) - # We have tests that test our deprecated api. - target_compile_options (test-libmongoc-lib - PRIVATE $<$>:-Wno-deprecated-declarations> - ) - target_include_directories (test-libmongoc-lib - PRIVATE - ${PROJECT_SOURCE_DIR}/tests - ${BSON_STATIC_INCLUDE_DIRS} - ) - target_compile_definitions (test-libmongoc-lib - PUBLIC - "MONGOC_COMPILATION" - "BSON_COMPILATION" - "MCOMMON_NAME_PREFIX=_mongoc_mcommon" - ) - - function (mongoc_add_test test) - add_executable (${test} ${ARGN}) - target_link_libraries (${test} - PUBLIC - $<$:DbgHelp.dll> - mongoc_static - ) - # We have tests that test our deprecated api. - target_compile_options (${test} - PRIVATE $<$>:-Wno-deprecated-declarations> - ) - target_include_directories (${test} - PRIVATE - ${PROJECT_SOURCE_DIR}/tests - ${BSON_STATIC_INCLUDE_DIRS} - ) - target_compile_definitions (${test} - PUBLIC - "MONGOC_COMPILATION" - "BSON_COMPILATION" - "MCOMMON_NAME_PREFIX=_mongoc_mcommon" - ) - endfunction () - - mongoc_add_test (test-libmongoc ${PROJECT_SOURCE_DIR}/tests/test-libmongoc-main.c) - target_link_libraries (test-libmongoc PUBLIC test-libmongoc-lib) - - mongoc_add_test (test-atlas-executor ${PROJECT_SOURCE_DIR}/tests/test-atlas-executor.c) - target_link_libraries (test-atlas-executor PUBLIC test-libmongoc-lib) - - mongoc_add_test (test-mongoc-gssapi ${PROJECT_SOURCE_DIR}/tests/test-mongoc-gssapi.c) - mongoc_add_test (test-mongoc-cache ${PROJECT_SOURCE_DIR}/tests/test-mongoc-cache.c) - mongoc_add_test (test-azurekms ${PROJECT_SOURCE_DIR}/tests/test-azurekms.c) - mongoc_add_test (test-gcpkms ${PROJECT_SOURCE_DIR}/tests/test-gcpkms.c) - mongoc_add_test (test-awsauth ${PROJECT_SOURCE_DIR}/tests/test-awsauth.c) - - # "make test" doesn't compile tests, so we create "make check" which compiles - # and runs tests: https://gitlab.kitware.com/cmake/cmake/issues/8774 - add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} -V - DEPENDS test-libmongoc - ) -endif () - -if (ENABLE_EXAMPLES AND ENABLE_SHARED) - function (mongoc_add_example example) - add_executable (${example} ${ARGN}) - target_link_libraries (${example} mongoc_shared ${LIBRARIES}) - if (WIN32) - target_link_libraries (${example} shlwapi) - endif () - set (EXAMPLES ${EXAMPLES} ${example}) - endfunction () - - # examples/ - mongoc_add_example (example-client ${PROJECT_SOURCE_DIR}/examples/example-client.c) - mongoc_add_example (example-collection-watch ${PROJECT_SOURCE_DIR}/examples/example-collection-watch.c) - if (NOT WIN32) - mongoc_add_example (example-resume ${PROJECT_SOURCE_DIR}/examples/example-resume.c) - endif() - mongoc_add_example (example-start-at-optime ${PROJECT_SOURCE_DIR}/examples/example-start-at-optime.c) - mongoc_add_example (example-command-monitoring ${PROJECT_SOURCE_DIR}/examples/example-command-monitoring.c) - mongoc_add_example (example-command-with-opts ${PROJECT_SOURCE_DIR}/examples/example-command-with-opts.c) - mongoc_add_example (example-manage-collection-indexes ${PROJECT_SOURCE_DIR}/examples/example-manage-collection-indexes.c) - mongoc_add_example (example-manage-search-indexes ${PROJECT_SOURCE_DIR}/examples/example-manage-search-indexes.c) - mongoc_add_example (example-gridfs ${PROJECT_SOURCE_DIR}/examples/example-gridfs.c) - mongoc_add_example (example-gridfs-bucket ${PROJECT_SOURCE_DIR}/examples/example-gridfs-bucket.c) - if (NOT WIN32 AND ENABLE_EXAMPLES) - mongoc_add_example (example-pool ${PROJECT_SOURCE_DIR}/examples/example-pool.c) - endif () - mongoc_add_example (example-scram ${PROJECT_SOURCE_DIR}/examples/example-scram.c) - mongoc_add_example (example-sdam-monitoring ${PROJECT_SOURCE_DIR}/examples/example-sdam-monitoring.c) - mongoc_add_example (example-session ${PROJECT_SOURCE_DIR}/examples/example-session.c) - mongoc_add_example (example-transaction ${PROJECT_SOURCE_DIR}/examples/example-transaction.c) - mongoc_add_example (example-update ${PROJECT_SOURCE_DIR}/examples/example-update.c) - mongoc_add_example (find-and-modify ${PROJECT_SOURCE_DIR}/examples/find-and-modify.c) - mongoc_add_example (hello_mongoc ${PROJECT_SOURCE_DIR}/examples/hello_mongoc.c) - mongoc_add_example (mongoc-dump ${PROJECT_SOURCE_DIR}/examples/mongoc-dump.c) - mongoc_add_example (mongoc-ping ${PROJECT_SOURCE_DIR}/examples/mongoc-ping.c) - mongoc_add_example (mongoc-tail ${PROJECT_SOURCE_DIR}/examples/mongoc-tail.c) - mongoc_add_example (example-collection-command ${PROJECT_SOURCE_DIR}/examples/example-collection-command.c) - - # examples/aggregation/ - mongoc_add_example (aggregation1 ${PROJECT_SOURCE_DIR}/examples/aggregation/aggregation1.c) - - # examples/basic_aggregation/ - mongoc_add_example (basic-aggregation ${PROJECT_SOURCE_DIR}/examples/basic_aggregation/basic-aggregation.c) - - # examples/bulk/ - mongoc_add_example (bulk-collation ${PROJECT_SOURCE_DIR}/examples/bulk/bulk-collation.c) - mongoc_add_example (bulk1 ${PROJECT_SOURCE_DIR}/examples/bulk/bulk1.c) - mongoc_add_example (bulk2 ${PROJECT_SOURCE_DIR}/examples/bulk/bulk2.c) - mongoc_add_example (bulk3 ${PROJECT_SOURCE_DIR}/examples/bulk/bulk3.c) - mongoc_add_example (bulk4 ${PROJECT_SOURCE_DIR}/examples/bulk/bulk4.c) - mongoc_add_example (bulk5 ${PROJECT_SOURCE_DIR}/examples/bulk/bulk5.c) - mongoc_add_example (bulk6 ${PROJECT_SOURCE_DIR}/examples/bulk/bulk6.c) - - # examples/common_operations/ - mongoc_add_example (common-operations ${PROJECT_SOURCE_DIR}/examples/common_operations/common-operations.c) - - # examples/find_and_modify_with_opts/ - mongoc_add_example (fam ${PROJECT_SOURCE_DIR}/examples/find_and_modify_with_opts/fam.c) - - if (MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION) - mongoc_add_example (client-side-encryption-schema-map ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-schema-map.c ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-helpers.c) - mongoc_add_example (client-side-encryption-server-schema ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-server-schema.c ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-helpers.c) - mongoc_add_example (client-side-encryption-explicit ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-explicit.c ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-helpers.c) - mongoc_add_example (client-side-encryption-auto-decryption ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-auto-decryption.c ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-helpers.c) - mongoc_add_example (client-side-encryption-doc-snippets ${PROJECT_SOURCE_DIR}/examples/client-side-encryption-doc-snippets.c) - endif () - - # examples/tutorial - mongoc_add_example (executing ${PROJECT_SOURCE_DIR}/examples/tutorial/executing.c) - mongoc_add_example (appending ${PROJECT_SOURCE_DIR}/examples/tutorial/appending.c) -endif () - -file (COPY ${PROJECT_SOURCE_DIR}/tests/binary DESTINATION ${PROJECT_BINARY_DIR}/tests) -file (COPY ${PROJECT_SOURCE_DIR}/tests/json DESTINATION ${PROJECT_BINARY_DIR}/tests) -file (COPY ${PROJECT_SOURCE_DIR}/tests/x509gen DESTINATION ${PROJECT_BINARY_DIR}/tests) -file (COPY ${PROJECT_SOURCE_DIR}/tests/release_files DESTINATION ${PROJECT_BINARY_DIR}/tests) - -set (TARGETS_TO_INSTALL) - -if (MONGOC_ENABLE_STATIC_INSTALL) - list (APPEND TARGETS_TO_INSTALL mongoc_static) -endif () - -if (ENABLE_SHARED) - list (APPEND TARGETS_TO_INSTALL mongoc_shared) -endif () - -set (MONGOC_HEADER_INSTALL_DIR - "${CMAKE_INSTALL_INCLUDEDIR}/libmongoc-${MONGOC_API_VERSION}" -) - -install ( - TARGETS ${TARGETS_TO_INSTALL} ${EXAMPLES} - EXPORT mongoc-targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - INCLUDES DESTINATION ${MONGOC_HEADER_INSTALL_DIR} - FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} -) - -install ( - FILES ${HEADERS} - DESTINATION "${MONGOC_HEADER_INSTALL_DIR}/mongoc" -) - -install ( - FILES ${HEADERS_FORWARDING} - DESTINATION "${MONGOC_HEADER_INSTALL_DIR}" -) - -if (ENABLE_APPLE_FRAMEWORK) - install ( - FILES "${PROJECT_BINARY_DIR}/src/mongoc/modules/module.modulemap" - DESTINATION "${CMAKE_INSTALL_BINDIR}/mongoc.framework/Modules/" - ) -endif () - -# Collect link items for the static library to be inserted into the pkg-config -if(TARGET mongoc_static) - set(link_options ${ZLIB_LIBRARIES} - ${SNAPPY_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY}) - # Replace all absolute paths with search-dir link-file options: - list(TRANSFORM link_options - REPLACE "^(.+)/lib([^/\\.]+)\\..+$" - "-L\\1;-l\\2" - REGEX "^/") - # Prepend "-l" to all bare names: - list(TRANSFORM link_options PREPEND "-l" REGEX "^[^-]") - list(REMOVE_DUPLICATES link_options) - message(DEBUG "Computed static library link options: ${link_options}") - set_property(TARGET mongoc_static APPEND PROPERTY pkg_config_LIBS ${link_options}) -endif() - -# Relative include-path will be given the install prefix: -set_property(TARGET ${TARGETS_TO_INSTALL} APPEND PROPERTY pkg_config_INCLUDE_DIRECTORIES "${MONGOC_HEADER_INSTALL_DIR}") - -# Deprecated alias for libmongoc-1.0.pc, see CDRIVER-2086. -if (MONGOC_ENABLE_SSL) - configure_file ( - ${CMAKE_CURRENT_SOURCE_DIR}/src/libmongoc-ssl-1.0.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/src/libmongoc-ssl-1.0.pc - @ONLY) - install ( - FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libmongoc-ssl-1.0.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - ) -endif () - -include (CMakePackageConfigHelpers) - -write_basic_package_version_file ( - "${CMAKE_CURRENT_BINARY_DIR}/mongoc/mongoc-${MONGOC_API_VERSION}-config-version.cmake" - VERSION ${MONGOC_VERSION} - COMPATIBILITY AnyNewerVersion -) - -configure_file (src/mongoc-config.cmake - "${CMAKE_CURRENT_BINARY_DIR}/mongoc/mongoc-${MONGOC_API_VERSION}-config.cmake" - @ONLY -) - -install (EXPORT mongoc-targets - NAMESPACE mongo:: - FILE mongoc-targets.cmake - DESTINATION ${MONGOC_TARGETS_INSTALL_DIR} -) - -install ( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/mongoc/mongoc-${MONGOC_API_VERSION}-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/mongoc/mongoc-${MONGOC_API_VERSION}-config-version.cmake" - DESTINATION - ${MONGOC_TARGETS_INSTALL_DIR} - COMPONENT - Devel -) - -include (LegacyPackage) - -if (ENABLE_MAN_PAGES STREQUAL ON OR ENABLE_HTML_DOCS STREQUAL ON) - find_package (Sphinx REQUIRED) - add_subdirectory (doc) - add_custom_target (mongoc-doc - ALL - DEPENDS - $<$:mongoc-man> - $<$:mongoc-html> - ) -endif () diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/THIRD_PARTY_NOTICES b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/THIRD_PARTY_NOTICES deleted file mode 100644 index 2bba00a5b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/THIRD_PARTY_NOTICES +++ /dev/null @@ -1,56 +0,0 @@ -The MongoDB C Driver uses third-party code distributed under different licenses. - -License notice for mongoc-stream-tls-secure-channel.c -------------------------------------------------------------------------------- - -Curl License - -Significant portions of mongoc-stream-tls-secure-channel.c are from Curl. - -Copyright (C) 2012 - 2015, Marc Hoersken, -Copyright (C) 2012, Mark Salisbury, -Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. - -All rights reserved. - -Permission to use, copy, modify, and distribute this software for any purpose -with or without fee is hereby granted, provided that the above copyright -notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN -NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE -OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of a copyright holder shall not -be used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization of the copyright holder. - - -License notice for utlist.h -------------------------------------------------------------------------------- - -BSD 1-Clause License - -Copyright: 2007-2014, Troy D. Hanson http://troydhanson.github.com/uthash/ - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/basic_aggregation/map-reduce-advanced.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/basic_aggregation/map-reduce-advanced.c deleted file mode 100644 index 145fb7a4d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/basic_aggregation/map-reduce-advanced.c +++ /dev/null @@ -1,47 +0,0 @@ -bool -map_reduce_advanced (mongoc_database_t *database) -{ - bson_t *command; - bson_error_t error; - bool res = true; - mongoc_cursor_t *cursor; - mongoc_read_prefs_t *read_pref; - const bson_t *doc; - - /* Construct the mapReduce command */ - /* Other arguments can also be specified here, like "query" or "limit" - and so on */ - - /* Read the results inline from a secondary replica */ - command = BCON_NEW ("mapReduce", - BCON_UTF8 (COLLECTION_NAME), - "map", - BCON_CODE (MAPPER), - "reduce", - BCON_CODE (REDUCER), - "out", - "{", - "inline", - "1", - "}"); - - read_pref = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - cursor = mongoc_database_command ( - database, MONGOC_QUERY_NONE, 0, 0, 0, command, NULL, read_pref); - - /* Do something with the results */ - while (mongoc_cursor_next (cursor, &doc)) { - print_res (doc); - } - - if (mongoc_cursor_error (cursor, &error)) { - fprintf (stderr, "ERROR: %s\n", error.message); - res = false; - } - - mongoc_cursor_destroy (cursor); - mongoc_read_prefs_destroy (read_pref); - bson_destroy (command); - - return res; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/basic_aggregation/map-reduce-basic.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/basic_aggregation/map-reduce-basic.c deleted file mode 100644 index 78a655b5b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/basic_aggregation/map-reduce-basic.c +++ /dev/null @@ -1,71 +0,0 @@ -bool -map_reduce_basic (mongoc_database_t *database) -{ - bson_t reply; - bson_t *command; - bool res; - bson_error_t error; - mongoc_cursor_t *cursor; - const bson_t *doc; - - bool query_done = false; - - const char *out_collection_name = "outCollection"; - mongoc_collection_t *out_collection; - - /* Empty find query */ - bson_t find_query = BSON_INITIALIZER; - - /* Construct the mapReduce command */ - - /* Other arguments can also be specified here, like "query" or - "limit" and so on */ - command = BCON_NEW ("mapReduce", - BCON_UTF8 (COLLECTION_NAME), - "map", - BCON_CODE (MAPPER), - "reduce", - BCON_CODE (REDUCER), - "out", - BCON_UTF8 (out_collection_name)); - res = - mongoc_database_command_simple (database, command, NULL, &reply, &error); - - if (!res) { - fprintf (stderr, "MapReduce failed: %s\n", error.message); - goto cleanup; - } - - /* Do something with the reply (it doesn't contain the mapReduce results) */ - print_res (&reply); - - /* Now we'll query outCollection to see what the results are */ - out_collection = - mongoc_database_get_collection (database, out_collection_name); - cursor = mongoc_collection_find_with_opts ( - out_collection, &find_query, NULL, NULL); - query_done = true; - - /* Do something with the results */ - while (mongoc_cursor_next (cursor, &doc)) { - print_res (doc); - } - - if (mongoc_cursor_error (cursor, &error)) { - fprintf (stderr, "ERROR: %s\n", error.message); - res = false; - goto cleanup; - } - -cleanup: - /* cleanup */ - if (query_done) { - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (out_collection); - } - - bson_destroy (&reply); - bson_destroy (command); - - return res; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-auto-decryption.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-auto-decryption.c deleted file mode 100644 index 4e696c355..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-auto-decryption.c +++ /dev/null @@ -1,235 +0,0 @@ -#include -#include -#include - -#include "client-side-encryption-helpers.h" - -/* This example demonstrates how to set up automatic decryption without - * automatic encryption using the community version of MongoDB */ -int -main (void) -{ -/* The collection used to store the encryption data keys. */ -#define KEYVAULT_DB "encryption" -#define KEYVAULT_COLL "__libmongocTestKeyVault" -/* The collection used to store the encrypted documents in this example. */ -#define ENCRYPTED_DB "test" -#define ENCRYPTED_COLL "coll" - - int exit_status = EXIT_FAILURE; - bool ret; - uint8_t *local_masterkey = NULL; - uint32_t local_masterkey_len; - bson_t *kms_providers = NULL; - bson_error_t error = {0}; - bson_t *index_keys = NULL; - bson_t *index_opts = NULL; - mongoc_index_model_t *index_model = NULL; - bson_t *schema = NULL; - mongoc_client_t *client = NULL; - mongoc_collection_t *coll = NULL; - mongoc_collection_t *keyvault_coll = NULL; - bson_t *to_insert = NULL; - bson_t *create_cmd = NULL; - bson_t *create_cmd_opts = NULL; - mongoc_write_concern_t *wc = NULL; - mongoc_client_encryption_t *client_encryption = NULL; - mongoc_client_encryption_opts_t *client_encryption_opts = NULL; - mongoc_client_encryption_datakey_opts_t *datakey_opts = NULL; - char *keyaltnames[] = {"mongoc_encryption_example_4"}; - bson_value_t datakey_id = {0}; - bson_value_t encrypted_field = {0}; - bson_value_t to_encrypt = {0}; - mongoc_client_encryption_encrypt_opts_t *encrypt_opts = NULL; - bson_value_t decrypted = {0}; - mongoc_auto_encryption_opts_t *auto_encryption_opts = NULL; - mongoc_client_t *unencrypted_client = NULL; - mongoc_collection_t *unencrypted_coll = NULL; - - mongoc_init (); - - /* Configure the master key. This must be the same master key that was used - * to create the encryption key. */ - local_masterkey = - hex_to_bin (getenv ("LOCAL_MASTERKEY"), &local_masterkey_len); - if (!local_masterkey || local_masterkey_len != 96) { - fprintf (stderr, - "Specify LOCAL_MASTERKEY environment variable as a " - "secure random 96 byte hex value.\n"); - goto fail; - } - - kms_providers = BCON_NEW ("local", - "{", - "key", - BCON_BIN (0, local_masterkey, local_masterkey_len), - "}"); - - client = - mongoc_client_new ("mongodb://localhost/?appname=client-side-encryption"); - auto_encryption_opts = mongoc_auto_encryption_opts_new (); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - auto_encryption_opts, KEYVAULT_DB, KEYVAULT_COLL); - mongoc_auto_encryption_opts_set_kms_providers (auto_encryption_opts, - kms_providers); - - /* Setting bypass_auto_encryption to true disables automatic encryption but - * keeps the automatic decryption behavior. bypass_auto_encryption will also - * disable spawning mongocryptd */ - mongoc_auto_encryption_opts_set_bypass_auto_encryption (auto_encryption_opts, - true); - - /* Once bypass_auto_encryption is set, community users can enable auto - * encryption on the client. This will, in fact, only perform automatic - * decryption. */ - ret = mongoc_client_enable_auto_encryption ( - client, auto_encryption_opts, &error); - if (!ret) { - goto fail; - } - - /* Now that automatic decryption is on, we can test it by inserting a - * document with an explicitly encrypted value into the collection. When we - * look up the document later, it should be automatically decrypted for us. - */ - coll = mongoc_client_get_collection (client, ENCRYPTED_DB, ENCRYPTED_COLL); - - /* Clear old data */ - mongoc_collection_drop (coll, NULL); - - /* Set up the key vault for this example. */ - keyvault_coll = - mongoc_client_get_collection (client, KEYVAULT_DB, KEYVAULT_COLL); - mongoc_collection_drop (keyvault_coll, NULL); - - /* Create a unique index to ensure that two data keys cannot share the same - * keyAltName. This is recommended practice for the key vault. */ - index_keys = BCON_NEW ("keyAltNames", BCON_INT32 (1)); - index_opts = BCON_NEW ("unique", - BCON_BOOL (true), - "partialFilterExpression", - "{", - "keyAltNames", - "{", - "$exists", - BCON_BOOL (true), - "}", - "}"); - index_model = mongoc_index_model_new (index_keys, index_opts); - ret = mongoc_collection_create_indexes_with_opts (keyvault_coll, - &index_model, - 1, - NULL /* opts */, - NULL /* reply */, - &error); - - if (!ret) { - goto fail; - } - - client_encryption_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, KEYVAULT_DB, KEYVAULT_COLL); - - /* The key vault client is used for reading to/from the key vault. This can - * be the same mongoc_client_t used by the application. */ - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - client); - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, &error); - if (!client_encryption) { - goto fail; - } - - /* Create a new data key for the encryptedField. - * https://dochub.mongodb.org/core/client-side-field-level-encryption-automatic-encryption-rules - */ - datakey_opts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_keyaltnames ( - datakey_opts, keyaltnames, 1); - ret = mongoc_client_encryption_create_datakey ( - client_encryption, "local", datakey_opts, &datakey_id, &error); - if (!ret) { - goto fail; - } - - /* Explicitly encrypt a field. */ - encrypt_opts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - encrypt_opts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); - mongoc_client_encryption_encrypt_opts_set_keyaltname ( - encrypt_opts, "mongoc_encryption_example_4"); - to_encrypt.value_type = BSON_TYPE_UTF8; - to_encrypt.value.v_utf8.str = "123456789"; - const size_t len = strlen (to_encrypt.value.v_utf8.str); - BSON_ASSERT (bson_in_range_unsigned (uint32_t, len)); - to_encrypt.value.v_utf8.len = (uint32_t) len; - - ret = mongoc_client_encryption_encrypt ( - client_encryption, &to_encrypt, encrypt_opts, &encrypted_field, &error); - if (!ret) { - goto fail; - } - - to_insert = bson_new (); - BSON_APPEND_VALUE (to_insert, "encryptedField", &encrypted_field); - ret = mongoc_collection_insert_one ( - coll, to_insert, NULL /* opts */, NULL /* reply */, &error); - if (!ret) { - goto fail; - } - - /* When we retrieve the document, any encrypted fields will get automatically - * decrypted by the driver. */ - printf ("decrypted document: "); - if (!print_one_document (coll, &error)) { - goto fail; - } - printf ("\n"); - - unencrypted_client = - mongoc_client_new ("mongodb://localhost/?appname=client-side-encryption"); - unencrypted_coll = mongoc_client_get_collection ( - unencrypted_client, ENCRYPTED_DB, ENCRYPTED_COLL); - - printf ("encrypted document: "); - if (!print_one_document (unencrypted_coll, &error)) { - goto fail; - } - printf ("\n"); - - exit_status = EXIT_SUCCESS; -fail: - if (error.code) { - fprintf (stderr, "error: %s\n", error.message); - } - - bson_free (local_masterkey); - bson_destroy (kms_providers); - mongoc_collection_destroy (keyvault_coll); - mongoc_index_model_destroy (index_model); - bson_destroy (index_opts); - bson_destroy (index_keys); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - bson_destroy (to_insert); - bson_destroy (schema); - bson_destroy (create_cmd); - bson_destroy (create_cmd_opts); - mongoc_write_concern_destroy (wc); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_datakey_opts_destroy (datakey_opts); - mongoc_client_encryption_opts_destroy (client_encryption_opts); - bson_value_destroy (&encrypted_field); - mongoc_client_encryption_encrypt_opts_destroy (encrypt_opts); - bson_value_destroy (&decrypted); - bson_value_destroy (&datakey_id); - mongoc_collection_destroy (unencrypted_coll); - mongoc_client_destroy (unencrypted_client); - mongoc_auto_encryption_opts_destroy (auto_encryption_opts); - - mongoc_cleanup (); - return exit_status; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-explicit.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-explicit.c deleted file mode 100644 index 58ca141c8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-explicit.c +++ /dev/null @@ -1,198 +0,0 @@ -#include -#include -#include - -#include "client-side-encryption-helpers.h" - -/* This example demonstrates how to use explicit encryption and decryption using - * the community version of MongoDB */ -int -main (void) -{ -/* The collection used to store the encryption data keys. */ -#define KEYVAULT_DB "encryption" -#define KEYVAULT_COLL "__libmongocTestKeyVault" -/* The collection used to store the encrypted documents in this example. */ -#define ENCRYPTED_DB "test" -#define ENCRYPTED_COLL "coll" - - int exit_status = EXIT_FAILURE; - bool ret; - uint8_t *local_masterkey = NULL; - uint32_t local_masterkey_len; - bson_t *kms_providers = NULL; - bson_error_t error = {0}; - bson_t *index_keys = NULL; - bson_t *index_opts = NULL; - mongoc_index_model_t *index_model = NULL; - bson_t *schema = NULL; - mongoc_client_t *client = NULL; - mongoc_collection_t *coll = NULL; - mongoc_collection_t *keyvault_coll = NULL; - bson_t *to_insert = NULL; - bson_t *create_cmd = NULL; - bson_t *create_cmd_opts = NULL; - mongoc_write_concern_t *wc = NULL; - mongoc_client_encryption_t *client_encryption = NULL; - mongoc_client_encryption_opts_t *client_encryption_opts = NULL; - mongoc_client_encryption_datakey_opts_t *datakey_opts = NULL; - char *keyaltnames[] = {"mongoc_encryption_example_3"}; - bson_value_t datakey_id = {0}; - bson_value_t encrypted_field = {0}; - bson_value_t to_encrypt = {0}; - mongoc_client_encryption_encrypt_opts_t *encrypt_opts = NULL; - bson_value_t decrypted = {0}; - - mongoc_init (); - - /* Configure the master key. This must be the same master key that was used - * to create the encryption key. */ - local_masterkey = - hex_to_bin (getenv ("LOCAL_MASTERKEY"), &local_masterkey_len); - if (!local_masterkey || local_masterkey_len != 96) { - fprintf (stderr, - "Specify LOCAL_MASTERKEY environment variable as a " - "secure random 96 byte hex value.\n"); - goto fail; - } - - kms_providers = BCON_NEW ("local", - "{", - "key", - BCON_BIN (0, local_masterkey, local_masterkey_len), - "}"); - - /* The mongoc_client_t used to read/write application data. */ - client = - mongoc_client_new ("mongodb://localhost/?appname=client-side-encryption"); - coll = mongoc_client_get_collection (client, ENCRYPTED_DB, ENCRYPTED_COLL); - - /* Clear old data */ - mongoc_collection_drop (coll, NULL); - - /* Set up the key vault for this example. */ - keyvault_coll = - mongoc_client_get_collection (client, KEYVAULT_DB, KEYVAULT_COLL); - mongoc_collection_drop (keyvault_coll, NULL); - - /* Create a unique index to ensure that two data keys cannot share the same - * keyAltName. This is recommended practice for the key vault. */ - index_keys = BCON_NEW ("keyAltNames", BCON_INT32 (1)); - index_opts = BCON_NEW ("unique", - BCON_BOOL (true), - "partialFilterExpression", - "{", - "keyAltNames", - "{", - "$exists", - BCON_BOOL (true), - "}", - "}"); - index_model = mongoc_index_model_new (index_keys, index_opts); - ret = mongoc_collection_create_indexes_with_opts (keyvault_coll, - &index_model, - 1, - NULL /* opts */, - NULL /* reply */, - &error); - - if (!ret) { - goto fail; - } - - client_encryption_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, KEYVAULT_DB, KEYVAULT_COLL); - - /* Set a mongoc_client_t to use for reading/writing to the key vault. This - * can be the same mongoc_client_t used by the main application. */ - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - client); - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, &error); - if (!client_encryption) { - goto fail; - } - - /* Create a new data key for the encryptedField. - * https://dochub.mongodb.org/core/client-side-field-level-encryption-automatic-encryption-rules - */ - datakey_opts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_keyaltnames ( - datakey_opts, keyaltnames, 1); - if (!mongoc_client_encryption_create_datakey ( - client_encryption, "local", datakey_opts, &datakey_id, &error)) { - goto fail; - } - - /* Explicitly encrypt a field */ - encrypt_opts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - encrypt_opts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); - mongoc_client_encryption_encrypt_opts_set_keyid (encrypt_opts, &datakey_id); - to_encrypt.value_type = BSON_TYPE_UTF8; - to_encrypt.value.v_utf8.str = "123456789"; - const size_t len = strlen (to_encrypt.value.v_utf8.str); - BSON_ASSERT (bson_in_range_unsigned (uint32_t, len)); - to_encrypt.value.v_utf8.len = (uint32_t) len; - - ret = mongoc_client_encryption_encrypt ( - client_encryption, &to_encrypt, encrypt_opts, &encrypted_field, &error); - if (!ret) { - goto fail; - } - - to_insert = bson_new (); - BSON_APPEND_VALUE (to_insert, "encryptedField", &encrypted_field); - ret = mongoc_collection_insert_one ( - coll, to_insert, NULL /* opts */, NULL /* reply */, &error); - if (!ret) { - goto fail; - } - - printf ("encrypted document: "); - if (!print_one_document (coll, &error)) { - goto fail; - } - printf ("\n"); - - /* Explicitly decrypt a field */ - ret = mongoc_client_encryption_decrypt ( - client_encryption, &encrypted_field, &decrypted, &error); - if (!ret) { - goto fail; - } - printf ("decrypted value: %s\n", decrypted.value.v_utf8.str); - - exit_status = EXIT_SUCCESS; -fail: - if (error.code) { - fprintf (stderr, "error: %s\n", error.message); - } - - bson_free (local_masterkey); - bson_destroy (kms_providers); - mongoc_collection_destroy (keyvault_coll); - mongoc_index_model_destroy (index_model); - bson_destroy (index_opts); - bson_destroy (index_keys); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - bson_destroy (to_insert); - bson_destroy (schema); - bson_destroy (create_cmd); - bson_destroy (create_cmd_opts); - mongoc_write_concern_destroy (wc); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_datakey_opts_destroy (datakey_opts); - mongoc_client_encryption_opts_destroy (client_encryption_opts); - bson_value_destroy (&encrypted_field); - mongoc_client_encryption_encrypt_opts_destroy (encrypt_opts); - bson_value_destroy (&decrypted); - bson_value_destroy (&datakey_id); - - mongoc_cleanup (); - return exit_status; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-schema-map.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-schema-map.c deleted file mode 100644 index 5304cc18a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-schema-map.c +++ /dev/null @@ -1,285 +0,0 @@ -#include -#include -#include - -#include "client-side-encryption-helpers.h" - -/* Helper method to create a new data key in the key vault, a schema to use that - * key, and writes the schema to a file for later use. */ -static bool -create_schema_file (bson_t *kms_providers, - const char *keyvault_db, - const char *keyvault_coll, - mongoc_client_t *keyvault_client, - bson_error_t *error) -{ - mongoc_client_encryption_t *client_encryption = NULL; - mongoc_client_encryption_opts_t *client_encryption_opts = NULL; - mongoc_client_encryption_datakey_opts_t *datakey_opts = NULL; - bson_value_t datakey_id = {0}; - char *keyaltnames[] = {"mongoc_encryption_example_1"}; - bson_t *schema = NULL; - char *schema_string = NULL; - size_t schema_string_len; - FILE *outfile = NULL; - bool ret = false; - - client_encryption_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, keyvault_db, keyvault_coll); - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - keyvault_client); - - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, error); - if (!client_encryption) { - goto fail; - } - - /* Create a new data key and json schema for the encryptedField. - * https://dochub.mongodb.org/core/client-side-field-level-encryption-automatic-encryption-rules - */ - datakey_opts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_keyaltnames ( - datakey_opts, keyaltnames, 1); - if (!mongoc_client_encryption_create_datakey ( - client_encryption, "local", datakey_opts, &datakey_id, error)) { - goto fail; - } - - /* Create a schema describing that "encryptedField" is a string encrypted - * with the newly created data key using deterministic encryption. */ - schema = BCON_NEW ("properties", - "{", - "encryptedField", - "{", - "encrypt", - "{", - "keyId", - "[", - BCON_BIN (datakey_id.value.v_binary.subtype, - datakey_id.value.v_binary.data, - datakey_id.value.v_binary.data_len), - "]", - "bsonType", - "string", - "algorithm", - MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC, - "}", - "}", - "}", - "bsonType", - "object"); - - /* Use canonical JSON so that other drivers and tools will be - * able to parse the MongoDB extended JSON file. */ - schema_string = bson_as_canonical_extended_json (schema, &schema_string_len); - outfile = fopen ("jsonSchema.json", "w"); - if (0 == fwrite (schema_string, sizeof (char), schema_string_len, outfile)) { - fprintf (stderr, "failed to write to file\n"); - goto fail; - } - - ret = true; -fail: - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_datakey_opts_destroy (datakey_opts); - mongoc_client_encryption_opts_destroy (client_encryption_opts); - bson_free (schema_string); - bson_destroy (schema); - bson_value_destroy (&datakey_id); - if (outfile) { - fclose (outfile); - } - return ret; -} - -/* This example demonstrates how to use automatic encryption with a client-side - * schema map using the enterprise version of MongoDB */ -int -main (void) -{ -/* The collection used to store the encryption data keys. */ -#define KEYVAULT_DB "encryption" -#define KEYVAULT_COLL "__libmongocTestKeyVault" -/* The collection used to store the encrypted documents in this example. */ -#define ENCRYPTED_DB "test" -#define ENCRYPTED_COLL "coll" - - int exit_status = EXIT_FAILURE; - bool ret; - uint8_t *local_masterkey = NULL; - uint32_t local_masterkey_len; - bson_t *kms_providers = NULL; - bson_error_t error = {0}; - bson_t *index_keys = NULL; - bson_t *index_opts = NULL; - mongoc_index_model_t *index_model = NULL; - bson_json_reader_t *reader = NULL; - bson_t schema = BSON_INITIALIZER; - bson_t *schema_map = NULL; - - /* The MongoClient used to access the key vault (keyvault_namespace). */ - mongoc_client_t *keyvault_client = NULL; - mongoc_collection_t *keyvault_coll = NULL; - mongoc_auto_encryption_opts_t *auto_encryption_opts = NULL; - mongoc_client_t *client = NULL; - mongoc_collection_t *coll = NULL; - bson_t *to_insert = NULL; - mongoc_client_t *unencrypted_client = NULL; - mongoc_collection_t *unencrypted_coll = NULL; - - mongoc_init (); - - /* Configure the master key. This must be the same master key that was used - * to create the encryption key. */ - local_masterkey = - hex_to_bin (getenv ("LOCAL_MASTERKEY"), &local_masterkey_len); - if (!local_masterkey || local_masterkey_len != 96) { - fprintf (stderr, - "Specify LOCAL_MASTERKEY environment variable as a " - "secure random 96 byte hex value.\n"); - goto fail; - } - - kms_providers = BCON_NEW ("local", - "{", - "key", - BCON_BIN (0, local_masterkey, local_masterkey_len), - "}"); - - /* Set up the key vault for this example. */ - keyvault_client = mongoc_client_new ( - "mongodb://localhost/?appname=client-side-encryption-keyvault"); - BSON_ASSERT (keyvault_client); - - keyvault_coll = mongoc_client_get_collection ( - keyvault_client, KEYVAULT_DB, KEYVAULT_COLL); - mongoc_collection_drop (keyvault_coll, NULL); - - /* Create a unique index to ensure that two data keys cannot share the same - * keyAltName. This is recommended practice for the key vault. */ - index_keys = BCON_NEW ("keyAltNames", BCON_INT32 (1)); - index_opts = BCON_NEW ("unique", - BCON_BOOL (true), - "partialFilterExpression", - "{", - "keyAltNames", - "{", - "$exists", - BCON_BOOL (true), - "}", - "}"); - index_model = mongoc_index_model_new (index_keys, index_opts); - ret = mongoc_collection_create_indexes_with_opts (keyvault_coll, - &index_model, - 1, - NULL /* opts */, - NULL /* reply */, - &error); - - if (!ret) { - goto fail; - } - - /* Create a new data key and a schema using it for encryption. Save the - * schema to the file jsonSchema.json */ - ret = create_schema_file ( - kms_providers, KEYVAULT_DB, KEYVAULT_COLL, keyvault_client, &error); - - if (!ret) { - goto fail; - } - - /* Load the JSON Schema and construct the local schema_map option. */ - reader = bson_json_reader_new_from_file ("jsonSchema.json", &error); - if (!reader) { - goto fail; - } - - bson_json_reader_read (reader, &schema, &error); - - /* Construct the schema map, mapping the namespace of the collection to the - * schema describing encryption. */ - schema_map = - BCON_NEW (ENCRYPTED_DB "." ENCRYPTED_COLL, BCON_DOCUMENT (&schema)); - - auto_encryption_opts = mongoc_auto_encryption_opts_new (); - mongoc_auto_encryption_opts_set_keyvault_client (auto_encryption_opts, - keyvault_client); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - auto_encryption_opts, KEYVAULT_DB, KEYVAULT_COLL); - mongoc_auto_encryption_opts_set_kms_providers (auto_encryption_opts, - kms_providers); - mongoc_auto_encryption_opts_set_schema_map (auto_encryption_opts, - schema_map); - - client = - mongoc_client_new ("mongodb://localhost/?appname=client-side-encryption"); - BSON_ASSERT (client); - - /* Enable automatic encryption. It will determine that encryption is - * necessary from the schema map instead of relying on the server to provide - * a schema. */ - ret = mongoc_client_enable_auto_encryption ( - client, auto_encryption_opts, &error); - if (!ret) { - goto fail; - } - - coll = mongoc_client_get_collection (client, ENCRYPTED_DB, ENCRYPTED_COLL); - - /* Clear old data */ - mongoc_collection_drop (coll, NULL); - - to_insert = BCON_NEW ("encryptedField", "123456789"); - ret = mongoc_collection_insert_one ( - coll, to_insert, NULL /* opts */, NULL /* reply */, &error); - if (!ret) { - goto fail; - } - printf ("decrypted document: "); - if (!print_one_document (coll, &error)) { - goto fail; - } - printf ("\n"); - - unencrypted_client = mongoc_client_new ( - "mongodb://localhost/?appname=client-side-encryption-unencrypted"); - BSON_ASSERT (unencrypted_client); - - unencrypted_coll = mongoc_client_get_collection ( - unencrypted_client, ENCRYPTED_DB, ENCRYPTED_COLL); - printf ("encrypted document: "); - if (!print_one_document (unencrypted_coll, &error)) { - goto fail; - } - printf ("\n"); - - exit_status = EXIT_SUCCESS; -fail: - if (error.code) { - fprintf (stderr, "error: %s\n", error.message); - } - - bson_free (local_masterkey); - bson_destroy (kms_providers); - mongoc_collection_destroy (keyvault_coll); - mongoc_index_model_destroy (index_model); - bson_destroy (index_opts); - bson_destroy (index_keys); - bson_json_reader_destroy (reader); - mongoc_auto_encryption_opts_destroy (auto_encryption_opts); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - bson_destroy (to_insert); - mongoc_collection_destroy (unencrypted_coll); - mongoc_client_destroy (unencrypted_client); - mongoc_client_destroy (keyvault_client); - bson_destroy (&schema); - bson_destroy (schema_map); - mongoc_cleanup (); - return exit_status; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-server-schema.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-server-schema.c deleted file mode 100644 index 59e22e8f2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/client-side-encryption-server-schema.c +++ /dev/null @@ -1,284 +0,0 @@ -#include -#include -#include - -#include "client-side-encryption-helpers.h" - -/* Helper method to create and return a JSON schema to use for encryption. -The caller will use the returned schema for server-side encryption validation. -*/ -static bson_t * -create_schema (bson_t *kms_providers, - const char *keyvault_db, - const char *keyvault_coll, - mongoc_client_t *keyvault_client, - bson_error_t *error) -{ - mongoc_client_encryption_t *client_encryption = NULL; - mongoc_client_encryption_opts_t *client_encryption_opts = NULL; - mongoc_client_encryption_datakey_opts_t *datakey_opts = NULL; - bson_value_t datakey_id = {0}; - char *keyaltnames[] = {"mongoc_encryption_example_2"}; - bson_t *schema = NULL; - - client_encryption_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, keyvault_db, keyvault_coll); - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - keyvault_client); - - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, error); - if (!client_encryption) { - goto fail; - } - - /* Create a new data key and json schema for the encryptedField. - * https://dochub.mongodb.org/core/client-side-field-level-encryption-automatic-encryption-rules - */ - datakey_opts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_keyaltnames ( - datakey_opts, keyaltnames, 1); - if (!mongoc_client_encryption_create_datakey ( - client_encryption, "local", datakey_opts, &datakey_id, error)) { - goto fail; - } - - /* Create a schema describing that "encryptedField" is a string encrypted - * with the newly created data key using deterministic encryption. */ - schema = BCON_NEW ("properties", - "{", - "encryptedField", - "{", - "encrypt", - "{", - "keyId", - "[", - BCON_BIN (datakey_id.value.v_binary.subtype, - datakey_id.value.v_binary.data, - datakey_id.value.v_binary.data_len), - "]", - "bsonType", - "string", - "algorithm", - MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC, - "}", - "}", - "}", - "bsonType", - "object"); - -fail: - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_datakey_opts_destroy (datakey_opts); - mongoc_client_encryption_opts_destroy (client_encryption_opts); - bson_value_destroy (&datakey_id); - return schema; -} - -/* This example demonstrates how to use automatic encryption with a server-side - * schema using the enterprise version of MongoDB */ -int -main (void) -{ -/* The collection used to store the encryption data keys. */ -#define KEYVAULT_DB "encryption" -#define KEYVAULT_COLL "__libmongocTestKeyVault" -/* The collection used to store the encrypted documents in this example. */ -#define ENCRYPTED_DB "test" -#define ENCRYPTED_COLL "coll" - - int exit_status = EXIT_FAILURE; - bool ret; - uint8_t *local_masterkey = NULL; - uint32_t local_masterkey_len; - bson_t *kms_providers = NULL; - bson_error_t error = {0}; - bson_t *index_keys = NULL; - bson_t *index_opts = NULL; - mongoc_index_model_t *index_model = NULL; - bson_json_reader_t *reader = NULL; - bson_t *schema = NULL; - - /* The MongoClient used to access the key vault (keyvault_namespace). */ - mongoc_client_t *keyvault_client = NULL; - mongoc_collection_t *keyvault_coll = NULL; - mongoc_auto_encryption_opts_t *auto_encryption_opts = NULL; - mongoc_client_t *client = NULL; - mongoc_collection_t *coll = NULL; - bson_t *to_insert = NULL; - mongoc_client_t *unencrypted_client = NULL; - mongoc_collection_t *unencrypted_coll = NULL; - bson_t *create_cmd = NULL; - bson_t *create_cmd_opts = NULL; - mongoc_write_concern_t *wc = NULL; - - mongoc_init (); - - /* Configure the master key. This must be the same master key that was used - * to create - * the encryption key. */ - local_masterkey = - hex_to_bin (getenv ("LOCAL_MASTERKEY"), &local_masterkey_len); - if (!local_masterkey || local_masterkey_len != 96) { - fprintf (stderr, - "Specify LOCAL_MASTERKEY environment variable as a " - "secure random 96 byte hex value.\n"); - goto fail; - } - - kms_providers = BCON_NEW ("local", - "{", - "key", - BCON_BIN (0, local_masterkey, local_masterkey_len), - "}"); - - /* Set up the key vault for this example. */ - keyvault_client = mongoc_client_new ( - "mongodb://localhost/?appname=client-side-encryption-keyvault"); - BSON_ASSERT (keyvault_client); - - keyvault_coll = mongoc_client_get_collection ( - keyvault_client, KEYVAULT_DB, KEYVAULT_COLL); - mongoc_collection_drop (keyvault_coll, NULL); - - /* Create a unique index to ensure that two data keys cannot share the same - * keyAltName. This is recommended practice for the key vault. */ - index_keys = BCON_NEW ("keyAltNames", BCON_INT32 (1)); - index_opts = BCON_NEW ("unique", - BCON_BOOL (true), - "partialFilterExpression", - "{", - "keyAltNames", - "{", - "$exists", - BCON_BOOL (true), - "}", - "}"); - index_model = mongoc_index_model_new (index_keys, index_opts); - ret = mongoc_collection_create_indexes_with_opts (keyvault_coll, - &index_model, - 1, - NULL /* opts */, - NULL /* reply */, - &error); - - if (!ret) { - goto fail; - } - - auto_encryption_opts = mongoc_auto_encryption_opts_new (); - mongoc_auto_encryption_opts_set_keyvault_client (auto_encryption_opts, - keyvault_client); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - auto_encryption_opts, KEYVAULT_DB, KEYVAULT_COLL); - mongoc_auto_encryption_opts_set_kms_providers (auto_encryption_opts, - kms_providers); - schema = create_schema ( - kms_providers, KEYVAULT_DB, KEYVAULT_COLL, keyvault_client, &error); - - if (!schema) { - goto fail; - } - - client = - mongoc_client_new ("mongodb://localhost/?appname=client-side-encryption"); - BSON_ASSERT (client); - - ret = mongoc_client_enable_auto_encryption ( - client, auto_encryption_opts, &error); - if (!ret) { - goto fail; - } - - coll = mongoc_client_get_collection (client, ENCRYPTED_DB, ENCRYPTED_COLL); - - /* Clear old data */ - mongoc_collection_drop (coll, NULL); - - /* Create the collection with the encryption JSON Schema. */ - create_cmd = BCON_NEW ("create", - ENCRYPTED_COLL, - "validator", - "{", - "$jsonSchema", - BCON_DOCUMENT (schema), - "}"); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_wmajority (wc, 0); - create_cmd_opts = bson_new (); - mongoc_write_concern_append (wc, create_cmd_opts); - ret = mongoc_client_command_with_opts (client, - ENCRYPTED_DB, - create_cmd, - NULL /* read prefs */, - create_cmd_opts, - NULL /* reply */, - &error); - if (!ret) { - goto fail; - } - - to_insert = BCON_NEW ("encryptedField", "123456789"); - ret = mongoc_collection_insert_one ( - coll, to_insert, NULL /* opts */, NULL /* reply */, &error); - if (!ret) { - goto fail; - } - printf ("decrypted document: "); - if (!print_one_document (coll, &error)) { - goto fail; - } - printf ("\n"); - - unencrypted_client = mongoc_client_new ( - "mongodb://localhost/?appname=client-side-encryption-unencrypted"); - BSON_ASSERT (unencrypted_client); - - unencrypted_coll = mongoc_client_get_collection ( - unencrypted_client, ENCRYPTED_DB, ENCRYPTED_COLL); - printf ("encrypted document: "); - if (!print_one_document (unencrypted_coll, &error)) { - goto fail; - } - printf ("\n"); - - /* Expect a server-side error if inserting with the unencrypted collection. - */ - ret = mongoc_collection_insert_one ( - unencrypted_coll, to_insert, NULL /* opts */, NULL /* reply */, &error); - if (!ret) { - printf ("insert with unencrypted collection failed: %s\n", error.message); - memset (&error, 0, sizeof (error)); - } - - exit_status = EXIT_SUCCESS; -fail: - if (error.code) { - fprintf (stderr, "error: %s\n", error.message); - } - - bson_free (local_masterkey); - bson_destroy (kms_providers); - mongoc_collection_destroy (keyvault_coll); - mongoc_index_model_destroy (index_model); - bson_destroy (index_opts); - bson_destroy (index_keys); - bson_json_reader_destroy (reader); - mongoc_auto_encryption_opts_destroy (auto_encryption_opts); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - bson_destroy (to_insert); - mongoc_collection_destroy (unencrypted_coll); - mongoc_client_destroy (unencrypted_client); - mongoc_client_destroy (keyvault_client); - bson_destroy (schema); - bson_destroy (create_cmd); - bson_destroy (create_cmd_opts); - mongoc_write_concern_destroy (wc); - - mongoc_cleanup (); - return exit_status; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake-deprecated/find_package/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake-deprecated/find_package/CMakeLists.txt deleted file mode 100644 index 682d2d826..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake-deprecated/find_package/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Demonstrates how to use the CMake 'find_package' mechanism to locate -# and build against libmongoc. - -cmake_minimum_required (VERSION 2.8) - -if (APPLE) - cmake_policy (SET CMP0042 OLD) -endif () - -project (hello_mongoc LANGUAGES C) - -# NOTE: For this to work, the CMAKE_PREFIX_PATH variable must be set to point to -# the directory that was used as the argument to CMAKE_INSTALL_PREFIX when -# building libmongoc. -# -- sphinx-include-start -- -# Specify the minimum version you require. -find_package (libmongoc-1.0 1.7 REQUIRED) - -message (STATUS " mongoc found version \"${MONGOC_VERSION}\"") -message (STATUS " mongoc include path \"${MONGOC_INCLUDE_DIRS}\"") -message (STATUS " mongoc libraries \"${MONGOC_LIBRARIES}\"") - -# The "hello_mongoc.c" sample program is shared among four tests. -add_executable (hello_mongoc ../../hello_mongoc.c) -target_include_directories (hello_mongoc PRIVATE "${MONGOC_INCLUDE_DIRS}") -target_link_libraries (hello_mongoc PRIVATE "${MONGOC_LIBRARIES}") -target_compile_definitions (hello_mongoc PRIVATE "${MONGOC_DEFINITIONS}") diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake-deprecated/find_package_static/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake-deprecated/find_package_static/CMakeLists.txt deleted file mode 100644 index a965225f6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake-deprecated/find_package_static/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Demonstrates how to use the CMake 'find_package' mechanism to locate -# and build against libmongoc. - -cmake_minimum_required (VERSION 2.8) - -if (APPLE) - cmake_policy (SET CMP0042 OLD) -endif () - -project (hello_mongoc LANGUAGES C) - -# NOTE: For this to work, the CMAKE_PREFIX_PATH variable must be set to point to -# the directory that was used as the argument to CMAKE_INSTALL_PREFIX when -# building libmongoc. -# -- sphinx-include-start -- -# Specify the minimum version you require. -find_package (libmongoc-static-1.0 1.7 REQUIRED) - -message (STATUS " mongoc found version \"${MONGOC_STATIC_VERSION}\"") -message (STATUS " mongoc include path \"${MONGOC_STATIC_INCLUDE_DIRS}\"") -message (STATUS " mongoc libraries \"${MONGOC_STATIC_LIBRARIES}\"") - -# The "hello_mongoc.c" sample program is shared among four tests. -add_executable (hello_mongoc ../../hello_mongoc.c) -target_include_directories (hello_mongoc PRIVATE "${MONGOC_STATIC_INCLUDE_DIRS}") -target_link_libraries (hello_mongoc PRIVATE "${MONGOC_STATIC_LIBRARIES}") -target_compile_definitions (hello_mongoc PRIVATE "${MONGOC_STATIC_DEFINITIONS}") diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake/find_package/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake/find_package/CMakeLists.txt deleted file mode 100644 index 8e062ae58..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake/find_package/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Demonstrates how to use the CMake 'find_package' mechanism to locate -# and build against libmongoc. - -cmake_minimum_required (VERSION 3.0) - -if (APPLE) - cmake_policy (SET CMP0042 OLD) -endif () - -project (hello_mongoc LANGUAGES C) - -# NOTE: For this to work, the CMAKE_PREFIX_PATH variable must be set to point to -# the directory that was used as the argument to CMAKE_INSTALL_PREFIX when -# building libmongoc. -# -- sphinx-include-start -- -# Specify the minimum version you require. -find_package (mongoc-1.0 1.7 REQUIRED) - -# The "hello_mongoc.c" sample program is shared among four tests. -add_executable (hello_mongoc ../../hello_mongoc.c) -target_link_libraries (hello_mongoc PRIVATE mongo::mongoc_shared) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake/find_package_static/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake/find_package_static/CMakeLists.txt deleted file mode 100644 index f7e3e0907..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake/find_package_static/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2017 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Demonstrates how to use the CMake 'find_package' mechanism to locate -# and build against libmongoc. - -cmake_minimum_required (VERSION 3.0) - -if (APPLE) - cmake_policy (SET CMP0042 OLD) -endif () - -project (hello_mongoc LANGUAGES C) - -# NOTE: For this to work, the CMAKE_PREFIX_PATH variable must be set to point to -# the directory that was used as the argument to CMAKE_INSTALL_PREFIX when -# building libmongoc. -# -- sphinx-include-start -- -# Specify the minimum version you require. -find_package (mongoc-1.0 1.7 REQUIRED) - -# The "hello_mongoc.c" sample program is shared among four tests. -add_executable (hello_mongoc ../../hello_mongoc.c) -target_link_libraries (hello_mongoc PRIVATE mongo::mongoc_static) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake/vcpkg/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake/vcpkg/CMakeLists.txt deleted file mode 100644 index 271548a41..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/cmake/vcpkg/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.15) -project(vcpkg-example-project) - -find_package(mongoc-1.0 CONFIG REQUIRED) -message(STATUS "Found libmongoc: ${mongoc-1.0_DIR}") - -enable_testing() - -add_executable(my-app app.c) -target_link_libraries(my-app PRIVATE mongo::mongoc_static) -add_test(my-app my-app) -set_property( - TEST my-app - PROPERTY PASS_REGULAR_EXPRESSION - "^Linked with libmongoc [1-9]+\\.[0-9]+\\.[0-9]+\r?\n$" -) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/common_operations/explain.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/common_operations/explain.c deleted file mode 100644 index 7ef77ae90..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/common_operations/explain.c +++ /dev/null @@ -1,33 +0,0 @@ -bool -explain (mongoc_collection_t *collection) -{ - bson_t *command; - bson_t reply; - bson_error_t error; - bool res; - - command = BCON_NEW ("explain", - "{", - "find", - BCON_UTF8 (COLLECTION_NAME), - "filter", - "{", - "x", - BCON_INT32 (1), - "}", - "}"); - res = mongoc_collection_command_simple ( - collection, command, NULL, &reply, &error); - if (!res) { - fprintf (stderr, "Error with explain: %s\n", error.message); - goto cleanup; - } - - /* Do something with the reply */ - print_res (&reply); - -cleanup: - bson_destroy (&reply); - bson_destroy (command); - return res; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/compile-with-pkg-config-static.sh b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/compile-with-pkg-config-static.sh deleted file mode 100644 index acc7fbdb9..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/compile-with-pkg-config-static.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# -- sphinx-include-start -- -gcc -o hello_mongoc hello_mongoc.c $(pkg-config --libs --cflags libmongoc-static-1.0) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/compile-with-pkg-config.sh b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/compile-with-pkg-config.sh deleted file mode 100755 index 91e0a7ebc..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/compile-with-pkg-config.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# -- sphinx-include-start -- -gcc -o hello_mongoc hello_mongoc.c $(pkg-config --libs --cflags libmongoc-1.0) diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/example-manage-collection-indexes.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/example-manage-collection-indexes.c deleted file mode 100644 index 761cc34b8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/example-manage-collection-indexes.c +++ /dev/null @@ -1,109 +0,0 @@ -// example-manage-collection-indexes creates, lists and deletes an index from -// the `test.test` collection. - -#include -#include // abort - -#define HANDLE_ERROR(...) \ - if (1) { \ - fprintf (stderr, "Failure at %s:%d\n", __FILE__, __LINE__); \ - fprintf (stderr, __VA_ARGS__); \ - fprintf (stderr, "\n"); \ - goto fail; \ - } else \ - (void) 0 - -int -main (int argc, char *argv[]) -{ - mongoc_client_t *client = NULL; - const char *uri_string = - "mongodb://127.0.0.1/?appname=create-indexes-example"; - mongoc_uri_t *uri = NULL; - mongoc_collection_t *coll = NULL; - bson_error_t error; - bool ok = false; - - mongoc_init (); - - if (argc > 2) { - HANDLE_ERROR ( - "Unexpected arguments. Expected usage: %s [CONNECTION_STRING]", - argv[0]); - } - - if (argc > 1) { - uri_string = argv[1]; - } - - uri = mongoc_uri_new_with_error (uri_string, &error); - if (!uri) { - HANDLE_ERROR ("Failed to parse URI: %s", error.message); - } - client = mongoc_client_new_from_uri_with_error (uri, &error); - if (!client) { - HANDLE_ERROR ("Failed to create client: %s", error.message); - } - - coll = mongoc_client_get_collection (client, "test", "test"); - - { - // Create an index ... begin - // `keys` represents an ascending index on field `x`. - bson_t *keys = BCON_NEW ("x", BCON_INT32 (1)); - mongoc_index_model_t *im = mongoc_index_model_new (keys, NULL /* opts */); - if (mongoc_collection_create_indexes_with_opts ( - coll, &im, 1, NULL /* opts */, NULL /* reply */, &error)) { - printf ("Successfully created index\n"); - } else { - bson_destroy (keys); - HANDLE_ERROR ("Failed to create index: %s", error.message); - } - bson_destroy (keys); - // Create an index ... end - } - - { - // List indexes ... begin - mongoc_cursor_t *cursor = - mongoc_collection_find_indexes_with_opts (coll, NULL /* opts */); - printf ("Listing indexes:\n"); - const bson_t *got; - while (mongoc_cursor_next (cursor, &got)) { - char *got_str = bson_as_canonical_extended_json (got, NULL); - printf (" %s\n", got_str); - bson_free (got_str); - } - if (mongoc_cursor_error (cursor, &error)) { - mongoc_cursor_destroy (cursor); - HANDLE_ERROR ("Failed to list indexes: %s", error.message); - } - mongoc_cursor_destroy (cursor); - // List indexes ... end - } - - { - // Drop an index ... begin - bson_t *keys = BCON_NEW ("x", BCON_INT32 (1)); - char *index_name = mongoc_collection_keys_to_index_string (keys); - if (mongoc_collection_drop_index_with_opts ( - coll, index_name, NULL /* opts */, &error)) { - printf ("Successfully dropped index\n"); - } else { - bson_free (index_name); - bson_destroy (keys); - HANDLE_ERROR ("Failed to drop index: %s", error.message); - } - bson_free (index_name); - bson_destroy (keys); - // Drop an index ... end - } - - ok = true; -fail: - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mongoc_cleanup (); - return ok ? EXIT_SUCCESS : EXIT_FAILURE; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/example-manage-search-indexes.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/example-manage-search-indexes.c deleted file mode 100644 index dac5c5bb5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/example-manage-search-indexes.c +++ /dev/null @@ -1,230 +0,0 @@ -// example-manage-search-indexes creates, lists, updates, and deletes an Atlas -// search index from the `test.test` collection. -// Example is expected to be run against a MongoDB Atlas cluster. - -#include -#include // abort - -#define HANDLE_ERROR(...) \ - if (1) { \ - fprintf (stderr, __VA_ARGS__); \ - fprintf (stderr, "\n"); \ - goto fail; \ - } else \ - (void) 0 - -#define ASSERT(stmt) \ - if (!stmt) { \ - fprintf (stderr, \ - "assertion failed on line: %d, statement: %s\n", \ - __LINE__, \ - #stmt); \ - abort (); \ - } else \ - (void) 0 - -int -main (int argc, char *argv[]) -{ - mongoc_client_t *client = NULL; - const char *uri_string = - "mongodb://127.0.0.1/?appname=create-search-indexes-example"; - mongoc_uri_t *uri = NULL; - mongoc_collection_t *coll = NULL; - bson_error_t error; - bool ok = false; - - mongoc_init (); - - if (argc > 2) { - HANDLE_ERROR ( - "Unexpected arguments. Expected usage: %s [CONNECTION_STRING]", - argv[0]); - } - - if (argc > 1) { - uri_string = argv[1]; - } - - uri = mongoc_uri_new_with_error (uri_string, &error); - if (!uri) { - HANDLE_ERROR ("Failed to parse URI: %s", error.message); - } - client = mongoc_client_new_from_uri_with_error (uri, &error); - if (!client) { - HANDLE_ERROR ("Failed to create client: %s", error.message); - } - - // Create a random collection name. - char collname[25]; - { - // There is a server-side limitation that prevents multiple search indexes - // from being created with the same name, definition and collection name. - // Atlas search index management operations are asynchronous. Dropping a - // collection may not result in the index being dropped immediately. Use a - // randomly generated collection name to avoid errors. - bson_oid_t oid; - bson_oid_init (&oid, NULL); - bson_oid_to_string (&oid, collname); - } - - // Create collection object. - { - // Create the collection server-side to avoid the server error: - // "Collection 'test.' does not exist." - mongoc_database_t *db = mongoc_client_get_database (client, "test"); - coll = mongoc_database_create_collection ( - db, collname, NULL /* options */, &error); - if (!coll) { - mongoc_database_destroy (db); - HANDLE_ERROR ("Failed to create collection: %s", error.message); - } - mongoc_database_destroy (db); - } - - // Check that $listSearchIndexes pipeline stage is supported. - // This is intended to check that a MongoDB Atlas cluster is used. - { - const char *pipeline_str = - BSON_STR ({"pipeline" : [ {"$listSearchIndexes" : {}} ]}); - bson_t pipeline; - ASSERT (bson_init_from_json (&pipeline, pipeline_str, -1, &error)); - mongoc_cursor_t *cursor = - mongoc_collection_aggregate (coll, - MONGOC_QUERY_NONE, - &pipeline, - NULL /* opts */, - NULL /* read_prefs */); - const bson_t *got; - while (mongoc_cursor_next (cursor, &got)) - ; - if (mongoc_cursor_error (cursor, &error)) { - bson_destroy (&pipeline); - mongoc_cursor_destroy (cursor); - HANDLE_ERROR ("Failed to run $listSearchIndexes with error: %s\n" - "Does the URI point to a MongoDB Atlas cluster? %s", - error.message, - uri_string); - } - bson_destroy (&pipeline); - mongoc_cursor_destroy (cursor); - } - - { - // Create an Atlas Search Index ... begin - bson_t cmd; - // Create command. - { - char *cmd_str = bson_strdup_printf ( - BSON_STR ({ - "createSearchIndexes" : "%s", - "indexes" : [ { - "definition" : {"mappings" : {"dynamic" : false}}, - "name" : "test-index" - } ] - }), - collname); - ASSERT (bson_init_from_json (&cmd, cmd_str, -1, &error)); - bson_free (cmd_str); - } - if (!mongoc_collection_command_simple ( - coll, &cmd, NULL /* read_prefs */, NULL /* reply */, &error)) { - bson_destroy (&cmd); - HANDLE_ERROR ("Failed to run createSearchIndexes: %s", error.message); - } - printf ("Created index: \"test-index\"\n"); - bson_destroy (&cmd); - // Create an Atlas Search Index ... end - } - - { - // List Atlas Search Indexes ... begin - const char *pipeline_str = - BSON_STR ({"pipeline" : [ {"$listSearchIndexes" : {}} ]}); - bson_t pipeline; - ASSERT (bson_init_from_json (&pipeline, pipeline_str, -1, &error)); - mongoc_cursor_t *cursor = - mongoc_collection_aggregate (coll, - MONGOC_QUERY_NONE, - &pipeline, - NULL /* opts */, - NULL /* read_prefs */); - printf ("Listing indexes:\n"); - const bson_t *got; - while (mongoc_cursor_next (cursor, &got)) { - char *got_str = bson_as_canonical_extended_json (got, NULL); - printf (" %s\n", got_str); - bson_free (got_str); - } - if (mongoc_cursor_error (cursor, &error)) { - bson_destroy (&pipeline); - mongoc_cursor_destroy (cursor); - HANDLE_ERROR ("Failed to run $listSearchIndexes: %s", error.message); - } - bson_destroy (&pipeline); - mongoc_cursor_destroy (cursor); - // List Atlas Search Indexes ... end - } - - { - // Update an Atlas Search Index ... begin - bson_t cmd; - // Create command. - { - char *cmd_str = bson_strdup_printf ( - BSON_STR ({ - "updateSearchIndex" : "%s", - "definition" : {"mappings" : {"dynamic" : true}}, - "name" : "test-index" - }), - collname); - ASSERT (bson_init_from_json (&cmd, cmd_str, -1, &error)); - bson_free (cmd_str); - } - if (!mongoc_collection_command_simple ( - coll, &cmd, NULL /* read_prefs */, NULL /* reply */, &error)) { - bson_destroy (&cmd); - HANDLE_ERROR ("Failed to run updateSearchIndex: %s", error.message); - } - printf ("Updated index: \"test-index\"\n"); - bson_destroy (&cmd); - // Update an Atlas Search Index ... end - } - - { - // Drop an Atlas Search Index ... begin - bson_t cmd; - // Create command. - { - char *cmd_str = bson_strdup_printf ( - BSON_STR ({"dropSearchIndex" : "%s", "name" : "test-index"}), - collname); - ASSERT (bson_init_from_json (&cmd, cmd_str, -1, &error)); - bson_free (cmd_str); - } - if (!mongoc_collection_command_simple ( - coll, &cmd, NULL /* read_prefs */, NULL /* reply */, &error)) { - bson_destroy (&cmd); - HANDLE_ERROR ("Failed to run dropSearchIndex: %s", error.message); - } - printf ("Dropped index: \"test-index\"\n"); - bson_destroy (&cmd); - // Drop an Atlas Search Index ... end - } - - // Drop created collection. - { - if (!mongoc_collection_drop (coll, &error)) { - HANDLE_ERROR ( - "Failed to drop collection '%s': %s", collname, error.message); - } - } - - ok = true; -fail: - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mongoc_cleanup (); - return ok ? EXIT_SUCCESS : EXIT_FAILURE; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/find-and-modify.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/find-and-modify.c deleted file mode 100644 index 3297fc581..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/find-and-modify.c +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include - - -int -main (void) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - const char *uri_string = - "mongodb://127.0.0.1:27017/?appname=find-and-modify-example"; - mongoc_uri_t *uri; - bson_error_t error; - bson_t *query; - bson_t *update; - bson_t reply; - char *str; - - mongoc_init (); - - uri = mongoc_uri_new_with_error (uri_string, &error); - if (!uri) { - fprintf (stderr, - "failed to parse URI: %s\n" - "error message: %s\n", - uri_string, - error.message); - return EXIT_FAILURE; - } - - client = mongoc_client_new_from_uri (uri); - if (!client) { - return EXIT_FAILURE; - } - - mongoc_client_set_error_api (client, 2); - collection = mongoc_client_get_collection (client, "test", "test"); - - /* - * Build our query, {"cmpxchg": 1} - */ - query = BCON_NEW ("cmpxchg", BCON_INT32 (1)); - - /* - * Build our update. {"$set": {"cmpxchg": 2}} - */ - update = BCON_NEW ("$set", "{", "cmpxchg", BCON_INT32 (2), "}"); - - /* - * Submit the findAndModify. - */ - if (!mongoc_collection_find_and_modify (collection, - query, - NULL, - update, - NULL, - false, - false, - true, - &reply, - &error)) { - fprintf (stderr, "find_and_modify() failure: %s\n", error.message); - return EXIT_FAILURE; - } - - /* - * Print the result as JSON. - */ - str = bson_as_canonical_extended_json (&reply, NULL); - printf ("%s\n", str); - bson_free (str); - - /* - * Cleanup. - */ - bson_destroy (query); - bson_destroy (update); - bson_destroy (&reply); - mongoc_collection_destroy (collection); - mongoc_uri_destroy (uri); - mongoc_client_destroy (client); - - mongoc_cleanup (); - - return EXIT_SUCCESS; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/tutorial/executing.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/tutorial/executing.c deleted file mode 100644 index a67166ff3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/examples/tutorial/executing.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include - -int -main (int argc, char *argv[]) -{ - mongoc_client_t *client; - bson_error_t error; - bson_t *command; - bson_t reply; - char *str; - - mongoc_init (); - - client = mongoc_client_new ( - "mongodb://localhost:27017/?appname=executing-example"); - - command = BCON_NEW ("ping", BCON_INT32 (1)); - if (mongoc_client_command_simple ( - client, "mydb", command, NULL, &reply, &error)) { - str = bson_as_canonical_extended_json (&reply, NULL); - printf ("%s\n", str); - bson_free (str); - } else { - fprintf (stderr, "Failed to run command: %s\n", error.message); - } - - bson_destroy (command); - bson_destroy (&reply); - mongoc_client_destroy (client); - mongoc_cleanup (); - - return 0; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/libmongoc-ssl-1.0.pc.in b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/libmongoc-ssl-1.0.pc.in deleted file mode 100644 index d29b11014..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/libmongoc-ssl-1.0.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${exec_prefix}/include - -Name: libmongoc-@MONGOC_API_VERSION@ -Description: SSL support for the libmongoc-@MONGOC_API_VERSION@ library. -Version: @MONGOC_VERSION@ -Requires: libmongoc-1.0 -Libs: -Cflags: diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc-config.cmake b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc-config.cmake deleted file mode 100644 index 31e6cbc6e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc-config.cmake +++ /dev/null @@ -1,45 +0,0 @@ -include(CMakeFindDependencyMacro) -find_dependency(bson-1.0 @libmongoc_VERSION@) - -# If we need to import a TLS package for our imported targets, do that now: -set(MONGOC_TLS_BACKEND [[@TLS_BACKEND@]]) -set(_tls_package [[@TLS_IMPORT_PACKAGE@]]) -if(_tls_package) - # We bring our own FindLibreSSL, since most systems do not have one yet. The system's version - # will be preferred, if possible. - set(_prev_path "${CMAKE_MODULE_PATH}") - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/3rdParty") - find_dependency("${_tls_package}") - set(CMAKE_MODULE_PATH "${_prev_path}") -endif() - -include("${CMAKE_CURRENT_LIST_DIR}/mongoc-targets.cmake") - -unset(_required) -unset(_quiet) -if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) - set(_required REQUIRED) -endif() -if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) - set(_quiet QUIET) -endif() - -set(_mongoc_built_with_bundled_utf8proc "@USE_BUNDLED_UTF8PROC@") -if(NOT _mongoc_built_with_bundled_utf8proc AND NOT TARGET PkgConfig::PC_UTF8PROC) - # libmongoc was compiled against an external utf8proc and links against a - # FindPkgConfig-generated IMPORTED target. Find that package and generate that - # imported target here: - find_dependency(PkgConfig) - pkg_check_modules(PC_UTF8PROC ${_required} ${_quiet} libutf8proc IMPORTED_TARGET GLOBAL) -endif() - -# Find dependencies for SASL -set(_sasl_backend [[@SASL_BACKEND@]]) -if(_sasl_backend STREQUAL "Cyrus") - # We need libsasl2. The find-module should be installed within this package. - # temporarily place it on the module search path: - set(_prev_path "${CMAKE_MODULE_PATH}") - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/3rdParty") - find_dependency(SASL2 2.0) - set(CMAKE_MODULE_PATH "${_prev_path}") -endif() diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/forwarding/mongoc.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/forwarding/mongoc.h deleted file mode 100644 index 458369f13..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/forwarding/mongoc.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2018-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Including mongoc.h is superseded. Use mongoc/mongoc.h instead. */ -#include "mongoc/mongoc.h" \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mcd-azure.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mcd-azure.c deleted file mode 100644 index 8f51351f8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mcd-azure.c +++ /dev/null @@ -1,210 +0,0 @@ -/** - * Copyright 2022 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "./mcd-azure.h" - -#include "mongoc-util-private.h" - -#define AZURE_API_VERSION "2018-02-01" - -static const char *const DEFAULT_METADATA_PATH = - "/metadata/identity/oauth2/" - "token?api-version=" AZURE_API_VERSION - "&resource=https%3A%2F%2Fvault.azure.net"; - -void -mcd_azure_imds_request_init (mcd_azure_imds_request *req, - const char *const opt_imds_host, - int opt_port, - const char *const opt_extra_headers) -{ - BSON_ASSERT_PARAM (req); - _mongoc_http_request_init (&req->req); - // The HTTP host of the IMDS server - req->req.host = req->_owned_host = - bson_strdup (opt_imds_host ? opt_imds_host : "169.254.169.254"); - if (opt_port) { - req->req.port = opt_port; - } else { - req->req.port = 80; - } - // No body - req->req.body = ""; - // We GET - req->req.method = "GET"; - // 'Metadata: true' is required - req->req.extra_headers = req->_owned_headers = - bson_strdup_printf ("Metadata: true\r\n" - "Accept: application/json\r\n%s", - opt_extra_headers ? opt_extra_headers : ""); - // The default path is suitable. In the future, we may want to add query - // parameters to disambiguate a managed identity. - req->req.path = req->_owned_path = bson_strdup (DEFAULT_METADATA_PATH); -} - -void -mcd_azure_imds_request_destroy (mcd_azure_imds_request *req) -{ - BSON_ASSERT_PARAM (req); - bson_free (req->_owned_path); - bson_free (req->_owned_host); - bson_free (req->_owned_headers); - *req = MCD_AZURE_IMDS_REQUEST_INIT; -} - -bool -mcd_azure_access_token_try_init_from_json_str (mcd_azure_access_token *out, - const char *json, - int len, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (out); - BSON_ASSERT_PARAM (json); - bool okay = false; - - if (len < 0) { - // Detect from a null-terminated string - len = (int) strlen (json); - } - - // Zero the output - *out = (mcd_azure_access_token){0}; - - // Parse the JSON data - bson_t bson; - if (!bson_init_from_json (&bson, json, len, error)) { - return false; - } - - bson_iter_t iter; - // access_token - bool found = bson_iter_init_find (&iter, &bson, "access_token"); - const char *const access_token = - !found ? NULL : bson_iter_utf8 (&iter, NULL); - // resource - found = bson_iter_init_find (&iter, &bson, "resource"); - const char *const resource = !found ? NULL : bson_iter_utf8 (&iter, NULL); - // token_type - found = bson_iter_init_find (&iter, &bson, "token_type"); - const char *const token_type = !found ? NULL : bson_iter_utf8 (&iter, NULL); - // expires_in - found = bson_iter_init_find (&iter, &bson, "expires_in"); - uint32_t expires_in_len = 0; - const char *const expires_in_str = - !found ? NULL : bson_iter_utf8 (&iter, &expires_in_len); - - if (!(access_token && resource && token_type && expires_in_str)) { - bson_set_error ( - error, - MONGOC_ERROR_AZURE, - MONGOC_ERROR_KMS_SERVER_BAD_JSON, - "One or more required JSON properties are missing/invalid: data: %.*s", - len, - json); - } else { - // Set the output, duplicate each string - *out = (mcd_azure_access_token){ - .access_token = bson_strdup (access_token), - .resource = bson_strdup (resource), - .token_type = bson_strdup (token_type), - }; - // "expires_in" encodes the number of seconds since the issue time for - // which the token will be valid. strtoll() will saturate on range errors - // and return zero on parse errors. - char *parse_end; - long long s = strtoll (expires_in_str, &parse_end, 0); - if (parse_end != expires_in_str + expires_in_len) { - // Did not parse the entire string. Bad - bson_set_error ( - error, - MONGOC_ERROR_AZURE, - MONGOC_ERROR_KMS_SERVER_BAD_JSON, - "Invalid 'expires_in' string \"%.*s\" from IMDS server", - expires_in_len, - expires_in_str); - } else { - out->expires_in = mcd_seconds (s); - okay = true; - } - } - - bson_destroy (&bson); - return okay; -} - - -void -mcd_azure_access_token_destroy (mcd_azure_access_token *c) -{ - bson_free (c->access_token); - bson_free (c->resource); - bson_free (c->token_type); - c->access_token = NULL; - c->resource = NULL; - c->token_type = NULL; -} - - -bool -mcd_azure_access_token_from_imds (mcd_azure_access_token *const out, - const char *const opt_imds_host, - int opt_port, - const char *opt_extra_headers, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (out); - - bool okay = false; - - // Clear the output - *out = (mcd_azure_access_token){0}; - - mongoc_http_response_t resp; - _mongoc_http_response_init (&resp); - - mcd_azure_imds_request req = MCD_AZURE_IMDS_REQUEST_INIT; - mcd_azure_imds_request_init ( - &req, opt_imds_host, opt_port, opt_extra_headers); - - if (!_mongoc_http_send (&req.req, 3 * 1000, false, NULL, &resp, error)) { - goto fail; - } - - // We only accept an HTTP 200 as a success - if (resp.status != 200) { - bson_set_error (error, - MONGOC_ERROR_AZURE, - MONGOC_ERROR_KMS_SERVER_HTTP, - "Error from Azure IMDS server while looking for " - "Managed Identity access token: %.*s", - resp.body_len, - resp.body); - goto fail; - } - - // Parse the token from the response JSON - if (!mcd_azure_access_token_try_init_from_json_str ( - out, resp.body, resp.body_len, error)) { - goto fail; - } - - okay = true; - -fail: - mcd_azure_imds_request_destroy (&req); - _mongoc_http_response_cleanup (&resp); - return okay; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/modules/module.modulemap.in b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/modules/module.modulemap.in deleted file mode 100644 index cfea5c66a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/modules/module.modulemap.in +++ /dev/null @@ -1,5 +0,0 @@ -framework module mongoc { - umbrella header "mongoc.h" - - export * -} \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-aggregate.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-aggregate.c deleted file mode 100644 index 83b4b4f1d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-aggregate.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright 2019 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-aggregate-private.h" -#include "mongoc-client-private.h" -#include "mongoc-cursor-private.h" -#include "mongoc-read-prefs-private.h" -#include "mongoc-server-stream-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-util-private.h" - -#include - -/*-------------------------------------------------------------------------- - * - * _has_write_key -- - * - * Returns true if the aggregation pipeline's last stage is "$out" - * or "$merge"; otherwise returns false. - * - * Side effects: - * Advances @iter to the last element. - * - *-------------------------------------------------------------------------- - */ - -bool -_has_write_key (bson_iter_t *iter) -{ - bson_iter_t stage; - bson_iter_t next; - - memcpy (&next, iter, sizeof (bson_iter_t)); - if (!bson_iter_next (&next)) { - /* default to false when iter is emtpy */ - return false; - } - - while (bson_iter_next (iter)) { - if (!bson_iter_next (&next) && BSON_ITER_HOLDS_DOCUMENT (iter)) { - bson_iter_recurse (iter, &stage); - if (bson_iter_find (&stage, "$out")) { - return true; - } - - bson_iter_recurse (iter, &stage); - if (bson_iter_find (&stage, "$merge")) { - return true; - } - } - } - - return false; -} - - -/*-------------------------------------------------------------------------- - * - * _make_agg_cmd -- - * - * Constructs an aggregate command. If @ns does not include a collection - * name, 1 will be used in its place for the value of "aggregate" in the - * command document. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * @command is always initialized. - * @error is set if there is a failure. - * - *-------------------------------------------------------------------------- - */ - -static bool -_make_agg_cmd (const char *ns, - const bson_t *pipeline, - mongoc_aggregate_opts_t *opts, - bson_t *command, - bson_error_t *err) -{ - const char *const dot = strstr (ns, "."); - const char *error = NULL; - const char *error_hint = NULL; - - bsonBuild ( - *command, - kv ("aggregate", - if (dot, - /* Note: we're not validating that the collection name's length is - one or more characters, as functions such as - mongoc_client_get_collection also do not validate. */ - // If 'ns' contains a dot, insert the string after the dot: - then (cstr (dot + 1)), - // Otherwise just an integer 1: - else(int32 (1))))); - if ((error_hint = "append-aggregate", error = bsonBuildError)) { - goto fail; - } - - /* - * The following will allow @pipeline to be either an array of - * items for the pipeline, or {"pipeline": [...]}. - */ - bsonParse ( - *pipeline, - find (keyWithType ("pipeline", array), - // There is a "pipeline" array in the document - append (*command, kv ("pipeline", iterValue (bsonVisitIter)))), - else( // We did not find a "pipeline" array. copy the pipeline as - // an array into the command - append (*command, kv ("pipeline", array (insert (*pipeline, true)))))); - if ((error_hint = "append-pipeline", error = bsonParseError)) { - goto fail; - } - - // Check if there is a $merge or $out in the pipeline for the command - bool has_write_key = false; - bsonParse (*command, - find ( - // Find the "pipeline" array - keyWithType ("pipeline", array), - parse ( - // Find the last element of the pipeline array - find (lastElement, - // If it has an "$out" or "$merge" key, it is a - // writing aggregate command. - parse (find (key ("$out", "$merge"), - do(has_write_key = true))))))); - if ((error_hint = "parse-pipeline", error = bsonParseError)) { - goto fail; - } - - bsonBuildAppend ( - *command, - kv ("cursor", - // If batchSize is set, and if we are not a writing command with zero - // batchSize, append 'batchSize' to the cursor, otherwise leave the - // 'cursor' as an empty subdocument. - doc (if (opts->batchSize_is_set && - !(has_write_key && opts->batchSize == 0), - then (kv ("batchSize", int32 (opts->batchSize))))))); - if ((error_hint = "build-cursor", error = bsonBuildError)) { - goto fail; - } - - return true; - -fail: - bson_set_error (err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Error while building aggregate command [%s]: %s", - error_hint, - error); - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_aggregate -- - * - * Constructs a mongoc_cursor_t for an "aggregate" command. - * - * This function will always return a new mongoc_cursor_t that should - * be freed with mongoc_cursor_destroy(). - * - * The cursor may fail once iterated upon, so check - * mongoc_cursor_error() if mongoc_cursor_next() returns false. - * - * See https://www.mongodb.com/docs/manual/aggregation/ for more - * information on how to build aggregation pipelines. - * - * Parameters: - * @ns: Namespace (or database name for database-level aggregation). - * @flags: Bitwise or of mongoc_query_flags_t or 0. - * @pipeline: A bson_t containing the pipeline request. @pipeline - * will be sent as an array type in the request. - * @opts: A bson_t containing aggregation options, such as - * bypassDocumentValidation (used with $out and $merge), maxTimeMS - * (declaring maximum server execution time) and explain (return - * information on the processing of the pipeline). - * @user_rp: Optional read preferences for the command. - * @default_rp: Default read preferences from the collection or database. - * @default_rc: Default read concern from the collection or database. - * @default_wc: Default write concern from the collection or database. - * - * Returns: - * A newly allocated mongoc_cursor_t that should be freed with - * mongoc_cursor_destroy(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_cursor_t * -_mongoc_aggregate (mongoc_client_t *client, - const char *ns, - mongoc_query_flags_t flags, - const bson_t *pipeline, - const bson_t *opts, - const mongoc_read_prefs_t *user_rp, - const mongoc_read_prefs_t *default_rp, - const mongoc_read_concern_t *default_rc, - const mongoc_write_concern_t *default_wc) - -{ - mongoc_server_stream_t *server_stream = NULL; - bool has_write_key; - bson_iter_t ar; - mongoc_cursor_t *cursor; - bson_iter_t iter; - bson_t command = BSON_INITIALIZER; - bson_t cursor_opts; - bool created_command; - bson_error_t create_cmd_err = {0}; - mongoc_aggregate_opts_t aggregate_opts; - bson_error_t opts_err = {0}; - bool parsed_opts; - - ENTRY; - - BSON_ASSERT (client); - BSON_ASSERT (ns); - BSON_ASSERT (pipeline); - - bson_init (&cursor_opts); - _mongoc_cursor_flags_to_opts (flags, &cursor_opts, NULL); - if (opts) { - bson_concat (&cursor_opts /* destination */, opts /* source */); - } - - parsed_opts = - _mongoc_aggregate_opts_parse (client, opts, &aggregate_opts, &opts_err); - - if (parsed_opts) { - created_command = _make_agg_cmd ( - ns, pipeline, &aggregate_opts, &command, &create_cmd_err); - } else { - created_command = false; - } - - cursor = _mongoc_cursor_cmd_new (client, - ns, - created_command ? &command : NULL, - &cursor_opts, - user_rp, - default_rp, - default_rc); - - bson_destroy (&command); - bson_destroy (&cursor_opts); - - if (!parsed_opts) { - memcpy (&cursor->error, &opts_err, sizeof (bson_error_t)); - GOTO (done); - } - - if (!created_command) { - /* copy error back to cursor. */ - memcpy (&cursor->error, &create_cmd_err, sizeof (bson_error_t)); - GOTO (done); - } - - if (mongoc_cursor_error (cursor, NULL)) { - GOTO (done); - } - - if (!_mongoc_read_prefs_validate (cursor->read_prefs, &cursor->error)) { - GOTO (done); - } - - /* pipeline could be like {pipeline: [{$out: 'test'}]} or [{$out: 'test'}] */ - if (bson_iter_init_find (&iter, pipeline, "pipeline") && - BSON_ITER_HOLDS_ARRAY (&iter) && bson_iter_recurse (&iter, &ar)) { - has_write_key = _has_write_key (&ar); - } else { - if (!bson_iter_init (&iter, pipeline)) { - bson_set_error (&cursor->error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Pipeline is invalid BSON"); - GOTO (done); - } - has_write_key = _has_write_key (&iter); - } - - /* This has an important effect on server selection when - * readPreferences=secondary. Keep track of this fact for later use. */ - cursor->is_aggr_with_write_stage = has_write_key; - - /* server id isn't enough. ensure we're connected & know wire version */ - server_stream = _mongoc_cursor_fetch_stream (cursor); - if (!server_stream) { - GOTO (done); - } - - /* Only inherit WriteConcern when aggregate has $out or $merge */ - if (!aggregate_opts.write_concern_owned && has_write_key) { - mongoc_write_concern_destroy (cursor->write_concern); - cursor->write_concern = mongoc_write_concern_copy (default_wc); - } - -done: - _mongoc_aggregate_opts_cleanup (&aggregate_opts); - mongoc_server_stream_cleanup (server_stream); /* null ok */ - - /* we always return the cursor, even if it fails; users can detect the - * failure on performing a cursor operation. see CDRIVER-880. */ - RETURN (cursor); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-apm.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-apm.c deleted file mode 100644 index ddde68053..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-apm.c +++ /dev/null @@ -1,1082 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-util-private.h" -#include "mongoc-apm-private.h" -#include "mongoc-cmd-private.h" -#include "mongoc-handshake-private.h" - -static bson_oid_t kObjectIdZero = {{0}}; - -/* - * An Application Performance Management (APM) implementation, complying with - * MongoDB's Command Logging and Monitoring Spec: - * - * https://github.com/mongodb/specifications/tree/master/source/command-logging-and-monitoring - */ - -static void -append_documents_from_cmd (const mongoc_cmd_t *cmd, - mongoc_apm_command_started_t *event) -{ - if (!cmd->payload || !cmd->payload_size) { - return; - } - - if (!event->command_owned) { - event->command = bson_copy (event->command); - event->command_owned = true; - } - - _mongoc_cmd_append_payload_as_array (cmd, event->command); -} - - -/* - * Private initializer / cleanup functions. - */ - -static void -mongoc_apm_redact_command (bson_t *command); - -static void -mongoc_apm_redact_reply (bson_t *reply); - -/*-------------------------------------------------------------------------- - * - * mongoc_apm_command_started_init -- - * - * Initialises the command started event. - * - * Side effects: - * If provided, is_redacted indicates whether the command document was - * redacted to hide sensitive information. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_apm_command_started_init (mongoc_apm_command_started_t *event, - const bson_t *command, - const char *database_name, - const char *command_name, - int64_t request_id, - int64_t operation_id, - const mongoc_host_list_t *host, - uint32_t server_id, - const bson_oid_t *service_id, - int64_t server_connection_id, - bool *is_redacted, /* out */ - void *context) -{ - bson_iter_t iter; - uint32_t len; - const uint8_t *data; - - /* Command Monitoring Spec: - * - * In cases where queries or commands are embedded in a $query parameter - * when a read preference is provided, they MUST be unwrapped and the value - * of the $query attribute becomes the filter or the command in the started - * event. The read preference will subsequently be dropped as it is - * considered metadata and metadata is not currently provided in the command - * events. - */ - if (bson_has_field (command, "$readPreference")) { - if (bson_iter_init_find (&iter, command, "$query") && - BSON_ITER_HOLDS_DOCUMENT (&iter)) { - bson_iter_document (&iter, &len, &data); - event->command = bson_new_from_data (data, len); - event->command_owned = true; - } else { - /* Got $readPreference without $query, probably OP_MSG */ - event->command = (bson_t *) command; - event->command_owned = false; - } - } else { - /* discard "const", we promise not to modify "command" */ - event->command = (bson_t *) command; - event->command_owned = false; - } - - if (mongoc_apm_is_sensitive_command_message (command_name, command)) { - if (!event->command_owned) { - event->command = bson_copy (event->command); - event->command_owned = true; - } - - if (is_redacted) { - *is_redacted = true; - } - - mongoc_apm_redact_command (event->command); - } else if (is_redacted) { - *is_redacted = false; - } - - event->database_name = database_name; - event->command_name = command_name; - event->request_id = request_id; - event->operation_id = operation_id; - event->host = host; - event->server_id = server_id; - event->context = context; - event->server_connection_id = server_connection_id; - - bson_oid_copy_unsafe (service_id, &event->service_id); -} - - -/*-------------------------------------------------------------------------- - * - * mongoc_apm_command_started_init_with_cmd -- - * - * Initialises the command started event from a mongoc_cmd_t. - * - * Side effects: - * If provided, is_redacted indicates whether the command document was - * redacted to hide sensitive information. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_apm_command_started_init_with_cmd (mongoc_apm_command_started_t *event, - mongoc_cmd_t *cmd, - int64_t request_id, - bool *is_redacted, /* out */ - void *context) -{ - mongoc_apm_command_started_init ( - event, - cmd->command, - cmd->db_name, - cmd->command_name, - request_id, - cmd->operation_id, - &cmd->server_stream->sd->host, - cmd->server_stream->sd->id, - &cmd->server_stream->sd->service_id, - cmd->server_stream->sd->server_connection_id, - is_redacted, - context); - - /* OP_MSG document sequence for insert, update, or delete? */ - append_documents_from_cmd (cmd, event); -} - - -void -mongoc_apm_command_started_cleanup (mongoc_apm_command_started_t *event) -{ - if (event->command_owned) { - bson_destroy (event->command); - } -} - - -/*-------------------------------------------------------------------------- - * - * mongoc_apm_command_succeeded_init -- - * - * Initialises the command succeeded event. - * - * Parameters: - * @force_redaction: If true, the reply document is always redacted, - * regardless of whether the command contains sensitive information. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_apm_command_succeeded_init (mongoc_apm_command_succeeded_t *event, - int64_t duration, - const bson_t *reply, - const char *command_name, - int64_t request_id, - int64_t operation_id, - const mongoc_host_list_t *host, - uint32_t server_id, - const bson_oid_t *service_id, - int64_t server_connection_id, - bool force_redaction, - void *context) -{ - BSON_ASSERT (reply); - - if (force_redaction || - mongoc_apm_is_sensitive_command_message (command_name, reply)) { - event->reply = bson_copy (reply); - event->reply_owned = true; - - mongoc_apm_redact_reply (event->reply); - } else { - /* discard "const", we promise not to modify "reply" */ - event->reply = (bson_t *) reply; - event->reply_owned = false; - } - - event->duration = duration; - event->command_name = command_name; - event->request_id = request_id; - event->operation_id = operation_id; - event->host = host; - event->server_id = server_id; - event->server_connection_id = server_connection_id; - event->context = context; - - bson_oid_copy_unsafe (service_id, &event->service_id); -} - - -void -mongoc_apm_command_succeeded_cleanup (mongoc_apm_command_succeeded_t *event) -{ - if (event->reply_owned) { - bson_destroy (event->reply); - } -} - - -/*-------------------------------------------------------------------------- - * - * mongoc_apm_command_failed_init -- - * - * Initialises the command failed event. - * - * Parameters: - * @force_redaction: If true, the reply document is always redacted, - * regardless of whether the command contains sensitive information. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_apm_command_failed_init (mongoc_apm_command_failed_t *event, - int64_t duration, - const char *command_name, - const bson_error_t *error, - const bson_t *reply, - int64_t request_id, - int64_t operation_id, - const mongoc_host_list_t *host, - uint32_t server_id, - const bson_oid_t *service_id, - int64_t server_connection_id, - bool force_redaction, - void *context) -{ - BSON_ASSERT (reply); - - if (force_redaction || - mongoc_apm_is_sensitive_command_message (command_name, reply)) { - event->reply = bson_copy (reply); - event->reply_owned = true; - - mongoc_apm_redact_reply (event->reply); - } else { - /* discard "const", we promise not to modify "reply" */ - event->reply = (bson_t *) reply; - event->reply_owned = false; - } - - event->duration = duration; - event->command_name = command_name; - event->error = error; - event->request_id = request_id; - event->operation_id = operation_id; - event->host = host; - event->server_id = server_id; - event->server_connection_id = server_connection_id; - event->context = context; - - bson_oid_copy_unsafe (service_id, &event->service_id); -} - - -void -mongoc_apm_command_failed_cleanup (mongoc_apm_command_failed_t *event) -{ - if (event->reply_owned) { - bson_destroy (event->reply); - } -} - - -/* - * event field accessors - */ - -/* command-started event fields */ - -const bson_t * -mongoc_apm_command_started_get_command ( - const mongoc_apm_command_started_t *event) -{ - return event->command; -} - - -const char * -mongoc_apm_command_started_get_database_name ( - const mongoc_apm_command_started_t *event) -{ - return event->database_name; -} - - -const char * -mongoc_apm_command_started_get_command_name ( - const mongoc_apm_command_started_t *event) -{ - return event->command_name; -} - - -int64_t -mongoc_apm_command_started_get_request_id ( - const mongoc_apm_command_started_t *event) -{ - return event->request_id; -} - - -int64_t -mongoc_apm_command_started_get_operation_id ( - const mongoc_apm_command_started_t *event) -{ - return event->operation_id; -} - - -const mongoc_host_list_t * -mongoc_apm_command_started_get_host (const mongoc_apm_command_started_t *event) -{ - return event->host; -} - - -uint32_t -mongoc_apm_command_started_get_server_id ( - const mongoc_apm_command_started_t *event) -{ - return event->server_id; -} - - -const bson_oid_t * -mongoc_apm_command_started_get_service_id ( - const mongoc_apm_command_started_t *event) -{ - if (0 == bson_oid_compare (&event->service_id, &kObjectIdZero)) { - /* serviceId is unset. */ - return NULL; - } - - return &event->service_id; -} - - -int32_t -mongoc_apm_command_started_get_server_connection_id ( - const mongoc_apm_command_started_t *event) -{ - if (event->server_connection_id > INT32_MAX || - event->server_connection_id < INT32_MIN) { - MONGOC_WARNING ( - "Server connection ID %" PRId64 - " is outside of int32 range. Returning -1. Use " - "mongoc_apm_command_started_get_server_connection_id_int64.", - event->server_connection_id); - return MONGOC_NO_SERVER_CONNECTION_ID; - } - - return (int32_t) event->server_connection_id; -} - - -int64_t -mongoc_apm_command_started_get_server_connection_id_int64 ( - const mongoc_apm_command_started_t *event) -{ - return event->server_connection_id; -} - - -void * -mongoc_apm_command_started_get_context ( - const mongoc_apm_command_started_t *event) -{ - return event->context; -} - - -/* command-succeeded event fields */ - -int64_t -mongoc_apm_command_succeeded_get_duration ( - const mongoc_apm_command_succeeded_t *event) -{ - return event->duration; -} - - -const bson_t * -mongoc_apm_command_succeeded_get_reply ( - const mongoc_apm_command_succeeded_t *event) -{ - return event->reply; -} - - -const char * -mongoc_apm_command_succeeded_get_command_name ( - const mongoc_apm_command_succeeded_t *event) -{ - return event->command_name; -} - - -int64_t -mongoc_apm_command_succeeded_get_request_id ( - const mongoc_apm_command_succeeded_t *event) -{ - return event->request_id; -} - - -int64_t -mongoc_apm_command_succeeded_get_operation_id ( - const mongoc_apm_command_succeeded_t *event) -{ - return event->operation_id; -} - - -const mongoc_host_list_t * -mongoc_apm_command_succeeded_get_host ( - const mongoc_apm_command_succeeded_t *event) -{ - return event->host; -} - - -uint32_t -mongoc_apm_command_succeeded_get_server_id ( - const mongoc_apm_command_succeeded_t *event) -{ - return event->server_id; -} - - -const bson_oid_t * -mongoc_apm_command_succeeded_get_service_id ( - const mongoc_apm_command_succeeded_t *event) -{ - if (0 == bson_oid_compare (&event->service_id, &kObjectIdZero)) { - /* serviceId is unset. */ - return NULL; - } - - return &event->service_id; -} - - -int32_t -mongoc_apm_command_succeeded_get_server_connection_id ( - const mongoc_apm_command_succeeded_t *event) -{ - if (event->server_connection_id > INT32_MAX || - event->server_connection_id < INT32_MIN) { - MONGOC_WARNING ( - "Server connection ID %" PRId64 - " is outside of int32 range. Returning -1. Use " - "mongoc_apm_command_succeeded_get_server_connection_id_int64.", - event->server_connection_id); - return MONGOC_NO_SERVER_CONNECTION_ID; - } - - return (int32_t) event->server_connection_id; -} - - -int64_t -mongoc_apm_command_succeeded_get_server_connection_id_int64 ( - const mongoc_apm_command_succeeded_t *event) -{ - return event->server_connection_id; -} - - -void * -mongoc_apm_command_succeeded_get_context ( - const mongoc_apm_command_succeeded_t *event) -{ - return event->context; -} - - -/* command-failed event fields */ - -int64_t -mongoc_apm_command_failed_get_duration ( - const mongoc_apm_command_failed_t *event) -{ - return event->duration; -} - - -const char * -mongoc_apm_command_failed_get_command_name ( - const mongoc_apm_command_failed_t *event) -{ - return event->command_name; -} - - -void -mongoc_apm_command_failed_get_error (const mongoc_apm_command_failed_t *event, - bson_error_t *error) -{ - memcpy (error, event->error, sizeof *event->error); -} - -const bson_t * -mongoc_apm_command_failed_get_reply (const mongoc_apm_command_failed_t *event) -{ - return event->reply; -} - -int64_t -mongoc_apm_command_failed_get_request_id ( - const mongoc_apm_command_failed_t *event) -{ - return event->request_id; -} - - -int64_t -mongoc_apm_command_failed_get_operation_id ( - const mongoc_apm_command_failed_t *event) -{ - return event->operation_id; -} - - -const mongoc_host_list_t * -mongoc_apm_command_failed_get_host (const mongoc_apm_command_failed_t *event) -{ - return event->host; -} - - -uint32_t -mongoc_apm_command_failed_get_server_id ( - const mongoc_apm_command_failed_t *event) -{ - return event->server_id; -} - - -const bson_oid_t * -mongoc_apm_command_failed_get_service_id ( - const mongoc_apm_command_failed_t *event) -{ - if (0 == bson_oid_compare (&event->service_id, &kObjectIdZero)) { - /* serviceId is unset. */ - return NULL; - } - - return &event->service_id; -} - - -int32_t -mongoc_apm_command_failed_get_server_connection_id ( - const mongoc_apm_command_failed_t *event) -{ - if (event->server_connection_id > INT32_MAX || - event->server_connection_id < INT32_MIN) { - MONGOC_WARNING ( - "Server connection ID %" PRId64 - " is outside of int32 range. Returning -1. Use " - "mongoc_apm_command_failed_get_server_connection_id_int64.", - event->server_connection_id); - return MONGOC_NO_SERVER_CONNECTION_ID; - } - - return (int32_t) event->server_connection_id; -} - - -int64_t -mongoc_apm_command_failed_get_server_connection_id_int64 ( - const mongoc_apm_command_failed_t *event) -{ - return event->server_connection_id; -} - - -void * -mongoc_apm_command_failed_get_context (const mongoc_apm_command_failed_t *event) -{ - return event->context; -} - - -/* server-changed event fields */ - -const mongoc_host_list_t * -mongoc_apm_server_changed_get_host (const mongoc_apm_server_changed_t *event) -{ - return event->host; -} - - -void -mongoc_apm_server_changed_get_topology_id ( - const mongoc_apm_server_changed_t *event, bson_oid_t *topology_id) -{ - bson_oid_copy (&event->topology_id, topology_id); -} - - -const mongoc_server_description_t * -mongoc_apm_server_changed_get_previous_description ( - const mongoc_apm_server_changed_t *event) -{ - return event->previous_description; -} - - -const mongoc_server_description_t * -mongoc_apm_server_changed_get_new_description ( - const mongoc_apm_server_changed_t *event) -{ - return event->new_description; -} - - -void * -mongoc_apm_server_changed_get_context (const mongoc_apm_server_changed_t *event) -{ - return event->context; -} - - -/* server-opening event fields */ - -const mongoc_host_list_t * -mongoc_apm_server_opening_get_host (const mongoc_apm_server_opening_t *event) -{ - return event->host; -} - - -void -mongoc_apm_server_opening_get_topology_id ( - const mongoc_apm_server_opening_t *event, bson_oid_t *topology_id) -{ - bson_oid_copy (&event->topology_id, topology_id); -} - - -void * -mongoc_apm_server_opening_get_context (const mongoc_apm_server_opening_t *event) -{ - return event->context; -} - - -/* server-closed event fields */ - -const mongoc_host_list_t * -mongoc_apm_server_closed_get_host (const mongoc_apm_server_closed_t *event) -{ - return event->host; -} - - -void -mongoc_apm_server_closed_get_topology_id ( - const mongoc_apm_server_closed_t *event, bson_oid_t *topology_id) -{ - bson_oid_copy (&event->topology_id, topology_id); -} - - -void * -mongoc_apm_server_closed_get_context (const mongoc_apm_server_closed_t *event) -{ - return event->context; -} - - -/* topology-changed event fields */ - -void -mongoc_apm_topology_changed_get_topology_id ( - const mongoc_apm_topology_changed_t *event, bson_oid_t *topology_id) -{ - bson_oid_copy (&event->topology_id, topology_id); -} - - -const mongoc_topology_description_t * -mongoc_apm_topology_changed_get_previous_description ( - const mongoc_apm_topology_changed_t *event) -{ - return event->previous_description; -} - - -const mongoc_topology_description_t * -mongoc_apm_topology_changed_get_new_description ( - const mongoc_apm_topology_changed_t *event) -{ - return event->new_description; -} - - -void * -mongoc_apm_topology_changed_get_context ( - const mongoc_apm_topology_changed_t *event) -{ - return event->context; -} - - -/* topology-opening event field */ - -void -mongoc_apm_topology_opening_get_topology_id ( - const mongoc_apm_topology_opening_t *event, bson_oid_t *topology_id) -{ - bson_oid_copy (&event->topology_id, topology_id); -} - - -void * -mongoc_apm_topology_opening_get_context ( - const mongoc_apm_topology_opening_t *event) -{ - return event->context; -} - - -/* topology-closed event field */ - -void -mongoc_apm_topology_closed_get_topology_id ( - const mongoc_apm_topology_closed_t *event, bson_oid_t *topology_id) -{ - bson_oid_copy (&event->topology_id, topology_id); -} - - -void * -mongoc_apm_topology_closed_get_context ( - const mongoc_apm_topology_closed_t *event) -{ - return event->context; -} - - -/* heartbeat-started event field */ - -const mongoc_host_list_t * -mongoc_apm_server_heartbeat_started_get_host ( - const mongoc_apm_server_heartbeat_started_t *event) -{ - return event->host; -} - - -void * -mongoc_apm_server_heartbeat_started_get_context ( - const mongoc_apm_server_heartbeat_started_t *event) -{ - return event->context; -} - -bool -mongoc_apm_server_heartbeat_started_get_awaited ( - const mongoc_apm_server_heartbeat_started_t *event) -{ - return event->awaited; -} - - -/* heartbeat-succeeded event fields */ - -int64_t -mongoc_apm_server_heartbeat_succeeded_get_duration ( - const mongoc_apm_server_heartbeat_succeeded_t *event) -{ - return event->duration_usec; -} - - -const bson_t * -mongoc_apm_server_heartbeat_succeeded_get_reply ( - const mongoc_apm_server_heartbeat_succeeded_t *event) -{ - return event->reply; -} - - -const mongoc_host_list_t * -mongoc_apm_server_heartbeat_succeeded_get_host ( - const mongoc_apm_server_heartbeat_succeeded_t *event) -{ - return event->host; -} - - -void * -mongoc_apm_server_heartbeat_succeeded_get_context ( - const mongoc_apm_server_heartbeat_succeeded_t *event) -{ - return event->context; -} - -bool -mongoc_apm_server_heartbeat_succeeded_get_awaited ( - const mongoc_apm_server_heartbeat_succeeded_t *event) -{ - return event->awaited; -} - - -/* heartbeat-failed event fields */ - -int64_t -mongoc_apm_server_heartbeat_failed_get_duration ( - const mongoc_apm_server_heartbeat_failed_t *event) -{ - return event->duration_usec; -} - - -void -mongoc_apm_server_heartbeat_failed_get_error ( - const mongoc_apm_server_heartbeat_failed_t *event, bson_error_t *error) -{ - memcpy (error, event->error, sizeof *event->error); -} - - -const mongoc_host_list_t * -mongoc_apm_server_heartbeat_failed_get_host ( - const mongoc_apm_server_heartbeat_failed_t *event) -{ - return event->host; -} - - -void * -mongoc_apm_server_heartbeat_failed_get_context ( - const mongoc_apm_server_heartbeat_failed_t *event) -{ - return event->context; -} - -bool -mongoc_apm_server_heartbeat_failed_get_awaited ( - const mongoc_apm_server_heartbeat_failed_t *event) -{ - return event->awaited; -} - -/* - * registering callbacks - */ - -mongoc_apm_callbacks_t * -mongoc_apm_callbacks_new (void) -{ - size_t s = sizeof (mongoc_apm_callbacks_t); - - return (mongoc_apm_callbacks_t *) bson_malloc0 (s); -} - - -void -mongoc_apm_callbacks_destroy (mongoc_apm_callbacks_t *callbacks) -{ - bson_free (callbacks); -} - - -void -mongoc_apm_set_command_started_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_command_started_cb_t cb) -{ - callbacks->started = cb; -} - - -void -mongoc_apm_set_command_succeeded_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_command_succeeded_cb_t cb) -{ - callbacks->succeeded = cb; -} - - -void -mongoc_apm_set_command_failed_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_command_failed_cb_t cb) -{ - callbacks->failed = cb; -} - -void -mongoc_apm_set_server_changed_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_changed_cb_t cb) -{ - callbacks->server_changed = cb; -} - - -void -mongoc_apm_set_server_opening_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_opening_cb_t cb) -{ - callbacks->server_opening = cb; -} - - -void -mongoc_apm_set_server_closed_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_closed_cb_t cb) -{ - callbacks->server_closed = cb; -} - - -void -mongoc_apm_set_topology_changed_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_topology_changed_cb_t cb) -{ - callbacks->topology_changed = cb; -} - - -void -mongoc_apm_set_topology_opening_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_topology_opening_cb_t cb) -{ - callbacks->topology_opening = cb; -} - - -void -mongoc_apm_set_topology_closed_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_topology_closed_cb_t cb) -{ - callbacks->topology_closed = cb; -} - - -void -mongoc_apm_set_server_heartbeat_started_cb ( - mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_heartbeat_started_cb_t cb) -{ - callbacks->server_heartbeat_started = cb; -} - - -void -mongoc_apm_set_server_heartbeat_succeeded_cb ( - mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_heartbeat_succeeded_cb_t cb) -{ - callbacks->server_heartbeat_succeeded = cb; -} - - -void -mongoc_apm_set_server_heartbeat_failed_cb ( - mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_heartbeat_failed_cb_t cb) -{ - callbacks->server_heartbeat_failed = cb; -} - -static bool -_mongoc_apm_is_sensitive_command_name (const char *command_name) -{ - return 0 == strcasecmp (command_name, "authenticate") || - 0 == strcasecmp (command_name, "saslStart") || - 0 == strcasecmp (command_name, "saslContinue") || - 0 == strcasecmp (command_name, "getnonce") || - 0 == strcasecmp (command_name, "createUser") || - 0 == strcasecmp (command_name, "updateUser") || - 0 == strcasecmp (command_name, "copydbgetnonce") || - 0 == strcasecmp (command_name, "copydbsaslstart") || - 0 == strcasecmp (command_name, "copydb"); -} - -static bool -_mongoc_apm_is_sensitive_hello_message (const char *command_name, - const bson_t *body) -{ - const bool is_hello = - (0 == strcasecmp (command_name, "hello") || - 0 == strcasecmp (command_name, HANDSHAKE_CMD_LEGACY_HELLO)); - - if (!is_hello) { - return false; - } - if (bson_empty (body)) { - /* An empty message body means that it has been redacted */ - return true; - } else if (bson_has_field (body, "speculativeAuthenticate")) { - /* "hello" messages are only sensitive if they contain - * 'speculativeAuthenticate' */ - return true; - } else { - /* Other "hello" messages are okay */ - return false; - } -} - -bool -mongoc_apm_is_sensitive_command_message (const char *command_name, - const bson_t *body) -{ - BSON_ASSERT (body); - - return _mongoc_apm_is_sensitive_command_name (command_name) || - _mongoc_apm_is_sensitive_hello_message (command_name, body); -} - -void -mongoc_apm_redact_command (bson_t *command) -{ - BSON_ASSERT (command); - - /* Reinit the command to have an empty document */ - bson_reinit (command); -} - - -void -mongoc_apm_redact_reply (bson_t *reply) -{ - BSON_ASSERT (reply); - - /* Reinit the reply to have an empty document */ - bson_reinit (reply); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-apm.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-apm.h deleted file mode 100644 index 70e304483..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-apm.h +++ /dev/null @@ -1,393 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_APM_H -#define MONGOC_APM_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-host-list.h" -#include "mongoc-server-description.h" -#include "mongoc-topology-description.h" - -BSON_BEGIN_DECLS - -/* - * Application Performance Management (APM) interface, complies with two specs. - * MongoDB's Command Logging and Monitoring Spec: - * - * https://github.com/mongodb/specifications/tree/master/source/command-logging-and-monitoring - * - * MongoDB's Spec for Monitoring Server Discovery and Monitoring (SDAM) events: - * - * https://github.com/mongodb/specifications/tree/master/source/server-discovery-and-monitoring - * - */ - -/* - * callbacks to receive APM events - */ - -typedef struct _mongoc_apm_callbacks_t mongoc_apm_callbacks_t; - - -/* - * command monitoring events - */ - -typedef struct _mongoc_apm_command_started_t mongoc_apm_command_started_t; -typedef struct _mongoc_apm_command_succeeded_t mongoc_apm_command_succeeded_t; -typedef struct _mongoc_apm_command_failed_t mongoc_apm_command_failed_t; - - -/* - * SDAM monitoring events - */ - -typedef struct _mongoc_apm_server_changed_t mongoc_apm_server_changed_t; -typedef struct _mongoc_apm_server_opening_t mongoc_apm_server_opening_t; -typedef struct _mongoc_apm_server_closed_t mongoc_apm_server_closed_t; -typedef struct _mongoc_apm_topology_changed_t mongoc_apm_topology_changed_t; -typedef struct _mongoc_apm_topology_opening_t mongoc_apm_topology_opening_t; -typedef struct _mongoc_apm_topology_closed_t mongoc_apm_topology_closed_t; -typedef struct _mongoc_apm_server_heartbeat_started_t - mongoc_apm_server_heartbeat_started_t; -typedef struct _mongoc_apm_server_heartbeat_succeeded_t - mongoc_apm_server_heartbeat_succeeded_t; -typedef struct _mongoc_apm_server_heartbeat_failed_t - mongoc_apm_server_heartbeat_failed_t; - -/* - * event field accessors - */ - -/* command-started event fields */ - -MONGOC_EXPORT (const bson_t *) -mongoc_apm_command_started_get_command ( - const mongoc_apm_command_started_t *event); -MONGOC_EXPORT (const char *) -mongoc_apm_command_started_get_database_name ( - const mongoc_apm_command_started_t *event); -MONGOC_EXPORT (const char *) -mongoc_apm_command_started_get_command_name ( - const mongoc_apm_command_started_t *event); -MONGOC_EXPORT (int64_t) -mongoc_apm_command_started_get_request_id ( - const mongoc_apm_command_started_t *event); -MONGOC_EXPORT (int64_t) -mongoc_apm_command_started_get_operation_id ( - const mongoc_apm_command_started_t *event); -MONGOC_EXPORT (const mongoc_host_list_t *) -mongoc_apm_command_started_get_host (const mongoc_apm_command_started_t *event); -MONGOC_EXPORT (uint32_t) -mongoc_apm_command_started_get_server_id ( - const mongoc_apm_command_started_t *event); -MONGOC_EXPORT (const bson_oid_t *) -mongoc_apm_command_started_get_service_id ( - const mongoc_apm_command_started_t *event); -MONGOC_EXPORT (int32_t) -mongoc_apm_command_started_get_server_connection_id ( - const mongoc_apm_command_started_t *event) - BSON_GNUC_DEPRECATED_FOR ( - "mongoc_apm_command_started_get_server_connection_id_int64"); -MONGOC_EXPORT (int64_t) -mongoc_apm_command_started_get_server_connection_id_int64 ( - const mongoc_apm_command_started_t *event); -MONGOC_EXPORT (void *) -mongoc_apm_command_started_get_context ( - const mongoc_apm_command_started_t *event); - -/* command-succeeded event fields */ - -MONGOC_EXPORT (int64_t) -mongoc_apm_command_succeeded_get_duration ( - const mongoc_apm_command_succeeded_t *event); -MONGOC_EXPORT (const bson_t *) -mongoc_apm_command_succeeded_get_reply ( - const mongoc_apm_command_succeeded_t *event); -MONGOC_EXPORT (const char *) -mongoc_apm_command_succeeded_get_command_name ( - const mongoc_apm_command_succeeded_t *event); -MONGOC_EXPORT (int64_t) -mongoc_apm_command_succeeded_get_request_id ( - const mongoc_apm_command_succeeded_t *event); -MONGOC_EXPORT (int64_t) -mongoc_apm_command_succeeded_get_operation_id ( - const mongoc_apm_command_succeeded_t *event); -MONGOC_EXPORT (const mongoc_host_list_t *) -mongoc_apm_command_succeeded_get_host ( - const mongoc_apm_command_succeeded_t *event); -MONGOC_EXPORT (uint32_t) -mongoc_apm_command_succeeded_get_server_id ( - const mongoc_apm_command_succeeded_t *event); -MONGOC_EXPORT (const bson_oid_t *) -mongoc_apm_command_succeeded_get_service_id ( - const mongoc_apm_command_succeeded_t *event); -MONGOC_EXPORT (int32_t) -mongoc_apm_command_succeeded_get_server_connection_id ( - const mongoc_apm_command_succeeded_t *event) - BSON_GNUC_DEPRECATED_FOR ( - "mongoc_apm_command_succeeded_get_server_connection_id_int64"); -MONGOC_EXPORT (int64_t) -mongoc_apm_command_succeeded_get_server_connection_id_int64 ( - const mongoc_apm_command_succeeded_t *event); -MONGOC_EXPORT (void *) -mongoc_apm_command_succeeded_get_context ( - const mongoc_apm_command_succeeded_t *event); - -/* command-failed event fields */ - -MONGOC_EXPORT (int64_t) -mongoc_apm_command_failed_get_duration ( - const mongoc_apm_command_failed_t *event); -MONGOC_EXPORT (const char *) -mongoc_apm_command_failed_get_command_name ( - const mongoc_apm_command_failed_t *event); -/* retrieve the error by filling out the passed-in "error" struct */ -MONGOC_EXPORT (void) -mongoc_apm_command_failed_get_error (const mongoc_apm_command_failed_t *event, - bson_error_t *error); -MONGOC_EXPORT (const bson_t *) -mongoc_apm_command_failed_get_reply (const mongoc_apm_command_failed_t *event); -MONGOC_EXPORT (int64_t) -mongoc_apm_command_failed_get_request_id ( - const mongoc_apm_command_failed_t *event); -MONGOC_EXPORT (int64_t) -mongoc_apm_command_failed_get_operation_id ( - const mongoc_apm_command_failed_t *event); -MONGOC_EXPORT (const mongoc_host_list_t *) -mongoc_apm_command_failed_get_host (const mongoc_apm_command_failed_t *event); -MONGOC_EXPORT (uint32_t) -mongoc_apm_command_failed_get_server_id ( - const mongoc_apm_command_failed_t *event); -MONGOC_EXPORT (const bson_oid_t *) -mongoc_apm_command_failed_get_service_id ( - const mongoc_apm_command_failed_t *event); -MONGOC_EXPORT (int32_t) -mongoc_apm_command_failed_get_server_connection_id ( - const mongoc_apm_command_failed_t *event) - BSON_GNUC_DEPRECATED_FOR ( - "mongoc_apm_command_failed_get_server_connection_id_int64"); -MONGOC_EXPORT (int64_t) -mongoc_apm_command_failed_get_server_connection_id_int64 ( - const mongoc_apm_command_failed_t *event); -MONGOC_EXPORT (void *) -mongoc_apm_command_failed_get_context ( - const mongoc_apm_command_failed_t *event); - -/* server-changed event fields */ - -MONGOC_EXPORT (const mongoc_host_list_t *) -mongoc_apm_server_changed_get_host (const mongoc_apm_server_changed_t *event); -MONGOC_EXPORT (void) -mongoc_apm_server_changed_get_topology_id ( - const mongoc_apm_server_changed_t *event, bson_oid_t *topology_id); -MONGOC_EXPORT (const mongoc_server_description_t *) -mongoc_apm_server_changed_get_previous_description ( - const mongoc_apm_server_changed_t *event); -MONGOC_EXPORT (const mongoc_server_description_t *) -mongoc_apm_server_changed_get_new_description ( - const mongoc_apm_server_changed_t *event); -MONGOC_EXPORT (void *) -mongoc_apm_server_changed_get_context ( - const mongoc_apm_server_changed_t *event); - -/* server-opening event fields */ - -MONGOC_EXPORT (const mongoc_host_list_t *) -mongoc_apm_server_opening_get_host (const mongoc_apm_server_opening_t *event); -MONGOC_EXPORT (void) -mongoc_apm_server_opening_get_topology_id ( - const mongoc_apm_server_opening_t *event, bson_oid_t *topology_id); -MONGOC_EXPORT (void *) -mongoc_apm_server_opening_get_context ( - const mongoc_apm_server_opening_t *event); - -/* server-closed event fields */ - -MONGOC_EXPORT (const mongoc_host_list_t *) -mongoc_apm_server_closed_get_host (const mongoc_apm_server_closed_t *event); -MONGOC_EXPORT (void) -mongoc_apm_server_closed_get_topology_id ( - const mongoc_apm_server_closed_t *event, bson_oid_t *topology_id); -MONGOC_EXPORT (void *) -mongoc_apm_server_closed_get_context (const mongoc_apm_server_closed_t *event); - -/* topology-changed event fields */ - -MONGOC_EXPORT (void) -mongoc_apm_topology_changed_get_topology_id ( - const mongoc_apm_topology_changed_t *event, bson_oid_t *topology_id); -MONGOC_EXPORT (const mongoc_topology_description_t *) -mongoc_apm_topology_changed_get_previous_description ( - const mongoc_apm_topology_changed_t *event); -MONGOC_EXPORT (const mongoc_topology_description_t *) -mongoc_apm_topology_changed_get_new_description ( - const mongoc_apm_topology_changed_t *event); -MONGOC_EXPORT (void *) -mongoc_apm_topology_changed_get_context ( - const mongoc_apm_topology_changed_t *event); - -/* topology-opening event field */ - -MONGOC_EXPORT (void) -mongoc_apm_topology_opening_get_topology_id ( - const mongoc_apm_topology_opening_t *event, bson_oid_t *topology_id); -MONGOC_EXPORT (void *) -mongoc_apm_topology_opening_get_context ( - const mongoc_apm_topology_opening_t *event); - -/* topology-closed event field */ - -MONGOC_EXPORT (void) -mongoc_apm_topology_closed_get_topology_id ( - const mongoc_apm_topology_closed_t *event, bson_oid_t *topology_id); -MONGOC_EXPORT (void *) -mongoc_apm_topology_closed_get_context ( - const mongoc_apm_topology_closed_t *event); - -/* heartbeat-started event field */ - -MONGOC_EXPORT (const mongoc_host_list_t *) -mongoc_apm_server_heartbeat_started_get_host ( - const mongoc_apm_server_heartbeat_started_t *event); -MONGOC_EXPORT (void *) -mongoc_apm_server_heartbeat_started_get_context ( - const mongoc_apm_server_heartbeat_started_t *event); -MONGOC_EXPORT (bool) -mongoc_apm_server_heartbeat_started_get_awaited ( - const mongoc_apm_server_heartbeat_started_t *event); - -/* heartbeat-succeeded event fields */ - -MONGOC_EXPORT (int64_t) -mongoc_apm_server_heartbeat_succeeded_get_duration ( - const mongoc_apm_server_heartbeat_succeeded_t *event); -MONGOC_EXPORT (const bson_t *) -mongoc_apm_server_heartbeat_succeeded_get_reply ( - const mongoc_apm_server_heartbeat_succeeded_t *event); -MONGOC_EXPORT (const mongoc_host_list_t *) -mongoc_apm_server_heartbeat_succeeded_get_host ( - const mongoc_apm_server_heartbeat_succeeded_t *event); -MONGOC_EXPORT (void *) -mongoc_apm_server_heartbeat_succeeded_get_context ( - const mongoc_apm_server_heartbeat_succeeded_t *event); -MONGOC_EXPORT (bool) -mongoc_apm_server_heartbeat_succeeded_get_awaited ( - const mongoc_apm_server_heartbeat_succeeded_t *event); - -/* heartbeat-failed event fields */ - -MONGOC_EXPORT (int64_t) -mongoc_apm_server_heartbeat_failed_get_duration ( - const mongoc_apm_server_heartbeat_failed_t *event); -MONGOC_EXPORT (void) -mongoc_apm_server_heartbeat_failed_get_error ( - const mongoc_apm_server_heartbeat_failed_t *event, bson_error_t *error); -MONGOC_EXPORT (const mongoc_host_list_t *) -mongoc_apm_server_heartbeat_failed_get_host ( - const mongoc_apm_server_heartbeat_failed_t *event); -MONGOC_EXPORT (void *) -mongoc_apm_server_heartbeat_failed_get_context ( - const mongoc_apm_server_heartbeat_failed_t *event); -MONGOC_EXPORT (bool) -mongoc_apm_server_heartbeat_failed_get_awaited ( - const mongoc_apm_server_heartbeat_failed_t *event); - - -/* - * callbacks - */ - -typedef void (*mongoc_apm_command_started_cb_t) ( - const mongoc_apm_command_started_t *event); -typedef void (*mongoc_apm_command_succeeded_cb_t) ( - const mongoc_apm_command_succeeded_t *event); -typedef void (*mongoc_apm_command_failed_cb_t) ( - const mongoc_apm_command_failed_t *event); -typedef void (*mongoc_apm_server_changed_cb_t) ( - const mongoc_apm_server_changed_t *event); -typedef void (*mongoc_apm_server_opening_cb_t) ( - const mongoc_apm_server_opening_t *event); -typedef void (*mongoc_apm_server_closed_cb_t) ( - const mongoc_apm_server_closed_t *event); -typedef void (*mongoc_apm_topology_changed_cb_t) ( - const mongoc_apm_topology_changed_t *event); -typedef void (*mongoc_apm_topology_opening_cb_t) ( - const mongoc_apm_topology_opening_t *event); -typedef void (*mongoc_apm_topology_closed_cb_t) ( - const mongoc_apm_topology_closed_t *event); -typedef void (*mongoc_apm_server_heartbeat_started_cb_t) ( - const mongoc_apm_server_heartbeat_started_t *event); -typedef void (*mongoc_apm_server_heartbeat_succeeded_cb_t) ( - const mongoc_apm_server_heartbeat_succeeded_t *event); -typedef void (*mongoc_apm_server_heartbeat_failed_cb_t) ( - const mongoc_apm_server_heartbeat_failed_t *event); - -/* - * registering callbacks - */ - -MONGOC_EXPORT (mongoc_apm_callbacks_t *) -mongoc_apm_callbacks_new (void) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_apm_callbacks_destroy (mongoc_apm_callbacks_t *callbacks); -MONGOC_EXPORT (void) -mongoc_apm_set_command_started_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_command_started_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_command_succeeded_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_command_succeeded_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_command_failed_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_command_failed_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_server_changed_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_changed_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_server_opening_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_opening_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_server_closed_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_closed_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_topology_changed_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_topology_changed_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_topology_opening_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_topology_opening_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_topology_closed_cb (mongoc_apm_callbacks_t *callbacks, - mongoc_apm_topology_closed_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_server_heartbeat_started_cb ( - mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_heartbeat_started_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_server_heartbeat_succeeded_cb ( - mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_heartbeat_succeeded_cb_t cb); -MONGOC_EXPORT (void) -mongoc_apm_set_server_heartbeat_failed_cb ( - mongoc_apm_callbacks_t *callbacks, - mongoc_apm_server_heartbeat_failed_cb_t cb); -BSON_END_DECLS - -#endif /* MONGOC_APM_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-array-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-array-private.h deleted file mode 100644 index 73b598f1b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-array-private.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_ARRAY_PRIVATE_H -#define MONGOC_ARRAY_PRIVATE_H - -#include - - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_array_t mongoc_array_t; - - -struct _mongoc_array_t { - size_t len; - size_t element_alignment; - size_t element_size; - size_t allocated; - void *data; -}; - - -#define mongoc_array_aligned_init(a, Type) \ - _mongoc_array_aligned_init (a, BSON_ALIGNOF (Type), sizeof (Type)) -#define _mongoc_array_append_val(a, v) _mongoc_array_append_vals (a, &v, 1) -#define _mongoc_array_index(a, t, i) (((t *) (a)->data)[i]) -#define _mongoc_array_clear(a) (a)->len = 0 - - -void -_mongoc_array_aligned_init (mongoc_array_t *array, - size_t element_alignment, - size_t element_size); -void -_mongoc_array_init (mongoc_array_t *array, size_t element_size); -void -_mongoc_array_copy (mongoc_array_t *dst, const mongoc_array_t *src); -void -_mongoc_array_append_vals (mongoc_array_t *array, - const void *data, - uint32_t n_elements); -void -_mongoc_array_destroy (mongoc_array_t *array); - - -BSON_END_DECLS - - -#endif /* MONGOC_ARRAY_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-async-cmd.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-async-cmd.c deleted file mode 100644 index 3ba899618..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-async-cmd.c +++ /dev/null @@ -1,516 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "mongoc-client.h" -#include "mongoc-async-cmd-private.h" -#include "mongoc-async-private.h" -#include "mongoc-cluster-private.h" -#include "mongoc-error.h" -#include "mongoc-opcode.h" -#include "mongoc-rpc-private.h" -#include "mongoc-stream-private.h" -#include "mongoc-server-description-private.h" -#include "mongoc-topology-scanner-private.h" -#include "mongoc-log.h" -#include "utlist.h" - -#ifdef MONGOC_ENABLE_SSL -#include "mongoc-stream-tls.h" -#endif - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "async" - -typedef mongoc_async_cmd_result_t (*_mongoc_async_cmd_phase_t) ( - mongoc_async_cmd_t *cmd); - -mongoc_async_cmd_result_t -_mongoc_async_cmd_phase_initiate (mongoc_async_cmd_t *cmd); -mongoc_async_cmd_result_t -_mongoc_async_cmd_phase_setup (mongoc_async_cmd_t *cmd); -mongoc_async_cmd_result_t -_mongoc_async_cmd_phase_send (mongoc_async_cmd_t *cmd); -mongoc_async_cmd_result_t -_mongoc_async_cmd_phase_recv_len (mongoc_async_cmd_t *cmd); -mongoc_async_cmd_result_t -_mongoc_async_cmd_phase_recv_rpc (mongoc_async_cmd_t *cmd); - -static const _mongoc_async_cmd_phase_t gMongocCMDPhases[] = { - _mongoc_async_cmd_phase_initiate, - _mongoc_async_cmd_phase_setup, - _mongoc_async_cmd_phase_send, - _mongoc_async_cmd_phase_recv_len, - _mongoc_async_cmd_phase_recv_rpc, - NULL, /* no callback for MONGOC_ASYNC_CMD_ERROR_STATE */ - NULL, /* no callback for MONGOC_ASYNC_CMD_CANCELED_STATE */ -}; - -#ifdef MONGOC_ENABLE_SSL -int -mongoc_async_cmd_tls_setup (mongoc_stream_t *stream, - int *events, - void *ctx, - int32_t timeout_msec, - bson_error_t *error) -{ - mongoc_stream_t *tls_stream; - const char *host = (const char *) ctx; - int retry_events = 0; - - - for (tls_stream = stream; tls_stream->type != MONGOC_STREAM_TLS; - tls_stream = mongoc_stream_get_base_stream (tls_stream)) { - } - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) || \ - defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) - /* pass 0 for the timeout to begin / continue non-blocking handshake */ - timeout_msec = 0; -#endif - if (mongoc_stream_tls_handshake ( - tls_stream, host, timeout_msec, &retry_events, error)) { - return 1; - } - - if (retry_events) { - *events = retry_events; - return 0; - } - return -1; -} -#endif - -bool -mongoc_async_cmd_run (mongoc_async_cmd_t *acmd) -{ - mongoc_async_cmd_result_t result; - int64_t duration_usec; - _mongoc_async_cmd_phase_t phase_callback; - - BSON_ASSERT (acmd); - - /* if we have successfully connected to the node, call the callback. */ - if (acmd->state == MONGOC_ASYNC_CMD_SEND) { - acmd->cb (acmd, MONGOC_ASYNC_CMD_CONNECTED, NULL, 0); - } - - phase_callback = gMongocCMDPhases[acmd->state]; - if (phase_callback) { - result = phase_callback (acmd); - } else { - result = MONGOC_ASYNC_CMD_ERROR; - } - - if (result == MONGOC_ASYNC_CMD_IN_PROGRESS) { - return true; - } - - duration_usec = bson_get_monotonic_time () - acmd->cmd_started; - - if (result == MONGOC_ASYNC_CMD_SUCCESS) { - acmd->cb (acmd, result, &acmd->reply, duration_usec); - } else { - /* we're in ERROR, TIMEOUT, or CANCELED */ - acmd->cb (acmd, result, NULL, duration_usec); - } - - mongoc_async_cmd_destroy (acmd); - return false; -} - -static void -_mongoc_async_cmd_init_send (const int32_t cmd_opcode, - mongoc_async_cmd_t *acmd, - const char *dbname) -{ - BSON_ASSERT (cmd_opcode == MONGOC_OP_CODE_QUERY || - cmd_opcode == MONGOC_OP_CODE_MSG); - - int32_t message_length = 0; - - message_length += mcd_rpc_header_set_message_length (acmd->rpc, 0); - message_length += - mcd_rpc_header_set_request_id (acmd->rpc, ++acmd->async->request_id); - message_length += mcd_rpc_header_set_response_to (acmd->rpc, 0); - message_length += mcd_rpc_header_set_op_code (acmd->rpc, cmd_opcode); - - if (cmd_opcode == MONGOC_OP_CODE_QUERY) { - acmd->ns = bson_strdup_printf ("%s.$cmd", dbname); - message_length += mcd_rpc_op_query_set_flags ( - acmd->rpc, MONGOC_OP_QUERY_FLAG_SECONDARY_OK); - message_length += - mcd_rpc_op_query_set_full_collection_name (acmd->rpc, acmd->ns); - message_length += mcd_rpc_op_query_set_number_to_skip (acmd->rpc, 0); - message_length += mcd_rpc_op_query_set_number_to_return (acmd->rpc, -1); - message_length += - mcd_rpc_op_query_set_query (acmd->rpc, bson_get_data (&acmd->cmd)); - } else { - mcd_rpc_op_msg_set_sections_count (acmd->rpc, 1u); - message_length += - mcd_rpc_op_msg_set_flag_bits (acmd->rpc, MONGOC_OP_MSG_FLAG_NONE); - message_length += mcd_rpc_op_msg_section_set_kind (acmd->rpc, 0u, 0); - message_length += mcd_rpc_op_msg_section_set_body ( - acmd->rpc, 0u, bson_get_data (&acmd->cmd)); - } - - mcd_rpc_message_set_length (acmd->rpc, message_length); - - /* This will always be hello, which are not allowed to be compressed */ - acmd->iovec = mcd_rpc_message_to_iovecs (acmd->rpc, &acmd->niovec); - BSON_ASSERT (acmd->iovec); - - acmd->bytes_written = 0; -} - -void -_mongoc_async_cmd_state_start (mongoc_async_cmd_t *acmd, bool is_setup_done) -{ - if (!acmd->stream) { - acmd->state = MONGOC_ASYNC_CMD_INITIATE; - } else if (acmd->setup && !is_setup_done) { - acmd->state = MONGOC_ASYNC_CMD_SETUP; - } else { - acmd->state = MONGOC_ASYNC_CMD_SEND; - } - - acmd->events = POLLOUT; -} - -mongoc_async_cmd_t * -mongoc_async_cmd_new (mongoc_async_t *async, - mongoc_stream_t *stream, - bool is_setup_done, - struct addrinfo *dns_result, - mongoc_async_cmd_initiate_t initiator, - int64_t initiate_delay_ms, - mongoc_async_cmd_setup_t setup, - void *setup_ctx, - const char *dbname, - const bson_t *cmd, - const int32_t cmd_opcode, /* OP_QUERY or OP_MSG */ - mongoc_async_cmd_cb_t cb, - void *cb_data, - int64_t timeout_msec) -{ - BSON_ASSERT_PARAM (cmd); - BSON_ASSERT_PARAM (dbname); - - mongoc_async_cmd_t *const acmd = BSON_ALIGNED_ALLOC0 (mongoc_async_cmd_t); - acmd->async = async; - acmd->dns_result = dns_result; - acmd->timeout_msec = timeout_msec; - acmd->stream = stream; - acmd->initiator = initiator; - acmd->initiate_delay_ms = initiate_delay_ms; - acmd->setup = setup; - acmd->setup_ctx = setup_ctx; - acmd->cb = cb; - acmd->data = cb_data; - acmd->connect_started = bson_get_monotonic_time (); - bson_copy_to (cmd, &acmd->cmd); - - if (MONGOC_OP_CODE_MSG == cmd_opcode) { - /* If we're sending an OP_MSG, we need to add the "db" field: */ - bson_append_utf8 (&acmd->cmd, "$db", 3, "admin", 5); - } - - acmd->rpc = mcd_rpc_message_new (); - acmd->iovec = NULL; - _mongoc_buffer_init (&acmd->buffer, NULL, 0, NULL, NULL); - - _mongoc_async_cmd_init_send (cmd_opcode, acmd, dbname); - - _mongoc_async_cmd_state_start (acmd, is_setup_done); - - async->ncmds++; - DL_APPEND (async->cmds, acmd); - - return acmd; -} - - -void -mongoc_async_cmd_destroy (mongoc_async_cmd_t *acmd) -{ - BSON_ASSERT (acmd); - - DL_DELETE (acmd->async->cmds, acmd); - acmd->async->ncmds--; - - bson_destroy (&acmd->cmd); - - if (acmd->reply_needs_cleanup) { - bson_destroy (&acmd->reply); - } - - bson_free (acmd->iovec); - _mongoc_buffer_destroy (&acmd->buffer); - mcd_rpc_message_destroy (acmd->rpc); - - bson_free (acmd->ns); - bson_free (acmd); -} - -mongoc_async_cmd_result_t -_mongoc_async_cmd_phase_initiate (mongoc_async_cmd_t *acmd) -{ - acmd->stream = acmd->initiator (acmd); - if (!acmd->stream) { - return MONGOC_ASYNC_CMD_ERROR; - } - /* reset the connect started time after connection starts. */ - acmd->connect_started = bson_get_monotonic_time (); - if (acmd->setup) { - acmd->state = MONGOC_ASYNC_CMD_SETUP; - } else { - acmd->state = MONGOC_ASYNC_CMD_SEND; - } - return MONGOC_ASYNC_CMD_IN_PROGRESS; -} - -mongoc_async_cmd_result_t -_mongoc_async_cmd_phase_setup (mongoc_async_cmd_t *acmd) -{ - int retval; - - BSON_ASSERT (acmd->timeout_msec < INT32_MAX); - retval = acmd->setup (acmd->stream, - &acmd->events, - acmd->setup_ctx, - (int32_t) acmd->timeout_msec, - &acmd->error); - switch (retval) { - case -1: - return MONGOC_ASYNC_CMD_ERROR; - case 0: - break; - case 1: - acmd->state = MONGOC_ASYNC_CMD_SEND; - acmd->events = POLLOUT; - break; - default: - abort (); - } - - return MONGOC_ASYNC_CMD_IN_PROGRESS; -} - -mongoc_async_cmd_result_t -_mongoc_async_cmd_phase_send (mongoc_async_cmd_t *acmd) -{ - size_t total_bytes = 0; - size_t offset; - ssize_t bytes; - /* if a continued write, then iovec will be set to a temporary copy */ - bool used_temp_iovec = false; - mongoc_iovec_t *iovec = acmd->iovec; - size_t niovec = acmd->niovec; - - for (size_t i = 0u; i < acmd->niovec; i++) { - total_bytes += acmd->iovec[i].iov_len; - } - - if (acmd->bytes_written > 0) { - BSON_ASSERT (acmd->bytes_written < total_bytes); - /* if bytes have been written before, compute the offset in the next - * iovec entry to be written. */ - offset = acmd->bytes_written; - - size_t i = 0u; - - /* subtract the lengths of all iovec entries written so far. */ - for (i = 0u; i < acmd->niovec; i++) { - if (offset < acmd->iovec[i].iov_len) { - break; - } - offset -= acmd->iovec[i].iov_len; - } - - BSON_ASSERT (i < acmd->niovec); - - /* create a new iovec with the remaining data to be written. */ - niovec = acmd->niovec - i; - iovec = bson_malloc (niovec * sizeof (mongoc_iovec_t)); - memcpy (iovec, acmd->iovec + i, niovec * sizeof (mongoc_iovec_t)); - iovec[0].iov_base = (char *) iovec[0].iov_base + offset; - iovec[0].iov_len -= offset; - used_temp_iovec = true; - } - - mcd_rpc_message_egress (acmd->rpc); - bytes = mongoc_stream_writev (acmd->stream, iovec, niovec, 0); - - if (used_temp_iovec) { - bson_free (iovec); - } - - if (bytes <= 0 && mongoc_stream_should_retry (acmd->stream)) { - return MONGOC_ASYNC_CMD_IN_PROGRESS; - } - - if (bytes < 0) { - bson_set_error (&acmd->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to write rpc bytes."); - return MONGOC_ASYNC_CMD_ERROR; - } - - acmd->bytes_written += bytes; - - if (acmd->bytes_written < total_bytes) { - return MONGOC_ASYNC_CMD_IN_PROGRESS; - } - - acmd->state = MONGOC_ASYNC_CMD_RECV_LEN; - acmd->bytes_to_read = 4; - acmd->events = POLLIN; - - acmd->cmd_started = bson_get_monotonic_time (); - - return MONGOC_ASYNC_CMD_IN_PROGRESS; -} - -mongoc_async_cmd_result_t -_mongoc_async_cmd_phase_recv_len (mongoc_async_cmd_t *acmd) -{ - ssize_t bytes = _mongoc_buffer_try_append_from_stream ( - &acmd->buffer, acmd->stream, acmd->bytes_to_read, 0); - uint32_t msg_len; - - if (bytes <= 0 && mongoc_stream_should_retry (acmd->stream)) { - return MONGOC_ASYNC_CMD_IN_PROGRESS; - } - - if (bytes < 0) { - bson_set_error (&acmd->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to receive length header from server."); - return MONGOC_ASYNC_CMD_ERROR; - } - - if (bytes == 0) { - bson_set_error (&acmd->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Server closed connection."); - return MONGOC_ASYNC_CMD_ERROR; - } - - acmd->bytes_to_read = (size_t) (acmd->bytes_to_read - bytes); - - if (!acmd->bytes_to_read) { - memcpy (&msg_len, acmd->buffer.data, 4); - msg_len = BSON_UINT32_FROM_LE (msg_len); - - if (msg_len < 16 || msg_len > MONGOC_DEFAULT_MAX_MSG_SIZE || - msg_len < acmd->buffer.len) { - bson_set_error (&acmd->error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "Invalid reply from server."); - return MONGOC_ASYNC_CMD_ERROR; - } - - acmd->bytes_to_read = msg_len - acmd->buffer.len; - acmd->state = MONGOC_ASYNC_CMD_RECV_RPC; - - return _mongoc_async_cmd_phase_recv_rpc (acmd); - } - - return MONGOC_ASYNC_CMD_IN_PROGRESS; -} - -mongoc_async_cmd_result_t -_mongoc_async_cmd_phase_recv_rpc (mongoc_async_cmd_t *acmd) -{ - ssize_t bytes = _mongoc_buffer_try_append_from_stream ( - &acmd->buffer, acmd->stream, acmd->bytes_to_read, 0); - - if (bytes <= 0 && mongoc_stream_should_retry (acmd->stream)) { - return MONGOC_ASYNC_CMD_IN_PROGRESS; - } - - if (bytes < 0) { - bson_set_error (&acmd->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to receive rpc bytes from server."); - return MONGOC_ASYNC_CMD_ERROR; - } - - if (bytes == 0) { - bson_set_error (&acmd->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Server closed connection."); - return MONGOC_ASYNC_CMD_ERROR; - } - - acmd->bytes_to_read = (size_t) (acmd->bytes_to_read - bytes); - - if (!acmd->bytes_to_read) { - mcd_rpc_message_reset (acmd->rpc); - if (!mcd_rpc_message_from_data_in_place ( - acmd->rpc, acmd->buffer.data, acmd->buffer.len, NULL)) { - bson_set_error (&acmd->error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "Invalid reply from server."); - return MONGOC_ASYNC_CMD_ERROR; - } - mcd_rpc_message_ingress (acmd->rpc); - - void *decompressed_data; - size_t decompressed_data_len; - - if (!mcd_rpc_message_decompress_if_necessary ( - acmd->rpc, &decompressed_data, &decompressed_data_len)) { - bson_set_error (&acmd->error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "Could not decompress server reply"); - return MONGOC_ASYNC_CMD_ERROR; - } - - if (decompressed_data) { - _mongoc_buffer_destroy (&acmd->buffer); - _mongoc_buffer_init (&acmd->buffer, - decompressed_data, - decompressed_data_len, - NULL, - NULL); - } - - if (!mcd_rpc_message_get_body (acmd->rpc, &acmd->reply)) { - bson_set_error (&acmd->error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "Invalid reply from server"); - return MONGOC_ASYNC_CMD_ERROR; - } - - acmd->reply_needs_cleanup = true; - - return MONGOC_ASYNC_CMD_SUCCESS; - } - - return MONGOC_ASYNC_CMD_IN_PROGRESS; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-async.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-async.c deleted file mode 100644 index e4f8c1c5f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-async.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "mongoc-async-private.h" -#include "mongoc-async-cmd-private.h" -#include "utlist.h" -#include "mongoc.h" -#include "mongoc-socket-private.h" -#include "mongoc-util-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "async" - - -mongoc_async_t * -mongoc_async_new (void) -{ - mongoc_async_t *async = (mongoc_async_t *) bson_malloc0 (sizeof (*async)); - - return async; -} - -void -mongoc_async_destroy (mongoc_async_t *async) -{ - mongoc_async_cmd_t *acmd, *tmp; - - DL_FOREACH_SAFE (async->cmds, acmd, tmp) - { - mongoc_async_cmd_destroy (acmd); - } - - bson_free (async); -} - -void -mongoc_async_run (mongoc_async_t *async) -{ - mongoc_async_cmd_t *acmd, *tmp; - mongoc_async_cmd_t **acmds_polled = NULL; - mongoc_stream_poll_t *poller = NULL; - int nstreams, i; - ssize_t nactive = 0; - int64_t now; - int64_t expire_at; - int64_t poll_timeout_msec; - size_t poll_size; - - now = bson_get_monotonic_time (); - poll_size = 0; - - /* CDRIVER-1571 reset start times in case a stream initiator was slow */ - DL_FOREACH (async->cmds, acmd) - { - acmd->connect_started = now; - } - - while (async->ncmds) { - /* ncmds grows if we discover a replica & start calling hello on it */ - if (poll_size < async->ncmds) { - poller = (mongoc_stream_poll_t *) bson_realloc ( - poller, sizeof (*poller) * async->ncmds); - acmds_polled = (mongoc_async_cmd_t **) bson_realloc ( - acmds_polled, sizeof (*acmds_polled) * async->ncmds); - poll_size = async->ncmds; - } - - expire_at = INT64_MAX; - nstreams = 0; - - /* check if any cmds are ready to be initiated. */ - DL_FOREACH_SAFE (async->cmds, acmd, tmp) - { - if (acmd->state == MONGOC_ASYNC_CMD_INITIATE) { - BSON_ASSERT (!acmd->stream); - if (now >= acmd->initiate_delay_ms * 1000 + acmd->connect_started) { - /* time to initiate. */ - if (mongoc_async_cmd_run (acmd)) { - BSON_ASSERT (acmd->stream); - } else { - /* this command was removed. */ - continue; - } - } else { - /* don't poll longer than the earliest cmd ready to init. */ - expire_at = BSON_MIN ( - expire_at, acmd->connect_started + acmd->initiate_delay_ms); - } - } - - if (acmd->stream) { - acmds_polled[nstreams] = acmd; - poller[nstreams].stream = acmd->stream; - poller[nstreams].events = acmd->events; - poller[nstreams].revents = 0; - expire_at = BSON_MIN ( - expire_at, acmd->connect_started + acmd->timeout_msec * 1000); - ++nstreams; - } - } - - if (async->ncmds == 0) { - /* all cmds failed to initiate and removed themselves. */ - break; - } - - poll_timeout_msec = BSON_MAX (0, (expire_at - now) / 1000); - BSON_ASSERT (poll_timeout_msec < INT32_MAX); - - if (nstreams > 0) { - /* we need at least one stream to poll. */ - nactive = - mongoc_stream_poll (poller, nstreams, (int32_t) poll_timeout_msec); - } else { - /* currently this does not get hit. we always have at least one command - * initialized with a stream. */ - _mongoc_usleep (poll_timeout_msec * 1000); - } - - if (nactive > 0) { - for (i = 0; i < nstreams; i++) { - mongoc_async_cmd_t *iter = acmds_polled[i]; - if (poller[i].revents & (POLLERR | POLLHUP)) { - int hup = poller[i].revents & POLLHUP; - if (iter->state == MONGOC_ASYNC_CMD_SEND) { - bson_set_error (&iter->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - hup ? "connection refused" - : "unknown connection error"); - } else { - bson_set_error (&iter->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - hup ? "connection closed" - : "unknown socket error"); - } - - iter->state = MONGOC_ASYNC_CMD_ERROR_STATE; - } - - if ((poller[i].revents & poller[i].events) || - iter->state == MONGOC_ASYNC_CMD_ERROR_STATE) { - (void) mongoc_async_cmd_run (iter); - nactive--; - } - - if (!nactive) { - break; - } - } - } - - DL_FOREACH_SAFE (async->cmds, acmd, tmp) - { - bool remove_cmd = false; - mongoc_async_cmd_result_t result; - - /* check if an initiated cmd has passed the connection timeout. */ - if (acmd->state != MONGOC_ASYNC_CMD_INITIATE && - now > acmd->connect_started + acmd->timeout_msec * 1000) { - bson_set_error (&acmd->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - acmd->state == MONGOC_ASYNC_CMD_SEND - ? "connection timeout" - : "socket timeout"); - - remove_cmd = true; - result = MONGOC_ASYNC_CMD_TIMEOUT; - } else if (acmd->state == MONGOC_ASYNC_CMD_CANCELED_STATE) { - remove_cmd = true; - result = MONGOC_ASYNC_CMD_ERROR; - } - - if (remove_cmd) { - acmd->cb (acmd, result, NULL, (now - acmd->connect_started) / 1000); - - /* Remove acmd from the async->cmds doubly-linked list */ - mongoc_async_cmd_destroy (acmd); - } - } - - now = bson_get_monotonic_time (); - } - - bson_free (poller); - bson_free (acmds_polled); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-buffer-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-buffer-private.h deleted file mode 100644 index 36c71446d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-buffer-private.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_BUFFER_PRIVATE_H -#define MONGOC_BUFFER_PRIVATE_H - -#include - -#include "mongoc-stream.h" - - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_buffer_t mongoc_buffer_t; - - -struct _mongoc_buffer_t { - uint8_t *data; - size_t datalen; - size_t len; - bson_realloc_func realloc_func; - void *realloc_data; -}; - - -void -_mongoc_buffer_init (mongoc_buffer_t *buffer, - uint8_t *buf, - size_t buflen, - bson_realloc_func realloc_func, - void *realloc_data); - -bool -_mongoc_buffer_append (mongoc_buffer_t *buffer, - const uint8_t *data, - size_t data_size); - -bool -_mongoc_buffer_append_from_stream (mongoc_buffer_t *buffer, - mongoc_stream_t *stream, - size_t size, - int64_t timeout_msec, - bson_error_t *error); - -ssize_t -_mongoc_buffer_try_append_from_stream (mongoc_buffer_t *buffer, - mongoc_stream_t *stream, - size_t size, - int64_t timeout_msec); - -ssize_t -_mongoc_buffer_fill (mongoc_buffer_t *buffer, - mongoc_stream_t *stream, - size_t min_bytes, - int64_t timeout_msec, - bson_error_t *error); - -void -_mongoc_buffer_destroy (mongoc_buffer_t *buffer); - -void -_mongoc_buffer_clear (mongoc_buffer_t *buffer, bool zero); - - -BSON_END_DECLS - - -#endif /* MONGOC_BUFFER_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-buffer.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-buffer.c deleted file mode 100644 index d8bd2892d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-buffer.c +++ /dev/null @@ -1,358 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include - -#include "mongoc-error.h" -#include "mongoc-buffer-private.h" -#include "mongoc-trace-private.h" - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "buffer" - -#ifndef MONGOC_BUFFER_DEFAULT_SIZE -#define MONGOC_BUFFER_DEFAULT_SIZE 1024 -#endif - - -static void -make_space_for (mongoc_buffer_t *buffer, size_t data_size) -{ - if (buffer->len + data_size > buffer->datalen) { - buffer->datalen = bson_next_power_of_two (buffer->len + data_size); - buffer->data = (uint8_t *) buffer->realloc_func ( - buffer->data, buffer->datalen, buffer->realloc_data); - } -} - - -/** - * _mongoc_buffer_init: - * @buffer: A mongoc_buffer_t to initialize. - * @buf: A data buffer to attach to @buffer. - * @buflen: The size of @buflen. - * @realloc_func: A function to resize @buf. - * - * Initializes @buffer for use. If additional space is needed by @buffer, then - * @realloc_func will be called to resize @buf. - * - * @buffer takes ownership of @buf and will realloc it to zero bytes when - * cleaning up the data structure. - */ -void -_mongoc_buffer_init (mongoc_buffer_t *buffer, - uint8_t *buf, - size_t buflen, - bson_realloc_func realloc_func, - void *realloc_data) -{ - BSON_ASSERT_PARAM (buffer); - BSON_ASSERT (buflen || !buf); - - if (!realloc_func) { - realloc_func = bson_realloc_ctx; - } - - if (!buflen) { - buflen = MONGOC_BUFFER_DEFAULT_SIZE; - } - - if (!buf) { - buf = (uint8_t *) realloc_func (NULL, buflen, NULL); - } - - memset (buffer, 0, sizeof *buffer); - - buffer->data = buf; - buffer->datalen = buflen; - buffer->len = 0; - buffer->realloc_func = realloc_func; - buffer->realloc_data = realloc_data; -} - - -/** - * _mongoc_buffer_destroy: - * @buffer: A mongoc_buffer_t. - * - * Cleanup after @buffer and release any allocated resources. - */ -void -_mongoc_buffer_destroy (mongoc_buffer_t *buffer) -{ - BSON_ASSERT_PARAM (buffer); - - if (buffer->data && buffer->realloc_func) { - buffer->realloc_func (buffer->data, 0, buffer->realloc_data); - } - - memset (buffer, 0, sizeof *buffer); -} - - -/** - * _mongoc_buffer_clear: - * @buffer: A mongoc_buffer_t. - * @zero: If the memory should be zeroed. - * - * Clears a buffers contents and resets it to initial state. You can request - * that the memory is zeroed, which might be useful if you know the contents - * contain security related information. - */ -void -_mongoc_buffer_clear (mongoc_buffer_t *buffer, bool zero) -{ - BSON_ASSERT_PARAM (buffer); - - if (zero) { - memset (buffer->data, 0, buffer->datalen); - } - - buffer->len = 0; -} - - -bool -_mongoc_buffer_append (mongoc_buffer_t *buffer, - const uint8_t *data, - size_t data_size) -{ - uint8_t *buf; - - ENTRY; - - BSON_ASSERT_PARAM (buffer); - BSON_ASSERT (data_size); - - BSON_ASSERT (buffer->datalen); - - make_space_for (buffer, data_size); - - buf = &buffer->data[buffer->len]; - - BSON_ASSERT ((buffer->len + data_size) <= buffer->datalen); - - memcpy (buf, data, data_size); - - buffer->len += data_size; - - RETURN (true); -} - - -/** - * mongoc_buffer_append_from_stream: - * @buffer; A mongoc_buffer_t. - * @stream: The stream to read from. - * @size: The number of bytes to read. - * @timeout_msec: The number of milliseconds to wait or -1 for the default - * @error: A location for a bson_error_t, or NULL. - * - * Reads from stream @size bytes and stores them in @buffer. This can be used - * in conjunction with reading RPCs from a stream. You read from the stream - * into this buffer and then scatter the buffer into the RPC. - * - * Returns: true if successful; otherwise false and @error is set. - */ -bool -_mongoc_buffer_append_from_stream (mongoc_buffer_t *buffer, - mongoc_stream_t *stream, - size_t size, - int64_t timeout_msec, - bson_error_t *error) -{ - uint8_t *buf; - ssize_t ret; - - ENTRY; - - BSON_ASSERT_PARAM (buffer); - BSON_ASSERT_PARAM (stream); - BSON_ASSERT (size); - - BSON_ASSERT (buffer->datalen); - - make_space_for (buffer, size); - - buf = &buffer->data[buffer->len]; - - BSON_ASSERT ((buffer->len + size) <= buffer->datalen); - - if (BSON_UNLIKELY (!bson_in_range_signed (int32_t, timeout_msec))) { - // CDRIVER-4589 - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "timeout_msec value %" PRId64 - " exceeds supported 32-bit range", - timeout_msec); - RETURN (false); - } - - ret = mongoc_stream_read (stream, buf, size, size, (int32_t) timeout_msec); - if (bson_cmp_not_equal_su (ret, size)) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to read %zu bytes: socket error or timeout", - size); - RETURN (false); - } - - buffer->len += (size_t) ret; - - RETURN (true); -} - - -/** - * _mongoc_buffer_fill: - * @buffer: A mongoc_buffer_t. - * @stream: A stream to read from. - * @min_bytes: The minimum number of bytes to read. - * @error: A location for a bson_error_t or NULL. - * - * Attempts to fill the entire buffer, or at least @min_bytes. - * - * Returns: The number of buffered bytes, or -1 on failure. - */ -ssize_t -_mongoc_buffer_fill (mongoc_buffer_t *buffer, - mongoc_stream_t *stream, - size_t min_bytes, - int64_t timeout_msec, - bson_error_t *error) -{ - ssize_t ret; - size_t avail_bytes; - - ENTRY; - - BSON_ASSERT_PARAM (buffer); - BSON_ASSERT_PARAM (stream); - - BSON_ASSERT (buffer->data); - BSON_ASSERT (buffer->datalen); - - if (min_bytes <= buffer->len) { - BSON_ASSERT (bson_in_range_unsigned (ssize_t, buffer->len)); - RETURN ((ssize_t) buffer->len); - } - - min_bytes -= buffer->len; - - make_space_for (buffer, min_bytes); - - avail_bytes = buffer->datalen - buffer->len; - - if (BSON_UNLIKELY (!bson_in_range_signed (int32_t, timeout_msec))) { - // CDRIVER-4589 - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "timeout_msec value %" PRId64 - " exceeds supported 32-bit range", - timeout_msec); - RETURN (false); - } - - ret = mongoc_stream_read (stream, - &buffer->data[buffer->len], - avail_bytes, - min_bytes, - (int32_t) timeout_msec); - - if (ret < 0) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to buffer %zu bytes", - min_bytes); - RETURN (-1); - } - - buffer->len += (size_t) ret; - - if (buffer->len < min_bytes) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Could only buffer %zu of %zu bytes", - buffer->len, - min_bytes); - RETURN (-1); - } - - BSON_ASSERT (bson_in_range_unsigned (ssize_t, buffer->len)); - RETURN ((ssize_t) buffer->len); -} - - -/** - * mongoc_buffer_try_append_from_stream: - * @buffer; A mongoc_buffer_t. - * @stream: The stream to read from. - * @size: The number of bytes to read. - * @timeout_msec: The number of milliseconds to wait or -1 for the default - * - * Reads from stream @size bytes and stores them in @buffer. This can be used - * in conjunction with reading RPCs from a stream. You read from the stream - * into this buffer and then scatter the buffer into the RPC. - * - * Returns: bytes read if successful; otherwise 0 or -1. - */ -ssize_t -_mongoc_buffer_try_append_from_stream (mongoc_buffer_t *buffer, - mongoc_stream_t *stream, - size_t size, - int64_t timeout_msec) -{ - uint8_t *buf; - ssize_t ret; - - ENTRY; - - BSON_ASSERT_PARAM (buffer); - BSON_ASSERT_PARAM (stream); - BSON_ASSERT (size); - - BSON_ASSERT (buffer->datalen); - - make_space_for (buffer, size); - - buf = &buffer->data[buffer->len]; - - BSON_ASSERT ((buffer->len + size) <= buffer->datalen); - - if (BSON_UNLIKELY (!bson_in_range_signed (int32_t, timeout_msec))) { - // CDRIVER-4589 - MONGOC_ERROR ("timeout_msec value %" PRId64 - " exceeds supported 32-bit range", - timeout_msec); - RETURN (-1); - } - - ret = mongoc_stream_read (stream, buf, size, 0, (int32_t) timeout_msec); - - if (ret > 0) { - buffer->len += (size_t) ret; - } - - RETURN (ret); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-bulk-operation.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-bulk-operation.c deleted file mode 100644 index d5a4a67e0..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-bulk-operation.c +++ /dev/null @@ -1,1026 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-bulk-operation.h" -#include "mongoc-bulk-operation-private.h" -#include "mongoc-client-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-util-private.h" -#include "mongoc-opts-private.h" -#include "mongoc-write-command-private.h" - - -/* - * This is the implementation of both write commands and bulk write commands. - * They are all implemented as one contiguous set since we'd like to cut down - * on code duplication here. - * - * This implementation is currently naive. - * - * Some interesting optimizations might be: - * - * - If unordered mode, send operations as we get them instead of waiting - * for execute() to be called. This could save us memcpy()'s too. - * - If there is no acknowledgement desired, keep a count of how many - * replies we need and ask the socket layer to skip that many bytes - * when reading. - * - Try to use iovec to send write commands with subdocuments rather than - * copying them into the write command document. - */ - - -mongoc_bulk_operation_t * -mongoc_bulk_operation_new (bool ordered) -{ - mongoc_bulk_operation_t *bulk; - - bulk = BSON_ALIGNED_ALLOC0 (mongoc_bulk_operation_t); - bulk->flags.bypass_document_validation = false; - bulk->flags.ordered = ordered; - bulk->server_id = 0; - - bson_init (&bulk->let); - - mongoc_array_aligned_init (&bulk->commands, mongoc_write_command_t); - _mongoc_write_result_init (&bulk->result); - - return bulk; -} - - -mongoc_bulk_operation_t * -_mongoc_bulk_operation_new ( - mongoc_client_t *client, /* IN */ - const char *database, /* IN */ - const char *collection, /* IN */ - mongoc_bulk_write_flags_t flags, /* IN */ - const mongoc_write_concern_t *write_concern) /* IN */ -{ - mongoc_bulk_operation_t *bulk; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT_PARAM (collection); - - bulk = mongoc_bulk_operation_new (flags.ordered); - bulk->client = client; - bulk->database = bson_strdup (database); - bulk->collection = bson_strdup (collection); - bulk->write_concern = mongoc_write_concern_copy (write_concern); - bulk->executed = false; - bulk->flags = flags; - bulk->operation_id = ++client->cluster.operation_id; - - return bulk; -} - - -void -mongoc_bulk_operation_destroy (mongoc_bulk_operation_t *bulk) /* IN */ -{ - mongoc_write_command_t *command; - - if (bulk) { - for (size_t i = 0; i < bulk->commands.len; i++) { - command = - &_mongoc_array_index (&bulk->commands, mongoc_write_command_t, i); - _mongoc_write_command_destroy (command); - } - - bson_free (bulk->database); - bson_free (bulk->collection); - bson_value_destroy (&bulk->comment); - bson_destroy (&bulk->let); - mongoc_write_concern_destroy (bulk->write_concern); - _mongoc_array_destroy (&bulk->commands); - - _mongoc_write_result_destroy (&bulk->result); - - bson_free (bulk); - } -} - - -/* already failed, e.g. a bad call to mongoc_bulk_operation_insert? */ -#define BULK_EXIT_IF_PRIOR_ERROR \ - do { \ - if (bulk->result.error.domain) { \ - EXIT; \ - } \ - } while (0) - -#define BULK_RETURN_IF_PRIOR_ERROR \ - do { \ - if (bulk->result.error.domain) { \ - if (error != &bulk->result.error) { \ - bson_set_error (error, \ - MONGOC_ERROR_COMMAND, \ - MONGOC_ERROR_COMMAND_INVALID_ARG, \ - "Bulk operation is invalid from prior error: %s", \ - bulk->result.error.message); \ - }; \ - return false; \ - }; \ - } while (0) - - -static bool -_mongoc_bulk_operation_remove_with_opts ( - mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const mongoc_bulk_remove_opts_t *remove_opts, - int32_t limit, - bson_error_t *error) /* OUT */ -{ - mongoc_write_command_t command = {0}; - mongoc_write_command_t *last; - bson_t cmd_opts = BSON_INITIALIZER; - bson_t opts; - bool has_collation; - bool ret = false; - bool has_delete_hint; - - ENTRY; - - BSON_ASSERT_PARAM (bulk); - BSON_ASSERT_PARAM (selector); - - bson_init (&opts); - - /* allow "limit" in opts, but it must be the correct limit */ - if (remove_opts->limit != limit) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid \"limit\" in opts: %" PRId32 "." - " The value must be %" PRId32 ", or omitted.", - remove_opts->limit, - limit); - GOTO (done); - } - - bson_append_int32 (&opts, "limit", 5, limit); - has_collation = !bson_empty (&remove_opts->collation); - if (has_collation) { - bson_append_document (&opts, "collation", 9, &remove_opts->collation); - } - - has_delete_hint = !!(remove_opts->hint.value_type); - if (has_delete_hint) { - bson_append_value (&opts, "hint", 4, &remove_opts->hint); - } - - if (bulk->commands.len) { - last = &_mongoc_array_index ( - &bulk->commands, mongoc_write_command_t, bulk->commands.len - 1); - if (last->type == MONGOC_WRITE_COMMAND_DELETE) { - last->flags.has_collation |= has_collation; - last->flags.has_delete_hint |= has_delete_hint; - last->flags.has_multi_write |= (remove_opts->limit == 0); - _mongoc_write_command_delete_append (last, selector, &opts); - ret = true; - GOTO (done); - } - } - - if (bulk->comment.value_type != BSON_TYPE_EOD) { - bson_append_value (&cmd_opts, "comment", 7, &bulk->comment); - } - - if (!bson_empty (&bulk->let)) { - bson_append_document (&cmd_opts, "let", 3, &bulk->let); - } - - _mongoc_write_command_init_delete ( - &command, selector, &cmd_opts, &opts, bulk->flags, bulk->operation_id); - - command.flags.has_collation = has_collation; - command.flags.has_delete_hint = has_delete_hint; - command.flags.has_multi_write = (remove_opts->limit == 0); - - _mongoc_array_append_val (&bulk->commands, command); - ret = true; - -done: - bson_destroy (&cmd_opts); - bson_destroy (&opts); - RETURN (ret); -} - - -bool -mongoc_bulk_operation_remove_one_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *opts, - bson_error_t *error) /* OUT */ -{ - mongoc_bulk_remove_one_opts_t remove_opts; - bool ret; - - ENTRY; - - BULK_RETURN_IF_PRIOR_ERROR; - - if (!_mongoc_bulk_remove_one_opts_parse ( - bulk->client, opts, &remove_opts, error)) { - _mongoc_bulk_remove_one_opts_cleanup (&remove_opts); - RETURN (false); - } - - ret = _mongoc_bulk_operation_remove_with_opts ( - bulk, selector, &remove_opts.remove, 1, error); - - _mongoc_bulk_remove_one_opts_cleanup (&remove_opts); - RETURN (ret); -} - - -bool -mongoc_bulk_operation_remove_many_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *opts, - bson_error_t *error) /* OUT */ -{ - mongoc_bulk_remove_many_opts_t remove_opts; - bool ret; - - ENTRY; - - BULK_RETURN_IF_PRIOR_ERROR; - - if (!_mongoc_bulk_remove_many_opts_parse ( - bulk->client, opts, &remove_opts, error)) { - _mongoc_bulk_remove_many_opts_cleanup (&remove_opts); - RETURN (false); - } - - ret = _mongoc_bulk_operation_remove_with_opts ( - bulk, selector, &remove_opts.remove, 0, error); - - _mongoc_bulk_remove_many_opts_cleanup (&remove_opts); - RETURN (ret); -} - - -void -mongoc_bulk_operation_remove (mongoc_bulk_operation_t *bulk, /* IN */ - const bson_t *selector) /* IN */ -{ - bson_error_t *error = &bulk->result.error; - - ENTRY; - - BULK_EXIT_IF_PRIOR_ERROR; - - if (!mongoc_bulk_operation_remove_many_with_opts ( - bulk, selector, NULL, error)) { - MONGOC_WARNING ("%s", error->message); - } - - if (error->domain) { - MONGOC_WARNING ("%s", error->message); - } - - EXIT; -} - - -void -mongoc_bulk_operation_remove_one (mongoc_bulk_operation_t *bulk, /* IN */ - const bson_t *selector) /* IN */ -{ - bson_error_t *error = &bulk->result.error; - - ENTRY; - - BULK_EXIT_IF_PRIOR_ERROR; - - if (!mongoc_bulk_operation_remove_one_with_opts ( - bulk, selector, NULL, error)) { - MONGOC_WARNING ("%s", error->message); - } - - if (error->domain) { - MONGOC_WARNING ("%s", error->message); - } - - EXIT; -} - -void -mongoc_bulk_operation_delete (mongoc_bulk_operation_t *bulk, - const bson_t *selector) -{ - ENTRY; - - mongoc_bulk_operation_remove (bulk, selector); - - EXIT; -} - -void -mongoc_bulk_operation_delete_one (mongoc_bulk_operation_t *bulk, - const bson_t *selector) -{ - ENTRY; - - mongoc_bulk_operation_remove_one (bulk, selector); - - EXIT; -} - -void -mongoc_bulk_operation_insert (mongoc_bulk_operation_t *bulk, - const bson_t *document) -{ - ENTRY; - - BSON_ASSERT_PARAM (bulk); - BSON_ASSERT_PARAM (document); - - if (!mongoc_bulk_operation_insert_with_opts ( - bulk, document, NULL /* opts */, &bulk->result.error)) { - MONGOC_WARNING ("%s", bulk->result.error.message); - } - - EXIT; -} - -bool -mongoc_bulk_operation_insert_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *document, - const bson_t *opts, - bson_error_t *error) -{ - mongoc_bulk_insert_opts_t insert_opts; - mongoc_write_command_t command = {0}; - mongoc_write_command_t *last; - bson_t cmd_opts = BSON_INITIALIZER; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (bulk); - BSON_ASSERT_PARAM (document); - - BULK_RETURN_IF_PRIOR_ERROR; - - if (!_mongoc_bulk_insert_opts_parse ( - bulk->client, opts, &insert_opts, error)) { - GOTO (done); - } - - if (!_mongoc_validate_new_document (document, insert_opts.validate, error)) { - GOTO (done); - } - - /* Note: mongoc_bulk_insert_opts_t specifies allow_extra=False, so there is - * no reason to concatenate cmd_opts with &insert_opts.extra. */ - - if (bulk->commands.len) { - last = &_mongoc_array_index ( - &bulk->commands, mongoc_write_command_t, bulk->commands.len - 1); - - if (last->type == MONGOC_WRITE_COMMAND_INSERT) { - _mongoc_write_command_insert_append (last, document); - ret = true; - GOTO (done); - } - } - - if (bulk->comment.value_type != BSON_TYPE_EOD) { - bson_append_value (&cmd_opts, "comment", 7, &bulk->comment); - } - - _mongoc_write_command_init_insert ( - &command, document, &cmd_opts, bulk->flags, bulk->operation_id); - - _mongoc_array_append_val (&bulk->commands, command); - - ret = true; - -done: - _mongoc_bulk_insert_opts_cleanup (&insert_opts); - bson_destroy (&cmd_opts); - - RETURN (ret); -} - -static void -_mongoc_bulk_operation_update_append ( - mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - const mongoc_bulk_update_opts_t *update_opts, - const bson_t *array_filters, - const bson_t *extra_opts) -{ - mongoc_write_command_t command = {0}; - mongoc_write_command_t *last; - bson_t cmd_opts = BSON_INITIALIZER; - bson_t opts; - bool has_collation; - bool has_array_filters; - bool has_update_hint; - - bson_init (&opts); - bson_append_bool (&opts, "upsert", 6, update_opts->upsert); - bson_append_bool (&opts, "multi", 5, update_opts->multi); - - has_array_filters = !bson_empty0 (array_filters); - if (has_array_filters) { - bson_append_array (&opts, "arrayFilters", 12, array_filters); - } - - has_collation = !bson_empty (&update_opts->collation); - if (has_collation) { - bson_append_document (&opts, "collation", 9, &update_opts->collation); - } - - has_update_hint = !!(update_opts->hint.value_type); - if (has_update_hint) { - bson_append_value (&opts, "hint", 4, &update_opts->hint); - } - - if (extra_opts) { - bson_concat (&opts, extra_opts); - } - - if (bulk->commands.len) { - last = &_mongoc_array_index ( - &bulk->commands, mongoc_write_command_t, bulk->commands.len - 1); - if (last->type == MONGOC_WRITE_COMMAND_UPDATE) { - last->flags.has_array_filters |= has_array_filters; - last->flags.has_collation |= has_collation; - last->flags.has_update_hint |= has_update_hint; - last->flags.has_multi_write |= update_opts->multi; - _mongoc_write_command_update_append (last, selector, document, &opts); - GOTO (done); - } - } - - if (bulk->comment.value_type != BSON_TYPE_EOD) { - bson_append_value (&cmd_opts, "comment", 7, &bulk->comment); - } - - if (!bson_empty (&bulk->let)) { - bson_append_document (&cmd_opts, "let", 3, &bulk->let); - } - - _mongoc_write_command_init_update (&command, - selector, - document, - &cmd_opts, - &opts, - bulk->flags, - bulk->operation_id); - - command.flags.has_array_filters = has_array_filters; - command.flags.has_collation = has_collation; - command.flags.has_update_hint = has_update_hint; - command.flags.has_multi_write = update_opts->multi; - - _mongoc_array_append_val (&bulk->commands, command); - -done: - bson_destroy (&cmd_opts); - bson_destroy (&opts); -} - -static bool -_mongoc_bulk_operation_update_with_opts ( - mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - const mongoc_bulk_update_opts_t *update_opts, - const bson_t *array_filters, - const bson_t *extra_opts, - bool multi, - bson_error_t *error) /* OUT */ -{ - ENTRY; - - BSON_ASSERT_PARAM (bulk); - BSON_ASSERT_PARAM (selector); - BSON_ASSERT_PARAM (document); - - if (!_mongoc_validate_update (document, update_opts->validate, error)) { - RETURN (false); - } - - /* allow "multi" in opts, but it must be the correct multi */ - if (update_opts->multi != multi) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid \"multi\" in opts: %s." - " The value must be %s, or omitted.", - update_opts->multi ? "true" : "false", - multi ? "true" : "false"); - RETURN (false); - } - - _mongoc_bulk_operation_update_append ( - bulk, selector, document, update_opts, array_filters, extra_opts); - - RETURN (true); -} - -bool -mongoc_bulk_operation_update_one_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - const bson_t *opts, - bson_error_t *error) /* OUT */ -{ - mongoc_bulk_update_one_opts_t update_opts; - bool ret; - - ENTRY; - - BULK_RETURN_IF_PRIOR_ERROR; - - if (!_mongoc_bulk_update_one_opts_parse ( - bulk->client, opts, &update_opts, error)) { - _mongoc_bulk_update_one_opts_cleanup (&update_opts); - RETURN (false); - } - - ret = _mongoc_bulk_operation_update_with_opts (bulk, - selector, - document, - &update_opts.update, - &update_opts.arrayFilters, - &update_opts.extra, - false /* multi */, - error); - - _mongoc_bulk_update_one_opts_cleanup (&update_opts); - RETURN (ret); -} - -bool -mongoc_bulk_operation_update_many_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - const bson_t *opts, - bson_error_t *error) /* OUT */ -{ - mongoc_bulk_update_many_opts_t update_opts; - bool ret; - - ENTRY; - - BULK_RETURN_IF_PRIOR_ERROR; - - if (!_mongoc_bulk_update_many_opts_parse ( - bulk->client, opts, &update_opts, error)) { - _mongoc_bulk_update_many_opts_cleanup (&update_opts); - RETURN (false); - } - - ret = _mongoc_bulk_operation_update_with_opts (bulk, - selector, - document, - &update_opts.update, - &update_opts.arrayFilters, - &update_opts.extra, - true /* multi */, - error); - - _mongoc_bulk_update_many_opts_cleanup (&update_opts); - RETURN (ret); -} - -void -mongoc_bulk_operation_update (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - bool upsert) -{ - bson_t opts; - bson_error_t *error = &bulk->result.error; - - ENTRY; - - BULK_EXIT_IF_PRIOR_ERROR; - - bson_init (&opts); - if (upsert) { - BSON_APPEND_BOOL (&opts, "upsert", upsert); - } - - if (!mongoc_bulk_operation_update_many_with_opts ( - bulk, selector, document, &opts, error)) { - MONGOC_WARNING ("%s", error->message); - } - - bson_destroy (&opts); - - if (error->domain) { - MONGOC_WARNING ("%s", error->message); - } - - EXIT; -} - -void -mongoc_bulk_operation_update_one (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - bool upsert) -{ - bson_t opts; - bson_error_t *error = &bulk->result.error; - - ENTRY; - - BULK_EXIT_IF_PRIOR_ERROR; - - bson_init (&opts); - BSON_APPEND_BOOL (&opts, "upsert", upsert); - - if (!mongoc_bulk_operation_update_one_with_opts ( - bulk, selector, document, &opts, error)) { - MONGOC_WARNING ("%s", error->message); - } - - bson_destroy (&opts); - - if (error->domain) { - MONGOC_WARNING ("%s", error->message); - } - - EXIT; -} - -bool -mongoc_bulk_operation_replace_one_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - const bson_t *opts, - bson_error_t *error) /* OUT */ -{ - mongoc_bulk_replace_one_opts_t repl_opts; - mongoc_bulk_update_opts_t *update_opts = &repl_opts.update; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (bulk); - BSON_ASSERT_PARAM (selector); - BSON_ASSERT_PARAM (document); - - BULK_RETURN_IF_PRIOR_ERROR; - - if (!_mongoc_bulk_replace_one_opts_parse ( - bulk->client, opts, &repl_opts, error)) { - GOTO (done); - } - - if (!_mongoc_validate_replace (document, update_opts->validate, error)) { - GOTO (done); - } - - /* allow "multi" in opts, but it must be the correct multi */ - if (update_opts->multi) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid \"multi\": true in opts for" - " mongoc_bulk_operation_replace_one_with_opts." - " The value must be true, or omitted."); - GOTO (done); - } - - _mongoc_bulk_operation_update_append ( - bulk, selector, document, update_opts, NULL, &repl_opts.extra); - ret = true; - -done: - _mongoc_bulk_replace_one_opts_cleanup (&repl_opts); - RETURN (ret); -} - -void -mongoc_bulk_operation_replace_one (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - bool upsert) -{ - bson_t opts = BSON_INITIALIZER; - bson_error_t *error = &bulk->result.error; - - ENTRY; - - BSON_APPEND_BOOL (&opts, "upsert", upsert); - - if (!mongoc_bulk_operation_replace_one_with_opts ( - bulk, selector, document, &opts, error)) { - MONGOC_WARNING ("%s", error->message); - } - - bson_destroy (&opts); - - EXIT; -} - -uint32_t -mongoc_bulk_operation_execute (mongoc_bulk_operation_t *bulk, /* IN */ - bson_t *reply, /* OUT */ - bson_error_t *error) /* OUT */ -{ - mongoc_cluster_t *cluster; - mongoc_write_command_t *command; - mongoc_server_stream_t *server_stream; - bool ret; - uint32_t offset = 0; - - ENTRY; - - BSON_ASSERT_PARAM (bulk); - - if (!bulk->client) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "mongoc_bulk_operation_execute() requires a client " - "and one has not been set."); - GOTO (err); - } - cluster = &bulk->client->cluster; - - if (bulk->executed) { - _mongoc_write_result_destroy (&bulk->result); - _mongoc_write_result_init (&bulk->result); - } - - bulk->executed = true; - - if (!bulk->database) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "mongoc_bulk_operation_execute() requires a database " - "and one has not been set."); - GOTO (err); - } else if (!bulk->collection) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "mongoc_bulk_operation_execute() requires a collection " - "and one has not been set."); - GOTO (err); - } - - /* error stored by functions like mongoc_bulk_operation_insert that - * can't report errors immediately */ - if (bulk->result.error.domain) { - if (error) { - memcpy (error, &bulk->result.error, sizeof (bson_error_t)); - } - - GOTO (err); - } - - if (!bulk->commands.len) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot do an empty bulk write"); - GOTO (err); - } - - for (size_t i = 0u; i < bulk->commands.len; i++) { - if (bulk->server_id) { - server_stream = - mongoc_cluster_stream_for_server (cluster, - bulk->server_id, - true /* reconnect_ok */, - bulk->session, - reply, - error); - } else { - server_stream = mongoc_cluster_stream_for_writes ( - cluster, bulk->session, NULL, reply, error); - } - - if (!server_stream) { - /* stream_for_server and stream_for_writes initialize reply on error */ - RETURN (false); - } - - command = - &_mongoc_array_index (&bulk->commands, mongoc_write_command_t, i); - - _mongoc_write_command_execute (command, - bulk->client, - server_stream, - bulk->database, - bulk->collection, - bulk->write_concern, - offset, - bulk->session, - &bulk->result); - - bulk->server_id = server_stream->sd->id; - /* If a retryable error occurred and a new primary was selected, use it in - * subsequent commands. */ - if (bulk->result.retry_server_id) { - bulk->server_id = bulk->result.retry_server_id; - } - - if (bulk->result.failed && - (bulk->flags.ordered || bulk->result.must_stop)) { - mongoc_server_stream_cleanup (server_stream); - GOTO (cleanup); - } - - offset += command->n_documents; - mongoc_server_stream_cleanup (server_stream); - } - -cleanup: - _mongoc_bson_init_if_set (reply); - ret = MONGOC_WRITE_RESULT_COMPLETE (&bulk->result, - bulk->client->error_api_version, - bulk->write_concern, - MONGOC_ERROR_COMMAND /* err domain */, - reply, - error); - - RETURN (ret ? bulk->server_id : 0); - -err: - _mongoc_bson_init_if_set (reply); - RETURN (false); -} - -void -mongoc_bulk_operation_set_write_concern ( - mongoc_bulk_operation_t *bulk, const mongoc_write_concern_t *write_concern) -{ - BSON_ASSERT_PARAM (bulk); - - if (bulk->write_concern) { - mongoc_write_concern_destroy (bulk->write_concern); - } - - if (write_concern) { - bulk->write_concern = mongoc_write_concern_copy (write_concern); - } else { - bulk->write_concern = mongoc_write_concern_new (); - } -} - -const mongoc_write_concern_t * -mongoc_bulk_operation_get_write_concern (const mongoc_bulk_operation_t *bulk) -{ - BSON_ASSERT_PARAM (bulk); - - return bulk->write_concern; -} - - -void -mongoc_bulk_operation_set_database (mongoc_bulk_operation_t *bulk, - const char *database) -{ - BSON_ASSERT_PARAM (bulk); - - if (bulk->database) { - bson_free (bulk->database); - } - - bulk->database = bson_strdup (database); -} - - -void -mongoc_bulk_operation_set_collection (mongoc_bulk_operation_t *bulk, - const char *collection) -{ - BSON_ASSERT_PARAM (bulk); - - if (bulk->collection) { - bson_free (bulk->collection); - } - - bulk->collection = bson_strdup (collection); -} - - -void -mongoc_bulk_operation_set_client (mongoc_bulk_operation_t *bulk, void *client) -{ - BSON_ASSERT_PARAM (bulk); - BSON_ASSERT_PARAM (client); - - if (bulk->session) { - BSON_ASSERT (bulk->session->client == client); - } - - bulk->client = (mongoc_client_t *) client; - - /* if you call set_client, bulk was likely made by mongoc_bulk_operation_new, - * not mongoc_collection_create_bulk_operation_with_opts(), so operation_id - * is 0. */ - if (!bulk->operation_id) { - bulk->operation_id = ++bulk->client->cluster.operation_id; - } -} - - -void -mongoc_bulk_operation_set_client_session ( - mongoc_bulk_operation_t *bulk, - struct _mongoc_client_session_t *client_session) -{ - BSON_ASSERT_PARAM (bulk); - BSON_ASSERT_PARAM (client_session); - - if (bulk->client) { - BSON_ASSERT (bulk->client == client_session->client); - } - - bulk->session = client_session; -} - - -uint32_t -mongoc_bulk_operation_get_hint (const mongoc_bulk_operation_t *bulk) -{ - BSON_ASSERT_PARAM (bulk); - - return bulk->server_id; -} - - -void -mongoc_bulk_operation_set_hint (mongoc_bulk_operation_t *bulk, - uint32_t server_id) -{ - BSON_ASSERT_PARAM (bulk); - - bulk->server_id = server_id; -} - - -void -mongoc_bulk_operation_set_bypass_document_validation ( - mongoc_bulk_operation_t *bulk, bool bypass) -{ - BSON_ASSERT_PARAM (bulk); - - bulk->flags.bypass_document_validation = bypass; -} - - -void -mongoc_bulk_operation_set_comment (mongoc_bulk_operation_t *bulk, - const bson_value_t *comment) -{ - BSON_ASSERT_PARAM (bulk); - BSON_ASSERT_PARAM (comment); - BSON_ASSERT (comment->value_type != BSON_TYPE_EOD); - - /* This method cannot be called after appending operations, as the CRUD spec - * states the option should apply to all commands. Since commands are - * initialized as operations are added, allowing "comment" to be changed at - * any time could violate that contract. */ - BSON_ASSERT (bulk->commands.len == 0); - - bson_value_destroy (&bulk->comment); - bson_value_copy (comment, &bulk->comment); -} - - -void -mongoc_bulk_operation_set_let (mongoc_bulk_operation_t *bulk, const bson_t *let) -{ - BSON_ASSERT_PARAM (bulk); - BSON_ASSERT_PARAM (let); - - /* This method cannot be called after appending operations, as the CRUD spec - * states the option should apply to all commands (excluding insert). Since - * commands are initialized as operations are added, allowing "let" to be - * changed at any time could violate that contract. */ - BSON_ASSERT (bulk->commands.len == 0); - - bson_destroy (&bulk->let); - bson_copy_to (let, &bulk->let); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-bulk-operation.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-bulk-operation.h deleted file mode 100644 index 515bfb2f6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-bulk-operation.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - - -#ifndef MONGOC_BULK_OPERATION_H -#define MONGOC_BULK_OPERATION_H - - -#include - -#include "mongoc-macros.h" -#include "mongoc-write-concern.h" - -/* ordered, bypass_document_validation, has_collation, multi */ -#define MONGOC_BULK_WRITE_FLAGS_INIT \ - { \ - true, false, 0 \ - } - -BSON_BEGIN_DECLS - -/* forward decl */ -struct _mongoc_client_session_t; - -typedef struct _mongoc_bulk_operation_t mongoc_bulk_operation_t; -typedef struct _mongoc_bulk_write_flags_t mongoc_bulk_write_flags_t; - - -MONGOC_EXPORT (void) -mongoc_bulk_operation_destroy (mongoc_bulk_operation_t *bulk); -MONGOC_EXPORT (uint32_t) -mongoc_bulk_operation_execute (mongoc_bulk_operation_t *bulk, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (void) -mongoc_bulk_operation_delete (mongoc_bulk_operation_t *bulk, - const bson_t *selector) - BSON_GNUC_DEPRECATED_FOR (mongoc_bulk_operation_remove); -MONGOC_EXPORT (void) -mongoc_bulk_operation_delete_one (mongoc_bulk_operation_t *bulk, - const bson_t *selector) - BSON_GNUC_DEPRECATED_FOR (mongoc_bulk_operation_remove_one); -MONGOC_EXPORT (void) -mongoc_bulk_operation_insert (mongoc_bulk_operation_t *bulk, - const bson_t *document); -MONGOC_EXPORT (bool) -mongoc_bulk_operation_insert_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *document, - const bson_t *opts, - bson_error_t *error); /* OUT */ -MONGOC_EXPORT (void) -mongoc_bulk_operation_remove (mongoc_bulk_operation_t *bulk, - const bson_t *selector); -MONGOC_EXPORT (bool) -mongoc_bulk_operation_remove_many_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *opts, - bson_error_t *error); /* OUT */ -MONGOC_EXPORT (void) -mongoc_bulk_operation_remove_one (mongoc_bulk_operation_t *bulk, - const bson_t *selector); -MONGOC_EXPORT (bool) -mongoc_bulk_operation_remove_one_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *opts, - bson_error_t *error); /* OUT */ -MONGOC_EXPORT (void) -mongoc_bulk_operation_replace_one (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - bool upsert); -MONGOC_EXPORT (bool) -mongoc_bulk_operation_replace_one_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - const bson_t *opts, - bson_error_t *error); /* OUT */ -MONGOC_EXPORT (void) -mongoc_bulk_operation_update (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - bool upsert); -MONGOC_EXPORT (bool) -mongoc_bulk_operation_update_many_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - const bson_t *opts, - bson_error_t *error); /* OUT */ -MONGOC_EXPORT (void) -mongoc_bulk_operation_update_one (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - bool upsert); -MONGOC_EXPORT (bool) -mongoc_bulk_operation_update_one_with_opts (mongoc_bulk_operation_t *bulk, - const bson_t *selector, - const bson_t *document, - const bson_t *opts, - bson_error_t *error); /* OUT */ -MONGOC_EXPORT (void) -mongoc_bulk_operation_set_bypass_document_validation ( - mongoc_bulk_operation_t *bulk, bool bypass); -MONGOC_EXPORT (void) -mongoc_bulk_operation_set_comment (mongoc_bulk_operation_t *bulk, - const bson_value_t *comment); -MONGOC_EXPORT (void) -mongoc_bulk_operation_set_let (mongoc_bulk_operation_t *bulk, - const bson_t *let); - - -/* - * The following functions are really only useful by language bindings and - * those wanting to replay a bulk operation to a number of clients or - * collections. - */ -MONGOC_EXPORT (mongoc_bulk_operation_t *) -mongoc_bulk_operation_new (bool ordered) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_bulk_operation_set_write_concern ( - mongoc_bulk_operation_t *bulk, const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (void) -mongoc_bulk_operation_set_database (mongoc_bulk_operation_t *bulk, - const char *database); -MONGOC_EXPORT (void) -mongoc_bulk_operation_set_collection (mongoc_bulk_operation_t *bulk, - const char *collection); -MONGOC_EXPORT (void) -mongoc_bulk_operation_set_client (mongoc_bulk_operation_t *bulk, void *client); -MONGOC_EXPORT (void) -mongoc_bulk_operation_set_client_session ( - mongoc_bulk_operation_t *bulk, - struct _mongoc_client_session_t *client_session); -/* These names include the term "hint" for backward compatibility, should be - * mongoc_bulk_operation_get_server_id, mongoc_bulk_operation_set_server_id. */ -MONGOC_EXPORT (void) -mongoc_bulk_operation_set_hint (mongoc_bulk_operation_t *bulk, - uint32_t server_id); -MONGOC_EXPORT (uint32_t) -mongoc_bulk_operation_get_hint (const mongoc_bulk_operation_t *bulk); -MONGOC_EXPORT (const mongoc_write_concern_t *) -mongoc_bulk_operation_get_write_concern (const mongoc_bulk_operation_t *bulk); -BSON_END_DECLS - - -#endif /* MONGOC_BULK_OPERATION_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-change-stream-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-change-stream-private.h deleted file mode 100644 index a38e5ba62..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-change-stream-private.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2017-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_CHANGE_STREAM_PRIVATE_H -#define MONGOC_CHANGE_STREAM_PRIVATE_H - -#include "mongoc-change-stream.h" -#include "mongoc-client-session.h" -#include "mongoc-collection.h" -#include "mongoc-cursor.h" -#include "mongoc-opts-private.h" -#include "mongoc-opts-helpers-private.h" - -typedef enum { - MONGOC_CHANGE_STREAM_COLLECTION, - MONGOC_CHANGE_STREAM_DATABASE, - MONGOC_CHANGE_STREAM_CLIENT -} mongoc_change_stream_type_t; - -struct _mongoc_change_stream_t { - mongoc_change_stream_opts_t opts; - mongoc_timestamp_t operation_time; - bson_t pipeline_to_append; - bson_t resume_token; - bson_t *full_document; - bson_t *full_document_before_change; - bool show_expanded_events; - - bson_error_t err; - bson_t err_doc; - - mongoc_cursor_t *cursor; - - mongoc_client_t *client; - mongoc_read_prefs_t *read_prefs; - mongoc_read_concern_t *read_concern; - - mongoc_change_stream_type_t change_stream_type; - char *db; - char *coll; - - int64_t max_await_time_ms; - int32_t batch_size; - - bool has_returned_results; - - /* Track whether the change stream has resumed after an error, as this - * determines how we construct an initial or resuming aggregate command. */ - bool resumed; - - mongoc_client_session_t *implicit_session; - - /* The max_wire_version of the server the change stream is tied to. */ - uint32_t max_wire_version; -}; - -mongoc_change_stream_t * -_mongoc_change_stream_new_from_collection (const mongoc_collection_t *coll, - const bson_t *pipeline, - const bson_t *opts); - -mongoc_change_stream_t * -_mongoc_change_stream_new_from_database (const mongoc_database_t *db, - const bson_t *pipeline, - const bson_t *opts); - -mongoc_change_stream_t * -_mongoc_change_stream_new_from_client (mongoc_client_t *client, - const bson_t *pipeline, - const bson_t *opts); - -#endif /* MONGOC_CHANGE_STREAM_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-change-stream.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-change-stream.c deleted file mode 100644 index 15c568c7f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-change-stream.c +++ /dev/null @@ -1,684 +0,0 @@ -/* - * Copyright 2017-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "mongoc-cluster-private.h" -#include "mongoc-change-stream-private.h" -#include "mongoc-collection-private.h" -#include "mongoc-client-private.h" -#include "mongoc-client-session-private.h" -#include "mongoc-cursor-private.h" -#include "mongoc-database-private.h" -#include "mongoc-error.h" -#include "mongoc-error-private.h" - -#define CHANGE_STREAM_ERR(_str) \ - bson_set_error (&stream->err, \ - MONGOC_ERROR_CURSOR, \ - MONGOC_ERROR_BSON, \ - "Could not set " _str); - -/* the caller knows either a client or server error has occurred. - * `reply` contains the server reply or an empty document. */ -static bool -_is_resumable_error (mongoc_change_stream_t *stream, const bson_t *reply) -{ - bson_error_t error = {0}; - - /* Change Streams Spec resumable criteria: "any error encountered which is - * not a server error (e.g. a timeout error or network error)" */ - if (bson_empty (reply)) { - return true; - } - - if (_mongoc_cmd_check_ok (reply, MONGOC_ERROR_API_VERSION_2, &error)) { - return true; - } - - if (error.code == MONGOC_SERVER_ERR_CURSOR_NOT_FOUND) { - return true; - } - - if (stream->max_wire_version >= WIRE_VERSION_4_4) { - return mongoc_error_has_label (reply, "ResumableChangeStreamError"); - } - - switch (error.code) { - case MONGOC_SERVER_ERR_HOSTUNREACHABLE: - case MONGOC_SERVER_ERR_HOSTNOTFOUND: - case MONGOC_SERVER_ERR_NETWORKTIMEOUT: - case MONGOC_SERVER_ERR_SHUTDOWNINPROGRESS: - case MONGOC_SERVER_ERR_PRIMARYSTEPPEDDOWN: - case MONGOC_SERVER_ERR_EXCEEDEDTIMELIMIT: - case MONGOC_SERVER_ERR_SOCKETEXCEPTION: - case MONGOC_SERVER_ERR_NOTPRIMARY: - case MONGOC_SERVER_ERR_INTERRUPTEDATSHUTDOWN: - case MONGOC_SERVER_ERR_INTERRUPTEDDUETOREPLSTATECHANGE: - case MONGOC_SERVER_ERR_NOTPRIMARYNOSECONDARYOK: - case MONGOC_SERVER_ERR_NOTPRIMARYORSECONDARY: - case MONGOC_SERVER_ERR_STALESHARDVERSION: - case MONGOC_SERVER_ERR_STALEEPOCH: - case MONGOC_SERVER_ERR_STALECONFIG: - case MONGOC_SERVER_ERR_RETRYCHANGESTREAM: - case MONGOC_SERVER_ERR_FAILEDTOSATISFYREADPREFERENCE: - return true; - default: - return false; - } -} - - -static void -_set_resume_token (mongoc_change_stream_t *stream, const bson_t *resume_token) -{ - BSON_ASSERT (stream); - BSON_ASSERT (resume_token); - - bson_destroy (&stream->resume_token); - bson_copy_to (resume_token, &stream->resume_token); -} - - -/* construct the aggregate command in cmd. looks like one of the following: - * for a collection change stream: - * { aggregate: collname, pipeline: [], cursor: { batchSize: x } } - * for a database change stream: - * { aggregate: 1, pipeline: [], cursor: { batchSize: x } } - * for a client change stream: - * { aggregate: 1, pipeline: [{$changeStream: {allChangesForCluster: true}}], - * cursor: { batchSize: x } } - */ -static void -_make_command (mongoc_change_stream_t *stream, bson_t *command) -{ - bson_iter_t iter; - bson_t change_stream_stage; /* { $changeStream: } */ - bson_t change_stream_doc; - bson_array_builder_t *pipeline; - bson_t cursor_doc; - - if (stream->change_stream_type == MONGOC_CHANGE_STREAM_COLLECTION) { - bson_append_utf8 ( - command, "aggregate", 9, stream->coll, (int) strlen (stream->coll)); - } else { - bson_append_int32 (command, "aggregate", 9, 1); - } - - bson_append_array_builder_begin (command, "pipeline", 8, &pipeline); - - /* append the $changeStream stage. */ - bson_array_builder_append_document_begin (pipeline, &change_stream_stage); - bson_append_document_begin ( - &change_stream_stage, "$changeStream", 13, &change_stream_doc); - if (stream->full_document) { - bson_concat (&change_stream_doc, stream->full_document); - } - if (stream->full_document_before_change) { - bson_concat (&change_stream_doc, stream->full_document_before_change); - } - if (stream->show_expanded_events) { - BSON_APPEND_BOOL (&change_stream_doc, - "showExpandedEvents", - stream->show_expanded_events); - } - - if (stream->resumed) { - /* Change stream spec: Resume Process */ - /* If there is a cached resumeToken: */ - if (!bson_empty (&stream->resume_token)) { - /* If the ChangeStream was started with startAfter - and has yet to return a result document: */ - if (!bson_empty (&stream->opts.startAfter) && - !stream->has_returned_results) { - /* The driver MUST set startAfter to the cached resumeToken */ - BSON_APPEND_DOCUMENT ( - &change_stream_doc, "startAfter", &stream->resume_token); - } else { - /* The driver MUST set resumeAfter to the cached resumeToken */ - BSON_APPEND_DOCUMENT ( - &change_stream_doc, "resumeAfter", &stream->resume_token); - } - } else if (!_mongoc_timestamp_empty (&stream->operation_time) && - stream->max_wire_version >= WIRE_VERSION_4_0) { - /* Else if there is no cached resumeToken and the ChangeStream - has a saved operation time and the max wire version is >= 7, - the driver MUST set startAtOperationTime */ - _mongoc_timestamp_append (&stream->operation_time, - &change_stream_doc, - "startAtOperationTime"); - } - } else { - /* Change streams spec: "startAtOperationTime, resumeAfter, and startAfter - * are all mutually exclusive; if any two are set, the server will return - * an error. Drivers MUST NOT throw a custom error, and MUST defer to the - * server error." */ - if (!bson_empty (&stream->opts.resumeAfter)) { - BSON_APPEND_DOCUMENT ( - &change_stream_doc, "resumeAfter", &stream->opts.resumeAfter); - - /* Update the cached resume token */ - _set_resume_token (stream, &stream->opts.resumeAfter); - } - - if (!bson_empty (&stream->opts.startAfter)) { - BSON_APPEND_DOCUMENT ( - &change_stream_doc, "startAfter", &stream->opts.startAfter); - - /* Update the cached resume token (take precedence over resumeAfter) */ - _set_resume_token (stream, &stream->opts.startAfter); - } - - if (!_mongoc_timestamp_empty (&stream->operation_time)) { - _mongoc_timestamp_append (&stream->operation_time, - &change_stream_doc, - "startAtOperationTime"); - } - } - - if (stream->change_stream_type == MONGOC_CHANGE_STREAM_CLIENT) { - bson_append_bool (&change_stream_doc, "allChangesForCluster", 20, true); - } - bson_append_document_end (&change_stream_stage, &change_stream_doc); - bson_array_builder_append_document_end (pipeline, &change_stream_stage); - - /* Append user pipeline if it exists */ - if (bson_iter_init_find (&iter, &stream->pipeline_to_append, "pipeline") && - BSON_ITER_HOLDS_ARRAY (&iter)) { - bson_iter_t child_iter; - - BSON_ASSERT (bson_iter_recurse (&iter, &child_iter)); - while (bson_iter_next (&child_iter)) { - /* the user pipeline may consist of invalid stages or non-documents. - * append anyway, and rely on the server error. */ - bson_array_builder_append_value (pipeline, - bson_iter_value (&child_iter)); - } - } - - bson_append_array_builder_end (command, pipeline); - - /* Add batch size if needed */ - bson_append_document_begin (command, "cursor", 6, &cursor_doc); - if (stream->batch_size > 0) { - bson_append_int32 (&cursor_doc, "batchSize", 9, stream->batch_size); - } - bson_append_document_end (command, &cursor_doc); -} - -/*--------------------------------------------------------------------------- - * - * _make_cursor -- - * - * Construct and send the aggregate command and create the resulting - * cursor. On error, stream->cursor remains NULL, otherwise it is - * created and must be destroyed. - * - * Return: - * False on error and sets stream->err. - * - *-------------------------------------------------------------------------- - */ -static bool -_make_cursor (mongoc_change_stream_t *stream) -{ - mongoc_client_session_t *cs = NULL; - bson_t command_opts; - bson_t command; /* { aggregate: "coll", pipeline: [], ... } */ - bson_t reply; - bson_t getmore_opts = BSON_INITIALIZER; - bson_iter_t iter; - mongoc_server_stream_t *server_stream; - - BSON_ASSERT (stream); - BSON_ASSERT (!stream->cursor); - bson_init (&command); - bson_copy_to (&(stream->opts.extra), &command_opts); - - if (stream->opts.comment.value_type != BSON_TYPE_EOD) { - bson_append_value (&command_opts, "comment", 7, &stream->opts.comment); - bson_append_value (&getmore_opts, "comment", 7, &stream->opts.comment); - } - - if (bson_iter_init_find (&iter, &command_opts, "sessionId")) { - if (!_mongoc_client_session_from_iter ( - stream->client, &iter, &cs, &stream->err)) { - goto cleanup; - } - } else if (stream->implicit_session) { - /* If an implicit session was created before, and this cursor is now - * being recreated after resuming, then use the same session as before. */ - cs = stream->implicit_session; - if (!mongoc_client_session_append (cs, &command_opts, &stream->err)) { - goto cleanup; - } - } else { - /* Create an implicit session. This session lsid must be the same for the - * agg command and the subsequent getMores. Thus, this implicit session is - * passed as if it were an explicit session to - * mongoc_client_read_command_with_opts and - * _mongoc_cursor_change_stream_new, but it is still implicit and its - * lifetime is owned by this change_stream_t. */ - mongoc_session_opt_t *session_opts; - session_opts = mongoc_session_opts_new (); - mongoc_session_opts_set_causal_consistency (session_opts, false); - /* returns NULL if sessions aren't supported. ignore errors. */ - cs = mongoc_client_start_session (stream->client, session_opts, NULL); - stream->implicit_session = cs; - mongoc_session_opts_destroy (session_opts); - if (cs && - !mongoc_client_session_append (cs, &command_opts, &stream->err)) { - goto cleanup; - } - } - - if (cs && !mongoc_client_session_append (cs, &getmore_opts, &stream->err)) { - goto cleanup; - } - - server_stream = mongoc_cluster_stream_for_reads (&stream->client->cluster, - stream->read_prefs, - cs, - NULL, - &reply, - &stream->err); - if (!server_stream) { - bson_destroy (&stream->err_doc); - bson_copy_to (&reply, &stream->err_doc); - bson_destroy (&reply); - goto cleanup; - } - bson_append_int32 (&command_opts, "serverId", 8, server_stream->sd->id); - bson_append_int32 (&getmore_opts, "serverId", 8, server_stream->sd->id); - stream->max_wire_version = server_stream->sd->max_wire_version; - mongoc_server_stream_cleanup (server_stream); - - if (stream->read_concern && !bson_has_field (&command_opts, "readConcern")) { - mongoc_read_concern_append (stream->read_concern, &command_opts); - } - - _make_command (stream, &command); - - /* even though serverId has already been set, still pass the read prefs. - * they are necessary for OP_MSG if sending to a secondary. */ - if (!mongoc_client_read_command_with_opts (stream->client, - stream->db, - &command, - stream->read_prefs, - &command_opts, - &reply, - &stream->err)) { - bson_destroy (&stream->err_doc); - bson_copy_to (&reply, &stream->err_doc); - bson_destroy (&reply); - goto cleanup; - } - - bson_append_bool ( - &getmore_opts, MONGOC_CURSOR_TAILABLE, MONGOC_CURSOR_TAILABLE_LEN, true); - bson_append_bool (&getmore_opts, - MONGOC_CURSOR_AWAIT_DATA, - MONGOC_CURSOR_AWAIT_DATA_LEN, - true); - - /* maxTimeMS is only appended to getMores if these are set in cursor opts. */ - if (stream->max_await_time_ms > 0) { - bson_append_int64 (&getmore_opts, - MONGOC_CURSOR_MAX_AWAIT_TIME_MS, - MONGOC_CURSOR_MAX_AWAIT_TIME_MS_LEN, - stream->max_await_time_ms); - } - - if (stream->batch_size > 0) { - bson_append_int32 (&getmore_opts, - MONGOC_CURSOR_BATCH_SIZE, - MONGOC_CURSOR_BATCH_SIZE_LEN, - stream->batch_size); - } - - /* steals reply. */ - stream->cursor = - _mongoc_cursor_change_stream_new (stream->client, &reply, &getmore_opts); - - if (mongoc_cursor_error (stream->cursor, NULL)) { - goto cleanup; - } - - /* Change stream spec: "When aggregate or getMore returns: If an empty batch - * was returned and a postBatchResumeToken was included, cache it." */ - if (_mongoc_cursor_change_stream_end_of_batch (stream->cursor) && - _mongoc_cursor_change_stream_has_post_batch_resume_token ( - stream->cursor)) { - _set_resume_token ( - stream, - _mongoc_cursor_change_stream_get_post_batch_resume_token ( - stream->cursor)); - } - - /* Change stream spec: startAtOperationTime */ - if (bson_empty (&stream->opts.resumeAfter) && - bson_empty (&stream->opts.startAfter) && - _mongoc_timestamp_empty (&stream->operation_time) && - stream->max_wire_version >= WIRE_VERSION_4_0 && - bson_empty (&stream->resume_token) && - bson_iter_init_find ( - &iter, - _mongoc_cursor_change_stream_get_reply (stream->cursor), - "operationTime") && - BSON_ITER_HOLDS_TIMESTAMP (&iter)) { - _mongoc_timestamp_set_from_bson (&stream->operation_time, &iter); - } - -cleanup: - bson_destroy (&command); - bson_destroy (&command_opts); - bson_destroy (&getmore_opts); - return stream->err.code == 0; -} - -/*--------------------------------------------------------------------------- - * - * _change_stream_init -- - * - * Called after @stream has the collection name, database name, read - * preferences, and read concern set. Creates the change streams - * cursor. - * - *-------------------------------------------------------------------------- - */ -void -_change_stream_init (mongoc_change_stream_t *stream, - const bson_t *pipeline, - const bson_t *opts) -{ - BSON_ASSERT (pipeline); - - stream->max_await_time_ms = -1; - stream->batch_size = -1; - bson_init (&stream->pipeline_to_append); - bson_init (&stream->resume_token); - bson_init (&stream->err_doc); - - if (!_mongoc_change_stream_opts_parse ( - stream->client, opts, &stream->opts, &stream->err)) { - return; - } - - if (stream->opts.fullDocument) { - stream->full_document = - BCON_NEW ("fullDocument", stream->opts.fullDocument); - } - - if (stream->opts.fullDocumentBeforeChange) { - stream->full_document_before_change = BCON_NEW ( - "fullDocumentBeforeChange", stream->opts.fullDocumentBeforeChange); - } - - _mongoc_timestamp_set (&stream->operation_time, - &stream->opts.startAtOperationTime); - - stream->batch_size = stream->opts.batchSize; - stream->max_await_time_ms = stream->opts.maxAwaitTimeMS; - stream->show_expanded_events = stream->opts.showExpandedEvents; - - /* Accept two forms of user pipeline: - * 1. A document like: { "pipeline": [...] } - * 2. An array-like document: { "0": {}, "1": {}, ... } - * If the passed pipeline is invalid, we pass it along and let the server - * error instead. - */ - if (!bson_empty (pipeline)) { - bson_iter_t iter; - if (bson_iter_init_find (&iter, pipeline, "pipeline") && - BSON_ITER_HOLDS_ARRAY (&iter)) { - if (!BSON_APPEND_VALUE (&stream->pipeline_to_append, - "pipeline", - bson_iter_value (&iter))) { - CHANGE_STREAM_ERR ("pipeline"); - } - } else { - if (!BSON_APPEND_ARRAY ( - &stream->pipeline_to_append, "pipeline", pipeline)) { - CHANGE_STREAM_ERR ("pipeline"); - } - } - } - - if (stream->err.code == 0) { - (void) _make_cursor (stream); - } -} - -mongoc_change_stream_t * -_mongoc_change_stream_new_from_collection (const mongoc_collection_t *coll, - const bson_t *pipeline, - const bson_t *opts) -{ - mongoc_change_stream_t *stream; - BSON_ASSERT (coll); - - stream = BSON_ALIGNED_ALLOC0 (mongoc_change_stream_t); - stream->db = bson_strdup (coll->db); - stream->coll = bson_strdup (coll->collection); - stream->read_prefs = mongoc_read_prefs_copy (coll->read_prefs); - stream->read_concern = mongoc_read_concern_copy (coll->read_concern); - stream->client = coll->client; - stream->change_stream_type = MONGOC_CHANGE_STREAM_COLLECTION; - _change_stream_init (stream, pipeline, opts); - return stream; -} - -mongoc_change_stream_t * -_mongoc_change_stream_new_from_database (const mongoc_database_t *db, - const bson_t *pipeline, - const bson_t *opts) -{ - mongoc_change_stream_t *stream; - BSON_ASSERT (db); - - stream = BSON_ALIGNED_ALLOC0 (mongoc_change_stream_t); - stream->db = bson_strdup (db->name); - stream->coll = NULL; - stream->read_prefs = mongoc_read_prefs_copy (db->read_prefs); - stream->read_concern = mongoc_read_concern_copy (db->read_concern); - stream->client = db->client; - stream->change_stream_type = MONGOC_CHANGE_STREAM_DATABASE; - _change_stream_init (stream, pipeline, opts); - return stream; -} - -mongoc_change_stream_t * -_mongoc_change_stream_new_from_client (mongoc_client_t *client, - const bson_t *pipeline, - const bson_t *opts) -{ - mongoc_change_stream_t *stream; - BSON_ASSERT (client); - - stream = BSON_ALIGNED_ALLOC0 (mongoc_change_stream_t); - stream->db = bson_strdup ("admin"); - stream->coll = NULL; - stream->read_prefs = mongoc_read_prefs_copy (client->read_prefs); - stream->read_concern = mongoc_read_concern_copy (client->read_concern); - stream->client = client; - stream->change_stream_type = MONGOC_CHANGE_STREAM_CLIENT; - _change_stream_init (stream, pipeline, opts); - return stream; -} - - -const bson_t * -mongoc_change_stream_get_resume_token (mongoc_change_stream_t *stream) -{ - if (!bson_empty (&stream->resume_token)) { - return &stream->resume_token; - } - - return NULL; -} - - -bool -mongoc_change_stream_next (mongoc_change_stream_t *stream, const bson_t **bson) -{ - bson_iter_t iter; - bson_t doc_resume_token; - uint32_t len; - const uint8_t *data; - bool ret = false; - - BSON_ASSERT (stream); - BSON_ASSERT (bson); - - if (stream->err.code != 0) { - goto end; - } - - BSON_ASSERT (stream->cursor); - if (!mongoc_cursor_next (stream->cursor, bson)) { - const bson_t *err_doc; - bson_error_t err; - bool resumable = false; - - if (!mongoc_cursor_error_document (stream->cursor, &err, &err_doc)) { - /* no error occurred, just no documents left. */ - goto end; - } - - resumable = _is_resumable_error (stream, err_doc); - while (resumable) { - /* recreate the cursor. */ - mongoc_cursor_destroy (stream->cursor); - stream->cursor = NULL; - stream->resumed = true; - if (!_make_cursor (stream)) { - goto end; - } - if (mongoc_cursor_next (stream->cursor, bson)) { - break; - } - if (!mongoc_cursor_error_document (stream->cursor, &err, &err_doc)) { - goto end; - } - if (err_doc) { - resumable = _is_resumable_error (stream, err_doc); - } else { - resumable = false; - } - } - - if (!resumable) { - stream->err = err; - bson_destroy (&stream->err_doc); - bson_copy_to (err_doc, &stream->err_doc); - goto end; - } - } - - /* we have received documents, either from the first call to next or after a - * resume. */ - stream->has_returned_results = true; - - if (!bson_iter_init_find (&iter, *bson, "_id") || - !BSON_ITER_HOLDS_DOCUMENT (&iter)) { - bson_set_error (&stream->err, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CHANGE_STREAM_NO_RESUME_TOKEN, - "Cannot provide resume functionality when the resume " - "token is missing"); - goto end; - } - - /* copy the resume token. */ - bson_iter_document (&iter, &len, &data); - BSON_ASSERT (bson_init_static (&doc_resume_token, data, len)); - _set_resume_token (stream, &doc_resume_token); - - /* clear out the operation time, since we no longer need it to resume. */ - _mongoc_timestamp_clear (&stream->operation_time); - ret = true; - -end: - /* Change stream spec: Updating the Cached Resume Token */ - if (stream->cursor && !mongoc_cursor_error (stream->cursor, NULL) && - _mongoc_cursor_change_stream_end_of_batch (stream->cursor) && - _mongoc_cursor_change_stream_has_post_batch_resume_token ( - stream->cursor)) { - _set_resume_token ( - stream, - _mongoc_cursor_change_stream_get_post_batch_resume_token ( - stream->cursor)); - } - - - /* Driver Sessions Spec: "When an implicit session is associated with a - * cursor for use with getMore operations, the session MUST be returned to - * the pool immediately following a getMore operation that indicates that the - * cursor has been exhausted." */ - if (stream->implicit_session) { - /* if creating the change stream cursor errored, it may be null. */ - if (!stream->cursor || stream->cursor->cursor_id == 0) { - mongoc_client_session_destroy (stream->implicit_session); - stream->implicit_session = NULL; - } - } - return ret; -} - -bool -mongoc_change_stream_error_document (const mongoc_change_stream_t *stream, - bson_error_t *err, - const bson_t **bson) -{ - BSON_ASSERT (stream); - - if (stream->err.code != 0) { - if (err) { - *err = stream->err; - } - if (bson) { - *bson = &stream->err_doc; - } - return true; - } - - if (bson) { - *bson = NULL; - } - return false; -} - -void -mongoc_change_stream_destroy (mongoc_change_stream_t *stream) -{ - if (!stream) { - return; - } - - bson_destroy (&stream->pipeline_to_append); - bson_destroy (&stream->resume_token); - bson_destroy (stream->full_document); - bson_destroy (stream->full_document_before_change); - bson_destroy (&stream->err_doc); - _mongoc_change_stream_opts_cleanup (&stream->opts); - mongoc_cursor_destroy (stream->cursor); - mongoc_client_session_destroy (stream->implicit_session); - mongoc_read_prefs_destroy (stream->read_prefs); - mongoc_read_concern_destroy (stream->read_concern); - - bson_free (stream->db); - bson_free (stream->coll); - bson_free (stream); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-pool.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-pool.c deleted file mode 100644 index 486b5c5c6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-pool.c +++ /dev/null @@ -1,599 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc.h" -#include "mongoc-apm-private.h" -#include "mongoc-counters-private.h" -#include "mongoc-client-pool-private.h" -#include "mongoc-client-pool.h" -#include "mongoc-client-private.h" -#include "mongoc-client-side-encryption-private.h" -#include "mongoc-queue-private.h" -#include "mongoc-thread-private.h" -#include "mongoc-topology-private.h" -#include "mongoc-topology-background-monitoring-private.h" -#include "mongoc-trace-private.h" - -#ifdef MONGOC_ENABLE_SSL -#include "mongoc-ssl-private.h" -#endif - -struct _mongoc_client_pool_t { - bson_mutex_t mutex; - mongoc_cond_t cond; - mongoc_queue_t queue; - mongoc_topology_t *topology; - mongoc_uri_t *uri; - uint32_t min_pool_size; - uint32_t max_pool_size; - uint32_t size; -#ifdef MONGOC_ENABLE_SSL - bool ssl_opts_set; - mongoc_ssl_opt_t ssl_opts; -#endif - bool apm_callbacks_set; - mongoc_apm_callbacks_t apm_callbacks; - void *apm_context; - int32_t error_api_version; - bool error_api_set; - mongoc_server_api_t *api; - bool client_initialized; -}; - - -#ifdef MONGOC_ENABLE_SSL -void -mongoc_client_pool_set_ssl_opts (mongoc_client_pool_t *pool, - const mongoc_ssl_opt_t *opts) -{ - BSON_ASSERT_PARAM (pool); - - bson_mutex_lock (&pool->mutex); - - _mongoc_ssl_opts_cleanup (&pool->ssl_opts, - false /* don't free internal opts. */); - - pool->ssl_opts_set = false; - - if (opts) { - _mongoc_ssl_opts_copy_to ( - opts, &pool->ssl_opts, false /* don't overwrite internal opts. */); - pool->ssl_opts_set = true; - } - - mongoc_topology_scanner_set_ssl_opts (pool->topology->scanner, - &pool->ssl_opts); - - bson_mutex_unlock (&pool->mutex); -} - -void -_mongoc_client_pool_set_internal_tls_opts ( - mongoc_client_pool_t *pool, _mongoc_internal_tls_opts_t *internal) -{ - BSON_ASSERT_PARAM (pool); - - bson_mutex_lock (&pool->mutex); - if (!pool->ssl_opts_set) { - bson_mutex_unlock (&pool->mutex); - return; - } - pool->ssl_opts.internal = bson_malloc (sizeof (_mongoc_internal_tls_opts_t)); - memcpy ( - pool->ssl_opts.internal, internal, sizeof (_mongoc_internal_tls_opts_t)); - bson_mutex_unlock (&pool->mutex); -} -#endif - - -mongoc_client_pool_t * -mongoc_client_pool_new (const mongoc_uri_t *uri) -{ - mongoc_client_pool_t *pool; - bson_error_t error = {0}; - - if (!(pool = mongoc_client_pool_new_with_error (uri, &error))) { - MONGOC_ERROR ("%s", error.message); - } - - return pool; -} - - -mongoc_client_pool_t * -mongoc_client_pool_new_with_error (const mongoc_uri_t *uri, bson_error_t *error) -{ - mongoc_topology_t *topology; - mongoc_client_pool_t *pool; - const bson_t *b; - bson_iter_t iter; - const char *appname; - - - ENTRY; - - BSON_ASSERT (uri); - -#ifndef MONGOC_ENABLE_SSL - if (mongoc_uri_get_tls (uri)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Can't create SSL client pool, SSL not enabled in this " - "build."); - return NULL; - } -#endif - - topology = mongoc_topology_new (uri, false); - - if (!topology->valid) { - if (error) { - memcpy (error, &topology->scanner->error, sizeof (bson_error_t)); - } - - mongoc_topology_destroy (topology); - - RETURN (NULL); - } - - pool = (mongoc_client_pool_t *) bson_malloc0 (sizeof *pool); - bson_mutex_init (&pool->mutex); - mongoc_cond_init (&pool->cond); - _mongoc_queue_init (&pool->queue); - pool->uri = mongoc_uri_copy (uri); - pool->min_pool_size = 0; - pool->max_pool_size = 100; - pool->size = 0; - pool->topology = topology; - pool->error_api_version = MONGOC_ERROR_API_VERSION_LEGACY; - - b = mongoc_uri_get_options (pool->uri); - - if (bson_iter_init_find_case (&iter, b, MONGOC_URI_MINPOOLSIZE)) { - MONGOC_WARNING ( - MONGOC_URI_MINPOOLSIZE - " is deprecated; its behavior does not match its name, and its actual" - " behavior will likely hurt performance."); - - if (BSON_ITER_HOLDS_INT32 (&iter)) { - pool->min_pool_size = BSON_MAX (0, bson_iter_int32 (&iter)); - } - } - - if (bson_iter_init_find_case (&iter, b, MONGOC_URI_MAXPOOLSIZE)) { - if (BSON_ITER_HOLDS_INT32 (&iter)) { - pool->max_pool_size = BSON_MAX (1, bson_iter_int32 (&iter)); - } - } - - appname = - mongoc_uri_get_option_as_utf8 (pool->uri, MONGOC_URI_APPNAME, NULL); - if (appname) { - /* the appname should have already been validated */ - BSON_ASSERT (mongoc_client_pool_set_appname (pool, appname)); - } - -#ifdef MONGOC_ENABLE_SSL - if (mongoc_uri_get_tls (pool->uri)) { - mongoc_ssl_opt_t ssl_opt = {0}; - _mongoc_internal_tls_opts_t internal_tls_opts = {0}; - - _mongoc_ssl_opts_from_uri (&ssl_opt, &internal_tls_opts, pool->uri); - /* sets use_ssl = true */ - mongoc_client_pool_set_ssl_opts (pool, &ssl_opt); - _mongoc_client_pool_set_internal_tls_opts (pool, &internal_tls_opts); - } -#endif - mongoc_counter_client_pools_active_inc (); - - RETURN (pool); -} - - -void -mongoc_client_pool_destroy (mongoc_client_pool_t *pool) -{ - mongoc_client_t *client; - - ENTRY; - - if (!pool) { - EXIT; - } - - if (!mongoc_server_session_pool_is_empty (pool->topology->session_pool)) { - client = mongoc_client_pool_pop (pool); - _mongoc_client_end_sessions (client); - mongoc_client_pool_push (pool, client); - } - - while ( - (client = (mongoc_client_t *) _mongoc_queue_pop_head (&pool->queue))) { - mongoc_client_destroy (client); - } - - mongoc_topology_destroy (pool->topology); - - mongoc_uri_destroy (pool->uri); - bson_mutex_destroy (&pool->mutex); - mongoc_cond_destroy (&pool->cond); - - mongoc_server_api_destroy (pool->api); - -#ifdef MONGOC_ENABLE_SSL - _mongoc_ssl_opts_cleanup (&pool->ssl_opts, true); -#endif - - bson_free (pool); - - mongoc_counter_client_pools_active_dec (); - mongoc_counter_client_pools_disposed_inc (); - - EXIT; -} - - -/* - * Start the background topology scanner. - * - * This function assumes the pool's mutex is locked - */ -static void -_start_scanner_if_needed (mongoc_client_pool_t *pool) -{ - BSON_ASSERT_PARAM (pool); - - if (!pool->topology->single_threaded) { - _mongoc_topology_background_monitoring_start (pool->topology); - } -} - -static void -_initialize_new_client (mongoc_client_pool_t *pool, mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (pool); - BSON_ASSERT_PARAM (client); - - /* for tests */ - mongoc_client_set_stream_initiator ( - client, - pool->topology->scanner->initiator, - pool->topology->scanner->initiator_context); - - pool->client_initialized = true; - client->is_pooled = true; - client->error_api_version = pool->error_api_version; - _mongoc_client_set_apm_callbacks_private ( - client, &pool->apm_callbacks, pool->apm_context); - - client->api = mongoc_server_api_copy (pool->api); - -#ifdef MONGOC_ENABLE_SSL - if (pool->ssl_opts_set) { - mongoc_client_set_ssl_opts (client, &pool->ssl_opts); - } -#endif -} - -mongoc_client_t * -mongoc_client_pool_pop (mongoc_client_pool_t *pool) -{ - mongoc_client_t *client; - int32_t wait_queue_timeout_ms; - int64_t expire_at_ms = -1; - int64_t now_ms; - int r; - - ENTRY; - - BSON_ASSERT_PARAM (pool); - - wait_queue_timeout_ms = mongoc_uri_get_option_as_int32 ( - pool->uri, MONGOC_URI_WAITQUEUETIMEOUTMS, -1); - if (wait_queue_timeout_ms > 0) { - expire_at_ms = - (bson_get_monotonic_time () / 1000) + wait_queue_timeout_ms; - } - bson_mutex_lock (&pool->mutex); - -again: - if (!(client = (mongoc_client_t *) _mongoc_queue_pop_head (&pool->queue))) { - if (pool->size < pool->max_pool_size) { - client = _mongoc_client_new_from_topology (pool->topology); - BSON_ASSERT (client); - _initialize_new_client (pool, client); - pool->size++; - } else { - if (wait_queue_timeout_ms > 0) { - now_ms = bson_get_monotonic_time () / 1000; - if (now_ms < expire_at_ms) { - r = mongoc_cond_timedwait ( - &pool->cond, &pool->mutex, expire_at_ms - now_ms); - if (mongo_cond_ret_is_timedout (r)) { - GOTO (done); - } - } else { - GOTO (done); - } - } else { - mongoc_cond_wait (&pool->cond, &pool->mutex); - } - GOTO (again); - } - } - - _start_scanner_if_needed (pool); -done: - bson_mutex_unlock (&pool->mutex); - - RETURN (client); -} - - -mongoc_client_t * -mongoc_client_pool_try_pop (mongoc_client_pool_t *pool) -{ - mongoc_client_t *client; - - ENTRY; - - BSON_ASSERT_PARAM (pool); - - bson_mutex_lock (&pool->mutex); - - if (!(client = (mongoc_client_t *) _mongoc_queue_pop_head (&pool->queue))) { - if (pool->size < pool->max_pool_size) { - client = _mongoc_client_new_from_topology (pool->topology); - BSON_ASSERT (client); - _initialize_new_client (pool, client); - pool->size++; - } - } - - if (client) { - _start_scanner_if_needed (pool); - } - bson_mutex_unlock (&pool->mutex); - - RETURN (client); -} - - -void -mongoc_client_pool_push (mongoc_client_pool_t *pool, mongoc_client_t *client) -{ - ENTRY; - - BSON_ASSERT_PARAM (pool); - BSON_ASSERT_PARAM (client); - - bson_mutex_lock (&pool->mutex); - _mongoc_queue_push_head (&pool->queue, client); - - if (pool->min_pool_size && - _mongoc_queue_get_length (&pool->queue) > pool->min_pool_size) { - mongoc_client_t *old_client; - old_client = (mongoc_client_t *) _mongoc_queue_pop_tail (&pool->queue); - if (old_client) { - mongoc_client_destroy (old_client); - pool->size--; - } - } - - mongoc_cond_signal (&pool->cond); - bson_mutex_unlock (&pool->mutex); - - EXIT; -} - -/* for tests */ -void -_mongoc_client_pool_set_stream_initiator (mongoc_client_pool_t *pool, - mongoc_stream_initiator_t si, - void *context) -{ - BSON_ASSERT_PARAM (pool); - - mongoc_topology_scanner_set_stream_initiator ( - pool->topology->scanner, si, context); -} - -/* for tests */ -size_t -mongoc_client_pool_get_size (mongoc_client_pool_t *pool) -{ - size_t size = 0; - - ENTRY; - BSON_ASSERT_PARAM (pool); - - bson_mutex_lock (&pool->mutex); - size = pool->size; - bson_mutex_unlock (&pool->mutex); - - RETURN (size); -} - - -size_t -mongoc_client_pool_num_pushed (mongoc_client_pool_t *pool) -{ - size_t num_pushed = 0; - - ENTRY; - BSON_ASSERT_PARAM (pool); - - bson_mutex_lock (&pool->mutex); - num_pushed = pool->queue.length; - bson_mutex_unlock (&pool->mutex); - - RETURN (num_pushed); -} - - -mongoc_topology_t * -_mongoc_client_pool_get_topology (mongoc_client_pool_t *pool) -{ - BSON_ASSERT_PARAM (pool); - - return pool->topology; -} - - -void -mongoc_client_pool_max_size (mongoc_client_pool_t *pool, uint32_t max_pool_size) -{ - ENTRY; - BSON_ASSERT_PARAM (pool); - - bson_mutex_lock (&pool->mutex); - pool->max_pool_size = max_pool_size; - bson_mutex_unlock (&pool->mutex); - - EXIT; -} - -void -mongoc_client_pool_min_size (mongoc_client_pool_t *pool, uint32_t min_pool_size) -{ - ENTRY; - BSON_ASSERT_PARAM (pool); - - MONGOC_WARNING ( - "mongoc_client_pool_min_size is deprecated; its behavior does not match" - " its name, and its actual behavior will likely hurt performance."); - - bson_mutex_lock (&pool->mutex); - pool->min_pool_size = min_pool_size; - bson_mutex_unlock (&pool->mutex); - - EXIT; -} - -bool -mongoc_client_pool_set_apm_callbacks (mongoc_client_pool_t *pool, - mongoc_apm_callbacks_t *callbacks, - void *context) -{ - BSON_ASSERT_PARAM (pool); - - mongoc_topology_t *const topology = BSON_ASSERT_PTR_INLINE (pool)->topology; - mc_tpld_modification tdmod; - - if (pool->apm_callbacks_set) { - MONGOC_ERROR ("Can only set callbacks once"); - return false; - } - - tdmod = mc_tpld_modify_begin (topology); - - if (callbacks) { - memcpy (&tdmod.new_td->apm_callbacks, - callbacks, - sizeof (mongoc_apm_callbacks_t)); - memcpy (&pool->apm_callbacks, callbacks, sizeof (mongoc_apm_callbacks_t)); - } - - mongoc_topology_set_apm_callbacks ( - topology, tdmod.new_td, callbacks, context); - tdmod.new_td->apm_context = context; - pool->apm_context = context; - pool->apm_callbacks_set = true; - - mc_tpld_modify_commit (tdmod); - - return true; -} - -bool -mongoc_client_pool_set_error_api (mongoc_client_pool_t *pool, int32_t version) -{ - if (version != MONGOC_ERROR_API_VERSION_LEGACY && - version != MONGOC_ERROR_API_VERSION_2) { - MONGOC_ERROR ("Unsupported Error API Version: %" PRId32, version); - return false; - } - - BSON_ASSERT_PARAM (pool); - - if (pool->error_api_set) { - MONGOC_ERROR ("Can only set Error API Version once"); - return false; - } - - pool->error_api_version = version; - pool->error_api_set = true; - - return true; -} - -bool -mongoc_client_pool_set_appname (mongoc_client_pool_t *pool, const char *appname) -{ - bool ret; - - BSON_ASSERT_PARAM (pool); - - bson_mutex_lock (&pool->mutex); - ret = _mongoc_topology_set_appname (pool->topology, appname); - bson_mutex_unlock (&pool->mutex); - - return ret; -} - -bool -mongoc_client_pool_enable_auto_encryption (mongoc_client_pool_t *pool, - mongoc_auto_encryption_opts_t *opts, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (pool); - - return _mongoc_cse_client_pool_enable_auto_encryption ( - pool->topology, opts, error); -} - -bool -mongoc_client_pool_set_server_api (mongoc_client_pool_t *pool, - const mongoc_server_api_t *api, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (pool); - BSON_ASSERT_PARAM (api); - - if (pool->api) { - bson_set_error (error, - MONGOC_ERROR_POOL, - MONGOC_ERROR_POOL_API_ALREADY_SET, - "Cannot set server api more than once per pool"); - return false; - } - - if (pool->client_initialized) { - bson_set_error (error, - MONGOC_ERROR_POOL, - MONGOC_ERROR_POOL_API_TOO_LATE, - "Cannot set server api after a client has been created"); - return false; - } - - pool->api = mongoc_server_api_copy (api); - - _mongoc_topology_scanner_set_server_api (pool->topology->scanner, api); - - return true; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-pool.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-pool.h deleted file mode 100644 index c4df560fe..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-pool.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_CLIENT_POOL_H -#define MONGOC_CLIENT_POOL_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-apm.h" -#include "mongoc-client.h" -#include "mongoc-config.h" -#ifdef MONGOC_ENABLE_SSL -#include "mongoc-ssl.h" -#endif -#include "mongoc-uri.h" - - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_client_pool_t mongoc_client_pool_t; - - -MONGOC_EXPORT (mongoc_client_pool_t *) -mongoc_client_pool_new (const mongoc_uri_t *uri) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_client_pool_t *) -mongoc_client_pool_new_with_error (const mongoc_uri_t *uri, bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_client_pool_destroy (mongoc_client_pool_t *pool); -MONGOC_EXPORT (mongoc_client_t *) -mongoc_client_pool_pop (mongoc_client_pool_t *pool) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_client_pool_push (mongoc_client_pool_t *pool, mongoc_client_t *client); -MONGOC_EXPORT (mongoc_client_t *) -mongoc_client_pool_try_pop (mongoc_client_pool_t *pool) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_client_pool_max_size (mongoc_client_pool_t *pool, - uint32_t max_pool_size); -MONGOC_EXPORT (void) -mongoc_client_pool_min_size (mongoc_client_pool_t *pool, - uint32_t min_pool_size) BSON_GNUC_DEPRECATED; -#ifdef MONGOC_ENABLE_SSL -MONGOC_EXPORT (void) -mongoc_client_pool_set_ssl_opts (mongoc_client_pool_t *pool, - const mongoc_ssl_opt_t *opts); -#endif -MONGOC_EXPORT (bool) -mongoc_client_pool_set_apm_callbacks (mongoc_client_pool_t *pool, - mongoc_apm_callbacks_t *callbacks, - void *context); -MONGOC_EXPORT (bool) -mongoc_client_pool_set_error_api (mongoc_client_pool_t *pool, int32_t version); -MONGOC_EXPORT (bool) -mongoc_client_pool_set_appname (mongoc_client_pool_t *pool, - const char *appname); -MONGOC_EXPORT (bool) -mongoc_client_pool_enable_auto_encryption (mongoc_client_pool_t *pool, - mongoc_auto_encryption_opts_t *opts, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_client_pool_set_server_api (mongoc_client_pool_t *pool, - const mongoc_server_api_t *api, - bson_error_t *error); - -BSON_END_DECLS - - -#endif /* MONGOC_CLIENT_POOL_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-session.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-session.c deleted file mode 100644 index 4293e59b6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-session.c +++ /dev/null @@ -1,1742 +0,0 @@ -/* - * Copyright 2017 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-client-session-private.h" -#include "mongoc-cluster-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-client-private.h" -#include "mongoc-rand-private.h" -#include "mongoc-util-private.h" -#include "mongoc-read-concern-private.h" -#include "mongoc-read-prefs-private.h" -#include "mongoc-error-private.h" - -#include - -#define WITH_TXN_TIMEOUT_MS (120 * 1000) - -static void -txn_opts_set (mongoc_transaction_opt_t *opts, - const mongoc_read_concern_t *read_concern, - const mongoc_write_concern_t *write_concern, - const mongoc_read_prefs_t *read_prefs, - int64_t max_commit_time_ms) -{ - if (read_concern) { - mongoc_transaction_opts_set_read_concern (opts, read_concern); - } - - if (write_concern) { - mongoc_transaction_opts_set_write_concern (opts, write_concern); - } - - if (read_prefs) { - mongoc_transaction_opts_set_read_prefs (opts, read_prefs); - } - - if (max_commit_time_ms != DEFAULT_MAX_COMMIT_TIME_MS) { - mongoc_transaction_opts_set_max_commit_time_ms (opts, max_commit_time_ms); - } -} - - -static void -txn_opts_cleanup (mongoc_transaction_opt_t *opts) -{ - /* null inputs are ok */ - mongoc_read_concern_destroy (opts->read_concern); - mongoc_write_concern_destroy (opts->write_concern); - mongoc_read_prefs_destroy (opts->read_prefs); - /* prepare opts for reuse */ - opts->read_concern = NULL; - opts->write_concern = NULL; - opts->read_prefs = NULL; - opts->max_commit_time_ms = DEFAULT_MAX_COMMIT_TIME_MS; -} - - -static void -txn_opts_copy (const mongoc_transaction_opt_t *src, - mongoc_transaction_opt_t *dst) -{ - txn_opts_cleanup (dst); - /* null inputs are ok for these copy functions */ - dst->read_concern = mongoc_read_concern_copy (src->read_concern); - dst->write_concern = mongoc_write_concern_copy (src->write_concern); - dst->read_prefs = mongoc_read_prefs_copy (src->read_prefs); - dst->max_commit_time_ms = src->max_commit_time_ms; -} - - -static bool -txn_abort (mongoc_client_session_t *session, bson_t *reply, bson_error_t *error) -{ - bson_t cmd = BSON_INITIALIZER; - bson_t opts = BSON_INITIALIZER; - bson_error_t err_local; - bson_error_t *err_ptr = error ? error : &err_local; - bson_t reply_local = BSON_INITIALIZER; - bool r = false; - - _mongoc_bson_init_if_set (reply); - - if (!mongoc_client_session_append (session, &opts, err_ptr)) { - GOTO (done); - } - - if (session->txn.opts.write_concern) { - if (!mongoc_write_concern_append (session->txn.opts.write_concern, - &opts)) { - bson_set_error (err_ptr, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Invalid transaction write concern"); - GOTO (done); - } - } - - BSON_APPEND_INT32 (&cmd, "abortTransaction", 1); - if (session->recovery_token) { - BSON_APPEND_DOCUMENT (&cmd, "recoveryToken", session->recovery_token); - } - - /* will be reinitialized by mongoc_client_write_command_with_opts */ - bson_destroy (&reply_local); - r = mongoc_client_write_command_with_opts ( - session->client, "admin", &cmd, &opts, &reply_local, err_ptr); - - /* Transactions Spec: "Drivers MUST retry the commitTransaction command once - * after it fails with a retryable error", same for abort. Note that a - * RetryableWriteError label has already been appended here. */ - if (mongoc_error_has_label (&reply_local, RETRYABLE_WRITE_ERROR)) { - _mongoc_client_session_unpin (session); - bson_destroy (&reply_local); - r = mongoc_client_write_command_with_opts ( - session->client, "admin", &cmd, &opts, &reply_local, err_ptr); - } - - if (!r) { - /* we won't return an error from abortTransaction, so warn */ - MONGOC_WARNING ("Error in abortTransaction: %s", err_ptr->message); - _mongoc_client_session_unpin (session); - } - -done: - bson_destroy (&reply_local); - bson_destroy (&cmd); - bson_destroy (&opts); - - return r; -} - - -static mongoc_write_concern_t * -create_commit_retry_wc (const mongoc_write_concern_t *existing_wc) -{ - mongoc_write_concern_t *wc; - - wc = existing_wc ? mongoc_write_concern_copy (existing_wc) - : mongoc_write_concern_new (); - - /* Transactions spec: "If the modified write concern does not include a - * wtimeout value, drivers MUST also apply wtimeout: 10000 to the write - * concern in order to avoid waiting forever if the majority write concern - * cannot be satisfied." */ - if (mongoc_write_concern_get_wtimeout_int64 (wc) <= 0) { - mongoc_write_concern_set_wtimeout_int64 ( - wc, MONGOC_DEFAULT_WTIMEOUT_FOR_COMMIT_RETRY); - } - - /* Transactions spec: "If the transaction is using a write concern that is - * not the server default, any other write concern options MUST be left as-is - * when applying w:majority. */ - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY); - - return wc; -} - - -static bool -txn_commit (mongoc_client_session_t *session, - bool explicitly_retrying, - bson_t *reply, - bson_error_t *error) -{ - bson_t cmd = BSON_INITIALIZER; - bson_t opts = BSON_INITIALIZER; - bson_error_t err_local = {0}; - bson_error_t *err_ptr = error ? error : &err_local; - bson_t reply_local = BSON_INITIALIZER; - mongoc_write_err_type_t error_type; - bool r = false; - bool retrying_after_error = false; - mongoc_write_concern_t *retry_wc = NULL; - - _mongoc_bson_init_if_set (reply); - - BSON_APPEND_INT32 (&cmd, "commitTransaction", 1); - if (session->recovery_token) { - BSON_APPEND_DOCUMENT (&cmd, "recoveryToken", session->recovery_token); - } - -retry: - if (!mongoc_client_session_append (session, &opts, err_ptr)) { - GOTO (done); - } - - if (session->txn.opts.max_commit_time_ms != DEFAULT_MAX_COMMIT_TIME_MS) { - if (!bson_append_int64 ( - &opts, "maxTimeMS", -1, session->txn.opts.max_commit_time_ms)) { - bson_set_error (err_ptr, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "error appending maxCommitTimeMS"); - GOTO (done); - } - } - - /* Transactions Spec: "When commitTransaction is retried, either by the - * driver's internal retry-once logic or explicitly by the user calling - * commitTransaction again, drivers MUST apply w:majority to the write - * concern of the commitTransaction command." */ - if (!retry_wc && (retrying_after_error || explicitly_retrying)) { - retry_wc = create_commit_retry_wc (session->txn.opts.write_concern - ? session->txn.opts.write_concern - : session->client->write_concern); - } - - if (retry_wc || session->txn.opts.write_concern) { - if (!mongoc_write_concern_append ( - retry_wc ? retry_wc : session->txn.opts.write_concern, &opts)) { - bson_set_error (err_ptr, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Invalid transaction write concern"); - GOTO (done); - } - } - - /* will be reinitialized by mongoc_client_write_command_with_opts */ - bson_destroy (&reply_local); - r = mongoc_client_write_command_with_opts ( - session->client, "admin", &cmd, &opts, &reply_local, err_ptr); - - /* Transactions Spec: "Drivers MUST retry the commitTransaction command once - * after it fails with a retryable error", same for abort. Note that a - * RetryableWriteError label has already been appended here. */ - error_type = _mongoc_write_error_get_type (&reply_local); - if (!retrying_after_error && error_type == MONGOC_WRITE_ERR_RETRY) { - retrying_after_error = true; /* retry after error only once */ - _mongoc_client_session_unpin (session); - bson_reinit (&opts); - GOTO (retry); - } - - /* Transactions Spec: "add the UnknownTransactionCommitResult error label - * when commitTransaction fails with a network error, server selection - * error, MaxTimeMSExpired error, or write concern failed / timeout." */ - if (!r && (err_ptr->domain == MONGOC_ERROR_SERVER_SELECTION || - error_type == MONGOC_WRITE_ERR_RETRY || - error_type == MONGOC_WRITE_ERR_WRITE_CONCERN || - err_ptr->code == MONGOC_ERROR_MAX_TIME_MS_EXPIRED)) { - /* Drivers MUST unpin a ClientSession when any individual - * commitTransaction command attempt fails with an - * UnknownTransactionCommitResult error label. Do this even if we won't - * actually apply the error label due to reply being NULL */ - _mongoc_client_session_unpin (session); - if (reply) { - bsonBuildAppend (*reply, - insert (reply_local, not(key ("errorLabels")))); - _mongoc_error_copy_labels_and_upsert ( - &reply_local, reply, UNKNOWN_COMMIT_RESULT); - } - } else if (reply) { - /* maintain invariants: reply & reply_local are valid until the end */ - bson_destroy (reply); - bson_steal (reply, &reply_local); - bson_init (&reply_local); - } - -done: - bson_destroy (&reply_local); - bson_destroy (&cmd); - bson_destroy (&opts); - - if (retry_wc) { - mongoc_write_concern_destroy (retry_wc); - } - - return r; -} - - -mongoc_transaction_opt_t * -mongoc_transaction_opts_new (void) -{ - mongoc_transaction_opt_t *opts; - opts = (mongoc_transaction_opt_t *) bson_malloc0 ( - sizeof (mongoc_transaction_opt_t)); - opts->max_commit_time_ms = DEFAULT_MAX_COMMIT_TIME_MS; - - return opts; -} - - -mongoc_transaction_opt_t * -mongoc_transaction_opts_clone (const mongoc_transaction_opt_t *opts) -{ - mongoc_transaction_opt_t *cloned_opts; - - ENTRY; - - BSON_ASSERT (opts); - - cloned_opts = mongoc_transaction_opts_new (); - txn_opts_copy (opts, cloned_opts); - - RETURN (cloned_opts); -} - - -void -mongoc_transaction_opts_destroy (mongoc_transaction_opt_t *opts) -{ - ENTRY; - - if (!opts) { - EXIT; - } - - txn_opts_cleanup (opts); - bson_free (opts); - - EXIT; -} - - -void -mongoc_transaction_opts_set_max_commit_time_ms (mongoc_transaction_opt_t *opts, - int64_t max_commit_time_ms) -{ - BSON_ASSERT (opts); - opts->max_commit_time_ms = max_commit_time_ms; -} - - -int64_t -mongoc_transaction_opts_get_max_commit_time_ms (mongoc_transaction_opt_t *opts) -{ - BSON_ASSERT (opts); - return opts->max_commit_time_ms; -} - - -void -mongoc_transaction_opts_set_read_concern ( - mongoc_transaction_opt_t *opts, const mongoc_read_concern_t *read_concern) -{ - BSON_ASSERT (opts); - mongoc_read_concern_destroy (opts->read_concern); - opts->read_concern = mongoc_read_concern_copy (read_concern); -} - - -const mongoc_read_concern_t * -mongoc_transaction_opts_get_read_concern (const mongoc_transaction_opt_t *opts) -{ - BSON_ASSERT (opts); - return opts->read_concern; -} - - -void -mongoc_transaction_opts_set_write_concern ( - mongoc_transaction_opt_t *opts, const mongoc_write_concern_t *write_concern) -{ - BSON_ASSERT (opts); - mongoc_write_concern_destroy (opts->write_concern); - opts->write_concern = mongoc_write_concern_copy (write_concern); -} - - -const mongoc_write_concern_t * -mongoc_transaction_opts_get_write_concern (const mongoc_transaction_opt_t *opts) -{ - BSON_ASSERT (opts); - return opts->write_concern; -} - - -void -mongoc_transaction_opts_set_read_prefs (mongoc_transaction_opt_t *opts, - const mongoc_read_prefs_t *read_prefs) -{ - BSON_ASSERT (opts); - mongoc_read_prefs_destroy (opts->read_prefs); - opts->read_prefs = mongoc_read_prefs_copy (read_prefs); -} - - -const mongoc_read_prefs_t * -mongoc_transaction_opts_get_read_prefs (const mongoc_transaction_opt_t *opts) -{ - BSON_ASSERT (opts); - return opts->read_prefs; -} - -bool -mongoc_session_opts_get_causal_consistency (const mongoc_session_opt_t *opts) -{ - ENTRY; - - BSON_ASSERT (opts); - - /* Causal Consistency spec: If no value is provided for causalConsistency - * and snapshot reads are not requested a value of true is implied. */ - if (!mongoc_optional_is_set (&opts->causal_consistency) && - !mongoc_optional_value (&opts->snapshot)) { - RETURN (true); - } - - RETURN (mongoc_optional_value (&opts->causal_consistency)); -} - -bool -mongoc_session_opts_get_snapshot (const mongoc_session_opt_t *opts) -{ - ENTRY; - - BSON_ASSERT (opts); - - RETURN (mongoc_optional_value (&opts->snapshot)); -} - -void -mongoc_session_opts_set_causal_consistency (mongoc_session_opt_t *opts, - bool causal_consistency) -{ - ENTRY; - - BSON_ASSERT (opts); - - mongoc_optional_set_value (&opts->causal_consistency, causal_consistency); - - EXIT; -} - -void -mongoc_session_opts_set_snapshot (mongoc_session_opt_t *opts, bool snapshot) -{ - ENTRY; - - BSON_ASSERT (opts); - - mongoc_optional_set_value (&opts->snapshot, snapshot); - - EXIT; -} - -mongoc_session_opt_t * -mongoc_session_opts_new (void) -{ - mongoc_session_opt_t *opts = bson_malloc0 (sizeof (mongoc_session_opt_t)); - - mongoc_optional_init (&opts->causal_consistency); - mongoc_optional_init (&opts->snapshot); - - return opts; -} - -void -mongoc_session_opts_set_default_transaction_opts ( - mongoc_session_opt_t *opts, const mongoc_transaction_opt_t *txn_opts) -{ - ENTRY; - - BSON_ASSERT (opts); - BSON_ASSERT (txn_opts); - - txn_opts_set (&opts->default_txn_opts, - txn_opts->read_concern, - txn_opts->write_concern, - txn_opts->read_prefs, - txn_opts->max_commit_time_ms); - - EXIT; -} - - -const mongoc_transaction_opt_t * -mongoc_session_opts_get_default_transaction_opts ( - const mongoc_session_opt_t *opts) -{ - ENTRY; - - BSON_ASSERT (opts); - - RETURN (&opts->default_txn_opts); -} - - -mongoc_transaction_opt_t * -mongoc_session_opts_get_transaction_opts ( - const mongoc_client_session_t *session) -{ - ENTRY; - - BSON_ASSERT (session); - - if (mongoc_client_session_in_transaction (session)) { - RETURN (mongoc_transaction_opts_clone (&session->txn.opts)); - } - - RETURN (NULL); -} - -static void -_mongoc_session_opts_copy (const mongoc_session_opt_t *src, - mongoc_session_opt_t *dst) -{ - mongoc_optional_copy (&src->causal_consistency, &dst->causal_consistency); - mongoc_optional_copy (&src->snapshot, &dst->snapshot); - txn_opts_copy (&src->default_txn_opts, &dst->default_txn_opts); -} - - -mongoc_session_opt_t * -mongoc_session_opts_clone (const mongoc_session_opt_t *opts) -{ - mongoc_session_opt_t *cloned_opts; - - ENTRY; - - BSON_ASSERT (opts); - - cloned_opts = bson_malloc0 (sizeof (mongoc_session_opt_t)); - _mongoc_session_opts_copy (opts, cloned_opts); - - RETURN (cloned_opts); -} - - -void -mongoc_session_opts_destroy (mongoc_session_opt_t *opts) -{ - ENTRY; - - if (!opts) { - EXIT; - } - - txn_opts_cleanup (&opts->default_txn_opts); - bson_free (opts); - - EXIT; -} - - -static bool -_mongoc_server_session_uuid (uint8_t *data /* OUT */, bson_error_t *error) -{ -#ifdef MONGOC_ENABLE_CRYPTO - /* https://tools.ietf.org/html/rfc4122#page-14 - * o Set the two most significant bits (bits 6 and 7) of the - * clock_seq_hi_and_reserved to zero and one, respectively. - * - * o Set the four most significant bits (bits 12 through 15) of the - * time_hi_and_version field to the 4-bit version number from - * Section 4.1.3. - * - * o Set all the other bits to randomly (or pseudo-randomly) chosen - * values. - */ - - if (!_mongoc_rand_bytes (data, 16)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_SESSION_FAILURE, - "Could not generate UUID for logical session id"); - - return false; - } - - data[6] = (uint8_t) (0x40 | (data[6] & 0xf)); - data[8] = (uint8_t) (0x80 | (data[8] & 0x3f)); - - return true; -#else - /* no _mongoc_rand_bytes without a crypto library */ - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_SESSION_FAILURE, - "Could not generate UUID for logical session id, we need a" - " cryptography library like libcrypto, Common Crypto, or" - " CNG"); - - return false; -#endif -} - - -bool -_mongoc_parse_cluster_time (const bson_t *cluster_time, - uint32_t *timestamp, - uint32_t *increment) -{ - bson_iter_t iter; - char *s; - - if (!cluster_time || - !bson_iter_init_find (&iter, cluster_time, "clusterTime") || - !BSON_ITER_HOLDS_TIMESTAMP (&iter)) { - s = bson_as_json (cluster_time, NULL); - MONGOC_ERROR ("Cannot parse cluster time from %s\n", s); - bson_free (s); - return false; - } - - bson_iter_timestamp (&iter, timestamp, increment); - - return true; -} - - -bool -_mongoc_cluster_time_greater (const bson_t *new, const bson_t *old) -{ - uint32_t new_t, new_i, old_t, old_i; - - if (!_mongoc_parse_cluster_time (new, &new_t, &new_i) || - !_mongoc_parse_cluster_time (old, &old_t, &old_i)) { - return false; - } - - return (new_t > old_t) || (new_t == old_t && new_i > old_i); -} - - -void -_mongoc_client_session_handle_reply (mongoc_client_session_t *session, - bool is_acknowledged, - const char *cmd_name, - const bson_t *reply) -{ - bson_iter_t iter; - bson_iter_t cursor_iter; - uint32_t len; - const uint8_t *data; - bson_t cluster_time; - uint32_t operation_t; - uint32_t operation_i; - uint32_t snapshot_t; - uint32_t snapshot_i; - bool is_find_aggregate_distinct; - - BSON_ASSERT (session); - - if (!reply || !bson_iter_init (&iter, reply)) { - return; - } - - is_find_aggregate_distinct = - (!strcmp (cmd_name, "find") || !strcmp (cmd_name, "aggregate") || - !strcmp (cmd_name, "distinct")); - - if (mongoc_error_has_label (reply, "TransientTransactionError")) { - /* Transaction Spec: "Drivers MUST unpin a ClientSession when a command - * within a transaction, including commitTransaction and abortTransaction, - * fails with a TransientTransactionError". If the server reply included - * a TransientTransactionError, we unpin here. If a network error caused - * us to add a label client-side, we unpin in network_error_reply. */ - _mongoc_client_session_unpin (session); - } - - while (bson_iter_next (&iter)) { - if (!strcmp (bson_iter_key (&iter), "$clusterTime") && - BSON_ITER_HOLDS_DOCUMENT (&iter)) { - bson_iter_document (&iter, &len, &data); - BSON_ASSERT (bson_init_static (&cluster_time, data, (size_t) len)); - - mongoc_client_session_advance_cluster_time (session, &cluster_time); - } else if (!strcmp (bson_iter_key (&iter), "operationTime") && - BSON_ITER_HOLDS_TIMESTAMP (&iter) && is_acknowledged) { - bson_iter_timestamp (&iter, &operation_t, &operation_i); - mongoc_client_session_advance_operation_time ( - session, operation_t, operation_i); - } else if (is_find_aggregate_distinct && - !strcmp (bson_iter_key (&iter), "atClusterTime") && - mongoc_session_opts_get_snapshot (&session->opts) && - !session->snapshot_time_set) { - /* If command is "find", "aggregate" or "distinct", atClusterTime is on - * top level of reply, snapshot is enabled for the session, and - * snapshot_time has not already been set, set it. */ - bson_iter_timestamp (&iter, &snapshot_t, &snapshot_i); - _mongoc_client_session_set_snapshot_time ( - session, snapshot_t, snapshot_i); - } else if (is_find_aggregate_distinct && - !strcmp (bson_iter_key (&iter), "cursor") && - mongoc_session_opts_get_snapshot (&session->opts) && - !session->snapshot_time_set) { - /* If command is "find", "aggregate" or "distinct", cursor is present, - * snapshot is enabled for the session, and snapshot_time has not - * already been set, try to find atClusterTime in cursor field to set - * snapshot_time. */ - bson_iter_recurse (&iter, &cursor_iter); - - while (bson_iter_next (&cursor_iter)) { - /* If atClusterTime is in cursor and is a valid timestamp, use it to - * set snapshot_time. */ - if (!strcmp (bson_iter_key (&cursor_iter), "atClusterTime") && - BSON_ITER_HOLDS_TIMESTAMP (&cursor_iter)) { - bson_iter_timestamp (&cursor_iter, &snapshot_t, &snapshot_i); - _mongoc_client_session_set_snapshot_time ( - session, snapshot_t, snapshot_i); - } - } - } - } -} - -bool -_mongoc_server_session_init (mongoc_server_session_t *self, bson_error_t *error) -{ - uint8_t uuid_data[16]; - ENTRY; - BSON_ASSERT (self); - if (!_mongoc_server_session_uuid (uuid_data, error)) { - RETURN (false); - } - /* transaction number is a positive integer and will be incremented before - * each use, so ensure it is initialized to zero. */ - self->txn_number = 0; - self->last_used_usec = SESSION_NEVER_USED; - bson_init (&self->lsid); - BSON_APPEND_BINARY ( - &self->lsid, "id", BSON_SUBTYPE_UUID, uuid_data, sizeof uuid_data); - - RETURN (true); -} - -bool -_mongoc_server_session_timed_out (const mongoc_server_session_t *server_session, - int64_t session_timeout_minutes) -{ - int64_t timeout_usec; - const int64_t minute_to_usec = 60 * 1000 * 1000; - - ENTRY; - - if (session_timeout_minutes == MONGOC_NO_SESSIONS) { - /* not connected right now; keep the session */ - return false; - } - - if (server_session->last_used_usec == SESSION_NEVER_USED) { - return false; - } - - /* Driver Sessions Spec: if a session has less than one minute left before - * becoming stale, discard it */ - timeout_usec = - server_session->last_used_usec + session_timeout_minutes * minute_to_usec; - - RETURN (timeout_usec - bson_get_monotonic_time () < 1 * minute_to_usec); -} - - -void -_mongoc_server_session_destroy (mongoc_server_session_t *self) -{ - bson_destroy (&self->lsid); -} - - -mongoc_client_session_t * -_mongoc_client_session_new (mongoc_client_t *client, - mongoc_server_session_t *server_session, - const mongoc_session_opt_t *opts, - uint32_t client_session_id) -{ - mongoc_client_session_t *session; - - ENTRY; - - BSON_ASSERT (client); - BSON_ASSERT (server_session); - - session = BSON_ALIGNED_ALLOC0 (mongoc_client_session_t); - session->client = client; - session->client_generation = client->generation; - session->server_session = server_session; - session->client_session_id = client_session_id; - bson_init (&session->cluster_time); - - mongoc_optional_init (&session->opts.causal_consistency); - mongoc_optional_init (&session->opts.snapshot); - txn_opts_set (&session->opts.default_txn_opts, - client->read_concern, - client->write_concern, - client->read_prefs, - DEFAULT_MAX_COMMIT_TIME_MS); - - if (opts) { - mongoc_optional_copy (&opts->causal_consistency, - &session->opts.causal_consistency); - mongoc_optional_copy (&opts->snapshot, &session->opts.snapshot); - txn_opts_set (&session->opts.default_txn_opts, - opts->default_txn_opts.read_concern, - opts->default_txn_opts.write_concern, - opts->default_txn_opts.read_prefs, - opts->default_txn_opts.max_commit_time_ms); - } - - /* snapshot_time_set is false by default */ - _mongoc_client_session_clear_snapshot_time (session); - - /* these values are used for testing only. */ - session->with_txn_timeout_ms = 0; - session->fail_commit_label = NULL; - - RETURN (session); -} - - -mongoc_client_t * -mongoc_client_session_get_client (const mongoc_client_session_t *session) -{ - BSON_ASSERT (session); - - return session->client; -} - - -const mongoc_session_opt_t * -mongoc_client_session_get_opts (const mongoc_client_session_t *session) -{ - BSON_ASSERT (session); - - return &session->opts; -} - - -const bson_t * -mongoc_client_session_get_lsid (const mongoc_client_session_t *session) -{ - BSON_ASSERT (session); - - return &session->server_session->lsid; -} - -const bson_t * -mongoc_client_session_get_cluster_time (const mongoc_client_session_t *session) -{ - BSON_ASSERT (session); - - if (bson_empty (&session->cluster_time)) { - return NULL; - } - - return &session->cluster_time; -} - -uint32_t -mongoc_client_session_get_server_id (const mongoc_client_session_t *session) -{ - BSON_ASSERT (session); - - return session->server_id; -} - -void -mongoc_client_session_advance_cluster_time (mongoc_client_session_t *session, - const bson_t *cluster_time) -{ - uint32_t t, i; - - ENTRY; - - if (bson_empty (&session->cluster_time) && - _mongoc_parse_cluster_time (cluster_time, &t, &i)) { - bson_destroy (&session->cluster_time); - bson_copy_to (cluster_time, &session->cluster_time); - EXIT; - } - - if (_mongoc_cluster_time_greater (cluster_time, &session->cluster_time)) { - bson_destroy (&session->cluster_time); - bson_copy_to (cluster_time, &session->cluster_time); - } - - EXIT; -} - -void -mongoc_client_session_get_operation_time ( - const mongoc_client_session_t *session, - uint32_t *timestamp, - uint32_t *increment) -{ - BSON_ASSERT (session); - BSON_ASSERT (timestamp); - BSON_ASSERT (increment); - - *timestamp = session->operation_timestamp; - *increment = session->operation_increment; -} - -void -mongoc_client_session_advance_operation_time (mongoc_client_session_t *session, - uint32_t timestamp, - uint32_t increment) -{ - ENTRY; - - BSON_ASSERT (session); - - if (timestamp > session->operation_timestamp || - (timestamp == session->operation_timestamp && - increment > session->operation_increment)) { - session->operation_timestamp = timestamp; - session->operation_increment = increment; - } - - EXIT; -} - -static bool -timeout_exceeded (int64_t expire_at) -{ - int64_t current_time = bson_get_monotonic_time (); - return current_time >= expire_at; -} - -static bool -_max_time_ms_failure (bson_t *reply) -{ - bson_iter_t iter; - bson_iter_t descendant; - - if (!reply) { - return false; - } - - /* We can fail with a maxTimeMS error with the error code at the top - level, or nested within a writeConcernError. */ - if (bson_iter_init_find (&iter, reply, "codeName") && - BSON_ITER_HOLDS_UTF8 (&iter) && - 0 == strcmp (bson_iter_utf8 (&iter, NULL), MAX_TIME_MS_EXPIRED)) { - return true; - } - - bson_iter_init (&iter, reply); - if (bson_iter_find_descendant ( - &iter, "writeConcernError.codeName", &descendant) && - BSON_ITER_HOLDS_UTF8 (&descendant) && - 0 == strcmp (bson_iter_utf8 (&descendant, NULL), MAX_TIME_MS_EXPIRED)) { - return true; - } - - return false; -} - -bool -mongoc_client_session_with_transaction ( - mongoc_client_session_t *session, - mongoc_client_session_with_transaction_cb_t cb, - const mongoc_transaction_opt_t *opts, - void *ctx, - bson_t *reply, - bson_error_t *error) -{ - mongoc_internal_transaction_state_t state; - int64_t timeout; - int64_t expire_at; - bson_t local_reply; - bson_t *active_reply = NULL; - bool res; - - ENTRY; - - timeout = session->with_txn_timeout_ms > 0 ? session->with_txn_timeout_ms - : WITH_TXN_TIMEOUT_MS; - - expire_at = bson_get_monotonic_time () + ((int64_t) timeout * 1000); - - /* Attempt to wrap a user callback in start- and end- transaction semantics. - If this fails for transient reasons, restart, either from the very - beginning, or just retry committing the transaction. Will retry until - the timeout WITH_TXN_TIMEOUT_MS is exhausted. - - At the top of this loop, active_reply should always be NULL, and - local_reply should always be uninitialized. */ - while (true) { - res = mongoc_client_session_start_transaction (session, opts, error); - - if (!res) { - GOTO (done); - } - - res = cb (session, ctx, &active_reply, error); - state = session->txn.state; - - /* If the user cb set a reply, use it. Otherwise, sub in local_reply - since we must have an active reply object one way or another. */ - if (!active_reply) { - bson_init (&local_reply); - active_reply = &local_reply; - } - - if (!res) { - if (state == MONGOC_INTERNAL_TRANSACTION_STARTING || - state == MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS) { - BSON_ASSERT ( - mongoc_client_session_abort_transaction (session, NULL)); - } - - if (mongoc_error_has_label (active_reply, TRANSIENT_TXN_ERR) && - !timeout_exceeded (expire_at)) { - bson_destroy (active_reply); - active_reply = NULL; - continue; - } - - /* Unknown error running callback, fail. */ - GOTO (done); - } - - if (state == MONGOC_INTERNAL_TRANSACTION_ABORTED || - state == MONGOC_INTERNAL_TRANSACTION_NONE || - state == MONGOC_INTERNAL_TRANSACTION_COMMITTED || - state == MONGOC_INTERNAL_TRANSACTION_COMMITTED_EMPTY) { - GOTO (done); - } - - /* Whether or not we used local_reply above, use it now, but access it - * through active_reply so cleanup in DONE is simpler. */ - bson_destroy (active_reply); - active_reply = &local_reply; - - /* Commit the transaction, retrying either from here or from the outer - loop on error. - - At the top of this loop, active_reply should always be pointing to - an uninitialized stack-allocated bson_t, so we can pass it into - commit_transaction, which requires this like our other public - functions that take a bson_t reply. */ - while (true) { - res = mongoc_client_session_commit_transaction ( - session, active_reply, error); - - if (!res) { - /* If we have a MaxTimeMsExpired error, fail and propogate - the error to the caller. */ - if (_max_time_ms_failure (active_reply)) { - GOTO (done); - } - - if (mongoc_error_has_label (active_reply, UNKNOWN_COMMIT_RESULT) && - !timeout_exceeded (expire_at)) { - /* Commit_transaction applies majority write concern on retry - * attempts. - * - * Here, we don't want to set active_reply = NULL when we - * destroy, because we want it to point to an uninitialized - * bson_t at the top of this loop every time.*/ - bson_destroy (active_reply); - continue; - } - - if (mongoc_error_has_label (active_reply, TRANSIENT_TXN_ERR) && - !timeout_exceeded (expire_at)) { - /* In the case of a transient txn error, go back to outside loop. - We must set the reply to NULL so it may be used by the cb. */ - bson_destroy (active_reply); - active_reply = NULL; - break; - } - - /* Unknown error committing transaction, fail. */ - GOTO (done); - } - - /* Transaction successfully committed! */ - GOTO (done); - } - } - -done: - /* At this point, active_reply is either pointing to the user's reply - object, or our local one on the stack, or is NULL. */ - if (reply && active_reply) { - bson_copy_to (active_reply, reply); - } else if (reply) { - bson_init (reply); - } - - bson_destroy (active_reply); - - RETURN (res); -} - -bool -mongoc_client_session_start_transaction (mongoc_client_session_t *session, - const mongoc_transaction_opt_t *opts, - bson_error_t *error) -{ - mongoc_server_stream_t *server_stream = NULL; - bool ret; - - ENTRY; - BSON_ASSERT (session); - - ret = true; - server_stream = - mongoc_cluster_stream_for_writes (&session->client->cluster, - session, - NULL /* deprioritized servers */, - NULL /* reply */, - error); - if (!server_stream) { - ret = false; - GOTO (done); - } - - if (mongoc_session_opts_get_snapshot (&session->opts)) { - bson_set_error (error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Transactions are not supported in snapshot sessions"); - ret = false; - GOTO (done); - } - - if (server_stream->sd->max_wire_version < 7 || - (server_stream->sd->max_wire_version < 8 && - server_stream->sd->type == MONGOC_SERVER_MONGOS)) { - bson_set_error (error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Multi-document transactions are not supported by this " - "server version"); - ret = false; - GOTO (done); - } - - /* use "switch" so that static checkers ensure we handle all states */ - switch (session->txn.state) { - case MONGOC_INTERNAL_TRANSACTION_STARTING: - case MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS: - bson_set_error (error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Transaction already in progress"); - ret = false; - GOTO (done); - case MONGOC_INTERNAL_TRANSACTION_ENDING: - MONGOC_ERROR ( - "starting txn in invalid state MONGOC_INTERNAL_TRANSACTION_ENDING"); - abort (); - case MONGOC_INTERNAL_TRANSACTION_COMMITTED: - case MONGOC_INTERNAL_TRANSACTION_COMMITTED_EMPTY: - case MONGOC_INTERNAL_TRANSACTION_ABORTED: - case MONGOC_INTERNAL_TRANSACTION_NONE: - default: - break; - } - - session->server_session->txn_number++; - - txn_opts_set (&session->txn.opts, - session->opts.default_txn_opts.read_concern, - session->opts.default_txn_opts.write_concern, - session->opts.default_txn_opts.read_prefs, - session->opts.default_txn_opts.max_commit_time_ms); - - if (opts) { - txn_opts_set (&session->txn.opts, - opts->read_concern, - opts->write_concern, - opts->read_prefs, - opts->max_commit_time_ms); - } - - if (!mongoc_write_concern_is_acknowledged ( - session->txn.opts.write_concern)) { - bson_set_error ( - error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Transactions do not support unacknowledged write concern"); - ret = false; - GOTO (done); - } - - /* Transactions Spec: Starting a new transaction on a pinned ClientSession - * MUST unpin the session. */ - _mongoc_client_session_unpin (session); - session->txn.state = MONGOC_INTERNAL_TRANSACTION_STARTING; - /* Transactions spec: "Drivers MUST clear a session's cached - * 'recoveryToken' when transitioning to the 'no transaction' or - * 'starting transaction' state." */ - bson_destroy (session->recovery_token); - session->recovery_token = NULL; - -done: - mongoc_server_stream_cleanup (server_stream); - return ret; -} - - -bool -mongoc_client_session_in_transaction (const mongoc_client_session_t *session) -{ - ENTRY; - - BSON_ASSERT (session); - - /* call the internal function, which would allow a NULL session */ - RETURN (_mongoc_client_session_in_txn (session)); -} - - -mongoc_transaction_state_t -mongoc_client_session_get_transaction_state ( - const mongoc_client_session_t *session) -{ - ENTRY; - - BSON_ASSERT (session); - - switch (session->txn.state) { - case MONGOC_INTERNAL_TRANSACTION_NONE: - RETURN (MONGOC_TRANSACTION_NONE); - case MONGOC_INTERNAL_TRANSACTION_STARTING: - RETURN (MONGOC_TRANSACTION_STARTING); - case MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS: - RETURN (MONGOC_TRANSACTION_IN_PROGRESS); - case MONGOC_INTERNAL_TRANSACTION_COMMITTED_EMPTY: - case MONGOC_INTERNAL_TRANSACTION_COMMITTED: - RETURN (MONGOC_TRANSACTION_COMMITTED); - case MONGOC_INTERNAL_TRANSACTION_ABORTED: - RETURN (MONGOC_TRANSACTION_ABORTED); - case MONGOC_INTERNAL_TRANSACTION_ENDING: - MONGOC_ERROR ("invalid state MONGOC_INTERNAL_TRANSACTION_ENDING when " - "getting transaction state"); - abort (); - default: - MONGOC_ERROR ("invalid state %d when getting transaction state", - (int) session->txn.state); - abort (); - break; - } -} - -bool -mongoc_client_session_commit_transaction (mongoc_client_session_t *session, - bson_t *reply, - bson_error_t *error) -{ - bool r = false; - - ENTRY; - - BSON_ASSERT (session); - - /* For testing only, mock out certain kinds of errors. */ - if (session->fail_commit_label) { - bson_array_builder_t *labels; - - BSON_ASSERT (reply); - - bson_init (reply); - BSON_APPEND_ARRAY_BUILDER_BEGIN (reply, "errorLabels", &labels); - bson_array_builder_append_utf8 (labels, session->fail_commit_label, -1); - bson_append_array_builder_end (reply, labels); - - /* Waste the test timeout, if there is one set. */ - if (session->with_txn_timeout_ms) { - _mongoc_usleep (session->with_txn_timeout_ms * 1000); - } - - RETURN (r); - } - - /* See Transactions Spec for state diagram. In COMMITTED state, user can call - * commit again to retry after network error */ - - switch (session->txn.state) { - case MONGOC_INTERNAL_TRANSACTION_NONE: - bson_set_error (error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "No transaction started"); - _mongoc_bson_init_if_set (reply); - break; - case MONGOC_INTERNAL_TRANSACTION_STARTING: - case MONGOC_INTERNAL_TRANSACTION_COMMITTED_EMPTY: - /* we sent no commands, not actually started on server */ - session->txn.state = MONGOC_INTERNAL_TRANSACTION_COMMITTED_EMPTY; - _mongoc_bson_init_if_set (reply); - r = true; - break; - case MONGOC_INTERNAL_TRANSACTION_COMMITTED: - case MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS: { - bool explicitly_retrying = - (session->txn.state == MONGOC_INTERNAL_TRANSACTION_COMMITTED); - /* in MONGOC_INTERNAL_TRANSACTION_ENDING we add txnNumber and autocommit: - * false to the commitTransaction command, but if it fails with network - * error we add UnknownTransactionCommitResult not - * TransientTransactionError */ - session->txn.state = MONGOC_INTERNAL_TRANSACTION_ENDING; - r = txn_commit (session, explicitly_retrying, reply, error); - session->txn.state = MONGOC_INTERNAL_TRANSACTION_COMMITTED; - break; - } - case MONGOC_INTERNAL_TRANSACTION_ENDING: - MONGOC_ERROR ( - "commit called in invalid state MONGOC_INTERNAL_TRANSACTION_ENDING"); - abort (); - case MONGOC_INTERNAL_TRANSACTION_ABORTED: - default: - bson_set_error ( - error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Cannot call commitTransaction after calling abortTransaction"); - _mongoc_bson_init_if_set (reply); - break; - } - - RETURN (r); -} - - -bool -mongoc_client_session_abort_transaction (mongoc_client_session_t *session, - bson_error_t *error) -{ - ENTRY; - - BSON_ASSERT (session); - - switch (session->txn.state) { - case MONGOC_INTERNAL_TRANSACTION_STARTING: - /* we sent no commands, not actually started on server */ - session->txn.state = MONGOC_INTERNAL_TRANSACTION_ABORTED; - /* Transactions Spec: aborting a transaction MUST unpin the session. - * It's likely the transaction is already unpinned if TRANSACTION_STARTING - * was just assigned, but there is no harm in doing so again. */ - _mongoc_client_session_unpin (session); - txn_opts_cleanup (&session->txn.opts); - RETURN (true); - case MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS: - session->txn.state = MONGOC_INTERNAL_TRANSACTION_ENDING; - /* Transactions Spec: ignore errors from abortTransaction command */ - txn_abort (session, NULL, NULL); - session->txn.state = MONGOC_INTERNAL_TRANSACTION_ABORTED; - /* Transactions Spec: aborting a transaction MUST unpin the session. */ - _mongoc_client_session_unpin (session); - RETURN (true); - case MONGOC_INTERNAL_TRANSACTION_COMMITTED: - case MONGOC_INTERNAL_TRANSACTION_COMMITTED_EMPTY: - bson_set_error ( - error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Cannot call abortTransaction after calling commitTransaction"); - RETURN (false); - case MONGOC_INTERNAL_TRANSACTION_ABORTED: - bson_set_error (error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Cannot call abortTransaction twice"); - RETURN (false); - case MONGOC_INTERNAL_TRANSACTION_ENDING: - MONGOC_ERROR ( - "abort called in invalid state MONGOC_INTERNAL_TRANSACTION_ENDING"); - abort (); - case MONGOC_INTERNAL_TRANSACTION_NONE: - default: - bson_set_error (error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "No transaction started"); - RETURN (false); - } -} - - -bool -_mongoc_client_session_from_iter (mongoc_client_t *client, - const bson_iter_t *iter, - mongoc_client_session_t **cs, - bson_error_t *error) -{ - ENTRY; - BSON_ASSERT_PARAM (client); - - /* must be int64 that fits in uint32 */ - if (!BSON_ITER_HOLDS_INT64 (iter) || bson_iter_int64 (iter) > 0xffffffff) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid sessionId"); - RETURN (false); - } - - RETURN (_mongoc_client_lookup_session ( - client, (uint32_t) bson_iter_int64 (iter), cs, error)); -} - -/* Returns true if in the middle of a transaction. Note: this returns false if - * the commit/abort is running. */ -bool -_mongoc_client_session_in_txn (const mongoc_client_session_t *session) -{ - if (!session) { - return false; - } - - /* use "switch" so that static checkers ensure we handle all states */ - switch (session->txn.state) { - case MONGOC_INTERNAL_TRANSACTION_STARTING: - case MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS: - return true; - case MONGOC_INTERNAL_TRANSACTION_NONE: - case MONGOC_INTERNAL_TRANSACTION_ENDING: - case MONGOC_INTERNAL_TRANSACTION_COMMITTED: - case MONGOC_INTERNAL_TRANSACTION_COMMITTED_EMPTY: - case MONGOC_INTERNAL_TRANSACTION_ABORTED: - default: - return false; - } -} - -/* Like _mongoc_client_session_in_txn, but also returns true if running the - * commit/abort for this transaction. */ -bool -_mongoc_client_session_in_txn_or_ending (const mongoc_client_session_t *session) -{ - if (!session) { - return false; - } - - /* use "switch" so that static checkers ensure we handle all states */ - switch (session->txn.state) { - case MONGOC_INTERNAL_TRANSACTION_STARTING: - case MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS: - case MONGOC_INTERNAL_TRANSACTION_ENDING: - return true; - case MONGOC_INTERNAL_TRANSACTION_NONE: - case MONGOC_INTERNAL_TRANSACTION_COMMITTED: - case MONGOC_INTERNAL_TRANSACTION_COMMITTED_EMPTY: - case MONGOC_INTERNAL_TRANSACTION_ABORTED: - default: - return false; - } -} - - -bool -_mongoc_client_session_txn_in_progress (const mongoc_client_session_t *session) -{ - if (!session) { - return false; - } - - return session->txn.state == MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_client_session_append_txn -- - * - * Add transaction fields besides "readConcern" to @cmd. - * - * Returns: - * Returns false and sets @error if @cmd is empty, otherwise returns - * true. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -_mongoc_client_session_append_txn (mongoc_client_session_t *session, - bson_t *cmd, - bson_error_t *error) -{ - mongoc_transaction_t *txn; - - ENTRY; - - if (!session) { - RETURN (true); - } - - if (bson_empty0 (cmd)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Empty command in transaction"); - RETURN (false); - } - - txn = &session->txn; - - /* See Transactions Spec for state transitions. In COMMITTED / ABORTED, the - * next operation resets the session and moves to TRANSACTION_NONE */ - switch (session->txn.state) { - case MONGOC_INTERNAL_TRANSACTION_STARTING: - txn->state = MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS; - bson_append_bool (cmd, "startTransaction", 16, true); - /* FALL THROUGH */ - case MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS: - case MONGOC_INTERNAL_TRANSACTION_ENDING: - bson_append_int64 ( - cmd, "txnNumber", 9, session->server_session->txn_number); - bson_append_bool (cmd, "autocommit", 10, false); - RETURN (true); - case MONGOC_INTERNAL_TRANSACTION_COMMITTED: - if (!strcmp (_mongoc_get_command_name (cmd), "commitTransaction")) { - /* send commitTransaction again */ - bson_append_int64 ( - cmd, "txnNumber", 9, session->server_session->txn_number); - bson_append_bool (cmd, "autocommit", 10, false); - RETURN (true); - } - /* FALL THROUGH */ - case MONGOC_INTERNAL_TRANSACTION_COMMITTED_EMPTY: - case MONGOC_INTERNAL_TRANSACTION_ABORTED: - txn_opts_cleanup (&session->txn.opts); - txn->state = MONGOC_INTERNAL_TRANSACTION_NONE; - - /* Transactions spec: "Drivers MUST clear a session's cached - * 'recoveryToken' when transitioning to the 'no transaction' or - * 'starting transaction' state." */ - bson_destroy (session->recovery_token); - session->recovery_token = NULL; - RETURN (true); - case MONGOC_INTERNAL_TRANSACTION_NONE: - default: - RETURN (true); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_client_session_append_read_concern -- - * - * Add read concern if we're doing a read outside a transaction, or if - * we're starting a transaction, or if the user explicitly passed a read - * concern in some function's "opts". The contents of the read concern - * are "level" and/or "afterClusterTime" - if both are empty, don't add - * read concern. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -_mongoc_client_session_append_read_concern (const mongoc_client_session_t *cs, - const bson_t *rc, - bool is_read_command, - bson_t *cmd) -{ - const mongoc_read_concern_t *txn_rc; - mongoc_internal_transaction_state_t txn_state; - bool user_rc_has_level; - bool txn_has_level; - bool has_timestamp; - bool is_snapshot; - bool has_level; - bson_t child; - - ENTRY; - - BSON_ASSERT (cs); - - txn_state = cs->txn.state; - txn_rc = cs->txn.opts.read_concern; - - if (txn_state == MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS) { - return; - } - - has_timestamp = - (txn_state == MONGOC_INTERNAL_TRANSACTION_STARTING || is_read_command) && - mongoc_session_opts_get_causal_consistency (&cs->opts) && - cs->operation_timestamp; - is_snapshot = mongoc_session_opts_get_snapshot (&cs->opts); - user_rc_has_level = rc && bson_has_field (rc, "level"); - txn_has_level = txn_state == MONGOC_INTERNAL_TRANSACTION_STARTING && - !mongoc_read_concern_is_default (txn_rc); - has_level = user_rc_has_level || txn_has_level; - - /* do not append read concern if no causal consistency, snapshot disabled and - * no read concern is provided. */ - if (!has_timestamp && !is_snapshot && !has_level) { - return; - } - - bson_append_document_begin (cmd, "readConcern", 11, &child); - if (rc) { - bson_concat (&child, rc); - } - - if (txn_state == MONGOC_INTERNAL_TRANSACTION_STARTING) { - /* add transaction's read concern level unless user overrides or snapshot - * is enabled. */ - if (txn_has_level && !user_rc_has_level && !is_snapshot) { - bson_append_utf8 (&child, "level", 5, txn_rc->level, -1); - } - } - if (is_snapshot) { - bson_append_utf8 ( - &child, "level", 5, MONGOC_READ_CONCERN_LEVEL_SNAPSHOT, -1); - } - - /* append afterClusterTime if causal consistency and operation_time is set. - * otherwise append atClusterTime if snapshot enabled and snapshot_time is - * set. */ - if (has_timestamp) { - bson_append_timestamp (&child, - "afterClusterTime", - 16, - cs->operation_timestamp, - cs->operation_increment); - } else if (is_snapshot && cs->snapshot_time_set) { - bson_append_timestamp (&child, - "atClusterTime", - 13, - cs->snapshot_time_timestamp, - cs->snapshot_time_increment); - } - - bson_append_document_end (cmd, &child); -} - - -bool -mongoc_client_session_append (const mongoc_client_session_t *client_session, - bson_t *opts, - bson_error_t *error) -{ - ENTRY; - - BSON_ASSERT (client_session); - BSON_ASSERT (opts); - - if (!bson_append_int64 ( - opts, "sessionId", 9, client_session->client_session_id)) { - bson_set_error ( - error, MONGOC_ERROR_BSON, MONGOC_ERROR_BSON_INVALID, "invalid opts"); - - RETURN (false); - } - - RETURN (true); -} - - -void -mongoc_client_session_destroy (mongoc_client_session_t *session) -{ - ENTRY; - - if (!session) { - EXIT; - } - - if (session->client_generation == session->client->generation) { - if (mongoc_client_session_in_transaction (session)) { - mongoc_client_session_abort_transaction (session, NULL); - } - - _mongoc_client_unregister_session (session->client, session); - _mongoc_client_push_server_session (session->client, - session->server_session); - } else { - /** If the client has been reset, destroy the server session instead of - * pushing it back into the topology's pool. */ - mongoc_server_session_pool_drop (session->client->topology->session_pool, - session->server_session); - } - - txn_opts_cleanup (&session->opts.default_txn_opts); - txn_opts_cleanup (&session->txn.opts); - - bson_destroy (&session->cluster_time); - bson_destroy (session->recovery_token); - bson_free (session); - - EXIT; -} - -void -_mongoc_client_session_unpin (mongoc_client_session_t *session) -{ - BSON_ASSERT (session); - - session->server_id = 0; -} - -void -_mongoc_client_session_pin (mongoc_client_session_t *session, - uint32_t server_id) -{ - BSON_ASSERT (session); - - session->server_id = server_id; -} - -void -_mongoc_client_session_set_snapshot_time (mongoc_client_session_t *session, - uint32_t t, - uint32_t i) -{ - BSON_ASSERT (session); - BSON_ASSERT (!session->snapshot_time_set); - - session->snapshot_time_set = true; - session->snapshot_time_timestamp = t; - session->snapshot_time_increment = i; -} - -void -_mongoc_client_session_clear_snapshot_time (mongoc_client_session_t *session) -{ - BSON_ASSERT (session); - - session->snapshot_time_set = false; -} - -bool -mongoc_client_session_get_dirty (mongoc_client_session_t *session) -{ - BSON_ASSERT_PARAM (session); - - return session->server_session->dirty; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-session.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-session.h deleted file mode 100644 index b27426172..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-session.h +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2017 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_CLIENT_SESSION_H -#define MONGOC_CLIENT_SESSION_H - -#include -#include "mongoc-macros.h" -/* mongoc_client_session_t, mongoc_transaction_opt_t, and - mongoc_session_opt_t are typedef'ed here */ -#include "mongoc-client.h" - -BSON_BEGIN_DECLS - -typedef bool (*mongoc_client_session_with_transaction_cb_t) ( - mongoc_client_session_t *session, - void *ctx, - bson_t **reply, - bson_error_t *error); - -typedef enum { - MONGOC_TRANSACTION_NONE = 0, - MONGOC_TRANSACTION_STARTING = 1, - MONGOC_TRANSACTION_IN_PROGRESS = 2, - MONGOC_TRANSACTION_COMMITTED = 3, - MONGOC_TRANSACTION_ABORTED = 4, -} mongoc_transaction_state_t; - -/* these options types are named "opt_t" but their functions are named with - * "opts", for consistency with the older mongoc_ssl_opt_t */ -MONGOC_EXPORT (mongoc_transaction_opt_t *) -mongoc_transaction_opts_new (void) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (mongoc_transaction_opt_t *) -mongoc_transaction_opts_clone (const mongoc_transaction_opt_t *opts) - BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (void) -mongoc_transaction_opts_destroy (mongoc_transaction_opt_t *opts); - -MONGOC_EXPORT (void) -mongoc_transaction_opts_set_max_commit_time_ms (mongoc_transaction_opt_t *opts, - int64_t max_commit_time_ms); - -MONGOC_EXPORT (int64_t) -mongoc_transaction_opts_get_max_commit_time_ms (mongoc_transaction_opt_t *opts); - -MONGOC_EXPORT (void) -mongoc_transaction_opts_set_read_concern ( - mongoc_transaction_opt_t *opts, const mongoc_read_concern_t *read_concern); - -MONGOC_EXPORT (const mongoc_read_concern_t *) -mongoc_transaction_opts_get_read_concern (const mongoc_transaction_opt_t *opts); - -MONGOC_EXPORT (void) -mongoc_transaction_opts_set_write_concern ( - mongoc_transaction_opt_t *opts, const mongoc_write_concern_t *write_concern); - -MONGOC_EXPORT (const mongoc_write_concern_t *) -mongoc_transaction_opts_get_write_concern ( - const mongoc_transaction_opt_t *opts); - -MONGOC_EXPORT (void) -mongoc_transaction_opts_set_read_prefs (mongoc_transaction_opt_t *opts, - const mongoc_read_prefs_t *read_prefs); - -MONGOC_EXPORT (const mongoc_read_prefs_t *) -mongoc_transaction_opts_get_read_prefs (const mongoc_transaction_opt_t *opts); - -MONGOC_EXPORT (mongoc_session_opt_t *) -mongoc_session_opts_new (void) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (void) -mongoc_session_opts_set_causal_consistency (mongoc_session_opt_t *opts, - bool causal_consistency); - -MONGOC_EXPORT (bool) -mongoc_session_opts_get_causal_consistency (const mongoc_session_opt_t *opts); - -MONGOC_EXPORT (void) -mongoc_session_opts_set_snapshot (mongoc_session_opt_t *opts, bool snapshot); - -MONGOC_EXPORT (bool) -mongoc_session_opts_get_snapshot (const mongoc_session_opt_t *opts); - -MONGOC_EXPORT (void) -mongoc_session_opts_set_default_transaction_opts ( - mongoc_session_opt_t *opts, const mongoc_transaction_opt_t *txn_opts); - -MONGOC_EXPORT (const mongoc_transaction_opt_t *) -mongoc_session_opts_get_default_transaction_opts ( - const mongoc_session_opt_t *opts); - -MONGOC_EXPORT (mongoc_transaction_opt_t *) -mongoc_session_opts_get_transaction_opts ( - const mongoc_client_session_t *session) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (mongoc_session_opt_t *) -mongoc_session_opts_clone (const mongoc_session_opt_t *opts) - BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (void) -mongoc_session_opts_destroy (mongoc_session_opt_t *opts); - -MONGOC_EXPORT (mongoc_client_t *) -mongoc_client_session_get_client (const mongoc_client_session_t *session); - -MONGOC_EXPORT (const mongoc_session_opt_t *) -mongoc_client_session_get_opts (const mongoc_client_session_t *session); - -MONGOC_EXPORT (const bson_t *) -mongoc_client_session_get_lsid (const mongoc_client_session_t *session); - -MONGOC_EXPORT (const bson_t *) -mongoc_client_session_get_cluster_time (const mongoc_client_session_t *session); - -MONGOC_EXPORT (void) -mongoc_client_session_advance_cluster_time (mongoc_client_session_t *session, - const bson_t *cluster_time); - -MONGOC_EXPORT (void) -mongoc_client_session_get_operation_time ( - const mongoc_client_session_t *session, - uint32_t *timestamp, - uint32_t *increment); - -MONGOC_EXPORT (uint32_t) -mongoc_client_session_get_server_id (const mongoc_client_session_t *session); - -MONGOC_EXPORT (void) -mongoc_client_session_advance_operation_time (mongoc_client_session_t *session, - uint32_t timestamp, - uint32_t increment); - -MONGOC_EXPORT (bool) -mongoc_client_session_with_transaction ( - mongoc_client_session_t *session, - mongoc_client_session_with_transaction_cb_t cb, - const mongoc_transaction_opt_t *opts, - void *ctx, - bson_t *reply, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_session_start_transaction (mongoc_client_session_t *session, - const mongoc_transaction_opt_t *opts, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_session_in_transaction (const mongoc_client_session_t *session); - -MONGOC_EXPORT (mongoc_transaction_state_t) -mongoc_client_session_get_transaction_state ( - const mongoc_client_session_t *session); - -MONGOC_EXPORT (bool) -mongoc_client_session_commit_transaction (mongoc_client_session_t *session, - bson_t *reply, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_session_abort_transaction (mongoc_client_session_t *session, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_session_append (const mongoc_client_session_t *client_session, - bson_t *opts, - bson_error_t *error); - -/* There is no mongoc_client_session_end, only mongoc_client_session_destroy. - * Driver Sessions Spec: "In languages that have idiomatic ways of disposing of - * resources, drivers SHOULD support that in addition to or instead of - * endSession." - */ - -MONGOC_EXPORT (void) -mongoc_client_session_destroy (mongoc_client_session_t *session); - -MONGOC_EXPORT (bool) -mongoc_client_session_get_dirty (mongoc_client_session_t *session); - -BSON_END_DECLS - - -#endif /* MONGOC_CLIENT_SESSION_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-side-encryption-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-side-encryption-private.h deleted file mode 100644 index e9533bb6f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-side-encryption-private.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2019-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_CLIENT_SIDE_ENCRYPTION_PRIVATE_H -#define MONGOC_CLIENT_SIDE_ENCRYPTION_PRIVATE_H - -#include "mongoc-client.h" -#include "mongoc-client-pool.h" -#include "mongoc-client-side-encryption.h" -#include "mongoc-cmd-private.h" -#include "mongoc-topology-private.h" -#include "bson/bson.h" - -/* cse is an abbreviation for "Client Side Encryption" */ - -bool -_mongoc_cse_auto_encrypt (mongoc_client_t *client, - const mongoc_cmd_t *cmd, - mongoc_cmd_t *encrypted_cmd, - bson_t *encrypted, - bson_error_t *error); - -bool -_mongoc_cse_auto_decrypt (mongoc_client_t *client, - const char *db_name, - const bson_t *reply, - bson_t *decrypted, - bson_error_t *error); - -bool -_mongoc_cse_client_enable_auto_encryption ( - mongoc_client_t *client, - mongoc_auto_encryption_opts_t *opts /* may be NULL */, - bson_error_t *error); - -bool -_mongoc_cse_client_pool_enable_auto_encryption ( - mongoc_topology_t *topology, - mongoc_auto_encryption_opts_t *opts /* may be NULL */, - bson_error_t *error); - -/* If this returns true, client side encryption is enabled - * on the client (or it's parent client pool), and cannot - * be disabled. This check is done while holding the - * topology lock. So if this returns true, callers are - * guaranteed that CSE remains enabled afterwards. */ -bool -_mongoc_cse_is_enabled (mongoc_client_t *client); - -/** - * @brief The context for the automatic creation of a datakey - */ -struct auto_datakey_context { - /// The output destination for the new key ID. Never NULL. - bson_value_t *out_keyid; - /// An error output destination for the key generation. May be NULL. - bson_error_t *out_error; - /// The userdata pointer given to @ref - /// _mongoc_encryptedFields_fill_auto_datakeys - void *userdata; -}; - -/** - * @brief The type of a datakey-creating callback. - * - * @param ctx The context of the keyId request. @sa auto_datakey_context - * @retval true Upon success - * @retval false Otherwise. - * - * @note Errors should be written into `ctx->out_error`. - */ -typedef bool (*auto_datakey_factory) (struct auto_datakey_context *ctx); - -/** - * @brief Process an array of encryptedFields.fields, automatically filling null - * keyId elements by calling the given factory function. - * - * @param[out] out_fields The modified encryptedFields.fields. Must be destroyed - * by the caller. - * @param[in] in_fields The input encryptedFields.fields - * @param factory A keyId factory. @see auto_datakey_factory - * @param userdata The userdata pointer for `factory` - * @param[out] error An error output parameter - * @retval true On success - * @retval false Otherwise - */ -bool -_mongoc_encryptedFields_fill_auto_datakeys (bson_t *out_fields, - const bson_t *in_fields, - auto_datakey_factory factory, - void *userdata, - bson_error_t *error); - -#endif /* MONGOC_CLIENT_SIDE_ENCRYPTION_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-side-encryption.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-side-encryption.c deleted file mode 100644 index 2e344f35f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-side-encryption.c +++ /dev/null @@ -1,3230 +0,0 @@ -/* - * Copyright 2019-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _WIN32 -#include -#include -#endif - -#include - -#include "mongoc.h" -#include "mongoc-client-private.h" -#include "mongoc-client-side-encryption-private.h" -#include "mongoc-host-list-private.h" -#include "mongoc-stream-private.h" -#include "mongoc-topology-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-database-private.h" -#include "mongoc-util-private.h" - -/*-------------------------------------------------------------------------- - * Auto Encryption options. - *-------------------------------------------------------------------------- - */ -struct _mongoc_auto_encryption_opts_t { - /* keyvault_client and keyvault_client_pool are not owned and must outlive - * auto encrypted client/pool. */ - mongoc_client_t *keyvault_client; - mongoc_client_pool_t *keyvault_client_pool; - char *keyvault_db; - char *keyvault_coll; - bson_t *kms_providers; - bson_t *tls_opts; - bson_t *schema_map; - bson_t *encrypted_fields_map; - bool bypass_auto_encryption; - bool bypass_query_analysis; - mc_kms_credentials_callback creds_cb; - bson_t *extra; -}; - -static void -_set_creds_callback (mc_kms_credentials_callback *cb, - mongoc_kms_credentials_provider_callback_fn fn, - void *userdata) -{ - BSON_ASSERT (cb); - cb->fn = fn; - cb->userdata = userdata; -} - -mongoc_auto_encryption_opts_t * -mongoc_auto_encryption_opts_new (void) -{ - return bson_malloc0 (sizeof (mongoc_auto_encryption_opts_t)); -} - -void -mongoc_auto_encryption_opts_destroy (mongoc_auto_encryption_opts_t *opts) -{ - if (!opts) { - return; - } - bson_destroy (opts->extra); - bson_destroy (opts->kms_providers); - bson_destroy (opts->schema_map); - bson_destroy (opts->encrypted_fields_map); - bson_free (opts->keyvault_db); - bson_free (opts->keyvault_coll); - bson_destroy (opts->tls_opts); - bson_free (opts); -} - -void -mongoc_auto_encryption_opts_set_keyvault_client ( - mongoc_auto_encryption_opts_t *opts, mongoc_client_t *client) -{ - if (!opts) { - return; - } - /* Does not own. */ - opts->keyvault_client = client; -} - -void -mongoc_auto_encryption_opts_set_keyvault_client_pool ( - mongoc_auto_encryption_opts_t *opts, mongoc_client_pool_t *pool) -{ - if (!opts) { - return; - } - /* Does not own. */ - opts->keyvault_client_pool = pool; -} - -void -mongoc_auto_encryption_opts_set_keyvault_namespace ( - mongoc_auto_encryption_opts_t *opts, const char *db, const char *coll) -{ - if (!opts) { - return; - } - bson_free (opts->keyvault_db); - opts->keyvault_db = NULL; - opts->keyvault_db = bson_strdup (db); - bson_free (opts->keyvault_coll); - opts->keyvault_coll = NULL; - opts->keyvault_coll = bson_strdup (coll); -} - -void -mongoc_auto_encryption_opts_set_kms_providers ( - mongoc_auto_encryption_opts_t *opts, const bson_t *providers) -{ - if (!opts) { - return; - } - - bson_destroy (opts->kms_providers); - opts->kms_providers = NULL; - if (providers) { - opts->kms_providers = bson_copy (providers); - } -} - -/* _bson_copy_or_null returns a copy of @bson or NULL if @bson is NULL */ -static bson_t * -_bson_copy_or_null (const bson_t *bson) -{ - if (bson) { - return bson_copy (bson); - } - return NULL; -} - -void -mongoc_auto_encryption_opts_set_tls_opts (mongoc_auto_encryption_opts_t *opts, - const bson_t *tls_opts) -{ - if (!opts) { - return; - } - bson_destroy (opts->tls_opts); - opts->tls_opts = _bson_copy_or_null (tls_opts); -} - -void -mongoc_auto_encryption_opts_set_schema_map (mongoc_auto_encryption_opts_t *opts, - const bson_t *schema_map) -{ - if (!opts) { - return; - } - - bson_destroy (opts->schema_map); - opts->schema_map = NULL; - if (schema_map) { - opts->schema_map = bson_copy (schema_map); - } -} - -void -mongoc_auto_encryption_opts_set_encrypted_fields_map ( - mongoc_auto_encryption_opts_t *opts, const bson_t *encrypted_fields_map) -{ - if (!opts) { - return; - } - bson_destroy (opts->encrypted_fields_map); - opts->encrypted_fields_map = NULL; - if (encrypted_fields_map) { - opts->encrypted_fields_map = bson_copy (encrypted_fields_map); - } -} - -void -mongoc_auto_encryption_opts_set_bypass_auto_encryption ( - mongoc_auto_encryption_opts_t *opts, bool bypass_auto_encryption) -{ - if (!opts) { - return; - } - opts->bypass_auto_encryption = bypass_auto_encryption; -} - -void -mongoc_auto_encryption_opts_set_bypass_query_analysis ( - mongoc_auto_encryption_opts_t *opts, bool bypass_query_analysis) -{ - if (!opts) { - return; - } - opts->bypass_query_analysis = bypass_query_analysis; -} - -void -mongoc_auto_encryption_opts_set_extra (mongoc_auto_encryption_opts_t *opts, - const bson_t *extra) -{ - if (!opts) { - return; - } - bson_destroy (opts->extra); - opts->extra = NULL; - if (extra) { - opts->extra = bson_copy (extra); - } -} - -void -mongoc_auto_encryption_opts_set_kms_credential_provider_callback ( - mongoc_auto_encryption_opts_t *opts, - mongoc_kms_credentials_provider_callback_fn fn, - void *userdata) -{ - _set_creds_callback (&opts->creds_cb, fn, userdata); -} - -/*-------------------------------------------------------------------------- - * Client Encryption options. - *-------------------------------------------------------------------------- - */ -struct _mongoc_client_encryption_opts_t { - mongoc_client_t *keyvault_client; - char *keyvault_db; - char *keyvault_coll; - bson_t *kms_providers; - bson_t *tls_opts; - mc_kms_credentials_callback creds_cb; -}; - -mongoc_client_encryption_opts_t * -mongoc_client_encryption_opts_new (void) -{ - return bson_malloc0 (sizeof (mongoc_client_encryption_opts_t)); -} - -void -mongoc_client_encryption_opts_destroy (mongoc_client_encryption_opts_t *opts) -{ - if (!opts) { - return; - } - _set_creds_callback (&opts->creds_cb, NULL, NULL); - bson_free (opts->keyvault_db); - bson_free (opts->keyvault_coll); - bson_destroy (opts->kms_providers); - bson_destroy (opts->tls_opts); - bson_free (opts); -} - -void -mongoc_client_encryption_opts_set_keyvault_client ( - mongoc_client_encryption_opts_t *opts, mongoc_client_t *keyvault_client) -{ - if (!opts) { - return; - } - opts->keyvault_client = keyvault_client; -} - -void -mongoc_client_encryption_opts_set_keyvault_namespace ( - mongoc_client_encryption_opts_t *opts, const char *db, const char *coll) -{ - if (!opts) { - return; - } - bson_free (opts->keyvault_db); - opts->keyvault_db = NULL; - opts->keyvault_db = bson_strdup (db); - bson_free (opts->keyvault_coll); - opts->keyvault_coll = NULL; - opts->keyvault_coll = bson_strdup (coll); -} - -void -mongoc_client_encryption_opts_set_kms_providers ( - mongoc_client_encryption_opts_t *opts, const bson_t *kms_providers) -{ - if (!opts) { - return; - } - bson_destroy (opts->kms_providers); - opts->kms_providers = NULL; - if (kms_providers) { - opts->kms_providers = bson_copy (kms_providers); - } -} - -void -mongoc_client_encryption_opts_set_tls_opts ( - mongoc_client_encryption_opts_t *opts, const bson_t *tls_opts) -{ - if (!opts) { - return; - } - bson_destroy (opts->tls_opts); - opts->tls_opts = _bson_copy_or_null (tls_opts); -} - -void -mongoc_client_encryption_opts_set_kms_credential_provider_callback ( - mongoc_client_encryption_opts_t *opts, - mongoc_kms_credentials_provider_callback_fn fn, - void *userdata) -{ - BSON_ASSERT_PARAM (opts); - opts->creds_cb.fn = fn; - opts->creds_cb.userdata = userdata; -} - -/*-------------------------------------------------------------------------- - * Data key options. - *-------------------------------------------------------------------------- - */ -struct _mongoc_client_encryption_datakey_opts_t { - bson_t *masterkey; - char **keyaltnames; - uint32_t keyaltnames_count; - uint8_t *keymaterial; - uint32_t keymaterial_len; -}; - -mongoc_client_encryption_datakey_opts_t * -mongoc_client_encryption_datakey_opts_new (void) -{ - return bson_malloc0 (sizeof (mongoc_client_encryption_datakey_opts_t)); -} - -static void -_clear_datakey_keyaltnames (mongoc_client_encryption_datakey_opts_t *opts) -{ - if (opts->keyaltnames) { - for (uint32_t i = 0u; i < opts->keyaltnames_count; i++) { - bson_free (opts->keyaltnames[i]); - } - bson_free (opts->keyaltnames); - opts->keyaltnames = NULL; - opts->keyaltnames_count = 0; - } -} - -void -mongoc_client_encryption_datakey_opts_destroy ( - mongoc_client_encryption_datakey_opts_t *opts) -{ - if (!opts) { - return; - } - - bson_destroy (opts->masterkey); - _clear_datakey_keyaltnames (opts); - bson_free (opts->keymaterial); - - bson_free (opts); -} - -void -mongoc_client_encryption_datakey_opts_set_masterkey ( - mongoc_client_encryption_datakey_opts_t *opts, const bson_t *masterkey) -{ - if (!opts) { - return; - } - bson_destroy (opts->masterkey); - opts->masterkey = NULL; - if (masterkey) { - opts->masterkey = bson_copy (masterkey); - } -} - -void -mongoc_client_encryption_datakey_opts_set_keyaltnames ( - mongoc_client_encryption_datakey_opts_t *opts, - char **keyaltnames, - uint32_t keyaltnames_count) -{ - if (!opts) { - return; - } - - /* Free all first (if any have been set before). */ - _clear_datakey_keyaltnames (opts); - BSON_ASSERT (!opts->keyaltnames); - - if (keyaltnames_count) { - opts->keyaltnames = bson_malloc (sizeof (char *) * keyaltnames_count); - for (uint32_t i = 0u; i < keyaltnames_count; i++) { - opts->keyaltnames[i] = bson_strdup (keyaltnames[i]); - } - opts->keyaltnames_count = keyaltnames_count; - } -} - -void -mongoc_client_encryption_datakey_opts_set_keymaterial ( - mongoc_client_encryption_datakey_opts_t *opts, - const uint8_t *data, - uint32_t len) -{ - if (!opts) { - return; - } - - if (opts->keymaterial) { - bson_free (opts->keymaterial); - } - - opts->keymaterial = bson_malloc (len); - memcpy (opts->keymaterial, data, len); - opts->keymaterial_len = len; -} - -/*-------------------------------------------------------------------------- - * Explicit Encryption options. - *-------------------------------------------------------------------------- - */ -struct _mongoc_client_encryption_encrypt_range_opts_t { - struct { - bson_value_t value; - bool set; - } min; - struct { - bson_value_t value; - bool set; - } max; - int64_t sparsity; - struct { - int32_t value; - bool set; - } precision; -}; - -struct _mongoc_client_encryption_encrypt_opts_t { - bson_value_t keyid; - char *algorithm; - char *keyaltname; - struct { - int64_t value; - bool set; - } contention_factor; - char *query_type; - mongoc_client_encryption_encrypt_range_opts_t *range_opts; -}; - -mongoc_client_encryption_encrypt_opts_t * -mongoc_client_encryption_encrypt_opts_new (void) -{ - return bson_malloc0 (sizeof (mongoc_client_encryption_encrypt_opts_t)); -} - -void -mongoc_client_encryption_encrypt_range_opts_destroy ( - mongoc_client_encryption_encrypt_range_opts_t *range_opts) -{ - if (!range_opts) { - return; - } - - if (range_opts->min.set) { - bson_value_destroy (&range_opts->min.value); - } - if (range_opts->max.set) { - bson_value_destroy (&range_opts->max.value); - } - bson_free (range_opts); -} - -void -mongoc_client_encryption_encrypt_opts_destroy ( - mongoc_client_encryption_encrypt_opts_t *opts) -{ - if (!opts) { - return; - } - mongoc_client_encryption_encrypt_range_opts_destroy (opts->range_opts); - bson_value_destroy (&opts->keyid); - bson_free (opts->algorithm); - bson_free (opts->keyaltname); - bson_free (opts->query_type); - bson_free (opts); -} - -void -mongoc_client_encryption_encrypt_opts_set_keyid ( - mongoc_client_encryption_encrypt_opts_t *opts, const bson_value_t *keyid) -{ - if (!opts) { - return; - } - bson_value_destroy (&opts->keyid); - memset (&opts->keyid, 0, sizeof (opts->keyid)); - if (keyid) { - bson_value_copy (keyid, &opts->keyid); - } -} - -void -mongoc_client_encryption_encrypt_opts_set_keyaltname ( - mongoc_client_encryption_encrypt_opts_t *opts, const char *keyaltname) -{ - if (!opts) { - return; - } - bson_free (opts->keyaltname); - opts->keyaltname = NULL; - opts->keyaltname = bson_strdup (keyaltname); -} - -void -mongoc_client_encryption_encrypt_opts_set_algorithm ( - mongoc_client_encryption_encrypt_opts_t *opts, const char *algorithm) -{ - if (!opts) { - return; - } - bson_free (opts->algorithm); - opts->algorithm = NULL; - opts->algorithm = bson_strdup (algorithm); -} - -void -mongoc_client_encryption_encrypt_opts_set_contention_factor ( - mongoc_client_encryption_encrypt_opts_t *opts, int64_t contention_factor) -{ - if (!opts) { - return; - } - opts->contention_factor.value = contention_factor; - opts->contention_factor.set = true; -} - -void -mongoc_client_encryption_encrypt_opts_set_query_type ( - mongoc_client_encryption_encrypt_opts_t *opts, const char *query_type) -{ - if (!opts) { - return; - } - bson_free (opts->query_type); - opts->query_type = query_type ? bson_strdup (query_type) : NULL; -} - -/*-------------------------------------------------------------------------- - * Explicit Encryption Range Options - *-------------------------------------------------------------------------- - */ -mongoc_client_encryption_encrypt_range_opts_t * -mongoc_client_encryption_encrypt_range_opts_new (void) -{ - return bson_malloc0 (sizeof (mongoc_client_encryption_encrypt_range_opts_t)); -} - -void -mongoc_client_encryption_encrypt_range_opts_set_sparsity ( - mongoc_client_encryption_encrypt_range_opts_t *range_opts, int64_t sparsity) -{ - BSON_ASSERT_PARAM (range_opts); - range_opts->sparsity = sparsity; -} - -void -mongoc_client_encryption_encrypt_range_opts_set_min ( - mongoc_client_encryption_encrypt_range_opts_t *range_opts, - const bson_value_t *min) -{ - BSON_ASSERT_PARAM (range_opts); - BSON_ASSERT_PARAM (min); - - if (range_opts->min.set) { - bson_value_destroy (&range_opts->min.value); - } - range_opts->min.set = true; - bson_value_copy (min, &range_opts->min.value); -} - -void -mongoc_client_encryption_encrypt_range_opts_set_max ( - mongoc_client_encryption_encrypt_range_opts_t *range_opts, - const bson_value_t *max) -{ - BSON_ASSERT_PARAM (range_opts); - BSON_ASSERT_PARAM (max); - - if (range_opts->max.set) { - bson_value_destroy (&range_opts->max.value); - } - range_opts->max.set = true; - bson_value_copy (max, &range_opts->max.value); -} - -void -mongoc_client_encryption_encrypt_range_opts_set_precision ( - mongoc_client_encryption_encrypt_range_opts_t *range_opts, int32_t precision) -{ - BSON_ASSERT_PARAM (range_opts); - range_opts->precision.set = true; - range_opts->precision.value = precision; -} - -static mongoc_client_encryption_encrypt_range_opts_t * -copy_range_opts (const mongoc_client_encryption_encrypt_range_opts_t *opts) -{ - BSON_ASSERT_PARAM (opts); - mongoc_client_encryption_encrypt_range_opts_t *opts_new = - mongoc_client_encryption_encrypt_range_opts_new (); - if (opts->min.set) { - bson_value_copy (&opts->min.value, &opts_new->min.value); - opts_new->min.set = true; - } - if (opts->max.set) { - bson_value_copy (&opts->max.value, &opts_new->max.value); - opts_new->max.set = true; - } - if (opts->precision.set) { - opts_new->precision.value = opts->precision.value; - opts_new->precision.set = true; - } - opts_new->sparsity = opts->sparsity; - return opts_new; -} - -void -mongoc_client_encryption_encrypt_opts_set_range_opts ( - mongoc_client_encryption_encrypt_opts_t *opts, - const mongoc_client_encryption_encrypt_range_opts_t *range_opts) -{ - BSON_ASSERT_PARAM (opts); - - if (opts->range_opts) { - mongoc_client_encryption_encrypt_range_opts_destroy (opts->range_opts); - opts->range_opts = NULL; - } - - opts->range_opts = copy_range_opts (range_opts); -} - -/*-------------------------------------------------------------------------- - * RewrapManyDataKeyResult. - *-------------------------------------------------------------------------- - */ -struct _mongoc_client_encryption_rewrap_many_datakey_result_t { - bson_t bulk_write_result; -}; - -mongoc_client_encryption_rewrap_many_datakey_result_t * -mongoc_client_encryption_rewrap_many_datakey_result_new (void) -{ - mongoc_client_encryption_rewrap_many_datakey_result_t *const res = - BSON_ALIGNED_ALLOC0 ( - mongoc_client_encryption_rewrap_many_datakey_result_t); - - bson_init (&res->bulk_write_result); - - return res; -} - -void -mongoc_client_encryption_rewrap_many_datakey_result_destroy ( - mongoc_client_encryption_rewrap_many_datakey_result_t *result) -{ - if (!result) { - return; - } - - bson_destroy (&result->bulk_write_result); - bson_free (result); -} - -const bson_t * -mongoc_client_encryption_rewrap_many_datakey_result_get_bulk_write_result ( - mongoc_client_encryption_rewrap_many_datakey_result_t *result) -{ - if (!result) { - return NULL; - } - - /* bulkWriteResult may be empty if no result of a bulk write operation has - * been assigned to it. Treat as equivalent to an unset optional state. */ - if (bson_empty (&result->bulk_write_result)) { - return NULL; - } - - return &result->bulk_write_result; -} - -#ifndef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION - -static bool -_disabled_error (bson_error_t *error) -{ - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "libmongoc is not built with support for Client-Side Field " - "Level Encryption. Configure with " - "ENABLE_CLIENT_SIDE_ENCRYPTION=ON."); - return false; -} - -bool -_mongoc_cse_auto_encrypt (mongoc_client_t *client, - const mongoc_cmd_t *cmd, - mongoc_cmd_t *encrypted_cmd, - bson_t *encrypted, - bson_error_t *error) -{ - BSON_UNUSED (client); - BSON_UNUSED (cmd); - BSON_UNUSED (encrypted_cmd); - - bson_init (encrypted); - - return _disabled_error (error); -} - -bool -_mongoc_cse_auto_decrypt (mongoc_client_t *client, - const char *db_name, - const bson_t *reply, - bson_t *decrypted, - bson_error_t *error) -{ - BSON_UNUSED (client); - BSON_UNUSED (db_name); - BSON_UNUSED (reply); - - bson_init (decrypted); - - return _disabled_error (error); -} - -bool -_mongoc_cse_client_enable_auto_encryption ( - mongoc_client_t *client, - mongoc_auto_encryption_opts_t *opts /* may be NULL */, - bson_error_t *error) -{ - BSON_UNUSED (client); - BSON_UNUSED (opts); - - return _disabled_error (error); -} - -bool -_mongoc_cse_client_pool_enable_auto_encryption ( - mongoc_topology_t *topology, - mongoc_auto_encryption_opts_t *opts /* may be NULL */, - bson_error_t *error) -{ - BSON_UNUSED (topology); - BSON_UNUSED (opts); - - return _disabled_error (error); -} - - -bool -mongoc_client_encryption_create_datakey ( - mongoc_client_encryption_t *client_encryption, - const char *kms_provider, - const mongoc_client_encryption_datakey_opts_t *opts, - bson_value_t *keyid, - bson_error_t *error) -{ - BSON_UNUSED (client_encryption); - BSON_UNUSED (kms_provider); - BSON_UNUSED (opts); - - if (keyid) { - memset (keyid, 0, sizeof (*keyid)); - } - - return _disabled_error (error); -} - - -bool -mongoc_client_encryption_rewrap_many_datakey ( - mongoc_client_encryption_t *client_encryption, - const bson_t *filter, - const char *provider, - const bson_t *master_key, - mongoc_client_encryption_rewrap_many_datakey_result_t *result, - bson_error_t *error) -{ - BSON_UNUSED (client_encryption); - BSON_UNUSED (filter); - BSON_UNUSED (provider); - BSON_UNUSED (master_key); - BSON_UNUSED (result); - - return _disabled_error (error); -} - - -bool -mongoc_client_encryption_delete_key ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - bson_t *reply, - bson_error_t *error) -{ - BSON_UNUSED (client_encryption); - BSON_UNUSED (keyid); - - _mongoc_bson_init_if_set (reply); - - return _disabled_error (error); -} - - -bool -mongoc_client_encryption_get_key (mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - bson_t *key_doc, - bson_error_t *error) -{ - BSON_UNUSED (client_encryption); - BSON_UNUSED (keyid); - - _mongoc_bson_init_if_set (key_doc); - - return _disabled_error (error); -} - - -mongoc_cursor_t * -mongoc_client_encryption_get_keys ( - mongoc_client_encryption_t *client_encryption, bson_error_t *error) -{ - BSON_UNUSED (client_encryption); - - _disabled_error (error); - - return NULL; -} - - -bool -mongoc_client_encryption_add_key_alt_name ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - const char *keyaltname, - bson_t *key_doc, - bson_error_t *error) -{ - BSON_UNUSED (client_encryption); - BSON_UNUSED (keyid); - BSON_UNUSED (keyaltname); - - _mongoc_bson_init_if_set (key_doc); - - return _disabled_error (error); -} - - -bool -mongoc_client_encryption_remove_key_alt_name ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - const char *keyaltname, - bson_t *key_doc, - bson_error_t *error) -{ - BSON_UNUSED (client_encryption); - BSON_UNUSED (keyid); - BSON_UNUSED (keyaltname); - - _mongoc_bson_init_if_set (key_doc); - - return _disabled_error (error); -} - - -bool -mongoc_client_encryption_get_key_by_alt_name ( - mongoc_client_encryption_t *client_encryption, - const char *keyaltname, - bson_t *key_doc, - bson_error_t *error) -{ - BSON_UNUSED (client_encryption); - BSON_UNUSED (keyaltname); - - _mongoc_bson_init_if_set (key_doc); - - return _disabled_error (error); -} - - -MONGOC_EXPORT (mongoc_client_encryption_t *) -mongoc_client_encryption_new (mongoc_client_encryption_opts_t *opts, - bson_error_t *error) -{ - BSON_UNUSED (opts); - - _disabled_error (error); - - return NULL; -} - -void -mongoc_client_encryption_destroy (mongoc_client_encryption_t *client_encryption) -{ - BSON_UNUSED (client_encryption); -} - -bool -mongoc_client_encryption_encrypt (mongoc_client_encryption_t *client_encryption, - const bson_value_t *value, - mongoc_client_encryption_encrypt_opts_t *opts, - bson_value_t *ciphertext, - bson_error_t *error) -{ - BSON_UNUSED (client_encryption); - BSON_UNUSED (value); - BSON_UNUSED (opts); - - if (ciphertext) { - memset (ciphertext, 0, sizeof (*ciphertext)); - } - - return _disabled_error (error); -} - -bool -mongoc_client_encryption_encrypt_expression ( - mongoc_client_encryption_t *client_encryption, - const bson_t *expr, - mongoc_client_encryption_encrypt_opts_t *opts, - bson_t *expr_encrypted, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client_encryption); - BSON_ASSERT_PARAM (expr); - BSON_ASSERT_PARAM (opts); - BSON_ASSERT_PARAM (expr_encrypted); - BSON_ASSERT (error || true); - - bson_init (expr_encrypted); - - return _disabled_error (error); -} - -bool -mongoc_client_encryption_decrypt (mongoc_client_encryption_t *client_encryption, - const bson_value_t *ciphertext, - bson_value_t *value, - bson_error_t *error) -{ - BSON_UNUSED (client_encryption); - BSON_UNUSED (ciphertext); - - if (value) { - memset (value, 0, sizeof (*value)); - } - - return _disabled_error (error); -} - -bool -_mongoc_cse_is_enabled (mongoc_client_t *client) -{ - BSON_UNUSED (client); - - return false; -} - -mongoc_collection_t * -mongoc_client_encryption_create_encrypted_collection ( - mongoc_client_encryption_t *enc, - struct _mongoc_database_t *database, - const char *name, - const bson_t *in_options, - bson_t *opt_out_options, - const char *const kms_provider, - const bson_t *opt_masterkey, - bson_error_t *error) -{ - BSON_UNUSED (enc); - BSON_UNUSED (database); - BSON_UNUSED (name); - BSON_UNUSED (in_options); - BSON_UNUSED (opt_out_options); - BSON_UNUSED (kms_provider); - BSON_UNUSED (opt_masterkey); - - _disabled_error (error); - return NULL; -} - -#else - -/* Appends the range opts set by the user into a bson_t that can be passed to - * libmongocrypt. - */ -static void -append_bson_range_opts (bson_t *bson_range_opts, - const mongoc_client_encryption_encrypt_opts_t *opts) -{ - BSON_ASSERT_PARAM (bson_range_opts); - BSON_ASSERT_PARAM (opts); - - if (opts->range_opts->min.set) { - BSON_ASSERT (BSON_APPEND_VALUE ( - bson_range_opts, "min", &opts->range_opts->min.value)); - } - if (opts->range_opts->max.set) { - BSON_ASSERT (BSON_APPEND_VALUE ( - bson_range_opts, "max", &opts->range_opts->max.value)); - } - if (opts->range_opts->precision.set) { - BSON_ASSERT (BSON_APPEND_INT32 ( - bson_range_opts, "precision", opts->range_opts->precision.value)); - } - if (opts->range_opts->sparsity) { - BSON_ASSERT (BSON_APPEND_INT64 ( - bson_range_opts, "sparsity", opts->range_opts->sparsity)); - } -} - -/*-------------------------------------------------------------------------- - * - * _prep_for_auto_encryption -- - * If @cmd contains a type=1 payload (document sequence), convert it into - * a type=0 payload (array payload). See OP_MSG spec for details. - * Place the command BSON that should be encrypted into @out. - * - * Post-conditions: - * @out is initialized and set to the full payload. If @cmd did not include - * a type=1 payload, @out is statically initialized. Caller must not modify - * @out after, but must call bson_destroy. - * - * -------------------------------------------------------------------------- - */ -static void -_prep_for_auto_encryption (const mongoc_cmd_t *cmd, bson_t *out) -{ - /* If there is no type=1 payload, return the command unchanged. */ - if (!cmd->payload || !cmd->payload_size) { - BSON_ASSERT (bson_init_static ( - out, bson_get_data (cmd->command), cmd->command->len)); - return; - } - - /* Otherwise, append the type=1 payload as an array. */ - bson_copy_to (cmd->command, out); - _mongoc_cmd_append_payload_as_array (cmd, out); -} - -/* Return the mongocryptd client to use on a client with automatic encryption - * enabled. - * If @client_encrypted is single-threaded, use the client to mongocryptd. - * If @client_encrypted is multi-threaded, use the client pool to mongocryptd. - */ -mongoc_client_t * -_get_mongocryptd_client (mongoc_client_t *client_encrypted) -{ - BSON_ASSERT_PARAM (client_encrypted); - - if (client_encrypted->topology->single_threaded) { - return client_encrypted->topology->mongocryptd_client; - } - return mongoc_client_pool_pop ( - client_encrypted->topology->mongocryptd_client_pool); -} - -void -_release_mongocryptd_client (mongoc_client_t *client_encrypted, - mongoc_client_t *mongocryptd_client) -{ - BSON_ASSERT_PARAM (client_encrypted); - - if (!mongocryptd_client) { - return; - } - if (!client_encrypted->topology->single_threaded) { - mongoc_client_pool_push ( - client_encrypted->topology->mongocryptd_client_pool, - mongocryptd_client); - } -} - -/* Return the key vault collection to use on a client with automatic encryption - * enabled. - * If no custom key vault client/pool is set, create a collection from the - * @client_encrypted itself. - * If @client_encrypted is single-threaded, use the client to mongocryptd to - * create the collection. - * If @client_encrypted is multi-threaded, use the client pool to mongocryptd - * to create the collection. - */ -mongoc_collection_t * -_get_keyvault_coll (mongoc_client_t *client_encrypted) -{ - BSON_ASSERT_PARAM (client_encrypted); - - mongoc_write_concern_t *const wc = mongoc_write_concern_new (); - mongoc_read_concern_t *const rc = mongoc_read_concern_new (); - - mongoc_client_t *keyvault_client; - const char *db; - const char *coll; - mongoc_collection_t *res = NULL; - - db = client_encrypted->topology->keyvault_db; - coll = client_encrypted->topology->keyvault_coll; - - if (client_encrypted->topology->single_threaded) { - if (client_encrypted->topology->keyvault_client) { - keyvault_client = client_encrypted->topology->keyvault_client; - } else { - keyvault_client = client_encrypted; - } - } else { - if (client_encrypted->topology->keyvault_client_pool) { - keyvault_client = mongoc_client_pool_pop ( - client_encrypted->topology->keyvault_client_pool); - } else { - keyvault_client = client_encrypted; - } - } - - res = mongoc_client_get_collection (keyvault_client, db, coll); - - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY); - mongoc_collection_set_write_concern (res, wc); - - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_MAJORITY); - mongoc_collection_set_read_concern (res, rc); - - mongoc_write_concern_destroy (wc); - mongoc_read_concern_destroy (rc); - - return res; -} - -void -_release_keyvault_coll (mongoc_client_t *client_encrypted, - mongoc_collection_t *keyvault_coll) -{ - mongoc_client_t *keyvault_client; - - BSON_ASSERT_PARAM (client_encrypted); - - if (!keyvault_coll) { - return; - } - - keyvault_client = keyvault_coll->client; - mongoc_collection_destroy (keyvault_coll); - if (!client_encrypted->topology->single_threaded && - client_encrypted->topology->keyvault_client_pool) { - mongoc_client_pool_push (client_encrypted->topology->keyvault_client_pool, - keyvault_client); - } -} - -static bool -_spawn_mongocryptd (const char *mongocryptd_spawn_path, - const bson_t *mongocryptd_spawn_args, - bson_error_t *error); - -/*-------------------------------------------------------------------------- - * - * _mongoc_cse_auto_encrypt -- - * - * Perform automatic encryption if enabled. - * - * Return: - * True on success, false on error. - * - * Pre-conditions: - * CSE is enabled on client or its associated client pool. - * - * Post-conditions: - * If return false, @error is set. @encrypted is always initialized. - * @encrypted_cmd is set to the mongoc_cmd_t to send, which may refer - * to @encrypted. - * If automatic encryption was bypassed, @encrypted is set to an empty - * document, but @encrypted_cmd is a copy of @cmd. Caller must always - * bson_destroy @encrypted. - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_cse_auto_encrypt (mongoc_client_t *client_encrypted, - const mongoc_cmd_t *cmd, - mongoc_cmd_t *encrypted_cmd, - bson_t *encrypted, - bson_error_t *error) -{ - bool ret = false; - bson_t cmd_bson = BSON_INITIALIZER; - bson_t *result = NULL; - bson_iter_t iter; - mongoc_client_t *mongocryptd_client = NULL; - mongoc_collection_t *keyvault_coll = NULL; - bool retried = false; - - ENTRY; - - BSON_ASSERT_PARAM (client_encrypted); - bson_init (encrypted); - - if (client_encrypted->topology->bypass_auto_encryption) { - memcpy (encrypted_cmd, cmd, sizeof (mongoc_cmd_t)); - bson_destroy (&cmd_bson); - RETURN (true); - } - - if (cmd->server_stream->sd->max_wire_version < WIRE_VERSION_CSE) { - bson_set_error ( - error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "%s", - "Auto-encryption requires a minimum MongoDB version of 4.2"); - GOTO (fail); - } - - /* Construct the command we're sending to libmongocrypt. If cmd includes a - * type 1 payload, convert it to a type 0 payload. */ - bson_destroy (&cmd_bson); - _prep_for_auto_encryption (cmd, &cmd_bson); - keyvault_coll = _get_keyvault_coll (client_encrypted); - mongocryptd_client = _get_mongocryptd_client (client_encrypted); - -retry: - bson_destroy (encrypted); - if (!_mongoc_crypt_auto_encrypt (client_encrypted->topology->crypt, - keyvault_coll, - mongocryptd_client, - client_encrypted, - cmd->db_name, - &cmd_bson, - encrypted, - error)) { - /* From the Client-Side Encryption spec: If spawning is necessary, the - * driver MUST spawn mongocryptd whenever server selection on the - * MongoClient to mongocryptd fails. If the MongoClient fails to connect - * after spawning, the server selection error is propagated to the user. - */ - if (!client_encrypted->topology->mongocryptd_bypass_spawn && - error->domain == MONGOC_ERROR_SERVER_SELECTION && !retried) { - if (!_spawn_mongocryptd ( - client_encrypted->topology->mongocryptd_spawn_path, - client_encrypted->topology->mongocryptd_spawn_args, - error)) { - GOTO (fail); - } - /* Respawn and retry. */ - memset (error, 0, sizeof (*error)); - retried = true; - GOTO (retry); - } - GOTO (fail); - } - - - /* Re-append $db if encryption stripped it. */ - if (!bson_iter_init_find (&iter, encrypted, "$db")) { - BSON_APPEND_UTF8 (encrypted, "$db", cmd->db_name); - } - - /* Create the modified cmd_t. */ - memcpy (encrypted_cmd, cmd, sizeof (mongoc_cmd_t)); - /* Modify the mongoc_cmd_t and clear the payload, since - * _mongoc_cse_auto_encrypt converted the payload into an embedded array. */ - encrypted_cmd->payload = NULL; - encrypted_cmd->payload_size = 0; - encrypted_cmd->command = encrypted; - - ret = true; - -fail: - bson_destroy (result); - bson_destroy (&cmd_bson); - _release_mongocryptd_client (client_encrypted, mongocryptd_client); - _release_keyvault_coll (client_encrypted, keyvault_coll); - RETURN (ret); -} - -/*-------------------------------------------------------------------------- - * - * _mongoc_cse_auto_decrypt -- - * - * Perform automatic decryption. - * - * Return: - * True on success, false on error. - * - * Pre-conditions: - * FLE is enabled on client or its associated client pool. - * - * Post-conditions: - * If return false, @error is set. @decrypted is always initialized. - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_cse_auto_decrypt (mongoc_client_t *client_encrypted, - const char *db_name, - const bson_t *reply, - bson_t *decrypted, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *keyvault_coll = NULL; - - ENTRY; - - BSON_ASSERT_PARAM (client_encrypted); - BSON_UNUSED (db_name); - - keyvault_coll = _get_keyvault_coll (client_encrypted); - if (!_mongoc_crypt_auto_decrypt (client_encrypted->topology->crypt, - keyvault_coll, - reply, - decrypted, - error)) { - GOTO (fail); - } - - ret = true; - -fail: - _release_keyvault_coll (client_encrypted, keyvault_coll); - RETURN (ret); -} - -static void -_uri_construction_error (bson_error_t *error) -{ - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "Error constructing URI to mongocryptd"); -} - - -#ifdef _WIN32 -static bool -_do_spawn (const char *path, char **args, bson_error_t *error) -{ - bson_string_t *command; - char **arg; - PROCESS_INFORMATION process_information; - STARTUPINFO startup_info; - - /* Construct the full command, quote path and arguments. */ - command = bson_string_new (""); - bson_string_append (command, "\""); - if (path) { - bson_string_append (command, path); - } - bson_string_append (command, "mongocryptd.exe"); - bson_string_append (command, "\""); - /* skip the "mongocryptd" first arg. */ - arg = args + 1; - while (*arg) { - bson_string_append (command, " \""); - bson_string_append (command, *arg); - bson_string_append (command, "\""); - arg++; - } - - ZeroMemory (&process_information, sizeof (process_information)); - ZeroMemory (&startup_info, sizeof (startup_info)); - - startup_info.cb = sizeof (startup_info); - - if (!CreateProcessA (NULL, - command->str, - NULL, - NULL, - false /* inherit descriptors */, - DETACHED_PROCESS /* FLAGS */, - NULL /* environment */, - NULL /* current directory */, - &startup_info, - &process_information)) { - long lastError = GetLastError (); - LPSTR message = NULL; - - FormatMessageA ( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_ARGUMENT_ARRAY | - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - lastError, - 0, - (LPSTR) &message, - 0, - NULL); - - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "failed to spawn mongocryptd: %s", - message); - LocalFree (message); - bson_string_free (command, true); - return false; - } - - bson_string_free (command, true); - return true; -} -#else - - -/*-------------------------------------------------------------------------- - * - * _do_spawn -- - * - * Spawn process defined by arg[0] on POSIX systems. - * - * Note, if mongocryptd fails to spawn (due to not being found on the path), - * an error is not reported and true is returned. Users will get an error - * later, upon first attempt to use mongocryptd. - * - * These comments refer to three distinct processes: parent, child, and - * mongocryptd. - * - parent is initial calling process - * - child is the first forked child. It fork-execs mongocryptd then - * terminates. This makes mongocryptd an orphan, making it immediately - * adopted by the init process. - * - mongocryptd is the final background daemon (grandchild process). - * - * Return: - * False if an error definitely occurred. Returns true if no reportable - * error occurred (though an error may have occurred in starting - * mongocryptd, resulting in the process not running). - * - * Arguments: - * args - A NULL terminated list of arguments. The first argument MUST - * be the name of the process to execute, and the last argument MUST be - * NULL. - * - * Post-conditions: - * If return false, @error is set. - * - *-------------------------------------------------------------------------- - */ -static bool -_do_spawn (const char *path, char **args, bson_error_t *error) -{ - pid_t pid; - int fd; - char *to_exec; - - // String allocation must be done up-front, as allocation is not fork-safe. - if (path) { - to_exec = bson_strdup_printf ("%s%s", path, args[0]); - } else { - to_exec = bson_strdup (args[0]); - } - - /* Fork. The child will terminate immediately (after fork-exec'ing - * mongocryptd). This orphans mongocryptd, and allows parent to wait on - * child. */ - pid = fork (); - if (pid < 0) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "failed to fork (errno=%d) '%s'", - errno, - strerror (errno)); - bson_free (to_exec); - return false; - } else if (pid > 0) { - int child_status; - - /* Child will spawn mongocryptd and immediately terminate to turn - * mongocryptd into an orphan. */ - if (waitpid (pid, &child_status, 0 /* options */) < 0) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "failed to wait for child (errno=%d) '%s'", - errno, - strerror (errno)); - bson_free (to_exec); - return false; - } - /* parent is done at this point, return. */ - bson_free (to_exec); - return true; - } - - /* We're no longer in the parent process. Errors encountered result in an - * exit. - * Note, we're not logging here, because that would require the user's log - * callback to be fork-safe. - */ - - /* Start a new session for the child, so it is not bound to the current - * session (e.g. terminal session). */ - if (setsid () < 0) { - _exit (EXIT_FAILURE); - } - - /* Fork again. Child terminates so mongocryptd gets orphaned and immedately - * adopted by init. */ - signal (SIGHUP, SIG_IGN); - pid = fork (); - if (pid < 0) { - _exit (EXIT_FAILURE); - } else if (pid > 0) { - /* Child terminates immediately. */ - _exit (EXIT_SUCCESS); - } - - /* If we later decide to change the working directory for the pid file path, - * possibly change the process's working directory with chdir like: `chdir - * (default_pid_path)`. Currently pid file ends up in application's working - * directory. */ - - /* Set the user file creation mask to zero. */ - umask (0); - - /* Close and reopen stdin. */ - fd = open ("/dev/null", O_RDONLY); - if (fd < 0) { - _exit (EXIT_FAILURE); - } - dup2 (fd, STDIN_FILENO); - close (fd); - - /* Close and reopen stdout. */ - fd = open ("/dev/null", O_WRONLY); - if (fd < 0) { - _exit (EXIT_FAILURE); - } - if (dup2 (fd, STDOUT_FILENO) < 0 || close (fd) < 0) { - _exit (EXIT_FAILURE); - } - - /* Close and reopen stderr. */ - fd = open ("/dev/null", O_RDWR); - if (fd < 0) { - _exit (EXIT_FAILURE); - } - if (dup2 (fd, STDERR_FILENO) < 0 || close (fd) < 0) { - _exit (EXIT_FAILURE); - } - - if (execvp (to_exec, args) < 0) { - /* Need to exit. */ - _exit (EXIT_FAILURE); - } - - /* Will never execute. */ - return false; -} -#endif - -/*-------------------------------------------------------------------------- - * - * _spawn_mongocryptd -- - * - * Attempt to spawn mongocryptd as a background process. - * - * Return: - * False if an error definitely occurred. Returns true if no reportable - * error occurred (though an error may have occurred in starting - * mongocryptd, resulting in the process not running). - * - * Arguments: - * mongocryptd_spawn_path May be NULL, otherwise the path to mongocryptd. - * mongocryptd_spawn_args May be NULL, otherwise a bson_iter_t to the - * value "mongocryptdSpawnArgs" in AutoEncryptionOpts.extraOptions - * (see spec). - * - * Post-conditions: - * If return false, @error is set. - * - *-------------------------------------------------------------------------- - */ -static bool -_spawn_mongocryptd (const char *mongocryptd_spawn_path, - const bson_t *mongocryptd_spawn_args, - bson_error_t *error) -{ - char **args = NULL; - bson_iter_t iter; - bool passed_idle_shutdown_timeout_secs = false; - int num_args = 2; /* for leading "mongocrypt" and trailing NULL */ - int i; - bool ret; - - /* iterate once to get length and validate all are strings */ - if (mongocryptd_spawn_args) { - bson_iter_init (&iter, mongocryptd_spawn_args); - while (bson_iter_next (&iter)) { - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "invalid argument for mongocryptd, must be string"); - return false; - } - /* Check if the arg starts with --idleShutdownTimeoutSecs= or is equal - * to --idleShutdownTimeoutSecs */ - if (0 == strncmp ("--idleShutdownTimeoutSecs=", - bson_iter_utf8 (&iter, NULL), - 26) || - 0 == strcmp ("--idleShutdownTimeoutSecs", - bson_iter_utf8 (&iter, NULL))) { - passed_idle_shutdown_timeout_secs = true; - } - num_args++; - } - } - - if (!passed_idle_shutdown_timeout_secs) { - /* add one more */ - num_args++; - } - - args = (char **) bson_malloc (sizeof (char *) * num_args); - i = 0; - args[i++] = "mongocryptd"; - - if (mongocryptd_spawn_args) { - bson_iter_init (&iter, mongocryptd_spawn_args); - while (bson_iter_next (&iter)) { - args[i++] = (char *) bson_iter_utf8 (&iter, NULL); - } - } - - if (!passed_idle_shutdown_timeout_secs) { - args[i++] = "--idleShutdownTimeoutSecs=60"; - } - - BSON_ASSERT (i == num_args - 1); - args[i++] = NULL; - - ret = _do_spawn (mongocryptd_spawn_path, args, error); - bson_free (args); - return ret; -} - -static bool -_parse_extra (const bson_t *extra, - mongoc_topology_t *topology, - mongoc_uri_t **uri, - bson_error_t *error) -{ - bson_iter_t iter; - bool ret = false; - - ENTRY; - - *uri = NULL; - if (extra) { - if (bson_iter_init_find (&iter, extra, "mongocryptdBypassSpawn")) { - if (!BSON_ITER_HOLDS_BOOL (&iter)) { - bson_set_error ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Expected bool for option 'mongocryptdBypassSpawn'"); - GOTO (fail); - } - topology->mongocryptd_bypass_spawn = bson_iter_bool (&iter); - } - if (bson_iter_init_find (&iter, extra, "mongocryptdSpawnPath")) { - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - bson_set_error ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Expected string for option 'mongocryptdSpawnPath'"); - GOTO (fail); - } - topology->mongocryptd_spawn_path = - bson_strdup (bson_iter_utf8 (&iter, NULL)); - } - if (bson_iter_init_find (&iter, extra, "mongocryptdSpawnArgs")) { - uint32_t array_len; - const uint8_t *array_data; - - if (!BSON_ITER_HOLDS_ARRAY (&iter)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Expected array for option 'mongocryptdSpawnArgs'"); - GOTO (fail); - } - bson_iter_array (&iter, &array_len, &array_data); - topology->mongocryptd_spawn_args = - bson_new_from_data (array_data, array_len); - } - - if (bson_iter_init_find (&iter, extra, "mongocryptdURI")) { - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Expected string for option 'mongocryptdURI'"); - GOTO (fail); - } - *uri = mongoc_uri_new_with_error (bson_iter_utf8 (&iter, NULL), error); - if (!*uri) { - GOTO (fail); - } - } - - if (bson_iter_init_find (&iter, extra, "cryptSharedLibPath")) { - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Expected a string for 'cryptSharedLibPath'"); - GOTO (fail); - } - size_t len; - const char *ptr = bson_iter_utf8_unsafe (&iter, &len); - bson_free (topology->clientSideEncryption.autoOptions.extraOptions - .cryptSharedLibPath); - topology->clientSideEncryption.autoOptions.extraOptions - .cryptSharedLibPath = bson_strdup (ptr); - } - - if (bson_iter_init_find (&iter, extra, "cryptSharedLibRequired")) { - if (!BSON_ITER_HOLDS_BOOL (&iter)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Expected a bool for 'cryptSharedLibRequired'"); - GOTO (fail); - } - topology->clientSideEncryption.autoOptions.extraOptions - .cryptSharedLibRequired = bson_iter_bool_unsafe (&iter); - } - } - - - if (!*uri) { - *uri = mongoc_uri_new_with_error ("mongodb://localhost:27020", error); - - if (!*uri) { - GOTO (fail); - } - - if (!mongoc_uri_set_option_as_int32 ( - *uri, MONGOC_URI_SERVERSELECTIONTIMEOUTMS, 10000)) { - _uri_construction_error (error); - GOTO (fail); - } - } - - ret = true; -fail: - RETURN (ret); -} - -bool -_mongoc_cse_client_enable_auto_encryption (mongoc_client_t *client, - mongoc_auto_encryption_opts_t *opts, - bson_error_t *error) -{ - bool ret = false; - mongoc_uri_t *mongocryptd_uri = NULL; - - ENTRY; - - BSON_ASSERT (client); - if (!client->topology->single_threaded) { - bson_set_error ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Automatic encryption on pooled clients must be set on the pool"); - GOTO (fail); - } - - if (!opts) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Auto encryption options required"); - GOTO (fail); - } - - if (opts->keyvault_client_pool) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "The key vault client pool only applies to a client " - "pool, not a single threaded client"); - GOTO (fail); - } - - if (opts->keyvault_client && - !opts->keyvault_client->topology->single_threaded) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "The key vault client must be single threaded, not be " - "from a client pool"); - GOTO (fail); - } - - /* Check for required options */ - if (!opts->keyvault_db || !opts->keyvault_coll) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Key vault namespace option required"); - GOTO (fail); - } - - if (!opts->kms_providers) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "KMS providers option required"); - GOTO (fail); - } - - if (client->topology->cse_state != MONGOC_CSE_DISABLED) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "Automatic encryption already set"); - GOTO (fail); - } else { - client->topology->cse_state = MONGOC_CSE_ENABLED; - } - - if (!_parse_extra (opts->extra, client->topology, &mongocryptd_uri, error)) { - GOTO (fail); - } - - client->topology->crypt = - _mongoc_crypt_new (opts->kms_providers, - opts->schema_map, - opts->encrypted_fields_map, - opts->tls_opts, - client->topology->clientSideEncryption.autoOptions - .extraOptions.cryptSharedLibPath, - client->topology->clientSideEncryption.autoOptions - .extraOptions.cryptSharedLibRequired, - opts->bypass_auto_encryption, - opts->bypass_query_analysis, - opts->creds_cb, - error); - if (!client->topology->crypt) { - GOTO (fail); - } - - const bool have_crypt_shared = - _mongoc_crypt_get_crypt_shared_version (client->topology->crypt) != NULL; - - client->topology->bypass_auto_encryption = opts->bypass_auto_encryption; - client->topology->bypass_query_analysis = opts->bypass_query_analysis; - - if (!client->topology->bypass_auto_encryption && - !client->topology->bypass_query_analysis && !have_crypt_shared) { - if (!client->topology->mongocryptd_bypass_spawn) { - if (!_spawn_mongocryptd (client->topology->mongocryptd_spawn_path, - client->topology->mongocryptd_spawn_args, - error)) { - GOTO (fail); - } - } - - /* By default, single threaded clients set serverSelectionTryOnce to - * true, which means server selection fails if a topology scan fails - * the first time (i.e. it will not make repeat attempts until - * serverSelectionTimeoutMS expires). Override this, since the first - * attempt to connect to mongocryptd may fail when spawning, as it - * takes some time for mongocryptd to listen on sockets. */ - if (!mongoc_uri_set_option_as_bool ( - mongocryptd_uri, MONGOC_URI_SERVERSELECTIONTRYONCE, false)) { - _uri_construction_error (error); - GOTO (fail); - } - - client->topology->mongocryptd_client = - mongoc_client_new_from_uri (mongocryptd_uri); - - if (!client->topology->mongocryptd_client) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "Unable to create client to mongocryptd"); - GOTO (fail); - } - /* Similarly, single threaded clients will by default wait for 5 second - * cooldown period after failing to connect to a server before making - * another attempt. Meaning if the first attempt to mongocryptd fails - * to connect, then the user observes a 5 second delay. This is not - * configurable in the URI, so override. */ - _mongoc_topology_bypass_cooldown ( - client->topology->mongocryptd_client->topology); - - /* Also, since single threaded server selection can foreseeably take - * connectTimeoutMS (which by default is longer than 10 seconds), reduce - * this as well. */ - if (!mongoc_uri_set_option_as_int32 ( - mongocryptd_uri, MONGOC_URI_CONNECTTIMEOUTMS, 10000)) { - _uri_construction_error (error); - GOTO (fail); - } - } - - client->topology->keyvault_db = bson_strdup (opts->keyvault_db); - client->topology->keyvault_coll = bson_strdup (opts->keyvault_coll); - if (opts->keyvault_client) { - client->topology->keyvault_client = opts->keyvault_client; - } - - if (opts->encrypted_fields_map) { - client->topology->encrypted_fields_map = - bson_copy (opts->encrypted_fields_map); - } - - ret = true; -fail: - mongoc_uri_destroy (mongocryptd_uri); - RETURN (ret); -} - -bool -_mongoc_cse_client_pool_enable_auto_encryption ( - mongoc_topology_t *topology, - mongoc_auto_encryption_opts_t *opts, - bson_error_t *error) -{ - bool setup_okay = false; - mongoc_uri_t *mongocryptd_uri = NULL; - mongoc_topology_cse_state_t prev_cse_state = MONGOC_CSE_STARTING; - - BSON_ASSERT (topology); - if (!opts) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Auto encryption options required"); - GOTO (fail); - } - - if (opts->keyvault_client) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "The key vault client only applies to a single threaded " - "client not a client pool. Set a key vault client pool"); - GOTO (fail); - } - - /* Check for required options */ - if (!opts->keyvault_db || !opts->keyvault_coll) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Key vault namespace option required"); - GOTO (fail); - } - - if (!opts->kms_providers) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "KMS providers option required"); - GOTO (fail); - } - - prev_cse_state = - bson_atomic_int_compare_exchange_strong ((int *) &topology->cse_state, - MONGOC_CSE_DISABLED, - MONGOC_CSE_STARTING, - bson_memory_order_acquire); - while (prev_cse_state == MONGOC_CSE_STARTING) { - /* Another thread is starting client-side encryption. It may take some - * time to start, but don't continue until it is finished. */ - bson_thrd_yield (); - prev_cse_state = - bson_atomic_int_compare_exchange_strong ((int *) &topology->cse_state, - MONGOC_CSE_DISABLED, - MONGOC_CSE_STARTING, - bson_memory_order_acquire); - } - - if (prev_cse_state == MONGOC_CSE_ENABLED) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "Automatic encryption already set"); - GOTO (fail); - } - - /* We just set the CSE state from DISABLED to STARTING. Start it up now. */ - - if (!_parse_extra (opts->extra, topology, &mongocryptd_uri, error)) { - GOTO (fail); - } - - topology->crypt = - _mongoc_crypt_new (opts->kms_providers, - opts->schema_map, - opts->encrypted_fields_map, - opts->tls_opts, - topology->clientSideEncryption.autoOptions.extraOptions - .cryptSharedLibPath, - topology->clientSideEncryption.autoOptions.extraOptions - .cryptSharedLibRequired, - opts->bypass_auto_encryption, - opts->bypass_query_analysis, - opts->creds_cb, - error); - if (!topology->crypt) { - GOTO (fail); - } - - topology->bypass_auto_encryption = opts->bypass_auto_encryption; - topology->bypass_query_analysis = opts->bypass_query_analysis; - - if (!topology->bypass_auto_encryption && !topology->bypass_query_analysis) { - if (!topology->mongocryptd_bypass_spawn) { - if (!_spawn_mongocryptd (topology->mongocryptd_spawn_path, - topology->mongocryptd_spawn_args, - error)) { - GOTO (fail); - } - } - - topology->mongocryptd_client_pool = - mongoc_client_pool_new (mongocryptd_uri); - - if (!topology->mongocryptd_client_pool) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "Unable to create client pool to mongocryptd"); - GOTO (fail); - } - } - - topology->keyvault_db = bson_strdup (opts->keyvault_db); - topology->keyvault_coll = bson_strdup (opts->keyvault_coll); - if (opts->keyvault_client_pool) { - topology->keyvault_client_pool = opts->keyvault_client_pool; - } - - if (opts->encrypted_fields_map) { - topology->encrypted_fields_map = bson_copy (opts->encrypted_fields_map); - } - - setup_okay = true; - BSON_ASSERT (prev_cse_state == MONGOC_CSE_DISABLED); -fail: - if (prev_cse_state == MONGOC_CSE_DISABLED) { - /* We need to set the new CSE state. */ - mongoc_topology_cse_state_t new_state = - setup_okay ? MONGOC_CSE_ENABLED : MONGOC_CSE_DISABLED; - bson_atomic_int_exchange ( - (int *) &topology->cse_state, new_state, bson_memory_order_release); - } - mongoc_uri_destroy (mongocryptd_uri); - RETURN (setup_okay); -} - -struct _mongoc_client_encryption_t { - _mongoc_crypt_t *crypt; - mongoc_collection_t *keyvault_coll; - bson_t *kms_providers; -}; - -mongoc_client_encryption_t * -mongoc_client_encryption_new (mongoc_client_encryption_opts_t *opts, - bson_error_t *error) -{ - mongoc_client_encryption_t *client_encryption = NULL; - bool success = false; - mongoc_write_concern_t *wc = NULL; - mongoc_read_concern_t *rc = NULL; - - /* Check for required options */ - if (!opts || !opts->keyvault_client || !opts->keyvault_db || - !opts->keyvault_coll) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Key vault client and namespace option required"); - goto fail; - } - - if (!opts->kms_providers) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "KMS providers option required"); - goto fail; - } - - client_encryption = bson_malloc0 (sizeof (*client_encryption)); - client_encryption->keyvault_coll = mongoc_client_get_collection ( - opts->keyvault_client, opts->keyvault_db, opts->keyvault_coll); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY); - mongoc_collection_set_write_concern (client_encryption->keyvault_coll, wc); - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_MAJORITY); - mongoc_collection_set_read_concern (client_encryption->keyvault_coll, rc); - - client_encryption->kms_providers = bson_copy (opts->kms_providers); - client_encryption->crypt = - _mongoc_crypt_new (opts->kms_providers, - NULL /* schema_map */, - NULL /* encrypted_fields_map */, - opts->tls_opts, - NULL /* No crypt_shared path */, - false /* crypt_shared not requried */, - true, /* bypassAutoEncryption (We are explicit) */ - false, - /* bypass_query_analysis. Not applicable. */ - opts->creds_cb, - error); - if (!client_encryption->crypt) { - goto fail; - } - - success = true; - -fail: - mongoc_write_concern_destroy (wc); - mongoc_read_concern_destroy (rc); - if (!success) { - mongoc_client_encryption_destroy (client_encryption); - return NULL; - } - return client_encryption; -} - -void -mongoc_client_encryption_destroy (mongoc_client_encryption_t *client_encryption) -{ - if (!client_encryption) { - return; - } - _mongoc_crypt_destroy (client_encryption->crypt); - mongoc_collection_destroy (client_encryption->keyvault_coll); - bson_destroy (client_encryption->kms_providers); - bson_free (client_encryption); -} - -static bool -_coll_has_write_concern_majority (const mongoc_collection_t *coll) -{ - const mongoc_write_concern_t *const wc = - mongoc_collection_get_write_concern (coll); - return wc && mongoc_write_concern_get_wmajority (wc); -} - -static bool -_coll_has_read_concern_majority (const mongoc_collection_t *coll) -{ - const mongoc_read_concern_t *const rc = - mongoc_collection_get_read_concern (coll); - const char *const level = rc ? mongoc_read_concern_get_level (rc) : NULL; - return level && strcmp (level, MONGOC_READ_CONCERN_LEVEL_MAJORITY) == 0; -} - -bool -mongoc_client_encryption_create_datakey ( - mongoc_client_encryption_t *client_encryption, - const char *kms_provider, - const mongoc_client_encryption_datakey_opts_t *opts, - bson_value_t *keyid, - bson_error_t *error) -{ - bool ret = false; - bson_t datakey = BSON_INITIALIZER; - bson_t insert_opts = BSON_INITIALIZER; - - ENTRY; - - BSON_ASSERT_PARAM (client_encryption); - - BSON_ASSERT ( - _coll_has_write_concern_majority (client_encryption->keyvault_coll)); - - if (!opts) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "required 'opts' unset"); - GOTO (fail); - } - - /* reset, so it is safe for caller to call bson_value_destroy on error or - * success. */ - if (keyid) { - keyid->value_type = BSON_TYPE_EOD; - } - - bson_destroy (&datakey); - if (!_mongoc_crypt_create_datakey (client_encryption->crypt, - kms_provider, - opts->masterkey, - opts->keyaltnames, - opts->keyaltnames_count, - opts->keymaterial, - opts->keymaterial_len, - &datakey, - error)) { - GOTO (fail); - } - - if (!mongoc_collection_insert_one (client_encryption->keyvault_coll, - &datakey, - NULL /* opts */, - NULL /* reply */, - error)) { - GOTO (fail); - } - - if (keyid) { - bson_iter_t iter; - const bson_value_t *id_value; - - if (!bson_iter_init_find (&iter, &datakey, "_id")) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "data key not did not contain _id"); - GOTO (fail); - } else if (!BSON_ITER_HOLDS_BINARY (&iter)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "data key _id does not contain binary"); - GOTO (fail); - } else { - id_value = bson_iter_value (&iter); - bson_value_copy (id_value, keyid); - } - } - - ret = true; - -fail: - bson_destroy (&insert_opts); - bson_destroy (&datakey); - - RETURN (ret); -} - -bool -mongoc_client_encryption_rewrap_many_datakey ( - mongoc_client_encryption_t *client_encryption, - const bson_t *filter, - const char *provider, - const bson_t *master_key, - mongoc_client_encryption_rewrap_many_datakey_result_t *result, - bson_error_t *error) -{ - bson_t keys = BSON_INITIALIZER; - bson_t local_result = BSON_INITIALIZER; - bson_t *const bulk_write_result = - result ? &result->bulk_write_result : &local_result; - mongoc_bulk_operation_t *bulk = NULL; - bson_iter_t iter; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (client_encryption); - - BSON_ASSERT ( - _coll_has_read_concern_majority (client_encryption->keyvault_coll)); - BSON_ASSERT ( - _coll_has_write_concern_majority (client_encryption->keyvault_coll)); - - bson_reinit (bulk_write_result); - - if (master_key && !provider) { - bson_set_error ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "expected 'provider' to be set to identify type of 'master_key'"); - GOTO (fail); - } - - if (!_mongoc_crypt_rewrap_many_datakey (client_encryption->crypt, - client_encryption->keyvault_coll, - filter, - provider, - master_key, - &keys, - error)) { - GOTO (fail); - } - - /* No keys rewrapped, no key documents to update. */ - if (bson_empty (&keys)) { - bson_destroy (&keys); - bson_destroy (&local_result); - return true; - } - - bulk = mongoc_collection_create_bulk_operation_with_opts ( - client_encryption->keyvault_coll, NULL); - - BSON_ASSERT (bulk); - - if (!bson_iter_init_find (&iter, &keys, "v")) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "result did not contain expected field 'v'"); - GOTO (fail); - } - - if (!BSON_ITER_HOLDS_ARRAY (&iter)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "result did not return an array as expected"); - GOTO (fail); - } - - BSON_ASSERT (bson_iter_recurse (&iter, &iter)); - - while (bson_iter_next (&iter)) { - const uint8_t *data = NULL; - uint32_t len = 0u; - bson_t key; - bson_iter_t key_iter; - bson_subtype_t subtype; - bson_t selector = BSON_INITIALIZER; - bson_t document = BSON_INITIALIZER; - bool doc_success = false; - - bson_iter_document (&iter, &len, &data); - - if (!data || !bson_init_static (&key, data, len)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "element is not a valid BSON document"); - goto doc_done; - } - - /* Find _id and use as selector. */ - { - if (!bson_iter_init_find (&key_iter, &key, "_id")) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "could not find _id in key document"); - goto doc_done; - } - - bson_iter_binary (&key_iter, &subtype, &len, &data); - - if (!data || subtype != BSON_SUBTYPE_UUID) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "expected _id in key document to be a UUID"); - goto doc_done; - } - - BSON_ASSERT (bson_append_iter (&selector, "_id", 3, &key_iter)); - } - - /* Find and include potentially updated fields. */ - { - bson_t child; - - BSON_ASSERT (BSON_APPEND_DOCUMENT_BEGIN (&document, "$set", &child)); - { - if (bson_iter_init_find (&key_iter, &key, "masterKey")) { - BSON_ASSERT ( - bson_append_iter (&child, "masterKey", -1, &key_iter)); - } - - if (bson_iter_init_find (&key_iter, &key, "keyMaterial")) { - BSON_ASSERT ( - bson_append_iter (&child, "keyMaterial", -1, &key_iter)); - } - } - BSON_ASSERT (bson_append_document_end (&document, &child)); - } - - /* Update updateDate field. */ - BCON_APPEND ( - &document, "$currentDate", "{", "updateDate", BCON_BOOL (true), "}"); - - if (!mongoc_bulk_operation_update_one_with_opts ( - bulk, &selector, &document, NULL, error)) { - goto doc_done; - } - - doc_success = true; - - doc_done: - bson_destroy (&key); - bson_destroy (&selector); - bson_destroy (&document); - - if (!doc_success) { - GOTO (fail); - } - } - - if (!mongoc_bulk_operation_execute (bulk, bulk_write_result, error)) { - GOTO (fail); - } - - ret = true; - -fail: - bson_destroy (&keys); - bson_destroy (&local_result); - mongoc_bulk_operation_destroy (bulk); - - RETURN (ret); -} - -bool -mongoc_client_encryption_delete_key ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - bson_t *reply, - bson_error_t *error) -{ - bool ret = false; - bson_t selector = BSON_INITIALIZER; - - ENTRY; - - BSON_ASSERT_PARAM (client_encryption); - BSON_ASSERT_PARAM (keyid); - - BSON_ASSERT ( - _coll_has_write_concern_majority (client_encryption->keyvault_coll)); - - BSON_ASSERT (keyid->value_type == BSON_TYPE_BINARY); - BSON_ASSERT (keyid->value.v_binary.subtype == BSON_SUBTYPE_UUID); - BSON_ASSERT (keyid->value.v_binary.data_len > 0u); - - BSON_ASSERT (BSON_APPEND_BINARY (&selector, - "_id", - keyid->value.v_binary.subtype, - keyid->value.v_binary.data, - keyid->value.v_binary.data_len)); - - ret = mongoc_collection_delete_one ( - client_encryption->keyvault_coll, &selector, NULL, reply, error); - - bson_destroy (&selector); - - RETURN (ret); -} - -bool -mongoc_client_encryption_get_key (mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - bson_t *key_doc, - bson_error_t *error) -{ - bson_t filter = BSON_INITIALIZER; - mongoc_cursor_t *cursor = NULL; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (client_encryption); - BSON_ASSERT_PARAM (keyid); - - BSON_ASSERT (keyid->value_type == BSON_TYPE_BINARY); - BSON_ASSERT (keyid->value.v_binary.subtype == BSON_SUBTYPE_UUID); - BSON_ASSERT (keyid->value.v_binary.data_len > 0u); - - BSON_ASSERT (BSON_APPEND_BINARY (&filter, - "_id", - keyid->value.v_binary.subtype, - keyid->value.v_binary.data, - keyid->value.v_binary.data_len)); - - BSON_ASSERT ( - _coll_has_read_concern_majority (client_encryption->keyvault_coll)); - - _mongoc_bson_init_if_set (key_doc); - - cursor = mongoc_collection_find_with_opts ( - client_encryption->keyvault_coll, &filter, NULL, NULL); - - ret = !mongoc_cursor_error (cursor, error); - - if (ret && key_doc) { - const bson_t *bson = NULL; - - if (mongoc_cursor_next (cursor, &bson)) { - bson_copy_to (bson, key_doc); - } else if (mongoc_cursor_error (cursor, error)) { - ret = false; - } - } - - bson_destroy (&filter); - mongoc_cursor_destroy (cursor); - - RETURN (ret); -} - -mongoc_cursor_t * -mongoc_client_encryption_get_keys ( - mongoc_client_encryption_t *client_encryption, bson_error_t *error) -{ - mongoc_cursor_t *cursor = NULL; - bson_t filter = BSON_INITIALIZER; - - ENTRY; - - BSON_UNUSED (error); - - BSON_ASSERT_PARAM (client_encryption); - - BSON_ASSERT ( - _coll_has_read_concern_majority (client_encryption->keyvault_coll)); - - /* If an error occurred, user should query cursor error. */ - cursor = mongoc_collection_find_with_opts ( - client_encryption->keyvault_coll, &filter, NULL, NULL); - - bson_destroy (&filter); - - RETURN (cursor); -} - -bool -mongoc_client_encryption_add_key_alt_name ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - const char *keyaltname, - bson_t *key_doc, - bson_error_t *error) -{ - mongoc_find_and_modify_opts_t *const opts = - mongoc_find_and_modify_opts_new (); - bson_t query = BSON_INITIALIZER; - bool ret = false; - bson_t local_reply; - - ENTRY; - - BSON_ASSERT_PARAM (client_encryption); - BSON_ASSERT_PARAM (keyid); - BSON_ASSERT_PARAM (keyaltname); - - BSON_ASSERT ( - _coll_has_read_concern_majority (client_encryption->keyvault_coll)); - BSON_ASSERT ( - _coll_has_write_concern_majority (client_encryption->keyvault_coll)); - - BSON_ASSERT (keyid->value_type == BSON_TYPE_BINARY); - BSON_ASSERT (keyid->value.v_binary.subtype == BSON_SUBTYPE_UUID); - BSON_ASSERT (keyid->value.v_binary.data_len > 0u); - - BSON_ASSERT (BSON_APPEND_BINARY (&query, - "_id", - keyid->value.v_binary.subtype, - keyid->value.v_binary.data, - keyid->value.v_binary.data_len)); - - _mongoc_bson_init_if_set (key_doc); - - { - bson_t *const update = BCON_NEW ( - "$addToSet", "{", "keyAltNames", BCON_UTF8 (keyaltname), "}"); - BSON_ASSERT (mongoc_find_and_modify_opts_set_update (opts, update)); - bson_destroy (update); - } - - ret = mongoc_collection_find_and_modify_with_opts ( - client_encryption->keyvault_coll, &query, opts, &local_reply, error); - - if (ret && key_doc) { - bson_iter_t iter; - - if (bson_iter_init_find (&iter, &local_reply, "value")) { - const bson_value_t *const value = bson_iter_value (&iter); - - if (value->value_type == BSON_TYPE_DOCUMENT) { - bson_t bson; - BSON_ASSERT (bson_init_static ( - &bson, value->value.v_doc.data, value->value.v_doc.data_len)); - bson_copy_to (&bson, key_doc); - bson_destroy (&bson); - } else if (value->value_type == BSON_TYPE_NULL) { - bson_t bson = BSON_INITIALIZER; - bson_copy_to (&bson, key_doc); - bson_destroy (&bson); - } else { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "expected field value to be a document or null"); - ret = false; - } - } - } - - mongoc_find_and_modify_opts_destroy (opts); - bson_destroy (&query); - bson_destroy (&local_reply); - - RETURN (ret); -} - -bool -mongoc_client_encryption_remove_key_alt_name ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - const char *keyaltname, - bson_t *key_doc, - bson_error_t *error) -{ - bson_t query = BSON_INITIALIZER; - bool ret = false; - bson_t local_reply; - - ENTRY; - - BSON_ASSERT_PARAM (client_encryption); - BSON_ASSERT_PARAM (keyid); - BSON_ASSERT_PARAM (keyaltname); - - BSON_ASSERT ( - _coll_has_write_concern_majority (client_encryption->keyvault_coll)); - - BSON_ASSERT (keyid->value_type == BSON_TYPE_BINARY); - BSON_ASSERT (keyid->value.v_binary.subtype == BSON_SUBTYPE_UUID); - BSON_ASSERT (keyid->value.v_binary.data_len > 0u); - - BSON_ASSERT (BSON_APPEND_BINARY (&query, - "_id", - keyid->value.v_binary.subtype, - keyid->value.v_binary.data, - keyid->value.v_binary.data_len)); - - _mongoc_bson_init_if_set (key_doc); - - - { - mongoc_find_and_modify_opts_t *const opts = - mongoc_find_and_modify_opts_new (); - - /* clang-format off */ - bson_t *const update = BCON_NEW ( - "0", "{", - "$set", "{", - "keyAltNames", "{", - "$cond", "[", - "{", - "$eq", "[", "$keyAltNames", "[", keyaltname, "]", "]", - "}", - "$$REMOVE", - "{", - "$filter", "{", - "input", "$keyAltNames", - "cond", "{", - "$ne", "[", "$$this", keyaltname, "]", - "}", - "}", - "}", - "]", - "}", - "}", - "}"); - /* clang-format on */ - - BSON_ASSERT (mongoc_find_and_modify_opts_set_update (opts, update)); - - ret = mongoc_collection_find_and_modify_with_opts ( - client_encryption->keyvault_coll, &query, opts, &local_reply, error); - - bson_destroy (update); - mongoc_find_and_modify_opts_destroy (opts); - } - - if (ret && key_doc) { - bson_iter_t iter; - - if (bson_iter_init_find (&iter, &local_reply, "value")) { - const bson_value_t *const value = bson_iter_value (&iter); - - if (value->value_type == BSON_TYPE_DOCUMENT) { - bson_t bson; - BSON_ASSERT (bson_init_static ( - &bson, value->value.v_doc.data, value->value.v_doc.data_len)); - bson_copy_to (&bson, key_doc); - bson_destroy (&bson); - } else if (value->value_type == BSON_TYPE_NULL) { - bson_t bson = BSON_INITIALIZER; - bson_copy_to (&bson, key_doc); - bson_destroy (&bson); - } else { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "expected field value to be a document or null"); - ret = false; - } - } - } - - bson_destroy (&query); - bson_destroy (&local_reply); - - RETURN (ret); -} - -bool -mongoc_client_encryption_get_key_by_alt_name ( - mongoc_client_encryption_t *client_encryption, - const char *keyaltname, - bson_t *key_doc, - bson_error_t *error) -{ - bson_t filter = BSON_INITIALIZER; - mongoc_cursor_t *cursor = NULL; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (client_encryption); - BSON_ASSERT_PARAM (keyaltname); - - BSON_ASSERT ( - _coll_has_write_concern_majority (client_encryption->keyvault_coll)); - - BSON_ASSERT (BSON_APPEND_UTF8 (&filter, "keyAltNames", keyaltname)); - - _mongoc_bson_init_if_set (key_doc); - - cursor = mongoc_collection_find_with_opts ( - client_encryption->keyvault_coll, &filter, NULL, NULL); - - ret = !mongoc_cursor_error (cursor, error); - - if (ret && key_doc) { - const bson_t *bson = NULL; - - if (mongoc_cursor_next (cursor, &bson)) { - bson_copy_to (bson, key_doc); - } else if (mongoc_cursor_error (cursor, error)) { - ret = false; - } - } - - bson_destroy (&filter); - mongoc_cursor_destroy (cursor); - - RETURN (ret); -} - -bool -mongoc_client_encryption_encrypt (mongoc_client_encryption_t *client_encryption, - const bson_value_t *value, - mongoc_client_encryption_encrypt_opts_t *opts, - bson_value_t *ciphertext, - bson_error_t *error) -{ - bool ret = false; - bson_t *range_opts = NULL; - - ENTRY; - - BSON_ASSERT (client_encryption); - - if (!ciphertext) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "required 'ciphertext' unset"); - GOTO (fail); - } - /* reset, so it is safe for caller to call bson_value_destroy on error or - * success. */ - ciphertext->value_type = BSON_TYPE_EOD; - - if (!opts) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "required 'opts' unset"); - GOTO (fail); - } - - if (opts->range_opts) { - range_opts = bson_new (); - append_bson_range_opts (range_opts, opts); - } - - if (!_mongoc_crypt_explicit_encrypt ( - client_encryption->crypt, - client_encryption->keyvault_coll, - opts->algorithm, - &opts->keyid, - opts->keyaltname, - opts->query_type, - opts->contention_factor.set ? &opts->contention_factor.value : NULL, - range_opts, - value, - ciphertext, - error)) { - GOTO (fail); - } - - ret = true; -fail: - bson_destroy (range_opts); - RETURN (ret); -} - - -bool -mongoc_client_encryption_encrypt_expression ( - mongoc_client_encryption_t *client_encryption, - const bson_t *expr, - mongoc_client_encryption_encrypt_opts_t *opts, - bson_t *expr_out, - bson_error_t *error) -{ - ENTRY; - - BSON_ASSERT_PARAM (client_encryption); - BSON_ASSERT_PARAM (expr); - BSON_ASSERT_PARAM (opts); - BSON_ASSERT_PARAM (expr_out); - BSON_ASSERT (error || true); - - bson_init (expr_out); - - bson_t *range_opts = NULL; - if (opts->range_opts) { - range_opts = bson_new (); - append_bson_range_opts (range_opts, opts); - } - - if (!_mongoc_crypt_explicit_encrypt_expression ( - client_encryption->crypt, - client_encryption->keyvault_coll, - opts->algorithm, - &opts->keyid, - opts->keyaltname, - opts->query_type, - opts->contention_factor.set ? &opts->contention_factor.value : NULL, - range_opts, - expr, - expr_out, - error)) { - bson_destroy (range_opts); - RETURN (false); - } - bson_destroy (range_opts); - RETURN (true); -} - -bool -mongoc_client_encryption_decrypt (mongoc_client_encryption_t *client_encryption, - const bson_value_t *ciphertext, - bson_value_t *value, - bson_error_t *error) -{ - bool ret = false; - - ENTRY; - - BSON_ASSERT (client_encryption); - - if (!value) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "required 'value' unset"); - GOTO (fail); - } - - /* reset, so it is safe for caller to call bson_value_destroy on error or - * success. */ - value->value_type = BSON_TYPE_EOD; - - if (ciphertext->value_type != BSON_TYPE_BINARY || - ciphertext->value.v_binary.subtype != BSON_SUBTYPE_ENCRYPTED) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "ciphertext must be BSON binary subtype 6"); - GOTO (fail); - } - - if (!_mongoc_crypt_explicit_decrypt (client_encryption->crypt, - client_encryption->keyvault_coll, - ciphertext, - value, - error)) { - GOTO (fail); - } - - ret = true; -fail: - RETURN (ret); -} - -bool -_mongoc_cse_is_enabled (mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (client); - - while (1) { - mongoc_topology_cse_state_t state = bson_atomic_int_fetch ( - (int *) &client->topology->cse_state, bson_memory_order_relaxed); - if (state != MONGOC_CSE_STARTING) { - return state == MONGOC_CSE_ENABLED; - } - /* CSE is starting up. Wait until that succeeds or fails. */ - bson_thrd_yield (); - } -} - -/// Context for creating a new datakey using an existing ClientEncryption state -struct cec_context { - mongoc_client_encryption_t *enc; - const mongoc_client_encryption_datakey_opts_t *dk_opts; - const char *kms_provider; -}; - -/// Automatically create a new datakey. @see auto_datakey_factory -static bool -_auto_datakey (struct auto_datakey_context *ctx) -{ - struct cec_context *cec = ctx->userdata; - return mongoc_client_encryption_create_datakey (cec->enc, - cec->kms_provider, - cec->dk_opts, - ctx->out_keyid, - ctx->out_error); -} - -mongoc_collection_t * -mongoc_client_encryption_create_encrypted_collection ( - mongoc_client_encryption_t *enc, - struct _mongoc_database_t *database, - const char *name, - const bson_t *in_options, - bson_t *opt_out_options, - const char *const kms_provider, - const bson_t *opt_masterkey, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (enc); - BSON_ASSERT_PARAM (database); - BSON_ASSERT_PARAM (name); - BSON_ASSERT_PARAM (in_options); - BSON_ASSERT (opt_out_options || true); - BSON_ASSERT_PARAM (kms_provider); - BSON_ASSERT (error || true); - - mongoc_collection_t *ret = NULL; - - bson_t in_encryptedFields = BSON_INITIALIZER; - bson_t new_encryptedFields = BSON_INITIALIZER; - bson_t local_new_options = BSON_INITIALIZER; - - mongoc_client_encryption_datakey_opts_t *dk_opts = - mongoc_client_encryption_datakey_opts_new (); - if (opt_masterkey) { - mongoc_client_encryption_datakey_opts_set_masterkey (dk_opts, - opt_masterkey); - } - - if (!opt_out_options) { - // We'll use our own storage for the new options - opt_out_options = &local_new_options; - } - - // Init the storage. Either inits the caller's copy, or our local version. - bson_init (opt_out_options); - - // Look up the encryptedfields that we should use for this collection. They - // may be in the given options, or they may be in the encryptedFieldsMap. - if (!_mongoc_get_collection_encryptedFields ( - database->client, - mongoc_database_get_name (database), - name, - in_options, - false /* checkEncryptedFieldsMap */, - &in_encryptedFields, - error)) { - // Error finding the encryptedFields - goto done; - } - - if (bson_empty (&in_encryptedFields)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "No 'encryptedFields' are defined for the creation of " - "the '%s' collection", - name); - goto done; - } - - // Add the keyIds to the encryptedFields. - // Context for the creation of new datakeys: - struct cec_context ctx = { - .enc = enc, - .dk_opts = dk_opts, - .kms_provider = kms_provider, - }; - bson_t fields_ref; - bsonVisitEach ( - in_encryptedFields, - case ( - // We only care about the "fields" array - when (not(key ("fields")), appendTo (new_encryptedFields)), - // Automaticall fill in the "keyId" no each field: - else ( - storeDocRef (fields_ref), do ({ - bson_t new_fields = BSON_INITIALIZER; - // Create the new fields, filling out the 'keyId' - // automatically: - if (!_mongoc_encryptedFields_fill_auto_datakeys ( - &new_fields, &fields_ref, _auto_datakey, &ctx, error)) { - bsonParseError = "Error creating datakeys"; - } else { - BSON_APPEND_ARRAY ( - &new_encryptedFields, "fields", &new_fields); - bson_destroy (&new_fields); - } - })))); - if (bsonParseError) { - // Error creating the new datakeys. - // `error` was set by _mongoc_encryptedFields_fill_auto_datakeys - goto done; - } - - // We've successfully filled out all null keyIds. Now create the collection - // with our new options: - bsonBuild (*opt_out_options, - insert (*in_options, not(key ("encryptedFields"))), - kv ("encryptedFields", bson (new_encryptedFields))); - if (bsonBuildError) { - // Error while building the new options. - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Error while building new createCollection options: %s", - bsonBuildError); - goto done; - } - - ret = mongoc_database_create_collection ( - database, name, opt_out_options, error); - -done: - bson_destroy (&new_encryptedFields); - bson_destroy (&in_encryptedFields); - mongoc_client_encryption_datakey_opts_destroy (dk_opts); - // Destroy the local options, which may or may not have been used. If unused, - // the new options are now owned by the caller and this is a no-op. - bson_destroy (&local_new_options); - // The resulting collection, or NULL on error: - return ret; -} - -#endif /* MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION */ - -/// Generate one encryptedField element. -static void -_init_1_encryptedField (bson_t *out_field, - const bson_t *in_field, - auto_datakey_factory fac, - void *fac_userdata, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (out_field); - BSON_ASSERT_PARAM (in_field); - BSON_ASSERT_PARAM (fac); - BSON_ASSERT (fac_userdata || true); - BSON_ASSERT (error || true); - bsonVisitEach ( - *in_field, - // If it is not a "keyId":null element, just copy it to the output. - if (not(keyWithType ("keyId", null)), - then (appendTo (*out_field), continue)), - // Otherwise: - do ({ - // Set up factory context - bson_value_t new_key = {0}; - struct auto_datakey_context ctx = { - .out_keyid = &new_key, - .out_error = error, - .userdata = fac_userdata, - }; - // Call the callback to create the new key - if (!fac (&ctx)) { - bsonParseError = "Factory function indicated failure"; - } else { - // Append to the field - BSON_APPEND_VALUE (out_field, "keyId", &new_key); - } - bson_value_destroy (&new_key); - })); -} - -/// Generate the "encryptedFields" output for auto-datakeys -static void -_init_encryptedFields (bson_t *out_fields, - const bson_t *in_fields, - auto_datakey_factory fac, - void *fac_userdata, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (out_fields); - BSON_ASSERT_PARAM (in_fields); - BSON_ASSERT_PARAM (fac); - BSON_ASSERT (fac_userdata || true); - BSON_ASSERT (error || true); - // Ref to one encyrptedField - bson_t cur_field; - bsonVisitEach ( - *in_fields, - // Each field must be a document element - if (not(type (doc)), - then (error ("Each 'encryptedFields' element must be a document"))), - // Append a new element with the same name as the field: - storeDocRef (cur_field), - append ( - *out_fields, - kv ( - bson_iter_key (&bsonVisitIter), - // Construct the encryptedField document from the input: - doc (do (_init_1_encryptedField ( - bsonBuildContext.doc, &cur_field, fac, fac_userdata, error)))))); - if (error && error->code == 0) { - // The factory/internal code did not set error, so we may have to set it - // for an error while BSON parsing/generating. - if (bsonParseError) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Error while generating datakeys: %s", - bsonParseError); - } - if (bsonBuildError) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Error while generating datakeys: %s", - bsonBuildError); - } - } -} - -bool -_mongoc_encryptedFields_fill_auto_datakeys (bson_t *out_fields, - const bson_t *in_fields, - auto_datakey_factory factory, - void *userdata, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (in_fields); - BSON_ASSERT_PARAM (out_fields); - BSON_ASSERT_PARAM (factory); - - if (error) { - *error = (bson_error_t){0}; - } - bson_init (out_fields); - - _init_encryptedFields (out_fields, in_fields, factory, userdata, error); - - // DSL errors will be set in case of failure - return bsonParseError == NULL && bsonBuildError == NULL; -} - -const char * -mongoc_client_encryption_get_crypt_shared_version ( - const mongoc_client_encryption_t *enc) -{ -#ifdef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION - return _mongoc_crypt_get_crypt_shared_version (enc->crypt); -#else - BSON_UNUSED (enc); - return NULL; -#endif -} - -const char * -mongoc_client_get_crypt_shared_version (const mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (client); - -#ifdef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION - if (!client->topology->crypt) { - return NULL; - } - return _mongoc_crypt_get_crypt_shared_version (client->topology->crypt); -#else - BSON_UNUSED (client); - return NULL; -#endif -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-side-encryption.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-side-encryption.h deleted file mode 100644 index 3a1e81806..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client-side-encryption.h +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright 2019-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_CLIENT_SIDE_ENCRYPTION_H -#define MONGOC_CLIENT_SIDE_ENCRYPTION_H - -#include - -/* Forward declare */ -struct _mongoc_client_t; -struct _mongoc_client_pool_t; -struct _mongoc_cursor_t; - -struct _mongoc_collection_t; -struct _mongoc_database_t; - -#define MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM \ - "AEAD_AES_256_CBC_HMAC_SHA_512-Random" -#define MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC \ - "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" -#define MONGOC_ENCRYPT_ALGORITHM_INDEXED "Indexed" -#define MONGOC_ENCRYPT_ALGORITHM_UNINDEXED "Unindexed" -#define MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW "RangePreview" - -#define MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY "equality" -#define MONGOC_ENCRYPT_QUERY_TYPE_RANGEPREVIEW "rangePreview" - - -BSON_BEGIN_DECLS - -typedef struct _mongoc_auto_encryption_opts_t mongoc_auto_encryption_opts_t; - -typedef bool (*mongoc_kms_credentials_provider_callback_fn) ( - void *userdata, const bson_t *params, bson_t *out, bson_error_t *error); - -MONGOC_EXPORT (mongoc_auto_encryption_opts_t *) -mongoc_auto_encryption_opts_new (void) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_destroy (mongoc_auto_encryption_opts_t *opts); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_keyvault_client ( - mongoc_auto_encryption_opts_t *opts, struct _mongoc_client_t *client); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_keyvault_client_pool ( - mongoc_auto_encryption_opts_t *opts, struct _mongoc_client_pool_t *pool); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_keyvault_namespace ( - mongoc_auto_encryption_opts_t *opts, const char *db, const char *coll); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_kms_providers ( - mongoc_auto_encryption_opts_t *opts, const bson_t *kms_providers); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_tls_opts (mongoc_auto_encryption_opts_t *opts, - const bson_t *tls_opts); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_schema_map (mongoc_auto_encryption_opts_t *opts, - const bson_t *schema_map); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_encrypted_fields_map ( - mongoc_auto_encryption_opts_t *opts, const bson_t *encrypted_fields_map); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_bypass_auto_encryption ( - mongoc_auto_encryption_opts_t *opts, bool bypass_auto_encryption); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_bypass_query_analysis ( - mongoc_auto_encryption_opts_t *opts, bool bypass_query_analysis); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_extra (mongoc_auto_encryption_opts_t *opts, - const bson_t *extra); - -MONGOC_EXPORT (void) -mongoc_auto_encryption_opts_set_kms_credential_provider_callback ( - mongoc_auto_encryption_opts_t *opts, - mongoc_kms_credentials_provider_callback_fn fn, - void *userdata); - -typedef struct _mongoc_client_encryption_opts_t mongoc_client_encryption_opts_t; -typedef struct _mongoc_client_encryption_t mongoc_client_encryption_t; -typedef struct _mongoc_client_encryption_encrypt_range_opts_t - mongoc_client_encryption_encrypt_range_opts_t; -typedef struct _mongoc_client_encryption_encrypt_opts_t - mongoc_client_encryption_encrypt_opts_t; -typedef struct _mongoc_client_encryption_datakey_opts_t - mongoc_client_encryption_datakey_opts_t; -typedef struct _mongoc_client_encryption_rewrap_many_datakey_result_t - mongoc_client_encryption_rewrap_many_datakey_result_t; - -MONGOC_EXPORT (mongoc_client_encryption_opts_t *) -mongoc_client_encryption_opts_new (void) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (void) -mongoc_client_encryption_opts_destroy (mongoc_client_encryption_opts_t *opts); - -MONGOC_EXPORT (void) -mongoc_client_encryption_opts_set_keyvault_client ( - mongoc_client_encryption_opts_t *opts, - struct _mongoc_client_t *keyvault_client); - -MONGOC_EXPORT (void) -mongoc_client_encryption_opts_set_keyvault_namespace ( - mongoc_client_encryption_opts_t *opts, const char *db, const char *coll); - -MONGOC_EXPORT (void) -mongoc_client_encryption_opts_set_kms_providers ( - mongoc_client_encryption_opts_t *opts, const bson_t *kms_providers); - -MONGOC_EXPORT (void) -mongoc_client_encryption_opts_set_tls_opts ( - mongoc_client_encryption_opts_t *opts, const bson_t *tls_opts); - -MONGOC_EXPORT (void) -mongoc_client_encryption_opts_set_kms_credential_provider_callback ( - mongoc_client_encryption_opts_t *opts, - mongoc_kms_credentials_provider_callback_fn fn, - void *userdata); - -MONGOC_EXPORT (mongoc_client_encryption_rewrap_many_datakey_result_t *) -mongoc_client_encryption_rewrap_many_datakey_result_new (void) - BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (void) -mongoc_client_encryption_rewrap_many_datakey_result_destroy ( - mongoc_client_encryption_rewrap_many_datakey_result_t *result); - -MONGOC_EXPORT (const bson_t *) -mongoc_client_encryption_rewrap_many_datakey_result_get_bulk_write_result ( - mongoc_client_encryption_rewrap_many_datakey_result_t *result) - BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (mongoc_client_encryption_t *) -mongoc_client_encryption_new (mongoc_client_encryption_opts_t *opts, - bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (void) -mongoc_client_encryption_destroy ( - mongoc_client_encryption_t *client_encryption); - -MONGOC_EXPORT (bool) -mongoc_client_encryption_create_datakey ( - mongoc_client_encryption_t *client_encryption, - const char *kms_provider, - const mongoc_client_encryption_datakey_opts_t *opts, - bson_value_t *keyid, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_encryption_rewrap_many_datakey ( - mongoc_client_encryption_t *client_encryption, - const bson_t *filter, - const char *provider, - const bson_t *master_key, - mongoc_client_encryption_rewrap_many_datakey_result_t *result, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_encryption_delete_key ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - bson_t *reply, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_encryption_get_key (mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - bson_t *key_doc, - bson_error_t *error); - -MONGOC_EXPORT (struct _mongoc_cursor_t *) -mongoc_client_encryption_get_keys ( - mongoc_client_encryption_t *client_encryption, bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_encryption_add_key_alt_name ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - const char *keyaltname, - bson_t *key_doc, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_encryption_remove_key_alt_name ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *keyid, - const char *keyaltname, - bson_t *key_doc, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_encryption_get_key_by_alt_name ( - mongoc_client_encryption_t *client_encryption, - const char *keyaltname, - bson_t *key_doc, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_encryption_encrypt (mongoc_client_encryption_t *client_encryption, - const bson_value_t *value, - mongoc_client_encryption_encrypt_opts_t *opts, - bson_value_t *ciphertext, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_encryption_encrypt_expression ( - mongoc_client_encryption_t *client_encryption, - const bson_t *expr, - mongoc_client_encryption_encrypt_opts_t *opts, - bson_t *expr_out, - bson_error_t *error); - -MONGOC_EXPORT (bool) -mongoc_client_encryption_decrypt (mongoc_client_encryption_t *client_encryption, - const bson_value_t *ciphertext, - bson_value_t *value, - bson_error_t *error); - -MONGOC_EXPORT (mongoc_client_encryption_encrypt_opts_t *) -mongoc_client_encryption_encrypt_opts_new (void) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_opts_destroy ( - mongoc_client_encryption_encrypt_opts_t *opts); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_opts_set_keyid ( - mongoc_client_encryption_encrypt_opts_t *opts, const bson_value_t *keyid); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_opts_set_keyaltname ( - mongoc_client_encryption_encrypt_opts_t *opts, const char *keyaltname); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_opts_set_algorithm ( - mongoc_client_encryption_encrypt_opts_t *opts, const char *algorithm); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_opts_set_contention_factor ( - mongoc_client_encryption_encrypt_opts_t *opts, int64_t contention_factor); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_opts_set_query_type ( - mongoc_client_encryption_encrypt_opts_t *opts, const char *query_type); - -MONGOC_EXPORT (mongoc_client_encryption_encrypt_range_opts_t *) -mongoc_client_encryption_encrypt_range_opts_new (void); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_range_opts_destroy ( - mongoc_client_encryption_encrypt_range_opts_t *range_opts); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_range_opts_set_sparsity ( - mongoc_client_encryption_encrypt_range_opts_t *range_opts, int64_t sparsity); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_range_opts_set_min ( - mongoc_client_encryption_encrypt_range_opts_t *range_opts, - const bson_value_t *min); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_range_opts_set_max ( - mongoc_client_encryption_encrypt_range_opts_t *range_opts, - const bson_value_t *max); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_range_opts_set_precision ( - mongoc_client_encryption_encrypt_range_opts_t *range_opts, - int32_t precision); - -MONGOC_EXPORT (void) -mongoc_client_encryption_encrypt_opts_set_range_opts ( - mongoc_client_encryption_encrypt_opts_t *opts, - const mongoc_client_encryption_encrypt_range_opts_t *range_opts); - -MONGOC_EXPORT (mongoc_client_encryption_datakey_opts_t *) -mongoc_client_encryption_datakey_opts_new (void) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (void) -mongoc_client_encryption_datakey_opts_destroy ( - mongoc_client_encryption_datakey_opts_t *opts); - -MONGOC_EXPORT (void) -mongoc_client_encryption_datakey_opts_set_masterkey ( - mongoc_client_encryption_datakey_opts_t *opts, const bson_t *masterkey); - -MONGOC_EXPORT (void) -mongoc_client_encryption_datakey_opts_set_keyaltnames ( - mongoc_client_encryption_datakey_opts_t *opts, - char **keyaltnames, - uint32_t keyaltnames_count); - -MONGOC_EXPORT (void) -mongoc_client_encryption_datakey_opts_set_keymaterial ( - mongoc_client_encryption_datakey_opts_t *opts, - const uint8_t *data, - uint32_t len); - -MONGOC_EXPORT (const char *) -mongoc_client_encryption_get_crypt_shared_version ( - mongoc_client_encryption_t const *enc) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (struct _mongoc_collection_t *) -mongoc_client_encryption_create_encrypted_collection ( - mongoc_client_encryption_t *enc, - struct _mongoc_database_t *database, - const char *name, - const bson_t *in_options, - bson_t *opt_out_options, - const char *const kms_provider, - const bson_t *opt_masterkey, - bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; - -BSON_END_DECLS - -#endif /* MONGOC_CLIENT_SIDE_ENCRYPTION_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client.c deleted file mode 100644 index 7066d4e8d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client.c +++ /dev/null @@ -1,3265 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "mongoc-config.h" -#ifdef MONGOC_HAVE_DNSAPI -/* for DnsQuery_UTF8 */ -#include -#include -#include -#else -#if defined(MONGOC_HAVE_RES_NSEARCH) || defined(MONGOC_HAVE_RES_SEARCH) -#include -#include -#include -#include -#include -#define BSON_INSIDE -#include -#undef BSON_INSIDE - -#endif -#endif - -#include "mongoc-client-private.h" -#include "mongoc-client-side-encryption-private.h" -#include "mongoc-collection-private.h" -#include "mongoc-counters-private.h" -#include "mongoc-database-private.h" -#include "mongoc-gridfs-private.h" -#include "mongoc-error.h" -#include "mongoc-error-private.h" -#include "mongoc-log.h" -#include "mongoc-queue-private.h" -#include "mongoc-socket.h" -#include "mongoc-stream-buffered.h" -#include "mongoc-stream-socket.h" -#include "mongoc-thread-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-uri-private.h" -#include "mongoc-util-private.h" -#include "mongoc-set-private.h" -#include "mongoc-log.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-read-concern-private.h" -#include "mongoc-host-list-private.h" -#include "mongoc-read-prefs-private.h" -#include "mongoc-change-stream-private.h" -#include "mongoc-client-session-private.h" -#include "mongoc-cursor-private.h" - -#ifdef MONGOC_ENABLE_SSL -#include "mongoc-stream-tls.h" -#include "mongoc-ssl-private.h" -#include "mongoc-cmd-private.h" -#include "mongoc-opts-private.h" -#endif - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "client" - - -static void -_mongoc_client_op_killcursors (mongoc_cluster_t *cluster, - mongoc_server_stream_t *server_stream, - int64_t cursor_id, - int64_t operation_id, - const char *db, - const char *collection); - -static void -_mongoc_client_killcursors_command (mongoc_cluster_t *cluster, - mongoc_server_stream_t *server_stream, - int64_t cursor_id, - const char *db, - const char *collection, - mongoc_client_session_t *cs); - -#define DNS_ERROR(_msg, ...) \ - do { \ - bson_set_error (error, \ - MONGOC_ERROR_STREAM, \ - MONGOC_ERROR_STREAM_NAME_RESOLUTION, \ - _msg, \ - __VA_ARGS__); \ - GOTO (done); \ - } while (0) - - -#if MONGOC_ENABLE_SRV == 0 // ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ ENABLE_SRV disabled - -/* SRV support is disabled */ - -#elif defined(MONGOC_HAVE_DNSAPI) // ↑↑↑ ENABLE_SRV disabled / Win32 Dnsapi ↓↓↓↓ - -typedef bool (*mongoc_rr_callback_t) (const char *hostname, - PDNS_RECORD pdns, - mongoc_rr_data_t *rr_data, - bson_error_t *error); - -static bool -srv_callback (const char *hostname, - PDNS_RECORD pdns, - mongoc_rr_data_t *rr_data, - bson_error_t *error) -{ - mongoc_host_list_t new_host; - - if (rr_data && rr_data->hosts) { - _mongoc_host_list_remove_host ( - &(rr_data->hosts), pdns->Data.SRV.pNameTarget, pdns->Data.SRV.wPort); - } - - if (!_mongoc_host_list_from_hostport_with_err ( - &new_host, pdns->Data.SRV.pNameTarget, pdns->Data.SRV.wPort, error)) { - return false; - } - _mongoc_host_list_upsert (&rr_data->hosts, &new_host); - - return true; -} - -/* rr_data is unused, but here to match srv_callback signature */ -static bool -txt_callback (const char *hostname, - PDNS_RECORD pdns, - mongoc_rr_data_t *rr_data, - bson_error_t *error) -{ - DWORD i; - bson_string_t *txt; - - txt = bson_string_new (NULL); - - for (i = 0; i < pdns->Data.TXT.dwStringCount; i++) { - bson_string_append (txt, pdns->Data.TXT.pStringArray[i]); - } - - rr_data->txt_record_opts = bson_strdup (txt->str); - bson_string_free (txt, true); - - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_get_rr_dnsapi -- - * - * Fetch SRV or TXT resource records using the Windows DNS API and - * put results in @rr_data. - * - * Returns: - * Success or failure. - * - * For an SRV lookup, returns false if there is any error. - * - * For TXT lookup, ignores any error fetching the resource record and - * always returns true. - * - * Side effects: - * @error is set if there is a failure. - * @rr_data->hosts may be set if querying SRV. Caller must destroy. - * @rr_data->txt_record_opts may be set if querying TXT. Caller must - * free. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_get_rr_dnsapi (const char *hostname, - mongoc_rr_type_t rr_type, - mongoc_rr_data_t *rr_data, - bson_error_t *error) -{ - const char *rr_type_name; - WORD nst; - mongoc_rr_callback_t callback; - PDNS_RECORD pdns = NULL; - DNS_STATUS res; - LPVOID lpMsgBuf = NULL; - bool dns_success; - bool callback_success = true; - int i; - - ENTRY; - - if (rr_type == MONGOC_RR_SRV) { - /* return true only if DNS succeeds */ - dns_success = false; - rr_type_name = "SRV"; - nst = DNS_TYPE_SRV; - callback = srv_callback; - } else { - /* return true whether or not DNS succeeds */ - dns_success = true; - rr_type_name = "TXT"; - nst = DNS_TYPE_TEXT; - callback = txt_callback; - } - - res = DnsQuery_UTF8 (hostname, - nst, - DNS_QUERY_BYPASS_CACHE, - NULL /* IP Address */, - &pdns, - 0 /* reserved */); - - if (res) { - DWORD flags = FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; - - if (FormatMessage (flags, - 0, - res, - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &lpMsgBuf, - 0, - 0)) { - DNS_ERROR ("Failed to look up %s record \"%s\": %s", - rr_type_name, - hostname, - (char *) lpMsgBuf); - } - - DNS_ERROR ("Failed to look up %s record \"%s\": Unknown error", - rr_type_name, - hostname); - } - - if (!pdns) { - DNS_ERROR ("No %s records for \"%s\"", rr_type_name, hostname); - } - - i = 0; - - do { - /* DnsQuery can return additional records not of the requested type */ - if ((rr_type == MONGOC_RR_TXT && pdns->wType == DNS_TYPE_TEXT) || - (rr_type == MONGOC_RR_SRV && pdns->wType == DNS_TYPE_SRV)) { - if (i > 0 && rr_type == MONGOC_RR_TXT) { - /* Initial DNS Seedlist Discovery Spec: a client "MUST raise an - error when multiple TXT records are encountered". */ - callback_success = false; - DNS_ERROR ("Multiple TXT records for \"%s\"", hostname); - } - - if (rr_data) { - if ((i == 0) || (pdns->dwTtl < rr_data->min_ttl)) { - rr_data->min_ttl = pdns->dwTtl; - } - } - - if (!callback (hostname, pdns, rr_data, error)) { - callback_success = false; - GOTO (done); - } - - i++; - } - - pdns = pdns->pNext; - } while (pdns); - - - rr_data->count = i; - if (i == 0) { - DNS_ERROR ("No matching %s records for \"%s\"", rr_type_name, hostname); - } - dns_success = true; - -done: - if (pdns) { - DnsRecordListFree (pdns, DnsFreeRecordList); - } - - if (lpMsgBuf) { - LocalFree (lpMsgBuf); - } - - RETURN (dns_success && callback_success); -} - -#elif ( \ - defined(MONGOC_HAVE_RES_NSEARCH) || \ - defined(MONGOC_HAVE_RES_SEARCH)) // ↑↑↑↑↑↑↑ Win32 Dnsapi / resolv ↓↓↓↓↓↓↓↓ - -typedef bool (*mongoc_rr_callback_t) (const char *hostname, - ns_msg *ns_answer, - ns_rr *rr, - mongoc_rr_data_t *rr_data, - bson_error_t *error); - -static const char * -_mongoc_hstrerror (int code) -{ - switch (code) { - case HOST_NOT_FOUND: - return "The specified host is unknown."; - case NO_ADDRESS: - return "The requested name is valid but does not have an IP address."; - case NO_RECOVERY: - return "A nonrecoverable name server error occurred."; - case TRY_AGAIN: - return "A temporary error occurred on an authoritative name server. Try " - "again later."; - default: - return "An unknown error occurred."; - } -} - -static bool -srv_callback (const char *hostname, - ns_msg *ns_answer, - ns_rr *rr, - mongoc_rr_data_t *rr_data, - bson_error_t *error) -{ - const uint8_t *data; - char name[1024]; - uint16_t port; - int size; - bool ret = false; - mongoc_host_list_t new_host; - - data = ns_rr_rdata (*rr); - /* memcpy the network endian port before converting to host endian. we cannot - * cast (data + 4) directly as a uint16_t*, because it may not align on an - * 2-byte boundary. */ - memcpy (&port, data + 4, sizeof (port)); - port = ntohs (port); - size = dn_expand (ns_msg_base (*ns_answer), - ns_msg_end (*ns_answer), - data + 6, - name, - sizeof (name)); - - if (size < 1) { - DNS_ERROR ("Invalid record in SRV answer for \"%s\": \"%s\"", - hostname, - _mongoc_hstrerror (h_errno)); - } - - if (!_mongoc_host_list_from_hostport_with_err ( - &new_host, name, port, error)) { - GOTO (done); - } - _mongoc_host_list_upsert (&rr_data->hosts, &new_host); - ret = true; -done: - return ret; -} - -static bool -txt_callback (const char *hostname, - ns_msg *ns_answer, - ns_rr *rr, - mongoc_rr_data_t *rr_data, - bson_error_t *error) -{ - char s[256]; - const uint8_t *data; - bson_string_t *txt; - uint16_t pos, total; - uint8_t len; - bool ret = false; - - BSON_UNUSED (ns_answer); - - total = (uint16_t) ns_rr_rdlen (*rr); - if (total < 1 || total > 255) { - DNS_ERROR ("Invalid TXT record size %hu for \"%s\"", total, hostname); - } - - /* a TXT record has one or more strings, each up to 255 chars, each is - * prefixed by its length as 1 byte. thus endianness doesn't matter. */ - txt = bson_string_new (NULL); - pos = 0; - data = ns_rr_rdata (*rr); - - while (pos < total) { - memcpy (&len, data + pos, sizeof (uint8_t)); - pos++; - bson_strncpy (s, (const char *) (data + pos), (size_t) len + 1); - bson_string_append (txt, s); - pos += len; - } - - rr_data->txt_record_opts = bson_strdup (txt->str); - bson_string_free (txt, true); - ret = true; - -done: - return ret; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_get_rr_search -- - * - * Fetch SRV or TXT resource records using libresolv and put results in - * @rr_data. - * - * Returns: - * Success or failure. - * - * For an SRV lookup, returns false if there is any error. - * - * For TXT lookup, ignores any error fetching the resource record and - * always returns true. - * - * Side effects: - * @error is set if there is a failure. - * @rr_data->hosts may be set if querying SRV. Caller must destroy. - * @rr_data->txt_record_opts may be set if querying TXT. Caller must - * free. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_get_rr_search (const char *hostname, - mongoc_rr_type_t rr_type, - mongoc_rr_data_t *rr_data, - size_t initial_buffer_size, - bson_error_t *error) -{ -#ifdef MONGOC_HAVE_RES_NSEARCH - struct __res_state state = {0}; -#endif - int size = 0; - unsigned char *search_buf = NULL; - size_t buffer_size = initial_buffer_size; - ns_msg ns_answer; - int n; - int i; - const char *rr_type_name; - ns_type nst; - mongoc_rr_callback_t callback; - ns_rr resource_record; - bool dns_success; - bool callback_success = true; - int num_matching_records; - uint32_t ttl; - - ENTRY; - - if (rr_type == MONGOC_RR_SRV) { - /* return true only if DNS succeeds */ - dns_success = false; - rr_type_name = "SRV"; - nst = ns_t_srv; - callback = srv_callback; - } else { - /* return true whether or not DNS succeeds */ - dns_success = true; - rr_type_name = "TXT"; - nst = ns_t_txt; - callback = txt_callback; - } - - do { - if (search_buf) { - bson_free (search_buf); - - /* increase buffer size by the previous response size. This ensures - * that even if a subsequent response is larger, we'll still be able - * to fit it in the response buffer */ - buffer_size = buffer_size + size; - } - - search_buf = (unsigned char *) bson_malloc (buffer_size); - BSON_ASSERT (search_buf); - -#ifdef MONGOC_HAVE_RES_NSEARCH - /* thread-safe */ - res_ninit (&state); - size = - res_nsearch (&state, hostname, ns_c_in, nst, search_buf, buffer_size); -#elif defined(MONGOC_HAVE_RES_SEARCH) - size = res_search (hostname, ns_c_in, nst, search_buf, buffer_size); -#endif - - if (size < 0) { - DNS_ERROR ("Failed to look up %s record \"%s\": %s", - rr_type_name, - hostname, - _mongoc_hstrerror (h_errno)); - } - } while (size >= buffer_size); - - if (ns_initparse (search_buf, size, &ns_answer)) { - DNS_ERROR ("Invalid %s answer for \"%s\"", rr_type_name, hostname); - } - - n = ns_msg_count (ns_answer, ns_s_an); - if (!n) { - DNS_ERROR ("No %s records for \"%s\"", rr_type_name, hostname); - } - - rr_data->count = n; - num_matching_records = 0; - for (i = 0; i < n; i++) { - if (ns_parserr (&ns_answer, ns_s_an, i, &resource_record)) { - DNS_ERROR ("Invalid record %d of %s answer for \"%s\": \"%s\"", - i, - rr_type_name, - hostname, - _mongoc_hstrerror (h_errno)); - } - - /* Skip records that don't match the ones we requested. CDRIVER-3628 shows - * that we can receive records that were not requested. */ - if (rr_type == MONGOC_RR_TXT) { - if (ns_rr_type (resource_record) != ns_t_txt) { - continue; - } - } else if (rr_type == MONGOC_RR_SRV) { - if (ns_rr_type (resource_record) != ns_t_srv) { - continue; - } - } - - if (num_matching_records > 0 && rr_type == MONGOC_RR_TXT) { - /* Initial DNS Seedlist Discovery Spec: a client "MUST raise an error - * when multiple TXT records are encountered". */ - callback_success = false; - DNS_ERROR ("Multiple TXT records for \"%s\"", hostname); - } - - num_matching_records++; - - ttl = ns_rr_ttl (resource_record); - if ((i == 0) || (ttl < rr_data->min_ttl)) { - rr_data->min_ttl = ttl; - } - - if (!callback (hostname, &ns_answer, &resource_record, rr_data, error)) { - callback_success = false; - GOTO (done); - } - } - - if (num_matching_records == 0) { - DNS_ERROR ("No matching %s records for \"%s\"", rr_type_name, hostname); - } - - dns_success = true; - -done: - - bson_free (search_buf); - -#ifdef MONGOC_HAVE_RES_NDESTROY - /* defined on BSD/Darwin, and only if MONGOC_HAVE_RES_NSEARCH is defined */ - res_ndestroy (&state); -#elif defined(MONGOC_HAVE_RES_NCLOSE) - /* defined on Linux, and only if MONGOC_HAVE_RES_NSEARCH is defined */ - res_nclose (&state); -#endif - RETURN (dns_success && callback_success); -} -#endif // ↑↑↑↑↑↑↑↑↑↑↑↑↑ resolv - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_client_get_rr -- - * - * Fetch an SRV or TXT resource record and update put results in - * @rr_data. - * - * See RFCs 1464 and 2782, MongoDB's "Initial DNS Seedlist Discovery" - * spec, and MongoDB's "Polling SRV Records for Mongos Discovery" - * spec. - * - * Returns: - * Success or failure. - * - * Side effects: - * @error is set if there is a failure. Errors fetching TXT are - * ignored. - * @rr_data->hosts may be set if querying SRV. Caller must destroy. - * @rr_data->txt_record_opts may be set if querying TXT. Caller must - * free. - * - *-------------------------------------------------------------------------- - */ - -bool -_mongoc_client_get_rr (const char *hostname, - mongoc_rr_type_t rr_type, - mongoc_rr_data_t *rr_data, - size_t initial_buffer_size, - bson_error_t *error) -{ - BSON_ASSERT (rr_data); - -#if MONGOC_ENABLE_SRV == 0 - // Disabled - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "libresolv unavailable, cannot use mongodb+srv URI"); - return false; -#elif defined(MONGOC_HAVE_DNSAPI) - return _mongoc_get_rr_dnsapi (hostname, rr_type, rr_data, error); -#elif (defined(MONGOC_HAVE_RES_NSEARCH) || defined(MONGOC_HAVE_RES_SEARCH)) - return _mongoc_get_rr_search ( - hostname, rr_type, rr_data, initial_buffer_size, error); -#else -#error No SRV library is available, but ENABLE_SRV is true! -#endif -} - -#undef DNS_ERROR - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_connect_tcp -- - * - * Connect to a host using a TCP socket. - * - * This will be performed synchronously and return a mongoc_stream_t - * that can be used to connect with the remote host. - * - * Returns: - * A newly allocated mongoc_stream_t if successful; otherwise - * NULL and @error is set. - * - * Side effects: - * @error is set if return value is NULL. - * - *-------------------------------------------------------------------------- - */ - -mongoc_stream_t * -mongoc_client_connect_tcp (int32_t connecttimeoutms, - const mongoc_host_list_t *host, - bson_error_t *error) -{ - mongoc_socket_t *sock = NULL; - struct addrinfo hints; - struct addrinfo *result, *rp; - int64_t expire_at; - char portstr[8]; - int s; - - ENTRY; - - BSON_ASSERT (connecttimeoutms); - BSON_ASSERT (host); - - bson_snprintf (portstr, sizeof portstr, "%hu", host->port); - - memset (&hints, 0, sizeof hints); - hints.ai_family = host->family; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = 0; - hints.ai_protocol = 0; - - TRACE ("DNS lookup for %s", host->host); - s = getaddrinfo (host->host, portstr, &hints, &result); - - if (s != 0) { - mongoc_counter_dns_failure_inc (); - TRACE ("Failed to resolve %s", host->host); - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "Failed to resolve %s", - host->host); - RETURN (NULL); - } - - mongoc_counter_dns_success_inc (); - - for (rp = result; rp; rp = rp->ai_next) { - /* - * Create a new non-blocking socket. - */ - if (!(sock = mongoc_socket_new ( - rp->ai_family, rp->ai_socktype, rp->ai_protocol))) { - continue; - } - - /* - * Try to connect to the peer. - */ - expire_at = bson_get_monotonic_time () + (connecttimeoutms * 1000L); - if (0 != - mongoc_socket_connect ( - sock, rp->ai_addr, (mongoc_socklen_t) rp->ai_addrlen, expire_at)) { - mongoc_socket_destroy (sock); - sock = NULL; - continue; - } - - break; - } - - if (!sock) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "Failed to connect to target host: %s", - host->host_and_port); - freeaddrinfo (result); - RETURN (NULL); - } - - freeaddrinfo (result); - - return mongoc_stream_socket_new (sock); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_connect_unix -- - * - * Connect to a MongoDB server using a UNIX domain socket. - * - * Returns: - * A newly allocated mongoc_stream_t if successful; otherwise - * NULL and @error is set. - * - * Side effects: - * @error is set if return value is NULL. - * - *-------------------------------------------------------------------------- - */ - -static mongoc_stream_t * -mongoc_client_connect_unix (const mongoc_host_list_t *host, bson_error_t *error) -{ -#ifdef _WIN32 - ENTRY; - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "UNIX domain sockets not supported on win32."); - RETURN (NULL); -#else - struct sockaddr_un saddr; - mongoc_socket_t *sock; - mongoc_stream_t *ret = NULL; - - ENTRY; - - BSON_ASSERT (host); - - memset (&saddr, 0, sizeof saddr); - saddr.sun_family = AF_UNIX; - bson_snprintf (saddr.sun_path, sizeof saddr.sun_path - 1, "%s", host->host); - - sock = mongoc_socket_new (AF_UNIX, SOCK_STREAM, 0); - - if (sock == NULL) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to create socket."); - RETURN (NULL); - } - - if (-1 == mongoc_socket_connect ( - sock, (struct sockaddr *) &saddr, sizeof saddr, -1)) { - mongoc_socket_destroy (sock); - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "Failed to connect to UNIX domain socket."); - RETURN (NULL); - } - - ret = mongoc_stream_socket_new (sock); - - RETURN (ret); -#endif -} - -mongoc_stream_t * -mongoc_client_connect (bool buffered, - bool use_ssl, - void *ssl_opts_void, - const mongoc_uri_t *uri, - const mongoc_host_list_t *host, - bson_error_t *error) -{ - mongoc_stream_t *base_stream = NULL; - int32_t connecttimeoutms; - - BSON_ASSERT (uri); - BSON_ASSERT (host); - -#ifndef MONGOC_ENABLE_SSL - if (ssl_opts_void || mongoc_uri_get_tls (uri)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_NO_ACCEPTABLE_PEER, - "TLS is not enabled in this build of mongo-c-driver."); - return NULL; - } -#endif - - connecttimeoutms = mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_CONNECTTIMEOUTMS, MONGOC_DEFAULT_CONNECTTIMEOUTMS); - - switch (host->family) { - case AF_UNSPEC: -#if defined(AF_INET6) - case AF_INET6: -#endif - case AF_INET: - base_stream = mongoc_client_connect_tcp (connecttimeoutms, host, error); - break; - case AF_UNIX: - base_stream = mongoc_client_connect_unix (host, error); - break; - default: - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_INVALID_TYPE, - "Invalid address family: 0x%02x", - host->family); - break; - } - -#ifdef MONGOC_ENABLE_SSL - if (base_stream) { - mongoc_ssl_opt_t *ssl_opts; - const char *mechanism; - - ssl_opts = (mongoc_ssl_opt_t *) ssl_opts_void; - mechanism = mongoc_uri_get_auth_mechanism (uri); - - if (use_ssl || (mechanism && (0 == strcmp (mechanism, "MONGODB-X509")))) { - mongoc_stream_t *original = base_stream; - - base_stream = mongoc_stream_tls_new_with_hostname ( - base_stream, host->host, ssl_opts, true); - - if (!base_stream) { - mongoc_stream_destroy (original); - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed initialize TLS state."); - return NULL; - } - - if (!mongoc_stream_tls_handshake_block ( - base_stream, host->host, connecttimeoutms, error)) { - mongoc_stream_destroy (base_stream); - return NULL; - } - } - } -#endif - - if (!base_stream) { - return NULL; - } - if (buffered) { - return mongoc_stream_buffered_new (base_stream, 1024); - } - return base_stream; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_default_stream_initiator -- - * - * A mongoc_stream_initiator_t that will handle the various type - * of supported sockets by MongoDB including TCP and UNIX. - * - * Language binding authors may want to implement an alternate - * version of this method to use their native stream format. - * - * Returns: - * A mongoc_stream_t if successful; otherwise NULL and @error is set. - * - * Side effects: - * @error is set if return value is NULL. - * - *-------------------------------------------------------------------------- - */ - -mongoc_stream_t * -mongoc_client_default_stream_initiator (const mongoc_uri_t *uri, - const mongoc_host_list_t *host, - void *user_data, - bson_error_t *error) -{ - void *ssl_opts_void = NULL; - bool use_ssl = false; -#ifdef MONGOC_ENABLE_SSL - mongoc_client_t *client = (mongoc_client_t *) user_data; - - use_ssl = client->use_ssl; - ssl_opts_void = (void *) &client->ssl_opts; - -#endif - - return mongoc_client_connect ( - true, use_ssl, ssl_opts_void, uri, host, error); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_client_create_stream -- - * - * INTERNAL API - * - * This function is used by the mongoc_cluster_t to initiate a - * new stream. This is done because cluster is private API and - * those using mongoc_client_t may need to override this process. - * - * This function calls the default initiator for new streams. - * - * Returns: - * A newly allocated mongoc_stream_t if successful; otherwise - * NULL and @error is set. - * - * Side effects: - * @error is set if return value is NULL. - * - *-------------------------------------------------------------------------- - */ - -mongoc_stream_t * -_mongoc_client_create_stream (mongoc_client_t *client, - const mongoc_host_list_t *host, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - BSON_ASSERT (host); - - return client->initiator (client->uri, host, client->initiator_data, error); -} - - -bool -_mongoc_client_recv (mongoc_client_t *client, - mcd_rpc_message *rpc, - mongoc_buffer_t *buffer, - mongoc_server_stream_t *server_stream, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - BSON_ASSERT (rpc); - BSON_ASSERT (buffer); - BSON_ASSERT (server_stream); - BSON_ASSERT_PARAM (error); - - return mongoc_cluster_try_recv ( - &client->cluster, rpc, buffer, server_stream, error); -} - - -mongoc_client_t * -mongoc_client_new (const char *uri_string) -{ - mongoc_client_t *client; - mongoc_uri_t *uri; - bson_error_t error = {0}; - - if (!uri_string) { - uri_string = "mongodb://127.0.0.1/"; - } - - if (!(uri = mongoc_uri_new_with_error (uri_string, &error))) { - /* Log URI errors as a warning for consistency with mongoc_uri_new */ - MONGOC_WARNING ("Error parsing URI: '%s'", error.message); - return NULL; - } - - if (!(client = mongoc_client_new_from_uri_with_error (uri, &error))) { - MONGOC_ERROR ("%s", error.message); - } - - mongoc_uri_destroy (uri); - - return client; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_set_ssl_opts - * - * set ssl opts for a client - * - * Returns: - * Nothing - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -#ifdef MONGOC_ENABLE_SSL -/* Only called internally. Caller must ensure opts->internal is valid. */ -void -_mongoc_client_set_internal_tls_opts (mongoc_client_t *client, - _mongoc_internal_tls_opts_t *internal) -{ - BSON_ASSERT_PARAM (client); - if (!client->use_ssl) { - return; - } - client->ssl_opts.internal = - bson_malloc (sizeof (_mongoc_internal_tls_opts_t)); - memcpy (client->ssl_opts.internal, - internal, - sizeof (_mongoc_internal_tls_opts_t)); -} - -void -mongoc_client_set_ssl_opts (mongoc_client_t *client, - const mongoc_ssl_opt_t *opts) -{ - BSON_ASSERT_PARAM (client); - BSON_ASSERT (opts); - - _mongoc_ssl_opts_cleanup (&client->ssl_opts, - false /* don't free internal opts */); - - client->use_ssl = true; - _mongoc_ssl_opts_copy_to ( - opts, &client->ssl_opts, false /* don't overwrite internal opts */); - - if (client->topology->single_threaded) { - mongoc_topology_scanner_set_ssl_opts (client->topology->scanner, - &client->ssl_opts); - } -} -#endif - - -mongoc_client_t * -mongoc_client_new_from_uri (const mongoc_uri_t *uri) -{ - mongoc_client_t *client; - bson_error_t error = {0}; - - if (!(client = mongoc_client_new_from_uri_with_error (uri, &error))) { - MONGOC_ERROR ("%s", error.message); - } - - return client; -} - - -mongoc_client_t * -mongoc_client_new_from_uri_with_error (const mongoc_uri_t *uri, - bson_error_t *error) -{ - mongoc_client_t *client; - mongoc_topology_t *topology; - - - ENTRY; - - BSON_ASSERT (uri); - -#ifndef MONGOC_ENABLE_SSL - if (mongoc_uri_get_tls (uri)) { - bson_set_error ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Can't create SSL client, SSL not enabled in this build."); - RETURN (NULL); - } -#endif - - topology = mongoc_topology_new (uri, true); - - if (!topology->valid) { - if (error) { - memcpy (error, &topology->scanner->error, sizeof (bson_error_t)); - } - - mongoc_topology_destroy (topology); - - RETURN (NULL); - } - - client = _mongoc_client_new_from_topology (topology); - BSON_ASSERT (client); - - RETURN (client); -} - - -/* precondition: topology is valid */ -mongoc_client_t * -_mongoc_client_new_from_topology (mongoc_topology_t *topology) -{ - mongoc_client_t *client; - const mongoc_read_prefs_t *read_prefs; - const mongoc_read_concern_t *read_concern; - const mongoc_write_concern_t *write_concern; - const char *appname; - - BSON_ASSERT (topology); - BSON_ASSERT (topology->valid); - - client = (mongoc_client_t *) bson_malloc0 (sizeof *client); - client->uri = mongoc_uri_copy (topology->uri); - client->initiator = mongoc_client_default_stream_initiator; - client->initiator_data = client; - client->topology = topology; - client->error_api_version = MONGOC_ERROR_API_VERSION_LEGACY; - client->error_api_set = false; - client->client_sessions = mongoc_set_new (8, NULL, NULL); - client->csid_rand_seed = (unsigned int) bson_get_monotonic_time (); - - write_concern = mongoc_uri_get_write_concern (client->uri); - client->write_concern = mongoc_write_concern_copy (write_concern); - - read_concern = mongoc_uri_get_read_concern (client->uri); - client->read_concern = mongoc_read_concern_copy (read_concern); - - read_prefs = mongoc_uri_get_read_prefs_t (client->uri); - client->read_prefs = mongoc_read_prefs_copy (read_prefs); - - appname = - mongoc_uri_get_option_as_utf8 (client->uri, MONGOC_URI_APPNAME, NULL); - if (appname && client->topology->single_threaded) { - /* the appname should have already been validated */ - BSON_ASSERT (mongoc_client_set_appname (client, appname)); - } - - mongoc_cluster_init (&client->cluster, client->uri, client); - -#ifdef MONGOC_ENABLE_SSL - client->use_ssl = false; - if (mongoc_uri_get_tls (client->uri)) { - mongoc_ssl_opt_t ssl_opt = {0}; - _mongoc_internal_tls_opts_t internal_tls_opts = {0}; - - _mongoc_ssl_opts_from_uri (&ssl_opt, &internal_tls_opts, client->uri); - /* sets use_ssl = true */ - mongoc_client_set_ssl_opts (client, &ssl_opt); - _mongoc_client_set_internal_tls_opts (client, &internal_tls_opts); - } -#endif - - mongoc_counter_clients_active_inc (); - - return client; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_destroy -- - * - * Destroys a mongoc_client_t and cleans up all resources associated - * with the client instance. - * - * Returns: - * None. - * - * Side effects: - * @client is destroyed. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_client_destroy (mongoc_client_t *client) -{ - if (client) { - if (client->topology->single_threaded) { - _mongoc_client_end_sessions (client); - mongoc_topology_destroy (client->topology); - } - - mongoc_write_concern_destroy (client->write_concern); - mongoc_read_concern_destroy (client->read_concern); - mongoc_read_prefs_destroy (client->read_prefs); - mongoc_cluster_destroy (&client->cluster); - mongoc_uri_destroy (client->uri); - mongoc_set_destroy (client->client_sessions); - mongoc_server_api_destroy (client->api); - -#ifdef MONGOC_ENABLE_SSL - _mongoc_ssl_opts_cleanup (&client->ssl_opts, true); -#endif - - bson_free (client); - - mongoc_counter_clients_active_dec (); - mongoc_counter_clients_disposed_inc (); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_get_uri -- - * - * Fetch the URI used for @client. - * - * Returns: - * A mongoc_uri_t that should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const mongoc_uri_t * -mongoc_client_get_uri (const mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (client); - - return client->uri; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_start_session -- - * - * Creates a structure to communicate in a session over @client. - * - * This structure should be freed when the caller is done with it - * using mongoc_client_session_destroy(). - * - * Returns: - * A newly allocated mongoc_client_session_t. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_client_session_t * -mongoc_client_start_session (mongoc_client_t *client, - const mongoc_session_opt_t *opts, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - - mongoc_server_session_t *ss; - mongoc_client_session_t *cs; - uint32_t csid; - - ENTRY; - - ss = _mongoc_client_pop_server_session (client, error); - if (!ss) { - RETURN (NULL); - } - - /* get a random internal id for the session, retrying on collision */ - do { - csid = (uint32_t) _mongoc_rand_simple (&client->csid_rand_seed); - } while (mongoc_set_get (client->client_sessions, csid)); - - /* causal consistency and snapshot cannot both be set. */ - if (opts && mongoc_session_opts_get_causal_consistency (opts) && - mongoc_session_opts_get_snapshot (opts)) { - bson_set_error ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_SESSION_FAILURE, - "Only one of causal consistency and snapshot can be enabled."); - _mongoc_client_push_server_session (client, ss); - RETURN (NULL); - } - cs = _mongoc_client_session_new (client, ss, opts, csid); - - /* remember session so if we see its client_session_id in a command, we can - * find its lsid and clusterTime */ - mongoc_set_add (client->client_sessions, csid, cs); - - RETURN (cs); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_get_database -- - * - * Fetches a newly allocated database structure to communicate with - * a database over @client. - * - * @database should be a db name such as "test". - * - * This structure should be freed when the caller is done with it - * using mongoc_database_destroy(). - * - * Returns: - * A newly allocated mongoc_database_t. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_database_t * -mongoc_client_get_database (mongoc_client_t *client, const char *name) -{ - BSON_ASSERT_PARAM (client); - BSON_ASSERT (name); - - return _mongoc_database_new (client, - name, - client->read_prefs, - client->read_concern, - client->write_concern); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_get_default_database -- - * - * Get the database named in the MongoDB connection URI, or NULL - * if none was specified in the URI. - * - * This structure should be freed when the caller is done with it - * using mongoc_database_destroy(). - * - * Returns: - * A newly allocated mongoc_database_t or NULL. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_database_t * -mongoc_client_get_default_database (mongoc_client_t *client) -{ - const char *db; - - BSON_ASSERT_PARAM (client); - db = mongoc_uri_get_database (client->uri); - - if (db) { - return mongoc_client_get_database (client, db); - } - - return NULL; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_get_collection -- - * - * This function returns a newly allocated collection structure. - * - * @db should be the name of the database, such as "test". - * @collection should be the name of the collection such as "test". - * - * The above would result in the namespace "test.test". - * - * You should free this structure when you are done with it using - * mongoc_collection_destroy(). - * - * Returns: - * A newly allocated mongoc_collection_t that should be freed with - * mongoc_collection_destroy(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_collection_t * -mongoc_client_get_collection (mongoc_client_t *client, - const char *db, - const char *collection) -{ - BSON_ASSERT_PARAM (client); - BSON_ASSERT (db); - BSON_ASSERT (collection); - - return _mongoc_collection_new (client, - db, - collection, - client->read_prefs, - client->read_concern, - client->write_concern); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_get_gridfs -- - * - * This function returns a newly allocated collection structure. - * - * @db should be the name of the database, such as "test". - * - * @prefix optional prefix for GridFS collection names, or NULL. Default - * is "fs", thus the default collection names for GridFS are "fs.files" - * and "fs.chunks". - * - * Returns: - * A newly allocated mongoc_gridfs_t that should be freed with - * mongoc_gridfs_destroy(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_gridfs_t * -mongoc_client_get_gridfs (mongoc_client_t *client, - const char *db, - const char *prefix, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - BSON_ASSERT (db); - - if (!prefix) { - prefix = "fs"; - } - - return _mongoc_gridfs_new (client, db, prefix, error); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_get_write_concern -- - * - * Fetches the default write concern for @client. - * - * Returns: - * A mongoc_write_concern_t that should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const mongoc_write_concern_t * -mongoc_client_get_write_concern (const mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (client); - - return client->write_concern; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_set_write_concern -- - * - * Sets the default write concern for @client. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_client_set_write_concern (mongoc_client_t *client, - const mongoc_write_concern_t *write_concern) -{ - BSON_ASSERT_PARAM (client); - - if (write_concern != client->write_concern) { - if (client->write_concern) { - mongoc_write_concern_destroy (client->write_concern); - } - client->write_concern = write_concern - ? mongoc_write_concern_copy (write_concern) - : mongoc_write_concern_new (); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_get_read_concern -- - * - * Fetches the default read concern for @client. - * - * Returns: - * A mongoc_read_concern_t that should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const mongoc_read_concern_t * -mongoc_client_get_read_concern (const mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (client); - - return client->read_concern; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_set_read_concern -- - * - * Sets the default read concern for @client. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_client_set_read_concern (mongoc_client_t *client, - const mongoc_read_concern_t *read_concern) -{ - BSON_ASSERT_PARAM (client); - - if (read_concern != client->read_concern) { - if (client->read_concern) { - mongoc_read_concern_destroy (client->read_concern); - } - client->read_concern = read_concern - ? mongoc_read_concern_copy (read_concern) - : mongoc_read_concern_new (); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_get_read_prefs -- - * - * Fetch the default read preferences for @client. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const mongoc_read_prefs_t * -mongoc_client_get_read_prefs (const mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (client); - - return client->read_prefs; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_set_read_prefs -- - * - * Set the default read preferences for @client. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_client_set_read_prefs (mongoc_client_t *client, - const mongoc_read_prefs_t *read_prefs) -{ - BSON_ASSERT_PARAM (client); - - if (read_prefs != client->read_prefs) { - if (client->read_prefs) { - mongoc_read_prefs_destroy (client->read_prefs); - } - client->read_prefs = read_prefs - ? mongoc_read_prefs_copy (read_prefs) - : mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - } -} - -mongoc_cursor_t * -mongoc_client_command (mongoc_client_t *client, - const char *db_name, - mongoc_query_flags_t flags, - uint32_t skip, - uint32_t limit, - uint32_t batch_size, - const bson_t *query, - const bson_t *fields, - const mongoc_read_prefs_t *read_prefs) -{ - char *ns = NULL; - mongoc_cursor_t *cursor; - - BSON_UNUSED (flags); - BSON_UNUSED (skip); - BSON_UNUSED (limit); - BSON_UNUSED (batch_size); - BSON_UNUSED (fields); - - BSON_ASSERT_PARAM (client); - BSON_ASSERT (db_name); - BSON_ASSERT (query); - - /* - * Allow a caller to provide a fully qualified namespace - */ - if (NULL == strstr (db_name, "$cmd")) { - ns = bson_strdup_printf ("%s.$cmd", db_name); - db_name = ns; - } - - cursor = - _mongoc_cursor_cmd_deprecated_new (client, db_name, query, read_prefs); - - bson_free (ns); - return cursor; -} - - -static bool -_mongoc_client_retryable_write_command_with_stream ( - mongoc_client_t *client, - mongoc_cmd_parts_t *parts, - mongoc_server_stream_t *server_stream, - bson_t *reply, - bson_error_t *error) -{ - mongoc_server_stream_t *retry_server_stream = NULL; - bson_iter_t txn_number_iter; - bool is_retryable = true; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT (parts->is_retryable_write); - - /* increment the transaction number for the first attempt of each retryable - * write command */ - BSON_ASSERT (bson_iter_init_find ( - &txn_number_iter, parts->assembled.command, "txnNumber")); - bson_iter_overwrite_int64 ( - &txn_number_iter, ++parts->assembled.session->server_session->txn_number); - - // Store the original error and reply if needed. - struct { - bson_t reply; - bson_error_t error; - bool set; - } original_error = {.reply = {0}, .error = {0}, false}; - -retry: - ret = mongoc_cluster_run_command_monitored ( - &client->cluster, &parts->assembled, reply, error); - - _mongoc_write_error_handle_labels (ret, error, reply, server_stream->sd); - - if (is_retryable) { - _mongoc_write_error_update_if_unsupported_storage_engine ( - ret, error, reply); - } - - /* If a retryable error is encountered and the write is retryable, select - * a new writable stream and retry. If server selection fails or the selected - * server does not support retryable writes, fall through and allow the - * original error to be reported. */ - if (is_retryable && - _mongoc_write_error_get_type (reply) == MONGOC_WRITE_ERR_RETRY) { - bson_error_t ignored_error; - - // The write command may be retried at most once. - is_retryable = false; - - { - mongoc_deprioritized_servers_t *const ds = - mongoc_deprioritized_servers_new (); - - mongoc_deprioritized_servers_add_if_sharded ( - ds, server_stream->topology_type, server_stream->sd); - - BSON_ASSERT (!retry_server_stream); - retry_server_stream = - mongoc_cluster_stream_for_writes (&client->cluster, - parts->assembled.session, - ds, - NULL, - &ignored_error); - - mongoc_deprioritized_servers_destroy (ds); - } - - if (retry_server_stream) { - parts->assembled.server_stream = retry_server_stream; - { - // Store the original error and reply before retry. - BSON_ASSERT (!original_error.set); // Retry only happens once. - original_error.set = true; - bson_copy_to (reply, &original_error.reply); - if (error) { - original_error.error = *error; - } - } - bson_destroy (reply); - GOTO (retry); - } - } - - if (retry_server_stream) { - mongoc_server_stream_cleanup (retry_server_stream); - } - - // If a retry attempt fails with an error labeled NoWritesPerformed, - // drivers MUST return the original error. - if (original_error.set && - mongoc_error_has_label (reply, "NoWritesPerformed")) { - if (error) { - *error = original_error.error; - } - bson_destroy (reply); - bson_copy_to (&original_error.reply, reply); - } - - if (original_error.set) { - bson_destroy (&original_error.reply); - } - - if (ret && error) { - /* if a retry succeeded, clear the initial error */ - memset (error, 0, sizeof (bson_error_t)); - } - - RETURN (ret); -} - - -static bool -_mongoc_client_retryable_read_command_with_stream ( - mongoc_client_t *client, - mongoc_cmd_parts_t *parts, - mongoc_server_stream_t *server_stream, - bson_t *reply, - bson_error_t *error) -{ - mongoc_server_stream_t *retry_server_stream = NULL; - bool is_retryable = true; - bool ret; - bson_t reply_local; - - BSON_ASSERT_PARAM (client); - BSON_UNUSED (server_stream); - - if (reply == NULL) { - reply = &reply_local; - } - - ENTRY; - - BSON_ASSERT (parts->is_retryable_read); - -retry: - ret = mongoc_cluster_run_command_monitored ( - &client->cluster, &parts->assembled, reply, error); - - /* If a retryable error is encountered and the read is retryable, select - * a new readable stream and retry. If server selection fails or the selected - * server does not support retryable reads, fall through and allow the - * original error to be reported. */ - if (is_retryable && _mongoc_read_error_get_type (ret, error, reply) == - MONGOC_READ_ERR_RETRY) { - bson_error_t ignored_error; - - /* each read command may be retried at most once */ - is_retryable = false; - - { - mongoc_deprioritized_servers_t *const ds = - mongoc_deprioritized_servers_new (); - - if (retry_server_stream) { - mongoc_deprioritized_servers_add_if_sharded ( - ds, retry_server_stream->topology_type, retry_server_stream->sd); - mongoc_server_stream_cleanup (retry_server_stream); - } else { - mongoc_deprioritized_servers_add_if_sharded ( - ds, server_stream->topology_type, server_stream->sd); - } - - retry_server_stream = - mongoc_cluster_stream_for_reads (&client->cluster, - parts->read_prefs, - parts->assembled.session, - ds, - NULL, - &ignored_error); - - mongoc_deprioritized_servers_destroy (ds); - } - - if (retry_server_stream) { - parts->assembled.server_stream = retry_server_stream; - bson_destroy (reply); - GOTO (retry); - } - } - - if (retry_server_stream) { - mongoc_server_stream_cleanup (retry_server_stream); - } - - if (ret && error) { - /* if a retry succeeded, clear the initial error */ - memset (error, 0, sizeof (bson_error_t)); - } - - RETURN (ret); -} - - -static bool -_mongoc_client_command_with_stream (mongoc_client_t *client, - mongoc_cmd_parts_t *parts, - const mongoc_read_prefs_t *read_prefs, - mongoc_server_stream_t *server_stream, - bson_t *reply, - bson_error_t *error) -{ - ENTRY; - - BSON_ASSERT_PARAM (client); - BSON_UNUSED (read_prefs); - - parts->assembled.operation_id = ++client->cluster.operation_id; - if (!mongoc_cmd_parts_assemble (parts, server_stream, error)) { - _mongoc_bson_init_if_set (reply); - return false; - }; - - if (parts->is_retryable_write) { - RETURN (_mongoc_client_retryable_write_command_with_stream ( - client, parts, server_stream, reply, error)); - } - - if (parts->is_retryable_read) { - RETURN (_mongoc_client_retryable_read_command_with_stream ( - client, parts, server_stream, reply, error)); - } - - RETURN (mongoc_cluster_run_command_monitored ( - &client->cluster, &parts->assembled, reply, error)); -} - - -bool -mongoc_client_command_simple (mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error) -{ - mongoc_cluster_t *cluster; - mongoc_server_stream_t *server_stream = NULL; - mongoc_cmd_parts_t parts; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT (db_name); - BSON_ASSERT (command); - - if (!_mongoc_read_prefs_validate (read_prefs, error)) { - RETURN (false); - } - - cluster = &client->cluster; - mongoc_cmd_parts_init (&parts, client, db_name, MONGOC_QUERY_NONE, command); - parts.read_prefs = read_prefs; - - /* Server Selection Spec: "The generic command method has a default read - * preference of mode 'primary'. The generic command method MUST ignore any - * default read preference from client, database or collection - * configuration. The generic command method SHOULD allow an optional read - * preference argument." - */ - server_stream = mongoc_cluster_stream_for_reads ( - cluster, read_prefs, NULL, NULL, reply, error); - - if (server_stream) { - ret = _mongoc_client_command_with_stream ( - client, &parts, read_prefs, server_stream, reply, error); - } else { - /* reply initialized by mongoc_cluster_stream_for_reads */ - ret = false; - } - - mongoc_cmd_parts_cleanup (&parts); - mongoc_server_stream_cleanup (server_stream); - - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_client_command_with_opts -- - * - * Execute a command on the server. If mode is MONGOC_CMD_READ or - * MONGOC_CMD_RW, then read concern is applied from @opts, or else from - * @default_rc, and read preferences are applied from @user_prefs, or else - * from @default_prefs. If mode is MONGOC_CMD_WRITE or MONGOC_CMD_RW, then - * write concern is applied from @opts if present, or else @default_wc. - * - * If mode is MONGOC_CMD_RAW, then read concern and write concern are - * applied from @opts only. Read preferences are applied from - * @user_prefs. - * - * The mongoc_client_t's read preference, read concern, and write concern - * are *NOT* applied. - * - * Returns: - * Success or failure. - * A write concern timeout or write concern error is considered a failure. - * - * Side effects: - * @reply is always initialized. - * @error is filled out if the command fails. - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_client_command_with_opts (mongoc_client_t *client, - const char *db_name, - const bson_t *command, - mongoc_command_mode_t mode, - const bson_t *opts, - mongoc_query_flags_t flags, - const mongoc_read_prefs_t *user_prefs, - const mongoc_read_prefs_t *default_prefs, - mongoc_read_concern_t *default_rc, - mongoc_write_concern_t *default_wc, - bson_t *reply, - bson_error_t *error) -{ - mongoc_read_write_opts_t read_write_opts; - mongoc_cmd_parts_t parts; - const char *command_name; - const mongoc_read_prefs_t *prefs = COALESCE (user_prefs, default_prefs); - mongoc_server_stream_t *server_stream = NULL; - mongoc_cluster_t *cluster; - mongoc_client_session_t *cs; - bson_t reply_local; - bson_t *reply_ptr; - bool reply_initialized = false; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT (db_name); - BSON_ASSERT (command); - - command_name = _mongoc_get_command_name (command); - cluster = &client->cluster; - reply_ptr = reply ? reply : &reply_local; - - mongoc_cmd_parts_init (&parts, client, db_name, flags, command); - parts.is_read_command = (mode & MONGOC_CMD_READ); - parts.is_write_command = (mode & MONGOC_CMD_WRITE); - - if (!_mongoc_read_write_opts_parse (client, opts, &read_write_opts, error)) { - GOTO (done); - } - - cs = read_write_opts.client_session; - - if (!command_name) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Empty command document"); - GOTO (done); - } - - if (_mongoc_client_session_in_txn (read_write_opts.client_session)) { - if ((mode == MONGOC_CMD_READ || mode == MONGOC_CMD_RAW) && - !IS_PREF_PRIMARY (user_prefs)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Read preference in a transaction must be primary"); - GOTO (done); - } - - if (!bson_empty (&read_write_opts.readConcern)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot set read concern after starting transaction"); - GOTO (done); - } - - if (read_write_opts.writeConcern && - strcmp (command_name, "commitTransaction") != 0 && - strcmp (command_name, "abortTransaction") != 0) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot set write concern after starting transaction"); - GOTO (done); - } - } - - if (mode == MONGOC_CMD_READ || mode == MONGOC_CMD_RAW) { - /* NULL read pref is ok */ - if (!_mongoc_read_prefs_validate (prefs, error)) { - GOTO (done); - } - - parts.read_prefs = prefs; - } else { - /* this is a command that writes */ - prefs = NULL; - } - - if (read_write_opts.serverId) { - /* "serverId" passed in opts */ - server_stream = - mongoc_cluster_stream_for_server (cluster, - read_write_opts.serverId, - true /* reconnect ok */, - cs, - reply_ptr, - error); - - if (server_stream && server_stream->sd->type != MONGOC_SERVER_MONGOS) { - parts.user_query_flags |= MONGOC_QUERY_SECONDARY_OK; - } - } else if (parts.is_write_command) { - server_stream = - mongoc_cluster_stream_for_writes (cluster, cs, NULL, reply_ptr, error); - } else { - server_stream = mongoc_cluster_stream_for_reads ( - cluster, prefs, cs, NULL, reply_ptr, error); - } - - if (!server_stream) { - /* stream_for_reads/writes/server has initialized reply */ - reply_initialized = true; - GOTO (done); - } - - if (!mongoc_cmd_parts_append_read_write (&parts, &read_write_opts, error)) { - GOTO (done); - } - - if (mode & MONGOC_CMD_WRITE) { - /* use default write concern unless it's in opts */ - if (!mongoc_write_concern_is_default (default_wc) && - !read_write_opts.write_concern_owned) { - if (!mongoc_cmd_parts_set_write_concern (&parts, default_wc, error)) { - GOTO (done); - } - } - } - - /* use default read concern for read command, unless it's in opts */ - if ((mode & MONGOC_CMD_READ) && bson_empty (&read_write_opts.readConcern)) { - if (!mongoc_cmd_parts_set_read_concern (&parts, default_rc, error)) { - GOTO (done); - } - } - - ret = _mongoc_client_command_with_stream ( - client, &parts, user_prefs, server_stream, reply_ptr, error); - - reply_initialized = true; - - if (ret && (mode & MONGOC_CMD_WRITE)) { - ret = !_mongoc_parse_wc_err (reply_ptr, error); - } - -done: - if (reply_ptr == &reply_local) { - if (reply_initialized) { - bson_destroy (reply_ptr); - } - } else if (!reply_initialized) { - _mongoc_bson_init_if_set (reply); - } - - if (server_stream) { - mongoc_server_stream_cleanup (server_stream); - } - - mongoc_cmd_parts_cleanup (&parts); - _mongoc_read_write_opts_cleanup (&read_write_opts); - - RETURN (ret); -} - - -bool -mongoc_client_read_command_with_opts (mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - return _mongoc_client_command_with_opts (client, - db_name, - command, - MONGOC_CMD_READ, - opts, - MONGOC_QUERY_NONE, - read_prefs, - client->read_prefs, - client->read_concern, - client->write_concern, - reply, - error); -} - - -bool -mongoc_client_write_command_with_opts (mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - return _mongoc_client_command_with_opts (client, - db_name, - command, - MONGOC_CMD_WRITE, - opts, - MONGOC_QUERY_NONE, - NULL, - client->read_prefs, - client->read_concern, - client->write_concern, - reply, - error); -} - - -bool -mongoc_client_read_write_command_with_opts ( - mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs /* IGNORED */, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - return _mongoc_client_command_with_opts (client, - db_name, - command, - MONGOC_CMD_RW, - opts, - MONGOC_QUERY_NONE, - read_prefs, - client->read_prefs, - client->read_concern, - client->write_concern, - reply, - error); -} - - -bool -mongoc_client_command_with_opts (mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - return _mongoc_client_command_with_opts (client, - db_name, - command, - MONGOC_CMD_RAW, - opts, - MONGOC_QUERY_NONE, - read_prefs, - NULL, - client->read_concern, - client->write_concern, - reply, - error); -} - - -bool -mongoc_client_command_simple_with_server_id ( - mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - uint32_t server_id, - bson_t *reply, - bson_error_t *error) -{ - mongoc_server_stream_t *server_stream; - mongoc_cmd_parts_t parts; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT (db_name); - BSON_ASSERT (command); - - if (!_mongoc_read_prefs_validate (read_prefs, error)) { - RETURN (false); - } - - server_stream = mongoc_cluster_stream_for_server ( - &client->cluster, server_id, true /* reconnect ok */, NULL, reply, error); - - if (server_stream) { - mongoc_cmd_parts_init ( - &parts, client, db_name, MONGOC_QUERY_NONE, command); - parts.read_prefs = read_prefs; - - ret = _mongoc_client_command_with_stream ( - client, &parts, read_prefs, server_stream, reply, error); - - mongoc_cmd_parts_cleanup (&parts); - mongoc_server_stream_cleanup (server_stream); - RETURN (ret); - } else { - /* stream_for_server initialized reply */ - RETURN (false); - } -} - - -static void -_mongoc_client_prepare_killcursors_command (int64_t cursor_id, - const char *collection, - bson_t *command) -{ - bson_array_builder_t *child; - - bson_append_utf8 (command, "killCursors", 11, collection, -1); - bson_append_array_builder_begin (command, "cursors", 7, &child); - bson_array_builder_append_int64 (child, cursor_id); - bson_append_array_builder_end (command, child); -} - - -void -_mongoc_client_kill_cursor (mongoc_client_t *client, - uint32_t server_id, - int64_t cursor_id, - int64_t operation_id, - const char *db, - const char *collection, - mongoc_client_session_t *cs) -{ - mongoc_server_stream_t *server_stream; - - ENTRY; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT (cursor_id); - - /* don't attempt reconnect if server unavailable, and ignore errors */ - server_stream = mongoc_cluster_stream_for_server ( - &client->cluster, server_id, false /* reconnect_ok */, NULL, NULL, NULL); - - if (!server_stream) { - return; - } - - if (db && collection) { - _mongoc_client_killcursors_command ( - &client->cluster, server_stream, cursor_id, db, collection, cs); - } else { - _mongoc_client_op_killcursors (&client->cluster, - server_stream, - cursor_id, - operation_id, - db, - collection); - } - - mongoc_server_stream_cleanup (server_stream); - - EXIT; -} - - -static void -_mongoc_client_monitor_op_killcursors (mongoc_cluster_t *cluster, - mongoc_server_stream_t *server_stream, - int64_t cursor_id, - int64_t operation_id, - const char *db, - const char *collection) -{ - bson_t doc; - mongoc_client_t *client; - mongoc_apm_command_started_t event; - - ENTRY; - - client = cluster->client; - - if (!client->apm_callbacks.started) { - return; - } - - bson_init (&doc); - _mongoc_client_prepare_killcursors_command (cursor_id, collection, &doc); - mongoc_apm_command_started_init (&event, - &doc, - db, - "killCursors", - cluster->request_id, - operation_id, - &server_stream->sd->host, - server_stream->sd->id, - &server_stream->sd->service_id, - server_stream->sd->server_connection_id, - NULL, - client->apm_context); - - client->apm_callbacks.started (&event); - mongoc_apm_command_started_cleanup (&event); - bson_destroy (&doc); - - EXIT; -} - - -static void -_mongoc_client_monitor_op_killcursors_succeeded ( - mongoc_cluster_t *cluster, - int64_t duration, - mongoc_server_stream_t *server_stream, - int64_t cursor_id, - int64_t operation_id) -{ - mongoc_client_t *client; - bson_t doc; - bson_array_builder_t *cursors_unknown; - mongoc_apm_command_succeeded_t event; - - ENTRY; - - client = cluster->client; - - if (!client->apm_callbacks.succeeded) { - EXIT; - } - - /* fake server reply to killCursors command: {ok: 1, cursorsUnknown: [42]} */ - bson_init (&doc); - bson_append_int32 (&doc, "ok", 2, 1); - bson_append_array_builder_begin ( - &doc, "cursorsUnknown", 14, &cursors_unknown); - bson_array_builder_append_int64 (cursors_unknown, cursor_id); - bson_append_array_builder_end (&doc, cursors_unknown); - - mongoc_apm_command_succeeded_init (&event, - duration, - &doc, - "killCursors", - cluster->request_id, - operation_id, - &server_stream->sd->host, - server_stream->sd->id, - &server_stream->sd->service_id, - server_stream->sd->server_connection_id, - false, - client->apm_context); - - client->apm_callbacks.succeeded (&event); - - mongoc_apm_command_succeeded_cleanup (&event); - bson_destroy (&doc); -} - - -static void -_mongoc_client_monitor_op_killcursors_failed ( - mongoc_cluster_t *cluster, - int64_t duration, - mongoc_server_stream_t *server_stream, - const bson_error_t *error, - int64_t operation_id) -{ - mongoc_client_t *client; - bson_t doc; - mongoc_apm_command_failed_t event; - - ENTRY; - - client = cluster->client; - - if (!client->apm_callbacks.failed) { - EXIT; - } - - /* fake server reply to killCursors command: {ok: 0} */ - bson_init (&doc); - bson_append_int32 (&doc, "ok", 2, 0); - - mongoc_apm_command_failed_init (&event, - duration, - "killCursors", - error, - &doc, - cluster->request_id, - operation_id, - &server_stream->sd->host, - server_stream->sd->id, - &server_stream->sd->service_id, - server_stream->sd->server_connection_id, - false, - client->apm_context); - - client->apm_callbacks.failed (&event); - - mongoc_apm_command_failed_cleanup (&event); - bson_destroy (&doc); -} - - -static void -_mongoc_client_op_killcursors (mongoc_cluster_t *cluster, - mongoc_server_stream_t *server_stream, - int64_t cursor_id, - int64_t operation_id, - const char *db, - const char *collection) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT_PARAM (server_stream); - BSON_ASSERT (db || true); - BSON_ASSERT (collection || true); - - const bool has_ns = db && collection; - const int64_t started = bson_get_monotonic_time (); - - mcd_rpc_message *const rpc = mcd_rpc_message_new (); - - { - int32_t message_length = 0; - - message_length += mcd_rpc_header_set_message_length (rpc, 0); - message_length += - mcd_rpc_header_set_request_id (rpc, ++cluster->request_id); - message_length += mcd_rpc_header_set_response_to (rpc, 0); - message_length += - mcd_rpc_header_set_op_code (rpc, MONGOC_OP_CODE_KILL_CURSORS); - - message_length += sizeof (int32_t); // ZERO - message_length += - mcd_rpc_op_kill_cursors_set_cursor_ids (rpc, &cursor_id, 1); - - mcd_rpc_message_set_length (rpc, message_length); - } - - if (has_ns) { - _mongoc_client_monitor_op_killcursors ( - cluster, server_stream, cursor_id, operation_id, db, collection); - } - - bson_error_t error; - const bool res = mongoc_cluster_legacy_rpc_sendv_to_server ( - cluster, rpc, server_stream, &error); - - if (has_ns) { - if (res) { - _mongoc_client_monitor_op_killcursors_succeeded ( - cluster, - bson_get_monotonic_time () - started, - server_stream, - cursor_id, - operation_id); - } else { - _mongoc_client_monitor_op_killcursors_failed ( - cluster, - bson_get_monotonic_time () - started, - server_stream, - &error, - operation_id); - } - } - - mcd_rpc_message_destroy (rpc); -} - - -static void -_mongoc_client_killcursors_command (mongoc_cluster_t *cluster, - mongoc_server_stream_t *server_stream, - int64_t cursor_id, - const char *db, - const char *collection, - mongoc_client_session_t *cs) -{ - bson_t command = BSON_INITIALIZER; - mongoc_cmd_parts_t parts; - - ENTRY; - - _mongoc_client_prepare_killcursors_command (cursor_id, collection, &command); - mongoc_cmd_parts_init ( - &parts, cluster->client, db, MONGOC_QUERY_SECONDARY_OK, &command); - parts.assembled.operation_id = ++cluster->operation_id; - mongoc_cmd_parts_set_session (&parts, cs); - - if (mongoc_cmd_parts_assemble (&parts, server_stream, NULL)) { - /* Find, getMore And killCursors Commands Spec: "The result from the - * killCursors command MAY be safely ignored." - */ - (void) mongoc_cluster_run_command_monitored ( - cluster, &parts.assembled, NULL, NULL); - } - - mongoc_cmd_parts_cleanup (&parts); - bson_destroy (&command); - - EXIT; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_kill_cursor -- - * - * Destroy a cursor on the server. - * - * NOTE: this is only reliable when connected to a single mongod or - * mongos. If connected to a replica set, the driver attempts to - * kill the cursor on the primary. If connected to multiple mongoses - * the kill-cursors message is sent to a *random* mongos. - * - * If no primary, mongos, or standalone server is known, return - * without attempting to reconnect. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_client_kill_cursor (mongoc_client_t *client, int64_t cursor_id) -{ - BSON_ASSERT_PARAM (client); - - mongoc_topology_t *const topology = - BSON_ASSERT_PTR_INLINE (client)->topology; - mongoc_server_description_t const *selected_server; - mongoc_read_prefs_t *read_prefs; - bson_error_t error; - uint32_t server_id = 0; - mc_shared_tpld td = mc_tpld_take_ref (topology); - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - if (!mongoc_topology_compatible (td.ptr, NULL, &error)) { - MONGOC_ERROR ("Could not kill cursor: %s", error.message); - mc_tpld_drop_ref (&td); - mongoc_read_prefs_destroy (read_prefs); - return; - } - - /* see if there's a known writable server - do no I/O or retries */ - selected_server = - mongoc_topology_description_select (td.ptr, - MONGOC_SS_WRITE, - read_prefs, - NULL /* chosen read mode */, - NULL /* deprioritized servers */, - topology->local_threshold_msec); - - if (selected_server) { - server_id = selected_server->id; - } - - if (server_id) { - _mongoc_client_kill_cursor (client, - server_id, - cursor_id, - 0 /* operation_id */, - NULL /* db */, - NULL /* collection */, - NULL /* session */); - } else { - MONGOC_INFO ("No server available for mongoc_client_kill_cursor"); - } - - mongoc_read_prefs_destroy (read_prefs); - mc_tpld_drop_ref (&td); -} - - -char ** -mongoc_client_get_database_names (mongoc_client_t *client, bson_error_t *error) -{ - return mongoc_client_get_database_names_with_opts (client, NULL, error); -} - - -char ** -mongoc_client_get_database_names_with_opts (mongoc_client_t *client, - const bson_t *opts, - bson_error_t *error) -{ - bson_iter_t iter; - const char *name; - char **ret = NULL; - int i = 0; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_t cmd = BSON_INITIALIZER; - - BSON_ASSERT_PARAM (client); - BSON_APPEND_INT32 (&cmd, "listDatabases", 1); - BSON_APPEND_BOOL (&cmd, "nameOnly", true); - - /* ignore client read prefs */ - cursor = _mongoc_cursor_array_new (client, "admin", &cmd, opts, "databases"); - bson_destroy (&cmd); - - while (mongoc_cursor_next (cursor, &doc)) { - if (bson_iter_init (&iter, doc) && bson_iter_find (&iter, "name") && - BSON_ITER_HOLDS_UTF8 (&iter) && - (name = bson_iter_utf8 (&iter, NULL))) { - ret = (char **) bson_realloc (ret, sizeof (char *) * (i + 2)); - ret[i] = bson_strdup (name); - ret[++i] = NULL; - } - } - - if (!ret && !mongoc_cursor_error (cursor, error)) { - ret = (char **) bson_malloc0 (sizeof (void *)); - } - - mongoc_cursor_destroy (cursor); - - return ret; -} - - -mongoc_cursor_t * -mongoc_client_find_databases (mongoc_client_t *client, bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - BSON_UNUSED (error); - - /* existing bug in this deprecated API: error pointer is unused */ - return mongoc_client_find_databases_with_opts (client, NULL); -} - - -mongoc_cursor_t * -mongoc_client_find_databases_with_opts (mongoc_client_t *client, - const bson_t *opts) -{ - bson_t cmd = BSON_INITIALIZER; - mongoc_cursor_t *cursor; - - BSON_ASSERT_PARAM (client); - BSON_APPEND_INT32 (&cmd, "listDatabases", 1); - cursor = _mongoc_cursor_array_new (client, "admin", &cmd, opts, "databases"); - bson_destroy (&cmd); - return cursor; -} - - -int32_t -mongoc_client_get_max_message_size (mongoc_client_t *client) /* IN */ -{ - BSON_ASSERT_PARAM (client); - - return mongoc_cluster_get_max_msg_size (&client->cluster); -} - - -int32_t -mongoc_client_get_max_bson_size (mongoc_client_t *client) /* IN */ -{ - BSON_ASSERT_PARAM (client); - - return mongoc_cluster_get_max_bson_obj_size (&client->cluster); -} - - -bool -mongoc_client_get_server_status (mongoc_client_t *client, /* IN */ - mongoc_read_prefs_t *read_prefs, /* IN */ - bson_t *reply, /* OUT */ - bson_error_t *error) /* OUT */ -{ - bson_t cmd = BSON_INITIALIZER; - bool ret = false; - - BSON_ASSERT_PARAM (client); - - BSON_APPEND_INT32 (&cmd, "serverStatus", 1); - ret = mongoc_client_command_simple ( - client, "admin", &cmd, read_prefs, reply, error); - bson_destroy (&cmd); - - return ret; -} - - -void -mongoc_client_set_stream_initiator (mongoc_client_t *client, - mongoc_stream_initiator_t initiator, - void *user_data) -{ - BSON_ASSERT_PARAM (client); - - if (!initiator) { - initiator = mongoc_client_default_stream_initiator; - user_data = client; - } else { - MONGOC_DEBUG ("Using custom stream initiator."); - } - - client->initiator = initiator; - client->initiator_data = user_data; - - if (client->topology->single_threaded) { - mongoc_topology_scanner_set_stream_initiator ( - client->topology->scanner, initiator, user_data); - } -} - - -bool -_mongoc_client_set_apm_callbacks_private (mongoc_client_t *client, - mongoc_apm_callbacks_t *callbacks, - void *context) -{ - BSON_ASSERT_PARAM (client); - - if (callbacks) { - memcpy ( - &client->apm_callbacks, callbacks, sizeof (mongoc_apm_callbacks_t)); - } else { - memset (&client->apm_callbacks, 0, sizeof (mongoc_apm_callbacks_t)); - } - - client->apm_context = context; - - /* A client pool sets APM callbacks for the entire pool. */ - if (client->topology->single_threaded) { - mongoc_topology_set_apm_callbacks ( - client->topology, - /* We are safe to modify the shared_descr directly, since we are - * single-threaded */ - mc_tpld_unsafe_get_mutable (client->topology), - callbacks, - context); - } - - return true; -} - - -bool -mongoc_client_set_apm_callbacks (mongoc_client_t *client, - mongoc_apm_callbacks_t *callbacks, - void *context) -{ - BSON_ASSERT_PARAM (client); - - if (!client->topology->single_threaded) { - MONGOC_ERROR ("Cannot set callbacks on a pooled client, use " - "mongoc_client_pool_set_apm_callbacks"); - return false; - } - - return _mongoc_client_set_apm_callbacks_private (client, callbacks, context); -} - -mongoc_server_description_t * -mongoc_client_get_server_description (mongoc_client_t *client, - uint32_t server_id) -{ - BSON_ASSERT_PARAM (client); - - mongoc_server_description_t *ret; - mc_shared_tpld td = mc_tpld_take_ref (client->topology); - mongoc_server_description_t const *sd = - mongoc_topology_description_server_by_id_const ( - td.ptr, server_id, NULL /* <- the error info isn't useful */); - ret = mongoc_server_description_new_copy (sd); - mc_tpld_drop_ref (&td); - return ret; -} - - -mongoc_server_description_t ** -mongoc_client_get_server_descriptions (const mongoc_client_t *client, - size_t *n /* OUT */) -{ - BSON_ASSERT_PARAM (client); - - mc_shared_tpld td = - mc_tpld_take_ref (BSON_ASSERT_PTR_INLINE (client)->topology); - mongoc_server_description_t **const sds = - mongoc_topology_description_get_servers (td.ptr, - BSON_ASSERT_PTR_INLINE (n)); - mc_tpld_drop_ref (&td); - return sds; -} - - -void -mongoc_server_descriptions_destroy_all (mongoc_server_description_t **sds, - size_t n) -{ - size_t i; - - for (i = 0; i < n; ++i) { - mongoc_server_description_destroy (sds[i]); - } - - bson_free (sds); -} - - -mongoc_server_description_t * -mongoc_client_select_server (mongoc_client_t *client, - bool for_writes, - const mongoc_read_prefs_t *prefs, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - - mongoc_ss_optype_t optype = for_writes ? MONGOC_SS_WRITE : MONGOC_SS_READ; - mongoc_server_description_t *sd; - - if (for_writes && prefs) { - bson_set_error (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "Cannot use read preferences with for_writes = true"); - return NULL; - } - - if (!_mongoc_read_prefs_validate (prefs, error)) { - return NULL; - } - - sd = mongoc_topology_select ( - client->topology, optype, prefs, NULL /* chosen read mode */, error); - if (!sd) { - return NULL; - } - - if (mongoc_cluster_check_interval (&client->cluster, sd->id)) { - /* check not required, or it succeeded */ - return sd; - } - - /* check failed, retry once */ - mongoc_server_description_destroy (sd); - sd = mongoc_topology_select ( - client->topology, optype, prefs, NULL /* chosen read mode */, error); - if (sd) { - return sd; - } - - return NULL; -} - -bool -mongoc_client_set_error_api (mongoc_client_t *client, int32_t version) -{ - BSON_ASSERT_PARAM (client); - - if (!client->topology->single_threaded) { - MONGOC_ERROR ("Cannot set Error API Version on a pooled client, use " - "mongoc_client_pool_set_error_api"); - return false; - } - - if (version != MONGOC_ERROR_API_VERSION_LEGACY && - version != MONGOC_ERROR_API_VERSION_2) { - MONGOC_ERROR ("Unsupported Error API Version: %" PRId32, version); - return false; - } - - if (client->error_api_set) { - MONGOC_ERROR ("Can only set Error API Version once"); - return false; - } - - client->error_api_version = version; - client->error_api_set = true; - - return true; -} - -bool -mongoc_client_set_appname (mongoc_client_t *client, const char *appname) -{ - BSON_ASSERT_PARAM (client); - - if (!client->topology->single_threaded) { - MONGOC_ERROR ("Cannot call set_appname on a client from a pool"); - return false; - } - - return _mongoc_topology_set_appname (client->topology, appname); -} - -mongoc_server_session_t * -_mongoc_client_pop_server_session (mongoc_client_t *client, bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - - return _mongoc_topology_pop_server_session (client->topology, error); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_client_lookup_session -- - * - * Retrieve a mongoc_client_session_t associated with @client_session_id. - * Use this to find the "lsid" and "$clusterTime" to send in the server - * command. - * - * Returns: - * True on success, false on error and @error is set. Will return false - * if the session is from an outdated client generation, a holdover - * from before a call to mongoc_client_reset. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_client_lookup_session (const mongoc_client_t *client, - uint32_t client_session_id, - mongoc_client_session_t **cs /* OUT */, - bson_error_t *error /* OUT */) -{ - ENTRY; - BSON_ASSERT_PARAM (client); - - *cs = mongoc_set_get (client->client_sessions, client_session_id); - - if (*cs) { - RETURN (true); - } - - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid sessionId"); - - RETURN (false); -} - -void -_mongoc_client_unregister_session (mongoc_client_t *client, - mongoc_client_session_t *session) -{ - BSON_ASSERT_PARAM (client); - - mongoc_set_rm (client->client_sessions, session->client_session_id); -} - -void -_mongoc_client_push_server_session (mongoc_client_t *client, - mongoc_server_session_t *server_session) -{ - BSON_ASSERT_PARAM (client); - - _mongoc_topology_push_server_session (client->topology, server_session); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_client_end_sessions -- - * - * End all server sessions in the topology's server session pool. - * Don't block long: if server selection or connecting fails, quit. - * - * The server session pool becomes invalid, but may not be empty. - * Destroy the topology after this without using any sessions. - * - *-------------------------------------------------------------------------- - */ - -void -_mongoc_client_end_sessions (mongoc_client_t *client) -{ - mongoc_topology_t *t = client->topology; - mongoc_read_prefs_t *prefs; - bson_error_t error; - uint32_t server_id; - bson_t cmd; - mongoc_server_stream_t *stream; - mongoc_cmd_parts_t parts; - mongoc_cluster_t *cluster = &client->cluster; - bool r; - - BSON_ASSERT_PARAM (client); - - while (!mongoc_server_session_pool_is_empty (t->session_pool)) { - prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY_PREFERRED); - server_id = - mongoc_topology_select_server_id (t, - MONGOC_SS_READ, - prefs, - NULL /* chosen read mode */, - NULL /* deprioritized servers */, - &error); - - mongoc_read_prefs_destroy (prefs); - if (!server_id) { - MONGOC_WARNING ("Couldn't send \"endSessions\": %s", error.message); - return; - } - - stream = mongoc_cluster_stream_for_server ( - cluster, server_id, false /* reconnect_ok */, NULL, NULL, &error); - - if (!stream) { - MONGOC_WARNING ("Couldn't send \"endSessions\": %s", error.message); - return; - } - - /* end sessions in chunks */ - while (_mongoc_topology_end_sessions_cmd (t, &cmd)) { - mongoc_cmd_parts_init ( - &parts, client, "admin", MONGOC_QUERY_SECONDARY_OK, &cmd); - parts.assembled.operation_id = ++cluster->operation_id; - parts.prohibit_lsid = true; - - r = mongoc_cmd_parts_assemble (&parts, stream, &error); - if (!r) { - MONGOC_WARNING ("Couldn't construct \"endSessions\" command: %s", - error.message); - } else { - r = mongoc_cluster_run_command_monitored ( - cluster, &parts.assembled, NULL, &error); - - if (!r) { - MONGOC_WARNING ("Couldn't send \"endSessions\": %s", - error.message); - } - } - - mongoc_cmd_parts_cleanup (&parts); - - if (!mongoc_cluster_stream_valid (cluster, stream)) { - /* The stream was invalidated as a result of a network error, so we - * stop sending commands. */ - break; - } - - bson_destroy (&cmd); - } - - bson_destroy (&cmd); - mongoc_server_stream_cleanup (stream); - } -} - -void -mongoc_client_reset (mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (client); - - client->generation++; - - /* Client sessions are owned and destroyed by the user, but we keep - local pointers to them for reference. On reset, clear our local - set without destroying the sessions or calling endSessions. - client_sessions has no dtor, so it won't destroy its items. - - Destroying the local cache of client sessions here ensures they - cannot be used by future operations--lookup for them will fail. */ - mongoc_set_destroy (client->client_sessions); - client->client_sessions = mongoc_set_new (8, NULL, NULL); - - /* Server sessions are owned by us, so we clear the pool on reset. */ - mongoc_server_session_pool_clear (client->topology->session_pool); -} - -mongoc_change_stream_t * -mongoc_client_watch (mongoc_client_t *client, - const bson_t *pipeline, - const bson_t *opts) -{ - return _mongoc_change_stream_new_from_client (client, pipeline, opts); -} - -bool -mongoc_client_enable_auto_encryption (mongoc_client_t *client, - mongoc_auto_encryption_opts_t *opts, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - - if (!client->topology->single_threaded) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Cannot enable auto encryption on a pooled client, use " - "mongoc_client_pool_enable_auto_encryption"); - return false; - } - return _mongoc_cse_client_enable_auto_encryption (client, opts, error); -} - -bool -mongoc_client_set_server_api (mongoc_client_t *client, - const mongoc_server_api_t *api, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - BSON_ASSERT_PARAM (api); - - if (client->is_pooled) { - bson_set_error ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_API_FROM_POOL, - "Cannot set server api on a client checked out from a pool"); - return false; - } - - if (mongoc_client_uses_server_api (client)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_API_ALREADY_SET, - "Cannot set server api more than once per client"); - return false; - } - - client->api = mongoc_server_api_copy (api); - _mongoc_topology_scanner_set_server_api (client->topology->scanner, api); - return true; -} - -mongoc_server_description_t * -mongoc_client_get_handshake_description (mongoc_client_t *client, - uint32_t server_id, - bson_t *opts, - bson_error_t *error) -{ - mongoc_server_stream_t *server_stream; - mongoc_server_description_t *sd; - - BSON_ASSERT_PARAM (client); - BSON_UNUSED (opts); - - server_stream = mongoc_cluster_stream_for_server (&client->cluster, - server_id, - true /* reconnect */, - NULL /* client session */, - NULL /* reply */, - error); - if (!server_stream) { - return NULL; - } - - sd = mongoc_server_description_new_copy (server_stream->sd); - mongoc_server_stream_cleanup (server_stream); - return sd; -} - -bool -mongoc_client_uses_server_api (const mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (client); - - return mongoc_topology_uses_server_api (client->topology); -} - -bool -mongoc_client_uses_loadbalanced (const mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (client); - - return mongoc_topology_uses_loadbalanced (client->topology); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client.h deleted file mode 100644 index cff520fe3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-client.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_CLIENT_H -#define MONGOC_CLIENT_H - -#include - -#include "mongoc-apm.h" -#include "mongoc-client-side-encryption.h" -#include "mongoc-collection.h" -#include "mongoc-config.h" -#include "mongoc-cursor.h" -#include "mongoc-database.h" -#include "mongoc-gridfs.h" -#include "mongoc-index.h" -#include "mongoc-macros.h" -#include "mongoc-read-prefs.h" -#include "mongoc-server-api.h" -#ifdef MONGOC_ENABLE_SSL -#include "mongoc-ssl.h" -#endif -#include "mongoc-stream.h" -#include "mongoc-uri.h" -#include "mongoc-write-concern.h" -#include "mongoc-read-concern.h" -#include "mongoc-server-description.h" - -BSON_BEGIN_DECLS - -/* This define is part of our public API. But per MongoDB 4.4, there is no - * longer a size limit on collection names. */ -#define MONGOC_NAMESPACE_MAX 128 - - -#ifndef MONGOC_DEFAULT_CONNECTTIMEOUTMS -#define MONGOC_DEFAULT_CONNECTTIMEOUTMS (10 * 1000L) -#endif - - -#ifndef MONGOC_DEFAULT_SOCKETTIMEOUTMS -/* - * NOTE: The default socket timeout for connections is 5 minutes. This - * means that if your MongoDB server dies or becomes unavailable - * it will take 5 minutes to detect this. - * - * You can change this by providing sockettimeoutms= in your - * connection URI. - */ -#define MONGOC_DEFAULT_SOCKETTIMEOUTMS (1000L * 60L * 5L) -#endif - - -/** - * mongoc_client_t: - * - * The mongoc_client_t structure maintains information about a connection to - * a MongoDB server. - */ -typedef struct _mongoc_client_t mongoc_client_t; - - -typedef struct _mongoc_client_session_t mongoc_client_session_t; -typedef struct _mongoc_session_opt_t mongoc_session_opt_t; -typedef struct _mongoc_transaction_opt_t mongoc_transaction_opt_t; - -/** - * mongoc_stream_initiator_t: - * @uri: The uri and options for the stream. - * @host: The host and port (or UNIX domain socket path) to connect to. - * @user_data: The pointer passed to mongoc_client_set_stream_initiator. - * @error: A location for an error. - * - * Creates a new mongoc_stream_t for the host and port. Begin a - * non-blocking connect and return immediately. - * - * This can be used by language bindings to create network transports other - * than those built into libmongoc. An example of such would be the streams - * API provided by PHP. - * - * Returns: A newly allocated mongoc_stream_t or NULL on failure. - */ -typedef mongoc_stream_t *(*mongoc_stream_initiator_t) ( - const mongoc_uri_t *uri, - const mongoc_host_list_t *host, - void *user_data, - bson_error_t *error); - - -MONGOC_EXPORT (mongoc_client_t *) -mongoc_client_new (const char *uri_string) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_client_t *) -mongoc_client_new_from_uri (const mongoc_uri_t *uri) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_client_t *) -mongoc_client_new_from_uri_with_error ( - const mongoc_uri_t *uri, bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (const mongoc_uri_t *) -mongoc_client_get_uri (const mongoc_client_t *client); -MONGOC_EXPORT (void) -mongoc_client_set_stream_initiator (mongoc_client_t *client, - mongoc_stream_initiator_t initiator, - void *user_data); -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_client_command (mongoc_client_t *client, - const char *db_name, - mongoc_query_flags_t flags, - uint32_t skip, - uint32_t limit, - uint32_t batch_size, - const bson_t *query, - const bson_t *fields, - const mongoc_read_prefs_t *read_prefs) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_client_kill_cursor (mongoc_client_t *client, - int64_t cursor_id) BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (bool) -mongoc_client_command_simple (mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_client_read_command_with_opts (mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_client_write_command_with_opts (mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_client_read_write_command_with_opts ( - mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs /* IGNORED */, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_client_command_with_opts (mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_client_command_simple_with_server_id ( - mongoc_client_t *client, - const char *db_name, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - uint32_t server_id, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (void) -mongoc_client_destroy (mongoc_client_t *client); -MONGOC_EXPORT (mongoc_client_session_t *) -mongoc_client_start_session (mongoc_client_t *client, - const mongoc_session_opt_t *opts, - bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_database_t *) -mongoc_client_get_database (mongoc_client_t *client, - const char *name) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_database_t *) -mongoc_client_get_default_database (mongoc_client_t *client) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_gridfs_t *) -mongoc_client_get_gridfs (mongoc_client_t *client, - const char *db, - const char *prefix, - bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_collection_t *) -mongoc_client_get_collection (mongoc_client_t *client, - const char *db, - const char *collection) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (char **) -mongoc_client_get_database_names (mongoc_client_t *client, bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT - BSON_GNUC_DEPRECATED_FOR (mongoc_client_get_database_names_with_opts); -MONGOC_EXPORT (char **) -mongoc_client_get_database_names_with_opts (mongoc_client_t *client, - const bson_t *opts, - bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_client_find_databases (mongoc_client_t *client, - bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT - BSON_GNUC_DEPRECATED_FOR (mongoc_client_find_databases_with_opts); -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_client_find_databases_with_opts ( - mongoc_client_t *client, const bson_t *opts) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (bool) -mongoc_client_get_server_status (mongoc_client_t *client, - mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error) BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (int32_t) -mongoc_client_get_max_message_size (mongoc_client_t *client) - BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (int32_t) -mongoc_client_get_max_bson_size (mongoc_client_t *client) BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (const mongoc_write_concern_t *) -mongoc_client_get_write_concern (const mongoc_client_t *client); -MONGOC_EXPORT (void) -mongoc_client_set_write_concern (mongoc_client_t *client, - const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (const mongoc_read_concern_t *) -mongoc_client_get_read_concern (const mongoc_client_t *client); -MONGOC_EXPORT (void) -mongoc_client_set_read_concern (mongoc_client_t *client, - const mongoc_read_concern_t *read_concern); -MONGOC_EXPORT (const mongoc_read_prefs_t *) -mongoc_client_get_read_prefs (const mongoc_client_t *client); -MONGOC_EXPORT (void) -mongoc_client_set_read_prefs (mongoc_client_t *client, - const mongoc_read_prefs_t *read_prefs); -#ifdef MONGOC_ENABLE_SSL -MONGOC_EXPORT (void) -mongoc_client_set_ssl_opts (mongoc_client_t *client, - const mongoc_ssl_opt_t *opts); -#endif -MONGOC_EXPORT (bool) -mongoc_client_set_apm_callbacks (mongoc_client_t *client, - mongoc_apm_callbacks_t *callbacks, - void *context); -MONGOC_EXPORT (mongoc_server_description_t *) -mongoc_client_get_server_description ( - mongoc_client_t *client, uint32_t server_id) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_server_description_t **) -mongoc_client_get_server_descriptions (const mongoc_client_t *client, - size_t *n) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_server_descriptions_destroy_all (mongoc_server_description_t **sds, - size_t n); -MONGOC_EXPORT (mongoc_server_description_t *) -mongoc_client_select_server (mongoc_client_t *client, - bool for_writes, - const mongoc_read_prefs_t *prefs, - bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (bool) -mongoc_client_set_error_api (mongoc_client_t *client, int32_t version); -MONGOC_EXPORT (bool) -mongoc_client_set_appname (mongoc_client_t *client, const char *appname); -MONGOC_EXPORT (mongoc_change_stream_t *) -mongoc_client_watch (mongoc_client_t *client, - const bson_t *pipeline, - const bson_t *opts) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_client_reset (mongoc_client_t *client); - -MONGOC_EXPORT (bool) -mongoc_client_enable_auto_encryption (mongoc_client_t *client, - mongoc_auto_encryption_opts_t *opts, - bson_error_t *error); - -MONGOC_EXPORT (const char *) -mongoc_client_get_crypt_shared_version (const mongoc_client_t *client) - BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (bool) -mongoc_client_set_server_api (mongoc_client_t *client, - const mongoc_server_api_t *api, - bson_error_t *error); - -MONGOC_EXPORT (mongoc_server_description_t *) -mongoc_client_get_handshake_description (mongoc_client_t *client, - uint32_t server_id, - bson_t *opts, - bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT; - -BSON_END_DECLS - - -#endif /* MONGOC_CLIENT_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-aws.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-aws.c deleted file mode 100644 index 9455e300e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-aws.c +++ /dev/null @@ -1,1536 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* All interaction with kms_message is limited to this file. */ - -#include "common-b64-private.h" -#include "mcd-time.h" -#include "mongoc-cluster-aws-private.h" -#include "mongoc-client-private.h" -#include "mongoc-host-list-private.h" -#include "mongoc-rand-private.h" -#include "mongoc-stream-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-uri-private.h" -#include "mongoc-util-private.h" -#include "mongoc-http-private.h" -#include "mongoc-rand-private.h" -#include "mongoc-ssl-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "aws_auth" - -#define AUTH_ERROR_AND_FAIL(...) \ - do { \ - bson_set_error (error, \ - MONGOC_ERROR_CLIENT, \ - MONGOC_ERROR_CLIENT_AUTHENTICATE, \ - __VA_ARGS__); \ - goto fail; \ - } while (0) - - -#ifdef MONGOC_ENABLE_MONGODB_AWS_AUTH -#include "kms_message/kms_message.h" - -/* - * Run a single command on a stream. - * - * On success, returns true. - * On failure, returns false and sets error. - * reply is always initialized. - */ -static bool -_run_command (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_t *command, - bson_t *reply, - bson_error_t *error) -{ - mongoc_cmd_parts_t parts; - mongoc_server_stream_t *server_stream; - bool ret; - mc_shared_tpld td = - mc_tpld_take_ref (BSON_ASSERT_PTR_INLINE (cluster)->client->topology); - - mongoc_cmd_parts_init (&parts, - cluster->client, - "$external", - MONGOC_QUERY_NONE /* unused for OP_MSG */, - command); - /* Drivers must not append session ids to auth commands per sessions spec. */ - parts.prohibit_lsid = true; - server_stream = _mongoc_cluster_create_server_stream (td.ptr, sd, stream); - mc_tpld_drop_ref (&td); - ret = mongoc_cluster_run_command_parts ( - cluster, server_stream, &parts, reply, error); - mongoc_server_stream_cleanup (server_stream); - return ret; -} - -/* - * Utility function to parse out a server reply's payload. - * - * Given a server reply like { ok: 1, payload: , ... } parse out the - * payload into a bson_t. - * On success, returns true. - * On failure, returns false and sets error. - * payload is always initialized. - */ -static bool -_sasl_reply_parse_payload_as_bson (const bson_t *reply, - bson_t *payload, - bson_error_t *error) -{ - bson_iter_t iter; - bson_subtype_t payload_subtype; - const uint8_t *payload_data; - uint32_t payload_len; - bool ret = false; - - bson_init (payload); - - if (!bson_iter_init_find (&iter, reply, "payload") || - !BSON_ITER_HOLDS_BINARY (&iter)) { - AUTH_ERROR_AND_FAIL ("server reply did not contain binary payload"); - } - - bson_iter_binary (&iter, &payload_subtype, &payload_len, &payload_data); - - if (payload_subtype != BSON_SUBTYPE_BINARY) { - AUTH_ERROR_AND_FAIL ("server reply contained unexpected binary subtype"); - } - - bson_destroy (payload); - if (!bson_init_static (payload, payload_data, payload_len)) { - AUTH_ERROR_AND_FAIL ("server payload is invalid BSON"); - } - - ret = true; -fail: - return ret; -} - - -/* - * Send an HTTP request and get a response. - * On success, returns true. - * On failure, returns false and sets error. - * headers is a \r\n delimitted list of headers (or an empty string). - * http_response_body is always set, and must be freed. - * http_response_headers is always set, and must be freed. This may be used for - * error reporting since the response headers should not include sensitive - * credentials. - */ -static bool -_send_http_request (bool use_tls, - const char *ip, - int port, - const char *method, - const char *path, - const char *headers, - char **http_response_body, - char **http_response_headers, - bson_error_t *error) -{ - mongoc_http_request_t req; - mongoc_http_response_t res; - const int socket_timeout_ms = 10000; - bool ret; - mongoc_ssl_opt_t ssl_opt = {0}; - - *http_response_body = NULL; - *http_response_headers = NULL; - _mongoc_http_request_init (&req); - _mongoc_http_response_init (&res); - - req.host = ip; - req.port = port; - req.method = method; - req.path = path; - req.extra_headers = headers; - if (use_tls) { - _mongoc_ssl_opts_copy_to ( - mongoc_ssl_opt_get_default (), &ssl_opt, true /* copy_internal */); - } - ret = _mongoc_http_send (&req, - socket_timeout_ms, - use_tls /* use_tls */, - use_tls ? &ssl_opt : NULL, - &res, - error); - - if (ret) { - *http_response_headers = bson_strndup (res.headers, res.headers_len); - *http_response_body = (char *) bson_malloc0 (res.body_len + 1); - memcpy (*http_response_body, res.body, res.body_len); - } - - _mongoc_http_response_cleanup (&res); - _mongoc_ssl_opts_cleanup (&ssl_opt, true); - return ret; -} - - -static bool -_creds_empty (_mongoc_aws_credentials_t *creds) -{ - return creds->access_key_id == NULL && creds->secret_access_key == NULL && - creds->session_token == NULL; -} - -/* - * Helper to validate and possibly set credentials. - * - * On success, returns true. - * On failure, returns false and sets error. - * Caller should use _creds_empty to determine whether credentials have been - * set. - */ -static bool -_validate_and_set_creds (const char *access_key_id, - const char *secret_access_key, - const char *session_token, - _mongoc_aws_credentials_t *creds, - bson_error_t *error) -{ - bool has_access_key_id = access_key_id && strlen (access_key_id) != 0; - bool has_secret_access_key = - secret_access_key && strlen (secret_access_key) != 0; - bool has_session_token = session_token && strlen (session_token) != 0; - bool ret = false; - - /* Check for invalid combinations of URI parameters. */ - if (has_access_key_id && !has_secret_access_key) { - AUTH_ERROR_AND_FAIL ( - "ACCESS_KEY_ID is set, but SECRET_ACCESS_KEY is missing"); - } - - if (!has_access_key_id && has_secret_access_key) { - AUTH_ERROR_AND_FAIL ( - "SECRET_ACCESS_KEY is set, but ACCESS_KEY_ID is missing"); - } - - if (!has_access_key_id && !has_secret_access_key && has_session_token) { - AUTH_ERROR_AND_FAIL ("AWS_SESSION_TOKEN is set, but ACCESS_KEY_ID and " - "SECRET_ACCESS_KEY are missing"); - } - - creds->access_key_id = bson_strdup (access_key_id); - creds->secret_access_key = bson_strdup (secret_access_key); - creds->session_token = session_token ? bson_strdup (session_token) : NULL; - - ret = true; -fail: - return ret; -} - -/* - * Validate and possibly set credentials. - * - * On success, returns true. - * On failure, returns false and sets error. - * Caller should use _creds_empty to determine whether credentials have been - * set. - */ -static bool -_obtain_creds_from_uri (_mongoc_aws_credentials_t *creds, - mongoc_uri_t *uri, - bson_error_t *error) -{ - bool ret = false; - bson_t auth_mechanism_props; - const char *uri_session_token = NULL; - - if (mongoc_uri_get_mechanism_properties (uri, &auth_mechanism_props)) { - bson_iter_t iter; - if (bson_iter_init_find_case ( - &iter, &auth_mechanism_props, "AWS_SESSION_TOKEN") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - uri_session_token = bson_iter_utf8 (&iter, NULL); - } - } - - if (!_validate_and_set_creds (mongoc_uri_get_username (uri), - mongoc_uri_get_password (uri), - uri_session_token, - creds, - error)) { - goto fail; - } - - ret = true; -fail: - return ret; -} - -static bool -_obtain_creds_from_env (_mongoc_aws_credentials_t *creds, bson_error_t *error) -{ - bool ret = false; - char *env_access_key_id = NULL; - char *env_secret_access_key = NULL; - char *env_session_token = NULL; - - /* Check environment variables. */ - env_access_key_id = _mongoc_getenv ("AWS_ACCESS_KEY_ID"); - env_secret_access_key = _mongoc_getenv ("AWS_SECRET_ACCESS_KEY"); - env_session_token = _mongoc_getenv ("AWS_SESSION_TOKEN"); - - if (!_validate_and_set_creds (env_access_key_id, - env_secret_access_key, - env_session_token, - creds, - error)) { - goto fail; - } - ret = true; -fail: - bson_free (env_access_key_id); - bson_free (env_secret_access_key); - bson_free (env_session_token); - return ret; -} - -// expiration_ms_to_timer converts milliseconds since Unix Epoch into the -// mcd_timer `expiration_timer`. -static bool -expiration_ms_to_timer (int64_t expiration_ms, - mcd_timer *expiration_timer, - bson_error_t *error) -{ - bool ret = false; - - // get current time in milliseconds since Unix Epoch. - int64_t now_ms; - { - struct timeval now; - if (0 != bson_gettimeofday (&now)) { - AUTH_ERROR_AND_FAIL ("bson_gettimeofday returned failure. Unable to " - "determine expiration."); - } else { - now_ms = (1000 * now.tv_sec) + (now.tv_usec / 1000); - } - } - - *expiration_timer = mcd_timer_expire_after (mcd_milliseconds ( - expiration_ms - now_ms - MONGOC_AWS_CREDENTIALS_EXPIRATION_WINDOW_MS)); - ret = true; -fail: - return ret; -} - -// expiration_iso8601_to_timer parses the "Expiration" string value returned -// from an ECS or EC2 response. "Expiration" is expected to be an ISO-8601 -// string. Example: "2023-02-07T20:04:27Z". On success, `expiration_timer` is -// set to the expiration time. -static bool -expiration_iso8601_to_timer (const char *expiration_str, - mcd_timer *expiration_timer, - bson_error_t *error) -{ - bool ret = false; - - // get expiration time in milliseconds since Unix Epoch. - int64_t expiration_ms; - { - bson_error_t json_err; - bson_t date_doc; - bson_iter_t date_iter; - char *date_doc_str; - // libbson has private API `_bson_iso8601_date_parse` to parse ISO-8601 - // strings. The private API is inaccessible to libmongoc. - // Create a temporary bson document with a $date to parse. - date_doc_str = bson_strdup_printf ( - "{\"Expiration\" : {\"$date\" : \"%s\"}}", expiration_str); - - if (!bson_init_from_json (&date_doc, date_doc_str, -1, &json_err)) { - bson_free (date_doc_str); - AUTH_ERROR_AND_FAIL ("failed to parse Expiration: %s", - json_err.message); - } - BSON_ASSERT (bson_iter_init_find (&date_iter, &date_doc, "Expiration")); - expiration_ms = bson_iter_date_time (&date_iter); - bson_free (date_doc_str); - bson_destroy (&date_doc); - } - - if (!expiration_ms_to_timer (expiration_ms, expiration_timer, error)) { - goto fail; - } - ret = true; -fail: - return ret; -} - -// generate_AWS_ROLE_SESSION_NAME generates a 16 byte hex string (32 characters) -// to use as the AWS_ROLE_SESSION_NAME. -static char * -generate_AWS_ROLE_SESSION_NAME (bson_error_t *error) -{ -#define NUM_BYTES 16 - bool ok = false; - uint8_t data[NUM_BYTES]; - char *out = bson_malloc (NUM_BYTES * 2 + 1); - if (!_mongoc_rand_bytes (data, NUM_BYTES)) { - AUTH_ERROR_AND_FAIL ( - "unable to generate random bytes for AWS_ROLE_SESSION_NAME"); - } - - size_t i; - for (i = 0; i < NUM_BYTES; i++) { - bson_snprintf (out + (2 * i), 3, "%02x", data[i]); - } - out[NUM_BYTES * 2] = '\0'; - - ok = true; -fail: - if (!ok) { - bson_free (out); - out = NULL; - } - return out; -#undef NUM_BYTES -} - -static bool -_obtain_creds_from_ecs (_mongoc_aws_credentials_t *creds, bson_error_t *error) -{ - bool ret = false; - char *http_response_headers = NULL; - char *http_response_body = NULL; - char *relative_ecs_uri = NULL; - bson_t *response_json = NULL; - bson_iter_t iter; - const char *ecs_access_key_id = NULL; - const char *ecs_secret_access_key = NULL; - const char *ecs_session_token = NULL; - bson_error_t http_error; - - relative_ecs_uri = _mongoc_getenv ("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"); - if (!relative_ecs_uri || strlen (relative_ecs_uri) == 0) { - bson_free (relative_ecs_uri); - return true; - } - - if (!_send_http_request (false /* use_tls */, - "169.254.170.2", - 80, - "GET", - relative_ecs_uri, - "", - &http_response_body, - &http_response_headers, - &http_error)) { - AUTH_ERROR_AND_FAIL ("failed to contact ECS link local server: %s", - http_error.message); - } - - response_json = bson_new_from_json ( - (const uint8_t *) http_response_body, strlen (http_response_body), error); - if (!response_json) { - AUTH_ERROR_AND_FAIL ("invalid JSON in ECS response. Response headers: %s", - http_response_headers); - } - - if (bson_iter_init_find_case (&iter, response_json, "AccessKeyId") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - ecs_access_key_id = bson_iter_utf8 (&iter, NULL); - } - - if (bson_iter_init_find_case (&iter, response_json, "SecretAccessKey") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - ecs_secret_access_key = bson_iter_utf8 (&iter, NULL); - } - - if (bson_iter_init_find_case (&iter, response_json, "Token") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - ecs_session_token = bson_iter_utf8 (&iter, NULL); - } - - if (bson_iter_init_find_case (&iter, response_json, "Expiration") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - if (!expiration_iso8601_to_timer ( - bson_iter_utf8 (&iter, NULL), &creds->expiration.value, error)) { - goto fail; - } - creds->expiration.set = true; - } - - if (!_validate_and_set_creds (ecs_access_key_id, - ecs_secret_access_key, - ecs_session_token, - creds, - error)) { - goto fail; - } - - ret = true; -fail: - bson_destroy (response_json); - bson_free (http_response_headers); - bson_free (http_response_body); - bson_free (relative_ecs_uri); - return ret; -} - -static bool -_obtain_creds_from_assumerolewithwebidentity (_mongoc_aws_credentials_t *creds, - bson_error_t *error) -{ - bool ret = false; - char *http_response_headers = NULL; - char *http_response_body = NULL; - char *aws_web_identity_token_file = NULL; - char *aws_role_arn = NULL; - char *aws_role_session_name = NULL; - bson_t *response_bson = NULL; - bson_iter_t iter; - const char *access_key_id = NULL; - const char *secret_access_key = NULL; - const char *session_token = NULL; - bson_error_t http_error; - mongoc_stream_t *fstream = NULL; - bson_string_t *token_file_contents = NULL; - char *path_and_query = NULL; - - aws_web_identity_token_file = _mongoc_getenv ("AWS_WEB_IDENTITY_TOKEN_FILE"); - aws_role_arn = _mongoc_getenv ("AWS_ROLE_ARN"); - if (!aws_web_identity_token_file || - strlen (aws_web_identity_token_file) == 0 || !aws_role_arn || - strlen (aws_role_arn) == 0) { - bson_free (aws_role_arn); - bson_free (aws_web_identity_token_file); - // Not an error. May need to obtain credentials another way. - return true; - } - - aws_role_session_name = _mongoc_getenv ("AWS_ROLE_SESSION_NAME"); - if (!aws_role_session_name) { - aws_role_session_name = generate_AWS_ROLE_SESSION_NAME (error); - if (!aws_role_session_name) { - goto fail; - } - } - - // Read the contents of the file given by ``AWS_WEB_IDENTITY_TOKEN_FILE``. - { - fstream = mongoc_stream_file_new_for_path ( - aws_web_identity_token_file, O_RDONLY, 0); - if (!fstream) { - AUTH_ERROR_AND_FAIL ( - "failed to open AWS_WEB_IDENTITY_TOKEN_FILE: %s. Reason: %s", - aws_web_identity_token_file, - strerror (errno)); - } - - token_file_contents = bson_string_new (NULL); - - for (;;) { - char buf[128]; - ssize_t got = mongoc_stream_read ( - fstream, - buf, - sizeof (buf) - 1 /* leave space for null terminator */, - 0 /* min_bytes */, - 0 /* timeout_msec. Unused for file stream. */); - - if (got > 0) { - // add null terminator. - buf[got] = '\0'; - bson_string_append (token_file_contents, (const char *) buf); - } else if (got == 0) { - // EOF. - break; - } else { - AUTH_ERROR_AND_FAIL ( - "failed to read AWS_WEB_IDENTITY_TOKEN_FILE: %s. Reason: %s", - aws_web_identity_token_file, - strerror (errno)); - } - } - } - - path_and_query = - bson_strdup_printf ("/?Action=AssumeRoleWithWebIdentity" - "&RoleSessionName=%s" - "&RoleArn=%s" - "&WebIdentityToken=%s&Version=2011-06-15", - aws_role_session_name, - aws_role_arn, - token_file_contents->str); - - // send an HTTP request to sts.amazonaws.com. - if (!_send_http_request (true /* use_tls */, - "sts.amazonaws.com", - 443, - "POST", - path_and_query, - "Accept: application/json\r\n", - &http_response_body, - &http_response_headers, - &http_error)) { - AUTH_ERROR_AND_FAIL ("failed to contact sts.amazonaws.com: %s", - http_error.message); - } - - response_bson = bson_new_from_json ( - (const uint8_t *) http_response_body, strlen (http_response_body), error); - if (!response_bson) { - AUTH_ERROR_AND_FAIL ("invalid JSON in response from sts.amazonaws.com. " - "Response headers: %s", - http_response_headers); - } - - if (!bson_iter_init (&iter, response_bson)) { - AUTH_ERROR_AND_FAIL ("failed to initialize BSON iterator to response: %s", - http_response_body); - } - - // If the response contains "Error", return only the "Error" document. - // Do not include http_response_body in subsequent errors to limit risk of - // including credentials in error messages. - bson_iter_t Error_iter; - if (bson_iter_init_find (&Error_iter, response_bson, "Error")) { - bson_t Error_bson; - if (!_mongoc_iter_document_as_bson (&Error_iter, &Error_bson, error)) { - goto fail; - } - char *Error_json = bson_as_json (&Error_bson, NULL); - bson_set_error ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Response to AssumeRoleWithWebIdentity contains 'Error': %s", - Error_json); - bson_free (Error_json); - goto fail; - } - - bson_iter_t Credentials_iter; - if (!bson_iter_find_descendant ( - &iter, - "AssumeRoleWithWebIdentityResponse.AssumeRoleWithWebIdentityResult." - "Credentials", - &iter)) { - AUTH_ERROR_AND_FAIL ( - "did not find " - "AssumeRoleWithWebIdentityResponse.AssumeRoleWithWebIdentityResult." - "Credentials in response from sts.amazonaws.com."); - } - - if (!bson_iter_recurse (&iter, &Credentials_iter)) { - AUTH_ERROR_AND_FAIL ( - "Unable to recurse in Credentials in response from sts.amazonaws.com"); - } - - iter = Credentials_iter; - if (bson_iter_find (&iter, "AccessKeyId") && BSON_ITER_HOLDS_UTF8 (&iter)) { - access_key_id = bson_iter_utf8 (&iter, NULL); - } else { - AUTH_ERROR_AND_FAIL ( - "did not find AccessKeyId in response from sts.amazonaws.com"); - } - - iter = Credentials_iter; - if (bson_iter_find (&iter, "SecretAccessKey") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - secret_access_key = bson_iter_utf8 (&iter, NULL); - } else { - AUTH_ERROR_AND_FAIL ( - "did not find SecretAccessKey in response from sts.amazonaws.com"); - } - - iter = Credentials_iter; - if (bson_iter_find (&iter, "SessionToken") && BSON_ITER_HOLDS_UTF8 (&iter)) { - session_token = bson_iter_utf8 (&iter, NULL); - } else { - AUTH_ERROR_AND_FAIL ( - "did not find SessionToken in response from sts.amazonaws.com"); - } - - iter = Credentials_iter; - if (bson_iter_find (&iter, "Expiration") && BSON_ITER_HOLDS_DOUBLE (&iter)) { - // "Expiration" is returned as a double representing the number of seconds - // since Unix Epoch. This differs from the ISO-8601 string returned in EC2 - // and ECS responses. - int64_t expiration_ms = (int64_t) (1000.0 * bson_iter_double (&iter)); - if (!expiration_ms_to_timer ( - expiration_ms, &creds->expiration.value, error)) { - goto fail; - } - creds->expiration.set = true; - } else { - AUTH_ERROR_AND_FAIL ( - "did not find Expiration in response from sts.amazonaws.com"); - } - - if (!_validate_and_set_creds ( - access_key_id, secret_access_key, session_token, creds, error)) { - goto fail; - } - - ret = true; -fail: - bson_free (path_and_query); - bson_destroy (response_bson); - bson_free (http_response_headers); - bson_free (http_response_body); - bson_string_free (token_file_contents, true /* free segment */); - mongoc_stream_destroy (fstream); - bson_free (aws_role_session_name); - bson_free (aws_role_arn); - bson_free (aws_web_identity_token_file); - return ret; -} - -static bool -_obtain_creds_from_ec2 (_mongoc_aws_credentials_t *creds, bson_error_t *error) -{ - bool ret = false; - char *http_response_headers = NULL; - char *http_response_body = NULL; - char *token_header = NULL; - char *token = NULL; - char *role_name = NULL; - char *relative_ecs_uri = NULL; - char *path_with_role = NULL; - bson_t *response_json = NULL; - bson_iter_t iter; - const char *ec2_access_key_id = NULL; - const char *ec2_secret_access_key = NULL; - const char *ec2_session_token = NULL; - bson_error_t http_error; - const char *ip = "169.254.169.254"; - - /* Get the token. */ - if (!_send_http_request (false /* use_tls */, - ip, - 80, - "PUT", - "/latest/api/token", - "X-aws-ec2-metadata-token-ttl-seconds: 30\r\n", - &token, - &http_response_headers, - &http_error)) { - AUTH_ERROR_AND_FAIL ("failed to contact EC2 link local server: %s", - http_error.message); - } - - if (0 == strlen (token)) { - AUTH_ERROR_AND_FAIL ( - "unable to retrieve token from EC2 metadata. Headers: %s", - http_response_headers); - } - - bson_free (http_response_headers); - http_response_headers = NULL; - token_header = - bson_strdup_printf ("X-aws-ec2-metadata-token: %s\r\n", token); - - /* Get the role name. */ - if (!_send_http_request (false /* use_tls */, - ip, - 80, - "GET", - "/latest/meta-data/iam/security-credentials/", - token_header, - &role_name, - &http_response_headers, - &http_error)) { - AUTH_ERROR_AND_FAIL ("failed to contact EC2 link local server: %s", - http_error.message); - } - - if (0 == strlen (role_name)) { - AUTH_ERROR_AND_FAIL ( - "unable to retrieve role_name from EC2 metadata. Headers: %s", - http_response_headers); - } - - /* Get the creds. */ - path_with_role = bson_strdup_printf ( - "/latest/meta-data/iam/security-credentials/%s", role_name); - bson_free (http_response_headers); - http_response_headers = NULL; - if (!_send_http_request (false /* use_tls */, - ip, - 80, - "GET", - path_with_role, - token_header, - &http_response_body, - &http_response_headers, - &http_error)) { - AUTH_ERROR_AND_FAIL ("failed to contact EC2 link local server: %s", - http_error.message); - } - - response_json = bson_new_from_json ( - (const uint8_t *) http_response_body, strlen (http_response_body), error); - if (!response_json) { - AUTH_ERROR_AND_FAIL ("invalid JSON in EC2 response. Response headers: %s", - http_response_headers); - } - - if (bson_iter_init_find_case (&iter, response_json, "AccessKeyId") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - ec2_access_key_id = bson_iter_utf8 (&iter, NULL); - } - - if (bson_iter_init_find_case (&iter, response_json, "SecretAccessKey") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - ec2_secret_access_key = bson_iter_utf8 (&iter, NULL); - } - - if (bson_iter_init_find_case (&iter, response_json, "Token") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - ec2_session_token = bson_iter_utf8 (&iter, NULL); - } - - if (bson_iter_init_find_case (&iter, response_json, "Expiration") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - if (!expiration_iso8601_to_timer ( - bson_iter_utf8 (&iter, NULL), &creds->expiration.value, error)) { - goto fail; - } - creds->expiration.set = true; - } - - if (!_validate_and_set_creds (ec2_access_key_id, - ec2_secret_access_key, - ec2_session_token, - creds, - error)) { - goto fail; - } - - ret = true; -fail: - bson_destroy (response_json); - bson_free (http_response_headers); - bson_free (http_response_body); - bson_free (token); - bson_free (role_name); - bson_free (token_header); - bson_free (relative_ecs_uri); - bson_free (path_with_role); - return ret; -} - -/* - * Attempt to obtain AWS credentials. - * - * Credentials may be passed in multiple ways. The precedence is as follows: - * 1. Username/password in the URI (and authMechanismProperty for session token) - * 2. From environment variables. - * 3. From querying the ECS local HTTP server. - * 4. From querying the EC2 local HTTP server. - * - * On success, returns true. - * On failure, returns false and sets error. - */ -bool -_mongoc_aws_credentials_obtain (mongoc_uri_t *uri, - _mongoc_aws_credentials_t *creds, - bson_error_t *error) -{ - bool ret = false; - - BSON_ASSERT_PARAM (creds); - *creds = MONGOC_AWS_CREDENTIALS_INIT; - - // Check cache before enviroment variables. This is required by the - // specification: "Even if the environment variables are present in - // subsequent authorization attempts, the driver MUST use the cached - // credentials" - if (_mongoc_aws_credentials_cache_get (creds)) { - goto succeed; - } - - if (uri) { - TRACE ("%s", "checking URI for credentials"); - if (!_obtain_creds_from_uri (creds, uri, error)) { - goto fail; - } - if (!_creds_empty (creds)) { - goto succeed; - } - } - - TRACE ("%s", "checking environment variables for credentials"); - if (!_obtain_creds_from_env (creds, error)) { - goto fail; - } - if (!_creds_empty (creds)) { - goto succeed; - } - - // Try to fetch credentials from cacheable sources: - // AssumeRoleWithWebIdentity, ECS or EC2. Lock the cache to prevent duplicate - // requests. - { - _mongoc_aws_credentials_cache_lock (); - - // Check again if credentials have been cached. - if (_mongoc_aws_credentials_cache_get_nolock (creds)) { - _mongoc_aws_credentials_cache_unlock (); - goto succeed; - } - - TRACE ("%s", "checking AssumeRoleWithWebIdentity for credentials"); - if (!_obtain_creds_from_assumerolewithwebidentity (creds, error)) { - _mongoc_aws_credentials_cache_unlock (); - goto fail; - } - if (!_creds_empty (creds)) { - if (creds->expiration.set) { - // Only try to cache credentials if an expiration time is included. - _mongoc_aws_credentials_cache_put_nolock (creds); - } - _mongoc_aws_credentials_cache_unlock (); - goto succeed; - } - - TRACE ("%s", "checking ECS metadata for credentials"); - if (!_obtain_creds_from_ecs (creds, error)) { - _mongoc_aws_credentials_cache_unlock (); - goto fail; - } - if (!_creds_empty (creds)) { - if (creds->expiration.set) { - // Only try to cache credentials if an expiration time is included. - _mongoc_aws_credentials_cache_put_nolock (creds); - } - _mongoc_aws_credentials_cache_unlock (); - goto succeed; - } - - TRACE ("%s", "checking EC2 metadata for credentials"); - if (!_obtain_creds_from_ec2 (creds, error)) { - _mongoc_aws_credentials_cache_unlock (); - goto fail; - } - if (!_creds_empty (creds)) { - if (creds->expiration.set) { - // Only try to cache credentials if an expiration time is included. - _mongoc_aws_credentials_cache_put_nolock (creds); - } - _mongoc_aws_credentials_cache_unlock (); - goto succeed; - } - - _mongoc_aws_credentials_cache_unlock (); - } - - AUTH_ERROR_AND_FAIL ("unable to get credentials\n"); - -succeed: - ret = true; -fail: - return ret; -} - -/* - * Validate the STS host returned by the server and derive the region. - * - * On success, returns true. - * On failure, returns false and sets error. - * region is always set and must be freed by caller. - */ -bool -_mongoc_validate_and_derive_region (char *sts_fqdn, - size_t sts_fqdn_len, - char **region, - bson_error_t *error) -{ - bool ret = false; - char *ptr; - char *ptr_prev; - char *second_part = NULL; - - /* Default to us-east-1. */ - *region = bson_strdup ("us-east-1"); - - /* Drivers must also validate that the host is greater than 0 and less than - * or equal to 255 bytes per RFC 1035 */ - if (sts_fqdn_len == 0u) { - AUTH_ERROR_AND_FAIL ("invalid STS host: empty"); - } - - if (sts_fqdn_len > 255u) { - AUTH_ERROR_AND_FAIL ("invalid STS host: too large"); - } - - /* If sts.amazonaws.com, then use default region. */ - if (0 == bson_strcasecmp ("sts.amazonaws.com", sts_fqdn)) { - goto succeed; - } - - /* Drivers MUST reject FQDN names with empty labels, e.g., "abc..def" */ - ptr_prev = sts_fqdn; - ptr = strstr (sts_fqdn, "."); - if (ptr) { - second_part = ptr + 1; - } - if (0 == ptr - sts_fqdn) { - AUTH_ERROR_AND_FAIL ("invalid STS host: empty part"); - } - while (ptr) { - if (1 == ptr - ptr_prev) { - AUTH_ERROR_AND_FAIL ("invalid STS host: empty part"); - } - ptr_prev = ptr; - ptr = strstr (ptr + 1, "."); - } - if (strlen (ptr_prev + 1) == 0) { - AUTH_ERROR_AND_FAIL ("invalid STS host: empty part"); - } - - if (second_part) { - char *second_part_end; - - second_part_end = strstr (second_part, "."); - bson_free (*region); - if (!second_part_end) { - *region = bson_strdup (second_part); - } else { - *region = bson_strndup (second_part, second_part_end - second_part); - } - } - -succeed: - ret = true; -fail: - return ret; -} - -/* -------------------------------------------------------------------------- - * Step 1 - * -------------------------------------------------------------------------- - * Client sends BSON payload: - * { - * "r": <32 byte client nonce>, - * "p": 110 - * } - * Server responds with BSON payload: - * { - * "s": <32 byte client nonce + 32 byte server nonce>, - * "h": - * } - * - * Payloads are wrapped in SASL commands. The command a client sends is like: - * { "saslStart": 1, "mechanism": "MONGODB-AWS", "payload": } - * And similar for server responses: - * { "ok": 1, "conversationId": 1, "done": false, "payload": } - * - * On success, returns true. - * On failure, returns false and sets error. - * -------------------------------------------------------------------------- - */ -static bool -_client_first (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - uint8_t *server_nonce, - char **sts_fqdn, - char **region, - int *conv_id, - bson_error_t *error) -{ - bool ret = false; - uint8_t client_nonce[32]; - bson_t client_payload = BSON_INITIALIZER; - bson_t client_command = BSON_INITIALIZER; - bson_t server_payload = BSON_INITIALIZER; - bson_t server_reply = BSON_INITIALIZER; - bson_iter_t iter; - bson_subtype_t reply_nonce_subtype; - const uint8_t *reply_nonce_data; - uint32_t reply_nonce_len; - uint32_t sts_fqdn_len; - - /* Reset out params. */ - memset (server_nonce, 0, 32); - *sts_fqdn = NULL; - *region = NULL; - *conv_id = 0; - -#ifdef MONGOC_ENABLE_CRYPTO - /* Generate secure random nonce. */ - if (!_mongoc_rand_bytes (client_nonce, 32)) { - AUTH_ERROR_AND_FAIL ("Could not generate client nonce"); - } -#else - AUTH_ERROR_AND_FAIL ("libmongoc requires a cryptography library (libcrypto, " - "Common Crypto, or cng) to support MONGODB-AWS"); -#endif - - BCON_APPEND (&client_payload, - "r", - BCON_BIN (BSON_SUBTYPE_BINARY, client_nonce, 32), - "p", - BCON_INT32 (110)); - - BCON_APPEND (&client_command, - "saslStart", - BCON_INT32 (1), - "mechanism", - "MONGODB-AWS", - "payload", - BCON_BIN (BSON_SUBTYPE_BINARY, - bson_get_data (&client_payload), - client_payload.len)); - - bson_destroy (&server_reply); - if (!_run_command ( - cluster, stream, sd, &client_command, &server_reply, error)) { - goto fail; - } - - *conv_id = _mongoc_cluster_get_conversation_id (&server_reply); - if (!*conv_id) { - AUTH_ERROR_AND_FAIL ("server reply did not contain conversationId"); - } - - bson_destroy (&server_payload); - if (!_sasl_reply_parse_payload_as_bson ( - &server_reply, &server_payload, error)) { - goto fail; - } - - if (!bson_iter_init_find (&iter, &server_payload, "h") || - !BSON_ITER_HOLDS_UTF8 (&iter)) { - AUTH_ERROR_AND_FAIL ("server payload did not contain string STS FQDN"); - } - *sts_fqdn = bson_strdup (bson_iter_utf8 (&iter, &sts_fqdn_len)); - - if (!_mongoc_validate_and_derive_region ( - *sts_fqdn, sts_fqdn_len, region, error)) { - goto fail; - } - - if (!bson_iter_init_find (&iter, &server_payload, "s") || - !BSON_ITER_HOLDS_BINARY (&iter)) { - AUTH_ERROR_AND_FAIL ("server payload did not contain nonce"); - } - - bson_iter_binary ( - &iter, &reply_nonce_subtype, &reply_nonce_len, &reply_nonce_data); - if (reply_nonce_len != 64) { - AUTH_ERROR_AND_FAIL ("server reply nonce was not 64 bytes"); - } - - if (0 != memcmp (reply_nonce_data, client_nonce, 32)) { - AUTH_ERROR_AND_FAIL ( - "server reply nonce prefix did not match client nonce"); - } - - /* Drivers MUST error on any additional fields */ - bson_iter_init (&iter, &server_payload); - while (bson_iter_next (&iter)) { - const char *field; - - field = bson_iter_key (&iter); - if (0 == strcmp (field, "h")) { - continue; - } - if (0 == strcmp (field, "s")) { - continue; - } - AUTH_ERROR_AND_FAIL ("unexpected field from server's reply: %s", field); - } - - memcpy (server_nonce, reply_nonce_data, 64); - - ret = true; -fail: - bson_destroy (&client_payload); - bson_destroy (&client_command); - bson_destroy (&server_reply); - bson_destroy (&server_payload); - return ret; -} - -#define KMS_REQUEST_ADD_HEADER(key, value) \ - do { \ - if (!kms_request_add_header_field (request, key, value)) { \ - AUTH_ERROR_AND_FAIL ("Failed to add header '%s'", key); \ - } \ - } while (0) - -#define KMS_REQUEST_SET(fn, name, value) \ - do { \ - if (!fn (request, value)) { \ - AUTH_ERROR_AND_FAIL ("Failed to set %s", name); \ - } \ - } while (0) - -/* -------------------------------------------------------------------------- - * Step 2 - * -------------------------------------------------------------------------- - * Client sends BSON payload: - * { - * "a": , - * "d": - * "t": - * } - * - * Server responds with final result. - * - * On success, returns true. - * On failure, returns false and sets error. - * -------------------------------------------------------------------------- - */ -static bool -_client_second (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - _mongoc_aws_credentials_t *creds, - const uint8_t *server_nonce, - const char *sts_fqdn, - const char *region, - int conv_id, - bson_error_t *error) -{ - bool ret = false; - kms_request_t *request = NULL; - char *signature = NULL; - const char *date = NULL; - const size_t server_nonce_str_len = - mcommon_b64_ntop_calculate_target_size (64); - char *server_nonce_str = NULL; - const char *body = "Action=GetCallerIdentity&Version=2011-06-15"; - bson_t client_payload = BSON_INITIALIZER; - bson_t client_command = BSON_INITIALIZER; - bson_t server_reply = BSON_INITIALIZER; - - BSON_ASSERT (cluster); - BSON_ASSERT (stream); - BSON_ASSERT (sd); - BSON_ASSERT (creds); - BSON_ASSERT (server_nonce); - BSON_ASSERT (sts_fqdn); - BSON_ASSERT (conv_id); - BSON_ASSERT (creds->access_key_id); - BSON_ASSERT (creds->secret_access_key); - - server_nonce_str = bson_malloc (server_nonce_str_len); - - request = kms_request_new ("POST", "/", NULL); - if (kms_request_get_error (request)) { - AUTH_ERROR_AND_FAIL ("Failed to create new KMS request: %s", - kms_request_get_error (request)); - } - - if (mcommon_b64_ntop ( - server_nonce, 64, server_nonce_str, server_nonce_str_len) == -1) { - AUTH_ERROR_AND_FAIL ("Failed to parse server nonce"); - } - - if (!kms_request_append_payload (request, body, strlen(body))) { - AUTH_ERROR_AND_FAIL ("Failed to append payload"); - } - - KMS_REQUEST_SET ( - kms_request_set_access_key_id, "access key ID", creds->access_key_id); - KMS_REQUEST_SET ( - kms_request_set_secret_key, "secret key", creds->secret_access_key); - KMS_REQUEST_SET (kms_request_set_date, "date", NULL /* use current time */); - KMS_REQUEST_SET (kms_request_set_region, "region", region); - KMS_REQUEST_SET (kms_request_set_service, "service", "sts"); - - KMS_REQUEST_ADD_HEADER ("Content-Type", "application/x-www-form-urlencoded"); - KMS_REQUEST_ADD_HEADER ("Host", sts_fqdn); - KMS_REQUEST_ADD_HEADER ("X-MongoDB-Server-Nonce", server_nonce_str); - KMS_REQUEST_ADD_HEADER ("X-MongoDB-GS2-CB-Flag", "n"); - if (creds->session_token) { - KMS_REQUEST_ADD_HEADER ("X-Amz-Security-Token", creds->session_token); - } - - signature = kms_request_get_signature (request); - if (kms_request_get_error (request)) { - AUTH_ERROR_AND_FAIL ("Failed to get signature: %s", - kms_request_get_error (request)); - } - - date = kms_request_get_canonical_header (request, "X-Amz-Date"); - if (kms_request_get_error (request)) { - AUTH_ERROR_AND_FAIL ("Failed to get canonical header: %s", - kms_request_get_error (request)); - } - - BCON_APPEND ( - &client_payload, "a", BCON_UTF8 (signature), "d", BCON_UTF8 (date)); - if (creds->session_token) { - BCON_APPEND (&client_payload, "t", BCON_UTF8 (creds->session_token)); - } - - BCON_APPEND (&client_command, - "saslContinue", - BCON_INT32 (1), - "conversationId", - BCON_INT32 (conv_id), - "payload", - BCON_BIN (BSON_SUBTYPE_BINARY, - bson_get_data (&client_payload), - client_payload.len)); - - bson_destroy (&server_reply); - if (!_run_command ( - cluster, stream, sd, &client_command, &server_reply, error)) { - goto fail; - } - - ret = true; -fail: - bson_destroy (&client_payload); - bson_destroy (&client_command); - bson_destroy (&server_reply); - kms_request_destroy (request); - bson_free (signature); - bson_free (server_nonce_str); - return ret; -} - -bool -_mongoc_cluster_auth_node_aws (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_error_t *error) -{ - bool ret = false; - uint8_t server_nonce[64]; - char *sts_fqdn = NULL; - char *region = NULL; - int conv_id = 0; - _mongoc_aws_credentials_t creds = MONGOC_AWS_CREDENTIALS_INIT; - - if (!_mongoc_aws_credentials_obtain (cluster->client->uri, &creds, error)) { - goto fail; - } - - if (!_client_first (cluster, - stream, - sd, - server_nonce, - &sts_fqdn, - ®ion, - &conv_id, - error)) { - goto fail; - } - - if (!_client_second (cluster, - stream, - sd, - &creds, - server_nonce, - sts_fqdn, - region, - conv_id, - error)) { - goto fail; - } - - ret = true; -fail: - if (!ret) { - _mongoc_aws_credentials_cache_clear (); - } - _mongoc_aws_credentials_cleanup (&creds); - bson_free (sts_fqdn); - bson_free (region); - return ret; -} - -#else - -bool -_mongoc_cluster_auth_node_aws (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_error_t *error) -{ - AUTH_ERROR_AND_FAIL ("AWS auth not supported, configure libmongoc with " - "ENABLE_MONGODB_AWS_AUTH=ON"); -fail: - return false; -} - - -bool -_mongoc_aws_credentials_obtain (mongoc_uri_t *uri, - _mongoc_aws_credentials_t *creds, - bson_error_t *error) -{ - AUTH_ERROR_AND_FAIL ("AWS auth not supported, configure libmongoc with " - "ENABLE_MONGODB_AWS_AUTH=ON"); -fail: - return false; -} - -bool -_mongoc_validate_and_derive_region (char *sts_fqdn, - size_t sts_fqdn_len, - char **region, - bson_error_t *error) -{ - AUTH_ERROR_AND_FAIL ("AWS auth not supported, configure libmongoc with " - "ENABLE_MONGODB_AWS_AUTH=ON"); -fail: - return false; -} - -#endif /* MONGOC_ENABLE_MONGODB_AWS_AUTH */ - -void -_mongoc_aws_credentials_cleanup (_mongoc_aws_credentials_t *creds) -{ - bson_free (creds->access_key_id); - bson_free (creds->secret_access_key); - bson_free (creds->session_token); -} - -void -_mongoc_aws_credentials_copy_to (const _mongoc_aws_credentials_t *src, - _mongoc_aws_credentials_t *dst) -{ - BSON_ASSERT_PARAM (src); - BSON_ASSERT_PARAM (dst); - - dst->access_key_id = bson_strdup (src->access_key_id); - dst->secret_access_key = bson_strdup (src->secret_access_key); - dst->session_token = bson_strdup (src->session_token); - dst->expiration = src->expiration; -} - -_mongoc_aws_credentials_cache_t mongoc_aws_credentials_cache; - -void -_mongoc_aws_credentials_cache_init (void) -{ - _mongoc_aws_credentials_cache_t *cache = &mongoc_aws_credentials_cache; - bson_mutex_init (&cache->mutex); -} - -static bool -check_expired (const _mongoc_aws_credentials_t *creds) -{ - if (!creds->expiration.set) { - return true; - } - return mcd_get_milliseconds ( - mcd_timer_remaining (creds->expiration.value)) == 0; -} - -void -_mongoc_aws_credentials_cache_lock (void) -{ - _mongoc_aws_credentials_cache_t *cache = &mongoc_aws_credentials_cache; - bson_mutex_lock (&cache->mutex); -} - -void -_mongoc_aws_credentials_cache_unlock (void) -{ - _mongoc_aws_credentials_cache_t *cache = &mongoc_aws_credentials_cache; - bson_mutex_unlock (&cache->mutex); -} - -void -_mongoc_aws_credentials_cache_put_nolock ( - const _mongoc_aws_credentials_t *creds) -{ - _mongoc_aws_credentials_cache_t *cache = &mongoc_aws_credentials_cache; - BSON_ASSERT_PARAM (creds); - - if (check_expired (creds)) { - // Do not add expired credentials. - return; - } - _mongoc_aws_credentials_cache_clear_nolock (); - _mongoc_aws_credentials_copy_to (creds, &cache->cached.value); - cache->cached.set = true; -} - -void -_mongoc_aws_credentials_cache_put (const _mongoc_aws_credentials_t *creds) -{ - _mongoc_aws_credentials_cache_lock (); - _mongoc_aws_credentials_cache_put_nolock (creds); - _mongoc_aws_credentials_cache_unlock (); -} - -bool -_mongoc_aws_credentials_cache_get_nolock (_mongoc_aws_credentials_t *creds) -{ - _mongoc_aws_credentials_cache_t *cache = &mongoc_aws_credentials_cache; - BSON_ASSERT_PARAM (creds); - bool found_valid = false; - bool expired = false; - if (cache->cached.set) { - expired = check_expired (&cache->cached.value); - if (!expired) { - found_valid = true; - _mongoc_aws_credentials_copy_to (&cache->cached.value, creds); - } - } - if (expired) { - _mongoc_aws_credentials_cache_clear_nolock (); - return false; - } - return found_valid; -} - -bool -_mongoc_aws_credentials_cache_get (_mongoc_aws_credentials_t *creds) -{ - _mongoc_aws_credentials_cache_lock (); - bool got = _mongoc_aws_credentials_cache_get_nolock (creds); - _mongoc_aws_credentials_cache_unlock (); - return got; -} - -void -_mongoc_aws_credentials_cache_clear_nolock (void) -{ - _mongoc_aws_credentials_cache_t *cache = &mongoc_aws_credentials_cache; - - if (cache->cached.set) { - _mongoc_aws_credentials_cleanup (&cache->cached.value); - } - cache->cached.set = false; -} - -void -_mongoc_aws_credentials_cache_clear (void) -{ - _mongoc_aws_credentials_cache_lock (); - _mongoc_aws_credentials_cache_clear_nolock (); - _mongoc_aws_credentials_cache_unlock (); -} - -void -_mongoc_aws_credentials_cache_cleanup (void) -{ - _mongoc_aws_credentials_cache_t *cache = &mongoc_aws_credentials_cache; - if (cache->cached.set) { - _mongoc_aws_credentials_cleanup (&cache->cached.value); - } - bson_mutex_destroy (&cache->mutex); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-cyrus.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-cyrus.c deleted file mode 100644 index 4825010b5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-cyrus.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2017 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SASL_CYRUS -#include "mongoc-client-private.h" -#include "mongoc-cyrus-private.h" -#include "mongoc-cluster-cyrus-private.h" -#include "mongoc-error.h" -#include "mongoc-trace-private.h" - -bool -_mongoc_cluster_auth_node_cyrus (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_error_t *error) -{ - mongoc_cmd_parts_t parts; - mongoc_cyrus_t sasl; - bson_iter_t iter; - bool ret = false; - const char *tmpstr; - /* input into cyrus */ - uint8_t *inbuf = NULL; - uint32_t inbuf_len = 0; - /* output from cyrus */ - uint8_t *outbuf = NULL; - uint32_t outbuf_len = 0; - mc_shared_tpld td = MC_SHARED_TPLD_NULL; - - bson_t cmd; - bson_t reply; - int conv_id = 0; - mongoc_server_stream_t *server_stream; - - BSON_ASSERT (cluster); - BSON_ASSERT (stream); - - if (!_mongoc_cyrus_new_from_cluster ( - &sasl, cluster, stream, sd->host.host, error)) { - return false; - } - - for (;;) { - mongoc_cmd_parts_init ( - &parts, cluster->client, "$external", MONGOC_QUERY_SECONDARY_OK, &cmd); - parts.prohibit_lsid = true; - - /* If this is the first step, input buffer is NULL. */ - bson_free (outbuf); - outbuf = NULL; - outbuf_len = 0; - if (!_mongoc_cyrus_step ( - &sasl, inbuf, inbuf_len, &outbuf, &outbuf_len, error)) { - goto failure; - } - - bson_init (&cmd); - - if (sasl.step == 1) { - _mongoc_cluster_build_sasl_start (&cmd, - sasl.credentials.mechanism, - (const char *) outbuf, - outbuf_len); - } else { - _mongoc_cluster_build_sasl_continue ( - &cmd, conv_id, (const char *) outbuf, outbuf_len); - } - - TRACE ("SASL: authenticating (step %d)", sasl.step); - - mc_tpld_renew_ref (&td, cluster->client->topology); - server_stream = _mongoc_cluster_create_server_stream (td.ptr, sd, stream); - - if (!mongoc_cmd_parts_assemble (&parts, server_stream, error)) { - mongoc_server_stream_cleanup (server_stream); - bson_destroy (&cmd); - goto failure; - } - - if (!mongoc_cluster_run_command_private ( - cluster, &parts.assembled, &reply, error)) { - mongoc_server_stream_cleanup (server_stream); - bson_destroy (&cmd); - bson_destroy (&reply); - goto failure; - } - mongoc_server_stream_cleanup (server_stream); - - bson_destroy (&cmd); - - if (bson_iter_init_find (&iter, &reply, "done") && - bson_iter_as_bool (&iter)) { - bson_destroy (&reply); - break; - } - - conv_id = _mongoc_cluster_get_conversation_id (&reply); - - if (!bson_iter_init_find (&iter, &reply, "payload") || - !BSON_ITER_HOLDS_UTF8 (&iter)) { - MONGOC_DEBUG ("SASL: authentication failed"); - bson_destroy (&reply); - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Received invalid SASL reply from MongoDB server."); - goto failure; - } - - tmpstr = bson_iter_utf8 (&iter, &inbuf_len); - bson_free (inbuf); - /* include the trailing NULL byte, since base64 decoding expects a NULL - * terminates string. */ - inbuf = bson_malloc (inbuf_len + 1); - memcpy (inbuf, tmpstr, inbuf_len + 1); - - bson_destroy (&reply); - mongoc_cmd_parts_cleanup (&parts); - } - - TRACE ("%s", "SASL: authenticated"); - - ret = true; - -failure: - bson_free (inbuf); - bson_free (outbuf); - _mongoc_cyrus_destroy (&sasl); - mongoc_cmd_parts_cleanup (&parts); - mc_tpld_drop_ref (&td); - - return ret; -} -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-private.h deleted file mode 100644 index 7af22850a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-private.h +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_CLUSTER_PRIVATE_H -#define MONGOC_CLUSTER_PRIVATE_H - -#include - -#include "mcd-rpc.h" -#include "mongoc-array-private.h" -#include "mongoc-buffer-private.h" -#include "mongoc-config.h" -#include "mongoc-client.h" -#include "mongoc-list-private.h" -#include "mongoc-opcode.h" -#include "mongoc-rpc-private.h" -#include "mongoc-server-stream-private.h" -#include "mongoc-set-private.h" -#include "mongoc-stream.h" -#include "mongoc-topology-private.h" -#include "mongoc-topology-description-private.h" -#include "mongoc-write-concern.h" -#include "mongoc-scram-private.h" -#include "mongoc-cmd-private.h" -#include "mongoc-crypto-private.h" -#include "mongoc-deprioritized-servers-private.h" - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_cluster_node_t { - mongoc_stream_t *stream; - char *connection_address; - /* handshake_sd is a server description created from the handshake on the - * stream. */ - mongoc_server_description_t *handshake_sd; -} mongoc_cluster_node_t; - -typedef struct _mongoc_cluster_t { - int64_t operation_id; - int32_t request_id; - int32_t sockettimeoutms; - int32_t socketcheckintervalms; - mongoc_uri_t *uri; - unsigned requires_auth : 1; - - mongoc_client_t *client; - - mongoc_set_t *nodes; - mongoc_array_t iov; -} mongoc_cluster_t; - - -void -mongoc_cluster_init (mongoc_cluster_t *cluster, - const mongoc_uri_t *uri, - void *client); - -void -mongoc_cluster_destroy (mongoc_cluster_t *cluster); - -void -mongoc_cluster_disconnect_node (mongoc_cluster_t *cluster, uint32_t id); - -int32_t -mongoc_cluster_get_max_bson_obj_size (mongoc_cluster_t *cluster); - -int32_t -mongoc_cluster_get_max_msg_size (mongoc_cluster_t *cluster); - -size_t -_mongoc_cluster_buffer_iovec (mongoc_iovec_t *iov, - size_t iovcnt, - int skip, - char *buffer); - -bool -mongoc_cluster_check_interval (mongoc_cluster_t *cluster, uint32_t server_id); - -bool -mongoc_cluster_legacy_rpc_sendv_to_server ( - mongoc_cluster_t *cluster, - mcd_rpc_message *rpc, - mongoc_server_stream_t *server_stream, - bson_error_t *error); - -bool -mongoc_cluster_try_recv (mongoc_cluster_t *cluster, - mcd_rpc_message *rpc, - mongoc_buffer_t *buffer, - mongoc_server_stream_t *server_stream, - bson_error_t *error); - -/** - * @brief Obtain a server stream appropriate for read operations on the - * cluster. - * - * Returns a new stream (that must be freed) or NULL and sets an error via - * `error`. - * - * @note The returned stream must be released via - * `mongoc_server_stream_cleanup`. - * - * @note May add nodes and/or update the cluster's topology. - */ -mongoc_server_stream_t * -mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster, - const mongoc_read_prefs_t *read_prefs, - mongoc_client_session_t *cs, - const mongoc_deprioritized_servers_t *ds, - bson_t *reply, - bson_error_t *error); - -/** - * @brief Obtain a server stream appropriate for write operations on the - * cluster. - * - * Returns a new stream (that must be freed) or NULL and sets an error via - * `error`. - * - * @note The returned stream must be released via `mongoc_server_stream_cleanup` - * - * @note May add nodes and/or update the cluster's topology. - */ -mongoc_server_stream_t * -mongoc_cluster_stream_for_writes (mongoc_cluster_t *cluster, - mongoc_client_session_t *cs, - const mongoc_deprioritized_servers_t *ds, - bson_t *reply, - bson_error_t *error); - -/** - * @brief Obtain a server stream appropriate for aggregate operations with - * writes on the cluster. - * - * Returns a new stream (that must be freed) or NULL and sets an error via - * `error`. - * - * @note The returned stream must be released via - * `mongoc_server_stream_cleanup`. - * - * @note May add nodes and/or update the cluster's topology. - */ -mongoc_server_stream_t * -mongoc_cluster_stream_for_aggr_with_write ( - mongoc_cluster_t *cluster, - const mongoc_read_prefs_t *read_prefs, - mongoc_client_session_t *cs, - bson_t *reply, - bson_error_t *error); - -/** - * @brief Obtain a server stream associated with the cluster node associated - * with the given server ID. - * - * Returns a new server stream (that must be freed) or NULL and sets `error`. - * - * @param server_id The ID of a server in the cluster topology. - * @param reconnect_ok If `true`, the server exists in the topology but is not - * connected, then attempt to reconnect with the server. If `false`, then only - * create a stream if the server is connected and ready. - * - * @note The returned stream must be released via `mongoc_server_stream_cleanup` - * - * @note May update the cluster's topology. - */ -mongoc_server_stream_t * -mongoc_cluster_stream_for_server (mongoc_cluster_t *cluster, - uint32_t server_id, - bool reconnect_ok, - mongoc_client_session_t *cs, - bson_t *reply, - bson_error_t *error); - -bool -mongoc_cluster_stream_valid (mongoc_cluster_t *cluster, - mongoc_server_stream_t *server_stream); - -bool -mongoc_cluster_run_command_monitored (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - bson_t *reply, - bson_error_t *error); - -bool -mongoc_cluster_run_command_parts (mongoc_cluster_t *cluster, - mongoc_server_stream_t *server_stream, - mongoc_cmd_parts_t *parts, - bson_t *reply, - bson_error_t *error); - -bool -mongoc_cluster_run_command_private (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - bson_t *reply, - bson_error_t *error); - -void -_mongoc_cluster_build_sasl_start (bson_t *cmd, - const char *mechanism, - const char *buf, - uint32_t buflen); - -void -_mongoc_cluster_build_sasl_continue (bson_t *cmd, - int conv_id, - const char *buf, - uint32_t buflen); - -int -_mongoc_cluster_get_conversation_id (const bson_t *reply); - -mongoc_server_stream_t * -_mongoc_cluster_create_server_stream (const mongoc_topology_description_t *td, - const mongoc_server_description_t *sd, - mongoc_stream_t *stream); - -bool -_mongoc_cluster_get_auth_cmd_x509 (const mongoc_uri_t *uri, - const mongoc_ssl_opt_t *ssl_opts, - bson_t *cmd /* OUT */, - bson_error_t *error /* OUT */); - -/* Returns true if a versioned server API has been selected, otherwise returns - * false. */ -bool -mongoc_cluster_uses_server_api (const mongoc_cluster_t *cluster); - -/* Returns true if load balancing mode has been selected, otherwise returns - * false. */ -bool -mongoc_cluster_uses_loadbalanced (const mongoc_cluster_t *cluster); - -#ifdef MONGOC_ENABLE_CRYPTO -void -_mongoc_cluster_init_scram (const mongoc_cluster_t *cluster, - mongoc_scram_t *scram, - mongoc_crypto_hash_algorithm_t algo); - -bool -_mongoc_cluster_get_auth_cmd_scram (mongoc_crypto_hash_algorithm_t algo, - mongoc_scram_t *scram, - bson_t *cmd /* OUT */, - bson_error_t *error /* OUT */); -#endif /* MONGOC_ENABLE_CRYPTO */ - -bool -mcd_rpc_message_compress (mcd_rpc_message *rpc, - int32_t compressor_id, - int32_t compression_level, - void **compressed_data, - size_t *compressed_data_len, - bson_error_t *error); - -bool -mcd_rpc_message_decompress (mcd_rpc_message *rpc, - void **data, - size_t *data_len); - -bool -mcd_rpc_message_decompress_if_necessary (mcd_rpc_message *rpc, - void **data, - size_t *data_len); - -BSON_END_DECLS - - -#endif /* MONGOC_CLUSTER_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-sasl.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-sasl.c deleted file mode 100644 index fd9f3acba..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-sasl.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2017 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* for size_t */ -#include -#include "mongoc-config.h" - -#include "mongoc-cluster-private.h" -#include "mongoc-log.h" -#include "mongoc-trace-private.h" -#include "mongoc-stream-private.h" -#include "mongoc-stream-socket.h" -#include "mongoc-error.h" -#include "mongoc-util-private.h" - -#ifdef MONGOC_ENABLE_SASL - -#ifdef MONGOC_ENABLE_SASL_CYRUS -#include "mongoc-cluster-cyrus-private.h" -#endif -#ifdef MONGOC_ENABLE_SASL_SSPI -#include "mongoc-cluster-sspi-private.h" -#endif - -#endif - -void -_mongoc_cluster_build_sasl_start (bson_t *cmd, - const char *mechanism, - const char *buf, - uint32_t buflen) -{ - BSON_APPEND_INT32 (cmd, "saslStart", 1); - BSON_APPEND_UTF8 (cmd, "mechanism", mechanism); - bson_append_utf8 (cmd, "payload", 7, buf, buflen); - BSON_APPEND_INT32 (cmd, "autoAuthorize", 1); -} -void -_mongoc_cluster_build_sasl_continue (bson_t *cmd, - int conv_id, - const char *buf, - uint32_t buflen) -{ - BSON_APPEND_INT32 (cmd, "saslContinue", 1); - BSON_APPEND_INT32 (cmd, "conversationId", conv_id); - bson_append_utf8 (cmd, "payload", 7, buf, buflen); -} -int -_mongoc_cluster_get_conversation_id (const bson_t *reply) -{ - bson_iter_t iter; - - if (bson_iter_init_find (&iter, reply, "conversationId") && - BSON_ITER_HOLDS_INT32 (&iter)) { - return bson_iter_int32 (&iter); - } - - return 0; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_auth_node_sasl -- - * - * Perform authentication for a cluster node using SASL. This is - * only supported for GSSAPI at the moment. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * error may be set. - * - *-------------------------------------------------------------------------- - */ - -bool -_mongoc_cluster_auth_node_sasl (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_error_t *error) -{ -#ifndef MONGOC_ENABLE_SASL - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "The GSSAPI authentication mechanism requires libmongoc " - "built with ENABLE_SASL"); - return false; -#elif defined(MONGOC_ENABLE_SASL_CYRUS) - return _mongoc_cluster_auth_node_cyrus (cluster, stream, sd, error); -#elif defined(MONGOC_ENABLE_SASL_SSPI) - return _mongoc_cluster_auth_node_sspi (cluster, stream, sd, error); -#endif -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-sspi.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-sspi.c deleted file mode 100644 index 13cf8c52a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster-sspi.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright 2017 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SASL_SSPI -#include "mongoc-client-private.h" -#include "mongoc-cluster-sspi-private.h" -#include "mongoc-cluster-sasl-private.h" -#include "mongoc-sasl-private.h" -#include "mongoc-sspi-private.h" -#include "mongoc-error.h" -#include "mongoc-util-private.h" - - -static mongoc_sspi_client_state_t * -_mongoc_cluster_sspi_new (mongoc_uri_t *uri, - mongoc_stream_t *stream, - const char *hostname) -{ - WCHAR *service; /* L"serviceName@hostname@REALM" */ - const char *service_name = "mongodb"; - ULONG flags = ISC_REQ_MUTUAL_AUTH; - const char *service_realm = NULL; - char *service_ascii = NULL; - mongoc_sspi_client_state_t *state; - size_t service_ascii_len; - size_t tmp_creds_len; - bson_t properties; - bson_iter_t iter; - char real_name[BSON_HOST_NAME_MAX + 1]; - int service_len; - WCHAR *pass = NULL; - WCHAR *user = NULL; - size_t user_len = 0; - size_t pass_len = 0; - int res; - - state = (mongoc_sspi_client_state_t *) bson_malloc0 (sizeof *state); - _mongoc_sasl_set_properties (&state->sasl, uri); - - if (state->sasl.canonicalize_host_name && - _mongoc_sasl_get_canonicalized_name ( - stream, real_name, sizeof real_name)) { - hostname = real_name; - } - - /* service realm is an SSPI-specific feature */ - if (mongoc_uri_get_mechanism_properties (uri, &properties) && - bson_iter_init_find_case (&iter, &properties, "SERVICE_REALM") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - service_realm = bson_iter_utf8 (&iter, NULL); - service_ascii = - bson_strdup_printf ("%s@%s@%s", service_name, hostname, service_realm); - } else { - service_ascii = bson_strdup_printf ("%s@%s", service_name, hostname); - } - service_ascii_len = strlen (service_ascii); - - /* this is donated to the sspi */ - service = bson_malloc0 ((service_ascii_len + 1) * sizeof (WCHAR)); - service_len = MultiByteToWideChar (CP_UTF8, - 0, - service_ascii, - (int) service_ascii_len, - service, - (int) service_ascii_len); - service[service_len] = L'\0'; - bson_free (service_ascii); - - if (state->sasl.pass) { - tmp_creds_len = strlen (state->sasl.pass); - - /* this is donated to the sspi */ - pass = bson_malloc0 ((tmp_creds_len + 1) * sizeof (WCHAR)); - pass_len = MultiByteToWideChar (CP_UTF8, - 0, - state->sasl.pass, - (int) tmp_creds_len, - pass, - (int) tmp_creds_len); - pass[pass_len] = L'\0'; - } - - if (state->sasl.user) { - tmp_creds_len = strlen (state->sasl.user); - - /* this is donated to the sspi */ - user = bson_malloc0 ((tmp_creds_len + 1) * sizeof (WCHAR)); - user_len = MultiByteToWideChar (CP_UTF8, - 0, - state->sasl.user, - (int) tmp_creds_len, - user, - (int) tmp_creds_len); - user[user_len] = L'\0'; - } - - res = _mongoc_sspi_auth_sspi_client_init (service, - flags, - user, - (ULONG) user_len, - NULL, - 0, - pass, - (ULONG) pass_len, - state); - - if (res != MONGOC_SSPI_AUTH_GSS_ERROR) { - return state; - } - bson_free (state); - return NULL; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_auth_node_sspi -- - * - * Perform authentication for a cluster node using SSPI - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * error may be set. - * - *-------------------------------------------------------------------------- - */ - -bool -_mongoc_cluster_auth_node_sspi (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_error_t *error) -{ - mongoc_cmd_parts_t parts; - mongoc_sspi_client_state_t *state; - SEC_CHAR *buf = NULL; - bson_iter_t iter; - uint32_t buflen; - bson_t reply; - const char *tmpstr; - int conv_id; - bson_t cmd; - int res = MONGOC_SSPI_AUTH_GSS_CONTINUE; - int step; - mongoc_server_stream_t *server_stream; - bool ret = false; - mc_shared_tpld td = MC_SHARED_TPLD_NULL; - - state = _mongoc_cluster_sspi_new (cluster->uri, stream, sd->host.host); - - if (!state) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Couldn't initialize SSPI service."); - goto failure; - } - - for (step = 0;; step++) { - mongoc_cmd_parts_init ( - &parts, cluster->client, "$external", MONGOC_QUERY_SECONDARY_OK, &cmd); - parts.prohibit_lsid = true; - bson_init (&cmd); - - if (res == MONGOC_SSPI_AUTH_GSS_CONTINUE) { - res = _mongoc_sspi_auth_sspi_client_step (state, buf); - } else if (res == MONGOC_SSPI_AUTH_GSS_COMPLETE) { - char *response; - size_t tmp_creds_len = strlen (state->sasl.user); - - res = _mongoc_sspi_auth_sspi_client_unwrap (state, buf); - response = bson_strdup (state->response); - _mongoc_sspi_auth_sspi_client_wrap (state, - response, - (SEC_CHAR *) state->sasl.user, - (ULONG) tmp_creds_len, - 0); - bson_free (response); - } - - if (res == MONGOC_SSPI_AUTH_GSS_ERROR) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Received invalid SSPI data."); - - mongoc_cmd_parts_cleanup (&parts); - bson_destroy (&cmd); - goto failure; - } - - if (step == 0) { - _mongoc_cluster_build_sasl_start (&cmd, - "GSSAPI", - state->response, - (uint32_t) strlen (state->response)); - } else { - if (state->response) { - _mongoc_cluster_build_sasl_continue ( - &cmd, - conv_id, - state->response, - (uint32_t) strlen (state->response)); - } else { - _mongoc_cluster_build_sasl_continue (&cmd, conv_id, "", 0); - } - } - - mc_tpld_renew_ref (&td, cluster->client->topology); - server_stream = _mongoc_cluster_create_server_stream (td.ptr, sd, stream); - - if (!mongoc_cmd_parts_assemble (&parts, server_stream, error)) { - mongoc_server_stream_cleanup (server_stream); - mongoc_cmd_parts_cleanup (&parts); - bson_destroy (&cmd); - goto failure; - } - - if (!mongoc_cluster_run_command_private ( - cluster, &parts.assembled, &reply, error)) { - mongoc_server_stream_cleanup (server_stream); - mongoc_cmd_parts_cleanup (&parts); - bson_destroy (&cmd); - bson_destroy (&reply); - goto failure; - } - - mongoc_server_stream_cleanup (server_stream); - mongoc_cmd_parts_cleanup (&parts); - bson_destroy (&cmd); - - if (bson_iter_init_find (&iter, &reply, "done") && - bson_iter_as_bool (&iter)) { - bson_destroy (&reply); - break; - } - - conv_id = _mongoc_cluster_get_conversation_id (&reply); - - if (!bson_iter_init_find (&iter, &reply, "payload") || - !BSON_ITER_HOLDS_UTF8 (&iter)) { - bson_destroy (&reply); - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Received invalid SASL reply from MongoDB server."); - goto failure; - } - - - tmpstr = bson_iter_utf8 (&iter, &buflen); - bson_free (buf); - buf = bson_malloc (sizeof (SEC_CHAR) * (buflen + 1)); - memcpy (buf, tmpstr, buflen); - buf[buflen] = (SEC_CHAR) 0; - - bson_destroy (&reply); - } - - ret = true; -failure: - mc_tpld_drop_ref (&td); - bson_free (buf); - bson_free (state); - return ret; -} - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster.c deleted file mode 100644 index 343528bfc..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cluster.c +++ /dev/null @@ -1,4006 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-config.h" - -#include - -#include "mcd-rpc.h" -#include "mongoc-cluster-private.h" -#include "mongoc-client-private.h" -#include "mongoc-client-side-encryption-private.h" -#include "mongoc-counters-private.h" -#include "mongoc-config.h" -#include "mongoc-error.h" -#include "mongoc-flags-private.h" -#include "mongoc-host-list-private.h" -#include "mongoc-log.h" -#include "mongoc-cluster-sasl-private.h" -#ifdef MONGOC_ENABLE_SSL -#include "mongoc-ssl.h" -#include "mongoc-ssl-private.h" -#include "mongoc-stream-tls.h" -#endif -#include "common-b64-private.h" -#include "mongoc-scram-private.h" -#include "mongoc-set-private.h" -#include "mongoc-socket.h" -#include "mongoc-stream-private.h" -#include "mongoc-stream-socket.h" -#include "mongoc-stream-tls.h" -#include "mongoc-thread-private.h" -#include "mongoc-topology-private.h" -#include "mongoc-topology-background-monitoring-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-util-private.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-uri-private.h" -#include "mongoc-rpc-private.h" -#include "mongoc-compression-private.h" -#include "mongoc-cmd-private.h" -#include "utlist.h" -#include "mongoc-handshake-private.h" -#include "mongoc-cluster-aws-private.h" -#include "mongoc-error-private.h" - -#include - -#include - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "cluster" - - -#define CHECK_CLOSED_DURATION_MSEC 1000 - -#define IS_NOT_COMMAND(_name) (!!strcasecmp (cmd->command_name, _name)) - -static mongoc_server_stream_t * -_cluster_fetch_stream_single (mongoc_cluster_t *cluster, - const mongoc_topology_description_t *td, - uint32_t server_id, - bool reconnect_ok, - bson_error_t *error); - -static mongoc_server_stream_t * -_cluster_fetch_stream_pooled (mongoc_cluster_t *cluster, - const mongoc_topology_description_t *td, - uint32_t server_id, - bool reconnect_ok, - bson_error_t *error); - -static bool -mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - bson_t *reply, - bson_error_t *error); - -static void -_bson_error_message_printf (bson_error_t *error, const char *format, ...) - BSON_GNUC_PRINTF (2, 3); - -static void -_handle_not_primary_error (mongoc_cluster_t *cluster, - const mongoc_server_stream_t *server_stream, - const bson_t *reply) -{ - uint32_t server_id; - - server_id = server_stream->sd->id; - if (_mongoc_topology_handle_app_error (cluster->client->topology, - server_id, - true /* handshake complete */, - MONGOC_SDAM_APP_ERROR_COMMAND, - reply, - NULL, - server_stream->sd->max_wire_version, - server_stream->sd->generation, - &server_stream->sd->service_id)) { - mongoc_cluster_disconnect_node (cluster, server_id); - } -} - -/* Called when a network error occurs on an application socket. - */ -static void -_handle_network_error (mongoc_cluster_t *cluster, - mongoc_server_stream_t *server_stream, - const bson_error_t *why) -{ - mongoc_topology_t *topology; - uint32_t server_id; - _mongoc_sdam_app_error_type_t type; - - BSON_ASSERT (server_stream); - - ENTRY; - topology = cluster->client->topology; - server_id = server_stream->sd->id; - type = MONGOC_SDAM_APP_ERROR_NETWORK; - if (mongoc_stream_timed_out (server_stream->stream)) { - type = MONGOC_SDAM_APP_ERROR_TIMEOUT; - } - - _mongoc_topology_handle_app_error (topology, - server_id, - true, // handshake_complete - type, - NULL, - why, - server_stream->sd->max_wire_version, - server_stream->sd->generation, - &server_stream->sd->service_id); - /* Always disconnect the current connection on network error. */ - mongoc_cluster_disconnect_node (cluster, server_id); - - EXIT; -} - - -static int32_t -_int32_from_le (const void *data) -{ - BSON_ASSERT_PARAM (data); - return bson_iter_int32_unsafe (&(bson_iter_t){.raw = data}); -} - - -static int32_t -_compression_level_from_uri (int32_t compressor_id, const mongoc_uri_t *uri) -{ - if (compressor_id == MONGOC_COMPRESSOR_ZLIB_ID) { - return mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, -1); - } - - return -1; -} - - -size_t -_mongoc_cluster_buffer_iovec (mongoc_iovec_t *iov, - size_t iovcnt, - int skip, - char *buffer) -{ - size_t buffer_offset = 0; - int total_iov_len = 0; - size_t difference = 0; - - for (size_t n = 0u; n < iovcnt; n++) { - BSON_ASSERT (bson_in_range_unsigned (int, iov[n].iov_len)); - const int iov_len = (int) iov[n].iov_len; - - total_iov_len += iov_len; - - if (total_iov_len <= skip) { - continue; - } - - /* If this iovec starts before the skip, and takes the total count - * beyond the skip, we need to figure out the portion of the iovec - * we should skip passed */ - const int remaining = total_iov_len - iov_len; - if (remaining < skip) { - difference = (size_t) (skip - remaining); - } else { - difference = 0u; - } - - memcpy (buffer + buffer_offset, - ((char *) iov[n].iov_base) + difference, - iov[n].iov_len - difference); - buffer_offset += iov[n].iov_len - difference; - } - - return buffer_offset; -} - -/* Allows caller to safely overwrite error->message with a formatted string, - * even if the formatted string includes original error->message. */ -static void -_bson_error_message_printf (bson_error_t *error, const char *format, ...) -{ - va_list args; - char error_message[sizeof error->message]; - - if (error) { - va_start (args, format); - bson_vsnprintf (error_message, sizeof error->message, format, args); - va_end (args); - - bson_strncpy (error->message, error_message, sizeof error->message); - } -} - -#define RUN_CMD_ERR_DECORATE \ - do { \ - _bson_error_message_printf ( \ - error, \ - "Failed to send \"%s\" command with database \"%s\": %s", \ - cmd->command_name, \ - cmd->db_name, \ - error->message); \ - } while (0) - -#define RUN_CMD_ERR(_domain, _code, ...) \ - do { \ - bson_set_error (error, _domain, _code, __VA_ARGS__); \ - RUN_CMD_ERR_DECORATE; \ - } while (0) - - -// msgHeader consists of four int32 fields. -static const int32_t message_header_length = 4u * sizeof (int32_t); - - -static bool -_mongoc_cluster_run_command_opquery_send (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - int32_t compressor_id, - mcd_rpc_message *rpc, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT_PARAM (cmd); - BSON_ASSERT_PARAM (rpc); - BSON_ASSERT_PARAM (error); - - bool ret = false; - - mongoc_stream_t *const stream = cmd->server_stream->stream; - - char *const ns = bson_strdup_printf ("%s.$cmd", cmd->db_name); - const int32_t request_id = ++cluster->request_id; - - // Find, getMore And killCursors Commands Spec: "When sending a find command - // rather than a legacy OP_QUERY find, only the secondaryOk flag is honored." - // For other cursor-typed commands like aggregate, only secondaryOk can be - // set. Clear bits except secondaryOk; leave secondaryOk set only if it is - // already. - const int32_t flags = - (int32_t) cmd->query_flags & MONGOC_OP_QUERY_FLAG_SECONDARY_OK; - - { - int32_t message_length = 0; - - message_length += mcd_rpc_header_set_message_length (rpc, 0); - message_length += mcd_rpc_header_set_request_id (rpc, request_id); - message_length += mcd_rpc_header_set_response_to (rpc, 0); - message_length += mcd_rpc_header_set_op_code (rpc, MONGOC_OP_CODE_QUERY); - - message_length += mcd_rpc_op_query_set_flags (rpc, flags); - message_length += mcd_rpc_op_query_set_full_collection_name (rpc, ns); - message_length += mcd_rpc_op_query_set_number_to_skip (rpc, 0); - message_length += mcd_rpc_op_query_set_number_to_return (rpc, -1); - message_length += - mcd_rpc_op_query_set_query (rpc, bson_get_data (cmd->command)); - - mcd_rpc_message_set_length (rpc, message_length); - } - - size_t num_iovecs = 0u; - mongoc_iovec_t *const iovecs = mcd_rpc_message_to_iovecs (rpc, &num_iovecs); - BSON_ASSERT (iovecs); - - const bool is_compressible = - compressor_id != -1 && IS_NOT_COMMAND (HANDSHAKE_CMD_LEGACY_HELLO) && - IS_NOT_COMMAND ("hello") && IS_NOT_COMMAND ("saslstart") && - IS_NOT_COMMAND ("saslcontinue") && IS_NOT_COMMAND ("getnonce") && - IS_NOT_COMMAND ("authenticate") && IS_NOT_COMMAND ("createuser") && - IS_NOT_COMMAND ("updateuser"); - - void *compressed_data = NULL; - size_t compressed_data_len = 0u; - - if (is_compressible && - !mcd_rpc_message_compress ( - rpc, - compressor_id, - _compression_level_from_uri (compressor_id, cluster->uri), - &compressed_data, - &compressed_data_len, - error)) { - goto done; - } - - if (cluster->client->in_exhaust) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_IN_EXHAUST, - "a cursor derived from this client is in exhaust"); - goto done; - } - - mcd_rpc_message_egress (rpc); - if (!_mongoc_stream_writev_full ( - stream, iovecs, num_iovecs, cluster->sockettimeoutms, error)) { - RUN_CMD_ERR_DECORATE; - _handle_network_error (cluster, cmd->server_stream, error); - goto done; - } - - ret = true; - -done: - bson_free (compressed_data); - bson_free (iovecs); - bson_free (ns); - - return ret; -} - -static bool -_mongoc_cluster_run_command_opquery_recv (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - mcd_rpc_message *rpc, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT_PARAM (cmd); - BSON_ASSERT_PARAM (rpc); - BSON_ASSERT_PARAM (reply); - BSON_ASSERT_PARAM (error); - - bool ret = false; - - mongoc_stream_t *const stream = cmd->server_stream->stream; - - mongoc_buffer_t buffer; - _mongoc_buffer_init (&buffer, NULL, 0, NULL, NULL); - - void *decompressed_data = NULL; - size_t decompressed_data_len = 0u; - - if (!_mongoc_buffer_append_from_stream ( - &buffer, stream, sizeof (int32_t), cluster->sockettimeoutms, error)) { - RUN_CMD_ERR (MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "socket error or timeout"); - _handle_network_error (cluster, cmd->server_stream, error); - goto done; - } - - const int32_t message_length = _int32_from_le (buffer.data); - - if (message_length < message_header_length || - message_length > MONGOC_DEFAULT_MAX_MSG_SIZE) { - RUN_CMD_ERR (MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "invalid message length"); - _handle_network_error (cluster, cmd->server_stream, error); - goto done; - } - - const size_t remaining_bytes = (size_t) message_length - sizeof (int32_t); - - if (!_mongoc_buffer_append_from_stream ( - &buffer, stream, remaining_bytes, cluster->sockettimeoutms, error)) { - RUN_CMD_ERR (MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "socket error or timeout"); - _handle_network_error (cluster, cmd->server_stream, error); - goto done; - } - - if (!mcd_rpc_message_from_data_in_place ( - rpc, buffer.data, buffer.len, NULL)) { - RUN_CMD_ERR (MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "malformed reply from server"); - goto done; - } - - mcd_rpc_message_ingress (rpc); - - if (!mcd_rpc_message_decompress_if_necessary ( - rpc, &decompressed_data, &decompressed_data_len)) { - RUN_CMD_ERR (MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "could not decompress server reply"); - goto done; - } - - { - bson_t body; - - if (!mcd_rpc_message_get_body (rpc, &body)) { - RUN_CMD_ERR (MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "malformed reply from server"); - goto done; - } - - bson_copy_to (&body, reply); - bson_destroy (&body); - } - - if (!_mongoc_cmd_check_ok ( - reply, cluster->client->error_api_version, error)) { - goto done; - } - - ret = true; - -done: - bson_free (decompressed_data); - _mongoc_buffer_destroy (&buffer); - - return ret; -} - -static bool -mongoc_cluster_run_command_opquery (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - int32_t compressor_id, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT_PARAM (cmd); - BSON_ASSERT_PARAM (cmd->server_stream); - BSON_ASSERT_PARAM (reply); - BSON_ASSERT_PARAM (error); - - ENTRY; - - bool ret = false; - - bson_init (reply); - error->code = 0; - - mcd_rpc_message *const rpc = mcd_rpc_message_new (); - - if (!_mongoc_cluster_run_command_opquery_send ( - cluster, cmd, compressor_id, rpc, error)) { - GOTO (done); - } - - mcd_rpc_message_reset (rpc); - - if (!_mongoc_cluster_run_command_opquery_recv ( - cluster, cmd, rpc, reply, error)) { - GOTO (done); - } - - ret = true; - -done: - if (!ret && error->code == 0) { - /* generic error */ - RUN_CMD_ERR (MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid reply from server"); - } - - mcd_rpc_message_destroy (rpc); - - RETURN (ret); -} - -static bool -_in_sharded_txn (const mongoc_client_session_t *session) -{ - return session && _mongoc_client_session_in_txn_or_ending (session) && - _mongoc_topology_get_type (session->client->topology) == - MONGOC_TOPOLOGY_SHARDED; -} - -static bool -_in_sharded_or_loadbalanced_txn (const mongoc_client_session_t *session) -{ - if (!session) { - return false; - } - - if (!_mongoc_client_session_in_txn_or_ending (session)) { - return false; - } - - mongoc_topology_description_type_t type = - _mongoc_topology_get_type (session->client->topology); - - return (type == MONGOC_TOPOLOGY_SHARDED) || - (type == MONGOC_TOPOLOGY_LOAD_BALANCED); -} - -static void -_handle_txn_error_labels (bool cmd_ret, - const bson_error_t *cmd_err, - const mongoc_cmd_t *cmd, - bson_t *reply) -{ - if (!cmd->is_txn_finish) { - return; - } - - _mongoc_write_error_handle_labels ( - cmd_ret, cmd_err, reply, cmd->server_stream->sd); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_run_command_monitored -- - * - * Internal function to run a command on a given stream. - * @error and @reply are optional out-pointers. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * If the client's APM callbacks are set, they are executed. - * @reply is set and should ALWAYS be released with bson_destroy(). - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_cluster_run_command_monitored (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - bson_t *reply, - bson_error_t *error) -{ - bool retval; - const int32_t request_id = ++cluster->request_id; - uint32_t server_id; - mongoc_apm_callbacks_t *callbacks; - mongoc_apm_command_started_t started_event; - mongoc_apm_command_succeeded_t succeeded_event; - mongoc_apm_command_failed_t failed_event; - int64_t started = bson_get_monotonic_time (); - const mongoc_server_stream_t *server_stream; - bson_t reply_local; - bson_error_t error_local; - bson_iter_t iter; - bson_t encrypted = BSON_INITIALIZER; - bson_t decrypted = BSON_INITIALIZER; - mongoc_cmd_t encrypted_cmd; - bool is_redacted = false; - - server_stream = cmd->server_stream; - server_id = server_stream->sd->id; - - callbacks = &cluster->client->apm_callbacks; - if (!reply) { - reply = &reply_local; - } - if (!error) { - error = &error_local; - } - - if (_mongoc_cse_is_enabled (cluster->client)) { - bson_destroy (&encrypted); - - retval = _mongoc_cse_auto_encrypt ( - cluster->client, cmd, &encrypted_cmd, &encrypted, error); - cmd = &encrypted_cmd; - if (!retval) { - bson_init (reply); - goto fail_no_events; - } - } - - if (callbacks->started) { - mongoc_apm_command_started_init_with_cmd (&started_event, - cmd, - request_id, - &is_redacted, - cluster->client->apm_context); - - callbacks->started (&started_event); - mongoc_apm_command_started_cleanup (&started_event); - } - - retval = mongoc_cluster_run_opmsg (cluster, cmd, reply, error); - - if (retval && callbacks->succeeded) { - bson_t fake_reply = BSON_INITIALIZER; - /* - * Unacknowledged writes must provide a CommandSucceededEvent with an - * {ok: 1} reply. - * https://github.com/mongodb/specifications/blob/master/source/command-logging-and-monitoring/command-logging-and-monitoring.rst#unacknowledged-acknowledged-writes - */ - if (!cmd->is_acknowledged) { - bson_append_int32 (&fake_reply, "ok", 2, 1); - } - mongoc_apm_command_succeeded_init ( - &succeeded_event, - bson_get_monotonic_time () - started, - cmd->is_acknowledged ? reply : &fake_reply, - cmd->command_name, - request_id, - cmd->operation_id, - &server_stream->sd->host, - server_id, - &server_stream->sd->service_id, - server_stream->sd->server_connection_id, - is_redacted, - cluster->client->apm_context); - - callbacks->succeeded (&succeeded_event); - mongoc_apm_command_succeeded_cleanup (&succeeded_event); - bson_destroy (&fake_reply); - } - if (!retval && callbacks->failed) { - mongoc_apm_command_failed_init (&failed_event, - bson_get_monotonic_time () - started, - cmd->command_name, - error, - reply, - request_id, - cmd->operation_id, - &server_stream->sd->host, - server_id, - &server_stream->sd->service_id, - server_stream->sd->server_connection_id, - is_redacted, - cluster->client->apm_context); - - callbacks->failed (&failed_event); - mongoc_apm_command_failed_cleanup (&failed_event); - } - - if (retval && _mongoc_cse_is_enabled (cluster->client)) { - bson_destroy (&decrypted); - retval = _mongoc_cse_auto_decrypt ( - cluster->client, cmd->db_name, reply, &decrypted, error); - bson_destroy (reply); - bson_steal (reply, &decrypted); - bson_init (&decrypted); - if (!retval) { - goto fail_no_events; - } - } - - _handle_not_primary_error (cluster, server_stream, reply); - - _handle_txn_error_labels (retval, error, cmd, reply); - - if (retval && _in_sharded_or_loadbalanced_txn (cmd->session) && - bson_iter_init_find (&iter, reply, "recoveryToken")) { - bson_destroy (cmd->session->recovery_token); - if (BSON_ITER_HOLDS_DOCUMENT (&iter)) { - cmd->session->recovery_token = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - } else { - MONGOC_ERROR ("Malformed recovery token from server"); - cmd->session->recovery_token = NULL; - } - } - -fail_no_events: - if (reply == &reply_local) { - bson_destroy (&reply_local); - } - - bson_destroy (&encrypted); - bson_destroy (&decrypted); - - _mongoc_topology_update_last_used (cluster->client->topology, server_id); - - return retval; -} - - -static bool -_should_use_op_msg (const mongoc_cluster_t *cluster) -{ - return mongoc_cluster_uses_server_api (cluster) || - mongoc_cluster_uses_loadbalanced (cluster); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_run_command_private -- - * - * Internal function to run a command on a given stream. - * @error and @reply are optional out-pointers. - * The client's APM callbacks are not executed. - * Automatic encryption/decryption is not performed. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * @reply is set and should ALWAYS be released with bson_destroy(). - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_cluster_run_command_private (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - bson_t *reply, - bson_error_t *error) -{ - bool retval; - const mongoc_server_stream_t *server_stream; - bson_t reply_local; - bson_error_t error_local; - - if (!error) { - error = &error_local; - } - - /* If NULL was passed, we use our local variable as a temporary sink: */ - if (!reply) { - reply = &reply_local; - } - - server_stream = cmd->server_stream; - - if (_should_use_op_msg (cluster) || - server_stream->sd->max_wire_version >= WIRE_VERSION_MIN) { - retval = mongoc_cluster_run_opmsg (cluster, cmd, reply, error); - } else { - retval = - mongoc_cluster_run_command_opquery (cluster, cmd, -1, reply, error); - } - - _handle_not_primary_error (cluster, server_stream, reply); - - if (reply == &reply_local) { - bson_destroy (&reply_local); - } - - _mongoc_topology_update_last_used (cluster->client->topology, - server_stream->sd->id); - - return retval; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_run_command_parts -- - * - * Internal function to assemble command parts and run a command - * on a given stream. @error and @reply are optional out-pointers. - * The client's APM callbacks are not executed. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * @reply is set and should ALWAYS be released with bson_destroy(). - * mongoc_cmd_parts_cleanup will be always be called on parts. The - * caller should *not* call cleanup on the parts. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_cluster_run_command_parts (mongoc_cluster_t *cluster, - mongoc_server_stream_t *server_stream, - mongoc_cmd_parts_t *parts, - bson_t *reply, - bson_error_t *error) -{ - bool ret; - - if (!mongoc_cmd_parts_assemble (parts, server_stream, error)) { - _mongoc_bson_init_if_set (reply); - mongoc_cmd_parts_cleanup (parts); - return false; - } - - ret = mongoc_cluster_run_command_private ( - cluster, &parts->assembled, reply, error); - mongoc_cmd_parts_cleanup (parts); - return ret; -} - -/* - *-------------------------------------------------------------------------- - * - * _stream_run_hello -- - * - * Run a hello command on the given stream. If - * @negotiate_sasl_supported_mechs is true, then saslSupportedMechs is - * added to the hello command. - * - * Returns: - * A mongoc_server_description_t you must destroy or NULL. If the call - * failed its error is set and its type is MONGOC_SERVER_UNKNOWN. - * - *-------------------------------------------------------------------------- - */ -static mongoc_server_description_t * -_stream_run_hello (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - const char *address, - uint32_t server_id, - bool negotiate_sasl_supported_mechs, - mongoc_scram_t *scram, - bson_t *speculative_auth_response /* OUT */, - bson_error_t *error) -{ - bson_t handshake_command; /* Initialized by dup_handshake below */ - mongoc_cmd_t hello_cmd; - bson_t reply; - int64_t start; - int64_t rtt_msec; - mongoc_server_description_t empty_sd; - mongoc_server_description_t *ret_handshake_sd; - mongoc_server_stream_t *server_stream; - bool r; - mongoc_ssl_opt_t *ssl_opts = NULL; - mc_shared_tpld td = - mc_tpld_take_ref (BSON_ASSERT_PTR_INLINE (cluster)->client->topology); - - ENTRY; - - BSON_ASSERT (stream); - - _mongoc_topology_dup_handshake_cmd (cluster->client->topology, - &handshake_command); - - if (cluster->requires_auth && speculative_auth_response) { -#ifdef MONGOC_ENABLE_SSL - ssl_opts = &cluster->client->ssl_opts; -#endif - - _mongoc_topology_scanner_add_speculative_authentication ( - &handshake_command, cluster->uri, ssl_opts, scram); - } - - if (negotiate_sasl_supported_mechs) { - _mongoc_handshake_append_sasl_supported_mechs (cluster->uri, - &handshake_command); - } - - start = bson_get_monotonic_time (); - /* TODO CDRIVER-3654: do not use a mongoc_server_stream here. - * Instead, use a plain stream. If a network error occurs, check the cluster - * node's generation (which is the generation of the created connection) to - * determine if the error should be handled. - * The current behavior may double invalidate. - * If a network error occurs in mongoc_cluster_run_command_private below, - * that invalidates (thinking the error is a post-handshake network error). - * Then _mongoc_cluster_stream_for_server also handles the error, and - * invalidates again. - */ - mongoc_server_description_init (&empty_sd, address, server_id); - server_stream = - _mongoc_cluster_create_server_stream (td.ptr, &empty_sd, stream); - - mongoc_server_description_cleanup (&empty_sd); - - /* Set up the shared parts of the mongo_cmd_t, which will later be converted - to either an op_msg or op_query: */ - memset (&hello_cmd, 0, sizeof (hello_cmd)); - - /* Use OP_QUERY for the handshake, unless the user has specified an - * API version; the correct hello_cmd has already been selected: */ - if (!_should_use_op_msg (cluster)) { - /* Complete OPCODE_QUERY setup: */ - hello_cmd.query_flags = MONGOC_QUERY_SECONDARY_OK; - } else { - /* We're using OP_MSG, and require some additional doctoring: */ - bson_append_utf8 (&handshake_command, "$db", 3, "admin", 5); - } - - hello_cmd.db_name = "admin"; - hello_cmd.command = &handshake_command; - hello_cmd.command_name = _mongoc_get_command_name (&handshake_command); - hello_cmd.server_stream = server_stream; - hello_cmd.is_acknowledged = true; - - if (!mongoc_cluster_run_command_private ( - cluster, &hello_cmd, &reply, error)) { - if (negotiate_sasl_supported_mechs) { - bsonParse (reply, - find (allOf (key ("ok"), isFalse), // - do ({ - /* hello response returned ok: 0. According to - * auth spec: "If the hello of the MongoDB - * Handshake fails with an error, drivers MUST - * treat this an authentication error." */ - error->domain = MONGOC_ERROR_CLIENT; - error->code = MONGOC_ERROR_CLIENT_AUTHENTICATE; - }))); - } - - mongoc_server_stream_cleanup (server_stream); - ret_handshake_sd = NULL; - goto done; - } - - rtt_msec = (bson_get_monotonic_time () - start) / 1000; - - ret_handshake_sd = BSON_ALIGNED_ALLOC0 (mongoc_server_description_t); - - mongoc_server_description_init (ret_handshake_sd, address, server_id); - /* send the error from run_command IN to handle_hello */ - mongoc_server_description_handle_hello ( - ret_handshake_sd, &reply, rtt_msec, error); - - if (cluster->requires_auth && speculative_auth_response) { - _mongoc_topology_scanner_parse_speculative_authentication ( - &reply, speculative_auth_response); - } - - /* Note: This call will render our copy of the topology description to be - * stale */ - r = _mongoc_topology_update_from_handshake (cluster->client->topology, - ret_handshake_sd); - if (!r) { - mongoc_server_description_reset (ret_handshake_sd); - bson_set_error (&ret_handshake_sd->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NOT_ESTABLISHED, - "\"%s\" removed from topology", - address); - } - - mongoc_server_stream_cleanup (server_stream); - -done: - bson_destroy (&handshake_command); - bson_destroy (&reply); - mc_tpld_drop_ref (&td); - - RETURN (ret_handshake_sd); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_run_hello -- - * - * Run an initial hello command for the given node and handle result. - * - * Returns: - * mongoc_server_description_t on success, NULL otherwise. - * the mongoc_server_description_t MUST BE DESTROYED BY THE CALLER. - * - * Side effects: - * Makes a blocking I/O call, updates cluster->topology->description - * with hello result. - * - *-------------------------------------------------------------------------- - */ -static mongoc_server_description_t * -_cluster_run_hello (mongoc_cluster_t *cluster, - mongoc_cluster_node_t *node, - uint32_t server_id, - mongoc_scram_t *scram /* OUT */, - bson_t *speculative_auth_response /* OUT */, - bson_error_t *error /* OUT */) -{ - mongoc_server_description_t *sd; - - ENTRY; - - BSON_ASSERT (cluster); - BSON_ASSERT (node); - BSON_ASSERT (node->stream); - - sd = _stream_run_hello (cluster, - node->stream, - node->connection_address, - server_id, - _mongoc_uri_requires_auth_negotiation (cluster->uri), - scram, - speculative_auth_response, - error); - - if (!sd) { - return NULL; - } - - if (sd->type == MONGOC_SERVER_UNKNOWN) { - memcpy (error, &sd->error, sizeof (bson_error_t)); - mongoc_server_description_destroy (sd); - return NULL; - } - - return sd; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_build_basic_auth_digest -- - * - * Computes the Basic Authentication digest using the credentials - * configured for @cluster and the @nonce provided. - * - * The result should be freed by the caller using bson_free() when - * they are finished with it. - * - * Returns: - * A newly allocated string containing the digest. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static char * -_mongoc_cluster_build_basic_auth_digest (mongoc_cluster_t *cluster, - const char *nonce) -{ - const char *username; - const char *password; - char *password_digest; - char *password_md5; - char *digest_in; - char *ret; - - ENTRY; - - /* - * The following generates the digest to be used for basic authentication - * with a MongoDB server. More information on the format can be found - * at the following location: - * - * https://www.mongodb.com/docs/meta-driver/latest/legacy/ - * implement-authentication-in-driver/ - */ - - BSON_ASSERT (cluster); - BSON_ASSERT (cluster->uri); - - username = mongoc_uri_get_username (cluster->uri); - password = mongoc_uri_get_password (cluster->uri); - password_digest = bson_strdup_printf ("%s:mongo:%s", username, password); - password_md5 = _mongoc_hex_md5 (password_digest); - digest_in = bson_strdup_printf ("%s%s%s", nonce, username, password_md5); - ret = _mongoc_hex_md5 (digest_in); - bson_free (digest_in); - bson_free (password_md5); - bson_free (password_digest); - - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_auth_node_cr -- - * - * Performs authentication of @node using the credentials provided - * when configuring the @cluster instance. - * - * This is the Challenge-Response mode of authentication. - * - * Returns: - * true if authentication was successful; otherwise false and - * @error is set. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_cluster_auth_node_cr (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_error_t *error) -{ - mongoc_cmd_parts_t parts; - bson_iter_t iter; - const char *auth_source; - bson_t command; - bson_t reply; - char *digest; - char *nonce; - bool ret; - mongoc_server_stream_t *server_stream; - mc_shared_tpld td; - - ENTRY; - - BSON_ASSERT (cluster); - BSON_ASSERT (stream); - - if (!(auth_source = mongoc_uri_get_auth_source (cluster->uri)) || - (*auth_source == '\0')) { - auth_source = "admin"; - } - - /* - * To authenticate a node using basic authentication, we need to first - * get the nonce from the server. We use that to hash our password which - * is sent as a reply to the server. If everything went good we get a - * success notification back from the server. - */ - - /* - * Execute the getnonce command to fetch the nonce used for generating - * md5 digest of our password information. - */ - bson_init (&command); - bson_append_int32 (&command, "getnonce", 8, 1); - mongoc_cmd_parts_init (&parts, - cluster->client, - auth_source, - MONGOC_QUERY_SECONDARY_OK, - &command); - parts.prohibit_lsid = true; - - td = mc_tpld_take_ref (cluster->client->topology); - server_stream = _mongoc_cluster_create_server_stream (td.ptr, sd, stream); - mc_tpld_drop_ref (&td); - - if (!mongoc_cluster_run_command_parts ( - cluster, server_stream, &parts, &reply, error)) { - mongoc_server_stream_cleanup (server_stream); - bson_destroy (&command); - bson_destroy (&reply); - RETURN (false); - } - bson_destroy (&command); - if (!bson_iter_init_find_case (&iter, &reply, "nonce")) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_GETNONCE, - "Invalid reply from getnonce"); - bson_destroy (&reply); - RETURN (false); - } - - /* - * Build our command to perform the authentication. - */ - nonce = bson_iter_dup_utf8 (&iter, NULL); - digest = _mongoc_cluster_build_basic_auth_digest (cluster, nonce); - bson_init (&command); - bson_append_int32 (&command, "authenticate", 12, 1); - bson_append_utf8 ( - &command, "user", 4, mongoc_uri_get_username (cluster->uri), -1); - bson_append_utf8 (&command, "nonce", 5, nonce, -1); - bson_append_utf8 (&command, "key", 3, digest, -1); - bson_destroy (&reply); - bson_free (nonce); - bson_free (digest); - - /* - * Execute the authenticate command. mongoc_cluster_run_command_private - * checks for {ok: 1} in the response. - */ - mongoc_cmd_parts_init (&parts, - cluster->client, - auth_source, - MONGOC_QUERY_SECONDARY_OK, - &command); - parts.prohibit_lsid = true; - ret = mongoc_cluster_run_command_parts ( - cluster, server_stream, &parts, &reply, error); - - if (!ret) { - /* error->message is already set */ - error->domain = MONGOC_ERROR_CLIENT; - error->code = MONGOC_ERROR_CLIENT_AUTHENTICATE; - } - - mongoc_server_stream_cleanup (server_stream); - bson_destroy (&command); - bson_destroy (&reply); - - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_auth_node_plain -- - * - * Perform SASL PLAIN authentication for @node. We do this manually - * instead of using the SASL module because it is rather simplistic. - * - * Returns: - * true if successful; otherwise false and error is set. - * - * Side effects: - * error may be set. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_cluster_auth_node_plain (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_error_t *error) -{ - mongoc_cmd_parts_t parts; - char buf[4096]; - int buflen = 0; - const char *username; - const char *password; - bson_t b = BSON_INITIALIZER; - bson_t reply; - size_t len; - char *str; - bool ret; - mongoc_server_stream_t *server_stream; - mc_shared_tpld td; - - BSON_ASSERT (cluster); - BSON_ASSERT (stream); - - username = mongoc_uri_get_username (cluster->uri); - if (!username) { - username = ""; - } - - password = mongoc_uri_get_password (cluster->uri); - if (!password) { - password = ""; - } - - str = bson_strdup_printf ("%c%s%c%s", '\0', username, '\0', password); - len = strlen (username) + strlen (password) + 2; - buflen = mcommon_b64_ntop ((const uint8_t *) str, len, buf, sizeof buf); - bson_free (str); - - if (buflen == -1) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "failed base64 encoding message"); - return false; - } - - BSON_APPEND_INT32 (&b, "saslStart", 1); - BSON_APPEND_UTF8 (&b, "mechanism", "PLAIN"); - bson_append_utf8 (&b, "payload", 7, (const char *) buf, buflen); - BSON_APPEND_INT32 (&b, "autoAuthorize", 1); - - mongoc_cmd_parts_init ( - &parts, cluster->client, "$external", MONGOC_QUERY_SECONDARY_OK, &b); - parts.prohibit_lsid = true; - - td = mc_tpld_take_ref (cluster->client->topology); - server_stream = _mongoc_cluster_create_server_stream (td.ptr, sd, stream); - mc_tpld_drop_ref (&td); - - ret = mongoc_cluster_run_command_parts ( - cluster, server_stream, &parts, &reply, error); - mongoc_server_stream_cleanup (server_stream); - if (!ret) { - /* error->message is already set */ - error->domain = MONGOC_ERROR_CLIENT; - error->code = MONGOC_ERROR_CLIENT_AUTHENTICATE; - } - - bson_destroy (&b); - bson_destroy (&reply); - - return ret; -} - -bool -_mongoc_cluster_get_auth_cmd_x509 (const mongoc_uri_t *uri, - const mongoc_ssl_opt_t *ssl_opts, - bson_t *cmd /* OUT */, - bson_error_t *error /* OUT */) -{ -#ifndef MONGOC_ENABLE_SSL - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "The MONGODB-X509 authentication mechanism requires " - "libmongoc built with ENABLE_SSL"); - return false; -#else - const char *username_from_uri = NULL; - char *username_from_subject = NULL; - - BSON_ASSERT (uri); - - username_from_uri = mongoc_uri_get_username (uri); - if (username_from_uri) { - TRACE ("%s", "X509: got username from URI"); - } else { - if (!ssl_opts || !ssl_opts->pem_file) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "cannot determine username for " - "X-509 authentication."); - return false; - } - - username_from_subject = - mongoc_ssl_extract_subject (ssl_opts->pem_file, ssl_opts->pem_pwd); - if (!username_from_subject) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "No username provided for X509 authentication."); - return false; - } - - TRACE ("%s", "X509: got username from certificate"); - } - - bson_init (cmd); - BSON_APPEND_INT32 (cmd, "authenticate", 1); - BSON_APPEND_UTF8 (cmd, "mechanism", "MONGODB-X509"); - BSON_APPEND_UTF8 (cmd, - "user", - username_from_uri ? username_from_uri - : username_from_subject); - - bson_free (username_from_subject); - - return true; -#endif -} - - -static bool -_mongoc_cluster_auth_node_x509 (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_error_t *error) -{ -#ifndef MONGOC_ENABLE_SSL - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "The MONGODB-X509 authentication mechanism requires " - "libmongoc built with ENABLE_SSL"); - return false; -#else - mongoc_cmd_parts_t parts; - bson_t cmd; - bson_t reply; - bool ret; - mongoc_server_stream_t *server_stream; - mc_shared_tpld td; - - BSON_ASSERT (cluster); - BSON_ASSERT (stream); - - if (!_mongoc_cluster_get_auth_cmd_x509 ( - cluster->uri, &cluster->client->ssl_opts, &cmd, error)) { - return false; - } - - mongoc_cmd_parts_init ( - &parts, cluster->client, "$external", MONGOC_QUERY_SECONDARY_OK, &cmd); - parts.prohibit_lsid = true; - td = mc_tpld_take_ref (cluster->client->topology); - server_stream = _mongoc_cluster_create_server_stream (td.ptr, sd, stream); - mc_tpld_drop_ref (&td); - - ret = mongoc_cluster_run_command_parts ( - cluster, server_stream, &parts, &reply, error); - mongoc_server_stream_cleanup (server_stream); - if (!ret) { - /* error->message is already set */ - error->domain = MONGOC_ERROR_CLIENT; - error->code = MONGOC_ERROR_CLIENT_AUTHENTICATE; - } - - bson_destroy (&cmd); - bson_destroy (&reply); - - return ret; -#endif -} - -bool -mongoc_cluster_uses_server_api (const mongoc_cluster_t *cluster) -{ - BSON_ASSERT_PARAM (cluster); - return mongoc_client_uses_server_api (cluster->client); -} - -bool -mongoc_cluster_uses_loadbalanced (const mongoc_cluster_t *cluster) -{ - BSON_ASSERT_PARAM (cluster); - return mongoc_client_uses_loadbalanced (cluster->client); -} - -#ifdef MONGOC_ENABLE_CRYPTO -void -_mongoc_cluster_init_scram (const mongoc_cluster_t *cluster, - mongoc_scram_t *scram, - mongoc_crypto_hash_algorithm_t algo) -{ - _mongoc_uri_init_scram (cluster->uri, scram, algo); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_get_auth_cmd_scram -- - * - * Generates the saslStart command for scram authentication. Used - * during explicit authentication as well as speculative - * authentication during hello. - * - * - * Returns: - * true if the command could be generated, false otherwise - * - * Side effects: - * @error is set on failure. - * - *-------------------------------------------------------------------------- - */ - -bool -_mongoc_cluster_get_auth_cmd_scram (mongoc_crypto_hash_algorithm_t algo, - mongoc_scram_t *scram, - bson_t *cmd /* OUT */, - bson_error_t *error /* OUT */) -{ - uint8_t buf[4096] = {0}; - uint32_t buflen = 0; - bson_t options; - - if (!_mongoc_scram_step ( - scram, buf, buflen, buf, sizeof buf, &buflen, error)) { - return false; - } - - BSON_ASSERT (scram->step == 1); - - bson_init (cmd); - - BSON_APPEND_INT32 (cmd, "saslStart", 1); - if (algo == MONGOC_CRYPTO_ALGORITHM_SHA_1) { - BSON_APPEND_UTF8 (cmd, "mechanism", "SCRAM-SHA-1"); - } else if (algo == MONGOC_CRYPTO_ALGORITHM_SHA_256) { - BSON_APPEND_UTF8 (cmd, "mechanism", "SCRAM-SHA-256"); - } else { - BSON_ASSERT (false); - } - bson_append_binary (cmd, "payload", 7, BSON_SUBTYPE_BINARY, buf, buflen); - BSON_APPEND_INT32 (cmd, "autoAuthorize", 1); - - BSON_APPEND_DOCUMENT_BEGIN (cmd, "options", &options); - BSON_APPEND_BOOL (&options, "skipEmptyExchange", true); - bson_append_document_end (cmd, &options); - - bson_destroy (&options); - - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_run_scram_command -- - * - * Runs a scram authentication command, handling auth_source and - * errors during the command. - * - * - * Returns: - * true if the command was successful, false otherwise - * - * Side effects: - * @error is set on failure. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_cluster_run_scram_command ( - mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - const mongoc_server_description_t *handshake_sd, - const bson_t *cmd, - bson_t *reply, - bson_error_t *error) -{ - mongoc_cmd_parts_t parts; - mongoc_server_stream_t *server_stream; - const char *auth_source; - mc_shared_tpld td = - mc_tpld_take_ref (BSON_ASSERT_PTR_INLINE (cluster)->client->topology); - - if (!(auth_source = mongoc_uri_get_auth_source (cluster->uri)) || - (*auth_source == '\0')) { - auth_source = "admin"; - } - - mongoc_cmd_parts_init ( - &parts, cluster->client, auth_source, MONGOC_QUERY_SECONDARY_OK, cmd); - parts.prohibit_lsid = true; - server_stream = - _mongoc_cluster_create_server_stream (td.ptr, handshake_sd, stream); - mc_tpld_drop_ref (&td); - - if (!mongoc_cluster_run_command_parts ( - cluster, server_stream, &parts, reply, error)) { - mongoc_server_stream_cleanup (server_stream); - bson_destroy (reply); - - /* error->message is already set */ - error->domain = MONGOC_ERROR_CLIENT; - error->code = MONGOC_ERROR_CLIENT_AUTHENTICATE; - - return false; - } - - mongoc_server_stream_cleanup (server_stream); - - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_auth_scram_start -- - * - * Starts scram authentication by generating and sending the saslStart - * command. The conversation can then be resumed using - * _mongoc_cluster_auth_scram_continue. - * - * - * Returns: - * true if the saslStart command was successful, false otherwise - * - * Side effects: - * @error is set on failure. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_cluster_auth_scram_start ( - mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - const mongoc_server_description_t *handshake_sd, - mongoc_crypto_hash_algorithm_t algo, - mongoc_scram_t *scram, - bson_t *reply, - bson_error_t *error) -{ - bson_t cmd; - - BSON_ASSERT (scram->step == 0); - - if (!_mongoc_cluster_get_auth_cmd_scram (algo, scram, &cmd, error)) { - /* error->message is already set */ - error->domain = MONGOC_ERROR_CLIENT; - error->code = MONGOC_ERROR_CLIENT_AUTHENTICATE; - - return false; - } - - if (!_mongoc_cluster_run_scram_command ( - cluster, stream, handshake_sd, &cmd, reply, error)) { - bson_destroy (&cmd); - - return false; - } - - bson_destroy (&cmd); - - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_scram_handle_reply -- - * - * Handles replies from _mongoc_cluster_run_scram_command. The @done - * argument will be set to true if the scram conversation was - * completed successfully. - * - * - * Returns: - * true if the reply was handled successfully, false if there was an - * error. Note that the return value itself does not indicate whether - * authentication was completed successfully. - * - * Side effects: - * @error is set on failure. @done, @conv_id, @buf, and @buflen are - * set for use in the next scram step. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_cluster_scram_handle_reply (mongoc_scram_t *scram, - const bson_t *reply, - bool *done /* OUT */, - int *conv_id /* OUT */, - uint8_t *buf /* OUT */, - uint32_t bufmax, - uint32_t *buflen /* OUT */, - bson_error_t *error) -{ - bson_iter_t iter; - bson_subtype_t btype; - const char *tmpstr; - - BSON_ASSERT (scram); - - bool is_done = false; - bsonParse (*reply, find (key ("done"), storeBool (is_done))); - - if (is_done) { - if (scram->step < 2) { - /* Prior to step 2, we haven't even received server proof. */ - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Incorrect step for 'done'"); - return false; - } - *done = true; - if (scram->step >= 3) { - return true; - } - } - - if (!bson_iter_init_find (&iter, reply, "conversationId") || - !BSON_ITER_HOLDS_INT32 (&iter) || - !(*conv_id = bson_iter_int32 (&iter)) || - !bson_iter_init_find (&iter, reply, "payload") || - !BSON_ITER_HOLDS_BINARY (&iter)) { - const char *errmsg = "Received invalid SCRAM reply from MongoDB server."; - - MONGOC_DEBUG ("SCRAM: authentication failed"); - - if (bson_iter_init_find (&iter, reply, "errmsg") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - errmsg = bson_iter_utf8 (&iter, NULL); - } - - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "%s", - errmsg); - return false; - } - - bson_iter_binary (&iter, &btype, buflen, (const uint8_t **) &tmpstr); - - if (*buflen > bufmax) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "SCRAM reply from MongoDB is too large."); - return false; - } - - memcpy (buf, tmpstr, *buflen); - - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_auth_scram_continue -- - * - * Continues the scram conversation from the reply to a saslStart - * command, either sent explicitly or received through speculative - * authentication during hello. - * - * - * Returns: - * true if authenticated. false on failure and @error is set. - * - * Side effects: - * @error is set on failure. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_cluster_auth_scram_continue ( - mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - const mongoc_server_description_t *handshake_sd, - mongoc_scram_t *scram, - const bson_t *sasl_start_reply, - bson_error_t *error) -{ - bson_t cmd; - uint8_t buf[4096] = {0}; - uint32_t buflen = 0; - int conv_id = 0; - bool done = false; - bson_t reply_local; - - if (!_mongoc_cluster_scram_handle_reply (scram, - sasl_start_reply, - &done, - &conv_id, - buf, - sizeof buf, - &buflen, - error)) { - return false; - } - - for (;;) { - if (!_mongoc_scram_step ( - scram, buf, buflen, buf, sizeof buf, &buflen, error)) { - return false; - } - - if (done && (scram->step >= 3)) { - break; - } - - bson_init (&cmd); - - BSON_APPEND_INT32 (&cmd, "saslContinue", 1); - BSON_APPEND_INT32 (&cmd, "conversationId", conv_id); - bson_append_binary (&cmd, "payload", 7, BSON_SUBTYPE_BINARY, buf, buflen); - - TRACE ("SCRAM: authenticating (step %d)", scram->step); - - if (!_mongoc_cluster_run_scram_command ( - cluster, stream, handshake_sd, &cmd, &reply_local, error)) { - bson_destroy (&cmd); - return false; - } - - bson_destroy (&cmd); - - if (!_mongoc_cluster_scram_handle_reply (scram, - &reply_local, - &done, - &conv_id, - buf, - sizeof buf, - &buflen, - error)) { - bson_destroy (&reply_local); - return false; - } - - bson_destroy (&reply_local); - - if (done && (scram->step >= 3)) { - break; - } - } - - TRACE ("%s", "SCRAM: authenticated"); - - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_auth_node_scram -- - * - * Invokes scram authentication by sending a saslStart command and - * handling all replies. - * - * - * Returns: - * true if authenticated. false on failure and @error is set. - * - * Side effects: - * @error is set on failure. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_cluster_auth_node_scram (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *handshake_sd, - mongoc_crypto_hash_algorithm_t algo, - bson_error_t *error) -{ - mongoc_scram_t scram; - bool ret = false; - bson_t reply; - - BSON_ASSERT (cluster); - - _mongoc_cluster_init_scram (cluster, &scram, algo); - - if (!_mongoc_cluster_auth_scram_start ( - cluster, stream, handshake_sd, algo, &scram, &reply, error)) { - goto failure; - } - - if (!_mongoc_cluster_auth_scram_continue ( - cluster, stream, handshake_sd, &scram, &reply, error)) { - bson_destroy (&reply); - - goto failure; - } - - TRACE ("%s", "SCRAM: authenticated"); - - ret = true; - - bson_destroy (&reply); - -failure: - _mongoc_scram_destroy (&scram); - - return ret; -} -#endif - -static bool -_mongoc_cluster_auth_node_scram_sha_1 (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_error_t *error) -{ -#ifndef MONGOC_ENABLE_CRYPTO - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "The SCRAM_SHA_1 authentication mechanism requires " - "libmongoc built with ENABLE_SSL"); - return false; -#else - return _mongoc_cluster_auth_node_scram ( - cluster, stream, sd, MONGOC_CRYPTO_ALGORITHM_SHA_1, error); -#endif -} - -static bool -_mongoc_cluster_auth_node_scram_sha_256 (mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - bson_error_t *error) -{ -#ifndef MONGOC_ENABLE_CRYPTO - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "The SCRAM_SHA_256 authentication mechanism requires " - "libmongoc built with ENABLE_SSL"); - return false; -#else - return _mongoc_cluster_auth_node_scram ( - cluster, stream, sd, MONGOC_CRYPTO_ALGORITHM_SHA_256, error); -#endif -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cluster_auth_node -- - * - * Authenticate a cluster node depending on the required mechanism. - * - * Returns: - * true if authenticated. false on failure and @error is set. - * - * Side effects: - * @error is set on failure. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_cluster_auth_node ( - mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *sd, - const mongoc_handshake_sasl_supported_mechs_t *sasl_supported_mechs, - bson_error_t *error) -{ - bool ret = false; - const char *mechanism; - ENTRY; - - BSON_ASSERT (cluster); - BSON_ASSERT (stream); - - mechanism = mongoc_uri_get_auth_mechanism (cluster->uri); - - if (!mechanism) { - if (sasl_supported_mechs->scram_sha_256) { - /* Auth spec: "If SCRAM-SHA-256 is present in the list of mechanisms, - * then it MUST be used as the default; otherwise, SCRAM-SHA-1 MUST be - * used as the default, regardless of whether SCRAM-SHA-1 is in the - * list. Drivers MUST NOT attempt to use any other mechanism (e.g. - * PLAIN) as the default." [...] "If saslSupportedMechs is not present - * in the hello results for mechanism negotiation, then SCRAM-SHA-1 - * MUST be used when talking to servers >= 3.0." */ - mechanism = "SCRAM-SHA-256"; - } else { - mechanism = "SCRAM-SHA-1"; - } - } - - if (0 == strcasecmp (mechanism, "MONGODB-CR")) { - ret = _mongoc_cluster_auth_node_cr (cluster, stream, sd, error); - } else if (0 == strcasecmp (mechanism, "MONGODB-X509")) { - ret = _mongoc_cluster_auth_node_x509 (cluster, stream, sd, error); - } else if (0 == strcasecmp (mechanism, "SCRAM-SHA-1")) { - ret = _mongoc_cluster_auth_node_scram_sha_1 (cluster, stream, sd, error); - } else if (0 == strcasecmp (mechanism, "SCRAM-SHA-256")) { - ret = - _mongoc_cluster_auth_node_scram_sha_256 (cluster, stream, sd, error); - } else if (0 == strcasecmp (mechanism, "GSSAPI")) { - ret = _mongoc_cluster_auth_node_sasl (cluster, stream, sd, error); - } else if (0 == strcasecmp (mechanism, "PLAIN")) { - ret = _mongoc_cluster_auth_node_plain (cluster, stream, sd, error); - } else if (0 == strcasecmp (mechanism, "MONGODB-AWS")) { - ret = _mongoc_cluster_auth_node_aws (cluster, stream, sd, error); - } else { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Unknown authentication mechanism \"%s\".", - mechanism); - } - - if (!ret) { - mongoc_counter_auth_failure_inc (); - MONGOC_DEBUG ("Authentication failed: %s", error->message); - } else { - mongoc_counter_auth_success_inc (); - TRACE ("%s", "Authentication succeeded"); - } - - RETURN (ret); -} - - -/* - * Close the connection associated with this server. - * - * Called when a network error occurs, or to close connection tied to an exhaust - * cursor. - * If the cluster is pooled, removes the node from cluster's set of nodes. - * WARNING: pointers to a disconnected mongoc_cluster_node_t or its stream are - * now invalid, be careful of dangling pointers. - */ - -void -mongoc_cluster_disconnect_node (mongoc_cluster_t *cluster, uint32_t server_id) -{ - mongoc_topology_t *topology = cluster->client->topology; - - ENTRY; - - if (topology->single_threaded) { - mongoc_topology_scanner_node_t *scanner_node; - - scanner_node = - mongoc_topology_scanner_get_node (topology->scanner, server_id); - - /* might never actually have connected */ - if (scanner_node && scanner_node->stream) { - mongoc_topology_scanner_node_disconnect (scanner_node, true); - } - } else { - mongoc_set_rm (cluster->nodes, server_id); - } - - EXIT; -} - -static void -_mongoc_cluster_node_destroy (mongoc_cluster_node_t *node) -{ - /* Failure, or Replica Set reconfigure without this node */ - mongoc_stream_failed (node->stream); - bson_free (node->connection_address); - mongoc_server_description_destroy (node->handshake_sd); - - bson_free (node); -} - -static void -_mongoc_cluster_node_dtor (void *data_, void *ctx_) -{ - mongoc_cluster_node_t *node = (mongoc_cluster_node_t *) data_; - - BSON_UNUSED (ctx_); - - _mongoc_cluster_node_destroy (node); -} - -static mongoc_cluster_node_t * -_mongoc_cluster_node_new (mongoc_stream_t *stream, - const char *connection_address) -{ - mongoc_cluster_node_t *node; - - if (!stream) { - return NULL; - } - - node = (mongoc_cluster_node_t *) bson_malloc0 (sizeof *node); - - node->stream = stream; - node->connection_address = bson_strdup (connection_address); - - /* Note that the node->sd field is set to NULL by bson_malloc0(), - rather than being explicitly initialized. */ - - return node; -} - -static bool -_mongoc_cluster_finish_speculative_auth ( - mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - mongoc_server_description_t *handshake_sd, - bson_t *speculative_auth_response, - mongoc_scram_t *scram, - bson_error_t *error) -{ - const char *mechanism = - _mongoc_topology_scanner_get_speculative_auth_mechanism (cluster->uri); - bool ret = false; - bool auth_handled = false; - - BSON_ASSERT (handshake_sd); - BSON_ASSERT (speculative_auth_response); - - if (!mechanism) { - return false; - } - - if (bson_empty (speculative_auth_response)) { - return false; - } - -#ifdef MONGOC_ENABLE_SSL - if (strcasecmp (mechanism, "MONGODB-X509") == 0) { - /* For X509, a successful hello with speculativeAuthenticate field - * indicates successful auth */ - ret = true; - auth_handled = true; - } -#endif - -#ifdef MONGOC_ENABLE_CRYPTO - if (strcasecmp (mechanism, "SCRAM-SHA-1") == 0 || - strcasecmp (mechanism, "SCRAM-SHA-256") == 0) { - /* Don't attempt authentication if scram objects have advanced past - * saslStart */ - if (scram->step != 1) { - return false; - } - - auth_handled = true; - - ret = _mongoc_cluster_auth_scram_continue (cluster, - stream, - handshake_sd, - scram, - speculative_auth_response, - error); - } -#endif - - if (auth_handled) { - if (!ret) { - mongoc_counter_auth_failure_inc (); - MONGOC_DEBUG ("Speculative authentication failed: %s", error->message); - } else { - mongoc_counter_auth_success_inc (); - TRACE ("%s", "Speculative authentication succeeded"); - } - } - - bson_reinit (speculative_auth_response); - - return ret; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_add_node -- - * - * Add a new node to this cluster for the given server description. - * - * NOTE: does NOT check if this server is already in the cluster. - * - * Returns: - * A stream connected to the server, or NULL on failure. - * - * Side effects: - * Adds a cluster node, or sets error on failure. - * - *-------------------------------------------------------------------------- - */ -static mongoc_cluster_node_t * -_cluster_add_node (mongoc_cluster_t *cluster, - const mongoc_topology_description_t *td, - uint32_t server_id, - bson_error_t *error /* OUT */) -{ - mongoc_host_list_t *host = NULL; - mongoc_cluster_node_t *cluster_node = NULL; - mongoc_stream_t *stream; - mongoc_server_description_t *handshake_sd; - mongoc_handshake_sasl_supported_mechs_t sasl_supported_mechs; - mongoc_scram_t scram = {0}; - bson_t speculative_auth_response = BSON_INITIALIZER; - - ENTRY; - - BSON_ASSERT (!cluster->client->topology->single_threaded); - - host = _mongoc_topology_host_by_id (td, server_id, error); - - if (!host) { - GOTO (error); - } - - TRACE ("Adding new server to cluster: %s", host->host_and_port); - - stream = _mongoc_client_create_stream (cluster->client, host, error); - - if (!stream) { - MONGOC_WARNING ( - "Failed connection to %s (%s)", host->host_and_port, error->message); - GOTO (error); - /* TODO CDRIVER-3654: if this is a non-timeout network error and the - * generation is not stale, mark the server unknown and increment the - * generation. */ - } - - /* take critical fields from a fresh hello */ - cluster_node = _mongoc_cluster_node_new (stream, host->host_and_port); - - handshake_sd = _cluster_run_hello (cluster, - cluster_node, - server_id, - &scram, - &speculative_auth_response, - error); - if (!handshake_sd) { - GOTO (error); - } - - _mongoc_handshake_parse_sasl_supported_mechs ( - &handshake_sd->last_hello_response, &sasl_supported_mechs); - - if (cluster->requires_auth) { - /* Complete speculative authentication */ - bool is_auth = - _mongoc_cluster_finish_speculative_auth (cluster, - stream, - handshake_sd, - &speculative_auth_response, - &scram, - error); - - if (!is_auth && !_mongoc_cluster_auth_node (cluster, - cluster_node->stream, - handshake_sd, - &sasl_supported_mechs, - error)) { - MONGOC_WARNING ("Failed authentication to %s (%s)", - host->host_and_port, - error->message); - mongoc_server_description_destroy (handshake_sd); - GOTO (error); - } - } - - /* Transfer ownership of the server description into the cluster node. */ - cluster_node->handshake_sd = handshake_sd; - /* Copy the latest connection pool generation. - * TODO (CDRIVER-4078) do not store the generation counter on the server - * description */ - handshake_sd->generation = _mongoc_topology_get_connection_pool_generation ( - td, server_id, &handshake_sd->service_id); - - bson_destroy (&speculative_auth_response); - mongoc_set_add (cluster->nodes, server_id, cluster_node); - _mongoc_host_list_destroy_all (host); - -#ifdef MONGOC_ENABLE_CRYPTO - _mongoc_scram_destroy (&scram); -#endif - - RETURN (cluster_node); - -error: - bson_destroy (&speculative_auth_response); - _mongoc_host_list_destroy_all (host); /* null ok */ - -#ifdef MONGOC_ENABLE_CRYPTO - _mongoc_scram_destroy (&scram); -#endif - - if (cluster_node) { - _mongoc_cluster_node_destroy (cluster_node); /* also destroys stream */ - } - - RETURN (NULL); -} - -static void -node_not_found (const mongoc_topology_description_t *td, - uint32_t server_id, - bson_error_t *error /* OUT */) -{ - mongoc_server_description_t const *sd; - - if (!error) { - return; - } - - sd = mongoc_topology_description_server_by_id_const (td, server_id, error); - - if (!sd) { - return; - } - - if (sd->error.code) { - memcpy (error, &sd->error, sizeof *error); - } else { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NOT_ESTABLISHED, - "Could not find node %s", - sd->host.host_and_port); - } -} - - -static void -stream_not_found (const mongoc_topology_description_t *td, - uint32_t server_id, - const char *connection_address, - bson_error_t *error /* OUT */) -{ - mongoc_server_description_t const *sd; - - sd = mongoc_topology_description_server_by_id_const (td, server_id, error); - - if (error) { - if (sd && sd->error.code) { - memcpy (error, &sd->error, sizeof *error); - } else { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NOT_ESTABLISHED, - "Could not find stream for node %s", - connection_address); - } - } -} - -static mongoc_server_stream_t * -_try_get_server_stream (mongoc_cluster_t *cluster, - const mongoc_topology_description_t *td, - uint32_t server_id, - bool reconnect_ok, - bson_error_t *error) -{ - if (cluster->client->topology->single_threaded) { - /* in the single-threaded use case we share topology's streams */ - return _cluster_fetch_stream_single ( - cluster, td, server_id, reconnect_ok, error); - } else { - return _cluster_fetch_stream_pooled ( - cluster, td, server_id, reconnect_ok, error); - } -} - -static mongoc_server_stream_t * -_mongoc_cluster_stream_for_server (mongoc_cluster_t *cluster, - uint32_t server_id, - bool reconnect_ok, - const mongoc_client_session_t *cs, - bson_t *reply, - bson_error_t *error /* OUT */) -{ - mongoc_topology_t *const topology = - BSON_ASSERT_PTR_INLINE (cluster)->client->topology; - mongoc_server_stream_t *ret_server_stream; - bson_error_t err_local; - /* if fetch_stream fails we need a place to receive error details and pass - * them to mongoc_topology_description_invalidate_server. */ - bson_error_t *err_ptr = error ? error : &err_local; - mc_tpld_modification tdmod; - mc_shared_tpld td; - - ENTRY; - - td = mc_tpld_take_ref (topology); - - ret_server_stream = _try_get_server_stream ( - cluster, td.ptr, server_id, reconnect_ok, err_ptr); - - if (!ret_server_stream) { - /* TODO CDRIVER-3654. A null server stream could be due to: - * 1. Network error during handshake. - * 2. Failure to retrieve server description (if it was removed from - * topology). - * 3. Auth error during handshake. - * Only (1) should mark the server unknown and clear the pool. - * Network errors should be checked at a lower layer than this, when an - * operation on a stream fails, and should take the connection generation - * into account. - */ - - _mongoc_bson_init_if_set (reply); - - // Add a transient transaction label if applicable. - _mongoc_add_transient_txn_error (cs, reply); - - /* Update the topology */ - tdmod = mc_tpld_modify_begin (topology); - - /* When establishing a new connection in load balanced mode, drivers MUST - * NOT perform SDAM error handling for any errors that occur before the - * MongoDB Handshake. */ - if (tdmod.new_td->type == MONGOC_TOPOLOGY_LOAD_BALANCED) { - mc_tpld_modify_drop (tdmod); - ret_server_stream = NULL; - goto done; - } - - mongoc_topology_description_invalidate_server ( - tdmod.new_td, server_id, err_ptr); - mongoc_cluster_disconnect_node (cluster, server_id); - /* This is not load balanced mode, so there are no service IDs associated - * with connections. Pass kZeroServiceId to clear the entire connection - * pool to this server. */ - _mongoc_topology_description_clear_connection_pool ( - tdmod.new_td, server_id, &kZeroServiceId); - - if (!topology->single_threaded) { - _mongoc_topology_background_monitoring_cancel_check (topology, - server_id); - } - mc_tpld_modify_commit (tdmod); - ret_server_stream = NULL; - goto done; - } - - /* If this is a load balanced topology and the server stream does not have a - * service id, disconnect and return an error. */ - if (td.ptr->type == MONGOC_TOPOLOGY_LOAD_BALANCED) { - if (!mongoc_server_description_has_service_id (ret_server_stream->sd)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_LOAD_BALANCER, - "Driver attempted to initialize in load balancing " - "mode, but the server does not support this mode."); - mongoc_server_stream_cleanup (ret_server_stream); - mongoc_cluster_disconnect_node (cluster, server_id); - _mongoc_bson_init_if_set (reply); - ret_server_stream = NULL; - goto done; - } - } - -done: - mc_tpld_drop_ref (&td); - RETURN (ret_server_stream); -} - - -mongoc_server_stream_t * -mongoc_cluster_stream_for_server (mongoc_cluster_t *cluster, - uint32_t server_id, - bool reconnect_ok, - mongoc_client_session_t *cs, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT (cs || true); - BSON_ASSERT (reply || true); - BSON_ASSERT (error || true); - - ENTRY; - - BSON_ASSERT (cluster); - - if (cs && cs->server_id && cs->server_id != server_id) { - _mongoc_bson_init_if_set (reply); - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_SERVER_SELECTION_INVALID_ID, - "Requested server id does not matched pinned server id"); - RETURN (NULL); - } - - - mongoc_server_stream_t *const server_stream = - _mongoc_cluster_stream_for_server ( - cluster, server_id, reconnect_ok, cs, reply, error); - - if (_in_sharded_txn (cs)) { - _mongoc_client_session_pin (cs, server_id); - } else { - /* Transactions Spec: Additionally, any non-transaction operation using - * a pinned ClientSession MUST unpin the session and the operation MUST - * perform normal server selection. */ - if (cs && !_mongoc_client_session_in_txn_or_ending (cs)) { - _mongoc_client_session_unpin (cs); - } - } - - RETURN (server_stream); -} - - -static mongoc_server_stream_t * -_cluster_fetch_stream_single (mongoc_cluster_t *cluster, - const mongoc_topology_description_t *td, - uint32_t server_id, - bool reconnect_ok, - bson_error_t *error /* OUT */) -{ - mongoc_server_description_t *handshake_sd; - mongoc_topology_scanner_node_t *scanner_node; - char *address; - - scanner_node = mongoc_topology_scanner_get_node ( - cluster->client->topology->scanner, server_id); - /* This could happen if a user explicitly passes a bad server id. */ - if (!scanner_node) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Could not find server with id: %d", - server_id); - return NULL; - } - - /* Retired scanner nodes are removed at the end of a scan. If the node was - * retired, that would indicate a bug. */ - if (scanner_node->retired) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Unexpected, selecting server marked for removal: %s", - scanner_node->host.host_and_port); - return NULL; - } - - if (scanner_node->stream) { - handshake_sd = - mongoc_server_description_new_copy (scanner_node->handshake_sd); - } else { - if (!reconnect_ok) { - stream_not_found ( - td, server_id, scanner_node->host.host_and_port, error); - return NULL; - } - - /* save the scanner node address in case it is removed during the scan. */ - address = bson_strdup (scanner_node->host.host_and_port); - _mongoc_topology_do_blocking_scan (cluster->client->topology, error); - if (error->code) { - bson_free (address); - return NULL; - } - - scanner_node = mongoc_topology_scanner_get_node ( - cluster->client->topology->scanner, server_id); - - if (!scanner_node || !scanner_node->stream) { - stream_not_found (td, server_id, address, error); - bson_free (address); - return NULL; - } - bson_free (address); - - handshake_sd = - mongoc_server_description_new_copy (scanner_node->handshake_sd); - } - - if (handshake_sd->type == MONGOC_SERVER_UNKNOWN) { - *error = handshake_sd->error; - mongoc_server_description_destroy (handshake_sd); - return NULL; - } - - /* stream open but not auth'ed: first use since connect or reconnect */ - if (cluster->requires_auth && !scanner_node->has_auth) { - /* Complete speculative authentication */ - bool has_speculative_auth = _mongoc_cluster_finish_speculative_auth ( - cluster, - scanner_node->stream, - handshake_sd, - &scanner_node->speculative_auth_response, - &scanner_node->scram, - &handshake_sd->error); - -#ifdef MONGOC_ENABLE_CRYPTO - _mongoc_scram_destroy (&scanner_node->scram); -#endif - - if (!scanner_node->stream) { - *error = handshake_sd->error; - mongoc_server_description_destroy (handshake_sd); - return NULL; - } - - if (!has_speculative_auth && - !_mongoc_cluster_auth_node (cluster, - scanner_node->stream, - handshake_sd, - &scanner_node->sasl_supported_mechs, - &handshake_sd->error)) { - *error = handshake_sd->error; - mongoc_server_description_destroy (handshake_sd); - return NULL; - } - - scanner_node->has_auth = true; - } - - /* Copy the latest connection pool generation. - * TODO (CDRIVER-4078) do not store the generation counter on the server - * description */ - handshake_sd->generation = _mongoc_topology_get_connection_pool_generation ( - td, server_id, &handshake_sd->service_id); - return mongoc_server_stream_new (td, handshake_sd, scanner_node->stream); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_stream_valid -- - * - * Internal function to determine if @server_stream is valid and - * associated with the given cluster. - * - * Returns: - * true if @server_stream is not NULL, hasn't been freed or changed; - * otherwise false. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_cluster_stream_valid (mongoc_cluster_t *cluster, - mongoc_server_stream_t *server_stream) -{ - mongoc_server_stream_t *tmp_stream = NULL; - mongoc_topology_t *topology = - BSON_ASSERT_PTR_INLINE (cluster)->client->topology; - const mongoc_server_description_t *sd; - bool ret = false; - bson_error_t error; - mc_shared_tpld td = mc_tpld_take_ref (topology); - - if (!server_stream) { - goto done; - } - - tmp_stream = mongoc_cluster_stream_for_server ( - cluster, server_stream->sd->id, false, NULL, NULL, NULL); - if (!tmp_stream || tmp_stream->stream != server_stream->stream) { - /* stream was freed, or has changed. */ - goto done; - } - - /* Check that the server stream is still valid for the given server, and that - * the server is still registered. */ - sd = mongoc_topology_description_server_by_id_const ( - td.ptr, server_stream->sd->id, &error); - if (!sd || - server_stream->sd->generation < - _mongoc_topology_get_connection_pool_generation ( - td.ptr, server_stream->sd->id, &server_stream->sd->service_id)) { - /* No server description, or the pool has been cleared. */ - goto done; - } - - ret = true; -done: - mc_tpld_drop_ref (&td); - mongoc_server_stream_cleanup (tmp_stream); - return ret; -} - -mongoc_server_stream_t * -_mongoc_cluster_create_server_stream ( - mongoc_topology_description_t const *td, - const mongoc_server_description_t *handshake_sd, - mongoc_stream_t *stream) -{ - mongoc_server_description_t *const sd = - mongoc_server_description_new_copy (handshake_sd); - /* can't just use mongoc_topology_server_by_id(), since we must hold the - * lock while copying topology->shared_descr.ptr->logical_time below */ - return mongoc_server_stream_new (td, sd, stream); -} - - -static mongoc_server_stream_t * -_cluster_fetch_stream_pooled (mongoc_cluster_t *cluster, - const mongoc_topology_description_t *td, - uint32_t server_id, - bool reconnect_ok, - bson_error_t *error /* OUT */) -{ - mongoc_cluster_node_t *cluster_node; - mongoc_server_description_t const *sd; - bool has_server_description = false; - - cluster_node = - (mongoc_cluster_node_t *) mongoc_set_get (cluster->nodes, server_id); - - sd = mongoc_topology_description_server_by_id_const (td, server_id, error); - if (sd) { - has_server_description = true; - } - - if (cluster_node) { - uint32_t connection_pool_generation = 0; - BSON_ASSERT (cluster_node->stream); - - connection_pool_generation = - _mongoc_topology_get_connection_pool_generation ( - td, server_id, &cluster_node->handshake_sd->service_id); - - if (!has_server_description || - cluster_node->handshake_sd->generation < connection_pool_generation) { - /* Since the stream was created, connections to this server were - * invalidated. - * This may have happened if: - * - A background scan removed the server description. - * - A network error or a "not primary"/"node is recovering" error - * occurred on an app connection. - * - A network error occurred on the monitor connection. - */ - mongoc_cluster_disconnect_node (cluster, server_id); - } else { - return _mongoc_cluster_create_server_stream ( - td, cluster_node->handshake_sd, cluster_node->stream); - } - } - - /* no node, or out of date */ - if (!reconnect_ok) { - node_not_found (td, server_id, error); - return NULL; - } - - cluster_node = _cluster_add_node (cluster, td, server_id, error); - if (cluster_node) { - return _mongoc_cluster_create_server_stream ( - td, cluster_node->handshake_sd, cluster_node->stream); - } else { - return NULL; - } -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_init -- - * - * Initializes @cluster using the @uri and @client provided. The - * @uri is used to determine the "mode" of the cluster. Based on the - * uri we can determine if we are connected to a single host, a - * replicaSet, or a shardedCluster. - * - * Returns: - * None. - * - * Side effects: - * @cluster is initialized. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_cluster_init (mongoc_cluster_t *cluster, - const mongoc_uri_t *uri, - void *client) -{ - ENTRY; - - BSON_ASSERT (cluster); - BSON_ASSERT (uri); - - memset (cluster, 0, sizeof *cluster); - - cluster->uri = mongoc_uri_copy (uri); - cluster->client = (mongoc_client_t *) client; - cluster->requires_auth = - (mongoc_uri_get_username (uri) || mongoc_uri_get_auth_mechanism (uri)); - - cluster->sockettimeoutms = mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_SOCKETTIMEOUTMS, MONGOC_DEFAULT_SOCKETTIMEOUTMS); - - cluster->socketcheckintervalms = - mongoc_uri_get_option_as_int32 (uri, - MONGOC_URI_SOCKETCHECKINTERVALMS, - MONGOC_TOPOLOGY_SOCKET_CHECK_INTERVAL_MS); - - /* TODO for single-threaded case we don't need this */ - cluster->nodes = mongoc_set_new (8, _mongoc_cluster_node_dtor, NULL); - - _mongoc_array_init (&cluster->iov, sizeof (mongoc_iovec_t)); - - cluster->operation_id = rand (); - - EXIT; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_destroy -- - * - * Clean up after @cluster and destroy all active connections. - * All resources for @cluster are released. - * - * Returns: - * None. - * - * Side effects: - * Everything. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_cluster_destroy (mongoc_cluster_t *cluster) /* INOUT */ -{ - ENTRY; - - BSON_ASSERT (cluster); - - mongoc_uri_destroy (cluster->uri); - - mongoc_set_destroy (cluster->nodes); - - _mongoc_array_destroy (&cluster->iov); - - EXIT; -} - -static uint32_t -_mongoc_cluster_select_server_id (mongoc_client_session_t *cs, - mongoc_topology_t *topology, - mongoc_ss_optype_t optype, - const mongoc_read_prefs_t *read_prefs, - bool *must_use_primary, - const mongoc_deprioritized_servers_t *ds, - bson_error_t *error) -{ - BSON_ASSERT (cs || true); - BSON_ASSERT_PARAM (topology); - BSON_ASSERT (read_prefs || true); - BSON_ASSERT_PARAM (must_use_primary); - BSON_ASSERT (error || true); - - uint32_t server_id; - - if (_in_sharded_txn (cs)) { - server_id = cs->server_id; - if (!server_id) { - server_id = mongoc_topology_select_server_id ( - topology, optype, read_prefs, must_use_primary, ds, error); - if (server_id) { - _mongoc_client_session_pin (cs, server_id); - } - } - } else { - server_id = mongoc_topology_select_server_id ( - topology, optype, read_prefs, must_use_primary, ds, error); - /* Transactions Spec: Additionally, any non-transaction operation using a - * pinned ClientSession MUST unpin the session and the operation MUST - * perform normal server selection. */ - if (cs && !_mongoc_client_session_in_txn_or_ending (cs)) { - _mongoc_client_session_unpin (cs); - } - } - - return server_id; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_stream_for_optype -- - * - * Internal server selection. - * - * Returns: - * A mongoc_server_stream_t on which you must call - * mongoc_server_stream_cleanup, or NULL on failure (sets @error) - * - * Side effects: - * May add or disconnect nodes in @cluster->nodes. - * Sets @error and initializes @reply on error. - * - *-------------------------------------------------------------------------- - */ - -static mongoc_server_stream_t * -_mongoc_cluster_stream_for_optype (mongoc_cluster_t *cluster, - mongoc_ss_optype_t optype, - const mongoc_read_prefs_t *read_prefs, - mongoc_client_session_t *cs, - bool is_retryable, - const mongoc_deprioritized_servers_t *ds, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT (read_prefs || true); - BSON_ASSERT (cs || true); - BSON_ASSERT (reply || true); - BSON_ASSERT (error || true); - - mongoc_server_stream_t *server_stream; - uint32_t server_id; - mongoc_topology_t *topology = cluster->client->topology; - bool must_use_primary = false; - - ENTRY; - - BSON_ASSERT (cluster); - - server_id = _mongoc_cluster_select_server_id ( - cs, topology, optype, read_prefs, &must_use_primary, ds, error); - - if (!server_id) { - if (reply) { - bson_init (reply); - _mongoc_add_transient_txn_error (cs, reply); - } - RETURN (NULL); - } - - if (!mongoc_cluster_check_interval (cluster, server_id)) { - /* Server Selection Spec: try once more */ - server_id = _mongoc_cluster_select_server_id ( - cs, topology, optype, read_prefs, &must_use_primary, ds, error); - - if (!server_id) { - if (reply) { - bson_init (reply); - _mongoc_add_transient_txn_error (cs, reply); - } - RETURN (NULL); - } - } - - bson_t first_reply; - bson_error_t first_error = {0}; - - server_stream = _mongoc_cluster_stream_for_server (cluster, - server_id, - true /* reconnect_ok */, - cs, - &first_reply, - &first_error); - - if (server_stream) { - server_stream->must_use_primary = must_use_primary; - RETURN (server_stream); - } - - // Important: authentication errors are also considered retryable even if - // they not considered a network error. - const bool retryable_error = _mongoc_error_is_network (&first_error) || - _mongoc_error_is_auth (&first_error); - - if (is_retryable && retryable_error) { - bson_t retry_reply; - bson_error_t retry_error = {0}; - - server_stream = - _mongoc_cluster_stream_for_server (cluster, - server_id, - true /* reconnect_ok */, - cs, - &retry_reply, - &retry_error); - - if (server_stream) { - server_stream->must_use_primary = must_use_primary; - server_stream->retry_attempted = true; - bson_destroy (&first_reply); - RETURN (server_stream); - } - - if (optype != MONGOC_SS_READ) { - // Retryable Writes Spec: When the driver encounters a network error - // establishing an initial connection to a server, it MUST add a - // RetryableWriteError label to that error if the MongoClient - // performing the operation has the retryWrites configuration option - // set to true. - _mongoc_write_error_append_retryable_label (&first_reply); - } - - bson_destroy (&retry_reply); - } - - // Retryable Writes Spec: If the driver cannot select a server for the retry - // attempt [...], retrying is not possible and drivers MUST raise the - // original retryable error. - { - if (reply) { - bson_copy_to (&first_reply, reply); - } - - bson_destroy (&first_reply); - - if (error) { - *error = first_error; - } - } - - RETURN (NULL); -} - -mongoc_server_stream_t * -mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster, - const mongoc_read_prefs_t *read_prefs, - mongoc_client_session_t *cs, - const mongoc_deprioritized_servers_t *ds, - bson_t *reply, - bson_error_t *error) -{ - const mongoc_read_prefs_t *const prefs_override = - _mongoc_client_session_in_txn (cs) ? cs->txn.opts.read_prefs : read_prefs; - - // Retryable Reads Spec: This boolean option determines whether retryable - // behavior will be applied to all read operations executed within the - // MongoClient. - const bool is_retryable = mongoc_uri_get_option_as_bool ( - cluster->uri, MONGOC_URI_RETRYREADS, MONGOC_DEFAULT_RETRYREADS); - - return _mongoc_cluster_stream_for_optype (cluster, - MONGOC_SS_READ, - prefs_override, - cs, - is_retryable, - ds, - reply, - error); -} - -mongoc_server_stream_t * -mongoc_cluster_stream_for_writes (mongoc_cluster_t *cluster, - mongoc_client_session_t *cs, - const mongoc_deprioritized_servers_t *ds, - bson_t *reply, - bson_error_t *error) -{ - const bool is_retryable = mongoc_uri_get_option_as_bool ( - cluster->uri, MONGOC_URI_RETRYWRITES, MONGOC_DEFAULT_RETRYWRITES); - - return _mongoc_cluster_stream_for_optype ( - cluster, MONGOC_SS_WRITE, NULL, cs, is_retryable, ds, reply, error); -} - -mongoc_server_stream_t * -mongoc_cluster_stream_for_aggr_with_write ( - mongoc_cluster_t *cluster, - const mongoc_read_prefs_t *read_prefs, - mongoc_client_session_t *cs, - bson_t *reply, - bson_error_t *error) -{ - const mongoc_read_prefs_t *const prefs_override = - _mongoc_client_session_in_txn (cs) ? cs->txn.opts.read_prefs : read_prefs; - - const bool is_retryable = mongoc_uri_get_option_as_bool ( - cluster->uri, MONGOC_URI_RETRYWRITES, MONGOC_DEFAULT_RETRYWRITES); - - return _mongoc_cluster_stream_for_optype (cluster, - MONGOC_SS_AGGREGATE_WITH_WRITE, - prefs_override, - cs, - is_retryable, - NULL, - reply, - error); -} - -static bool -_mongoc_cluster_min_of_max_obj_size_sds (const void *item, void *ctx) -{ - const mongoc_server_description_t *sd = item; - int32_t *current_min = (int32_t *) ctx; - - if (sd->max_bson_obj_size < *current_min) { - *current_min = sd->max_bson_obj_size; - } - return true; -} - -static bool -_mongoc_cluster_min_of_max_obj_size_nodes (void *item, void *ctx) -{ - mongoc_cluster_node_t *node = (mongoc_cluster_node_t *) item; - int32_t *current_min = (int32_t *) ctx; - - if (node->handshake_sd->max_bson_obj_size < *current_min) { - *current_min = node->handshake_sd->max_bson_obj_size; - } - return true; -} - -static bool -_mongoc_cluster_min_of_max_msg_size_sds (const void *item, void *ctx) -{ - const mongoc_server_description_t *sd = item; - int32_t *current_min = (int32_t *) ctx; - - if (sd->max_msg_size < *current_min) { - *current_min = sd->max_msg_size; - } - return true; -} - -static bool -_mongoc_cluster_min_of_max_msg_size_nodes (void *item, void *ctx) -{ - mongoc_cluster_node_t *node = (mongoc_cluster_node_t *) item; - int32_t *current_min = (int32_t *) ctx; - - if (node->handshake_sd->max_msg_size < *current_min) { - *current_min = node->handshake_sd->max_msg_size; - } - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_get_max_bson_obj_size -- - * - * Return the minimum max_bson_obj_size across all servers in cluster. - * - * Returns: - * The minimum max_bson_obj_size. - * - * Side effects: - * None - * - *-------------------------------------------------------------------------- - */ -int32_t -mongoc_cluster_get_max_bson_obj_size (mongoc_cluster_t *cluster) -{ - int32_t max_bson_obj_size = -1; - - max_bson_obj_size = MONGOC_DEFAULT_BSON_OBJ_SIZE; - - if (!cluster->client->topology->single_threaded) { - mongoc_set_for_each (cluster->nodes, - _mongoc_cluster_min_of_max_obj_size_nodes, - &max_bson_obj_size); - } else { - mc_shared_tpld td = - mc_tpld_take_ref (BSON_ASSERT_PTR_INLINE (cluster)->client->topology); - mongoc_set_for_each_const (mc_tpld_servers_const (td.ptr), - _mongoc_cluster_min_of_max_obj_size_sds, - &max_bson_obj_size); - mc_tpld_drop_ref (&td); - } - - return max_bson_obj_size; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_get_max_msg_size -- - * - * Return the minimum max msg size across all servers in cluster. - * - * Returns: - * The minimum max_msg_size - * - * Side effects: - * None - * - *-------------------------------------------------------------------------- - */ -int32_t -mongoc_cluster_get_max_msg_size (mongoc_cluster_t *cluster) -{ - int32_t max_msg_size = MONGOC_DEFAULT_MAX_MSG_SIZE; - - if (!cluster->client->topology->single_threaded) { - mongoc_set_for_each (cluster->nodes, - _mongoc_cluster_min_of_max_msg_size_nodes, - &max_msg_size); - } else { - mc_shared_tpld td = - mc_tpld_take_ref (BSON_ASSERT_PTR_INLINE (cluster)->client->topology); - mongoc_set_for_each_const (mc_tpld_servers_const (td.ptr), - _mongoc_cluster_min_of_max_msg_size_sds, - &max_msg_size); - mc_tpld_drop_ref (&td); - } - - return max_msg_size; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cluster_check_interval -- - * - * Server Selection Spec: - * - * Only for single-threaded drivers. - * - * If a server is selected that has an existing connection that has been - * idle for socketCheckIntervalMS, the driver MUST check the connection - * with the "ping" command. If the ping succeeds, use the selected - * connection. If not, set the server's type to Unknown and update the - * Topology Description according to the Server Discovery and Monitoring - * Spec, and attempt once more to select a server. - * - * Returns: - * True if the check succeeded or no check was required, false if the - * check failed. - * - * Side effects: - * If a check fails, closes stream and may set server type Unknown. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_cluster_check_interval (mongoc_cluster_t *cluster, uint32_t server_id) -{ - mongoc_cmd_parts_t parts; - mongoc_topology_t *topology; - mongoc_topology_scanner_node_t *scanner_node; - mongoc_stream_t *stream; - int64_t now; - bson_t command; - bson_error_t error; - bool r = true; - mongoc_server_stream_t *server_stream; - mongoc_server_description_t *handshake_sd; - - topology = cluster->client->topology; - - if (!topology->single_threaded) { - return true; - } - - scanner_node = - mongoc_topology_scanner_get_node (topology->scanner, server_id); - - if (!scanner_node) { - return false; - } - - BSON_ASSERT (!scanner_node->retired); - - stream = scanner_node->stream; - - if (!stream) { - return false; - } - - handshake_sd = scanner_node->handshake_sd; - BSON_ASSERT (handshake_sd); - - now = bson_get_monotonic_time (); - - if (scanner_node->last_used + (1000 * CHECK_CLOSED_DURATION_MSEC) < now) { - if (mongoc_stream_check_closed (stream)) { - mc_tpld_modification tdmod; - bson_set_error (&error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "connection closed"); - mongoc_cluster_disconnect_node (cluster, server_id); - tdmod = mc_tpld_modify_begin (topology); - /* invalidate_server() is okay if 'server_id' was already removed. */ - mongoc_topology_description_invalidate_server ( - tdmod.new_td, server_id, &error); - mc_tpld_modify_commit (tdmod); - return false; - } - } - - if (scanner_node->last_used + (1000 * cluster->socketcheckintervalms) < - now) { - mc_shared_tpld td; - - bson_init (&command); - BSON_APPEND_INT32 (&command, "ping", 1); - mongoc_cmd_parts_init ( - &parts, cluster->client, "admin", MONGOC_QUERY_SECONDARY_OK, &command); - parts.prohibit_lsid = true; - - td = mc_tpld_take_ref (cluster->client->topology); - server_stream = - _mongoc_cluster_create_server_stream (td.ptr, handshake_sd, stream); - mc_tpld_drop_ref (&td); - - if (!server_stream) { - bson_destroy (&command); - return false; - } - r = mongoc_cluster_run_command_parts ( - cluster, server_stream, &parts, NULL, &error); - - mongoc_server_stream_cleanup (server_stream); - bson_destroy (&command); - - if (!r) { - mc_tpld_modification tdmod; - mongoc_cluster_disconnect_node (cluster, server_id); - tdmod = mc_tpld_modify_begin (cluster->client->topology); - /* invalidate_server() is okay if 'server_id' was already removed. */ - mongoc_topology_description_invalidate_server ( - tdmod.new_td, server_id, &error); - mc_tpld_modify_commit (tdmod); - } - } - - return r; -} - - -bool -mongoc_cluster_legacy_rpc_sendv_to_server ( - mongoc_cluster_t *cluster, - mcd_rpc_message *rpc, - mongoc_server_stream_t *server_stream, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT_PARAM (rpc); - BSON_ASSERT_PARAM (server_stream); - BSON_ASSERT_PARAM (error); - - ENTRY; - - bool ret = false; - - void *compressed_data = NULL; - size_t compressed_data_len = 0u; - mongoc_iovec_t *iovecs = NULL; - size_t num_iovecs = 0u; - - if (cluster->client->in_exhaust) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_IN_EXHAUST, - "a cursor derived from this client is in exhaust"); - GOTO (done); - } - - const int32_t compressor_id = - mongoc_server_description_compressor_id (server_stream->sd); - - if (compressor_id != -1 && - !mcd_rpc_message_compress ( - rpc, - compressor_id, - _compression_level_from_uri (compressor_id, cluster->uri), - &compressed_data, - &compressed_data_len, - error)) { - GOTO (done); - } - - const uint32_t server_id = server_stream->sd->id; - const int32_t max_msg_size = - mongoc_server_stream_max_msg_size (server_stream); - - const int32_t message_length = mcd_rpc_header_get_message_length (rpc); - - if (message_length > max_msg_size) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_TOO_BIG, - "attempted to send an RPC message with length %" PRId32 - " which exceeds the maximum allowed length %" PRId32, - message_length, - max_msg_size); - GOTO (done); - } - - iovecs = mcd_rpc_message_to_iovecs (rpc, &num_iovecs); - BSON_ASSERT (iovecs); - - mcd_rpc_message_egress (rpc); - if (!_mongoc_stream_writev_full (server_stream->stream, - iovecs, - num_iovecs, - cluster->sockettimeoutms, - error)) { - GOTO (done); - } - - _mongoc_topology_update_last_used (cluster->client->topology, server_id); - - ret = true; - -done: - bson_free (iovecs); - bson_free (compressed_data); - - RETURN (ret); -} - - -bool -mongoc_cluster_try_recv (mongoc_cluster_t *cluster, - mcd_rpc_message *rpc, - mongoc_buffer_t *buffer, - mongoc_server_stream_t *server_stream, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT_PARAM (rpc); - BSON_ASSERT_PARAM (server_stream); - BSON_ASSERT_PARAM (error); - - ENTRY; - - bool ret = false; - - TRACE ("Waiting for reply from server_id \"%u\"", server_stream->sd->id); - - const size_t offset = buffer->len; - - if (!_mongoc_buffer_append_from_stream (buffer, - server_stream->stream, - sizeof (int32_t), - cluster->sockettimeoutms, - error)) { - MONGOC_DEBUG ( - "could not read message length, stream probably closed or timed out"); - mongoc_counter_protocol_ingress_error_inc (); - _handle_network_error (cluster, server_stream, error); - GOTO (done); - } - - const int32_t message_length = _int32_from_le (buffer->data + offset); - - const int32_t max_msg_size = - mongoc_server_stream_max_msg_size (server_stream); - - if (message_length < message_header_length || - message_length > max_msg_size) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "message length %" PRId32 - " is not within valid range of %" PRId32 "-%" PRId32 - " bytes", - message_header_length, - message_length, - server_stream->sd->max_msg_size); - _handle_network_error (cluster, server_stream, error); - mongoc_counter_protocol_ingress_error_inc (); - GOTO (done); - } - - const size_t remaining_bytes = (size_t) message_length - sizeof (int32_t); - - if (!_mongoc_buffer_append_from_stream (buffer, - server_stream->stream, - remaining_bytes, - cluster->sockettimeoutms, - error)) { - _handle_network_error (cluster, server_stream, error); - mongoc_counter_protocol_ingress_error_inc (); - GOTO (done); - } - - if (!mcd_rpc_message_from_data_in_place ( - rpc, buffer->data + offset, (size_t) message_length, NULL)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "failed to decode reply from server"); - _handle_network_error (cluster, server_stream, error); - mongoc_counter_protocol_ingress_error_inc (); - GOTO (done); - } - - mcd_rpc_message_ingress (rpc); - - void *decompressed_data = NULL; - size_t decompressed_data_len = 0u; - - if (!mcd_rpc_message_decompress_if_necessary ( - rpc, &decompressed_data, &decompressed_data_len)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "could not decompress server reply"); - GOTO (done); - } - - if (decompressed_data) { - _mongoc_buffer_destroy (buffer); - _mongoc_buffer_init ( - buffer, decompressed_data, decompressed_data_len, NULL, NULL); - } - - ret = true; - -done: - - return ret; -} - - -static void -network_error_reply (bson_t *reply, mongoc_cmd_t *cmd) -{ - bson_array_builder_t *labels; - - if (reply) { - bson_init (reply); - } - - if (cmd->session) { - if (cmd->session->server_session) { - cmd->session->server_session->dirty = true; - } - /* Transactions Spec defines TransientTransactionError: "Any - * network error or server selection error encountered running any - * command besides commitTransaction in a transaction. In the case - * of command errors, the server adds the label; in the case of - * network errors or server selection errors where the client - * receives no server reply, the client adds the label." */ - if (_mongoc_client_session_in_txn (cmd->session) && !cmd->is_txn_finish) { - /* Transaction Spec: "Drivers MUST unpin a ClientSession when a command - * within a transaction, including commitTransaction and - * abortTransaction, - * fails with a TransientTransactionError". If we're about to add - * a TransientTransactionError label due to a client side error then we - * unpin. If commitTransaction/abortTransation includes a label in the - * server reply, we unpin in _mongoc_client_session_handle_reply. */ - cmd->session->server_id = 0; - if (!reply) { - return; - } - - BSON_APPEND_ARRAY_BUILDER_BEGIN (reply, "errorLabels", &labels); - bson_array_builder_append_utf8 (labels, TRANSIENT_TXN_ERR, -1); - bson_append_array_builder_end (reply, labels); - } - } -} - - -static bool -_mongoc_cluster_run_opmsg_send (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - mcd_rpc_message *rpc, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT_PARAM (cmd); - BSON_ASSERT_PARAM (rpc); - BSON_ASSERT_PARAM (reply); - BSON_ASSERT_PARAM (error); - - mongoc_server_stream_t *const server_stream = cmd->server_stream; - - const uint32_t flags = - (cmd->is_acknowledged ? MONGOC_OP_MSG_FLAG_NONE - : MONGOC_OP_MSG_FLAG_MORE_TO_COME) | - (cmd->op_msg_is_exhaust ? MONGOC_OP_MSG_FLAG_EXHAUST_ALLOWED - : MONGOC_OP_MSG_FLAG_NONE); - - { - int32_t message_length = 0; - - message_length += mcd_rpc_header_set_message_length (rpc, 0); - message_length += - mcd_rpc_header_set_request_id (rpc, ++cluster->request_id); - message_length += mcd_rpc_header_set_response_to (rpc, 0); - message_length += mcd_rpc_header_set_op_code (rpc, MONGOC_OP_CODE_MSG); - - mcd_rpc_op_msg_set_sections_count (rpc, cmd->payload ? 2u : 1u); - - message_length += mcd_rpc_op_msg_set_flag_bits (rpc, flags); - message_length += mcd_rpc_op_msg_section_set_kind (rpc, 0u, 0); - message_length += mcd_rpc_op_msg_section_set_body ( - rpc, 0u, bson_get_data (cmd->command)); - - if (cmd->payload) { - BSON_ASSERT (bson_in_range_signed (size_t, cmd->payload_size)); - - const size_t section_length = sizeof (int32_t) + - strlen (cmd->payload_identifier) + 1u + - (size_t) cmd->payload_size; - BSON_ASSERT (bson_in_range_unsigned (int32_t, section_length)); - - message_length += mcd_rpc_op_msg_section_set_kind (rpc, 1u, 1); - message_length += mcd_rpc_op_msg_section_set_length ( - rpc, 1u, (int32_t) section_length); - message_length += mcd_rpc_op_msg_section_set_identifier ( - rpc, 1u, cmd->payload_identifier); - message_length += mcd_rpc_op_msg_section_set_document_sequence ( - rpc, 1u, cmd->payload, (size_t) cmd->payload_size); - } - - mcd_rpc_message_set_length (rpc, message_length); - } - - void *compressed_data = NULL; - size_t compressed_data_len = 0u; - - if (mongoc_cmd_is_compressible (cmd)) { - const int32_t compressor_id = - mongoc_server_description_compressor_id (server_stream->sd); - - TRACE ( - "Function '%s' is compressible: %d", cmd->command_name, compressor_id); - - if (compressor_id != -1 && - !mcd_rpc_message_compress ( - rpc, - compressor_id, - _compression_level_from_uri (compressor_id, cluster->uri), - &compressed_data, - &compressed_data_len, - error)) { - RUN_CMD_ERR_DECORATE; - _handle_network_error (cluster, server_stream, error); - server_stream->stream = NULL; - network_error_reply (reply, cmd); - return false; - } - } - - size_t num_iovecs = 0u; - mongoc_iovec_t *const iovecs = mcd_rpc_message_to_iovecs (rpc, &num_iovecs); - BSON_ASSERT (iovecs); - - mcd_rpc_message_egress (rpc); - const bool res = _mongoc_stream_writev_full (server_stream->stream, - iovecs, - num_iovecs, - cluster->sockettimeoutms, - error); - - if (!res) { - RUN_CMD_ERR_DECORATE; - _handle_network_error (cluster, server_stream, error); - server_stream->stream = NULL; - network_error_reply (reply, cmd); - } - - bson_free (iovecs); - bson_free (compressed_data); - - return res; -} - -static bool -_mongoc_cluster_run_opmsg_recv (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - mcd_rpc_message *rpc, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT_PARAM (cmd); - BSON_ASSERT_PARAM (rpc); - BSON_ASSERT_PARAM (reply); - BSON_ASSERT_PARAM (error); - - bool ret = false; - - mongoc_server_stream_t *const server_stream = cmd->server_stream; - - mongoc_buffer_t buffer; - _mongoc_buffer_init (&buffer, NULL, 0, NULL, NULL); - - if (!_mongoc_buffer_append_from_stream (&buffer, - server_stream->stream, - sizeof (int32_t), - cluster->sockettimeoutms, - error)) { - MONGOC_DEBUG ( - "could not read message length, stream probably closed or timed out"); - RUN_CMD_ERR_DECORATE; - _handle_network_error (cluster, server_stream, error); - server_stream->stream = NULL; - network_error_reply (reply, cmd); - goto done; - } - - const int32_t message_length = _int32_from_le (buffer.data); - - if (message_length < message_header_length || - message_length > server_stream->sd->max_msg_size) { - RUN_CMD_ERR (MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "message length %" PRId32 - " is not within valid range of %" PRId32 "-%" PRId32 - " bytes", - message_header_length, - message_length, - server_stream->sd->max_msg_size); - _handle_network_error (cluster, server_stream, error); - server_stream->stream = NULL; - network_error_reply (reply, cmd); - goto done; - } - - const size_t remaining_bytes = (size_t) message_length - sizeof (int32_t); - - if (!_mongoc_buffer_append_from_stream (&buffer, - server_stream->stream, - remaining_bytes, - cluster->sockettimeoutms, - error)) { - RUN_CMD_ERR_DECORATE; - _handle_network_error (cluster, server_stream, error); - server_stream->stream = NULL; - network_error_reply (reply, cmd); - goto done; - } - - if (!mcd_rpc_message_from_data_in_place ( - rpc, buffer.data, buffer.len, NULL)) { - RUN_CMD_ERR (MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "malformed server message"); - _handle_network_error (cluster, server_stream, error); - server_stream->stream = NULL; - network_error_reply (reply, cmd); - goto done; - } - mcd_rpc_message_ingress (rpc); - - void *decompressed_data = NULL; - size_t decompressed_data_len = 0u; - - if (!mcd_rpc_message_decompress_if_necessary ( - rpc, &decompressed_data, &decompressed_data_len)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "could not decompress message from server"); - _handle_network_error (cluster, server_stream, error); - server_stream->stream = NULL; - network_error_reply (reply, cmd); - GOTO (done); - } - - if (decompressed_data) { - _mongoc_buffer_destroy (&buffer); - _mongoc_buffer_init ( - &buffer, decompressed_data, decompressed_data_len, NULL, NULL); - } - - bson_t body; - - uint32_t op_msg_flags = mcd_rpc_op_msg_get_flag_bits (rpc); - cluster->client->in_exhaust = op_msg_flags & MONGOC_OP_MSG_FLAG_MORE_TO_COME; - - if (!mcd_rpc_message_get_body (rpc, &body)) { - RUN_CMD_ERR (MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "malformed message from server"); - _handle_network_error (cluster, server_stream, error); - server_stream->stream = NULL; - network_error_reply (reply, cmd); - goto done; - } - - _mongoc_topology_update_cluster_time (cluster->client->topology, &body); - - ret = - _mongoc_cmd_check_ok (&body, cluster->client->error_api_version, error); - - if (cmd->session) { - _mongoc_client_session_handle_reply ( - cmd->session, cmd->is_acknowledged, cmd->command_name, &body); - } - - bson_copy_to (&body, reply); - bson_destroy (&body); - -done: - _mongoc_buffer_destroy (&buffer); - - return ret; -} - -static bool -mongoc_cluster_run_opmsg (mongoc_cluster_t *cluster, - mongoc_cmd_t *cmd, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (cluster); - BSON_ASSERT_PARAM (cmd); - BSON_ASSERT_PARAM (reply); - BSON_ASSERT_PARAM (error); - - if (!cmd->command_name) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "empty command document"); - bson_init (reply); - return false; - } - - if (!cmd->op_msg_is_exhaust && cluster->client->in_exhaust) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_IN_EXHAUST, - "another cursor derived from this client is in exhaust"); - bson_init (reply); - return false; - } - - bool ret = false; - - mcd_rpc_message *const rpc = mcd_rpc_message_new (); - - if (!cluster->client->in_exhaust && - !_mongoc_cluster_run_opmsg_send (cluster, cmd, rpc, reply, error)) { - goto done; - } - - if (!cmd->is_acknowledged) { - // Nothing more to do. - bson_init (reply); - ret = true; - goto done; - } - - mcd_rpc_message_reset (rpc); - - if (!_mongoc_cluster_run_opmsg_recv (cluster, cmd, rpc, reply, error)) { - goto done; - } - - ret = true; - -done: - mcd_rpc_message_destroy (rpc); - - return ret; -} - - -bool -mcd_rpc_message_compress (mcd_rpc_message *rpc, - int32_t compressor_id, - int32_t compression_level, - void **data, - size_t *data_len, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (rpc); - BSON_ASSERT_PARAM (data); - BSON_ASSERT_PARAM (data_len); - - bool ret = false; - - char *uncompressed_message = NULL; - char *compressed_message = NULL; - mongoc_iovec_t *iovecs = NULL; - - const int32_t original_message_length = - mcd_rpc_header_get_message_length (rpc); - - // msgHeader consists of four int32 fields. - const int32_t message_header_length = 4u * sizeof (int32_t); - - // compressedMessage does not include msgHeader fields. - BSON_ASSERT (original_message_length >= message_header_length); - const size_t uncompressed_size = - (size_t) (original_message_length - message_header_length); - BSON_ASSERT (bson_in_range_unsigned (int32_t, uncompressed_size)); - - const size_t estimated_compressed_size = - mongoc_compressor_max_compressed_length (compressor_id, - uncompressed_size); - - if (estimated_compressed_size == 0u) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Could not determine compression bounds for %s", - mongoc_compressor_id_to_name (compressor_id)); - goto fail; - } - - // Store values before they are converted to little endian. - const int32_t request_id = mcd_rpc_header_get_request_id (rpc); - const int32_t response_to = mcd_rpc_header_get_response_to (rpc); - const int32_t op_code = mcd_rpc_header_get_op_code (rpc); - - size_t num_iovecs; - iovecs = mcd_rpc_message_to_iovecs (rpc, &num_iovecs); - BSON_ASSERT (iovecs); - - uncompressed_message = bson_malloc (uncompressed_size); - BSON_ASSERT ( - _mongoc_cluster_buffer_iovec ( - iovecs, num_iovecs, message_header_length, uncompressed_message) == - uncompressed_size); - - compressed_message = bson_malloc (estimated_compressed_size); - - // This value may be passed as an argument to an in-out parameter depending - // on the compressor, not just an out-parameter. - size_t compressed_size = estimated_compressed_size; - - if (!mongoc_compress (compressor_id, - compression_level, - uncompressed_message, - uncompressed_size, - compressed_message, - &compressed_size)) { - MONGOC_WARNING ("Could not compress data with %s", - mongoc_compressor_id_to_name (compressor_id)); - goto fail; - } - - mcd_rpc_message_reset (rpc); - - { - int32_t message_len = 0; - - message_len += mcd_rpc_header_set_message_length (rpc, 0); - message_len += mcd_rpc_header_set_request_id (rpc, request_id); - message_len += mcd_rpc_header_set_response_to (rpc, response_to); - message_len += - mcd_rpc_header_set_op_code (rpc, MONGOC_OP_CODE_COMPRESSED); - message_len += mcd_rpc_op_compressed_set_original_opcode (rpc, op_code); - message_len += mcd_rpc_op_compressed_set_uncompressed_size ( - rpc, (int32_t) uncompressed_size); - message_len += - mcd_rpc_op_compressed_set_compressor_id (rpc, (uint8_t) compressor_id); - message_len += mcd_rpc_op_compressed_set_compressed_message ( - rpc, compressed_message, compressed_size); - - mcd_rpc_message_set_length (rpc, message_len); - } - - *data = compressed_message; - *data_len = compressed_size; - compressed_message = NULL; - - ret = true; - -fail: - bson_free (compressed_message); - bson_free (uncompressed_message); - bson_free (iovecs); - - return ret; -} - -bool -mcd_rpc_message_decompress (mcd_rpc_message *rpc, void **data, size_t *data_len) -{ - BSON_ASSERT_PARAM (rpc); - BSON_ASSERT_PARAM (data); - BSON_ASSERT_PARAM (data_len); - - BSON_ASSERT (mcd_rpc_header_get_op_code (rpc) == MONGOC_OP_CODE_COMPRESSED); - - // msgHeader consists of four int32 fields. - const size_t message_header_length = 4u * sizeof (int32_t); - - const size_t uncompressed_size = - (size_t) mcd_rpc_op_compressed_get_uncompressed_size (rpc); - - // uncompressedSize does not include msgHeader fields. - const size_t original_message_length = - message_header_length + uncompressed_size; - uint8_t *const ptr = bson_malloc (original_message_length); - - const int32_t message_length = original_message_length; - const int32_t request_id = mcd_rpc_header_get_request_id (rpc); - const int32_t response_to = mcd_rpc_header_get_response_to (rpc); - const int32_t op_code = mcd_rpc_op_compressed_get_original_opcode (rpc); - - // Populate the msgHeader fields. - { - uint32_t storage; - - memcpy (&storage, &message_length, sizeof (storage)); - storage = BSON_UINT32_TO_LE (storage); - memcpy (ptr + 0, &storage, sizeof (storage)); - - memcpy (&storage, &request_id, sizeof (storage)); - storage = BSON_UINT32_TO_LE (storage); - memcpy (ptr + 4, &storage, sizeof (storage)); - - memcpy (&storage, &response_to, sizeof (storage)); - storage = BSON_UINT32_TO_LE (storage); - memcpy (ptr + 8, &storage, sizeof (storage)); - - memcpy (&storage, &op_code, sizeof (storage)); - storage = BSON_UINT32_TO_LE (storage); - memcpy (ptr + 12, &storage, sizeof (storage)); - } - - // This value may be passed as an argument to an in-out parameter depending - // on the compressor, not just an out-parameter. - size_t actual_uncompressed_size = uncompressed_size; - - // Populate the rest of the uncompressed message. - if (!mongoc_uncompress ( - mcd_rpc_op_compressed_get_compressor_id (rpc), - mcd_rpc_op_compressed_get_compressed_message (rpc), - mcd_rpc_op_compressed_get_compressed_message_length (rpc), - ptr + message_header_length, - &actual_uncompressed_size)) { - bson_free (ptr); - return false; - } - - BSON_ASSERT (uncompressed_size == actual_uncompressed_size); - - *data_len = original_message_length; - *data = ptr; // Ownership transfer. - - mcd_rpc_message_reset (rpc); - - return mcd_rpc_message_from_data_in_place (rpc, *data, *data_len, NULL); -} - -bool -mcd_rpc_message_decompress_if_necessary (mcd_rpc_message *rpc, - void **data, - size_t *data_len) -{ - BSON_ASSERT_PARAM (rpc); - BSON_ASSERT_PARAM (data); - BSON_ASSERT_PARAM (data_len); - - if (mcd_rpc_header_get_op_code (rpc) != MONGOC_OP_CODE_COMPRESSED) { - // Nothing to do. - *data = NULL; - *data_len = 0u; - return true; - } - - return mcd_rpc_message_decompress (rpc, data, data_len); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cmd-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cmd-private.h deleted file mode 100644 index 602528f56..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cmd-private.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2017 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - - -/* - * Internal struct to represent a command we will send to the server - command - * parameters are collected in a mongoc_cmd_parts_t until we know the server's - * wire version and whether it is mongos, then we collect the parts into a - * mongoc_cmd_t, and gather that into an RPC message. - */ - -#ifndef MONGOC_CMD_PRIVATE_H -#define MONGOC_CMD_PRIVATE_H - -#include - -#include "mongoc-server-api.h" -#include "mongoc-server-stream-private.h" -#include "mongoc-read-prefs.h" -#include "mongoc.h" -#include "mongoc-opts-private.h" - -BSON_BEGIN_DECLS - -#define MONGOC_DEFAULT_RETRYREADS true -/* retryWrites requires sessions, which require crypto */ -#ifdef MONGOC_ENABLE_CRYPTO -#define MONGOC_DEFAULT_RETRYWRITES true -#else -#define MONGOC_DEFAULT_RETRYWRITES false -#endif - -typedef enum { - MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_UNKNOWN, - MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_YES, - MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_NO -} mongoc_cmd_parts_allow_txn_number_t; - -typedef struct _mongoc_cmd_t { - const char *db_name; - mongoc_query_flags_t query_flags; - const bson_t *command; - const char *command_name; - const uint8_t *payload; - int32_t payload_size; - const char *payload_identifier; - mongoc_server_stream_t *server_stream; - int64_t operation_id; - mongoc_client_session_t *session; - mongoc_server_api_t *api; - bool is_acknowledged; - bool is_txn_finish; - bool op_msg_is_exhaust; -} mongoc_cmd_t; - - -typedef struct _mongoc_cmd_parts_t { - mongoc_cmd_t assembled; - mongoc_query_flags_t user_query_flags; - const bson_t *body; - bson_t read_concern_document; - bson_t write_concern_document; - bson_t extra; - const mongoc_read_prefs_t *read_prefs; - bson_t assembled_body; - bool is_read_command; - bool is_write_command; - bool prohibit_lsid; - mongoc_cmd_parts_allow_txn_number_t allow_txn_number; - bool is_retryable_read; - bool is_retryable_write; - bool has_temp_session; - mongoc_client_t *client; - mongoc_server_api_t *api; -} mongoc_cmd_parts_t; - - -void -mongoc_cmd_parts_init (mongoc_cmd_parts_t *op, - mongoc_client_t *client, - const char *db_name, - mongoc_query_flags_t user_query_flags, - const bson_t *command_body); - -void -mongoc_cmd_parts_set_session (mongoc_cmd_parts_t *parts, - mongoc_client_session_t *cs); - -void -mongoc_cmd_parts_set_server_api (mongoc_cmd_parts_t *parts, - mongoc_server_api_t *api); - -bool -mongoc_cmd_parts_append_opts (mongoc_cmd_parts_t *parts, - bson_iter_t *iter, - bson_error_t *error); - -bool -mongoc_cmd_parts_set_read_concern (mongoc_cmd_parts_t *parts, - const mongoc_read_concern_t *rc, - bson_error_t *error); - -bool -mongoc_cmd_parts_set_write_concern (mongoc_cmd_parts_t *parts, - const mongoc_write_concern_t *wc, - bson_error_t *error); - -bool -mongoc_cmd_parts_append_read_write (mongoc_cmd_parts_t *parts, - mongoc_read_write_opts_t *rw_opts, - bson_error_t *error); - -bool -mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts, - mongoc_server_stream_t *server_stream, - bson_error_t *error); - -bool -mongoc_cmd_is_compressible (mongoc_cmd_t *cmd); - -void -mongoc_cmd_parts_cleanup (mongoc_cmd_parts_t *op); - -bool -_is_retryable_read (const mongoc_cmd_parts_t *parts, - const mongoc_server_stream_t *server_stream); - -void -_mongoc_cmd_append_payload_as_array (const mongoc_cmd_t *cmd, bson_t *out); - -void -_mongoc_cmd_append_server_api (bson_t *command_body, - const mongoc_server_api_t *api); - -BSON_END_DECLS - - -#endif /* MONGOC_CMD_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cmd.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cmd.c deleted file mode 100644 index 6ad74c43a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cmd.c +++ /dev/null @@ -1,1140 +0,0 @@ -/* - * Copyright 2017 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-cmd-private.h" -#include "mongoc-read-prefs-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-client-private.h" -#include "mongoc-read-concern-private.h" -#include "mongoc-server-api-private.h" -#include "mongoc-write-concern-private.h" -/* For strcasecmp on Windows */ -#include "mongoc-util-private.h" - - -void -mongoc_cmd_parts_init (mongoc_cmd_parts_t *parts, - mongoc_client_t *client, - const char *db_name, - mongoc_query_flags_t user_query_flags, - const bson_t *command_body) -{ - BSON_ASSERT_PARAM (client); - - parts->body = command_body; - parts->user_query_flags = user_query_flags; - parts->read_prefs = NULL; - parts->is_read_command = false; - parts->is_write_command = false; - parts->prohibit_lsid = false; - parts->allow_txn_number = MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_UNKNOWN; - parts->is_retryable_read = false; - parts->is_retryable_write = false; - parts->has_temp_session = false; - parts->client = client; - bson_init (&parts->read_concern_document); - bson_init (&parts->write_concern_document); - bson_init (&parts->extra); - bson_init (&parts->assembled_body); - - parts->assembled.db_name = db_name; - parts->assembled.command = NULL; - parts->assembled.query_flags = MONGOC_QUERY_NONE; - parts->assembled.op_msg_is_exhaust = false; - parts->assembled.payload_identifier = NULL; - parts->assembled.payload = NULL; - parts->assembled.session = NULL; - parts->assembled.is_acknowledged = true; - parts->assembled.is_txn_finish = false; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cmd_parts_set_session -- - * - * Set the client session field. - * - * Side effects: - * Aborts if the command is assembled or if mongoc_cmd_parts_append_opts - * was called before. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_cmd_parts_set_session (mongoc_cmd_parts_t *parts, - mongoc_client_session_t *cs) -{ - BSON_ASSERT (parts); - BSON_ASSERT (!parts->assembled.command); - BSON_ASSERT (!parts->assembled.session); - - parts->assembled.session = cs; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cmd_parts_append_opts -- - * - * Take an iterator over user-supplied options document and append the - * options to @parts->command_extra, taking the selected server's max - * wire version into account. - * - * Return: - * True if the options were successfully applied. If any options are - * invalid, returns false and fills out @error. In that case @parts is - * invalid and must not be used. - * - * Side effects: - * May partly apply options before returning an error. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_cmd_parts_append_opts (mongoc_cmd_parts_t *parts, - bson_iter_t *iter, - bson_error_t *error) -{ - mongoc_client_session_t *cs = NULL; - mongoc_write_concern_t *wc; - uint32_t len; - const uint8_t *data; - bson_t read_concern; - const char *to_append; - - ENTRY; - - /* not yet assembled */ - BSON_ASSERT (!parts->assembled.command); - - while (bson_iter_next (iter)) { - if (BSON_ITER_IS_KEY (iter, "writeConcern")) { - wc = _mongoc_write_concern_new_from_iter (iter, error); - if (!wc) { - RETURN (false); - } - - if (!mongoc_cmd_parts_set_write_concern (parts, wc, error)) { - mongoc_write_concern_destroy (wc); - RETURN (false); - } - - mongoc_write_concern_destroy (wc); - continue; - } else if (BSON_ITER_IS_KEY (iter, "readConcern")) { - if (!BSON_ITER_HOLDS_DOCUMENT (iter)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "Invalid readConcern"); - RETURN (false); - } - - /* add readConcern later, once we know about causal consistency */ - bson_iter_document (iter, &len, &data); - BSON_ASSERT (bson_init_static (&read_concern, data, (size_t) len)); - bson_destroy (&parts->read_concern_document); - bson_copy_to (&read_concern, &parts->read_concern_document); - continue; - } else if (BSON_ITER_IS_KEY (iter, "sessionId")) { - BSON_ASSERT (!parts->assembled.session); - - if (!_mongoc_client_session_from_iter ( - parts->client, iter, &cs, error)) { - RETURN (false); - } - - parts->assembled.session = cs; - continue; - } else if (BSON_ITER_IS_KEY (iter, "serverId") || - BSON_ITER_IS_KEY (iter, "maxAwaitTimeMS") || - BSON_ITER_IS_KEY (iter, "exhaust")) { - continue; - } - - to_append = bson_iter_key (iter); - if (!bson_append_iter (&parts->extra, to_append, -1, iter)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Failed to append \"%s\" to create command.", - to_append); - RETURN (false); - } - } - - RETURN (true); -} - - -#define OPTS_ERR(_code, ...) \ - do { \ - bson_set_error ( \ - error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_##_code, __VA_ARGS__); \ - RETURN (false); \ - } while (0) - - -/* set readConcern if allowed, otherwise error */ -bool -mongoc_cmd_parts_set_read_concern (mongoc_cmd_parts_t *parts, - const mongoc_read_concern_t *rc, - bson_error_t *error) -{ - const char *command_name; - - ENTRY; - - /* In a txn, set read concern in mongoc_cmd_parts_assemble, not here. * - * Transactions Spec: "The readConcern MUST NOT be inherited from the - * collection, database, or client associated with the driver method that - * invokes the first command." */ - if (_mongoc_client_session_in_txn (parts->assembled.session)) { - RETURN (true); - } - - command_name = _mongoc_get_command_name (parts->body); - - if (!command_name) { - OPTS_ERR (COMMAND_INVALID_ARG, "Empty command document"); - } - - if (mongoc_read_concern_is_default (rc)) { - RETURN (true); - } - - bson_destroy (&parts->read_concern_document); - bson_copy_to (_mongoc_read_concern_get_bson ((mongoc_read_concern_t *) rc), - &parts->read_concern_document); - - RETURN (true); -} - - -/* set writeConcern if allowed, otherwise ignore - unlike set_read_concern, it's - * the caller's responsibility to check if writeConcern is supported */ -bool -mongoc_cmd_parts_set_write_concern (mongoc_cmd_parts_t *parts, - const mongoc_write_concern_t *wc, - bson_error_t *error) -{ - ENTRY; - - if (!wc) { - RETURN (true); - } - - const char *const command_name = _mongoc_get_command_name (parts->body); - - if (!command_name) { - OPTS_ERR (COMMAND_INVALID_ARG, "Empty command document"); - } - - parts->assembled.is_acknowledged = mongoc_write_concern_is_acknowledged (wc); - bson_destroy (&parts->write_concern_document); - bson_copy_to (_mongoc_write_concern_get_bson ((mongoc_write_concern_t *) wc), - &parts->write_concern_document); - - RETURN (true); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cmd_parts_append_read_write -- - * - * Append user-supplied options to @parts->command_extra, taking the - * selected server's max wire version into account. - * - * Return: - * True if the options were successfully applied. If any options are - * invalid, returns false and fills out @error. In that case @parts is - * invalid and must not be used. - * - * Side effects: - * May partly apply options before returning an error. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_cmd_parts_append_read_write (mongoc_cmd_parts_t *parts, - mongoc_read_write_opts_t *rw_opts, - bson_error_t *error) -{ - ENTRY; - - /* not yet assembled */ - BSON_ASSERT (!parts->assembled.command); - - if (!bson_empty (&rw_opts->collation)) { - if (!bson_append_document ( - &parts->extra, "collation", 9, &rw_opts->collation)) { - OPTS_ERR (COMMAND_INVALID_ARG, "'opts' with 'collation' is too large"); - } - } - - if (!mongoc_cmd_parts_set_write_concern ( - parts, rw_opts->writeConcern, error)) { - RETURN (false); - } - - /* process explicit read concern */ - if (!bson_empty (&rw_opts->readConcern)) { - /* save readConcern for later, once we know about causal consistency */ - bson_destroy (&parts->read_concern_document); - bson_copy_to (&rw_opts->readConcern, &parts->read_concern_document); - } - - if (rw_opts->client_session) { - BSON_ASSERT (!parts->assembled.session); - parts->assembled.session = rw_opts->client_session; - } - - if (!bson_concat (&parts->extra, &rw_opts->extra)) { - OPTS_ERR (COMMAND_INVALID_ARG, "'opts' with extra fields is too large"); - } - - RETURN (true); -} - -#undef OPTS_ERR - -static void -_mongoc_cmd_parts_ensure_copied (mongoc_cmd_parts_t *parts) -{ - if (parts->assembled.command == parts->body) { - bson_concat (&parts->assembled_body, parts->body); - bson_concat (&parts->assembled_body, &parts->extra); - parts->assembled.command = &parts->assembled_body; - } -} - - -static void -_mongoc_cmd_parts_add_write_concern (mongoc_cmd_parts_t *parts) -{ - if (!bson_empty (&parts->write_concern_document)) { - _mongoc_cmd_parts_ensure_copied (parts); - bson_append_document (&parts->assembled_body, - "writeConcern", - 12, - &parts->write_concern_document); - } -} - - -/* The server type must be mongos, or message must be OP_MSG. */ -static void -_mongoc_cmd_parts_add_read_prefs (bson_t *query, - const mongoc_read_prefs_t *prefs) -{ - bson_t child; - const char *mode_str; - const bson_t *tags; - int64_t stale; - const bson_t *hedge; - - mode_str = _mongoc_read_mode_as_str (mongoc_read_prefs_get_mode (prefs)); - tags = mongoc_read_prefs_get_tags (prefs); - stale = mongoc_read_prefs_get_max_staleness_seconds (prefs); - hedge = mongoc_read_prefs_get_hedge (prefs); - - bson_append_document_begin (query, "$readPreference", 15, &child); - bson_append_utf8 (&child, "mode", 4, mode_str, -1); - if (!bson_empty0 (tags)) { - bson_append_array (&child, "tags", 4, tags); - } - - if (stale != MONGOC_NO_MAX_STALENESS) { - bson_append_int64 (&child, "maxStalenessSeconds", 19, stale); - } - - if (!bson_empty0 (hedge)) { - bson_append_document (&child, "hedge", 5, hedge); - } - - bson_append_document_end (query, &child); -} - - -static void -_iter_concat (bson_t *dst, bson_iter_t *iter) -{ - uint32_t len; - const uint8_t *data; - bson_t src; - - bson_iter_document (iter, &len, &data); - BSON_ASSERT (bson_init_static (&src, data, len)); - BSON_ASSERT (bson_concat (dst, &src)); -} - - -/* Update result with the read prefs. Server must be mongos. - */ -static void -_mongoc_cmd_parts_assemble_mongos (mongoc_cmd_parts_t *parts, - const mongoc_server_stream_t *server_stream) -{ - mongoc_read_mode_t mode; - const bson_t *tags = NULL; - int64_t max_staleness_seconds = MONGOC_NO_MAX_STALENESS; - const bson_t *hedge = NULL; - bool add_read_prefs = false; - bson_t query; - bson_iter_t dollar_query; - bool has_dollar_query = false; - bool requires_read_concern; - bool requires_write_concern; - - ENTRY; - - mode = mongoc_read_prefs_get_mode (parts->read_prefs); - if (parts->read_prefs) { - max_staleness_seconds = - mongoc_read_prefs_get_max_staleness_seconds (parts->read_prefs); - - tags = mongoc_read_prefs_get_tags (parts->read_prefs); - hedge = mongoc_read_prefs_get_hedge (parts->read_prefs); - } - - if (server_stream->must_use_primary) { - /* Server selection has overriden the read mode used to generate this - * server stream. This has effects on the body of the message that we send - * to the server */ - mode = MONGOC_READ_PRIMARY; - } - - /* Server Selection Spec says: - * - * For mode 'primary', drivers MUST NOT set the secondaryOk wire protocol - * flag and MUST NOT use $readPreference - * - * For mode 'secondary', drivers MUST set the secondaryOk wire protocol flag - * and MUST also use $readPreference - * - * For mode 'primaryPreferred', drivers MUST set the secondaryOk wire - * protocol flag and MUST also use $readPreference - * - * For mode 'secondaryPreferred', drivers MUST set the secondaryOk wire - * protocol flag. If the read preference contains a non-empty tag_sets - * parameter, maxStalenessSeconds is a positive integer, or the hedge - * parameter is non-empty, drivers MUST use $readPreference; otherwise, - * drivers MUST NOT use $readPreference - * - * For mode 'nearest', drivers MUST set the secondaryOk wire protocol flag - * and MUST also use $readPreference - */ - switch (mode) { - case MONGOC_READ_PRIMARY: - break; - case MONGOC_READ_SECONDARY_PREFERRED: - if (!bson_empty0 (tags) || max_staleness_seconds > 0 || - !bson_empty0 (hedge)) { - add_read_prefs = true; - } - parts->assembled.query_flags |= MONGOC_QUERY_SECONDARY_OK; - break; - case MONGOC_READ_PRIMARY_PREFERRED: - case MONGOC_READ_SECONDARY: - case MONGOC_READ_NEAREST: - default: - parts->assembled.query_flags |= MONGOC_QUERY_SECONDARY_OK; - add_read_prefs = true; - } - - requires_read_concern = - !bson_empty (&parts->read_concern_document) && - strcmp (parts->assembled.command_name, "getMore") != 0; - - requires_write_concern = !bson_empty (&parts->write_concern_document); - - if (add_read_prefs) { - /* produce {$query: {user query, readConcern}, $readPreference: ... } */ - bson_append_document_begin (&parts->assembled_body, "$query", 6, &query); - - if (bson_iter_init_find (&dollar_query, parts->body, "$query")) { - /* user provided something like {$query: {key: "x"}} */ - has_dollar_query = true; - _iter_concat (&query, &dollar_query); - } else { - bson_concat (&query, parts->body); - } - - bson_concat (&query, &parts->extra); - if (requires_read_concern) { - bson_append_document ( - &query, "readConcern", 11, &parts->read_concern_document); - } - - if (requires_write_concern) { - bson_append_document ( - &query, "writeConcern", 12, &parts->write_concern_document); - } - - bson_append_document_end (&parts->assembled_body, &query); - _mongoc_cmd_parts_add_read_prefs (&parts->assembled_body, - parts->read_prefs); - - if (has_dollar_query) { - /* copy anything that isn't in user's $query */ - bson_copy_to_excluding_noinit ( - parts->body, &parts->assembled_body, "$query", NULL); - } - - parts->assembled.command = &parts->assembled_body; - } else if (bson_iter_init_find (&dollar_query, parts->body, "$query")) { - /* user provided $query, we have no read prefs */ - bson_append_document_begin (&parts->assembled_body, "$query", 6, &query); - _iter_concat (&query, &dollar_query); - bson_concat (&query, &parts->extra); - if (requires_read_concern) { - bson_append_document ( - &query, "readConcern", 11, &parts->read_concern_document); - } - - if (requires_write_concern) { - bson_append_document ( - &query, "writeConcern", 12, &parts->write_concern_document); - } - - bson_append_document_end (&parts->assembled_body, &query); - /* copy anything that isn't in user's $query */ - bson_copy_to_excluding_noinit ( - parts->body, &parts->assembled_body, "$query", NULL); - - parts->assembled.command = &parts->assembled_body; - } else { - if (requires_read_concern) { - _mongoc_cmd_parts_ensure_copied (parts); - bson_append_document (&parts->assembled_body, - "readConcern", - 11, - &parts->read_concern_document); - } - - _mongoc_cmd_parts_add_write_concern (parts); - } - - if (!bson_empty (&parts->extra)) { - /* if none of the above logic has merged "extra", do it now */ - _mongoc_cmd_parts_ensure_copied (parts); - } - - EXIT; -} - - -static void -_mongoc_cmd_parts_assemble_mongod (mongoc_cmd_parts_t *parts, - const mongoc_server_stream_t *server_stream) -{ - ENTRY; - - if (!parts->is_write_command) { - switch (server_stream->topology_type) { - case MONGOC_TOPOLOGY_SINGLE: - /* Server Selection Spec: for topology type single and server types - * besides mongos, "clients MUST always set the secondaryOk wire - * protocol flag on reads to ensure that any server type can handle - * the request." - */ - parts->assembled.query_flags |= MONGOC_QUERY_SECONDARY_OK; - break; - - case MONGOC_TOPOLOGY_RS_NO_PRIMARY: - case MONGOC_TOPOLOGY_RS_WITH_PRIMARY: - /* Server Selection Spec: for RS topology types, "For all read - * preferences modes except primary, clients MUST set the secondaryOk - * wire protocol flag to ensure that any suitable server can handle the - * request. Clients MUST NOT set the secondaryOk wire protocol flag if - * the read preference mode is primary. - */ - if (parts->read_prefs && - parts->read_prefs->mode != MONGOC_READ_PRIMARY) { - parts->assembled.query_flags |= MONGOC_QUERY_SECONDARY_OK; - } - - break; - case MONGOC_TOPOLOGY_SHARDED: - case MONGOC_TOPOLOGY_UNKNOWN: - case MONGOC_TOPOLOGY_LOAD_BALANCED: - case MONGOC_TOPOLOGY_DESCRIPTION_TYPES: - default: - /* must not call this function w/ sharded, load balanced, or unknown - * topology type */ - BSON_ASSERT (false); - } - } /* if (!parts->is_write_command) */ - - if (!bson_empty (&parts->extra)) { - _mongoc_cmd_parts_ensure_copied (parts); - } - - if (!bson_empty (&parts->read_concern_document) && - strcmp (parts->assembled.command_name, "getMore") != 0) { - _mongoc_cmd_parts_ensure_copied (parts); - bson_append_document (&parts->assembled_body, - "readConcern", - 11, - &parts->read_concern_document); - } - - _mongoc_cmd_parts_add_write_concern (parts); - - EXIT; -} - - -static const bson_t * -_largest_cluster_time (const bson_t *a, const bson_t *b) -{ - if (!a) { - return b; - } - - if (!b) { - return a; - } - - if (_mongoc_cluster_time_greater (a, b)) { - return a; - } - - return b; -} - - -/* Check if the command should allow a transaction number if that has not - * already been determined. - * - * This should only return true for write commands that are always retryable for - * the server stream's wire version. - * - * The basic write commands (i.e. insert, update, delete) are intentionally - * excluded here. While insert is always retryable, update and delete are only - * retryable if they include no multi-document writes. Since it would be costly - * to inspect the command document here, the bulk operation API explicitly sets - * allow_txn_number for us. This means that insert, update, and delete are not - * retryable if executed via mongoc_client_write_command_with_opts(); however, - * documentation already instructs users not to use that for basic writes. - */ -static bool -_allow_txn_number (const mongoc_cmd_parts_t *parts, - const mongoc_server_stream_t *server_stream) -{ - /* There is no reason to call this function if allow_txn_number is set */ - BSON_ASSERT (parts->allow_txn_number == - MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_UNKNOWN); - - if (!parts->is_write_command) { - return false; - } - - if (server_stream->retry_attempted) { - return false; - } - - if (!parts->assembled.is_acknowledged) { - return false; - } - - if (!strcasecmp (parts->assembled.command_name, "findandmodify")) { - return true; - } - - return false; -} - - -/* Check if the write command should support retryable behavior. */ -static bool -_is_retryable_write (const mongoc_cmd_parts_t *parts, - const mongoc_server_stream_t *server_stream) -{ - if (!parts->assembled.session) { - return false; - } - - if (!parts->is_write_command) { - return false; - } - - if (parts->allow_txn_number != MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_YES) { - return false; - } - - if (server_stream->retry_attempted) { - return false; - } - - if (server_stream->sd->type == MONGOC_SERVER_STANDALONE) { - return false; - } - - if (_mongoc_client_session_in_txn (parts->assembled.session)) { - return false; - } - - if (!mongoc_uri_get_option_as_bool (parts->client->uri, - MONGOC_URI_RETRYWRITES, - MONGOC_DEFAULT_RETRYWRITES)) { - return false; - } - - return true; -} - - -/* Check if the read command should support retryable behavior. */ -bool -_is_retryable_read (const mongoc_cmd_parts_t *parts, - const mongoc_server_stream_t *server_stream) -{ - if (!parts->is_read_command) { - return false; - } - - /* Commands that go through read_write_command helpers are also write - * commands. Prohibit from read retry. */ - if (parts->is_write_command) { - return false; - } - - if (server_stream->retry_attempted) { - return false; - } - - if (_mongoc_client_session_in_txn (parts->assembled.session)) { - return false; - } - - if (!mongoc_uri_get_option_as_bool (parts->client->uri, - MONGOC_URI_RETRYREADS, - MONGOC_DEFAULT_RETRYREADS)) { - return false; - } - - return true; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cmd_parts_assemble -- - * - * Assemble the command body, options, and read preference into one - * command. - * - * Return: - * True if the options were successfully applied. If any options are - * invalid, returns false and fills out @error. In that case @parts is - * invalid and must not be used. - * - * Side effects: - * May partly assemble before returning an error. - * mongoc_cmd_parts_cleanup should be called in all cases. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts, - mongoc_server_stream_t *server_stream, - bson_error_t *error) -{ - mongoc_server_description_type_t server_type; - mongoc_client_session_t *cs; - const bson_t *cluster_time = NULL; - mongoc_read_prefs_t *prefs = NULL; - const char *cmd_name; - bool is_get_more; - const mongoc_read_prefs_t *prefs_ptr; - mongoc_read_mode_t mode; - bool ret = false; - - ENTRY; - - BSON_ASSERT (parts); - BSON_ASSERT (server_stream); - - server_type = server_stream->sd->type; - - cs = parts->prohibit_lsid ? NULL : parts->assembled.session; - - /* Assembling the command depends on the type of server. If the server has - * been invalidated, error. */ - if (server_type == MONGOC_SERVER_UNKNOWN) { - if (error) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot assemble command for invalidated server: %s", - server_stream->sd->error.message); - } - RETURN (false); - } - - /* must not be assembled already */ - BSON_ASSERT (!parts->assembled.command); - BSON_ASSERT (bson_empty (&parts->assembled_body)); - - /* begin with raw flags/cmd as assembled flags/cmd, might change below */ - parts->assembled.command = parts->body; - /* unused in OP_MSG: */ - parts->assembled.query_flags = parts->user_query_flags; - parts->assembled.server_stream = server_stream; - cmd_name = parts->assembled.command_name = - _mongoc_get_command_name (parts->assembled.command); - - if (!parts->assembled.command_name) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Empty command document"); - GOTO (done); - } - - TRACE ("Preparing '%s'", cmd_name); - - is_get_more = !strcmp (cmd_name, "getMore"); - parts->assembled.is_txn_finish = !strcmp (cmd_name, "commitTransaction") || - !strcmp (cmd_name, "abortTransaction"); - - if (!parts->is_write_command && IS_PREF_PRIMARY (parts->read_prefs) && - server_stream->topology_type == MONGOC_TOPOLOGY_SINGLE && - server_type != MONGOC_SERVER_MONGOS) { - prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY_PREFERRED); - prefs_ptr = prefs; - } else { - prefs_ptr = parts->read_prefs; - } - - mode = mongoc_read_prefs_get_mode (prefs_ptr); - if (server_stream->must_use_primary) { - /* Server selection may have overriden the read mode used to generate this - * server stream. This has effects on the body of the message that we send - * to the server */ - mode = MONGOC_READ_PRIMARY; - } - - if (mongoc_client_uses_server_api (parts->client) || - mongoc_client_uses_loadbalanced (parts->client) || - server_stream->sd->max_wire_version >= WIRE_VERSION_MIN) { - if (!bson_has_field (parts->body, "$db")) { - BSON_APPEND_UTF8 (&parts->extra, "$db", parts->assembled.db_name); - } - - if (cs && _mongoc_client_session_in_txn (cs)) { - if (!IS_PREF_PRIMARY (cs->txn.opts.read_prefs) && - !parts->is_write_command) { - bson_set_error (error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Read preference in a transaction must be primary"); - GOTO (done); - } - } else if (mode != MONGOC_READ_PRIMARY && - server_type != MONGOC_SERVER_STANDALONE) { - /* "Type Standalone: clients MUST NOT send the read preference to the - * server" */ - _mongoc_cmd_parts_add_read_prefs (&parts->extra, prefs_ptr); - } - - if (!bson_empty (&parts->extra)) { - _mongoc_cmd_parts_ensure_copied (parts); - } - - /* If an explicit session was not provided and lsid is not prohibited, - * attempt to create an implicit session (ignoring any errors). */ - if (!cs && !parts->prohibit_lsid && parts->assembled.is_acknowledged) { - cs = mongoc_client_start_session (parts->client, NULL, NULL); - - if (cs) { - parts->assembled.session = cs; - parts->has_temp_session = true; - } - } - - /* Driver Sessions Spec: "For unacknowledged writes with an explicit - * session, drivers SHOULD raise an error.... Without an explicit - * session, drivers SHOULD NOT use an implicit session." We intentionally - * do not restrict this logic to parts->is_write_command, since - * mongoc_client_command_with_opts() does not identify as a write - * command but may still include a write concern. - */ - if (cs) { - if (!parts->assembled.is_acknowledged) { - bson_set_error ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot use client session with unacknowledged command"); - GOTO (done); - } - - _mongoc_cmd_parts_ensure_copied (parts); - bson_append_document (&parts->assembled_body, - "lsid", - 4, - mongoc_client_session_get_lsid (cs)); - - cs->server_session->last_used_usec = bson_get_monotonic_time (); - cluster_time = mongoc_client_session_get_cluster_time (cs); - } - - /* Ensure we know if the write command allows a transaction number */ - if (!_mongoc_client_session_txn_in_progress (cs) && - parts->is_write_command && - parts->allow_txn_number == - MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_UNKNOWN) { - parts->allow_txn_number = _allow_txn_number (parts, server_stream) - ? MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_YES - : MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_NO; - } - - /* Determine if the command is retryable. If so, append txnNumber now - * for future use and mark the command as such. */ - if (_is_retryable_write (parts, server_stream)) { - _mongoc_cmd_parts_ensure_copied (parts); - bson_append_int64 (&parts->assembled_body, "txnNumber", 9, 0); - parts->is_retryable_write = true; - } - - /* Conversely, check if the command is retryable if it is a read. */ - if (_is_retryable_read (parts, server_stream) && !is_get_more) { - parts->is_retryable_read = true; - } - - if (!bson_empty (&server_stream->cluster_time)) { - cluster_time = - _largest_cluster_time (&server_stream->cluster_time, cluster_time); - } - - if (cluster_time && server_type != MONGOC_SERVER_STANDALONE) { - _mongoc_cmd_parts_ensure_copied (parts); - bson_append_document ( - &parts->assembled_body, "$clusterTime", 12, cluster_time); - } - - /* Add versioned server api, if it is set. */ - if (mongoc_client_uses_server_api (parts->client)) { - _mongoc_cmd_append_server_api (&parts->assembled_body, - parts->client->api); - } - - if (!is_get_more) { - if (cs) { - /* Snapshot Sessions Spec: "Snapshot reads require MongoDB 5.0+." - * Throw an error if snapshot is enabled and wire version is less - * than 13 before potentially appending "snapshot" read concern. */ - if (mongoc_session_opts_get_snapshot (&cs->opts) && - server_stream->sd->max_wire_version < - WIRE_VERSION_SNAPSHOT_READS) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_SESSION_FAILURE, - "Snapshot reads require MongoDB 5.0 or later"); - GOTO (done); - } - - _mongoc_cmd_parts_ensure_copied (parts); - _mongoc_client_session_append_read_concern ( - cs, - &parts->read_concern_document, - parts->is_read_command, - &parts->assembled_body); - } else if (!bson_empty (&parts->read_concern_document)) { - _mongoc_cmd_parts_ensure_copied (parts); - bson_append_document (&parts->assembled_body, - "readConcern", - 11, - &parts->read_concern_document); - } - } - - /* if transaction is in progress do not inherit write concern */ - if (parts->assembled.is_txn_finish || - !_mongoc_client_session_in_txn (cs)) { - _mongoc_cmd_parts_add_write_concern (parts); - } - - _mongoc_cmd_parts_ensure_copied (parts); - if (!_mongoc_client_session_append_txn ( - cs, &parts->assembled_body, error)) { - GOTO (done); - } - - ret = true; - } else if (server_type == MONGOC_SERVER_MONGOS || - server_stream->topology_type == MONGOC_TOPOLOGY_LOAD_BALANCED) { - /* TODO (CDRIVER-4117) remove the check of the topology description type. - */ - _mongoc_cmd_parts_assemble_mongos (parts, server_stream); - ret = true; - } else { - _mongoc_cmd_parts_assemble_mongod (parts, server_stream); - ret = true; - } - -done: - mongoc_read_prefs_destroy (prefs); - RETURN (ret); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cmd_parts_cleanup -- - * - * Free memory associated with a stack-allocated mongoc_cmd_parts_t. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_cmd_parts_cleanup (mongoc_cmd_parts_t *parts) -{ - bson_destroy (&parts->read_concern_document); - bson_destroy (&parts->write_concern_document); - bson_destroy (&parts->extra); - bson_destroy (&parts->assembled_body); - - if (parts->has_temp_session) { - /* client session returns its server session to server session pool */ - mongoc_client_session_destroy (parts->assembled.session); - } -} - -bool -mongoc_cmd_is_compressible (mongoc_cmd_t *cmd) -{ - BSON_ASSERT (cmd); - BSON_ASSERT (cmd->command_name); - - return !!strcasecmp (cmd->command_name, "hello") && - !!strcasecmp (cmd->command_name, HANDSHAKE_CMD_LEGACY_HELLO) && - !!strcasecmp (cmd->command_name, "authenticate") && - !!strcasecmp (cmd->command_name, "getnonce") && - !!strcasecmp (cmd->command_name, "saslstart") && - !!strcasecmp (cmd->command_name, "saslcontinue") && - !!strcasecmp (cmd->command_name, "createuser") && - !!strcasecmp (cmd->command_name, "updateuser"); -} - -/*-------------------------------------------------------------------------- - * - * _mongoc_cmd_append_payload_as_array -- - * Append a write command payload as an array in a BSON document. - * Used by APM and Client-Side Encryption - * - * Arguments: - * cmd The mongoc_cmd_t, which may contain a payload to be appended. - * out A bson_t, which will be appended to if @cmd->payload is set. - * - * Pre-conditions: - * - @out is initialized. - * - cmd has a payload (i.e. is a write command). - * - * Post-conditions: - * - If @cmd->payload is set, then @out is appended to with the payload - * field's name ("documents" if insert, "updates" if update, - * "deletes" if delete) an the payload as a BSON array. - * - *-------------------------------------------------------------------------- - */ -void -_mongoc_cmd_append_payload_as_array (const mongoc_cmd_t *cmd, bson_t *out) -{ - int32_t doc_len; - bson_t doc; - const uint8_t *pos; - const char *field_name; - bson_array_builder_t *bson; - - BSON_ASSERT (cmd->payload && cmd->payload_size); - - /* make array from outgoing OP_MSG payload type 1 on an "insert", - * "update", or "delete" command. */ - field_name = _mongoc_get_documents_field_name (cmd->command_name); - BSON_ASSERT (field_name); - BSON_ASSERT (BSON_APPEND_ARRAY_BUILDER_BEGIN (out, field_name, &bson)); - - pos = cmd->payload; - while (pos < cmd->payload + cmd->payload_size) { - memcpy (&doc_len, pos, sizeof (doc_len)); - doc_len = BSON_UINT32_FROM_LE (doc_len); - BSON_ASSERT (bson_init_static (&doc, pos, (size_t) doc_len)); - bson_array_builder_append_document (bson, &doc); - - pos += doc_len; - } - - bson_append_array_builder_end (out, bson); -} - -/*-------------------------------------------------------------------------- - * - * _mongoc_cmd_append_server_api -- - * Append versioned API fields to a mongoc_cmd_t - * - * Arguments: - * cmd The mongoc_cmd_t, which will have versioned API fields added - * api A mongoc_server_api_t holding server API information - * - * Pre-conditions: - * - @api is initialized. - * - @command_body is initialised - * - *-------------------------------------------------------------------------- - */ -void -_mongoc_cmd_append_server_api (bson_t *command_body, - const mongoc_server_api_t *api) -{ - const char *string_version; - - BSON_ASSERT (command_body); - BSON_ASSERT (api); - - string_version = mongoc_server_api_version_to_string (api->version); - - BSON_ASSERT (string_version); - - bson_append_utf8 (command_body, "apiVersion", -1, string_version, -1); - - if (api->strict.is_set) { - bson_append_bool (command_body, "apiStrict", -1, api->strict.value); - } - - if (api->deprecation_errors.is_set) { - bson_append_bool (command_body, - "apiDeprecationErrors", - -1, - api->deprecation_errors.value); - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-collection.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-collection.c deleted file mode 100644 index 5dc87be4e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-collection.c +++ /dev/null @@ -1,3875 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "mongoc-aggregate-private.h" -#include "mongoc-bulk-operation.h" -#include "mongoc-bulk-operation-private.h" -#include "mongoc-change-stream-private.h" -#include "mongoc-client-private.h" -#include "mongoc-find-and-modify-private.h" -#include "mongoc-find-and-modify.h" -#include "mongoc-collection.h" -#include "mongoc-collection-private.h" -#include "mongoc-cursor-private.h" -#include "mongoc-error.h" -#include "mongoc-index.h" -#include "mongoc-log.h" -#include "mongoc-trace-private.h" -#include "mongoc-read-concern-private.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-read-prefs-private.h" -#include "mongoc-util-private.h" -#include "mongoc-write-command-private.h" -#include "mongoc-opts-private.h" -#include "mongoc-write-command-private.h" -#include "mongoc-error-private.h" -#include "mongoc-database-private.h" - -#include - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "collection" - -static void -_mongoc_collection_write_command_execute ( - mongoc_write_command_t *command, - const mongoc_collection_t *collection, - const mongoc_write_concern_t *write_concern, - mongoc_client_session_t *cs, - mongoc_write_result_t *result) -{ - mongoc_server_stream_t *server_stream; - - ENTRY; - - server_stream = mongoc_cluster_stream_for_writes ( - &collection->client->cluster, cs, NULL, NULL, &result->error); - - if (!server_stream) { - /* result->error has been filled out */ - EXIT; - } - - _mongoc_write_command_execute (command, - collection->client, - server_stream, - collection->db, - collection->collection, - write_concern, - 0 /* offset */, - cs, - result); - - mongoc_server_stream_cleanup (server_stream); - - EXIT; -} - - -static void -_mongoc_collection_write_command_execute_idl ( - mongoc_write_command_t *command, - const mongoc_collection_t *collection, - mongoc_crud_opts_t *crud, - mongoc_write_result_t *result) -{ - mongoc_server_stream_t *server_stream; - bson_t reply; - - ENTRY; - - server_stream = - mongoc_cluster_stream_for_writes (&collection->client->cluster, - crud->client_session, - NULL, - &reply, - &result->error); - - if (!server_stream) { - /* result->error and reply have been filled out */ - _mongoc_bson_array_copy_labels_to (&reply, &result->errorLabels); - bson_destroy (&reply); - EXIT; - } - - if (_mongoc_client_session_in_txn (crud->client_session) && - crud->writeConcern) { - bson_set_error (&result->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot set write concern after starting transaction"); - mongoc_server_stream_cleanup (server_stream); - EXIT; - } - - if (!crud->writeConcern && - !_mongoc_client_session_in_txn (crud->client_session)) { - crud->writeConcern = collection->write_concern; - crud->write_concern_owned = false; - } - - _mongoc_write_command_execute_idl (command, - collection->client, - server_stream, - collection->db, - collection->collection, - 0 /* offset */, - crud, - result); - - mongoc_server_stream_cleanup (server_stream); - - EXIT; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_collection_new -- - * - * INTERNAL API - * - * Create a new mongoc_collection_t structure for the given client. - * - * @client must remain valid during the lifetime of this structure. - * @db is the db name of the collection. - * @collection is the name of the collection. - * @read_prefs is the default read preferences to apply or NULL. - * @read_concern is the default read concern to apply or NULL. - * @write_concern is the default write concern to apply or NULL. - * - * Returns: - * A newly allocated mongoc_collection_t that should be freed with - * mongoc_collection_destroy(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_collection_t * -_mongoc_collection_new (mongoc_client_t *client, - const char *db, - const char *collection, - const mongoc_read_prefs_t *read_prefs, - const mongoc_read_concern_t *read_concern, - const mongoc_write_concern_t *write_concern) -{ - mongoc_collection_t *col; - - ENTRY; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT_PARAM (db); - BSON_ASSERT_PARAM (collection); - - col = (mongoc_collection_t *) bson_malloc0 (sizeof *col); - col->client = client; - col->write_concern = write_concern - ? mongoc_write_concern_copy (write_concern) - : mongoc_write_concern_new (); - col->read_concern = read_concern ? mongoc_read_concern_copy (read_concern) - : mongoc_read_concern_new (); - col->read_prefs = read_prefs ? mongoc_read_prefs_copy (read_prefs) - : mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - col->ns = bson_strdup_printf ("%s.%s", db, collection); - col->db = bson_strdup (db); - col->collection = bson_strdup (collection); - - col->collectionlen = (uint32_t) strlen (col->collection); - col->nslen = (uint32_t) strlen (col->ns); - - col->gle = NULL; - - RETURN (col); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_destroy -- - * - * Release resources associated with @collection and frees the - * structure. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_collection_destroy (mongoc_collection_t *collection) /* IN */ -{ - ENTRY; - - if (!collection) { - EXIT; - } - - bson_clear (&collection->gle); - - if (collection->read_prefs) { - mongoc_read_prefs_destroy (collection->read_prefs); - collection->read_prefs = NULL; - } - - if (collection->read_concern) { - mongoc_read_concern_destroy (collection->read_concern); - collection->read_concern = NULL; - } - - if (collection->write_concern) { - mongoc_write_concern_destroy (collection->write_concern); - collection->write_concern = NULL; - } - - bson_free (collection->collection); - bson_free (collection->db); - bson_free (collection->ns); - bson_free (collection); - - EXIT; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_copy -- - * - * Returns a copy of @collection that needs to be freed by calling - * mongoc_collection_destroy. - * - * Returns: - * A copy of this collection. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_collection_t * -mongoc_collection_copy (mongoc_collection_t *collection) /* IN */ -{ - ENTRY; - - BSON_ASSERT_PARAM (collection); - - RETURN (_mongoc_collection_new (collection->client, - collection->db, - collection->collection, - collection->read_prefs, - collection->read_concern, - collection->write_concern)); -} - - -mongoc_cursor_t * -mongoc_collection_aggregate (mongoc_collection_t *collection, /* IN */ - mongoc_query_flags_t flags, /* IN */ - const bson_t *pipeline, /* IN */ - const bson_t *opts, /* IN */ - const mongoc_read_prefs_t *read_prefs) /* IN */ -{ - return _mongoc_aggregate (collection->client, - collection->ns, - flags, - pipeline, - opts, - read_prefs, - collection->read_prefs, - collection->read_concern, - collection->write_concern); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_find -- - * - * DEPRECATED: use mongoc_collection_find_with_opts. - * - * Performs a query against the configured MongoDB server. If @read_prefs - * is provided, it will be used to locate a MongoDB node in the cluster - * to deliver the query to. - * - * @flags may be bitwise-or'd flags or MONGOC_QUERY_NONE. - * - * @skip may contain the number of documents to skip before returning the - * matching document. - * - * @limit may contain the maximum number of documents that may be - * returned. - * - * This function will always return a cursor, with the exception of - * invalid API use. - * - * Parameters: - * @collection: A mongoc_collection_t. - * @flags: A bitwise or of mongoc_query_flags_t. - * @skip: The number of documents to skip. - * @limit: The maximum number of items. - * @batch_size: The batch size - * @query: The query to locate matching documents. - * @fields: The fields to return, or NULL for all fields. - * @read_prefs: Read preferences to choose cluster node. - * - * Returns: - * A newly allocated mongoc_cursor_t that should be freed with - * mongoc_cursor_destroy(). - * - * The client used by mongoc_collection_t must be valid for the - * lifetime of the resulting mongoc_cursor_t. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_cursor_t * -mongoc_collection_find (mongoc_collection_t *collection, /* IN */ - mongoc_query_flags_t flags, /* IN */ - uint32_t skip, /* IN */ - uint32_t limit, /* IN */ - uint32_t batch_size, /* IN */ - const bson_t *query, /* IN */ - const bson_t *fields, /* IN */ - const mongoc_read_prefs_t *read_prefs) /* IN */ -{ - bool has_unwrapped; - bson_t unwrapped; - bson_error_t error = {0}; - bson_t opts; - bool secondary_ok; - mongoc_cursor_t *cursor; - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (query); - - bson_clear (&collection->gle); - - bson_init (&opts); - _mongoc_cursor_flags_to_opts (flags, &opts, &secondary_ok); - /* check if the query is wrapped in $query */ - has_unwrapped = _mongoc_cursor_translate_dollar_query_opts ( - query, &opts, &unwrapped, &error); - if (!bson_empty0 (fields)) { - bson_append_document ( - &opts, MONGOC_CURSOR_PROJECTION, MONGOC_CURSOR_PROJECTION_LEN, fields); - } - cursor = _mongoc_cursor_find_new (collection->client, - collection->ns, - has_unwrapped ? &unwrapped : query, - &opts, - read_prefs, - collection->read_prefs, - collection->read_concern); - if (skip) { - _mongoc_cursor_set_opt_int64 (cursor, MONGOC_CURSOR_SKIP, skip); - } - if (limit) { - /* limit must be cast to int32_t. Although the argument is a uint32_t, - * callers can specify a negative limit by casting to a signed int32_t - * value to uint32_t. E.g. to set a limit of -4, the caller passes - * UINT32_MAX - 3 */ - (void) mongoc_cursor_set_limit (cursor, (int32_t) limit); - } - if (batch_size) { - mongoc_cursor_set_batch_size (cursor, batch_size); - } - bson_destroy (&unwrapped); - bson_destroy (&opts); - - if (error.domain) { - memcpy (&cursor->error, &error, sizeof (error)); - } - - return cursor; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_find_with_opts -- - * - * Create a cursor with a query filter. All other options are - * specified in a free-form BSON document. - * - * Parameters: - * @collection: A mongoc_collection_t. - * @filter: The query to locate matching documents. - * @opts: Other options. - * @read_prefs: Optional read preferences to choose cluster node. - * - * Returns: - * A newly allocated mongoc_cursor_t that should be freed with - * mongoc_cursor_destroy(). - * - * The client used by mongoc_collection_t must be valid for the - * lifetime of the resulting mongoc_cursor_t. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_cursor_t * -mongoc_collection_find_with_opts (mongoc_collection_t *collection, - const bson_t *filter, - const bson_t *opts, - const mongoc_read_prefs_t *read_prefs) -{ - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (filter); - - bson_clear (&collection->gle); - - return _mongoc_cursor_find_new (collection->client, - collection->ns, - filter, - opts, - read_prefs, - collection->read_prefs, - collection->read_concern); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_command -- - * - * Executes a command on a cluster node matching @read_prefs. If - * @read_prefs is not provided, it will be run on the primary node. - * - * This function will always return a mongoc_cursor_t. - * - * Parameters: - * @collection: A mongoc_collection_t. - * @flags: Bitwise-or'd flags for command. - * @skip: Number of documents to skip, typically 0. - * @limit : Number of documents to return - * @batch_size : Batch size - * @query: The command to execute. - * @fields: The fields to return, or NULL. - * @read_prefs: Command read preferences or NULL. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_cursor_t * -mongoc_collection_command (mongoc_collection_t *collection, - mongoc_query_flags_t flags, - uint32_t skip, - uint32_t limit, - uint32_t batch_size, - const bson_t *query, - const bson_t *fields, - const mongoc_read_prefs_t *read_prefs) -{ - char *ns; - mongoc_cursor_t *cursor; - - BSON_UNUSED (flags); - BSON_UNUSED (skip); - BSON_UNUSED (limit); - BSON_UNUSED (batch_size); - BSON_UNUSED (fields); - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (query); - - if (!read_prefs) { - read_prefs = collection->read_prefs; - } - - bson_clear (&collection->gle); - - if (NULL == strstr (collection->collection, "$cmd")) { - ns = bson_strdup_printf ("%s.$cmd", collection->db); - } else { - ns = bson_strdup (collection->db); - } - - /* Server Selection Spec: "The generic command method has a default read - * preference of mode 'primary'. The generic command method MUST ignore any - * default read preference from client, database or collection - * configuration. The generic command method SHOULD allow an optional read - * preference argument." - */ - - /* flags, skip, limit, batch_size, fields are unused */ - cursor = _mongoc_cursor_cmd_deprecated_new ( - collection->client, ns, query, read_prefs); - bson_free (ns); - return cursor; -} - - -bool -mongoc_collection_read_command_with_opts (mongoc_collection_t *collection, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (collection); - - return _mongoc_client_command_with_opts (collection->client, - collection->db, - command, - MONGOC_CMD_READ, - opts, - MONGOC_QUERY_NONE, - read_prefs, - collection->read_prefs, - collection->read_concern, - collection->write_concern, - reply, - error); -} - - -bool -mongoc_collection_write_command_with_opts (mongoc_collection_t *collection, - const bson_t *command, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (collection); - - return _mongoc_client_command_with_opts (collection->client, - collection->db, - command, - MONGOC_CMD_WRITE, - opts, - MONGOC_QUERY_NONE, - NULL, - collection->read_prefs, - collection->read_concern, - collection->write_concern, - reply, - error); -} - - -bool -mongoc_collection_read_write_command_with_opts ( - mongoc_collection_t *collection, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs /* IGNORED */, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (collection); - - return _mongoc_client_command_with_opts (collection->client, - collection->db, - command, - MONGOC_CMD_RW, - opts, - MONGOC_QUERY_NONE, - read_prefs, - collection->read_prefs, - collection->read_concern, - collection->write_concern, - reply, - error); -} - - -bool -mongoc_collection_command_with_opts (mongoc_collection_t *collection, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (collection); - - /* Server Selection Spec: "The generic command method has a default read - * preference of mode 'primary'. The generic command method MUST ignore any - * default read preference from client, database or collection - * configuration. The generic command method SHOULD allow an optional read - * preference argument." */ - - return _mongoc_client_command_with_opts (collection->client, - collection->db, - command, - MONGOC_CMD_RAW, - opts, - MONGOC_QUERY_NONE, - read_prefs, - NULL /* default prefs */, - collection->read_concern, - collection->write_concern, - reply, - error); -} - - -bool -mongoc_collection_command_simple (mongoc_collection_t *collection, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (command); - - bson_clear (&collection->gle); - - /* Server Selection Spec: "The generic command method has a default read - * preference of mode 'primary'. The generic command method MUST ignore any - * default read preference from client, database or collection - * configuration. The generic command method SHOULD allow an optional read - * preference argument." - */ - - return _mongoc_client_command_with_opts (collection->client, - collection->db, - command, - MONGOC_CMD_RAW, - NULL /* opts */, - MONGOC_QUERY_NONE, - read_prefs, - NULL /* default prefs */, - NULL /* read concern */, - NULL /* write concern */, - reply, - error); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_count -- - * - * Count the number of documents matching @query. - * - * Parameters: - * @flags: A mongoc_query_flags_t describing the query flags or 0. - * @query: The query to perform or NULL for {}. - * @skip: The $skip to perform within the query or 0. - * @limit: The $limit to perform within the query or 0. - * @read_prefs: desired read preferences or NULL. - * @error: A location for an error or NULL. - * - * Returns: - * -1 on failure; otherwise the number of matching documents. - * - * Side effects: - * @error is set upon failure if non-NULL. - * - *-------------------------------------------------------------------------- - */ - -int64_t -mongoc_collection_count (mongoc_collection_t *collection, /* IN */ - mongoc_query_flags_t flags, /* IN */ - const bson_t *query, /* IN */ - int64_t skip, /* IN */ - int64_t limit, /* IN */ - const mongoc_read_prefs_t *read_prefs, /* IN */ - bson_error_t *error) /* OUT */ -{ - int64_t ret; - bson_t opts = BSON_INITIALIZER; - - /* Complex types must be parts of `opts`, otherwise we can't - * follow various specs that require validation etc */ - if (collection->read_concern->level != NULL) { - const bson_t *read_concern_bson; - - read_concern_bson = - _mongoc_read_concern_get_bson (collection->read_concern); - BSON_APPEND_DOCUMENT (&opts, "readConcern", read_concern_bson); - } - - /* Server Selection Spec: "may-use-secondary" commands SHOULD take a read - * preference argument and otherwise MUST use the default read preference - * from client, database or collection configuration. */ - BEGIN_IGNORE_DEPRECATIONS - ret = mongoc_collection_count_with_opts ( - collection, flags, query, skip, limit, &opts, read_prefs, error); - END_IGNORE_DEPRECATIONS - - bson_destroy (&opts); - return ret; -} - - -int64_t -mongoc_collection_count_with_opts ( - mongoc_collection_t *collection, /* IN */ - mongoc_query_flags_t flags, /* IN */ - const bson_t *query, /* IN */ - int64_t skip, /* IN */ - int64_t limit, /* IN */ - const bson_t *opts, /* IN */ - const mongoc_read_prefs_t *read_prefs, /* IN */ - bson_error_t *error) /* OUT */ -{ - bson_iter_t iter; - int64_t ret = -1; - bool success; - bson_t reply; - bson_t cmd = BSON_INITIALIZER; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - - bsonBuildAppend ( - cmd, - kv ("count", - utf8_w_len (collection->collection, collection->collectionlen)), - kv ("query", - if (query, // If we have a query, - then (bson (*query)), // Copy it - else (doc ()))), // Otherwise, add an empty doc - if (limit, then (kv ("limit", int64 (limit)))), - if (skip, then (kv ("skip", int64 (skip))))); - - - success = _mongoc_client_command_with_opts (collection->client, - collection->db, - &cmd, - MONGOC_CMD_READ, - opts, - flags, - read_prefs, - collection->read_prefs, - collection->read_concern, - collection->write_concern, - &reply, - error); - - if (success) { - if (bson_iter_init_find (&iter, &reply, "n")) { - ret = bson_iter_as_int64 (&iter); - } - } - - bson_destroy (&reply); - bson_destroy (&cmd); - - RETURN (ret); -} - -int64_t -mongoc_collection_estimated_document_count ( - mongoc_collection_t *coll, - const bson_t *opts, - const mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error) -{ - bson_iter_t iter; - int64_t count = -1; - bool ret; - bson_t reply_local; - bson_t *reply_ptr; - bson_t cmd = BSON_INITIALIZER; - mongoc_server_stream_t *server_stream = NULL; - - ENTRY; - - BSON_ASSERT_PARAM (coll); - - server_stream = mongoc_cluster_stream_for_reads ( - &coll->client->cluster, read_prefs, NULL, NULL, reply, error); - - if (opts && bson_has_field (opts, "sessionId")) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Collection count must not specify explicit session"); - GOTO (done); - } - - reply_ptr = reply ? reply : &reply_local; - - BSON_APPEND_UTF8 (&cmd, "count", coll->collection); - ret = _mongoc_client_command_with_opts (coll->client, - coll->db, - &cmd, - MONGOC_CMD_READ, - opts, - MONGOC_QUERY_NONE, - read_prefs, - coll->read_prefs, - coll->read_concern, - coll->write_concern, - reply_ptr, - error); - if (ret) { - if (bson_iter_init_find (&iter, reply_ptr, "n")) { - count = bson_iter_as_int64 (&iter); - } - } - -done: - if (!reply) { - bson_destroy (&reply_local); - } - bson_destroy (&cmd); - mongoc_server_stream_cleanup (server_stream); - - RETURN (count); -} - - -/* -------------------------------------------------------------------------- - * - * _make_aggregate_for_count -- - * - * Construct an aggregate pipeline with the following form: - * { pipeline: [ - * { $match: {...} }, - * { $group: { _id: 1, n: { sum: 1 } } }, - * { $skip: ... }, - * { $limit: ... } - * ] - * } - * - *-------------------------------------------------------------------------- - */ -static void -_make_aggregate_for_count (const mongoc_collection_t *coll, - const bson_t *filter, - mongoc_count_document_opts_t *opts, - bson_t *out) -{ - bson_array_builder_t *pipeline; - bson_t match_stage; - bson_t group_stage; - bson_t group_stage_doc; - bson_t sum; - bson_t empty; - - bson_init (out); - bson_append_utf8 ( - out, "aggregate", 9, coll->collection, coll->collectionlen); - bson_append_document_begin (out, "cursor", 6, &empty); - bson_append_document_end (out, &empty); - bson_append_array_builder_begin (out, "pipeline", 8, &pipeline); - - bson_array_builder_append_document_begin (pipeline, &match_stage); - bson_append_document (&match_stage, "$match", 6, filter); - bson_array_builder_append_document_end (pipeline, &match_stage); - /* if @opts includes "skip", or "limit", append $skip and $limit stages to - * the aggregate pipeline. */ - if (opts->skip.value_type != BSON_TYPE_EOD) { - bson_t skip_stage; - bson_array_builder_append_document_begin (pipeline, &skip_stage); - bson_append_value (&skip_stage, "$skip", 5, &opts->skip); - bson_array_builder_append_document_end (pipeline, &skip_stage); - } - if (opts->limit.value_type != BSON_TYPE_EOD) { - bson_t limit_stage; - bson_array_builder_append_document_begin (pipeline, &limit_stage); - bson_append_value (&limit_stage, "$limit", 6, &opts->limit); - bson_array_builder_append_document_end (pipeline, &limit_stage); - } - bson_array_builder_append_document_begin (pipeline, &group_stage); - bson_append_document_begin (&group_stage, "$group", 6, &group_stage_doc); - bson_append_int32 (&group_stage_doc, "_id", 3, 1); - bson_append_document_begin (&group_stage_doc, "n", 1, &sum); - bson_append_int32 (&sum, "$sum", 4, 1); - bson_append_document_end (&group_stage_doc, &sum); - bson_append_document_end (&group_stage, &group_stage_doc); - bson_array_builder_append_document_end (pipeline, &group_stage); - bson_append_array_builder_end (out, pipeline); -} - - -int64_t -mongoc_collection_count_documents (mongoc_collection_t *coll, - const bson_t *filter, - const bson_t *opts, - const mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error) -{ - bson_t aggregate_cmd; - bson_t aggregate_opts; - bool ret; - const bson_t *result; - mongoc_cursor_t *cursor = NULL; - int64_t count = -1; - bson_t cmd_reply; - bson_iter_t iter; - - ENTRY; - - BSON_ASSERT_PARAM (coll); - BSON_ASSERT_PARAM (filter); - - // Parse options to validate. - mongoc_count_document_opts_t cd_opts; - if (!_mongoc_count_document_opts_parse ( - coll->client, opts, &cd_opts, error)) { - GOTO (done); - } - - _make_aggregate_for_count (coll, filter, &cd_opts, &aggregate_cmd); - bson_init (&aggregate_opts); - if (opts) { - bsonBuildAppend (aggregate_opts, - insert (*opts, not(key ("skip", "limit")))); - } - - ret = mongoc_collection_read_command_with_opts ( - coll, &aggregate_cmd, read_prefs, &aggregate_opts, &cmd_reply, error); - bson_destroy (&aggregate_cmd); - bson_destroy (&aggregate_opts); - if (reply) { - bson_copy_to (&cmd_reply, reply); - } - - if (!ret) { - bson_destroy (&cmd_reply); - GOTO (done); - } - - /* steals reply */ - cursor = mongoc_cursor_new_from_command_reply_with_opts ( - coll->client, &cmd_reply, NULL); - BSON_ASSERT (mongoc_cursor_get_id (cursor) == 0); - ret = mongoc_cursor_next (cursor, &result); - if (!ret) { - if (mongoc_cursor_error (cursor, error)) { - GOTO (done); - } else { - count = 0; - GOTO (done); - } - } - - if (bson_iter_init_find (&iter, result, "n") && - BSON_ITER_HOLDS_INT (&iter)) { - count = bson_iter_as_int64 (&iter); - } - -done: - _mongoc_count_document_opts_cleanup (&cd_opts); - if (cursor) { - mongoc_cursor_destroy (cursor); - } - RETURN (count); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_drop -- - * - * Request the MongoDB server drop the collection. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * @error is set upon failure. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_drop (mongoc_collection_t *collection, /* IN */ - bson_error_t *error) /* OUT */ -{ - return mongoc_collection_drop_with_opts (collection, NULL, error); -} - - -static bool -drop_with_opts (mongoc_collection_t *collection, - const bson_t *opts, - bson_error_t *error) -{ - bool ret; - bson_t cmd; - - BSON_ASSERT_PARAM (collection); - - bson_init (&cmd); - bson_append_utf8 ( - &cmd, "drop", 4, collection->collection, collection->collectionlen); - - ret = _mongoc_client_command_with_opts (collection->client, - collection->db, - &cmd, - MONGOC_CMD_WRITE, - opts, - MONGOC_QUERY_NONE, - NULL, /* user prefs */ - collection->read_prefs, - collection->read_concern, - collection->write_concern, - NULL, /* reply */ - error); - bson_destroy (&cmd); - - return ret; -} - -static bool -drop_with_opts_with_encryptedFields (mongoc_collection_t *collection, - const bson_t *opts, - const bson_t *encryptedFields, - bson_error_t *error) -{ - char *escName = NULL; - char *ecocName = NULL; - mongoc_collection_t *escCollection = NULL; - mongoc_collection_t *ecocCollection = NULL; - bool ok = false; - const char *name = mongoc_collection_get_name (collection); - bson_error_t local_error = {0}; - - if (!error) { - /* If no error is passed, use a local error. Error codes are checked - * when collections are dropped. */ - error = &local_error; - } - - /* Drop ESC collection. */ - escName = _mongoc_get_encryptedField_state_collection ( - encryptedFields, name, "esc", error); - if (!escName) { - goto fail; - } - - escCollection = mongoc_client_get_collection ( - collection->client, collection->db, escName); - if (!drop_with_opts (escCollection, NULL /* opts */, error)) { - if (error->code == MONGOC_SERVER_ERR_NS_NOT_FOUND) { - memset (error, 0, sizeof (bson_error_t)); - } else { - goto fail; - } - } - - /* Drop ECOC collection. */ - ecocName = _mongoc_get_encryptedField_state_collection ( - encryptedFields, name, "ecoc", error); - if (!ecocName) { - goto fail; - } - - ecocCollection = mongoc_client_get_collection ( - collection->client, collection->db, ecocName); - if (!drop_with_opts (ecocCollection, NULL /* opts */, error)) { - if (error->code == MONGOC_SERVER_ERR_NS_NOT_FOUND) { - memset (error, 0, sizeof (bson_error_t)); - } else { - goto fail; - } - } - - /* Drop data collection. */ - if (!drop_with_opts (collection, opts, error)) { - if (error->code == MONGOC_SERVER_ERR_NS_NOT_FOUND) { - memset (error, 0, sizeof (bson_error_t)); - } else { - goto fail; - } - } - - ok = true; -fail: - mongoc_collection_destroy (ecocCollection); - bson_free (ecocName); - mongoc_collection_destroy (escCollection); - bson_free (escName); - return ok; -} - -bool -mongoc_collection_drop_with_opts (mongoc_collection_t *collection, - const bson_t *opts, - bson_error_t *error) -{ - // The encryptedFields for the collection. - bson_t encryptedFields = BSON_INITIALIZER; - bson_t opts_without_encryptedFields = BSON_INITIALIZER; - bool okay = false; - - // Try to find the encryptedFields from the collection options or from the - // encryptedFieldsMap. - if (!_mongoc_get_collection_encryptedFields ( - collection->client, - collection->db, - mongoc_collection_get_name (collection), - opts, - true /* checkEncryptedFieldsMap */, - &encryptedFields, - error)) { - goto done; - } - - if (bson_empty (&encryptedFields)) { - // We didn't find the encryptedFields (yet) - if (collection->client->topology->encrypted_fields_map != NULL) { - // but we can ask the server for them: - if (!_mongoc_get_encryptedFields_from_server ( - collection->client, - collection->db, - mongoc_collection_get_name (collection), - &encryptedFields, - error)) { - goto done; - } - } - } - - if (bson_empty (&encryptedFields)) { - // There are no encryptedFields with this collection, so we can just do a - // regular drop - okay = drop_with_opts (collection, opts, error); - goto done; - } - - // We've found the encryptedFields, so we need to do something different - // to drop this collection: - bsonBuildAppend ( - opts_without_encryptedFields, - if (opts, then (insert (*opts, not(key ("encryptedFields")))))); - if (bsonBuildError) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Error while updating drop options: %s", - bsonBuildError); - goto done; - } - - okay = drop_with_opts_with_encryptedFields ( - collection, &opts_without_encryptedFields, &encryptedFields, error); - -done: - bson_destroy (&opts_without_encryptedFields); - bson_destroy (&encryptedFields); - return okay; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_drop_index -- - * - * Request the MongoDB server drop the named index. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * @error is setup upon failure if non-NULL. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_drop_index (mongoc_collection_t *collection, /* IN */ - const char *index_name, /* IN */ - bson_error_t *error) /* OUT */ -{ - return mongoc_collection_drop_index_with_opts ( - collection, index_name, NULL, error); -} - - -bool -mongoc_collection_drop_index_with_opts (mongoc_collection_t *collection, - const char *index_name, - const bson_t *opts, - bson_error_t *error) -{ - bool ret; - bson_t cmd; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (index_name); - - bson_init (&cmd); - bson_append_utf8 (&cmd, - "dropIndexes", - -1, - collection->collection, - collection->collectionlen); - bson_append_utf8 (&cmd, "index", -1, index_name, -1); - - ret = _mongoc_client_command_with_opts (collection->client, - collection->db, - &cmd, - MONGOC_CMD_WRITE, - opts, - MONGOC_QUERY_NONE, - NULL, /* user prefs */ - collection->read_prefs, - collection->read_concern, - collection->write_concern, - NULL, /* reply */ - error); - bson_destroy (&cmd); - - return ret; -} - - -char * -mongoc_collection_keys_to_index_string (const bson_t *keys) -{ - bson_string_t *s; - bson_iter_t iter; - bson_type_t type; - int i = 0; - - BSON_ASSERT_PARAM (keys); - - if (!bson_iter_init (&iter, keys)) { - return NULL; - } - - s = bson_string_new (NULL); - - while (bson_iter_next (&iter)) { - /* Index type can be specified as a string ("2d") or as an integer - * representing direction */ - type = bson_iter_type (&iter); - if (type == BSON_TYPE_UTF8) { - bson_string_append_printf (s, - (i++ ? "_%s_%s" : "%s_%s"), - bson_iter_key (&iter), - bson_iter_utf8 (&iter, NULL)); - } else if (type == BSON_TYPE_INT32) { - bson_string_append_printf (s, - (i++ ? "_%s_%d" : "%s_%d"), - bson_iter_key (&iter), - bson_iter_int32 (&iter)); - } else if (type == BSON_TYPE_INT64) { - bson_string_append_printf (s, - (i++ ? "_%s_%" PRId64 : "%s_%" PRId64), - bson_iter_key (&iter), - bson_iter_int64 (&iter)); - } else { - bson_string_free (s, true); - return NULL; - } - } - return bson_string_free (s, false); -} - - -bool -mongoc_collection_create_index (mongoc_collection_t *collection, - const bson_t *keys, - const mongoc_index_opt_t *opt, - bson_error_t *error) -{ - bson_t reply; - bool ret; - - BEGIN_IGNORE_DEPRECATIONS - - ret = mongoc_collection_create_index_with_opts ( - collection, keys, opt, NULL, &reply, error); - - END_IGNORE_DEPRECATIONS - - bson_destroy (&reply); - return ret; -} - -static bool -_mongoc_collection_index_keys_equal (const bson_t *expected, - const bson_t *actual) -{ - bson_iter_t iter_expected; - bson_iter_t iter_actual; - - bson_iter_init (&iter_expected, expected); - bson_iter_init (&iter_actual, actual); - - while (bson_iter_next (&iter_expected)) { - /* If the key document has fewer items than expected, indexes are unequal - */ - if (!bson_iter_next (&iter_actual)) { - return false; - } - - /* If key order does not match, indexes are unequal */ - if (strcmp (bson_iter_key (&iter_expected), - bson_iter_key (&iter_actual)) != 0) { - return false; - } - - if (BSON_ITER_HOLDS_NUMBER (&iter_expected) && - BSON_ITER_HOLDS_NUMBER (&iter_actual)) { - if (bson_iter_as_int64 (&iter_expected) != - bson_iter_as_int64 (&iter_actual)) { - return false; - } - } else if (BSON_ITER_HOLDS_UTF8 (&iter_expected) && - BSON_ITER_HOLDS_UTF8 (&iter_actual)) { - if (strcmp (bson_iter_utf8 (&iter_expected, NULL), - bson_iter_utf8 (&iter_actual, NULL)) != 0) { - return false; - } - } else { - return false; - } - } - - /* If our expected document is exhausted, make sure there are no extra keys - * in the actual key document */ - if (bson_iter_next (&iter_actual)) { - return false; - } - - return true; -} - -bool -_mongoc_collection_create_index_if_not_exists (mongoc_collection_t *collection, - const bson_t *keys, - const bson_t *opts, - bson_error_t *error) -{ - mongoc_cursor_t *cursor; - bool index_exists; - bool r = false; - const bson_t *doc; - bson_iter_t iter; - bson_t inner_doc; - uint32_t data_len; - const uint8_t *data; - bson_t index; - bson_t command; - - BSON_ASSERT (collection); - BSON_ASSERT (keys); - - cursor = mongoc_collection_find_indexes_with_opts (collection, NULL); - - index_exists = false; - - while (mongoc_cursor_next (cursor, &doc) && !index_exists) { - r = bson_iter_init_find (&iter, doc, "key"); - if (!r) { - continue; - } - - bson_iter_document (&iter, &data_len, &data); - BSON_ASSERT (bson_init_static (&inner_doc, data, data_len)); - - if (_mongoc_collection_index_keys_equal (keys, &inner_doc)) { - index_exists = true; - } - - bson_destroy (&inner_doc); - } - - if (mongoc_cursor_error (cursor, error)) { - mongoc_cursor_destroy (cursor); - return false; - } - - mongoc_cursor_destroy (cursor); - - if (index_exists) { - return true; - } - - if (opts) { - bson_copy_to (opts, &index); - } else { - bson_init (&index); - } - - BSON_APPEND_DOCUMENT (&index, "key", keys); - - if (!bson_has_field (&index, "name")) { - char *alloc_name = mongoc_collection_keys_to_index_string (keys); - - if (!alloc_name) { - bson_set_error ( - error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Cannot generate index name from invalid `keys` argument"); - GOTO (done); - } - - BSON_APPEND_UTF8 (&index, "name", alloc_name); - - bson_free (alloc_name); - } - - bson_init (&command); - BCON_APPEND (&command, - "createIndexes", - BCON_UTF8 (mongoc_collection_get_name (collection)), - "indexes", - "[", - BCON_DOCUMENT (&index), - "]"); - - r = mongoc_collection_write_command_with_opts ( - collection, &command, NULL, NULL, error); - -done: - bson_destroy (&index); - bson_destroy (&command); - - return r; -} - -bool -mongoc_collection_create_index_with_opts (mongoc_collection_t *collection, - const bson_t *keys, - const mongoc_index_opt_t *opt, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - mongoc_create_index_opts_t parsed; - mongoc_cmd_parts_t parts; - const mongoc_index_opt_t *def_opt; - const mongoc_index_opt_geo_t *def_geo; - const char *name; - bson_t cmd = BSON_INITIALIZER; - bson_array_builder_t *ar; - bson_t doc; - bson_t storage_doc; - bson_t wt_doc; - const mongoc_index_opt_geo_t *geo_opt; - const mongoc_index_opt_storage_t *storage_opt; - const mongoc_index_opt_wt_t *wt_opt; - char *alloc_name = NULL; - bool ret = false; - bool reply_initialized = false; - mongoc_server_stream_t *server_stream = NULL; - mongoc_cluster_t *cluster; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (keys); - - def_opt = mongoc_index_opt_get_default (); - opt = opt ? opt : def_opt; - - mongoc_cmd_parts_init ( - &parts, collection->client, collection->db, MONGOC_QUERY_NONE, &cmd); - parts.is_write_command = true; - - if (!_mongoc_create_index_opts_parse ( - collection->client, opts, &parsed, error)) { - GOTO (done); - } - - if (!parsed.writeConcern) { - parsed.writeConcern = collection->write_concern; - parsed.write_concern_owned = false; - } - - /* - * Generate the key name if it was not provided. - */ - name = (opt->name != def_opt->name) ? opt->name : NULL; - if (!name) { - alloc_name = mongoc_collection_keys_to_index_string (keys); - if (alloc_name) { - name = alloc_name; - } else { - bson_set_error ( - error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Cannot generate index name from invalid `keys` argument"); - GOTO (done); - } - } - - /* - * Build our createIndexes command to send to the server. - */ - BSON_ASSERT ( - BSON_APPEND_UTF8 (&cmd, "createIndexes", collection->collection)); - bson_append_array_builder_begin (&cmd, "indexes", 7, &ar); - bson_array_builder_append_document_begin (ar, &doc); - BSON_ASSERT (BSON_APPEND_DOCUMENT (&doc, "key", keys)); - BSON_ASSERT (BSON_APPEND_UTF8 (&doc, "name", name)); - if (opt->background) { - BSON_ASSERT (BSON_APPEND_BOOL (&doc, "background", true)); - } - if (opt->unique) { - BSON_ASSERT (BSON_APPEND_BOOL (&doc, "unique", true)); - } - if (opt->drop_dups) { - BSON_ASSERT (BSON_APPEND_BOOL (&doc, "dropDups", true)); - } - if (opt->sparse) { - BSON_ASSERT (BSON_APPEND_BOOL (&doc, "sparse", true)); - } - if (opt->expire_after_seconds != def_opt->expire_after_seconds) { - BSON_ASSERT (BSON_APPEND_INT32 ( - &doc, "expireAfterSeconds", opt->expire_after_seconds)); - } - if (opt->v != def_opt->v) { - BSON_ASSERT (BSON_APPEND_INT32 (&doc, "v", opt->v)); - } - if (opt->weights && (opt->weights != def_opt->weights)) { - BSON_ASSERT (BSON_APPEND_DOCUMENT (&doc, "weights", opt->weights)); - } - if (opt->default_language != def_opt->default_language) { - BSON_ASSERT ( - BSON_APPEND_UTF8 (&doc, "default_language", opt->default_language)); - } - if (opt->language_override != def_opt->language_override) { - BSON_ASSERT ( - BSON_APPEND_UTF8 (&doc, "language_override", opt->language_override)); - } - if (opt->partial_filter_expression) { - BSON_ASSERT (BSON_APPEND_DOCUMENT ( - &doc, "partialFilterExpression", opt->partial_filter_expression)); - } - if (opt->collation) { - BSON_ASSERT (BSON_APPEND_DOCUMENT (&doc, "collation", opt->collation)); - } - if (opt->geo_options) { - geo_opt = opt->geo_options; - def_geo = mongoc_index_opt_geo_get_default (); - if (geo_opt->twod_sphere_version != def_geo->twod_sphere_version) { - BSON_ASSERT (BSON_APPEND_INT32 ( - &doc, "2dsphereIndexVersion", geo_opt->twod_sphere_version)); - } - if (geo_opt->twod_bits_precision != def_geo->twod_bits_precision) { - BSON_ASSERT ( - BSON_APPEND_INT32 (&doc, "bits", geo_opt->twod_bits_precision)); - } - if (geo_opt->twod_location_min != def_geo->twod_location_min) { - BSON_ASSERT ( - BSON_APPEND_DOUBLE (&doc, "min", geo_opt->twod_location_min)); - } - if (geo_opt->twod_location_max != def_geo->twod_location_max) { - BSON_ASSERT ( - BSON_APPEND_DOUBLE (&doc, "max", geo_opt->twod_location_max)); - } - if (geo_opt->haystack_bucket_size != def_geo->haystack_bucket_size) { - BSON_ASSERT (BSON_APPEND_DOUBLE ( - &doc, "bucketSize", geo_opt->haystack_bucket_size)); - } - } - - if (opt->storage_options) { - storage_opt = opt->storage_options; - switch (storage_opt->type) { - case MONGOC_INDEX_STORAGE_OPT_WIREDTIGER: - wt_opt = (mongoc_index_opt_wt_t *) storage_opt; - BSON_APPEND_DOCUMENT_BEGIN (&doc, "storageEngine", &storage_doc); - BSON_APPEND_DOCUMENT_BEGIN (&storage_doc, "wiredTiger", &wt_doc); - BSON_ASSERT ( - BSON_APPEND_UTF8 (&wt_doc, "configString", wt_opt->config_str)); - bson_append_document_end (&storage_doc, &wt_doc); - bson_append_document_end (&doc, &storage_doc); - break; - default: - break; - } - } - - bson_array_builder_append_document_end (ar, &doc); - bson_append_array_builder_end (&cmd, ar); - - server_stream = mongoc_cluster_stream_for_writes ( - &collection->client->cluster, parsed.client_session, NULL, reply, error); - - if (!server_stream) { - reply_initialized = true; - GOTO (done); - } - - if (!mongoc_cmd_parts_set_write_concern ( - &parts, parsed.writeConcern, error)) { - GOTO (done); - } - - parts.assembled.session = parsed.client_session; - if (!bson_concat (&parts.extra, &parsed.extra)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "'opts' is too large"); - GOTO (done); - } - - cluster = &collection->client->cluster; - if (mongoc_cmd_parts_assemble (&parts, server_stream, error)) { - ret = mongoc_cluster_run_command_monitored ( - cluster, &parts.assembled, reply, error); - } else { - _mongoc_bson_init_if_set (reply); - } - - reply_initialized = true; - - if (ret) { - if (reply) { - ret = !_mongoc_parse_wc_err (reply, error); - } - } - -done: - bson_destroy (&cmd); - bson_free (alloc_name); - _mongoc_create_index_opts_cleanup (&parsed); - mongoc_server_stream_cleanup (server_stream); - mongoc_cmd_parts_cleanup (&parts); - if (!reply_initialized && reply) { - bson_init (reply); - } - - RETURN (ret); -} - - -bool -mongoc_collection_ensure_index (mongoc_collection_t *collection, - const bson_t *keys, - const mongoc_index_opt_t *opt, - bson_error_t *error) -{ - BEGIN_IGNORE_DEPRECATIONS - return mongoc_collection_create_index (collection, keys, opt, error); - END_IGNORE_DEPRECATIONS -} - - -mongoc_cursor_t * -mongoc_collection_find_indexes (mongoc_collection_t *collection, - bson_error_t *error) -{ - mongoc_cursor_t *cursor; - - cursor = mongoc_collection_find_indexes_with_opts (collection, NULL); - - (void) mongoc_cursor_error (cursor, error); - - return cursor; -} - - -mongoc_cursor_t * -mongoc_collection_find_indexes_with_opts (mongoc_collection_t *collection, - const bson_t *opts) -{ - mongoc_cursor_t *cursor; - bson_t cmd = BSON_INITIALIZER; - bson_t child; - bson_error_t error; - - BSON_ASSERT_PARAM (collection); - - bson_append_utf8 (&cmd, - "listIndexes", - -1, - collection->collection, - collection->collectionlen); - - BSON_APPEND_DOCUMENT_BEGIN (&cmd, "cursor", &child); - bson_append_document_end (&cmd, &child); - - /* No read preference. Index Enumeration Spec: "run listIndexes on the - * primary node in replicaSet mode". */ - cursor = _mongoc_cursor_cmd_new ( - collection->client, collection->ns, &cmd, opts, NULL, NULL, NULL); - - if (!mongoc_cursor_error (cursor, &error)) { - _mongoc_cursor_prime (cursor); - } - - if (mongoc_cursor_error (cursor, &error) && - error.code == MONGOC_ERROR_COLLECTION_DOES_NOT_EXIST) { - /* collection does not exist. from spec: return no documents but no err: - * https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst#enumeration-getting-index-information - */ - _mongoc_cursor_set_empty (cursor); - } - - bson_destroy (&cmd); - - return cursor; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_insert_bulk -- - * - * Bulk insert documents into a MongoDB collection. - * - * Parameters: - * @collection: A mongoc_collection_t. - * @flags: flags for the insert or 0. - * @documents: The documents to insert. - * @n_documents: The number of documents to insert. - * @write_concern: A write concern or NULL. - * @error: a location for an error or NULL. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * If the write concern does not dictate checking the result of the - * insert, then true may be returned even though the document was - * not actually inserted on the MongoDB server or cluster. - * - * Side effects: - * @collection->gle is setup, depending on write_concern->w value. - * @error may be set upon failure if non-NULL. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_insert_bulk (mongoc_collection_t *collection, - mongoc_insert_flags_t flags, - const bson_t **documents, - uint32_t n_documents, - const mongoc_write_concern_t *write_concern, - bson_error_t *error) -{ - mongoc_write_command_t command; - mongoc_write_result_t result; - mongoc_bulk_write_flags_t write_flags = MONGOC_BULK_WRITE_FLAGS_INIT; - uint32_t i; - bool ret; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (documents); - - if (!write_concern) { - write_concern = collection->write_concern; - } - - if (!(flags & MONGOC_INSERT_NO_VALIDATE)) { - for (i = 0; i < n_documents; i++) { - if (!_mongoc_validate_new_document ( - documents[i], _mongoc_default_insert_vflags, error)) { - RETURN (false); - } - } - } - - bson_clear (&collection->gle); - - _mongoc_write_result_init (&result); - - write_flags.ordered = !(flags & MONGOC_INSERT_CONTINUE_ON_ERROR); - - _mongoc_write_command_init_insert ( - &command, - NULL, - NULL, - write_flags, - ++collection->client->cluster.operation_id); - - for (i = 0; i < n_documents; i++) { - _mongoc_write_command_insert_append (&command, documents[i]); - } - - _mongoc_collection_write_command_execute ( - &command, collection, write_concern, NULL, &result); - - collection->gle = bson_new (); - ret = MONGOC_WRITE_RESULT_COMPLETE (&result, - collection->client->error_api_version, - write_concern, - /* no error domain override */ - (mongoc_error_domain_t) 0, - collection->gle, - error); - - _mongoc_write_result_destroy (&result); - _mongoc_write_command_destroy (&command); - - return ret; -} - - -bool -mongoc_collection_insert (mongoc_collection_t *collection, - mongoc_insert_flags_t flags, - const bson_t *document, - const mongoc_write_concern_t *write_concern, - bson_error_t *error) -{ - bson_t opts = BSON_INITIALIZER; - bson_t reply; - bool r; - - bson_clear (&collection->gle); - - if (flags & MONGOC_INSERT_NO_VALIDATE) { - bson_append_bool (&opts, "validate", 8, false); - } - - if (write_concern) { - mongoc_write_concern_append ((mongoc_write_concern_t *) write_concern, - &opts); - } - - r = - mongoc_collection_insert_one (collection, document, &opts, &reply, error); - - collection->gle = bson_copy (&reply); - bson_destroy (&reply); - bson_destroy (&opts); - - return r; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_insert_one -- - * - * Insert a document into a MongoDB collection. - * - * Parameters: - * @collection: A mongoc_collection_t. - * @document: The document to insert. - * @opts: Standard command options. - * @reply: Optional. Uninitialized doc to receive the update result. - * @error: A location for an error or NULL. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * If the write concern does not dictate checking the result of the - * insert, then true may be returned even though the document was - * not actually inserted on the MongoDB server or cluster. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_insert_one (mongoc_collection_t *collection, - const bson_t *document, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - mongoc_insert_one_opts_t insert_one_opts; - mongoc_write_command_t command; - mongoc_write_result_t result; - bson_t cmd_opts = BSON_INITIALIZER; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (document); - - _mongoc_bson_init_if_set (reply); - - if (!_mongoc_insert_one_opts_parse ( - collection->client, opts, &insert_one_opts, error)) { - GOTO (done); - } - - if (!bson_empty (&insert_one_opts.extra)) { - bson_concat (&cmd_opts, &insert_one_opts.extra); - } - - if (insert_one_opts.crud.comment.value_type != BSON_TYPE_EOD) { - bson_append_value ( - &cmd_opts, "comment", 7, &insert_one_opts.crud.comment); - } - - if (!_mongoc_validate_new_document ( - document, insert_one_opts.crud.validate, error)) { - GOTO (done); - } - - _mongoc_write_result_init (&result); - _mongoc_write_command_init_insert_idl ( - &command, - document, - &cmd_opts, - ++collection->client->cluster.operation_id); - - command.flags.bypass_document_validation = insert_one_opts.bypass; - _mongoc_collection_write_command_execute_idl ( - &command, collection, &insert_one_opts.crud, &result); - - ret = MONGOC_WRITE_RESULT_COMPLETE (&result, - collection->client->error_api_version, - insert_one_opts.crud.writeConcern, - /* no error domain override */ - (mongoc_error_domain_t) 0, - reply, - error, - "insertedCount"); - - _mongoc_write_result_destroy (&result); - _mongoc_write_command_destroy (&command); - -done: - _mongoc_insert_one_opts_cleanup (&insert_one_opts); - bson_destroy (&cmd_opts); - - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_insert_many -- - * - * Insert documents into a MongoDB collection. Replaces - * mongoc_collection_insert_bulk. - * - * Parameters: - * @collection: A mongoc_collection_t. - * @documents: The documents to insert. - * @n_documents: Length of @documents array. - * @opts: Standard command options. - * @reply: Optional. Uninitialized doc to receive the update result. - * @error: A location for an error or NULL. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * If the write concern does not dictate checking the result of the - * insert, then true may be returned even though the document was - * not actually inserted on the MongoDB server or cluster. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_insert_many (mongoc_collection_t *collection, - const bson_t **documents, - size_t n_documents, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - mongoc_insert_many_opts_t insert_many_opts; - mongoc_write_command_t command; - mongoc_write_result_t result; - bson_t cmd_opts = BSON_INITIALIZER; - size_t i; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (documents); - - _mongoc_bson_init_if_set (reply); - - if (!_mongoc_insert_many_opts_parse ( - collection->client, opts, &insert_many_opts, error)) { - _mongoc_insert_many_opts_cleanup (&insert_many_opts); - return false; - } - - if (insert_many_opts.crud.comment.value_type != BSON_TYPE_EOD) { - bson_append_value ( - &cmd_opts, "comment", 7, &insert_many_opts.crud.comment); - } - - if (!bson_empty (&insert_many_opts.extra)) { - bson_concat (&cmd_opts, &insert_many_opts.extra); - } - - _mongoc_write_result_init (&result); - _mongoc_write_command_init_insert_idl ( - &command, NULL, &cmd_opts, ++collection->client->cluster.operation_id); - - command.flags.ordered = insert_many_opts.ordered; - command.flags.bypass_document_validation = insert_many_opts.bypass; - - for (i = 0; i < n_documents; i++) { - if (!_mongoc_validate_new_document ( - documents[i], insert_many_opts.crud.validate, error)) { - ret = false; - GOTO (done); - } - - _mongoc_write_command_insert_append (&command, documents[i]); - } - - _mongoc_collection_write_command_execute_idl ( - &command, collection, &insert_many_opts.crud, &result); - - ret = MONGOC_WRITE_RESULT_COMPLETE (&result, - collection->client->error_api_version, - insert_many_opts.crud.writeConcern, - /* no error domain override */ - (mongoc_error_domain_t) 0, - reply, - error, - "insertedCount"); - -done: - _mongoc_write_result_destroy (&result); - _mongoc_write_command_destroy (&command); - _mongoc_insert_many_opts_cleanup (&insert_many_opts); - bson_destroy (&cmd_opts); - - RETURN (ret); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_update -- - * - * Updates one or more documents matching @selector with @update. - * - * Parameters: - * @collection: A mongoc_collection_t. - * @flags: The flags for the update. - * @selector: A bson_t containing your selector. - * @update: A bson_t containing your update document. - * @write_concern: The write concern or NULL. - * @error: A location for an error or NULL. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * @collection->gle is setup, depending on write_concern->w value. - * @error is setup upon failure. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_update (mongoc_collection_t *collection, - mongoc_update_flags_t uflags, - const bson_t *selector, - const bson_t *update, - const mongoc_write_concern_t *write_concern, - bson_error_t *error) -{ - mongoc_bulk_write_flags_t write_flags = MONGOC_BULK_WRITE_FLAGS_INIT; - mongoc_write_command_t command; - mongoc_write_result_t result; - bson_iter_t iter; - bool ret; - int flags = uflags; - bson_t opts; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (selector); - BSON_ASSERT_PARAM (update); - - bson_clear (&collection->gle); - - if (!write_concern) { - write_concern = collection->write_concern; - } - - if (!((uint32_t) flags & MONGOC_UPDATE_NO_VALIDATE) && - bson_iter_init (&iter, update) && bson_iter_next (&iter)) { - if (bson_iter_key (&iter)[0] == '$') { - /* update document, all keys must be $-operators */ - if (!_mongoc_validate_update ( - update, _mongoc_default_update_vflags, error)) { - return false; - } - } else { - if (!_mongoc_validate_replace ( - update, _mongoc_default_replace_vflags, error)) { - return false; - } - } - } - - bson_init (&opts); - BSON_APPEND_BOOL (&opts, "upsert", !!(flags & MONGOC_UPDATE_UPSERT)); - BSON_APPEND_BOOL (&opts, "multi", !!(flags & MONGOC_UPDATE_MULTI_UPDATE)); - - _mongoc_write_result_init (&result); - _mongoc_write_command_init_update ( - &command, - selector, - update, - NULL, /* cmd_opts */ - &opts, - write_flags, - ++collection->client->cluster.operation_id); - bson_destroy (&opts); - - command.flags.has_multi_write = !!(flags & MONGOC_UPDATE_MULTI_UPDATE); - - _mongoc_collection_write_command_execute ( - &command, collection, write_concern, NULL, &result); - - collection->gle = bson_new (); - ret = MONGOC_WRITE_RESULT_COMPLETE (&result, - collection->client->error_api_version, - write_concern, - /* no error domain override */ - (mongoc_error_domain_t) 0, - collection->gle, - error); - - _mongoc_write_result_destroy (&result); - _mongoc_write_command_destroy (&command); - - RETURN (ret); -} - -static bool -_mongoc_collection_update_or_replace (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *update, - mongoc_update_opts_t *update_opts, - bool multi, - bool bypass, - const bson_t *array_filters, - bson_t *extra, - bson_t *reply, - bson_error_t *error) -{ - mongoc_write_command_t command; - mongoc_write_result_t result; - mongoc_server_stream_t *server_stream = NULL; - bson_t cmd_opts = BSON_INITIALIZER; - bool reply_initialized = false; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (selector); - BSON_ASSERT_PARAM (update); - - if (!bson_empty (&update_opts->let)) { - bson_append_document (&cmd_opts, "let", 3, &update_opts->let); - } - - if (update_opts->crud.comment.value_type != BSON_TYPE_EOD) { - bson_append_value (&cmd_opts, "comment", 7, &update_opts->crud.comment); - } - - if (update_opts->upsert) { - bson_append_bool (extra, "upsert", 6, true); - } - - if (!bson_empty (&update_opts->collation)) { - bson_append_document (extra, "collation", 9, &update_opts->collation); - } - - if (update_opts->hint.value_type) { - bson_append_value (extra, "hint", 4, &update_opts->hint); - } - - if (!bson_empty0 (array_filters)) { - bson_append_array (extra, "arrayFilters", 12, array_filters); - } - - if (multi) { - bson_append_bool (extra, "multi", 5, true); - } - - _mongoc_write_result_init (&result); - _mongoc_write_command_init_update_idl ( - &command, - selector, - update, - &cmd_opts, - extra, - ++collection->client->cluster.operation_id); - - command.flags.has_multi_write = multi; - command.flags.bypass_document_validation = bypass; - if (!bson_empty (&update_opts->collation)) { - command.flags.has_collation = true; - } - if (update_opts->hint.value_type) { - command.flags.has_update_hint = true; - } - - server_stream = - mongoc_cluster_stream_for_writes (&collection->client->cluster, - update_opts->crud.client_session, - NULL, - reply, - error); - - if (!server_stream) { - /* mongoc_cluster_stream_for_writes inits reply on error */ - reply_initialized = true; - GOTO (done); - } - - if (!bson_empty0 (array_filters)) { - if (!mongoc_write_concern_is_acknowledged ( - update_opts->crud.writeConcern)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "Cannot use array filters with unacknowledged writes"); - GOTO (done); - } - } - - if (_mongoc_client_session_in_txn (update_opts->crud.client_session) && - update_opts->crud.writeConcern) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot set write concern after starting transaction"); - GOTO (done); - } - - if (!update_opts->crud.writeConcern && - !_mongoc_client_session_in_txn (update_opts->crud.client_session)) { - update_opts->crud.writeConcern = collection->write_concern; - update_opts->crud.write_concern_owned = false; - } - - _mongoc_write_command_execute_idl (&command, - collection->client, - server_stream, - collection->db, - collection->collection, - 0 /* offset */, - &update_opts->crud, - &result); - - _mongoc_bson_init_if_set (reply); - reply_initialized = true; - - /* set fields described in CRUD spec for the UpdateResult */ - ret = MONGOC_WRITE_RESULT_COMPLETE (&result, - collection->client->error_api_version, - update_opts->crud.writeConcern, - /* no error domain override */ - (mongoc_error_domain_t) 0, - reply, - error, - "modifiedCount", - "matchedCount", - "upsertedCount", - "upsertedId"); - -done: - _mongoc_write_result_destroy (&result); - mongoc_server_stream_cleanup (server_stream); - _mongoc_write_command_destroy (&command); - bson_destroy (&cmd_opts); - - if (!reply_initialized) { - _mongoc_bson_init_if_set (reply); - } - - RETURN (ret); -} - -bool -mongoc_collection_update_one (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *update, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - mongoc_update_one_opts_t update_one_opts; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (update); - - if (!_mongoc_update_one_opts_parse ( - collection->client, opts, &update_one_opts, error)) { - _mongoc_update_one_opts_cleanup (&update_one_opts); - _mongoc_bson_init_if_set (reply); - return false; - } - - if (!_mongoc_validate_update ( - update, update_one_opts.update.crud.validate, error)) { - _mongoc_update_one_opts_cleanup (&update_one_opts); - _mongoc_bson_init_if_set (reply); - return false; - } - - ret = _mongoc_collection_update_or_replace (collection, - selector, - update, - &update_one_opts.update, - false /* multi */, - update_one_opts.update.bypass, - &update_one_opts.arrayFilters, - &update_one_opts.extra, - reply, - error); - - _mongoc_update_one_opts_cleanup (&update_one_opts); - - RETURN (ret); -} - -bool -mongoc_collection_update_many (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *update, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - mongoc_update_many_opts_t update_many_opts; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (update); - - if (!_mongoc_update_many_opts_parse ( - collection->client, opts, &update_many_opts, error)) { - _mongoc_update_many_opts_cleanup (&update_many_opts); - _mongoc_bson_init_if_set (reply); - return false; - } - - if (!_mongoc_validate_update ( - update, update_many_opts.update.crud.validate, error)) { - _mongoc_update_many_opts_cleanup (&update_many_opts); - _mongoc_bson_init_if_set (reply); - return false; - } - - ret = _mongoc_collection_update_or_replace (collection, - selector, - update, - &update_many_opts.update, - true /* multi */, - update_many_opts.update.bypass, - &update_many_opts.arrayFilters, - &update_many_opts.extra, - reply, - error); - - _mongoc_update_many_opts_cleanup (&update_many_opts); - - RETURN (ret); -} - -bool -mongoc_collection_replace_one (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *replacement, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - mongoc_replace_one_opts_t replace_one_opts; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (replacement); - - if (!_mongoc_replace_one_opts_parse ( - collection->client, opts, &replace_one_opts, error)) { - _mongoc_replace_one_opts_cleanup (&replace_one_opts); - _mongoc_bson_init_if_set (reply); - return false; - } - - if (!_mongoc_validate_replace ( - replacement, replace_one_opts.update.crud.validate, error)) { - _mongoc_replace_one_opts_cleanup (&replace_one_opts); - _mongoc_bson_init_if_set (reply); - return false; - } - - ret = _mongoc_collection_update_or_replace (collection, - selector, - replacement, - &replace_one_opts.update, - false /* multi */, - replace_one_opts.update.bypass, - NULL, - &replace_one_opts.extra, - reply, - error); - - _mongoc_replace_one_opts_cleanup (&replace_one_opts); - - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_save -- - * - * Save @document to @collection. - * - * If the document has an _id field, it will be updated. Otherwise, - * the document will be inserted into the collection. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * @error is set upon failure if non-NULL. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_save (mongoc_collection_t *collection, - const bson_t *document, - const mongoc_write_concern_t *write_concern, - bson_error_t *error) -{ - bson_iter_t iter; - bool ret; - bson_t selector; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (document); - - BEGIN_IGNORE_DEPRECATIONS - if (!bson_iter_init_find (&iter, document, "_id")) { - return mongoc_collection_insert ( - collection, MONGOC_INSERT_NONE, document, write_concern, error); - } - - bson_init (&selector); - if (!bson_append_iter (&selector, NULL, 0, &iter)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Failed to append bson to create update."); - bson_destroy (&selector); - return false; - } - - /* this document will be inserted, validate same as for inserts */ - if (!_mongoc_validate_new_document ( - document, _mongoc_default_insert_vflags, error)) { - return false; - } - - ret = mongoc_collection_update (collection, - MONGOC_UPDATE_UPSERT | - MONGOC_UPDATE_NO_VALIDATE, - &selector, - document, - write_concern, - error); - END_IGNORE_DEPRECATIONS - - bson_destroy (&selector); - - return ret; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_remove -- - * - * Delete one or more items from a collection. If you want to - * limit to a single delete, provided MONGOC_REMOVE_SINGLE_REMOVE - * for @flags. - * - * Superseded by mongoc_collection_delete_one/many. - * - * Parameters: - * @collection: A mongoc_collection_t. - * @flags: the delete flags or 0. - * @selector: A selector of documents to delete. - * @write_concern: A write concern or NULL. If NULL, the default - * write concern for the collection will be used. - * @error: A location for an error or NULL. - * - * Returns: - * true if successful; otherwise false and error is set. - * - * If the write concern does not dictate checking the result, this - * function may return true even if it failed. - * - * Side effects: - * @collection->gle is setup, depending on write_concern->w value. - * @error is setup upon failure. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_remove (mongoc_collection_t *collection, - mongoc_remove_flags_t flags, - const bson_t *selector, - const mongoc_write_concern_t *write_concern, - bson_error_t *error) -{ - mongoc_bulk_write_flags_t write_flags = MONGOC_BULK_WRITE_FLAGS_INIT; - mongoc_write_command_t command; - mongoc_write_result_t result; - bson_t opts; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (selector); - - bson_clear (&collection->gle); - - if (!write_concern) { - write_concern = collection->write_concern; - } - - bson_init (&opts); - BSON_APPEND_INT32 ( - &opts, "limit", flags & MONGOC_REMOVE_SINGLE_REMOVE ? 1 : 0); - _mongoc_write_result_init (&result); - ++collection->client->cluster.operation_id; - _mongoc_write_command_init_delete (&command, - selector, - NULL, - &opts, - write_flags, - collection->client->cluster.operation_id); - bson_destroy (&opts); - - command.flags.has_multi_write = !(flags & MONGOC_REMOVE_SINGLE_REMOVE); - - _mongoc_collection_write_command_execute ( - &command, collection, write_concern, NULL, &result); - - collection->gle = bson_new (); - ret = MONGOC_WRITE_RESULT_COMPLETE (&result, - collection->client->error_api_version, - write_concern, - 0 /* no error domain override */, - collection->gle, - error); - - _mongoc_write_result_destroy (&result); - _mongoc_write_command_destroy (&command); - - RETURN (ret); -} - - -bool -mongoc_collection_delete (mongoc_collection_t *collection, - mongoc_delete_flags_t flags, - const bson_t *selector, - const mongoc_write_concern_t *write_concern, - bson_error_t *error) -{ - return mongoc_collection_remove (collection, - (mongoc_remove_flags_t) flags, - selector, - write_concern, - error); -} - - -static bool -_mongoc_delete_one_or_many (mongoc_collection_t *collection, - bool multi, - const bson_t *selector, - mongoc_delete_opts_t *delete_opts, - const bson_t *extra, - bson_t *reply, - bson_error_t *error) -{ - mongoc_write_command_t command; - mongoc_write_result_t result; - bson_t cmd_opts = BSON_INITIALIZER; - bson_t opts = BSON_INITIALIZER; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (selector); - BSON_ASSERT (bson_empty0 (reply)); - - /* TODO: This function has historically used `extra` for top-level, command - * options. That is inconsistent with the update function, which uses `extra` - * for statement-level options. We will keep the original behavior for BC - * reasons, but this should ultimately be addressed by CDRIVER-4306. */ - if (!bson_empty0 (extra)) { - bson_concat (&cmd_opts, extra); - } - - if (!bson_empty (&delete_opts->let)) { - bson_append_document (&cmd_opts, "let", 3, &delete_opts->let); - } - - if (delete_opts->crud.comment.value_type != BSON_TYPE_EOD) { - bson_append_value (&cmd_opts, "comment", 7, &delete_opts->crud.comment); - } - - _mongoc_write_result_init (&result); - bson_append_int32 (&opts, "limit", 5, multi ? 0 : 1); - - if (!bson_empty (&delete_opts->collation)) { - bson_append_document (&opts, "collation", 9, &delete_opts->collation); - } - - if (delete_opts->hint.value_type) { - bson_append_value (&opts, "hint", 4, &delete_opts->hint); - } - - _mongoc_write_command_init_delete_idl ( - &command, - selector, - &cmd_opts, - &opts, - ++collection->client->cluster.operation_id); - - command.flags.has_multi_write = multi; - if (!bson_empty (&delete_opts->collation)) { - command.flags.has_collation = true; - } - if (delete_opts->hint.value_type) { - command.flags.has_delete_hint = true; - } - - _mongoc_collection_write_command_execute_idl ( - &command, collection, &delete_opts->crud, &result); - - /* set field described in CRUD spec for the DeleteResult */ - ret = MONGOC_WRITE_RESULT_COMPLETE (&result, - collection->client->error_api_version, - delete_opts->crud.writeConcern, - /* no error domain override */ - (mongoc_error_domain_t) 0, - reply, - error, - "deletedCount"); - - _mongoc_write_result_destroy (&result); - _mongoc_write_command_destroy (&command); - bson_destroy (&cmd_opts); - bson_destroy (&opts); - - RETURN (ret); -} - - -bool -mongoc_collection_delete_one (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - mongoc_delete_one_opts_t delete_one_opts; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (selector); - - _mongoc_bson_init_if_set (reply); - if (!_mongoc_delete_one_opts_parse ( - collection->client, opts, &delete_one_opts, error)) { - GOTO (done); - } - - ret = _mongoc_delete_one_or_many (collection, - false /* multi */, - selector, - &delete_one_opts.delete, - &delete_one_opts.extra, - reply, - error); - -done: - _mongoc_delete_one_opts_cleanup (&delete_one_opts); - - RETURN (ret); -} - -bool -mongoc_collection_delete_many (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - mongoc_delete_many_opts_t delete_many_opts; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (selector); - - _mongoc_bson_init_if_set (reply); - if (!_mongoc_delete_many_opts_parse ( - collection->client, opts, &delete_many_opts, error)) { - GOTO (done); - } - - ret = _mongoc_delete_one_or_many (collection, - true /* multi */, - selector, - &delete_many_opts.delete, - &delete_many_opts.extra, - reply, - error); - -done: - _mongoc_delete_many_opts_cleanup (&delete_many_opts); - - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_get_read_prefs -- - * - * Fetch the default read preferences for the collection. - * - * Returns: - * A mongoc_read_prefs_t that should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const mongoc_read_prefs_t * -mongoc_collection_get_read_prefs (const mongoc_collection_t *collection) -{ - BSON_ASSERT_PARAM (collection); - return collection->read_prefs; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_set_read_prefs -- - * - * Sets the default read preferences for the collection instance. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_collection_set_read_prefs (mongoc_collection_t *collection, - const mongoc_read_prefs_t *read_prefs) -{ - BSON_ASSERT_PARAM (collection); - - if (collection->read_prefs) { - mongoc_read_prefs_destroy (collection->read_prefs); - collection->read_prefs = NULL; - } - - if (read_prefs) { - collection->read_prefs = mongoc_read_prefs_copy (read_prefs); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_get_read_concern -- - * - * Fetches the default read concern for the collection instance. - * - * Returns: - * A mongoc_read_concern_t that should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const mongoc_read_concern_t * -mongoc_collection_get_read_concern (const mongoc_collection_t *collection) -{ - BSON_ASSERT_PARAM (collection); - - return collection->read_concern; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_set_read_concern -- - * - * Sets the default read concern for the collection instance. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_collection_set_read_concern (mongoc_collection_t *collection, - const mongoc_read_concern_t *read_concern) -{ - BSON_ASSERT_PARAM (collection); - - if (collection->read_concern) { - mongoc_read_concern_destroy (collection->read_concern); - collection->read_concern = NULL; - } - - if (read_concern) { - collection->read_concern = mongoc_read_concern_copy (read_concern); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_get_write_concern -- - * - * Fetches the default write concern for the collection instance. - * - * Returns: - * A mongoc_write_concern_t that should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const mongoc_write_concern_t * -mongoc_collection_get_write_concern (const mongoc_collection_t *collection) -{ - BSON_ASSERT_PARAM (collection); - - return collection->write_concern; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_set_write_concern -- - * - * Sets the default write concern for the collection instance. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_collection_set_write_concern ( - mongoc_collection_t *collection, const mongoc_write_concern_t *write_concern) -{ - BSON_ASSERT_PARAM (collection); - - if (collection->write_concern) { - mongoc_write_concern_destroy (collection->write_concern); - collection->write_concern = NULL; - } - - if (write_concern) { - collection->write_concern = mongoc_write_concern_copy (write_concern); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_get_name -- - * - * Returns the name of the collection, excluding the database name. - * - * Returns: - * A string which should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const char * -mongoc_collection_get_name (mongoc_collection_t *collection) -{ - BSON_ASSERT_PARAM (collection); - - return collection->collection; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_get_last_error -- - * - * Returns a bulk result. - * - * Returns: - * NULL or a bson_t that should not be modified or freed. This value - * is not guaranteed to be persistent between calls into the - * mongoc_collection_t instance, and therefore must be copied if - * you would like to keep it around. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const bson_t * -mongoc_collection_get_last_error ( - const mongoc_collection_t *collection) /* IN */ -{ - BSON_ASSERT_PARAM (collection); - - return collection->gle; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_validate -- - * - * Helper to call the validate command on the MongoDB server to - * validate the collection. - * - * Options may be additional options, or NULL. - * Currently supported options are: - * - * "full": Boolean - * - * If full is true, then perform a more resource intensive - * validation. - * - * The result is stored in reply. - * - * Returns: - * true if successful; otherwise false and @error is set. - * - * Side effects: - * @reply is set if successful. - * @error may be set. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_validate (mongoc_collection_t *collection, /* IN */ - const bson_t *options, /* IN */ - bson_t *reply, /* OUT */ - bson_error_t *error) /* IN */ -{ - bson_iter_t iter; - bson_t cmd = BSON_INITIALIZER; - bool ret = false; - bool reply_initialized = false; - - BSON_ASSERT_PARAM (collection); - - if (options && bson_iter_init_find (&iter, options, "full") && - !BSON_ITER_HOLDS_BOOL (&iter)) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "'full' must be a boolean value."); - goto cleanup; - } - - bson_append_utf8 ( - &cmd, "validate", 8, collection->collection, collection->collectionlen); - - if (options) { - bson_concat (&cmd, options); - } - - ret = - mongoc_collection_command_simple (collection, &cmd, NULL, reply, error); - reply_initialized = true; - -cleanup: - bson_destroy (&cmd); - - if (reply && !reply_initialized) { - bson_init (reply); - } - - return ret; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_rename -- - * - * Rename the collection to @new_name. - * - * If @new_db is NULL, the same db will be used. - * - * If @drop_target_before_rename is true, then a collection named - * @new_name will be dropped before renaming @collection to - * @new_name. - * - * Returns: - * true on success; false on failure and @error is set. - * - * Side effects: - * @error is set on failure. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_rename (mongoc_collection_t *collection, - const char *new_db, - const char *new_name, - bool drop_target_before_rename, - bson_error_t *error) -{ - return mongoc_collection_rename_with_opts ( - collection, new_db, new_name, drop_target_before_rename, NULL, error); -} - - -bool -mongoc_collection_rename_with_opts (mongoc_collection_t *collection, - const char *new_db, - const char *new_name, - bool drop_target_before_rename, - const bson_t *opts, - bson_error_t *error) -{ - bson_t cmd = BSON_INITIALIZER; - char *newns; - bool ret; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (new_name); - - if (strchr (new_name, '$')) { - bson_set_error (error, - MONGOC_ERROR_NAMESPACE, - MONGOC_ERROR_NAMESPACE_INVALID, - "\"%s\" is an invalid collection name.", - new_name); - return false; - } - - newns = - bson_strdup_printf ("%s.%s", new_db ? new_db : collection->db, new_name); - - BSON_APPEND_UTF8 (&cmd, "renameCollection", collection->ns); - BSON_APPEND_UTF8 (&cmd, "to", newns); - - if (drop_target_before_rename) { - BSON_APPEND_BOOL (&cmd, "dropTarget", true); - } - - ret = _mongoc_client_command_with_opts (collection->client, - "admin", - &cmd, - MONGOC_CMD_WRITE, - opts, - MONGOC_QUERY_NONE, - NULL, /* user prefs */ - collection->read_prefs, - collection->read_concern, - collection->write_concern, - NULL, /* reply */ - error); - - if (ret) { - if (new_db) { - bson_free (collection->db); - collection->db = bson_strdup (new_db); - } - - bson_free (collection->collection); - collection->collection = bson_strdup (new_name); - collection->collectionlen = (int) strlen (collection->collection); - - bson_free (collection->ns); - collection->ns = bson_strdup_printf ("%s.%s", collection->db, new_name); - collection->nslen = (int) strlen (collection->ns); - } - - bson_free (newns); - bson_destroy (&cmd); - - return ret; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_stats -- - * - * Fetches statistics about the collection. - * - * The result is stored in @stats, which should NOT be an initialized - * bson_t or a leak will occur. - * - * @stats, @options, and @error are optional. - * - * Returns: - * true on success and @stats is set. - * false on failure and @error is set. - * - * Side effects: - * @stats and @error. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_stats (mongoc_collection_t *collection, - const bson_t *options, - bson_t *stats, - bson_error_t *error) -{ - bson_iter_t iter; - bson_t cmd = BSON_INITIALIZER; - bool ret; - - BSON_ASSERT_PARAM (collection); - - if (options && bson_iter_init_find (&iter, options, "scale") && - !BSON_ITER_HOLDS_INT32 (&iter)) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "'scale' must be an int32 value."); - return false; - } - - BSON_APPEND_UTF8 (&cmd, "collStats", collection->collection); - - if (options) { - bson_concat (&cmd, options); - } - - /* Server Selection Spec: "may-use-secondary" commands SHOULD take a read - * preference argument and otherwise MUST use the default read preference - * from client, database or collection configuration. */ - ret = mongoc_collection_command_simple ( - collection, &cmd, collection->read_prefs, stats, error); - - bson_destroy (&cmd); - - return ret; -} - - -mongoc_bulk_operation_t * -mongoc_collection_create_bulk_operation ( - mongoc_collection_t *collection, - bool ordered, - const mongoc_write_concern_t *write_concern) -{ - bson_t opts = BSON_INITIALIZER; - mongoc_bulk_operation_t *bulk; - bool wc_ok = true; - - bson_append_bool (&opts, "ordered", 7, ordered); - if (write_concern) { - wc_ok = mongoc_write_concern_append ( - (mongoc_write_concern_t *) write_concern, &opts); - } - - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, &opts); - - bson_destroy (&opts); - - if (!wc_ok) { - bson_set_error (&bulk->result.error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "invalid writeConcern"); - } - - return bulk; -} - - -mongoc_bulk_operation_t * -mongoc_collection_create_bulk_operation_with_opts ( - mongoc_collection_t *collection, const bson_t *opts) -{ - mongoc_bulk_opts_t bulk_opts; - mongoc_bulk_write_flags_t write_flags = MONGOC_BULK_WRITE_FLAGS_INIT; - mongoc_write_concern_t *wc = NULL; - mongoc_bulk_operation_t *bulk; - bson_error_t err = {0}; - - BSON_ASSERT_PARAM (collection); - - (void) _mongoc_bulk_opts_parse (collection->client, opts, &bulk_opts, &err); - if (!_mongoc_client_session_in_txn (bulk_opts.client_session)) { - wc = COALESCE (bulk_opts.writeConcern, collection->write_concern); - } - write_flags.ordered = bulk_opts.ordered; - bulk = _mongoc_bulk_operation_new (collection->client, - collection->db, - collection->collection, - write_flags, - wc); - - if (!bson_empty (&bulk_opts.let)) { - mongoc_bulk_operation_set_let (bulk, &bulk_opts.let); - } - - if (bulk_opts.comment.value_type != BSON_TYPE_EOD) { - mongoc_bulk_operation_set_comment (bulk, &bulk_opts.comment); - } - - bulk->session = bulk_opts.client_session; - if (err.domain) { - /* _mongoc_bulk_opts_parse failed, above */ - memcpy (&bulk->result.error, &err, sizeof (bson_error_t)); - } else if (_mongoc_client_session_in_txn (bulk_opts.client_session) && - !mongoc_write_concern_is_default (bulk_opts.writeConcern)) { - bson_set_error (&bulk->result.error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot set write concern after starting transaction"); - } - - _mongoc_bulk_opts_cleanup (&bulk_opts); - - return bulk; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_find_and_modify_with_opts -- - * - * Find a document in @collection matching @query, applying @opts. - * - * If @reply is not NULL, then the result document will be placed - * in reply and should be released with bson_destroy(). - * - * See for more information: - * https://www.mongodb.com/docs/manual/reference/command/findAndModify/ - * - * Returns: - * true on success; false on failure. - * - * Side effects: - * reply is initialized. - * error is set if false is returned. - * - *-------------------------------------------------------------------------- - */ -bool -mongoc_collection_find_and_modify_with_opts ( - mongoc_collection_t *collection, - const bson_t *query, - const mongoc_find_and_modify_opts_t *opts, - bson_t *reply, - bson_error_t *error) -{ - mongoc_cluster_t *cluster; - mongoc_cmd_parts_t parts; - bool is_retryable; - bson_iter_t iter; - bson_iter_t inner; - const char *name; - bson_t ss_reply; - bson_t reply_local; - bson_t *reply_ptr; - bool ret = false; - bson_t command = BSON_INITIALIZER; - mongoc_server_stream_t *server_stream = NULL; - mongoc_server_stream_t *retry_server_stream = NULL; - mongoc_find_and_modify_appended_opts_t appended_opts; - mongoc_write_concern_t *write_concern = NULL; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (query); - BSON_ASSERT_PARAM (opts); - - reply_ptr = reply ? reply : &reply_local; - cluster = &collection->client->cluster; - - mongoc_cmd_parts_init ( - &parts, collection->client, collection->db, MONGOC_QUERY_NONE, &command); - parts.is_read_command = true; - parts.is_write_command = true; - - bson_init (reply_ptr); - - if (!_mongoc_find_and_modify_appended_opts_parse ( - cluster->client, &opts->extra, &appended_opts, error)) { - GOTO (done); - } - - server_stream = mongoc_cluster_stream_for_writes ( - cluster, appended_opts.client_session, NULL, &ss_reply, error); - - if (!server_stream) { - bson_concat (reply_ptr, &ss_reply); - bson_destroy (&ss_reply); - GOTO (done); - } - - name = mongoc_collection_get_name (collection); - BSON_APPEND_UTF8 (&command, "findAndModify", name); - BSON_APPEND_DOCUMENT (&command, "query", query); - - if (opts->sort) { - BSON_APPEND_DOCUMENT (&command, "sort", opts->sort); - } - - if (opts->update) { - if (_mongoc_document_is_pipeline (opts->update)) { - BSON_APPEND_ARRAY (&command, "update", opts->update); - } else { - BSON_APPEND_DOCUMENT (&command, "update", opts->update); - } - } - - if (opts->fields) { - BSON_APPEND_DOCUMENT (&command, "fields", opts->fields); - } - - if (opts->flags & MONGOC_FIND_AND_MODIFY_REMOVE) { - BSON_APPEND_BOOL (&command, "remove", true); - } - - if (opts->flags & MONGOC_FIND_AND_MODIFY_UPSERT) { - BSON_APPEND_BOOL (&command, "upsert", true); - } - - if (opts->flags & MONGOC_FIND_AND_MODIFY_RETURN_NEW) { - BSON_APPEND_BOOL (&command, "new", true); - } - - if (opts->bypass_document_validation) { - BSON_APPEND_BOOL (&command, - "bypassDocumentValidation", - opts->bypass_document_validation); - } - - if (opts->max_time_ms > 0) { - BSON_APPEND_INT32 (&command, "maxTimeMS", opts->max_time_ms); - } - - /* Some options set via mongoc_find_and_modify_opts_append were parsed. Set - * them on the command parts. */ - if (appended_opts.client_session) { - mongoc_cmd_parts_set_session (&parts, appended_opts.client_session); - } - - if (appended_opts.writeConcern) { - if (_mongoc_client_session_in_txn (parts.assembled.session)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot set write concern after starting transaction"); - GOTO (done); - } - - write_concern = appended_opts.writeConcern; - } - /* inherit write concern from collection if not in transaction */ - else if (!_mongoc_client_session_in_txn (parts.assembled.session)) { - if (!mongoc_write_concern_is_valid (collection->write_concern)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The write concern is invalid."); - GOTO (done); - } - - write_concern = collection->write_concern; - } - - if (appended_opts.hint.value_type) { - int max_wire_version = - mongoc_write_concern_is_acknowledged (write_concern) - ? WIRE_VERSION_FIND_AND_MODIFY_HINT_SERVER_SIDE_ERROR - : WIRE_VERSION_FIND_AND_MODIFY_HINT; - - if (server_stream->sd->max_wire_version < max_wire_version) { - bson_set_error ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "The selected server does not support hint for findAndModify"); - GOTO (done); - } - - bson_append_value (&parts.extra, "hint", 4, &appended_opts.hint); - } - - if (!bson_empty (&appended_opts.let)) { - bson_append_document (&parts.extra, "let", 3, &appended_opts.let); - } - - if (appended_opts.comment.value_type != BSON_TYPE_EOD) { - bson_append_value (&parts.extra, "comment", 7, &appended_opts.comment); - } - - /* Append any remaining unparsed options set via - * mongoc_find_and_modify_opts_append to the command part. */ - if (bson_iter_init (&iter, &appended_opts.extra)) { - if (!mongoc_cmd_parts_append_opts (&parts, &iter, error)) { - GOTO (done); - } - } - - /* An empty write concern amounts to a no-op, so there's no need to guard - * against it. */ - if (!mongoc_cmd_parts_set_write_concern (&parts, write_concern, error)) { - GOTO (done); - } - - parts.assembled.operation_id = ++cluster->operation_id; - if (!mongoc_cmd_parts_assemble (&parts, server_stream, error)) { - GOTO (done); - } - - is_retryable = parts.is_retryable_write; - - /* increment the transaction number for the first attempt of each retryable - * write command */ - if (is_retryable) { - bson_iter_t txn_number_iter; - BSON_ASSERT (bson_iter_init_find ( - &txn_number_iter, parts.assembled.command, "txnNumber")); - bson_iter_overwrite_int64 ( - &txn_number_iter, - ++parts.assembled.session->server_session->txn_number); - } - - // Store the original error and reply if needed. - struct { - bson_t reply; - bson_error_t error; - bool set; - } original_error = {.reply = {0}, .error = {0}, .set = false}; - -retry: - bson_destroy (reply_ptr); - ret = mongoc_cluster_run_command_monitored ( - cluster, &parts.assembled, reply_ptr, error); - - if (parts.is_retryable_write) { - _mongoc_write_error_handle_labels ( - ret, error, reply_ptr, server_stream->sd); - } - - if (is_retryable) { - _mongoc_write_error_update_if_unsupported_storage_engine ( - ret, error, reply_ptr); - } - - /* If a retryable error is encountered and the write is retryable, select - * a new writable stream and retry. If server selection fails or the selected - * server does not support retryable writes, fall through and allow the - * original error to be reported. */ - if (is_retryable && - _mongoc_write_error_get_type (reply_ptr) == MONGOC_WRITE_ERR_RETRY) { - bson_error_t ignored_error; - - /* each write command may be retried at most once */ - is_retryable = false; - - { - mongoc_deprioritized_servers_t *const ds = - mongoc_deprioritized_servers_new (); - - mongoc_deprioritized_servers_add_if_sharded ( - ds, server_stream->topology_type, server_stream->sd); - - retry_server_stream = - mongoc_cluster_stream_for_writes (cluster, - parts.assembled.session, - ds, - NULL /* reply */, - &ignored_error); - - mongoc_deprioritized_servers_destroy (ds); - } - - if (retry_server_stream) { - parts.assembled.server_stream = retry_server_stream; - { - // Store the original error and reply before retry. - BSON_ASSERT (!original_error.set); // Retry only happens once. - original_error.set = true; - bson_copy_to (reply_ptr, &original_error.reply); - if (error) { - original_error.error = *error; - } - } - GOTO (retry); - } - } - - // If a retry attempt fails with an error labeled NoWritesPerformed, - // drivers MUST return the original error. - if (original_error.set && - mongoc_error_has_label (reply_ptr, "NoWritesPerformed")) { - if (error) { - *error = original_error.error; - } - bson_destroy (reply_ptr); - bson_copy_to (&original_error.reply, reply_ptr); - } - - if (original_error.set) { - bson_destroy (&original_error.reply); - } - - if (bson_iter_init_find (&iter, reply_ptr, "writeConcernError") && - BSON_ITER_HOLDS_DOCUMENT (&iter)) { - const char *errmsg = NULL; - int32_t code = 0; - - BSON_ASSERT (bson_iter_recurse (&iter, &inner)); - while (bson_iter_next (&inner)) { - if (BSON_ITER_IS_KEY (&inner, "code")) { - code = (uint32_t) bson_iter_as_int64 (&inner); - } else if (BSON_ITER_IS_KEY (&inner, "errmsg")) { - errmsg = bson_iter_utf8 (&inner, NULL); - } - } - bson_set_error (error, - MONGOC_ERROR_WRITE_CONCERN, - code, - "Write Concern error: %s", - errmsg); - ret = false; - } - - -done: - mongoc_server_stream_cleanup (server_stream); - mongoc_server_stream_cleanup (retry_server_stream); - - if (ret && error) { - /* if a retry succeeded, clear the initial error */ - memset (error, 0, sizeof (bson_error_t)); - } - mongoc_cmd_parts_cleanup (&parts); - bson_destroy (&command); - if (&reply_local == reply_ptr) { - bson_destroy (&reply_local); - } - _mongoc_find_and_modify_appended_opts_cleanup (&appended_opts); - RETURN (ret); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_collection_find_and_modify -- - * - * Find a document in @collection matching @query and update it with - * the update document @update. - * - * If @reply is not NULL, then the result document will be placed - * in reply and should be released with bson_destroy(). - * - * If @remove is true, then the matching documents will be removed. - * - * If @fields is not NULL, it will be used to select the desired - * resulting fields. - * - * If @_new is true, then the new version of the document is returned - * instead of the old document. - * - * See for more information: - * https://www.mongodb.com/docs/manual/reference/command/findAndModify/ - * - * Returns: - * true on success; false on failure. - * - * Side effects: - * reply is initialized. - * error is set if false is returned. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_collection_find_and_modify (mongoc_collection_t *collection, - const bson_t *query, - const bson_t *sort, - const bson_t *update, - const bson_t *fields, - bool _remove, - bool upsert, - bool _new, - bson_t *reply, - bson_error_t *error) -{ - mongoc_find_and_modify_opts_t *opts; - int flags = 0; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (query); - BSON_ASSERT (update || _remove); - - - if (_remove) { - flags |= MONGOC_FIND_AND_MODIFY_REMOVE; - } - if (upsert) { - flags |= MONGOC_FIND_AND_MODIFY_UPSERT; - } - if (_new) { - flags |= MONGOC_FIND_AND_MODIFY_RETURN_NEW; - } - - opts = mongoc_find_and_modify_opts_new (); - - mongoc_find_and_modify_opts_set_sort (opts, sort); - mongoc_find_and_modify_opts_set_update (opts, update); - mongoc_find_and_modify_opts_set_fields (opts, fields); - mongoc_find_and_modify_opts_set_flags (opts, flags); - - ret = mongoc_collection_find_and_modify_with_opts ( - collection, query, opts, reply, error); - mongoc_find_and_modify_opts_destroy (opts); - - return ret; -} - -mongoc_change_stream_t * -mongoc_collection_watch (const mongoc_collection_t *coll, - const bson_t *pipeline, - const bson_t *opts) -{ - return _mongoc_change_stream_new_from_collection (coll, pipeline, opts); -} - -struct _mongoc_index_model_t { - bson_t *keys; - bson_t *opts; -}; - -mongoc_index_model_t * -mongoc_index_model_new (const bson_t *keys, const bson_t *opts) -{ - BSON_ASSERT_PARAM (keys); - // `opts` may be NULL. - - mongoc_index_model_t *im = bson_malloc (sizeof (mongoc_index_model_t)); - im->keys = bson_copy (keys); - im->opts = opts ? bson_copy (opts) : NULL; - return im; -} - -void -mongoc_index_model_destroy (mongoc_index_model_t *im) -{ - if (!im) { - return; - } - bson_destroy (im->keys); - bson_destroy (im->opts); - bson_free (im); -} - -bool -mongoc_collection_create_indexes_with_opts (mongoc_collection_t *collection, - mongoc_index_model_t *const *models, - size_t n_models, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (collection); - BSON_ASSERT_PARAM (models); - // `opts` may be NULL. - // `reply` may be NULL. - // `error` may be NULL. - bson_t reply_local = BSON_INITIALIZER; - bson_t *reply_ptr; - mongoc_server_stream_t *server_stream = NULL; - bool ok = false; - bson_t cmd = BSON_INITIALIZER; - - reply_ptr = reply ? reply : &reply_local; - // Always initialize `reply` if set. Caller is expected to `bson_destroy - // (reply)`. - bson_init (reply_ptr); - - // Check for commitQuorum option. - if (opts && bson_has_field (opts, "commitQuorum")) { - server_stream = - mongoc_cluster_stream_for_writes (&collection->client->cluster, - NULL /* mongoc_client_session_t */, - NULL /* deprioritized servers */, - reply_ptr, - error); - if (server_stream->sd->max_wire_version < WIRE_VERSION_4_4) { - // Raise an error required by the specification: - // "Drivers MUST manually raise an error if this option is specified - // when creating an index on a pre 4.4 server." - bson_set_error ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "The selected server does not support the commitQuorum option"); - GOTO (fail); - } - } - - // Build the createIndexes command. - BSON_ASSERT ( - BSON_APPEND_UTF8 (&cmd, "createIndexes", collection->collection)); - bson_array_builder_t *indexes; - BSON_ASSERT (BSON_APPEND_ARRAY_BUILDER_BEGIN (&cmd, "indexes", &indexes)); - for (uint32_t idx = 0; idx < n_models; idx++) { - /* - Append a document of this form: - : { - key: { - , - , - ... - }, - name: , - , - , - ... - }, - */ - - bson_t index; - BSON_ASSERT (bson_array_builder_append_document_begin (indexes, &index)); - BSON_ASSERT (BSON_APPEND_DOCUMENT (&index, "key", models[idx]->keys)); - bson_iter_t name_iter; - if (models[idx]->opts && - bson_iter_init_find (&name_iter, models[idx]->opts, "name")) { - // `name` was specified as an index option. - } else { - // No `name` was specified. Create index `name` from keys. - char *name = - mongoc_collection_keys_to_index_string (models[idx]->keys); - BSON_ASSERT (name); - BSON_ASSERT (BSON_APPEND_UTF8 (&index, "name", name)); - bson_free (name); - } - - if (models[idx]->opts) { - BSON_ASSERT (bson_concat (&index, models[idx]->opts)); - } - BSON_ASSERT (bson_array_builder_append_document_end (indexes, &index)); - } - BSON_ASSERT (bson_append_array_builder_end (&cmd, indexes)); - - ok = mongoc_client_command_with_opts (collection->client, - collection->db, - &cmd, - NULL /* read_prefs */, - opts, - reply_ptr, - error); - -fail: - mongoc_server_stream_cleanup (server_stream); - bson_destroy (&cmd); - bson_destroy (&reply_local); - return ok; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-collection.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-collection.h deleted file mode 100644 index 89ff3e40e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-collection.h +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright 2013-2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_COLLECTION_H -#define MONGOC_COLLECTION_H - -#include - -#include "mongoc-change-stream.h" -#include "mongoc-macros.h" -#include "mongoc-bulk-operation.h" -#include "mongoc-flags.h" -#include "mongoc-cursor.h" -#include "mongoc-index.h" -#include "mongoc-read-prefs.h" -#include "mongoc-read-concern.h" -#include "mongoc-write-concern.h" -#include "mongoc-find-and-modify.h" - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_collection_t mongoc_collection_t; - -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_collection_aggregate (mongoc_collection_t *collection, - mongoc_query_flags_t flags, - const bson_t *pipeline, - const bson_t *opts, - const mongoc_read_prefs_t *read_prefs) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_collection_destroy (mongoc_collection_t *collection); -MONGOC_EXPORT (mongoc_collection_t *) -mongoc_collection_copy (mongoc_collection_t *collection) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_collection_command (mongoc_collection_t *collection, - mongoc_query_flags_t flags, - uint32_t skip, - uint32_t limit, - uint32_t batch_size, - const bson_t *command, - const bson_t *fields, - const mongoc_read_prefs_t *read_prefs) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (bool) -mongoc_collection_read_command_with_opts (mongoc_collection_t *collection, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_write_command_with_opts (mongoc_collection_t *collection, - const bson_t *command, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_read_write_command_with_opts ( - mongoc_collection_t *collection, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs /* IGNORED */, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_command_with_opts (mongoc_collection_t *collection, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_command_simple (mongoc_collection_t *collection, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (int64_t) -mongoc_collection_count (mongoc_collection_t *collection, - mongoc_query_flags_t flags, - const bson_t *query, - int64_t skip, - int64_t limit, - const mongoc_read_prefs_t *read_prefs, - bson_error_t *error) - BSON_GNUC_DEPRECATED_FOR (mongoc_collection_count_documents or - mongoc_collection_estimated_document_count); -MONGOC_EXPORT (int64_t) -mongoc_collection_count_with_opts (mongoc_collection_t *collection, - mongoc_query_flags_t flags, - const bson_t *query, - int64_t skip, - int64_t limit, - const bson_t *opts, - const mongoc_read_prefs_t *read_prefs, - bson_error_t *error) - BSON_GNUC_DEPRECATED_FOR (mongoc_collection_count_documents or - mongoc_collection_estimated_document_count); -MONGOC_EXPORT (bool) -mongoc_collection_drop (mongoc_collection_t *collection, bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_drop_with_opts (mongoc_collection_t *collection, - const bson_t *opts, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_drop_index (mongoc_collection_t *collection, - const char *index_name, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_drop_index_with_opts (mongoc_collection_t *collection, - const char *index_name, - const bson_t *opts, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_create_index (mongoc_collection_t *collection, - const bson_t *keys, - const mongoc_index_opt_t *opt, - bson_error_t *error) BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (bool) -mongoc_collection_create_index_with_opts (mongoc_collection_t *collection, - const bson_t *keys, - const mongoc_index_opt_t *opt, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) - BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (bool) -mongoc_collection_ensure_index (mongoc_collection_t *collection, - const bson_t *keys, - const mongoc_index_opt_t *opt, - bson_error_t *error) BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_collection_find_indexes (mongoc_collection_t *collection, - bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT - BSON_GNUC_DEPRECATED_FOR (mongoc_collection_find_indexes_with_opts); -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_collection_find_indexes_with_opts (mongoc_collection_t *collection, - const bson_t *opts) - BSON_GNUC_WARN_UNUSED_RESULT; - -typedef struct _mongoc_index_model_t mongoc_index_model_t; - -MONGOC_EXPORT (mongoc_index_model_t *) -mongoc_index_model_new (const bson_t *keys, const bson_t *opts); - -MONGOC_EXPORT (void) mongoc_index_model_destroy (mongoc_index_model_t *model); - -MONGOC_EXPORT (bool) -mongoc_collection_create_indexes_with_opts (mongoc_collection_t *collection, - mongoc_index_model_t *const *models, - size_t n_models, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); - - -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_collection_find (mongoc_collection_t *collection, - mongoc_query_flags_t flags, - uint32_t skip, - uint32_t limit, - uint32_t batch_size, - const bson_t *query, - const bson_t *fields, - const mongoc_read_prefs_t *read_prefs) - BSON_GNUC_DEPRECATED_FOR (mongoc_collection_find_with_opts) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_collection_find_with_opts (mongoc_collection_t *collection, - const bson_t *filter, - const bson_t *opts, - const mongoc_read_prefs_t *read_prefs) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (bool) -mongoc_collection_insert (mongoc_collection_t *collection, - mongoc_insert_flags_t flags, - const bson_t *document, - const mongoc_write_concern_t *write_concern, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_insert_one (mongoc_collection_t *collection, - const bson_t *document, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_insert_many (mongoc_collection_t *collection, - const bson_t **documents, - size_t n_documents, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_insert_bulk (mongoc_collection_t *collection, - mongoc_insert_flags_t flags, - const bson_t **documents, - uint32_t n_documents, - const mongoc_write_concern_t *write_concern, - bson_error_t *error) - BSON_GNUC_DEPRECATED_FOR (mongoc_collection_insert_many); -MONGOC_EXPORT (bool) -mongoc_collection_update (mongoc_collection_t *collection, - mongoc_update_flags_t flags, - const bson_t *selector, - const bson_t *update, - const mongoc_write_concern_t *write_concern, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_update_one (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *update, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_update_many (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *update, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_replace_one (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *replacement, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_delete (mongoc_collection_t *collection, - mongoc_delete_flags_t flags, - const bson_t *selector, - const mongoc_write_concern_t *write_concern, - bson_error_t *error) - BSON_GNUC_DEPRECATED_FOR (mongoc_collection_delete_one or - mongoc_collection_delete_many); -MONGOC_EXPORT (bool) -mongoc_collection_save (mongoc_collection_t *collection, - const bson_t *document, - const mongoc_write_concern_t *write_concern, - bson_error_t *error) - BSON_GNUC_DEPRECATED_FOR (mongoc_collection_insert_one or - mongoc_collection_replace_one); -MONGOC_EXPORT (bool) -mongoc_collection_remove (mongoc_collection_t *collection, - mongoc_remove_flags_t flags, - const bson_t *selector, - const mongoc_write_concern_t *write_concern, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_delete_one (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_delete_many (mongoc_collection_t *collection, - const bson_t *selector, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_rename (mongoc_collection_t *collection, - const char *new_db, - const char *new_name, - bool drop_target_before_rename, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_rename_with_opts (mongoc_collection_t *collection, - const char *new_db, - const char *new_name, - bool drop_target_before_rename, - const bson_t *opts, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_find_and_modify_with_opts ( - mongoc_collection_t *collection, - const bson_t *query, - const mongoc_find_and_modify_opts_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_find_and_modify (mongoc_collection_t *collection, - const bson_t *query, - const bson_t *sort, - const bson_t *update, - const bson_t *fields, - bool _remove, - bool upsert, - bool _new, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_collection_stats (mongoc_collection_t *collection, - const bson_t *options, - bson_t *reply, - bson_error_t *error) BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (mongoc_bulk_operation_t *) -mongoc_collection_create_bulk_operation ( - mongoc_collection_t *collection, - bool ordered, - const mongoc_write_concern_t *write_concern) BSON_GNUC_WARN_UNUSED_RESULT - BSON_GNUC_DEPRECATED_FOR (mongoc_collection_create_bulk_operation_with_opts); -MONGOC_EXPORT (mongoc_bulk_operation_t *) -mongoc_collection_create_bulk_operation_with_opts ( - mongoc_collection_t *collection, - const bson_t *opts) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (const mongoc_read_prefs_t *) -mongoc_collection_get_read_prefs (const mongoc_collection_t *collection); -MONGOC_EXPORT (void) -mongoc_collection_set_read_prefs (mongoc_collection_t *collection, - const mongoc_read_prefs_t *read_prefs); -MONGOC_EXPORT (const mongoc_read_concern_t *) -mongoc_collection_get_read_concern (const mongoc_collection_t *collection); -MONGOC_EXPORT (void) -mongoc_collection_set_read_concern (mongoc_collection_t *collection, - const mongoc_read_concern_t *read_concern); -MONGOC_EXPORT (const mongoc_write_concern_t *) -mongoc_collection_get_write_concern (const mongoc_collection_t *collection); -MONGOC_EXPORT (void) -mongoc_collection_set_write_concern ( - mongoc_collection_t *collection, - const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (const char *) -mongoc_collection_get_name (mongoc_collection_t *collection); -MONGOC_EXPORT (const bson_t *) -mongoc_collection_get_last_error (const mongoc_collection_t *collection) - BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (char *) -mongoc_collection_keys_to_index_string (const bson_t *keys) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (bool) -mongoc_collection_validate (mongoc_collection_t *collection, - const bson_t *options, - bson_t *reply, - bson_error_t *error) BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (mongoc_change_stream_t *) -mongoc_collection_watch (const mongoc_collection_t *coll, - const bson_t *pipeline, - const bson_t *opts) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (int64_t) -mongoc_collection_count_documents (mongoc_collection_t *coll, - const bson_t *filter, - const bson_t *opts, - const mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (int64_t) -mongoc_collection_estimated_document_count ( - mongoc_collection_t *coll, - const bson_t *opts, - const mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error); - -BSON_END_DECLS - - -#endif /* MONGOC_COLLECTION_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-compression.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-compression.c deleted file mode 100644 index f1a50b7ed..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-compression.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright 2017 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-config.h" - -#include "mongoc-compression-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-util-private.h" - -#ifdef MONGOC_ENABLE_COMPRESSION -#ifdef MONGOC_ENABLE_COMPRESSION_ZLIB -#include -#endif -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY -#include -#endif -#ifdef MONGOC_ENABLE_COMPRESSION_ZSTD -#include -#endif -#endif - -size_t -mongoc_compressor_max_compressed_length (int32_t compressor_id, size_t len) -{ - TRACE ("Getting compression length for '%s' (%d)", - mongoc_compressor_id_to_name (compressor_id), - compressor_id); - switch (compressor_id) { -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY - case MONGOC_COMPRESSOR_SNAPPY_ID: - return snappy_max_compressed_length (len); - break; -#endif - -#ifdef MONGOC_ENABLE_COMPRESSION_ZLIB - case MONGOC_COMPRESSOR_ZLIB_ID: - BSON_ASSERT (bson_in_range_unsigned (unsigned_long, len)); - return compressBound ((unsigned long) len); - break; -#endif - -#ifdef MONGOC_ENABLE_COMPRESSION_ZSTD - case MONGOC_COMPRESSOR_ZSTD_ID: - return ZSTD_compressBound (len); - break; -#endif - case MONGOC_COMPRESSOR_NOOP_ID: - return len; - break; - default: - return 0; - } -} - -bool -mongoc_compressor_supported (const char *compressor) -{ -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY - if (!strcasecmp (compressor, MONGOC_COMPRESSOR_SNAPPY_STR)) { - return true; - } -#endif - -#ifdef MONGOC_ENABLE_COMPRESSION_ZLIB - if (!strcasecmp (compressor, MONGOC_COMPRESSOR_ZLIB_STR)) { - return true; - } -#endif - -#ifdef MONGOC_ENABLE_COMPRESSION_ZSTD - if (!strcasecmp (compressor, MONGOC_COMPRESSOR_ZSTD_STR)) { - return true; - } -#endif - - if (!strcasecmp (compressor, MONGOC_COMPRESSOR_NOOP_STR)) { - return true; - } - - return false; -} - -const char * -mongoc_compressor_id_to_name (int32_t compressor_id) -{ - switch (compressor_id) { - case MONGOC_COMPRESSOR_SNAPPY_ID: - return MONGOC_COMPRESSOR_SNAPPY_STR; - - case MONGOC_COMPRESSOR_ZLIB_ID: - return MONGOC_COMPRESSOR_ZLIB_STR; - - case MONGOC_COMPRESSOR_ZSTD_ID: - return MONGOC_COMPRESSOR_ZSTD_STR; - - case MONGOC_COMPRESSOR_NOOP_ID: - return MONGOC_COMPRESSOR_NOOP_STR; - - default: - return "unknown"; - } -} - -int -mongoc_compressor_name_to_id (const char *compressor) -{ -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY - if (strcasecmp (MONGOC_COMPRESSOR_SNAPPY_STR, compressor) == 0) { - return MONGOC_COMPRESSOR_SNAPPY_ID; - } -#endif - -#ifdef MONGOC_ENABLE_COMPRESSION_ZLIB - if (strcasecmp (MONGOC_COMPRESSOR_ZLIB_STR, compressor) == 0) { - return MONGOC_COMPRESSOR_ZLIB_ID; - } -#endif - -#ifdef MONGOC_ENABLE_COMPRESSION_ZSTD - if (strcasecmp (MONGOC_COMPRESSOR_ZSTD_STR, compressor) == 0) { - return MONGOC_COMPRESSOR_ZSTD_ID; - } -#endif - - if (strcasecmp (MONGOC_COMPRESSOR_NOOP_STR, compressor) == 0) { - return MONGOC_COMPRESSOR_NOOP_ID; - } - - return -1; -} - -bool -mongoc_uncompress (int32_t compressor_id, - const uint8_t *compressed, - size_t compressed_len, - uint8_t *uncompressed, - size_t *uncompressed_len) -{ - TRACE ("Uncompressing with '%s' (%d)", - mongoc_compressor_id_to_name (compressor_id), - compressor_id); - - switch (compressor_id) { - case MONGOC_COMPRESSOR_SNAPPY_ID: { -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY - snappy_status status; - status = snappy_uncompress ((const char *) compressed, - compressed_len, - (char *) uncompressed, - uncompressed_len); - - return status == SNAPPY_OK; -#else - MONGOC_WARNING ("Received snappy compressed opcode, but snappy " - "compression is not compiled in"); - return false; -#endif - break; - } - - case MONGOC_COMPRESSOR_ZLIB_ID: { -#ifdef MONGOC_ENABLE_COMPRESSION_ZLIB - BSON_ASSERT (bson_in_range_unsigned (unsigned_long, compressed_len)); - const int ok = uncompress (uncompressed, - (unsigned long *) uncompressed_len, - compressed, - (unsigned long) compressed_len); - - return ok == Z_OK; -#else - MONGOC_WARNING ("Received zlib compressed opcode, but zlib " - "compression is not compiled in"); - return false; -#endif - break; - } - - case MONGOC_COMPRESSOR_ZSTD_ID: { -#ifdef MONGOC_ENABLE_COMPRESSION_ZSTD - int ok; - - ok = ZSTD_decompress ((void *) uncompressed, - *uncompressed_len, - (const void *) compressed, - compressed_len); - - if (!ZSTD_isError (ok)) { - *uncompressed_len = ok; - } - - return !ZSTD_isError (ok); -#else - MONGOC_WARNING ("Received zstd compressed opcode, but zstd " - "compression is not compiled in"); - return false; -#endif - break; - } - case MONGOC_COMPRESSOR_NOOP_ID: - memcpy (uncompressed, compressed, compressed_len); - *uncompressed_len = compressed_len; - return true; - - default: - MONGOC_WARNING ("Unknown compressor ID %d", compressor_id); - } - - return false; -} - -bool -mongoc_compress (int32_t compressor_id, - int32_t compression_level, - char *uncompressed, - size_t uncompressed_len, - char *compressed, - size_t *compressed_len) -{ - TRACE ("Compressing with '%s' (%d)", - mongoc_compressor_id_to_name (compressor_id), - compressor_id); - switch (compressor_id) { - case MONGOC_COMPRESSOR_SNAPPY_ID: -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY - /* No compression_level option for snappy */ - return snappy_compress ( - uncompressed, uncompressed_len, compressed, compressed_len) == - SNAPPY_OK; -#else - MONGOC_ERROR ("Client attempting to use compress with snappy, but snappy " - "compression is not compiled in"); - return false; -#endif - - case MONGOC_COMPRESSOR_ZLIB_ID: -#ifdef MONGOC_ENABLE_COMPRESSION_ZLIB - BSON_ASSERT (bson_in_range_unsigned (unsigned_long, uncompressed_len)); - return compress2 ((unsigned char *) compressed, - (unsigned long *) compressed_len, - (unsigned char *) uncompressed, - (unsigned long) uncompressed_len, - compression_level) == Z_OK; -#else - MONGOC_ERROR ("Client attempting to use compress with zlib, but zlib " - "compression is not compiled in"); - return false; -#endif - - case MONGOC_COMPRESSOR_ZSTD_ID: { -#ifdef MONGOC_ENABLE_COMPRESSION_ZSTD - int ok; - - ok = ZSTD_compress ((void *) compressed, - *compressed_len, - (const void *) uncompressed, - uncompressed_len, - 0); - - if (!ZSTD_isError (ok)) { - *compressed_len = ok; - } - return !ZSTD_isError (ok); -#else - MONGOC_ERROR ("Client attempting to use compress with zstd, but zstd " - "compression is not compiled in"); - return false; -#endif - } - case MONGOC_COMPRESSOR_NOOP_ID: - memcpy (compressed, uncompressed, uncompressed_len); - *compressed_len = uncompressed_len; - return true; - - default: - return false; - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-counters-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-counters-private.h deleted file mode 100644 index 736a56ca3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-counters-private.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_COUNTERS_PRIVATE_H -#define MONGOC_COUNTERS_PRIVATE_H - -#include - -#include "mongoc.h" - -#ifdef __linux__ -#include -#include -#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ - defined(__OpenBSD__) -#include -#include -#include -#include -#elif defined(__hpux__) -#include -#endif - - -BSON_BEGIN_DECLS - - -void -_mongoc_counters_init (void); -void -_mongoc_counters_cleanup (void); - - -static BSON_INLINE unsigned -_mongoc_get_cpu_count (void) -{ -#if defined(__linux__) && defined(_SC_NPROCESSORS_CONF) - long count = sysconf (_SC_NPROCESSORS_CONF); - if (count < 1) { - return 1; - } - return count; -#elif defined(__hpux__) - struct pst_dynamic psd; - - if (pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1) { - return psd.psd_max_proc_cnt; - } - return 1; -#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ - defined(__OpenBSD__) - int mib[2]; - int maxproc; - size_t len; - - mib[0] = CTL_HW; - mib[1] = HW_NCPU; - len = sizeof (maxproc); - - if (-1 == sysctl (mib, 2, &maxproc, &len, NULL, 0)) { - return 1; - } - - return len; -#elif defined(__APPLE__) || defined(__sun) || defined(_AIX) - int ncpu; - - ncpu = (int) sysconf (_SC_NPROCESSORS_ONLN); - return (ncpu > 0) ? ncpu : 1; -#elif defined(_MSC_VER) || defined(_WIN32) - SYSTEM_INFO si; - GetSystemInfo (&si); - return si.dwNumberOfProcessors; -#else -#warning "_mongoc_get_cpu_count() not supported, defaulting to 1." - return 1; -#endif -} - - -#if defined(MONGOC_ENABLE_RDTSCP) -static BSON_INLINE unsigned -_mongoc_sched_getcpu (void) -{ - volatile uint32_t rax, rdx, rcx; - __asm__ volatile ("rdtscp\n" : "=a"(rax), "=d"(rdx), "=c"(rcx) : :); - unsigned core_id; - core_id = rcx & 0xFFF; - return core_id; -} -#elif defined(MONGOC_HAVE_SCHED_GETCPU) -#define _mongoc_sched_getcpu sched_getcpu -#elif defined(__APPLE__) && defined(__aarch64__) -static BSON_INLINE unsigned -_mongoc_sched_getcpu (void) -{ - uintptr_t tls; - unsigned core_id; - /* Get the current thread ID, not the core ID. - * Getting the core ID requires privileged execution. */ - __asm__ volatile ("mrs %x0, tpidrro_el0" : "=r"(tls)); - /* In ARM, only 8 cores are manageable. */ - core_id = tls & 0x07u; - return core_id; -} -#else -#define _mongoc_sched_getcpu() (0) -#endif - - -#ifndef SLOTS_PER_CACHELINE -#define SLOTS_PER_CACHELINE 8 -#endif - - -typedef struct { - int64_t slots[SLOTS_PER_CACHELINE]; -} mongoc_counter_slots_t; - - -typedef struct { - mongoc_counter_slots_t *cpus; -} mongoc_counter_t; - - -#define COUNTER(ident, Category, Name, Description) \ - extern mongoc_counter_t __mongoc_counter_##ident; -#include "mongoc-counters.defs" -#undef COUNTER - - -enum { -#define COUNTER(ident, Category, Name, Description) COUNTER_##ident, -#include "mongoc-counters.defs" -#undef COUNTER - LAST_COUNTER -}; - -#ifdef MONGOC_ENABLE_SHM_COUNTERS -#define COUNTER(ident, Category, Name, Description) \ - static BSON_INLINE void mongoc_counter_##ident##_add (int64_t val) \ - { \ - int64_t *counter = \ - &BSON_CONCAT (__mongoc_counter_, ident) \ - .cpus[_mongoc_sched_getcpu ()] \ - .slots[BSON_CONCAT (COUNTER_, ident) % SLOTS_PER_CACHELINE]; \ - bson_atomic_int64_fetch_add (counter, val, bson_memory_order_seq_cst); \ - } \ - static BSON_INLINE void mongoc_counter_##ident##_inc (void) \ - { \ - mongoc_counter_##ident##_add (1); \ - } \ - static BSON_INLINE void mongoc_counter_##ident##_dec (void) \ - { \ - mongoc_counter_##ident##_add (-1); \ - } \ - static BSON_INLINE void mongoc_counter_##ident##_reset (void) \ - { \ - uint32_t i; \ - for (i = 0; i < _mongoc_get_cpu_count (); i++) { \ - int64_t *counter = &__mongoc_counter_##ident.cpus[i] \ - .slots[COUNTER_##ident % SLOTS_PER_CACHELINE]; \ - bson_atomic_int64_exchange (counter, 0, bson_memory_order_seq_cst); \ - } \ - bson_atomic_thread_fence (); \ - } \ - static BSON_INLINE int32_t mongoc_counter_##ident##_count (void) \ - { \ - int32_t _sum = 0; \ - uint32_t _i; \ - for (_i = 0; _i < _mongoc_get_cpu_count (); _i++) { \ - const int64_t *counter = \ - &BSON_CONCAT (__mongoc_counter_, ident) \ - .cpus[_i] \ - .slots[BSON_CONCAT (COUNTER_, ident) % SLOTS_PER_CACHELINE]; \ - _sum += bson_atomic_int64_fetch (counter, bson_memory_order_seq_cst); \ - } \ - return _sum; \ - } -#include "mongoc-counters.defs" -#undef COUNTER - -#else -/* when counters are disabled, these functions are no-ops */ -#define COUNTER(ident, Category, Name, Description) \ - static BSON_INLINE void mongoc_counter_##ident##_add (int64_t val) \ - { \ - } \ - static BSON_INLINE void mongoc_counter_##ident##_inc (void) \ - { \ - } \ - static BSON_INLINE void mongoc_counter_##ident##_dec (void) \ - { \ - } \ - static BSON_INLINE void mongoc_counter_##ident##_reset (void) \ - { \ - } \ - static BSON_INLINE void mongoc_counter_##ident##_count (void) \ - { \ - } -#include "mongoc-counters.defs" -#undef COUNTER -#endif - -BSON_END_DECLS - - -#endif /* MONGOC_COUNTERS_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypt-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypt-private.h deleted file mode 100644 index b9ac23b17..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypt-private.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2019-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_CRYPT_PRIVATE_H -#define MONGOC_CRYPT_PRIVATE_H - -#include "mongoc-config.h" - -#include "mongoc.h" - -typedef struct mc_kms_credentials_callback { - mongoc_kms_credentials_provider_callback_fn fn; - void *userdata; -} mc_kms_credentials_callback; - -#ifdef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION - -/* For interacting with libmongocrypt */ -typedef struct __mongoc_crypt_t _mongoc_crypt_t; - -/* -Creates a new handle into libmongocrypt. -- schema_map may be NULL. -- may return NULL and set error. -*/ -_mongoc_crypt_t * -_mongoc_crypt_new (const bson_t *kms_providers, - const bson_t *schema_map, - const bson_t *encrypted_fields_map, - const bson_t *tls_opts, - const char *crypt_shared_lib_path, - bool crypt_shared_lib_required, - bool bypass_auto_encryption, - bool bypass_query_analysis, - mc_kms_credentials_callback creds_cb, - bson_error_t *error); - -void -_mongoc_crypt_destroy (_mongoc_crypt_t *crypt); - -/* -Perform auto encryption. -- cmd_out is always initialized. -- may return false and set error. -*/ -bool -_mongoc_crypt_auto_encrypt (_mongoc_crypt_t *crypt, - mongoc_collection_t *key_vault_coll, - mongoc_client_t *mongocryptd_client, - mongoc_client_t *collinfo_client, - const char *db_name, - const bson_t *cmd_in, - bson_t *cmd_out, - bson_error_t *error); - -/* -Perform auto decryption. -- doc_out is always initialized. -- may return false and set error. -*/ -bool -_mongoc_crypt_auto_decrypt (_mongoc_crypt_t *crypt, - mongoc_collection_t *key_vault_coll, - const bson_t *doc_in, - bson_t *doc_out, - bson_error_t *error); - -/* -Perform explicit encryption. -Return false on error and sets `error`. -*/ -bool -_mongoc_crypt_explicit_encrypt ( - _mongoc_crypt_t *crypt, - mongoc_collection_t *key_vault_coll, - const char *algorithm /* may be NULL */, - const bson_value_t *keyid /* may be NULL */, - const char *keyaltname /* may be NULL */, - const char *query_type /* may be NULL */, - const int64_t *contention_factor /* may be NULL */, - const bson_t *range_opts /* may be NULL */, - const bson_value_t *value_in, - bson_value_t *value_out, - bson_error_t *error); - -/* -Perform explicit encryption on an expression. -Return false on error and sets `error`. -*/ -bool -_mongoc_crypt_explicit_encrypt_expression ( - _mongoc_crypt_t *crypt, - mongoc_collection_t *key_vault_coll, - const char *algorithm /* may be NULL */, - const bson_value_t *keyid /* may be NULL */, - const char *keyaltname /* may be NULL */, - const char *query_type /* may be NULL */, - const int64_t *contention_factor /* may be NULL */, - const bson_t *range_opts /* may be NULL */, - const bson_t *expr_in, - bson_t *expr_out, - bson_error_t *error); - -/* -Perform explicit decryption. -- value_out is always initialized. -- may return false and set error. -*/ -bool -_mongoc_crypt_explicit_decrypt (_mongoc_crypt_t *crypt, - mongoc_collection_t *key_vault_coll, - const bson_value_t *value_in, - bson_value_t *value_out, - bson_error_t *error); -/* -Create a data key document (does not insert into key vault). -- keyaltnames may be NULL. -- doc_out is always initialized. -- may return false and set error. -*/ -bool -_mongoc_crypt_create_datakey (_mongoc_crypt_t *crypt, - const char *kms_provider, - const bson_t *masterkey, - char **keyaltnames, - uint32_t keyaltnames_count, - const uint8_t *keymaterial, - uint32_t keymaterial_len, - bson_t *doc_out, - bson_error_t *error); - -/* -Rewrap datakeys in keyvault_coll matching the given filter with a new KMS -provider (does not bulk-update into key vault). -- filter may be NULL (equivalent to an empty document). -- kms_provider may be NULL. -- masterkey may be NULL if kms_provider is NULL. -- doc_out is always initialized. -- may return false and set error. -*/ -bool -_mongoc_crypt_rewrap_many_datakey (_mongoc_crypt_t *crypt, - mongoc_collection_t *keyvault_coll, - const bson_t *filter, - const char *provider, - const bson_t *master_key, - bson_t *doc_out, - bson_error_t *error); - -const char * -_mongoc_crypt_get_crypt_shared_version (const _mongoc_crypt_t *crypt); - -#endif /* MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION */ -#endif /* MONGOC_CRYPT_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypt.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypt.c deleted file mode 100644 index 847a75cf0..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypt.c +++ /dev/null @@ -1,2195 +0,0 @@ -/* - * Copyright 2019-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define MONGOC_LOG_DOMAIN "client-side-encryption" - -#include "mongoc-crypt-private.h" - -#ifdef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION - -#include - -#include "mongoc-client-private.h" -#include "mongoc-collection-private.h" -#include "mongoc-host-list-private.h" -#include "mongoc-stream-private.h" -#include "mongoc-ssl-private.h" -#include "mongoc-cluster-aws-private.h" -#include "mongoc-util-private.h" -#include "mongoc-http-private.h" -#include "mcd-azure.h" -#include "mcd-time.h" -#include "service-gcp.h" - -// `mcd_mapof_kmsid_to_tlsopts` maps a KMS ID (e.g. `aws` or `aws:myname`) to a -// `mongoc_ssl_opt_t`. The acryonym TLS is preferred over SSL for -// consistency with the CSE and URI specifications. -typedef struct { - mongoc_array_t entries; -} mcd_mapof_kmsid_to_tlsopts; - -typedef struct { - char *kmsid; - mongoc_ssl_opt_t tlsopts; -} mcd_mapof_kmsid_to_tlsopts_entry; - -mcd_mapof_kmsid_to_tlsopts * -mcd_mapof_kmsid_to_tlsopts_new (void) -{ - mcd_mapof_kmsid_to_tlsopts *k2t = - bson_malloc0 (sizeof (mcd_mapof_kmsid_to_tlsopts)); - _mongoc_array_init (&k2t->entries, - sizeof (mcd_mapof_kmsid_to_tlsopts_entry)); - return k2t; -} - -void -mcd_mapof_kmsid_to_tlsopts_destroy (mcd_mapof_kmsid_to_tlsopts *k2t) -{ - if (!k2t) { - return; - } - for (size_t i = 0; i < k2t->entries.len; i++) { - mcd_mapof_kmsid_to_tlsopts_entry *e = &_mongoc_array_index ( - &k2t->entries, mcd_mapof_kmsid_to_tlsopts_entry, i); - bson_free (e->kmsid); - _mongoc_ssl_opts_cleanup (&e->tlsopts, true /* free_internal */); - } - _mongoc_array_destroy (&k2t->entries); - bson_free (k2t); -} - -// `mcd_mapof_kmsid_to_tlsopts_insert` adds an entry into the map. -// `kmsid` and `tlsopts` are copied. -// No checking is done to prohibit duplicate entries. -void -mcd_mapof_kmsid_to_tlsopts_insert (mcd_mapof_kmsid_to_tlsopts *k2t, - const char *kmsid, - const mongoc_ssl_opt_t *tlsopts) -{ - BSON_ASSERT_PARAM (k2t); - BSON_ASSERT_PARAM (kmsid); - BSON_ASSERT_PARAM (tlsopts); - - mcd_mapof_kmsid_to_tlsopts_entry e = {.kmsid = bson_strdup (kmsid)}; - _mongoc_ssl_opts_copy_to (tlsopts, &e.tlsopts, true /* copy_internal */); - _mongoc_array_append_val (&k2t->entries, e); -} - -// `mcd_mapof_kmsid_to_tlsopts_get` returns the TLS options for a KMS ID, or -// NULL. -const mongoc_ssl_opt_t * -mcd_mapof_kmsid_to_tlsopts_get (const mcd_mapof_kmsid_to_tlsopts *k2t, - const char *kmsid) -{ - BSON_ASSERT_PARAM (k2t); - BSON_ASSERT_PARAM (kmsid); - - for (size_t i = 0; i < k2t->entries.len; i++) { - mcd_mapof_kmsid_to_tlsopts_entry *e = &_mongoc_array_index ( - &k2t->entries, mcd_mapof_kmsid_to_tlsopts_entry, i); - if (0 == strcmp (e->kmsid, kmsid)) { - return &e->tlsopts; - } - } - return NULL; -} - - -bool -mcd_mapof_kmsid_to_tlsopts_has (const mcd_mapof_kmsid_to_tlsopts *k2t, - const char *kmsid) -{ - return NULL != mcd_mapof_kmsid_to_tlsopts_get (k2t, kmsid); -} - -struct __mongoc_crypt_t { - mongocrypt_t *handle; - mongoc_ssl_opt_t kmip_tls_opt; - mongoc_ssl_opt_t aws_tls_opt; - mongoc_ssl_opt_t azure_tls_opt; - mongoc_ssl_opt_t gcp_tls_opt; - mcd_mapof_kmsid_to_tlsopts *kmsid_to_tlsopts; - - /// The kmsProviders that were provided by the user when encryption was - /// initiated. We need to remember this in case we need to load on-demand - /// credentials. - bson_t kms_providers; - mc_kms_credentials_callback creds_cb; - - /// The most recently auto-acquired Azure token, on null if it was destroyed - /// or not yet acquired. - mcd_azure_access_token azure_token; - /// The time point at which the `azure_token` was acquired. - mcd_time_point azure_token_issued_at; -}; - -static void -_log_callback (mongocrypt_log_level_t mongocrypt_log_level, - const char *message, - uint32_t message_len, - void *ctx) -{ - mongoc_log_level_t log_level = MONGOC_LOG_LEVEL_ERROR; - - BSON_UNUSED (message_len); - BSON_UNUSED (ctx); - - switch (mongocrypt_log_level) { - case MONGOCRYPT_LOG_LEVEL_FATAL: - log_level = MONGOC_LOG_LEVEL_CRITICAL; - break; - case MONGOCRYPT_LOG_LEVEL_ERROR: - log_level = MONGOC_LOG_LEVEL_ERROR; - break; - case MONGOCRYPT_LOG_LEVEL_WARNING: - log_level = MONGOC_LOG_LEVEL_WARNING; - break; - case MONGOCRYPT_LOG_LEVEL_INFO: - log_level = MONGOC_LOG_LEVEL_INFO; - break; - case MONGOCRYPT_LOG_LEVEL_TRACE: - log_level = MONGOC_LOG_LEVEL_TRACE; - break; - default: - log_level = MONGOC_LOG_LEVEL_CRITICAL; - break; - } - - mongoc_log (log_level, MONGOC_LOG_DOMAIN, "%s", message); -} - -static void -_prefix_mongocryptd_error (bson_error_t *error) -{ - char buf[sizeof (error->message)]; - - bson_snprintf (buf, sizeof (buf), "mongocryptd error: %s:", error->message); - memcpy (error->message, buf, sizeof (buf)); -} - -static void -_prefix_keyvault_error (bson_error_t *error) -{ - char buf[sizeof (error->message)]; - - bson_snprintf (buf, sizeof (buf), "key vault error: %s:", error->message); - memcpy (error->message, buf, sizeof (buf)); -} - -static void -_status_to_error (mongocrypt_status_t *status, bson_error_t *error) -{ - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - mongocrypt_status_code (status), - "%s", - mongocrypt_status_message (status, NULL)); -} - -/* Checks for an error on mongocrypt context. - * If error_expected, then we expect mongocrypt_ctx_status to report a failure - * status (due to a previous failed function call). If it did not, return a - * generic error. - * Returns true if ok, and does not modify @error. - * Returns false if error, and sets @error. - */ -bool -_ctx_check_error (mongocrypt_ctx_t *ctx, - bson_error_t *error, - bool error_expected) -{ - mongocrypt_status_t *status; - - status = mongocrypt_status_new (); - if (!mongocrypt_ctx_status (ctx, status)) { - _status_to_error (status, error); - mongocrypt_status_destroy (status); - return false; - } else if (error_expected) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "generic error from libmongocrypt operation"); - mongocrypt_status_destroy (status); - return false; - } - mongocrypt_status_destroy (status); - return true; -} - -bool -_kms_ctx_check_error (mongocrypt_kms_ctx_t *kms_ctx, - bson_error_t *error, - bool error_expected) -{ - mongocrypt_status_t *status; - - status = mongocrypt_status_new (); - if (!mongocrypt_kms_ctx_status (kms_ctx, status)) { - _status_to_error (status, error); - mongocrypt_status_destroy (status); - return false; - } else if (error_expected) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "generic error from libmongocrypt KMS operation"); - mongocrypt_status_destroy (status); - return false; - } - mongocrypt_status_destroy (status); - return true; -} - -bool -_crypt_check_error (mongocrypt_t *crypt, - bson_error_t *error, - bool error_expected) -{ - mongocrypt_status_t *status; - - status = mongocrypt_status_new (); - if (!mongocrypt_status (crypt, status)) { - _status_to_error (status, error); - mongocrypt_status_destroy (status); - return false; - } else if (error_expected) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "generic error from libmongocrypt handle"); - mongocrypt_status_destroy (status); - return false; - } - mongocrypt_status_destroy (status); - return true; -} - -/* Convert a mongocrypt_binary_t to a static bson_t */ -static bool -_bin_to_static_bson (mongocrypt_binary_t *bin, bson_t *out, bson_error_t *error) -{ - /* Copy bin into bson_t result. */ - if (!bson_init_static ( - out, mongocrypt_binary_data (bin), mongocrypt_binary_len (bin))) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "invalid returned bson"); - return false; - } - return true; -} - - -typedef struct { - mongocrypt_ctx_t *ctx; - mongoc_collection_t *keyvault_coll; - mongoc_client_t *mongocryptd_client; - mongoc_client_t *collinfo_client; - const char *db_name; - _mongoc_crypt_t *crypt; -} _state_machine_t; - -_state_machine_t * -_state_machine_new (_mongoc_crypt_t *crypt) -{ - _state_machine_t *sm = bson_malloc0 (sizeof (_state_machine_t)); - sm->crypt = crypt; - return sm; -} - -void -_state_machine_destroy (_state_machine_t *state_machine) -{ - if (!state_machine) { - return; - } - mongocrypt_ctx_destroy (state_machine->ctx); - bson_free (state_machine); -} - -/* State handler MONGOCRYPT_CTX_NEED_MONGO_COLLINFO */ -static bool -_state_need_mongo_collinfo (_state_machine_t *state_machine, - bson_error_t *error) -{ - mongoc_database_t *db = NULL; - mongoc_cursor_t *cursor = NULL; - bson_t filter_bson; - const bson_t *collinfo_bson = NULL; - bson_t opts = BSON_INITIALIZER; - mongocrypt_binary_t *filter_bin = NULL; - mongocrypt_binary_t *collinfo_bin = NULL; - bool ret = false; - - /* 1. Run listCollections on the encrypted MongoClient with the filter - * provided by mongocrypt_ctx_mongo_op */ - filter_bin = mongocrypt_binary_new (); - if (!mongocrypt_ctx_mongo_op (state_machine->ctx, filter_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - if (!_bin_to_static_bson (filter_bin, &filter_bson, error)) { - goto fail; - } - - bson_append_document (&opts, "filter", -1, &filter_bson); - db = mongoc_client_get_database (state_machine->collinfo_client, - state_machine->db_name); - cursor = mongoc_database_find_collections_with_opts (db, &opts); - if (mongoc_cursor_error (cursor, error)) { - goto fail; - } - - /* 2. Return the first result (if any) with mongocrypt_ctx_mongo_feed or - * proceed to the next step if nothing was returned. */ - if (mongoc_cursor_next (cursor, &collinfo_bson)) { - collinfo_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (collinfo_bson), collinfo_bson->len); - if (!mongocrypt_ctx_mongo_feed (state_machine->ctx, collinfo_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - } else if (mongoc_cursor_error (cursor, error)) { - goto fail; - } - - /* 3. Call mongocrypt_ctx_mongo_done */ - if (!mongocrypt_ctx_mongo_done (state_machine->ctx)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - ret = true; - -fail: - - bson_destroy (&opts); - mongocrypt_binary_destroy (filter_bin); - mongocrypt_binary_destroy (collinfo_bin); - mongoc_cursor_destroy (cursor); - mongoc_database_destroy (db); - return ret; -} - -static bool -_state_need_mongo_markings (_state_machine_t *state_machine, - bson_error_t *error) -{ - bool ret = false; - mongocrypt_binary_t *mongocryptd_cmd_bin = NULL; - mongocrypt_binary_t *mongocryptd_reply_bin = NULL; - bson_t mongocryptd_cmd_bson; - bson_t reply = BSON_INITIALIZER; - - mongocryptd_cmd_bin = mongocrypt_binary_new (); - - if (!mongocrypt_ctx_mongo_op (state_machine->ctx, mongocryptd_cmd_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - if (!_bin_to_static_bson ( - mongocryptd_cmd_bin, &mongocryptd_cmd_bson, error)) { - goto fail; - } - - /* 1. Use db.runCommand to run the command provided by - * mongocrypt_ctx_mongo_op on the MongoClient connected to mongocryptd. */ - bson_destroy (&reply); - if (!mongoc_client_command_simple (state_machine->mongocryptd_client, - state_machine->db_name, - &mongocryptd_cmd_bson, - NULL /* read_prefs */, - &reply, - error)) { - _prefix_mongocryptd_error (error); - goto fail; - } - - /* 2. Feed the reply back with mongocrypt_ctx_mongo_feed. */ - mongocryptd_reply_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (&reply), reply.len); - if (!mongocrypt_ctx_mongo_feed (state_machine->ctx, mongocryptd_reply_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - /* 3. Call mongocrypt_ctx_mongo_done. */ - if (!mongocrypt_ctx_mongo_done (state_machine->ctx)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - ret = true; -fail: - bson_destroy (&reply); - mongocrypt_binary_destroy (mongocryptd_cmd_bin); - mongocrypt_binary_destroy (mongocryptd_reply_bin); - return ret; -} - -static bool -_state_need_mongo_keys (_state_machine_t *state_machine, bson_error_t *error) -{ - bool ret = false; - mongocrypt_binary_t *filter_bin = NULL; - bson_t filter_bson; - bson_t opts = BSON_INITIALIZER; - mongocrypt_binary_t *key_bin = NULL; - const bson_t *key_bson; - mongoc_cursor_t *cursor = NULL; - - /* 1. Use MongoCollection.find on the MongoClient connected to the key vault - * client (which may be the same as the encrypted client). Use the filter - * provided by mongocrypt_ctx_mongo_op. */ - filter_bin = mongocrypt_binary_new (); - if (!mongocrypt_ctx_mongo_op (state_machine->ctx, filter_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - if (!_bin_to_static_bson (filter_bin, &filter_bson, error)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - { - const mongoc_read_concern_t *const rc = - mongoc_collection_get_read_concern (state_machine->keyvault_coll); - const char *const level = rc ? mongoc_read_concern_get_level (rc) : NULL; - BSON_ASSERT (level && - strcmp (level, MONGOC_READ_CONCERN_LEVEL_MAJORITY) == 0); - } - - cursor = mongoc_collection_find_with_opts ( - state_machine->keyvault_coll, &filter_bson, &opts, NULL /* read prefs */); - /* 2. Feed all resulting documents back (if any) with repeated calls to - * mongocrypt_ctx_mongo_feed. */ - while (mongoc_cursor_next (cursor, &key_bson)) { - mongocrypt_binary_destroy (key_bin); - key_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (key_bson), key_bson->len); - if (!mongocrypt_ctx_mongo_feed (state_machine->ctx, key_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - } - if (mongoc_cursor_error (cursor, error)) { - _prefix_keyvault_error (error); - goto fail; - } - - /* 3. Call mongocrypt_ctx_mongo_done. */ - if (!mongocrypt_ctx_mongo_done (state_machine->ctx)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - ret = true; -fail: - mongocrypt_binary_destroy (filter_bin); - mongoc_cursor_destroy (cursor); - bson_destroy (&opts); - mongocrypt_binary_destroy (key_bin); - return ret; -} - -static mongoc_stream_t * -_get_stream (const char *endpoint, - int32_t connecttimeoutms, - const mongoc_ssl_opt_t *ssl_opt, - bson_error_t *error) -{ - mongoc_stream_t *base_stream = NULL; - mongoc_stream_t *tls_stream = NULL; - bool ret = false; - mongoc_ssl_opt_t ssl_opt_copy = {0}; - mongoc_host_list_t host; - - if (!_mongoc_host_list_from_string_with_err (&host, endpoint, error)) { - goto fail; - } - - base_stream = mongoc_client_connect_tcp (connecttimeoutms, &host, error); - if (!base_stream) { - goto fail; - } - - /* Wrap in a tls_stream. */ - _mongoc_ssl_opts_copy_to (ssl_opt, &ssl_opt_copy, true /* copy_internal */); - tls_stream = mongoc_stream_tls_new_with_hostname ( - base_stream, host.host, &ssl_opt_copy, 1 /* client */); - - if (!tls_stream) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to create TLS stream to: %s", - endpoint); - goto fail; - } - - if (!mongoc_stream_tls_handshake_block ( - tls_stream, host.host, connecttimeoutms, error)) { - goto fail; - } - - ret = true; -fail: - _mongoc_ssl_opts_cleanup (&ssl_opt_copy, true /* free_internal */); - if (!ret) { - if (tls_stream) { - /* destroys base_stream too */ - mongoc_stream_destroy (tls_stream); - } else if (base_stream) { - mongoc_stream_destroy (base_stream); - } - return NULL; - } - return tls_stream; -} - -static bool -_state_need_kms (_state_machine_t *state_machine, bson_error_t *error) -{ - mongocrypt_kms_ctx_t *kms_ctx = NULL; - mongoc_stream_t *tls_stream = NULL; - bool ret = false; - mongocrypt_binary_t *http_req = NULL; - mongocrypt_binary_t *http_reply = NULL; - const char *endpoint; - const int32_t sockettimeout = MONGOC_DEFAULT_SOCKETTIMEOUTMS; - kms_ctx = mongocrypt_ctx_next_kms_ctx (state_machine->ctx); - while (kms_ctx) { - mongoc_iovec_t iov; - const mongoc_ssl_opt_t *ssl_opt; - const char *provider; - - provider = mongocrypt_kms_ctx_get_kms_provider (kms_ctx, NULL); - - if (0 == strcmp ("kmip", provider)) { - ssl_opt = &state_machine->crypt->kmip_tls_opt; - } else if (0 == strcmp ("aws", provider)) { - ssl_opt = &state_machine->crypt->aws_tls_opt; - } else if (0 == strcmp ("azure", provider)) { - ssl_opt = &state_machine->crypt->azure_tls_opt; - } else if (0 == strcmp ("gcp", provider)) { - ssl_opt = &state_machine->crypt->gcp_tls_opt; - } else if (mcd_mapof_kmsid_to_tlsopts_has ( - state_machine->crypt->kmsid_to_tlsopts, provider)) { - ssl_opt = mcd_mapof_kmsid_to_tlsopts_get ( - state_machine->crypt->kmsid_to_tlsopts, provider); - } else { - ssl_opt = mongoc_ssl_opt_get_default (); - } - - mongocrypt_binary_destroy (http_req); - http_req = mongocrypt_binary_new (); - if (!mongocrypt_kms_ctx_message (kms_ctx, http_req)) { - _kms_ctx_check_error (kms_ctx, error, true); - goto fail; - } - - if (!mongocrypt_kms_ctx_endpoint (kms_ctx, &endpoint)) { - _kms_ctx_check_error (kms_ctx, error, true); - goto fail; - } - - mongoc_stream_destroy (tls_stream); - tls_stream = _get_stream (endpoint, sockettimeout, ssl_opt, error); -#ifdef MONGOC_ENABLE_SSL_SECURE_CHANNEL - /* Retry once with schannel as a workaround for CDRIVER-3566. */ - if (!tls_stream) { - tls_stream = _get_stream (endpoint, sockettimeout, ssl_opt, error); - } -#endif - if (!tls_stream) { - goto fail; - } - - iov.iov_base = (char *) mongocrypt_binary_data (http_req); - iov.iov_len = mongocrypt_binary_len (http_req); - - if (!_mongoc_stream_writev_full ( - tls_stream, &iov, 1, sockettimeout, error)) { - goto fail; - } - - /* Read and feed reply. */ - while (mongocrypt_kms_ctx_bytes_needed (kms_ctx) > 0) { -#define BUFFER_SIZE 1024 - uint8_t buf[BUFFER_SIZE]; - uint32_t bytes_needed = mongocrypt_kms_ctx_bytes_needed (kms_ctx); - ssize_t read_ret; - - /* Cap the bytes requested at the buffer size. */ - if (bytes_needed > BUFFER_SIZE) { - bytes_needed = BUFFER_SIZE; - } - - read_ret = mongoc_stream_read ( - tls_stream, buf, bytes_needed, 1 /* min_bytes. */, sockettimeout); - if (read_ret == -1) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "failed to read from KMS stream: %d", - errno); - goto fail; - } - - if (read_ret == 0) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "unexpected EOF from KMS stream"); - goto fail; - } - - mongocrypt_binary_destroy (http_reply); - - BSON_ASSERT (bson_in_range_signed (uint32_t, read_ret)); - http_reply = - mongocrypt_binary_new_from_data (buf, (uint32_t) read_ret); - if (!mongocrypt_kms_ctx_feed (kms_ctx, http_reply)) { - _kms_ctx_check_error (kms_ctx, error, true); - goto fail; - } - } - kms_ctx = mongocrypt_ctx_next_kms_ctx (state_machine->ctx); - } - /* When NULL is returned by mongocrypt_ctx_next_kms_ctx, this can either be - * an error or end-of-list. */ - if (!_ctx_check_error (state_machine->ctx, error, false)) { - goto fail; - } - - if (!mongocrypt_ctx_kms_done (state_machine->ctx)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - ret = true; -fail: - mongoc_stream_destroy (tls_stream); - mongocrypt_binary_destroy (http_req); - mongocrypt_binary_destroy (http_reply); - return ret; -#undef BUFFER_SIZE -} - -/** - * @brief Determine whether the given kmsProviders has an empty 'aws' - * subdocument - * - * @param kms_providers The user-provided kmsProviders - * @param error Output parameter for possible errors. - * @retval true If 'aws' is present and an empty subdocument - * @retval false Otherwise or on error - */ -static bool -_needs_on_demand_aws_kms (bson_t const *kms_providers, bson_error_t *error) -{ - bson_iter_t iter; - if (!bson_iter_init_find (&iter, kms_providers, "aws")) { - // No "aws" subdocument - return false; - } - - if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) { - // "aws" is not a document? Should be validated by libmongocrypt - return false; - } - - const uint8_t *dataptr; - uint32_t datalen; - bson_iter_document (&iter, &datalen, &dataptr); - bson_t subdoc; - if (!bson_init_static (&subdoc, dataptr, datalen)) { - // Invalid "aws" document? Should be validated by libmongocrypt - return false; - } - - if (bson_empty (&subdoc)) { - // "aws" is present and is an empty subdocument, which means that the user - // requests that the AWS credentials be loaded on-demand from the - // environment. - return true; - } else { - // "aws" is present and is non-empty, which means that the user has - // already provided credentials for AWS. - return false; - } -} - -/** - * @brief Check whether the given kmsProviders object requests automatic Azure - * credentials - * - * @param kmsprov The input kmsProviders that may have an "azure" property - * @param error An output error - * @retval true If success AND `kmsprov` requests automatic Azure credentials - * @retval false Otherwise. Check error->code for failure. - */ -static bool -_check_azure_kms_auto (const bson_t *kmsprov, bson_error_t *error) -{ - if (error) { - *error = (bson_error_t){0}; - } - - bson_iter_t iter; - if (!bson_iter_init_find (&iter, kmsprov, "azure")) { - return false; - } - - bson_t azure_subdoc; - if (!_mongoc_iter_document_as_bson (&iter, &azure_subdoc, error)) { - return false; - } - - return bson_empty (&azure_subdoc); -} - -/** - * @brief Attempt to load AWS credentials from the environment and insert them - * into the given kmsProviders bson document on the "aws" property. - * - * @param out A kmsProviders object to update - * @param error An error-out parameter - * @retval true If there was no error and we successfully loaded credentials. - * @retval false If there was an error while updating the BSON data or obtaining - * credentials. - */ -static bool -_try_add_aws_from_env (bson_t *out, bson_error_t *error) -{ - // Attempt to obtain AWS credentials from the environment. - _mongoc_aws_credentials_t creds; - if (!_mongoc_aws_credentials_obtain (NULL, &creds, error)) { - // Error while obtaining credentials - return false; - } - - // Build the new "aws" subdoc - bson_t aws; - bool okay = - BSON_APPEND_DOCUMENT_BEGIN (out, "aws", &aws) - // Add the accessKeyId and the secretAccessKey - && BSON_APPEND_UTF8 (&aws, "accessKeyId", creds.access_key_id) // - && BSON_APPEND_UTF8 (&aws, "secretAccessKey", creds.secret_access_key) // - // Add the sessionToken, if we got one: - && (!creds.session_token || - BSON_APPEND_UTF8 (&aws, "sessionToken", creds.session_token)) // - // Finish the document - && bson_append_document_end (out, &aws); - BSON_ASSERT (okay && "Failed to build aws credentials document"); - // Good! - _mongoc_aws_credentials_cleanup (&creds); - return true; -} - -/** - * @brief Attempt to request a new Azure access token from the IMDS HTTP server - * - * @param out The token to populate. Must later be destroyed by the caller. - * @param error An output parameter to capture any errors - * @retval true Upon successfully obtaining and parsing a token - * @retval false If any error occurs. - */ -static bool -_request_new_azure_token (mcd_azure_access_token *out, bson_error_t *error) -{ - return mcd_azure_access_token_from_imds (out, - NULL, // Use the default host - 0, // Default port as well - NULL, // No extra headers - error); -} - -/** - * @brief Attempt to load an Azure access token from the environment and append - * them to the kmsProviders - * - * @param out A kmsProviders object to update - * @param error An error-out parameter - * @retval true If there was no error and we loaded credentials - * @retval false If there was an error obtaining or appending credentials - */ -static bool -_try_add_azure_from_env (_mongoc_crypt_t *crypt, - bson_t *out, - bson_error_t *error) -{ - if (crypt->azure_token.access_token) { - // The access-token is non-null, so we may have one cached. - mcd_time_point one_min_from_now = mcd_later (mcd_now (), mcd_minutes (1)); - mcd_time_point expires_at = mcd_later (crypt->azure_token_issued_at, - crypt->azure_token.expires_in); - if (mcd_time_compare (expires_at, one_min_from_now) >= 0) { - // The token is still valid for at least another minute - } else { - // The token will expire soon. Destroy it, and below we will below ask - // IMDS for a new one. - mcd_azure_access_token_destroy (&crypt->azure_token); - } - } - - if (crypt->azure_token.access_token == NULL) { - // There is no access token in our cache. - // Save the current time point as the "issue time" of the token, even - // though it will take some time for the HTTP request to hit the metadata - // server. This time is only used to track token expiry. IMDS gives us a - // number of seconds that the token will be valid relative to its issue - // time. Avoid reliance on system clocks by comparing the issue time to an - // abstract monotonic "now" - crypt->azure_token_issued_at = mcd_now (); - // Get the token: - if (!_request_new_azure_token (&crypt->azure_token, error)) { - return false; - } - } - - // Build the new KMS credentials - bson_t new_azure_creds = BSON_INITIALIZER; - const bool okay = BSON_APPEND_UTF8 (&new_azure_creds, - "accessToken", - crypt->azure_token.access_token) && - BSON_APPEND_DOCUMENT (out, "azure", &new_azure_creds); - bson_destroy (&new_azure_creds); - if (!okay) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_BSON_INVALID, - "Failed to build new 'azure' credentials"); - } - - return okay; -} - -/** - * @brief Check whether the given kmsProviders object requests automatic GCP - * credentials - * - * @param kmsprov The input kmsProviders that may have an "gcp" property - * @param error An output error - * @retval true If success AND `kmsprov` requests automatic GCP credentials - * @retval false Otherwise. Check error->code for failure. - */ -static bool -_check_gcp_kms_auto (const bson_t *kmsprov, bson_error_t *error) -{ - if (error) { - *error = (bson_error_t){0}; - } - - bson_iter_t iter; - if (!bson_iter_init_find (&iter, kmsprov, "gcp")) { - return false; - } - - bson_t gcp_subdoc; - if (!_mongoc_iter_document_as_bson (&iter, &gcp_subdoc, error)) { - return false; - } - - return bson_empty (&gcp_subdoc); -} - -/** - * @brief Attempt to request a new GCP access token from the HTTP server - * - * @param out The token to populate. Must later be destroyed by the caller. - * @param error An output parameter to capture any errors - * @retval true Upon successfully obtaining and parsing a token - * @retval false If any error occurs. - */ -static bool -_request_new_gcp_token (gcp_service_account_token *out, bson_error_t *error) -{ - return (gcp_access_token_from_gcp_server (out, NULL, 0, NULL, error)); -} - -/** - * @brief Attempt to load an GCP access token from the environment and append - * them to the kmsProviders - * - * @param out A kmsProviders object to update - * @param error An error-out parameter - * @retval true If there was no error and we loaded credentials - * @retval false If there was an error obtaining or appending credentials - */ -static bool -_try_add_gcp_from_env (bson_t *out, bson_error_t *error) -{ - // Not caching gcp tokens, so we will always request a new one from the gcp - // server. - gcp_service_account_token gcp_token; - if (!_request_new_gcp_token (&gcp_token, error)) { - return false; - } - - // Build the new KMS credentials - bson_t new_gcp_creds = BSON_INITIALIZER; - const bool okay = BSON_APPEND_UTF8 (&new_gcp_creds, - "accessToken", - gcp_token.access_token) && - BSON_APPEND_DOCUMENT (out, "gcp", &new_gcp_creds); - bson_destroy (&new_gcp_creds); - gcp_access_token_destroy (&gcp_token); - if (!okay) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_BSON_INVALID, - "Failed to build new 'gcp' credentials"); - } - - return okay; -} - -static bool -_state_need_kms_credentials (_state_machine_t *sm, bson_error_t *error) -{ - bson_t creds = BSON_INITIALIZER; - const bson_t empty = BSON_INITIALIZER; - bool okay = false; - - if (sm->crypt->creds_cb.fn) { - // We have a user-provided credentials callback. Try it. - if (!sm->crypt->creds_cb.fn ( - sm->crypt->creds_cb.userdata, &empty, &creds, error)) { - // User-provided callback indicated failure - if (!error->code) { - // The callback did not set an error, so we'll provide a default - // one. - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "The user-provided callback for on-demand KMS " - "credentials failed."); - } - goto fail; - } - // The user's callback reported success - } - - bson_iter_t iter; - const bool callback_provided_aws = - bson_iter_init_find (&iter, &creds, "aws"); - - if (!callback_provided_aws && - _needs_on_demand_aws_kms (&sm->crypt->kms_providers, error)) { - // The original kmsProviders had an empty "aws" property, and the - // user-provided callback did not fill in a new "aws" property for us. - // Attempt instead to load the AWS credentials from the environment: - if (!_try_add_aws_from_env (&creds, error)) { - // Error while trying to add AWS credentials - goto fail; - } - } - - // Whether the callback provided Azure credentials - const bool cb_provided_azure = bson_iter_init_find (&iter, &creds, "azure"); - // Whether the original kmsProviders requested auto-Azure credentials: - const bool orig_wants_auto_azure = - _check_azure_kms_auto (&sm->crypt->kms_providers, error); - if (error->code) { - // _check_azure_kms_auto failed - goto fail; - } - const bool wants_auto_azure = orig_wants_auto_azure && !cb_provided_azure; - if (wants_auto_azure) { - if (!_try_add_azure_from_env (sm->crypt, &creds, error)) { - goto fail; - } - } - - // Whether the callback provided GCP credentials - const bool cb_provided_gcp = bson_iter_init_find (&iter, &creds, "gcp"); - // Whether the original kmsProviders requested auto-GCP credentials: - const bool orig_wants_auto_gcp = - _check_gcp_kms_auto (&sm->crypt->kms_providers, error); - if (error->code) { - // _check_gcp_kms_auto failed - goto fail; - } - const bool wants_auto_gcp = orig_wants_auto_gcp && !cb_provided_gcp; - if (wants_auto_gcp) { - if (!_try_add_gcp_from_env (&creds, error)) { - goto fail; - } - } - - // Now actually send that data to libmongocrypt - mongocrypt_binary_t *const def = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (&creds), creds.len); - okay = mongocrypt_ctx_provide_kms_providers (sm->ctx, def); - if (!okay) { - _ctx_check_error (sm->ctx, error, true); - } - mongocrypt_binary_destroy (def); - -fail: - bson_destroy (&creds); - - return okay; -} - - -static bool -_state_ready (_state_machine_t *state_machine, - bson_t *result, - bson_error_t *error) -{ - mongocrypt_binary_t *result_bin = NULL; - bson_t tmp; - bool ret = false; - - bson_init (result); - result_bin = mongocrypt_binary_new (); - if (!mongocrypt_ctx_finalize (state_machine->ctx, result_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - if (!_bin_to_static_bson (result_bin, &tmp, error)) { - goto fail; - } - - bson_destroy (result); - bson_copy_to (&tmp, result); - - ret = true; -fail: - mongocrypt_binary_destroy (result_bin); - return ret; -} - -/*-------------------------------------------------------------------------- - * - * _mongoc_cse_run_state_machine -- - * Run the mongocrypt_ctx state machine. - * - * Post-conditions: - * *result may be set to a new bson_t, or NULL otherwise. Caller should - * not assume return value of true means *result is set. If false returned, - * @error is set. - * - * -------------------------------------------------------------------------- - */ -bool -_state_machine_run (_state_machine_t *state_machine, - bson_t *result, - bson_error_t *error) -{ - bool ret = false; - mongocrypt_binary_t *bin = NULL; - - bson_init (result); - while (true) { - switch (mongocrypt_ctx_state (state_machine->ctx)) { - default: - case MONGOCRYPT_CTX_ERROR: - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - case MONGOCRYPT_CTX_NEED_MONGO_COLLINFO: - if (!_state_need_mongo_collinfo (state_machine, error)) { - goto fail; - } - break; - case MONGOCRYPT_CTX_NEED_MONGO_MARKINGS: - if (!_state_need_mongo_markings (state_machine, error)) { - goto fail; - } - break; - case MONGOCRYPT_CTX_NEED_MONGO_KEYS: - if (!_state_need_mongo_keys (state_machine, error)) { - goto fail; - } - break; - case MONGOCRYPT_CTX_NEED_KMS: - if (!_state_need_kms (state_machine, error)) { - goto fail; - } - break; - case MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS: - if (!_state_need_kms_credentials (state_machine, error)) { - goto fail; - } - break; - case MONGOCRYPT_CTX_READY: - bson_destroy (result); - if (!_state_ready (state_machine, result, error)) { - goto fail; - } - break; - case MONGOCRYPT_CTX_DONE: - goto success; - break; - } - } - -success: - ret = true; -fail: - mongocrypt_binary_destroy (bin); - return ret; -} - -/* _parse_one_tls_opts parses one TLS document. - * Pre-conditions: - * - @iter is an iterator at the start of a KMS provider key/value pair. - * - @out_opt must not be initialized. - * Post-conditions: - * - @out_opt is always initialized. - * Returns false and sets @error on error. */ -static bool -_parse_one_tls_opts (bson_iter_t *iter, - mongoc_ssl_opt_t *out_opt, - bson_error_t *error) -{ - bool ok = false; - const char *kms_provider; - bson_t tls_opts_doc; - const uint8_t *data; - uint32_t len; - bson_string_t *errmsg; - bson_iter_t permitted_iter; - - errmsg = bson_string_new (NULL); - kms_provider = bson_iter_key (iter); - memset (out_opt, 0, sizeof (mongoc_ssl_opt_t)); - - if (!BSON_ITER_HOLDS_DOCUMENT (iter)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Expected TLS options for %s to be a document, got: %s", - kms_provider, - _mongoc_bson_type_to_str (bson_iter_type (iter))); - goto fail; - } - - bson_iter_document (iter, &len, &data); - if (!bson_init_static (&tls_opts_doc, data, len) || - !bson_iter_init (&permitted_iter, &tls_opts_doc)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error iterating into TLS options document for %s", - kms_provider); - goto fail; - } - - while (bson_iter_next (&permitted_iter)) { - const char *key = bson_iter_key (&permitted_iter); - - if (0 == - bson_strcasecmp (key, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD)) { - continue; - } - - if (0 == bson_strcasecmp (key, MONGOC_URI_TLSCERTIFICATEKEYFILE)) { - continue; - } - - if (0 == bson_strcasecmp (key, MONGOC_URI_TLSCAFILE)) { - continue; - } - - if (0 == bson_strcasecmp (key, MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK)) { - continue; - } - - bson_set_error ( - error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error setting TLS option %s for %s. Insecure TLS options prohibited.", - key, - kms_provider); - goto fail; - } - - if (!_mongoc_ssl_opts_from_bson (out_opt, &tls_opts_doc, errmsg)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error parsing TLS options for %s: %s", - kms_provider, - errmsg->str); - goto fail; - } - - ok = true; -fail: - bson_string_free (errmsg, true /* free_segment */); - return ok; -} - -/* _parse_all_tls_opts initializes TLS options for all KMS providers. - * @tls_opts is the BSON document passed through - * mongoc_client_encryption_opts_set_tls_opts or - * mongoc_auto_encryption_opts_set_tls_opts. - * Defaults to using mongoc_ssl_opt_get_default() if options are not passed for - * a provider. Returns false and sets @error on error. */ -static bool -_parse_all_tls_opts (_mongoc_crypt_t *crypt, - const bson_t *tls_opts, - bson_error_t *error) -{ - bson_iter_t iter; - bool ok = false; - bool has_aws = false; - bool has_azure = false; - bool has_gcp = false; - bool has_kmip = false; - - if (!tls_opts) { - return true; - } - - if (!bson_iter_init (&iter, tls_opts)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error starting iteration of TLS options"); - goto fail; - } - - while (bson_iter_next (&iter)) { - const char *key; - - key = bson_iter_key (&iter); - if (0 == strcmp (key, "aws")) { - if (has_aws) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error parsing duplicate TLS options for %s", - key); - goto fail; - } - - has_aws = true; - if (!_parse_one_tls_opts (&iter, &crypt->aws_tls_opt, error)) { - goto fail; - } - continue; - } - - if (0 == strcmp (key, "azure")) { - if (has_azure) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error parsing duplicate TLS options for %s", - key); - goto fail; - } - - has_azure = true; - if (!_parse_one_tls_opts (&iter, &crypt->azure_tls_opt, error)) { - goto fail; - } - continue; - } - - if (0 == strcmp (key, "gcp")) { - if (has_gcp) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error parsing duplicate TLS options for %s", - key); - goto fail; - } - - has_gcp = true; - if (!_parse_one_tls_opts (&iter, &crypt->gcp_tls_opt, error)) { - goto fail; - } - continue; - } - - if (0 == strcmp (key, "kmip")) { - if (has_kmip) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error parsing duplicate TLS options for %s", - key); - goto fail; - } - - has_kmip = true; - if (!_parse_one_tls_opts (&iter, &crypt->kmip_tls_opt, error)) { - goto fail; - } - continue; - } - - const char *colon_pos = strstr (key, ":"); - if (colon_pos != NULL) { - // Parse TLS options for a named KMS provider. - if (mcd_mapof_kmsid_to_tlsopts_has (crypt->kmsid_to_tlsopts, key)) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error parsing duplicate TLS options for %s", - key); - goto fail; - } - - mongoc_ssl_opt_t tlsopts = {0}; - if (!_parse_one_tls_opts (&iter, &tlsopts, error)) { - _mongoc_ssl_opts_cleanup (&tlsopts, true /* free_internal */); - goto fail; - } - mcd_mapof_kmsid_to_tlsopts_insert ( - crypt->kmsid_to_tlsopts, key, &tlsopts); - _mongoc_ssl_opts_cleanup (&tlsopts, true /* free_internal */); - continue; - } - - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Cannot configure TLS options for KMS provider: %s", - key); - goto fail; - } - - /* Configure with default TLS options. The mongoc_ssl_opt_t returned by - * mongoc_ssl_opt_get_default may contain non-NULL fields if - * MONGOC_SSL_DEFAULT_TRUST_FILE or MONGOC_SSL_DEFAULT_TRUST_DIR are defined. - */ - if (!has_aws) { - _mongoc_ssl_opts_copy_to (mongoc_ssl_opt_get_default (), - &crypt->aws_tls_opt, - false /* copy internal */); - } - - if (!has_azure) { - _mongoc_ssl_opts_copy_to (mongoc_ssl_opt_get_default (), - &crypt->azure_tls_opt, - false /* copy internal */); - } - - if (!has_gcp) { - _mongoc_ssl_opts_copy_to (mongoc_ssl_opt_get_default (), - &crypt->gcp_tls_opt, - false /* copy internal */); - } - - if (!has_kmip) { - _mongoc_ssl_opts_copy_to (mongoc_ssl_opt_get_default (), - &crypt->kmip_tls_opt, - false /* copy internal */); - } - ok = true; -fail: - return ok; -} - -/* Note, _mongoc_crypt_t only has one member, to the top-level handle of - libmongocrypt, mongocrypt_t. - The purpose of defining _mongoc_crypt_t is to limit all interaction with - libmongocrypt to this one - file. -*/ -_mongoc_crypt_t * -_mongoc_crypt_new (const bson_t *kms_providers, - const bson_t *schema_map, - const bson_t *encrypted_fields_map, - const bson_t *tls_opts, - const char *crypt_shared_lib_path, - bool crypt_shared_lib_required, - bool bypass_auto_encryption, - bool bypass_query_analysis, - mc_kms_credentials_callback creds_cb, - bson_error_t *error) -{ - _mongoc_crypt_t *crypt; - mongocrypt_binary_t *local_masterkey_bin = NULL; - mongocrypt_binary_t *schema_map_bin = NULL; - mongocrypt_binary_t *encrypted_fields_map_bin = NULL; - mongocrypt_binary_t *kms_providers_bin = NULL; - bool success = false; - - /* Create the handle to libmongocrypt. */ - crypt = bson_malloc0 (sizeof (*crypt)); - crypt->kmsid_to_tlsopts = mcd_mapof_kmsid_to_tlsopts_new (); - crypt->handle = mongocrypt_new (); - - // Stash away a copy of the user's kmsProviders in case we need to lazily - // load credentials. - bson_copy_to (kms_providers, &crypt->kms_providers); - - if (!_parse_all_tls_opts (crypt, tls_opts, error)) { - goto fail; - } - - mongocrypt_setopt_log_handler ( - crypt->handle, _log_callback, NULL /* context */); - - kms_providers_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (kms_providers), kms_providers->len); - if (!mongocrypt_setopt_kms_providers (crypt->handle, kms_providers_bin)) { - _crypt_check_error (crypt->handle, error, true); - goto fail; - } - - if (schema_map) { - schema_map_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (schema_map), schema_map->len); - if (!mongocrypt_setopt_schema_map (crypt->handle, schema_map_bin)) { - _crypt_check_error (crypt->handle, error, true); - goto fail; - } - } - - if (encrypted_fields_map) { - encrypted_fields_map_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (encrypted_fields_map), - encrypted_fields_map->len); - if (!mongocrypt_setopt_encrypted_field_config_map ( - crypt->handle, encrypted_fields_map_bin)) { - _crypt_check_error (crypt->handle, error, true); - goto fail; - } - } - - if (!bypass_auto_encryption) { - mongocrypt_setopt_append_crypt_shared_lib_search_path (crypt->handle, - "$SYSTEM"); - if (!_crypt_check_error (crypt->handle, error, false)) { - goto fail; - } - - if (crypt_shared_lib_path != NULL) { - mongocrypt_setopt_set_crypt_shared_lib_path_override ( - crypt->handle, crypt_shared_lib_path); - if (!_crypt_check_error (crypt->handle, error, false)) { - goto fail; - } - } - } - - if (bypass_query_analysis) { - mongocrypt_setopt_bypass_query_analysis (crypt->handle); - if (!_crypt_check_error (crypt->handle, error, false)) { - goto fail; - } - } - - // Enable the NEEDS_CREDENTIALS state for on-demand credential loading - mongocrypt_setopt_use_need_kms_credentials_state (crypt->handle); - - if (!mongocrypt_init (crypt->handle)) { - _crypt_check_error (crypt->handle, error, true); - goto fail; - } - - if (crypt_shared_lib_required) { - uint32_t len = 0; - const char *s = - mongocrypt_crypt_shared_lib_version_string (crypt->handle, &len); - if (!s || len == 0) { - // empty/null version string indicates that crypt_shared was not loaded - // by libmongocrypt - bson_set_error ( - error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "Option 'cryptSharedLibRequired' is 'true', but failed to " - "load the crypt_shared runtime library"); - goto fail; - } - mongoc_log (MONGOC_LOG_LEVEL_DEBUG, - MONGOC_LOG_DOMAIN, - "crypt_shared library version '%s' was found and loaded", - s); - } - - crypt->creds_cb = creds_cb; - - success = true; -fail: - mongocrypt_binary_destroy (local_masterkey_bin); - mongocrypt_binary_destroy (encrypted_fields_map_bin); - mongocrypt_binary_destroy (schema_map_bin); - mongocrypt_binary_destroy (kms_providers_bin); - - if (!success) { - _mongoc_crypt_destroy (crypt); - return NULL; - } - - return crypt; -} - -void -_mongoc_crypt_destroy (_mongoc_crypt_t *crypt) -{ - if (!crypt) { - return; - } - mongocrypt_destroy (crypt->handle); - _mongoc_ssl_opts_cleanup (&crypt->kmip_tls_opt, true /* free_internal */); - _mongoc_ssl_opts_cleanup (&crypt->aws_tls_opt, true /* free_internal */); - _mongoc_ssl_opts_cleanup (&crypt->azure_tls_opt, true /* free_internal */); - _mongoc_ssl_opts_cleanup (&crypt->gcp_tls_opt, true /* free_internal */); - bson_destroy (&crypt->kms_providers); - mcd_azure_access_token_destroy (&crypt->azure_token); - mcd_mapof_kmsid_to_tlsopts_destroy (crypt->kmsid_to_tlsopts); - bson_free (crypt); -} - -bool -_mongoc_crypt_auto_encrypt (_mongoc_crypt_t *crypt, - mongoc_collection_t *keyvault_coll, - mongoc_client_t *mongocryptd_client, - mongoc_client_t *collinfo_client, - const char *db_name, - const bson_t *cmd_in, - bson_t *cmd_out, - bson_error_t *error) -{ - _state_machine_t *state_machine = NULL; - mongocrypt_binary_t *cmd_bin = NULL; - bool ret = false; - - BSON_ASSERT_PARAM (collinfo_client); - bson_init (cmd_out); - - state_machine = _state_machine_new (crypt); - state_machine->keyvault_coll = keyvault_coll; - state_machine->mongocryptd_client = mongocryptd_client; - state_machine->collinfo_client = collinfo_client; - state_machine->db_name = db_name; - state_machine->ctx = mongocrypt_ctx_new (crypt->handle); - if (!state_machine->ctx) { - _crypt_check_error (crypt->handle, error, true); - goto fail; - } - - cmd_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (cmd_in), cmd_in->len); - if (!mongocrypt_ctx_encrypt_init ( - state_machine->ctx, db_name, -1, cmd_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - bson_destroy (cmd_out); - if (!_state_machine_run (state_machine, cmd_out, error)) { - goto fail; - } - - ret = true; -fail: - mongocrypt_binary_destroy (cmd_bin); - _state_machine_destroy (state_machine); - return ret; -} - -bool -_mongoc_crypt_auto_decrypt (_mongoc_crypt_t *crypt, - mongoc_collection_t *keyvault_coll, - const bson_t *doc_in, - bson_t *doc_out, - bson_error_t *error) -{ - bool ret = false; - _state_machine_t *state_machine = NULL; - mongocrypt_binary_t *doc_bin = NULL; - - bson_init (doc_out); - - state_machine = _state_machine_new (crypt); - state_machine->keyvault_coll = keyvault_coll; - state_machine->ctx = mongocrypt_ctx_new (crypt->handle); - if (!state_machine->ctx) { - _crypt_check_error (crypt->handle, error, true); - goto fail; - } - - doc_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (doc_in), doc_in->len); - if (!mongocrypt_ctx_decrypt_init (state_machine->ctx, doc_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - bson_destroy (doc_out); - if (!_state_machine_run (state_machine, doc_out, error)) { - goto fail; - } - - ret = true; -fail: - mongocrypt_binary_destroy (doc_bin); - _state_machine_destroy (state_machine); - return ret; -} - -// _create_explicit_state_machine_t creates a _state_machine_t for explicit -// encryption. The returned state machine may be used encrypting a value or -// encrypting an expression. -static _state_machine_t * -_create_explicit_state_machine (_mongoc_crypt_t *crypt, - mongoc_collection_t *keyvault_coll, - const char *algorithm, - const bson_value_t *keyid, - const char *keyaltname, - const char *query_type, - const int64_t *contention_factor, - const bson_t *range_opts, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (crypt); - BSON_ASSERT_PARAM (keyvault_coll); - BSON_ASSERT (algorithm || true); - BSON_ASSERT (keyid || true); - BSON_ASSERT (keyaltname || true); - BSON_ASSERT (query_type || true); - BSON_ASSERT (range_opts || true); - BSON_ASSERT (error || true); - - _state_machine_t *state_machine = NULL; - bool ok = false; - - /* Create the context for the operation. */ - state_machine = _state_machine_new (crypt); - state_machine->keyvault_coll = keyvault_coll; - state_machine->ctx = mongocrypt_ctx_new (crypt->handle); - if (!state_machine->ctx) { - _crypt_check_error (crypt->handle, error, true); - goto fail; - } - - if (!mongocrypt_ctx_setopt_algorithm (state_machine->ctx, algorithm, -1)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - if (range_opts != NULL) { - /* mongocrypt error checks and parses range options */ - mongocrypt_binary_t *binary_range_opts = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (range_opts), range_opts->len); - if (!mongocrypt_ctx_setopt_algorithm_range (state_machine->ctx, - binary_range_opts)) { - mongocrypt_binary_destroy (binary_range_opts); - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - mongocrypt_binary_destroy (binary_range_opts); - } - - if (query_type != NULL) { - if (!mongocrypt_ctx_setopt_query_type ( - state_machine->ctx, query_type, -1)) { - goto fail; - } - } - - if (contention_factor != NULL) { - if (!mongocrypt_ctx_setopt_contention_factor (state_machine->ctx, - *contention_factor)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - } - - if (keyaltname) { - bool keyaltname_ret; - mongocrypt_binary_t *keyaltname_bin; - bson_t *keyaltname_doc; - - keyaltname_doc = BCON_NEW ("keyAltName", keyaltname); - keyaltname_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (keyaltname_doc), keyaltname_doc->len); - keyaltname_ret = mongocrypt_ctx_setopt_key_alt_name (state_machine->ctx, - keyaltname_bin); - mongocrypt_binary_destroy (keyaltname_bin); - bson_destroy (keyaltname_doc); - if (!keyaltname_ret) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - } - - if (keyid && keyid->value_type == BSON_TYPE_BINARY) { - mongocrypt_binary_t *keyid_bin; - bool keyid_ret; - - if (keyid->value.v_binary.subtype != BSON_SUBTYPE_UUID) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "keyid must be a UUID"); - goto fail; - } - - keyid_bin = mongocrypt_binary_new_from_data ( - keyid->value.v_binary.data, keyid->value.v_binary.data_len); - keyid_ret = mongocrypt_ctx_setopt_key_id (state_machine->ctx, keyid_bin); - mongocrypt_binary_destroy (keyid_bin); - if (!keyid_ret) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - } - - ok = true; -fail: - if (!ok) { - _state_machine_destroy (state_machine); - state_machine = NULL; - } - return state_machine; -} - -bool -_mongoc_crypt_explicit_encrypt (_mongoc_crypt_t *crypt, - mongoc_collection_t *keyvault_coll, - const char *algorithm, - const bson_value_t *keyid, - const char *keyaltname, - const char *query_type, - const int64_t *contention_factor, - const bson_t *range_opts, - const bson_value_t *value_in, - bson_value_t *value_out, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (crypt); - BSON_ASSERT_PARAM (keyvault_coll); - BSON_ASSERT (algorithm || true); - BSON_ASSERT (keyid || true); - BSON_ASSERT (keyaltname || true); - BSON_ASSERT (query_type || true); - BSON_ASSERT (range_opts || true); - BSON_ASSERT_PARAM (value_in); - BSON_ASSERT_PARAM (value_out); - BSON_ASSERT (error || true); - - _state_machine_t *state_machine = NULL; - bson_t *to_encrypt_doc = NULL; - mongocrypt_binary_t *to_encrypt_bin = NULL; - bson_iter_t iter; - bool ret = false; - bson_t result = BSON_INITIALIZER; - - value_out->value_type = BSON_TYPE_EOD; - - state_machine = _create_explicit_state_machine (crypt, - keyvault_coll, - algorithm, - keyid, - keyaltname, - query_type, - contention_factor, - range_opts, - error); - if (!state_machine) { - goto fail; - } - - to_encrypt_doc = bson_new (); - BSON_APPEND_VALUE (to_encrypt_doc, "v", value_in); - to_encrypt_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (to_encrypt_doc), to_encrypt_doc->len); - if (!mongocrypt_ctx_explicit_encrypt_init (state_machine->ctx, - to_encrypt_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - bson_destroy (&result); - if (!_state_machine_run (state_machine, &result, error)) { - goto fail; - } - - /* extract value */ - if (!bson_iter_init_find (&iter, &result, "v")) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "encrypted result unexpected: no 'v' found"); - goto fail; - } else { - const bson_value_t *tmp; - - tmp = bson_iter_value (&iter); - bson_value_copy (tmp, value_out); - } - - ret = true; -fail: - _state_machine_destroy (state_machine); - mongocrypt_binary_destroy (to_encrypt_bin); - bson_destroy (to_encrypt_doc); - bson_destroy (&result); - return ret; -} - -bool -_mongoc_crypt_explicit_encrypt_expression (_mongoc_crypt_t *crypt, - mongoc_collection_t *keyvault_coll, - const char *algorithm, - const bson_value_t *keyid, - const char *keyaltname, - const char *query_type, - const int64_t *contention_factor, - const bson_t *range_opts, - const bson_t *expr_in, - bson_t *expr_out, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (crypt); - BSON_ASSERT_PARAM (keyvault_coll); - BSON_ASSERT (algorithm || true); - BSON_ASSERT (keyid || true); - BSON_ASSERT (keyaltname || true); - BSON_ASSERT (query_type || true); - BSON_ASSERT (range_opts || true); - BSON_ASSERT_PARAM (expr_in); - BSON_ASSERT_PARAM (expr_out); - BSON_ASSERT (error || true); - - _state_machine_t *state_machine = NULL; - bson_t *to_encrypt_doc = NULL; - mongocrypt_binary_t *to_encrypt_bin = NULL; - bson_iter_t iter; - bool ret = false; - bson_t result = BSON_INITIALIZER; - - bson_init (expr_out); - - state_machine = _create_explicit_state_machine (crypt, - keyvault_coll, - algorithm, - keyid, - keyaltname, - query_type, - contention_factor, - range_opts, - error); - if (!state_machine) { - goto fail; - } - - to_encrypt_doc = bson_new (); - BSON_APPEND_DOCUMENT (to_encrypt_doc, "v", expr_in); - to_encrypt_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (to_encrypt_doc), to_encrypt_doc->len); - if (!mongocrypt_ctx_explicit_encrypt_expression_init (state_machine->ctx, - to_encrypt_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - bson_destroy (&result); - if (!_state_machine_run (state_machine, &result, error)) { - goto fail; - } - - /* extract document */ - if (!bson_iter_init_find (&iter, &result, "v")) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "encrypted result unexpected: no 'v' found"); - goto fail; - } else { - bson_t tmp; - - if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) { - bson_set_error ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "encrypted result unexpected: 'v' is not a document, got: %s", - _mongoc_bson_type_to_str (bson_iter_type (&iter))); - goto fail; - } - - if (!_mongoc_iter_document_as_bson (&iter, &tmp, error)) { - goto fail; - } - - bson_copy_to (&tmp, expr_out); - } - - ret = true; -fail: - _state_machine_destroy (state_machine); - mongocrypt_binary_destroy (to_encrypt_bin); - bson_destroy (to_encrypt_doc); - bson_destroy (&result); - return ret; -} - -bool -_mongoc_crypt_explicit_decrypt (_mongoc_crypt_t *crypt, - mongoc_collection_t *keyvault_coll, - const bson_value_t *value_in, - bson_value_t *value_out, - bson_error_t *error) -{ - _state_machine_t *state_machine = NULL; - bson_t *to_decrypt_doc = NULL; - mongocrypt_binary_t *to_decrypt_bin = NULL; - bson_iter_t iter; - bool ret = false; - bson_t result = BSON_INITIALIZER; - - state_machine = _state_machine_new (crypt); - state_machine->keyvault_coll = keyvault_coll; - state_machine->ctx = mongocrypt_ctx_new (crypt->handle); - if (!state_machine->ctx) { - _crypt_check_error (crypt->handle, error, true); - goto fail; - } - - to_decrypt_doc = bson_new (); - BSON_APPEND_VALUE (to_decrypt_doc, "v", value_in); - to_decrypt_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (to_decrypt_doc), to_decrypt_doc->len); - if (!mongocrypt_ctx_explicit_decrypt_init (state_machine->ctx, - to_decrypt_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - bson_destroy (&result); - if (!_state_machine_run (state_machine, &result, error)) { - goto fail; - } - - /* extract value */ - if (!bson_iter_init_find (&iter, &result, "v")) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "decrypted result unexpected"); - goto fail; - } else { - const bson_value_t *tmp; - - tmp = bson_iter_value (&iter); - bson_value_copy (tmp, value_out); - } - - ret = true; -fail: - _state_machine_destroy (state_machine); - mongocrypt_binary_destroy (to_decrypt_bin); - bson_destroy (to_decrypt_doc); - bson_destroy (&result); - return ret; -} - -bool -_mongoc_crypt_create_datakey (_mongoc_crypt_t *crypt, - const char *kms_provider, - const bson_t *masterkey, - char **keyaltnames, - uint32_t keyaltnames_count, - const uint8_t *keymaterial, - uint32_t keymaterial_len, - bson_t *doc_out, - bson_error_t *error) -{ - _state_machine_t *state_machine = NULL; - bool ret = false; - bson_t masterkey_w_provider = BSON_INITIALIZER; - mongocrypt_binary_t *masterkey_w_provider_bin = NULL; - - bson_init (doc_out); - state_machine = _state_machine_new (crypt); - state_machine->ctx = mongocrypt_ctx_new (crypt->handle); - if (!state_machine->ctx) { - _crypt_check_error (crypt->handle, error, true); - goto fail; - } - - BSON_APPEND_UTF8 (&masterkey_w_provider, "provider", kms_provider); - if (masterkey) { - bson_concat (&masterkey_w_provider, masterkey); - } - masterkey_w_provider_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (&masterkey_w_provider), - masterkey_w_provider.len); - - if (!mongocrypt_ctx_setopt_key_encryption_key (state_machine->ctx, - masterkey_w_provider_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - if (keyaltnames) { - for (uint32_t i = 0u; i < keyaltnames_count; i++) { - bool keyaltname_ret; - mongocrypt_binary_t *keyaltname_bin; - bson_t *keyaltname_doc; - - keyaltname_doc = BCON_NEW ("keyAltName", keyaltnames[i]); - keyaltname_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (keyaltname_doc), keyaltname_doc->len); - keyaltname_ret = mongocrypt_ctx_setopt_key_alt_name ( - state_machine->ctx, keyaltname_bin); - mongocrypt_binary_destroy (keyaltname_bin); - bson_destroy (keyaltname_doc); - if (!keyaltname_ret) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - } - } - - if (keymaterial) { - bson_t *const bson = BCON_NEW ( - "keyMaterial", - BCON_BIN (BSON_SUBTYPE_BINARY, keymaterial, keymaterial_len)); - mongocrypt_binary_t *const bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (bson), bson->len); - - mongocrypt_ctx_setopt_key_material (state_machine->ctx, bin); - - bson_destroy (bson); - mongocrypt_binary_destroy (bin); - } - - if (!mongocrypt_ctx_datakey_init (state_machine->ctx)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - bson_destroy (doc_out); - if (!_state_machine_run (state_machine, doc_out, error)) { - goto fail; - } - - ret = true; - -fail: - bson_destroy (&masterkey_w_provider); - mongocrypt_binary_destroy (masterkey_w_provider_bin); - _state_machine_destroy (state_machine); - return ret; -} - -bool -_mongoc_crypt_rewrap_many_datakey (_mongoc_crypt_t *crypt, - mongoc_collection_t *keyvault_coll, - const bson_t *filter, - const char *provider, - const bson_t *master_key, - bson_t *doc_out, - bson_error_t *error) -{ - _state_machine_t *state_machine = NULL; - const bson_t empty_bson = BSON_INITIALIZER; - mongocrypt_binary_t *filter_bin = NULL; - bool ret = false; - - // Caller must ensure `provider` is provided alongside `master_key`. - BSON_ASSERT (!master_key || provider); - - bson_init (doc_out); - state_machine = _state_machine_new (crypt); - state_machine->keyvault_coll = keyvault_coll; - state_machine->ctx = mongocrypt_ctx_new (crypt->handle); - if (!state_machine->ctx) { - _crypt_check_error (crypt->handle, error, true); - goto fail; - } - - { - bson_t new_provider = BSON_INITIALIZER; - mongocrypt_binary_t *new_provider_bin = NULL; - bool success = true; - - if (provider) { - BSON_APPEND_UTF8 (&new_provider, "provider", provider); - - if (master_key) { - bson_concat (&new_provider, master_key); - } - - new_provider_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (&new_provider), new_provider.len); - - if (!mongocrypt_ctx_setopt_key_encryption_key (state_machine->ctx, - new_provider_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - success = false; - } - - mongocrypt_binary_destroy (new_provider_bin); - } - - bson_destroy (&new_provider); - - if (!success) { - goto fail; - } - } - - if (!filter) { - filter = &empty_bson; - } - - filter_bin = mongocrypt_binary_new_from_data ( - (uint8_t *) bson_get_data (filter), filter->len); - - if (!mongocrypt_ctx_rewrap_many_datakey_init (state_machine->ctx, - filter_bin)) { - _ctx_check_error (state_machine->ctx, error, true); - goto fail; - } - - bson_destroy (doc_out); - if (!_state_machine_run (state_machine, doc_out, error)) { - goto fail; - } - - ret = true; - -fail: - mongocrypt_binary_destroy (filter_bin); - _state_machine_destroy (state_machine); - - return ret; -} - -const char * -_mongoc_crypt_get_crypt_shared_version (const _mongoc_crypt_t *crypt) -{ - return mongocrypt_crypt_shared_lib_version_string (crypt->handle, NULL); -} - -#else -/* ensure the translation unit is not empty */ -extern int no_mongoc_client_side_encryption; -#endif /* MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-cng-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-cng-private.h deleted file mode 100644 index 07210b208..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-cng-private.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifdef MONGOC_ENABLE_CRYPTO_CNG - -#ifndef MONGOC_CRYPTO_CNG_PRIVATE_H -#define MONGOC_CRYPTO_CNG_PRIVATE_H - - -#include "mongoc-config.h" - - -BSON_BEGIN_DECLS - -void -mongoc_crypto_cng_init (void); - -void -mongoc_crypto_cng_cleanup (void); - -void -mongoc_crypto_cng_hmac_sha1 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out); - -bool -mongoc_crypto_cng_sha1 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out); - -void -mongoc_crypto_cng_hmac_sha256 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out); - -bool -mongoc_crypto_cng_sha256 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out); - - -BSON_END_DECLS - -#endif /* MONGOC_CRYPTO_CNG_PRIVATE_H */ -#endif /* MONGOC_ENABLE_CRYPTO_CNG */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-cng.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-cng.c deleted file mode 100644 index 4cf82ca47..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-cng.c +++ /dev/null @@ -1,233 +0,0 @@ -/* Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_CRYPTO_CNG -#include "mongoc-crypto-private.h" -#include "mongoc-crypto-cng-private.h" -#include "mongoc-log.h" -#include "mongoc-thread-private.h" - -#include -#include -#include - -#define NT_SUCCESS(Status) (((NTSTATUS) (Status)) >= 0) -#define STATUS_UNSUCCESSFUL ((NTSTATUS) 0xC0000001L) - -static BCRYPT_ALG_HANDLE _sha1_hash_algo; -static BCRYPT_ALG_HANDLE _sha1_hmac_algo; -static BCRYPT_ALG_HANDLE _sha256_hash_algo; -static BCRYPT_ALG_HANDLE _sha256_hmac_algo; - -void -mongoc_crypto_cng_init (void) -{ - NTSTATUS status = STATUS_UNSUCCESSFUL; - _sha1_hash_algo = 0; - status = BCryptOpenAlgorithmProvider ( - &_sha1_hash_algo, BCRYPT_SHA1_ALGORITHM, NULL, 0); - if (!NT_SUCCESS (status)) { - MONGOC_ERROR ("BCryptOpenAlgorithmProvider(SHA1): %ld", status); - } - - _sha1_hmac_algo = 0; - status = BCryptOpenAlgorithmProvider (&_sha1_hmac_algo, - BCRYPT_SHA1_ALGORITHM, - NULL, - BCRYPT_ALG_HANDLE_HMAC_FLAG); - if (!NT_SUCCESS (status)) { - MONGOC_ERROR ("BCryptOpenAlgorithmProvider(SHA1 HMAC): %ld", status); - } - - _sha256_hash_algo = 0; - status = BCryptOpenAlgorithmProvider ( - &_sha256_hash_algo, BCRYPT_SHA256_ALGORITHM, NULL, 0); - if (!NT_SUCCESS (status)) { - MONGOC_ERROR ("BCryptOpenAlgorithmProvider(SHA256): %ld", status); - } - - _sha256_hmac_algo = 0; - status = BCryptOpenAlgorithmProvider (&_sha256_hmac_algo, - BCRYPT_SHA256_ALGORITHM, - NULL, - BCRYPT_ALG_HANDLE_HMAC_FLAG); - if (!NT_SUCCESS (status)) { - MONGOC_ERROR ("BCryptOpenAlgorithmProvider(SHA256 HMAC): %ld", status); - } -} - -void -mongoc_crypto_cng_cleanup (void) -{ - if (_sha1_hash_algo) { - BCryptCloseAlgorithmProvider (&_sha1_hash_algo, 0); - } - if (_sha1_hmac_algo) { - BCryptCloseAlgorithmProvider (&_sha1_hmac_algo, 0); - } - if (_sha256_hash_algo) { - BCryptCloseAlgorithmProvider (&_sha256_hash_algo, 0); - } - if (_sha256_hash_algo) { - BCryptCloseAlgorithmProvider (&_sha256_hash_algo, 0); - } -} - -bool -_mongoc_crypto_cng_hmac_or_hash (BCRYPT_ALG_HANDLE algorithm, - const void *key, - size_t key_length, - void *data, - size_t data_length, - void *output) -{ - unsigned char *hash_object_buffer = 0; - ULONG hash_object_length = 0; - BCRYPT_HASH_HANDLE hash = 0; - ULONG mac_length = 0; - NTSTATUS status = STATUS_UNSUCCESSFUL; - bool retval = false; - ULONG noop = 0; - - status = BCryptGetProperty (algorithm, - BCRYPT_OBJECT_LENGTH, - (unsigned char *) &hash_object_length, - sizeof hash_object_length, - &noop, - 0); - - if (!NT_SUCCESS (status)) { - MONGOC_ERROR ("BCryptGetProperty(): OBJECT_LENGTH %ld", status); - return false; - } - - status = BCryptGetProperty (algorithm, - BCRYPT_HASH_LENGTH, - (unsigned char *) &mac_length, - sizeof mac_length, - &noop, - 0); - - if (!NT_SUCCESS (status)) { - MONGOC_ERROR ("BCryptGetProperty(): HASH_LENGTH %ld", status); - return false; - } - - hash_object_buffer = bson_malloc (hash_object_length); - - status = BCryptCreateHash (algorithm, - &hash, - hash_object_buffer, - hash_object_length, - (PUCHAR) key, - (ULONG) key_length, - 0); - - if (!NT_SUCCESS (status)) { - MONGOC_ERROR ("BCryptCreateHash(): %ld", status); - goto cleanup; - } - - status = BCryptHashData (hash, data, (ULONG) data_length, 0); - if (!NT_SUCCESS (status)) { - MONGOC_ERROR ("BCryptHashData(): %ld", status); - goto cleanup; - } - - status = BCryptFinishHash (hash, output, mac_length, 0); - if (!NT_SUCCESS (status)) { - MONGOC_ERROR ("BCryptFinishHash(): %ld", status); - goto cleanup; - } - - retval = true; - -cleanup: - if (hash) { - (void) BCryptDestroyHash (hash); - } - - bson_free (hash_object_buffer); - return retval; -} - -void -mongoc_crypto_cng_hmac_sha1 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out) -{ - if (!_sha1_hmac_algo) { - return; - } - - _mongoc_crypto_cng_hmac_or_hash ( - _sha1_hmac_algo, key, key_len, (void *) data, data_len, hmac_out); -} - -bool -mongoc_crypto_cng_sha1 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out) -{ - bool res; - - if (!_sha1_hash_algo) { - return false; - } - - res = _mongoc_crypto_cng_hmac_or_hash ( - _sha1_hash_algo, NULL, 0, (void *) input, input_len, hash_out); - return res; -} - -void -mongoc_crypto_cng_hmac_sha256 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out) -{ - if (!_sha256_hmac_algo) { - return; - } - - _mongoc_crypto_cng_hmac_or_hash ( - _sha256_hmac_algo, key, key_len, (void *) data, data_len, hmac_out); -} - -bool -mongoc_crypto_cng_sha256 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out) -{ - bool res; - - if (!_sha256_hash_algo) { - return false; - } - - res = _mongoc_crypto_cng_hmac_or_hash ( - _sha256_hash_algo, NULL, 0, (void *) input, input_len, hash_out); - return res; -} -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto-private.h deleted file mode 100644 index 3384a7260..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto-private.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifdef MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO - -#ifndef MONGOC_CRYPTO_COMMON_CRYPTO_PRIVATE_H -#define MONGOC_CRYPTO_COMMON_CRYPTO_PRIVATE_H - - -#include "mongoc-config.h" - - -BSON_BEGIN_DECLS - -void -mongoc_crypto_common_crypto_hmac_sha1 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out); - -bool -mongoc_crypto_common_crypto_sha1 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out); - -void -mongoc_crypto_common_crypto_hmac_sha256 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out); - -bool -mongoc_crypto_common_crypto_sha256 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out); - -BSON_END_DECLS - -#endif /* MONGOC_CRYPTO_COMMON_CRYPTO_PRIVATE_H */ -#endif /* MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto.c deleted file mode 100644 index 141a7afa1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" -#include "mongoc-crypto-private.h" - -#ifdef MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO -#include "mongoc-crypto-common-crypto-private.h" -#include -#include - - -void -mongoc_crypto_common_crypto_hmac_sha1 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out) -{ - /* U1 = HMAC(input, salt + 0001) */ - CCHmac ( - kCCHmacAlgSHA1, key, (size_t) key_len, data, (size_t) data_len, hmac_out); -} - -bool -mongoc_crypto_common_crypto_sha1 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out) -{ - if (CC_SHA1 (input, (CC_LONG) input_len, hash_out)) { - return true; - } - return false; -} - -void -mongoc_crypto_common_crypto_hmac_sha256 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out) -{ - CCHmac (kCCHmacAlgSHA256, - key, - (size_t) key_len, - data, - (size_t) data_len, - hmac_out); -} - -bool -mongoc_crypto_common_crypto_sha256 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out) -{ - if (CC_SHA256 (input, (CC_LONG) input_len, hash_out)) { - return true; - } - return false; -} - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-openssl-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-openssl-private.h deleted file mode 100644 index 7c4879800..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-openssl-private.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#include "mongoc-config.h" -#include - -#ifdef MONGOC_ENABLE_CRYPTO_LIBCRYPTO - -#ifndef MONGOC_CRYPTO_OPENSSL_PRIVATE_H -#define MONGOC_CRYPTO_OPENSSL_PRIVATE_H - -#include "mongoc-crypto-private.h" - -BSON_BEGIN_DECLS - -void -mongoc_crypto_openssl_hmac_sha1 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out); - -bool -mongoc_crypto_openssl_sha1 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out); - -void -mongoc_crypto_openssl_hmac_sha256 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out); - -bool -mongoc_crypto_openssl_sha256 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out); - -BSON_END_DECLS -#endif /* MONGOC_CRYPTO_OPENSSL_PRIVATE_H */ -#endif /* MONGOC_ENABLE_CRYPTO_LIBCRYPTO */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-openssl.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-openssl.c deleted file mode 100644 index 6cc7c91a6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-openssl.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" -#include - -#ifdef MONGOC_ENABLE_CRYPTO_LIBCRYPTO -#include "mongoc-crypto-openssl-private.h" -#include "mongoc-crypto-private.h" - -#include -#include -#include - - -void -mongoc_crypto_openssl_hmac_sha1 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out) -{ - BSON_UNUSED (crypto); - - /* U1 = HMAC(input, salt + 0001) */ - HMAC (EVP_sha1 (), key, key_len, data, data_len, hmac_out, NULL); -} - -#if OPENSSL_VERSION_NUMBER < 0x10100000L || \ - (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) -static EVP_MD_CTX * -EVP_MD_CTX_new (void) -{ - return bson_malloc0 (sizeof (EVP_MD_CTX)); -} - -static void -EVP_MD_CTX_free (EVP_MD_CTX *ctx) -{ - EVP_MD_CTX_cleanup (ctx); - bson_free (ctx); -} -#endif - -bool -mongoc_crypto_openssl_sha1 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out) -{ - EVP_MD_CTX *digest_ctxp = EVP_MD_CTX_new (); - bool rval = false; - - BSON_UNUSED (crypto); - - if (1 != EVP_DigestInit_ex (digest_ctxp, EVP_sha1 (), NULL)) { - goto cleanup; - } - - if (1 != EVP_DigestUpdate (digest_ctxp, input, input_len)) { - goto cleanup; - } - - rval = (1 == EVP_DigestFinal_ex (digest_ctxp, hash_out, NULL)); - -cleanup: - EVP_MD_CTX_free (digest_ctxp); - - return rval; -} - -void -mongoc_crypto_openssl_hmac_sha256 (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out) -{ - BSON_UNUSED (crypto); - - /* U1 = HMAC(input, salt + 0001) */ - HMAC (EVP_sha256 (), key, key_len, data, data_len, hmac_out, NULL); -} - -bool -mongoc_crypto_openssl_sha256 (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out) -{ - EVP_MD_CTX *digest_ctxp = EVP_MD_CTX_new (); - bool rval = false; - - BSON_UNUSED (crypto); - - if (1 != EVP_DigestInit_ex (digest_ctxp, EVP_sha256 (), NULL)) { - goto cleanup; - } - - if (1 != EVP_DigestUpdate (digest_ctxp, input, input_len)) { - goto cleanup; - } - - rval = (1 == EVP_DigestFinal_ex (digest_ctxp, hash_out, NULL)); - -cleanup: - EVP_MD_CTX_free (digest_ctxp); - - return rval; -} - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-private.h deleted file mode 100644 index 0a4136022..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto-private.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#include "mongoc-config.h" -#include - -#ifdef MONGOC_ENABLE_CRYPTO - -#ifndef MONGOC_CRYPTO_PRIVATE_H -#define MONGOC_CRYPTO_PRIVATE_H - - -BSON_BEGIN_DECLS - -typedef struct _mongoc_crypto_t mongoc_crypto_t; -typedef enum { - MONGOC_CRYPTO_ALGORITHM_SHA_1, - MONGOC_CRYPTO_ALGORITHM_SHA_256 -} mongoc_crypto_hash_algorithm_t; - -struct _mongoc_crypto_t { - void (*hmac) (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out); - bool (*hash) (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out); - mongoc_crypto_hash_algorithm_t algorithm; -}; - -void -mongoc_crypto_init (mongoc_crypto_t *crypto, - mongoc_crypto_hash_algorithm_t algo); - -void -mongoc_crypto_hmac (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out); - -bool -mongoc_crypto_hash (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *hash_out); - -BSON_END_DECLS -#endif /* MONGOC_CRYPTO_PRIVATE_H */ -#endif /* MONGOC_ENABLE_CRYPTO */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto.c deleted file mode 100644 index 79c693efb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-crypto.c +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_CRYPTO - -#include -#include "mongoc-log.h" -#include "mongoc-crypto-private.h" -#if defined(MONGOC_ENABLE_CRYPTO_LIBCRYPTO) -#include "mongoc-crypto-openssl-private.h" -#elif defined(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO) -#include "mongoc-crypto-common-crypto-private.h" -#elif defined(MONGOC_ENABLE_CRYPTO_CNG) -#include "mongoc-crypto-cng-private.h" -#endif - -void -mongoc_crypto_init (mongoc_crypto_t *crypto, - mongoc_crypto_hash_algorithm_t algo) -{ - crypto->hmac = NULL; - crypto->hash = NULL; - if (algo == MONGOC_CRYPTO_ALGORITHM_SHA_1) { -#ifdef MONGOC_ENABLE_CRYPTO_LIBCRYPTO - crypto->hmac = mongoc_crypto_openssl_hmac_sha1; - crypto->hash = mongoc_crypto_openssl_sha1; -#elif defined(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO) - crypto->hmac = mongoc_crypto_common_crypto_hmac_sha1; - crypto->hash = mongoc_crypto_common_crypto_sha1; -#elif defined(MONGOC_ENABLE_CRYPTO_CNG) - crypto->hmac = mongoc_crypto_cng_hmac_sha1; - crypto->hash = mongoc_crypto_cng_sha1; -#endif - } else if (algo == MONGOC_CRYPTO_ALGORITHM_SHA_256) { -#ifdef MONGOC_ENABLE_CRYPTO_LIBCRYPTO - crypto->hmac = mongoc_crypto_openssl_hmac_sha256; - crypto->hash = mongoc_crypto_openssl_sha256; -#elif defined(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO) - crypto->hmac = mongoc_crypto_common_crypto_hmac_sha256; - crypto->hash = mongoc_crypto_common_crypto_sha256; -#elif defined(MONGOC_ENABLE_CRYPTO_CNG) - crypto->hmac = mongoc_crypto_cng_hmac_sha256; - crypto->hash = mongoc_crypto_cng_sha256; -#endif - } - BSON_ASSERT (crypto->hmac); - BSON_ASSERT (crypto->hash); - crypto->algorithm = algo; -} - -void -mongoc_crypto_hmac (mongoc_crypto_t *crypto, - const void *key, - int key_len, - const unsigned char *data, - int data_len, - unsigned char *hmac_out) -{ - crypto->hmac (crypto, key, key_len, data, data_len, hmac_out); -} - -bool -mongoc_crypto_hash (mongoc_crypto_t *crypto, - const unsigned char *input, - const size_t input_len, - unsigned char *output) -{ - return crypto->hash (crypto, input, input_len, output); -} -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor-legacy.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor-legacy.c deleted file mode 100644 index 8c93d955e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor-legacy.c +++ /dev/null @@ -1,696 +0,0 @@ -/* - * Copyright 2018-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* cursor functions for pre-3.2 MongoDB, including: - * - OP_QUERY find (superseded by the find command) - * - OP_GETMORE (superseded by the getMore command) - * - receiving OP_REPLY documents in a stream (instead of batch) - */ - -#include "mongoc-cursor.h" -#include "mongoc-cursor-private.h" -#include "mongoc-client-private.h" -#include "mongoc-counters-private.h" -#include "mongoc-error.h" -#include "mongoc-log.h" -#include "mongoc-trace-private.h" -#include "mongoc-read-concern-private.h" -#include "mongoc-util-private.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-read-prefs-private.h" -#include "mongoc-rpc-private.h" - -#include - -static bool -_mongoc_cursor_monitor_legacy_get_more (mongoc_cursor_t *cursor, - mongoc_server_stream_t *server_stream) -{ - bson_t doc; - char *db; - mongoc_client_t *client; - mongoc_apm_command_started_t event; - - ENTRY; - - client = cursor->client; - if (!client->apm_callbacks.started) { - /* successful */ - RETURN (true); - } - - _mongoc_cursor_prepare_getmore_command (cursor, &doc); - - db = bson_strndup (cursor->ns, cursor->dblen); - mongoc_apm_command_started_init (&event, - &doc, - db, - "getMore", - client->cluster.request_id, - cursor->operation_id, - &server_stream->sd->host, - server_stream->sd->id, - &server_stream->sd->service_id, - server_stream->sd->server_connection_id, - NULL, - client->apm_context); - - client->apm_callbacks.started (&event); - mongoc_apm_command_started_cleanup (&event); - bson_destroy (&doc); - bson_free (db); - - RETURN (true); -} - - -static bool -_mongoc_cursor_monitor_legacy_query (mongoc_cursor_t *cursor, - const bson_t *filter, - mongoc_server_stream_t *server_stream) -{ - bson_t doc; - mongoc_client_t *client; - char *db; - bool r; - - ENTRY; - - client = cursor->client; - if (!client->apm_callbacks.started) { - /* successful */ - RETURN (true); - } - - bson_init (&doc); - db = bson_strndup (cursor->ns, cursor->dblen); - - /* simulate a MongoDB 3.2+ "find" command */ - _mongoc_cursor_prepare_find_command (cursor, filter, &doc); - - bsonBuildAppend ( - cursor->opts, - insert (doc, not(key ("serverId", "maxAwaitTimeMS", "sessionId")))); - - r = _mongoc_cursor_monitor_command (cursor, server_stream, &doc, "find"); - - bson_destroy (&doc); - bson_free (db); - - RETURN (r); -} - - -static bool -_mongoc_cursor_op_getmore_send (mongoc_cursor_t *cursor, - mongoc_server_stream_t *server_stream, - int32_t request_id, - int32_t flags, - mcd_rpc_message *rpc) -{ - BSON_ASSERT_PARAM (cursor); - BSON_ASSERT_PARAM (server_stream); - BSON_ASSERT_PARAM (rpc); - - const int32_t n_return = (flags & MONGOC_OP_QUERY_FLAG_TAILABLE_CURSOR) != 0 - ? 0 - : _mongoc_n_return (cursor); - - { - int32_t message_length = 0; - - message_length += mcd_rpc_header_set_message_length (rpc, 0); - message_length += mcd_rpc_header_set_request_id (rpc, request_id); - message_length += mcd_rpc_header_set_response_to (rpc, 0); - message_length += - mcd_rpc_header_set_op_code (rpc, MONGOC_OP_CODE_GET_MORE); - - message_length += sizeof (int32_t); // ZERO - message_length += - mcd_rpc_op_get_more_set_full_collection_name (rpc, cursor->ns); - message_length += - mcd_rpc_op_get_more_set_number_to_return (rpc, n_return); - message_length += - mcd_rpc_op_get_more_set_cursor_id (rpc, cursor->cursor_id); - - mcd_rpc_message_set_length (rpc, message_length); - } - - if (!_mongoc_cursor_monitor_legacy_get_more (cursor, server_stream)) { - return false; - } - - if (!mongoc_cluster_legacy_rpc_sendv_to_server ( - &cursor->client->cluster, rpc, server_stream, &cursor->error)) { - return false; - } - - return true; -} - -void -_mongoc_cursor_op_getmore (mongoc_cursor_t *cursor, - mongoc_cursor_response_legacy_t *response) -{ - BSON_ASSERT_PARAM (cursor); - BSON_ASSERT_PARAM (response); - - ENTRY; - - const int64_t started = bson_get_monotonic_time (); - - mongoc_server_stream_t *const server_stream = - _mongoc_cursor_fetch_stream (cursor); - - if (!server_stream) { - GOTO (done); - } - - int32_t flags; - if (!_mongoc_cursor_opts_to_flags (cursor, server_stream, &flags)) { - GOTO (fail); - } - mongoc_cluster_t *const cluster = &cursor->client->cluster; - - const int32_t request_id = cursor->in_exhaust - ? mcd_rpc_header_get_request_id (response->rpc) - : ++cluster->request_id; - - if (!cursor->in_exhaust && - !_mongoc_cursor_op_getmore_send ( - cursor, server_stream, request_id, flags, response->rpc)) { - GOTO (fail); - } - - mcd_rpc_message_reset (response->rpc); - _mongoc_buffer_clear (&response->buffer, false); - cursor->cursor_id = 0; - - if (!_mongoc_client_recv (cursor->client, - response->rpc, - &response->buffer, - server_stream, - &cursor->error)) { - GOTO (fail); - } - - const int32_t op_code = mcd_rpc_header_get_op_code (response->rpc); - if (op_code != MONGOC_OP_CODE_REPLY) { - bson_set_error (&cursor->error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid opcode for OP_GET_MORE: expected %" PRId32 - ", got %" PRId32, - MONGOC_OP_CODE_REPLY, - op_code); - GOTO (fail); - } - - const int32_t response_to = mcd_rpc_header_get_response_to (response->rpc); - if (response_to != request_id) { - bson_set_error (&cursor->error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid response_to for OP_GET_MORE: expected %" PRId32 - ", got %" PRId32, - request_id, - response_to); - GOTO (fail); - } - - if (!mcd_rpc_message_check_ok (response->rpc, - cursor->client->error_api_version, - &cursor->error, - &cursor->error_doc)) { - GOTO (fail); - } - - if (response->reader) { - bson_reader_destroy (response->reader); - } - - cursor->cursor_id = mcd_rpc_op_reply_get_cursor_id (response->rpc); - - const void *documents = mcd_rpc_op_reply_get_documents (response->rpc); - if (documents == NULL) { - // Use a non-NULL pointer to satisfy precondition of - // `bson_reader_new_from_data`: - documents = ""; - } - - response->reader = bson_reader_new_from_data (documents, mcd_rpc_op_reply_get_documents_len (response->rpc)); - - _mongoc_cursor_monitor_succeeded (cursor, - response, - bson_get_monotonic_time () - started, - false, /* not first batch */ - server_stream, - "getMore"); - - GOTO (done); - -fail: - _mongoc_cursor_monitor_failed ( - cursor, bson_get_monotonic_time () - started, server_stream, "getMore"); - -done: - mongoc_server_stream_cleanup (server_stream); -} - - -#define OPT_CHECK(_type) \ - do { \ - if (!BSON_ITER_HOLDS_##_type (&iter)) { \ - bson_set_error (&cursor->error, \ - MONGOC_ERROR_COMMAND, \ - MONGOC_ERROR_COMMAND_INVALID_ARG, \ - "invalid option %s, should be type %s", \ - key, \ - #_type); \ - return NULL; \ - } \ - } while (false) - - -#define OPT_CHECK_INT() \ - do { \ - if (!BSON_ITER_HOLDS_INT (&iter)) { \ - bson_set_error (&cursor->error, \ - MONGOC_ERROR_COMMAND, \ - MONGOC_ERROR_COMMAND_INVALID_ARG, \ - "invalid option %s, should be integer", \ - key); \ - return NULL; \ - } \ - } while (false) - - -#define OPT_ERR(_msg) \ - do { \ - bson_set_error (&cursor->error, \ - MONGOC_ERROR_COMMAND, \ - MONGOC_ERROR_COMMAND_INVALID_ARG, \ - _msg); \ - return NULL; \ - } while (false) - - -#define OPT_BSON_ERR(_msg) \ - do { \ - bson_set_error ( \ - &cursor->error, MONGOC_ERROR_BSON, MONGOC_ERROR_BSON_INVALID, _msg); \ - return NULL; \ - } while (false) - - -#define OPT_FLAG(_flag) \ - do { \ - OPT_CHECK (BOOL); \ - if (bson_iter_as_bool (&iter)) { \ - *flags |= _flag; \ - } \ - } while (false) - - -#define PUSH_DOLLAR_QUERY() \ - do { \ - if (!pushed_dollar_query) { \ - pushed_dollar_query = true; \ - bson_append_document (query, "$query", 6, filter); \ - } \ - } while (false) - - -#define OPT_SUBDOCUMENT(_opt_name, _legacy_name) \ - do { \ - OPT_CHECK (DOCUMENT); \ - bson_iter_document (&iter, &len, &data); \ - if (!bson_init_static (&subdocument, data, (size_t) len)) { \ - OPT_BSON_ERR ("Invalid '" #_opt_name "' subdocument in 'opts'."); \ - } \ - BSON_APPEND_DOCUMENT (query, "$" #_legacy_name, &subdocument); \ - } while (false) - -static bson_t * -_mongoc_cursor_parse_opts_for_op_query (mongoc_cursor_t *cursor, - mongoc_server_stream_t *stream, - bson_t *filter, - bson_t *query /* OUT */, - bson_t *fields /* OUT */, - int32_t *flags /* OUT */, - int32_t *skip /* OUT */) -{ - bool pushed_dollar_query; - bson_iter_t iter; - uint32_t len; - const uint8_t *data; - bson_t subdocument; - const char *key; - char *dollar_modifier; - - *flags = MONGOC_OP_QUERY_FLAG_NONE; - *skip = 0; - - /* assume we'll send filter straight to server, like "{a: 1}". if we find an - * opt we must add, like "sort", we push the query like "$query: {a: 1}", - * then add a query modifier for the option, in this example "$orderby". - */ - pushed_dollar_query = false; - - if (!bson_iter_init (&iter, &cursor->opts)) { - OPT_BSON_ERR ("Invalid 'opts' parameter."); - } - - while (bson_iter_next (&iter)) { - key = bson_iter_key (&iter); - - /* most common options first */ - if (!strcmp (key, MONGOC_CURSOR_PROJECTION)) { - OPT_CHECK (DOCUMENT); - bson_iter_document (&iter, &len, &data); - if (!bson_init_static (&subdocument, data, (size_t) len)) { - OPT_BSON_ERR ("Invalid 'projection' subdocument in 'opts'."); - } - bson_destroy (fields); - bson_copy_to (&subdocument, fields); - } else if (!strcmp (key, MONGOC_CURSOR_SORT)) { - PUSH_DOLLAR_QUERY (); - OPT_SUBDOCUMENT (sort, orderby); - } else if (!strcmp (key, MONGOC_CURSOR_SKIP)) { - OPT_CHECK_INT (); - *skip = (int32_t) bson_iter_as_int64 (&iter); - } - /* the rest of the options, alphabetically */ - else if (!strcmp (key, MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS)) { - OPT_FLAG (MONGOC_OP_QUERY_FLAG_PARTIAL); - } else if (!strcmp (key, MONGOC_CURSOR_AWAIT_DATA)) { - OPT_FLAG (MONGOC_OP_QUERY_FLAG_AWAIT_DATA); - } else if (!strcmp (key, MONGOC_CURSOR_COMMENT)) { - OPT_CHECK (UTF8); - PUSH_DOLLAR_QUERY (); - BSON_APPEND_UTF8 (query, "$comment", bson_iter_utf8 (&iter, NULL)); - } else if (!strcmp (key, MONGOC_CURSOR_HINT)) { - if (BSON_ITER_HOLDS_UTF8 (&iter)) { - PUSH_DOLLAR_QUERY (); - BSON_APPEND_UTF8 (query, "$hint", bson_iter_utf8 (&iter, NULL)); - } else if (BSON_ITER_HOLDS_DOCUMENT (&iter)) { - PUSH_DOLLAR_QUERY (); - OPT_SUBDOCUMENT (hint, hint); - } else { - OPT_ERR ("Wrong type for 'hint' field in 'opts'."); - } - } else if (!strcmp (key, MONGOC_CURSOR_MAX)) { - PUSH_DOLLAR_QUERY (); - OPT_SUBDOCUMENT (max, max); - } else if (!strcmp (key, MONGOC_CURSOR_MAX_SCAN)) { - OPT_CHECK_INT (); - PUSH_DOLLAR_QUERY (); - BSON_APPEND_INT64 (query, "$maxScan", bson_iter_as_int64 (&iter)); - } else if (!strcmp (key, MONGOC_CURSOR_MAX_TIME_MS)) { - OPT_CHECK_INT (); - PUSH_DOLLAR_QUERY (); - BSON_APPEND_INT64 (query, "$maxTimeMS", bson_iter_as_int64 (&iter)); - } else if (!strcmp (key, MONGOC_CURSOR_MIN)) { - PUSH_DOLLAR_QUERY (); - OPT_SUBDOCUMENT (min, min); - } else if (!strcmp (key, MONGOC_CURSOR_READ_CONCERN)) { - OPT_ERR ("Set readConcern on client, database, or collection," - " not in a query."); - } else if (!strcmp (key, MONGOC_CURSOR_RETURN_KEY)) { - OPT_CHECK (BOOL); - PUSH_DOLLAR_QUERY (); - BSON_APPEND_BOOL (query, "$returnKey", bson_iter_as_bool (&iter)); - } else if (!strcmp (key, MONGOC_CURSOR_SHOW_RECORD_ID)) { - OPT_CHECK (BOOL); - PUSH_DOLLAR_QUERY (); - BSON_APPEND_BOOL (query, "$showDiskLoc", bson_iter_as_bool (&iter)); - } else if (!strcmp (key, MONGOC_CURSOR_SNAPSHOT)) { - OPT_CHECK (BOOL); - PUSH_DOLLAR_QUERY (); - BSON_APPEND_BOOL (query, "$snapshot", bson_iter_as_bool (&iter)); - } else if (!strcmp (key, MONGOC_CURSOR_COLLATION)) { - bson_set_error (&cursor->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "The selected server does not support collation"); - return NULL; - } - /* singleBatch limit and batchSize are handled in _mongoc_n_return, - * exhaust noCursorTimeout oplogReplay tailable in _mongoc_cursor_flags - * maxAwaitTimeMS is handled in _mongoc_cursor_prepare_getmore_command - * sessionId is used to retrieve the mongoc_client_session_t - */ - else if (strcmp (key, MONGOC_CURSOR_SINGLE_BATCH) && - strcmp (key, MONGOC_CURSOR_LIMIT) && - strcmp (key, MONGOC_CURSOR_BATCH_SIZE) && - strcmp (key, MONGOC_CURSOR_EXHAUST) && - strcmp (key, MONGOC_CURSOR_NO_CURSOR_TIMEOUT) && - strcmp (key, MONGOC_CURSOR_OPLOG_REPLAY) && - strcmp (key, MONGOC_CURSOR_TAILABLE) && - strcmp (key, MONGOC_CURSOR_MAX_AWAIT_TIME_MS)) { - /* pass unrecognized options to server, prefixed with $ */ - PUSH_DOLLAR_QUERY (); - dollar_modifier = bson_strdup_printf ("$%s", key); - if (!bson_append_iter (query, dollar_modifier, -1, &iter)) { - bson_set_error (&cursor->error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Error adding \"%s\" to query", - dollar_modifier); - bson_free (dollar_modifier); - return NULL; - } - bson_free (dollar_modifier); - } - } - - if (!_mongoc_cursor_opts_to_flags (cursor, stream, flags)) { - /* cursor->error is set */ - return NULL; - } - - return pushed_dollar_query ? query : filter; -} - -#undef OPT_CHECK -#undef OPT_ERR -#undef OPT_BSON_ERR -#undef OPT_FLAG -#undef OPT_SUBDOCUMENT - - -static bool -_mongoc_cursor_op_query_find_send (mongoc_cursor_t *cursor, - mongoc_server_stream_t *server_stream, - int32_t request_id, - bson_t *filter, - mcd_rpc_message *rpc) -{ - bool ret = false; - - cursor->operation_id = ++cursor->client->cluster.operation_id; - - mongoc_assemble_query_result_t result = ASSEMBLE_QUERY_RESULT_INIT; - bson_t query = BSON_INITIALIZER; - bson_t fields = BSON_INITIALIZER; - int32_t skip; - int32_t flags; - const bson_t *const query_ptr = _mongoc_cursor_parse_opts_for_op_query ( - cursor, server_stream, filter, &query, &fields, &flags, &skip); - - if (!query_ptr) { - GOTO (done); - } - - assemble_query ( - cursor->read_prefs, server_stream, query_ptr, flags, &result); - - { - int32_t message_length = 0; - - message_length += mcd_rpc_header_set_message_length (rpc, 0); - message_length += mcd_rpc_header_set_request_id (rpc, request_id); - message_length += mcd_rpc_header_set_response_to (rpc, 0); - message_length += mcd_rpc_header_set_op_code (rpc, MONGOC_OP_CODE_QUERY); - - message_length += mcd_rpc_op_query_set_flags (rpc, result.flags); - message_length += - mcd_rpc_op_query_set_full_collection_name (rpc, cursor->ns); - message_length += mcd_rpc_op_query_set_number_to_skip (rpc, skip); - message_length += - mcd_rpc_op_query_set_number_to_return (rpc, _mongoc_n_return (cursor)); - message_length += mcd_rpc_op_query_set_query ( - rpc, bson_get_data (result.assembled_query)); - - if (!bson_empty (&fields)) { - message_length += mcd_rpc_op_query_set_return_fields_selector ( - rpc, bson_get_data (&fields)); - } - - mcd_rpc_message_set_length (rpc, message_length); - } - - if (!_mongoc_cursor_monitor_legacy_query (cursor, filter, server_stream)) { - GOTO (done); - } - - if (!mongoc_cluster_legacy_rpc_sendv_to_server ( - &cursor->client->cluster, rpc, server_stream, &cursor->error)) { - GOTO (done); - } - - ret = true; - -done: - assemble_query_result_cleanup (&result); - bson_destroy (&fields); - bson_destroy (&query); - - return ret; -} - -bool -_mongoc_cursor_op_query_find (mongoc_cursor_t *cursor, - bson_t *filter, - mongoc_cursor_response_legacy_t *response) -{ - BSON_ASSERT_PARAM (cursor); - BSON_ASSERT_PARAM (filter); - BSON_ASSERT_PARAM (response); - - ENTRY; - - bool ret = false; - - mongoc_server_stream_t *const server_stream = - _mongoc_cursor_fetch_stream (cursor); - - if (!server_stream) { - RETURN (false); - } - - const int64_t started = bson_get_monotonic_time (); - const int32_t request_id = ++cursor->client->cluster.request_id; - mcd_rpc_message *const rpc = mcd_rpc_message_new (); - - if (!_mongoc_cursor_op_query_find_send ( - cursor, server_stream, request_id, filter, rpc)) { - GOTO (done); - } - - mcd_rpc_message_reset (rpc); - _mongoc_buffer_clear (&response->buffer, false); - - if (!_mongoc_client_recv (cursor->client, - response->rpc, - &response->buffer, - server_stream, - &cursor->error)) { - GOTO (done); - } - - const int32_t op_code = mcd_rpc_header_get_op_code (response->rpc); - if (op_code != MONGOC_OP_CODE_REPLY) { - bson_set_error (&cursor->error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid opcode for OP_QUERY: expected %" PRId32 - ", got %" PRId32, - MONGOC_OP_CODE_REPLY, - op_code); - GOTO (done); - } - - const int32_t response_to = mcd_rpc_header_get_response_to (response->rpc); - if (response_to != request_id) { - bson_set_error (&cursor->error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid response_to for OP_QUERY: expected %" PRId32 - ", got %" PRId32, - request_id, - response_to); - GOTO (done); - } - - if (!mcd_rpc_message_check_ok (response->rpc, - cursor->client->error_api_version, - &cursor->error, - &cursor->error_doc)) { - GOTO (done); - } - - if (response->reader) { - bson_reader_destroy (response->reader); - } - - cursor->cursor_id = mcd_rpc_op_reply_get_cursor_id (response->rpc); - - const void *documents = mcd_rpc_op_reply_get_documents (response->rpc); - if (documents == NULL) { - // Use a non-NULL pointer to satisfy precondition of - // `bson_reader_new_from_data`: - documents = ""; - } - - response->reader = bson_reader_new_from_data (documents, mcd_rpc_op_reply_get_documents_len (response->rpc)); - - if (_mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_EXHAUST)) { - cursor->in_exhaust = true; - cursor->client->in_exhaust = true; - } - - _mongoc_cursor_monitor_succeeded (cursor, - response, - bson_get_monotonic_time () - started, - true, /* first_batch */ - server_stream, - "find"); - - ret = true; - -done: - if (!ret) { - _mongoc_cursor_monitor_failed ( - cursor, bson_get_monotonic_time () - started, server_stream, "find"); - } - - mcd_rpc_message_destroy (rpc); - mongoc_server_stream_cleanup (server_stream); - - return ret; -} - - -void -_mongoc_cursor_response_legacy_init (mongoc_cursor_response_legacy_t *response) -{ - response->rpc = mcd_rpc_message_new (); - _mongoc_buffer_init (&response->buffer, NULL, 0, NULL, NULL); -} - - -void -_mongoc_cursor_response_legacy_destroy ( - mongoc_cursor_response_legacy_t *response) -{ - if (response->reader) { - bson_reader_destroy (response->reader); - response->reader = NULL; - } - _mongoc_buffer_destroy (&response->buffer); - mcd_rpc_message_destroy (response->rpc); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor-private.h deleted file mode 100644 index 98cb8e4d3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor-private.h +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_CURSOR_PRIVATE_H -#define MONGOC_CURSOR_PRIVATE_H - -#include - -#include "mongoc-client.h" -#include "mongoc-buffer-private.h" -#include "mongoc-rpc-private.h" -#include "mongoc-server-stream-private.h" -#include "mongoc-cluster-private.h" - - -BSON_BEGIN_DECLS - -#define MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS "allowPartialResults" -#define MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS_LEN 19 -#define MONGOC_CURSOR_AWAIT_DATA "awaitData" -#define MONGOC_CURSOR_AWAIT_DATA_LEN 9 -#define MONGOC_CURSOR_BATCH_SIZE "batchSize" -#define MONGOC_CURSOR_BATCH_SIZE_LEN 9 -#define MONGOC_CURSOR_COLLATION "collation" -#define MONGOC_CURSOR_COLLATION_LEN 9 -#define MONGOC_CURSOR_COMMENT "comment" -#define MONGOC_CURSOR_COMMENT_LEN 7 -#define MONGOC_CURSOR_EXHAUST "exhaust" -#define MONGOC_CURSOR_EXHAUST_LEN 7 -#define MONGOC_CURSOR_FILTER "filter" -#define MONGOC_CURSOR_FILTER_LEN 6 -#define MONGOC_CURSOR_FIND "find" -#define MONGOC_CURSOR_FIND_LEN 4 -#define MONGOC_CURSOR_HINT "hint" -#define MONGOC_CURSOR_HINT_LEN 4 -#define MONGOC_CURSOR_LIMIT "limit" -#define MONGOC_CURSOR_LIMIT_LEN 5 -#define MONGOC_CURSOR_MAX "max" -#define MONGOC_CURSOR_MAX_LEN 3 -#define MONGOC_CURSOR_MAX_AWAIT_TIME_MS "maxAwaitTimeMS" -#define MONGOC_CURSOR_MAX_AWAIT_TIME_MS_LEN 14 -#define MONGOC_CURSOR_MAX_SCAN "maxScan" -#define MONGOC_CURSOR_MAX_SCAN_LEN 7 -#define MONGOC_CURSOR_MAX_TIME_MS "maxTimeMS" -#define MONGOC_CURSOR_MAX_TIME_MS_LEN 9 -#define MONGOC_CURSOR_MIN "min" -#define MONGOC_CURSOR_MIN_LEN 3 -#define MONGOC_CURSOR_NO_CURSOR_TIMEOUT "noCursorTimeout" -#define MONGOC_CURSOR_NO_CURSOR_TIMEOUT_LEN 15 -#define MONGOC_CURSOR_OPLOG_REPLAY "oplogReplay" -#define MONGOC_CURSOR_OPLOG_REPLAY_LEN 11 -#define MONGOC_CURSOR_ORDERBY "orderby" -#define MONGOC_CURSOR_ORDERBY_LEN 7 -#define MONGOC_CURSOR_PROJECTION "projection" -#define MONGOC_CURSOR_PROJECTION_LEN 10 -#define MONGOC_CURSOR_QUERY "query" -#define MONGOC_CURSOR_QUERY_LEN 5 -#define MONGOC_CURSOR_READ_CONCERN "readConcern" -#define MONGOC_CURSOR_READ_CONCERN_LEN 11 -#define MONGOC_CURSOR_RETURN_KEY "returnKey" -#define MONGOC_CURSOR_RETURN_KEY_LEN 9 -#define MONGOC_CURSOR_SHOW_DISK_LOC "showDiskLoc" -#define MONGOC_CURSOR_SHOW_DISK_LOC_LEN 11 -#define MONGOC_CURSOR_SHOW_RECORD_ID "showRecordId" -#define MONGOC_CURSOR_SHOW_RECORD_ID_LEN 12 -#define MONGOC_CURSOR_SINGLE_BATCH "singleBatch" -#define MONGOC_CURSOR_SINGLE_BATCH_LEN 11 -#define MONGOC_CURSOR_SKIP "skip" -#define MONGOC_CURSOR_SKIP_LEN 4 -#define MONGOC_CURSOR_SNAPSHOT "snapshot" -#define MONGOC_CURSOR_SNAPSHOT_LEN 8 -#define MONGOC_CURSOR_SORT "sort" -#define MONGOC_CURSOR_SORT_LEN 4 -#define MONGOC_CURSOR_TAILABLE "tailable" -#define MONGOC_CURSOR_TAILABLE_LEN 8 - -typedef struct _mongoc_cursor_impl_t mongoc_cursor_impl_t; -typedef enum { UNPRIMED, IN_BATCH, END_OF_BATCH, DONE } mongoc_cursor_state_t; -typedef mongoc_cursor_state_t (*_mongoc_cursor_impl_transition_t) ( - mongoc_cursor_t *cursor); -struct _mongoc_cursor_impl_t { - void (*clone) (mongoc_cursor_impl_t *dst, const mongoc_cursor_impl_t *src); - void (*destroy) (mongoc_cursor_impl_t *ctx); - _mongoc_cursor_impl_transition_t prime; - _mongoc_cursor_impl_transition_t pop_from_batch; - _mongoc_cursor_impl_transition_t get_next_batch; - void *data; -}; - -/* pre-3.2 and exhaust cursor responses -- read documents from stream. */ -typedef struct _mongoc_cursor_response_legacy { - mcd_rpc_message *rpc; - mongoc_buffer_t buffer; - bson_reader_t *reader; -} mongoc_cursor_response_legacy_t; - -/* 3.2+ responses -- read batch docs like {cursor:{id: 123, firstBatch: []}} */ -typedef struct _mongoc_cursor_response_t { - bson_t reply; /* the entire command reply */ - bson_iter_t batch_iter; /* iterates over the batch array */ - bson_t current_doc; /* the current doc inside the batch array */ -} mongoc_cursor_response_t; - -struct _mongoc_cursor_t { - mongoc_client_t *client; - uint32_t client_generation; - - uint32_t server_id; - bool secondary_ok; - - mongoc_cursor_state_t state; - bool in_exhaust; - - bson_t opts; - - mongoc_read_concern_t *read_concern; - mongoc_read_prefs_t *read_prefs; - mongoc_write_concern_t *write_concern; - - /** If the cursor was created for an operation that might have overridden the - * user's read preferences' read mode, then server selection forced the - * cursor to use a read preference mode of 'primary' server. Whether this - * force occurred is stored here: */ - bool must_use_primary; - - /** Whether this cursor corresponds to an aggregate command that contains a - * writing-stage */ - bool is_aggr_with_write_stage; - - bool explicit_session; - mongoc_client_session_t *client_session; - - uint32_t count; - - char *ns; - uint32_t nslen; - uint32_t dblen; - - bson_error_t error; - bson_t error_doc; /* always initialized, and set with server errors. */ - - const bson_t *current; - - mongoc_cursor_impl_t impl; - - int64_t operation_id; - int64_t cursor_id; -}; - -int32_t -_mongoc_n_return (mongoc_cursor_t *cursor); -void -_mongoc_set_cursor_ns (mongoc_cursor_t *cursor, const char *ns, uint32_t nslen); -bool -_mongoc_cursor_get_opt_bool (const mongoc_cursor_t *cursor, const char *option); -void -_mongoc_cursor_flags_to_opts (mongoc_query_flags_t qflags, - bson_t *opts, - bool *secondary_ok); -bool -_mongoc_cursor_translate_dollar_query_opts (const bson_t *query, - bson_t *opts, - bson_t *unwrapped, - bson_error_t *error); -mongoc_server_stream_t * -_mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor); -void -_mongoc_cursor_collection (const mongoc_cursor_t *cursor, - const char **collection, - int *collection_len); -bool -_mongoc_cursor_run_command (mongoc_cursor_t *cursor, - const bson_t *command, - const bson_t *opts, - bson_t *reply, - bool retry_prohibited); -bool -_mongoc_cursor_more (mongoc_cursor_t *cursor); - -bool -_mongoc_cursor_set_opt_int64 (mongoc_cursor_t *cursor, - const char *option, - int64_t value); -void -_mongoc_cursor_monitor_failed (mongoc_cursor_t *cursor, - int64_t duration, - mongoc_server_stream_t *stream, - const char *cmd_name); -bool -_mongoc_cursor_monitor_command (mongoc_cursor_t *cursor, - mongoc_server_stream_t *server_stream, - const bson_t *cmd, - const char *cmd_name); -void -_mongoc_cursor_prepare_find_command (mongoc_cursor_t *cursor, - const bson_t *filter, - bson_t *command); -const bson_t * -_mongoc_cursor_initial_query (mongoc_cursor_t *cursor); -const bson_t * -_mongoc_cursor_get_more (mongoc_cursor_t *cursor); -bool -_mongoc_cursor_opts_to_flags (mongoc_cursor_t *cursor, - mongoc_server_stream_t *stream, - int32_t *flags /* OUT */); -bool -_mongoc_cursor_use_op_msg (const mongoc_cursor_t *cursor, int32_t wire_version); -void -_mongoc_cursor_monitor_succeeded (mongoc_cursor_t *cursor, - mongoc_cursor_response_legacy_t *response, - int64_t duration, - bool first_batch, - mongoc_server_stream_t *stream, - const char *cmd_name); -/* start iterating a reply like - * {cursor: {id: 1234, ns: "db.collection", firstBatch: [...]}} or - * {cursor: {id: 1234, ns: "db.collection", nextBatch: [...]}} */ -void -_mongoc_cursor_response_refresh (mongoc_cursor_t *cursor, - const bson_t *command, - const bson_t *opts, - mongoc_cursor_response_t *response); -bool -_mongoc_cursor_start_reading_response (mongoc_cursor_t *cursor, - mongoc_cursor_response_t *response); -void -_mongoc_cursor_response_read (mongoc_cursor_t *cursor, - mongoc_cursor_response_t *response, - const bson_t **bson); -void -_mongoc_cursor_prepare_getmore_command (mongoc_cursor_t *cursor, - bson_t *command); -void -_mongoc_cursor_set_empty (mongoc_cursor_t *cursor); -bool -_mongoc_cursor_check_and_copy_to (mongoc_cursor_t *cursor, - const char *err_prefix, - const bson_t *src, - bson_t *dst); -void -_mongoc_cursor_prime (mongoc_cursor_t *cursor); -/* legacy functions defined in mongoc-cursor-legacy.c */ -bool -_mongoc_cursor_next (mongoc_cursor_t *cursor, const bson_t **bson); -bool -_mongoc_cursor_op_query_find (mongoc_cursor_t *cursor, - bson_t *filter, - mongoc_cursor_response_legacy_t *response); -void -_mongoc_cursor_op_getmore (mongoc_cursor_t *cursor, - mongoc_cursor_response_legacy_t *response); -mongoc_cursor_t * -_mongoc_cursor_new_with_opts (mongoc_client_t *client, - const char *db_and_collection, - const bson_t *opts, - const mongoc_read_prefs_t *user_prefs, - const mongoc_read_prefs_t *default_prefs, - const mongoc_read_concern_t *read_concern); -void -_mongoc_cursor_response_legacy_init (mongoc_cursor_response_legacy_t *response); -void -_mongoc_cursor_response_legacy_destroy ( - mongoc_cursor_response_legacy_t *response); -/* cursor constructors. */ -mongoc_cursor_t * -_mongoc_cursor_find_new (mongoc_client_t *client, - const char *db_and_coll, - const bson_t *filter, - const bson_t *opts, - const mongoc_read_prefs_t *user_prefs, - const mongoc_read_prefs_t *default_prefs, - const mongoc_read_concern_t *read_concern); - -mongoc_cursor_t * -_mongoc_cursor_cmd_new (mongoc_client_t *client, - const char *db_and_coll, - const bson_t *cmd, - const bson_t *opts, - const mongoc_read_prefs_t *user_prefs, - const mongoc_read_prefs_t *default_prefs, - const mongoc_read_concern_t *read_concern); - -mongoc_cursor_t * -_mongoc_cursor_cmd_new_from_reply (mongoc_client_t *client, - const bson_t *cmd, - const bson_t *opts, - bson_t *reply); - -mongoc_cursor_t * -_mongoc_cursor_cmd_deprecated_new (mongoc_client_t *client, - const char *db_and_coll, - const bson_t *cmd, - const mongoc_read_prefs_t *read_prefs); - -mongoc_cursor_t * -_mongoc_cursor_array_new (mongoc_client_t *client, - const char *db_and_coll, - const bson_t *cmd, - const bson_t *opts, - const char *field_name); - -mongoc_cursor_t * -_mongoc_cursor_change_stream_new (mongoc_client_t *client, - bson_t *reply, - const bson_t *opts); - -bool -_mongoc_cursor_change_stream_end_of_batch (mongoc_cursor_t *cursor); - -const bson_t * -_mongoc_cursor_change_stream_get_post_batch_resume_token ( - mongoc_cursor_t *cursor); - -bool -_mongoc_cursor_change_stream_has_post_batch_resume_token ( - mongoc_cursor_t *cursor); - -const bson_t * -_mongoc_cursor_change_stream_get_reply (mongoc_cursor_t *cursor); - -BSON_END_DECLS - - -#endif /* MONGOC_CURSOR_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor.c deleted file mode 100644 index 8e39e3bc1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor.c +++ /dev/null @@ -1,1851 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-cursor.h" -#include "mongoc-cursor-private.h" -#include "mongoc-client-private.h" -#include "mongoc-client-session-private.h" -#include "mongoc-counters-private.h" -#include "mongoc-error.h" -#include "mongoc-error-private.h" -#include "mongoc-log.h" -#include "mongoc-trace-private.h" -#include "mongoc-read-concern-private.h" -#include "mongoc-util-private.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-read-prefs-private.h" -#include "mongoc-aggregate-private.h" - -#include - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "cursor" - - -#define CURSOR_FAILED(cursor_) ((cursor_)->error.domain != 0) - -static bool -_translate_query_opt (const char *query_field, - const char **cmd_field, - int *len); - - -bool -_mongoc_cursor_set_opt_int64 (mongoc_cursor_t *cursor, - const char *option, - int64_t value) -{ - bson_iter_t iter; - - if (bson_iter_init_find (&iter, &cursor->opts, option)) { - if (!BSON_ITER_HOLDS_INT64 (&iter)) { - return false; - } - - bson_iter_overwrite_int64 (&iter, value); - return true; - } - - return BSON_APPEND_INT64 (&cursor->opts, option, value); -} - - -static int64_t -_mongoc_cursor_get_opt_int64 (const mongoc_cursor_t *cursor, - const char *option, - int64_t default_value) -{ - bson_iter_t iter; - - if (bson_iter_init_find (&iter, &cursor->opts, option)) { - return bson_iter_as_int64 (&iter); - } - - return default_value; -} - - -static bool -_mongoc_cursor_set_opt_bool (mongoc_cursor_t *cursor, - const char *option, - bool value) -{ - bson_iter_t iter; - - if (bson_iter_init_find (&iter, &cursor->opts, option)) { - if (!BSON_ITER_HOLDS_BOOL (&iter)) { - return false; - } - - bson_iter_overwrite_bool (&iter, value); - return true; - } - - return BSON_APPEND_BOOL (&cursor->opts, option, value); -} - - -bool -_mongoc_cursor_get_opt_bool (const mongoc_cursor_t *cursor, const char *option) -{ - bson_iter_t iter; - - if (bson_iter_init_find (&iter, &cursor->opts, option)) { - return bson_iter_as_bool (&iter); - } - - return false; -} - - -int32_t -_mongoc_n_return (mongoc_cursor_t *cursor) -{ - int64_t limit; - int64_t batch_size; - int64_t n_return; - - /* calculate numberToReturn according to: - * https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#combining-limit-and-batch-size-for-the-wire-protocol - */ - limit = mongoc_cursor_get_limit (cursor); - batch_size = mongoc_cursor_get_batch_size (cursor); - - if (limit < 0) { - n_return = limit; - } else if (limit == 0) { - n_return = batch_size; - } else if (batch_size == 0) { - n_return = limit; - } else if (limit < batch_size) { - n_return = limit; - } else { - n_return = batch_size; - } - - /* if a specified limit exists, account for documents already returned. */ - if (limit > 0 && cursor->count) { - int64_t remaining = limit - cursor->count; - /* remaining can be 0 if we have retrieved "limit" documents, but still - * have a cursor id: SERVER-21086. use nonzero batchSize to fetch final - * empty batch and trigger server to close cursor. */ - if (remaining <= 0) { - return 1; - } - - n_return = BSON_MIN (n_return, remaining); - } - - /* check boundary conditions */ - if (n_return < INT32_MIN) { - return INT32_MIN; - } else if (n_return > INT32_MAX) { - return INT32_MAX; - } else { - return (int32_t) n_return; - } -} - - -void -_mongoc_set_cursor_ns (mongoc_cursor_t *cursor, const char *ns, uint32_t nslen) -{ - const char *dot; - - bson_free (cursor->ns); - cursor->ns = bson_strndup (ns, nslen); - cursor->nslen = nslen; - dot = strstr (cursor->ns, "."); - - if (dot) { - cursor->dblen = (uint32_t) (dot - cursor->ns); - } else { - /* a database name with no collection name */ - cursor->dblen = cursor->nslen; - } -} - - -/* return first key beginning with $, or NULL. precondition: bson is valid. */ -static const char * -_first_dollar_field (const bson_t *bson) -{ - bson_iter_t iter; - const char *key; - - BSON_ASSERT (bson_iter_init (&iter, bson)); - while (bson_iter_next (&iter)) { - key = bson_iter_key (&iter); - - if (key[0] == '$') { - return key; - } - } - - return NULL; -} - - -/* if src is non-NULL, it is validated and copied to dst. returns false and - * sets the cursor error if validation fails. */ -bool -_mongoc_cursor_check_and_copy_to (mongoc_cursor_t *cursor, - const char *err_prefix, - const bson_t *src, - bson_t *dst) -{ - bson_error_t validate_err; - bson_init (dst); - if (src) { - if (!bson_validate_with_error ( - src, BSON_VALIDATE_EMPTY_KEYS, &validate_err)) { - bson_set_error (&cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Invalid %s: %s", - err_prefix, - validate_err.message); - return false; - } - - bson_destroy (dst); - bson_copy_to (src, dst); - } - return true; -} - - -mongoc_cursor_t * -_mongoc_cursor_new_with_opts (mongoc_client_t *client, - const char *db_and_collection, - const bson_t *opts, - const mongoc_read_prefs_t *user_prefs, - const mongoc_read_prefs_t *default_prefs, - const mongoc_read_concern_t *read_concern) -{ - mongoc_cursor_t *cursor; - uint32_t server_id; - mongoc_read_concern_t *read_concern_local = NULL; - bson_error_t validate_err; - const char *dollar_field; - bson_iter_t iter; - - ENTRY; - - BSON_ASSERT_PARAM (client); - - cursor = BSON_ALIGNED_ALLOC0 (mongoc_cursor_t); - cursor->client = client; - cursor->state = UNPRIMED; - cursor->client_generation = client->generation; - cursor->is_aggr_with_write_stage = false; - - bson_init (&cursor->opts); - bson_init (&cursor->error_doc); - - if (opts) { - if (!bson_validate_with_error ( - opts, BSON_VALIDATE_EMPTY_KEYS, &validate_err)) { - bson_set_error (&cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Invalid opts: %s", - validate_err.message); - GOTO (finish); - } - - dollar_field = _first_dollar_field (opts); - if (dollar_field) { - bson_set_error (&cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot use $-modifiers in opts: \"%s\"", - dollar_field); - GOTO (finish); - } - - if (bson_iter_init_find (&iter, opts, "sessionId")) { - if (!_mongoc_client_session_from_iter ( - client, &iter, &cursor->client_session, &cursor->error)) { - GOTO (finish); - } - - cursor->explicit_session = true; - } - - if (bson_iter_init_find (&iter, opts, "readConcern")) { - read_concern_local = - _mongoc_read_concern_new_from_iter (&iter, &cursor->error); - - if (!read_concern_local) { - /* invalid read concern */ - GOTO (finish); - } - - read_concern = read_concern_local; - } - - /* true if there's a valid serverId or no serverId, false on err */ - if (!_mongoc_get_server_id_from_opts (opts, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - &server_id, - &cursor->error)) { - GOTO (finish); - } - - if (server_id) { - (void) mongoc_cursor_set_hint (cursor, server_id); - } - - // Selectively copy the options: - bsonBuildAppend ( - cursor->opts, - insert (*opts, - not(key ("serverId", "sessionId"), - // Drop bypassDocumentValidation if it isn't true: - allOf (key ("bypassDocumentValidation"), isFalse)))); - } - - if (_mongoc_client_session_in_txn (cursor->client_session)) { - if (!IS_PREF_PRIMARY (user_prefs)) { - bson_set_error (&cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Read preference in a transaction must be primary"); - GOTO (finish); - } - - cursor->read_prefs = - mongoc_read_prefs_copy (cursor->client_session->txn.opts.read_prefs); - - if (bson_has_field (opts, "readConcern")) { - bson_set_error (&cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot set read concern after starting transaction"); - GOTO (finish); - } - } else if (user_prefs) { - cursor->read_prefs = mongoc_read_prefs_copy (user_prefs); - } else if (default_prefs) { - cursor->read_prefs = mongoc_read_prefs_copy (default_prefs); - } else { - cursor->read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - } - - cursor->read_concern = read_concern ? mongoc_read_concern_copy (read_concern) - : mongoc_read_concern_new (); - - if (db_and_collection) { - _mongoc_set_cursor_ns ( - cursor, db_and_collection, (uint32_t) strlen (db_and_collection)); - } - - if (_mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_EXHAUST)) { - if (_mongoc_cursor_get_opt_int64 (cursor, MONGOC_CURSOR_LIMIT, 0)) { - bson_set_error (&cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot specify both 'exhaust' and 'limit'."); - GOTO (finish); - } - } - - (void) _mongoc_read_prefs_validate (cursor->read_prefs, &cursor->error); - -finish: - mongoc_read_concern_destroy (read_concern_local); - mongoc_counter_cursors_active_inc (); - - RETURN (cursor); -} - - -static bool -_translate_query_opt (const char *query_field, const char **cmd_field, int *len) -{ - if (query_field[0] != '$') { - *cmd_field = query_field; - *len = -1; - return true; - } - - /* strip the leading '$' */ - query_field++; - - if (!strcmp (MONGOC_CURSOR_ORDERBY, query_field)) { - *cmd_field = MONGOC_CURSOR_SORT; - *len = MONGOC_CURSOR_SORT_LEN; - } else if (!strcmp (MONGOC_CURSOR_SHOW_DISK_LOC, - query_field)) { /* <= MongoDb 3.0 */ - *cmd_field = MONGOC_CURSOR_SHOW_RECORD_ID; - *len = MONGOC_CURSOR_SHOW_RECORD_ID_LEN; - } else if (!strcmp (MONGOC_CURSOR_HINT, query_field)) { - *cmd_field = MONGOC_CURSOR_HINT; - *len = MONGOC_CURSOR_HINT_LEN; - } else if (!strcmp (MONGOC_CURSOR_COMMENT, query_field)) { - *cmd_field = MONGOC_CURSOR_COMMENT; - *len = MONGOC_CURSOR_COMMENT_LEN; - } else if (!strcmp (MONGOC_CURSOR_MAX_SCAN, query_field)) { - *cmd_field = MONGOC_CURSOR_MAX_SCAN; - *len = MONGOC_CURSOR_MAX_SCAN_LEN; - } else if (!strcmp (MONGOC_CURSOR_MAX_TIME_MS, query_field)) { - *cmd_field = MONGOC_CURSOR_MAX_TIME_MS; - *len = MONGOC_CURSOR_MAX_TIME_MS_LEN; - } else if (!strcmp (MONGOC_CURSOR_MAX, query_field)) { - *cmd_field = MONGOC_CURSOR_MAX; - *len = MONGOC_CURSOR_MAX_LEN; - } else if (!strcmp (MONGOC_CURSOR_MIN, query_field)) { - *cmd_field = MONGOC_CURSOR_MIN; - *len = MONGOC_CURSOR_MIN_LEN; - } else if (!strcmp (MONGOC_CURSOR_RETURN_KEY, query_field)) { - *cmd_field = MONGOC_CURSOR_RETURN_KEY; - *len = MONGOC_CURSOR_RETURN_KEY_LEN; - } else if (!strcmp (MONGOC_CURSOR_SNAPSHOT, query_field)) { - *cmd_field = MONGOC_CURSOR_SNAPSHOT; - *len = MONGOC_CURSOR_SNAPSHOT_LEN; - } else { - /* not a special command field, must be a query operator like $or */ - return false; - } - - return true; -} - - -/* set up a new opt bson from older ways of specifying options. - * secondary_ok may be NULL. - * error may be NULL. - */ -void -_mongoc_cursor_flags_to_opts (mongoc_query_flags_t qflags, - bson_t *opts, /* IN/OUT */ - bool *secondary_ok /* OUT */) -{ - ENTRY; - BSON_ASSERT (opts); - - if (secondary_ok) { - *secondary_ok = !!(qflags & MONGOC_QUERY_SECONDARY_OK); - } - - if (qflags & MONGOC_QUERY_TAILABLE_CURSOR) { - bson_append_bool ( - opts, MONGOC_CURSOR_TAILABLE, MONGOC_CURSOR_TAILABLE_LEN, true); - } - - if (qflags & MONGOC_QUERY_OPLOG_REPLAY) { - bson_append_bool (opts, - MONGOC_CURSOR_OPLOG_REPLAY, - MONGOC_CURSOR_OPLOG_REPLAY_LEN, - true); - } - - if (qflags & MONGOC_QUERY_NO_CURSOR_TIMEOUT) { - bson_append_bool (opts, - MONGOC_CURSOR_NO_CURSOR_TIMEOUT, - MONGOC_CURSOR_NO_CURSOR_TIMEOUT_LEN, - true); - } - - if (qflags & MONGOC_QUERY_AWAIT_DATA) { - bson_append_bool ( - opts, MONGOC_CURSOR_AWAIT_DATA, MONGOC_CURSOR_AWAIT_DATA_LEN, true); - } - - if (qflags & MONGOC_QUERY_EXHAUST) { - bson_append_bool ( - opts, MONGOC_CURSOR_EXHAUST, MONGOC_CURSOR_EXHAUST_LEN, true); - } - - if (qflags & MONGOC_QUERY_PARTIAL) { - bson_append_bool (opts, - MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS, - MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS_LEN, - true); - } -} - -/* Checks if the passed query was wrapped in a $query, and if so, parses the - * query modifiers: - * https://www.mongodb.com/docs/manual/reference/operator/query-modifier/ - * and translates them to find command options: - * https://www.mongodb.com/docs/manual/reference/command/find/ - * opts must be initialized, and may already have options set. - * unwrapped must be uninitialized, and will be initialized at return. - * Returns true if query was unwrapped. */ -bool -_mongoc_cursor_translate_dollar_query_opts (const bson_t *query, - bson_t *opts, - bson_t *unwrapped, - bson_error_t *error) -{ - bool has_filter = false; - const char *key; - bson_iter_t iter; - const char *opt_key; - int len; - uint32_t data_len; - const uint8_t *data; - bson_error_t error_local = {0}; - - ENTRY; - BSON_ASSERT (query); - BSON_ASSERT (opts); - /* If the query is explicitly specified wrapped in $query, unwrap it and - * translate the options to new options. */ - if (bson_has_field (query, "$query")) { - /* like "{$query: {a: 1}, $orderby: {b: 1}, $otherModifier: true}" */ - if (!bson_iter_init (&iter, query)) { - bson_set_error (&error_local, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Invalid BSON in query document"); - GOTO (done); - } - while (bson_iter_next (&iter)) { - key = bson_iter_key (&iter); - if (key[0] != '$') { - bson_set_error (&error_local, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot mix $query with non-dollar field '%s'", - key); - GOTO (done); - } - if (!strcmp (key, "$query")) { - /* set "filter" to the incoming document's "$query" */ - bson_iter_document (&iter, &data_len, &data); - if (!bson_init_static (unwrapped, data, (size_t) data_len)) { - bson_set_error (&error_local, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Invalid BSON in $query subdocument"); - GOTO (done); - } - has_filter = true; - } else if (_translate_query_opt (key, &opt_key, &len)) { - /* "$orderby" becomes "sort", etc., "$unknown" -> "unknown" */ - if (!bson_append_iter (opts, opt_key, len, &iter)) { - bson_set_error (&error_local, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Error adding \"%s\" to query", - opt_key); - } - } else { - /* strip leading "$" */ - if (!bson_append_iter (opts, key + 1, -1, &iter)) { - bson_set_error (&error_local, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Error adding \"%s\" to query", - key); - } - } - } - } -done: - if (error) { - memcpy (error, &error_local, sizeof (bson_error_t)); - } - if (!has_filter) { - bson_init (unwrapped); - } - RETURN (has_filter); -} - - -void -mongoc_cursor_destroy (mongoc_cursor_t *cursor) -{ - char *db; - ENTRY; - - if (!cursor) { - EXIT; - } - - if (cursor->impl.destroy) { - cursor->impl.destroy (&cursor->impl); - } - - /* Always close the socket for an exhaust cursor, even if the client was - * reset with mongoc_client_reset. That prevents further use of that socket. - */ - if (cursor->in_exhaust) { - cursor->client->in_exhaust = false; - if (cursor->state != DONE) { - /* The only way to stop an exhaust cursor is to kill the connection - */ - mongoc_cluster_disconnect_node (&cursor->client->cluster, - cursor->server_id); - } - } else if (cursor->client_generation == cursor->client->generation) { - if (cursor->cursor_id) { - db = bson_strndup (cursor->ns, cursor->dblen); - - _mongoc_client_kill_cursor (cursor->client, - cursor->server_id, - cursor->cursor_id, - cursor->operation_id, - db, - cursor->ns + cursor->dblen + 1, - cursor->client_session); - bson_free (db); - } - } - - if (cursor->client_session && !cursor->explicit_session) { - mongoc_client_session_destroy (cursor->client_session); - } - - mongoc_read_prefs_destroy (cursor->read_prefs); - mongoc_read_concern_destroy (cursor->read_concern); - mongoc_write_concern_destroy (cursor->write_concern); - - bson_destroy (&cursor->opts); - bson_destroy (&cursor->error_doc); - bson_free (cursor->ns); - bson_free (cursor); - - mongoc_counter_cursors_active_dec (); - mongoc_counter_cursors_disposed_inc (); - - EXIT; -} - - -mongoc_server_stream_t * -_mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor) -{ - mongoc_server_stream_t *server_stream; - bson_t reply; - - ENTRY; - - if (cursor->server_id) { - /* We already did server selection once before. Reuse the prior - * selection to create a new stream on the same server. */ - server_stream = - mongoc_cluster_stream_for_server (&cursor->client->cluster, - cursor->server_id, - true /* reconnect_ok */, - cursor->client_session, - &reply, - &cursor->error); - if (server_stream) { - /* Also restore whether primary read preference was forced by server - * selection */ - server_stream->must_use_primary = cursor->must_use_primary; - } - } else { - server_stream = - cursor->is_aggr_with_write_stage - ? mongoc_cluster_stream_for_aggr_with_write ( - &cursor->client->cluster, - cursor->read_prefs, - cursor->client_session, - &reply, - &cursor->error) - : mongoc_cluster_stream_for_reads (&cursor->client->cluster, - cursor->read_prefs, - cursor->client_session, - NULL, - &reply, - &cursor->error); - - if (server_stream) { - /* Remember the selected server_id and whether primary read mode was - * forced so that we can re-create an equivalent server_stream at a - * later time */ - cursor->server_id = server_stream->sd->id; - cursor->must_use_primary = server_stream->must_use_primary; - } - } - - if (!server_stream) { - bson_destroy (&cursor->error_doc); - bson_copy_to (&reply, &cursor->error_doc); - bson_destroy (&reply); - } - - RETURN (server_stream); -} - - -bool -_mongoc_cursor_monitor_command (mongoc_cursor_t *cursor, - mongoc_server_stream_t *server_stream, - const bson_t *cmd, - const char *cmd_name) -{ - mongoc_client_t *client; - mongoc_apm_command_started_t event; - char *db; - - ENTRY; - - client = cursor->client; - if (!client->apm_callbacks.started) { - /* successful */ - RETURN (true); - } - - db = bson_strndup (cursor->ns, cursor->dblen); - - mongoc_apm_command_started_init (&event, - cmd, - db, - cmd_name, - client->cluster.request_id, - cursor->operation_id, - &server_stream->sd->host, - server_stream->sd->id, - &server_stream->sd->service_id, - server_stream->sd->server_connection_id, - NULL, - client->apm_context); - - client->apm_callbacks.started (&event); - mongoc_apm_command_started_cleanup (&event); - bson_free (db); - - RETURN (true); -} - - -/* append array of docs from current cursor batch */ -static void -_mongoc_cursor_append_docs_array (mongoc_cursor_t *cursor, - bson_t *docs, - mongoc_cursor_response_legacy_t *response) -{ - bool eof = false; - char str[16]; - const char *key; - uint32_t i = 0; - size_t keylen; - const bson_t *doc; - - BSON_UNUSED (cursor); - - while ((doc = bson_reader_read (response->reader, &eof))) { - keylen = bson_uint32_to_string (i, &key, str, sizeof str); - bson_append_document (docs, key, (int) keylen, doc); - } - - bson_reader_reset (response->reader); -} - - -void -_mongoc_cursor_monitor_succeeded (mongoc_cursor_t *cursor, - mongoc_cursor_response_legacy_t *response, - int64_t duration, - bool first_batch, - mongoc_server_stream_t *stream, - const char *cmd_name) -{ - bson_t docs_array; - mongoc_apm_command_succeeded_t event; - mongoc_client_t *client; - - ENTRY; - - client = cursor->client; - - if (!client->apm_callbacks.succeeded) { - EXIT; - } - - /* we sent OP_QUERY/OP_GETMORE, fake a reply to find/getMore command: - * {ok: 1, cursor: {id: 17, ns: "...", first/nextBatch: [ ... docs ... ]}} - */ - bson_init (&docs_array); - _mongoc_cursor_append_docs_array (cursor, &docs_array, response); - - bsonBuildDecl (reply, - kv ("ok", int32 (1)), - kv ("cursor", - doc (kv ("id", int64 (mongoc_cursor_get_id (cursor))), - kv ("ns", utf8_w_len (cursor->ns, cursor->nslen)), - kv (first_batch ? "firstBatch" : "nextBatch", - bsonArray (docs_array))))); - - bson_destroy (&docs_array); - - mongoc_apm_command_succeeded_init (&event, - duration, - &reply, - cmd_name, - client->cluster.request_id, - cursor->operation_id, - &stream->sd->host, - stream->sd->id, - &stream->sd->service_id, - stream->sd->server_connection_id, - false, - client->apm_context); - - client->apm_callbacks.succeeded (&event); - - mongoc_apm_command_succeeded_cleanup (&event); - bson_destroy (&reply); - - EXIT; -} - - -void -_mongoc_cursor_monitor_failed (mongoc_cursor_t *cursor, - int64_t duration, - mongoc_server_stream_t *stream, - const char *cmd_name) -{ - mongoc_apm_command_failed_t event; - mongoc_client_t *client; - - ENTRY; - - client = cursor->client; - - if (!client->apm_callbacks.failed) { - EXIT; - } - - /* we sent OP_QUERY/OP_GETMORE, fake a reply to find/getMore command: - * {ok: 0} - */ - bsonBuildDecl (reply, kv ("ok", int32 (0))); - - mongoc_apm_command_failed_init (&event, - duration, - cmd_name, - &cursor->error, - &reply, - client->cluster.request_id, - cursor->operation_id, - &stream->sd->host, - stream->sd->id, - &stream->sd->service_id, - stream->sd->server_connection_id, - false, - client->apm_context); - - client->apm_callbacks.failed (&event); - - mongoc_apm_command_failed_cleanup (&event); - bson_destroy (&reply); - - EXIT; -} - - -#define ADD_FLAG(_flags, _value) \ - do { \ - if (!BSON_ITER_HOLDS_BOOL (&iter)) { \ - bson_set_error (&cursor->error, \ - MONGOC_ERROR_COMMAND, \ - MONGOC_ERROR_COMMAND_INVALID_ARG, \ - "invalid option %s, should be type bool", \ - key); \ - return false; \ - } \ - if (bson_iter_as_bool (&iter)) { \ - *_flags |= _value; \ - } \ - } while (false); - -bool -_mongoc_cursor_opts_to_flags (mongoc_cursor_t *cursor, - mongoc_server_stream_t *stream, - int32_t *flags /* OUT */) -{ - /* CDRIVER-4722: these flags are only used in legacy OP_QUERY */ - bson_iter_t iter; - const char *key; - - *flags = MONGOC_OP_QUERY_FLAG_NONE; - - if (!bson_iter_init (&iter, &cursor->opts)) { - bson_set_error (&cursor->error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Invalid 'opts' parameter."); - return false; - } - - while (bson_iter_next (&iter)) { - key = bson_iter_key (&iter); - - if (!strcmp (key, MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS)) { - ADD_FLAG (flags, MONGOC_OP_QUERY_FLAG_PARTIAL); - } else if (!strcmp (key, MONGOC_CURSOR_AWAIT_DATA)) { - ADD_FLAG (flags, MONGOC_OP_QUERY_FLAG_AWAIT_DATA); - } else if (!strcmp (key, MONGOC_CURSOR_EXHAUST)) { - ADD_FLAG (flags, MONGOC_OP_QUERY_FLAG_EXHAUST); - } else if (!strcmp (key, MONGOC_CURSOR_NO_CURSOR_TIMEOUT)) { - ADD_FLAG (flags, MONGOC_OP_QUERY_FLAG_NO_CURSOR_TIMEOUT); - } else if (!strcmp (key, MONGOC_CURSOR_OPLOG_REPLAY)) { - ADD_FLAG (flags, MONGOC_OP_QUERY_FLAG_OPLOG_REPLAY); - } else if (!strcmp (key, MONGOC_CURSOR_TAILABLE)) { - ADD_FLAG (flags, MONGOC_OP_QUERY_FLAG_TAILABLE_CURSOR); - } - } - - if (cursor->secondary_ok) { - *flags |= MONGOC_OP_QUERY_FLAG_SECONDARY_OK; - } else if (cursor->server_id && - (stream->topology_type == MONGOC_TOPOLOGY_RS_WITH_PRIMARY || - stream->topology_type == MONGOC_TOPOLOGY_RS_NO_PRIMARY) && - stream->sd->type != MONGOC_SERVER_RS_PRIMARY) { - *flags |= MONGOC_OP_QUERY_FLAG_SECONDARY_OK; - } - - return true; -} - -bool -_mongoc_cursor_use_op_msg (const mongoc_cursor_t *cursor, int32_t wire_version) -{ - /* CDRIVER-4722: always true once 4.2 is the minimum supported - No check needed for 3.6 as it's the current minimum */ - return !_mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_EXHAUST) || - wire_version >= WIRE_VERSION_4_2; -} - -bool -_mongoc_cursor_run_command (mongoc_cursor_t *cursor, - const bson_t *command, - const bson_t *opts, - bson_t *reply, - bool retry_prohibited) -{ - mongoc_server_stream_t *server_stream; - bson_iter_t iter; - mongoc_cmd_parts_t parts; - const char *cmd_name; - bool is_primary; - mongoc_read_prefs_t *prefs = NULL; - char *db = NULL; - mongoc_session_opt_t *session_opts; - bool ret = false; - bool is_retryable = true; - - ENTRY; - - mongoc_cmd_parts_init ( - &parts, cursor->client, db, MONGOC_QUERY_NONE, command); - parts.is_read_command = true; - parts.read_prefs = cursor->read_prefs; - parts.assembled.operation_id = cursor->operation_id; - server_stream = _mongoc_cursor_fetch_stream (cursor); - - if (!server_stream) { - _mongoc_bson_init_if_set (reply); - GOTO (done); - } - - if (opts) { - if (!bson_iter_init (&iter, opts)) { - _mongoc_bson_init_if_set (reply); - bson_set_error (&cursor->error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Invalid BSON in opts document"); - GOTO (done); - } - if (!mongoc_cmd_parts_append_opts (&parts, &iter, &cursor->error)) { - _mongoc_bson_init_if_set (reply); - GOTO (done); - } - } - - if (parts.assembled.session) { - /* initial query/aggregate/etc, and opts contains "sessionId" */ - BSON_ASSERT (!cursor->client_session); - BSON_ASSERT (!cursor->explicit_session); - cursor->client_session = parts.assembled.session; - cursor->explicit_session = true; - } else if (cursor->client_session) { - /* a getMore with implicit or explicit session already acquired */ - mongoc_cmd_parts_set_session (&parts, cursor->client_session); - } else { - /* try to create an implicit session. not causally consistent. we keep - * the session but leave cursor->explicit_session as 0, so we use the - * same lsid for getMores but destroy the session when the cursor dies. - */ - session_opts = mongoc_session_opts_new (); - mongoc_session_opts_set_causal_consistency (session_opts, false); - /* returns NULL if sessions aren't supported. ignore errors. */ - cursor->client_session = - mongoc_client_start_session (cursor->client, session_opts, NULL); - mongoc_cmd_parts_set_session (&parts, cursor->client_session); - mongoc_session_opts_destroy (session_opts); - } - - if (!mongoc_cmd_parts_set_read_concern ( - &parts, cursor->read_concern, &cursor->error)) { - _mongoc_bson_init_if_set (reply); - GOTO (done); - } - - db = bson_strndup (cursor->ns, cursor->dblen); - parts.assembled.db_name = db; - - { - int32_t flags; - if (!_mongoc_cursor_opts_to_flags (cursor, server_stream, &flags)) { - _mongoc_bson_init_if_set (reply); - GOTO (done); - } - parts.user_query_flags = (mongoc_query_flags_t) flags; - } - - if (_mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_EXHAUST)) { - const bool sharded = - _mongoc_topology_get_type (cursor->client->topology) == - MONGOC_TOPOLOGY_SHARDED; - const int32_t wire_version = server_stream->sd->max_wire_version; - if (sharded && wire_version < WIRE_VERSION_MONGOS_EXHAUST) { - /* Return error since mongos < 7.2 doesn't support exhaust cursors */ - bson_set_error (&cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "exhaust cursors require mongos with wire version: " - "%d, but mongos has wire version: %d.", - wire_version, - WIRE_VERSION_MONGOS_EXHAUST); - _mongoc_bson_init_if_set (reply); - GOTO (done); - } - parts.assembled.op_msg_is_exhaust = true; - } - - /* we might use mongoc_cursor_set_hint to target a secondary but have no - * read preference, so the secondary rejects the read. same if we have a - * direct connection to a secondary (topology type "single"). with - * OP_QUERY we handle this by setting secondaryOk. here we use - * $readPreference. - */ - cmd_name = _mongoc_get_command_name (command); - is_primary = - !cursor->read_prefs || cursor->read_prefs->mode == MONGOC_READ_PRIMARY; - - if (strcmp (cmd_name, "getMore") != 0 && is_primary && - parts.user_query_flags & MONGOC_QUERY_SECONDARY_OK) { - parts.read_prefs = prefs = - mongoc_read_prefs_new (MONGOC_READ_PRIMARY_PREFERRED); - } else { - parts.read_prefs = cursor->read_prefs; - } - - is_retryable = _is_retryable_read (&parts, server_stream); - if (!strcmp (cmd_name, "getMore")) { - is_retryable = false; - } - if (!strcmp (cmd_name, "aggregate")) { - bson_iter_t pipeline_iter; - if (bson_iter_init_find (&pipeline_iter, command, "pipeline") && - BSON_ITER_HOLDS_ARRAY (&pipeline_iter) && - bson_iter_recurse (&pipeline_iter, &pipeline_iter)) { - if (_has_write_key (&pipeline_iter)) { - is_retryable = false; - } - } - } - if (is_retryable && retry_prohibited) { - is_retryable = false; - } - - if (cursor->write_concern && - !mongoc_write_concern_is_default (cursor->write_concern)) { - parts.assembled.is_acknowledged = - mongoc_write_concern_is_acknowledged (cursor->write_concern); - mongoc_write_concern_append (cursor->write_concern, &parts.extra); - } - - if (!mongoc_cmd_parts_assemble (&parts, server_stream, &cursor->error)) { - _mongoc_bson_init_if_set (reply); - GOTO (done); - } - -retry: - ret = mongoc_cluster_run_command_monitored ( - &cursor->client->cluster, &parts.assembled, reply, &cursor->error); - - if (ret) { - memset (&cursor->error, 0, sizeof (bson_error_t)); - } - - if (is_retryable && - _mongoc_read_error_get_type (ret, &cursor->error, reply) == - MONGOC_READ_ERR_RETRY) { - is_retryable = false; - - { - mongoc_deprioritized_servers_t *const ds = - mongoc_deprioritized_servers_new (); - - mongoc_deprioritized_servers_add_if_sharded ( - ds, server_stream->topology_type, server_stream->sd); - - mongoc_server_stream_cleanup (server_stream); - - BSON_ASSERT (!cursor->is_aggr_with_write_stage && - "Cannot attempt a retry on an aggregate operation that " - "contains write stages"); - server_stream = - mongoc_cluster_stream_for_reads (&cursor->client->cluster, - cursor->read_prefs, - cursor->client_session, - ds, - reply, - &cursor->error); - - mongoc_deprioritized_servers_destroy (ds); - } - - if (server_stream) { - cursor->server_id = server_stream->sd->id; - parts.assembled.server_stream = server_stream; - bson_destroy (reply); - GOTO (retry); - } - } - - if (cursor->error.domain) { - bson_destroy (&cursor->error_doc); - bson_copy_to (reply, &cursor->error_doc); - } - - /* Read and Write Concern Spec: "Drivers SHOULD parse server replies for a - * "writeConcernError" field and report the error only in command-specific - * helper methods that take a separate write concern parameter or an options - * parameter that may contain a write concern option. - * - * Only command helpers with names like "_with_write_concern" can create - * cursors with a non-NULL write_concern field. - */ - if (ret && cursor->write_concern) { - ret = !_mongoc_parse_wc_err (reply, &cursor->error); - } - -done: - mongoc_server_stream_cleanup (server_stream); - mongoc_cmd_parts_cleanup (&parts); - mongoc_read_prefs_destroy (prefs); - bson_free (db); - - return ret; -} - - -void -_mongoc_cursor_collection (const mongoc_cursor_t *cursor, - const char **collection, - int *collection_len) -{ - /* ns is like "db.collection". Collection name is located past the ".". */ - *collection = cursor->ns + (cursor->dblen + 1); - /* Collection name's length is ns length, minus length of db name and ".". */ - *collection_len = cursor->nslen - cursor->dblen - 1; - - BSON_ASSERT (*collection_len > 0); -} - - -void -_mongoc_cursor_prepare_find_command (mongoc_cursor_t *cursor, - const bson_t *filter, - bson_t *command) -{ - const char *collection; - int collection_len; - - _mongoc_cursor_collection (cursor, &collection, &collection_len); - bson_append_utf8 (command, - MONGOC_CURSOR_FIND, - MONGOC_CURSOR_FIND_LEN, - collection, - collection_len); - bson_append_document ( - command, MONGOC_CURSOR_FILTER, MONGOC_CURSOR_FILTER_LEN, filter); -} - - -bool -mongoc_cursor_error (mongoc_cursor_t *cursor, bson_error_t *error) -{ - ENTRY; - - RETURN (mongoc_cursor_error_document (cursor, error, NULL)); -} - - -bool -mongoc_cursor_error_document (mongoc_cursor_t *cursor, - bson_error_t *error, - const bson_t **doc) -{ - ENTRY; - - BSON_ASSERT (cursor); - - if (BSON_UNLIKELY (CURSOR_FAILED (cursor))) { - bson_set_error (error, - cursor->error.domain, - cursor->error.code, - "%s", - cursor->error.message); - - if (doc) { - *doc = &cursor->error_doc; - } - - RETURN (true); - } - - if (doc) { - *doc = NULL; - } - - RETURN (false); -} - - -static mongoc_cursor_state_t -_call_transition (mongoc_cursor_t *cursor) -{ - mongoc_cursor_state_t state = cursor->state; - _mongoc_cursor_impl_transition_t fn = NULL; - switch (state) { - case UNPRIMED: - fn = cursor->impl.prime; - break; - case IN_BATCH: - fn = cursor->impl.pop_from_batch; - break; - case END_OF_BATCH: - fn = cursor->impl.get_next_batch; - break; - case DONE: - default: - fn = NULL; - break; - } - if (!fn) { - return DONE; - } - state = fn (cursor); - if (cursor->error.domain) { - state = DONE; - } - return state; -} - - -bool -mongoc_cursor_next (mongoc_cursor_t *cursor, const bson_t **bson) -{ - bool ret = false; - bool attempted_refresh = false; - - ENTRY; - - BSON_ASSERT (cursor); - BSON_ASSERT (bson); - - TRACE ("cursor_id(%" PRId64 ")", cursor->cursor_id); - - if (cursor->client_generation != cursor->client->generation) { - bson_set_error (&cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot advance cursor after client reset"); - RETURN (false); - } - - if (bson) { - *bson = NULL; - } - - if (CURSOR_FAILED (cursor)) { - RETURN (false); - } - - if (cursor->state == DONE) { - bson_set_error (&cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot advance a completed or failed cursor."); - RETURN (false); - } - - /* - * We cannot proceed if another cursor is receiving results in exhaust mode. - */ - if (cursor->client->in_exhaust && !cursor->in_exhaust) { - bson_set_error (&cursor->error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_IN_EXHAUST, - "Another cursor derived from this client is in exhaust."); - RETURN (false); - } - - cursor->current = NULL; - - /* if an error was set on this cursor before calling next, transition to DONE - * immediately. */ - if (cursor->error.domain) { - cursor->state = DONE; - GOTO (done); - } - - while (cursor->state != DONE) { - /* even when there is no data to return, some cursors remain open and - * continue sending empty batches (e.g. a tailable or change stream - * cursor). in that case, do not attempt to get another batch. */ - if (cursor->state == END_OF_BATCH) { - if (attempted_refresh) { - RETURN (false); - } - attempted_refresh = true; - } - - cursor->state = _call_transition (cursor); - - /* check if we received a document. */ - if (cursor->current) { - *bson = cursor->current; - ret = true; - GOTO (done); - } - - if (cursor->state == DONE) { - GOTO (done); - } - } - -done: - cursor->count++; - RETURN (ret); -} - - -bool -mongoc_cursor_more (mongoc_cursor_t *cursor) -{ - ENTRY; - - BSON_ASSERT (cursor); - - if (CURSOR_FAILED (cursor)) { - RETURN (false); - } - - RETURN (cursor->state != DONE); -} - - -void -mongoc_cursor_get_host (mongoc_cursor_t *cursor, mongoc_host_list_t *host) -{ - mongoc_server_description_t const *description; - mc_shared_tpld td; - - BSON_ASSERT (cursor); - BSON_ASSERT (host); - - memset (host, 0, sizeof *host); - - if (!cursor->server_id) { - MONGOC_WARNING ("%s(): Must send query before fetching peer.", BSON_FUNC); - return; - } - - td = mc_tpld_take_ref (cursor->client->topology); - description = mongoc_topology_description_server_by_id_const ( - td.ptr, cursor->server_id, &cursor->error); - if (description) { - *host = description->host; - } - mc_tpld_drop_ref (&td); - - EXIT; -} - - -mongoc_cursor_t * -mongoc_cursor_clone (const mongoc_cursor_t *cursor) -{ - mongoc_cursor_t *_clone; - - BSON_ASSERT (cursor); - - _clone = BSON_ALIGNED_ALLOC0 (mongoc_cursor_t); - - _clone->client = cursor->client; - _clone->nslen = cursor->nslen; - _clone->dblen = cursor->dblen; - _clone->explicit_session = cursor->explicit_session; - - if (cursor->read_prefs) { - _clone->read_prefs = mongoc_read_prefs_copy (cursor->read_prefs); - } - - if (cursor->read_concern) { - _clone->read_concern = mongoc_read_concern_copy (cursor->read_concern); - } - - if (cursor->write_concern) { - _clone->write_concern = mongoc_write_concern_copy (cursor->write_concern); - } - - if (cursor->explicit_session) { - _clone->client_session = cursor->client_session; - } - - bson_copy_to (&cursor->opts, &_clone->opts); - bson_init (&_clone->error_doc); - - _clone->ns = bson_strdup (cursor->ns); - - /* copy the context functions by default. */ - memcpy (&_clone->impl, &cursor->impl, sizeof (cursor->impl)); - if (cursor->impl.clone) { - cursor->impl.clone (&_clone->impl, &cursor->impl); - } - - mongoc_counter_cursors_active_inc (); - - RETURN (_clone); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_cursor_is_alive -- - * - * Deprecated for mongoc_cursor_more. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_cursor_is_alive (const mongoc_cursor_t *cursor) /* IN */ -{ - return mongoc_cursor_more ((mongoc_cursor_t *) cursor); -} - - -const bson_t * -mongoc_cursor_current (const mongoc_cursor_t *cursor) /* IN */ -{ - BSON_ASSERT (cursor); - - return cursor->current; -} - - -void -mongoc_cursor_set_batch_size (mongoc_cursor_t *cursor, uint32_t batch_size) -{ - BSON_ASSERT (cursor); - bson_iter_t iter; - if (!bson_iter_init_find (&iter, &cursor->opts, MONGOC_CURSOR_BATCH_SIZE)) { - bson_append_int64 (&cursor->opts, - MONGOC_CURSOR_BATCH_SIZE, - MONGOC_CURSOR_BATCH_SIZE_LEN, - batch_size); - } else if (BSON_ITER_HOLDS_INT64 (&iter)) { - bson_iter_overwrite_int64 (&iter, (int64_t) batch_size); - } else if (BSON_ITER_HOLDS_INT32 (&iter)) { - if (!bson_in_range_int32_t_unsigned (batch_size)) { - MONGOC_WARNING ("unable to overwrite stored int32 batchSize with " - "out-of-range value %" PRIu32, - batch_size); - return; - } - bson_iter_overwrite_int32 (&iter, (int32_t) batch_size); - } else if (BSON_ITER_HOLDS_DOUBLE (&iter)) { - bson_iter_overwrite_double (&iter, (double) batch_size); - } else if (BSON_ITER_HOLDS_DECIMAL128 (&iter)) { - bson_decimal128_t val; - val.high = 0x3040000000000000; - val.low = (uint64_t) batch_size; - bson_iter_overwrite_decimal128 (&iter, &val); - } else { - MONGOC_WARNING ("unable to overwrite non-numeric stored batchSize"); - } -} - - -uint32_t -mongoc_cursor_get_batch_size (const mongoc_cursor_t *cursor) -{ - BSON_ASSERT (cursor); - - return (uint32_t) _mongoc_cursor_get_opt_int64 ( - cursor, MONGOC_CURSOR_BATCH_SIZE, 0); -} - - -bool -mongoc_cursor_set_limit (mongoc_cursor_t *cursor, int64_t limit) -{ - BSON_ASSERT (cursor); - - if (cursor->state == UNPRIMED) { - if (limit < 0) { - return _mongoc_cursor_set_opt_int64 ( - cursor, MONGOC_CURSOR_LIMIT, -limit) && - _mongoc_cursor_set_opt_bool ( - cursor, MONGOC_CURSOR_SINGLE_BATCH, true); - } else { - return _mongoc_cursor_set_opt_int64 ( - cursor, MONGOC_CURSOR_LIMIT, limit); - } - } else { - return false; - } -} - - -int64_t -mongoc_cursor_get_limit (const mongoc_cursor_t *cursor) -{ - int64_t limit; - bool single_batch; - - BSON_ASSERT (cursor); - - limit = _mongoc_cursor_get_opt_int64 (cursor, MONGOC_CURSOR_LIMIT, 0); - single_batch = - _mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_SINGLE_BATCH); - - if (limit > 0 && single_batch) { - limit = -limit; - } - - return limit; -} - - -bool -mongoc_cursor_set_hint (mongoc_cursor_t *cursor, uint32_t server_id) -{ - BSON_ASSERT (cursor); - - if (cursor->server_id) { - MONGOC_ERROR ("mongoc_cursor_set_hint: server_id already set"); - return false; - } - - if (!server_id) { - MONGOC_ERROR ("mongoc_cursor_set_hint: cannot set server_id to 0"); - return false; - } - - cursor->server_id = server_id; - - return true; -} - - -uint32_t -mongoc_cursor_get_hint (const mongoc_cursor_t *cursor) -{ - BSON_ASSERT (cursor); - - return cursor->server_id; -} - - -int64_t -mongoc_cursor_get_id (const mongoc_cursor_t *cursor) -{ - BSON_ASSERT (cursor); - - return cursor->cursor_id; -} - - -void -mongoc_cursor_set_max_await_time_ms (mongoc_cursor_t *cursor, - uint32_t max_await_time_ms) -{ - BSON_ASSERT (cursor); - - if (cursor->state == UNPRIMED) { - _mongoc_cursor_set_opt_int64 ( - cursor, MONGOC_CURSOR_MAX_AWAIT_TIME_MS, (int64_t) max_await_time_ms); - } -} - - -uint32_t -mongoc_cursor_get_max_await_time_ms (const mongoc_cursor_t *cursor) -{ - bson_iter_t iter; - - BSON_ASSERT (cursor); - - if (bson_iter_init_find ( - &iter, &cursor->opts, MONGOC_CURSOR_MAX_AWAIT_TIME_MS)) { - return (uint32_t) bson_iter_as_int64 (&iter); - } - - return 0; -} - - -/* deprecated for mongoc_cursor_new_from_command_reply_with_opts */ -mongoc_cursor_t * -mongoc_cursor_new_from_command_reply (mongoc_client_t *client, - bson_t *reply, - uint32_t server_id) -{ - mongoc_cursor_t *cursor; - bson_t cmd = BSON_INITIALIZER; - bson_t opts = BSON_INITIALIZER; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT (reply); - /* options are passed through by adding them to reply. */ - bsonBuildAppend ( - *reply, - insert ( - opts, - not(key ( - "cursor", "ok", "operationTime", "$clusterTime", "$gleStats")))); - - if (server_id) { - bson_append_int64 (&opts, "serverId", 8, server_id); - } - - cursor = _mongoc_cursor_cmd_new_from_reply (client, &cmd, &opts, reply); - bson_destroy (&cmd); - bson_destroy (&opts); - - return cursor; -} - - -mongoc_cursor_t * -mongoc_cursor_new_from_command_reply_with_opts (mongoc_client_t *client, - bson_t *reply, - const bson_t *opts) -{ - mongoc_cursor_t *cursor; - bson_t cmd = BSON_INITIALIZER; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT (reply); - - cursor = _mongoc_cursor_cmd_new_from_reply (client, &cmd, opts, reply); - bson_destroy (&cmd); - - return cursor; -} - - -bool -_mongoc_cursor_start_reading_response (mongoc_cursor_t *cursor, - mongoc_cursor_response_t *response) -{ - bson_iter_t iter; - bson_iter_t child; - const char *ns; - uint32_t nslen; - bool in_batch = false; - - if (bson_iter_init_find (&iter, &response->reply, "cursor") && - BSON_ITER_HOLDS_DOCUMENT (&iter) && bson_iter_recurse (&iter, &child)) { - while (bson_iter_next (&child)) { - if (BSON_ITER_IS_KEY (&child, "id")) { - cursor->cursor_id = bson_iter_as_int64 (&child); - } else if (BSON_ITER_IS_KEY (&child, "ns")) { - ns = bson_iter_utf8 (&child, &nslen); - _mongoc_set_cursor_ns (cursor, ns, nslen); - } else if (BSON_ITER_IS_KEY (&child, "firstBatch") || - BSON_ITER_IS_KEY (&child, "nextBatch")) { - if (BSON_ITER_HOLDS_ARRAY (&child) && - bson_iter_recurse (&child, &response->batch_iter)) { - in_batch = true; - } - } - } - } - - /* Driver Sessions Spec: "When an implicit session is associated with a - * cursor for use with getMore operations, the session MUST be returned to - * the pool immediately following a getMore operation that indicates that the - * cursor has been exhausted." */ - if (cursor->cursor_id == 0 && cursor->client_session && - !cursor->explicit_session) { - mongoc_client_session_destroy (cursor->client_session); - cursor->client_session = NULL; - } - - return in_batch; -} - - -void -_mongoc_cursor_response_read (mongoc_cursor_t *cursor, - mongoc_cursor_response_t *response, - const bson_t **bson) -{ - const uint8_t *data = NULL; - uint32_t data_len = 0; - - ENTRY; - - BSON_UNUSED (cursor); - - if (bson_iter_next (&response->batch_iter) && - BSON_ITER_HOLDS_DOCUMENT (&response->batch_iter)) { - bson_iter_document (&response->batch_iter, &data_len, &data); - - /* bson_iter_next guarantees valid BSON, so this must succeed */ - BSON_ASSERT (bson_init_static (&response->current_doc, data, data_len)); - *bson = &response->current_doc; - } -} - -/* sets cursor error if could not get the next batch. */ -void -_mongoc_cursor_response_refresh (mongoc_cursor_t *cursor, - const bson_t *command, - const bson_t *opts, - mongoc_cursor_response_t *response) -{ - ENTRY; - - bson_destroy (&response->reply); - - /* server replies to find / aggregate with {cursor: {id: N, firstBatch: []}}, - * to getMore command with {cursor: {id: N, nextBatch: []}}. */ - if (_mongoc_cursor_run_command ( - cursor, command, opts, &response->reply, false)) { - if (_mongoc_cursor_start_reading_response (cursor, response)) { - cursor->in_exhaust = cursor->client->in_exhaust; - return; - } - } - if (!cursor->error.domain) { - bson_set_error (&cursor->error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "Invalid reply to %s command.", - _mongoc_get_command_name (command)); - } -} - -void -_mongoc_cursor_prepare_getmore_command (mongoc_cursor_t *cursor, - bson_t *command) -{ - const char *collection; - int collection_len; - int64_t batch_size; - bson_iter_t iter; - bool await_data; - int64_t max_await_time_ms; - - ENTRY; - - _mongoc_cursor_collection (cursor, &collection, &collection_len); - - bson_init (command); - bson_append_int64 (command, "getMore", 7, mongoc_cursor_get_id (cursor)); - bson_append_utf8 (command, "collection", 10, collection, collection_len); - - batch_size = mongoc_cursor_get_batch_size (cursor); - - /* See find, getMore, and killCursors Spec for batchSize rules */ - if (batch_size) { - bson_append_int64 (command, - MONGOC_CURSOR_BATCH_SIZE, - MONGOC_CURSOR_BATCH_SIZE_LEN, - abs (_mongoc_n_return (cursor))); - } - - if (bson_iter_init_find (&iter, &cursor->opts, MONGOC_CURSOR_COMMENT) && - bson_iter_value (&iter)->value_type != BSON_TYPE_EOD) { - const bson_value_t *comment = bson_iter_value (&iter); - mongoc_server_stream_t *server_stream; - - /* CRUD spec: If a comment is provided, drivers MUST attach this comment - * to all subsequent getMore commands run on the same cursor for server - * versions 4.4 and above. For server versions below 4.4 drivers MUST NOT - * attach a comment to getMore commands. - * - * Since this function has no error reporting, we also no-op if we cannot - * fetch a stream. */ - server_stream = _mongoc_cursor_fetch_stream (cursor); - - if (server_stream != NULL && - server_stream->sd->max_wire_version >= WIRE_VERSION_4_4) { - bson_append_value ( - command, MONGOC_CURSOR_COMMENT, MONGOC_CURSOR_COMMENT_LEN, comment); - } - - mongoc_server_stream_cleanup (server_stream); - } - - /* Find, getMore And killCursors Commands Spec: "In the case of a tailable - cursor with awaitData == true the driver MUST provide a Cursor level - option named maxAwaitTimeMS (See CRUD specification for details). The - maxTimeMS option on the getMore command MUST be set to the value of the - option maxAwaitTimeMS. If no maxAwaitTimeMS is specified, the driver - SHOULD not set maxTimeMS on the getMore command." - */ - await_data = _mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_TAILABLE) && - _mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_AWAIT_DATA); - - if (await_data) { - max_await_time_ms = _mongoc_cursor_get_opt_int64 ( - cursor, MONGOC_CURSOR_MAX_AWAIT_TIME_MS, 0); - if (max_await_time_ms) { - bson_append_int64 (command, - MONGOC_CURSOR_MAX_TIME_MS, - MONGOC_CURSOR_MAX_TIME_MS_LEN, - max_await_time_ms); - } - } -} - -/* sets the cursor to be empty so it returns NULL on the first call to - * cursor_next but does not return an error. */ -void -_mongoc_cursor_set_empty (mongoc_cursor_t *cursor) -{ - memset (&cursor->error, 0, sizeof (bson_error_t)); - bson_reinit (&cursor->error_doc); - cursor->state = IN_BATCH; -} - -void -_mongoc_cursor_prime (mongoc_cursor_t *cursor) -{ - cursor->state = cursor->impl.prime (cursor); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor.h deleted file mode 100644 index b844c4761..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cursor.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_CURSOR_H -#define MONGOC_CURSOR_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-host-list.h" - - -BSON_BEGIN_DECLS - -typedef struct _mongoc_cursor_t mongoc_cursor_t; - - -/* forward decl */ -struct _mongoc_client_t; - -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_cursor_clone (const mongoc_cursor_t *cursor) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_cursor_destroy (mongoc_cursor_t *cursor); -MONGOC_EXPORT (bool) -mongoc_cursor_more (mongoc_cursor_t *cursor); -MONGOC_EXPORT (bool) -mongoc_cursor_next (mongoc_cursor_t *cursor, const bson_t **bson); -MONGOC_EXPORT (bool) -mongoc_cursor_error (mongoc_cursor_t *cursor, bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_cursor_error_document (mongoc_cursor_t *cursor, - bson_error_t *error, - const bson_t **doc); -MONGOC_EXPORT (void) -mongoc_cursor_get_host (mongoc_cursor_t *cursor, mongoc_host_list_t *host); -MONGOC_EXPORT (bool) -mongoc_cursor_is_alive (const mongoc_cursor_t *cursor) - BSON_GNUC_DEPRECATED_FOR (mongoc_cursor_more); -MONGOC_EXPORT (const bson_t *) -mongoc_cursor_current (const mongoc_cursor_t *cursor); -MONGOC_EXPORT (void) -mongoc_cursor_set_batch_size (mongoc_cursor_t *cursor, uint32_t batch_size); -MONGOC_EXPORT (uint32_t) -mongoc_cursor_get_batch_size (const mongoc_cursor_t *cursor); -MONGOC_EXPORT (bool) -mongoc_cursor_set_limit (mongoc_cursor_t *cursor, int64_t limit); -MONGOC_EXPORT (int64_t) -mongoc_cursor_get_limit (const mongoc_cursor_t *cursor); -/* These names include the term "hint" for backward compatibility, should be - * mongoc_cursor_get_server_id, mongoc_cursor_set_server_id. */ -MONGOC_EXPORT (bool) -mongoc_cursor_set_hint (mongoc_cursor_t *cursor, uint32_t server_id); -MONGOC_EXPORT (uint32_t) -mongoc_cursor_get_hint (const mongoc_cursor_t *cursor); -MONGOC_EXPORT (int64_t) -mongoc_cursor_get_id (const mongoc_cursor_t *cursor); -MONGOC_EXPORT (void) -mongoc_cursor_set_max_await_time_ms (mongoc_cursor_t *cursor, - uint32_t max_await_time_ms); -MONGOC_EXPORT (uint32_t) -mongoc_cursor_get_max_await_time_ms (const mongoc_cursor_t *cursor); -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_cursor_new_from_command_reply (struct _mongoc_client_t *client, - bson_t *reply, - uint32_t server_id) - BSON_GNUC_WARN_UNUSED_RESULT - BSON_GNUC_DEPRECATED_FOR (mongoc_cursor_new_from_command_reply_with_opts); -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_cursor_new_from_command_reply_with_opts (struct _mongoc_client_t *client, - bson_t *reply, - const bson_t *opts) - BSON_GNUC_WARN_UNUSED_RESULT; - -BSON_END_DECLS - - -#endif /* MONGOC_CURSOR_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cyrus.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cyrus.c deleted file mode 100644 index 830c20484..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-cyrus.c +++ /dev/null @@ -1,518 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SASL_CYRUS - -#include - -#include "mongoc-error.h" -#include "mongoc-cyrus-private.h" -#include "mongoc-util-private.h" -#include "mongoc-trace-private.h" -#include "common-b64-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "CYRUS-SASL" - -bool -_mongoc_cyrus_set_mechanism (mongoc_cyrus_t *sasl, - const char *mechanism, - bson_error_t *error) -{ - bson_string_t *str = bson_string_new (""); - const char **mechs = sasl_global_listmech (); - int i = 0; - bool ok = false; - - BSON_ASSERT (sasl); - - for (i = 0; mechs[i]; i++) { - if (!strcmp (mechs[i], mechanism)) { - ok = true; - break; - } - bson_string_append (str, mechs[i]); - if (mechs[i + 1]) { - bson_string_append (str, ","); - } - } - - if (ok) { - bson_free (sasl->credentials.mechanism); - sasl->credentials.mechanism = mechanism ? bson_strdup (mechanism) : NULL; - } else { - bson_set_error (error, - MONGOC_ERROR_SASL, - SASL_NOMECH, - "SASL Failure: Unsupported mechanism by client: %s. " - "Available mechanisms: %s", - mechanism, - str->str); - } - - bson_string_free (str, true); - return ok; -} - - -static int -_mongoc_cyrus_get_pass (mongoc_cyrus_t *sasl, - int param_id, - const char **result, - unsigned *result_len) -{ - BSON_ASSERT (sasl); - BSON_ASSERT (param_id == SASL_CB_PASS); - - if (result) { - *result = sasl->credentials.pass; - } - - if (result_len) { - *result_len = sasl->credentials.pass - ? (unsigned) strlen (sasl->credentials.pass) - : 0; - } - - return (sasl->credentials.pass != NULL) ? SASL_OK : SASL_FAIL; -} - - -static int -_mongoc_cyrus_canon_user (sasl_conn_t *conn, - mongoc_cyrus_t *sasl, - const char *in, - unsigned inlen, - unsigned flags, - const char *user_realm, - char *out, - unsigned out_max, - unsigned *out_len) -{ - BSON_UNUSED (conn); - BSON_UNUSED (sasl); - BSON_UNUSED (flags); - BSON_UNUSED (user_realm); - BSON_UNUSED (out_max); - - TRACE ("Canonicalizing %s (%" PRIu32 ")\n", in, inlen); - strcpy (out, in); - *out_len = inlen; - return SASL_OK; -} - -static int -_mongoc_cyrus_get_user (mongoc_cyrus_t *sasl, - int param_id, - const char **result, - unsigned *result_len) -{ - BSON_ASSERT (sasl); - BSON_ASSERT ((param_id == SASL_CB_USER) || (param_id == SASL_CB_AUTHNAME)); - - if (result) { - *result = sasl->credentials.user; - } - - if (result_len) { - *result_len = sasl->credentials.user - ? (unsigned) strlen (sasl->credentials.user) - : 0; - } - - return (sasl->credentials.user != NULL) ? SASL_OK : SASL_FAIL; -} - -static const char * -sasl_verify_type_to_str (sasl_verify_type_t type) -{ - switch (type) { - case SASL_VRFY_PLUGIN: - return "SASL_VRFY_PLUGIN"; - case SASL_VRFY_CONF: - return "SASL_VRFY_CONF"; - case SASL_VRFY_PASSWD: - return "SASL_VRFY_PASSWD"; - case SASL_VRFY_OTHER: - return "SASL_VRFY_OTHER"; - default: - return "Unknown"; - } -} - -int -_mongoc_cyrus_verifyfile_cb (void *context, const char *file, sasl_verify_type_t type) -{ - TRACE ("Attempting to load file: `%s`. Type is %s\n", file, sasl_verify_type_to_str (type)); - -#ifdef _WIN32 - // On Windows, Cyrus SASL hard-codes the plugin path. - // Only permit loading plugin from user configured path to prevent unintentional library loading. - if (type == SASL_VRFY_PLUGIN) { - const char *path_prefix = MONGOC_CYRUS_PLUGIN_PATH_PREFIX; - bool has_valid_prefix = (path_prefix && file == strstr (file, path_prefix)); - // Check if `file` has necessary prefix. - if (has_valid_prefix) { - return SASL_OK; - } - MONGOC_WARNING ("Refusing to load Cyrus SASL plugin at: '%s'. If needed, set CYRUS_PLUGIN_PATH_PREFIX (currently " - "'%s') to the absolute path prefix of the plugin during build configuration of the C Driver.", - file, - path_prefix ? path_prefix : "(unset)"); - return SASL_CONTINUE; - } -#endif - - return SASL_OK; -} - - -void -_mongoc_cyrus_init (mongoc_cyrus_t *sasl) -{ - sasl_callback_t callbacks[] = {{SASL_CB_AUTHNAME, SASL_CALLBACK_FN (_mongoc_cyrus_get_user), sasl}, - {SASL_CB_USER, SASL_CALLBACK_FN (_mongoc_cyrus_get_user), sasl}, - {SASL_CB_PASS, SASL_CALLBACK_FN (_mongoc_cyrus_get_pass), sasl}, - {SASL_CB_CANON_USER, SASL_CALLBACK_FN (_mongoc_cyrus_canon_user), sasl}, - {SASL_CB_VERIFYFILE, SASL_CALLBACK_FN (_mongoc_cyrus_verifyfile_cb), NULL}, - {SASL_CB_LIST_END}}; - - BSON_ASSERT (sasl); - - memset (sasl, 0, sizeof *sasl); - - memcpy (&sasl->callbacks, callbacks, sizeof callbacks); - - sasl->done = false; - sasl->step = 0; - sasl->conn = NULL; - sasl->interact = NULL; - sasl->credentials.mechanism = NULL; - sasl->credentials.user = NULL; - sasl->credentials.pass = NULL; - sasl->credentials.service_name = NULL; - sasl->credentials.service_host = NULL; -} - -bool -_mongoc_cyrus_new_from_cluster (mongoc_cyrus_t *sasl, - mongoc_cluster_t *cluster, - mongoc_stream_t *stream, - const char *hostname, - bson_error_t *error) -{ - const char *mechanism; - char real_name[BSON_HOST_NAME_MAX + 1]; - - _mongoc_cyrus_init (sasl); - - mechanism = mongoc_uri_get_auth_mechanism (cluster->uri); - if (!mechanism) { - mechanism = "GSSAPI"; - } - - if (!_mongoc_cyrus_set_mechanism (sasl, mechanism, error)) { - _mongoc_cyrus_destroy (sasl); - return false; - } - - _mongoc_sasl_set_pass ((mongoc_sasl_t *) sasl, - mongoc_uri_get_password (cluster->uri)); - _mongoc_sasl_set_user ((mongoc_sasl_t *) sasl, - mongoc_uri_get_username (cluster->uri)); - _mongoc_sasl_set_properties ((mongoc_sasl_t *) sasl, cluster->uri); - - /* - * If the URI requested canonicalizeHostname, we need to resolve the real - * hostname for the IP Address and pass that to the SASL layer. Some - * underlying GSSAPI layers will do this for us, but can be disabled in - * their config (krb.conf). - * - * This allows the consumer to specify canonicalizeHostname=true in the URI - * and have us do that for them. - * - * See CDRIVER-323 for more information. - */ - if (sasl->credentials.canonicalize_host_name && - _mongoc_sasl_get_canonicalized_name ( - stream, real_name, sizeof real_name)) { - _mongoc_sasl_set_service_host ((mongoc_sasl_t *) sasl, real_name); - } else { - _mongoc_sasl_set_service_host ((mongoc_sasl_t *) sasl, hostname); - } - return true; -} - - -void -_mongoc_cyrus_destroy (mongoc_cyrus_t *sasl) -{ - BSON_ASSERT (sasl); - - if (sasl->conn) { - sasl_dispose (&sasl->conn); - } - - bson_free (sasl->credentials.user); - bson_free (sasl->credentials.pass); - bson_free (sasl->credentials.mechanism); - bson_free (sasl->credentials.service_name); - bson_free (sasl->credentials.service_host); -} - - -static bool -_mongoc_cyrus_is_failure (int status, bson_error_t *error) -{ - bool ret = (status < 0); - - TRACE ("Got status: %d ok is %d, continue=%d interact=%d\n", - status, - SASL_OK, - SASL_CONTINUE, - SASL_INTERACT); - if (ret) { - switch (status) { - case SASL_NOMEM: - bson_set_error (error, - MONGOC_ERROR_SASL, - status, - "SASL Failure: insufficient memory."); - break; - case SASL_NOMECH: { - bson_string_t *str = bson_string_new ("available mechanisms: "); - const char **mechs = sasl_global_listmech (); - int i = 0; - - for (i = 0; mechs[i]; i++) { - bson_string_append (str, mechs[i]); - if (mechs[i + 1]) { - bson_string_append (str, ","); - } - } - bson_set_error (error, - MONGOC_ERROR_SASL, - status, - "SASL Failure: failure to negotiate mechanism (%s)", - str->str); - bson_string_free (str, 0); - } break; - case SASL_BADPARAM: - bson_set_error (error, - MONGOC_ERROR_SASL, - status, - "Bad parameter supplied. Please file a bug " - "with mongo-c-driver."); - break; - default: - bson_set_error (error, - MONGOC_ERROR_SASL, - status, - "SASL Failure: (%d): %s", - status, - sasl_errstring (status, NULL, NULL)); - break; - } - } - - return ret; -} - - -static bool -_mongoc_cyrus_start (mongoc_cyrus_t *sasl, - uint8_t **outbuf, - uint32_t *outbuflen, - bson_error_t *error) -{ - const char *service_name = "mongodb"; - const char *service_host = ""; - const char *mechanism = NULL; - const char *raw = NULL; - unsigned raw_len = 0; - int status; - - BSON_ASSERT (sasl); - BSON_ASSERT (outbuf); - BSON_ASSERT (outbuflen); - - if (sasl->credentials.service_name) { - service_name = sasl->credentials.service_name; - } - - if (sasl->credentials.service_host) { - service_host = sasl->credentials.service_host; - } - - status = sasl_client_new ( - service_name, service_host, NULL, NULL, sasl->callbacks, 0, &sasl->conn); - TRACE ("Created new sasl client %s", - status == SASL_OK ? "successfully" : "UNSUCCESSFULLY"); - if (_mongoc_cyrus_is_failure (status, error)) { - return false; - } - - status = sasl_client_start (sasl->conn, - sasl->credentials.mechanism, - &sasl->interact, - &raw, - &raw_len, - &mechanism); - TRACE ("Started the sasl client %s", - status == SASL_CONTINUE ? "successfully" : "UNSUCCESSFULLY"); - if (_mongoc_cyrus_is_failure (status, error)) { - return false; - } - - if ((0 != strcasecmp (mechanism, "GSSAPI")) && - (0 != strcasecmp (mechanism, "PLAIN"))) { - bson_set_error (error, - MONGOC_ERROR_SASL, - SASL_NOMECH, - "SASL Failure: invalid mechanism \"%s\"", - mechanism); - return false; - } - - *outbuflen = 0; - const size_t outbuf_capacity = - mcommon_b64_ntop_calculate_target_size (raw_len); - *outbuf = bson_malloc (outbuf_capacity); - - const int b64_ret = mcommon_b64_ntop ( - (uint8_t *) raw, raw_len, (char *) *outbuf, outbuf_capacity); - if (b64_ret < 0) { - bson_set_error (error, - MONGOC_ERROR_SASL, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Unable to base64 encode client SASL message"); - return false; - } else { - BSON_ASSERT (bson_in_range_signed (uint32_t, b64_ret)); - *outbuflen = (uint32_t) b64_ret; - } - - return true; -} - - -bool -_mongoc_cyrus_step (mongoc_cyrus_t *sasl, - const uint8_t *inbuf, - uint32_t inbuflen, - uint8_t **outbuf, - uint32_t *outbuflen, - bson_error_t *error) -{ - const char *raw = NULL; - unsigned rawlen = 0; - int status; - - BSON_ASSERT (sasl); - if (sasl->step > 1) { - BSON_ASSERT (inbuf); - } - BSON_ASSERT (outbuf); - BSON_ASSERT (outbuflen); - - TRACE ("Running %d, inbuflen: %" PRIu32, sasl->step, inbuflen); - sasl->step++; - - if (sasl->step == 1) { - return _mongoc_cyrus_start (sasl, outbuf, outbuflen, error); - } else if (sasl->step >= 10) { - bson_set_error (error, - MONGOC_ERROR_SASL, - SASL_NOTDONE, - "SASL Failure: maximum steps detected"); - return false; - } - - TRACE ("Running %d, inbuflen: %" PRIu32, sasl->step, inbuflen); - if (!inbuflen) { - bson_set_error (error, - MONGOC_ERROR_SASL, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "SASL Failure: no payload provided from server: %s", - sasl_errdetail (sasl->conn)); - return false; - } - - unsigned int decoded_len = 0; - const size_t decoded_capacity = - mcommon_b64_pton_calculate_target_size (inbuflen); - - char *const decoded = bson_malloc (decoded_capacity); - { - const int b64_ret = mcommon_b64_pton ( - (char *) inbuf, (uint8_t *) decoded, decoded_capacity); - if (b64_ret < 0) { - bson_set_error (error, - MONGOC_ERROR_SASL, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Unable to base64 decode client SASL message"); - bson_free (decoded); - bson_free (*outbuf); - *outbuf = NULL; - return false; - } else { - /* Set the output length to the number of bytes actually decoded to - * excluding the NULL. */ - decoded_len = (unsigned int) b64_ret; - } - } - - TRACE ("%s", "Running client_step"); - status = sasl_client_step ( - sasl->conn, decoded, decoded_len, &sasl->interact, &raw, &rawlen); - TRACE ("%s sent a client step", - status == SASL_OK ? "Successfully" : "UNSUCCESSFULLY"); - if (_mongoc_cyrus_is_failure (status, error)) { - bson_free (decoded); - return false; - } - - *outbuflen = 0; - const size_t outbuf_capacity = - mcommon_b64_ntop_calculate_target_size (rawlen); - *outbuf = bson_malloc0 (outbuf_capacity); - { - const int b64_ret = mcommon_b64_ntop ( - (const uint8_t *) raw, rawlen, (char *) *outbuf, outbuf_capacity); - if (b64_ret < 0) { - bson_set_error (error, - MONGOC_ERROR_SASL, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Unable to base64 encode client SASL message"); - bson_free (decoded); - bson_free (*outbuf); - *outbuf = NULL; - return false; - } else { - /* Set the output length to the number of characters written excluding - * the NULL. */ - BSON_ASSERT (bson_in_range_signed (uint32_t, b64_ret)); - *outbuflen = (uint32_t) b64_ret; - } - } - - bson_free (decoded); - return true; -} - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-database.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-database.c deleted file mode 100644 index 46fc2d620..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-database.c +++ /dev/null @@ -1,1400 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-aggregate-private.h" -#include "mongoc-client-private.h" -#include "mongoc-collection.h" -#include "mongoc-collection-private.h" -#include "mongoc-cursor.h" -#include "mongoc-cursor-private.h" -#include "mongoc-database.h" -#include "mongoc-database-private.h" -#include "mongoc-error.h" -#include "mongoc-log.h" -#include "mongoc-trace-private.h" -#include "mongoc-util-private.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-change-stream-private.h" - -#include - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "database" - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_database_new -- - * - * Create a new instance of mongoc_database_t for @client. - * - * @client must stay valid for the life of the resulting - * database structure. - * - * Returns: - * A newly allocated mongoc_database_t that should be freed with - * mongoc_database_destroy(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_database_t * -_mongoc_database_new (mongoc_client_t *client, - const char *name, - const mongoc_read_prefs_t *read_prefs, - const mongoc_read_concern_t *read_concern, - const mongoc_write_concern_t *write_concern) -{ - mongoc_database_t *db; - - ENTRY; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT_PARAM (name); - - db = (mongoc_database_t *) bson_malloc0 (sizeof *db); - db->client = client; - db->write_concern = write_concern ? mongoc_write_concern_copy (write_concern) - : mongoc_write_concern_new (); - db->read_concern = read_concern ? mongoc_read_concern_copy (read_concern) - : mongoc_read_concern_new (); - db->read_prefs = read_prefs ? mongoc_read_prefs_copy (read_prefs) - : mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - db->name = bson_strdup (name); - - RETURN (db); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_database_destroy -- - * - * Releases resources associated with @database. - * - * Returns: - * None. - * - * Side effects: - * Everything. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_database_destroy (mongoc_database_t *database) -{ - ENTRY; - - if (!database) { - EXIT; - } - - if (database->read_prefs) { - mongoc_read_prefs_destroy (database->read_prefs); - database->read_prefs = NULL; - } - - if (database->read_concern) { - mongoc_read_concern_destroy (database->read_concern); - database->read_concern = NULL; - } - - if (database->write_concern) { - mongoc_write_concern_destroy (database->write_concern); - database->write_concern = NULL; - } - - bson_free (database->name); - bson_free (database); - - EXIT; -} - - -mongoc_cursor_t * -mongoc_database_aggregate (mongoc_database_t *db, /* IN */ - const bson_t *pipeline, /* IN */ - const bson_t *opts, /* IN */ - const mongoc_read_prefs_t *read_prefs) /* IN */ -{ - return _mongoc_aggregate (db->client, - db->name, - MONGOC_QUERY_NONE, - pipeline, - opts, - read_prefs, - db->read_prefs, - db->read_concern, - db->write_concern); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_database_copy -- - * - * Returns a copy of @database that needs to be freed by calling - * mongoc_database_destroy. - * - * Returns: - * A copy of this database. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_database_t * -mongoc_database_copy (mongoc_database_t *database) -{ - ENTRY; - - BSON_ASSERT_PARAM (database); - - RETURN (_mongoc_database_new (database->client, - database->name, - database->read_prefs, - database->read_concern, - database->write_concern)); -} - -mongoc_cursor_t * -mongoc_database_command (mongoc_database_t *database, - mongoc_query_flags_t flags, - uint32_t skip, - uint32_t limit, - uint32_t batch_size, - const bson_t *command, - const bson_t *fields, - const mongoc_read_prefs_t *read_prefs) -{ - char *ns; - mongoc_cursor_t *cursor; - - BSON_UNUSED (flags); - BSON_UNUSED (skip); - BSON_UNUSED (limit); - BSON_UNUSED (batch_size); - BSON_UNUSED (fields); - - BSON_ASSERT_PARAM (database); - BSON_ASSERT_PARAM (command); - - ns = bson_strdup_printf ("%s.$cmd", database->name); - - /* Server Selection Spec: "The generic command method has a default read - * preference of mode 'primary'. The generic command method MUST ignore any - * default read preference from client, database or collection - * configuration. The generic command method SHOULD allow an optional read - * preference argument." - */ - - /* flags, skip, limit, batch_size, fields are unused */ - cursor = _mongoc_cursor_cmd_deprecated_new ( - database->client, ns, command, read_prefs); - bson_free (ns); - return cursor; -} - - -bool -mongoc_database_command_simple (mongoc_database_t *database, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (database); - BSON_ASSERT_PARAM (command); - - /* Server Selection Spec: "The generic command method has a default read - * preference of mode 'primary'. The generic command method MUST ignore any - * default read preference from client, database or collection - * configuration. The generic command method SHOULD allow an optional read - * preference argument." - */ - - return _mongoc_client_command_with_opts (database->client, - database->name, - command, - MONGOC_CMD_RAW, - NULL /* opts */, - MONGOC_QUERY_NONE, - read_prefs, - NULL, /* user prefs */ - NULL /* read concern */, - NULL /* write concern */, - reply, - error); -} - - -bool -mongoc_database_read_command_with_opts (mongoc_database_t *database, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - return _mongoc_client_command_with_opts (database->client, - database->name, - command, - MONGOC_CMD_READ, - opts, - MONGOC_QUERY_NONE, - read_prefs, - database->read_prefs, - database->read_concern, - database->write_concern, - reply, - error); -} - - -bool -mongoc_database_write_command_with_opts (mongoc_database_t *database, - const bson_t *command, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - return _mongoc_client_command_with_opts (database->client, - database->name, - command, - MONGOC_CMD_WRITE, - opts, - MONGOC_QUERY_NONE, - NULL, /* user prefs */ - database->read_prefs, - database->read_concern, - database->write_concern, - reply, - error); -} - - -bool -mongoc_database_read_write_command_with_opts ( - mongoc_database_t *database, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs /* IGNORED */, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - return _mongoc_client_command_with_opts (database->client, - database->name, - command, - MONGOC_CMD_RW, - opts, - MONGOC_QUERY_NONE, - read_prefs, - database->read_prefs, - database->read_concern, - database->write_concern, - reply, - error); -} - - -bool -mongoc_database_command_with_opts (mongoc_database_t *database, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error) -{ - return _mongoc_client_command_with_opts (database->client, - database->name, - command, - MONGOC_CMD_RAW, - opts, - MONGOC_QUERY_NONE, - read_prefs, - NULL, /* default prefs */ - database->read_concern, - database->write_concern, - reply, - error); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_database_drop -- - * - * Requests that the MongoDB server drops @database, including all - * collections and indexes associated with @database. - * - * Make sure this is really what you want! - * - * Returns: - * true if @database was dropped. - * - * Side effects: - * @error may be set. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_database_drop (mongoc_database_t *database, bson_error_t *error) -{ - return mongoc_database_drop_with_opts (database, NULL, error); -} - - -bool -mongoc_database_drop_with_opts (mongoc_database_t *database, - const bson_t *opts, - bson_error_t *error) -{ - bool ret; - bson_t cmd; - - BSON_ASSERT_PARAM (database); - - bson_init (&cmd); - bson_append_int32 (&cmd, "dropDatabase", 12, 1); - - ret = _mongoc_client_command_with_opts (database->client, - database->name, - &cmd, - MONGOC_CMD_WRITE, - opts, - MONGOC_QUERY_NONE, - NULL, /* user prefs */ - database->read_prefs, - database->read_concern, - database->write_concern, - NULL, /* reply */ - error); - bson_destroy (&cmd); - - return ret; -} - - -bool -mongoc_database_remove_user (mongoc_database_t *database, - const char *username, - bson_error_t *error) -{ - bson_t cmd; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (database); - BSON_ASSERT_PARAM (username); - - bson_init (&cmd); - BSON_APPEND_UTF8 (&cmd, "dropUser", username); - ret = mongoc_database_command_simple (database, &cmd, NULL, NULL, error); - bson_destroy (&cmd); - - RETURN (ret); -} - - -bool -mongoc_database_remove_all_users (mongoc_database_t *database, - bson_error_t *error) -{ - bson_t cmd; - bool ret; - - ENTRY; - - BSON_ASSERT_PARAM (database); - - bson_init (&cmd); - BSON_APPEND_INT32 (&cmd, "dropAllUsersFromDatabase", 1); - ret = mongoc_database_command_simple (database, &cmd, NULL, NULL, error); - bson_destroy (&cmd); - - RETURN (ret); -} - - -/** - * mongoc_database_add_user: - * @database: A #mongoc_database_t. - * @username: A string containing the username. - * @password: (allow-none): A string containing password, or NULL. - * @roles: (allow-none): An optional bson_t of roles. - * @custom_data: (allow-none): An optional bson_t of data to store. - * @error: (out) (allow-none): A location for a bson_error_t or %NULL. - * - * Creates a new user with access to @database. - * - * Returns: None. - * Side effects: None. - */ -bool -mongoc_database_add_user (mongoc_database_t *database, - const char *username, - const char *password, - const bson_t *roles, - const bson_t *custom_data, - bson_error_t *error) -{ - bson_t cmd; - bson_array_builder_t *ar; - bool ret = false; - - ENTRY; - - BSON_ASSERT_PARAM (database); - BSON_ASSERT_PARAM (username); - - bson_init (&cmd); - BSON_APPEND_UTF8 (&cmd, "createUser", username); - BSON_APPEND_UTF8 (&cmd, "pwd", password); - - if (custom_data) { - BSON_APPEND_DOCUMENT (&cmd, "customData", custom_data); - } - if (roles) { - BSON_APPEND_ARRAY (&cmd, "roles", roles); - } else { - bson_append_array_builder_begin (&cmd, "roles", 5, &ar); - bson_append_array_builder_end (&cmd, ar); - } - - ret = mongoc_database_command_simple (database, &cmd, NULL, NULL, error); - - bson_destroy (&cmd); - - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_database_get_read_prefs -- - * - * Fetch the read preferences for @database. - * - * Returns: - * A mongoc_read_prefs_t that should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const mongoc_read_prefs_t * -mongoc_database_get_read_prefs (const mongoc_database_t *database) /* IN */ -{ - BSON_ASSERT_PARAM (database); - return database->read_prefs; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_database_set_read_prefs -- - * - * Sets the default read preferences for @database. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_database_set_read_prefs (mongoc_database_t *database, - const mongoc_read_prefs_t *read_prefs) -{ - BSON_ASSERT_PARAM (database); - - if (database->read_prefs) { - mongoc_read_prefs_destroy (database->read_prefs); - database->read_prefs = NULL; - } - - if (read_prefs) { - database->read_prefs = mongoc_read_prefs_copy (read_prefs); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_database_get_read_concern -- - * - * Fetches the read concern for @database. - * - * Returns: - * A mongoc_read_concern_t that should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const mongoc_read_concern_t * -mongoc_database_get_read_concern (const mongoc_database_t *database) -{ - BSON_ASSERT_PARAM (database); - - return database->read_concern; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_database_set_read_concern -- - * - * Set the default read concern for @database. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_database_set_read_concern (mongoc_database_t *database, - const mongoc_read_concern_t *read_concern) -{ - BSON_ASSERT_PARAM (database); - - if (database->read_concern) { - mongoc_read_concern_destroy (database->read_concern); - database->read_concern = NULL; - } - - if (read_concern) { - database->read_concern = mongoc_read_concern_copy (read_concern); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_database_get_write_concern -- - * - * Fetches the write concern for @database. - * - * Returns: - * A mongoc_write_concern_t that should not be modified or freed. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -const mongoc_write_concern_t * -mongoc_database_get_write_concern (const mongoc_database_t *database) -{ - BSON_ASSERT_PARAM (database); - - return database->write_concern; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_database_set_write_concern -- - * - * Set the default write concern for @database. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_database_set_write_concern (mongoc_database_t *database, - const mongoc_write_concern_t *write_concern) -{ - BSON_ASSERT_PARAM (database); - - if (database->write_concern) { - mongoc_write_concern_destroy (database->write_concern); - database->write_concern = NULL; - } - - if (write_concern) { - database->write_concern = mongoc_write_concern_copy (write_concern); - } -} - - -/** - * mongoc_database_has_collection: - * @database: (in): A #mongoc_database_t. - * @name: (in): The name of the collection to check for. - * @error: (out) (allow-none): A location for a #bson_error_t, or %NULL. - * - * Checks to see if a collection exists within the database on the MongoDB - * server. - * - * This will return %false if their was an error communicating with the - * server, or if the collection does not exist. - * - * If @error is provided, it will first be zeroed. Upon error, error.domain - * will be set. - * - * Returns: %true if @name exists, otherwise %false. @error may be set. - */ -bool -mongoc_database_has_collection (mongoc_database_t *database, - const char *name, - bson_error_t *error) -{ - bson_iter_t col_iter; - bool ret = false; - const char *cur_name; - bson_t opts = BSON_INITIALIZER; - bson_t filter; - mongoc_cursor_t *cursor; - const bson_t *doc; - - ENTRY; - - BSON_ASSERT_PARAM (database); - BSON_ASSERT_PARAM (name); - - if (error) { - memset (error, 0, sizeof *error); - } - - BSON_APPEND_DOCUMENT_BEGIN (&opts, "filter", &filter); - BSON_APPEND_UTF8 (&filter, "name", name); - bson_append_document_end (&opts, &filter); - - cursor = mongoc_database_find_collections_with_opts (database, &opts); - while (mongoc_cursor_next (cursor, &doc)) { - if (bson_iter_init (&col_iter, doc) && - bson_iter_find (&col_iter, "name") && - BSON_ITER_HOLDS_UTF8 (&col_iter) && - (cur_name = bson_iter_utf8 (&col_iter, NULL))) { - if (!strcmp (cur_name, name)) { - ret = true; - GOTO (cleanup); - } - } - } - - (void) mongoc_cursor_error (cursor, error); - -cleanup: - mongoc_cursor_destroy (cursor); - bson_destroy (&opts); - - RETURN (ret); -} - - -mongoc_cursor_t * -mongoc_database_find_collections (mongoc_database_t *database, - const bson_t *filter, - bson_error_t *error) -{ - bson_t opts = BSON_INITIALIZER; - mongoc_cursor_t *cursor; - - BSON_ASSERT_PARAM (database); - - if (filter) { - if (!BSON_APPEND_DOCUMENT (&opts, "filter", filter)) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Invalid 'filter' parameter."); - bson_destroy (&opts); - return NULL; - } - } - - cursor = mongoc_database_find_collections_with_opts (database, &opts); - - bson_destroy (&opts); - - /* this deprecated API returns NULL on error */ - if (mongoc_cursor_error (cursor, error)) { - mongoc_cursor_destroy (cursor); - return NULL; - } - - return cursor; -} - - -mongoc_cursor_t * -mongoc_database_find_collections_with_opts (mongoc_database_t *database, - const bson_t *opts) -{ - mongoc_cursor_t *cursor; - bson_t cmd = BSON_INITIALIZER; - - BSON_ASSERT_PARAM (database); - - BSON_APPEND_INT32 (&cmd, "listCollections", 1); - - /* Enumerate Collections Spec: "run listCollections on the primary node in - * replicaset mode" */ - cursor = _mongoc_cursor_cmd_new ( - database->client, database->name, &cmd, opts, NULL, NULL, NULL); - if (cursor->error.domain == 0) { - _mongoc_cursor_prime (cursor); - } - bson_destroy (&cmd); - - return cursor; -} - - -char ** -mongoc_database_get_collection_names (mongoc_database_t *database, - bson_error_t *error) -{ - return mongoc_database_get_collection_names_with_opts ( - database, NULL, error); -} - - -char ** -mongoc_database_get_collection_names_with_opts (mongoc_database_t *database, - const bson_t *opts, - bson_error_t *error) -{ - bson_t opts_copy; - bson_iter_t col; - const char *name; - char *namecopy; - mongoc_array_t strv_buf; - mongoc_cursor_t *cursor; - const bson_t *doc; - char **ret; - - BSON_ASSERT_PARAM (database); - - if (opts) { - bson_copy_to (opts, &opts_copy); - } else { - bson_init (&opts_copy); - } - - /* nameOnly option is faster in MongoDB 4+, ignored by older versions, - * see Enumerating Collections Spec */ - if (!bson_has_field (&opts_copy, "nameOnly")) { - bson_append_bool (&opts_copy, "nameOnly", 8, true); - } - - cursor = mongoc_database_find_collections_with_opts (database, &opts_copy); - - _mongoc_array_init (&strv_buf, sizeof (char *)); - - while (mongoc_cursor_next (cursor, &doc)) { - if (bson_iter_init (&col, doc) && bson_iter_find (&col, "name") && - BSON_ITER_HOLDS_UTF8 (&col) && (name = bson_iter_utf8 (&col, NULL))) { - namecopy = bson_strdup (name); - _mongoc_array_append_val (&strv_buf, namecopy); - } - } - - /* append a null pointer for the last value. also handles the case - * of no values. */ - namecopy = NULL; - _mongoc_array_append_val (&strv_buf, namecopy); - - if (mongoc_cursor_error (cursor, error)) { - _mongoc_array_destroy (&strv_buf); - ret = NULL; - } else { - ret = (char **) strv_buf.data; - } - - mongoc_cursor_destroy (cursor); - bson_destroy (&opts_copy); - - return ret; -} - -static mongoc_collection_t * -create_collection (mongoc_database_t *database, - const char *name, - const bson_t *opts, - bson_error_t *error) -{ - mongoc_collection_t *collection = NULL; - bson_iter_t iter; - bson_t cmd; - bool capped = false; - - BSON_ASSERT_PARAM (database); - BSON_ASSERT_PARAM (name); - - if (strchr (name, '$')) { - bson_set_error (error, - MONGOC_ERROR_NAMESPACE, - MONGOC_ERROR_NAMESPACE_INVALID, - "The namespace \"%s\" is invalid.", - name); - return NULL; - } - - if (opts) { - if (bson_iter_init_find (&iter, opts, "capped")) { - if (!BSON_ITER_HOLDS_BOOL (&iter)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The argument \"capped\" must be a boolean."); - return NULL; - } - capped = bson_iter_bool (&iter); - } - - if (bson_iter_init_find (&iter, opts, "size")) { - if (!BSON_ITER_HOLDS_INT (&iter)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The argument \"size\" must be an integer."); - return NULL; - } - if (!capped) { - bson_set_error ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The \"size\" parameter requires {\"capped\": true}"); - return NULL; - } - } - - if (bson_iter_init_find (&iter, opts, "max")) { - if (!BSON_ITER_HOLDS_INT (&iter)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The argument \"max\" must be an integer."); - return NULL; - } - if (!capped) { - bson_set_error ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The \"max\" parameter requires {\"capped\": true}"); - return NULL; - } - } - - if (bson_iter_init_find (&iter, opts, "storageEngine")) { - if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) { - bson_set_error ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The \"storageEngine\" parameter must be a document"); - - return NULL; - } - - if (bson_iter_find (&iter, "wiredTiger")) { - if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The \"wiredTiger\" option must take a document " - "argument with a \"configString\" field"); - return NULL; - } - - if (bson_iter_find (&iter, "configString")) { - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - bson_set_error ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The \"configString\" parameter must be a string"); - return NULL; - } - } else { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The \"wiredTiger\" option must take a document " - "argument with a \"configString\" field"); - return NULL; - } - } - } - } - - - bson_init (&cmd); - BSON_APPEND_UTF8 (&cmd, "create", name); - - if (_mongoc_client_command_with_opts (database->client, - database->name, - &cmd, - MONGOC_CMD_WRITE, - opts, - MONGOC_QUERY_NONE, - NULL, /* user prefs */ - database->read_prefs, - database->read_concern, - database->write_concern, - NULL, /* reply */ - error)) { - collection = _mongoc_collection_new (database->client, - database->name, - name, - database->read_prefs, - database->read_concern, - database->write_concern); - } - - bson_destroy (&cmd); - - return collection; -} - -char * -_mongoc_get_encryptedField_state_collection ( - const bson_t *encryptedFields, - const char *data_collection, - const char *state_collection_suffix, - bson_error_t *error) -{ - bson_iter_t iter; - const char *fieldName = NULL; - - if (0 == strcmp (state_collection_suffix, "esc")) { - fieldName = "escCollection"; - } else if (0 == strcmp (state_collection_suffix, "ecoc")) { - fieldName = "ecocCollection"; - } else { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "expected state_collection_suffix to be 'esc' or " - "'ecoc', got: %s", - state_collection_suffix); - return NULL; - } - - if (bson_iter_init_find (&iter, encryptedFields, fieldName)) { - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "expected encryptedFields.%s to be UTF-8", - fieldName); - return NULL; - } - return bson_strdup (bson_iter_utf8 (&iter, NULL)); - } - return bson_strdup_printf ( - "enxcol_.%s.%s", data_collection, state_collection_suffix); -} - -static bool -create_encField_state_collection (mongoc_database_t *database, - const bson_t *encryptedFields, - const char *data_collection, - const char *state_collection_suffix, - bson_error_t *error) -{ - char *state_collection = NULL; - mongoc_collection_t *collection = NULL; - bool ok = false; - bson_t opts = BSON_INITIALIZER; - - state_collection = _mongoc_get_encryptedField_state_collection ( - encryptedFields, data_collection, state_collection_suffix, error); - if (!state_collection) { - goto fail; - } - - BCON_APPEND (&opts, - "clusteredIndex", - "{", - "key", - "{", - "_id", - BCON_INT32 (1), - "}", - "unique", - BCON_BOOL (true), - "}"); - - collection = create_collection (database, state_collection, &opts, error); - if (collection == NULL) { - goto fail; - } - - ok = true; -fail: - bson_free (state_collection); - mongoc_collection_destroy (collection); - bson_destroy (&opts); - return ok; -} - -static mongoc_collection_t * -create_collection_with_encryptedFields (mongoc_database_t *database, - const char *name, - const bson_t *opts, - const bson_t *encryptedFields, - bson_error_t *error) -{ - mongoc_collection_t *dataCollection = NULL; - bool ok = false; - bson_t *cc_opts = NULL; - - // Check the wire version to ensure server is 7.0.0 or newer. - { - mongoc_server_stream_t *stream = - mongoc_cluster_stream_for_writes (&database->client->cluster, - NULL /* client session */, - NULL /* deprioritized servers */, - NULL /* reply */, - error); - if (!stream) { - goto fail; - } - if (stream->sd->max_wire_version < WIRE_VERSION_7_0) { - bson_set_error ( - error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "Driver support of Queryable Encryption is incompatible " - "with server. Upgrade server to use Queryable Encryption. " - "Got maxWireVersion %" PRId32 " but need maxWireVersion >= %d", - stream->sd->max_wire_version, - WIRE_VERSION_7_0); - mongoc_server_stream_cleanup (stream); - goto fail; - } - mongoc_server_stream_cleanup (stream); - } - - bool state_collections_ok = - create_encField_state_collection ( - database, encryptedFields, name, "esc", error) && - create_encField_state_collection ( - database, encryptedFields, name, "ecoc", error); - if (!state_collections_ok) { - // Failed to create one or more state collections - goto fail; - } - - /* Create data collection. */ - cc_opts = bson_copy (opts); - if (!BSON_APPEND_DOCUMENT (cc_opts, "encryptedFields", encryptedFields)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "unable to append encryptedFields"); - goto fail; - } - dataCollection = create_collection (database, name, cc_opts, error); - if (!dataCollection) { - goto fail; - } - - /* Create index on __safeContent__. */ - { - bson_t *keys = BCON_NEW ("__safeContent__", BCON_INT32 (1)); - mongoc_index_model_t *im = mongoc_index_model_new (keys, NULL /* opts */); - ok = mongoc_collection_create_indexes_with_opts ( - dataCollection, &im, 1, NULL /* opts */, NULL /* reply */, error); - mongoc_index_model_destroy (im); - bson_destroy (keys); - if (!ok) { - goto fail; - } - } - - ok = true; -fail: - bson_destroy (cc_opts); - if (ok) { - return dataCollection; - } else { - mongoc_collection_destroy (dataCollection); - return NULL; - } -} - -bool -_mongoc_get_encryptedFields_from_map (mongoc_client_t *client, - const char *dbName, - const char *collName, - bson_t *encryptedFields, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - - const bson_t *efMap = client->topology->encrypted_fields_map; - - bson_init (encryptedFields); - - if (bson_empty0 (efMap)) { - /* Unset or empty efMap will have no encrypted fields */ - return true; - } - - char *ns = bson_strdup_printf ("%s.%s", dbName, collName); - bson_iter_t iter; - if (!bson_iter_init_find (&iter, efMap, ns)) { - /* No efMap entry for this database+collection. */ - bson_free (ns); - return true; - } - bson_free (ns); - - if (!_mongoc_iter_document_as_bson (&iter, encryptedFields, error)) { - /* The efMap entry should always be a document. */ - return false; - } - - return true; -} - -bool -_mongoc_get_encryptedFields_from_server (mongoc_client_t *client, - const char *dbName, - const char *collName, - bson_t *encryptedFields, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - - mongoc_database_t *db = mongoc_client_get_database (client, dbName); - bson_t *opts = BCON_NEW ("filter", "{", "name", BCON_UTF8 (collName), "}"); - mongoc_cursor_t *cursor; - bool ret = false; - const bson_t *collInfo; - - bson_init (encryptedFields); - - cursor = mongoc_database_find_collections_with_opts (db, opts); - if (mongoc_cursor_error (cursor, error)) { - goto fail; - } - - if (mongoc_cursor_next (cursor, &collInfo)) { - /* Check if the collInfo has options.encryptedFields. */ - bson_iter_t iter; - if (!bson_iter_init (&iter, collInfo)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "unable to iterate listCollections result"); - goto fail; - } - - if (bson_iter_find_descendant (&iter, "options.encryptedFields", &iter)) { - bson_t tmp; - if (!_mongoc_iter_document_as_bson (&iter, &tmp, error)) { - goto fail; - } - bson_copy_to (&tmp, encryptedFields); - } - } - - if (mongoc_cursor_error (cursor, error)) { - goto fail; - } - - ret = true; -fail: - mongoc_cursor_destroy (cursor); - bson_destroy (opts); - mongoc_database_destroy (db); - return ret; -} - -bool -_mongoc_get_collection_encryptedFields (mongoc_client_t *client, - const char *dbName, - const char *collName, - const bson_t *opts, - bool checkEncryptedFieldsMap, - bson_t *encryptedFields, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (client); - BSON_ASSERT_PARAM (dbName); - BSON_ASSERT_PARAM (collName); - BSON_ASSERT (opts || true); - BSON_ASSERT_PARAM (encryptedFields); - BSON_ASSERT (error || true); - - bson_init (encryptedFields); // Initially empty - - if (opts) { - // We have collection options, which may have encryptedFields in it - bool found = false; - bsonParse ( - *opts, - find (key ("encryptedFields"), - if (not(type (doc)), - then (error ("'encryptedFields' should be a document"))), - // Update encryptedFields to be a reference to the subdocument: - storeDocRef (*encryptedFields), - do (found = true))); - if (bsonParseError) { - // Error while parsing - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid createCollection command options: %s", - bsonParseError); - return false; - } else if (found) { - // Found it! - return true; - } else { - // Nothing found in the options - } - } - - // Look in the encryptedFieldsMap based on this collection name - if (checkEncryptedFieldsMap && - !_mongoc_get_encryptedFields_from_map ( - client, dbName, collName, encryptedFields, error)) { - // Error during lookup. - return false; - } - - // No error. We may or may not have found encryptedFields. The caller - // determines this by checking if encryptedFields is empty. - return true; -} - -mongoc_collection_t * -mongoc_database_create_collection (mongoc_database_t *database, - const char *name, - const bson_t *opts, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (database); - BSON_ASSERT_PARAM (name); - BSON_ASSERT (opts || true); - BSON_ASSERT (error || true); - - bson_t encryptedFields = BSON_INITIALIZER; - if (!_mongoc_get_collection_encryptedFields ( - database->client, - mongoc_database_get_name (database), - name, - opts, - true /* checkEncryptedFieldsMap */, - &encryptedFields, - error)) { - // Error during fields lookup - bson_destroy (&encryptedFields); - return false; - } - - if (!bson_empty (&encryptedFields)) { - // Clone 'opts' without the encryptedFields element - bsonBuildDecl ( - opts_without_encryptedFields, - if (opts, then (insert (*opts, not(key ("encryptedFields")))))); - - mongoc_collection_t *ret = - create_collection_with_encryptedFields (database, - name, - &opts_without_encryptedFields, - &encryptedFields, - error); - - bson_destroy (&encryptedFields); - bson_destroy (&opts_without_encryptedFields); - return ret; - } - - bson_destroy (&encryptedFields); - return create_collection (database, name, opts, error); -} - - -mongoc_collection_t * -mongoc_database_get_collection (mongoc_database_t *database, - const char *collection) -{ - BSON_ASSERT_PARAM (database); - BSON_ASSERT_PARAM (collection); - - return _mongoc_collection_new (database->client, - database->name, - collection, - database->read_prefs, - database->read_concern, - database->write_concern); -} - - -const char * -mongoc_database_get_name (mongoc_database_t *database) -{ - BSON_ASSERT_PARAM (database); - - return database->name; -} - - -mongoc_change_stream_t * -mongoc_database_watch (const mongoc_database_t *db, - const bson_t *pipeline, - const bson_t *opts) -{ - return _mongoc_change_stream_new_from_database (db, pipeline, opts); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-database.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-database.h deleted file mode 100644 index e958cd396..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-database.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_DATABASE_H -#define MONGOC_DATABASE_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-cursor.h" -#include "mongoc-flags.h" -#include "mongoc-read-prefs.h" -#include "mongoc-read-concern.h" -#include "mongoc-write-concern.h" - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_database_t mongoc_database_t; - - -MONGOC_EXPORT (const char *) -mongoc_database_get_name (mongoc_database_t *database); -MONGOC_EXPORT (bool) -mongoc_database_remove_user (mongoc_database_t *database, - const char *username, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_database_remove_all_users (mongoc_database_t *database, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_database_add_user (mongoc_database_t *database, - const char *username, - const char *password, - const bson_t *roles, - const bson_t *custom_data, - bson_error_t *error); -MONGOC_EXPORT (void) -mongoc_database_destroy (mongoc_database_t *database); -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_database_aggregate (mongoc_database_t *db, - const bson_t *pipeline, - const bson_t *opts, - const mongoc_read_prefs_t *read_prefs) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_database_t *) -mongoc_database_copy (mongoc_database_t *database) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_database_command (mongoc_database_t *database, - mongoc_query_flags_t flags, - uint32_t skip, - uint32_t limit, - uint32_t batch_size, - const bson_t *command, - const bson_t *fields, - const mongoc_read_prefs_t *read_prefs) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (bool) -mongoc_database_read_command_with_opts (mongoc_database_t *database, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_database_write_command_with_opts (mongoc_database_t *database, - const bson_t *command, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_database_read_write_command_with_opts ( - mongoc_database_t *database, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs /* IGNORED */, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_database_command_with_opts (mongoc_database_t *database, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - const bson_t *opts, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_database_command_simple (mongoc_database_t *database, - const bson_t *command, - const mongoc_read_prefs_t *read_prefs, - bson_t *reply, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_database_drop (mongoc_database_t *database, bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_database_drop_with_opts (mongoc_database_t *database, - const bson_t *opts, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_database_has_collection (mongoc_database_t *database, - const char *name, - bson_error_t *error); -MONGOC_EXPORT (mongoc_collection_t *) -mongoc_database_create_collection (mongoc_database_t *database, - const char *name, - const bson_t *options, - bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (const mongoc_read_prefs_t *) -mongoc_database_get_read_prefs (const mongoc_database_t *database); -MONGOC_EXPORT (void) -mongoc_database_set_read_prefs (mongoc_database_t *database, - const mongoc_read_prefs_t *read_prefs); -MONGOC_EXPORT (const mongoc_write_concern_t *) -mongoc_database_get_write_concern (const mongoc_database_t *database); -MONGOC_EXPORT (void) -mongoc_database_set_write_concern (mongoc_database_t *database, - const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (const mongoc_read_concern_t *) -mongoc_database_get_read_concern (const mongoc_database_t *database); -MONGOC_EXPORT (void) -mongoc_database_set_read_concern (mongoc_database_t *database, - const mongoc_read_concern_t *read_concern); -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_database_find_collections (mongoc_database_t *database, - const bson_t *filter, - bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT - BSON_GNUC_DEPRECATED_FOR (mongoc_database_find_collections_with_opts); -MONGOC_EXPORT (mongoc_cursor_t *) -mongoc_database_find_collections_with_opts (mongoc_database_t *database, - const bson_t *opts) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (char **) -mongoc_database_get_collection_names (mongoc_database_t *database, - bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT - BSON_GNUC_DEPRECATED_FOR (mongoc_database_get_collection_names_with_opts); -MONGOC_EXPORT (char **) -mongoc_database_get_collection_names_with_opts (mongoc_database_t *database, - const bson_t *opts, - bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_collection_t *) -mongoc_database_get_collection (mongoc_database_t *database, - const char *name) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_change_stream_t *) -mongoc_database_watch (const mongoc_database_t *db, - const bson_t *pipeline, - const bson_t *opts) BSON_GNUC_WARN_UNUSED_RESULT; - -BSON_END_DECLS - - -#endif /* MONGOC_DATABASE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-deprioritized-servers-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-deprioritized-servers-private.h deleted file mode 100644 index 6e9b0333d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-deprioritized-servers-private.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2024 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_DEPRIORITIZED_SERVERS_PRIVATE_H -#define MONGOC_DEPRIORITIZED_SERVERS_PRIVATE_H - -#include - -#include "mongoc-server-description.h" - -#include - -BSON_BEGIN_DECLS - -typedef struct _mongoc_deprioritized_servers_t mongoc_deprioritized_servers_t; - -mongoc_deprioritized_servers_t * -mongoc_deprioritized_servers_new (void); - -void -mongoc_deprioritized_servers_destroy ( - mongoc_deprioritized_servers_t *ds); - -void -mongoc_deprioritized_servers_add ( - mongoc_deprioritized_servers_t *ds, - const mongoc_server_description_t *sd); - -bool -mongoc_deprioritized_servers_contains ( - const mongoc_deprioritized_servers_t *ds, - const mongoc_server_description_t *sd); - -BSON_END_DECLS - -#endif // MONGOC_DEPRIORITIZED_SERVERS_PRIVATE_H diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-deprioritized-servers.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-deprioritized-servers.c deleted file mode 100644 index 71369f595..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-deprioritized-servers.c +++ /dev/null @@ -1,58 +0,0 @@ -#include "mongoc-deprioritized-servers-private.h" - -#include "mongoc-set-private.h" - -// Dedicated non-zero value to avoid confusing "key is present with a NULL item" -// from "key is not present" (also NULL). -#define MONGOC_DEPRIORITIZED_SERVERS_ITEM_VALUE ((void *) 1) - -struct _mongoc_deprioritized_servers_t { - // Use server ID (uint32_t) as keys to identify deprioritized servers. - mongoc_set_t *ids; -}; - -mongoc_deprioritized_servers_t * -mongoc_deprioritized_servers_new (void) -{ - mongoc_deprioritized_servers_t *const ret = bson_malloc (sizeof (*ret)); - - *ret = (mongoc_deprioritized_servers_t){ - .ids = mongoc_set_new (1u, NULL, NULL), - }; - - return ret; -} - -void -mongoc_deprioritized_servers_destroy (mongoc_deprioritized_servers_t *ds) -{ - if (!ds) { - return; - } - - mongoc_set_destroy (ds->ids); - bson_free (ds); -} - -void -mongoc_deprioritized_servers_add (mongoc_deprioritized_servers_t *ds, - const mongoc_server_description_t *sd) -{ - BSON_ASSERT_PARAM (ds); - BSON_ASSERT_PARAM (sd); - - mongoc_set_add (ds->ids, - mongoc_server_description_id (sd), - MONGOC_DEPRIORITIZED_SERVERS_ITEM_VALUE); -} - -bool -mongoc_deprioritized_servers_contains (const mongoc_deprioritized_servers_t *ds, - const mongoc_server_description_t *sd) -{ - BSON_ASSERT_PARAM (ds); - BSON_ASSERT_PARAM (sd); - - return mongoc_set_get_const (ds->ids, mongoc_server_description_id (sd)) == - MONGOC_DEPRIORITIZED_SERVERS_ITEM_VALUE; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-errno-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-errno-private.h deleted file mode 100644 index 3a8125d8c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-errno-private.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_ERRNO_PRIVATE_H -#define MONGOC_ERRNO_PRIVATE_H - -#include -#include -#ifdef _WIN32 -#include -#include -#endif - - -BSON_BEGIN_DECLS - - -#if defined(_WIN32) -#define MONGOC_ERRNO_IS_AGAIN(errno) \ - ((errno == EAGAIN) || (errno == WSAEWOULDBLOCK) || (errno == WSAEINPROGRESS)) -#define MONGOC_ERRNO_IS_TIMEDOUT(errno) (errno == WSAETIMEDOUT) -#elif defined(__sun) -/* for some reason, accept() returns -1 and errno of 0 */ -#define MONGOC_ERRNO_IS_AGAIN(errno) \ - ((errno == EINTR) || (errno == EAGAIN) || (errno == EWOULDBLOCK) || \ - (errno == EINPROGRESS) || (errno == 0)) -#define MONGOC_ERRNO_IS_TIMEDOUT(errno) (errno == ETIMEDOUT) -#else -#define MONGOC_ERRNO_IS_AGAIN(errno) \ - ((errno == EINTR) || (errno == EAGAIN) || (errno == EWOULDBLOCK) || \ - (errno == EINPROGRESS)) -#define MONGOC_ERRNO_IS_TIMEDOUT(errno) (errno == ETIMEDOUT) -#endif - - -BSON_END_DECLS - - -#endif /* MONGOC_ERRNO_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-error-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-error-private.h deleted file mode 100644 index 073c76d84..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-error-private.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#include -#include - -#include "mongoc-server-description.h" - -BSON_BEGIN_DECLS - -typedef enum { - MONGOC_READ_ERR_NONE, - MONGOC_READ_ERR_OTHER, - MONGOC_READ_ERR_RETRY -} mongoc_read_err_type_t; - -/* Server error codes libmongoc cares about. Compare with: - * https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.yml - */ -typedef enum { - MONGOC_SERVER_ERR_HOSTUNREACHABLE = 6, - MONGOC_SERVER_ERR_HOSTNOTFOUND = 7, - MONGOC_SERVER_ERR_CURSOR_NOT_FOUND = 43, - MONGOC_SERVER_ERR_STALESHARDVERSION = 63, - MONGOC_SERVER_ERR_NETWORKTIMEOUT = 89, - MONGOC_SERVER_ERR_SHUTDOWNINPROGRESS = 91, - MONGOC_SERVER_ERR_FAILEDTOSATISFYREADPREFERENCE = 133, - MONGOC_SERVER_ERR_READCONCERNMAJORITYNOTAVAILABLEYET = 134, - MONGOC_SERVER_ERR_STALEEPOCH = 150, - MONGOC_SERVER_ERR_PRIMARYSTEPPEDDOWN = 189, - MONGOC_SERVER_ERR_ELECTIONINPROGRESS = 216, - MONGOC_SERVER_ERR_RETRYCHANGESTREAM = 234, - MONGOC_SERVER_ERR_EXCEEDEDTIMELIMIT = 262, - MONGOC_SERVER_ERR_SOCKETEXCEPTION = 9001, - MONGOC_SERVER_ERR_NOTPRIMARY = 10107, - MONGOC_SERVER_ERR_INTERRUPTEDATSHUTDOWN = 11600, - MONGOC_SERVER_ERR_INTERRUPTEDDUETOREPLSTATECHANGE = 11602, - MONGOC_SERVER_ERR_STALECONFIG = 13388, - MONGOC_SERVER_ERR_NOTPRIMARYNOSECONDARYOK = 13435, - MONGOC_SERVER_ERR_NOTPRIMARYORSECONDARY = 13436, - MONGOC_SERVER_ERR_LEGACYNOTPRIMARY = 10058, - MONGOC_SERVER_ERR_NS_NOT_FOUND = 26 -} mongoc_server_err_t; - -mongoc_read_err_type_t -_mongoc_read_error_get_type (bool cmd_ret, - const bson_error_t *cmd_err, - const bson_t *reply); - -void -_mongoc_error_copy_labels_and_upsert (const bson_t *src, - bson_t *dst, - char *label); - -void -_mongoc_write_error_append_retryable_label (bson_t *reply); - -void -_mongoc_write_error_handle_labels (bool cmd_ret, - const bson_error_t *cmd_err, - bson_t *reply, - const mongoc_server_description_t *sd); - -bool -_mongoc_error_is_shutdown (bson_error_t *error); - -bool -_mongoc_error_is_recovering (bson_error_t *error); - -bool -_mongoc_error_is_not_primary (bson_error_t *error); - -bool -_mongoc_error_is_state_change (bson_error_t *error); - -bool -_mongoc_error_is_network (const bson_error_t *error); - -bool -_mongoc_error_is_server (const bson_error_t *error); - -bool -_mongoc_error_is_auth (const bson_error_t *error); - -BSON_END_DECLS diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-error.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-error.c deleted file mode 100644 index b25d910ac..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-error.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright 2018-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "mongoc-error.h" -#include "mongoc-error-private.h" -#include "mongoc-rpc-private.h" -#include "mongoc-client-private.h" -#include "mongoc-server-description-private.h" - -bool -mongoc_error_has_label (const bson_t *reply, const char *label) -{ - bson_iter_t iter; - bson_iter_t error_labels; - - BSON_ASSERT (reply); - BSON_ASSERT (label); - - if (bson_iter_init_find (&iter, reply, "errorLabels") && - bson_iter_recurse (&iter, &error_labels)) { - while (bson_iter_next (&error_labels)) { - if (BSON_ITER_HOLDS_UTF8 (&error_labels) && - !strcmp (bson_iter_utf8 (&error_labels, NULL), label)) { - return true; - } - } - } - - return false; -} - -bool -_mongoc_error_is_server (const bson_error_t *error) -{ - if (!error) { - return false; - } - - return error->domain == MONGOC_ERROR_SERVER || - error->domain == MONGOC_ERROR_WRITE_CONCERN; -} - -static bool -_mongoc_write_error_is_retryable (bson_error_t *error) -{ - if (!_mongoc_error_is_server (error)) { - return false; - } - - switch (error->code) { - case MONGOC_SERVER_ERR_HOSTUNREACHABLE: - case MONGOC_SERVER_ERR_HOSTNOTFOUND: - case MONGOC_SERVER_ERR_NETWORKTIMEOUT: - case MONGOC_SERVER_ERR_SHUTDOWNINPROGRESS: - case MONGOC_SERVER_ERR_PRIMARYSTEPPEDDOWN: - case MONGOC_SERVER_ERR_EXCEEDEDTIMELIMIT: - case MONGOC_SERVER_ERR_SOCKETEXCEPTION: - case MONGOC_SERVER_ERR_NOTPRIMARY: - case MONGOC_SERVER_ERR_INTERRUPTEDATSHUTDOWN: - case MONGOC_SERVER_ERR_INTERRUPTEDDUETOREPLSTATECHANGE: - case MONGOC_SERVER_ERR_NOTPRIMARYNOSECONDARYOK: - case MONGOC_SERVER_ERR_NOTPRIMARYORSECONDARY: - return true; - default: - return false; - } -} - -void -_mongoc_write_error_append_retryable_label (bson_t *reply) -{ - bson_t reply_local = BSON_INITIALIZER; - - if (!reply) { - bson_destroy (&reply_local); - return; - } - - bson_copy_to_excluding_noinit (reply, &reply_local, "errorLabels", NULL); - _mongoc_error_copy_labels_and_upsert ( - reply, &reply_local, RETRYABLE_WRITE_ERROR); - - bson_destroy (reply); - bson_steal (reply, &reply_local); -} - -void -_mongoc_write_error_handle_labels (bool cmd_ret, - const bson_error_t *cmd_err, - bson_t *reply, - const mongoc_server_description_t *sd) -{ - bson_error_t error; - - /* check for a client error. */ - if (!cmd_ret && _mongoc_error_is_network (cmd_err)) { - /* Retryable writes spec: When the driver encounters a network error - * communicating with any server version that supports retryable - * writes, it MUST add a RetryableWriteError label to that error. */ - _mongoc_write_error_append_retryable_label (reply); - return; - } - - if (sd->max_wire_version >= WIRE_VERSION_RETRYABLE_WRITE_ERROR_LABEL) { - return; - } - - /* Check for a server error. Do not consult writeConcernError for pre-4.4 - * mongos. */ - if (sd->type == MONGOC_SERVER_MONGOS) { - if (_mongoc_cmd_check_ok (reply, MONGOC_ERROR_API_VERSION_2, &error)) { - return; - } - } else { - if (_mongoc_cmd_check_ok_no_wce ( - reply, MONGOC_ERROR_API_VERSION_2, &error)) { - return; - } - } - - if (_mongoc_write_error_is_retryable (&error)) { - _mongoc_write_error_append_retryable_label (reply); - } -} - - -/*-------------------------------------------------------------------------- - * - * _mongoc_read_error_get_type -- - * - * Checks if the error or reply from a read command is considered - * retryable according to the retryable reads spec. Checks both - * for a client error (a network exception) and a server error in - * the reply. @cmd_ret and @cmd_err come from the result of a - * read_command function. - * - * - * Return: - * A mongoc_read_error_type_t indicating the type of error (if any). - * - *-------------------------------------------------------------------------- - */ -mongoc_read_err_type_t -_mongoc_read_error_get_type (bool cmd_ret, - const bson_error_t *cmd_err, - const bson_t *reply) -{ - bson_error_t error; - - /* check for a client error. */ - if (!cmd_ret && cmd_err && _mongoc_error_is_network (cmd_err)) { - /* Retryable reads spec: "considered retryable if [...] any network - * exception (e.g. socket timeout or error) */ - return MONGOC_READ_ERR_RETRY; - } - - /* check for a server error. */ - if (_mongoc_cmd_check_ok_no_wce ( - reply, MONGOC_ERROR_API_VERSION_2, &error)) { - return MONGOC_READ_ERR_NONE; - } - - switch (error.code) { - case MONGOC_SERVER_ERR_EXCEEDEDTIMELIMIT: - case MONGOC_SERVER_ERR_INTERRUPTEDATSHUTDOWN: - case MONGOC_SERVER_ERR_INTERRUPTEDDUETOREPLSTATECHANGE: - case MONGOC_SERVER_ERR_NOTPRIMARY: - case MONGOC_SERVER_ERR_NOTPRIMARYNOSECONDARYOK: - case MONGOC_SERVER_ERR_NOTPRIMARYORSECONDARY: - case MONGOC_SERVER_ERR_PRIMARYSTEPPEDDOWN: - case MONGOC_SERVER_ERR_READCONCERNMAJORITYNOTAVAILABLEYET: - case MONGOC_SERVER_ERR_SHUTDOWNINPROGRESS: - case MONGOC_SERVER_ERR_HOSTNOTFOUND: - case MONGOC_SERVER_ERR_HOSTUNREACHABLE: - case MONGOC_SERVER_ERR_NETWORKTIMEOUT: - case MONGOC_SERVER_ERR_SOCKETEXCEPTION: - return MONGOC_READ_ERR_RETRY; - default: - if (strstr (error.message, "not master") || - strstr (error.message, "node is recovering")) { - return MONGOC_READ_ERR_RETRY; - } - return MONGOC_READ_ERR_OTHER; - } -} - -void -_mongoc_error_copy_labels_and_upsert (const bson_t *src, - bson_t *dst, - char *label) -{ - bson_iter_t iter; - bson_iter_t src_label; - bson_array_builder_t *dst_labels; - - BSON_APPEND_ARRAY_BUILDER_BEGIN (dst, "errorLabels", &dst_labels); - bson_array_builder_append_utf8 (dst_labels, label, -1); - - /* append any other errorLabels already in "src" */ - if (bson_iter_init_find (&iter, src, "errorLabels") && - bson_iter_recurse (&iter, &src_label)) { - while (bson_iter_next (&src_label) && BSON_ITER_HOLDS_UTF8 (&src_label)) { - if (strcmp (bson_iter_utf8 (&src_label, NULL), label) != 0) { - bson_array_builder_append_utf8 ( - dst_labels, bson_iter_utf8 (&src_label, NULL), -1); - } - } - } - - bson_append_array_builder_end (dst, dst_labels); -} - -/* Defined in SDAM spec under "Application Errors". - * @error should have been obtained from a command reply, e.g. with - * _mongoc_cmd_check_ok. - */ -bool -_mongoc_error_is_shutdown (bson_error_t *error) -{ - if (!_mongoc_error_is_server (error)) { - return false; - } - switch (error->code) { - case 11600: /* InterruptedAtShutdown */ - case 91: /* ShutdownInProgress */ - return true; - default: - return false; - } -} - -bool -_mongoc_error_is_not_primary (bson_error_t *error) -{ - if (!_mongoc_error_is_server (error)) { - return false; - } - - if (_mongoc_error_is_recovering (error)) { - return false; - } - switch (error->code) { - case MONGOC_SERVER_ERR_NOTPRIMARY: - case MONGOC_SERVER_ERR_NOTPRIMARYNOSECONDARYOK: - case MONGOC_SERVER_ERR_LEGACYNOTPRIMARY: - return true; - /* All errors where no code was found are marked as - * MONGOC_ERROR_QUERY_FAILURE */ - case MONGOC_ERROR_QUERY_FAILURE: - return NULL != strstr (error->message, "not master"); - default: - return false; - } -} - -bool -_mongoc_error_is_recovering (bson_error_t *error) -{ - if (!_mongoc_error_is_server (error)) { - return false; - } - switch (error->code) { - case MONGOC_SERVER_ERR_INTERRUPTEDATSHUTDOWN: - case MONGOC_SERVER_ERR_INTERRUPTEDDUETOREPLSTATECHANGE: - case MONGOC_SERVER_ERR_NOTPRIMARYORSECONDARY: - case MONGOC_SERVER_ERR_PRIMARYSTEPPEDDOWN: - case MONGOC_SERVER_ERR_SHUTDOWNINPROGRESS: - return true; - /* All errors where no code was found are marked as - * MONGOC_ERROR_QUERY_FAILURE */ - case MONGOC_ERROR_QUERY_FAILURE: - return NULL != strstr (error->message, "not master or secondary") || - NULL != strstr (error->message, "node is recovering"); - default: - return false; - } -} - -/* Assumes @error was parsed as an API V2 error. */ -bool -_mongoc_error_is_state_change (bson_error_t *error) -{ - return _mongoc_error_is_recovering (error) || - _mongoc_error_is_not_primary (error); -} - -bool -_mongoc_error_is_network (const bson_error_t *error) -{ - if (!error) { - return false; - } - if (error->domain == MONGOC_ERROR_STREAM) { - return true; - } - - if (error->domain == MONGOC_ERROR_PROTOCOL && - error->code == MONGOC_ERROR_PROTOCOL_INVALID_REPLY) { - return true; - } - - return false; -} - -bool -_mongoc_error_is_auth (const bson_error_t *error) -{ - if (!error) { - return false; - } - - return error->domain == MONGOC_ERROR_CLIENT && - error->code == MONGOC_ERROR_CLIENT_AUTHENTICATE; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-find-and-modify.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-find-and-modify.c deleted file mode 100644 index ba6bbcdfc..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-find-and-modify.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-write-concern.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-find-and-modify.h" -#include "mongoc-find-and-modify-private.h" -#include "mongoc-util-private.h" - - -/** - * mongoc_find_and_modify_new: - * - * Create a new mongoc_find_and_modify_t. - * - * Returns: A newly allocated mongoc_find_and_modify_t. This should be freed - * with mongoc_find_and_modify_destroy(). - */ -mongoc_find_and_modify_opts_t * -mongoc_find_and_modify_opts_new (void) -{ - mongoc_find_and_modify_opts_t *opts = NULL; - - opts = BSON_ALIGNED_ALLOC0 (mongoc_find_and_modify_opts_t); - bson_init (&opts->extra); - opts->bypass_document_validation = false; - - return opts; -} - -bool -mongoc_find_and_modify_opts_set_sort (mongoc_find_and_modify_opts_t *opts, - const bson_t *sort) -{ - BSON_ASSERT (opts); - - if (sort) { - bson_destroy (opts->sort); - opts->sort = bson_copy (sort); - return true; - } - - return false; -} - -void -mongoc_find_and_modify_opts_get_sort (const mongoc_find_and_modify_opts_t *opts, - bson_t *sort) -{ - BSON_ASSERT (opts); - BSON_ASSERT (sort); - - if (opts->sort) { - bson_copy_to (opts->sort, sort); - } else { - bson_init (sort); - } -} - -bool -mongoc_find_and_modify_opts_set_update (mongoc_find_and_modify_opts_t *opts, - const bson_t *update) -{ - BSON_ASSERT (opts); - - if (update) { - bson_destroy (opts->update); - opts->update = bson_copy (update); - return true; - } - - return false; -} - -void -mongoc_find_and_modify_opts_get_update ( - const mongoc_find_and_modify_opts_t *opts, bson_t *update) -{ - BSON_ASSERT (opts); - BSON_ASSERT (update); - - if (opts->update) { - bson_copy_to (opts->update, update); - } else { - bson_init (update); - } -} - -bool -mongoc_find_and_modify_opts_set_fields (mongoc_find_and_modify_opts_t *opts, - const bson_t *fields) -{ - BSON_ASSERT (opts); - - if (fields) { - bson_destroy (opts->fields); - opts->fields = bson_copy (fields); - return true; - } - - return false; -} - -void -mongoc_find_and_modify_opts_get_fields ( - const mongoc_find_and_modify_opts_t *opts, bson_t *fields) -{ - BSON_ASSERT (opts); - BSON_ASSERT (fields); - - if (opts->fields) { - bson_copy_to (opts->fields, fields); - } else { - bson_init (fields); - } -} - -bool -mongoc_find_and_modify_opts_set_flags ( - mongoc_find_and_modify_opts_t *opts, - const mongoc_find_and_modify_flags_t flags) -{ - BSON_ASSERT (opts); - - opts->flags = flags; - return true; -} - -mongoc_find_and_modify_flags_t -mongoc_find_and_modify_opts_get_flags ( - const mongoc_find_and_modify_opts_t *opts) -{ - BSON_ASSERT (opts); - - return opts->flags; -} - -bool -mongoc_find_and_modify_opts_set_bypass_document_validation ( - mongoc_find_and_modify_opts_t *opts, bool bypass) -{ - BSON_ASSERT (opts); - - opts->bypass_document_validation = bypass; - return true; -} - -bool -mongoc_find_and_modify_opts_get_bypass_document_validation ( - const mongoc_find_and_modify_opts_t *opts) -{ - BSON_ASSERT (opts); - - return opts->bypass_document_validation; -} - -bool -mongoc_find_and_modify_opts_set_max_time_ms ( - mongoc_find_and_modify_opts_t *opts, uint32_t max_time_ms) -{ - BSON_ASSERT (opts); - - opts->max_time_ms = max_time_ms; - return true; -} - -uint32_t -mongoc_find_and_modify_opts_get_max_time_ms ( - const mongoc_find_and_modify_opts_t *opts) -{ - BSON_ASSERT (opts); - - return opts->max_time_ms; -} - -bool -mongoc_find_and_modify_opts_append (mongoc_find_and_modify_opts_t *opts, - const bson_t *extra) -{ - BSON_ASSERT (opts); - - if (!extra) { - return true; - } - - return bson_concat (&opts->extra, extra); -} - -void -mongoc_find_and_modify_opts_get_extra ( - const mongoc_find_and_modify_opts_t *opts, bson_t *extra) -{ - BSON_ASSERT (opts); - BSON_ASSERT (extra); - - bson_copy_to (&opts->extra, extra); -} - -/** - * mongoc_find_and_modify_opts_destroy: - * @opts: A mongoc_find_and_modify_opts_t. - * - * Releases a mongoc_find_and_modify_opts_t and all associated memory. - */ -void -mongoc_find_and_modify_opts_destroy (mongoc_find_and_modify_opts_t *opts) -{ - if (opts) { - bson_destroy (opts->sort); - bson_destroy (opts->update); - bson_destroy (opts->fields); - bson_destroy (&opts->extra); - bson_free (opts); - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-find-and-modify.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-find-and-modify.h deleted file mode 100644 index 7dfedcc58..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-find-and-modify.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_FIND_AND_MODIFY_H -#define MONGOC_FIND_AND_MODIFY_H - -#include - -#include "mongoc-macros.h" - -BSON_BEGIN_DECLS - -typedef enum { - MONGOC_FIND_AND_MODIFY_NONE = 0, - MONGOC_FIND_AND_MODIFY_REMOVE = 1 << 0, - MONGOC_FIND_AND_MODIFY_UPSERT = 1 << 1, - MONGOC_FIND_AND_MODIFY_RETURN_NEW = 1 << 2, -} mongoc_find_and_modify_flags_t; - -typedef struct _mongoc_find_and_modify_opts_t mongoc_find_and_modify_opts_t; - -MONGOC_EXPORT (mongoc_find_and_modify_opts_t *) -mongoc_find_and_modify_opts_new (void) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (bool) -mongoc_find_and_modify_opts_set_sort (mongoc_find_and_modify_opts_t *opts, - const bson_t *sort); - -MONGOC_EXPORT (void) -mongoc_find_and_modify_opts_get_sort (const mongoc_find_and_modify_opts_t *opts, - bson_t *sort); - -MONGOC_EXPORT (bool) -mongoc_find_and_modify_opts_set_update (mongoc_find_and_modify_opts_t *opts, - const bson_t *update); - -MONGOC_EXPORT (void) -mongoc_find_and_modify_opts_get_update ( - const mongoc_find_and_modify_opts_t *opts, bson_t *update); - -MONGOC_EXPORT (bool) -mongoc_find_and_modify_opts_set_fields (mongoc_find_and_modify_opts_t *opts, - const bson_t *fields); - -MONGOC_EXPORT (void) -mongoc_find_and_modify_opts_get_fields ( - const mongoc_find_and_modify_opts_t *opts, bson_t *fields); - -MONGOC_EXPORT (bool) -mongoc_find_and_modify_opts_set_flags ( - mongoc_find_and_modify_opts_t *opts, - const mongoc_find_and_modify_flags_t flags); - -MONGOC_EXPORT (mongoc_find_and_modify_flags_t) -mongoc_find_and_modify_opts_get_flags ( - const mongoc_find_and_modify_opts_t *opts); - -MONGOC_EXPORT (bool) -mongoc_find_and_modify_opts_set_bypass_document_validation ( - mongoc_find_and_modify_opts_t *opts, bool bypass); - -MONGOC_EXPORT (bool) -mongoc_find_and_modify_opts_get_bypass_document_validation ( - const mongoc_find_and_modify_opts_t *opts); - -MONGOC_EXPORT (bool) -mongoc_find_and_modify_opts_set_max_time_ms ( - mongoc_find_and_modify_opts_t *opts, uint32_t max_time_ms); - -MONGOC_EXPORT (uint32_t) -mongoc_find_and_modify_opts_get_max_time_ms ( - const mongoc_find_and_modify_opts_t *opts); - -MONGOC_EXPORT (bool) -mongoc_find_and_modify_opts_append (mongoc_find_and_modify_opts_t *opts, - const bson_t *extra); - -MONGOC_EXPORT (void) -mongoc_find_and_modify_opts_get_extra ( - const mongoc_find_and_modify_opts_t *opts, bson_t *extra); - -MONGOC_EXPORT (void) -mongoc_find_and_modify_opts_destroy (mongoc_find_and_modify_opts_t *opts); - -BSON_END_DECLS - - -#endif /* MONGOC_FIND_AND_MODIFY_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-flags.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-flags.c deleted file mode 100644 index 1393e4999..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-flags.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2023-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-flags.h" - -#include "mongoc-compression-private.h" -#include "mongoc-flags-private.h" - -#include "mcd-rpc.h" - -#include - -// Document and ensure consistency between equivalent macros in mcd-rpc and -// libmongoc. - -BSON_STATIC_ASSERT (MONGOC_OP_COMPRESSED_COMPRESSOR_ID_NOOP == - MONGOC_COMPRESSOR_NOOP_ID); -BSON_STATIC_ASSERT (MONGOC_OP_COMPRESSED_COMPRESSOR_ID_SNAPPY == - MONGOC_COMPRESSOR_SNAPPY_ID); -BSON_STATIC_ASSERT (MONGOC_OP_COMPRESSED_COMPRESSOR_ID_ZLIB == - MONGOC_COMPRESSOR_ZLIB_ID); -BSON_STATIC_ASSERT (MONGOC_OP_COMPRESSED_COMPRESSOR_ID_ZSTD == - MONGOC_COMPRESSOR_ZSTD_ID); - -BSON_STATIC_ASSERT (MONGOC_OP_MSG_FLAG_NONE == MONGOC_MSG_NONE); -BSON_STATIC_ASSERT (MONGOC_OP_MSG_FLAG_CHECKSUM_PRESENT == - MONGOC_MSG_CHECKSUM_PRESENT); -BSON_STATIC_ASSERT (MONGOC_OP_MSG_FLAG_MORE_TO_COME == MONGOC_MSG_MORE_TO_COME); -BSON_STATIC_ASSERT (MONGOC_OP_MSG_FLAG_EXHAUST_ALLOWED == - MONGOC_MSG_EXHAUST_ALLOWED); - -BSON_STATIC_ASSERT (MONGOC_OP_REPLY_RESPONSE_FLAG_NONE == MONGOC_REPLY_NONE); -BSON_STATIC_ASSERT (MONGOC_OP_REPLY_RESPONSE_FLAG_CURSOR_NOT_FOUND == - MONGOC_REPLY_CURSOR_NOT_FOUND); -BSON_STATIC_ASSERT (MONGOC_OP_REPLY_RESPONSE_FLAG_QUERY_FAILURE == - MONGOC_REPLY_QUERY_FAILURE); -BSON_STATIC_ASSERT (MONGOC_OP_REPLY_RESPONSE_FLAG_SHARD_CONFIG_STALE == - MONGOC_REPLY_SHARD_CONFIG_STALE); -BSON_STATIC_ASSERT (MONGOC_OP_REPLY_RESPONSE_FLAG_AWAIT_CAPABLE == - MONGOC_REPLY_AWAIT_CAPABLE); - -BSON_STATIC_ASSERT (MONGOC_OP_UPDATE_FLAG_NONE == MONGOC_UPDATE_NONE); -BSON_STATIC_ASSERT (MONGOC_OP_UPDATE_FLAG_UPSERT == MONGOC_UPDATE_UPSERT); -BSON_STATIC_ASSERT (MONGOC_OP_UPDATE_FLAG_MULTI_UPDATE == - MONGOC_UPDATE_MULTI_UPDATE); - -BSON_STATIC_ASSERT (MONGOC_OP_INSERT_FLAG_NONE == MONGOC_INSERT_NONE); -BSON_STATIC_ASSERT (MONGOC_OP_INSERT_FLAG_CONTINUE_ON_ERROR == - MONGOC_INSERT_CONTINUE_ON_ERROR); - -BSON_STATIC_ASSERT (MONGOC_OP_QUERY_FLAG_NONE == MONGOC_QUERY_NONE); -BSON_STATIC_ASSERT (MONGOC_OP_QUERY_FLAG_TAILABLE_CURSOR == - MONGOC_QUERY_TAILABLE_CURSOR); -BSON_STATIC_ASSERT (MONGOC_OP_QUERY_FLAG_SECONDARY_OK == - MONGOC_QUERY_SECONDARY_OK); -BSON_STATIC_ASSERT (MONGOC_OP_QUERY_FLAG_OPLOG_REPLAY == - MONGOC_QUERY_OPLOG_REPLAY); -BSON_STATIC_ASSERT (MONGOC_OP_QUERY_FLAG_NO_CURSOR_TIMEOUT == - MONGOC_QUERY_NO_CURSOR_TIMEOUT); -BSON_STATIC_ASSERT (MONGOC_OP_QUERY_FLAG_AWAIT_DATA == MONGOC_QUERY_AWAIT_DATA); -BSON_STATIC_ASSERT (MONGOC_OP_QUERY_FLAG_EXHAUST == MONGOC_QUERY_EXHAUST); -BSON_STATIC_ASSERT (MONGOC_OP_QUERY_FLAG_PARTIAL == MONGOC_QUERY_PARTIAL); - -BSON_STATIC_ASSERT (MONGOC_OP_DELETE_FLAG_NONE == MONGOC_DELETE_NONE); -BSON_STATIC_ASSERT (MONGOC_OP_DELETE_FLAG_SINGLE_REMOVE == - MONGOC_DELETE_SINGLE_REMOVE); diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-flags.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-flags.h deleted file mode 100644 index 343c0607a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-flags.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_FLAGS_H -#define MONGOC_FLAGS_H - -#include - - -BSON_BEGIN_DECLS - - -/** - * mongoc_delete_flags_t: - * @MONGOC_DELETE_NONE: Specify no delete flags. - * @MONGOC_DELETE_SINGLE_REMOVE: Only remove the first document matching the - * document selector. - * - * This type is only for use with deprecated functions and should not be - * used in new code. Use mongoc_remove_flags_t instead. - * - * #mongoc_delete_flags_t are used when performing a delete operation. - */ -typedef enum { - MONGOC_DELETE_NONE = 0, - MONGOC_DELETE_SINGLE_REMOVE = 1 << 0, -} mongoc_delete_flags_t; - - -/** - * mongoc_remove_flags_t: - * @MONGOC_REMOVE_NONE: Specify no delete flags. - * @MONGOC_REMOVE_SINGLE_REMOVE: Only remove the first document matching the - * document selector. - * - * #mongoc_remove_flags_t are used when performing a remove operation. - */ -typedef enum { - MONGOC_REMOVE_NONE = 0, - MONGOC_REMOVE_SINGLE_REMOVE = 1 << 0, -} mongoc_remove_flags_t; - - -/** - * mongoc_insert_flags_t: - * @MONGOC_INSERT_NONE: Specify no insert flags. - * @MONGOC_INSERT_CONTINUE_ON_ERROR: Continue inserting documents from - * the insertion set even if one fails. - * - * #mongoc_insert_flags_t are used when performing an insert operation. - */ -typedef enum { - MONGOC_INSERT_NONE = 0, - MONGOC_INSERT_CONTINUE_ON_ERROR = 1 << 0, -} mongoc_insert_flags_t; - - -#define MONGOC_INSERT_NO_VALIDATE (1U << 31) - - -/** - * mongoc_query_flags_t: - * @MONGOC_QUERY_NONE: No query flags supplied. - * @MONGOC_QUERY_TAILABLE_CURSOR: Cursor will not be closed when the last - * data is retrieved. You can resume this cursor later. - * @MONGOC_QUERY_SECONDARY_OK: Allow query of secondaries in a replica set. - * @MONGOC_QUERY_OPLOG_REPLAY: Used internally by Mongo. - * @MONGOC_QUERY_NO_CURSOR_TIMEOUT: The server normally times out idle - * cursors after an inactivity period (10 minutes). This prevents that. - * @MONGOC_QUERY_AWAIT_DATA: Use with %MONGOC_QUERY_TAILABLE_CURSOR. Block - * rather than returning no data. After a period, time out. - * @MONGOC_QUERY_EXHAUST: Stream the data down full blast in multiple - * "more" packages. Faster when you are pulling a lot of data and - * know you want to pull it all down. - * @MONGOC_QUERY_PARTIAL: Get partial results from mongos if some shards - * are down (instead of throwing an error). - * - * #mongoc_query_flags_t is used for querying a Mongo instance. - */ -typedef enum { - MONGOC_QUERY_NONE = 0, - MONGOC_QUERY_TAILABLE_CURSOR = 1 << 1, - MONGOC_QUERY_SLAVE_OK = 1 << 2, - MONGOC_QUERY_SECONDARY_OK = 1 << 2, - MONGOC_QUERY_OPLOG_REPLAY = 1 << 3, - MONGOC_QUERY_NO_CURSOR_TIMEOUT = 1 << 4, - MONGOC_QUERY_AWAIT_DATA = 1 << 5, - MONGOC_QUERY_EXHAUST = 1 << 6, - MONGOC_QUERY_PARTIAL = 1 << 7, -} mongoc_query_flags_t; - - -/** - * mongoc_reply_flags_t: - * @MONGOC_REPLY_NONE: No flags set. - * @MONGOC_REPLY_CURSOR_NOT_FOUND: Cursor was not found. - * @MONGOC_REPLY_QUERY_FAILURE: Query failed, error document provided. - * @MONGOC_REPLY_SHARD_CONFIG_STALE: Shard configuration is stale. - * @MONGOC_REPLY_AWAIT_CAPABLE: Wait for data to be returned until timeout - * has passed. Used with %MONGOC_QUERY_TAILABLE_CURSOR. - * - * #mongoc_reply_flags_t contains flags supplied by the Mongo server in reply - * to a request. - */ -typedef enum { - MONGOC_REPLY_NONE = 0, - MONGOC_REPLY_CURSOR_NOT_FOUND = 1 << 0, - MONGOC_REPLY_QUERY_FAILURE = 1 << 1, - MONGOC_REPLY_SHARD_CONFIG_STALE = 1 << 2, - MONGOC_REPLY_AWAIT_CAPABLE = 1 << 3, -} mongoc_reply_flags_t; - - -/** - * mongoc_update_flags_t: - * @MONGOC_UPDATE_NONE: No update flags specified. - * @MONGOC_UPDATE_UPSERT: Perform an upsert. - * @MONGOC_UPDATE_MULTI_UPDATE: Continue updating after first match. - * - * #mongoc_update_flags_t is used when updating documents found in Mongo. - */ -typedef enum { - MONGOC_UPDATE_NONE = 0, - MONGOC_UPDATE_UPSERT = 1 << 0, - MONGOC_UPDATE_MULTI_UPDATE = 1 << 1, -} mongoc_update_flags_t; - - -#define MONGOC_UPDATE_NO_VALIDATE (1U << 31) - -BSON_END_DECLS - - -#endif /* MONGOC_FLAGS_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-bucket-file.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-bucket-file.c deleted file mode 100644 index 425b8c80c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-bucket-file.c +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Copyright 2018-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc.h" -#include "mongoc-gridfs-bucket-file-private.h" -#include "mongoc-gridfs-bucket-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-stream-gridfs-download-private.h" -#include "mongoc-stream-gridfs-upload-private.h" -#include "mongoc-collection-private.h" -#include "mongoc-util-private.h" - -/* Returns the minimum of two numbers */ -static size_t -_mongoc_min (const size_t a, const size_t b) -{ - return a < b ? a : b; -} - -/*-------------------------------------------------------------------------- - * - * _mongoc_gridfs_bucket_create_indexes -- - * - * Creates the indexes needed for GridFS on the 'files' and 'chunks' - * collections. - * - * Return: - * True if creating the indexes was successful, otherwise returns - * false. - * - *-------------------------------------------------------------------------- - */ -static bool -_mongoc_gridfs_bucket_create_indexes (mongoc_gridfs_bucket_t *bucket, - bson_error_t *error) -{ - mongoc_read_prefs_t *prefs; - bson_t filter; - bson_t opts; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_t files_index; - bson_t chunks_index; - bool r; - - /* Check to see if there already exists a document in the files collection */ - bson_init (&filter); - bson_append_int32 (&filter, "_id", 3, 1); - bson_init (&opts); - bson_append_bool (&opts, "singleBatch", 11, true); - bson_append_int32 (&opts, "limit", 5, 1); - prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - cursor = - mongoc_collection_find_with_opts (bucket->files, &filter, &opts, prefs); - bson_destroy (&filter); - bson_destroy (&opts); - - r = mongoc_cursor_next (cursor, &doc); - - mongoc_read_prefs_destroy (prefs); - if (r) { - /* Files exist */ - mongoc_cursor_destroy (cursor); - return true; - } else if (mongoc_cursor_error (cursor, error)) { - mongoc_cursor_destroy (cursor); - return false; - } - mongoc_cursor_destroy (cursor); - - /* Create files index */ - bson_init (&files_index); - BSON_APPEND_INT32 (&files_index, "filename", 1); - BSON_APPEND_INT32 (&files_index, "uploadDate", 1); - - r = _mongoc_collection_create_index_if_not_exists ( - bucket->files, &files_index, NULL, error); - bson_destroy (&files_index); - if (!r) { - return false; - } - - /* Create unique chunks index */ - bson_init (&opts); - BSON_APPEND_BOOL (&opts, "unique", true); - BSON_APPEND_UTF8 (&opts, "name", "files_id_1_n_1"); - - bson_init (&chunks_index); - BSON_APPEND_INT32 (&chunks_index, "files_id", 1); - BSON_APPEND_INT32 (&chunks_index, "n", 1); - - r = _mongoc_collection_create_index_if_not_exists ( - bucket->chunks, &chunks_index, &opts, error); - bson_destroy (&opts); - bson_destroy (&chunks_index); - - if (!r) { - return false; - } - - return true; -} - -/*-------------------------------------------------------------------------- - * - * _mongoc_gridfs_bucket_write_chunk -- - * - * Writes a chunk from the buffer into the chunks collection. - * - * Return: - * Returns true if the chunk was successfully written. Otherwise, - * returns false and sets an error on the bucket file. - * - *-------------------------------------------------------------------------- - */ -static bool -_mongoc_gridfs_bucket_write_chunk (mongoc_gridfs_bucket_file_t *file) -{ - bson_t chunk; - bool r; - - BSON_ASSERT (file); - - bson_init (&chunk); - - BSON_APPEND_INT32 (&chunk, "n", file->curr_chunk); - BSON_APPEND_VALUE (&chunk, "files_id", file->file_id); - BSON_APPEND_BINARY (&chunk, - "data", - BSON_SUBTYPE_BINARY, - file->buffer, - (uint32_t) file->in_buffer); - - - r = mongoc_collection_insert_one (file->bucket->chunks, - &chunk, - NULL /* opts */, - NULL /* reply */, - &file->err); - bson_destroy (&chunk); - if (!r) { - return false; - } - - file->curr_chunk++; - file->in_buffer = 0; - return true; -} - -/*-------------------------------------------------------------------------- - * - * _mongoc_gridfs_bucket_init_cursor -- - * - * Initializes the cursor at file->cursor for the given file. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_gridfs_bucket_init_cursor (mongoc_gridfs_bucket_file_t *file) -{ - bson_t filter; - bson_t opts; - bson_t sort; - - BSON_ASSERT (file); - - bson_init (&filter); - bson_init (&opts); - bson_init (&sort); - - BSON_APPEND_VALUE (&filter, "files_id", file->file_id); - BSON_APPEND_INT32 (&sort, "n", 1); - BSON_APPEND_DOCUMENT (&opts, "sort", &sort); - - file->cursor = mongoc_collection_find_with_opts ( - file->bucket->chunks, &filter, &opts, NULL); - - bson_destroy (&filter); - bson_destroy (&opts); - bson_destroy (&sort); -} - -/*-------------------------------------------------------------------------- - * - * _mongoc_gridfs_bucket_read_chunk -- - * - * Reads a chunk from the server and places it into the file's buffer - * - * Return: - * True if the buffer has been filled with any available data. - * Otherwise, false and sets the error on the bucket file. - * - *-------------------------------------------------------------------------- - */ -static bool -_mongoc_gridfs_bucket_read_chunk (mongoc_gridfs_bucket_file_t *file) -{ - const bson_t *next; - bool r; - bson_iter_t iter; - int32_t n; - const uint8_t *data; - uint32_t data_len; - int64_t total_chunks; - int64_t expected_size; - - BSON_ASSERT (file); - - if (file->length == 0) { - /* This file has zero length */ - file->in_buffer = 0; - file->finished = true; - return true; - } - - /* Calculate the total number of chunks for this file */ - total_chunks = (file->length / file->chunk_size); - if (file->length % file->chunk_size != 0) { - total_chunks++; - } - - if (file->curr_chunk == total_chunks) { - /* All chunks have been read! */ - file->in_buffer = 0; - file->finished = true; - return true; - } - - if (file->cursor == NULL) { - _mongoc_gridfs_bucket_init_cursor (file); - } - - r = mongoc_cursor_next (file->cursor, &next); - - if (mongoc_cursor_error (file->cursor, &file->err)) { - return false; - } - - if (!r) { - bson_set_error (&file->err, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_CHUNK_MISSING, - "Missing chunk %d.", - file->curr_chunk); - return false; - } - - r = bson_iter_init_find (&iter, next, "n"); - if (!r) { - bson_set_error (&file->err, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_CORRUPT, - "Chunk %d missing a required field 'n'.", - file->curr_chunk); - return false; - } - - n = bson_iter_int32 (&iter); - - if (n != file->curr_chunk) { - bson_set_error (&file->err, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_CHUNK_MISSING, - "Missing chunk %d.", - file->curr_chunk); - return false; - } - - r = bson_iter_init_find (&iter, next, "data"); - if (!r) { - bson_set_error (&file->err, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_CORRUPT, - "Chunk %d missing a required field 'data'.", - file->curr_chunk); - return false; - } - - bson_iter_binary (&iter, NULL, &data_len, &data); - - /* Assert that the data is the correct length */ - if (file->curr_chunk != total_chunks - 1) { - expected_size = file->chunk_size; - } else { - expected_size = file->length - ((total_chunks - 1) * file->chunk_size); - } - - if (data_len != expected_size) { - bson_set_error (&file->err, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_CORRUPT, - "Chunk %d expected to have size %" PRId64 - " but is size %d.", - file->curr_chunk, - expected_size, - data_len); - return false; - } - - memcpy (file->buffer, data, data_len); - file->in_buffer = data_len; - file->bytes_read = 0u; - file->curr_chunk++; - - return true; -} - -ssize_t -_mongoc_gridfs_bucket_file_writev (mongoc_gridfs_bucket_file_t *file, - const mongoc_iovec_t *iov, - size_t iovcnt) -{ - BSON_ASSERT (file); - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - - size_t total = 0; - - if (file->err.code) { - return -1; - } - - if (file->saved) { - bson_set_error (&file->err, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_PROTOCOL_ERROR, - "Cannot write after saving/aborting on a GridFS file."); - return -1; - } - - if (!file->bucket->indexed) { - if (!_mongoc_gridfs_bucket_create_indexes (file->bucket, &file->err)) { - /* Error is set on file. */ - return -1; - } else { - file->bucket->indexed = true; - } - } - - BSON_ASSERT (bson_in_range_signed (size_t, file->chunk_size)); - const size_t chunk_size = (size_t) file->chunk_size; - - for (size_t i = 0u; i < iovcnt; i++) { - size_t written_this_iov = 0u; - - while (written_this_iov < iov[i].iov_len) { - const size_t bytes_available = iov[i].iov_len - written_this_iov; - const size_t space_available = chunk_size - file->in_buffer; - const size_t to_write = _mongoc_min (bytes_available, space_available); - - memcpy (file->buffer + file->in_buffer, - ((char *) iov[i].iov_base) + written_this_iov, - to_write); - - file->in_buffer += to_write; - written_this_iov += to_write; - total += to_write; - - if (file->in_buffer == chunk_size) { - /* Buffer is filled, write the chunk */ - _mongoc_gridfs_bucket_write_chunk (file); - } - } - } - - BSON_ASSERT (bson_in_range_unsigned (ssize_t, total)); - return (ssize_t) total; -} - -ssize_t -_mongoc_gridfs_bucket_file_readv (mongoc_gridfs_bucket_file_t *file, - mongoc_iovec_t *iov, - size_t iovcnt) -{ - BSON_ASSERT (file); - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - - if (file->err.code) { - return -1; - } - - if (file->finished) { - return 0; - } - - size_t total = 0u; - - for (size_t i = 0u; i < iovcnt; i++) { - size_t read_this_iov = 0u; - - while (read_this_iov < iov[i].iov_len) { - const size_t bytes_available = file->in_buffer - file->bytes_read; - const size_t space_available = iov[i].iov_len - read_this_iov; - const size_t to_read = _mongoc_min (bytes_available, space_available); - - memcpy (((char *) iov[i].iov_base) + read_this_iov, - file->buffer + file->bytes_read, - to_read); - - file->bytes_read += to_read; - read_this_iov += to_read; - total += to_read; - - if (file->bytes_read == file->in_buffer) { - /* Everything in the current chunk has been read, so read a new - * chunk */ - if (!_mongoc_gridfs_bucket_read_chunk (file)) { - /* an error occured while reading the chunk */ - return -1; - } - if (file->finished) { - /* There's nothing left to read */ - BSON_ASSERT (bson_in_range_unsigned (ssize_t, total)); - RETURN ((ssize_t) total); - } - } - } - } - - BSON_ASSERT (bson_in_range_unsigned (ssize_t, total)); - RETURN ((ssize_t) total); -} - - -/*-------------------------------------------------------------------------- - * - * _mongoc_gridfs_bucket_file_save -- - * - * Saves the file to the files collection in gridFS. This locks the - * file into GridFS, and no more chunks are allowed to be written. - * - * Return: - * True if saved or no-op. False otherwise, and sets the file error. - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_gridfs_bucket_file_save (mongoc_gridfs_bucket_file_t *file) -{ - bson_t new_doc; - int64_t length; - bool r; - - BSON_ASSERT (file); - - if (file->saved) { - /* Already saved, or aborted. */ - return true; - } - - if (file->err.code) { - return false; - } - - length = ((int64_t) file->curr_chunk) * file->chunk_size; - - if (file->in_buffer != 0) { - length += file->in_buffer; - _mongoc_gridfs_bucket_write_chunk (file); - } - - file->length = length; - - bson_init (&new_doc); - BSON_APPEND_VALUE (&new_doc, "_id", file->file_id); - BSON_APPEND_INT64 (&new_doc, "length", file->length); - BSON_APPEND_INT32 (&new_doc, "chunkSize", file->chunk_size); - BSON_APPEND_DATE_TIME (&new_doc, "uploadDate", _mongoc_get_real_time_ms ()); - BSON_APPEND_UTF8 (&new_doc, "filename", file->filename); - if (file->metadata) { - BSON_APPEND_DOCUMENT (&new_doc, "metadata", file->metadata); - } - - r = mongoc_collection_insert_one ( - file->bucket->files, &new_doc, NULL, NULL, &file->err); - bson_destroy (&new_doc); - file->saved = r; - return (file->err.code) ? false : true; -} - -void -_mongoc_gridfs_bucket_file_destroy (mongoc_gridfs_bucket_file_t *file) -{ - if (file) { - bson_value_destroy (file->file_id); - bson_free (file->file_id); - bson_destroy (file->metadata); - mongoc_cursor_destroy (file->cursor); - bson_free (file->buffer); - bson_free (file->filename); - bson_free (file); - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-list-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-list-private.h deleted file mode 100644 index d7179ca15..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-list-private.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2013 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_GRIDFS_FILE_LIST_PRIVATE_H -#define MONGOC_GRIDFS_FILE_LIST_PRIVATE_H - -#include - -#include "mongoc-gridfs.h" -#include "mongoc-gridfs-file.h" -#include "mongoc-cursor.h" - - -BSON_BEGIN_DECLS - - -struct _mongoc_gridfs_file_list_t { - mongoc_gridfs_t *gridfs; - mongoc_cursor_t *cursor; - bson_error_t error; -}; - - -mongoc_gridfs_file_list_t * -_mongoc_gridfs_file_list_new (mongoc_gridfs_t *gridfs, - const bson_t *query, - uint32_t limit); -mongoc_gridfs_file_list_t * -_mongoc_gridfs_file_list_new_with_opts (mongoc_gridfs_t *gridfs, - const bson_t *filter, - const bson_t *opts); - - -BSON_END_DECLS - - -#endif /* MONGOC_GRIDFS_FILE_LIST_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.c deleted file mode 100644 index eef37dfc5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2013 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "mongoc-cursor.h" -#include "mongoc-cursor-private.h" -#include "mongoc-collection-private.h" -#include "mongoc-gridfs.h" -#include "mongoc-gridfs-private.h" -#include "mongoc-gridfs-file.h" -#include "mongoc-gridfs-file-private.h" -#include "mongoc-gridfs-file-list.h" -#include "mongoc-gridfs-file-list-private.h" -#include "mongoc-trace-private.h" - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "gridfs_file_list" - - -mongoc_gridfs_file_list_t * -_mongoc_gridfs_file_list_new (mongoc_gridfs_t *gridfs, - const bson_t *query, - uint32_t limit) -{ - mongoc_gridfs_file_list_t *list; - mongoc_cursor_t *cursor; - bool use_unwrapped; - bson_t opts; - bson_t unwrapped; - bson_error_t error; - bson_init (&opts); - use_unwrapped = _mongoc_cursor_translate_dollar_query_opts ( - query, &opts, &unwrapped, &error); - - - cursor = _mongoc_cursor_find_new (gridfs->client, - gridfs->files->ns, - use_unwrapped ? &unwrapped : query, - &opts, - NULL, - gridfs->files->read_prefs, - gridfs->files->read_concern); - BSON_ASSERT (cursor); - bson_destroy (&opts); - if (limit) { - (void) mongoc_cursor_set_limit (cursor, limit); - } - bson_destroy (&unwrapped); - if (error.domain) { - memcpy (&cursor->error, &error, sizeof (bson_error_t)); - } - - list = (mongoc_gridfs_file_list_t *) bson_malloc0 (sizeof *list); - - list->cursor = cursor; - list->gridfs = gridfs; - - return list; -} - - -mongoc_gridfs_file_list_t * -_mongoc_gridfs_file_list_new_with_opts (mongoc_gridfs_t *gridfs, - const bson_t *filter, - const bson_t *opts) -{ - mongoc_gridfs_file_list_t *list; - mongoc_cursor_t *cursor; - - cursor = mongoc_collection_find_with_opts ( - gridfs->files, filter, opts, NULL /* read prefs */); - - BSON_ASSERT (cursor); - - list = (mongoc_gridfs_file_list_t *) bson_malloc0 (sizeof *list); - - list->cursor = cursor; - list->gridfs = gridfs; - - return list; -} - - -mongoc_gridfs_file_t * -mongoc_gridfs_file_list_next (mongoc_gridfs_file_list_t *list) -{ - const bson_t *bson; - - BSON_ASSERT (list); - - if (mongoc_cursor_next (list->cursor, &bson)) { - return _mongoc_gridfs_file_new_from_bson (list->gridfs, bson); - } else { - return NULL; - } -} - - -bool -mongoc_gridfs_file_list_error (mongoc_gridfs_file_list_t *list, - bson_error_t *error) -{ - return mongoc_cursor_error (list->cursor, error); -} - - -void -mongoc_gridfs_file_list_destroy (mongoc_gridfs_file_list_t *list) -{ - if (!list) { - return; - } - - mongoc_cursor_destroy (list->cursor); - bson_free (list); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.h deleted file mode 100644 index 284204ae4..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_GRIDFS_FILE_LIST_H -#define MONGOC_GRIDFS_FILE_LIST_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-gridfs-file.h" - - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_gridfs_file_list_t mongoc_gridfs_file_list_t; - - -MONGOC_EXPORT (mongoc_gridfs_file_t *) -mongoc_gridfs_file_list_next (mongoc_gridfs_file_list_t *list) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_gridfs_file_list_destroy (mongoc_gridfs_file_list_t *list); -MONGOC_EXPORT (bool) -mongoc_gridfs_file_list_error (mongoc_gridfs_file_list_t *list, - bson_error_t *error); - - -BSON_END_DECLS - - -#endif /* MONGOC_GRIDFS_FILE_LIST_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-page-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-page-private.h deleted file mode 100644 index c57943123..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-file-page-private.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2013 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_GRIDFS_FILE_PAGE_PRIVATE_H -#define MONGOC_GRIDFS_FILE_PAGE_PRIVATE_H - -#include - -#include "mongoc-gridfs-file.h" - - -BSON_BEGIN_DECLS - - -struct _mongoc_gridfs_file_page_t { - const uint8_t *read_buf; - uint8_t *buf; - uint32_t len; - uint32_t chunk_size; - uint32_t offset; -}; - - -mongoc_gridfs_file_page_t * -_mongoc_gridfs_file_page_new (const uint8_t *data, - uint32_t len, - uint32_t chunk_size); -void -_mongoc_gridfs_file_page_destroy (mongoc_gridfs_file_page_t *page); -bool -_mongoc_gridfs_file_page_seek (mongoc_gridfs_file_page_t *page, - uint32_t offset); -int32_t -_mongoc_gridfs_file_page_read (mongoc_gridfs_file_page_t *page, - void *dst, - uint32_t len); -int32_t -_mongoc_gridfs_file_page_write (mongoc_gridfs_file_page_t *page, - const void *src, - uint32_t len); -uint32_t -_mongoc_gridfs_file_page_memset0 (mongoc_gridfs_file_page_t *page, - uint32_t len); -uint32_t -_mongoc_gridfs_file_page_tell (mongoc_gridfs_file_page_t *page); -const uint8_t * -_mongoc_gridfs_file_page_get_data (mongoc_gridfs_file_page_t *page); -uint32_t -_mongoc_gridfs_file_page_get_len (mongoc_gridfs_file_page_t *page); -bool -_mongoc_gridfs_file_page_is_dirty (mongoc_gridfs_file_page_t *page); - - -BSON_END_DECLS - - -#endif /* MONGOC_GRIDFS_FILE_PAGE_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-private.h deleted file mode 100644 index 1138d331d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs-private.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_GRIDFS_PRIVATE_H -#define MONGOC_GRIDFS_PRIVATE_H - -#include - -#include "mongoc-read-prefs.h" -#include "mongoc-write-concern.h" -#include "mongoc-client.h" - - -BSON_BEGIN_DECLS - - -struct _mongoc_gridfs_t { - mongoc_client_t *client; - mongoc_collection_t *files; - mongoc_collection_t *chunks; -}; - - -mongoc_gridfs_t * -_mongoc_gridfs_new (mongoc_client_t *client, - const char *db, - const char *prefix, - bson_error_t *error); - - -BSON_END_DECLS - - -#endif /* MONGOC_GRIDFS_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs.c deleted file mode 100644 index 39f8bef80..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs.c +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright 2013 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "gridfs" - -#include "mongoc-bulk-operation.h" -#include "mongoc-client-private.h" -#include "mongoc-collection.h" -#include "mongoc-collection-private.h" -#include "mongoc-error.h" -#include "mongoc-index.h" -#include "mongoc-gridfs.h" -#include "mongoc-gridfs-private.h" -#include "mongoc-gridfs-file.h" -#include "mongoc-gridfs-file-private.h" -#include "mongoc-gridfs-file-list.h" -#include "mongoc-gridfs-file-list-private.h" -#include "mongoc-client.h" -#include "mongoc-trace-private.h" -#include "mongoc-cursor-private.h" -#include "mongoc-util-private.h" - -#define MONGOC_GRIDFS_STREAM_CHUNK 4096 - - -/** - * _mongoc_gridfs_ensure_index: - * - * ensure gridfs indexes - * - * Ensure fast searches for chunks via [ files_id, n ] - * Ensure fast searches for files via [ filename ] - */ -static bool -_mongoc_gridfs_ensure_index (mongoc_gridfs_t *gridfs, bson_error_t *error) -{ - bson_t keys; - bson_t opts; - bool r; - - ENTRY; - - bson_init (&opts); - BSON_APPEND_BOOL (&opts, "unique", true); - - bson_init (&keys); - - BSON_APPEND_INT32 (&keys, "files_id", 1); - BSON_APPEND_INT32 (&keys, "n", 1); - - r = _mongoc_collection_create_index_if_not_exists ( - gridfs->chunks, &keys, &opts, error); - - bson_destroy (&opts); - bson_destroy (&keys); - - if (!r) { - RETURN (r); - } - - bson_init (&keys); - - BSON_APPEND_INT32 (&keys, "filename", 1); - BSON_APPEND_INT32 (&keys, "uploadDate", 1); - - r = _mongoc_collection_create_index_if_not_exists ( - gridfs->files, &keys, NULL, error); - - bson_destroy (&keys); - - if (!r) { - RETURN (r); - } - - RETURN (1); -} - - -mongoc_gridfs_t * -_mongoc_gridfs_new (mongoc_client_t *client, - const char *db, - const char *prefix, - bson_error_t *error) -{ - mongoc_gridfs_t *gridfs; - char buf[128]; - bool r; - uint32_t prefix_len; - - ENTRY; - - BSON_ASSERT_PARAM (client); - BSON_ASSERT (db); - - if (!prefix) { - prefix = "fs"; - } - - /* make sure prefix is short enough to bucket the chunks and files - * collections - */ - prefix_len = (uint32_t) strlen (prefix); - BSON_ASSERT (prefix_len + sizeof (".chunks") < sizeof (buf)); - - gridfs = (mongoc_gridfs_t *) bson_malloc0 (sizeof *gridfs); - - gridfs->client = client; - - bson_snprintf (buf, sizeof (buf), "%s.chunks", prefix); - gridfs->chunks = mongoc_client_get_collection (client, db, buf); - - bson_snprintf (buf, sizeof (buf), "%s.files", prefix); - gridfs->files = mongoc_client_get_collection (client, db, buf); - - r = _mongoc_gridfs_ensure_index (gridfs, error); - - if (!r) { - mongoc_gridfs_destroy (gridfs); - RETURN (NULL); - } - - RETURN (gridfs); -} - - -bool -mongoc_gridfs_drop (mongoc_gridfs_t *gridfs, bson_error_t *error) -{ - bool r; - - ENTRY; - - r = mongoc_collection_drop (gridfs->files, error); - if (!r) { - RETURN (0); - } - - r = mongoc_collection_drop (gridfs->chunks, error); - if (!r) { - RETURN (0); - } - - RETURN (1); -} - - -void -mongoc_gridfs_destroy (mongoc_gridfs_t *gridfs) -{ - ENTRY; - - if (!gridfs) { - EXIT; - } - - mongoc_collection_destroy (gridfs->files); - mongoc_collection_destroy (gridfs->chunks); - - bson_free (gridfs); - - EXIT; -} - - -/** find all matching gridfs files */ -mongoc_gridfs_file_list_t * -mongoc_gridfs_find (mongoc_gridfs_t *gridfs, const bson_t *query) -{ - return _mongoc_gridfs_file_list_new (gridfs, query, 0); -} - - -/** find a single gridfs file */ -mongoc_gridfs_file_t * -mongoc_gridfs_find_one (mongoc_gridfs_t *gridfs, - const bson_t *query, - bson_error_t *error) -{ - mongoc_gridfs_file_list_t *list; - mongoc_gridfs_file_t *file; - - ENTRY; - - list = _mongoc_gridfs_file_list_new (gridfs, query, 1); - - file = mongoc_gridfs_file_list_next (list); - if (!mongoc_gridfs_file_list_error (list, error) && error) { - /* no error, but an error out-pointer was provided - clear it */ - memset (error, 0, sizeof (*error)); - } - - mongoc_gridfs_file_list_destroy (list); - - RETURN (file); -} - - -/** find all matching gridfs files */ -mongoc_gridfs_file_list_t * -mongoc_gridfs_find_with_opts (mongoc_gridfs_t *gridfs, - const bson_t *filter, - const bson_t *opts) -{ - return _mongoc_gridfs_file_list_new_with_opts (gridfs, filter, opts); -} - - -/** find a single gridfs file */ -mongoc_gridfs_file_t * -mongoc_gridfs_find_one_with_opts (mongoc_gridfs_t *gridfs, - const bson_t *filter, - const bson_t *opts, - bson_error_t *error) -{ - mongoc_gridfs_file_list_t *list; - mongoc_gridfs_file_t *file; - bson_t new_opts; - - ENTRY; - - bson_init (&new_opts); - - if (opts) { - bson_copy_to_excluding_noinit (opts, &new_opts, "limit", (char *) NULL); - } - - BSON_APPEND_INT32 (&new_opts, "limit", 1); - - list = _mongoc_gridfs_file_list_new_with_opts (gridfs, filter, &new_opts); - file = mongoc_gridfs_file_list_next (list); - - if (!mongoc_gridfs_file_list_error (list, error) && error) { - /* no error, but an error out-pointer was provided - clear it */ - memset (error, 0, sizeof (*error)); - } - - mongoc_gridfs_file_list_destroy (list); - bson_destroy (&new_opts); - - RETURN (file); -} - - -/** find a single gridfs file by filename */ -mongoc_gridfs_file_t * -mongoc_gridfs_find_one_by_filename (mongoc_gridfs_t *gridfs, - const char *filename, - bson_error_t *error) -{ - mongoc_gridfs_file_t *file; - - bson_t filter; - - bson_init (&filter); - - bson_append_utf8 (&filter, "filename", -1, filename, -1); - - file = mongoc_gridfs_find_one_with_opts (gridfs, &filter, NULL, error); - - bson_destroy (&filter); - - return file; -} - - -/** create a gridfs file from a stream - * - * The stream is fully consumed in creating the file - */ -mongoc_gridfs_file_t * -mongoc_gridfs_create_file_from_stream (mongoc_gridfs_t *gridfs, - mongoc_stream_t *stream, - mongoc_gridfs_file_opt_t *opt) -{ - mongoc_gridfs_file_t *file; - ssize_t r; - uint8_t buf[MONGOC_GRIDFS_STREAM_CHUNK]; - mongoc_iovec_t iov; - int timeout; - - ENTRY; - - BSON_ASSERT (gridfs); - BSON_ASSERT (stream); - - iov.iov_base = (void *) buf; - iov.iov_len = 0; - - file = _mongoc_gridfs_file_new (gridfs, opt); - timeout = gridfs->client->cluster.sockettimeoutms; - - for (;;) { - r = mongoc_stream_read ( - stream, iov.iov_base, MONGOC_GRIDFS_STREAM_CHUNK, 0, timeout); - - if (r > 0) { - iov.iov_len = r; - if (mongoc_gridfs_file_writev (file, &iov, 1, timeout) < 0) { - MONGOC_ERROR ("%s", file->error.message); - mongoc_gridfs_file_destroy (file); - RETURN (NULL); - } - } else if (r == 0) { - break; - } else { - MONGOC_ERROR ("Error reading from GridFS file source stream"); - mongoc_gridfs_file_destroy (file); - RETURN (NULL); - } - } - - mongoc_stream_failed (stream); - - if (-1 == mongoc_gridfs_file_seek (file, 0, SEEK_SET)) { - MONGOC_ERROR ("%s", file->error.message); - mongoc_gridfs_file_destroy (file); - RETURN (NULL); - } - - RETURN (file); -} - - -/** create an empty gridfs file */ -mongoc_gridfs_file_t * -mongoc_gridfs_create_file (mongoc_gridfs_t *gridfs, - mongoc_gridfs_file_opt_t *opt) -{ - mongoc_gridfs_file_t *file; - - ENTRY; - - BSON_ASSERT (gridfs); - - file = _mongoc_gridfs_file_new (gridfs, opt); - - RETURN (file); -} - -/** accessor functions for collections */ -mongoc_collection_t * -mongoc_gridfs_get_files (mongoc_gridfs_t *gridfs) -{ - BSON_ASSERT (gridfs); - - return gridfs->files; -} - -mongoc_collection_t * -mongoc_gridfs_get_chunks (mongoc_gridfs_t *gridfs) -{ - BSON_ASSERT (gridfs); - - return gridfs->chunks; -} - - -bool -mongoc_gridfs_remove_by_filename (mongoc_gridfs_t *gridfs, - const char *filename, - bson_error_t *error) -{ - mongoc_bulk_operation_t *bulk_files = NULL; - mongoc_bulk_operation_t *bulk_chunks = NULL; - mongoc_cursor_t *cursor = NULL; - bson_error_t files_error; - bson_error_t chunks_error; - const bson_t *doc; - const char *key; - char keybuf[16]; - int count = 0; - bool chunks_ret; - bool files_ret; - bool ret = false; - bson_iter_t iter; - bson_t *files_q = NULL; - bson_t *chunks_q = NULL; - bson_t find_filter = BSON_INITIALIZER; - bson_t find_opts = BSON_INITIALIZER; - bson_t find_opts_project; - bson_t ar = BSON_INITIALIZER; - bson_t opts = BSON_INITIALIZER; - - BSON_ASSERT (gridfs); - - if (!filename) { - bson_set_error (error, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_INVALID_FILENAME, - "A non-NULL filename must be specified."); - return false; - } - - /* - * Find all files matching this filename. Hopefully just one, but not - * strictly required! - */ - - BSON_APPEND_UTF8 (&find_filter, "filename", filename); - BSON_APPEND_DOCUMENT_BEGIN (&find_opts, "projection", &find_opts_project); - BSON_APPEND_INT32 (&find_opts_project, "_id", 1); - bson_append_document_end (&find_opts, &find_opts_project); - - cursor = _mongoc_cursor_find_new (gridfs->client, - gridfs->files->ns, - &find_filter, - &find_opts, - NULL /* user_prefs */, - NULL /* default_prefs */, - NULL /* read_concern */); - - BSON_ASSERT (cursor); - - while (mongoc_cursor_next (cursor, &doc)) { - if (bson_iter_init_find (&iter, doc, "_id")) { - const bson_value_t *value = bson_iter_value (&iter); - - bson_uint32_to_string (count, &key, keybuf, sizeof keybuf); - BSON_APPEND_VALUE (&ar, key, value); - } - } - - if (mongoc_cursor_error (cursor, error)) { - goto failure; - } - - bson_append_bool (&opts, "ordered", 7, false); - bulk_files = - mongoc_collection_create_bulk_operation_with_opts (gridfs->files, &opts); - bulk_chunks = - mongoc_collection_create_bulk_operation_with_opts (gridfs->chunks, &opts); - - bson_destroy (&opts); - - files_q = BCON_NEW ("_id", "{", "$in", BCON_ARRAY (&ar), "}"); - chunks_q = BCON_NEW ("files_id", "{", "$in", BCON_ARRAY (&ar), "}"); - - mongoc_bulk_operation_remove (bulk_files, files_q); - mongoc_bulk_operation_remove (bulk_chunks, chunks_q); - - files_ret = mongoc_bulk_operation_execute (bulk_files, NULL, &files_error); - chunks_ret = - mongoc_bulk_operation_execute (bulk_chunks, NULL, &chunks_error); - - if (error) { - if (!files_ret) { - memcpy (error, &files_error, sizeof *error); - } else if (!chunks_ret) { - memcpy (error, &chunks_error, sizeof *error); - } - } - - ret = (files_ret && chunks_ret); - -failure: - if (cursor) { - mongoc_cursor_destroy (cursor); - } - if (bulk_files) { - mongoc_bulk_operation_destroy (bulk_files); - } - if (bulk_chunks) { - mongoc_bulk_operation_destroy (bulk_chunks); - } - bson_destroy (&find_filter); - bson_destroy (&find_opts); - bson_destroy (&ar); - if (files_q) { - bson_destroy (files_q); - } - if (chunks_q) { - bson_destroy (chunks_q); - } - - return ret; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs.h deleted file mode 100644 index e75ba3972..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-gridfs.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2013 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_GRIDFS_H -#define MONGOC_GRIDFS_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-stream.h" -#include "mongoc-gridfs-file.h" -#include "mongoc-collection.h" -#include "mongoc-gridfs-file-list.h" - - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_gridfs_t mongoc_gridfs_t; - - -MONGOC_EXPORT (mongoc_gridfs_file_t *) -mongoc_gridfs_create_file_from_stream (mongoc_gridfs_t *gridfs, - mongoc_stream_t *stream, - mongoc_gridfs_file_opt_t *opt) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_gridfs_file_t *) -mongoc_gridfs_create_file (mongoc_gridfs_t *gridfs, - mongoc_gridfs_file_opt_t *opt) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_gridfs_file_list_t *) -mongoc_gridfs_find (mongoc_gridfs_t *gridfs, - const bson_t *query) BSON_GNUC_WARN_UNUSED_RESULT - BSON_GNUC_DEPRECATED_FOR (mongoc_gridfs_find_with_opts); -MONGOC_EXPORT (mongoc_gridfs_file_t *) -mongoc_gridfs_find_one (mongoc_gridfs_t *gridfs, - const bson_t *query, - bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT - BSON_GNUC_DEPRECATED_FOR (mongoc_gridfs_find_one_with_opts); -MONGOC_EXPORT (mongoc_gridfs_file_list_t *) -mongoc_gridfs_find_with_opts (mongoc_gridfs_t *gridfs, - const bson_t *filter, - const bson_t *opts) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_gridfs_file_t *) -mongoc_gridfs_find_one_with_opts (mongoc_gridfs_t *gridfs, - const bson_t *filter, - const bson_t *opts, - bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_gridfs_file_t *) -mongoc_gridfs_find_one_by_filename (mongoc_gridfs_t *gridfs, - const char *filename, - bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (bool) -mongoc_gridfs_drop (mongoc_gridfs_t *gridfs, bson_error_t *error); -MONGOC_EXPORT (void) -mongoc_gridfs_destroy (mongoc_gridfs_t *gridfs); -MONGOC_EXPORT (mongoc_collection_t *) -mongoc_gridfs_get_files (mongoc_gridfs_t *gridfs); -MONGOC_EXPORT (mongoc_collection_t *) -mongoc_gridfs_get_chunks (mongoc_gridfs_t *gridfs); -MONGOC_EXPORT (bool) -mongoc_gridfs_remove_by_filename (mongoc_gridfs_t *gridfs, - const char *filename, - bson_error_t *error); - - -BSON_END_DECLS - - -#endif /* MONGOC_GRIDFS_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-handshake.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-handshake.c deleted file mode 100644 index 6b3fc28ee..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-handshake.c +++ /dev/null @@ -1,887 +0,0 @@ -/* - * Copyright 2016-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#ifdef _POSIX_VERSION -#include -#endif - -#ifdef _WIN32 -#include -#endif - -#include "mongoc-linux-distro-scanner-private.h" -#include "mongoc-handshake.h" -#include "mongoc-handshake-compiler-private.h" -#include "mongoc-handshake-os-private.h" -#include "mongoc-handshake-private.h" -#include "mongoc-client.h" -#include "mongoc-client-private.h" -#include "mongoc-error.h" -#include "mongoc-log.h" -#include "mongoc-version.h" -#include "mongoc-util-private.h" - -#include - -/* - * Global handshake data instance. Initialized at startup from mongoc_init - * - * Can be modified by calls to mongoc_handshake_data_append - */ -static mongoc_handshake_t gMongocHandshake; - -/* - * Used for thread-safety in mongoc_handshake_data_append - */ -static bson_mutex_t gHandshakeLock; - -static void -_set_bit (uint8_t *bf, uint32_t byte_count, uint32_t bit) -{ - uint32_t byte = bit / 8; - uint32_t bit_of_byte = (bit) % 8; - /* byte 0 is the last location in bf. */ - bf[(byte_count - 1) - byte] |= 1u << bit_of_byte; -} - -/* returns a hex string for all config flag bits, which must be freed. */ -char * -_mongoc_handshake_get_config_hex_string (void) -{ - const uint32_t byte_count = - (LAST_MONGOC_MD_FLAG + 7) / 8; /* ceil (num_bits / 8) */ - /* allocate enough bytes to fit all config bits. */ - uint8_t *const bf = (uint8_t *) bson_malloc0 (byte_count); - -#ifdef MONGOC_ENABLE_SSL_SECURE_CHANNEL - _set_bit (bf, byte_count, MONGOC_ENABLE_SSL_SECURE_CHANNEL); -#endif - -#ifdef MONGOC_ENABLE_CRYPTO_CNG - _set_bit (bf, byte_count, MONGOC_ENABLE_CRYPTO_CNG); -#endif - -#ifdef MONGOC_ENABLE_SSL_SECURE_TRANSPORT - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_SSL_SECURE_TRANSPORT); -#endif - -#ifdef MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_CRYPTO_COMMON_CRYPTO); -#endif - -#ifdef MONGOC_ENABLE_SSL_OPENSSL - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_SSL_OPENSSL); -#endif - -#ifdef MONGOC_ENABLE_CRYPTO_LIBCRYPTO - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_CRYPTO_LIBCRYPTO); -#endif - -#ifdef MONGOC_ENABLE_SSL - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_SSL); -#endif - -#ifdef MONGOC_ENABLE_CRYPTO - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_CRYPTO); -#endif - -#ifdef MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_CRYPTO_SYSTEM_PROFILE); -#endif - -#ifdef MONGOC_ENABLE_SASL - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_SASL); -#endif - -#ifdef MONGOC_HAVE_SASL_CLIENT_DONE - _set_bit (bf, byte_count, MONGOC_MD_FLAG_HAVE_SASL_CLIENT_DONE); -#endif - -#ifdef MONGOC_NO_AUTOMATIC_GLOBALS - _set_bit (bf, byte_count, MONGOC_MD_FLAG_NO_AUTOMATIC_GLOBALS); -#endif - -#ifdef MONGOC_EXPERIMENTAL_FEATURES - _set_bit (bf, byte_count, MONGOC_MD_FLAG_EXPERIMENTAL_FEATURES); -#endif - -#ifdef MONGOC_ENABLE_SSL_LIBRESSL - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_SSL_LIBRESSL); -#endif - -#ifdef MONGOC_ENABLE_SASL_CYRUS - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_SASL_CYRUS); -#endif - -#ifdef MONGOC_ENABLE_SASL_SSPI - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_SASL_SSPI); -#endif - -#ifdef MONGOC_HAVE_SOCKLEN - _set_bit (bf, byte_count, MONGOC_MD_FLAG_HAVE_SOCKLEN); -#endif - -#ifdef MONGOC_ENABLE_COMPRESSION - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_COMPRESSION); -#endif - -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_COMPRESSION_SNAPPY); -#endif - -#ifdef MONGOC_ENABLE_COMPRESSION_ZLIB - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_COMPRESSION_ZLIB); -#endif - -#ifdef MONGOC_HAVE_RES_NSEARCH - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_RES_NSEARCH); -#endif - -#ifdef MONGOC_HAVE_RES_NDESTROY - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_RES_NDESTROY); -#endif - -#ifdef MONGOC_HAVE_RES_NCLOSE - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_RES_NCLOSE); -#endif - -#ifdef MONGOC_HAVE_RES_SEARCH - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_RES_SEARCH); -#endif - -#ifdef MONGOC_HAVE_DNSAPI - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_DNSAPI); -#endif - -#ifdef MONGOC_HAVE_RDTSCP - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_RDTSCP); -#endif - -#ifdef MONGOC_HAVE_SCHED_GETCPU - _set_bit (bf, byte_count, MONGOC_MD_FLAG_HAVE_SCHED_GETCPU); -#endif - -#ifdef MONGOC_ENABLE_SHM_COUNTERS - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_SHM_COUNTERS); -#endif - - if (MONGOC_TRACE_ENABLED) { - _set_bit (bf, byte_count, MONGOC_MD_FLAG_TRACE); - } - -#ifdef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_CLIENT_SIDE_ENCRYPTION); -#endif - -#ifdef MONGOC_ENABLE_MONGODB_AWS_AUTH - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_MONGODB_AWS_AUTH); -#endif - - if (MONGOC_SRV_ENABLED) { - _set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_SRV); - } - - bson_string_t *const str = bson_string_new ("0x"); - for (uint32_t i = 0u; i < byte_count; i++) { - bson_string_append_printf (str, "%02x", bf[i]); - } - bson_free (bf); - /* free the bson_string_t, but keep the underlying char* alive. */ - return bson_string_free (str, false); -} - -static char * -_get_os_type (void) -{ -#ifdef MONGOC_OS_TYPE - return bson_strndup (MONGOC_OS_TYPE, HANDSHAKE_OS_TYPE_MAX); -#else - return bson_strndup ("unknown", HANDSHAKE_OS_TYPE_MAX); -#endif -} - -static char * -_get_os_architecture (void) -{ - const char *ret = NULL; - -#ifdef _WIN32 - SYSTEM_INFO system_info; - DWORD arch; - GetSystemInfo (&system_info); - - arch = system_info.wProcessorArchitecture; - - switch (arch) { - case PROCESSOR_ARCHITECTURE_AMD64: - ret = "x86_64"; - break; - case PROCESSOR_ARCHITECTURE_ARM: - ret = "ARM"; - break; - case PROCESSOR_ARCHITECTURE_IA64: - ret = "IA64"; - break; - case PROCESSOR_ARCHITECTURE_INTEL: - ret = "x86"; - break; - case PROCESSOR_ARCHITECTURE_UNKNOWN: - ret = "Unknown"; - break; - default: - ret = "Other"; - break; - } - -#elif defined(_POSIX_VERSION) - struct utsname system_info; - - if (uname (&system_info) >= 0) { - ret = system_info.machine; - } - -#endif - - if (ret) { - return bson_strndup (ret, HANDSHAKE_OS_ARCHITECTURE_MAX); - } - - return NULL; -} - -#ifndef MONGOC_OS_IS_LINUX -static char * -_get_os_name (void) -{ -#ifdef MONGOC_OS_NAME - return bson_strndup (MONGOC_OS_NAME, HANDSHAKE_OS_NAME_MAX); -#elif defined(_POSIX_VERSION) - struct utsname system_info; - - if (uname (&system_info) >= 0) { - return bson_strndup (system_info.sysname, HANDSHAKE_OS_NAME_MAX); - } - -#endif - - return NULL; -} - -static char * -_get_os_version (void) -{ - char *ret = bson_malloc (HANDSHAKE_OS_VERSION_MAX); - bool found = false; - -#ifdef _WIN32 - OSVERSIONINFO osvi; - ZeroMemory (&osvi, sizeof (OSVERSIONINFO)); - osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); - -#if defined(_MSC_VER) - // CDRIVER-4263: GetVersionEx is deprecated. -#pragma warning(suppress : 4996) - const BOOL res = GetVersionEx (&osvi); -#else - const BOOL res = GetVersionEx (&osvi); -#endif - - if (res) { - bson_snprintf (ret, - HANDSHAKE_OS_VERSION_MAX, - "%lu.%lu (%lu)", - osvi.dwMajorVersion, - osvi.dwMinorVersion, - osvi.dwBuildNumber); - found = true; - } else { - MONGOC_WARNING ("Error with GetVersionEx(): %lu", GetLastError ()); - } - -#elif defined(_POSIX_VERSION) - struct utsname system_info; - - if (uname (&system_info) >= 0) { - bson_strncpy (ret, system_info.release, HANDSHAKE_OS_VERSION_MAX); - found = true; - } else { - MONGOC_WARNING ("Error with uname(): %d", errno); - } - -#endif - - if (!found) { - bson_free (ret); - ret = NULL; - } - - return ret; -} -#endif - -static void -_get_system_info (mongoc_handshake_t *handshake) -{ - handshake->os_type = _get_os_type (); - -#ifdef MONGOC_OS_IS_LINUX - _mongoc_linux_distro_scanner_get_distro (&handshake->os_name, - &handshake->os_version); -#else - handshake->os_name = _get_os_name (); - handshake->os_version = _get_os_version (); -#endif - - handshake->os_architecture = _get_os_architecture (); -} - -static void -_free_system_info (mongoc_handshake_t *handshake) -{ - bson_free (handshake->os_type); - bson_free (handshake->os_name); - bson_free (handshake->os_version); - bson_free (handshake->os_architecture); -} - -static void -_get_driver_info (mongoc_handshake_t *handshake) -{ - handshake->driver_name = bson_strndup ("mongoc", HANDSHAKE_DRIVER_NAME_MAX); - handshake->driver_version = - bson_strndup (MONGOC_VERSION_S, HANDSHAKE_DRIVER_VERSION_MAX); -} - -static void -_free_driver_info (mongoc_handshake_t *handshake) -{ - bson_free (handshake->driver_name); - bson_free (handshake->driver_version); -} - -static void -_set_platform_string (mongoc_handshake_t *handshake) -{ - bson_string_t *str; - - str = bson_string_new (""); - - handshake->platform = bson_string_free (str, false); -} - -static void -_free_env_info (mongoc_handshake_t *handshake) -{ - bson_free (handshake->env_region); -} - -static void -_get_env_info (mongoc_handshake_t *handshake) -{ - char *aws_env = _mongoc_getenv ("AWS_EXECUTION_ENV"); - char *aws_lambda = _mongoc_getenv ("AWS_LAMBDA_RUNTIME_API"); - char *vercel_env = _mongoc_getenv ("VERCEL"); - char *azure_env = _mongoc_getenv ("FUNCTIONS_WORKER_RUNTIME"); - char *gcp_env = _mongoc_getenv ("K_SERVICE"); - char *memory_str = NULL; - char *timeout_str = NULL; - char *region_str = NULL; - - bool is_aws = (aws_env && strlen (aws_env) && - (aws_env == strstr (aws_env, "AWS_Lambda_"))) || - (aws_lambda && strlen (aws_lambda)); - bool is_vercel = vercel_env && strlen (vercel_env); - bool is_azure = azure_env && strlen (azure_env); - bool is_gcp = gcp_env && strlen (gcp_env); - - handshake->env = MONGOC_HANDSHAKE_ENV_NONE; - handshake->env_region = NULL; - handshake->env_memory_mb.set = false; - handshake->env_timeout_sec.set = false; - - if ((is_aws || is_vercel) + is_azure + is_gcp != 1) { - goto cleanup; - } - - if (is_aws && !is_vercel) { - handshake->env = MONGOC_HANDSHAKE_ENV_AWS; - region_str = _mongoc_getenv ("AWS_REGION"); - memory_str = _mongoc_getenv ("AWS_LAMBDA_FUNCTION_MEMORY_SIZE"); - } else if (is_vercel) { - handshake->env = MONGOC_HANDSHAKE_ENV_VERCEL; - region_str = _mongoc_getenv ("VERCEL_REGION"); - } else if (is_gcp) { - handshake->env = MONGOC_HANDSHAKE_ENV_GCP; - region_str = _mongoc_getenv ("FUNCTION_REGION"); - memory_str = _mongoc_getenv ("FUNCTION_MEMORY_MB"); - timeout_str = _mongoc_getenv ("FUNCTION_TIMEOUT_SEC"); - } else if (is_azure) { - handshake->env = MONGOC_HANDSHAKE_ENV_AZURE; - } - - if (memory_str) { - char *endptr; - int64_t env_memory_mb = bson_ascii_strtoll (memory_str, &endptr, 10); - bool parse_ok = endptr == memory_str + (strlen (memory_str)); - bool in_range = bson_in_range_int32_t_signed (env_memory_mb); - - if (parse_ok && in_range) { - handshake->env_memory_mb.set = true; - handshake->env_memory_mb.value = (int32_t) env_memory_mb; - } - } - if (timeout_str) { - char *endptr; - int64_t env_timeout_sec = bson_ascii_strtoll (timeout_str, &endptr, 10); - bool parse_ok = endptr == timeout_str + (strlen (timeout_str)); - bool in_range = bson_in_range_int32_t_signed (env_timeout_sec); - - if (parse_ok && in_range) { - handshake->env_timeout_sec.set = true; - handshake->env_timeout_sec.value = (int32_t) env_timeout_sec; - } - } - if (region_str && strlen (region_str)) { - handshake->env_region = bson_strdup (region_str); - } - -cleanup: - bson_free (aws_env); - bson_free (aws_lambda); - bson_free (vercel_env); - bson_free (azure_env); - bson_free (gcp_env); - bson_free (memory_str); - bson_free (timeout_str); - bson_free (region_str); -} - -static void -_set_compiler_info (mongoc_handshake_t *handshake) -{ - bson_string_t *str; - char *config_str; - - str = bson_string_new (""); - - config_str = _mongoc_handshake_get_config_hex_string (); - bson_string_append_printf (str, "cfg=%s", config_str); - bson_free (config_str); - -#ifdef _POSIX_VERSION - bson_string_append_printf (str, " posix=%ld", _POSIX_VERSION); -#endif - -#ifdef __STDC_VERSION__ - bson_string_append_printf (str, " stdc=%ld", __STDC_VERSION__); -#endif - - bson_string_append_printf (str, " CC=%s", MONGOC_COMPILER); - -#ifdef MONGOC_COMPILER_VERSION - bson_string_append_printf (str, " %s", MONGOC_COMPILER_VERSION); -#endif - handshake->compiler_info = bson_string_free (str, false); -} - -static void -_set_flags (mongoc_handshake_t *handshake) -{ - bson_string_t *str; - - str = bson_string_new (""); - - if (strlen (MONGOC_EVALUATE_STR (MONGOC_USER_SET_CFLAGS)) > 0) { - bson_string_append_printf ( - str, " CFLAGS=%s", MONGOC_EVALUATE_STR (MONGOC_USER_SET_CFLAGS)); - } - - if (strlen (MONGOC_EVALUATE_STR (MONGOC_USER_SET_LDFLAGS)) > 0) { - bson_string_append_printf ( - str, " LDFLAGS=%s", MONGOC_EVALUATE_STR (MONGOC_USER_SET_LDFLAGS)); - } - - handshake->flags = bson_string_free (str, false); -} - -static void -_free_platform_string (mongoc_handshake_t *handshake) -{ - bson_free (handshake->platform); - bson_free (handshake->compiler_info); - bson_free (handshake->flags); -} - -void -_mongoc_handshake_init (void) -{ - _get_system_info (_mongoc_handshake_get ()); - _get_driver_info (_mongoc_handshake_get ()); - _set_platform_string (_mongoc_handshake_get ()); - _get_env_info (_mongoc_handshake_get ()); - _set_compiler_info (_mongoc_handshake_get ()); - _set_flags (_mongoc_handshake_get ()); - - _mongoc_handshake_get ()->frozen = false; - bson_mutex_init (&gHandshakeLock); -} - -void -_mongoc_handshake_cleanup (void) -{ - mongoc_handshake_t *h = _mongoc_handshake_get (); - _free_system_info (h); - _free_driver_info (h); - _free_platform_string (h); - _free_env_info (h); - *h = (mongoc_handshake_t){0}; - - bson_mutex_destroy (&gHandshakeLock); -} - -static void -_append_platform_field (bson_t *doc, const char *platform, bool truncate) -{ - char *compiler_info = _mongoc_handshake_get ()->compiler_info; - char *flags = _mongoc_handshake_get ()->flags; - bson_string_t *combined_platform = bson_string_new (platform); - - /* Compute space left for platform field */ - const int max_platform_str_size = - HANDSHAKE_MAX_SIZE - ((int) doc->len + - /* 1 byte for utf8 tag */ - 1 + - - /* key size */ - (int) strlen (HANDSHAKE_PLATFORM_FIELD) + 1 + - - /* 4 bytes for length of string */ - 4); - - if (truncate && max_platform_str_size <= 0) { - bson_string_free (combined_platform, true); - return; - } - - /* We opt to drop compiler info and flags if they can't fit, while the - * platform information is truncated - * Try to drop flags first, and if there is still not enough space also - * drop compiler info */ - if (!truncate || bson_cmp_greater_equal_su ( - max_platform_str_size, - combined_platform->len + strlen (compiler_info) + 1u)) { - bson_string_append (combined_platform, compiler_info); - } - if (!truncate || bson_cmp_greater_equal_su (max_platform_str_size, - combined_platform->len + - strlen (flags) + 1u)) { - bson_string_append (combined_platform, flags); - } - - /* We use the flags_index field to check if the CLAGS/LDFLAGS need to be - * truncated, and if so we drop them altogether */ - BSON_ASSERT (bson_in_range_unsigned (int, combined_platform->len)); - int length = truncate ? BSON_MIN (max_platform_str_size - 1, - (int) combined_platform->len) - : -1; - bson_append_utf8 ( - doc, HANDSHAKE_PLATFORM_FIELD, -1, combined_platform->str, length); - - bson_string_free (combined_platform, true); -} - -static bool -_get_subdoc_static (bson_t *doc, char *subdoc_name, bson_t *out) -{ - bson_iter_t iter; - if (bson_iter_init_find (&iter, doc, subdoc_name) && - BSON_ITER_HOLDS_DOCUMENT (&iter)) { - uint32_t len; - const uint8_t *data; - bson_iter_document (&iter, &len, &data); - BSON_ASSERT (bson_init_static (out, data, len)); - - return true; - } - return false; -} - -static bool -_truncate_handshake (bson_t **doc) -{ - if ((*doc)->len > HANDSHAKE_MAX_SIZE) { - bson_t env_doc; - if (_get_subdoc_static (*doc, "env", &env_doc)) { - bson_t *new_env = bson_new (); - bson_copy_to_including_noinit (&env_doc, new_env, "name", NULL); - - bson_t *new_doc = bson_new (); - bson_copy_to_excluding_noinit (*doc, new_doc, "env", NULL); - - bson_append_document (new_doc, "env", -1, new_env); - bson_destroy (new_env); - bson_destroy (*doc); - *doc = new_doc; - } - } - - if ((*doc)->len > HANDSHAKE_MAX_SIZE) { - bson_t os_doc; - if (_get_subdoc_static (*doc, "os", &os_doc)) { - bson_t *new_os = bson_new (); - bson_copy_to_including_noinit (&os_doc, new_os, "type", NULL); - - bson_t *new_doc = bson_new (); - bson_copy_to_excluding_noinit (*doc, new_doc, "os", NULL); - - bson_append_document (new_doc, "os", -1, new_os); - bson_destroy (new_os); - bson_destroy (*doc); - *doc = new_doc; - } - } - - if ((*doc)->len > HANDSHAKE_MAX_SIZE) { - bson_t *new_doc = bson_new (); - bson_copy_to_excluding_noinit (*doc, new_doc, "env", NULL); - bson_destroy (*doc); - *doc = new_doc; - } - - const mongoc_handshake_t *md = _mongoc_handshake_get (); - if ((*doc)->len > HANDSHAKE_MAX_SIZE && md->platform) { - bson_t *new_doc = bson_new (); - bson_copy_to_excluding_noinit (*doc, new_doc, "platform", NULL); - _append_platform_field (new_doc, md->platform, true); - bson_destroy (*doc); - *doc = new_doc; - } - - return (*doc)->len <= HANDSHAKE_MAX_SIZE; -} - -/* - * Return true if we build the document, and it's not too big - * false if there's no way to prevent the doc from being too big. In this - * case, the caller shouldn't include it with hello - */ -bson_t * -_mongoc_handshake_build_doc_with_application (const char *appname) -{ - const mongoc_handshake_t *md = _mongoc_handshake_get (); - char *env_name = NULL; - switch (md->env) { - case MONGOC_HANDSHAKE_ENV_AWS: - env_name = "aws.lambda"; - break; - case MONGOC_HANDSHAKE_ENV_GCP: - env_name = "gcp.func"; - break; - case MONGOC_HANDSHAKE_ENV_AZURE: - env_name = "azure.func"; - break; - case MONGOC_HANDSHAKE_ENV_VERCEL: - env_name = "vercel"; - break; - case MONGOC_HANDSHAKE_ENV_NONE: - env_name = NULL; - break; - default: - break; - } - - bson_t *doc = bson_new (); - // Optimistically include all handshake data - bsonBuildAppend ( - *doc, - if (appname, - then (kv ("application", doc (kv ("name", cstr (appname)))))), - kv ("driver", - doc (kv ("name", cstr (md->driver_name)), - kv ("version", cstr (md->driver_version)))), - kv ( - "os", - doc (kv ("type", cstr (md->os_type)), - if (md->os_name, then (kv ("name", cstr (md->os_name)))), - if (md->os_version, then (kv ("version", cstr (md->os_version)))), - if (md->os_architecture, - then (kv ("architecture", cstr (md->os_architecture)))))), - if (env_name, - then (kv ( - "env", - doc (kv ("name", cstr (env_name)), - if (md->env_timeout_sec.set, - then (kv ("timeout_sec", - int32 (md->env_timeout_sec.value)))), - if (md->env_memory_mb.set, - then (kv ("memory_mb", int32 (md->env_memory_mb.value)))), - if (md->env_region, - then (kv ("region", cstr (md->env_region))))))))); - - if (md->platform) { - _append_platform_field (doc, md->platform, false); - } - - if (_truncate_handshake (&doc)) { - return doc; - } else { - bson_destroy (doc); - return NULL; - } -} - -void -_mongoc_handshake_freeze (void) -{ - _mongoc_handshake_get ()->frozen = true; -} - -/* - * free (*s) and make *s point to *s concated with suffix. - * If *s is NULL it's treated like it's an empty string. - */ -static void -_append_and_truncate (char **s, const char *suffix, size_t max_len) -{ - char *old_str = *s; - const size_t delim_len = strlen (" / "); - - BSON_ASSERT_PARAM (s); - BSON_ASSERT_PARAM (suffix); - - const char *const prefix = old_str ? old_str : ""; - - const size_t required_space = strlen (prefix) + delim_len; - - if (max_len <= required_space) { - /* the old string already takes the whole allotted space */ - return; - } - - const size_t space_for_suffix = max_len - required_space; - BSON_ASSERT (bson_in_range_unsigned (int, space_for_suffix)); - - *s = - bson_strdup_printf ("%s / %.*s", prefix, (int) space_for_suffix, suffix); - BSON_ASSERT (strlen (*s) <= max_len); - - bson_free (old_str); -} - - -/* - * Set some values in our global handshake struct. These values will be sent - * to the server as part of the initial connection handshake (hello). - * If this function is called more than once, or after we've connected to a - * mongod, then it will do nothing and return false. It will return true if - * it successfully sets the values. - * - * All arguments are optional. - */ -bool -mongoc_handshake_data_append (const char *driver_name, - const char *driver_version, - const char *platform) -{ - int platform_space; - - bson_mutex_lock (&gHandshakeLock); - - if (_mongoc_handshake_get ()->frozen) { - bson_mutex_unlock (&gHandshakeLock); - return false; - } - - BSON_ASSERT (_mongoc_handshake_get ()->platform); - - /* allow practically any size for "platform", we'll trim it down in - * _mongoc_handshake_build_doc_with_application */ - platform_space = - HANDSHAKE_MAX_SIZE - (int) strlen (_mongoc_handshake_get ()->platform); - - if (platform) { - /* we check for an empty string as a special case to avoid an - * unnecessary delimiter being added in front of the string by - * _append_and_truncate */ - if (_mongoc_handshake_get ()->platform[0] == '\0') { - bson_free (_mongoc_handshake_get ()->platform); - _mongoc_handshake_get ()->platform = - bson_strdup_printf ("%.*s", platform_space, platform); - } else { - _append_and_truncate ( - &_mongoc_handshake_get ()->platform, platform, HANDSHAKE_MAX_SIZE); - } - } - - if (driver_name) { - _append_and_truncate (&_mongoc_handshake_get ()->driver_name, - driver_name, - HANDSHAKE_DRIVER_NAME_MAX); - } - - if (driver_version) { - _append_and_truncate (&_mongoc_handshake_get ()->driver_version, - driver_version, - HANDSHAKE_DRIVER_VERSION_MAX); - } - - _mongoc_handshake_freeze (); - bson_mutex_unlock (&gHandshakeLock); - - return true; -} - -mongoc_handshake_t * -_mongoc_handshake_get (void) -{ - return &gMongocHandshake; -} - -bool -_mongoc_handshake_appname_is_valid (const char *appname) -{ - return strlen (appname) <= MONGOC_HANDSHAKE_APPNAME_MAX; -} - -void -_mongoc_handshake_append_sasl_supported_mechs (const mongoc_uri_t *uri, - bson_t *cmd) -{ - const char *username; - char *db_user; - username = mongoc_uri_get_username (uri); - db_user = - bson_strdup_printf ("%s.%s", mongoc_uri_get_auth_source (uri), username); - bson_append_utf8 (cmd, "saslSupportedMechs", 18, db_user, -1); - bson_free (db_user); -} - -void -_mongoc_handshake_parse_sasl_supported_mechs ( - const bson_t *hello, - mongoc_handshake_sasl_supported_mechs_t *sasl_supported_mechs) -{ - memset (sasl_supported_mechs, 0, sizeof (*sasl_supported_mechs)); - bsonParse (*hello, - find (keyWithType ("saslSupportedMechs", array), - visitEach (case ( - when (strEqual ("SCRAM-SHA-256"), - do (sasl_supported_mechs->scram_sha_256 = true)), - when (strEqual ("SCRAM-SHA-1"), - do (sasl_supported_mechs->scram_sha_1 = true)))))); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-handshake.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-handshake.h deleted file mode 100644 index a1ff2f8ea..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-handshake.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2016-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - - -#ifndef MONGOC_HANDSHAKE_H -#define MONGOC_HANDSHAKE_H - -#include - -#include "mongoc-macros.h" - -BSON_BEGIN_DECLS - -#define MONGOC_HANDSHAKE_APPNAME_MAX 128 - -MONGOC_EXPORT (bool) -mongoc_handshake_data_append (const char *driver_name, - const char *driver_version, - const char *platform); - -BSON_END_DECLS - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-host-list-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-host-list-private.h deleted file mode 100644 index 14d47c8ab..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-host-list-private.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_HOST_LIST_PRIVATE_H -#define MONGOC_HOST_LIST_PRIVATE_H - -#include "mongoc-host-list.h" - - -BSON_BEGIN_DECLS - -mongoc_host_list_t * -_mongoc_host_list_push (const char *host, - uint16_t port, - int family, - mongoc_host_list_t *next); - -void -_mongoc_host_list_upsert (mongoc_host_list_t **list, - const mongoc_host_list_t *new_host); - -mongoc_host_list_t * -_mongoc_host_list_copy_all (const mongoc_host_list_t *src); - -bool -_mongoc_host_list_from_string (mongoc_host_list_t *host_list, - const char *host_and_port); - -bool -_mongoc_host_list_from_string_with_err (mongoc_host_list_t *host_list, - const char *host_and_port, - bson_error_t *error); - -bool -_mongoc_host_list_from_hostport_with_err (mongoc_host_list_t *host_list, - const char *host, - uint16_t port, - bson_error_t *error); - -size_t -_mongoc_host_list_length (const mongoc_host_list_t *list); - -bool -_mongoc_host_list_compare_one (const mongoc_host_list_t *host_a, - const mongoc_host_list_t *host_b); - -void -_mongoc_host_list_remove_host (mongoc_host_list_t **phosts, - const char *host, - uint16_t port); - -void -_mongoc_host_list_destroy_all (mongoc_host_list_t *host); - -bool -_mongoc_host_list_contains_one (mongoc_host_list_t *host_list, - mongoc_host_list_t *host); - -BSON_END_DECLS - - -#endif /* MONGOC_HOST_LIST_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-host-list.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-host-list.c deleted file mode 100644 index 3adbb952a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-host-list.c +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Copyright 2015 MongoDB Inc. - * Licensed under the Apache License, Version 2.0 (the "License"); - * - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include // PRIu16 - -#include "mongoc-host-list-private.h" -/* strcasecmp on windows */ -#include "mongoc-util-private.h" -#include "utlist.h" - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_host_list_push -- - * - * Add a host to the front of the list and return it. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -mongoc_host_list_t * -_mongoc_host_list_push (const char *host, - uint16_t port, - int family, - mongoc_host_list_t *next) -{ - mongoc_host_list_t *h; - - BSON_ASSERT (host); - - h = bson_malloc0 (sizeof (mongoc_host_list_t)); - bson_strncpy (h->host, host, sizeof h->host); - h->port = port; - bson_snprintf ( - h->host_and_port, sizeof h->host_and_port, "%s:%hu", host, port); - - h->family = family; - h->next = next; - - return h; -} - -static mongoc_host_list_t * -_mongoc_host_list_find_host_and_port (mongoc_host_list_t *hosts, - const char *host_and_port) -{ - mongoc_host_list_t *iter; - LL_FOREACH (hosts, iter) - { - BSON_ASSERT (iter); - - if (strcasecmp (iter->host_and_port, host_and_port) == 0) { - return iter; - } - } - - return NULL; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_host_list_upsert -- - * - * If new_host is not already in list, copy and add it to the end of list. - * If *list == NULL, then it will be set to a new host. - * - * Returns: - * Nothing. - * - *-------------------------------------------------------------------------- - */ -void -_mongoc_host_list_upsert (mongoc_host_list_t **list, - const mongoc_host_list_t *new_host) -{ - mongoc_host_list_t *link = NULL; - mongoc_host_list_t *next_link = NULL; - - BSON_ASSERT (list); - if (!new_host) { - return; - } - - link = _mongoc_host_list_find_host_and_port (*list, new_host->host_and_port); - - if (!link) { - link = bson_malloc0 (sizeof (mongoc_host_list_t)); - LL_APPEND (*list, link); - } else { - /* Make sure linking is preserved when copying data into final. */ - next_link = link->next; - } - - memcpy (link, new_host, sizeof (mongoc_host_list_t)); - link->next = next_link; -} - - -/* Duplicates a host list. - */ -mongoc_host_list_t * -_mongoc_host_list_copy_all (const mongoc_host_list_t *src) -{ - mongoc_host_list_t *tail = NULL; - const mongoc_host_list_t *src_iter; - mongoc_host_list_t *head = NULL; - - LL_FOREACH (src, src_iter) - { - tail = bson_malloc0 (sizeof (mongoc_host_list_t)); - memcpy (tail, src_iter, sizeof (mongoc_host_list_t)); - - LL_PREPEND (head, tail); - } - - return head; -} - -size_t -_mongoc_host_list_length (const mongoc_host_list_t *list) -{ - const mongoc_host_list_t *tmp; - size_t counter = 0u; - - tmp = list; - while (tmp) { - tmp = tmp->next; - counter++; - } - - return counter; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_host_list_compare_one -- - * - * Check two hosts have the same domain (case-insensitive), port, - * and address family. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_host_list_compare_one (const mongoc_host_list_t *host_a, - const mongoc_host_list_t *host_b) -{ - return (0 == strcasecmp (host_a->host_and_port, host_b->host_and_port) && - host_a->family == host_b->family); -} - -bool -_mongoc_host_list_contains_one (mongoc_host_list_t *host_list, - mongoc_host_list_t *host) -{ - return NULL != - _mongoc_host_list_find_host_and_port (host_list, host->host_and_port); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_host_list_destroy_all -- - * - * Destroy whole linked list of hosts. - * - *-------------------------------------------------------------------------- - */ -void -_mongoc_host_list_destroy_all (mongoc_host_list_t *host) -{ - mongoc_host_list_t *tmp; - - while (host) { - tmp = host->next; - bson_free (host); - host = tmp; - } -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_host_list_from_string -- - * - * Populate a mongoc_host_list_t from a fully qualified address - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_host_list_from_string (mongoc_host_list_t *link_, const char *address) -{ - bson_error_t error = {0}; - bool r = _mongoc_host_list_from_string_with_err (link_, address, &error); - if (!r) { - MONGOC_ERROR ("Could not parse address %s: %s", address, error.message); - return false; - } - return true; -} - -bool -_mongoc_host_list_from_string_with_err (mongoc_host_list_t *link_, - const char *address, - bson_error_t *error) -{ - char *close_bracket; - char *sport; - uint16_t port; - char *host; - bool ret; - bool ipv6 = false; - - close_bracket = strchr (address, ']'); - - /* if this is an ipv6 address. */ - if (close_bracket) { - /* if present, the port should immediately follow after ] */ - sport = strchr (close_bracket, ':'); - if (sport > close_bracket + 1) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "If present, port should immediately follow the \"]\"" - "in an IPv6 address"); - return false; - } - - /* otherwise ] should be the last char. */ - if (!sport && *(close_bracket + 1) != '\0') { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "If port is not supplied, \"[\" should be the last" - "character"); - return false; - } - - if (*address != '[') { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Missing matching bracket \"[\""); - return false; - } - - ipv6 = true; - } - /* otherwise, just find the first : */ - else { - sport = strchr (address, ':'); - } - - /* like "example.com:27019" or "[fe80::1]:27019", but not "[fe80::1]" */ - if (sport) { - if (sport == address) { - /* bad address like ":27017" */ - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Bad address, \":\" should not be first character"); - return false; - } - - if (!mongoc_parse_port (&port, sport + 1)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Port could not be parsed"); - return false; - } - - /* if this is an ipv6 address, strip the [ and ] */ - if (ipv6) { - host = bson_strndup (address + 1, close_bracket - address - 1); - } else { - host = bson_strndup (address, sport - address); - } - } else { - /* if this is an ipv6 address, strip the [ and ] */ - if (ipv6) { - host = bson_strndup (address + 1, close_bracket - address - 1); - } else { - host = bson_strdup (address); - } - port = MONGOC_DEFAULT_PORT; - } - - ret = _mongoc_host_list_from_hostport_with_err (link_, host, port, error); - - bson_free (host); - - return ret; -} - -bool -_mongoc_host_list_from_hostport_with_err (mongoc_host_list_t *link_, - const char *host, - uint16_t port, - bson_error_t *error) -{ - size_t host_len = strlen (host); - link_->port = port; - - if (host_len == 0) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "Empty hostname in URI"); - return false; - } - - if (host_len > BSON_HOST_NAME_MAX) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "Hostname provided in URI is too long, max is %d chars", - BSON_HOST_NAME_MAX); - return false; - } - - bson_strncpy (link_->host, host, host_len + 1); - - /* like "fe80::1" or "::1" */ - if (strchr (host, ':')) { - link_->family = AF_INET6; - - // Check that IPv6 literal is two less than the max to account for `[` and - // `]` added below. - if (host_len > BSON_HOST_NAME_MAX - 2) { - bson_set_error ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "IPv6 literal provided in URI is too long, max is %d chars", - BSON_HOST_NAME_MAX - 2); - return false; - } - - mongoc_lowercase (link_->host, link_->host); - int req = bson_snprintf (link_->host_and_port, - sizeof link_->host_and_port, - "[%s]:%" PRIu16, - link_->host, - link_->port); - BSON_ASSERT (bson_in_range_size_t_signed (req)); - // Use `<`, not `<=` to account for NULL byte. - BSON_ASSERT ((size_t) req < sizeof link_->host_and_port); - } else if (strchr (host, '/') && strstr (host, ".sock")) { - link_->family = AF_UNIX; - bson_strncpy (link_->host_and_port, link_->host, host_len + 1); - } else { - /* This is either an IPv4 or hostname. */ - link_->family = AF_UNSPEC; - - mongoc_lowercase (link_->host, link_->host); - int req = bson_snprintf (link_->host_and_port, - sizeof link_->host_and_port, - "%s:%" PRIu16, - link_->host, - link_->port); - BSON_ASSERT (bson_in_range_size_t_signed (req)); - // Use `<`, not `<=` to account for NULL byte. - BSON_ASSERT ((size_t) req < sizeof link_->host_and_port); - } - - link_->next = NULL; - return true; -} - -void -_mongoc_host_list_remove_host (mongoc_host_list_t **hosts, - const char *host, - uint16_t port) -{ - mongoc_host_list_t *current; - mongoc_host_list_t *prev = NULL; - - for (current = *hosts; current; prev = current, current = current->next) { - if ((current->port == port) && (strcmp (current->host, host) == 0)) { - /* Node found, unlink. */ - if (prev) { - prev->next = current->next; - } else { - /* No previous, unlinking at head. */ - *hosts = current->next; - } - bson_free (current); - break; - } - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-http.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-http.c deleted file mode 100644 index eba1754c2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-http.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-http-private.h" - -#include "mongoc-client-private.h" -#include "mongoc-host-list-private.h" -#include "mongoc-stream-tls.h" -#include "mongoc-stream-private.h" -#include "mongoc-buffer-private.h" -#include "mcd-time.h" - -void -_mongoc_http_request_init (mongoc_http_request_t *request) -{ - memset (request, 0, sizeof (*request)); -} - -void -_mongoc_http_response_init (mongoc_http_response_t *response) -{ - memset (response, 0, sizeof (*response)); -} - -void -_mongoc_http_response_cleanup (mongoc_http_response_t *response) -{ - if (!response) { - return; - } - bson_free (response->headers); - bson_free (response->body); -} - -bson_string_t * -_mongoc_http_render_request_head (const mongoc_http_request_t *req) -{ - BSON_ASSERT_PARAM (req); - char *path = NULL; - - // Default paths - if (!req->path) { - // Top path: - path = bson_strdup ("/"); - } else if (req->path[0] != '/') { - // Path MUST be prefixed with a separator - path = bson_strdup_printf ("/%s", req->path); - } else { - // Just copy the path - path = bson_strdup (req->path); - } - - bson_string_t *const string = bson_string_new (""); - // Set the request line - bson_string_append_printf (string, "%s %s HTTP/1.0\r\n", req->method, path); - // (We're done with the path string:) - bson_free (path); - - /* Always add Host header. */ - bson_string_append_printf (string, "Host: %s:%d\r\n", req->host, req->port); - /* Always add Connection: close header to ensure server closes connection. */ - bson_string_append_printf (string, "Connection: close\r\n"); - /* Add Content-Length if body is included. */ - if (req->body_len) { - bson_string_append_printf ( - string, "Content-Length: %d\r\n", req->body_len); - } - // Add any extra headers - if (req->extra_headers) { - bson_string_append (string, req->extra_headers); - } - - // Final terminator - bson_string_append (string, "\r\n"); - return string; -} - -static int32_t -_mongoc_http_msec_remaining (mcd_timer timer) -{ - const int64_t msec = mcd_get_milliseconds (mcd_timer_remaining (timer)); - BSON_ASSERT (bson_in_range_signed (int32_t, msec)); - return (int32_t) msec; -} - -bool -_mongoc_http_send (const mongoc_http_request_t *req, - int timeout_ms, - bool use_tls, - mongoc_ssl_opt_t *ssl_opts, - mongoc_http_response_t *res, - bson_error_t *error) -{ - mongoc_stream_t *stream = NULL; - mongoc_host_list_t host_list; - bool ret = false; - mongoc_iovec_t iovec; - char *path = NULL; - bson_string_t *http_request = NULL; - mongoc_buffer_t http_response_buf; - char *http_response_str; - char *ptr; - const char *header_delimiter = "\r\n\r\n"; - - const mcd_timer timer = - mcd_timer_expire_after (mcd_milliseconds (timeout_ms)); - - memset (res, 0, sizeof (*res)); - _mongoc_buffer_init (&http_response_buf, NULL, 0, NULL, NULL); - - if (!_mongoc_host_list_from_hostport_with_err ( - &host_list, req->host, (uint16_t) req->port, error)) { - goto fail; - } - - stream = mongoc_client_connect_tcp ( - // +1 to prevent passing zero as a timeout - _mongoc_http_msec_remaining (timer) + 1, - &host_list, - error); - if (!stream) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to connect to: %s", - req->host); - goto fail; - } - -#ifndef MONGOC_ENABLE_SSL - if (use_tls) { - bson_set_error ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to connect to %s: libmongoc not built with TLS support", - req->host); - goto fail; - } -#else - if (use_tls) { - mongoc_stream_t *tls_stream; - - BSON_ASSERT (ssl_opts); - tls_stream = mongoc_stream_tls_new_with_hostname ( - stream, req->host, ssl_opts, true); - if (!tls_stream) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed create TLS stream to: %s", - req->host); - goto fail; - } - - stream = tls_stream; - if (!mongoc_stream_tls_handshake_block ( - stream, req->host, _mongoc_http_msec_remaining (timer), error)) { - goto fail; - } - } -#endif - - if (!req->path) { - path = bson_strdup ("/"); - } else if (req->path[0] != '/') { - path = bson_strdup_printf ("/%s", req->path); - } else { - path = bson_strdup (req->path); - } - - http_request = _mongoc_http_render_request_head (req); - iovec.iov_base = http_request->str; - iovec.iov_len = http_request->len; - - if (!_mongoc_stream_writev_full ( - stream, &iovec, 1, _mongoc_http_msec_remaining (timer), error)) { - goto fail; - } - - if (req->body && req->body_len) { - iovec.iov_base = (void *) req->body; - iovec.iov_len = req->body_len; - if (!_mongoc_stream_writev_full ( - stream, &iovec, 1, _mongoc_http_msec_remaining (timer), error)) { - goto fail; - } - } - - /* Read until connection close. */ - while (1) { - const ssize_t bytes_read = _mongoc_buffer_try_append_from_stream ( - &http_response_buf, - stream, - 1024 * 32, - _mongoc_http_msec_remaining (timer)); - if (mongoc_stream_should_retry (stream)) { - continue; - } - if (bytes_read <= 0) { - break; - } - if (http_response_buf.len > 1024 * 1024 * 8) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "HTTP response message is too large"); - goto fail; - } - } - - if (mongoc_stream_timed_out (stream)) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Timeout reading from stream"); - goto fail; - } - - if (http_response_buf.len == 0) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "No response received"); - goto fail; - } - - http_response_str = (char *) http_response_buf.data; - const char *const resp_end_ptr = http_response_str + http_response_buf.len; - - - const char *proto_leader_10 = "HTTP/1.0 "; - const char *proto_leader_11 = "HTTP/1.1 "; - ptr = strstr (http_response_str, proto_leader_10); - if (!ptr) { - ptr = strstr (http_response_str, proto_leader_11); - } - - if (!ptr) { - bson_set_error ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "No HTTP version leader in HTTP response. Expected '%s' or '%s'", - proto_leader_10, - proto_leader_11); - goto fail; - } - - /* Both protocol leaders have the same length. */ - ptr += strlen (proto_leader_10); - ssize_t remain = resp_end_ptr - ptr; - if (remain < 4) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Short read in HTTP response"); - goto fail; - } - - char status_buf[4] = {0}; - memcpy (status_buf, ptr, 3); - char *status_endptr; - res->status = strtol (status_buf, &status_endptr, 10); - if (status_endptr != status_buf + 3) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Invalid HTTP response status string %*.s", - 4, - status_buf); - goto fail; - } - - /* Find the end of the headers. */ - ptr = strstr (http_response_str, header_delimiter); - if (NULL == ptr) { - bson_set_error ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Error occurred reading response: end of headers not found"); - goto fail; - } - - const size_t headers_len = (size_t) (ptr - http_response_str); - BSON_ASSERT (bson_in_range_unsigned (int, headers_len)); - - const size_t body_len = - http_response_buf.len - headers_len - strlen (header_delimiter); - BSON_ASSERT (bson_in_range_unsigned (int, body_len)); - - res->headers_len = (int) headers_len; - res->headers = bson_strndup (http_response_str, (size_t) headers_len); - res->body_len = (int) body_len; - /* Add a NULL character in case caller assumes NULL terminated. */ - res->body = bson_malloc0 (body_len + 1u); - memcpy (res->body, ptr + strlen (header_delimiter), body_len); - ret = true; - -fail: - mongoc_stream_destroy (stream); - if (http_request) { - bson_string_free (http_request, true); - } - _mongoc_buffer_destroy (&http_response_buf); - bson_free (path); - return ret; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-index.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-index.c deleted file mode 100644 index ca5f5363b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-index.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2013 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-index.h" -#include "mongoc-trace-private.h" - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "gridfs_index" - - -static mongoc_index_opt_t gMongocIndexOptDefault = { - 1, /* is_initialized */ - 0, /* background */ - 0, /* unique */ - NULL, /* name */ - 0, /* drop_dups */ - 0, /* sparse */ - -1, /* expire_after_seconds */ - -1, /* v */ - NULL, /* weights */ - NULL, /* default_language */ - NULL, /* language_override */ - NULL, /* mongoc_index_opt_geo_t geo_options */ - NULL, /* mongoc_index_opt_storage_t storage_options */ - NULL, /* partial_filter_expression */ - NULL, /* collation */ - {NULL} /* struct padding */ -}; - -static mongoc_index_opt_geo_t gMongocIndexOptGeoDefault = { - 26, /* twod_sphere_version */ - -90, /* twod_bits_precision */ - 90, /* twod_location_min */ - -1, /* twod_location_max */ - 2, /* haystack_bucket_size */ - {NULL} /* struct padding */ -}; - -static mongoc_index_opt_wt_t gMongocIndexOptWTDefault = { - {MONGOC_INDEX_STORAGE_OPT_WIREDTIGER}, /* mongoc_index_opt_storage_t */ - "", /* config_str */ - {NULL} /* struct padding */ -}; - -const mongoc_index_opt_t * -mongoc_index_opt_get_default (void) -{ - return &gMongocIndexOptDefault; -} - -const mongoc_index_opt_geo_t * -mongoc_index_opt_geo_get_default (void) -{ - return &gMongocIndexOptGeoDefault; -} - -const mongoc_index_opt_wt_t * -mongoc_index_opt_wt_get_default (void) -{ - return &gMongocIndexOptWTDefault; -} - -void -mongoc_index_opt_init (mongoc_index_opt_t *opt) -{ - BSON_ASSERT (opt); - - memcpy (opt, &gMongocIndexOptDefault, sizeof *opt); -} - -void -mongoc_index_opt_geo_init (mongoc_index_opt_geo_t *opt) -{ - BSON_ASSERT (opt); - - memcpy (opt, &gMongocIndexOptGeoDefault, sizeof *opt); -} - -void -mongoc_index_opt_wt_init (mongoc_index_opt_wt_t *opt) -{ - BSON_ASSERT (opt); - - memcpy (opt, &gMongocIndexOptWTDefault, sizeof *opt); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-index.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-index.h deleted file mode 100644 index a8a49c960..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-index.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2013 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_INDEX_H -#define MONGOC_INDEX_H - -#include - -#include "mongoc-macros.h" - - -BSON_BEGIN_DECLS - -typedef struct { - uint8_t twod_sphere_version; - uint8_t twod_bits_precision; - double twod_location_min; - double twod_location_max; - double haystack_bucket_size; - uint8_t *padding[32]; -} mongoc_index_opt_geo_t; - -typedef struct { - int type; -} mongoc_index_opt_storage_t; - -typedef enum { - MONGOC_INDEX_STORAGE_OPT_MMAPV1, - MONGOC_INDEX_STORAGE_OPT_WIREDTIGER, -} mongoc_index_storage_opt_type_t; - -typedef struct { - mongoc_index_opt_storage_t base; - const char *config_str; - void *padding[8]; -} mongoc_index_opt_wt_t; - -typedef struct { - bool is_initialized; - bool background; - bool unique; - const char *name; - bool drop_dups; - bool sparse; - int32_t expire_after_seconds; - int32_t v; - const bson_t *weights; - const char *default_language; - const char *language_override; - mongoc_index_opt_geo_t *geo_options; - mongoc_index_opt_storage_t *storage_options; - const bson_t *partial_filter_expression; - const bson_t *collation; - void *padding[4]; -} mongoc_index_opt_t; - - -MONGOC_EXPORT (const mongoc_index_opt_t *) -mongoc_index_opt_get_default (void) BSON_GNUC_PURE; -MONGOC_EXPORT (const mongoc_index_opt_geo_t *) -mongoc_index_opt_geo_get_default (void) BSON_GNUC_PURE; -MONGOC_EXPORT (const mongoc_index_opt_wt_t *) -mongoc_index_opt_wt_get_default (void) BSON_GNUC_PURE; -MONGOC_EXPORT (void) -mongoc_index_opt_init (mongoc_index_opt_t *opt); -MONGOC_EXPORT (void) -mongoc_index_opt_geo_init (mongoc_index_opt_geo_t *opt); -MONGOC_EXPORT (void) -mongoc_index_opt_wt_init (mongoc_index_opt_wt_t *opt); - -BSON_END_DECLS - - -#endif /* MONGOC_INDEX_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-init.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-init.c deleted file mode 100644 index 28356b44f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-init.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "mongoc-config.h" -#include "mongoc-counters-private.h" -#include "mongoc-init.h" - -#include "mongoc-handshake-private.h" - -#include "mongoc-cluster-aws-private.h" - -#ifdef MONGOC_ENABLE_SSL_OPENSSL -#include "mongoc-openssl-private.h" -#elif defined(MONGOC_ENABLE_SSL_LIBRESSL) -#include "tls.h" -#endif -#include "mongoc-thread-private.h" -#include "common-b64-private.h" -#if defined(MONGOC_ENABLE_CRYPTO_CNG) -#include "mongoc-crypto-private.h" -#include "mongoc-crypto-cng-private.h" -#endif - -#ifdef MONGOC_ENABLE_MONGODB_AWS_AUTH -#include "kms_message/kms_message.h" -#endif - -#ifdef MONGOC_ENABLE_OCSP_OPENSSL -#include "mongoc-ocsp-cache-private.h" -#endif - -#ifndef MONGOC_NO_AUTOMATIC_GLOBALS -#pragma message( \ - "Configure the driver with ENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF.\ - Automatic cleanup is deprecated and will be removed in version 2.0.") -#endif - -#ifdef MONGOC_ENABLE_SASL_CYRUS -#include -#include // _mongoc_cyrus_verifyfile_cb - -static void * -mongoc_cyrus_mutex_alloc (void) -{ - bson_mutex_t *mutex; - - mutex = (bson_mutex_t *) bson_malloc0 (sizeof (bson_mutex_t)); - bson_mutex_init (mutex); - - return (void *) mutex; -} - - -static int -mongoc_cyrus_mutex_lock (void *mutex) -{ - bson_mutex_lock ((bson_mutex_t *) mutex); - - return SASL_OK; -} - - -static int -mongoc_cyrus_mutex_unlock (void *mutex) -{ - bson_mutex_unlock ((bson_mutex_t *) mutex); - - return SASL_OK; -} - - -static void -mongoc_cyrus_mutex_free (void *mutex) -{ - bson_mutex_destroy ((bson_mutex_t *) mutex); - bson_free (mutex); -} - -#endif /* MONGOC_ENABLE_SASL_CYRUS */ - - -static BSON_ONCE_FUN (_mongoc_do_init) -{ -#ifdef MONGOC_ENABLE_SASL_CYRUS - int status; -#endif -#ifdef MONGOC_ENABLE_SSL_OPENSSL - _mongoc_openssl_init (); -#elif defined(MONGOC_ENABLE_SSL_LIBRESSL) - tls_init (); -#endif - -#ifdef MONGOC_ENABLE_SASL_CYRUS - /* The following functions should not use tracing, as they may be invoked - * before mongoc_log_set_handler() can complete. */ - sasl_set_mutex (mongoc_cyrus_mutex_alloc, - mongoc_cyrus_mutex_lock, - mongoc_cyrus_mutex_unlock, - mongoc_cyrus_mutex_free); - - sasl_callback_t callbacks[] = {// Include callback to disable loading plugins. - {SASL_CB_VERIFYFILE, SASL_CALLBACK_FN (_mongoc_cyrus_verifyfile_cb), NULL}, - {SASL_CB_LIST_END}}; - - status = sasl_client_init (callbacks); - BSON_ASSERT (status == SASL_OK); -#endif - - _mongoc_counters_init (); - -#ifdef _WIN32 - { - WORD wVersionRequested; - WSADATA wsaData; - int err; - - wVersionRequested = MAKEWORD (2, 2); - - err = WSAStartup (wVersionRequested, &wsaData); - - /* check the version perhaps? */ - - BSON_ASSERT (err == 0); - } -#endif - -#if defined(MONGOC_ENABLE_CRYPTO_CNG) - mongoc_crypto_cng_init (); -#endif - - _mongoc_handshake_init (); - -#if defined(MONGOC_ENABLE_MONGODB_AWS_AUTH) - kms_message_init (); - _mongoc_aws_credentials_cache_init (); -#endif - -#if defined(MONGOC_ENABLE_OCSP_OPENSSL) - _mongoc_ocsp_cache_init (); -#endif - - BSON_ONCE_RETURN; -} - -void -mongoc_init (void) -{ - static bson_once_t once = BSON_ONCE_INIT; - bson_once (&once, _mongoc_do_init); -} - -static BSON_ONCE_FUN (_mongoc_do_cleanup) -{ -#ifdef MONGOC_ENABLE_SSL_OPENSSL - _mongoc_openssl_cleanup (); -#endif - -#ifdef MONGOC_ENABLE_SASL_CYRUS -#ifdef MONGOC_HAVE_SASL_CLIENT_DONE - sasl_client_done (); -#else - /* fall back to deprecated function */ - sasl_done (); -#endif -#endif - -#ifdef _WIN32 - WSACleanup (); -#endif - -#if defined(MONGOC_ENABLE_CRYPTO_CNG) - mongoc_crypto_cng_cleanup (); -#endif - - _mongoc_counters_cleanup (); - - _mongoc_handshake_cleanup (); - -#if defined(MONGOC_ENABLE_MONGODB_AWS_AUTH) - kms_message_cleanup (); - _mongoc_aws_credentials_cache_cleanup (); -#endif - -#if defined(MONGOC_ENABLE_OCSP_OPENSSL) - _mongoc_ocsp_cache_cleanup (); -#endif - - BSON_ONCE_RETURN; -} - -void -mongoc_cleanup (void) -{ - static bson_once_t once = BSON_ONCE_INIT; - bson_once (&once, _mongoc_do_cleanup); -} - -/* - * On GCC, just use __attribute__((constructor)) to perform initialization - * automatically for the application. - */ -#if defined(__GNUC__) && !defined(MONGOC_NO_AUTOMATIC_GLOBALS) -static void -_mongoc_init_ctor (void) __attribute__ ((constructor)); -static void -_mongoc_init_ctor (void) -{ - mongoc_init (); -} - -static void -_mongoc_init_dtor (void) __attribute__ ((destructor)); -static void -_mongoc_init_dtor (void) -{ - bson_mem_restore_vtable (); - mongoc_cleanup (); -} -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-iovec.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-iovec.h deleted file mode 100644 index f18f41126..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-iovec.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - - -#ifndef MONGOC_IOVEC_H -#define MONGOC_IOVEC_H - - -#include - -#ifdef _WIN32 -#include -#else -#include -#endif - -BSON_BEGIN_DECLS - - -#ifdef _WIN32 -typedef struct { - size_t iov_len; - char *iov_base; -} mongoc_iovec_t; - -BSON_STATIC_ASSERT2 (sizeof_iovect_t, - sizeof (mongoc_iovec_t) == sizeof (WSABUF)); -BSON_STATIC_ASSERT2 (offsetof_iovec_base, - offsetof (mongoc_iovec_t, iov_base) == - offsetof (WSABUF, buf)); -BSON_STATIC_ASSERT2 (offsetof_iovec_len, - offsetof (mongoc_iovec_t, iov_len) == - offsetof (WSABUF, len)); - -#else -typedef struct iovec mongoc_iovec_t; -#endif - - -BSON_END_DECLS - - -#endif /* MONGOC_IOVEC_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-libressl-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-libressl-private.h deleted file mode 100644 index b40d550ea..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-libressl-private.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_LIBRESSL_PRIVATE_H -#define MONGOC_LIBRESSL_PRIVATE_H - -#include - -#include "mongoc-ssl.h" -#include "mongoc-stream-tls-libressl-private.h" -#include - - -BSON_BEGIN_DECLS - - -bool -mongoc_libressl_setup_ca (mongoc_stream_tls_libressl_t *libressl, - mongoc_ssl_opt_t *opt); -bool -mongoc_libressl_setup_certificate (mongoc_stream_tls_libressl_t *libressl, - mongoc_ssl_opt_t *opt); - -BSON_END_DECLS - - -#endif /* MONGOC_LIBRESSL_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-libressl.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-libressl.c deleted file mode 100644 index 9c92337dc..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-libressl.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SSL_LIBRESSL - -#include - -#include "mongoc-log.h" -#include "mongoc-trace-private.h" -#include "mongoc-ssl.h" -#include "mongoc-stream-tls.h" -#include "mongoc-stream-tls-private.h" -#include "mongoc-libressl-private.h" -#include "mongoc-stream-tls-libressl-private.h" - -#include - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "stream-libressl" - - -bool -mongoc_libressl_setup_certificate (mongoc_stream_tls_libressl_t *libressl, - mongoc_ssl_opt_t *opt) -{ - uint8_t *file; - size_t file_len; - - if (!opt->pem_file) { - return false; - } - - file = tls_load_file (opt->pem_file, &file_len, (char *) opt->pem_pwd); - if (!file) { - MONGOC_ERROR ("Cannot load private key: '%s'", opt->pem_file); - return false; - } - - if (tls_config_set_keypair_mem ( - libressl->config, file, file_len, file, file_len) == -1) { - MONGOC_ERROR ("%s", tls_config_error (libressl->config)); - return false; - } - - return true; -} - -bool -mongoc_libressl_setup_ca (mongoc_stream_tls_libressl_t *libressl, - mongoc_ssl_opt_t *opt) -{ - if (opt->ca_file) { - tls_config_set_ca_file (libressl->config, opt->ca_file); - } - if (opt->ca_dir) { - tls_config_set_ca_path (libressl->config, opt->ca_dir); - } - - - return true; -} - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-log-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-log-private.h deleted file mode 100644 index 150844820..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-log-private.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_LOG_PRIVATE_H -#define MONGOC_LOG_PRIVATE_H - -#include "mongoc-iovec.h" - -/* just for testing */ -void -_mongoc_log_get_handler (mongoc_log_func_t *log_func, void **user_data); - -bool -_mongoc_log_trace_is_enabled (void); - -void -mongoc_log_trace_bytes (const char *domain, const uint8_t *_b, size_t _l); - -void -mongoc_log_trace_iovec (const char *domain, - const mongoc_iovec_t *_iov, - size_t _iovcnt); - -#endif /* MONGOC_LOG_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-log.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-log.c deleted file mode 100644 index 49839a3b1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-log.c +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#if defined(__linux__) -#include -#elif defined(_WIN32) -#include -#elif defined(__APPLE__) -#include -#elif defined(__FreeBSD__) -#include -#elif defined(__NetBSD__) -#include -#else -#include -#endif -#include -#include - -#include "mongoc-log.h" -#include "mongoc-log-private.h" -#include "mongoc-thread-private.h" - - -static bson_once_t once = BSON_ONCE_INIT; -static bson_mutex_t gLogMutex; -static mongoc_log_func_t gLogFunc = mongoc_log_default_handler; -static bool gLogTrace = MONGOC_TRACE_ENABLED; -static void *gLogData; - -static BSON_ONCE_FUN (_mongoc_ensure_mutex_once) -{ - bson_mutex_init (&gLogMutex); - - BSON_ONCE_RETURN; -} - -void -mongoc_log_set_handler (mongoc_log_func_t log_func, void *user_data) -{ - bson_once (&once, &_mongoc_ensure_mutex_once); - - bson_mutex_lock (&gLogMutex); - gLogFunc = log_func; - gLogData = user_data; - bson_mutex_unlock (&gLogMutex); -} - -bool -_mongoc_log_trace_is_enabled (void) -{ - return gLogTrace && MONGOC_TRACE_ENABLED; -} - -void -mongoc_log_trace_enable (void) -{ - /* Enable trace logging if-and-only-if tracing is enabled at configure-time, - * otherwise tracing remains disabled. - */ - gLogTrace = MONGOC_TRACE_ENABLED; -} - -void -mongoc_log_trace_disable (void) -{ - gLogTrace = false; -} - -/* just for testing */ -void -_mongoc_log_get_handler (mongoc_log_func_t *log_func, void **user_data) -{ - *log_func = gLogFunc; - *user_data = gLogData; -} - - -void -mongoc_log (mongoc_log_level_t log_level, - const char *log_domain, - const char *format, - ...) -{ - va_list args; - char *message; - int stop_logging; - - bson_once (&once, &_mongoc_ensure_mutex_once); - - stop_logging = !gLogFunc; - stop_logging = stop_logging || (log_level == MONGOC_LOG_LEVEL_TRACE && - !_mongoc_log_trace_is_enabled ()); - if (stop_logging) { - return; - } - - BSON_ASSERT (format); - - va_start (args, format); - message = bson_strdupv_printf (format, args); - va_end (args); - - bson_mutex_lock (&gLogMutex); - gLogFunc (log_level, log_domain, message, gLogData); - bson_mutex_unlock (&gLogMutex); - - bson_free (message); -} - - -const char * -mongoc_log_level_str (mongoc_log_level_t log_level) -{ - switch (log_level) { - case MONGOC_LOG_LEVEL_ERROR: - return "ERROR"; - case MONGOC_LOG_LEVEL_CRITICAL: - return "CRITICAL"; - case MONGOC_LOG_LEVEL_WARNING: - return "WARNING"; - case MONGOC_LOG_LEVEL_MESSAGE: - return "MESSAGE"; - case MONGOC_LOG_LEVEL_INFO: - return "INFO"; - case MONGOC_LOG_LEVEL_DEBUG: - return "DEBUG"; - case MONGOC_LOG_LEVEL_TRACE: - return "TRACE"; - default: - return "UNKNOWN"; - } -} - - -void -mongoc_log_default_handler (mongoc_log_level_t log_level, - const char *log_domain, - const char *message, - void *user_data) -{ - struct timeval tv; - struct tm tt; - time_t t; - FILE *stream; - char nowstr[32]; - int pid; - - BSON_UNUSED (user_data); - - bson_gettimeofday (&tv); - t = tv.tv_sec; - -#ifdef _WIN32 -#ifdef _MSC_VER - localtime_s (&tt, &t); -#else - tt = *(localtime (&t)); -#endif -#else - localtime_r (&t, &tt); -#endif - - strftime (nowstr, sizeof nowstr, "%Y/%m/%d %H:%M:%S", &tt); - - switch (log_level) { - case MONGOC_LOG_LEVEL_ERROR: - case MONGOC_LOG_LEVEL_CRITICAL: - case MONGOC_LOG_LEVEL_WARNING: - stream = stderr; - break; - case MONGOC_LOG_LEVEL_MESSAGE: - case MONGOC_LOG_LEVEL_INFO: - case MONGOC_LOG_LEVEL_DEBUG: - case MONGOC_LOG_LEVEL_TRACE: - default: - stream = stdout; - } - -#ifdef __linux__ - pid = syscall (SYS_gettid); -#elif defined(_WIN32) - pid = (int) _getpid (); -#elif defined(__FreeBSD__) - long tid; - thr_self (&tid); - pid = (int) tid; -#elif defined(__OpenBSD__) - pid = (int) getthrid (); -#elif defined(__NetBSD__) - pid = (int) _lwp_self (); -#elif defined(__APPLE__) - uint64_t tid; - pthread_threadid_np (0, &tid); - pid = (int) tid; -#else - pid = (int) getpid (); -#endif - - fprintf (stream, - "%s.%04" PRId64 ": [%5d]: %8s: %12s: %s\n", - nowstr, - (int64_t) (tv.tv_usec / 1000), - pid, - mongoc_log_level_str (log_level), - log_domain, - message); -} - -void -mongoc_log_trace_bytes (const char *domain, const uint8_t *_b, size_t _l) -{ - if (!_mongoc_log_trace_is_enabled ()) { - return; - } - - bson_string_t *const str = bson_string_new (NULL); - bson_string_t *const astr = bson_string_new (NULL); - - size_t _i; - for (_i = 0u; _i < _l; _i++) { - const uint8_t _v = *(_b + _i); - const size_t rem = _i % 16u; - - if (rem == 0u) { - bson_string_append_printf (str, "%05zx: ", _i); - } - - bson_string_append_printf (str, " %02x", _v); - if (isprint (_v)) { - bson_string_append_printf (astr, " %c", _v); - } else { - bson_string_append (astr, " ."); - } - - if (rem == 15u) { - mongoc_log ( - MONGOC_LOG_LEVEL_TRACE, domain, "%s %s", str->str, astr->str); - bson_string_truncate (str, 0); - bson_string_truncate (astr, 0); - } else if (rem == 7u) { - bson_string_append (str, " "); - bson_string_append (astr, " "); - } - } - - if (_i != 16u) { - mongoc_log ( - MONGOC_LOG_LEVEL_TRACE, domain, "%-56s %s", str->str, astr->str); - } - - bson_string_free (str, true); - bson_string_free (astr, true); -} - -void -mongoc_log_trace_iovec (const char *domain, - const mongoc_iovec_t *_iov, - size_t _iovcnt) -{ - bson_string_t *str, *astr; - const char *_b; - unsigned _i = 0; - unsigned _j = 0; - unsigned _k = 0; - size_t _l = 0; - uint8_t _v; - - if (!_mongoc_log_trace_is_enabled ()) { - return; - } - - for (_i = 0; _i < _iovcnt; _i++) { - _l += _iov[_i].iov_len; - } - - _i = 0; - str = bson_string_new (NULL); - astr = bson_string_new (NULL); - - for (_j = 0; _j < _iovcnt; _j++) { - _b = (char *) _iov[_j].iov_base; - _l = _iov[_j].iov_len; - - for (_k = 0; _k < _l; _k++, _i++) { - _v = *(_b + _k); - if ((_i % 16) == 0) { - bson_string_append_printf (str, "%05x: ", _i); - } - - bson_string_append_printf (str, " %02x", _v); - if (isprint (_v)) { - bson_string_append_printf (astr, " %c", _v); - } else { - bson_string_append (astr, " ."); - } - - if ((_i % 16) == 15) { - mongoc_log ( - MONGOC_LOG_LEVEL_TRACE, domain, "%s %s", str->str, astr->str); - bson_string_truncate (str, 0); - bson_string_truncate (astr, 0); - } else if ((_i % 16) == 7) { - bson_string_append (str, " "); - bson_string_append (astr, " "); - } - } - } - - if (_i != 16) { - mongoc_log ( - MONGOC_LOG_LEVEL_TRACE, domain, "%-56s %s", str->str, astr->str); - } - - bson_string_free (str, true); - bson_string_free (astr, true); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-log.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-log.h deleted file mode 100644 index 8f5236479..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-log.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_LOG_H -#define MONGOC_LOG_H - -#include - -#include "mongoc-macros.h" - -BSON_BEGIN_DECLS - - -#ifndef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "mongoc" -#endif - - -#define MONGOC_ERROR(...) \ - mongoc_log (MONGOC_LOG_LEVEL_ERROR, MONGOC_LOG_DOMAIN, __VA_ARGS__) -#define MONGOC_CRITICAL(...) \ - mongoc_log (MONGOC_LOG_LEVEL_CRITICAL, MONGOC_LOG_DOMAIN, __VA_ARGS__) -#define MONGOC_WARNING(...) \ - mongoc_log (MONGOC_LOG_LEVEL_WARNING, MONGOC_LOG_DOMAIN, __VA_ARGS__) -#define MONGOC_MESSAGE(...) \ - mongoc_log (MONGOC_LOG_LEVEL_MESSAGE, MONGOC_LOG_DOMAIN, __VA_ARGS__) -#define MONGOC_INFO(...) \ - mongoc_log (MONGOC_LOG_LEVEL_INFO, MONGOC_LOG_DOMAIN, __VA_ARGS__) -#define MONGOC_DEBUG(...) \ - mongoc_log (MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, __VA_ARGS__) - - -typedef enum { - MONGOC_LOG_LEVEL_ERROR, - MONGOC_LOG_LEVEL_CRITICAL, - MONGOC_LOG_LEVEL_WARNING, - MONGOC_LOG_LEVEL_MESSAGE, - MONGOC_LOG_LEVEL_INFO, - MONGOC_LOG_LEVEL_DEBUG, - MONGOC_LOG_LEVEL_TRACE, -} mongoc_log_level_t; - - -/** - * mongoc_log_func_t: - * @log_level: The level of the log message. - * @log_domain: The domain of the log message, such as "client". - * @message: The message generated. - * @user_data: User data provided to mongoc_log_set_handler(). - * - * This function prototype can be used to set a custom log handler for the - * libmongoc library. This is useful if you would like to show them in a - * user interface or alternate storage. - */ -typedef void (*mongoc_log_func_t) (mongoc_log_level_t log_level, - const char *log_domain, - const char *message, - void *user_data); - - -/** - * mongoc_log_set_handler: - * @log_func: A function to handle log messages. - * @user_data: User data for @log_func. - * - * Sets the function to be called to handle logging. - */ -MONGOC_EXPORT (void) -mongoc_log_set_handler (mongoc_log_func_t log_func, void *user_data); - - -/** - * mongoc_log: - * @log_level: The log level. - * @log_domain: The log domain (such as "client"). - * @format: The format string for the log message. - * - * Logs a message using the currently configured logger. - * - * This method will hold a logging lock to prevent concurrent calls to the - * logging infrastructure. It is important that your configured log function - * does not re-enter the logging system or deadlock will occur. - * - */ -MONGOC_EXPORT (void) -mongoc_log (mongoc_log_level_t log_level, - const char *log_domain, - const char *format, - ...) BSON_GNUC_PRINTF (3, 4); - - -MONGOC_EXPORT (void) -mongoc_log_default_handler (mongoc_log_level_t log_level, - const char *log_domain, - const char *message, - void *user_data); - - -/** - * mongoc_log_level_str: - * @log_level: The log level. - * - * Returns: The string representation of log_level - */ -MONGOC_EXPORT (const char *) -mongoc_log_level_str (mongoc_log_level_t log_level); - - -/** - * mongoc_log_trace_enable: - * - * Enables tracing at runtime (if it has been enabled at compile time). - */ -MONGOC_EXPORT (void) -mongoc_log_trace_enable (void); - - -/** - * mongoc_log_trace_disable: - * - * Disables tracing at runtime (if it has been enabled at compile time). - */ -MONGOC_EXPORT (void) -mongoc_log_trace_disable (void); - - -BSON_END_DECLS - - -#endif /* MONGOC_LOG_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher-op-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher-op-private.h deleted file mode 100644 index 5b944790f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher-op-private.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_MATCHER_OP_PRIVATE_H -#define MONGOC_MATCHER_OP_PRIVATE_H - -#include - - -BSON_BEGIN_DECLS - - -typedef union _mongoc_matcher_op_t mongoc_matcher_op_t; -typedef struct _mongoc_matcher_op_base_t mongoc_matcher_op_base_t; -typedef struct _mongoc_matcher_op_logical_t mongoc_matcher_op_logical_t; -typedef struct _mongoc_matcher_op_compare_t mongoc_matcher_op_compare_t; -typedef struct _mongoc_matcher_op_exists_t mongoc_matcher_op_exists_t; -typedef struct _mongoc_matcher_op_type_t mongoc_matcher_op_type_t; -typedef struct _mongoc_matcher_op_not_t mongoc_matcher_op_not_t; - - -typedef enum { - MONGOC_MATCHER_OPCODE_EQ, - MONGOC_MATCHER_OPCODE_GT, - MONGOC_MATCHER_OPCODE_GTE, - MONGOC_MATCHER_OPCODE_IN, - MONGOC_MATCHER_OPCODE_LT, - MONGOC_MATCHER_OPCODE_LTE, - MONGOC_MATCHER_OPCODE_NE, - MONGOC_MATCHER_OPCODE_NIN, - MONGOC_MATCHER_OPCODE_OR, - MONGOC_MATCHER_OPCODE_AND, - MONGOC_MATCHER_OPCODE_NOT, - MONGOC_MATCHER_OPCODE_NOR, - MONGOC_MATCHER_OPCODE_EXISTS, - MONGOC_MATCHER_OPCODE_TYPE, -} mongoc_matcher_opcode_t; - - -struct _mongoc_matcher_op_base_t { - mongoc_matcher_opcode_t opcode; -}; - - -struct _mongoc_matcher_op_logical_t { - mongoc_matcher_op_base_t base; - mongoc_matcher_op_t *left; - mongoc_matcher_op_t *right; -}; - - -struct _mongoc_matcher_op_compare_t { - mongoc_matcher_op_base_t base; - char *path; - bson_iter_t iter; -}; - - -struct _mongoc_matcher_op_exists_t { - mongoc_matcher_op_base_t base; - char *path; - bool exists; -}; - - -struct _mongoc_matcher_op_type_t { - mongoc_matcher_op_base_t base; - bson_type_t type; - char *path; -}; - - -struct _mongoc_matcher_op_not_t { - mongoc_matcher_op_base_t base; - mongoc_matcher_op_t *child; - char *path; -}; - - -union _mongoc_matcher_op_t { - mongoc_matcher_op_base_t base; - mongoc_matcher_op_logical_t logical; - mongoc_matcher_op_compare_t compare; - mongoc_matcher_op_exists_t exists; - mongoc_matcher_op_type_t type; - mongoc_matcher_op_not_t not_; -}; - - -mongoc_matcher_op_t * -_mongoc_matcher_op_logical_new (mongoc_matcher_opcode_t opcode, - mongoc_matcher_op_t *left, - mongoc_matcher_op_t *right); -mongoc_matcher_op_t * -_mongoc_matcher_op_compare_new (mongoc_matcher_opcode_t opcode, - const char *path, - const bson_iter_t *iter); -mongoc_matcher_op_t * -_mongoc_matcher_op_exists_new (const char *path, bool exists); -mongoc_matcher_op_t * -_mongoc_matcher_op_type_new (const char *path, bson_type_t type); -mongoc_matcher_op_t * -_mongoc_matcher_op_not_new (const char *path, mongoc_matcher_op_t *child); -bool -_mongoc_matcher_op_match (mongoc_matcher_op_t *op, const bson_t *bson); -void -_mongoc_matcher_op_destroy (mongoc_matcher_op_t *op); -void -_mongoc_matcher_op_to_bson (mongoc_matcher_op_t *op, bson_t *bson); - - -BSON_END_DECLS - - -#endif /* MONGOC_MATCHER_OP_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher-op.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher-op.c deleted file mode 100644 index a4f63e039..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher-op.c +++ /dev/null @@ -1,1191 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-log.h" -#include "mongoc-matcher-op-private.h" -#include "mongoc-util-private.h" - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_exists_new -- - * - * Create a new op for checking {$exists: bool}. - * - * Returns: - * A newly allocated mongoc_matcher_op_t that should be freed with - * _mongoc_matcher_op_destroy(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_matcher_op_t * -_mongoc_matcher_op_exists_new (const char *path, /* IN */ - bool exists) /* IN */ -{ - mongoc_matcher_op_t *op; - - BSON_ASSERT (path); - - op = BSON_ALIGNED_ALLOC0 (mongoc_matcher_op_t); - op->exists.base.opcode = MONGOC_MATCHER_OPCODE_EXISTS; - op->exists.path = bson_strdup (path); - op->exists.exists = exists; - - return op; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_type_new -- - * - * Create a new op for checking {$type: int}. - * - * Returns: - * A newly allocated mongoc_matcher_op_t that should be freed with - * _mongoc_matcher_op_destroy(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_matcher_op_t * -_mongoc_matcher_op_type_new (const char *path, /* IN */ - bson_type_t type) /* IN */ -{ - mongoc_matcher_op_t *op; - - BSON_ASSERT (path); - BSON_ASSERT (type); - - op = BSON_ALIGNED_ALLOC0 (mongoc_matcher_op_t); - op->type.base.opcode = MONGOC_MATCHER_OPCODE_TYPE; - op->type.path = bson_strdup (path); - op->type.type = type; - - return op; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_logical_new -- - * - * Create a new op for checking any of: - * - * {$or: []} - * {$nor: []} - * {$and: []} - * - * Returns: - * A newly allocated mongoc_matcher_op_t that should be freed with - * _mongoc_matcher_op_destroy(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_matcher_op_t * -_mongoc_matcher_op_logical_new (mongoc_matcher_opcode_t opcode, /* IN */ - mongoc_matcher_op_t *left, /* IN */ - mongoc_matcher_op_t *right) /* IN */ -{ - mongoc_matcher_op_t *op; - - BSON_ASSERT (left); - BSON_ASSERT ((opcode >= MONGOC_MATCHER_OPCODE_OR) && - (opcode <= MONGOC_MATCHER_OPCODE_NOR)); - - op = BSON_ALIGNED_ALLOC0 (mongoc_matcher_op_t); - op->logical.base.opcode = opcode; - op->logical.left = left; - op->logical.right = right; - - return op; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_compare_new -- - * - * Create a new op for checking any of: - * - * {"abc": "def"} - * {$gt: {...} - * {$gte: {...} - * {$lt: {...} - * {$lte: {...} - * {$ne: {...} - * {$in: [...]} - * {$nin: [...]} - * - * Returns: - * A newly allocated mongoc_matcher_op_t that should be freed with - * _mongoc_matcher_op_destroy(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_matcher_op_t * -_mongoc_matcher_op_compare_new (mongoc_matcher_opcode_t opcode, /* IN */ - const char *path, /* IN */ - const bson_iter_t *iter) /* IN */ -{ - mongoc_matcher_op_t *op; - - BSON_ASSERT (path); - BSON_ASSERT (iter); - - op = BSON_ALIGNED_ALLOC0 (mongoc_matcher_op_t); - op->compare.base.opcode = opcode; - op->compare.path = bson_strdup (path); - memcpy (&op->compare.iter, iter, sizeof *iter); - - return op; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_not_new -- - * - * Create a new op for checking {$not: {...}} - * - * Returns: - * A newly allocated mongoc_matcher_op_t that should be freed with - * _mongoc_matcher_op_destroy(). - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_matcher_op_t * -_mongoc_matcher_op_not_new (const char *path, /* IN */ - mongoc_matcher_op_t *child) /* IN */ -{ - mongoc_matcher_op_t *op; - - BSON_ASSERT (path); - BSON_ASSERT (child); - - op = BSON_ALIGNED_ALLOC0 (mongoc_matcher_op_t); - op->not_.base.opcode = MONGOC_MATCHER_OPCODE_NOT; - op->not_.path = bson_strdup (path); - op->not_.child = child; - - return op; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_destroy -- - * - * Free a mongoc_matcher_op_t structure and all children structures. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -void -_mongoc_matcher_op_destroy (mongoc_matcher_op_t *op) /* IN */ -{ - BSON_ASSERT (op); - - switch (op->base.opcode) { - case MONGOC_MATCHER_OPCODE_EQ: - case MONGOC_MATCHER_OPCODE_GT: - case MONGOC_MATCHER_OPCODE_GTE: - case MONGOC_MATCHER_OPCODE_IN: - case MONGOC_MATCHER_OPCODE_LT: - case MONGOC_MATCHER_OPCODE_LTE: - case MONGOC_MATCHER_OPCODE_NE: - case MONGOC_MATCHER_OPCODE_NIN: - bson_free (op->compare.path); - break; - case MONGOC_MATCHER_OPCODE_OR: - case MONGOC_MATCHER_OPCODE_AND: - case MONGOC_MATCHER_OPCODE_NOR: - if (op->logical.left) - _mongoc_matcher_op_destroy (op->logical.left); - if (op->logical.right) - _mongoc_matcher_op_destroy (op->logical.right); - break; - case MONGOC_MATCHER_OPCODE_NOT: - _mongoc_matcher_op_destroy (op->not_.child); - bson_free (op->not_.path); - break; - case MONGOC_MATCHER_OPCODE_EXISTS: - bson_free (op->exists.path); - break; - case MONGOC_MATCHER_OPCODE_TYPE: - bson_free (op->type.path); - break; - default: - break; - } - - bson_free (op); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_exists_match -- - * - * Checks to see if @bson matches @exists requirements. The - * {$exists: bool} query can be either true or fase so we must - * handle false as "not exists". - * - * Returns: - * true if the field exists and the spec expected it. - * true if the field does not exist and the spec expected it to not - * exist. - * Otherwise, false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_exists_match (mongoc_matcher_op_exists_t *exists, /* IN */ - const bson_t *bson) /* IN */ -{ - bson_iter_t iter; - bson_iter_t desc; - bool found; - - BSON_ASSERT (exists); - BSON_ASSERT (bson); - - found = (bson_iter_init (&iter, bson) && - bson_iter_find_descendant (&iter, exists->path, &desc)); - - return (found == exists->exists); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_type_match -- - * - * Checks if @bson matches the {$type: ...} op. - * - * Returns: - * true if the requested field was found and the type matched - * the requested type. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_type_match (mongoc_matcher_op_type_t *type, /* IN */ - const bson_t *bson) /* IN */ -{ - bson_iter_t iter; - bson_iter_t desc; - - BSON_ASSERT (type); - BSON_ASSERT (bson); - - if (bson_iter_init (&iter, bson) && - bson_iter_find_descendant (&iter, type->path, &desc)) { - return (bson_iter_type (&iter) == type->type); - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_not_match -- - * - * Checks if the {$not: ...} expression matches by negating the - * child expression. - * - * Returns: - * true if the child expression returned false. - * Otherwise false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_not_match (mongoc_matcher_op_not_t *not_, /* IN */ - const bson_t *bson) /* IN */ -{ - BSON_ASSERT (not_); - BSON_ASSERT (bson); - - return !_mongoc_matcher_op_match (not_->child, bson); -} - - -#define _TYPE_CODE(l, r) ((((int) (l)) << 8) | ((int) (r))) -#define _NATIVE_COMPARE(op, t1, t2) \ - (bson_iter##t2 (iter) op bson_iter##t1 (compare_iter)) -#define _EQ_COMPARE(t1, t2) _NATIVE_COMPARE (==, t1, t2) -#define _NE_COMPARE(t1, t2) _NATIVE_COMPARE (!=, t1, t2) -#define _GT_COMPARE(t1, t2) _NATIVE_COMPARE (>, t1, t2) -#define _GTE_COMPARE(t1, t2) _NATIVE_COMPARE (>=, t1, t2) -#define _LT_COMPARE(t1, t2) _NATIVE_COMPARE (<, t1, t2) -#define _LTE_COMPARE(t1, t2) _NATIVE_COMPARE (<=, t1, t2) - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_iter_eq_match -- - * - * Performs equality match for all types on either left or right - * side of the equation. - * - * We try to default to what the compiler would do for comparing - * things like integers. Therefore, we just have MACRO'tized - * everything so that the compiler sees the native values. (Such - * as (double == int64). - * - * The _TYPE_CODE() stuff allows us to shove the type of the left - * and the right into a single integer and then do a jump table - * with a switch/case for all our supported types. - * - * I imagine a bunch more of these will need to be added, so feel - * free to submit patches. - * - * Returns: - * true if the equality match succeeded. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_iter_eq_match (bson_iter_t *compare_iter, /* IN */ - bson_iter_t *iter) /* IN */ -{ - int code; - - BSON_ASSERT (compare_iter); - BSON_ASSERT (iter); - - code = _TYPE_CODE (bson_iter_type (compare_iter), bson_iter_type (iter)); - - switch (code) { - /* Double on Left Side */ - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_DOUBLE): - return _EQ_COMPARE (_double, _double); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_BOOL): - return _EQ_COMPARE (_double, _bool); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_INT32): - return _EQ_COMPARE (_double, _int32); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_INT64): - return _EQ_COMPARE (_double, _int64); - - /* UTF8 on Left Side */ - case _TYPE_CODE (BSON_TYPE_UTF8, BSON_TYPE_UTF8): { - uint32_t llen; - uint32_t rlen; - const char *lstr; - const char *rstr; - - lstr = bson_iter_utf8 (compare_iter, &llen); - rstr = bson_iter_utf8 (iter, &rlen); - - return ((llen == rlen) && (0 == memcmp (lstr, rstr, llen))); - } - - /* Int32 on Left Side */ - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_DOUBLE): - return _EQ_COMPARE (_int32, _double); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_BOOL): - return _EQ_COMPARE (_int32, _bool); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_INT32): - return _EQ_COMPARE (_int32, _int32); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_INT64): - return _EQ_COMPARE (_int32, _int64); - - /* Int64 on Left Side */ - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_DOUBLE): - return _EQ_COMPARE (_int64, _double); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_BOOL): - return _EQ_COMPARE (_int64, _bool); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_INT32): - return _EQ_COMPARE (_int64, _int32); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_INT64): - return _EQ_COMPARE (_int64, _int64); - - /* Null on Left Side */ - case _TYPE_CODE (BSON_TYPE_NULL, BSON_TYPE_NULL): - case _TYPE_CODE (BSON_TYPE_NULL, BSON_TYPE_UNDEFINED): - return true; - - case _TYPE_CODE (BSON_TYPE_ARRAY, BSON_TYPE_ARRAY): { - bson_iter_t left_array; - bson_iter_t right_array; - BSON_ASSERT (bson_iter_recurse (compare_iter, &left_array)); - BSON_ASSERT (bson_iter_recurse (iter, &right_array)); - - while (true) { - bool left_has_next = bson_iter_next (&left_array); - bool right_has_next = bson_iter_next (&right_array); - - if (left_has_next != right_has_next) { - /* different lengths */ - return false; - } - - if (!left_has_next) { - /* finished */ - return true; - } - - if (!_mongoc_matcher_iter_eq_match (&left_array, &right_array)) { - return false; - } - } - } - - case _TYPE_CODE (BSON_TYPE_DOCUMENT, BSON_TYPE_DOCUMENT): { - uint32_t llen; - uint32_t rlen; - const uint8_t *ldoc; - const uint8_t *rdoc; - - bson_iter_document (compare_iter, &llen, &ldoc); - bson_iter_document (iter, &rlen, &rdoc); - - return ((llen == rlen) && (0 == memcmp (ldoc, rdoc, llen))); - } - - default: - return false; - } -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_eq_match -- - * - * Performs equality match for all types on either left or right - * side of the equation. - * - * Returns: - * true if the equality match succeeded. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_eq_match (mongoc_matcher_op_compare_t *compare, /* IN */ - bson_iter_t *iter) /* IN */ -{ - BSON_ASSERT (compare); - BSON_ASSERT (iter); - - return _mongoc_matcher_iter_eq_match (&compare->iter, iter); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_gt_match -- - * - * Perform {$gt: ...} match using @compare. - * - * In general, we try to default to what the compiler would do - * for comparison between different types. - * - * Returns: - * true if the document field was > the spec value. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_gt_match (mongoc_matcher_op_compare_t *compare, /* IN */ - bson_iter_t *iter) /* IN */ -{ - int code; - bson_iter_t *compare_iter = &compare->iter; - - BSON_ASSERT (compare); - BSON_ASSERT (iter); - - code = _TYPE_CODE (bson_iter_type (compare_iter), bson_iter_type (iter)); - - switch (code) { - /* Double on Left Side */ - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_DOUBLE): - return _GT_COMPARE (_double, _double); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_BOOL): - return _GT_COMPARE (_double, _bool); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_INT32): - return _GT_COMPARE (_double, _int32); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_INT64): - return _GT_COMPARE (_double, _int64); - - /* Int32 on Left Side */ - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_DOUBLE): - return _GT_COMPARE (_int32, _double); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_BOOL): - return _GT_COMPARE (_int32, _bool); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_INT32): - return _GT_COMPARE (_int32, _int32); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_INT64): - return _GT_COMPARE (_int32, _int64); - - /* Int64 on Left Side */ - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_DOUBLE): - return _GT_COMPARE (_int64, _double); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_BOOL): - return _GT_COMPARE (_int64, _bool); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_INT32): - return _GT_COMPARE (_int64, _int32); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_INT64): - return _GT_COMPARE (_int64, _int64); - - default: - MONGOC_WARNING ("Implement for (Type(%d) > Type(%d))", - bson_iter_type (compare_iter), - bson_iter_type (iter)); - break; - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_gte_match -- - * - * Perform a match of {"path": {"$gte": value}}. - * - * Returns: - * true if the spec matches, otherwise false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_gte_match (mongoc_matcher_op_compare_t *compare, /* IN */ - bson_iter_t *iter) /* IN */ -{ - bson_iter_t *compare_iter; - int code; - - BSON_ASSERT (compare); - BSON_ASSERT (iter); - - compare_iter = &compare->iter; - code = _TYPE_CODE (bson_iter_type (compare_iter), bson_iter_type (iter)); - - switch (code) { - /* Double on Left Side */ - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_DOUBLE): - return _GTE_COMPARE (_double, _double); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_BOOL): - return _GTE_COMPARE (_double, _bool); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_INT32): - return _GTE_COMPARE (_double, _int32); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_INT64): - return _GTE_COMPARE (_double, _int64); - - /* Int32 on Left Side */ - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_DOUBLE): - return _GTE_COMPARE (_int32, _double); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_BOOL): - return _GTE_COMPARE (_int32, _bool); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_INT32): - return _GTE_COMPARE (_int32, _int32); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_INT64): - return _GTE_COMPARE (_int32, _int64); - - /* Int64 on Left Side */ - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_DOUBLE): - return _GTE_COMPARE (_int64, _double); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_BOOL): - return _GTE_COMPARE (_int64, _bool); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_INT32): - return _GTE_COMPARE (_int64, _int32); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_INT64): - return _GTE_COMPARE (_int64, _int64); - - default: - MONGOC_WARNING ("Implement for (Type(%d) >= Type(%d))", - bson_iter_type (compare_iter), - bson_iter_type (iter)); - break; - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_in_match -- - * - * Checks the spec {"path": {"$in": [value1, value2, ...]}}. - * - * Returns: - * true if the spec matched, otherwise false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_in_match (mongoc_matcher_op_compare_t *compare, /* IN */ - bson_iter_t *iter) /* IN */ -{ - mongoc_matcher_op_compare_t op; - - op.base.opcode = MONGOC_MATCHER_OPCODE_EQ; - op.path = compare->path; - - if (!BSON_ITER_HOLDS_ARRAY (&compare->iter) || - !bson_iter_recurse (&compare->iter, &op.iter)) { - return false; - } - - while (bson_iter_next (&op.iter)) { - if (_mongoc_matcher_op_eq_match (&op, iter)) { - return true; - } - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_lt_match -- - * - * Perform a {"path": "$lt": {value}} match. - * - * Returns: - * true if the spec matched, otherwise false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_lt_match (mongoc_matcher_op_compare_t *compare, /* IN */ - bson_iter_t *iter) /* IN */ -{ - bson_iter_t *compare_iter; - int code; - - BSON_ASSERT (compare); - BSON_ASSERT (iter); - - compare_iter = &compare->iter; - code = _TYPE_CODE (bson_iter_type (compare_iter), bson_iter_type (iter)); - - switch (code) { - /* Double on Left Side */ - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_DOUBLE): - return _LT_COMPARE (_double, _double); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_BOOL): - return _LT_COMPARE (_double, _bool); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_INT32): - return _LT_COMPARE (_double, _int32); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_INT64): - return _LT_COMPARE (_double, _int64); - - /* Int32 on Left Side */ - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_DOUBLE): - return _LT_COMPARE (_int32, _double); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_BOOL): - return _LT_COMPARE (_int32, _bool); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_INT32): - return _LT_COMPARE (_int32, _int32); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_INT64): - return _LT_COMPARE (_int32, _int64); - - /* Int64 on Left Side */ - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_DOUBLE): - return _LT_COMPARE (_int64, _double); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_BOOL): - return _LT_COMPARE (_int64, _bool); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_INT32): - return _LT_COMPARE (_int64, _int32); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_INT64): - return _LT_COMPARE (_int64, _int64); - - default: - MONGOC_WARNING ("Implement for (Type(%d) < Type(%d))", - bson_iter_type (compare_iter), - bson_iter_type (iter)); - break; - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_lte_match -- - * - * Perform a {"$path": {"$lte": value}} match. - * - * Returns: - * true if the spec matched, otherwise false. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_lte_match (mongoc_matcher_op_compare_t *compare, /* IN */ - bson_iter_t *iter) /* IN */ -{ - bson_iter_t *compare_iter; - int code; - - BSON_ASSERT (compare); - BSON_ASSERT (iter); - - compare_iter = &compare->iter; - code = _TYPE_CODE (bson_iter_type (compare_iter), bson_iter_type (iter)); - - switch (code) { - /* Double on Left Side */ - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_DOUBLE): - return _LTE_COMPARE (_double, _double); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_BOOL): - return _LTE_COMPARE (_double, _bool); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_INT32): - return _LTE_COMPARE (_double, _int32); - case _TYPE_CODE (BSON_TYPE_DOUBLE, BSON_TYPE_INT64): - return _LTE_COMPARE (_double, _int64); - - /* Int32 on Left Side */ - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_DOUBLE): - return _LTE_COMPARE (_int32, _double); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_BOOL): - return _LTE_COMPARE (_int32, _bool); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_INT32): - return _LTE_COMPARE (_int32, _int32); - case _TYPE_CODE (BSON_TYPE_INT32, BSON_TYPE_INT64): - return _LTE_COMPARE (_int32, _int64); - - /* Int64 on Left Side */ - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_DOUBLE): - return _LTE_COMPARE (_int64, _double); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_BOOL): - return _LTE_COMPARE (_int64, _bool); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_INT32): - return _LTE_COMPARE (_int64, _int32); - case _TYPE_CODE (BSON_TYPE_INT64, BSON_TYPE_INT64): - return _LTE_COMPARE (_int64, _int64); - - default: - MONGOC_WARNING ("Implement for (Type(%d) <= Type(%d))", - bson_iter_type (compare_iter), - bson_iter_type (iter)); - break; - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_ne_match -- - * - * Perform a {"path": {"$ne": value}} match. - * - * Returns: - * true if the field "path" was not found or the value is not-equal - * to value. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_ne_match (mongoc_matcher_op_compare_t *compare, /* IN */ - bson_iter_t *iter) /* IN */ -{ - return !_mongoc_matcher_op_eq_match (compare, iter); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_nin_match -- - * - * Perform a {"path": {"$nin": value}} match. - * - * Returns: - * true if value was not found in the array at "path". - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_nin_match (mongoc_matcher_op_compare_t *compare, /* IN */ - bson_iter_t *iter) /* IN */ -{ - return !_mongoc_matcher_op_in_match (compare, iter); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_compare_match -- - * - * Dispatch function for mongoc_matcher_op_compare_t operations - * to perform a match. - * - * Returns: - * Opcode dependent. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_compare_match (mongoc_matcher_op_compare_t *compare, /* IN */ - const bson_t *bson) /* IN */ -{ - bson_iter_t tmp; - bson_iter_t iter; - - BSON_ASSERT (compare); - BSON_ASSERT (bson); - - if (strchr (compare->path, '.')) { - if (!bson_iter_init (&tmp, bson) || - !bson_iter_find_descendant (&tmp, compare->path, &iter)) { - return false; - } - } else if (!bson_iter_init_find (&iter, bson, compare->path)) { - return false; - } - - switch ((int) compare->base.opcode) { - case MONGOC_MATCHER_OPCODE_EQ: - return _mongoc_matcher_op_eq_match (compare, &iter); - case MONGOC_MATCHER_OPCODE_GT: - return _mongoc_matcher_op_gt_match (compare, &iter); - case MONGOC_MATCHER_OPCODE_GTE: - return _mongoc_matcher_op_gte_match (compare, &iter); - case MONGOC_MATCHER_OPCODE_IN: - return _mongoc_matcher_op_in_match (compare, &iter); - case MONGOC_MATCHER_OPCODE_LT: - return _mongoc_matcher_op_lt_match (compare, &iter); - case MONGOC_MATCHER_OPCODE_LTE: - return _mongoc_matcher_op_lte_match (compare, &iter); - case MONGOC_MATCHER_OPCODE_NE: - return _mongoc_matcher_op_ne_match (compare, &iter); - case MONGOC_MATCHER_OPCODE_NIN: - return _mongoc_matcher_op_nin_match (compare, &iter); - default: - BSON_ASSERT (false); - break; - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_logical_match -- - * - * Dispatch function for mongoc_matcher_op_logical_t operations - * to perform a match. - * - * Returns: - * Opcode specific. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_matcher_op_logical_match (mongoc_matcher_op_logical_t *logical, /* IN */ - const bson_t *bson) /* IN */ -{ - BSON_ASSERT (logical); - BSON_ASSERT (bson); - - switch ((int) logical->base.opcode) { - case MONGOC_MATCHER_OPCODE_OR: - return (_mongoc_matcher_op_match (logical->left, bson) || - _mongoc_matcher_op_match (logical->right, bson)); - case MONGOC_MATCHER_OPCODE_AND: - return (_mongoc_matcher_op_match (logical->left, bson) && - _mongoc_matcher_op_match (logical->right, bson)); - case MONGOC_MATCHER_OPCODE_NOR: - return !(_mongoc_matcher_op_match (logical->left, bson) || - _mongoc_matcher_op_match (logical->right, bson)); - default: - BSON_ASSERT (false); - break; - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_match -- - * - * Dispatch function for all operation types to perform a match. - * - * Returns: - * Opcode specific. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -_mongoc_matcher_op_match (mongoc_matcher_op_t *op, /* IN */ - const bson_t *bson) /* IN */ -{ - BSON_ASSERT (op); - BSON_ASSERT (bson); - - switch (op->base.opcode) { - case MONGOC_MATCHER_OPCODE_EQ: - case MONGOC_MATCHER_OPCODE_GT: - case MONGOC_MATCHER_OPCODE_GTE: - case MONGOC_MATCHER_OPCODE_IN: - case MONGOC_MATCHER_OPCODE_LT: - case MONGOC_MATCHER_OPCODE_LTE: - case MONGOC_MATCHER_OPCODE_NE: - case MONGOC_MATCHER_OPCODE_NIN: - return _mongoc_matcher_op_compare_match (&op->compare, bson); - case MONGOC_MATCHER_OPCODE_OR: - case MONGOC_MATCHER_OPCODE_AND: - case MONGOC_MATCHER_OPCODE_NOR: - return _mongoc_matcher_op_logical_match (&op->logical, bson); - case MONGOC_MATCHER_OPCODE_NOT: - return _mongoc_matcher_op_not_match (&op->not_, bson); - case MONGOC_MATCHER_OPCODE_EXISTS: - return _mongoc_matcher_op_exists_match (&op->exists, bson); - case MONGOC_MATCHER_OPCODE_TYPE: - return _mongoc_matcher_op_type_match (&op->type, bson); - default: - break; - } - - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_op_to_bson -- - * - * Convert the optree specified by @op to a bson document similar - * to what the query would have been. This is not perfectly the - * same, and so should not be used as such. - * - * Returns: - * None. - * - * Side effects: - * @bson is appended to, and therefore must be initialized before - * calling this function. - * - *-------------------------------------------------------------------------- - */ - -void -_mongoc_matcher_op_to_bson (mongoc_matcher_op_t *op, /* IN */ - bson_t *bson) /* IN */ -{ - const char *str; - bson_t child; - bson_t child2; - - BSON_ASSERT (op); - BSON_ASSERT (bson); - - switch (op->base.opcode) { - case MONGOC_MATCHER_OPCODE_EQ: - (void) bson_append_iter (bson, op->compare.path, -1, &op->compare.iter); - break; - case MONGOC_MATCHER_OPCODE_GT: - case MONGOC_MATCHER_OPCODE_GTE: - case MONGOC_MATCHER_OPCODE_IN: - case MONGOC_MATCHER_OPCODE_LT: - case MONGOC_MATCHER_OPCODE_LTE: - case MONGOC_MATCHER_OPCODE_NE: - case MONGOC_MATCHER_OPCODE_NIN: - switch ((int) op->base.opcode) { - case MONGOC_MATCHER_OPCODE_GT: - str = "$gt"; - break; - case MONGOC_MATCHER_OPCODE_GTE: - str = "$gte"; - break; - case MONGOC_MATCHER_OPCODE_IN: - str = "$in"; - break; - case MONGOC_MATCHER_OPCODE_LT: - str = "$lt"; - break; - case MONGOC_MATCHER_OPCODE_LTE: - str = "$lte"; - break; - case MONGOC_MATCHER_OPCODE_NE: - str = "$ne"; - break; - case MONGOC_MATCHER_OPCODE_NIN: - str = "$nin"; - break; - default: - str = "???"; - break; - } - if (bson_append_document_begin (bson, op->compare.path, -1, &child)) { - (void) bson_append_iter (&child, str, -1, &op->compare.iter); - bson_append_document_end (bson, &child); - } - break; - case MONGOC_MATCHER_OPCODE_OR: - case MONGOC_MATCHER_OPCODE_AND: - case MONGOC_MATCHER_OPCODE_NOR: - if (op->base.opcode == MONGOC_MATCHER_OPCODE_OR) { - str = "$or"; - } else if (op->base.opcode == MONGOC_MATCHER_OPCODE_AND) { - str = "$and"; - } else if (op->base.opcode == MONGOC_MATCHER_OPCODE_NOR) { - str = "$nor"; - } else { - BSON_ASSERT (false); - str = NULL; - } - { - bson_array_builder_t *bab; - bson_append_array_builder_begin (bson, str, -1, &bab); - bson_array_builder_append_document_begin (bab, &child2); - _mongoc_matcher_op_to_bson (op->logical.left, &child2); - bson_array_builder_append_document_end (bab, &child2); - if (op->logical.right) { - bson_array_builder_append_document_begin (bab, &child2); - _mongoc_matcher_op_to_bson (op->logical.right, &child2); - bson_array_builder_append_document_end (bab, &child2); - } - bson_append_array_builder_end (bson, bab); - } - break; - case MONGOC_MATCHER_OPCODE_NOT: - bson_append_document_begin (bson, op->not_.path, -1, &child); - bson_append_document_begin (&child, "$not", 4, &child2); - _mongoc_matcher_op_to_bson (op->not_.child, &child2); - bson_append_document_end (&child, &child2); - bson_append_document_end (bson, &child); - break; - case MONGOC_MATCHER_OPCODE_EXISTS: - BSON_APPEND_BOOL (bson, "$exists", op->exists.exists); - break; - case MONGOC_MATCHER_OPCODE_TYPE: - BSON_APPEND_INT32 (bson, "$type", (int) op->type.type); - break; - default: - BSON_ASSERT (false); - break; - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher-private.h deleted file mode 100644 index 44e851074..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher-private.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_MATCHER_PRIVATE_H -#define MONGOC_MATCHER_PRIVATE_H - -#include - -#include "mongoc-matcher-op-private.h" - - -BSON_BEGIN_DECLS - - -struct _mongoc_matcher_t { - bson_t query; - mongoc_matcher_op_t *optree; -}; - - -BSON_END_DECLS - - -#endif /* MONGOC_MATCHER_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher.c deleted file mode 100644 index fff40144c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "mongoc-error.h" -#include "mongoc-matcher.h" -#include "mongoc-matcher-private.h" -#include "mongoc-matcher-op-private.h" - - -static mongoc_matcher_op_t * -_mongoc_matcher_parse_logical (mongoc_matcher_opcode_t opcode, - bson_iter_t *iter, - bool is_root, - bson_error_t *error); - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_parse_compare -- - * - * Parse a compare spec such as $gt or $in. - * - * See the following link for more information. - * - * https://www.mongodb.com/docs/manual/reference/operator/query/ - * - * Returns: - * A newly allocated mongoc_matcher_op_t if successful; otherwise - * NULL and @error is set. - * - * Side effects: - * @error may be set. - * - *-------------------------------------------------------------------------- - */ - -static mongoc_matcher_op_t * -_mongoc_matcher_parse_compare (bson_iter_t *iter, /* IN */ - const char *path, /* IN */ - bson_error_t *error) /* OUT */ -{ - const char *key; - mongoc_matcher_op_t *op = NULL, *op_child; - bson_iter_t child; - - BSON_ASSERT (iter); - BSON_ASSERT (path); - - if (bson_iter_type (iter) == BSON_TYPE_DOCUMENT) { - if (!bson_iter_recurse (iter, &child) || !bson_iter_next (&child)) { - bson_set_error (error, - MONGOC_ERROR_MATCHER, - MONGOC_ERROR_MATCHER_INVALID, - "Document contains no operations."); - return NULL; - } - - key = bson_iter_key (&child); - - if (key[0] != '$') { - op = _mongoc_matcher_op_compare_new ( - MONGOC_MATCHER_OPCODE_EQ, path, iter); - } else if (strcmp (key, "$not") == 0) { - if (!(op_child = - _mongoc_matcher_parse_compare (&child, path, error))) { - return NULL; - } - op = _mongoc_matcher_op_not_new (path, op_child); - } else if (strcmp (key, "$gt") == 0) { - op = _mongoc_matcher_op_compare_new ( - MONGOC_MATCHER_OPCODE_GT, path, &child); - } else if (strcmp (key, "$gte") == 0) { - op = _mongoc_matcher_op_compare_new ( - MONGOC_MATCHER_OPCODE_GTE, path, &child); - } else if (strcmp (key, "$in") == 0) { - op = _mongoc_matcher_op_compare_new ( - MONGOC_MATCHER_OPCODE_IN, path, &child); - } else if (strcmp (key, "$lt") == 0) { - op = _mongoc_matcher_op_compare_new ( - MONGOC_MATCHER_OPCODE_LT, path, &child); - } else if (strcmp (key, "$lte") == 0) { - op = _mongoc_matcher_op_compare_new ( - MONGOC_MATCHER_OPCODE_LTE, path, &child); - } else if (strcmp (key, "$ne") == 0) { - op = _mongoc_matcher_op_compare_new ( - MONGOC_MATCHER_OPCODE_NE, path, &child); - } else if (strcmp (key, "$nin") == 0) { - op = _mongoc_matcher_op_compare_new ( - MONGOC_MATCHER_OPCODE_NIN, path, &child); - } else if (strcmp (key, "$exists") == 0) { - op = _mongoc_matcher_op_exists_new (path, bson_iter_bool (&child)); - } else if (strcmp (key, "$type") == 0) { - op = _mongoc_matcher_op_type_new (path, bson_iter_type (&child)); - } else { - bson_set_error (error, - MONGOC_ERROR_MATCHER, - MONGOC_ERROR_MATCHER_INVALID, - "Invalid operator \"%s\"", - key); - return NULL; - } - } else { - op = - _mongoc_matcher_op_compare_new (MONGOC_MATCHER_OPCODE_EQ, path, iter); - } - - BSON_ASSERT (op); - - return op; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_parse -- - * - * Parse a query spec observed by the current key of @iter. - * - * Returns: - * A newly allocated mongoc_matcher_op_t if successful; otherwise - * NULL an @error is set. - * - * Side effects: - * @error may be set. - * - *-------------------------------------------------------------------------- - */ - -static mongoc_matcher_op_t * -_mongoc_matcher_parse (bson_iter_t *iter, /* IN */ - bson_error_t *error) /* OUT */ -{ - bson_iter_t child; - const char *key; - - BSON_ASSERT (iter); - - key = bson_iter_key (iter); - - if (*key != '$') { - return _mongoc_matcher_parse_compare (iter, key, error); - } else { - BSON_ASSERT (bson_iter_type (iter) == BSON_TYPE_ARRAY); - - if (!bson_iter_recurse (iter, &child)) { - bson_set_error (error, - MONGOC_ERROR_MATCHER, - MONGOC_ERROR_MATCHER_INVALID, - "Invalid value for operator \"%s\"", - key); - return NULL; - } - - if (strcmp (key, "$or") == 0) { - return _mongoc_matcher_parse_logical ( - MONGOC_MATCHER_OPCODE_OR, &child, false, error); - } else if (strcmp (key, "$and") == 0) { - return _mongoc_matcher_parse_logical ( - MONGOC_MATCHER_OPCODE_AND, &child, false, error); - } else if (strcmp (key, "$nor") == 0) { - return _mongoc_matcher_parse_logical ( - MONGOC_MATCHER_OPCODE_NOR, &child, false, error); - } - } - - bson_set_error (error, - MONGOC_ERROR_MATCHER, - MONGOC_ERROR_MATCHER_INVALID, - "Invalid operator \"%s\"", - key); - - return NULL; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_matcher_parse_logical -- - * - * Parse a query spec containing a logical operator such as - * $or, $and, $not, and $nor. - * - * See the following link for more information. - * - * https://www.mongodb.com/docs/manual/reference/operator/query/ - * - * Returns: - * A newly allocated mongoc_matcher_op_t if successful; otherwise - * NULL and @error is set. - * - * Side effects: - * @error may be set. - * - *-------------------------------------------------------------------------- - */ - -static mongoc_matcher_op_t * -_mongoc_matcher_parse_logical (mongoc_matcher_opcode_t opcode, /* IN */ - bson_iter_t *iter, /* IN */ - bool is_root, /* IN */ - bson_error_t *error) /* OUT */ -{ - mongoc_matcher_op_t *left; - mongoc_matcher_op_t *right; - mongoc_matcher_op_t *more; - mongoc_matcher_op_t *more_wrap; - bson_iter_t child; - - BSON_ASSERT (opcode); - BSON_ASSERT (iter); - BSON_ASSERT (iter); - - if (!bson_iter_next (iter)) { - bson_set_error (error, - MONGOC_ERROR_MATCHER, - MONGOC_ERROR_MATCHER_INVALID, - "Invalid logical operator."); - return NULL; - } - - if (is_root) { - if (!(left = _mongoc_matcher_parse (iter, error))) { - return NULL; - } - } else { - if (!BSON_ITER_HOLDS_DOCUMENT (iter)) { - bson_set_error (error, - MONGOC_ERROR_MATCHER, - MONGOC_ERROR_MATCHER_INVALID, - "Expected document in value."); - return NULL; - } - - if (!bson_iter_recurse (iter, &child)) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "corrupt BSON"); - return NULL; - } - - if (!bson_iter_next (&child)) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "corrupt BSON"); - return NULL; - } - - if (!(left = _mongoc_matcher_parse (&child, error))) { - return NULL; - } - } - - if (!bson_iter_next (iter)) { - return left; - } - - if (is_root) { - if (!(right = _mongoc_matcher_parse (iter, error))) { - return NULL; - } - } else { - if (!BSON_ITER_HOLDS_DOCUMENT (iter)) { - bson_set_error (error, - MONGOC_ERROR_MATCHER, - MONGOC_ERROR_MATCHER_INVALID, - "Expected document in value."); - return NULL; - } - - if (!bson_iter_recurse (iter, &child)) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "bson_iter_recurse failed."); - return NULL; - } - - if (!bson_iter_next (&child)) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "corrupt BSON"); - return NULL; - } - - if (!(right = _mongoc_matcher_parse (&child, error))) { - return NULL; - } - } - - more = _mongoc_matcher_parse_logical (opcode, iter, is_root, error); - - if (more) { - more_wrap = _mongoc_matcher_op_logical_new (opcode, right, more); - return _mongoc_matcher_op_logical_new (opcode, left, more_wrap); - } - - return _mongoc_matcher_op_logical_new (opcode, left, right); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_matcher_new -- - * - * Create a new mongoc_matcher_t using the query specification - * provided in @query. - * - * This will build an operation tree that can be applied to arbitrary - * bson documents using mongoc_matcher_match(). - * - * Returns: - * A newly allocated mongoc_matcher_t if successful; otherwise NULL - * and @error is set. - * - * The mongoc_matcher_t should be freed with - * mongoc_matcher_destroy(). - * - * Side effects: - * @error may be set. - * - *-------------------------------------------------------------------------- - */ - -mongoc_matcher_t * -mongoc_matcher_new (const bson_t *query, /* IN */ - bson_error_t *error) /* OUT */ -{ - mongoc_matcher_op_t *op; - mongoc_matcher_t *matcher; - bson_iter_t iter; - - BSON_ASSERT (query); - - matcher = BSON_ALIGNED_ALLOC0 (mongoc_matcher_t); - bson_copy_to (query, &matcher->query); - - if (!bson_iter_init (&iter, &matcher->query)) { - goto failure; - } - - if (!(op = _mongoc_matcher_parse_logical ( - MONGOC_MATCHER_OPCODE_AND, &iter, true, error))) { - goto failure; - } - - matcher->optree = op; - - return matcher; - -failure: - bson_destroy (&matcher->query); - bson_free (matcher); - return NULL; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_matcher_match -- - * - * Checks to see if @bson matches the query specified when creating - * @matcher. - * - * Returns: - * TRUE if @bson matched the query, otherwise FALSE. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_matcher_match (const mongoc_matcher_t *matcher, /* IN */ - const bson_t *document) /* IN */ -{ - BSON_ASSERT (matcher); - BSON_ASSERT (matcher->optree); - BSON_ASSERT (document); - - return _mongoc_matcher_op_match (matcher->optree, document); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_matcher_destroy -- - * - * Release all resources associated with @matcher. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_matcher_destroy (mongoc_matcher_t *matcher) /* IN */ -{ - BSON_ASSERT (matcher); - - _mongoc_matcher_op_destroy (matcher->optree); - bson_destroy (&matcher->query); - bson_free (matcher); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher.h deleted file mode 100644 index 2534290fe..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-matcher.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_MATCHER_H -#define MONGOC_MATCHER_H - -#include - -#include "mongoc-macros.h" - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_matcher_t mongoc_matcher_t; - - -MONGOC_EXPORT (mongoc_matcher_t *) -mongoc_matcher_new (const bson_t *query, bson_error_t *error) - BSON_GNUC_WARN_UNUSED_RESULT BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (bool) -mongoc_matcher_match (const mongoc_matcher_t *matcher, - const bson_t *document) BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (void) -mongoc_matcher_destroy (mongoc_matcher_t *matcher) BSON_GNUC_DEPRECATED; - - -BSON_END_DECLS - - -#endif /* MONGOC_MATCHER_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-openssl-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-openssl-private.h deleted file mode 100644 index b276622fb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-openssl-private.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_OPENSSL_PRIVATE_H -#define MONGOC_OPENSSL_PRIVATE_H - -#include -#include -#include -#include - -#include "mongoc-ssl.h" -#include "mongoc-stream-tls-openssl-private.h" - -#if (OPENSSL_VERSION_NUMBER >= 0x10001000L) && !defined(OPENSSL_NO_OCSP) && \ - !defined(LIBRESSL_VERSION_NUMBER) -#define MONGOC_ENABLE_OCSP_OPENSSL -#endif - - -BSON_BEGIN_DECLS - -bool -_mongoc_openssl_check_peer_hostname (SSL *ssl, - const char *host, - bool allow_invalid_hostname); -SSL_CTX * -_mongoc_openssl_ctx_new (mongoc_ssl_opt_t *opt); -char * -_mongoc_openssl_extract_subject (const char *filename, const char *passphrase); -void -_mongoc_openssl_init (void); -void -_mongoc_openssl_cleanup (void); - -#ifdef MONGOC_ENABLE_OCSP_OPENSSL -int -_mongoc_ocsp_tlsext_status (SSL *ssl, mongoc_openssl_ocsp_opt_t *opts); -#endif - -bool -_mongoc_tlsfeature_has_status_request (const uint8_t *data, int length); - -BSON_END_DECLS - - -#endif /* MONGOC_OPENSSL_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-opts-helpers-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-opts-helpers-private.h deleted file mode 100644 index 500c8fd92..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-opts-helpers-private.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2019-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#include -#include "mongoc-client-session-private.h" -#include "mongoc-collection-private.h" -#include "mongoc-write-command-private.h" - -#ifndef LIBMONGOC_MONGOC_OPTS_HELPERS_H -#define LIBMONGOC_MONGOC_OPTS_HELPERS_H - -#define _mongoc_convert_session_id _mongoc_client_session_from_iter - -typedef struct _mongoc_timestamp_t { - uint32_t timestamp; - uint32_t increment; -} mongoc_timestamp_t; - -bool -_mongoc_timestamp_empty (mongoc_timestamp_t *timestamp); - -void -_mongoc_timestamp_set (mongoc_timestamp_t *dst, mongoc_timestamp_t *src); - -void -_mongoc_timestamp_set_from_bson (mongoc_timestamp_t *timestamp, - bson_iter_t *iter); - -void -_mongoc_timestamp_append (mongoc_timestamp_t *timestamp, - bson_t *bson, - char *key); - -void -_mongoc_timestamp_clear (mongoc_timestamp_t *timestamp); - -bool -_mongoc_convert_document (mongoc_client_t *client, - const bson_iter_t *iter, - bson_t *doc, - bson_error_t *error); - -bool -_mongoc_convert_array (mongoc_client_t *client, - const bson_iter_t *iter, - bson_t *doc, - bson_error_t *error); - -bool -_mongoc_convert_int64_positive (mongoc_client_t *client, - const bson_iter_t *iter, - int64_t *num, - bson_error_t *error); - -bool -_mongoc_convert_int32_t (mongoc_client_t *client, - const bson_iter_t *iter, - int32_t *num, - bson_error_t *error); - -bool -_mongoc_convert_int32_positive (mongoc_client_t *client, - const bson_iter_t *iter, - int32_t *num, - bson_error_t *error); - -bool -_mongoc_convert_bool (mongoc_client_t *client, - const bson_iter_t *iter, - bool *flag, - bson_error_t *error); - -bool -_mongoc_convert_bson_value_t (mongoc_client_t *client, - const bson_iter_t *iter, - bson_value_t *value, - bson_error_t *error); - -bool -_mongoc_convert_timestamp (mongoc_client_t *client, - const bson_iter_t *iter, - mongoc_timestamp_t *timestamp, - bson_error_t *error); - -bool -_mongoc_convert_utf8 (mongoc_client_t *client, - const bson_iter_t *iter, - const char **comment, - bson_error_t *error); - -bool -_mongoc_convert_validate_flags (mongoc_client_t *client, - const bson_iter_t *iter, - bson_validate_flags_t *flags, - bson_error_t *error); - -bool -_mongoc_convert_mongoc_write_bypass_document_validation_t ( - mongoc_client_t *client, - const bson_iter_t *iter, - bool *bdv, - bson_error_t *error); - -bool -_mongoc_convert_write_concern (mongoc_client_t *client, - const bson_iter_t *iter, - mongoc_write_concern_t **wc, - bson_error_t *error); - -bool -_mongoc_convert_server_id (mongoc_client_t *client, - const bson_iter_t *iter, - uint32_t *server_id, - bson_error_t *error); - -bool -_mongoc_convert_read_concern (mongoc_client_t *client, - const bson_iter_t *iter, - mongoc_read_concern_t **rc, - bson_error_t *error); - -bool -_mongoc_convert_hint (mongoc_client_t *client, - const bson_iter_t *iter, - bson_value_t *value, - bson_error_t *error); - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-opts-helpers.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-opts-helpers.c deleted file mode 100644 index 32bff262e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-opts-helpers.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright 2019-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-opts-helpers-private.h" -#include "mongoc-client-session-private.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-util-private.h" -#include "mongoc-read-concern-private.h" - -#define BSON_ERR(...) \ - do { \ - bson_set_error ( \ - error, MONGOC_ERROR_BSON, MONGOC_ERROR_BSON_INVALID, __VA_ARGS__); \ - return false; \ - } while (0) - - -#define CONVERSION_ERR(...) \ - do { \ - bson_set_error (error, \ - MONGOC_ERROR_COMMAND, \ - MONGOC_ERROR_COMMAND_INVALID_ARG, \ - __VA_ARGS__); \ - return false; \ - } while (0) - - -bool -_mongoc_timestamp_empty (mongoc_timestamp_t *timestamp) -{ - return (timestamp->timestamp == 0 && timestamp->increment == 0); -} - -void -_mongoc_timestamp_set (mongoc_timestamp_t *dst, mongoc_timestamp_t *src) -{ - dst->timestamp = src->timestamp; - dst->increment = src->increment; -} - -void -_mongoc_timestamp_set_from_bson (mongoc_timestamp_t *timestamp, - bson_iter_t *iter) -{ - bson_iter_timestamp (iter, &(timestamp->timestamp), &(timestamp->increment)); -} - -void -_mongoc_timestamp_append (mongoc_timestamp_t *timestamp, - bson_t *bson, - char *key) -{ - const size_t len = strlen (key); - BSON_ASSERT (bson_in_range_unsigned (int, len)); - bson_append_timestamp ( - bson, key, (int) len, timestamp->timestamp, timestamp->increment); -} - -void -_mongoc_timestamp_clear (mongoc_timestamp_t *timestamp) -{ - timestamp->timestamp = 0; - timestamp->increment = 0; -} - -bool -_mongoc_convert_document (mongoc_client_t *client, - const bson_iter_t *iter, - bson_t *doc, - bson_error_t *error) -{ - uint32_t len; - const uint8_t *data; - bson_t value; - - BSON_UNUSED (client); - - if (!BSON_ITER_HOLDS_DOCUMENT (iter)) { - CONVERSION_ERR ("Invalid field \"%s\" in opts, should contain document," - " not %s", - bson_iter_key (iter), - _mongoc_bson_type_to_str (bson_iter_type (iter))); - } - - bson_iter_document (iter, &len, &data); - if (!bson_init_static (&value, data, len)) { - BSON_ERR ("Corrupt BSON in field \"%s\" in opts", bson_iter_key (iter)); - } - - bson_destroy (doc); - bson_copy_to (&value, doc); - - return true; -} - -bool -_mongoc_convert_array (mongoc_client_t *client, - const bson_iter_t *iter, - bson_t *doc, - bson_error_t *error) -{ - uint32_t len; - const uint8_t *data; - bson_t value; - - BSON_UNUSED (client); - - if (!BSON_ITER_HOLDS_ARRAY (iter)) { - CONVERSION_ERR ("Invalid field \"%s\" in opts, should contain array," - " not %s", - bson_iter_key (iter), - _mongoc_bson_type_to_str (bson_iter_type (iter))); - } - - bson_iter_array (iter, &len, &data); - if (!bson_init_static (&value, data, len)) { - BSON_ERR ("Corrupt BSON in field \"%s\" in opts", bson_iter_key (iter)); - } - - bson_destroy (doc); - bson_copy_to (&value, doc); - - return true; -} - -bool -_mongoc_convert_int64_positive (mongoc_client_t *client, - const bson_iter_t *iter, - int64_t *num, - bson_error_t *error) -{ - int64_t i; - - BSON_UNUSED (client); - - if (!BSON_ITER_HOLDS_NUMBER (iter)) { - CONVERSION_ERR ("Invalid field \"%s\" in opts, should contain number," - " not %s", - bson_iter_key (iter), - _mongoc_bson_type_to_str (bson_iter_type (iter))); - } - - i = bson_iter_as_int64 (iter); - if (i <= 0) { - CONVERSION_ERR ("Invalid field \"%s\" in opts, should be greater than 0," - " not %" PRId64, - bson_iter_key (iter), - i); - } - - *num = bson_iter_as_int64 (iter); - return true; -} - -bool -_mongoc_convert_int32_t (mongoc_client_t *client, - const bson_iter_t *iter, - int32_t *num, - bson_error_t *error) -{ - int64_t i; - - BSON_UNUSED (client); - - if (!BSON_ITER_HOLDS_NUMBER (iter)) { - CONVERSION_ERR ("Invalid field \"%s\" in opts", bson_iter_key (iter)); - } - - i = bson_iter_as_int64 (iter); - if (i > INT32_MAX || i < INT32_MIN) { - CONVERSION_ERR ("Invalid field \"%s\" in opts: %" PRId64 - " out of range for int32", - bson_iter_key (iter), - i); - } - - *num = (int32_t) i; - - return true; -} - -bool -_mongoc_convert_int32_positive (mongoc_client_t *client, - const bson_iter_t *iter, - int32_t *num, - bson_error_t *error) -{ - int32_t i; - - if (!_mongoc_convert_int32_t (client, iter, &i, error)) { - return false; - } - - if (i <= 0) { - CONVERSION_ERR ( - "Invalid field \"%s\" in opts, should be greater than 0, not %d", - bson_iter_key (iter), - i); - } - - *num = i; - - return true; -} - -bool -_mongoc_convert_bool (mongoc_client_t *client, - const bson_iter_t *iter, - bool *flag, - bson_error_t *error) -{ - BSON_UNUSED (client); - - if (BSON_ITER_HOLDS_BOOL (iter)) { - *flag = bson_iter_bool (iter); - return true; - } - - CONVERSION_ERR ("Invalid field \"%s\" in opts, should contain bool," - " not %s", - bson_iter_key (iter), - _mongoc_bson_type_to_str (bson_iter_type (iter))); -} - -bool -_mongoc_convert_bson_value_t (mongoc_client_t *client, - const bson_iter_t *iter, - bson_value_t *value, - bson_error_t *error) -{ - BSON_UNUSED (client); - BSON_UNUSED (error); - - bson_value_copy (bson_iter_value ((bson_iter_t *) iter), value); - - return true; -} - -bool -_mongoc_convert_timestamp (mongoc_client_t *client, - const bson_iter_t *iter, - mongoc_timestamp_t *timestamp, - bson_error_t *error) -{ - BSON_UNUSED (client); - BSON_UNUSED (error); - - bson_iter_timestamp (iter, ×tamp->timestamp, ×tamp->increment); - - return true; -} - -bool -_mongoc_convert_utf8 (mongoc_client_t *client, - const bson_iter_t *iter, - const char **str, - bson_error_t *error) -{ - BSON_UNUSED (client); - - if (BSON_ITER_HOLDS_UTF8 (iter)) { - *str = bson_iter_utf8 (iter, NULL); - return true; - } - - CONVERSION_ERR ("Invalid field \"%s\" in opts, should contain string," - " not %s", - bson_iter_key (iter), - _mongoc_bson_type_to_str (bson_iter_type (iter))); -} - -bool -_mongoc_convert_validate_flags (mongoc_client_t *client, - const bson_iter_t *iter, - bson_validate_flags_t *flags, - bson_error_t *error) -{ - BSON_UNUSED (client); - - if (BSON_ITER_HOLDS_BOOL (iter)) { - if (!bson_iter_as_bool (iter)) { - *flags = BSON_VALIDATE_NONE; - return true; - } else { - /* validate: false is ok but validate: true is prohibited */ - CONVERSION_ERR ("Invalid option \"%s\": true, must be a bitwise-OR of" - " bson_validate_flags_t values.", - bson_iter_key (iter)); - } - } else if (BSON_ITER_HOLDS_INT32 (iter)) { - if (bson_iter_int32 (iter) <= 0x1F) { - *flags = (bson_validate_flags_t) bson_iter_int32 (iter); - return true; - } else { - CONVERSION_ERR ("Invalid field \"%s\" in opts, must be a bitwise-OR of" - " bson_validate_flags_t values.", - bson_iter_key (iter)); - } - } - CONVERSION_ERR ("Invalid type for option \"%s\": \"%s\"." - " \"%s\" must be a boolean or a bitwise-OR of" - " bson_validate_flags_t values.", - bson_iter_key (iter), - _mongoc_bson_type_to_str (bson_iter_type (iter)), - bson_iter_key (iter)); -} - -bool -_mongoc_convert_write_concern (mongoc_client_t *client, - const bson_iter_t *iter, - mongoc_write_concern_t **wc, - bson_error_t *error) -{ - mongoc_write_concern_t *tmp; - - BSON_UNUSED (client); - - tmp = _mongoc_write_concern_new_from_iter (iter, error); - if (tmp) { - *wc = tmp; - return true; - } - - return false; -} - -bool -_mongoc_convert_server_id (mongoc_client_t *client, - const bson_iter_t *iter, - uint32_t *server_id, - bson_error_t *error) -{ - int64_t tmp; - - BSON_UNUSED (client); - - if (!BSON_ITER_HOLDS_INT (iter)) { - CONVERSION_ERR ("The serverId option must be an integer"); - } - - tmp = bson_iter_as_int64 (iter); - if (tmp <= 0) { - CONVERSION_ERR ("The serverId option must be >= 1"); - } - - *server_id = (uint32_t) tmp; - return true; -} - -bool -_mongoc_convert_read_concern (mongoc_client_t *client, - const bson_iter_t *iter, - mongoc_read_concern_t **rc, - bson_error_t *error) -{ - BSON_UNUSED (client); - - *rc = _mongoc_read_concern_new_from_iter (iter, error); - if (!*rc) { - return false; - } - return true; -} - -bool -_mongoc_convert_hint (mongoc_client_t *client, - const bson_iter_t *iter, - bson_value_t *value, - bson_error_t *error) -{ - BSON_UNUSED (client); - - if (BSON_ITER_HOLDS_UTF8 (iter) || BSON_ITER_HOLDS_DOCUMENT (iter)) { - bson_value_copy (bson_iter_value ((bson_iter_t *) iter), value); - return true; - } - - CONVERSION_ERR ("The hint option must be a string or document"); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-read-prefs-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-read-prefs-private.h deleted file mode 100644 index a0d9d787a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-read-prefs-private.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_READ_PREFS_PRIVATE_H -#define MONGOC_READ_PREFS_PRIVATE_H - -#include - -#include "mongoc-cluster-private.h" -#include "mongoc-read-prefs.h" - - -BSON_BEGIN_DECLS - -struct _mongoc_read_prefs_t { - mongoc_read_mode_t mode; - bson_t tags; - int64_t max_staleness_seconds; - bson_t hedge; -}; - - -typedef struct _mongoc_assemble_query_result_t { - bson_t *assembled_query; - bool query_owned; - int32_t flags; -} mongoc_assemble_query_result_t; - - -#define ASSEMBLE_QUERY_RESULT_INIT \ - { \ - NULL, false, MONGOC_QUERY_NONE \ - } - -const char * -_mongoc_read_mode_as_str (mongoc_read_mode_t mode); - -void -assemble_query (const mongoc_read_prefs_t *read_prefs, - const mongoc_server_stream_t *server_stream, - const bson_t *query_bson, - int32_t initial_flags, - mongoc_assemble_query_result_t *result); - -void -assemble_query_result_cleanup (mongoc_assemble_query_result_t *result); - -bool -_mongoc_read_prefs_validate (const mongoc_read_prefs_t *read_prefs, - bson_error_t *error); - -#define IS_PREF_PRIMARY(_pref) \ - (!(_pref) || ((_pref)->mode == MONGOC_READ_PRIMARY)) - -BSON_END_DECLS - - -#endif /* MONGOC_READ_PREFS_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-read-prefs.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-read-prefs.c deleted file mode 100644 index 525f26b8f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-read-prefs.c +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-error.h" -#include "mongoc-read-prefs-private.h" -#include "mongoc-trace-private.h" - - -mongoc_read_prefs_t * -mongoc_read_prefs_new (mongoc_read_mode_t mode) -{ - mongoc_read_prefs_t *read_prefs; - - read_prefs = BSON_ALIGNED_ALLOC0 (mongoc_read_prefs_t); - read_prefs->mode = mode; - bson_init (&read_prefs->tags); - read_prefs->max_staleness_seconds = MONGOC_NO_MAX_STALENESS; - bson_init (&read_prefs->hedge); - - return read_prefs; -} - - -mongoc_read_mode_t -mongoc_read_prefs_get_mode (const mongoc_read_prefs_t *read_prefs) -{ - return read_prefs ? read_prefs->mode : MONGOC_READ_PRIMARY; -} - - -void -mongoc_read_prefs_set_mode (mongoc_read_prefs_t *read_prefs, - mongoc_read_mode_t mode) -{ - BSON_ASSERT (read_prefs); - BSON_ASSERT (mode <= MONGOC_READ_NEAREST); - - read_prefs->mode = mode; -} - - -const bson_t * -mongoc_read_prefs_get_tags (const mongoc_read_prefs_t *read_prefs) -{ - BSON_ASSERT (read_prefs); - return &read_prefs->tags; -} - - -void -mongoc_read_prefs_set_tags (mongoc_read_prefs_t *read_prefs, const bson_t *tags) -{ - BSON_ASSERT (read_prefs); - - bson_destroy (&read_prefs->tags); - - if (tags) { - bson_copy_to (tags, &read_prefs->tags); - } else { - bson_init (&read_prefs->tags); - } -} - - -void -mongoc_read_prefs_add_tag (mongoc_read_prefs_t *read_prefs, const bson_t *tag) -{ - bson_t empty = BSON_INITIALIZER; - char str[16]; - int key; - - BSON_ASSERT (read_prefs); - - key = bson_count_keys (&read_prefs->tags); - bson_snprintf (str, sizeof str, "%d", key); - - if (tag) { - bson_append_document (&read_prefs->tags, str, -1, tag); - } else { - bson_append_document (&read_prefs->tags, str, -1, &empty); - } - - bson_destroy (&empty); -} - - -int64_t -mongoc_read_prefs_get_max_staleness_seconds ( - const mongoc_read_prefs_t *read_prefs) -{ - BSON_ASSERT (read_prefs); - - return read_prefs->max_staleness_seconds; -} - - -void -mongoc_read_prefs_set_max_staleness_seconds (mongoc_read_prefs_t *read_prefs, - int64_t max_staleness_seconds) -{ - BSON_ASSERT (read_prefs); - - read_prefs->max_staleness_seconds = max_staleness_seconds; -} - - -const bson_t * -mongoc_read_prefs_get_hedge (const mongoc_read_prefs_t *read_prefs) -{ - BSON_ASSERT (read_prefs); - - return &read_prefs->hedge; -} - - -void -mongoc_read_prefs_set_hedge (mongoc_read_prefs_t *read_prefs, - const bson_t *hedge) -{ - BSON_ASSERT (read_prefs); - - bson_destroy (&read_prefs->hedge); - - if (hedge) { - bson_copy_to (hedge, &read_prefs->hedge); - } else { - bson_init (&read_prefs->hedge); - } -} - - -bool -mongoc_read_prefs_is_valid (const mongoc_read_prefs_t *read_prefs) -{ - BSON_ASSERT (read_prefs); - - /* - * Tags, maxStalenessSeconds, and hedge are not supported with PRIMARY mode. - */ - if (read_prefs->mode == MONGOC_READ_PRIMARY) { - if (!bson_empty (&read_prefs->tags) || - read_prefs->max_staleness_seconds != MONGOC_NO_MAX_STALENESS || - !bson_empty (&read_prefs->hedge)) { - return false; - } - } - - if (read_prefs->max_staleness_seconds != MONGOC_NO_MAX_STALENESS && - read_prefs->max_staleness_seconds <= 0) { - return false; - } - - - return true; -} - - -void -mongoc_read_prefs_destroy (mongoc_read_prefs_t *read_prefs) -{ - if (read_prefs) { - bson_destroy (&read_prefs->tags); - bson_destroy (&read_prefs->hedge); - bson_free (read_prefs); - } -} - - -mongoc_read_prefs_t * -mongoc_read_prefs_copy (const mongoc_read_prefs_t *read_prefs) -{ - mongoc_read_prefs_t *ret = NULL; - - if (read_prefs) { - ret = mongoc_read_prefs_new (read_prefs->mode); - bson_destroy (&ret->tags); - bson_copy_to (&read_prefs->tags, &ret->tags); - ret->max_staleness_seconds = read_prefs->max_staleness_seconds; - bson_destroy (&ret->hedge); - bson_copy_to (&read_prefs->hedge, &ret->hedge); - } - - return ret; -} - - -const char * -_mongoc_read_mode_as_str (mongoc_read_mode_t mode) -{ - switch (mode) { - case MONGOC_READ_PRIMARY: - return "primary"; - case MONGOC_READ_PRIMARY_PREFERRED: - return "primaryPreferred"; - case MONGOC_READ_SECONDARY: - return "secondary"; - case MONGOC_READ_SECONDARY_PREFERRED: - return "secondaryPreferred"; - case MONGOC_READ_NEAREST: - return "nearest"; - default: - return ""; - } -} - - -/* Update result with the read prefs, following Server Selection Spec. - * The driver must have discovered the server is a mongos. - */ -static void -_apply_read_preferences_mongos ( - const mongoc_read_prefs_t *read_prefs, - const bson_t *query_bson, - mongoc_assemble_query_result_t *result /* OUT */) -{ - mongoc_read_mode_t mode; - const bson_t *tags = NULL; - bson_t child; - const char *mode_str; - int64_t max_staleness_seconds = MONGOC_NO_MAX_STALENESS; - const bson_t *hedge = NULL; - - mode = mongoc_read_prefs_get_mode (read_prefs); - if (read_prefs) { - max_staleness_seconds = - mongoc_read_prefs_get_max_staleness_seconds (read_prefs); - - tags = mongoc_read_prefs_get_tags (read_prefs); - hedge = mongoc_read_prefs_get_hedge (read_prefs); - } - - /* Server Selection Spec says: - * - * For mode 'primary', drivers MUST NOT set the secondaryOk wire protocol - * flag and MUST NOT use $readPreference - * - * For mode 'secondary', drivers MUST set the secondaryOk wire protocol flag - * and MUST also use $readPreference - * - * For mode 'primaryPreferred', drivers MUST set the secondaryOk wire - * protocol flag and MUST also use $readPreference - * - * For mode 'secondaryPreferred', drivers MUST set the secondaryOk wire - * protocol flag. If the read preference contains a non-empty tag_sets - * parameter, maxStalenessSeconds is a positive integer, or the hedge - * parameter is non-empty, drivers MUST use $readPreference; otherwise, - * drivers MUST NOT use $readPreference - * - * For mode 'nearest', drivers MUST set the secondaryOk wire protocol flag - * and MUST also use $readPreference - */ - if (mode == MONGOC_READ_SECONDARY_PREFERRED && - (bson_empty0 (tags) && max_staleness_seconds <= 0 && - bson_empty0 (hedge))) { - result->flags |= MONGOC_QUERY_SECONDARY_OK; - - } else if (mode != MONGOC_READ_PRIMARY) { - result->flags |= MONGOC_QUERY_SECONDARY_OK; - - /* Server Selection Spec: "When any $ modifier is used, including the - * $readPreference modifier, the query MUST be provided using the $query - * modifier". - * - * This applies to commands, too. - */ - result->assembled_query = bson_new (); - result->query_owned = true; - - if (bson_has_field (query_bson, "$query")) { - bson_concat (result->assembled_query, query_bson); - } else { - bson_append_document ( - result->assembled_query, "$query", 6, query_bson); - } - - bson_append_document_begin ( - result->assembled_query, "$readPreference", 15, &child); - mode_str = _mongoc_read_mode_as_str (mode); - bson_append_utf8 (&child, "mode", 4, mode_str, -1); - if (!bson_empty0 (tags)) { - bson_append_array (&child, "tags", 4, tags); - } - - if (max_staleness_seconds != MONGOC_NO_MAX_STALENESS) { - bson_append_int64 ( - &child, "maxStalenessSeconds", 19, max_staleness_seconds); - } - - if (!bson_empty0 (hedge)) { - bson_append_document (&child, "hedge", 5, hedge); - } - - bson_append_document_end (result->assembled_query, &child); - } -} - -/* - *-------------------------------------------------------------------------- - * - * assemble_query -- - * - * Update @result based on @read_prefs, following the Server Selection - * Spec. - * - * Side effects: - * Sets @result->assembled_query and @result->flags. - * - * Note: - * This function, the mongoc_assemble_query_result_t struct, and all - * related functions are only used for find operations with OP_QUERY. - * Remove them once we have implemented exhaust cursors with OP_MSG in - * the server, and all previous server versions are EOL. - * - *-------------------------------------------------------------------------- - */ - -void -assemble_query (const mongoc_read_prefs_t *read_prefs, - const mongoc_server_stream_t *server_stream, - const bson_t *query_bson, - int32_t initial_flags, - mongoc_assemble_query_result_t *result /* OUT */) -{ - mongoc_server_description_type_t server_type; - - ENTRY; - - BSON_ASSERT (server_stream); - BSON_ASSERT (query_bson); - BSON_ASSERT (result); - - /* default values */ - result->assembled_query = (bson_t *) query_bson; - result->query_owned = false; - result->flags = initial_flags; - - server_type = server_stream->sd->type; - - switch (server_stream->topology_type) { - case MONGOC_TOPOLOGY_SINGLE: - if (server_type == MONGOC_SERVER_MONGOS) { - _apply_read_preferences_mongos (read_prefs, query_bson, result); - } else { - /* Server Selection Spec: for topology type single and server types - * besides mongos, "clients MUST always set the secondaryOk wire - * protocol flag on reads to ensure that any server type can handle the - * request." - */ - result->flags |= MONGOC_OP_QUERY_FLAG_SECONDARY_OK; - } - - break; - - case MONGOC_TOPOLOGY_RS_NO_PRIMARY: - case MONGOC_TOPOLOGY_RS_WITH_PRIMARY: - /* Server Selection Spec: for RS topology types, "For all read - * preferences modes except primary, clients MUST set the secondaryOk wire - * protocol flag to ensure that any suitable server can handle the - * request. Clients MUST NOT set the secondaryOk wire protocol flag if - * the read preference mode is primary. - */ - if (read_prefs && read_prefs->mode != MONGOC_READ_PRIMARY) { - result->flags |= MONGOC_OP_QUERY_FLAG_SECONDARY_OK; - } - - break; - - case MONGOC_TOPOLOGY_SHARDED: - case MONGOC_TOPOLOGY_LOAD_BALANCED: - _apply_read_preferences_mongos (read_prefs, query_bson, result); - break; - - case MONGOC_TOPOLOGY_UNKNOWN: - case MONGOC_TOPOLOGY_DESCRIPTION_TYPES: - default: - /* must not call _apply_read_preferences with unknown topology type */ - BSON_ASSERT (false); - } - - EXIT; -} - - -void -assemble_query_result_cleanup (mongoc_assemble_query_result_t *result) -{ - ENTRY; - - BSON_ASSERT (result); - - if (result->query_owned) { - bson_destroy (result->assembled_query); - } - - EXIT; -} - -bool -_mongoc_read_prefs_validate (const mongoc_read_prefs_t *read_prefs, - bson_error_t *error) -{ - if (read_prefs && !mongoc_read_prefs_is_valid (read_prefs)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid mongoc_read_prefs_t"); - return false; - } - return true; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-read-prefs.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-read-prefs.h deleted file mode 100644 index c378adbe5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-read-prefs.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_READ_PREFS_H -#define MONGOC_READ_PREFS_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-config.h" - -BSON_BEGIN_DECLS - - -#define MONGOC_NO_MAX_STALENESS -1 -#define MONGOC_SMALLEST_MAX_STALENESS_SECONDS 90 - -typedef struct _mongoc_read_prefs_t mongoc_read_prefs_t; - - -typedef enum { - /** Represents $readPreference.mode of 'primary' */ - MONGOC_READ_PRIMARY = (1 << 0), - /** Represents $readPreference.mode of 'secondary' */ - MONGOC_READ_SECONDARY = (1 << 1), - /** Represents $readPreference.mode of 'primaryPreferred' */ - MONGOC_READ_PRIMARY_PREFERRED = (1 << 2) | MONGOC_READ_PRIMARY, - /** Represents $readPreference.mode of 'secondaryPreferred' */ - MONGOC_READ_SECONDARY_PREFERRED = (1 << 2) | MONGOC_READ_SECONDARY, - /** Represents $readPreference.mode of 'nearest' */ - MONGOC_READ_NEAREST = (1 << 3) | MONGOC_READ_SECONDARY, -} mongoc_read_mode_t; - - -MONGOC_EXPORT (mongoc_read_prefs_t *) -mongoc_read_prefs_new (mongoc_read_mode_t read_mode) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_read_prefs_t *) -mongoc_read_prefs_copy (const mongoc_read_prefs_t *read_prefs) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_read_prefs_destroy (mongoc_read_prefs_t *read_prefs); -MONGOC_EXPORT (mongoc_read_mode_t) -mongoc_read_prefs_get_mode (const mongoc_read_prefs_t *read_prefs); -MONGOC_EXPORT (void) -mongoc_read_prefs_set_mode (mongoc_read_prefs_t *read_prefs, - mongoc_read_mode_t mode); -MONGOC_EXPORT (const bson_t *) -mongoc_read_prefs_get_tags (const mongoc_read_prefs_t *read_prefs); -MONGOC_EXPORT (void) -mongoc_read_prefs_set_tags (mongoc_read_prefs_t *read_prefs, - const bson_t *tags); -MONGOC_EXPORT (void) -mongoc_read_prefs_add_tag (mongoc_read_prefs_t *read_prefs, const bson_t *tag); -MONGOC_EXPORT (int64_t) -mongoc_read_prefs_get_max_staleness_seconds ( - const mongoc_read_prefs_t *read_prefs); -MONGOC_EXPORT (void) -mongoc_read_prefs_set_max_staleness_seconds (mongoc_read_prefs_t *read_prefs, - int64_t max_staleness_seconds); -MONGOC_EXPORT (const bson_t *) -mongoc_read_prefs_get_hedge (const mongoc_read_prefs_t *read_prefs); -MONGOC_EXPORT (void) -mongoc_read_prefs_set_hedge (mongoc_read_prefs_t *read_prefs, - const bson_t *hedge); -MONGOC_EXPORT (bool) -mongoc_read_prefs_is_valid (const mongoc_read_prefs_t *read_prefs); - - -BSON_END_DECLS - - -#endif /* MONGOC_READ_PREFS_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-rpc.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-rpc.c deleted file mode 100644 index 61edc4463..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-rpc.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc-rpc-private.h" - -#include "mongoc-counters-private.h" -#include "mongoc-trace-private.h" - - -bool -mcd_rpc_message_get_body (const mcd_rpc_message *rpc, bson_t *reply) -{ - switch (mcd_rpc_header_get_op_code (rpc)) { - case MONGOC_OP_CODE_MSG: { - const size_t sections_count = mcd_rpc_op_msg_get_sections_count (rpc); - - // Look for section kind 0. - for (size_t index = 0u; index < sections_count; ++index) { - switch (mcd_rpc_op_msg_section_get_kind (rpc, index)) { - case 0: { // Body. - const uint8_t *const body = - mcd_rpc_op_msg_section_get_body (rpc, index); - - const int32_t body_len = - bson_iter_int32_unsafe (&(bson_iter_t){.raw = body}); - - return bson_init_static (reply, body, (size_t) body_len); - } - - case 1: // Document Sequence. - continue; - - default: - // Validated by `mcd_rpc_message_from_data`. - BSON_UNREACHABLE ("invalid OP_MSG section kind"); - } - } - break; - } - - case MONGOC_OP_CODE_REPLY: { - if (mcd_rpc_op_reply_get_documents_len (rpc) < 1) { - return false; - } - - // Assume the first document in OP_REPLY is the body. - const uint8_t *const body = mcd_rpc_op_reply_get_documents (rpc); - - return bson_init_static ( - reply, - body, - (size_t) bson_iter_int32_unsafe (&(bson_iter_t){.raw = body})); - } - - default: - break; - } - - return false; -} - - -/* returns true if an error was found. */ -static bool -_parse_error_reply (const bson_t *doc, - bool check_wce, - uint32_t *code, - const char **msg) -{ - bson_iter_t iter; - bool found_error = false; - - ENTRY; - - BSON_ASSERT (doc); - BSON_ASSERT (code); - *code = 0; - - /* The server only returns real error codes as int32. - * But it may return as a double or int64 if a failpoint - * based on how it is configured to error. */ - if (bson_iter_init_find (&iter, doc, "code") && - BSON_ITER_HOLDS_NUMBER (&iter)) { - *code = (uint32_t) bson_iter_as_int64 (&iter); - BSON_ASSERT (*code); - found_error = true; - } - - if (bson_iter_init_find (&iter, doc, "errmsg") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - *msg = bson_iter_utf8 (&iter, NULL); - found_error = true; - } else if (bson_iter_init_find (&iter, doc, "$err") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - *msg = bson_iter_utf8 (&iter, NULL); - found_error = true; - } - - if (found_error) { - /* there was a command error */ - RETURN (true); - } - - if (check_wce) { - /* check for a write concern error */ - if (bson_iter_init_find (&iter, doc, "writeConcernError") && - BSON_ITER_HOLDS_DOCUMENT (&iter)) { - bson_iter_t child; - BSON_ASSERT (bson_iter_recurse (&iter, &child)); - if (bson_iter_find (&child, "code") && - BSON_ITER_HOLDS_NUMBER (&child)) { - *code = (uint32_t) bson_iter_as_int64 (&child); - BSON_ASSERT (*code); - found_error = true; - } - BSON_ASSERT (bson_iter_recurse (&iter, &child)); - if (bson_iter_find (&child, "errmsg") && - BSON_ITER_HOLDS_UTF8 (&child)) { - *msg = bson_iter_utf8 (&child, NULL); - found_error = true; - } - } - } - - RETURN (found_error); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cmd_check_ok -- - * - * Check if a server reply document is an error message. - * Optionally fill out a bson_error_t from the server error. - * Does *not* check for writeConcernError. - * - * Returns: - * false if @doc is an error message, true otherwise. - * - * Side effects: - * If @doc is an error reply and @error is not NULL, set its - * domain, code, and message. - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_cmd_check_ok (const bson_t *doc, - int32_t error_api_version, - bson_error_t *error) -{ - mongoc_error_domain_t domain = - error_api_version >= MONGOC_ERROR_API_VERSION_2 ? MONGOC_ERROR_SERVER - : MONGOC_ERROR_QUERY; - uint32_t code; - bson_iter_t iter; - const char *msg = "Unknown command error"; - - ENTRY; - - BSON_ASSERT (doc); - - if (bson_iter_init_find (&iter, doc, "ok") && bson_iter_as_bool (&iter)) { - /* no error */ - RETURN (true); - } - - if (!_parse_error_reply (doc, false /* check_wce */, &code, &msg)) { - RETURN (true); - } - - if (code == MONGOC_ERROR_PROTOCOL_ERROR || code == 13390) { - code = MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND; - } else if (code == 0) { - code = MONGOC_ERROR_QUERY_FAILURE; - } - - bson_set_error (error, domain, code, "%s", msg); - - /* there was a command error */ - RETURN (false); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_cmd_check_ok_no_wce -- - * - * Check if a server reply document is an error message. - * Optionally fill out a bson_error_t from the server error. - * If the response contains a writeConcernError, this is considered - * an error and returns false. - * - * Returns: - * false if @doc is an error message, true otherwise. - * - * Side effects: - * If @doc is an error reply and @error is not NULL, set its - * domain, code, and message. - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_cmd_check_ok_no_wce (const bson_t *doc, - int32_t error_api_version, - bson_error_t *error) -{ - mongoc_error_domain_t domain = - error_api_version >= MONGOC_ERROR_API_VERSION_2 ? MONGOC_ERROR_SERVER - : MONGOC_ERROR_QUERY; - uint32_t code; - const char *msg = "Unknown command error"; - - ENTRY; - - BSON_ASSERT (doc); - - if (!_parse_error_reply (doc, true /* check_wce */, &code, &msg)) { - RETURN (true); - } - - if (code == MONGOC_ERROR_PROTOCOL_ERROR || code == 13390) { - code = MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND; - } else if (code == 0) { - code = MONGOC_ERROR_QUERY_FAILURE; - } - - bson_set_error (error, domain, code, "%s", msg); - - /* there was a command error */ - RETURN (false); -} - - -/* helper function to parse error reply document to an OP_QUERY */ -static void -_mongoc_populate_query_error (const bson_t *doc, - int32_t error_api_version, - bson_error_t *error) -{ - mongoc_error_domain_t domain = - error_api_version >= MONGOC_ERROR_API_VERSION_2 ? MONGOC_ERROR_SERVER - : MONGOC_ERROR_QUERY; - uint32_t code = MONGOC_ERROR_QUERY_FAILURE; - bson_iter_t iter; - const char *msg = "Unknown query failure"; - - ENTRY; - - BSON_ASSERT (doc); - - if (bson_iter_init_find (&iter, doc, "code") && - BSON_ITER_HOLDS_NUMBER (&iter)) { - code = (uint32_t) bson_iter_as_int64 (&iter); - BSON_ASSERT (code); - } - - if (bson_iter_init_find (&iter, doc, "$err") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - msg = bson_iter_utf8 (&iter, NULL); - } - - bson_set_error (error, domain, code, "%s", msg); - - EXIT; -} - -bool -mcd_rpc_message_check_ok (mcd_rpc_message *rpc, - int32_t error_api_version, - bson_error_t *error /* OUT */, - bson_t *error_doc /* OUT */) -{ - BSON_ASSERT (rpc); - - ENTRY; - - if (mcd_rpc_header_get_op_code (rpc) != MONGOC_OP_CODE_REPLY) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "Received rpc other than OP_REPLY."); - RETURN (false); - } - - const int32_t flags = mcd_rpc_op_reply_get_response_flags (rpc); - - if (flags & MONGOC_OP_REPLY_RESPONSE_FLAG_QUERY_FAILURE) { - bson_t body; - - if (mcd_rpc_message_get_body (rpc, &body)) { - _mongoc_populate_query_error (&body, error_api_version, error); - - if (error_doc) { - bson_destroy (error_doc); - bson_copy_to (&body, error_doc); - } - - bson_destroy (&body); - } else { - bson_set_error (error, - MONGOC_ERROR_QUERY, - MONGOC_ERROR_QUERY_FAILURE, - "Unknown query failure."); - } - - RETURN (false); - } - - if (flags & MONGOC_OP_REPLY_RESPONSE_FLAG_CURSOR_NOT_FOUND) { - bson_set_error (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "The cursor is invalid or has expired."); - - RETURN (false); - } - - - RETURN (true); -} - -void -mcd_rpc_message_egress (const mcd_rpc_message *rpc) -{ - // `mcd_rpc_message_egress` is expected to be called after - // `mcd_rpc_message_to_iovecs`, which converts the opCode field to - // little endian. - int32_t op_code = mcd_rpc_header_get_op_code (rpc); - op_code = bson_iter_int32_unsafe ( - &(bson_iter_t){.raw = (const uint8_t *) &op_code}); - - if (op_code == MONGOC_OP_CODE_COMPRESSED) { - mongoc_counter_op_egress_compressed_inc (); - mongoc_counter_op_egress_total_inc (); - - op_code = mcd_rpc_op_compressed_get_original_opcode (rpc); - op_code = bson_iter_int32_unsafe ( - &(bson_iter_t){.raw = (const uint8_t *) &op_code}); - } - - switch (op_code) { - case MONGOC_OP_CODE_COMPRESSED: - BSON_UNREACHABLE ("invalid opcode (double compression?!)"); - break; - - case MONGOC_OP_CODE_MSG: - mongoc_counter_op_egress_msg_inc (); - mongoc_counter_op_egress_total_inc (); - break; - - case MONGOC_OP_CODE_REPLY: - BSON_UNREACHABLE ("unexpected OP_REPLY egress"); - break; - - case MONGOC_OP_CODE_UPDATE: - mongoc_counter_op_egress_update_inc (); - mongoc_counter_op_egress_total_inc (); - break; - - case MONGOC_OP_CODE_INSERT: - mongoc_counter_op_egress_insert_inc (); - mongoc_counter_op_egress_total_inc (); - break; - - case MONGOC_OP_CODE_QUERY: - mongoc_counter_op_egress_query_inc (); - mongoc_counter_op_egress_total_inc (); - break; - - case MONGOC_OP_CODE_GET_MORE: - mongoc_counter_op_egress_getmore_inc (); - mongoc_counter_op_egress_total_inc (); - break; - - case MONGOC_OP_CODE_DELETE: - mongoc_counter_op_egress_delete_inc (); - mongoc_counter_op_egress_total_inc (); - break; - - case MONGOC_OP_CODE_KILL_CURSORS: - mongoc_counter_op_egress_killcursors_inc (); - mongoc_counter_op_egress_total_inc (); - break; - - default: - BSON_UNREACHABLE ("invalid opcode"); - } -} - -void -mcd_rpc_message_ingress (const mcd_rpc_message *rpc) -{ - // `mcd_rpc_message_ingress` is expected be called after - // `mcd_rpc_message_from_data`, which converts the opCode field to native - // endian. - int32_t op_code = mcd_rpc_header_get_op_code (rpc); - - if (op_code == MONGOC_OP_CODE_COMPRESSED) { - mongoc_counter_op_ingress_compressed_inc (); - mongoc_counter_op_ingress_total_inc (); - - op_code = mcd_rpc_op_compressed_get_original_opcode (rpc); - } - - switch (op_code) { - case MONGOC_OP_CODE_COMPRESSED: - BSON_UNREACHABLE ("invalid opcode (double compression?!)"); - break; - - case MONGOC_OP_CODE_MSG: - mongoc_counter_op_ingress_msg_inc (); - mongoc_counter_op_ingress_total_inc (); - break; - - case MONGOC_OP_CODE_REPLY: - mongoc_counter_op_ingress_reply_inc (); - mongoc_counter_op_ingress_total_inc (); - break; - - case MONGOC_OP_CODE_UPDATE: - BSON_UNREACHABLE ("unexpected OP_UPDATE ingress"); - break; - - case MONGOC_OP_CODE_INSERT: - BSON_UNREACHABLE ("unexpected OP_INSERT ingress"); - break; - - case MONGOC_OP_CODE_QUERY: - BSON_UNREACHABLE ("unexpected OP_QUERY ingress"); - break; - - case MONGOC_OP_CODE_GET_MORE: - BSON_UNREACHABLE ("unexpected OP_GET_MORE ingress"); - break; - - case MONGOC_OP_CODE_DELETE: - BSON_UNREACHABLE ("unexpected OP_DELETE ingress"); - break; - - case MONGOC_OP_CODE_KILL_CURSORS: - BSON_UNREACHABLE ("unexpected OP_KILL_CURSORS ingress"); - break; - - default: - BSON_UNREACHABLE ("invalid opcode"); - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-sasl.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-sasl.c deleted file mode 100644 index a7c92edaa..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-sasl.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2017 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SASL -#include "mongoc-sasl-private.h" -#include "mongoc-util-private.h" - -#include "mongoc-trace-private.h" -#include "mongoc-change-stream-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "SASL" - -void -_mongoc_sasl_set_user (mongoc_sasl_t *sasl, const char *user) -{ - BSON_ASSERT (sasl); - - bson_free (sasl->user); - sasl->user = user ? bson_strdup (user) : NULL; -} - - -void -_mongoc_sasl_set_pass (mongoc_sasl_t *sasl, const char *pass) -{ - BSON_ASSERT (sasl); - - bson_free (sasl->pass); - sasl->pass = pass ? bson_strdup (pass) : NULL; -} - - -void -_mongoc_sasl_set_service_host (mongoc_sasl_t *sasl, const char *service_host) -{ - BSON_ASSERT (sasl); - - bson_free (sasl->service_host); - sasl->service_host = service_host ? bson_strdup (service_host) : NULL; -} - - -void -_mongoc_sasl_set_service_name (mongoc_sasl_t *sasl, const char *service_name) -{ - BSON_ASSERT (sasl); - - bson_free (sasl->service_name); - sasl->service_name = service_name ? bson_strdup (service_name) : NULL; -} - - -void -_mongoc_sasl_set_properties (mongoc_sasl_t *sasl, const mongoc_uri_t *uri) -{ - const bson_t *options; - bson_iter_t iter; - bson_t properties; - const char *service_name = NULL; - bool canonicalize = false; - - _mongoc_sasl_set_pass(sasl, mongoc_uri_get_password(uri)); - _mongoc_sasl_set_user(sasl, mongoc_uri_get_username(uri)); - - options = mongoc_uri_get_options (uri); - - if (!mongoc_uri_get_mechanism_properties (uri, &properties)) { - bson_init (&properties); - } - - if (bson_iter_init_find_case ( - &iter, options, MONGOC_URI_GSSAPISERVICENAME) && - BSON_ITER_HOLDS_UTF8 (&iter)) { - service_name = bson_iter_utf8 (&iter, NULL); - } - - if (bson_iter_init_find_case (&iter, &properties, "SERVICE_NAME") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - /* newer "authMechanismProperties" URI syntax takes precedence */ - service_name = bson_iter_utf8 (&iter, NULL); - } - - _mongoc_sasl_set_service_name (sasl, service_name); - - /* - * Driver Authentication Spec: "Drivers MAY allow the user to request - * canonicalization of the hostname. This might be required when the hosts - * report different hostnames than what is used in the kerberos database. - * The default is "false". - * - * Some underlying GSSAPI layers will do this for us, but can be disabled in - * their config (krb.conf). - * - * See CDRIVER-323 for more information. - */ - if (bson_iter_init_find_case ( - &iter, options, MONGOC_URI_CANONICALIZEHOSTNAME) && - BSON_ITER_HOLDS_BOOL (&iter)) { - canonicalize = bson_iter_bool (&iter); - } - - if (bson_iter_init_find_case ( - &iter, &properties, "CANONICALIZE_HOST_NAME") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - /* newer "authMechanismProperties" URI syntax takes precedence */ - canonicalize = !strcasecmp (bson_iter_utf8 (&iter, NULL), "true"); - } - - sasl->canonicalize_host_name = canonicalize; - - bson_destroy (&properties); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_sasl_get_canonicalized_name -- - * - * Query the node to get the canonicalized name. This may happen if - * the node has been accessed via an alias. - * - * The gssapi code will use this if canonicalizeHostname is true. - * - * Some underlying layers of krb might do this for us, but they can - * be disabled in krb.conf. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -_mongoc_sasl_get_canonicalized_name (mongoc_stream_t *node_stream, /* IN */ - char *name, /* OUT */ - size_t namelen) /* OUT */ -{ - mongoc_stream_t *stream; - mongoc_socket_t *sock = NULL; - char *canonicalized; - - ENTRY; - - BSON_ASSERT (node_stream); - BSON_ASSERT (name); - - stream = mongoc_stream_get_root_stream (node_stream); - BSON_ASSERT (stream); - - if (stream->type == MONGOC_STREAM_SOCKET) { - sock = - mongoc_stream_socket_get_socket ((mongoc_stream_socket_t *) stream); - if (sock) { - canonicalized = mongoc_socket_getnameinfo (sock); - if (canonicalized) { - bson_snprintf (name, namelen, "%s", canonicalized); - bson_free (canonicalized); - RETURN (true); - } - } - } - - RETURN (false); -} -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-scram-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-scram-private.h deleted file mode 100644 index 6b1ca1363..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-scram-private.h +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - - -#ifndef MONGOC_SCRAM_PRIVATE_H -#define MONGOC_SCRAM_PRIVATE_H - - -#include -#include "mongoc-crypto-private.h" - - -BSON_BEGIN_DECLS - -#define MONGOC_SCRAM_SHA_1_HASH_SIZE 20 -#define MONGOC_SCRAM_SHA_256_HASH_SIZE 32 -/* SCRAM-SHA-1 uses a hash size of 20, and SCRAM-SHA-256 uses a hash size - * of 32. Stack allocations should be large enough for either. */ -#define MONGOC_SCRAM_HASH_MAX_SIZE MONGOC_SCRAM_SHA_256_HASH_SIZE - -#define MONGOC_SCRAM_B64_ENCODED_SIZE(n) (2 * n) - -#define MONGOC_SCRAM_B64_HASH_MAX_SIZE \ - MONGOC_SCRAM_B64_ENCODED_SIZE (MONGOC_SCRAM_HASH_MAX_SIZE) - -enum { - /* It is unlikely that there will be more than 64 different user accounts - * used in a single process */ - MONGOC_SCRAM_CACHE_SIZE = 64, -}; - -typedef struct _mongoc_scram_t { - int step; - char *user; - char *pass; - char hashed_password[MONGOC_SCRAM_HASH_MAX_SIZE]; - uint8_t decoded_salt[MONGOC_SCRAM_B64_HASH_MAX_SIZE]; - uint32_t iterations; - uint8_t client_key[MONGOC_SCRAM_HASH_MAX_SIZE]; - uint8_t server_key[MONGOC_SCRAM_HASH_MAX_SIZE]; - uint8_t salted_password[MONGOC_SCRAM_HASH_MAX_SIZE]; - char encoded_nonce[48]; - int32_t encoded_nonce_len; - uint8_t *auth_message; - uint32_t auth_messagemax; - uint32_t auth_messagelen; -#ifdef MONGOC_ENABLE_CRYPTO - mongoc_crypto_t crypto; -#endif -} mongoc_scram_t; - -#ifdef MONGOC_ENABLE_CRYPTO -void -_mongoc_scram_init (mongoc_scram_t *scram, mongoc_crypto_hash_algorithm_t algo); -#endif - -void -_mongoc_scram_set_pass (mongoc_scram_t *scram, const char *pass); - -void -_mongoc_scram_set_user (mongoc_scram_t *scram, const char *user); - -void -_mongoc_scram_set_server_key (mongoc_scram_t *scram, - const uint8_t *server_key, - size_t len); - -void -_mongoc_scram_set_salted_password (mongoc_scram_t *scram, - const uint8_t *salted_password, - size_t len); - -void -_mongoc_scram_destroy (mongoc_scram_t *scram); - -bool -_mongoc_scram_step (mongoc_scram_t *scram, - const uint8_t *inbuf, - uint32_t inbuflen, - uint8_t *outbuf, - uint32_t outbufmax, - uint32_t *outbuflen, - bson_error_t *error); - -/* returns false if this string does not need SASLPrep. It returns true - * conservatively, if str might need to be SASLPrep'ed. */ -bool -_mongoc_sasl_prep_required (const char *str); - -/* returns the output of SASLPrep as a new string which must be freed. Returns - * null on error and sets err. */ -char * -_mongoc_sasl_prep (const char *in_utf8, bson_error_t *err); - -/* returns the byte length of the first UTF-8 code point in `s`. - * _mongoc_utf8_char_length is exposed for testing */ -size_t -_mongoc_utf8_char_length (const char *s); - -/* returns the byte length of the UTF-8 string. Returns -1 if `s` is not a valid - * UTF-8 string. - * _mongoc_utf8_string_length is exposed for testing. */ -ssize_t -_mongoc_utf8_string_length (const char *s); - -/* returns the first Unicode code point in `c`. Returns 0 if length is 0. - * `c` must be a valid UTF-8 string. - * _mongoc_utf8_get_first_code_point is exposed for testing. */ -uint32_t -_mongoc_utf8_get_first_code_point (const char *c, size_t length); - -/* the tables below all come from RFC 3454. They are all range tables, with - * value 2*n being the lower bound, and value 2*n + 1 being the upper bound. - * Both bounds are exclusive. - */ - -/* A.1 Unassigned code points in Unicode 3.2 - * these characters are not allowed for SASLPrep - */ -static const uint32_t unassigned_codepoint_ranges[] = { - 0x0221, 0x0221, 0x0234, 0x024F, 0x02AE, 0x02AF, 0x02EF, 0x02FF, - 0x0350, 0x035F, 0x0370, 0x0373, 0x0376, 0x0379, 0x037B, 0x037D, - 0x037F, 0x0383, 0x038B, 0x038B, 0x038D, 0x038D, 0x03A2, 0x03A2, - 0x03CF, 0x03CF, 0x03F7, 0x03FF, 0x0487, 0x0487, 0x04CF, 0x04CF, - 0x04F6, 0x04F7, 0x04FA, 0x04FF, 0x0510, 0x0530, 0x0557, 0x0558, - 0x0560, 0x0560, 0x0588, 0x0588, 0x058B, 0x0590, 0x05A2, 0x05A2, - 0x05BA, 0x05BA, 0x05C5, 0x05CF, 0x05EB, 0x05EF, 0x05F5, 0x060B, - 0x060D, 0x061A, 0x061C, 0x061E, 0x0620, 0x0620, 0x063B, 0x063F, - 0x0656, 0x065F, 0x06EE, 0x06EF, 0x06FF, 0x06FF, 0x070E, 0x070E, - 0x072D, 0x072F, 0x074B, 0x077F, 0x07B2, 0x0900, 0x0904, 0x0904, - 0x093A, 0x093B, 0x094E, 0x094F, 0x0955, 0x0957, 0x0971, 0x0980, - 0x0984, 0x0984, 0x098D, 0x098E, 0x0991, 0x0992, 0x09A9, 0x09A9, - 0x09B1, 0x09B1, 0x09B3, 0x09B5, 0x09BA, 0x09BB, 0x09BD, 0x09BD, - 0x09C5, 0x09C6, 0x09C9, 0x09CA, 0x09CE, 0x09D6, 0x09D8, 0x09DB, - 0x09DE, 0x09DE, 0x09E4, 0x09E5, 0x09FB, 0x0A01, 0x0A03, 0x0A04, - 0x0A0B, 0x0A0E, 0x0A11, 0x0A12, 0x0A29, 0x0A29, 0x0A31, 0x0A31, - 0x0A34, 0x0A34, 0x0A37, 0x0A37, 0x0A3A, 0x0A3B, 0x0A3D, 0x0A3D, - 0x0A43, 0x0A46, 0x0A49, 0x0A4A, 0x0A4E, 0x0A58, 0x0A5D, 0x0A5D, - 0x0A5F, 0x0A65, 0x0A75, 0x0A80, 0x0A84, 0x0A84, 0x0A8C, 0x0A8C, - 0x0A8E, 0x0A8E, 0x0A92, 0x0A92, 0x0AA9, 0x0AA9, 0x0AB1, 0x0AB1, - 0x0AB4, 0x0AB4, 0x0ABA, 0x0ABB, 0x0AC6, 0x0AC6, 0x0ACA, 0x0ACA, - 0x0ACE, 0x0ACF, 0x0AD1, 0x0ADF, 0x0AE1, 0x0AE5, 0x0AF0, 0x0B00, - 0x0B04, 0x0B04, 0x0B0D, 0x0B0E, 0x0B11, 0x0B12, 0x0B29, 0x0B29, - 0x0B31, 0x0B31, 0x0B34, 0x0B35, 0x0B3A, 0x0B3B, 0x0B44, 0x0B46, - 0x0B49, 0x0B4A, 0x0B4E, 0x0B55, 0x0B58, 0x0B5B, 0x0B5E, 0x0B5E, - 0x0B62, 0x0B65, 0x0B71, 0x0B81, 0x0B84, 0x0B84, 0x0B8B, 0x0B8D, - 0x0B91, 0x0B91, 0x0B96, 0x0B98, 0x0B9B, 0x0B9B, 0x0B9D, 0x0B9D, - 0x0BA0, 0x0BA2, 0x0BA5, 0x0BA7, 0x0BAB, 0x0BAD, 0x0BB6, 0x0BB6, - 0x0BBA, 0x0BBD, 0x0BC3, 0x0BC5, 0x0BC9, 0x0BC9, 0x0BCE, 0x0BD6, - 0x0BD8, 0x0BE6, 0x0BF3, 0x0C00, 0x0C04, 0x0C04, 0x0C0D, 0x0C0D, - 0x0C11, 0x0C11, 0x0C29, 0x0C29, 0x0C34, 0x0C34, 0x0C3A, 0x0C3D, - 0x0C45, 0x0C45, 0x0C49, 0x0C49, 0x0C4E, 0x0C54, 0x0C57, 0x0C5F, - 0x0C62, 0x0C65, 0x0C70, 0x0C81, 0x0C84, 0x0C84, 0x0C8D, 0x0C8D, - 0x0C91, 0x0C91, 0x0CA9, 0x0CA9, 0x0CB4, 0x0CB4, 0x0CBA, 0x0CBD, - 0x0CC5, 0x0CC5, 0x0CC9, 0x0CC9, 0x0CCE, 0x0CD4, 0x0CD7, 0x0CDD, - 0x0CDF, 0x0CDF, 0x0CE2, 0x0CE5, 0x0CF0, 0x0D01, 0x0D04, 0x0D04, - 0x0D0D, 0x0D0D, 0x0D11, 0x0D11, 0x0D29, 0x0D29, 0x0D3A, 0x0D3D, - 0x0D44, 0x0D45, 0x0D49, 0x0D49, 0x0D4E, 0x0D56, 0x0D58, 0x0D5F, - 0x0D62, 0x0D65, 0x0D70, 0x0D81, 0x0D84, 0x0D84, 0x0D97, 0x0D99, - 0x0DB2, 0x0DB2, 0x0DBC, 0x0DBC, 0x0DBE, 0x0DBF, 0x0DC7, 0x0DC9, - 0x0DCB, 0x0DCE, 0x0DD5, 0x0DD5, 0x0DD7, 0x0DD7, 0x0DE0, 0x0DF1, - 0x0DF5, 0x0E00, 0x0E3B, 0x0E3E, 0x0E5C, 0x0E80, 0x0E83, 0x0E83, - 0x0E85, 0x0E86, 0x0E89, 0x0E89, 0x0E8B, 0x0E8C, 0x0E8E, 0x0E93, - 0x0E98, 0x0E98, 0x0EA0, 0x0EA0, 0x0EA4, 0x0EA4, 0x0EA6, 0x0EA6, - 0x0EA8, 0x0EA9, 0x0EAC, 0x0EAC, 0x0EBA, 0x0EBA, 0x0EBE, 0x0EBF, - 0x0EC5, 0x0EC5, 0x0EC7, 0x0EC7, 0x0ECE, 0x0ECF, 0x0EDA, 0x0EDB, - 0x0EDE, 0x0EFF, 0x0F48, 0x0F48, 0x0F6B, 0x0F70, 0x0F8C, 0x0F8F, - 0x0F98, 0x0F98, 0x0FBD, 0x0FBD, 0x0FCD, 0x0FCE, 0x0FD0, 0x0FFF, - 0x1022, 0x1022, 0x1028, 0x1028, 0x102B, 0x102B, 0x1033, 0x1035, - 0x103A, 0x103F, 0x105A, 0x109F, 0x10C6, 0x10CF, 0x10F9, 0x10FA, - 0x10FC, 0x10FF, 0x115A, 0x115E, 0x11A3, 0x11A7, 0x11FA, 0x11FF, - 0x1207, 0x1207, 0x1247, 0x1247, 0x1249, 0x1249, 0x124E, 0x124F, - 0x1257, 0x1257, 0x1259, 0x1259, 0x125E, 0x125F, 0x1287, 0x1287, - 0x1289, 0x1289, 0x128E, 0x128F, 0x12AF, 0x12AF, 0x12B1, 0x12B1, - 0x12B6, 0x12B7, 0x12BF, 0x12BF, 0x12C1, 0x12C1, 0x12C6, 0x12C7, - 0x12CF, 0x12CF, 0x12D7, 0x12D7, 0x12EF, 0x12EF, 0x130F, 0x130F, - 0x1311, 0x1311, 0x1316, 0x1317, 0x131F, 0x131F, 0x1347, 0x1347, - 0x135B, 0x1360, 0x137D, 0x139F, 0x13F5, 0x1400, 0x1677, 0x167F, - 0x169D, 0x169F, 0x16F1, 0x16FF, 0x170D, 0x170D, 0x1715, 0x171F, - 0x1737, 0x173F, 0x1754, 0x175F, 0x176D, 0x176D, 0x1771, 0x1771, - 0x1774, 0x177F, 0x17DD, 0x17DF, 0x17EA, 0x17FF, 0x180F, 0x180F, - 0x181A, 0x181F, 0x1878, 0x187F, 0x18AA, 0x1DFF, 0x1E9C, 0x1E9F, - 0x1EFA, 0x1EFF, 0x1F16, 0x1F17, 0x1F1E, 0x1F1F, 0x1F46, 0x1F47, - 0x1F4E, 0x1F4F, 0x1F58, 0x1F58, 0x1F5A, 0x1F5A, 0x1F5C, 0x1F5C, - 0x1F5E, 0x1F5E, 0x1F7E, 0x1F7F, 0x1FB5, 0x1FB5, 0x1FC5, 0x1FC5, - 0x1FD4, 0x1FD5, 0x1FDC, 0x1FDC, 0x1FF0, 0x1FF1, 0x1FF5, 0x1FF5, - 0x1FFF, 0x1FFF, 0x2053, 0x2056, 0x2058, 0x205E, 0x2064, 0x2069, - 0x2072, 0x2073, 0x208F, 0x209F, 0x20B2, 0x20CF, 0x20EB, 0x20FF, - 0x213B, 0x213C, 0x214C, 0x2152, 0x2184, 0x218F, 0x23CF, 0x23FF, - 0x2427, 0x243F, 0x244B, 0x245F, 0x24FF, 0x24FF, 0x2614, 0x2615, - 0x2618, 0x2618, 0x267E, 0x267F, 0x268A, 0x2700, 0x2705, 0x2705, - 0x270A, 0x270B, 0x2728, 0x2728, 0x274C, 0x274C, 0x274E, 0x274E, - 0x2753, 0x2755, 0x2757, 0x2757, 0x275F, 0x2760, 0x2795, 0x2797, - 0x27B0, 0x27B0, 0x27BF, 0x27CF, 0x27EC, 0x27EF, 0x2B00, 0x2E7F, - 0x2E9A, 0x2E9A, 0x2EF4, 0x2EFF, 0x2FD6, 0x2FEF, 0x2FFC, 0x2FFF, - 0x3040, 0x3040, 0x3097, 0x3098, 0x3100, 0x3104, 0x312D, 0x3130, - 0x318F, 0x318F, 0x31B8, 0x31EF, 0x321D, 0x321F, 0x3244, 0x3250, - 0x327C, 0x327E, 0x32CC, 0x32CF, 0x32FF, 0x32FF, 0x3377, 0x337A, - 0x33DE, 0x33DF, 0x33FF, 0x33FF, 0x4DB6, 0x4DFF, 0x9FA6, 0x9FFF, - 0xA48D, 0xA48F, 0xA4C7, 0xABFF, 0xD7A4, 0xD7FF, 0xFA2E, 0xFA2F, - 0xFA6B, 0xFAFF, 0xFB07, 0xFB12, 0xFB18, 0xFB1C, 0xFB37, 0xFB37, - 0xFB3D, 0xFB3D, 0xFB3F, 0xFB3F, 0xFB42, 0xFB42, 0xFB45, 0xFB45, - 0xFBB2, 0xFBD2, 0xFD40, 0xFD4F, 0xFD90, 0xFD91, 0xFDC8, 0xFDCF, - 0xFDFD, 0xFDFF, 0xFE10, 0xFE1F, 0xFE24, 0xFE2F, 0xFE47, 0xFE48, - 0xFE53, 0xFE53, 0xFE67, 0xFE67, 0xFE6C, 0xFE6F, 0xFE75, 0xFE75, - 0xFEFD, 0xFEFE, 0xFF00, 0xFF00, 0xFFBF, 0xFFC1, 0xFFC8, 0xFFC9, - 0xFFD0, 0xFFD1, 0xFFD8, 0xFFD9, 0xFFDD, 0xFFDF, 0xFFE7, 0xFFE7, - 0xFFEF, 0xFFF8, 0x10000, 0x102FF, 0x1031F, 0x1031F, 0x10324, 0x1032F, - 0x1034B, 0x103FF, 0x10426, 0x10427, 0x1044E, 0x1CFFF, 0x1D0F6, 0x1D0FF, - 0x1D127, 0x1D129, 0x1D1DE, 0x1D3FF, 0x1D455, 0x1D455, 0x1D49D, 0x1D49D, - 0x1D4A0, 0x1D4A1, 0x1D4A3, 0x1D4A4, 0x1D4A7, 0x1D4A8, 0x1D4AD, 0x1D4AD, - 0x1D4BA, 0x1D4BA, 0x1D4BC, 0x1D4BC, 0x1D4C1, 0x1D4C1, 0x1D4C4, 0x1D4C4, - 0x1D506, 0x1D506, 0x1D50B, 0x1D50C, 0x1D515, 0x1D515, 0x1D51D, 0x1D51D, - 0x1D53A, 0x1D53A, 0x1D53F, 0x1D53F, 0x1D545, 0x1D545, 0x1D547, 0x1D549, - 0x1D551, 0x1D551, 0x1D6A4, 0x1D6A7, 0x1D7CA, 0x1D7CD, 0x1D800, 0x1FFFD, - 0x2A6D7, 0x2F7FF, 0x2FA1E, 0x2FFFD, 0x30000, 0x3FFFD, 0x40000, 0x4FFFD, - 0x50000, 0x5FFFD, 0x60000, 0x6FFFD, 0x70000, 0x7FFFD, 0x80000, 0x8FFFD, - 0x90000, 0x9FFFD, 0xA0000, 0xAFFFD, 0xB0000, 0xBFFFD, 0xC0000, 0xCFFFD, - 0xD0000, 0xDFFFD, 0xE0000, 0xE0000, 0xE0002, 0xE001F, 0xE0080, 0xEFFFD}; - -/* - * Table B.1 Commonly mapped to nothing - * these are all of the characters that will be mapped to nothing. - */ -static const uint32_t commonly_mapped_to_nothing_ranges[] = {0x00AD, - 0x00AD, - 0x034F, - 0x034F, - 0x1806, - 0x1806, - 0x180B, - 0x180D, - 0x200B, - 0x200D, - 0x2060, - 0x2060, - 0xFE00, - 0xFE0F, - 0xFEFF, - 0xFEFF}; - -/* - * Table C.1.2 Non-ASCII space characters - * these are all of the characters that will be mapped to the space character. - * (0x0020) - */ -static const uint32_t non_ascii_space_character_ranges[] = {0x00A0, - 0x00A0, - 0x1680, - 0x1680, - 0x2000, - 0x200B, - 0x202F, - 0x202F, - 0x205F, - 0x205F, - 0x3000, - 0x3000}; - -/* - * these are all of the characters that are "prohibited output" for SASLprep. - * The tables that they come from are listed. - */ -static const uint32_t prohibited_output_ranges[] = { - 0x0000, 0x001F, /* C.2.1 */ - 0x007F, 0x00A0, /* C.1.2, C.2.1, C.2.2 */ - 0x0340, 0x0341, /* C.8 */ - 0x06DD, 0x06DD, /* C.2.2 */ - 0x070F, 0x070F, /* C.2.2 */ - 0x1680, 0x1680, /* C.1.2 */ - 0x180E, 0x180E, /* C.2.2 */ - 0x2000, 0x200F, /* C.1.2, C.2.2, C.8 */ - 0x2028, 0x202F, /* C.1.2, C.2.2, C.8 */ - 0x205F, 0x2063, /* C.1.2, C.2.2 */ - 0x206A, 0x206F, /* C.2.2, C.8 */ - 0x2FF0, 0x2FFB, /* C.7 */ - 0x3000, 0x3000, /* C.1.2 */ - 0xD800, 0xF8FF, /* C.3, C.5 */ - 0xFDD0, 0xFDEF, /* C.4 */ - 0xFEFF, 0xFEFF, /* C.2.2 */ - 0xFFF9, 0xFFFF, /* C.2.2, C.4, C.6 */ - 0x1D173, 0x1D17A, /* C.2.2 */ - 0x1FFFE, 0x1FFFF, /* C.4 */ - 0x2FFFE, 0x2FFFF, /* C.4 */ - 0x3FFFE, 0x3FFFF, /* C.4 */ - 0x4FFFE, 0x4FFFF, /* C.4 */ - 0x5FFFE, 0x5FFFF, /* C.4 */ - 0x6FFFE, 0x6FFFF, /* C.4 */ - 0x7FFFE, 0x7FFFF, /* C.4 */ - 0x8FFFE, 0x8FFFF, /* C.4 */ - 0x9FFFE, 0x9FFFF, /* C.4 */ - 0xAFFFE, 0xAFFFF, /* C.4 */ - 0xBFFFE, 0xBFFFF, /* C.4 */ - 0xCFFFE, 0xCFFFF, /* C.4 */ - 0xDFFFE, 0xDFFFF, /* C.4 */ - 0xE0001, 0xE0001, /* C.9 */ - 0xE0020, 0xE007F, /* C.9 */ - 0xEFFFE, 0xEFFFF, /* C.4 */ - 0xF0000, 0xFFFFF, /* C.3, C.4 */ - 0x100000, 0x10FFFF /* C.3, C.4 */ -}; - -/* D.1 Characters with bidirectional property "R" or "AL" - * any string that contains one of these characters cannot contain a character - * with bidirectional property "L". - */ - -static const uint32_t RandALCat_bidi_ranges[] = { - 0x05BE, 0x05BE, 0x05C0, 0x05C0, 0x05C3, 0x05C3, 0x05D0, 0x05EA, 0x05F0, - 0x05F4, 0x061B, 0x061B, 0x061F, 0x061F, 0x0621, 0x063A, 0x0640, 0x064A, - 0x066D, 0x066F, 0x0671, 0x06D5, 0x06DD, 0x06DD, 0x06E5, 0x06E6, 0x06FA, - 0x06FE, 0x0700, 0x070D, 0x0710, 0x0710, 0x0712, 0x072C, 0x0780, 0x07A5, - 0x07B1, 0x07B1, 0x200F, 0x200F, 0xFB1D, 0xFB1D, 0xFB1F, 0xFB28, 0xFB2A, - 0xFB36, 0xFB38, 0xFB3C, 0xFB3E, 0xFB3E, 0xFB40, 0xFB41, 0xFB43, 0xFB44, - 0xFB46, 0xFBB1, 0xFBD3, 0xFD3D, 0xFD50, 0xFD8F, 0xFD92, 0xFDC7, 0xFDF0, - 0xFDFC, 0xFE70, 0xFE74, 0xFE76, 0xFEFC}; - -/* D.2 Characters with bidirectional property "L" - * any string that contains one of these characters cannot contain a character - * with bidirectional property "R" or "AL". - * */ -static const uint32_t LCat_bidi_ranges[] = { - 0x0041, 0x005A, 0x0061, 0x007A, 0x00AA, 0x00AA, 0x00B5, 0x00B5, - 0x00BA, 0x00BA, 0x00C0, 0x00D6, 0x00D8, 0x00F6, 0x00F8, 0x0220, - 0x0222, 0x0233, 0x0250, 0x02AD, 0x02B0, 0x02B8, 0x02BB, 0x02C1, - 0x02D0, 0x02D1, 0x02E0, 0x02E4, 0x02EE, 0x02EE, 0x037A, 0x037A, - 0x0386, 0x0386, 0x0388, 0x038A, 0x038C, 0x038C, 0x038E, 0x03A1, - 0x03A3, 0x03CE, 0x03D0, 0x03F5, 0x0400, 0x0482, 0x048A, 0x04CE, - 0x04D0, 0x04F5, 0x04F8, 0x04F9, 0x0500, 0x050F, 0x0531, 0x0556, - 0x0559, 0x055F, 0x0561, 0x0587, 0x0589, 0x0589, 0x0903, 0x0903, - 0x0905, 0x0939, 0x093D, 0x0940, 0x0949, 0x094C, 0x0950, 0x0950, - 0x0958, 0x0961, 0x0964, 0x0970, 0x0982, 0x0983, 0x0985, 0x098C, - 0x098F, 0x0990, 0x0993, 0x09A8, 0x09AA, 0x09B0, 0x09B2, 0x09B2, - 0x09B6, 0x09B9, 0x09BE, 0x09C0, 0x09C7, 0x09C8, 0x09CB, 0x09CC, - 0x09D7, 0x09D7, 0x09DC, 0x09DD, 0x09DF, 0x09E1, 0x09E6, 0x09F1, - 0x09F4, 0x09FA, 0x0A05, 0x0A0A, 0x0A0F, 0x0A10, 0x0A13, 0x0A28, - 0x0A2A, 0x0A30, 0x0A32, 0x0A33, 0x0A35, 0x0A36, 0x0A38, 0x0A39, - 0x0A3E, 0x0A40, 0x0A59, 0x0A5C, 0x0A5E, 0x0A5E, 0x0A66, 0x0A6F, - 0x0A72, 0x0A74, 0x0A83, 0x0A83, 0x0A85, 0x0A8B, 0x0A8D, 0x0A8D, - 0x0A8F, 0x0A91, 0x0A93, 0x0AA8, 0x0AAA, 0x0AB0, 0x0AB2, 0x0AB3, - 0x0AB5, 0x0AB9, 0x0ABD, 0x0AC0, 0x0AC9, 0x0AC9, 0x0ACB, 0x0ACC, - 0x0AD0, 0x0AD0, 0x0AE0, 0x0AE0, 0x0AE6, 0x0AEF, 0x0B02, 0x0B03, - 0x0B05, 0x0B0C, 0x0B0F, 0x0B10, 0x0B13, 0x0B28, 0x0B2A, 0x0B30, - 0x0B32, 0x0B33, 0x0B36, 0x0B39, 0x0B3D, 0x0B3E, 0x0B40, 0x0B40, - 0x0B47, 0x0B48, 0x0B4B, 0x0B4C, 0x0B57, 0x0B57, 0x0B5C, 0x0B5D, - 0x0B5F, 0x0B61, 0x0B66, 0x0B70, 0x0B83, 0x0B83, 0x0B85, 0x0B8A, - 0x0B8E, 0x0B90, 0x0B92, 0x0B95, 0x0B99, 0x0B9A, 0x0B9C, 0x0B9C, - 0x0B9E, 0x0B9F, 0x0BA3, 0x0BA4, 0x0BA8, 0x0BAA, 0x0BAE, 0x0BB5, - 0x0BB7, 0x0BB9, 0x0BBE, 0x0BBF, 0x0BC1, 0x0BC2, 0x0BC6, 0x0BC8, - 0x0BCA, 0x0BCC, 0x0BD7, 0x0BD7, 0x0BE7, 0x0BF2, 0x0C01, 0x0C03, - 0x0C05, 0x0C0C, 0x0C0E, 0x0C10, 0x0C12, 0x0C28, 0x0C2A, 0x0C33, - 0x0C35, 0x0C39, 0x0C41, 0x0C44, 0x0C60, 0x0C61, 0x0C66, 0x0C6F, - 0x0C82, 0x0C83, 0x0C85, 0x0C8C, 0x0C8E, 0x0C90, 0x0C92, 0x0CA8, - 0x0CAA, 0x0CB3, 0x0CB5, 0x0CB9, 0x0CBE, 0x0CBE, 0x0CC0, 0x0CC4, - 0x0CC7, 0x0CC8, 0x0CCA, 0x0CCB, 0x0CD5, 0x0CD6, 0x0CDE, 0x0CDE, - 0x0CE0, 0x0CE1, 0x0CE6, 0x0CEF, 0x0D02, 0x0D03, 0x0D05, 0x0D0C, - 0x0D0E, 0x0D10, 0x0D12, 0x0D28, 0x0D2A, 0x0D39, 0x0D3E, 0x0D40, - 0x0D46, 0x0D48, 0x0D4A, 0x0D4C, 0x0D57, 0x0D57, 0x0D60, 0x0D61, - 0x0D66, 0x0D6F, 0x0D82, 0x0D83, 0x0D85, 0x0D96, 0x0D9A, 0x0DB1, - 0x0DB3, 0x0DBB, 0x0DBD, 0x0DBD, 0x0DC0, 0x0DC6, 0x0DCF, 0x0DD1, - 0x0DD8, 0x0DDF, 0x0DF2, 0x0DF4, 0x0E01, 0x0E30, 0x0E32, 0x0E33, - 0x0E40, 0x0E46, 0x0E4F, 0x0E5B, 0x0E81, 0x0E82, 0x0E84, 0x0E84, - 0x0E87, 0x0E88, 0x0E8A, 0x0E8A, 0x0E8D, 0x0E8D, 0x0E94, 0x0E97, - 0x0E99, 0x0E9F, 0x0EA1, 0x0EA3, 0x0EA5, 0x0EA5, 0x0EA7, 0x0EA7, - 0x0EAA, 0x0EAB, 0x0EAD, 0x0EB0, 0x0EB2, 0x0EB3, 0x0EBD, 0x0EBD, - 0x0EC0, 0x0EC4, 0x0EC6, 0x0EC6, 0x0ED0, 0x0ED9, 0x0EDC, 0x0EDD, - 0x0F00, 0x0F17, 0x0F1A, 0x0F34, 0x0F36, 0x0F36, 0x0F38, 0x0F38, - 0x0F3E, 0x0F47, 0x0F49, 0x0F6A, 0x0F7F, 0x0F7F, 0x0F85, 0x0F85, - 0x0F88, 0x0F8B, 0x0FBE, 0x0FC5, 0x0FC7, 0x0FCC, 0x0FCF, 0x0FCF, - 0x1000, 0x1021, 0x1023, 0x1027, 0x1029, 0x102A, 0x102C, 0x102C, - 0x1031, 0x1031, 0x1038, 0x1038, 0x1040, 0x1057, 0x10A0, 0x10C5, - 0x10D0, 0x10F8, 0x10FB, 0x10FB, 0x1100, 0x1159, 0x115F, 0x11A2, - 0x11A8, 0x11F9, 0x1200, 0x1206, 0x1208, 0x1246, 0x1248, 0x1248, - 0x124A, 0x124D, 0x1250, 0x1256, 0x1258, 0x1258, 0x125A, 0x125D, - 0x1260, 0x1286, 0x1288, 0x1288, 0x128A, 0x128D, 0x1290, 0x12AE, - 0x12B0, 0x12B0, 0x12B2, 0x12B5, 0x12B8, 0x12BE, 0x12C0, 0x12C0, - 0x12C2, 0x12C5, 0x12C8, 0x12CE, 0x12D0, 0x12D6, 0x12D8, 0x12EE, - 0x12F0, 0x130E, 0x1310, 0x1310, 0x1312, 0x1315, 0x1318, 0x131E, - 0x1320, 0x1346, 0x1348, 0x135A, 0x1361, 0x137C, 0x13A0, 0x13F4, - 0x1401, 0x1676, 0x1681, 0x169A, 0x16A0, 0x16F0, 0x1700, 0x170C, - 0x170E, 0x1711, 0x1720, 0x1731, 0x1735, 0x1736, 0x1740, 0x1751, - 0x1760, 0x176C, 0x176E, 0x1770, 0x1780, 0x17B6, 0x17BE, 0x17C5, - 0x17C7, 0x17C8, 0x17D4, 0x17DA, 0x17DC, 0x17DC, 0x17E0, 0x17E9, - 0x1810, 0x1819, 0x1820, 0x1877, 0x1880, 0x18A8, 0x1E00, 0x1E9B, - 0x1EA0, 0x1EF9, 0x1F00, 0x1F15, 0x1F18, 0x1F1D, 0x1F20, 0x1F45, - 0x1F48, 0x1F4D, 0x1F50, 0x1F57, 0x1F59, 0x1F59, 0x1F5B, 0x1F5B, - 0x1F5D, 0x1F5D, 0x1F5F, 0x1F7D, 0x1F80, 0x1FB4, 0x1FB6, 0x1FBC, - 0x1FBE, 0x1FBE, 0x1FC2, 0x1FC4, 0x1FC6, 0x1FCC, 0x1FD0, 0x1FD3, - 0x1FD6, 0x1FDB, 0x1FE0, 0x1FEC, 0x1FF2, 0x1FF4, 0x1FF6, 0x1FFC, - 0x200E, 0x200E, 0x2071, 0x2071, 0x207F, 0x207F, 0x2102, 0x2102, - 0x2107, 0x2107, 0x210A, 0x2113, 0x2115, 0x2115, 0x2119, 0x211D, - 0x2124, 0x2124, 0x2126, 0x2126, 0x2128, 0x2128, 0x212A, 0x212D, - 0x212F, 0x2131, 0x2133, 0x2139, 0x213D, 0x213F, 0x2145, 0x2149, - 0x2160, 0x2183, 0x2336, 0x237A, 0x2395, 0x2395, 0x249C, 0x24E9, - 0x3005, 0x3007, 0x3021, 0x3029, 0x3031, 0x3035, 0x3038, 0x303C, - 0x3041, 0x3096, 0x309D, 0x309F, 0x30A1, 0x30FA, 0x30FC, 0x30FF, - 0x3105, 0x312C, 0x3131, 0x318E, 0x3190, 0x31B7, 0x31F0, 0x321C, - 0x3220, 0x3243, 0x3260, 0x327B, 0x327F, 0x32B0, 0x32C0, 0x32CB, - 0x32D0, 0x32FE, 0x3300, 0x3376, 0x337B, 0x33DD, 0x33E0, 0x33FE, - 0x3400, 0x4DB5, 0x4E00, 0x9FA5, 0xA000, 0xA48C, 0xAC00, 0xD7A3, - 0xD800, 0xFA2D, 0xFA30, 0xFA6A, 0xFB00, 0xFB06, 0xFB13, 0xFB17, - 0xFF21, 0xFF3A, 0xFF41, 0xFF5A, 0xFF66, 0xFFBE, 0xFFC2, 0xFFC7, - 0xFFCA, 0xFFCF, 0xFFD2, 0xFFD7, 0xFFDA, 0xFFDC, 0x10300, 0x1031E, - 0x10320, 0x10323, 0x10330, 0x1034A, 0x10400, 0x10425, 0x10428, 0x1044D, - 0x1D000, 0x1D0F5, 0x1D100, 0x1D126, 0x1D12A, 0x1D166, 0x1D16A, 0x1D172, - 0x1D183, 0x1D184, 0x1D18C, 0x1D1A9, 0x1D1AE, 0x1D1DD, 0x1D400, 0x1D454, - 0x1D456, 0x1D49C, 0x1D49E, 0x1D49F, 0x1D4A2, 0x1D4A2, 0x1D4A5, 0x1D4A6, - 0x1D4A9, 0x1D4AC, 0x1D4AE, 0x1D4B9, 0x1D4BB, 0x1D4BB, 0x1D4BD, 0x1D4C0, - 0x1D4C2, 0x1D4C3, 0x1D4C5, 0x1D505, 0x1D507, 0x1D50A, 0x1D50D, 0x1D514, - 0x1D516, 0x1D51C, 0x1D51E, 0x1D539, 0x1D53B, 0x1D53E, 0x1D540, 0x1D544, - 0x1D546, 0x1D546, 0x1D54A, 0x1D550, 0x1D552, 0x1D6A3, 0x1D6A8, 0x1D7C9, - 0x20000, 0x2A6D6, 0x2F800, 0x2FA1D, 0xF0000, 0xFFFFD, 0x100000, 0x10FFFD}; - - -BSON_END_DECLS - - -#endif /* MONGOC_SCRAM_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-scram.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-scram.c deleted file mode 100644 index 7fdff0e9d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-scram.c +++ /dev/null @@ -1,1563 +0,0 @@ -/* Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_CRYPTO - -#include - -#include "mongoc-error.h" -#include "mongoc-scram-private.h" -#include "mongoc-rand-private.h" -#include "mongoc-util-private.h" -#include "mongoc-trace-private.h" - -#include "mongoc-crypto-private.h" -#include "common-b64-private.h" - -#include "mongoc-memcmp-private.h" -#include "common-thread-private.h" -#include - -typedef struct _mongoc_scram_cache_entry_t { - /* book keeping */ - bool taken; - /* pre-secrets */ - char hashed_password[MONGOC_SCRAM_HASH_MAX_SIZE]; - uint8_t decoded_salt[MONGOC_SCRAM_B64_HASH_MAX_SIZE]; - uint32_t iterations; - /* secrets */ - uint8_t client_key[MONGOC_SCRAM_HASH_MAX_SIZE]; - uint8_t server_key[MONGOC_SCRAM_HASH_MAX_SIZE]; - uint8_t salted_password[MONGOC_SCRAM_HASH_MAX_SIZE]; -} mongoc_scram_cache_entry_t; - -#define MONGOC_SCRAM_SERVER_KEY "Server Key" -#define MONGOC_SCRAM_CLIENT_KEY "Client Key" - -/* returns true if the first UTF-8 code point in `s` is valid. */ -bool -_mongoc_utf8_first_code_point_is_valid (const char *c, size_t length); - -/* returns whether a character is between two limits (inclusive). */ -bool -_mongoc_utf8_code_unit_in_range (const uint8_t c, - const uint8_t lower, - const uint8_t upper); - -/* returns whether a codepoint exists in the specified table. The table format - * is that the 2*n element is the lower bound and the 2*n + 1 is the upper bound - * (both inclusive). */ -bool -_mongoc_utf8_code_point_is_in_table (uint32_t code, - const uint32_t *table, - size_t size); - -/* returns the byte length of the UTF-8 code point. Returns -1 if `c` is not a - * valid UTF-8 code point. */ -ssize_t -_mongoc_utf8_code_point_length (uint32_t c); - -/* converts a Unicode code point to UTF-8 character. Returns how many bytes the - * character converted is. Returns -1 if the code point is invalid. - * char *out must be large enough to contain all of the code units written to - * it. */ -ssize_t -_mongoc_utf8_code_point_to_str (uint32_t c, char *out); - -static bson_shared_mutex_t g_scram_cache_rwlock; - -static bson_once_t init_cache_once_control = BSON_ONCE_INIT; -static bson_mutex_t clear_cache_lock; - -/* - * Cache lookups are a linear search through this table. This table is a - * constant size, which is small enough that lookup cost is insignificant. - * - * This can be refactored into a hashmap if the cache size needs to grow larger - * in the future, but a linear lookup is currently fast enough and is much - * simpler logic to reason about. - */ -static mongoc_scram_cache_entry_t g_scram_cache[MONGOC_SCRAM_CACHE_SIZE]; - -static void -_mongoc_scram_cache_clear (void) -{ - bson_mutex_lock (&clear_cache_lock); - memset (g_scram_cache, 0, sizeof (g_scram_cache)); - bson_mutex_unlock (&clear_cache_lock); -} - -static BSON_ONCE_FUN (_mongoc_scram_cache_init) -{ - bson_shared_mutex_init (&g_scram_cache_rwlock); - bson_mutex_init (&clear_cache_lock); - _mongoc_scram_cache_clear (); - - BSON_ONCE_RETURN; -} - -static void -_mongoc_scram_cache_init_once (void) -{ - bson_once (&init_cache_once_control, _mongoc_scram_cache_init); -} - -static int -_scram_hash_size (mongoc_scram_t *scram) -{ - if (scram->crypto.algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_1) { - return MONGOC_SCRAM_SHA_1_HASH_SIZE; - } else if (scram->crypto.algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_256) { - return MONGOC_SCRAM_SHA_256_HASH_SIZE; - } - return 0; -} - -/* Copies the cache's secrets to scram */ -static void -_mongoc_scram_cache_apply_secrets (mongoc_scram_cache_entry_t *cache, - mongoc_scram_t *scram) -{ - BSON_ASSERT (cache); - BSON_ASSERT (scram); - - memcpy (scram->client_key, cache->client_key, sizeof (scram->client_key)); - memcpy (scram->server_key, cache->server_key, sizeof (scram->server_key)); - memcpy (scram->salted_password, - cache->salted_password, - sizeof (scram->salted_password)); -} - - -void -_mongoc_scram_cache_destroy (mongoc_scram_cache_entry_t *cache) -{ - BSON_ASSERT (cache); - bson_free (cache); -} - - -/* - * Checks whether the cache contains scram's pre-secrets. - * Populate `cache` with the values found in the global cache if found. - */ -static bool -_mongoc_scram_cache_has_presecrets (mongoc_scram_cache_entry_t *cache /* out */, - const mongoc_scram_t *scram) -{ - bool cache_hit = false; - - BSON_ASSERT (cache); - BSON_ASSERT (scram); - - _mongoc_scram_cache_init_once (); - - /* - * - Take a read lock - * - Search through g_scram_cache if the hashed_password, decoded_salt, and - * iterations match an entry. - * - If so, then return true - * - Otherwise return false - */ - bson_shared_mutex_lock_shared (&g_scram_cache_rwlock); - - for (size_t i = 0; i < MONGOC_SCRAM_CACHE_SIZE; i++) { - if (g_scram_cache[i].taken) { - mongoc_scram_cache_entry_t *cache_entry = &g_scram_cache[i]; - cache_hit = - !strcmp (cache_entry->hashed_password, scram->hashed_password) && - cache_entry->iterations == scram->iterations && - !memcmp (cache_entry->decoded_salt, - scram->decoded_salt, - sizeof (cache_entry->decoded_salt)); - if (cache_hit) { - /* copy the found cache items into the 'cache' output parameter */ - memcpy (cache->client_key, - cache_entry->client_key, - sizeof (cache->client_key)); - memcpy (cache->server_key, - cache_entry->server_key, - sizeof (cache->server_key)); - memcpy (cache->salted_password, - cache_entry->salted_password, - sizeof (cache->salted_password)); - goto done; - } - } - } - -done: - bson_shared_mutex_unlock_shared (&g_scram_cache_rwlock); - return cache_hit; -} - - -void -_mongoc_scram_set_pass (mongoc_scram_t *scram, const char *pass) -{ - BSON_ASSERT (scram); - - if (scram->pass) { - bson_zero_free (scram->pass, strlen (scram->pass)); - } - - scram->pass = pass ? bson_strdup (pass) : NULL; -} - - -void -_mongoc_scram_set_user (mongoc_scram_t *scram, const char *user) -{ - BSON_ASSERT (scram); - - bson_free (scram->user); - scram->user = user ? bson_strdup (user) : NULL; -} - - -void -_mongoc_scram_init (mongoc_scram_t *scram, mongoc_crypto_hash_algorithm_t algo) -{ - BSON_ASSERT (scram); - - memset (scram, 0, sizeof *scram); - - mongoc_crypto_init (&scram->crypto, algo); -} - - -void -_mongoc_scram_destroy (mongoc_scram_t *scram) -{ - BSON_ASSERT (scram); - - bson_free (scram->user); - - if (scram->pass) { - bson_zero_free (scram->pass, strlen (scram->pass)); - } - - memset (scram->hashed_password, 0, sizeof (scram->hashed_password)); - - bson_free (scram->auth_message); - - memset (scram, 0, sizeof *scram); -} - -static void -_mongoc_scram_cache_insert (const mongoc_scram_t *scram) -{ - bson_shared_mutex_lock (&g_scram_cache_rwlock); - -again: - for (size_t i = 0; i < MONGOC_SCRAM_CACHE_SIZE; i++) { - mongoc_scram_cache_entry_t *cache_entry = &g_scram_cache[i]; - bool already_exists = - !strcmp (cache_entry->hashed_password, scram->hashed_password) && - cache_entry->iterations == scram->iterations && - !memcmp (cache_entry->decoded_salt, - scram->decoded_salt, - sizeof (cache_entry->decoded_salt)) && - !memcmp (cache_entry->client_key, - scram->client_key, - sizeof (cache_entry->client_key)) && - !memcmp (cache_entry->server_key, - scram->server_key, - sizeof (cache_entry->server_key)) && - !memcmp (cache_entry->salted_password, - scram->salted_password, - sizeof (cache_entry->salted_password)); - - if (already_exists) { - /* cache entry already populated between read and write lock - * acquisition, skipping */ - break; - } - - if (!cache_entry->taken) { - /* found an empty slot */ - memcpy (cache_entry->client_key, - scram->client_key, - sizeof (cache_entry->client_key)); - memcpy (cache_entry->server_key, - scram->server_key, - sizeof (cache_entry->server_key)); - memcpy (cache_entry->salted_password, - scram->salted_password, - sizeof (cache_entry->salted_password)); - memcpy (cache_entry->decoded_salt, - scram->decoded_salt, - sizeof (cache_entry->decoded_salt)); - memcpy (cache_entry->hashed_password, - scram->hashed_password, - sizeof (cache_entry->hashed_password)); - cache_entry->iterations = scram->iterations; - cache_entry->taken = true; - break; - } - - /* if cache is full, then invalidate the cache and insert again */ - if (i == (MONGOC_SCRAM_CACHE_SIZE - 1)) { - _mongoc_scram_cache_clear (); - goto again; - } - } - - bson_shared_mutex_unlock (&g_scram_cache_rwlock); -} - -/* Updates the cache with scram's last-used pre-secrets and secrets */ -static void -_mongoc_scram_update_cache (const mongoc_scram_t *scram) -{ - mongoc_scram_cache_entry_t cache; - bool found = _mongoc_scram_cache_has_presecrets (&cache, scram); - if (!found) { - /* cache miss, insert this as a new cache entry */ - _mongoc_scram_cache_insert (scram); - } -} - - -static bool -_mongoc_scram_buf_write (const char *src, - int32_t src_len, - uint8_t *outbuf, - uint32_t outbufmax, - uint32_t *outbuflen) -{ - if (src_len < 0) { - src_len = (int32_t) strlen (src); - } - - if (*outbuflen + src_len >= outbufmax) { - return false; - } - - memcpy (outbuf + *outbuflen, src, src_len); - - *outbuflen += src_len; - - return true; -} - - -/* generate client-first-message: - * n,a=authzid,n=encoded-username,r=client-nonce - * - * note that a= is optional, so we aren't dealing with that here - */ -static bool -_mongoc_scram_start (mongoc_scram_t *scram, - uint8_t *outbuf, - uint32_t outbufmax, - uint32_t *outbuflen, - bson_error_t *error) -{ - uint8_t nonce[24]; - const char *ptr; - bool rval = true; - - BSON_ASSERT (scram); - BSON_ASSERT (outbuf); - BSON_ASSERT (outbufmax); - BSON_ASSERT (outbuflen); - - if (!scram->user) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: username is not set"); - goto FAIL; - } - - /* auth message is as big as the outbuf just because */ - scram->auth_message = (uint8_t *) bson_malloc (outbufmax); - scram->auth_messagemax = outbufmax; - - /* the server uses a 24 byte random nonce. so we do as well */ - if (1 != _mongoc_rand_bytes (nonce, sizeof (nonce))) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: could not generate a cryptographically " - "secure nonce in sasl step 1"); - goto FAIL; - } - - scram->encoded_nonce_len = mcommon_b64_ntop (nonce, - sizeof (nonce), - scram->encoded_nonce, - sizeof (scram->encoded_nonce)); - - if (-1 == scram->encoded_nonce_len) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: could not encode nonce"); - goto FAIL; - } - - if (!_mongoc_scram_buf_write ("n,,n=", -1, outbuf, outbufmax, outbuflen)) { - goto BUFFER; - } - - for (ptr = scram->user; *ptr; ptr++) { - /* RFC 5802 specifies that ',' and '=' and encoded as '=2C' and '=3D' - * respectively in the user name */ - switch (*ptr) { - case ',': - - if (!_mongoc_scram_buf_write ( - "=2C", -1, outbuf, outbufmax, outbuflen)) { - goto BUFFER; - } - - break; - case '=': - - if (!_mongoc_scram_buf_write ( - "=3D", -1, outbuf, outbufmax, outbuflen)) { - goto BUFFER; - } - - break; - default: - - if (!_mongoc_scram_buf_write (ptr, 1, outbuf, outbufmax, outbuflen)) { - goto BUFFER; - } - - break; - } - } - - if (!_mongoc_scram_buf_write (",r=", -1, outbuf, outbufmax, outbuflen)) { - goto BUFFER; - } - - if (!_mongoc_scram_buf_write (scram->encoded_nonce, - scram->encoded_nonce_len, - outbuf, - outbufmax, - outbuflen)) { - goto BUFFER; - } - - /* we have to keep track of the conversation to create a client proof later - * on. This copies the message we're crafting from the 'n=' portion onwards - * into a buffer we're managing */ - if (!_mongoc_scram_buf_write ((char *) outbuf + 3, - *outbuflen - 3, - scram->auth_message, - scram->auth_messagemax, - &scram->auth_messagelen)) { - goto BUFFER_AUTH; - } - - if (!_mongoc_scram_buf_write (",", - -1, - scram->auth_message, - scram->auth_messagemax, - &scram->auth_messagelen)) { - goto BUFFER_AUTH; - } - - goto CLEANUP; - -BUFFER_AUTH: - bson_set_error ( - error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: could not buffer auth message in sasl step1"); - - goto FAIL; - -BUFFER: - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: could not buffer sasl step1"); - - goto FAIL; - -FAIL: - rval = false; - -CLEANUP: - - return rval; -} - - -/* Compute the SCRAM step Hi() as defined in RFC5802 */ -static void -_mongoc_scram_salt_password (mongoc_scram_t *scram, - const char *password, - uint32_t password_len, - const uint8_t *salt, - uint32_t salt_len, - uint32_t iterations) -{ - uint8_t intermediate_digest[MONGOC_SCRAM_HASH_MAX_SIZE]; - uint8_t start_key[MONGOC_SCRAM_HASH_MAX_SIZE]; - - uint8_t *output = scram->salted_password; - - memcpy (start_key, salt, salt_len); - - start_key[salt_len] = 0; - start_key[salt_len + 1] = 0; - start_key[salt_len + 2] = 0; - start_key[salt_len + 3] = 1; - - mongoc_crypto_hmac (&scram->crypto, - password, - password_len, - start_key, - _scram_hash_size (scram), - output); - - memcpy (intermediate_digest, output, _scram_hash_size (scram)); - - /* intermediateDigest contains Ui and output contains the accumulated XOR:ed - * result */ - for (uint32_t i = 2u; i <= iterations; i++) { - const int hash_size = _scram_hash_size (scram); - - mongoc_crypto_hmac (&scram->crypto, - password, - password_len, - intermediate_digest, - hash_size, - intermediate_digest); - - for (int k = 0; k < hash_size; k++) { - output[k] ^= intermediate_digest[k]; - } - } -} - - -static bool -_mongoc_scram_generate_client_proof (mongoc_scram_t *scram, - uint8_t *outbuf, - uint32_t outbufmax, - uint32_t *outbuflen) -{ - uint8_t stored_key[MONGOC_SCRAM_HASH_MAX_SIZE]; - uint8_t client_signature[MONGOC_SCRAM_HASH_MAX_SIZE]; - unsigned char client_proof[MONGOC_SCRAM_HASH_MAX_SIZE]; - int i; - int r = 0; - - if (!*scram->client_key) { - /* ClientKey := HMAC(saltedPassword, "Client Key") */ - mongoc_crypto_hmac (&scram->crypto, - scram->salted_password, - _scram_hash_size (scram), - (uint8_t *) MONGOC_SCRAM_CLIENT_KEY, - (int) strlen (MONGOC_SCRAM_CLIENT_KEY), - scram->client_key); - } - - /* StoredKey := H(client_key) */ - mongoc_crypto_hash (&scram->crypto, - scram->client_key, - (size_t) _scram_hash_size (scram), - stored_key); - - /* ClientSignature := HMAC(StoredKey, AuthMessage) */ - mongoc_crypto_hmac (&scram->crypto, - stored_key, - _scram_hash_size (scram), - scram->auth_message, - scram->auth_messagelen, - client_signature); - - /* ClientProof := ClientKey XOR ClientSignature */ - - for (i = 0; i < _scram_hash_size (scram); i++) { - client_proof[i] = scram->client_key[i] ^ client_signature[i]; - } - - r = mcommon_b64_ntop (client_proof, - _scram_hash_size (scram), - (char *) outbuf + *outbuflen, - outbufmax - *outbuflen); - - if (-1 == r) { - return false; - } - - *outbuflen += r; - - return true; -} - - -/* Parse server-first-message of the form: - * r=client-nonce|server-nonce,s=user-salt,i=iteration-count - * - * Generate client-final-message of the form: - * c=channel-binding(base64),r=client-nonce|server-nonce,p=client-proof - */ -static bool -_mongoc_scram_step2 (mongoc_scram_t *scram, - const uint8_t *inbuf, - uint32_t inbuflen, - uint8_t *outbuf, - uint32_t outbufmax, - uint32_t *outbuflen, - bson_error_t *error) -{ - uint8_t *val_r = NULL; - uint32_t val_r_len; - uint8_t *val_s = NULL; - uint32_t val_s_len; - uint8_t *val_i = NULL; - uint32_t val_i_len; - - uint8_t **current_val; - uint32_t *current_val_len; - - const uint8_t *ptr; - const uint8_t *next_comma; - - char *tmp; - char *hashed_password = NULL; - - uint8_t decoded_salt[MONGOC_SCRAM_B64_HASH_MAX_SIZE] = {0}; - int32_t decoded_salt_len; - /* the decoded salt leaves four trailing bytes to add the int32 0x00000001 */ - const int32_t expected_salt_length = _scram_hash_size (scram) - 4; - bool rval = true; - - int iterations; - - - BSON_ASSERT (scram); - BSON_ASSERT (outbuf); - BSON_ASSERT (outbufmax); - BSON_ASSERT (outbuflen); - - if (scram->crypto.algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_1) { - /* Auth spec for SCRAM-SHA-1: "The password variable MUST be the mongodb - * hashed variant. The mongo hashed variant is computed as hash = HEX( - * MD5( UTF8( username + ':mongo:' + plain_text_password )))" */ - tmp = bson_strdup_printf ("%s:mongo:%s", scram->user, scram->pass); - hashed_password = _mongoc_hex_md5 (tmp); - bson_zero_free (tmp, strlen (tmp)); - } else if (scram->crypto.algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_256) { - /* Auth spec for SCRAM-SHA-256: "Passwords MUST be prepared with SASLprep, - * per RFC 5802. Passwords are used directly for key derivation; they - * MUST NOT be digested as they are in SCRAM-SHA-1." */ - hashed_password = _mongoc_sasl_prep (scram->pass, error); - if (!hashed_password) { - goto FAIL; - } - } else { - BSON_ASSERT (false); - } - - /* we need all of the incoming message for the final client proof */ - if (!_mongoc_scram_buf_write ((char *) inbuf, - inbuflen, - scram->auth_message, - scram->auth_messagemax, - &scram->auth_messagelen)) { - goto BUFFER_AUTH; - } - - if (!_mongoc_scram_buf_write (",", - -1, - scram->auth_message, - scram->auth_messagemax, - &scram->auth_messagelen)) { - goto BUFFER_AUTH; - } - - for (ptr = inbuf; ptr < inbuf + inbuflen;) { - switch (*ptr) { - case 'r': - current_val = &val_r; - current_val_len = &val_r_len; - break; - case 's': - current_val = &val_s; - current_val_len = &val_s_len; - break; - case 'i': - current_val = &val_i; - current_val_len = &val_i_len; - break; - default: - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: unknown key (%c) in sasl step 2", - *ptr); - goto FAIL; - } - - ptr++; - - if (*ptr != '=') { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: invalid parse state in sasl step 2"); - - goto FAIL; - } - - ptr++; - - next_comma = - (const uint8_t *) memchr (ptr, ',', (inbuf + inbuflen) - ptr); - - if (next_comma) { - *current_val_len = (uint32_t) (next_comma - ptr); - } else { - *current_val_len = (uint32_t) ((inbuf + inbuflen) - ptr); - } - - *current_val = (uint8_t *) bson_malloc (*current_val_len + 1); - memcpy (*current_val, ptr, *current_val_len); - (*current_val)[*current_val_len] = '\0'; - - if (next_comma) { - ptr = next_comma + 1; - } else { - break; - } - } - - if (!val_r) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: no r param in sasl step 2"); - - goto FAIL; - } - - if (!val_s) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: no s param in sasl step 2"); - - goto FAIL; - } - - if (!val_i) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: no i param in sasl step 2"); - - goto FAIL; - } - - /* verify our nonce */ - if (bson_cmp_less_us (val_r_len, scram->encoded_nonce_len) || - mongoc_memcmp (val_r, scram->encoded_nonce, scram->encoded_nonce_len)) { - bson_set_error ( - error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: client nonce not repeated in sasl step 2"); - } - - *outbuflen = 0; - - if (!_mongoc_scram_buf_write ( - "c=biws,r=", -1, outbuf, outbufmax, outbuflen)) { - goto BUFFER; - } - - if (!_mongoc_scram_buf_write ( - (char *) val_r, val_r_len, outbuf, outbufmax, outbuflen)) { - goto BUFFER; - } - - if (!_mongoc_scram_buf_write ((char *) outbuf, - *outbuflen, - scram->auth_message, - scram->auth_messagemax, - &scram->auth_messagelen)) { - goto BUFFER_AUTH; - } - - if (!_mongoc_scram_buf_write (",p=", -1, outbuf, outbufmax, outbuflen)) { - goto BUFFER; - } - - decoded_salt_len = - mcommon_b64_pton ((char *) val_s, decoded_salt, sizeof (decoded_salt)); - - if (-1 == decoded_salt_len) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: unable to decode salt in sasl step2"); - goto FAIL; - } - - if (expected_salt_length != decoded_salt_len) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: invalid salt length of %d in sasl step2", - decoded_salt_len); - goto FAIL; - } - - iterations = (int) bson_ascii_strtoll ((char *) val_i, &tmp, 10); - /* tmp holds the location of the failed to parse character. So if it's - * null, we got to the end of the string and didn't have a parse error */ - - if (*tmp) { - bson_set_error ( - error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: unable to parse iterations in sasl step2"); - goto FAIL; - } - - if (iterations < 0) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: iterations is negative in sasl step2"); - goto FAIL; - } - - /* drivers MUST enforce a minimum iteration count of 4096 and MUST error if - * the authentication conversation specifies a lower count. This mitigates - * downgrade attacks by a man-in-the-middle attacker. */ - if (iterations < 4096) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: iterations must be at least 4096"); - goto FAIL; - } - - /* Save the presecrets for caching */ - if (hashed_password) { - bson_strncpy (scram->hashed_password, - hashed_password, - sizeof (scram->hashed_password)); - } - - scram->iterations = iterations; - memcpy (scram->decoded_salt, decoded_salt, sizeof (scram->decoded_salt)); - - mongoc_scram_cache_entry_t cache; - if (_mongoc_scram_cache_has_presecrets (&cache, scram)) { - _mongoc_scram_cache_apply_secrets (&cache, scram); - } - - if (!*scram->salted_password) { - _mongoc_scram_salt_password (scram, - hashed_password, - (uint32_t) strlen (hashed_password), - decoded_salt, - decoded_salt_len, - (uint32_t) iterations); - } - - _mongoc_scram_generate_client_proof (scram, outbuf, outbufmax, outbuflen); - - goto CLEANUP; - -BUFFER_AUTH: - bson_set_error ( - error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: could not buffer auth message in sasl step2"); - - goto FAIL; - -BUFFER: - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: could not buffer sasl step2"); - - goto FAIL; - -FAIL: - rval = false; - -CLEANUP: - bson_free (val_r); - bson_free (val_s); - bson_free (val_i); - - if (hashed_password) { - bson_zero_free (hashed_password, strlen (hashed_password)); - } - - return rval; -} - - -static bool -_mongoc_scram_verify_server_signature (mongoc_scram_t *scram, - uint8_t *verification, - uint32_t len) -{ - char encoded_server_signature[MONGOC_SCRAM_B64_HASH_MAX_SIZE]; - int32_t encoded_server_signature_len; - uint8_t server_signature[MONGOC_SCRAM_HASH_MAX_SIZE]; - - if (!*scram->server_key) { - const size_t key_len = strlen (MONGOC_SCRAM_SERVER_KEY); - BSON_ASSERT (bson_in_range_unsigned (int, key_len)); - - /* ServerKey := HMAC(SaltedPassword, "Server Key") */ - mongoc_crypto_hmac (&scram->crypto, - scram->salted_password, - _scram_hash_size (scram), - (uint8_t *) MONGOC_SCRAM_SERVER_KEY, - (int) key_len, - scram->server_key); - } - - /* ServerSignature := HMAC(ServerKey, AuthMessage) */ - mongoc_crypto_hmac (&scram->crypto, - scram->server_key, - _scram_hash_size (scram), - scram->auth_message, - scram->auth_messagelen, - server_signature); - - encoded_server_signature_len = - mcommon_b64_ntop (server_signature, - _scram_hash_size (scram), - encoded_server_signature, - sizeof (encoded_server_signature)); - if (encoded_server_signature_len == -1) { - return false; - } - - return (len == encoded_server_signature_len) && - (mongoc_memcmp (verification, encoded_server_signature, len) == 0); -} - - -static bool -_mongoc_scram_step3 (mongoc_scram_t *scram, - const uint8_t *inbuf, - uint32_t inbuflen, - uint8_t *outbuf, - uint32_t outbufmax, - uint32_t *outbuflen, - bson_error_t *error) -{ - uint8_t *val_e = NULL; - uint32_t val_e_len; - uint8_t *val_v = NULL; - uint32_t val_v_len; - - uint8_t **current_val; - uint32_t *current_val_len; - - const uint8_t *ptr; - const uint8_t *next_comma; - - bool rval = true; - - BSON_ASSERT (scram); - BSON_ASSERT (outbuf); - BSON_ASSERT (outbufmax); - BSON_ASSERT (outbuflen); - - for (ptr = inbuf; ptr < inbuf + inbuflen;) { - switch (*ptr) { - case 'e': - current_val = &val_e; - current_val_len = &val_e_len; - break; - case 'v': - current_val = &val_v; - current_val_len = &val_v_len; - break; - default: - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: unknown key (%c) in sasl step 3", - *ptr); - goto FAIL; - } - - ptr++; - - if (*ptr != '=') { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: invalid parse state in sasl step 3"); - goto FAIL; - } - - ptr++; - - next_comma = - (const uint8_t *) memchr (ptr, ',', (inbuf + inbuflen) - ptr); - - if (next_comma) { - *current_val_len = (uint32_t) (next_comma - ptr); - } else { - *current_val_len = (uint32_t) ((inbuf + inbuflen) - ptr); - } - - *current_val = (uint8_t *) bson_malloc (*current_val_len + 1); - memcpy (*current_val, ptr, *current_val_len); - (*current_val)[*current_val_len] = '\0'; - - if (next_comma) { - ptr = next_comma + 1; - } else { - break; - } - } - - *outbuflen = 0; - - if (val_e) { - bson_set_error ( - error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: authentication failure in sasl step 3 : %s", - val_e); - goto FAIL; - } - - if (!val_v) { - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: no v param in sasl step 3"); - goto FAIL; - } - - if (!_mongoc_scram_verify_server_signature (scram, val_v, val_v_len)) { - bson_set_error ( - error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: could not verify server signature in sasl step 3"); - goto FAIL; - } - - /* Update the cache if authentication succeeds */ - _mongoc_scram_update_cache (scram); - - goto CLEANUP; - -FAIL: - rval = false; - -CLEANUP: - bson_free (val_e); - bson_free (val_v); - - return rval; -} - - -bool -_mongoc_scram_step (mongoc_scram_t *scram, - const uint8_t *inbuf, - uint32_t inbuflen, - uint8_t *outbuf, - uint32_t outbufmax, - uint32_t *outbuflen, - bson_error_t *error) -{ - BSON_ASSERT (scram); - BSON_ASSERT (inbuf); - BSON_ASSERT (outbuf); - BSON_ASSERT (outbuflen); - - scram->step++; - - switch (scram->step) { - case 1: - return _mongoc_scram_start (scram, outbuf, outbufmax, outbuflen, error); - case 2: - return _mongoc_scram_step2 ( - scram, inbuf, inbuflen, outbuf, outbufmax, outbuflen, error); - case 3: - return _mongoc_scram_step3 ( - scram, inbuf, inbuflen, outbuf, outbufmax, outbuflen, error); - default: - bson_set_error (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_NOT_DONE, - "SCRAM Failure: maximum steps detected"); - return false; - } -} - -bool -_mongoc_sasl_prep_required (const char *str) -{ - unsigned char c; - while (*str) { - c = (unsigned char) *str; - /* characters below 32 contain all of the control characters. - * characters above 127 are multibyte UTF-8 characters. - * character 127 is the DEL character. */ - if (c < 32 || c >= 127) { - return true; - } - str++; - } - return false; -} - -char * -_mongoc_sasl_prep_impl (const char *name, - const char *in_utf8, - bson_error_t *err) -{ - BSON_ASSERT_PARAM (name); - BSON_ASSERT_PARAM (in_utf8); - - uint32_t *utf8_codepoints; - ssize_t num_chars; - uint8_t *out_utf8; - -#define SASL_PREP_ERR_RETURN(msg) \ - do { \ - bson_set_error (err, \ - MONGOC_ERROR_SCRAM, \ - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, \ - (msg), \ - name); \ - return NULL; \ - } while (0) - - /* 1. convert str to Unicode codepoints. */ - /* preflight to get the destination length. */ - num_chars = _mongoc_utf8_string_length (in_utf8); - if (num_chars == -1) { - SASL_PREP_ERR_RETURN ("could not calculate UTF-8 length of %s"); - } - - /* convert to unicode. */ - utf8_codepoints = bson_malloc ( - sizeof (uint32_t) * (num_chars + 1)); /* add one for trailing 0 value. */ - const char *c = in_utf8; - - for (size_t i = 0; i < num_chars; ++i) { - const size_t utf8_char_length = _mongoc_utf8_char_length (c); - utf8_codepoints[i] = - _mongoc_utf8_get_first_code_point (c, utf8_char_length); - - c += utf8_char_length; - } - utf8_codepoints[num_chars] = '\0'; - - /* 2. perform SASLPREP */ - - // the steps below come directly from RFC 3454: 2. Preparation Overview. - - // a. Map - For each character in the input, check if it has a mapping (using - // the tables) and, if so, replace it with its mapping. - - // because we will have to map some characters to nothing, we'll use two - // pointers: one for reading the original characters (i) and one for writing - // the new characters (curr). i will always be >= curr. - size_t curr = 0; - for (size_t i = 0; i < num_chars; ++i) { - if (_mongoc_utf8_code_point_is_in_table ( - utf8_codepoints[i], - non_ascii_space_character_ranges, - sizeof (non_ascii_space_character_ranges) / sizeof (uint32_t))) - utf8_codepoints[curr++] = 0x0020; - else if (_mongoc_utf8_code_point_is_in_table ( - utf8_codepoints[i], - commonly_mapped_to_nothing_ranges, - sizeof (commonly_mapped_to_nothing_ranges) / - sizeof (uint32_t))) { - // effectively skip over the character because we don't increment curr. - } else - utf8_codepoints[curr++] = utf8_codepoints[i]; - } - utf8_codepoints[curr] = '\0'; - num_chars = curr; - - - // b. Normalize - normalize the result of step `a` using Unicode - // normalization. - - // this is an optional step for stringprep, but Unicode normalization with - // form KC is required for SASLPrep. - - // in order to do this, we must first convert back to UTF-8. - - // preflight for length - size_t utf8_pre_norm_len = 0; - for (size_t i = 0; i < num_chars; ++i) { - const ssize_t len = _mongoc_utf8_code_point_length (utf8_codepoints[i]); - if (len == -1) { - bson_free (utf8_codepoints); - SASL_PREP_ERR_RETURN ("invalid Unicode code point in %s"); - } else { - utf8_pre_norm_len += len; - } - } - char *utf8_pre_norm = - (char *) bson_malloc (sizeof (char) * (utf8_pre_norm_len + 1)); - - char *loc = utf8_pre_norm; - for (size_t i = 0; i < num_chars; ++i) { - const ssize_t utf8_char_length = - _mongoc_utf8_code_point_to_str (utf8_codepoints[i], loc); - if (utf8_char_length == -1) { - bson_free (utf8_pre_norm); - bson_free (utf8_codepoints); - SASL_PREP_ERR_RETURN ("invalid Unicode code point in %s"); - } - loc += utf8_char_length; - } - *loc = '\0'; - - out_utf8 = (uint8_t *) utf8proc_NFKC ((utf8proc_uint8_t *) utf8_pre_norm); - - // the last two steps are both checks for characters that should not be - // allowed. Because the normalization step is guarenteed to not create any - // characters that will cause an error, we will use the utf8_codepoints - // codepoints to check (pre-normalization) as to avoid converting back and - // forth from UTF-8 to unicode codepoints. - - // c. Prohibit -- Check for any characters - // that are not allowed in the output. If any are found, return an error. - - for (size_t i = 0; i < num_chars; ++i) { - if (_mongoc_utf8_code_point_is_in_table ( - utf8_codepoints[i], - prohibited_output_ranges, - sizeof (prohibited_output_ranges) / sizeof (uint32_t)) || - _mongoc_utf8_code_point_is_in_table ( - utf8_codepoints[i], - unassigned_codepoint_ranges, - sizeof (unassigned_codepoint_ranges) / sizeof (uint32_t))) { - bson_free (out_utf8); - bson_free (utf8_pre_norm); - bson_free (utf8_codepoints); - SASL_PREP_ERR_RETURN ("prohibited character included in %s"); - } - } - - // d. Check bidi -- Possibly check for right-to-left characters, and if - // any are found, make sure that the whole string satisfies the - // requirements for bidirectional strings. If the string does not - // satisfy the requirements for bidirectional strings, return an - // error. - - // note: bidi stands for directional (text). Most characters are displayed - // left to right but some are displayed right to left. The requirements are - // as follows: - // 1. If a string contains any RandALCat character, it can't contain an LCat - // character - // 2. If it contains an RandALCat character, there must be an RandALCat - // character at the beginning and the end of the string (does not have to be - // the same character) - bool contains_LCat = false; - bool contains_RandALCar = false; - - - for (size_t i = 0; i < num_chars; ++i) { - if (_mongoc_utf8_code_point_is_in_table (utf8_codepoints[i], - LCat_bidi_ranges, - sizeof (LCat_bidi_ranges) / - sizeof (uint32_t))) { - contains_LCat = true; - } - if (_mongoc_utf8_code_point_is_in_table (utf8_codepoints[i], - RandALCat_bidi_ranges, - sizeof (RandALCat_bidi_ranges) / - sizeof (uint32_t))) - contains_RandALCar = true; - } - - if ( - // requirement 1 - (contains_RandALCar && contains_LCat) || - // requirement 2 - (contains_RandALCar && - (!_mongoc_utf8_code_point_is_in_table (utf8_codepoints[0], - RandALCat_bidi_ranges, - sizeof (RandALCat_bidi_ranges) / - sizeof (uint32_t)) || - !_mongoc_utf8_code_point_is_in_table (utf8_codepoints[num_chars - 1], - RandALCat_bidi_ranges, - sizeof (RandALCat_bidi_ranges) / - sizeof (uint32_t))))) { - bson_free (out_utf8); - bson_free (utf8_pre_norm); - bson_free (utf8_codepoints); - SASL_PREP_ERR_RETURN ("%s does not meet bidirectional requirements"); - } - - bson_free (utf8_pre_norm); - bson_free (utf8_codepoints); - - return (char *) out_utf8; -#undef SASL_PREP_ERR_RETURN -} - -char * -_mongoc_sasl_prep (const char *in_utf8, bson_error_t *err) -{ - if (_mongoc_sasl_prep_required (in_utf8)) { - return _mongoc_sasl_prep_impl ("password", in_utf8, err); - } - return bson_strdup (in_utf8); -} - -size_t -_mongoc_utf8_char_length (const char *s) -{ - BSON_ASSERT_PARAM (s); - - uint8_t *c = (uint8_t *) s; - // UTF-8 characters are either 1, 2, 3, or 4 bytes and the character length - // can be determined by the first byte - if ((*c & UINT8_C (0x80)) == 0) - return 1u; - else if ((*c & UINT8_C (0xe0)) == UINT8_C (0xc0)) - return 2u; - else if ((*c & UINT8_C (0xf0)) == UINT8_C (0xe0)) - return 3u; - else if ((*c & UINT8_C (0xf8)) == UINT8_C (0xf0)) - return 4u; - else - return 1u; -} - -ssize_t -_mongoc_utf8_string_length (const char *s) -{ - BSON_ASSERT_PARAM (s); - - const uint8_t *c = (uint8_t *) s; - - ssize_t str_length = 0; - - while (*c) { - const size_t utf8_char_length = _mongoc_utf8_char_length ((char *) c); - - if (!_mongoc_utf8_first_code_point_is_valid ((char *) c, - utf8_char_length)) - return -1; - - str_length++; - c += utf8_char_length; - } - - return str_length; -} - - -bool -_mongoc_utf8_first_code_point_is_valid (const char *c, size_t length) -{ - BSON_ASSERT_PARAM (c); - - uint8_t *temp_c = (uint8_t *) c; - // Referenced table here: - // https://lemire.me/blog/2018/05/09/how-quickly-can-you-check-that-a-string-is-valid-unicode-utf-8/ - switch (length) { - case 1: - return _mongoc_utf8_code_unit_in_range ( - temp_c[0], UINT8_C (0x00), UINT8_C (0x7F)); - case 2: - return _mongoc_utf8_code_unit_in_range ( - temp_c[0], UINT8_C (0xC2), UINT8_C (0xDF)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[1], UINT8_C (0x80), UINT8_C (0xBF)); - case 3: - // Four options, separated by || - return (_mongoc_utf8_code_unit_in_range ( - temp_c[0], UINT8_C (0xE0), UINT8_C (0xE0)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[1], UINT8_C (0xA0), UINT8_C (0xBF)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[2], UINT8_C (0x80), UINT8_C (0xBF))) || - (_mongoc_utf8_code_unit_in_range ( - temp_c[0], UINT8_C (0xE1), UINT8_C (0xEC)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[1], UINT8_C (0x80), UINT8_C (0xBF)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[2], UINT8_C (0x80), UINT8_C (0xBF))) || - (_mongoc_utf8_code_unit_in_range ( - temp_c[0], UINT8_C (0xED), UINT8_C (0xED)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[1], UINT8_C (0x80), UINT8_C (0x9F)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[2], UINT8_C (0x80), UINT8_C (0xBF))) || - (_mongoc_utf8_code_unit_in_range ( - temp_c[0], UINT8_C (0xEE), UINT8_C (0xEF)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[1], UINT8_C (0x80), UINT8_C (0xBF)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[2], UINT8_C (0x80), UINT8_C (0xBF))); - case 4: - // Three options, separated by || - return (_mongoc_utf8_code_unit_in_range ( - temp_c[0], UINT8_C (0xF0), UINT8_C (0xF0)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[1], UINT8_C (0x90), UINT8_C (0xBF)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[2], UINT8_C (0x80), UINT8_C (0xBF)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[3], UINT8_C (0x80), UINT8_C (0xBF))) || - (_mongoc_utf8_code_unit_in_range ( - temp_c[0], UINT8_C (0xF1), UINT8_C (0xF3)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[1], UINT8_C (0x80), UINT8_C (0xBF)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[2], UINT8_C (0x80), UINT8_C (0xBF)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[3], UINT8_C (0x80), UINT8_C (0xBF))) || - (_mongoc_utf8_code_unit_in_range ( - temp_c[0], UINT8_C (0xF4), UINT8_C (0xF4)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[1], UINT8_C (0x80), UINT8_C (0x8F)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[2], UINT8_C (0x80), UINT8_C (0xBF)) && - _mongoc_utf8_code_unit_in_range ( - temp_c[3], UINT8_C (0x80), UINT8_C (0xBF))); - default: - return true; - } -} - - -bool -_mongoc_utf8_code_unit_in_range (const uint8_t c, - const uint8_t lower, - const uint8_t upper) -{ - return (c >= lower && c <= upper); -} - -bool -_mongoc_utf8_code_point_is_in_table (uint32_t code, - const uint32_t *table, - size_t size) -{ - BSON_ASSERT_PARAM (table); - - // all tables have size / 2 ranges - for (size_t i = 0; i < size; i += 2) { - if (code >= table[i] && code <= table[i + 1]) - return true; - } - - return false; -} - -uint32_t -_mongoc_utf8_get_first_code_point (const char *c, size_t length) -{ - BSON_ASSERT_PARAM (c); - - uint8_t *temp_c = (uint8_t *) c; - switch (length) { - case 1: - return (uint32_t) temp_c[0]; - case 2: - return (uint32_t) (((temp_c[0] & UINT8_C (0x1f)) << 6) | - (temp_c[1] & UINT8_C (0x3f))); - case 3: - return (uint32_t) (((temp_c[0] & UINT8_C (0x0f)) << 12) | - ((temp_c[1] & UINT8_C (0x3f)) << 6) | - (temp_c[2] & UINT8_C (0x3f))); - case 4: - return (uint32_t) (((temp_c[0] & UINT8_C (0x07)) << 18) | - ((temp_c[1] & UINT8_C (0x3f)) << 12) | - ((temp_c[2] & UINT8_C (0x3f)) << 6) | - (temp_c[3] & UINT8_C (0x3f))); - default: - return 0; - } -} - -ssize_t -_mongoc_utf8_code_point_to_str (uint32_t c, char *out) -{ - BSON_ASSERT_PARAM (out); - - uint8_t *ptr = (uint8_t *) out; - - if (c <= UINT8_C (0x7F)) { - // Plain ASCII - ptr[0] = (uint8_t) c; - return 1; - } else if (c <= 0x07FF) { - // 2-byte unicode - ptr[0] = (uint8_t) (((c >> 6) & UINT8_C (0x1F)) | UINT8_C (0xC0)); - ptr[1] = (uint8_t) (((c >> 0) & UINT8_C (0x3F)) | UINT8_C (0x80)); - return 2; - } else if (c <= 0xFFFF) { - // 3-byte unicode - ptr[0] = (uint8_t) (((c >> 12) & UINT8_C (0x0F)) | UINT8_C (0xE0)); - ptr[1] = (uint8_t) (((c >> 6) & UINT8_C (0x3F)) | UINT8_C (0x80)); - ptr[2] = (uint8_t) ((c & UINT8_C (0x3F)) | UINT8_C (0x80)); - return 3; - } else if (c <= 0x10FFFF) { - // 4-byte unicode - ptr[0] = (uint8_t) (((c >> 18) & UINT8_C (0x07)) | UINT8_C (0xF0)); - ptr[1] = (uint8_t) (((c >> 12) & UINT8_C (0x3F)) | UINT8_C (0x80)); - ptr[2] = (uint8_t) (((c >> 6) & UINT8_C (0x3F)) | UINT8_C (0x80)); - ptr[3] = (uint8_t) ((c & UINT8_C (0x3F)) | UINT8_C (0x80)); - return 4; - } else { - return -1; - } -} - -ssize_t -_mongoc_utf8_code_point_length (uint32_t c) -{ - if (c <= UINT8_C (0x7F)) - return 1; - else if (c <= 0x07FF) - return 2; - else if (c <= 0xFFFF) - return 3; - else if (c <= 0x10FFFF) - return 4; - else - return -1; -} - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-channel-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-channel-private.h deleted file mode 100644 index 78e6b0458..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-channel-private.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_SECURE_CHANNEL_PRIVATE_H -#define MONGOC_SECURE_CHANNEL_PRIVATE_H - -#include - -#include "mongoc-ssl.h" -#include "mongoc-stream-tls.h" -#include "mongoc-stream-tls-secure-channel-private.h" - -#define SECURITY_WIN32 -#include -#include -#include - -BSON_BEGIN_DECLS - - -char * -_mongoc_secure_channel_extract_subject (const char *filename, - const char *passphrase); - -bool -mongoc_secure_channel_setup_ca ( - mongoc_stream_tls_secure_channel_t *secure_channel, mongoc_ssl_opt_t *opt); - -bool -mongoc_secure_channel_setup_crl ( - mongoc_stream_tls_secure_channel_t *secure_channel, mongoc_ssl_opt_t *opt); - -ssize_t -mongoc_secure_channel_read (mongoc_stream_tls_t *tls, - void *data, - size_t data_length); - -ssize_t -mongoc_secure_channel_write (mongoc_stream_tls_t *tls, - const void *data, - size_t data_length); - -PCCERT_CONTEXT -mongoc_secure_channel_setup_certificate ( - mongoc_stream_tls_secure_channel_t *secure_channel, mongoc_ssl_opt_t *opt); - - -/* it may require 16k + some overhead to hold one decryptable block of data - do - * what cURL does, add 1k */ -#define MONGOC_SCHANNEL_BUFFER_INIT_SIZE (17 * 1024) - -void -_mongoc_secure_channel_init_sec_buffer (SecBuffer *buffer, - unsigned long buf_type, - void *buf_data_ptr, - unsigned long buf_byte_size); - -void -_mongoc_secure_channel_init_sec_buffer_desc (SecBufferDesc *desc, - SecBuffer *buffer_array, - unsigned long buffer_count); - -void -mongoc_secure_channel_realloc_buf (size_t *size, - uint8_t **buf, - size_t new_size); - -bool -mongoc_secure_channel_handshake_step_1 (mongoc_stream_tls_t *tls, - char *hostname, - bson_error_t *error); -bool -mongoc_secure_channel_handshake_step_2 (mongoc_stream_tls_t *tls, - char *hostname, - bson_error_t *error); -bool -mongoc_secure_channel_handshake_step_3 (mongoc_stream_tls_t *tls, - char *hostname, - bson_error_t *error); - -BSON_END_DECLS - - -#endif /* MONGOC_SECURE_CHANNEL_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-channel.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-channel.c deleted file mode 100644 index fd2007a59..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-channel.c +++ /dev/null @@ -1,1020 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SSL_SECURE_CHANNEL - -#include - -#include "mongoc-log.h" -#include "mongoc-trace-private.h" -#include "mongoc-ssl.h" -#include "mongoc-stream-tls.h" -#include "mongoc-stream-tls-private.h" -#include "mongoc-secure-channel-private.h" -#include "mongoc-stream-tls-secure-channel-private.h" -#include "mongoc-errno-private.h" -#include "mongoc-error.h" - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "stream-secure-channel" - -/* mingw doesn't define this */ -#ifndef SECBUFFER_ALERT -#define SECBUFFER_ALERT 17 -#endif - - -PCCERT_CONTEXT -mongoc_secure_channel_setup_certificate_from_file (const char *filename) -{ - char *pem; - FILE *file; - bool success; - HCRYPTKEY hKey; - long pem_length; - HCRYPTPROV provider; - CERT_BLOB public_blob; - const char *pem_public; - const char *pem_private; - LPBYTE blob_private = NULL; - PCCERT_CONTEXT cert = NULL; - DWORD blob_private_len = 0; - DWORD encrypted_private_len = 0; - LPBYTE encrypted_private = NULL; - - - file = fopen (filename, "rb"); - if (!file) { - MONGOC_ERROR ("Couldn't open file '%s'", filename); - return false; - } - - fseek (file, 0, SEEK_END); - pem_length = ftell (file); - fseek (file, 0, SEEK_SET); - if (pem_length < 1) { - MONGOC_ERROR ("Couldn't determine file size of '%s'", filename); - return false; - } - - pem = (char *) bson_malloc0 (pem_length); - fread ((void *) pem, 1, pem_length, file); - fclose (file); - - pem_public = strstr (pem, "-----BEGIN CERTIFICATE-----"); - pem_private = strstr (pem, "-----BEGIN ENCRYPTED PRIVATE KEY-----"); - - if (pem_private) { - MONGOC_ERROR ("Detected unsupported encrypted private key"); - goto fail; - } - - pem_private = strstr (pem, "-----BEGIN RSA PRIVATE KEY-----"); - if (!pem_private) { - pem_private = strstr (pem, "-----BEGIN PRIVATE KEY-----"); - } - - if (!pem_private) { - MONGOC_ERROR ("Can't find private key in '%s'", filename); - goto fail; - } - - public_blob.cbData = (DWORD) strlen (pem_public); - public_blob.pbData = (BYTE *) pem_public; - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa380264%28v=vs.85%29.aspx - */ - CryptQueryObject ( - CERT_QUERY_OBJECT_BLOB, /* dwObjectType, blob or file */ - &public_blob, /* pvObject, Unicode filename */ - CERT_QUERY_CONTENT_FLAG_ALL, /* dwExpectedContentTypeFlags */ - CERT_QUERY_FORMAT_FLAG_ALL, /* dwExpectedFormatTypeFlags */ - 0, /* dwFlags, reserved for "future use" */ - NULL, /* pdwMsgAndCertEncodingType, OUT, unused */ - NULL, /* pdwContentType (dwExpectedContentTypeFlags), OUT, unused */ - NULL, /* pdwFormatType (dwExpectedFormatTypeFlags,), OUT, unused */ - NULL, /* phCertStore, OUT, HCERTSTORE.., unused, for now */ - NULL, /* phMsg, OUT, HCRYPTMSG, only for PKC7, unused */ - (const void **) &cert /* ppvContext, OUT, the Certificate Context */ - ); - - if (!cert) { - MONGOC_ERROR ("Failed to extract public key from '%s'. Error 0x%.8X", - filename, - (unsigned int) GetLastError ()); - goto fail; - } - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa380285%28v=vs.85%29.aspx - */ - success = - CryptStringToBinaryA (pem_private, /* pszString */ - 0, /* cchString */ - CRYPT_STRING_BASE64HEADER, /* dwFlags */ - NULL, /* pbBinary */ - &encrypted_private_len, /* pcBinary, IN/OUT */ - NULL, /* pdwSkip */ - NULL); /* pdwFlags */ - if (!success) { - MONGOC_ERROR ("Failed to convert base64 private key. Error 0x%.8X", - (unsigned int) GetLastError ()); - goto fail; - } - - encrypted_private = (LPBYTE) bson_malloc0 (encrypted_private_len); - success = CryptStringToBinaryA (pem_private, - 0, - CRYPT_STRING_BASE64HEADER, - encrypted_private, - &encrypted_private_len, - NULL, - NULL); - if (!success) { - MONGOC_ERROR ("Failed to convert base64 private key. Error 0x%.8X", - (unsigned int) GetLastError ()); - goto fail; - } - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa379912%28v=vs.85%29.aspx - */ - success = CryptDecodeObjectEx ( - X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, /* dwCertEncodingType */ - PKCS_RSA_PRIVATE_KEY, /* lpszStructType */ - encrypted_private, /* pbEncoded */ - encrypted_private_len, /* cbEncoded */ - 0, /* dwFlags */ - NULL, /* pDecodePara */ - NULL, /* pvStructInfo */ - &blob_private_len); /* pcbStructInfo */ - if (!success) { - LPTSTR msg = NULL; - FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_ARGUMENT_ARRAY, - NULL, - GetLastError (), - LANG_NEUTRAL, - (LPTSTR) &msg, - 0, - NULL); - MONGOC_ERROR ("Failed to parse private key. %s (0x%.8X)", - msg, - (unsigned int) GetLastError ()); - LocalFree (msg); - goto fail; - } - - blob_private = (LPBYTE) bson_malloc0 (blob_private_len); - success = CryptDecodeObjectEx (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, - PKCS_RSA_PRIVATE_KEY, - encrypted_private, - encrypted_private_len, - 0, - NULL, - blob_private, - &blob_private_len); - if (!success) { - MONGOC_ERROR ("Failed to parse private key. Error 0x%.8X", - (unsigned int) GetLastError ()); - goto fail; - } - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa379886%28v=vs.85%29.aspx - */ - success = CryptAcquireContext (&provider, /* phProv */ - NULL, /* pszContainer */ - MS_ENHANCED_PROV, /* pszProvider */ - PROV_RSA_FULL, /* dwProvType */ - CRYPT_VERIFYCONTEXT); /* dwFlags */ - if (!success) { - MONGOC_ERROR ("CryptAcquireContext failed with error 0x%.8X", - (unsigned int) GetLastError ()); - goto fail; - } - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa380207%28v=vs.85%29.aspx - */ - success = CryptImportKey (provider, /* hProv */ - blob_private, /* pbData */ - blob_private_len, /* dwDataLen */ - 0, /* hPubKey */ - 0, /* dwFlags */ - &hKey); /* phKey, OUT */ - if (!success) { - MONGOC_ERROR ("CryptImportKey for private key failed with error 0x%.8X", - (unsigned int) GetLastError ()); - goto fail; - } - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa376573%28v=vs.85%29.aspx - */ - success = CertSetCertificateContextProperty ( - cert, /* pCertContext */ - CERT_KEY_PROV_HANDLE_PROP_ID, /* dwPropId */ - 0, /* dwFlags */ - (const void *) provider); /* pvData */ - if (success) { - TRACE ("%s", "Successfully loaded client certificate"); - return cert; - } - - MONGOC_ERROR ("Can't associate private key with public key: 0x%.8X", - (unsigned int) GetLastError ()); - -fail: - SecureZeroMemory (pem, pem_length); - bson_free (pem); - if (encrypted_private) { - SecureZeroMemory (encrypted_private, encrypted_private_len); - bson_free (encrypted_private); - } - - if (blob_private) { - SecureZeroMemory (blob_private, blob_private_len); - bson_free (blob_private); - } - - return NULL; -} - -PCCERT_CONTEXT -mongoc_secure_channel_setup_certificate ( - mongoc_stream_tls_secure_channel_t *secure_channel, mongoc_ssl_opt_t *opt) -{ - return mongoc_secure_channel_setup_certificate_from_file (opt->pem_file); -} - -void -_bson_append_szoid (bson_string_t *retval, - PCCERT_CONTEXT cert, - const char *label, - void *oid) -{ - DWORD oid_len = - CertGetNameString (cert, CERT_NAME_ATTR_TYPE, 0, oid, NULL, 0); - - if (oid_len > 1) { - char *tmp = bson_malloc0 (oid_len); - - CertGetNameString (cert, CERT_NAME_ATTR_TYPE, 0, oid, tmp, oid_len); - bson_string_append_printf (retval, "%s%s", label, tmp); - bson_free (tmp); - } -} -char * -_mongoc_secure_channel_extract_subject (const char *filename, - const char *passphrase) -{ - bson_string_t *retval; - PCCERT_CONTEXT cert; - - cert = mongoc_secure_channel_setup_certificate_from_file (filename); - if (!cert) { - return NULL; - } - - retval = bson_string_new (""); - ; - _bson_append_szoid (retval, cert, "C=", szOID_COUNTRY_NAME); - _bson_append_szoid (retval, cert, ",ST=", szOID_STATE_OR_PROVINCE_NAME); - _bson_append_szoid (retval, cert, ",L=", szOID_LOCALITY_NAME); - _bson_append_szoid (retval, cert, ",O=", szOID_ORGANIZATION_NAME); - _bson_append_szoid (retval, cert, ",OU=", szOID_ORGANIZATIONAL_UNIT_NAME); - _bson_append_szoid (retval, cert, ",CN=", szOID_COMMON_NAME); - _bson_append_szoid (retval, cert, ",STREET=", szOID_STREET_ADDRESS); - - return bson_string_free (retval, false); -} - -bool -mongoc_secure_channel_setup_ca ( - mongoc_stream_tls_secure_channel_t *secure_channel, mongoc_ssl_opt_t *opt) -{ - FILE *file; - long length; - const char *pem_key; - HCERTSTORE cert_store = NULL; - PCCERT_CONTEXT cert = NULL; - DWORD encrypted_cert_len = 0; - LPBYTE encrypted_cert = NULL; - - file = fopen (opt->ca_file, "rb"); - if (!file) { - MONGOC_ERROR ("Couldn't open file '%s'", opt->ca_file); - return false; - } - - fseek (file, 0, SEEK_END); - length = ftell (file); - fseek (file, 0, SEEK_SET); - if (length < 1) { - MONGOC_WARNING ("Couldn't determine file size of '%s'", opt->ca_file); - return false; - } - - pem_key = (const char *) bson_malloc0 (length); - fread ((void *) pem_key, 1, length, file); - fclose (file); - - /* If we have private keys or other fuzz, seek to the good stuff */ - pem_key = strstr (pem_key, "-----BEGIN CERTIFICATE-----"); - /*printf ("%s\n", pem_key);*/ - - if (!pem_key) { - MONGOC_WARNING ("Couldn't find certificate in '%s'", opt->ca_file); - return false; - } - - if (!CryptStringToBinaryA (pem_key, - 0, - CRYPT_STRING_BASE64HEADER, - NULL, - &encrypted_cert_len, - NULL, - NULL)) { - MONGOC_ERROR ("Failed to convert BASE64 public key. Error 0x%.8X", - (unsigned int) GetLastError ()); - return false; - } - - encrypted_cert = (LPBYTE) LocalAlloc (0, encrypted_cert_len); - if (!CryptStringToBinaryA (pem_key, - 0, - CRYPT_STRING_BASE64HEADER, - encrypted_cert, - &encrypted_cert_len, - NULL, - NULL)) { - MONGOC_ERROR ("Failed to convert BASE64 public key. Error 0x%.8X", - (unsigned int) GetLastError ()); - return false; - } - - cert = CertCreateCertificateContext ( - X509_ASN_ENCODING, encrypted_cert, encrypted_cert_len); - if (!cert) { - MONGOC_WARNING ("Could not convert certificate"); - return false; - } - - - cert_store = CertOpenStore ( - CERT_STORE_PROV_SYSTEM, /* provider */ - X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, /* certificate encoding */ - 0, /* unused */ - CERT_SYSTEM_STORE_LOCAL_MACHINE, /* dwFlags */ - L"Root"); /* system store name. "My" or "Root" */ - - if (cert_store == NULL) { - MONGOC_ERROR ("Error opening certificate store"); - return false; - } - - if (CertAddCertificateContextToStore ( - cert_store, cert, CERT_STORE_ADD_USE_EXISTING, NULL)) { - TRACE ("%s", "Added the certificate !"); - CertCloseStore (cert_store, 0); - return true; - } - MONGOC_WARNING ("Failed adding the cert"); - CertCloseStore (cert_store, 0); - - return false; -} - -bool -mongoc_secure_channel_setup_crl ( - mongoc_stream_tls_secure_channel_t *secure_channel, mongoc_ssl_opt_t *opt) -{ - HCERTSTORE cert_store = NULL; - PCCERT_CONTEXT cert = NULL; - LPWSTR str; - int chars; - - chars = MultiByteToWideChar (CP_ACP, 0, opt->crl_file, -1, NULL, 0); - if (chars < 1) { - MONGOC_WARNING ("Can't determine opt->crl_file length"); - return false; - } - str = (LPWSTR) bson_malloc0 (chars * sizeof (*str)); - MultiByteToWideChar (CP_ACP, 0, opt->crl_file, -1, str, chars); - - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa380264%28v=vs.85%29.aspx - */ - CryptQueryObject ( - CERT_QUERY_OBJECT_FILE, /* dwObjectType, blob or file */ - str, /* pvObject, Unicode filename */ - CERT_QUERY_CONTENT_FLAG_CRL, /* dwExpectedContentTypeFlags */ - CERT_QUERY_FORMAT_FLAG_ALL, /* dwExpectedFormatTypeFlags */ - 0, /* dwFlags, reserved for "future use" */ - NULL, /* pdwMsgAndCertEncodingType, OUT, unused */ - NULL, /* pdwContentType (dwExpectedContentTypeFlags), OUT, unused */ - NULL, /* pdwFormatType (dwExpectedFormatTypeFlags,), OUT, unused */ - NULL, /* phCertStore, OUT, HCERTSTORE.., unused, for now */ - NULL, /* phMsg, OUT, HCRYPTMSG, only for PKC7, unused */ - (const void **) &cert /* ppvContext, OUT, the Certificate Context */ - ); - bson_free (str); - - if (!cert) { - MONGOC_WARNING ("Can't extract CRL from '%s'", opt->crl_file); - return false; - } - - - cert_store = CertOpenStore ( - CERT_STORE_PROV_SYSTEM, /* provider */ - X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, /* certificate encoding */ - 0, /* unused */ - CERT_SYSTEM_STORE_LOCAL_MACHINE, /* dwFlags */ - L"Root"); /* system store name. "My" or "Root" */ - - if (cert_store == NULL) { - MONGOC_ERROR ("Error opening certificate store"); - CertFreeCertificateContext (cert); - return false; - } - - if (CertAddCertificateContextToStore ( - cert_store, cert, CERT_STORE_ADD_USE_EXISTING, NULL)) { - TRACE ("%s", "Added the certificate !"); - CertFreeCertificateContext (cert); - CertCloseStore (cert_store, 0); - return true; - } - - MONGOC_WARNING ("Failed adding the cert"); - CertFreeCertificateContext (cert); - CertCloseStore (cert_store, 0); - - return false; -} - -ssize_t -mongoc_secure_channel_read (mongoc_stream_tls_t *tls, - void *data, - size_t data_length) -{ - BSON_ASSERT_PARAM (tls); - - if (BSON_UNLIKELY (!bson_in_range_signed (int32_t, tls->timeout_msec))) { - // CDRIVER-4589 - MONGOC_ERROR ("timeout_msec value %" PRId64 - " exceeds supported 32-bit range", - tls->timeout_msec); - return -1; - } - - errno = 0; - TRACE ("Wanting to read: %zu, timeout is %" PRIu64, - data_length, - tls->timeout_msec); - /* 4th argument is minimum bytes, while the data_length is the - * size of the buffer. We are totally fine with just one TLS record (few - *bytes) - **/ - const ssize_t length = mongoc_stream_read ( - tls->base_stream, data, data_length, 0, (int32_t) tls->timeout_msec); - - TRACE ("Got %zd", length); - - if (length > 0) { - return length; - } - - return 0; -} - -ssize_t -mongoc_secure_channel_write (mongoc_stream_tls_t *tls, - const void *data, - size_t data_length) -{ - BSON_ASSERT_PARAM (tls); - - if (BSON_UNLIKELY (!bson_in_range_signed (int32_t, tls->timeout_msec))) { - // CDRIVER-4589 - MONGOC_ERROR ("timeout_msec value %" PRId64 - " exceeds supported 32-bit range", - tls->timeout_msec); - return -1; - } - - errno = 0; - TRACE ("Wanting to write: %zu", data_length); - const ssize_t length = mongoc_stream_write (tls->base_stream, - (void *) data, - data_length, - (int32_t) tls->timeout_msec); - TRACE ("Wrote: %zd", length); - - return length; -} - -void -mongoc_secure_channel_realloc_buf (size_t *size, uint8_t **buf, size_t new_size) -{ - *size = bson_next_power_of_two (new_size); - *buf = bson_realloc (*buf, *size); -} - -/** - * The follow functions comes from one of my favorite project, cURL! - * Thank you so much for having gone through the Secure Channel pain for me. - * - * - * Copyright (C) 2012 - 2015, Marc Hoersken, - * Copyright (C) 2012, Mark Salisbury, - * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* - * Based upon the PolarSSL implementation in polarssl.c and polarssl.h: - * Copyright (C) 2010, 2011, Hoi-Ho Chan, - * - * Based upon the CyaSSL implementation in cyassl.c and cyassl.h: - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. - * - * Thanks for code and inspiration! - */ - -void -_mongoc_secure_channel_init_sec_buffer (SecBuffer *buffer, - unsigned long buf_type, - void *buf_data_ptr, - unsigned long buf_byte_size) -{ - buffer->cbBuffer = buf_byte_size; - buffer->BufferType = buf_type; - buffer->pvBuffer = buf_data_ptr; -} - -void -_mongoc_secure_channel_init_sec_buffer_desc (SecBufferDesc *desc, - SecBuffer *buffer_array, - unsigned long buffer_count) -{ - desc->ulVersion = SECBUFFER_VERSION; - desc->pBuffers = buffer_array; - desc->cBuffers = buffer_count; -} - - -#define MONGOC_LOG_AND_SET_ERROR(ERROR, DOMAIN, CODE, ...) \ - do { \ - MONGOC_ERROR (__VA_ARGS__); \ - bson_set_error (ERROR, DOMAIN, CODE, __VA_ARGS__); \ - } while (0) - -bool -mongoc_secure_channel_handshake_step_1 (mongoc_stream_tls_t *tls, - char *hostname, - bson_error_t *error) -{ - SecBuffer outbuf; - ssize_t written = -1; - SecBufferDesc outbuf_desc; - SECURITY_STATUS sspi_status = SEC_E_OK; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - - TRACE ("SSL/TLS connection with '%s' (step 1/3)", hostname); - - /* setup output buffer */ - _mongoc_secure_channel_init_sec_buffer (&outbuf, SECBUFFER_EMPTY, NULL, 0); - _mongoc_secure_channel_init_sec_buffer_desc (&outbuf_desc, &outbuf, 1); - - /* setup request flags */ - secure_channel->req_flags = ISC_REQ_SEQUENCE_DETECT | ISC_REQ_REPLAY_DETECT | - ISC_REQ_CONFIDENTIALITY | - ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_STREAM; - - /* allocate memory for the security context handle */ - secure_channel->ctxt = (mongoc_secure_channel_ctxt *) bson_malloc0 ( - sizeof (mongoc_secure_channel_ctxt)); - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa375924.aspx */ - sspi_status = InitializeSecurityContext ( - &secure_channel->cred->cred_handle, /* phCredential */ - NULL, /* phContext */ - hostname, /* pszTargetName */ - secure_channel->req_flags, /* fContextReq */ - 0, /* Reserved1, must be 0 */ - 0, /* TargetDataRep, unused */ - NULL, /* pInput */ - 0, /* Reserved2, must be 0 */ - &secure_channel->ctxt->ctxt_handle, /* phNewContext OUT param */ - &outbuf_desc, /* pOutput OUT param */ - &secure_channel->ret_flags, /* pfContextAttr OUT param */ - &secure_channel->ctxt->time_stamp /* ptsExpiry OUT param */ - ); - - if (sspi_status != SEC_I_CONTINUE_NEEDED) { - MONGOC_LOG_AND_SET_ERROR (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "initial InitializeSecurityContext failed: %ld", - sspi_status); - return false; - } - - TRACE ("sending initial handshake data: sending %lu bytes...", - outbuf.cbBuffer); - - /* send initial handshake data which is now stored in output buffer */ - written = - mongoc_secure_channel_write (tls, outbuf.pvBuffer, outbuf.cbBuffer); - FreeContextBuffer (outbuf.pvBuffer); - - if (outbuf.cbBuffer != (size_t) written) { - MONGOC_LOG_AND_SET_ERROR (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "failed to send initial handshake data: " - "sent %zd of %lu bytes", - written, - outbuf.cbBuffer); - return false; - } - - TRACE ("sent initial handshake data: sent %zd bytes", written); - - secure_channel->recv_unrecoverable_err = 0; - secure_channel->recv_sspi_close_notify = false; - secure_channel->recv_connection_closed = false; - - /* continue to second handshake step */ - secure_channel->connecting_state = ssl_connect_2; - - return true; -} - -bool -mongoc_secure_channel_handshake_step_2 (mongoc_stream_tls_t *tls, - char *hostname, - bson_error_t *error) -{ - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - SECURITY_STATUS sspi_status = SEC_E_OK; - ssize_t nread = -1, written = -1; - SecBufferDesc outbuf_desc; - SecBufferDesc inbuf_desc; - SecBuffer outbuf[3]; - SecBuffer inbuf[2]; - bool doread; - int i; - - doread = (secure_channel->connecting_state != ssl_connect_2_writing) ? true - : false; - - TRACE ("%s", "SSL/TLS connection with endpoint (step 2/3)"); - - if (!secure_channel->cred || !secure_channel->ctxt) { - MONGOC_LOG_AND_SET_ERROR ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "required TLS credentials or context not provided"); - - return false; - } - - /* grow the buffer if necessary */ - if (secure_channel->encdata_length == secure_channel->encdata_offset) { - mongoc_secure_channel_realloc_buf (&secure_channel->encdata_length, - &secure_channel->encdata_buffer, - secure_channel->encdata_length + 1); - } - - for (;;) { - if (doread) { - /* read encrypted handshake data from socket */ - nread = mongoc_secure_channel_read ( - tls, - (char *) (secure_channel->encdata_buffer + - secure_channel->encdata_offset), - secure_channel->encdata_length - secure_channel->encdata_offset); - - if (!nread) { - if (MONGOC_ERRNO_IS_AGAIN (errno)) { - if (secure_channel->connecting_state != ssl_connect_2_writing) { - secure_channel->connecting_state = ssl_connect_2_reading; - } - - TRACE ("%s", "failed to receive handshake, need more data"); - return true; - } - - MONGOC_LOG_AND_SET_ERROR ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "failed to receive handshake, SSL/TLS connection failed"); - - return false; - } - - /* increase encrypted data buffer offset */ - secure_channel->encdata_offset += nread; - } - - TRACE ("encrypted data buffer: offset %d length %d", - (int) secure_channel->encdata_offset, - (int) secure_channel->encdata_length); - - /* setup input buffers */ - _mongoc_secure_channel_init_sec_buffer ( - &inbuf[0], - SECBUFFER_TOKEN, - bson_malloc (secure_channel->encdata_offset), - (unsigned long) (secure_channel->encdata_offset & - (size_t) 0xFFFFFFFFUL)); - _mongoc_secure_channel_init_sec_buffer ( - &inbuf[1], SECBUFFER_EMPTY, NULL, 0); - _mongoc_secure_channel_init_sec_buffer_desc (&inbuf_desc, inbuf, 2); - - /* setup output buffers */ - _mongoc_secure_channel_init_sec_buffer ( - &outbuf[0], SECBUFFER_TOKEN, NULL, 0); - _mongoc_secure_channel_init_sec_buffer ( - &outbuf[1], SECBUFFER_ALERT, NULL, 0); - _mongoc_secure_channel_init_sec_buffer ( - &outbuf[2], SECBUFFER_EMPTY, NULL, 0); - _mongoc_secure_channel_init_sec_buffer_desc (&outbuf_desc, outbuf, 3); - - if (inbuf[0].pvBuffer == NULL) { - MONGOC_LOG_AND_SET_ERROR (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "unable to allocate memory"); - return false; - } - - /* copy received handshake data into input buffer */ - memcpy (inbuf[0].pvBuffer, - secure_channel->encdata_buffer, - secure_channel->encdata_offset); - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa375924.aspx - */ - sspi_status = - InitializeSecurityContext (&secure_channel->cred->cred_handle, - &secure_channel->ctxt->ctxt_handle, - hostname, - secure_channel->req_flags, - 0, - 0, - &inbuf_desc, - 0, - NULL, - &outbuf_desc, - &secure_channel->ret_flags, - &secure_channel->ctxt->time_stamp); - - /* free buffer for received handshake data */ - bson_free (inbuf[0].pvBuffer); - - /* check if the handshake was incomplete */ - if (sspi_status == SEC_E_INCOMPLETE_MESSAGE) { - secure_channel->connecting_state = ssl_connect_2_reading; - TRACE ("%s", "received incomplete message, need more data"); - return true; - } - - /* If the server has requested a client certificate, attempt to continue - * the handshake without one. This will allow connections to servers which - * request a client certificate but do not require it. */ - if (sspi_status == SEC_I_INCOMPLETE_CREDENTIALS && - !(secure_channel->req_flags & ISC_REQ_USE_SUPPLIED_CREDS)) { - secure_channel->req_flags |= ISC_REQ_USE_SUPPLIED_CREDS; - secure_channel->connecting_state = ssl_connect_2_writing; - TRACE ("%s", "A client certificate has been requested"); - return true; - } - - /* check if the handshake needs to be continued */ - if (sspi_status == SEC_I_CONTINUE_NEEDED || sspi_status == SEC_E_OK) { - for (i = 0; i < 3; i++) { - /* search for handshake tokens that need to be send */ - if (outbuf[i].BufferType == SECBUFFER_TOKEN && - outbuf[i].cbBuffer > 0) { - TRACE ("sending next handshake data: sending %lu bytes...", - outbuf[i].cbBuffer); - - /* send handshake token to server */ - written = mongoc_secure_channel_write ( - tls, outbuf[i].pvBuffer, outbuf[i].cbBuffer); - - if (outbuf[i].cbBuffer != (size_t) written) { - MONGOC_LOG_AND_SET_ERROR ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "failed to send next handshake data: " - "sent %zd of %lu bytes", - written, - outbuf[i].cbBuffer); - return false; - } - } - - /* free obsolete buffer */ - if (outbuf[i].pvBuffer != NULL) { - FreeContextBuffer (outbuf[i].pvBuffer); - } - } - } else { - switch (sspi_status) { - case SEC_E_WRONG_PRINCIPAL: - MONGOC_LOG_AND_SET_ERROR ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "SSL Certification verification failed: hostname " - "doesn't match certificate"); - break; - - case SEC_E_UNTRUSTED_ROOT: - MONGOC_LOG_AND_SET_ERROR ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "SSL Certification verification failed: Untrusted " - "root certificate"); - break; - - case SEC_E_CERT_EXPIRED: - MONGOC_LOG_AND_SET_ERROR ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "SSL Certification verification failed: certificate " - "has expired"); - break; - case CRYPT_E_NO_REVOCATION_CHECK: - MONGOC_LOG_AND_SET_ERROR ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "SSL Certification verification failed: certificate " - "does not include revocation check."); - break; - - case SEC_E_INSUFFICIENT_MEMORY: - case SEC_E_INTERNAL_ERROR: - case SEC_E_INVALID_HANDLE: - case SEC_E_INVALID_TOKEN: - case SEC_E_LOGON_DENIED: - case SEC_E_NO_AUTHENTICATING_AUTHORITY: - case SEC_E_NO_CREDENTIALS: - case SEC_E_TARGET_UNKNOWN: - case SEC_E_UNSUPPORTED_FUNCTION: -#ifdef SEC_E_APPLICATION_PROTOCOL_MISMATCH - /* Not available in VS2010 */ - case SEC_E_APPLICATION_PROTOCOL_MISMATCH: -#endif - - - default: { - LPTSTR msg = NULL; - - FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_ARGUMENT_ARRAY, - NULL, - GetLastError (), - LANG_NEUTRAL, - (LPTSTR) &msg, - 0, - NULL); - MONGOC_LOG_AND_SET_ERROR ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to initialize security context, error code: " - "0x%04X%04X: %s", - (unsigned int) (sspi_status >> 16) & 0xffff, - (unsigned int) sspi_status & 0xffff, - msg); - LocalFree (msg); - } - } - return false; - } - - /* check if there was additional remaining encrypted data */ - if (inbuf[1].BufferType == SECBUFFER_EXTRA && inbuf[1].cbBuffer > 0) { - TRACE ("encrypted data length: %lu", inbuf[1].cbBuffer); - - /* - * There are two cases where we could be getting extra data here: - * 1) If we're renegotiating a connection and the handshake is already - * complete (from the server perspective), it can encrypted app data - * (not handshake data) in an extra buffer at this point. - * 2) (sspi_status == SEC_I_CONTINUE_NEEDED) We are negotiating a - * connection and this extra data is part of the handshake. - * We should process the data immediately; waiting for the socket to - * be ready may fail since the server is done sending handshake data. - */ - /* check if the remaining data is less than the total amount - * and therefore begins after the already processed data */ - if (secure_channel->encdata_offset > inbuf[1].cbBuffer) { - memmove (secure_channel->encdata_buffer, - (secure_channel->encdata_buffer + - secure_channel->encdata_offset) - - inbuf[1].cbBuffer, - inbuf[1].cbBuffer); - secure_channel->encdata_offset = inbuf[1].cbBuffer; - - if (sspi_status == SEC_I_CONTINUE_NEEDED) { - doread = FALSE; - continue; - } - } - } else { - secure_channel->encdata_offset = 0; - } - - break; - } - - /* check if the handshake needs to be continued */ - if (sspi_status == SEC_I_CONTINUE_NEEDED) { - secure_channel->connecting_state = ssl_connect_2_reading; - return true; - } - - /* check if the handshake is complete */ - if (sspi_status == SEC_E_OK) { - secure_channel->connecting_state = ssl_connect_3; - TRACE ("%s", "SSL/TLS handshake complete"); - } - - return true; -} - -bool -mongoc_secure_channel_handshake_step_3 (mongoc_stream_tls_t *tls, - char *hostname, - bson_error_t *error) -{ - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - - BSON_ASSERT (ssl_connect_3 == secure_channel->connecting_state); - - TRACE ("SSL/TLS connection with %s (step 3/3)", hostname); - - if (!secure_channel->cred) { - MONGOC_LOG_AND_SET_ERROR (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "required TLS credentials not provided"); - return false; - } - - /* check if the required context attributes are met */ - if (secure_channel->ret_flags != secure_channel->req_flags) { - MONGOC_LOG_AND_SET_ERROR (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed handshake"); - - return false; - } - - secure_channel->connecting_state = ssl_connect_done; - - return true; -} -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-transport-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-transport-private.h deleted file mode 100644 index c54038373..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-transport-private.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_SECURE_TRANSPORT_PRIVATE_H -#define MONGOC_SECURE_TRANSPORT_PRIVATE_H - -#include - -#include "mongoc-ssl.h" -#include "mongoc-stream-tls-secure-transport-private.h" -#include - - -BSON_BEGIN_DECLS - -char * -_mongoc_cfstringref_to_cstring (CFStringRef ref); - -char * -_mongoc_secure_transport_extract_subject (const char *filename, - const char *passphrase); - -OSStatus -mongoc_secure_transport_write (SSLConnectionRef connection, - const void *data, - size_t *data_length); -OSStatus -mongoc_secure_transport_read (SSLConnectionRef connection, - void *data, - size_t *data_length); - -bool -mongoc_secure_transport_setup_ca ( - mongoc_stream_tls_secure_transport_t *secure_transport, - mongoc_ssl_opt_t *opt); - -bool -mongoc_secure_transport_setup_certificate ( - mongoc_stream_tls_secure_transport_t *secure_transport, - mongoc_ssl_opt_t *opt); - -void -CFReleaseSafe (CFTypeRef cf); - -BSON_END_DECLS - - -#endif /* MONGOC_SECURE_TRANSPORT_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-transport.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-transport.c deleted file mode 100644 index 97437e0d7..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-secure-transport.c +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SSL_SECURE_TRANSPORT - -#include - -#include "mongoc-log.h" -#include "mongoc-trace-private.h" -#include "mongoc-ssl.h" -#include "mongoc-stream-tls.h" -#include "mongoc-stream-tls-private.h" -#include "mongoc-secure-transport-private.h" -#include "mongoc-stream-tls-secure-transport-private.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -/* Jailbreak Darwin Private API */ -/* - * An alternative to using SecIdentityCreate is to use - * SecIdentityCreateWithCertificate with a temporary keychain. However, doing so - * leads to memory bugs. Unfortunately, using this private API seems to be the - * best solution. - */ -SecIdentityRef -SecIdentityCreate (CFAllocatorRef allocator, - SecCertificateRef certificate, - SecKeyRef privateKey); - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "stream-secure_transport" - -char * -_mongoc_cfstringref_to_cstring (CFStringRef str) -{ - CFIndex length; - CFStringEncoding encoding; - CFIndex max_size; - char *cs; - - if (!str) { - return NULL; - } - - if (CFGetTypeID (str) != CFStringGetTypeID ()) { - return NULL; - } - - length = CFStringGetLength (str); - encoding = kCFStringEncodingASCII; - max_size = CFStringGetMaximumSizeForEncoding (length, encoding) + 1; - cs = bson_malloc ((size_t) max_size); - - if (CFStringGetCString (str, cs, max_size, encoding)) { - return cs; - } - - bson_free (cs); - return NULL; -} - -static void -_bson_append_cftyperef (bson_string_t *retval, const char *label, CFTypeRef str) -{ - char *cs; - - if (str) { - cs = _mongoc_cfstringref_to_cstring (str); - - if (cs) { - bson_string_append_printf (retval, "%s%s", label, cs); - bson_free (cs); - } else { - bson_string_append_printf (retval, "%s(null)", label); - } - } -} - -CFTypeRef -_mongoc_secure_transport_dict_get (CFArrayRef values, CFStringRef label) -{ - if (!values || CFGetTypeID (values) != CFArrayGetTypeID ()) { - return NULL; - } - - for (CFIndex i = 0; i < CFArrayGetCount (values); ++i) { - CFStringRef item_label; - CFDictionaryRef item = CFArrayGetValueAtIndex (values, i); - - if (CFGetTypeID (item) != CFDictionaryGetTypeID ()) { - continue; - } - - item_label = CFDictionaryGetValue (item, kSecPropertyKeyLabel); - if (item_label && - CFStringCompare (item_label, label, 0) == kCFCompareEqualTo) { - return CFDictionaryGetValue (item, kSecPropertyKeyValue); - } - } - - return NULL; -} - -char * -_mongoc_secure_transport_RFC2253_from_cert (SecCertificateRef cert) -{ - CFTypeRef value; - bson_string_t *retval; - CFTypeRef subject_name; - CFDictionaryRef cert_dict; - - cert_dict = SecCertificateCopyValues (cert, NULL, NULL); - if (!cert_dict) { - return NULL; - } - - subject_name = CFDictionaryGetValue (cert_dict, kSecOIDX509V1SubjectName); - if (!subject_name) { - CFRelease (cert_dict); - return NULL; - } - - subject_name = CFDictionaryGetValue (subject_name, kSecPropertyKeyValue); - if (!subject_name) { - CFRelease (cert_dict); - return NULL; - } - - retval = bson_string_new (""); - ; - - value = _mongoc_secure_transport_dict_get (subject_name, kSecOIDCountryName); - _bson_append_cftyperef (retval, "C=", value); - - value = _mongoc_secure_transport_dict_get (subject_name, - kSecOIDStateProvinceName); - _bson_append_cftyperef (retval, ",ST=", value); - - value = - _mongoc_secure_transport_dict_get (subject_name, kSecOIDLocalityName); - _bson_append_cftyperef (retval, ",L=", value); - - value = - _mongoc_secure_transport_dict_get (subject_name, kSecOIDOrganizationName); - _bson_append_cftyperef (retval, ",O=", value); - - value = _mongoc_secure_transport_dict_get (subject_name, - kSecOIDOrganizationalUnitName); - if (value) { - /* Can be either one unit name, or array of unit names */ - if (CFGetTypeID (value) == CFStringGetTypeID ()) { - _bson_append_cftyperef (retval, ",OU=", value); - } else if (CFGetTypeID (value) == CFArrayGetTypeID ()) { - CFIndex len = CFArrayGetCount (value); - - if (len > 0) { - _bson_append_cftyperef ( - retval, ",OU=", CFArrayGetValueAtIndex (value, 0)); - } - if (len > 1) { - _bson_append_cftyperef ( - retval, ",", CFArrayGetValueAtIndex (value, 1)); - } - if (len > 2) { - _bson_append_cftyperef ( - retval, ",", CFArrayGetValueAtIndex (value, 2)); - } - } - } - - value = _mongoc_secure_transport_dict_get (subject_name, kSecOIDCommonName); - _bson_append_cftyperef (retval, ",CN=", value); - - value = - _mongoc_secure_transport_dict_get (subject_name, kSecOIDStreetAddress); - _bson_append_cftyperef (retval, ",STREET", value); - - CFRelease (cert_dict); - return bson_string_free (retval, false); -} - - -static void -safe_release (CFTypeRef ref) -{ - if (ref) { - CFRelease (ref); - } -} - - -bool -_mongoc_secure_transport_import_pem (const char *filename, - const char *passphrase, - CFArrayRef *items, - SecExternalItemType *type) -{ - SecExternalFormat format = kSecFormatPEMSequence; - SecItemImportExportKeyParameters params = {0}; - SecTransformRef sec_transform = NULL; - CFReadStreamRef read_stream = NULL; - CFDataRef dataref = NULL; - CFErrorRef error = NULL; - CFURLRef url = NULL; - OSStatus res; - bool r = false; - - if (!filename) { - TRACE ("%s", "No certificate provided"); - return false; - } - - params.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION; - params.flags = 0; - params.passphrase = NULL; - params.alertTitle = NULL; - params.alertPrompt = NULL; - params.accessRef = NULL; - params.keyUsage = NULL; - params.keyAttributes = NULL; - - if (passphrase) { - params.passphrase = CFStringCreateWithCString ( - kCFAllocatorDefault, passphrase, kCFStringEncodingUTF8); - } - - url = CFURLCreateFromFileSystemRepresentation ( - kCFAllocatorDefault, (const UInt8 *) filename, strlen (filename), false); - read_stream = CFReadStreamCreateWithFile (kCFAllocatorDefault, url); - if (!CFReadStreamOpen (read_stream)) { - MONGOC_ERROR ("Cannot find certificate in '%s', error reading file", - filename); - goto done; - } - - sec_transform = SecTransformCreateReadTransformWithReadStream (read_stream); - dataref = SecTransformExecute (sec_transform, &error); - - if (error) { - CFStringRef str = CFErrorCopyDescription (error); - MONGOC_ERROR ( - "Failed importing PEM '%s': %s", - filename, - CFStringGetCStringPtr (str, CFStringGetFastestEncoding (str))); - - CFRelease (str); - goto done; - } - - res = SecItemImport ( - dataref, CFSTR (".pem"), &format, type, 0, ¶ms, NULL, items); - - if (res) { - MONGOC_ERROR ("Failed importing PEM '%s' (code: %d)", filename, res); - goto done; - } - - r = true; - -done: - safe_release (dataref); - safe_release (sec_transform); - safe_release (read_stream); - safe_release (url); - safe_release (params.passphrase); - - return r; -} - -char * -_mongoc_secure_transport_extract_subject (const char *filename, - const char *passphrase) -{ - bool success; - char *retval = NULL; - CFArrayRef items = NULL; - SecExternalItemType type = kSecItemTypeCertificate; - - - success = - _mongoc_secure_transport_import_pem (filename, passphrase, &items, &type); - - if (!success) { - return NULL; - } - - if (type == kSecItemTypeAggregate) { - for (CFIndex i = 0; i < CFArrayGetCount (items); ++i) { - CFTypeID item_id = CFGetTypeID (CFArrayGetValueAtIndex (items, i)); - - if (item_id == SecCertificateGetTypeID ()) { - retval = _mongoc_secure_transport_RFC2253_from_cert ( - (SecCertificateRef) CFArrayGetValueAtIndex (items, i)); - break; - } - } - } else if (type == kSecItemTypeCertificate) { - retval = - _mongoc_secure_transport_RFC2253_from_cert ((SecCertificateRef) items); - } - - if (items) { - CFRelease (items); - } - - return retval; -} - -bool -mongoc_secure_transport_setup_certificate ( - mongoc_stream_tls_secure_transport_t *secure_transport, - mongoc_ssl_opt_t *opt) -{ - bool success; - CFArrayRef items; - SecIdentityRef id; - SecKeyRef key = NULL; - SecCertificateRef cert = NULL; - SecExternalItemType type = kSecItemTypeCertificate; - - if (!opt->pem_file) { - TRACE ("%s", - "No private key provided, the server won't be able to verify us"); - return false; - } - - success = _mongoc_secure_transport_import_pem ( - opt->pem_file, opt->pem_pwd, &items, &type); - if (!success) { - /* caller will log an error */ - return false; - } - - if (type != kSecItemTypeAggregate) { - MONGOC_ERROR ("Cannot work with keys of type \"%d\". Please file a JIRA", - type); - CFRelease (items); - return false; - } - - for (CFIndex i = 0; i < CFArrayGetCount (items); ++i) { - CFTypeID item_id = CFGetTypeID (CFArrayGetValueAtIndex (items, i)); - - if (item_id == SecCertificateGetTypeID ()) { - cert = (SecCertificateRef) CFArrayGetValueAtIndex (items, i); - } else if (item_id == SecKeyGetTypeID ()) { - key = (SecKeyRef) CFArrayGetValueAtIndex (items, i); - } - } - - if (!cert || !key) { - MONGOC_ERROR ("Couldn't find valid private key"); - CFRelease (items); - return false; - } - - id = SecIdentityCreate (kCFAllocatorDefault, cert, key); - secure_transport->my_cert = - CFArrayCreateMutable (kCFAllocatorDefault, 2, &kCFTypeArrayCallBacks); - - CFArrayAppendValue (secure_transport->my_cert, id); - CFArrayAppendValue (secure_transport->my_cert, cert); - CFRelease (id); - - /* - * Secure Transport assumes the following: - * * The certificate references remain valid for the lifetime of the - * session. - * * The identity specified in certRefs[0] is capable of signing. - */ - success = !SSLSetCertificate (secure_transport->ssl_ctx_ref, - secure_transport->my_cert); - TRACE ("Setting client certificate %s", success ? "succeeded" : "failed"); - - CFRelease (items); - return success; -} - -bool -mongoc_secure_transport_setup_ca ( - mongoc_stream_tls_secure_transport_t *secure_transport, - mongoc_ssl_opt_t *opt) -{ - CFArrayRef items; - SecExternalItemType type = kSecItemTypeCertificate; - bool success; - - if (!opt->ca_file) { - TRACE ("%s", "No CA provided, using defaults"); - return false; - } - - success = - _mongoc_secure_transport_import_pem (opt->ca_file, NULL, &items, &type); - - if (!success) { - MONGOC_ERROR ("Cannot load Certificate Authorities from file \'%s\'", - opt->ca_file); - return false; - } - - if (type == kSecItemTypeAggregate) { - CFMutableArrayRef anchors = - CFArrayCreateMutable (kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); - - for (CFIndex i = 0; i < CFArrayGetCount (items); ++i) { - CFTypeID item_id = CFGetTypeID (CFArrayGetValueAtIndex (items, i)); - - if (item_id == SecCertificateGetTypeID ()) { - CFArrayAppendValue (anchors, CFArrayGetValueAtIndex (items, i)); - } - } - secure_transport->anchors = anchors; - CFRelease (items); - } else if (type == kSecItemTypeCertificate) { - secure_transport->anchors = items; - } else { - CFRelease (items); - } - - /* This should be SSLSetCertificateAuthorities But the /TLS/ tests fail - * when it is */ - success = !SSLSetTrustedRoots ( - secure_transport->ssl_ctx_ref, secure_transport->anchors, true); - TRACE ("Setting certificate authority %s (%s)", - success ? "succeeded" : "failed", - opt->ca_file); - return success; -} - -OSStatus -mongoc_secure_transport_read (SSLConnectionRef connection, - void *data, - size_t *data_length) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) connection; - ssize_t length; - ENTRY; - - errno = 0; - /* 4 arguments is *min_bytes* -- This is not a negotiation. - * Secure Transport wants all or nothing. We must continue reading until - * we get this amount, or timeout */ - length = mongoc_stream_read ( - tls->base_stream, data, *data_length, *data_length, tls->timeout_msec); - - if (length > 0) { - *data_length = length; - RETURN (noErr); - } - - if (length == 0) { - RETURN (errSSLClosedGraceful); - } - - switch (errno) { - case ENOENT: - RETURN (errSSLClosedGraceful); - break; - case ECONNRESET: - RETURN (errSSLClosedAbort); - break; - case EAGAIN: - RETURN (errSSLWouldBlock); - break; - default: - RETURN (-36); /* ioErr */ - break; - } -} - -OSStatus -mongoc_secure_transport_write (SSLConnectionRef connection, - const void *data, - size_t *data_length) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) connection; - ssize_t length; - ENTRY; - - errno = 0; - length = mongoc_stream_write ( - tls->base_stream, (void *) data, *data_length, tls->timeout_msec); - - if (length >= 0) { - *data_length = length; - RETURN (noErr); - } - - switch (errno) { - case EAGAIN: - RETURN (errSSLWouldBlock); - default: - RETURN (-36); /* ioErr */ - } -} - -void -CFReleaseSafe (CFTypeRef cf) -{ - if (cf != NULL) { - CFRelease (cf); - } -} - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-api.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-api.h deleted file mode 100644 index a0e3f3704..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-api.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2021 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_SERVER_API_H -#define MONGOC_SERVER_API_H - -#include - -#include "mongoc-optional.h" -#include "mongoc-macros.h" - -BSON_BEGIN_DECLS - -typedef enum { MONGOC_SERVER_API_V1 } mongoc_server_api_version_t; - -typedef struct _mongoc_server_api_t mongoc_server_api_t; - -MONGOC_EXPORT (const char *) -mongoc_server_api_version_to_string (mongoc_server_api_version_t version); - -MONGOC_EXPORT (bool) -mongoc_server_api_version_from_string (const char *version, - mongoc_server_api_version_t *out); - -MONGOC_EXPORT (mongoc_server_api_t *) -mongoc_server_api_new (mongoc_server_api_version_t version) - BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (mongoc_server_api_t *) -mongoc_server_api_copy (const mongoc_server_api_t *api) - BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (void) -mongoc_server_api_destroy (mongoc_server_api_t *api); - -MONGOC_EXPORT (void) -mongoc_server_api_strict (mongoc_server_api_t *api, bool strict); - -MONGOC_EXPORT (void) -mongoc_server_api_deprecation_errors (mongoc_server_api_t *api, - bool deprecation_errors); - -MONGOC_EXPORT (const mongoc_optional_t *) -mongoc_server_api_get_deprecation_errors (const mongoc_server_api_t *api); - -MONGOC_EXPORT (const mongoc_optional_t *) -mongoc_server_api_get_strict (const mongoc_server_api_t *api); - -MONGOC_EXPORT (mongoc_server_api_version_t) -mongoc_server_api_get_version (const mongoc_server_api_t *api); - -BSON_END_DECLS - -#endif /* MONGOC_SERVER_API_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-description-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-description-private.h deleted file mode 100644 index 58cfbb657..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-description-private.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_SERVER_DESCRIPTION_PRIVATE_H -#define MONGOC_SERVER_DESCRIPTION_PRIVATE_H - -#include "mongoc-server-description.h" -#include "mongoc-generation-map-private.h" - - -#define MONGOC_DEFAULT_WIRE_VERSION 0 -#define MONGOC_DEFAULT_WRITE_BATCH_SIZE 1000 -#define MONGOC_DEFAULT_BSON_OBJ_SIZE 16 * 1024 * 1024 -#define MONGOC_DEFAULT_MAX_MSG_SIZE 48000000 -/* This is slightly out-of-spec as of the current version of the spec (1.0.0), - * but SPEC-1397 plans to amend "Size limits and Wire Protocol Considerations" - * to say that drivers MAY split with a reduced maxBsonObjectSize or - * maxMessageSizeBytes - * depending on the implementation. It is less invasive for libmongoc to split - * OP_MSG payload type 1 with a reduced maxMessageSizeBytes and convert it to a - * payload type 0 - * rather than split a payload type 0 with a reduced maxBsonObjectSize. - */ -#define MONGOC_REDUCED_MAX_MSG_SIZE_FOR_FLE 2097152 -#define MONGOC_NO_SESSIONS -1 -#define MONGOC_IDLE_WRITE_PERIOD_MS 10 * 1000 - -/* represent a server or topology with no replica set config version */ -#define MONGOC_NO_SET_VERSION -1 - -#define MONGOC_RTT_UNSET -1 - -#define MONGOC_NO_SERVER_CONNECTION_ID -1 - -typedef enum { - MONGOC_SERVER_UNKNOWN, - MONGOC_SERVER_STANDALONE, - MONGOC_SERVER_MONGOS, - MONGOC_SERVER_POSSIBLE_PRIMARY, - MONGOC_SERVER_RS_PRIMARY, - MONGOC_SERVER_RS_SECONDARY, - MONGOC_SERVER_RS_ARBITER, - MONGOC_SERVER_RS_OTHER, - MONGOC_SERVER_RS_GHOST, - MONGOC_SERVER_LOAD_BALANCER, - MONGOC_SERVER_DESCRIPTION_TYPES, -} mongoc_server_description_type_t; - -struct _mongoc_server_description_t { - uint32_t id; - mongoc_host_list_t host; - int64_t round_trip_time_msec; - int64_t last_update_time_usec; - bson_t last_hello_response; - bool has_hello_response; - bool hello_ok; - const char *connection_address; - /* SDAM dictates storing me/hosts/passives/arbiters after being "normalized - * to lower-case" Instead, they are stored in the casing they are received, - * but compared case insensitively. This should be addressed in CDRIVER-3527. - */ - const char *me; - - /* whether an APM server-opened callback has been fired before */ - bool opened; - - const char *set_name; - bson_error_t error; - mongoc_server_description_type_t type; - - int32_t min_wire_version; - int32_t max_wire_version; - int32_t max_msg_size; - int32_t max_bson_obj_size; - int32_t max_write_batch_size; - int64_t session_timeout_minutes; - - /* hosts, passives, and arbiters are stored as a BSON array, but compared - * case insensitively. This should be improved in CDRIVER-3527. */ - bson_t hosts; - bson_t passives; - bson_t arbiters; - - bson_t tags; - const char *current_primary; - int64_t set_version; - bson_oid_t election_id; - int64_t last_write_date_ms; - - bson_t compressors; - bson_t topology_version; - /* - The generation is incremented every time connections to this server should be - invalidated. - This happens when: - 1. a monitor receives a network error - 2. an app thread receives any network error before completing a handshake - 3. an app thread receives a non-timeout network error after the handshake - 4. an app thread receives a "not primary" or "node is recovering" error from - a pre-4.2 server. - */ - - /* generation only applies to a server description tied to a connection. - * It represents the generation number for this connection. */ - uint32_t generation; - - /* _generation_map_ stores all generations for all service IDs associated - * with this server. _generation_map_ is only accessed on the server - * description for monitoring. In non-load-balanced mode, there are no - * service IDs. The only server generation is mapped from kZeroServiceID */ - mongoc_generation_map_t *_generation_map_; - bson_oid_t service_id; - int64_t server_connection_id; -}; - -/** Get a mutable pointer to the server's generation map */ -static BSON_INLINE mongoc_generation_map_t * -mc_tpl_sd_generation_map (mongoc_server_description_t *sd) -{ - return sd->_generation_map_; -} - -/** Get a const pointer to the server's generation map */ -static BSON_INLINE const mongoc_generation_map_t * -mc_tpl_sd_generation_map_const (const mongoc_server_description_t *sd) -{ - return sd->_generation_map_; -} - -/** - * @brief Increment the generation number on the given server for the associated - * service ID. - */ -static BSON_INLINE void -mc_tpl_sd_increment_generation (mongoc_server_description_t *sd, - const bson_oid_t *service_id) -{ - mongoc_generation_map_increment (mc_tpl_sd_generation_map (sd), service_id); -} - -/** - * @brief Get the generation number of the given server description for the - * associated service ID. - */ -static BSON_INLINE uint32_t -mc_tpl_sd_get_generation (const mongoc_server_description_t *sd, - const bson_oid_t *service_id) -{ - return mongoc_generation_map_get (mc_tpl_sd_generation_map_const (sd), - service_id); -} - -void -mongoc_server_description_init (mongoc_server_description_t *sd, - const char *address, - uint32_t id); -bool -mongoc_server_description_has_rs_member ( - const mongoc_server_description_t *description, const char *address); - - -bool -mongoc_server_description_has_set_version ( - const mongoc_server_description_t *description); - -bool -mongoc_server_description_has_election_id ( - const mongoc_server_description_t *description); - -void -mongoc_server_description_cleanup (mongoc_server_description_t *sd); - -void -mongoc_server_description_reset (mongoc_server_description_t *sd); - -void -mongoc_server_description_set_state (mongoc_server_description_t *description, - mongoc_server_description_type_t type); -void -mongoc_server_description_set_set_version ( - mongoc_server_description_t *description, int64_t set_version); -void -mongoc_server_description_set_election_id ( - mongoc_server_description_t *description, const bson_oid_t *election_id); -void -mongoc_server_description_update_rtt (mongoc_server_description_t *server, - int64_t rtt_msec); - -void -mongoc_server_description_handle_hello (mongoc_server_description_t *sd, - const bson_t *hello_response, - int64_t rtt_msec, - const bson_error_t *error /* IN */); - -void -mongoc_server_description_filter_stale ( - const mongoc_server_description_t **sds, - size_t sds_len, - const mongoc_server_description_t *primary, - int64_t heartbeat_frequency_ms, - const mongoc_read_prefs_t *read_prefs); - -void -mongoc_server_description_filter_tags ( - const mongoc_server_description_t **descriptions, - size_t description_len, - const mongoc_read_prefs_t *read_prefs); - -/* Compares server descriptions following the "Server Description Equality" - * rules. Not all fields are considered. */ -bool -_mongoc_server_description_equal (mongoc_server_description_t *sd1, - mongoc_server_description_t *sd2); - -int -mongoc_server_description_topology_version_cmp (const bson_t *tv1, - const bson_t *tv2); - -void -mongoc_server_description_set_topology_version (mongoc_server_description_t *sd, - const bson_t *tv); - -extern const bson_oid_t kZeroServiceId; - -bool -mongoc_server_description_has_service_id ( - const mongoc_server_description_t *description); - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-description.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-description.c deleted file mode 100644 index b1de91f9e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-description.c +++ /dev/null @@ -1,1283 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" -#include "mongoc-host-list.h" -#include "mongoc-host-list-private.h" -#include "mongoc-read-prefs.h" -#include "mongoc-read-prefs-private.h" -#include "mongoc-server-description-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-uri.h" -#include "mongoc-util-private.h" -#include "mongoc-compression-private.h" - -#include - -#include - -#define ALPHA 0.2 - -static bson_oid_t kObjectIdZero = {{0}}; - -const bson_oid_t kZeroServiceId = {{0}}; - -static bool -_match_tag_set (const mongoc_server_description_t *sd, - bson_iter_t *tag_set_iter); - -/* Destroy allocated resources within @description, but don't free it */ -void -mongoc_server_description_cleanup (mongoc_server_description_t *sd) -{ - BSON_ASSERT (sd); - - bson_destroy (&sd->last_hello_response); - bson_destroy (&sd->hosts); - bson_destroy (&sd->passives); - bson_destroy (&sd->arbiters); - bson_destroy (&sd->tags); - bson_destroy (&sd->compressors); - bson_destroy (&sd->topology_version); - mongoc_generation_map_destroy (sd->_generation_map_); -} - -/* Reset fields inside this sd, but keep same id, host information, RTT, - generation, topology version, and leave hello in empty inited state */ -void -mongoc_server_description_reset (mongoc_server_description_t *sd) -{ - BSON_ASSERT (sd); - - memset (&sd->error, 0, sizeof sd->error); - sd->set_name = NULL; - sd->type = MONGOC_SERVER_UNKNOWN; - - sd->min_wire_version = MONGOC_DEFAULT_WIRE_VERSION; - sd->max_wire_version = MONGOC_DEFAULT_WIRE_VERSION; - sd->max_msg_size = MONGOC_DEFAULT_MAX_MSG_SIZE; - sd->max_bson_obj_size = MONGOC_DEFAULT_BSON_OBJ_SIZE; - sd->max_write_batch_size = MONGOC_DEFAULT_WRITE_BATCH_SIZE; - sd->session_timeout_minutes = MONGOC_NO_SESSIONS; - sd->last_write_date_ms = -1; - sd->hello_ok = false; - - /* always leave last hello in an init-ed state until we destroy sd */ - bson_destroy (&sd->last_hello_response); - bson_init (&sd->last_hello_response); - sd->has_hello_response = false; - sd->last_update_time_usec = bson_get_monotonic_time (); - - bson_destroy (&sd->hosts); - bson_destroy (&sd->passives); - bson_destroy (&sd->arbiters); - bson_destroy (&sd->tags); - bson_destroy (&sd->compressors); - - bson_init (&sd->hosts); - bson_init (&sd->passives); - bson_init (&sd->arbiters); - bson_init (&sd->tags); - bson_init (&sd->compressors); - - sd->me = NULL; - sd->current_primary = NULL; - sd->set_version = MONGOC_NO_SET_VERSION; - bson_oid_copy_unsafe (&kObjectIdZero, &sd->election_id); - bson_oid_copy_unsafe (&kObjectIdZero, &sd->service_id); - sd->server_connection_id = MONGOC_NO_SERVER_CONNECTION_ID; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_init -- - * - * Initialize a new server_description_t. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_server_description_init (mongoc_server_description_t *sd, - const char *address, - uint32_t id) -{ - ENTRY; - - BSON_ASSERT (sd); - BSON_ASSERT (address); - - sd->id = id; - sd->type = MONGOC_SERVER_UNKNOWN; - sd->round_trip_time_msec = MONGOC_RTT_UNSET; - sd->generation = 0; - sd->opened = 0; - sd->_generation_map_ = mongoc_generation_map_new (); - - if (!_mongoc_host_list_from_string (&sd->host, address)) { - MONGOC_WARNING ("Failed to parse uri for %s", address); - return; - } - - sd->connection_address = sd->host.host_and_port; - bson_init (&sd->last_hello_response); - bson_init (&sd->hosts); - bson_init (&sd->passives); - bson_init (&sd->arbiters); - bson_init (&sd->tags); - bson_init (&sd->compressors); - bson_init (&sd->topology_version); - - mongoc_server_description_reset (sd); - - EXIT; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_destroy -- - * - * Destroy allocated resources within @description and free - * @description. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_server_description_destroy (mongoc_server_description_t *description) -{ - ENTRY; - - if (!description) { - EXIT; - } - - mongoc_server_description_cleanup (description); - - bson_free (description); - - EXIT; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_has_rs_member -- - * - * Return true if this address is included in server's list of rs - * members, false otherwise. - * - * Returns: - * true, false - * - * Side effects: - * None - * - *-------------------------------------------------------------------------- - */ -bool -mongoc_server_description_has_rs_member ( - const mongoc_server_description_t *server, const char *address) -{ - bson_iter_t member_iter; - const bson_t *rs_members[3]; - int i; - - if (server->type != MONGOC_SERVER_UNKNOWN) { - rs_members[0] = &server->hosts; - rs_members[1] = &server->arbiters; - rs_members[2] = &server->passives; - - for (i = 0; i < 3; i++) { - BSON_ASSERT (bson_iter_init (&member_iter, rs_members[i])); - - while (bson_iter_next (&member_iter)) { - if (strcasecmp (address, bson_iter_utf8 (&member_iter, NULL)) == - 0) { - return true; - } - } - } - } - - return false; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_has_set_version -- - * - * Did this server's hello response have a "setVersion" field? - * - * Returns: - * True if the server description's setVersion is set. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_server_description_has_set_version ( - const mongoc_server_description_t *description) -{ - return description->set_version != MONGOC_NO_SET_VERSION; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_has_election_id -- - * - * Did this server's hello response have an "electionId" field? - * - * Returns: - * True if the server description's electionId is set. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_server_description_has_election_id ( - const mongoc_server_description_t *description) -{ - return 0 != bson_oid_compare (&description->election_id, &kObjectIdZero); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_id -- - * - * Get the id of this server. - * - * Returns: - * Server's id. - * - *-------------------------------------------------------------------------- - */ - -uint32_t -mongoc_server_description_id (const mongoc_server_description_t *description) -{ - return description->id; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_host -- - * - * Return a reference to the host associated with this server description. - * - * Returns: - * This server description's host, a mongoc_host_list_t * you must - * not modify or free. - * - *-------------------------------------------------------------------------- - */ - -mongoc_host_list_t * -mongoc_server_description_host (const mongoc_server_description_t *description) -{ - return &((mongoc_server_description_t *) description)->host; -} - -int64_t -mongoc_server_description_last_update_time ( - const mongoc_server_description_t *description) -{ - return description->last_update_time_usec; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_round_trip_time -- - * - * Get the round trip time of this server, which is the client's - * measurement of the duration of a "hello" command. - * - * Returns: - * The server's round trip time in milliseconds. - * - *-------------------------------------------------------------------------- - */ - -int64_t -mongoc_server_description_round_trip_time ( - const mongoc_server_description_t *description) -{ - return description->round_trip_time_msec; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_type -- - * - * Get this server's type, one of the types defined in the Server - * Discovery And Monitoring Spec. - * - * Returns: - * A string. - * - *-------------------------------------------------------------------------- - */ - -const char * -mongoc_server_description_type (const mongoc_server_description_t *description) -{ - switch (description->type) { - case MONGOC_SERVER_UNKNOWN: - return "Unknown"; - case MONGOC_SERVER_STANDALONE: - return "Standalone"; - case MONGOC_SERVER_MONGOS: - return "Mongos"; - case MONGOC_SERVER_POSSIBLE_PRIMARY: - return "PossiblePrimary"; - case MONGOC_SERVER_RS_PRIMARY: - return "RSPrimary"; - case MONGOC_SERVER_RS_SECONDARY: - return "RSSecondary"; - case MONGOC_SERVER_RS_ARBITER: - return "RSArbiter"; - case MONGOC_SERVER_RS_OTHER: - return "RSOther"; - case MONGOC_SERVER_RS_GHOST: - return "RSGhost"; - case MONGOC_SERVER_LOAD_BALANCER: - return "LoadBalancer"; - case MONGOC_SERVER_DESCRIPTION_TYPES: - default: - MONGOC_ERROR ("Invalid mongoc_server_description_t type"); - return "Invalid"; - } -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_hello_response -- - * - * Return this server's most recent "hello" command response. - * - * Returns: - * A reference to a BSON document, owned by the server description. - * - *-------------------------------------------------------------------------- - */ - -const bson_t * -mongoc_server_description_hello_response ( - const mongoc_server_description_t *description) -{ - return &description->last_hello_response; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_ismaster -- - * - * Return this server's most recent "hello" command response. - * - * Returns: - * A reference to a BSON document, owned by the server description. - * - *-------------------------------------------------------------------------- - */ - -const bson_t * -mongoc_server_description_ismaster ( - const mongoc_server_description_t *description) -{ - return mongoc_server_description_hello_response (description); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_set_state -- - * - * Set the server description's server type. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_server_description_set_state (mongoc_server_description_t *description, - mongoc_server_description_type_t type) -{ - description->type = type; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_set_set_version -- - * - * Set the replica set version of this server. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_server_description_set_set_version ( - mongoc_server_description_t *description, int64_t set_version) -{ - description->set_version = set_version; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_set_election_id -- - * - * Set the election_id of this server. Copies the given ObjectId or, - * if it is NULL, zeroes description's election_id. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_server_description_set_election_id ( - mongoc_server_description_t *description, const bson_oid_t *election_id) -{ - if (election_id) { - bson_oid_copy_unsafe (election_id, &description->election_id); - } else { - bson_oid_copy_unsafe (&kObjectIdZero, &description->election_id); - } -} - -/* - *------------------------------------------------------------------------- - * - * mongoc_server_description_update_rtt -- - * - * Calculate this server's rtt calculation using an exponentially- - * weighted moving average formula. - * - * Side effects: - * None. - * - * If rtt_msec is MONGOC_RTT_UNSET, the value is not updated. - * - *------------------------------------------------------------------------- - */ -void -mongoc_server_description_update_rtt (mongoc_server_description_t *server, - int64_t rtt_msec) -{ - if (rtt_msec == MONGOC_RTT_UNSET) { - return; - } - if (server->round_trip_time_msec == MONGOC_RTT_UNSET) { - bson_atomic_int64_exchange ( - &server->round_trip_time_msec, rtt_msec, bson_memory_order_relaxed); - } else { - bson_atomic_int64_exchange ( - &server->round_trip_time_msec, - (int64_t) (ALPHA * rtt_msec + - (1 - ALPHA) * server->round_trip_time_msec), - bson_memory_order_relaxed); - } -} - - -static void -_mongoc_server_description_set_error (mongoc_server_description_t *sd, - const bson_error_t *error) -{ - if (error && error->code) { - memcpy (&sd->error, error, sizeof (bson_error_t)); - } else { - bson_set_error (&sd->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "unknown error calling hello"); - } - - /* Server Discovery and Monitoring Spec: if the server type changes from a - * known type to Unknown its RTT is set to null. */ - sd->round_trip_time_msec = MONGOC_RTT_UNSET; -} - - -/* - *------------------------------------------------------------------------- - * - * Called during SDAM, from topology description's hello handler, or - * when handshaking a connection in _mongoc_cluster_stream_for_server. - * - * If @hello_response is empty, @error must say why hello failed. - * - *------------------------------------------------------------------------- - */ - -void -mongoc_server_description_handle_hello (mongoc_server_description_t *sd, - const bson_t *hello_response, - int64_t rtt_msec, - const bson_error_t *error /* IN */) -{ - bson_iter_t iter; - bson_iter_t child; - bool is_primary = false; - bool is_shard = false; - bool is_secondary = false; - bool is_arbiter = false; - bool is_replicaset = false; - bool is_hidden = false; - const uint8_t *bytes; - uint32_t len; - int num_keys = 0; - ENTRY; - - BSON_ASSERT (sd); - - mongoc_server_description_reset (sd); - if (!hello_response) { - _mongoc_server_description_set_error (sd, error); - EXIT; - } - - bson_destroy (&sd->last_hello_response); - bsonBuild (sd->last_hello_response, - insert (*hello_response, not(key ("speculativeAuthenticate")))); - sd->has_hello_response = true; - - /* Only reinitialize the topology version if we have a hello response. - * Resetting a server description should not effect the topology version. */ - bson_reinit (&sd->topology_version); - - BSON_ASSERT (bson_iter_init (&iter, &sd->last_hello_response)); - - while (bson_iter_next (&iter)) { - num_keys++; - if (strcmp ("ok", bson_iter_key (&iter)) == 0) { - if (!bson_iter_as_bool (&iter)) { - /* it doesn't really matter what error API we use. the code and - * domain will be overwritten. */ - (void) _mongoc_cmd_check_ok ( - hello_response, MONGOC_ERROR_API_VERSION_2, &sd->error); - /* TODO CDRIVER-3696: this is an existing bug. If this is handling - * a hello reply that is NOT from a handshake, this should not - * be considered an auth error. */ - /* hello response returned ok: 0. According to auth spec: "If the - * hello of the MongoDB Handshake fails with an error, drivers - * MUST treat this an authentication error." */ - sd->error.domain = MONGOC_ERROR_CLIENT; - sd->error.code = MONGOC_ERROR_CLIENT_AUTHENTICATE; - GOTO (authfailure); - } - } else if (strcmp ("isWritablePrimary", bson_iter_key (&iter)) == 0 || - strcmp (HANDSHAKE_RESPONSE_LEGACY_HELLO, - bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_BOOL (&iter)) - GOTO (typefailure); - is_primary = bson_iter_bool (&iter); - } else if (strcmp ("helloOk", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_BOOL (&iter)) - GOTO (typefailure); - sd->hello_ok = bson_iter_bool (&iter); - } else if (strcmp ("me", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_UTF8 (&iter)) - GOTO (typefailure); - sd->me = bson_iter_utf8 (&iter, NULL); - } else if (strcmp ("maxMessageSizeBytes", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_INT32 (&iter)) - GOTO (typefailure); - sd->max_msg_size = bson_iter_int32 (&iter); - } else if (strcmp ("maxBsonObjectSize", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_INT32 (&iter)) - GOTO (typefailure); - sd->max_bson_obj_size = bson_iter_int32 (&iter); - } else if (strcmp ("maxWriteBatchSize", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_INT32 (&iter)) - GOTO (typefailure); - sd->max_write_batch_size = bson_iter_int32 (&iter); - } else if (strcmp ("logicalSessionTimeoutMinutes", - bson_iter_key (&iter)) == 0) { - if (BSON_ITER_HOLDS_NUMBER (&iter)) { - sd->session_timeout_minutes = bson_iter_as_int64 (&iter); - } else if (BSON_ITER_HOLDS_NULL (&iter)) { - /* this arises executing standard JSON tests */ - sd->session_timeout_minutes = MONGOC_NO_SESSIONS; - } else { - GOTO (typefailure); - } - } else if (strcmp ("minWireVersion", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_INT32 (&iter)) - GOTO (typefailure); - sd->min_wire_version = bson_iter_int32 (&iter); - } else if (strcmp ("maxWireVersion", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_INT32 (&iter)) - GOTO (typefailure); - sd->max_wire_version = bson_iter_int32 (&iter); - } else if (strcmp ("msg", bson_iter_key (&iter)) == 0) { - const char *msg; - if (!BSON_ITER_HOLDS_UTF8 (&iter)) - GOTO (typefailure); - msg = bson_iter_utf8 (&iter, NULL); - if (msg && 0 == strcmp (msg, "isdbgrid")) { - is_shard = true; - } - } else if (strcmp ("setName", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_UTF8 (&iter)) - GOTO (typefailure); - sd->set_name = bson_iter_utf8 (&iter, NULL); - } else if (strcmp ("setVersion", bson_iter_key (&iter)) == 0) { - mongoc_server_description_set_set_version (sd, - bson_iter_as_int64 (&iter)); - } else if (strcmp ("electionId", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_OID (&iter)) - GOTO (typefailure); - mongoc_server_description_set_election_id (sd, bson_iter_oid (&iter)); - } else if (strcmp ("secondary", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_BOOL (&iter)) - GOTO (typefailure); - is_secondary = bson_iter_bool (&iter); - } else if (strcmp ("hosts", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_ARRAY (&iter)) - GOTO (typefailure); - bson_iter_array (&iter, &len, &bytes); - bson_destroy (&sd->hosts); - BSON_ASSERT (bson_init_static (&sd->hosts, bytes, len)); - } else if (strcmp ("passives", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_ARRAY (&iter)) - GOTO (typefailure); - bson_iter_array (&iter, &len, &bytes); - bson_destroy (&sd->passives); - BSON_ASSERT (bson_init_static (&sd->passives, bytes, len)); - } else if (strcmp ("arbiters", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_ARRAY (&iter)) - GOTO (typefailure); - bson_iter_array (&iter, &len, &bytes); - bson_destroy (&sd->arbiters); - BSON_ASSERT (bson_init_static (&sd->arbiters, bytes, len)); - } else if (strcmp ("primary", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_UTF8 (&iter)) - GOTO (typefailure); - sd->current_primary = bson_iter_utf8 (&iter, NULL); - } else if (strcmp ("arbiterOnly", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_BOOL (&iter)) - GOTO (typefailure); - is_arbiter = bson_iter_bool (&iter); - } else if (strcmp ("isreplicaset", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_BOOL (&iter)) - GOTO (typefailure); - is_replicaset = bson_iter_bool (&iter); - } else if (strcmp ("tags", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) - GOTO (typefailure); - bson_iter_document (&iter, &len, &bytes); - bson_destroy (&sd->tags); - BSON_ASSERT (bson_init_static (&sd->tags, bytes, len)); - } else if (strcmp ("hidden", bson_iter_key (&iter)) == 0) { - is_hidden = bson_iter_bool (&iter); - } else if (strcmp ("lastWrite", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_DOCUMENT (&iter) || - !bson_iter_recurse (&iter, &child) || - !bson_iter_find (&child, "lastWriteDate") || - !BSON_ITER_HOLDS_DATE_TIME (&child)) { - GOTO (typefailure); - } - - sd->last_write_date_ms = bson_iter_date_time (&child); - } else if (strcmp ("compression", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_ARRAY (&iter)) - GOTO (typefailure); - bson_iter_array (&iter, &len, &bytes); - bson_destroy (&sd->compressors); - BSON_ASSERT (bson_init_static (&sd->compressors, bytes, len)); - } else if (strcmp ("topologyVersion", bson_iter_key (&iter)) == 0) { - bson_t incoming_topology_version; - - if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) { - GOTO (typefailure); - } - - bson_iter_document (&iter, &len, &bytes); - BSON_ASSERT ( - bson_init_static (&incoming_topology_version, bytes, len)); - mongoc_server_description_set_topology_version ( - sd, &incoming_topology_version); - bson_destroy (&incoming_topology_version); - } else if (strcmp ("serviceId", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_OID (&iter)) - GOTO (typefailure); - bson_oid_copy_unsafe (bson_iter_oid (&iter), &sd->service_id); - } else if (strcmp ("connectionId", bson_iter_key (&iter)) == 0) { - if (!BSON_ITER_HOLDS_NUMBER (&iter)) - GOTO (typefailure); - sd->server_connection_id = bson_iter_as_int64 (&iter); - } - } - - if (is_shard) { - sd->type = MONGOC_SERVER_MONGOS; - } else if (sd->set_name) { - if (is_hidden) { - sd->type = MONGOC_SERVER_RS_OTHER; - } else if (is_primary) { - sd->type = MONGOC_SERVER_RS_PRIMARY; - } else if (is_secondary) { - sd->type = MONGOC_SERVER_RS_SECONDARY; - } else if (is_arbiter) { - sd->type = MONGOC_SERVER_RS_ARBITER; - } else { - sd->type = MONGOC_SERVER_RS_OTHER; - } - } else if (is_replicaset) { - sd->type = MONGOC_SERVER_RS_GHOST; - } else if (num_keys > 0) { - sd->type = MONGOC_SERVER_STANDALONE; - } else { - sd->type = MONGOC_SERVER_UNKNOWN; - } - - if (!num_keys) { - /* empty reply means hello failed */ - _mongoc_server_description_set_error (sd, error); - } - - mongoc_server_description_update_rtt (sd, rtt_msec); - - EXIT; - -typefailure: - bson_set_error (&sd->error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_INVALID_TYPE, - "unexpected type %s for field %s in hello response", - _mongoc_bson_type_to_str (bson_iter_type (&iter)), - bson_iter_key (&iter)); -authfailure: - sd->type = MONGOC_SERVER_UNKNOWN; - sd->round_trip_time_msec = MONGOC_RTT_UNSET; - - EXIT; -} - -/* - *------------------------------------------------------------------------- - * - * mongoc_server_description_new_copy -- - * - * A copy of a server description that you must destroy, or NULL. - * - *------------------------------------------------------------------------- - */ -mongoc_server_description_t * -mongoc_server_description_new_copy ( - const mongoc_server_description_t *description) -{ - mongoc_server_description_t *copy; - - if (!description) { - return NULL; - } - - copy = BSON_ALIGNED_ALLOC0 (mongoc_server_description_t); - - copy->id = description->id; - copy->opened = description->opened; - memcpy (©->host, &description->host, sizeof (copy->host)); - copy->round_trip_time_msec = MONGOC_RTT_UNSET; - - copy->connection_address = copy->host.host_and_port; - bson_init (©->last_hello_response); - bson_init (©->hosts); - bson_init (©->passives); - bson_init (©->arbiters); - bson_init (©->tags); - bson_init (©->compressors); - bson_copy_to (&description->topology_version, ©->topology_version); - bson_oid_copy (&description->service_id, ©->service_id); - copy->server_connection_id = description->server_connection_id; - - if (description->has_hello_response) { - /* calls mongoc_server_description_reset */ - int64_t last_rtt_ms = bson_atomic_int64_fetch ( - &description->round_trip_time_msec, bson_memory_order_relaxed); - mongoc_server_description_handle_hello (copy, - &description->last_hello_response, - last_rtt_ms, - &description->error); - } else { - mongoc_server_description_reset (copy); - /* preserve the original server description type, which is manually set - * for a LoadBalancer server */ - copy->type = description->type; - } - - /* Preserve the error */ - memcpy (©->error, &description->error, sizeof copy->error); - - copy->generation = description->generation; - copy->_generation_map_ = - mongoc_generation_map_copy (mc_tpl_sd_generation_map_const (description)); - return copy; -} - - -/* - *------------------------------------------------------------------------- - * - * mongoc_server_description_filter_stale -- - * - * Estimate servers' staleness according to the Server Selection Spec. - * Determines the number of eligible servers, and sets any servers that - * are too stale to NULL in the descriptions set. - * - *------------------------------------------------------------------------- - */ - -void -mongoc_server_description_filter_stale ( - const mongoc_server_description_t **sds, - size_t sds_len, - const mongoc_server_description_t *primary, - int64_t heartbeat_frequency_ms, - const mongoc_read_prefs_t *read_prefs) -{ - int64_t max_staleness_seconds; - size_t i; - - int64_t heartbeat_frequency_usec; - int64_t max_last_write_date_usec; - int64_t staleness_usec; - int64_t max_staleness_usec; - - if (!read_prefs) { - /* NULL read_prefs is PRIMARY, no maxStalenessSeconds to filter by */ - return; - } - - max_staleness_seconds = - mongoc_read_prefs_get_max_staleness_seconds (read_prefs); - - if (max_staleness_seconds == MONGOC_NO_MAX_STALENESS) { - return; - } - - BSON_ASSERT (max_staleness_seconds > 0); - max_staleness_usec = max_staleness_seconds * 1000 * 1000; - heartbeat_frequency_usec = heartbeat_frequency_ms * 1000; - - if (primary) { - for (i = 0; i < sds_len; i++) { - if (!sds[i] || sds[i]->type != MONGOC_SERVER_RS_SECONDARY) { - continue; - } - - /* See max-staleness.rst for explanation of these formulae. */ - staleness_usec = - primary->last_write_date_ms * 1000 + - (sds[i]->last_update_time_usec - primary->last_update_time_usec) - - sds[i]->last_write_date_ms * 1000 + heartbeat_frequency_usec; - - if (staleness_usec > max_staleness_usec) { - TRACE ("Rejected stale RSSecondary [%s]", - sds[i]->host.host_and_port); - sds[i] = NULL; - } - } - } else { - /* find max last_write_date */ - max_last_write_date_usec = 0; - for (i = 0; i < sds_len; i++) { - if (sds[i] && sds[i]->type == MONGOC_SERVER_RS_SECONDARY) { - max_last_write_date_usec = BSON_MAX ( - max_last_write_date_usec, sds[i]->last_write_date_ms * 1000); - } - } - - /* use max last_write_date to estimate each secondary's staleness */ - for (i = 0; i < sds_len; i++) { - if (!sds[i] || sds[i]->type != MONGOC_SERVER_RS_SECONDARY) { - continue; - } - - staleness_usec = max_last_write_date_usec - - sds[i]->last_write_date_ms * 1000 + - heartbeat_frequency_usec; - - if (staleness_usec > max_staleness_usec) { - TRACE ("Rejected stale RSSecondary [%s]", - sds[i]->host.host_and_port); - sds[i] = NULL; - } - } - } -} - - -/* - *------------------------------------------------------------------------- - * - * mongoc_server_description_filter_tags -- - * - * Given a set of server descriptions, set to NULL any that don't - * match the read preference's tag sets. - * - * https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#tag-set - * - *------------------------------------------------------------------------- - */ - -void -mongoc_server_description_filter_tags ( - const mongoc_server_description_t **descriptions, - size_t description_len, - const mongoc_read_prefs_t *read_prefs) -{ - const bson_t *rp_tags; - bson_iter_t rp_tagset_iter; - bson_iter_t tag_set_iter; - bool *sd_matched = NULL; - bool found; - size_t i; - - if (!read_prefs) { - /* NULL read_prefs is PRIMARY, no tags to filter by */ - return; - } - - rp_tags = mongoc_read_prefs_get_tags (read_prefs); - - if (bson_count_keys (rp_tags) == 0) { - /* no tags to filter by */ - return; - } - - sd_matched = (bool *) bson_malloc0 (sizeof (bool) * description_len); - - bson_iter_init (&rp_tagset_iter, rp_tags); - - /* for each read preference tag set */ - while (bson_iter_next (&rp_tagset_iter)) { - found = false; - - for (i = 0; i < description_len; i++) { - if (!descriptions[i]) { - /* NULLed earlier in mongoc_topology_description_suitable_servers */ - continue; - } - - BSON_ASSERT (bson_iter_recurse (&rp_tagset_iter, &tag_set_iter)); - sd_matched[i] = _match_tag_set (descriptions[i], &tag_set_iter); - if (sd_matched[i]) { - found = true; - } - } - - if (found) { - for (i = 0; i < description_len; i++) { - if (!sd_matched[i] && descriptions[i]) { - TRACE ("Rejected [%s] [%s], doesn't match tags", - mongoc_server_description_type (descriptions[i]), - descriptions[i]->host.host_and_port); - descriptions[i] = NULL; - } - } - - goto CLEANUP; - } - } - - /* tried each */ - for (i = 0; i < description_len; i++) { - if (!sd_matched[i]) { - TRACE ("Rejected [%s] [%s], reached end of tags array without match", - mongoc_server_description_type (descriptions[i]), - descriptions[i]->host.host_and_port); - - descriptions[i] = NULL; - } - } - -CLEANUP: - bson_free (sd_matched); -} - - -/* - *------------------------------------------------------------------------- - * - * _match_tag_set -- - * - * Check if a server's tags match one tag set, like - * {'tag1': 'value1', 'tag2': 'value2'}. - * - *------------------------------------------------------------------------- - */ -static bool -_match_tag_set (const mongoc_server_description_t *sd, - bson_iter_t *tag_set_iter) -{ - bson_iter_t sd_iter; - uint32_t read_pref_tag_len; - uint32_t sd_len; - const char *read_pref_tag; - const char *read_pref_val; - const char *server_val; - - while (bson_iter_next (tag_set_iter)) { - /* one {'tag': 'value'} pair from the read preference's tag set */ - read_pref_tag = bson_iter_key (tag_set_iter); - read_pref_val = bson_iter_utf8 (tag_set_iter, &read_pref_tag_len); - - if (bson_iter_init_find (&sd_iter, &sd->tags, read_pref_tag)) { - /* The server has this tag - does it have the right value? */ - server_val = bson_iter_utf8 (&sd_iter, &sd_len); - if (sd_len != read_pref_tag_len || - memcmp (read_pref_val, server_val, read_pref_tag_len)) { - /* If the values don't match, no match */ - return false; - } - } else { - /* If the server description doesn't have that key, no match */ - return false; - } - } - - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_server_description_compressor_id -- - * - * Get the compressor id if compression was negotiated. - * - * Returns: - * The compressor ID, or -1 if none was negotiated. - * - *-------------------------------------------------------------------------- - */ - -int32_t -mongoc_server_description_compressor_id ( - const mongoc_server_description_t *description) -{ - int id; - bson_iter_t iter; - BSON_ASSERT (bson_iter_init (&iter, &description->compressors)); - - while (bson_iter_next (&iter)) { - id = mongoc_compressor_name_to_id (bson_iter_utf8 (&iter, NULL)); - if (id != -1) { - return id; - } - } - - return -1; -} - -/* Returns true if either or both is NULL. out is 1 if exactly one NULL, 0 if - * both NULL */ -typedef int (*strcmp_fn) (const char *, const char *); - -static int -_nullable_cmp (const char *a, const char *b, strcmp_fn cmp_fn) -{ - if (!a && b) { - return 1; - } - - if (a && !b) { - return 1; - } - - if (!a && !b) { - return 0; - } - - /* Both not NULL. */ - return cmp_fn (a, b); -} -static int -_nullable_strcasecmp (const char *a, const char *b) -{ - return _nullable_cmp (a, b, strcasecmp); -} - -static int -_nullable_strcmp (const char *a, const char *b) -{ - return _nullable_cmp (a, b, strcmp); -} - -bool -_mongoc_server_description_equal (mongoc_server_description_t *sd1, - mongoc_server_description_t *sd2) -{ - if (sd1->type != sd2->type) { - return false; - } - - if (sd1->min_wire_version != sd2->min_wire_version) { - return false; - } - - if (sd1->max_wire_version != sd2->max_wire_version) { - return false; - } - - if (0 != _nullable_strcasecmp (sd1->me, sd2->me)) { - return false; - } - - /* CDRIVER-3527: The hosts/passives/arbiters checks should really be a set - * comparison of case insensitive hostnames. */ - if (!bson_equal (&sd1->hosts, &sd2->hosts)) { - return false; - } - - if (!bson_equal (&sd1->passives, &sd2->passives)) { - return false; - } - - if (!bson_equal (&sd1->arbiters, &sd2->arbiters)) { - return false; - } - - if (!bson_equal (&sd1->tags, &sd2->tags)) { - return false; - } - - if (0 != _nullable_strcmp (sd1->set_name, sd2->set_name)) { - return false; - } - - if (sd1->set_version != sd2->set_version) { - return false; - } - - if (!bson_oid_equal (&sd1->election_id, &sd2->election_id)) { - return false; - } - - if (0 != _nullable_strcasecmp (sd1->current_primary, sd2->current_primary)) { - return false; - } - - if (sd1->session_timeout_minutes != sd2->session_timeout_minutes) { - return false; - } - - if (0 != memcmp (&sd1->error, &sd2->error, sizeof (bson_error_t))) { - return false; - } - - if (!bson_equal (&sd1->topology_version, &sd2->topology_version)) { - return false; - } - - return true; -} - -int -mongoc_server_description_topology_version_cmp (const bson_t *tv1, - const bson_t *tv2) -{ - const bson_oid_t *pid1; - const bson_oid_t *pid2; - int64_t counter1; - int64_t counter2; - bson_iter_t iter; - - BSON_ASSERT (tv1); - BSON_ASSERT (tv2); - - if (bson_empty (tv1) || bson_empty (tv2)) { - return -1; - } - - if (!bson_iter_init_find (&iter, tv1, "processId") || - !BSON_ITER_HOLDS_OID (&iter)) { - return -1; - } - pid1 = bson_iter_oid (&iter); - - if (!bson_iter_init_find (&iter, tv2, "processId") || - !BSON_ITER_HOLDS_OID (&iter)) { - return -1; - } - pid2 = bson_iter_oid (&iter); - - if (0 != bson_oid_compare (pid1, pid2)) { - /* Assume greater. */ - return -1; - } - - if (!bson_iter_init_find (&iter, tv1, "counter") || - !BSON_ITER_HOLDS_INT (&iter)) { - return -1; - } - counter1 = bson_iter_as_int64 (&iter); - - if (!bson_iter_init_find (&iter, tv2, "counter") || - !BSON_ITER_HOLDS_INT (&iter)) { - return -1; - } - counter2 = bson_iter_as_int64 (&iter); - - if (counter1 < counter2) { - return -1; - } else if (counter1 > counter2) { - return 1; - } - return 0; -} - -void -mongoc_server_description_set_topology_version (mongoc_server_description_t *sd, - const bson_t *tv) -{ - BSON_ASSERT (tv); - bson_destroy (&sd->topology_version); - bson_copy_to (tv, &sd->topology_version); -} - -bool -mongoc_server_description_has_service_id ( - const mongoc_server_description_t *description) -{ - if (0 == bson_oid_compare (&description->service_id, &kZeroServiceId)) { - return false; - } - return true; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-description.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-description.h deleted file mode 100644 index 79ab4af64..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-description.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_SERVER_DESCRIPTION_H -#define MONGOC_SERVER_DESCRIPTION_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-read-prefs.h" -#include "mongoc-host-list.h" - -BSON_BEGIN_DECLS - -typedef struct _mongoc_server_description_t mongoc_server_description_t; - -MONGOC_EXPORT (void) -mongoc_server_description_destroy (mongoc_server_description_t *description); - -MONGOC_EXPORT (mongoc_server_description_t *) -mongoc_server_description_new_copy ( - const mongoc_server_description_t *description) BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (uint32_t) -mongoc_server_description_id (const mongoc_server_description_t *description); - -MONGOC_EXPORT (mongoc_host_list_t *) -mongoc_server_description_host (const mongoc_server_description_t *description); - -MONGOC_EXPORT (int64_t) -mongoc_server_description_last_update_time ( - const mongoc_server_description_t *description); - -MONGOC_EXPORT (int64_t) -mongoc_server_description_round_trip_time ( - const mongoc_server_description_t *description); - -MONGOC_EXPORT (const char *) -mongoc_server_description_type (const mongoc_server_description_t *description); - -MONGOC_EXPORT (const bson_t *) -mongoc_server_description_hello_response ( - const mongoc_server_description_t *description); - -MONGOC_EXPORT (const bson_t *) -mongoc_server_description_ismaster ( - const mongoc_server_description_t *description) - BSON_GNUC_DEPRECATED_FOR (mongoc_server_description_hello_response); - -MONGOC_EXPORT (int32_t) -mongoc_server_description_compressor_id ( - const mongoc_server_description_t *description); - -BSON_END_DECLS - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-monitor-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-monitor-private.h deleted file mode 100644 index 49d45c08f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-monitor-private.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_SERVER_MONITOR_PRIVATE_H -#define MONGOC_SERVER_MONITOR_PRIVATE_H - -#include "mongoc.h" -#include "mongoc-server-description-private.h" -#include "mongoc-topology-private.h" - -/* For background monitoring of a single server. */ - -typedef struct _mongoc_server_monitor_t mongoc_server_monitor_t; - -mongoc_server_monitor_t * -mongoc_server_monitor_new (mongoc_topology_t *topology, - mongoc_topology_description_t *td, - mongoc_server_description_t *init_description); - -void -mongoc_server_monitor_request_cancel (mongoc_server_monitor_t *server_monitor); - -void -mongoc_server_monitor_request_scan (mongoc_server_monitor_t *server_monitor); - -bool -mongoc_server_monitor_request_shutdown ( - mongoc_server_monitor_t *server_monitor); - -void -mongoc_server_monitor_wait_for_shutdown ( - mongoc_server_monitor_t *server_monitor); - -void -mongoc_server_monitor_destroy (mongoc_server_monitor_t *server_monitor); - -void -mongoc_server_monitor_run (mongoc_server_monitor_t *server_monitor); - -void -mongoc_server_monitor_run_as_rtt (mongoc_server_monitor_t *server_monitor); - -#endif /* MONGOC_SERVER_MONITOR_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-monitor.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-monitor.c deleted file mode 100644 index b0925d3d1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-server-monitor.c +++ /dev/null @@ -1,1531 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "common-thread-private.h" -#include "mongoc-server-monitor-private.h" - -#include "mongoc/mcd-rpc.h" -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-error-private.h" -#include "mongoc/mongoc-handshake-private.h" -#include "mongoc/mongoc-ssl-private.h" -#include "mongoc/mongoc-stream-private.h" -#include "mongoc/mongoc-topology-background-monitoring-private.h" -#include "mongoc/mongoc-topology-private.h" -#include "mongoc/mongoc-trace-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "monitor" - -typedef enum { - MONGOC_THREAD_OFF = 0, - MONGOC_THREAD_RUNNING, - MONGOC_THREAD_SHUTTING_DOWN, - MONGOC_THREAD_JOINABLE -} thread_state_t; - -/* Use a signed and wide return type for timeouts as long as you can. Cast only - * when you know what you're doing with it. */ -static int64_t -_now_us (void) -{ - return bson_get_monotonic_time (); -} - -static int64_t -_now_ms (void) -{ - return _now_us () / 1000; -} - -struct _mongoc_server_monitor_t { - mongoc_topology_t *topology; - bson_thread_t thread; - - /* State accessed from multiple threads. */ - struct { - bson_mutex_t mutex; - mongoc_cond_t cond; - thread_state_t state; - bool scan_requested; - bool cancel_requested; - } shared; - - /* Default time to sleep between hello checks (reduced when a scan is - * requested) */ - int64_t heartbeat_frequency_ms; - /* The minimum time to sleep between hello checks. */ - int64_t min_heartbeat_frequency_ms; - int64_t connect_timeout_ms; - bool use_tls; -#ifdef MONGOC_ENABLE_SSL - mongoc_ssl_opt_t *ssl_opts; -#endif - mongoc_uri_t *uri; - /* A custom initiator may be set if a user provides overrides to create a - * stream. */ - mongoc_stream_initiator_t initiator; - void *initiator_context; - int32_t request_id; - mongoc_apm_callbacks_t apm_callbacks; - void *apm_context; - - mongoc_stream_t *stream; - bool more_to_come; - mongoc_server_description_t *description; - uint32_t server_id; - bool is_rtt; -}; - -static BSON_GNUC_PRINTF (3, 4) void _server_monitor_log ( - mongoc_server_monitor_t *server_monitor, - mongoc_log_level_t level, - const char *format, - ...) -{ - va_list ap; - char *msg; - - va_start (ap, format); - msg = bson_strdupv_printf (format, ap); - va_end (ap); - - mongoc_log (level, - MONGOC_LOG_DOMAIN, - "[%s%s] %s", - server_monitor->description->host.host_and_port, - server_monitor->is_rtt ? "-RTT" : "", - msg); - bson_free (msg); -} - -#define MONITOR_LOG(sm, ...) \ - do { \ - if (MONGOC_TRACE_ENABLED) { \ - _server_monitor_log (sm, MONGOC_LOG_LEVEL_TRACE, __VA_ARGS__); \ - } \ - } while (0) - -/* TODO CDRIVER-3710 use MONGOC_LOG_LEVEL_ERROR */ -#define MONITOR_LOG_ERROR(sm, ...) \ - _server_monitor_log (sm, MONGOC_LOG_LEVEL_DEBUG, __VA_ARGS__) -/* TODO CDRIVER-3710 use MONGOC_LOG_LEVEL_WARNING */ -#define MONITOR_LOG_WARNING(sm, ...) \ - _server_monitor_log (sm, MONGOC_LOG_LEVEL_DEBUG, __VA_ARGS__) - -static void -_server_monitor_heartbeat_started (mongoc_server_monitor_t *server_monitor, - bool awaited) -{ - mongoc_apm_server_heartbeat_started_t event; - MONGOC_DEBUG_ASSERT ( - !mcommon_mutex_is_locked (&server_monitor->topology->apm_mutex)); - - if (!server_monitor->apm_callbacks.server_heartbeat_started) { - return; - } - - event.host = &server_monitor->description->host; - event.context = server_monitor->apm_context; - MONITOR_LOG (server_monitor, - "%s heartbeat started", - awaited ? "awaitable" : "regular"); - event.awaited = awaited; - bson_mutex_lock (&server_monitor->topology->apm_mutex); - server_monitor->apm_callbacks.server_heartbeat_started (&event); - bson_mutex_unlock (&server_monitor->topology->apm_mutex); -} - -static void -_server_monitor_heartbeat_succeeded (mongoc_server_monitor_t *server_monitor, - const bson_t *reply, - int64_t duration_usec, - bool awaited) -{ - mongoc_apm_server_heartbeat_succeeded_t event; - - if (!server_monitor->apm_callbacks.server_heartbeat_succeeded) { - return; - } - - event.host = &server_monitor->description->host; - event.context = server_monitor->apm_context; - event.reply = reply; - event.duration_usec = duration_usec; - MONITOR_LOG (server_monitor, - "%s heartbeat succeeded", - awaited ? "awaitable" : "regular"); - event.awaited = awaited; - bson_mutex_lock (&server_monitor->topology->apm_mutex); - server_monitor->apm_callbacks.server_heartbeat_succeeded (&event); - bson_mutex_unlock (&server_monitor->topology->apm_mutex); -} - -static void -_server_monitor_heartbeat_failed (mongoc_server_monitor_t *server_monitor, - const bson_error_t *error, - int64_t duration_usec, - bool awaited) -{ - mongoc_apm_server_heartbeat_failed_t event; - - if (!server_monitor->apm_callbacks.server_heartbeat_failed) { - return; - } - - event.host = &server_monitor->description->host; - event.context = server_monitor->apm_context; - event.error = error; - event.duration_usec = duration_usec; - MONITOR_LOG ( - server_monitor, "%s heartbeat failed", awaited ? "awaitable" : "regular"); - event.awaited = awaited; - bson_mutex_lock (&server_monitor->topology->apm_mutex); - server_monitor->apm_callbacks.server_heartbeat_failed (&event); - bson_mutex_unlock (&server_monitor->topology->apm_mutex); -} - -static void -_server_monitor_append_cluster_time (mongoc_server_monitor_t *server_monitor, - bson_t *cmd) -{ - mc_shared_tpld td = - mc_tpld_take_ref (BSON_ASSERT_PTR_INLINE (server_monitor)->topology); - - /* Cluster time is updated on every reply. */ - if (!bson_empty (&td.ptr->cluster_time)) { - bson_append_document (cmd, "$clusterTime", 12, &td.ptr->cluster_time); - } - mc_tpld_drop_ref (&td); -} - -static int32_t -_int32_from_le (const void *data) -{ - BSON_ASSERT_PARAM (data); - return bson_iter_int32_unsafe (&(bson_iter_t){.raw = data}); -} - -static bool -_server_monitor_send_and_recv_hello_opmsg ( - mongoc_server_monitor_t *server_monitor, - const bson_t *cmd, - bson_t *reply, - bson_error_t *error) -{ - bool ret = false; - - mcd_rpc_message *const rpc = mcd_rpc_message_new (); - mongoc_buffer_t buffer; - _mongoc_buffer_init (&buffer, NULL, 0, NULL, NULL); - void *decompressed_data = NULL; - size_t decompressed_data_len = 0u; - - /* First, let's construct and send our OP_MSG: */ - { - int32_t message_length = 0; - - message_length += mcd_rpc_header_set_message_length (rpc, 0); - message_length += - mcd_rpc_header_set_request_id (rpc, server_monitor->request_id++); - message_length += mcd_rpc_header_set_response_to (rpc, 0); - message_length += mcd_rpc_header_set_op_code (rpc, MONGOC_OP_CODE_MSG); - - mcd_rpc_op_msg_set_sections_count (rpc, 1u); - - message_length += - mcd_rpc_op_msg_set_flag_bits (rpc, MONGOC_OP_MSG_FLAG_NONE); - message_length += mcd_rpc_op_msg_section_set_kind (rpc, 0u, 0); - message_length += - mcd_rpc_op_msg_section_set_body (rpc, 0u, bson_get_data (cmd)); - - mcd_rpc_message_set_length (rpc, message_length); - } - - size_t num_iovecs = 0u; - mongoc_iovec_t *const iovecs = mcd_rpc_message_to_iovecs (rpc, &num_iovecs); - BSON_ASSERT (iovecs); - - MONITOR_LOG (server_monitor, - "sending with timeout %" PRId64, - server_monitor->connect_timeout_ms); - - mcd_rpc_message_egress (rpc); - if (!_mongoc_stream_writev_full (server_monitor->stream, - iovecs, - num_iovecs, - server_monitor->connect_timeout_ms, - error)) { - MONITOR_LOG_ERROR ( - server_monitor, "failed to write polling hello: %s", error->message); - goto fail; - } - - /* Done sending! Now, receive the reply: */ - if (!_mongoc_buffer_append_from_stream (&buffer, - server_monitor->stream, - sizeof (int32_t), - server_monitor->connect_timeout_ms, - error)) { - goto fail; - } - - const int32_t message_length = _int32_from_le (buffer.data); - - // msgHeader consists of four int32 fields. - const int32_t message_header_length = 4u * sizeof (int32_t); - - if (message_length < message_header_length) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid reply from server: message length"); - goto fail; - } - - const size_t remaining_bytes = (size_t) message_length - sizeof (int32_t); - - if (!_mongoc_buffer_append_from_stream (&buffer, - server_monitor->stream, - remaining_bytes, - server_monitor->connect_timeout_ms, - error)) { - goto fail; - } - - mcd_rpc_message_reset (rpc); - if (!mcd_rpc_message_from_data_in_place ( - rpc, buffer.data, buffer.len, NULL)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid reply from server: malformed message"); - goto fail; - } - - mcd_rpc_message_ingress (rpc); - - if (!mcd_rpc_message_decompress_if_necessary ( - rpc, &decompressed_data, &decompressed_data_len)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid reply from server: decompression failure"); - goto fail; - } - - bson_t body; - if (!mcd_rpc_message_get_body (rpc, &body)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid reply from server: malformed body"); - goto fail; - } - - bson_copy_to (&body, reply); - bson_destroy (&body); - - ret = true; - -fail: - if (!ret) { - bson_init (reply); - } - - bson_free (decompressed_data); - _mongoc_buffer_destroy (&buffer); - bson_free (iovecs); - mcd_rpc_message_destroy (rpc); - - return ret; -} - -static bool -_server_monitor_send_and_recv_opquery (mongoc_server_monitor_t *server_monitor, - const bson_t *cmd, - bson_t *reply, - bson_error_t *error) -{ - bool ret = false; - - mcd_rpc_message *const rpc = mcd_rpc_message_new (); - size_t num_iovecs = 0u; - mongoc_iovec_t *iovecs = NULL; - mongoc_buffer_t buffer; - _mongoc_buffer_init (&buffer, NULL, 0, NULL, NULL); - void *decompressed_data = NULL; - size_t decompressed_data_len = 0u; - - { - int32_t message_length = 0; - - message_length += mcd_rpc_header_set_message_length (rpc, 0); - message_length += - mcd_rpc_header_set_request_id (rpc, server_monitor->request_id++); - message_length += mcd_rpc_header_set_response_to (rpc, 0); - message_length += mcd_rpc_header_set_op_code (rpc, MONGOC_OP_CODE_QUERY); - - message_length += - mcd_rpc_op_query_set_flags (rpc, MONGOC_OP_QUERY_FLAG_SECONDARY_OK); - message_length += - mcd_rpc_op_query_set_full_collection_name (rpc, "admin.$cmd"); - message_length += mcd_rpc_op_query_set_number_to_skip (rpc, 0); - message_length += mcd_rpc_op_query_set_number_to_return (rpc, -1); - message_length += mcd_rpc_op_query_set_query (rpc, bson_get_data (cmd)); - - mcd_rpc_message_set_length (rpc, message_length); - } - - iovecs = mcd_rpc_message_to_iovecs (rpc, &num_iovecs); - BSON_ASSERT (iovecs); - - mcd_rpc_message_egress (rpc); - if (!_mongoc_stream_writev_full (server_monitor->stream, - iovecs, - num_iovecs, - server_monitor->connect_timeout_ms, - error)) { - goto fail; - } - - if (!_mongoc_buffer_append_from_stream (&buffer, - server_monitor->stream, - sizeof (int32_t), - server_monitor->connect_timeout_ms, - error)) { - goto fail; - } - - const int32_t message_length = _int32_from_le (buffer.data); - - // msgHeader consists of four int32 fields. - const int32_t message_header_length = 4u * sizeof (int32_t); - - if (message_length < message_header_length) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid reply from server: message length"); - goto fail; - } - - const size_t remaining_bytes = (size_t) message_length - sizeof (int32_t); - - if (!_mongoc_buffer_append_from_stream (&buffer, - server_monitor->stream, - remaining_bytes, - server_monitor->connect_timeout_ms, - error)) { - goto fail; - } - - mcd_rpc_message_reset (rpc); - if (!mcd_rpc_message_from_data_in_place ( - rpc, buffer.data, buffer.len, NULL)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid reply from server: malformed message"); - goto fail; - } - - mcd_rpc_message_ingress (rpc); - - if (!mcd_rpc_message_decompress_if_necessary ( - rpc, &decompressed_data, &decompressed_data_len)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid reply from server: decompression failure"); - goto fail; - } - - bson_t body; - if (!mcd_rpc_message_get_body (rpc, &body)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "invalid reply from server: malformed body"); - goto fail; - } - - bson_copy_to (&body, reply); - bson_destroy (&body); - - ret = true; - -fail: - if (!ret) { - bson_init (reply); - } - - bson_free (decompressed_data); - _mongoc_buffer_destroy (&buffer); - bson_free (iovecs); - mcd_rpc_message_destroy (rpc); - - return ret; -} - -static bool -_server_monitor_send_and_recv (mongoc_server_monitor_t *server_monitor, - bson_t *cmd, - bson_t *reply, - bson_error_t *error) -{ - if (mongoc_topology_uses_server_api (server_monitor->topology) || - mongoc_topology_uses_loadbalanced (server_monitor->topology)) { - /* OP_MSG requires a "db" parameter: */ - bson_append_utf8 (cmd, "$db", 3, "admin", 5); - - return _server_monitor_send_and_recv_hello_opmsg ( - server_monitor, cmd, reply, error); - } else { - return _server_monitor_send_and_recv_opquery ( - server_monitor, cmd, reply, error); - } -} - -static bool -_server_monitor_polling_hello (mongoc_server_monitor_t *server_monitor, - bool hello_ok, - bson_t *hello_response, - bson_error_t *error) -{ - bson_t cmd; - const bson_t *hello; - bool ret; - - hello = _mongoc_topology_scanner_get_monitoring_cmd ( - server_monitor->topology->scanner, hello_ok); - bson_copy_to (hello, &cmd); - - _server_monitor_append_cluster_time (server_monitor, &cmd); - - ret = _server_monitor_send_and_recv ( - server_monitor, &cmd, hello_response, error); - - bson_destroy (&cmd); - return ret; -} - -static bool -_server_monitor_awaitable_hello_send (mongoc_server_monitor_t *server_monitor, - bson_t *cmd, - bson_error_t *error) -{ - bool ret = false; - - mcd_rpc_message *const rpc = mcd_rpc_message_new (); - - { - int32_t message_length = 0; - - message_length += mcd_rpc_header_set_message_length (rpc, 0); - message_length += - mcd_rpc_header_set_request_id (rpc, server_monitor->request_id++); - message_length += mcd_rpc_header_set_response_to (rpc, 0); - message_length += mcd_rpc_header_set_op_code (rpc, MONGOC_OP_CODE_MSG); - - mcd_rpc_op_msg_set_sections_count (rpc, 1); - - message_length += - mcd_rpc_op_msg_set_flag_bits (rpc, MONGOC_OP_MSG_FLAG_EXHAUST_ALLOWED); - message_length += mcd_rpc_op_msg_section_set_kind (rpc, 0u, 0); - message_length += - mcd_rpc_op_msg_section_set_body (rpc, 0u, bson_get_data (cmd)); - - mcd_rpc_message_set_length (rpc, message_length); - } - - size_t num_iovecs; - mongoc_iovec_t *const iovecs = mcd_rpc_message_to_iovecs (rpc, &num_iovecs); - BSON_ASSERT (iovecs); - - MONITOR_LOG (server_monitor, - "sending with timeout %" PRId64, - server_monitor->connect_timeout_ms); - - mcd_rpc_message_egress (rpc); - if (!_mongoc_stream_writev_full (server_monitor->stream, - iovecs, - num_iovecs, - server_monitor->connect_timeout_ms, - error)) { - MONITOR_LOG_ERROR ( - server_monitor, "failed to write awaitable hello: %s", error->message); - goto done; - } - - ret = true; - -done: - bson_free (iovecs); - mcd_rpc_message_destroy (rpc); - - return ret; -} - -/* Poll the server monitor stream for reading. Allows cancellation. - * - * Called only from server monitor thread. - * Locks server monitor mutex. - * Returns true if stream is readable. False on error or cancellation. - * On cancellation, no error is set, but cancelled is set to true. - */ -static bool -_server_monitor_poll_with_interrupt (mongoc_server_monitor_t *server_monitor, - int64_t expire_at_ms, - bool *cancelled, - bson_error_t *error) -{ - /* How many milliseconds we should poll for on each tick. - * On every tick, check whether the awaitable hello was cancelled. */ - const int32_t monitor_tick_ms = MONGOC_TOPOLOGY_MIN_HEARTBEAT_FREQUENCY_MS; - int64_t timeleft_ms; - - while ((timeleft_ms = expire_at_ms - _now_ms ()) > 0) { - ssize_t ret; - mongoc_stream_poll_t poller[1]; - - MONITOR_LOG (server_monitor, - "_server_monitor_poll_with_interrupt expires in: %" PRIu64 - "ms", - timeleft_ms); - poller[0].stream = server_monitor->stream; - poller[0].events = - POLLIN; /* POLLERR and POLLHUP are added in mongoc_socket_poll. */ - poller[0].revents = 0; - - MONITOR_LOG ( - server_monitor, - "polling for awaitable hello reply with timeleft_ms: %" PRId64, - timeleft_ms); - ret = mongoc_stream_poll ( - poller, 1, (int32_t) BSON_MIN (timeleft_ms, monitor_tick_ms)); - if (ret == -1) { - MONITOR_LOG (server_monitor, "mongoc_stream_poll error"); - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "poll error"); - return false; - } - - if (poller[0].revents & (POLLERR | POLLHUP)) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "connection closed while polling"); - return false; - } - - /* Check for cancellation. */ - bson_mutex_lock (&server_monitor->shared.mutex); - *cancelled = server_monitor->shared.cancel_requested; - server_monitor->shared.cancel_requested = false; - bson_mutex_unlock (&server_monitor->shared.mutex); - - if (*cancelled) { - MONITOR_LOG (server_monitor, "polling cancelled"); - return false; - } - - if (poller[0].revents & POLLIN) { - MONITOR_LOG (server_monitor, "mongoc_stream_poll ready to read"); - return true; - } - } - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "connection timeout while polling"); - return false; -} - -/* Calculate the timeout between the current time and an absolute expiration - * time in milliseconds. - * - * Returns 0 and sets error if time expired. - */ -int64_t -_get_timeout_ms (int64_t expire_at_ms, bson_error_t *error) -{ - int64_t timeout_ms; - - timeout_ms = expire_at_ms - _now_ms (); - if (timeout_ms <= 0) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "connection timed out reading message length"); - return 0; - } - return timeout_ms; -} - -/* Receive an awaitable hello reply. - * - * May be used to receive additional replies when moreToCome is set. - * Called only from server monitor thread. - * May lock server monitor mutex in functions that are called. - * May block for up to heartbeatFrequencyMS + connectTimeoutMS waiting for - * reply. - * Returns true if a reply was received. False on error or cancellation. - * On cancellation, no error is set, but cancelled is set to true. - */ -static bool -_server_monitor_awaitable_hello_recv (mongoc_server_monitor_t *server_monitor, - bson_t *hello_response, - bool *cancelled, - bson_error_t *error) -{ - bool ret = false; - - int64_t timeout_ms; - mcd_rpc_message *const rpc = mcd_rpc_message_new (); - mongoc_buffer_t buffer; - _mongoc_buffer_init (&buffer, NULL, 0, NULL, NULL); - void *decompressed_data = NULL; - size_t decompressed_data_len = 0u; - - const int64_t expire_at_ms = _now_ms () + - server_monitor->heartbeat_frequency_ms + - server_monitor->connect_timeout_ms; - - if (!_server_monitor_poll_with_interrupt ( - server_monitor, expire_at_ms, cancelled, error)) { - GOTO (fail); - } - - timeout_ms = _get_timeout_ms (expire_at_ms, error); - if (timeout_ms == 0) { - GOTO (fail); - } - - MONITOR_LOG (server_monitor, - "reading first 4 bytes with timeout: %" PRId64, - timeout_ms); - if (!_mongoc_buffer_append_from_stream (&buffer, - server_monitor->stream, - sizeof (int32_t), - (int32_t) timeout_ms, - error)) { - GOTO (fail); - } - - const int32_t message_length = _int32_from_le (buffer.data); - - // msgHeader consists of four int32 fields. - const int32_t message_header_length = 4u * sizeof (int32_t); - - if ((message_length < message_header_length) || - (message_length > server_monitor->description->max_msg_size)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "message size %" PRId32 - " is not within expected range 16-%" PRId32 " bytes", - message_length, - server_monitor->description->max_msg_size); - GOTO (fail); - } - - timeout_ms = _get_timeout_ms (expire_at_ms, error); - if (timeout_ms == 0) { - GOTO (fail); - } - - const size_t remaining_bytes = (size_t) message_length - sizeof (int32_t); - - MONITOR_LOG (server_monitor, - "reading remaining %zu bytes. Timeout %" PRId64, - remaining_bytes, - timeout_ms); - if (!_mongoc_buffer_append_from_stream (&buffer, - server_monitor->stream, - remaining_bytes, - timeout_ms, - error)) { - GOTO (fail); - } - - if (!mcd_rpc_message_from_data_in_place ( - rpc, buffer.data, buffer.len, NULL)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "malformed message from server"); - GOTO (fail); - } - - mcd_rpc_message_ingress (rpc); - - if (!mcd_rpc_message_decompress_if_necessary ( - rpc, &decompressed_data, &decompressed_data_len)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "decompression failure"); - GOTO (fail); - } - - bson_t body; - if (!mcd_rpc_message_get_body (rpc, &body)) { - bson_set_error (error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "malformed BSON payload from server"); - GOTO (fail); - } - - bson_copy_to (&body, hello_response); - bson_destroy (&body); - - server_monitor->more_to_come = (mcd_rpc_op_msg_get_flag_bits (rpc) & - MONGOC_OP_MSG_FLAG_MORE_TO_COME) != 0; - - ret = true; - -fail: - if (!ret) { - bson_init (hello_response); - } - - bson_free (decompressed_data); - _mongoc_buffer_destroy (&buffer); - mcd_rpc_message_destroy (rpc); - - return ret; -} - -/* Send and receive an awaitable hello. - * - * Called only from server monitor thread. - * May lock server monitor mutex in functions that are called. - * May block for up to heartbeatFrequencyMS waiting for reply. - */ -static bool -_server_monitor_awaitable_hello (mongoc_server_monitor_t *server_monitor, - const mongoc_server_description_t *description, - bson_t *hello_response, - bool *cancelled, - bson_error_t *error) -{ - bson_t cmd; - const bson_t *hello; - bool ret = false; - - hello = _mongoc_topology_scanner_get_monitoring_cmd ( - server_monitor->topology->scanner, description->hello_ok); - bson_copy_to (hello, &cmd); - - _server_monitor_append_cluster_time (server_monitor, &cmd); - bson_append_document ( - &cmd, "topologyVersion", 15, &description->topology_version); - bson_append_int64 ( - &cmd, "maxAwaitTimeMS", 14, server_monitor->heartbeat_frequency_ms); - bson_append_utf8 (&cmd, "$db", 3, "admin", 5); - - if (!_server_monitor_awaitable_hello_send (server_monitor, &cmd, error)) { - GOTO (fail); - } - - if (!_server_monitor_awaitable_hello_recv ( - server_monitor, hello_response, cancelled, error)) { - bson_destroy (hello_response); - GOTO (fail); - } - - ret = true; -fail: - if (!ret) { - bson_init (hello_response); - } - bson_destroy (&cmd); - return ret; -} - -/* Update the topology description with a reply or an error. - * - * Called only from server monitor thread. - * Caller must hold no locks. - * Locks server monitor mutex. - */ -static void -_update_topology_description (mongoc_server_monitor_t *server_monitor, - mongoc_server_description_t *description) -{ - mongoc_topology_t *topology; - bson_t *hello_response = NULL; - mc_tpld_modification tdmod; - - topology = server_monitor->topology; - if (description->has_hello_response) { - hello_response = &description->last_hello_response; - } - - if (hello_response) { - _mongoc_topology_update_cluster_time (topology, hello_response); - } - - if (bson_atomic_int_fetch (&topology->scanner_state, - bson_memory_order_relaxed) == - MONGOC_TOPOLOGY_SCANNER_SHUTTING_DOWN) { - return; - } - - tdmod = mc_tpld_modify_begin (topology); - bson_mutex_lock (&server_monitor->shared.mutex); - server_monitor->shared.scan_requested = false; - bson_mutex_unlock (&server_monitor->shared.mutex); - mongoc_topology_description_handle_hello (tdmod.new_td, - server_monitor->server_id, - hello_response, - description->round_trip_time_msec, - &description->error); - /* Reconcile server monitors. */ - _mongoc_topology_background_monitoring_reconcile (topology, tdmod.new_td); - /* Wake threads performing server selection. */ - mongoc_cond_broadcast (&server_monitor->topology->cond_client); - mc_tpld_modify_commit (tdmod); -} - -/* Create a new server monitor. - * - * Called during reconcile. - * Caller must hold topology lock. - */ -mongoc_server_monitor_t * -mongoc_server_monitor_new (mongoc_topology_t *topology, - mongoc_topology_description_t *td, - mongoc_server_description_t *init_description) -{ - mongoc_server_monitor_t *server_monitor = - bson_malloc0 (sizeof (*server_monitor)); - server_monitor->description = - mongoc_server_description_new_copy (init_description); - server_monitor->server_id = init_description->id; - server_monitor->topology = topology; - server_monitor->heartbeat_frequency_ms = td->heartbeat_msec; - server_monitor->min_heartbeat_frequency_ms = - topology->min_heartbeat_frequency_msec; - server_monitor->connect_timeout_ms = topology->connect_timeout_msec; - server_monitor->uri = mongoc_uri_copy (topology->uri); -/* TODO CDRIVER-3682: Do not retrieve ssl opts from topology scanner. They - * should be stored somewhere else. */ -#ifdef MONGOC_ENABLE_SSL - if (topology->scanner->ssl_opts) { - server_monitor->ssl_opts = bson_malloc0 (sizeof (mongoc_ssl_opt_t)); - - _mongoc_ssl_opts_copy_to ( - topology->scanner->ssl_opts, server_monitor->ssl_opts, true); - } -#endif - memcpy (&server_monitor->apm_callbacks, - &td->apm_callbacks, - sizeof (mongoc_apm_callbacks_t)); - server_monitor->apm_context = td->apm_context; - server_monitor->initiator = topology->scanner->initiator; - server_monitor->initiator_context = topology->scanner->initiator_context; - mongoc_cond_init (&server_monitor->shared.cond); - bson_mutex_init (&server_monitor->shared.mutex); - return server_monitor; -} - -/* Creates a stream and performs the initial hello handshake. - * - * Called only by server monitor thread. - * Returns true if both connection and handshake succeeds. - * Returns false and sets error otherwise. - * hello_response is always initialized. - */ -static bool -_server_monitor_setup_connection (mongoc_server_monitor_t *server_monitor, - bson_t *hello_response, - int64_t *start_us, - bson_error_t *error) -{ - bson_t cmd = BSON_INITIALIZER; - bool ret = false; - - ENTRY; - - BSON_ASSERT (!server_monitor->stream); - bson_init (hello_response); - - server_monitor->more_to_come = false; - - /* Using an initiator isn't really necessary. Users can't set them on - * pools. But it is used for tests. */ - if (server_monitor->initiator) { - server_monitor->stream = - server_monitor->initiator (server_monitor->uri, - &server_monitor->description->host, - server_monitor->initiator_context, - error); - } else { - void *ssl_opts_void = NULL; - -#ifdef MONGOC_ENABLE_SSL - ssl_opts_void = server_monitor->ssl_opts; -#endif - server_monitor->stream = - mongoc_client_connect (false, - ssl_opts_void != NULL, - ssl_opts_void, - server_monitor->uri, - &server_monitor->description->host, - error); - } - - if (!server_monitor->stream) { - GOTO (fail); - } - - /* Update the start time just before the handshake. */ - *start_us = _now_us (); - /* Perform handshake. */ - bson_destroy (&cmd); - _mongoc_topology_dup_handshake_cmd (server_monitor->topology, &cmd); - _server_monitor_append_cluster_time (server_monitor, &cmd); - bson_destroy (hello_response); - - ret = _server_monitor_send_and_recv ( - server_monitor, &cmd, hello_response, error); - -fail: - bson_destroy (&cmd); - RETURN (ret); -} - -/** - * @brief Perform a hello check on a server - * - * @param server_monitor The server monitor for this server. - * @param previous_description The most recent view of the description of this - * server. - * @param cancelled Output parameter: Whether the monitor check is cancelled. - * @return mongoc_server_description_t* The newly created updated server - * description. - * - * @note May update the topology description associated with the server monitor. - * - * @note In case of error, returns a new server description with the error - * information, but with no hello reply. - */ -static mongoc_server_description_t * -_server_monitor_check_server ( - mongoc_server_monitor_t *server_monitor, - const mongoc_server_description_t *previous_description, - bool *cancelled) -{ - bool ret = false; - bson_error_t error; - bson_t hello_response; - int64_t duration_us; - int64_t start_us; - bool command_or_network_error = false; - bool awaited = false; - mongoc_server_description_t *description; - mc_tpld_modification tdmod; - - ENTRY; - - *cancelled = false; - memset (&error, 0, sizeof (bson_error_t)); - description = BSON_ALIGNED_ALLOC0 (mongoc_server_description_t); - mongoc_server_description_init ( - description, - server_monitor->description->connection_address, - server_monitor->description->id); - start_us = _now_us (); - - if (!server_monitor->stream) { - MONITOR_LOG (server_monitor, "setting up connection"); - awaited = false; - _server_monitor_heartbeat_started (server_monitor, awaited); - ret = _server_monitor_setup_connection ( - server_monitor, &hello_response, &start_us, &error); - GOTO (exit); - } - - if (server_monitor->more_to_come) { - awaited = true; - /* Publish a heartbeat started for each additional response read. */ - _server_monitor_heartbeat_started (server_monitor, awaited); - MONITOR_LOG (server_monitor, "more to come"); - ret = _server_monitor_awaitable_hello_recv ( - server_monitor, &hello_response, cancelled, &error); - GOTO (exit); - } - - if (!bson_empty (&previous_description->topology_version) && - _mongoc_handshake_get ()->env == MONGOC_HANDSHAKE_ENV_NONE) { - // Use stream monitoring if: - // - Server supports stream monitoring (indicated by `topologyVersion`). - // - Application is not in an FaaS environment (e.g. AWS Lambda). - awaited = true; - _server_monitor_heartbeat_started (server_monitor, awaited); - MONITOR_LOG (server_monitor, "awaitable hello"); - ret = _server_monitor_awaitable_hello (server_monitor, - previous_description, - &hello_response, - cancelled, - &error); - GOTO (exit); - } - - MONITOR_LOG (server_monitor, "polling hello"); - awaited = false; - _server_monitor_heartbeat_started (server_monitor, awaited); - ret = _server_monitor_polling_hello ( - server_monitor, previous_description->hello_ok, &hello_response, &error); - -exit: - duration_us = _now_us () - start_us; - MONITOR_LOG ( - server_monitor, "server check duration (us): %" PRId64, duration_us); - - /* If ret is true, we have a reply. Check if "ok": 1. */ - if (ret && _mongoc_cmd_check_ok ( - &hello_response, MONGOC_ERROR_API_VERSION_2, &error)) { - int64_t rtt_ms = MONGOC_RTT_UNSET; - - /* rtt remains MONGOC_RTT_UNSET if awaited. */ - if (!awaited) { - rtt_ms = duration_us / 1000; - } - - mongoc_server_description_handle_hello ( - description, &hello_response, rtt_ms, NULL); - /* If the hello reply could not be parsed, consider this a command - * error. */ - if (description->error.code) { - MONITOR_LOG_ERROR (server_monitor, - "error parsing server reply: %s", - description->error.message); - command_or_network_error = true; - _server_monitor_heartbeat_failed ( - server_monitor, &description->error, duration_us, awaited); - } else { - _server_monitor_heartbeat_succeeded ( - server_monitor, &hello_response, duration_us, awaited); - } - } else if (*cancelled) { - MONITOR_LOG (server_monitor, "server monitor cancelled"); - if (server_monitor->stream) { - mongoc_stream_destroy (server_monitor->stream); - } - server_monitor->stream = NULL; - server_monitor->more_to_come = false; - _server_monitor_heartbeat_failed ( - server_monitor, &description->error, duration_us, awaited); - } else { - /* The hello reply had "ok":0 or a network error occurred. */ - MONITOR_LOG_ERROR (server_monitor, - "command or network error occurred: %s", - error.message); - command_or_network_error = true; - mongoc_server_description_handle_hello ( - description, NULL, MONGOC_RTT_UNSET, &error); - _server_monitor_heartbeat_failed ( - server_monitor, &description->error, duration_us, awaited); - } - - if (command_or_network_error) { - if (server_monitor->stream) { - mongoc_stream_failed (server_monitor->stream); - } - server_monitor->stream = NULL; - server_monitor->more_to_come = false; - tdmod = mc_tpld_modify_begin (server_monitor->topology); - /* clear_connection_pool() is a no-op if 'description->id' was already - * removed. */ - _mongoc_topology_description_clear_connection_pool ( - tdmod.new_td, - server_monitor->description->id, - &server_monitor->description->service_id); - mc_tpld_modify_commit (tdmod); - } - - bson_destroy (&hello_response); - return description; -} - -/* Request scan of a single server. - * - * Locks server monitor mutex to deliver scan_requested. - */ -void -mongoc_server_monitor_request_scan (mongoc_server_monitor_t *server_monitor) -{ - MONITOR_LOG (server_monitor, "requesting scan"); - bson_mutex_lock (&server_monitor->shared.mutex); - server_monitor->shared.scan_requested = true; - mongoc_cond_signal (&server_monitor->shared.cond); - bson_mutex_unlock (&server_monitor->shared.mutex); -} - -/* Request cancellation of an in progress awaitable hello. - * - * Called from app threads on network errors and during shutdown. - * Locks server monitor mutex. - */ -void -mongoc_server_monitor_request_cancel (mongoc_server_monitor_t *server_monitor) -{ - MONITOR_LOG (server_monitor, "requesting cancel"); - bson_mutex_lock (&server_monitor->shared.mutex); - server_monitor->shared.cancel_requested = true; - mongoc_cond_signal (&server_monitor->shared.cond); - bson_mutex_unlock (&server_monitor->shared.mutex); -} - -/* Wait for heartbeatFrequencyMS or minHeartbeatFrequencyMS if a scan is - * requested. - * - * Locks server monitor mutex. - */ -void -mongoc_server_monitor_wait (mongoc_server_monitor_t *server_monitor) -{ - int64_t start_ms; - int64_t scan_due_ms; - - start_ms = _now_ms (); - scan_due_ms = start_ms + server_monitor->heartbeat_frequency_ms; - - bson_mutex_lock (&server_monitor->shared.mutex); - while (true) { - int64_t sleep_duration_ms; - int cond_ret; - - if (server_monitor->shared.state != MONGOC_THREAD_RUNNING) { - break; - } - - if (server_monitor->shared.scan_requested) { - server_monitor->shared.scan_requested = false; - scan_due_ms = start_ms + server_monitor->min_heartbeat_frequency_ms; - } - - sleep_duration_ms = scan_due_ms - _now_ms (); - - if (sleep_duration_ms <= 0) { - break; - } - - MONITOR_LOG (server_monitor, "sleeping for %" PRId64, sleep_duration_ms); - cond_ret = mongoc_cond_timedwait (&server_monitor->shared.cond, - &server_monitor->shared.mutex, - sleep_duration_ms); - if (mongo_cond_ret_is_timedout (cond_ret)) { - break; - } - } - bson_mutex_unlock (&server_monitor->shared.mutex); -} - -/* The server monitor thread function. - * - * Server monitor must be in state MONGOC_THREAD_OFF. - */ -static BSON_THREAD_FUN (_server_monitor_thread, server_monitor_void) -{ - mongoc_server_monitor_t *server_monitor; - mongoc_server_description_t *description; - mongoc_server_description_t *previous_description; - - server_monitor = (mongoc_server_monitor_t *) server_monitor_void; - description = - mongoc_server_description_new_copy (server_monitor->description); - previous_description = NULL; - - while (true) { - bool cancelled = false; - - bson_mutex_lock (&server_monitor->shared.mutex); - if (server_monitor->shared.state != MONGOC_THREAD_RUNNING) { - bson_mutex_unlock (&server_monitor->shared.mutex); - break; - } - bson_mutex_unlock (&server_monitor->shared.mutex); - - mongoc_server_description_destroy (previous_description); - previous_description = mongoc_server_description_new_copy (description); - mongoc_server_description_destroy (description); - description = _server_monitor_check_server ( - server_monitor, previous_description, &cancelled); - - if (cancelled) { - mongoc_server_monitor_wait (server_monitor); - continue; - } - - _update_topology_description (server_monitor, description); - - /* Immediately proceed to the next check if the previous response was - * successful and included the topologyVersion field. */ - if (description->type != MONGOC_SERVER_UNKNOWN && - !bson_empty (&description->topology_version)) { - MONITOR_LOG (server_monitor, - "immediately proceeding due to topologyVersion"); - continue; - } - - /* ... or the previous response included the moreToCome flag */ - if (server_monitor->more_to_come) { - MONITOR_LOG (server_monitor, - "immediately proceeding due to moreToCome"); - continue; - } - - /* ... or the server has just transitioned to Unknown due to a network - * error. */ - if (_mongoc_error_is_network (&description->error) && - previous_description->type != MONGOC_SERVER_UNKNOWN) { - MONITOR_LOG (server_monitor, - "immediately proceeding due to network error"); - continue; - } - - mongoc_server_monitor_wait (server_monitor); - } - - bson_mutex_lock (&server_monitor->shared.mutex); - server_monitor->shared.state = MONGOC_THREAD_JOINABLE; - bson_mutex_unlock (&server_monitor->shared.mutex); - mongoc_server_description_destroy (previous_description); - mongoc_server_description_destroy (description); - BSON_THREAD_RETURN; -} - -static bool -_server_monitor_ping_server (mongoc_server_monitor_t *server_monitor, - bool hello_ok, - int64_t *rtt_ms) -{ - bool ret = false; - int64_t start_us = _now_us (); - bson_t hello_response; - bson_error_t error; - - *rtt_ms = MONGOC_RTT_UNSET; - - if (!server_monitor->stream) { - MONITOR_LOG (server_monitor, "rtt setting up connection"); - ret = _server_monitor_setup_connection ( - server_monitor, &hello_response, &start_us, &error); - bson_destroy (&hello_response); - } - - if (server_monitor->stream) { - MONITOR_LOG (server_monitor, "rtt polling hello"); - ret = _server_monitor_polling_hello ( - server_monitor, hello_ok, &hello_response, &error); - if (ret) { - *rtt_ms = (_now_us () - start_us) / 1000; - } - bson_destroy (&hello_response); - } - return ret; -} - -/* The RTT monitor thread function. - * - * Server monitor must be in state MONGOC_THREAD_OFF. - */ -static BSON_THREAD_FUN (_server_monitor_rtt_thread, server_monitor_void) -{ - mongoc_server_monitor_t *server_monitor = server_monitor_void; - - while (true) { - int64_t rtt_ms; - bson_error_t error; - bool hello_ok; - - bson_mutex_lock (&server_monitor->shared.mutex); - if (server_monitor->shared.state != MONGOC_THREAD_RUNNING) { - bson_mutex_unlock (&server_monitor->shared.mutex); - break; - } - bson_mutex_unlock (&server_monitor->shared.mutex); - - { - mc_shared_tpld td = mc_tpld_take_ref (server_monitor->topology); - const mongoc_server_description_t *sd = - mongoc_topology_description_server_by_id_const ( - td.ptr, server_monitor->description->id, &error); - hello_ok = sd ? sd->hello_ok : false; - mc_tpld_drop_ref (&td); - } - - _server_monitor_ping_server (server_monitor, hello_ok, &rtt_ms); - if (rtt_ms != MONGOC_RTT_UNSET) { - mc_tpld_modification tdmod = - mc_tpld_modify_begin (server_monitor->topology); - mongoc_server_description_t *const mut_sd = - mongoc_topology_description_server_by_id ( - tdmod.new_td, server_monitor->description->id, &error); - if (mut_sd) { - mongoc_server_description_update_rtt (mut_sd, rtt_ms); - mc_tpld_modify_commit (tdmod); - } else { - /* If the server description has been removed, the RTT thread will - * be terminated by background monitoring soon, so we have nothing - * to do but wait until we are about to be stopped. */ - mc_tpld_modify_drop (tdmod); - } - } - mongoc_server_monitor_wait (server_monitor); - } - - bson_mutex_lock (&server_monitor->shared.mutex); - server_monitor->shared.state = MONGOC_THREAD_JOINABLE; - bson_mutex_unlock (&server_monitor->shared.mutex); - BSON_THREAD_RETURN; -} - -void -mongoc_server_monitor_run (mongoc_server_monitor_t *server_monitor) -{ - bson_mutex_lock (&server_monitor->shared.mutex); - if (server_monitor->shared.state == MONGOC_THREAD_OFF) { - server_monitor->is_rtt = false; - int ret = mcommon_thread_create ( - &server_monitor->thread, _server_monitor_thread, server_monitor); - if (ret == 0) { - server_monitor->shared.state = MONGOC_THREAD_RUNNING; - } else { - char errmsg_buf[BSON_ERROR_BUFFER_SIZE]; - char *errmsg = bson_strerror_r (ret, errmsg_buf, sizeof errmsg_buf); - _server_monitor_log (server_monitor, - MONGOC_LOG_LEVEL_ERROR, - "Failed to start monitoring thread. This server " - "may not be selectable. Error: %s", - errmsg); - } - } - bson_mutex_unlock (&server_monitor->shared.mutex); -} - -void -mongoc_server_monitor_run_as_rtt (mongoc_server_monitor_t *server_monitor) -{ - bson_mutex_lock (&server_monitor->shared.mutex); - if (server_monitor->shared.state == MONGOC_THREAD_OFF) { - server_monitor->is_rtt = true; - int ret = mcommon_thread_create ( - &server_monitor->thread, _server_monitor_rtt_thread, server_monitor); - if (ret == 0) { - server_monitor->shared.state = MONGOC_THREAD_RUNNING; - } else { - char errmsg_buf[BSON_ERROR_BUFFER_SIZE]; - char *errmsg = bson_strerror_r (ret, errmsg_buf, sizeof errmsg_buf); - _server_monitor_log ( - server_monitor, - MONGOC_LOG_LEVEL_ERROR, - "Failed to start Round-Trip Time monitoring thread. Error: %s", - errmsg); - } - } - bson_mutex_unlock (&server_monitor->shared.mutex); -} - -/* Request thread shutdown. - * - * Returns true if in state MONGOC_THREAD_OFF and the server monitor can be - * safely destroyed. - * Called during topology description reconcile. - * Locks server monitor mutex. - */ -bool -mongoc_server_monitor_request_shutdown (mongoc_server_monitor_t *server_monitor) -{ - bool off = false; - - bson_mutex_lock (&server_monitor->shared.mutex); - if (server_monitor->shared.state == MONGOC_THREAD_RUNNING) { - server_monitor->shared.state = MONGOC_THREAD_SHUTTING_DOWN; - } - if (server_monitor->shared.state == MONGOC_THREAD_JOINABLE) { - mcommon_thread_join (server_monitor->thread); - server_monitor->shared.state = MONGOC_THREAD_OFF; - } - if (server_monitor->shared.state == MONGOC_THREAD_OFF) { - off = true; - } - mongoc_cond_signal (&server_monitor->shared.cond); - bson_mutex_unlock (&server_monitor->shared.mutex); - /* Cancel an in-progress hello check. */ - if (!off) { - mongoc_server_monitor_request_cancel (server_monitor); - } - return off; -} - -/* Request thread shutdown and block until the server monitor thread terminates. - * - * Called by one thread. - * Locks the server monitor mutex. - */ -void -mongoc_server_monitor_wait_for_shutdown ( - mongoc_server_monitor_t *server_monitor) -{ - if (mongoc_server_monitor_request_shutdown (server_monitor)) { - return; - } - - /* Shutdown requested, but thread is not yet off. Wait. */ - mcommon_thread_join (server_monitor->thread); - bson_mutex_lock (&server_monitor->shared.mutex); - server_monitor->shared.state = MONGOC_THREAD_OFF; - bson_mutex_unlock (&server_monitor->shared.mutex); -} - -/* Destroy a server monitor. - * - * Called only by one thread. - * Caller must not hold server monitor lock. - * Server monitor thread is in state MONGOC_THREAD_OFF. - */ -void -mongoc_server_monitor_destroy (mongoc_server_monitor_t *server_monitor) -{ - if (!server_monitor) { - return; - } - - /* Locking not necessary since this is only called by one thread, and server - * monitor thread is no longer running. */ - BSON_ASSERT (server_monitor->shared.state == MONGOC_THREAD_OFF); - - mongoc_server_description_destroy (server_monitor->description); - mongoc_stream_destroy (server_monitor->stream); - mongoc_uri_destroy (server_monitor->uri); - mongoc_cond_destroy (&server_monitor->shared.cond); - bson_mutex_destroy (&server_monitor->shared.mutex); -#ifdef MONGOC_ENABLE_SSL - if (server_monitor->ssl_opts) { - _mongoc_ssl_opts_cleanup (server_monitor->ssl_opts, true); - bson_free (server_monitor->ssl_opts); - } -#endif - bson_free (server_monitor); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-set-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-set-private.h deleted file mode 100644 index abef64095..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-set-private.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_SET_PRIVATE_H -#define MONGOC_SET_PRIVATE_H - -#include - -BSON_BEGIN_DECLS - -typedef void (*mongoc_set_item_dtor) (void *item, void *ctx); - -/* return true to continue iteration, false to stop */ -typedef bool (*mongoc_set_for_each_cb_t) (void *item, void *ctx); -typedef bool (*mongoc_set_for_each_const_cb_t) (const void *item, void *ctx); -typedef bool (*mongoc_set_for_each_with_id_cb_t) (uint32_t id, - void *item, - void *ctx); - -typedef struct { - uint32_t id; - void *item; -} mongoc_set_item_t; - -typedef struct { - mongoc_set_item_t *items; - size_t items_len; - size_t items_allocated; - mongoc_set_item_dtor dtor; - void *dtor_ctx; -} mongoc_set_t; - -mongoc_set_t * -mongoc_set_new (size_t nitems, mongoc_set_item_dtor dtor, void *dtor_ctx); - -void -mongoc_set_add (mongoc_set_t *set, uint32_t id, void *item); - -void -mongoc_set_rm (mongoc_set_t *set, uint32_t id); - -void * -mongoc_set_get (mongoc_set_t *set, uint32_t id); - -static BSON_INLINE const void * -mongoc_set_get_const (const mongoc_set_t *set, uint32_t id) -{ - return mongoc_set_get ((mongoc_set_t *) set, id); -} - -void * -mongoc_set_get_item (mongoc_set_t *set, size_t idx); - -static BSON_INLINE const void * -mongoc_set_get_item_const (const mongoc_set_t *set, size_t idx) -{ - return mongoc_set_get_item ((mongoc_set_t *) set, idx); -} - -void * -mongoc_set_get_item_and_id (mongoc_set_t *set, - size_t idx, - uint32_t *id /* OUT */); - -static BSON_INLINE const void * -mongoc_set_get_item_and_id_const (const mongoc_set_t *set, - size_t idx, - uint32_t *id) -{ - return mongoc_set_get_item_and_id ((mongoc_set_t *) set, idx, id); -} - -void -mongoc_set_destroy (mongoc_set_t *set); - -/* loops over the set safe-ish. - * - * Caveats: - * - you can add items at any iteration - * - if you remove elements other than the one you're currently looking at, - * you may see it later in the iteration - */ -void -mongoc_set_for_each (mongoc_set_t *set, mongoc_set_for_each_cb_t cb, void *ctx); - -static BSON_INLINE void -mongoc_set_for_each_const (const mongoc_set_t *set, - mongoc_set_for_each_const_cb_t cb, - void *ctx) -{ - mongoc_set_for_each ( - (mongoc_set_t *) set, (mongoc_set_for_each_cb_t) cb, ctx); -} - -void -mongoc_set_for_each_with_id (mongoc_set_t *set, - mongoc_set_for_each_with_id_cb_t cb, - void *ctx); - -/* first item in set for which "cb" returns true */ -void * -mongoc_set_find_item (mongoc_set_t *set, - mongoc_set_for_each_cb_t cb, - void *ctx); - -/* id of first item in set for which "cb" returns true, or 0. */ -uint32_t -mongoc_set_find_id (const mongoc_set_t *set, - mongoc_set_for_each_const_cb_t cb, - void *ctx); - -BSON_END_DECLS - -#endif /* MONGOC_SET_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-set.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-set.c deleted file mode 100644 index df99d074d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-set.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "mongoc-set-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "set" - -mongoc_set_t * -mongoc_set_new (size_t nitems, mongoc_set_item_dtor dtor, void *dtor_ctx) -{ - mongoc_set_t *set = (mongoc_set_t *) bson_malloc (sizeof (*set)); - - set->items_allocated = BSON_MAX (nitems, 1); - set->items = (mongoc_set_item_t *) bson_malloc (sizeof (*set->items) * - set->items_allocated); - set->items_len = 0; - - set->dtor = dtor; - set->dtor_ctx = dtor_ctx; - - return set; -} - -static int -mongoc_set_id_cmp (const void *a_, const void *b_) -{ - mongoc_set_item_t *a = (mongoc_set_item_t *) a_; - mongoc_set_item_t *b = (mongoc_set_item_t *) b_; - - if (a->id == b->id) { - return 0; - } - - return a->id < b->id ? -1 : 1; -} - -void -mongoc_set_add (mongoc_set_t *set, uint32_t id, void *item) -{ - if (set->items_len >= set->items_allocated) { - set->items_allocated *= 2; - set->items = (mongoc_set_item_t *) bson_realloc ( - set->items, sizeof (*set->items) * set->items_allocated); - } - - set->items[set->items_len].id = id; - set->items[set->items_len].item = item; - - set->items_len++; - - if (set->items_len > 1 && set->items[set->items_len - 2].id > id) { - qsort ( - set->items, set->items_len, sizeof (*set->items), mongoc_set_id_cmp); - } -} - -void -mongoc_set_rm (mongoc_set_t *set, uint32_t id) -{ - const mongoc_set_item_t key = {.id = id}; - - mongoc_set_item_t *const ptr = (mongoc_set_item_t *) bsearch ( - &key, set->items, set->items_len, sizeof (key), mongoc_set_id_cmp); - - if (ptr) { - if (set->dtor) { - set->dtor (ptr->item, set->dtor_ctx); - } - - const size_t index = (size_t) (ptr - set->items); - - if (index != set->items_len - 1u) { - memmove (set->items + index, - set->items + index + 1u, - (set->items_len - (index + 1u)) * sizeof (key)); - } - - set->items_len--; - } -} - -void * -mongoc_set_get (mongoc_set_t *set, uint32_t id) -{ - mongoc_set_item_t *ptr; - mongoc_set_item_t key; - - key.id = id; - - ptr = (mongoc_set_item_t *) bsearch ( - &key, set->items, set->items_len, sizeof (key), mongoc_set_id_cmp); - - return ptr ? ptr->item : NULL; -} - -void * -mongoc_set_get_item (mongoc_set_t *set, size_t idx) -{ - BSON_ASSERT (set); - BSON_ASSERT (idx < set->items_len); - - return set->items[idx].item; -} - - -void * -mongoc_set_get_item_and_id (mongoc_set_t *set, - size_t idx, - uint32_t *id /* OUT */) -{ - BSON_ASSERT (set); - BSON_ASSERT (id); - BSON_ASSERT (idx < set->items_len); - - *id = set->items[idx].id; - - return set->items[idx].item; -} - - -void -mongoc_set_destroy (mongoc_set_t *set) -{ - if (set->dtor) { - for (size_t i = 0u; i < set->items_len; i++) { - set->dtor (set->items[i].item, set->dtor_ctx); - } - } - - bson_free (set->items); - bson_free (set); -} - - -typedef struct { - mongoc_set_for_each_cb_t cb; - void *ctx; -} _mongoc_set_for_each_helper_t; - - -static bool -_mongoc_set_for_each_helper (uint32_t id, void *item, void *ctx) -{ - _mongoc_set_for_each_helper_t *helper = - (_mongoc_set_for_each_helper_t *) ctx; - - BSON_UNUSED (id); - - return helper->cb (item, helper->ctx); -} - - -void -mongoc_set_for_each (mongoc_set_t *set, mongoc_set_for_each_cb_t cb, void *ctx) -{ - _mongoc_set_for_each_helper_t helper; - helper.cb = cb; - helper.ctx = ctx; - - mongoc_set_for_each_with_id (set, _mongoc_set_for_each_helper, &helper); -} - -void -mongoc_set_for_each_with_id (mongoc_set_t *set, - mongoc_set_for_each_with_id_cb_t cb, - void *ctx) -{ - mongoc_set_item_t *old_set; - - BSON_ASSERT (bson_in_range_unsigned (uint32_t, set->items_len)); - const uint32_t items_len = (uint32_t) set->items_len; - - /* prevent undefined behavior of memcpy(NULL) */ - if (items_len == 0) { - return; - } - - old_set = (mongoc_set_item_t *) bson_malloc (sizeof (*old_set) * items_len); - memcpy (old_set, set->items, sizeof (*old_set) * items_len); - - for (uint32_t i = 0u; i < items_len; i++) { - if (!cb (i, old_set[i].item, ctx)) { - break; - } - } - - bson_free (old_set); -} - - -static mongoc_set_item_t * -_mongoc_set_find (const mongoc_set_t *set, - mongoc_set_for_each_const_cb_t cb, - void *ctx) -{ - size_t i; - size_t items_len; - mongoc_set_item_t *item; - - items_len = set->items_len; - - for (i = 0; i < items_len; i++) { - item = &set->items[i]; - if (cb (item->item, ctx)) { - return item; - } - } - - return NULL; -} - - -void * -mongoc_set_find_item (mongoc_set_t *set, mongoc_set_for_each_cb_t cb, void *ctx) -{ - mongoc_set_item_t *item; - - if ((item = - _mongoc_set_find (set, (mongoc_set_for_each_const_cb_t) cb, ctx))) { - return item->item; - } - - return NULL; -} - - -uint32_t -mongoc_set_find_id (const mongoc_set_t *set, - mongoc_set_for_each_const_cb_t cb, - void *ctx) -{ - const mongoc_set_item_t *item; - - if ((item = _mongoc_set_find (set, cb, ctx))) { - return item->id; - } - - return 0; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-sleep.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-sleep.h deleted file mode 100644 index db64535df..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-sleep.h +++ /dev/null @@ -1,40 +0,0 @@ -#include "mongoc-prelude.h" - -#ifndef MONGOC_SLEEP_H -#define MONGOC_SLEEP_H - -#include - -#include "mongoc-macros.h" - -BSON_BEGIN_DECLS - -/** - * mongoc_usleep_func_t: - * @usec: Number of microseconds to sleep for. - * @user_data: User data provided to mongoc_client_set_usleep_impl(). - */ -typedef void (*mongoc_usleep_func_t) (int64_t usec, void *user_data); - -/** - * mongoc_client_set_usleep_impl: - * @usleep_func: A function to perform microsecond sleep. - * - * Sets the function to be called to perform sleep during scanning. - * Returns the old function. - * If old_user_data is not NULL, *old_user_data is set to the old user_data. - * Not thread-safe. - * Providing a `usleep_func` that does not sleep (e.g. coroutine suspension) is - * not supported. Doing so is at the user's own risk. - */ -MONGOC_EXPORT (void) -mongoc_client_set_usleep_impl (mongoc_client_t *client, - mongoc_usleep_func_t usleep_func, - void *user_data); - -MONGOC_EXPORT (void) -mongoc_usleep_default_impl (int64_t usec, void *user_data); - -BSON_END_DECLS - -#endif /* MONGOC_SLEEP_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-socket.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-socket.h deleted file mode 100644 index 44be98954..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-socket.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_SOCKET_H -#define MONGOC_SOCKET_H - -#include -#include "mongoc-macros.h" -#include "mongoc-config.h" - -#ifdef _WIN32 -#include -#include -#else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#if defined(_AIX) && !defined(MONGOC_HAVE_SS_FAMILY) -#define ss_family __ss_family -#endif - -#include "mongoc-iovec.h" - - -BSON_BEGIN_DECLS - - -typedef MONGOC_SOCKET_ARG3 mongoc_socklen_t; - -typedef struct _mongoc_socket_t mongoc_socket_t; - -typedef struct { - mongoc_socket_t *socket; - int events; - int revents; -} mongoc_socket_poll_t; - -MONGOC_EXPORT (mongoc_socket_t *) -mongoc_socket_accept (mongoc_socket_t *sock, - int64_t expire_at) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (int) -mongoc_socket_bind (mongoc_socket_t *sock, - const struct sockaddr *addr, - mongoc_socklen_t addrlen); -MONGOC_EXPORT (int) -mongoc_socket_close (mongoc_socket_t *socket); -MONGOC_EXPORT (int) -mongoc_socket_connect (mongoc_socket_t *sock, - const struct sockaddr *addr, - mongoc_socklen_t addrlen, - int64_t expire_at); -MONGOC_EXPORT (char *) -mongoc_socket_getnameinfo (mongoc_socket_t *sock) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_socket_destroy (mongoc_socket_t *sock); -MONGOC_EXPORT (int) -mongoc_socket_errno (mongoc_socket_t *sock); -MONGOC_EXPORT (int) -mongoc_socket_getsockname (mongoc_socket_t *sock, - struct sockaddr *addr, - mongoc_socklen_t *addrlen); -MONGOC_EXPORT (int) -mongoc_socket_listen (mongoc_socket_t *sock, unsigned int backlog); -MONGOC_EXPORT (mongoc_socket_t *) -mongoc_socket_new (int domain, - int type, - int protocol) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (ssize_t) -mongoc_socket_recv (mongoc_socket_t *sock, - void *buf, - size_t buflen, - int flags, - int64_t expire_at); -MONGOC_EXPORT (int) -mongoc_socket_setsockopt (mongoc_socket_t *sock, - int level, - int optname, - const void *optval, - mongoc_socklen_t optlen); -MONGOC_EXPORT (ssize_t) -mongoc_socket_send (mongoc_socket_t *sock, - const void *buf, - size_t buflen, - int64_t expire_at); -MONGOC_EXPORT (ssize_t) -mongoc_socket_sendv (mongoc_socket_t *sock, - mongoc_iovec_t *iov, - size_t iovcnt, - int64_t expire_at); -MONGOC_EXPORT (bool) -mongoc_socket_check_closed (mongoc_socket_t *sock); -MONGOC_EXPORT (void) -mongoc_socket_inet_ntop (struct addrinfo *rp, char *buf, size_t buflen); -MONGOC_EXPORT (ssize_t) -mongoc_socket_poll (mongoc_socket_poll_t *sds, size_t nsds, int32_t timeout); - - -BSON_END_DECLS - - -#endif /* MONGOC_SOCKET_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-ssl-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-ssl-private.h deleted file mode 100644 index e64f68b78..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-ssl-private.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_SSL_PRIVATE_H -#define MONGOC_SSL_PRIVATE_H - -#include -#include "mongoc-uri-private.h" - - -BSON_BEGIN_DECLS - -typedef struct { - bool tls_disable_certificate_revocation_check; - bool tls_disable_ocsp_endpoint_check; -} _mongoc_internal_tls_opts_t; - -char * -mongoc_ssl_extract_subject (const char *filename, const char *passphrase); - -void -_mongoc_ssl_opts_from_uri (mongoc_ssl_opt_t *ssl_opt, - _mongoc_internal_tls_opts_t *internal, - mongoc_uri_t *uri); -void -_mongoc_ssl_opts_copy_to (const mongoc_ssl_opt_t *src, - mongoc_ssl_opt_t *dst, - bool copy_internal); - -bool -_mongoc_ssl_opts_disable_certificate_revocation_check ( - const mongoc_ssl_opt_t *ssl_opt); - -bool -_mongoc_ssl_opts_disable_ocsp_endpoint_check (const mongoc_ssl_opt_t *ssl_opt); - -void -_mongoc_ssl_opts_cleanup (mongoc_ssl_opt_t *opt, bool free_internal); - -/* _mongoc_ssl_opts_from_bson is an internal helper for constructing an ssl_opt - * from a BSON document. It is used to parse TLS options for the KMIP KMS - * provider in CSFLE. - * - ssl_opt must be a zero'd out ssl_opt struct. - * - errmsg must be an initialized bson_string_t. - * - Returns false on error and appends to errmsg. */ -bool -_mongoc_ssl_opts_from_bson (mongoc_ssl_opt_t *ssl_opt, - const bson_t *bson, - bson_string_t *errmsg); - -BSON_END_DECLS - - -#endif /* MONGOC_SSL_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-ssl.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-ssl.c deleted file mode 100644 index 174e43d13..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-ssl.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SSL - -#include -#include "mongoc-ssl.h" -#include "mongoc-ssl-private.h" -#include "mongoc-log.h" -#include "mongoc-uri.h" -#include "mongoc-util-private.h" - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) -#include "mongoc-openssl-private.h" -#elif defined(MONGOC_ENABLE_SSL_LIBRESSL) -#include "mongoc-libressl-private.h" -#elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) -#include "mongoc-secure-transport-private.h" -#elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) -#include "mongoc-secure-channel-private.h" -#endif - -/* TODO: we could populate these from a config or something further down the - * road for providing defaults */ -#ifndef MONGOC_SSL_DEFAULT_TRUST_FILE -#define MONGOC_SSL_DEFAULT_TRUST_FILE NULL -#endif -#ifndef MONGOC_SSL_DEFAULT_TRUST_DIR -#define MONGOC_SSL_DEFAULT_TRUST_DIR NULL -#endif - -static mongoc_ssl_opt_t gMongocSslOptDefault = { - NULL, NULL, MONGOC_SSL_DEFAULT_TRUST_FILE, MONGOC_SSL_DEFAULT_TRUST_DIR, -}; - -const mongoc_ssl_opt_t * -mongoc_ssl_opt_get_default (void) -{ - return &gMongocSslOptDefault; -} - -char * -mongoc_ssl_extract_subject (const char *filename, const char *passphrase) -{ - char *retval; - - if (!filename) { - MONGOC_ERROR ("No filename provided to extract subject from"); - return NULL; - } - -#ifdef _WIN32 - if (_access (filename, 0) != 0) { -#else - if (access (filename, R_OK) != 0) { -#endif - MONGOC_ERROR ("Can't extract subject from unreadable file: '%s'", - filename); - return NULL; - } - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) - retval = _mongoc_openssl_extract_subject (filename, passphrase); -#elif defined(MONGOC_ENABLE_SSL_LIBRESSL) - MONGOC_WARNING ( - "libtls doesn't support automatically extracting subject from " - "certificate to use with authentication"); - retval = NULL; -#elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) -retval = _mongoc_secure_transport_extract_subject (filename, passphrase); -#elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) -retval = _mongoc_secure_channel_extract_subject (filename, passphrase); -#endif - - if (!retval) { - MONGOC_ERROR ("Can't extract subject from file '%s'", filename); - } - - return retval; -} - -void -_mongoc_ssl_opts_from_uri (mongoc_ssl_opt_t *ssl_opt, - _mongoc_internal_tls_opts_t *internal, - mongoc_uri_t *uri) -{ - bool insecure = - mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSINSECURE, false); - - ssl_opt->pem_file = mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, NULL); - ssl_opt->pem_pwd = mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, NULL); - ssl_opt->ca_file = - mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, NULL); - ssl_opt->weak_cert_validation = mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, insecure); - ssl_opt->allow_invalid_hostname = mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, insecure); - ssl_opt->internal = internal; - internal->tls_disable_certificate_revocation_check = - mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK, false); - internal->tls_disable_ocsp_endpoint_check = mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK, false); -} - -void -_mongoc_ssl_opts_copy_to (const mongoc_ssl_opt_t *src, - mongoc_ssl_opt_t *dst, - bool copy_internal) -{ - BSON_ASSERT (src); - BSON_ASSERT (dst); - - dst->pem_file = bson_strdup (src->pem_file); - dst->pem_pwd = bson_strdup (src->pem_pwd); - dst->ca_file = bson_strdup (src->ca_file); - dst->ca_dir = bson_strdup (src->ca_dir); - dst->crl_file = bson_strdup (src->crl_file); - dst->weak_cert_validation = src->weak_cert_validation; - dst->allow_invalid_hostname = src->allow_invalid_hostname; - if (copy_internal) { - dst->internal = NULL; - if (src->internal) { - dst->internal = bson_malloc (sizeof (_mongoc_internal_tls_opts_t)); - memcpy ( - dst->internal, src->internal, sizeof (_mongoc_internal_tls_opts_t)); - } - } -} - -void -_mongoc_ssl_opts_cleanup (mongoc_ssl_opt_t *opt, bool free_internal) -{ - bson_free ((char *) opt->pem_file); - bson_free ((char *) opt->pem_pwd); - bson_free ((char *) opt->ca_file); - bson_free ((char *) opt->ca_dir); - bson_free ((char *) opt->crl_file); - if (free_internal) { - bson_free (opt->internal); - } -} - -bool -_mongoc_ssl_opts_disable_certificate_revocation_check ( - const mongoc_ssl_opt_t *ssl_opt) -{ - if (!ssl_opt->internal) { - return false; - } - return ((_mongoc_internal_tls_opts_t *) ssl_opt->internal) - ->tls_disable_certificate_revocation_check; -} - -bool -_mongoc_ssl_opts_disable_ocsp_endpoint_check (const mongoc_ssl_opt_t *ssl_opt) -{ - if (!ssl_opt->internal) { - return false; - } - return ((_mongoc_internal_tls_opts_t *) ssl_opt->internal) - ->tls_disable_ocsp_endpoint_check; -} - -bool -_mongoc_ssl_opts_from_bson (mongoc_ssl_opt_t *ssl_opt, - const bson_t *bson, - bson_string_t *errmsg) -{ - bson_iter_t iter; - - if (ssl_opt->internal) { - bson_string_append (errmsg, - "SSL options must not have internal state set"); - return false; - } - - ssl_opt->internal = bson_malloc0 (sizeof (_mongoc_internal_tls_opts_t)); - - if (!bson_iter_init (&iter, bson)) { - bson_string_append (errmsg, - "error initializing iterator to BSON SSL options"); - return false; - } - - while (bson_iter_next (&iter)) { - const char *key = bson_iter_key (&iter); - - if (BSON_ITER_HOLDS_UTF8 (&iter)) { - if (0 == bson_strcasecmp (key, MONGOC_URI_TLSCERTIFICATEKEYFILE)) { - ssl_opt->pem_file = bson_strdup (bson_iter_utf8 (&iter, NULL)); - continue; - } else if (0 == bson_strcasecmp ( - key, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD)) { - ssl_opt->pem_pwd = bson_strdup (bson_iter_utf8 (&iter, NULL)); - continue; - } else if (0 == bson_strcasecmp (key, MONGOC_URI_TLSCAFILE)) { - ssl_opt->ca_file = bson_strdup (bson_iter_utf8 (&iter, NULL)); - continue; - } - } - - if (BSON_ITER_HOLDS_BOOL (&iter)) { - if (0 == - bson_strcasecmp (key, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES)) { - /* If MONGOC_URI_TLSINSECURE was parsed, weak_cert_validation must - * remain true. */ - ssl_opt->weak_cert_validation = - ssl_opt->weak_cert_validation || bson_iter_bool (&iter); - continue; - } else if (0 == bson_strcasecmp ( - key, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES)) { - /* If MONGOC_URI_TLSINSECURE was parsed, allow_invalid_hostname must - * remain true. */ - ssl_opt->allow_invalid_hostname = - ssl_opt->allow_invalid_hostname || bson_iter_bool (&iter); - continue; - } else if (0 == bson_strcasecmp (key, MONGOC_URI_TLSINSECURE)) { - if (bson_iter_bool (&iter)) { - ssl_opt->weak_cert_validation = true; - ssl_opt->allow_invalid_hostname = true; - } - continue; - } else if (0 == - bson_strcasecmp ( - key, MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK)) { - ((_mongoc_internal_tls_opts_t *) ssl_opt->internal) - ->tls_disable_certificate_revocation_check = - bson_iter_bool (&iter); - continue; - } else if (0 == bson_strcasecmp ( - key, MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK)) { - ((_mongoc_internal_tls_opts_t *) ssl_opt->internal) - ->tls_disable_ocsp_endpoint_check = bson_iter_bool (&iter); - continue; - } - } - - bson_string_append_printf ( - errmsg, - "unexpected %s option: %s", - _mongoc_bson_type_to_str (bson_iter_type (&iter)), - key); - return false; - } - - return true; -} - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-gridfs-download.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-gridfs-download.c deleted file mode 100644 index 458bac1af..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-gridfs-download.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 2018-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-stream-gridfs-download-private.h" -#include "mongoc-gridfs-bucket-file-private.h" -#include "mongoc-counters-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-stream-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "stream-gridfs-download" - -static void -_mongoc_download_stream_gridfs_destroy (mongoc_stream_t *stream) -{ - mongoc_gridfs_download_stream_t *gridfs = - (mongoc_gridfs_download_stream_t *) stream; - - ENTRY; - - BSON_ASSERT (stream); - - mongoc_stream_close (stream); - _mongoc_gridfs_bucket_file_destroy (gridfs->file); - - bson_free (stream); - - mongoc_counter_streams_active_dec (); - mongoc_counter_streams_disposed_inc (); - - EXIT; -} - -static void -_mongoc_download_stream_gridfs_failed (mongoc_stream_t *stream) -{ - ENTRY; - - _mongoc_download_stream_gridfs_destroy (stream); - - EXIT; -} - -static int -_mongoc_download_stream_gridfs_close (mongoc_stream_t *stream) -{ - mongoc_gridfs_download_stream_t *gridfs = - (mongoc_gridfs_download_stream_t *) stream; - int ret = 0; - - ENTRY; - - BSON_ASSERT (stream); - - gridfs->file->finished = true; - - RETURN (ret); -} - -static ssize_t -_mongoc_download_stream_gridfs_readv (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - size_t min_bytes, - int32_t timeout_msec) -{ - mongoc_gridfs_download_stream_t *gridfs = - (mongoc_gridfs_download_stream_t *) stream; - ssize_t ret = 0; - - ENTRY; - - BSON_ASSERT (stream); - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - - (void) min_bytes; /* unused. */ - (void) timeout_msec; /* unused. */ - - /* timeout_msec is unused by mongoc_gridfs_bucket_file_readv */ - ret = _mongoc_gridfs_bucket_file_readv (gridfs->file, iov, iovcnt); - - mongoc_counter_streams_ingress_add (ret); - - RETURN (ret); -} - - -static bool -_mongoc_download_stream_gridfs_check_closed (mongoc_stream_t *stream) /* IN */ -{ - mongoc_gridfs_download_stream_t *gridfs = - (mongoc_gridfs_download_stream_t *) stream; - - ENTRY; - - BSON_ASSERT (stream); - - RETURN (gridfs->file->finished); -} - - -mongoc_stream_t * -_mongoc_download_stream_gridfs_new (mongoc_gridfs_bucket_file_t *file) -{ - mongoc_gridfs_download_stream_t *stream; - - ENTRY; - - BSON_ASSERT (file); - - stream = (mongoc_gridfs_download_stream_t *) bson_malloc0 (sizeof *stream); - stream->file = file; - stream->stream.type = MONGOC_STREAM_GRIDFS_DOWNLOAD; - stream->stream.destroy = _mongoc_download_stream_gridfs_destroy; - stream->stream.failed = _mongoc_download_stream_gridfs_failed; - stream->stream.close = _mongoc_download_stream_gridfs_close; - stream->stream.readv = _mongoc_download_stream_gridfs_readv; - stream->stream.check_closed = _mongoc_download_stream_gridfs_check_closed; - - mongoc_counter_streams_active_inc (); - - RETURN ((mongoc_stream_t *) stream); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-gridfs.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-gridfs.h deleted file mode 100644 index 9513f93d5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-gridfs.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2013 MongoDB Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_STREAM_GRIDFS_H -#define MONGOC_STREAM_GRIDFS_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-gridfs.h" -#include "mongoc-stream.h" - - -BSON_BEGIN_DECLS - - -MONGOC_EXPORT (mongoc_stream_t *) -mongoc_stream_gridfs_new (mongoc_gridfs_file_t *file) - BSON_GNUC_WARN_UNUSED_RESULT; - - -BSON_END_DECLS - - -#endif /* MONGOC_STREAM_GRIDFS_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl-private.h deleted file mode 100644 index c4d0b6e1b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl-private.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_STREAM_TLS_LIBRESSL_PRIVATE_H -#define MONGOC_STREAM_TLS_LIBRESSL_PRIVATE_H - -#ifdef MONGOC_ENABLE_SSL_LIBRESSL -#include - -#include - -BSON_BEGIN_DECLS - - -/** - * mongoc_stream_tls_libressl_t: - * - * Private storage for LibreSSL Streams - */ -typedef struct { - struct tls *ctx; - struct tls_config *config; -} mongoc_stream_tls_libressl_t; - - -BSON_END_DECLS - -#endif /* MONGOC_ENABLE_SSL_LIBRESSL */ -#endif /* MONGOC_STREAM_TLS_LIBRESSL_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c deleted file mode 100644 index 82289b632..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c +++ /dev/null @@ -1,554 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SSL_LIBRESSL - -#include - -#include "mongoc-trace-private.h" -#include "mongoc-log.h" -#include "mongoc-stream-tls.h" -#include "mongoc-stream-tls-private.h" -#include "mongoc-stream-private.h" -#include "mongoc-stream-tls-libressl-private.h" -#include "mongoc-libressl-private.h" -#include "mongoc-ssl.h" -#include "mongoc-ssl-private.h" -#include "mongoc-error.h" -#include "mongoc-counters-private.h" -#include "mongoc-stream-socket.h" -#include "mongoc-socket-private.h" - -#include - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "stream-tls-libressl" - -static void -_mongoc_stream_tls_libressl_destroy (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_libressl_t *libressl = - (mongoc_stream_tls_libressl_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (libressl); - - tls_close (libressl->ctx); - tls_free (libressl->ctx); - tls_config_free (libressl->config); - - mongoc_stream_destroy (tls->base_stream); - - bson_free (libressl); - bson_free (stream); - - mongoc_counter_streams_active_dec (); - mongoc_counter_streams_disposed_inc (); - EXIT; -} - -static void -_mongoc_stream_tls_libressl_failed (mongoc_stream_t *stream) -{ - ENTRY; - _mongoc_stream_tls_libressl_destroy (stream); - EXIT; -} - -static int -_mongoc_stream_tls_libressl_close (mongoc_stream_t *stream) -{ - int ret = 0; - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_libressl_t *libressl = - (mongoc_stream_tls_libressl_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (libressl); - - ret = mongoc_stream_close (tls->base_stream); - RETURN (ret); -} - -static int -_mongoc_stream_tls_libressl_flush (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_libressl_t *libressl = - (mongoc_stream_tls_libressl_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (libressl); - RETURN (0); -} - -static ssize_t -_mongoc_stream_tls_libressl_write (mongoc_stream_t *stream, - char *buf, - size_t buf_len) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_libressl_t *libressl = - (mongoc_stream_tls_libressl_t *) tls->ctx; - mongoc_stream_poll_t poller; - ssize_t total_write = 0; - ssize_t ret; - int64_t now; - int64_t expire = 0; - - ENTRY; - BSON_ASSERT (libressl); - - if (tls->timeout_msec >= 0) { - expire = bson_get_monotonic_time () + (tls->timeout_msec * 1000UL); - } - - do { - poller.stream = stream; - poller.revents = 0; - poller.events = POLLOUT; - ret = tls_write (libressl->ctx, buf, buf_len); - - if (ret == TLS_WANT_POLLIN) { - poller.events = POLLIN; - mongoc_stream_poll (&poller, 1, tls->timeout_msec); - } else if (ret == TLS_WANT_POLLOUT) { - poller.events = POLLOUT; - mongoc_stream_poll (&poller, 1, tls->timeout_msec); - } else if (ret < 0) { - RETURN (total_write); - } else { - buf += ret; - buf_len -= ret; - total_write += ret; - } - if (expire) { - now = bson_get_monotonic_time (); - - if ((expire - now) < 0) { - if (ret == 0) { - mongoc_counter_streams_timeout_inc (); - break; - } - - tls->timeout_msec = 0; - } else { - tls->timeout_msec = (expire - now) / 1000L; - } - } - } while (buf_len > 0); - - - RETURN (total_write); -} - -/* This is copypasta from _mongoc_stream_tls_openssl_writev */ -#define MONGOC_STREAM_TLS_BUFFER_SIZE 4096 -static ssize_t -_mongoc_stream_tls_libressl_writev (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - int32_t timeout_msec) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_libressl_t *libressl = - (mongoc_stream_tls_libressl_t *) tls->ctx; - char buf[MONGOC_STREAM_TLS_BUFFER_SIZE]; - ssize_t ret = 0; - ssize_t child_ret; - size_t i; - size_t iov_pos = 0; - - /* There's a bit of a dance to coalesce vectorized writes into - * MONGOC_STREAM_TLS_BUFFER_SIZE'd writes to avoid lots of small tls - * packets. - * - * The basic idea is that we want to combine writes in the buffer if they're - * smaller than the buffer, flushing as it gets full. For larger writes, or - * the last write in the iovec array, we want to ignore the buffer and just - * write immediately. We take care of doing buffer writes by re-invoking - * ourself with a single iovec_t, pointing at our stack buffer. - */ - char *buf_head = buf; - char *buf_tail = buf; - char *buf_end = buf + MONGOC_STREAM_TLS_BUFFER_SIZE; - size_t bytes; - - char *to_write = NULL; - size_t to_write_len; - - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - BSON_ASSERT (libressl); - ENTRY; - - tls->timeout_msec = timeout_msec; - - for (i = 0; i < iovcnt; i++) { - iov_pos = 0; - - while (iov_pos < iov[i].iov_len) { - if (buf_head != buf_tail || - ((i + 1 < iovcnt) && - ((buf_end - buf_tail) > (iov[i].iov_len - iov_pos)))) { - /* If we have either of: - * - buffered bytes already - * - another iovec to send after this one and we don't have more - * bytes to send than the size of the buffer. - * - * copy into the buffer */ - - bytes = BSON_MIN (iov[i].iov_len - iov_pos, buf_end - buf_tail); - - memcpy (buf_tail, (char *) iov[i].iov_base + iov_pos, bytes); - buf_tail += bytes; - iov_pos += bytes; - - if (buf_tail == buf_end) { - /* If we're full, request send */ - - to_write = buf_head; - to_write_len = buf_tail - buf_head; - - buf_tail = buf_head = buf; - } - } else { - /* Didn't buffer, so just write it through */ - - to_write = (char *) iov[i].iov_base + iov_pos; - to_write_len = iov[i].iov_len - iov_pos; - - iov_pos += to_write_len; - } - - if (to_write) { - /* We get here if we buffered some bytes and filled the buffer, or - * if we didn't buffer and have to send out of the iovec */ - - child_ret = _mongoc_stream_tls_libressl_write ( - stream, to_write, to_write_len); - - if (child_ret < 0) { - RETURN (ret); - } - - ret += child_ret; - - if (child_ret < to_write_len) { - /* we timed out, so send back what we could send */ - - RETURN (ret); - } - - to_write = NULL; - } - } - } - - if (buf_head != buf_tail) { - /* If we have any bytes buffered, send */ - - child_ret = _mongoc_stream_tls_libressl_write ( - stream, buf_head, buf_tail - buf_head); - - if (child_ret < 0) { - RETURN (child_ret); - } - - ret += child_ret; - } - - if (ret >= 0) { - mongoc_counter_streams_egress_add (ret); - } - - TRACE ("Returning %d", (int) ret); - RETURN (ret); -} - -/* This function is copypasta of _mongoc_stream_tls_openssl_readv */ -static ssize_t -_mongoc_stream_tls_libressl_readv (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - size_t min_bytes, - int32_t timeout_msec) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_libressl_t *libressl = - (mongoc_stream_tls_libressl_t *) tls->ctx; - ssize_t ret = 0; - ssize_t read_ret; - size_t i; - size_t iov_pos = 0; - int64_t now; - int64_t expire = 0; - mongoc_stream_poll_t poller; - - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - BSON_ASSERT (libressl); - ENTRY; - - tls->timeout_msec = timeout_msec; - - if (timeout_msec >= 0) { - expire = bson_get_monotonic_time () + (timeout_msec * 1000UL); - } - - for (i = 0; i < iovcnt; i++) { - iov_pos = 0; - - while (iov_pos < iov[i].iov_len) { - poller.stream = stream; - poller.revents = 0; - poller.events = POLLIN; - read_ret = tls_read (libressl->ctx, - (char *) iov[i].iov_base + iov_pos, - (int) (iov[i].iov_len - iov_pos)); - - if (read_ret == TLS_WANT_POLLIN) { - poller.events = POLLIN; - mongoc_stream_poll (&poller, 1, tls->timeout_msec); - } else if (read_ret == TLS_WANT_POLLOUT) { - poller.events = POLLOUT; - mongoc_stream_poll (&poller, 1, tls->timeout_msec); - } else if (read_ret < 0) { - RETURN (ret); - } else { - iov_pos += read_ret; - ret += read_ret; - } - if (expire) { - now = bson_get_monotonic_time (); - - if ((expire - now) < 0) { - if (read_ret == 0) { - mongoc_counter_streams_timeout_inc (); - errno = ETIMEDOUT; - RETURN (-1); - } - - tls->timeout_msec = 0; - } else { - tls->timeout_msec = (expire - now) / 1000L; - } - } - - - if (ret > 0 && (size_t) ret >= min_bytes) { - mongoc_counter_streams_ingress_add (ret); - RETURN (ret); - } - } - } - - if (ret >= 0) { - mongoc_counter_streams_ingress_add (ret); - } - - RETURN (ret); -} - -static int -_mongoc_stream_tls_libressl_setsockopt (mongoc_stream_t *stream, - int level, - int optname, - void *optval, - mongoc_socklen_t optlen) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_libressl_t *libressl = - (mongoc_stream_tls_libressl_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (libressl); - RETURN (mongoc_stream_setsockopt ( - tls->base_stream, level, optname, optval, optlen)); -} - -static mongoc_stream_t * -_mongoc_stream_tls_libressl_get_base_stream (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_libressl_t *libressl = - (mongoc_stream_tls_libressl_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (libressl); - RETURN (tls->base_stream); -} - - -static bool -_mongoc_stream_tls_libressl_check_closed (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_libressl_t *libressl = - (mongoc_stream_tls_libressl_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (libressl); - RETURN (mongoc_stream_check_closed (tls->base_stream)); -} - -bool -mongoc_stream_tls_libressl_handshake (mongoc_stream_t *stream, - const char *host, - int *events, - bson_error_t *error) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_libressl_t *libressl = - (mongoc_stream_tls_libressl_t *) tls->ctx; - int ret; - - ENTRY; - BSON_ASSERT (libressl); - - ret = tls_handshake (libressl->ctx); - - if (ret == TLS_WANT_POLLIN) { - *events = POLLIN; - } else if (ret == TLS_WANT_POLLOUT) { - *events = POLLOUT; - } else if (ret < 0) { - *events = 0; - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "TLS handshake failed: %s", - tls_error (libressl->ctx)); - RETURN (false); - } else { - RETURN (true); - } - RETURN (false); -} - -static bool -_mongoc_stream_tls_libressl_timed_out (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - - ENTRY; - - RETURN (mongoc_stream_timed_out (tls->base_stream)); -} - -static bool -_mongoc_stream_tls_libressl_should_retry (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - - ENTRY; - - RETURN (mongoc_stream_should_retry (tls->base_stream)); -} - -mongoc_stream_t * -mongoc_stream_tls_libressl_new (mongoc_stream_t *base_stream, - const char *host, - mongoc_ssl_opt_t *opt, - int client) -{ - mongoc_stream_tls_t *tls; - mongoc_stream_tls_libressl_t *libressl; - - ENTRY; - BSON_ASSERT (base_stream); - BSON_ASSERT (opt); - - - if (opt->crl_file) { - MONGOC_ERROR ( - "Setting mongoc_ssl_opt_t.crl_file has no effect when built " - "against libtls"); - RETURN (false); - } - libressl = (mongoc_stream_tls_libressl_t *) bson_malloc0 (sizeof *libressl); - - tls = (mongoc_stream_tls_t *) bson_malloc0 (sizeof *tls); - tls->parent.type = MONGOC_STREAM_TLS; - tls->parent.destroy = _mongoc_stream_tls_libressl_destroy; - tls->parent.failed = _mongoc_stream_tls_libressl_failed; - tls->parent.close = _mongoc_stream_tls_libressl_close; - tls->parent.flush = _mongoc_stream_tls_libressl_flush; - tls->parent.writev = _mongoc_stream_tls_libressl_writev; - tls->parent.readv = _mongoc_stream_tls_libressl_readv; - tls->parent.setsockopt = _mongoc_stream_tls_libressl_setsockopt; - tls->parent.get_base_stream = _mongoc_stream_tls_libressl_get_base_stream; - tls->parent.check_closed = _mongoc_stream_tls_libressl_check_closed; - tls->parent.timed_out = _mongoc_stream_tls_libressl_timed_out; - tls->parent.should_retry = _mongoc_stream_tls_libressl_should_retry; - memcpy (&tls->ssl_opts, opt, sizeof tls->ssl_opts); - tls->handshake = mongoc_stream_tls_libressl_handshake; - tls->ctx = (void *) libressl; - tls->timeout_msec = -1; - tls->base_stream = base_stream; - - libressl->ctx = client ? tls_client () : tls_server (); - libressl->config = tls_config_new (); - - if (opt->weak_cert_validation) { - tls_config_insecure_noverifycert (libressl->config); - tls_config_insecure_noverifytime (libressl->config); - } - if (opt->allow_invalid_hostname) { - tls_config_insecure_noverifyname (libressl->config); - } - tls_config_set_ciphers (libressl->config, "compat"); - - mongoc_libressl_setup_certificate (libressl, opt); - mongoc_libressl_setup_ca (libressl, opt); - { - mongoc_stream_t *stream = base_stream; - - do { - if (stream->type == MONGOC_STREAM_SOCKET) { - int socket = mongoc_stream_socket_get_socket ( - (mongoc_stream_socket_t *) stream) - ->sd; - if (tls_configure (libressl->ctx, libressl->config) == -1) { - MONGOC_ERROR ("%s", tls_config_error (libressl->config)); - RETURN (false); - } - if (tls_connect_socket (libressl->ctx, socket, host) == -1) { - MONGOC_ERROR ("%s", tls_error (libressl->ctx)); - RETURN (false); - } - break; - } - } while ((stream = mongoc_stream_get_base_stream (stream))); - } - - mongoc_counter_streams_active_inc (); - - if (_mongoc_ssl_opts_disable_certificate_revocation_check (opt)) { - MONGOC_ERROR ("Setting tlsDisableCertificateRevocationCheck has no " - "effect when built against libtls"); - } - - if (_mongoc_ssl_opts_disable_ocsp_endpoint_check (opt)) { - MONGOC_ERROR ("Setting tlsDisableOCSPEndpointCheck has no effect when " - "built against libtls"); - } - RETURN ((mongoc_stream_t *) tls); -} -#endif /* MONGOC_ENABLE_SSL_LIBRESSL */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.h deleted file mode 100644 index ca70a95eb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_STREAM_TLS_LIBRESSL_H -#define MONGOC_STREAM_TLS_LIBRESSL_H - -#ifdef MONGOC_ENABLE_SSL_LIBRESSL - -#include - -#include "mongoc-macros.h" - -BSON_BEGIN_DECLS - -MONGOC_EXPORT (mongoc_stream_t *) -mongoc_stream_tls_libressl_new (mongoc_stream_t *base_stream, - const char *host, - mongoc_ssl_opt_t *opt, - int client) BSON_GNUC_WARN_UNUSED_RESULT; - -BSON_END_DECLS - -#endif /* MONGOC_ENABLE_SSL_LIBRESSL */ -#endif /* MONGOC_STREAM_TLS_LIBRESSL_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-private.h deleted file mode 100644 index 2d8443ae1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-private.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_STREAM_TLS_OPENSSL_PRIVATE_H -#define MONGOC_STREAM_TLS_OPENSSL_PRIVATE_H - -#ifdef MONGOC_ENABLE_SSL_OPENSSL -#include - -BSON_BEGIN_DECLS - -typedef struct { - char *host; - bool allow_invalid_hostname; - bool weak_cert_validation; - bool disable_endpoint_check; - /* If reaching out to an OCSP responder requires TLS, - * use the same TLS options that the user provided. */ - mongoc_ssl_opt_t ssl_opts; -} mongoc_openssl_ocsp_opt_t; - -void -mongoc_openssl_ocsp_opt_destroy (void *ocsp_opt); - -/** - * mongoc_stream_tls_openssl_t: - * - * Private storage for handling callbacks from mongoc_stream and BIO_* - */ -typedef struct { - BIO *bio; - BIO_METHOD *meth; - SSL_CTX *ctx; - mongoc_openssl_ocsp_opt_t *ocsp_opts; -} mongoc_stream_tls_openssl_t; - - -BSON_END_DECLS - -#endif /* MONGOC_ENABLE_SSL_OPENSSL */ -#endif /* MONGOC_STREAM_TLS_OPENSSL_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.c deleted file mode 100644 index 1c7209007..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.c +++ /dev/null @@ -1,919 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SSL_OPENSSL - -#include - -#include -#include -#include -#include -#include -#include - -#include "mongoc-counters-private.h" -#include "mongoc-errno-private.h" -#include "mongoc-ssl.h" -#include "mongoc-ssl-private.h" -#include "mongoc-stream-tls.h" -#include "mongoc-stream-private.h" -#include "mongoc-stream-tls-private.h" -#include "mongoc-stream-tls-openssl-bio-private.h" -#include "mongoc-stream-tls-openssl-private.h" -#include "mongoc-openssl-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-log.h" -#include "mongoc-error.h" - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "stream-tls-openssl" - -#define MONGOC_STREAM_TLS_OPENSSL_BUFFER_SIZE 4096 - -#if OPENSSL_VERSION_NUMBER < 0x10100000L || \ - (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) -static void -BIO_meth_free (BIO_METHOD *meth) -{ - /* Nothing to free pre OpenSSL 1.1.0 */ -} -#endif - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_stream_tls_openssl_destroy -- - * - * Cleanup after usage of a mongoc_stream_tls_openssl_t. Free all - *allocated - * resources and ensure connections are closed. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static void -_mongoc_stream_tls_openssl_destroy (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_openssl_t *openssl = - (mongoc_stream_tls_openssl_t *) tls->ctx; - - BSON_ASSERT (tls); - - BIO_free_all (openssl->bio); - openssl->bio = NULL; - - BIO_meth_free (openssl->meth); - openssl->meth = NULL; - - mongoc_stream_destroy (tls->base_stream); - tls->base_stream = NULL; - - SSL_CTX_free (openssl->ctx); - openssl->ctx = NULL; - - mongoc_openssl_ocsp_opt_destroy (openssl->ocsp_opts); - openssl->ocsp_opts = NULL; - - bson_free (openssl); - bson_free (stream); - - mongoc_counter_streams_active_dec (); - mongoc_counter_streams_disposed_inc (); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_stream_tls_openssl_failed -- - * - * Called on stream failure. Same as _mongoc_stream_tls_openssl_destroy() - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static void -_mongoc_stream_tls_openssl_failed (mongoc_stream_t *stream) -{ - _mongoc_stream_tls_openssl_destroy (stream); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_stream_tls_openssl_close -- - * - * Close the underlying socket. - * - * Linus dictates that you should not check the result of close() - * since there is a race condition with EAGAIN and a new file - * descriptor being opened. - * - * Returns: - * 0 on success; otherwise -1. - * - * Side effects: - * The BIO fd is closed. - * - *-------------------------------------------------------------------------- - */ - -static int -_mongoc_stream_tls_openssl_close (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - int ret = 0; - ENTRY; - - BSON_ASSERT (tls); - - ret = mongoc_stream_close (tls->base_stream); - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_stream_tls_openssl_flush -- - * - * Flush the underlying stream. - * - * Returns: - * 0 if successful; otherwise -1. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static int -_mongoc_stream_tls_openssl_flush (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_openssl_t *openssl = - (mongoc_stream_tls_openssl_t *) tls->ctx; - - BSON_ASSERT (openssl); - - return BIO_flush (openssl->bio); -} - - -static ssize_t -_mongoc_stream_tls_openssl_write (mongoc_stream_tls_t *tls, - char *buf, - size_t buf_len) -{ - mongoc_stream_tls_openssl_t *openssl = - (mongoc_stream_tls_openssl_t *) tls->ctx; - ssize_t ret; - int64_t now; - int64_t expire = 0; - ENTRY; - - BSON_ASSERT (tls); - BSON_ASSERT (buf); - BSON_ASSERT (buf_len); - - if (tls->timeout_msec >= 0) { - expire = bson_get_monotonic_time () + (tls->timeout_msec * 1000); - } - - BSON_ASSERT (bson_in_range_unsigned (int, buf_len)); - ret = BIO_write (openssl->bio, buf, (int) buf_len); - - if (ret <= 0) { - return ret; - } - - if (expire) { - now = bson_get_monotonic_time (); - - if ((expire - now) < 0) { - if (bson_cmp_less_su (ret, buf_len)) { - mongoc_counter_streams_timeout_inc (); - } - - tls->timeout_msec = 0; - } else { - tls->timeout_msec = (expire - now) / 1000; - } - } - - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_stream_tls_openssl_writev -- - * - * Write the iovec to the stream. This function will try to write - * all of the bytes or fail. If the number of bytes is not equal - * to the number requested, a failure or EOF has occurred. - * - * Returns: - * -1 on failure, otherwise the number of bytes written. - * - * Side effects: - * None. - * - * This function is copied as _mongoc_stream_tls_secure_transport_writev - *-------------------------------------------------------------------------- - */ - -static ssize_t -_mongoc_stream_tls_openssl_writev (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - int32_t timeout_msec) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - char buf[MONGOC_STREAM_TLS_OPENSSL_BUFFER_SIZE]; - ssize_t ret = 0; - ssize_t child_ret; - size_t i; - size_t iov_pos = 0; - - /* There's a bit of a dance to coalesce vectorized writes into - * MONGOC_STREAM_TLS_OPENSSL_BUFFER_SIZE'd writes to avoid lots of small tls - * packets. - * - * The basic idea is that we want to combine writes in the buffer if they're - * smaller than the buffer, flushing as it gets full. For larger writes, or - * the last write in the iovec array, we want to ignore the buffer and just - * write immediately. We take care of doing buffer writes by re-invoking - * ourself with a single iovec_t, pointing at our stack buffer. - */ - char *buf_head = buf; - char *buf_tail = buf; - char *buf_end = buf + MONGOC_STREAM_TLS_OPENSSL_BUFFER_SIZE; - size_t bytes; - - char *to_write = NULL; - size_t to_write_len; - - BSON_ASSERT (tls); - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - ENTRY; - - tls->timeout_msec = timeout_msec; - - for (i = 0; i < iovcnt; i++) { - iov_pos = 0; - - while (iov_pos < iov[i].iov_len) { - BSON_ASSERT (buf_end >= buf_tail); - const size_t buf_remaining = (size_t) (buf_end - buf_tail); - - if (buf_head != buf_tail || - ((i + 1 < iovcnt) && - (buf_remaining > (iov[i].iov_len - iov_pos)))) { - /* If we have either of: - * - buffered bytes already - * - another iovec to send after this one and we don't have more - * bytes to send than the size of the buffer. - * - * copy into the buffer */ - - bytes = BSON_MIN (iov[i].iov_len - iov_pos, buf_remaining); - - memcpy (buf_tail, (char *) iov[i].iov_base + iov_pos, bytes); - buf_tail += bytes; - iov_pos += bytes; - - if (buf_tail == buf_end) { - /* If we're full, request send */ - - to_write = buf_head; - to_write_len = (size_t) (buf_tail - buf_head); - - buf_tail = buf_head = buf; - } - } else { - /* Didn't buffer, so just write it through */ - - to_write = (char *) iov[i].iov_base + iov_pos; - to_write_len = iov[i].iov_len - iov_pos; - - iov_pos += to_write_len; - } - - if (to_write) { - /* We get here if we buffered some bytes and filled the buffer, or - * if we didn't buffer and have to send out of the iovec */ - - child_ret = - _mongoc_stream_tls_openssl_write (tls, to_write, to_write_len); - if (bson_cmp_not_equal_su (child_ret, to_write_len)) { - TRACE ("Got child_ret: %zu while to_write_len is: %zu", - child_ret, - to_write_len); - } - - if (child_ret < 0) { - TRACE ("Returning what I had (%zu) as apposed to the error " - "(%zu, errno:%d)", - ret, - child_ret, - errno); - RETURN (ret); - } - - ret += child_ret; - - if (bson_cmp_less_su (child_ret, to_write_len)) { - /* we timed out, so send back what we could send */ - - RETURN (ret); - } - - to_write = NULL; - } - } - } - - if (buf_head != buf_tail) { - /* If we have any bytes buffered, send */ - - child_ret = - _mongoc_stream_tls_openssl_write (tls, buf_head, buf_tail - buf_head); - - if (child_ret < 0) { - RETURN (child_ret); - } - - ret += child_ret; - } - - if (ret >= 0) { - mongoc_counter_streams_egress_add (ret); - } - - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_stream_tls_openssl_readv -- - * - * Read from the stream into iov. This function will try to read - * all of the bytes or fail. If the number of bytes is not equal - * to the number requested, a failure or EOF has occurred. - * - * Returns: - * -1 on failure, 0 on EOF, otherwise the number of bytes read. - * - * Side effects: - * iov buffers will be written to. - * - * This function is copied as _mongoc_stream_tls_secure_transport_readv - * - *-------------------------------------------------------------------------- - */ - -static ssize_t -_mongoc_stream_tls_openssl_readv (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - size_t min_bytes, - int32_t timeout_msec) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_openssl_t *openssl = - (mongoc_stream_tls_openssl_t *) tls->ctx; - ssize_t ret = 0; - size_t i; - int read_ret; - size_t iov_pos = 0; - int64_t now; - int64_t expire = 0; - ENTRY; - - BSON_ASSERT (tls); - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - - tls->timeout_msec = timeout_msec; - - if (timeout_msec >= 0) { - expire = bson_get_monotonic_time () + (timeout_msec * 1000UL); - } - - for (i = 0; i < iovcnt; i++) { - iov_pos = 0; - - while (iov_pos < iov[i].iov_len) { - read_ret = BIO_read (openssl->bio, - (char *) iov[i].iov_base + iov_pos, - (int) (iov[i].iov_len - iov_pos)); - - /* https://www.openssl.org/docs/crypto/BIO_should_retry.html: - * - * If BIO_should_retry() returns false then the precise "error - * condition" depends on the BIO type that caused it and the return - * code of the BIO operation. For example if a call to BIO_read() on a - * socket BIO returns 0 and BIO_should_retry() is false then the cause - * will be that the connection closed. - */ - if (read_ret < 0 || - (read_ret == 0 && !BIO_should_retry (openssl->bio))) { - return -1; - } - - if (expire) { - now = bson_get_monotonic_time (); - - if ((expire - now) < 0) { - if (read_ret == 0) { - mongoc_counter_streams_timeout_inc (); -#ifdef _WIN32 - errno = WSAETIMEDOUT; -#else - errno = ETIMEDOUT; -#endif - RETURN (-1); - } - - tls->timeout_msec = 0; - } else { - tls->timeout_msec = (expire - now) / 1000L; - } - } - - ret += read_ret; - - if ((size_t) ret >= min_bytes) { - mongoc_counter_streams_ingress_add (ret); - RETURN (ret); - } - - iov_pos += read_ret; - } - } - - if (ret >= 0) { - mongoc_counter_streams_ingress_add (ret); - } - - RETURN (ret); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_stream_tls_openssl_setsockopt -- - * - * Perform a setsockopt on the underlying stream. - * - * Returns: - * -1 on failure, otherwise opt specific value. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static int -_mongoc_stream_tls_openssl_setsockopt (mongoc_stream_t *stream, - int level, - int optname, - void *optval, - mongoc_socklen_t optlen) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - - BSON_ASSERT (tls); - - return mongoc_stream_setsockopt ( - tls->base_stream, level, optname, optval, optlen); -} - - -static mongoc_stream_t * -_mongoc_stream_tls_openssl_get_base_stream (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - return tls->base_stream; -} - - -static bool -_mongoc_stream_tls_openssl_check_closed (mongoc_stream_t *stream) /* IN */ -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - BSON_ASSERT (stream); - return mongoc_stream_check_closed (tls->base_stream); -} - - -static bool -_mongoc_stream_tls_openssl_set_verify_cert_error (SSL *ssl, bson_error_t *error) -{ - long verify_result; - - BSON_ASSERT_PARAM (ssl); - BSON_ASSERT_PARAM (error); - - verify_result = SSL_get_verify_result (ssl); - - if (verify_result == X509_V_OK) { - return false; - } - - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "TLS handshake failed: certificate verify failed (%ld): %s", - verify_result, - X509_verify_cert_error_string (verify_result)); - - return true; -} - -/** - * mongoc_stream_tls_openssl_handshake: - */ -static bool -_mongoc_stream_tls_openssl_handshake (mongoc_stream_t *stream, - const char *host, - int *events, - bson_error_t *error) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_openssl_t *openssl = - (mongoc_stream_tls_openssl_t *) tls->ctx; - SSL *ssl; - - BSON_ASSERT (tls); - BSON_ASSERT (host); - ENTRY; - - BIO_get_ssl (openssl->bio, &ssl); - - if (BIO_do_handshake (openssl->bio) == 1) { - *events = 0; - -#ifdef MONGOC_ENABLE_OCSP_OPENSSL - /* Validate OCSP */ - if (openssl->ocsp_opts && - 1 != _mongoc_ocsp_tlsext_status (ssl, openssl->ocsp_opts)) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "TLS handshake failed: Failed OCSP verification"); - RETURN (false); - } -#endif - - if (_mongoc_openssl_check_peer_hostname ( - ssl, host, tls->ssl_opts.allow_invalid_hostname)) { - RETURN (true); - } - - /* Try to relay certificate failure reason from OpenSSL library if any. */ - if (_mongoc_stream_tls_openssl_set_verify_cert_error (ssl, error)) { - RETURN (false); - } - - /* Otherwise, use simple error message. */ - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "TLS handshake failed: Failed certificate verification"); - - RETURN (false); - } - - if (BIO_should_retry (openssl->bio)) { - *events = BIO_should_read (openssl->bio) ? POLLIN : POLLOUT; - RETURN (false); - } - - if (!errno) { -#ifdef _WIN32 - errno = WSAETIMEDOUT; -#else - errno = ETIMEDOUT; -#endif - } - - *events = 0; - - /* Try to relay certificate failure reason from OpenSSL library if any. */ - if (_mongoc_stream_tls_openssl_set_verify_cert_error (ssl, error)) { - RETURN (false); - } - - /* Otherwise, try to relay error info from OpenSSL. */ - if (ERR_peek_error () != 0) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "TLS handshake failed: %s", - ERR_error_string (ERR_get_error (), NULL)); - RETURN (false); - } - - /* Otherwise, use simple error info. */ - { -#ifdef _WIN32 - LPTSTR msg = NULL; - FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_ARGUMENT_ARRAY, - NULL, - errno, /* WSAETIMEDOUT */ - LANG_NEUTRAL, - (LPTSTR) &msg, - 0, - NULL); -#else - const char *msg = strerror (errno); /* ETIMEDOUT */ -#endif - - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "TLS handshake failed: %s", - msg); - -#ifdef _WIN32 - LocalFree (msg); -#endif - } - - RETURN (false); -} - -/* Callback to get the client provided SNI, if any - * It is only called in SSL "server mode" (e.g. when using the Mock Server), - * and we don't actually use the hostname for anything, just debug print it - */ -static int -_mongoc_stream_tls_openssl_sni (SSL *ssl, int *ad, void *arg) -{ - const char *hostname; - - BSON_UNUSED (ad); - BSON_UNUSED (arg); - - if (ssl == NULL) { - TRACE ("%s", "No SNI hostname provided"); - return SSL_TLSEXT_ERR_NOACK; - } - - hostname = SSL_get_servername (ssl, TLSEXT_NAMETYPE_host_name); - /* This is intentionally debug since its only used by the mock test server */ - MONGOC_DEBUG ("Got SNI: '%s'", hostname); - - return SSL_TLSEXT_ERR_OK; -} - -static bool -_mongoc_stream_tls_openssl_timed_out (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - - ENTRY; - - RETURN (mongoc_stream_timed_out (tls->base_stream)); -} - -static bool -_mongoc_stream_tls_openssl_should_retry (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_openssl_t *openssl = - (mongoc_stream_tls_openssl_t *) tls->ctx; - - ENTRY; - - if (BIO_should_retry (openssl->bio)) { - RETURN (true); - } - - RETURN (mongoc_stream_should_retry (tls->base_stream)); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_stream_tls_openssl_new -- - * - * Creates a new mongoc_stream_tls_openssl_t to communicate with a remote - * server using a TLS stream. - * - * @base_stream should be a stream that will become owned by the - * resulting tls stream. It will be used for raw I/O. - * - * @trust_store_dir should be a path to the SSL cert db to use for - * verifying trust of the remote server. - * - * Returns: - * NULL on failure, otherwise a mongoc_stream_t. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_stream_t * -mongoc_stream_tls_openssl_new (mongoc_stream_t *base_stream, - const char *host, - mongoc_ssl_opt_t *opt, - int client) -{ - mongoc_stream_tls_t *tls; - mongoc_stream_tls_openssl_t *openssl; - mongoc_openssl_ocsp_opt_t *ocsp_opts = NULL; - SSL_CTX *ssl_ctx = NULL; - BIO *bio_ssl = NULL; - BIO *bio_mongoc_shim = NULL; - BIO_METHOD *meth; - - BSON_ASSERT (base_stream); - BSON_ASSERT (opt); - ENTRY; - - ssl_ctx = _mongoc_openssl_ctx_new (opt); - - if (!ssl_ctx) { - RETURN (NULL); - } - -#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER) - if (!opt->allow_invalid_hostname) { - struct in_addr addr; - struct in6_addr addr6; - X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new (); - - X509_VERIFY_PARAM_set_hostflags (param, - X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS); - if (inet_pton (AF_INET, host, &addr) || - inet_pton (AF_INET6, host, &addr6)) { - X509_VERIFY_PARAM_set1_ip_asc (param, host); - } else { - X509_VERIFY_PARAM_set1_host (param, host, 0); - } - SSL_CTX_set1_param (ssl_ctx, param); - X509_VERIFY_PARAM_free (param); - } -#endif - - if (!client) { - /* Only used by the Mock Server. - * Set a callback to get the SNI, if provided */ - SSL_CTX_set_tlsext_servername_callback (ssl_ctx, - _mongoc_stream_tls_openssl_sni); - } - - if (opt->weak_cert_validation) { - SSL_CTX_set_verify (ssl_ctx, SSL_VERIFY_NONE, NULL); - } else { - SSL_CTX_set_verify (ssl_ctx, SSL_VERIFY_PEER, NULL); - } - - bio_ssl = BIO_new_ssl (ssl_ctx, client); - if (!bio_ssl) { - SSL_CTX_free (ssl_ctx); - RETURN (NULL); - } - meth = mongoc_stream_tls_openssl_bio_meth_new (); - bio_mongoc_shim = BIO_new (meth); - if (!bio_mongoc_shim) { - BIO_free_all (bio_ssl); - BIO_meth_free (meth); - SSL_CTX_free (ssl_ctx); - RETURN (NULL); - } - -/* Added in OpenSSL 0.9.8f, as a build time option */ -#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME - if (client) { - SSL *ssl; - /* Set the SNI hostname we are expecting certificate for */ - BIO_get_ssl (bio_ssl, &ssl); - SSL_set_tlsext_host_name (ssl, host); -#endif - } - - BIO_push (bio_ssl, bio_mongoc_shim); - -#ifdef MONGOC_ENABLE_OCSP_OPENSSL - if (client && !opt->weak_cert_validation && - !_mongoc_ssl_opts_disable_certificate_revocation_check (opt)) { - SSL *ssl; - - BIO_get_ssl (bio_ssl, &ssl); - - /* Set the status_request extension on the SSL object. - * Do not use SSL_CTX_set_tlsext_status_type, since that requires OpenSSL - * 1.1.0. - */ - if (!SSL_set_tlsext_status_type (ssl, TLSEXT_STATUSTYPE_ocsp)) { - MONGOC_ERROR ("cannot enable OCSP status request extension"); - mongoc_openssl_ocsp_opt_destroy (ocsp_opts); - BIO_free_all (bio_ssl); - BIO_meth_free (meth); - SSL_CTX_free (ssl_ctx); - RETURN (NULL); - } - - ocsp_opts = bson_malloc0 (sizeof (mongoc_openssl_ocsp_opt_t)); - ocsp_opts->allow_invalid_hostname = opt->allow_invalid_hostname; - ocsp_opts->weak_cert_validation = opt->weak_cert_validation; - ocsp_opts->disable_endpoint_check = - _mongoc_ssl_opts_disable_ocsp_endpoint_check (opt); - ocsp_opts->host = bson_strdup (host); - _mongoc_ssl_opts_copy_to (opt, &ocsp_opts->ssl_opts, true); - } -#endif /* MONGOC_ENABLE_OCSP_OPENSSL */ - - openssl = (mongoc_stream_tls_openssl_t *) bson_malloc0 (sizeof *openssl); - openssl->bio = bio_ssl; - openssl->meth = meth; - openssl->ctx = ssl_ctx; - openssl->ocsp_opts = ocsp_opts; - - tls = (mongoc_stream_tls_t *) bson_malloc0 (sizeof *tls); - tls->parent.type = MONGOC_STREAM_TLS; - tls->parent.destroy = _mongoc_stream_tls_openssl_destroy; - tls->parent.failed = _mongoc_stream_tls_openssl_failed; - tls->parent.close = _mongoc_stream_tls_openssl_close; - tls->parent.flush = _mongoc_stream_tls_openssl_flush; - tls->parent.writev = _mongoc_stream_tls_openssl_writev; - tls->parent.readv = _mongoc_stream_tls_openssl_readv; - tls->parent.setsockopt = _mongoc_stream_tls_openssl_setsockopt; - tls->parent.get_base_stream = _mongoc_stream_tls_openssl_get_base_stream; - tls->parent.check_closed = _mongoc_stream_tls_openssl_check_closed; - tls->parent.timed_out = _mongoc_stream_tls_openssl_timed_out; - tls->parent.should_retry = _mongoc_stream_tls_openssl_should_retry; - memcpy (&tls->ssl_opts, opt, sizeof tls->ssl_opts); - tls->handshake = _mongoc_stream_tls_openssl_handshake; - tls->ctx = (void *) openssl; - tls->timeout_msec = -1; - tls->base_stream = base_stream; - mongoc_stream_tls_openssl_bio_set_data (bio_mongoc_shim, tls); - - mongoc_counter_streams_active_inc (); - - RETURN ((mongoc_stream_t *) tls); -} - -void -mongoc_openssl_ocsp_opt_destroy (void *ocsp_opt) -{ - mongoc_openssl_ocsp_opt_t *casted; - - if (!ocsp_opt) { - return; - } - casted = (mongoc_openssl_ocsp_opt_t *) ocsp_opt; - bson_free (casted->host); - _mongoc_ssl_opts_cleanup (&casted->ssl_opts, true); - bson_free (ocsp_opt); -} - -#endif /* MONGOC_ENABLE_SSL_OPENSSL */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.h deleted file mode 100644 index 2ddf8a642..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_STREAM_TLS_OPENSSL_H -#define MONGOC_STREAM_TLS_OPENSSL_H - -#ifdef MONGOC_ENABLE_SSL_OPENSSL -#include - -#include "mongoc-macros.h" - -BSON_BEGIN_DECLS - -MONGOC_EXPORT (mongoc_stream_t *) -mongoc_stream_tls_openssl_new (mongoc_stream_t *base_stream, - const char *host, - mongoc_ssl_opt_t *opt, - int client) BSON_GNUC_WARN_UNUSED_RESULT; - -BSON_END_DECLS - -#endif /* MONGOC_ENABLE_SSL_OPENSSL */ -#endif /* MONGOC_STREAM_TLS_OPENSSL_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-private.h deleted file mode 100644 index e3da5f264..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-private.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_STREAM_TLS_PRIVATE_H -#define MONGOC_STREAM_TLS_PRIVATE_H - -#include - -#include "mongoc-ssl.h" -#include "mongoc-stream.h" - -BSON_BEGIN_DECLS - -/** - * mongoc_stream_tls_t: - * - * Overloaded mongoc_stream_t with additional TLS handshake and verification - * callbacks. - * - */ -struct _mongoc_stream_tls_t { - mongoc_stream_t parent; /* The TLS stream wrapper */ - mongoc_stream_t *base_stream; /* The underlying actual stream */ - void *ctx; /* TLS lib specific configuration or wrappers */ - int64_t timeout_msec; - mongoc_ssl_opt_t ssl_opts; - bool (*handshake) (mongoc_stream_t *stream, - const char *host, - int *events /* OUT*/, - bson_error_t *error); -}; - - -BSON_END_DECLS - -#endif /* MONGOC_STREAM_TLS_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel-private.h deleted file mode 100644 index 2405b8ea1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel-private.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_STREAM_TLS_SECURE_CHANNEL_PRIVATE_H -#define MONGOC_STREAM_TLS_SECURE_CHANNEL_PRIVATE_H - -#ifdef MONGOC_ENABLE_SSL_SECURE_CHANNEL -#include - -/* Its mandatory to indicate to Windows who is compiling the code */ -#define SECURITY_WIN32 -#include - - -BSON_BEGIN_DECLS - - -/* enum for the nonblocking SSL connection state machine */ -typedef enum { - ssl_connect_1, - ssl_connect_2, - ssl_connect_2_reading, - ssl_connect_2_writing, - ssl_connect_3, - ssl_connect_done -} ssl_connect_state; - -/* Structs to store Schannel handles */ -typedef struct { - CredHandle cred_handle; - TimeStamp time_stamp; -} mongoc_secure_channel_cred; - -typedef struct { - CtxtHandle ctxt_handle; - TimeStamp time_stamp; -} mongoc_secure_channel_ctxt; - -/** - * mongoc_stream_tls_secure_channel_t: - * - * Private storage for Secure Channel Streams - */ -typedef struct { - ssl_connect_state connecting_state; - mongoc_secure_channel_cred *cred; - mongoc_secure_channel_ctxt *ctxt; - SecPkgContext_StreamSizes stream_sizes; - size_t encdata_length, decdata_length; - size_t encdata_offset, decdata_offset; - unsigned char *encdata_buffer, *decdata_buffer; - unsigned long req_flags, ret_flags; - int recv_unrecoverable_err; /* _mongoc_stream_tls_secure_channel_read had an - unrecoverable err */ - bool recv_sspi_close_notify; /* true if connection closed by close_notify */ - bool recv_connection_closed; /* true if connection closed, regardless how */ -} mongoc_stream_tls_secure_channel_t; - - -BSON_END_DECLS - -#endif /* MONGOC_ENABLE_SSL_SECURE_CHANNEL */ -#endif /* MONGOC_STREAM_TLS_SECURE_CHANNEL_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c deleted file mode 100644 index ee9362758..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c +++ /dev/null @@ -1,1074 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Significant portion of this file, such as - * _mongoc_stream_tls_secure_channel_write & - *_mongoc_stream_tls_secure_channel_read - * comes straight from one of my favorite projects, cURL! - * Thank you so much for having gone through the Secure Channel pain for me. - * - * - * Copyright (C) 2012 - 2015, Marc Hoersken, - * Copyright (C) 2012, Mark Salisbury, - * Copyright (C) 2012 - 2015, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* - * Based upon the PolarSSL implementation in polarssl.c and polarssl.h: - * Copyright (C) 2010, 2011, Hoi-Ho Chan, - * - * Based upon the CyaSSL implementation in cyassl.c and cyassl.h: - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. - * - * Thanks for code and inspiration! - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SSL_SECURE_CHANNEL - -#include - -#include "mongoc-trace-private.h" -#include "mongoc-log.h" -#include "mongoc-stream-tls.h" -#include "mongoc-stream-tls-private.h" -#include "mongoc-stream-private.h" -#include "mongoc-stream-tls-secure-channel-private.h" -#include "mongoc-secure-channel-private.h" -#include "mongoc-ssl.h" -#include "mongoc-ssl-private.h" -#include "mongoc-error.h" -#include "mongoc-counters-private.h" -#include "mongoc-errno-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "stream-tls-secure-channel" - - -#define SECURITY_WIN32 -#include -#include -#include - -/* mingw doesn't define these */ -#ifndef SP_PROT_TLS1_1_CLIENT -#define SP_PROT_TLS1_1_CLIENT 0x00000200 -#endif - -#ifndef SP_PROT_TLS1_2_CLIENT -#define SP_PROT_TLS1_2_CLIENT 0x00000800 -#endif - - -static void -_mongoc_stream_tls_secure_channel_destroy (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_channel); - - - /* See https://msdn.microsoft.com/en-us/library/windows/desktop/aa380138.aspx - * Shutting Down an Schannel Connection - */ - - TRACE ("%s", "shutting down SSL/TLS connection"); - - if (secure_channel->cred && secure_channel->ctxt) { - SecBufferDesc BuffDesc; - SecBuffer Buffer; - SECURITY_STATUS sspi_status; - SecBuffer outbuf; - SecBufferDesc outbuf_desc; - DWORD dwshut = SCHANNEL_SHUTDOWN; - - _mongoc_secure_channel_init_sec_buffer ( - &Buffer, SECBUFFER_TOKEN, &dwshut, sizeof (dwshut)); - _mongoc_secure_channel_init_sec_buffer_desc (&BuffDesc, &Buffer, 1); - - sspi_status = - ApplyControlToken (&secure_channel->ctxt->ctxt_handle, &BuffDesc); - - if (sspi_status != SEC_E_OK) { - MONGOC_ERROR ("ApplyControlToken failure: %ld", sspi_status); - } - - /* setup output buffer */ - _mongoc_secure_channel_init_sec_buffer ( - &outbuf, SECBUFFER_EMPTY, NULL, 0); - _mongoc_secure_channel_init_sec_buffer_desc (&outbuf_desc, &outbuf, 1); - - sspi_status = - InitializeSecurityContext (&secure_channel->cred->cred_handle, - &secure_channel->ctxt->ctxt_handle, - /*tls->hostname*/ NULL, - secure_channel->req_flags, - 0, - 0, - NULL, - 0, - &secure_channel->ctxt->ctxt_handle, - &outbuf_desc, - &secure_channel->ret_flags, - &secure_channel->ctxt->time_stamp); - - if ((sspi_status == SEC_E_OK) || (sspi_status == SEC_I_CONTEXT_EXPIRED)) { - /* send close message which is in output buffer */ - ssize_t written = - mongoc_secure_channel_write (tls, outbuf.pvBuffer, outbuf.cbBuffer); - - FreeContextBuffer (outbuf.pvBuffer); - - if (outbuf.cbBuffer != (size_t) written) { - TRACE ("failed to send close msg (wrote %zd out of %lu)", - written, - outbuf.cbBuffer); - } - } - } - - /* free SSPI Schannel API security context handle */ - if (secure_channel->ctxt) { - TRACE ("%s", "clear security context handle"); - DeleteSecurityContext (&secure_channel->ctxt->ctxt_handle); - bson_free (secure_channel->ctxt); - } - - /* free SSPI Schannel API credential handle */ - if (secure_channel->cred) { - /* decrement the reference counter of the credential/session handle */ - /* if the handle was not cached and the refcount is zero */ - TRACE ("%s", "clear credential handle"); - FreeCredentialsHandle (&secure_channel->cred->cred_handle); - bson_free (secure_channel->cred); - } - - /* free internal buffer for received encrypted data */ - if (secure_channel->encdata_buffer != NULL) { - bson_free (secure_channel->encdata_buffer); - secure_channel->encdata_length = 0; - secure_channel->encdata_offset = 0; - } - - /* free internal buffer for received decrypted data */ - if (secure_channel->decdata_buffer != NULL) { - bson_free (secure_channel->decdata_buffer); - secure_channel->decdata_length = 0; - secure_channel->decdata_offset = 0; - } - - mongoc_stream_destroy (tls->base_stream); - - bson_free (secure_channel); - bson_free (stream); - - mongoc_counter_streams_active_dec (); - mongoc_counter_streams_disposed_inc (); - EXIT; -} - -static void -_mongoc_stream_tls_secure_channel_failed (mongoc_stream_t *stream) -{ - ENTRY; - _mongoc_stream_tls_secure_channel_destroy (stream); - EXIT; -} - -static int -_mongoc_stream_tls_secure_channel_close (mongoc_stream_t *stream) -{ - int ret = 0; - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_channel); - - ret = mongoc_stream_close (tls->base_stream); - RETURN (ret); -} - -static int -_mongoc_stream_tls_secure_channel_flush (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_channel); - RETURN (0); -} - -static ssize_t -_mongoc_stream_tls_secure_channel_write (mongoc_stream_t *stream, - char *buf, - size_t buf_len) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - ssize_t written = -1; - size_t data_len = 0; - unsigned char *data = NULL; - SecBuffer outbuf[4]; - SecBufferDesc outbuf_desc; - SECURITY_STATUS sspi_status = SEC_E_OK; - - ENTRY; - - BSON_ASSERT (secure_channel); - TRACE ("The entire buffer is: %zu", buf_len); - - /* check if the maximum stream sizes were queried */ - if (secure_channel->stream_sizes.cbMaximumMessage == 0) { - sspi_status = QueryContextAttributes (&secure_channel->ctxt->ctxt_handle, - SECPKG_ATTR_STREAM_SIZES, - &secure_channel->stream_sizes); - - if (sspi_status != SEC_E_OK) { - TRACE ("failing here: %d", __LINE__); - return -1; - } - } - - /* check if the buffer is longer than the maximum message length */ - if (buf_len > secure_channel->stream_sizes.cbMaximumMessage) { - TRACE ("SHRINKING buf_len from %zu to %lu", - buf_len, - secure_channel->stream_sizes.cbMaximumMessage); - buf_len = secure_channel->stream_sizes.cbMaximumMessage; - } - - /* calculate the complete message length and allocate a buffer for it */ - data_len = secure_channel->stream_sizes.cbHeader + buf_len + - secure_channel->stream_sizes.cbTrailer; - data = (unsigned char *) bson_malloc (data_len); - - /* setup output buffers (header, data, trailer, empty) */ - _mongoc_secure_channel_init_sec_buffer ( - &outbuf[0], - SECBUFFER_STREAM_HEADER, - data, - secure_channel->stream_sizes.cbHeader); - _mongoc_secure_channel_init_sec_buffer ( - &outbuf[1], - SECBUFFER_DATA, - data + secure_channel->stream_sizes.cbHeader, - (unsigned long) (buf_len & (size_t) 0xFFFFFFFFUL)); - _mongoc_secure_channel_init_sec_buffer ( - &outbuf[2], - SECBUFFER_STREAM_TRAILER, - data + secure_channel->stream_sizes.cbHeader + buf_len, - secure_channel->stream_sizes.cbTrailer); - _mongoc_secure_channel_init_sec_buffer ( - &outbuf[3], SECBUFFER_EMPTY, NULL, 0); - _mongoc_secure_channel_init_sec_buffer_desc (&outbuf_desc, outbuf, 4); - - /* copy data into output buffer */ - memcpy (outbuf[1].pvBuffer, buf, buf_len); - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa375390.aspx */ - sspi_status = - EncryptMessage (&secure_channel->ctxt->ctxt_handle, 0, &outbuf_desc, 0); - - /* check if the message was encrypted */ - if (sspi_status == SEC_E_OK) { - written = 0; - - /* send the encrypted message including header, data and trailer */ - buf_len = outbuf[0].cbBuffer + outbuf[1].cbBuffer + outbuf[2].cbBuffer; - written = mongoc_secure_channel_write (tls, data, buf_len); - } else { - written = -1; - } - - bson_free (data); - - if (buf_len == (size_t) written) { - /* Encrypted message including header, data and trailer entirely sent. - * The return value is the number of unencrypted bytes that were sent. */ - written = outbuf[1].cbBuffer; - } - - return written; -} - -/* This is copypasta from _mongoc_stream_tls_openssl_writev */ -#define MONGOC_STREAM_TLS_BUFFER_SIZE 4096 -static ssize_t -_mongoc_stream_tls_secure_channel_writev (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - int32_t timeout_msec) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - char buf[MONGOC_STREAM_TLS_BUFFER_SIZE]; - ssize_t ret = 0; - ssize_t child_ret; - size_t i; - size_t iov_pos = 0; - - /* There's a bit of a dance to coalesce vectorized writes into - * MONGOC_STREAM_TLS_BUFFER_SIZE'd writes to avoid lots of small tls - * packets. - * - * The basic idea is that we want to combine writes in the buffer if they're - * smaller than the buffer, flushing as it gets full. For larger writes, or - * the last write in the iovec array, we want to ignore the buffer and just - * write immediately. We take care of doing buffer writes by re-invoking - * ourself with a single iovec_t, pointing at our stack buffer. - */ - char *buf_head = buf; - char *buf_tail = buf; - char *buf_end = buf + MONGOC_STREAM_TLS_BUFFER_SIZE; - size_t bytes; - - char *to_write = NULL; - size_t to_write_len; - - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - BSON_ASSERT (secure_channel); - ENTRY; - - TRACE ("%s", "Trying to write to the server"); - tls->timeout_msec = timeout_msec; - - TRACE ("count: %zu, 0th: %zu", iovcnt, iov[0].iov_len); - - for (i = 0; i < iovcnt; i++) { - iov_pos = 0; - - TRACE ("iov %zu size: %zu", i, iov[i].iov_len); - while (iov_pos < iov[i].iov_len) { - BSON_ASSERT (buf_end >= buf_tail); - const size_t buf_remaining = (size_t) (buf_end - buf_tail); - - if (buf_head != buf_tail || - ((i + 1u < iovcnt) && - (buf_remaining > (iov[i].iov_len - iov_pos)))) { - /* If we have either of: - * - buffered bytes already - * - another iovec to send after this one and we don't have more - * bytes to send than the size of the buffer. - * - * copy into the buffer */ - - bytes = BSON_MIN (iov[i].iov_len - iov_pos, buf_remaining); - - memcpy (buf_tail, (char *) iov[i].iov_base + iov_pos, bytes); - buf_tail += bytes; - iov_pos += bytes; - - if (buf_tail == buf_end) { - /* If we're full, request send */ - - to_write = buf_head; - to_write_len = buf_tail - buf_head; - - buf_tail = buf_head = buf; - } - } else { - /* Didn't buffer, so just write it through */ - - to_write = (char *) iov[i].iov_base + iov_pos; - to_write_len = iov[i].iov_len - iov_pos; - - iov_pos += to_write_len; - } - - if (to_write) { - /* We get here if we buffered some bytes and filled the buffer, or - * if we didn't buffer and have to send out of the iovec */ - - child_ret = _mongoc_stream_tls_secure_channel_write ( - stream, to_write, to_write_len); - TRACE ("Child0wrote: %zd, was supposed to write: %zu", - child_ret, - to_write_len); - - if (child_ret < 0) { - RETURN (ret); - } - - ret += child_ret; - - iov_pos -= to_write_len - child_ret; - - to_write = NULL; - } - } - } - - if (buf_head != buf_tail) { - /* If we have any bytes buffered, send */ - - child_ret = _mongoc_stream_tls_secure_channel_write ( - stream, buf_head, buf_tail - buf_head); - TRACE ("Child1wrote: %zd, was supposed to write: %td", - child_ret, - buf_tail - buf_head); - - if (child_ret < 0) { - RETURN (child_ret); - } - - ret += child_ret; - } - - if (ret >= 0) { - mongoc_counter_streams_egress_add (ret); - } - - TRACE ("Returning %d", (int) ret); - RETURN (ret); -} - - -/* move up to "len" decrypted bytes to buf, return number of bytes */ -static ssize_t -_mongoc_stream_tls_secure_channel_debuf ( - mongoc_stream_tls_secure_channel_t *secure_channel, char *buf, size_t size) -{ - size_t s = BSON_MIN (size, secure_channel->decdata_offset); - memcpy (buf, secure_channel->decdata_buffer, s); - memmove (secure_channel->decdata_buffer, - secure_channel->decdata_buffer + s, - secure_channel->decdata_offset - s); - - secure_channel->decdata_offset -= s; - - TRACE ("decrypted data returned %d", (int) s); - TRACE ("decrypted data buffer: offset %d length %d", - (int) secure_channel->decdata_offset, - (int) secure_channel->decdata_length); - - return (ssize_t) s; -} - - -/* decrypt as many received bytes as possible to secure_channel.decdata_buf */ -static void -_mongoc_stream_tls_secure_channel_decrypt ( - mongoc_stream_tls_secure_channel_t *secure_channel) -{ - size_t size = 0; - size_t remaining; - SecBuffer inbuf[4]; - SecBufferDesc inbuf_desc; - SECURITY_STATUS sspi_status = SEC_E_OK; - - TRACE ("encrypted data buffer: offset %d length %d", - (int) secure_channel->encdata_offset, - (int) secure_channel->encdata_length); - - /* decrypt loop */ - while (secure_channel->encdata_offset > 0 && sspi_status == SEC_E_OK) { - /* prepare data buffer for DecryptMessage call */ - _mongoc_secure_channel_init_sec_buffer ( - &inbuf[0], - SECBUFFER_DATA, - secure_channel->encdata_buffer, - (unsigned long) (secure_channel->encdata_offset & - (size_t) 0xFFFFFFFFUL)); - - /* we need 3 more empty input buffers for possible output */ - _mongoc_secure_channel_init_sec_buffer ( - &inbuf[1], SECBUFFER_EMPTY, NULL, 0); - _mongoc_secure_channel_init_sec_buffer ( - &inbuf[2], SECBUFFER_EMPTY, NULL, 0); - _mongoc_secure_channel_init_sec_buffer ( - &inbuf[3], SECBUFFER_EMPTY, NULL, 0); - _mongoc_secure_channel_init_sec_buffer_desc (&inbuf_desc, inbuf, 4); - - /* https://msdn.microsoft.com/en-us/library/windows/desktop/aa375348.aspx - */ - sspi_status = DecryptMessage ( - &secure_channel->ctxt->ctxt_handle, &inbuf_desc, 0, NULL); - - /* check if everything went fine (server may want to renegotiate - * or shutdown the connection context) */ - if (sspi_status == SEC_E_OK || sspi_status == SEC_I_RENEGOTIATE || - sspi_status == SEC_I_CONTEXT_EXPIRED) { - /* check for successfully decrypted data, even before actual - * renegotiation or shutdown of the connection context */ - if (inbuf[1].BufferType == SECBUFFER_DATA) { - TRACE ("decrypted data length: %lu", inbuf[1].cbBuffer); - - size = inbuf[1].cbBuffer; - remaining = - secure_channel->decdata_length - secure_channel->decdata_offset; - - if (remaining < size) { - mongoc_secure_channel_realloc_buf ( - &secure_channel->decdata_length, - &secure_channel->decdata_buffer, - size); - } - - /* copy decrypted data to internal buffer */ - if (size) { - memcpy (secure_channel->decdata_buffer + - secure_channel->decdata_offset, - inbuf[1].pvBuffer, - size); - secure_channel->decdata_offset += size; - } - - TRACE ("decrypted data added: %d", (int) size); - TRACE ("decrypted data cached: offset %d length %d", - (int) secure_channel->decdata_offset, - (int) secure_channel->decdata_length); - } - - /* check for remaining encrypted data */ - if (inbuf[3].BufferType == SECBUFFER_EXTRA && inbuf[3].cbBuffer > 0) { - TRACE ("encrypted data length: %lu", inbuf[3].cbBuffer); - - /* check if the remaining data is less than the total amount - * and therefore begins after the already processed data - */ - if (secure_channel->encdata_offset > inbuf[3].cbBuffer) { - /* move remaining encrypted data forward to the beginning of - * buffer */ - memmove (secure_channel->encdata_buffer, - (secure_channel->encdata_buffer + - secure_channel->encdata_offset) - - inbuf[3].cbBuffer, - inbuf[3].cbBuffer); - secure_channel->encdata_offset = inbuf[3].cbBuffer; - } - - TRACE ("encrypted data cached: offset %d length %d", - (int) secure_channel->encdata_offset, - (int) secure_channel->encdata_length); - } else { - /* reset encrypted buffer offset, because there is no data remaining - */ - secure_channel->encdata_offset = 0; - } - - /* check if server wants to renegotiate the connection context */ - if (sspi_status == SEC_I_RENEGOTIATE) { - TRACE ("%s", "remote party requests renegotiation"); - } - /* check if the server closed the connection */ - else if (sspi_status == SEC_I_CONTEXT_EXPIRED) { - /* In Windows 2000 SEC_I_CONTEXT_EXPIRED (close_notify) is not - * returned so we have to work around that in cleanup. */ - secure_channel->recv_sspi_close_notify = true; - - if (!secure_channel->recv_connection_closed) { - secure_channel->recv_connection_closed = true; - TRACE ("%s", "server closed the connection"); - } - } - } else if (sspi_status == SEC_E_INCOMPLETE_MESSAGE) { - TRACE ("%s", "failed to decrypt data, need more data"); - } else { - TRACE ("failed to read data from server: %ld", sspi_status); - secure_channel->recv_unrecoverable_err = true; - } - } - - TRACE ("encrypted data buffer: offset %d length %d", - (int) secure_channel->encdata_offset, - (int) secure_channel->encdata_length); - - TRACE ("decrypted data buffer: offset %d length %d", - (int) secure_channel->decdata_offset, - (int) secure_channel->decdata_length); -} - - -static ssize_t -_mongoc_stream_tls_secure_channel_read (mongoc_stream_t *stream, - char *buf, - size_t len) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - ssize_t size = 0; - ssize_t nread; - - TRACE ("client wants to read %d bytes", (int) len); - BSON_ASSERT (len > 0); - - /* - * Our priority is to always return as much decrypted data to the caller as - * possible, even if an error occurs. The state of the decrypted buffer must - * always be valid. - */ - - if (secure_channel->decdata_offset) { - TRACE ("%s", "decrypted data is already available"); - return _mongoc_stream_tls_secure_channel_debuf (secure_channel, buf, len); - } - - /* is a complete encrypted block left from last network read? */ - if (secure_channel->encdata_offset) { - _mongoc_stream_tls_secure_channel_decrypt (secure_channel); - if (secure_channel->decdata_offset) { - return _mongoc_stream_tls_secure_channel_debuf ( - secure_channel, buf, len); - } - } - - /* keep these checks separated, for more detailed tracing */ - if (secure_channel->recv_unrecoverable_err) { - TRACE ("%s", "an unrecoverable error occurred in a prior call"); - return -1; - } - - if (secure_channel->recv_sspi_close_notify) { - TRACE ("%s", "server indicated shutdown in a prior call"); - return -1; - } - - if (secure_channel->recv_connection_closed) { - TRACE ("%s", "connection closed"); - return -1; - } - - size = secure_channel->encdata_length - secure_channel->encdata_offset; - - /* read encrypted data from socket. returns 0 on shutdown or error */ - nread = - mongoc_secure_channel_read (tls, - (char *) (secure_channel->encdata_buffer + - secure_channel->encdata_offset), - (size_t) size); - - if (!nread) { - if (MONGOC_ERRNO_IS_AGAIN (errno)) { - TRACE ("%s", "Try again"); - return 0; - } else { - secure_channel->recv_connection_closed = true; - TRACE ("reading failed: %d", errno); - return -1; - } - } - - secure_channel->encdata_offset += (size_t) nread; - TRACE ("encrypted data got %zd", nread); - - _mongoc_stream_tls_secure_channel_decrypt (secure_channel); - return _mongoc_stream_tls_secure_channel_debuf (secure_channel, buf, len); -} - - -/* This function is copypasta of _mongoc_stream_tls_openssl_readv */ -static ssize_t -_mongoc_stream_tls_secure_channel_readv (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - size_t min_bytes, - int32_t timeout_msec) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - ssize_t ret = 0; - size_t i; - size_t iov_pos = 0; - int64_t now; - int64_t expire = 0; - - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - BSON_ASSERT (secure_channel); - ENTRY; - - tls->timeout_msec = timeout_msec; - - if (timeout_msec >= 0) { - expire = bson_get_monotonic_time () + (timeout_msec * 1000UL); - } - - for (i = 0; i < iovcnt; i++) { - iov_pos = 0; - - while (iov_pos < iov[i].iov_len) { - ssize_t read_ret = _mongoc_stream_tls_secure_channel_read ( - stream, - (char *) iov[i].iov_base + iov_pos, - (int) (iov[i].iov_len - iov_pos)); - - if (read_ret < 0) { - RETURN (-1); - } - - if (expire) { - now = bson_get_monotonic_time (); - - if ((expire - now) < 0) { - if (read_ret == 0) { - mongoc_counter_streams_timeout_inc (); - errno = ETIMEDOUT; - RETURN (-1); - } - - tls->timeout_msec = 0; - } else { - tls->timeout_msec = (expire - now) / 1000L; - } - } - - ret += read_ret; - - if ((size_t) ret >= min_bytes) { - mongoc_counter_streams_ingress_add (ret); - RETURN (ret); - } - - iov_pos += read_ret; - } - } - - if (ret >= 0) { - mongoc_counter_streams_ingress_add (ret); - } - - RETURN (ret); -} - -static int -_mongoc_stream_tls_secure_channel_setsockopt (mongoc_stream_t *stream, - int level, - int optname, - void *optval, - mongoc_socklen_t optlen) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_channel); - RETURN (mongoc_stream_setsockopt ( - tls->base_stream, level, optname, optval, optlen)); -} - -static mongoc_stream_t * -_mongoc_stream_tls_secure_channel_get_base_stream (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_channel); - RETURN (tls->base_stream); -} - - -static bool -_mongoc_stream_tls_secure_channel_check_closed ( - mongoc_stream_t *stream) /* IN */ -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_channel); - RETURN (mongoc_stream_check_closed (tls->base_stream)); -} - -bool -mongoc_stream_tls_secure_channel_handshake (mongoc_stream_t *stream, - const char *host, - int *events, - bson_error_t *error) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_channel_t *secure_channel = - (mongoc_stream_tls_secure_channel_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_channel); - - if (error) { - error->code = 0; - } - - TRACE ("Getting ready for state: %d, timeout is %" PRId64, - secure_channel->connecting_state + 1, - tls->timeout_msec); - - switch (secure_channel->connecting_state) { - case ssl_connect_1: - - if (mongoc_secure_channel_handshake_step_1 (tls, (char *) host, error)) { - TRACE ("%s", "Step#1 Worked!\n\n"); - *events = POLLIN; - RETURN (false); - } else { - TRACE ("%s", "Step#1 FAILED!"); - } - - break; - - case ssl_connect_2: - case ssl_connect_2_reading: - case ssl_connect_2_writing: - - if (mongoc_secure_channel_handshake_step_2 (tls, (char *) host, error)) { - if (secure_channel->connecting_state == ssl_connect_2_reading) { - *events = POLLIN; - } else { - *events = POLLOUT; - } - RETURN (false); - } else { - TRACE ("%s", "Step#2 FAILED!"); - } - - break; - - case ssl_connect_3: - - if (mongoc_secure_channel_handshake_step_3 (tls, (char *) host, error)) { - TRACE ("%s", "Step#3 Worked!\n\n"); - *events = POLLIN | POLLOUT; - RETURN (false); - } else { - TRACE ("%s", "Step#3 FAILED!"); - } - - break; - - case ssl_connect_done: - TRACE ("%s", "Connect DONE!"); - /* reset our connection state machine */ - secure_channel->connecting_state = ssl_connect_1; - RETURN (true); - break; - default: /* do nothing */ - break; - } - - *events = 0; - - if (error && !error->code) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "TLS handshake failed"); - } - - RETURN (false); -} - -static bool -_mongoc_stream_tls_secure_channel_timed_out (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - - ENTRY; - - RETURN (mongoc_stream_timed_out (tls->base_stream)); -} - -static bool -_mongoc_stream_tls_secure_channel_should_retry (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - - ENTRY; - - RETURN (mongoc_stream_should_retry (tls->base_stream)); -} - -mongoc_stream_t * -mongoc_stream_tls_secure_channel_new (mongoc_stream_t *base_stream, - const char *host, - mongoc_ssl_opt_t *opt, - int client) -{ - SECURITY_STATUS sspi_status = SEC_E_OK; - SCHANNEL_CRED schannel_cred; - mongoc_stream_tls_t *tls; - mongoc_stream_tls_secure_channel_t *secure_channel; - PCCERT_CONTEXT cert = NULL; - - ENTRY; - BSON_ASSERT (base_stream); - BSON_ASSERT (opt); - - - secure_channel = (mongoc_stream_tls_secure_channel_t *) bson_malloc0 ( - sizeof *secure_channel); - - secure_channel->decdata_buffer = - bson_malloc (MONGOC_SCHANNEL_BUFFER_INIT_SIZE); - secure_channel->decdata_length = MONGOC_SCHANNEL_BUFFER_INIT_SIZE; - secure_channel->encdata_buffer = - bson_malloc (MONGOC_SCHANNEL_BUFFER_INIT_SIZE); - secure_channel->encdata_length = MONGOC_SCHANNEL_BUFFER_INIT_SIZE; - - tls = (mongoc_stream_tls_t *) bson_malloc0 (sizeof *tls); - tls->parent.type = MONGOC_STREAM_TLS; - tls->parent.destroy = _mongoc_stream_tls_secure_channel_destroy; - tls->parent.failed = _mongoc_stream_tls_secure_channel_failed; - tls->parent.close = _mongoc_stream_tls_secure_channel_close; - tls->parent.flush = _mongoc_stream_tls_secure_channel_flush; - tls->parent.writev = _mongoc_stream_tls_secure_channel_writev; - tls->parent.readv = _mongoc_stream_tls_secure_channel_readv; - tls->parent.setsockopt = _mongoc_stream_tls_secure_channel_setsockopt; - tls->parent.get_base_stream = - _mongoc_stream_tls_secure_channel_get_base_stream; - tls->parent.check_closed = _mongoc_stream_tls_secure_channel_check_closed; - tls->parent.timed_out = _mongoc_stream_tls_secure_channel_timed_out; - tls->parent.should_retry = _mongoc_stream_tls_secure_channel_should_retry; - memcpy (&tls->ssl_opts, opt, sizeof tls->ssl_opts); - tls->handshake = mongoc_stream_tls_secure_channel_handshake; - tls->ctx = (void *) secure_channel; - tls->timeout_msec = -1; - tls->base_stream = base_stream; - - TRACE ("%s", "SSL/TLS connection with endpoint AcquireCredentialsHandle"); - - /* setup Schannel API options */ - memset (&schannel_cred, 0, sizeof (schannel_cred)); - schannel_cred.dwVersion = SCHANNEL_CRED_VERSION; - -/* SCHANNEL_CRED: - * SCH_USE_STRONG_CRYPTO is not available in VS2010 - * https://msdn.microsoft.com/en-us/library/windows/desktop/aa379810.aspx */ -#ifdef SCH_USE_STRONG_CRYPTO - schannel_cred.dwFlags = SCH_USE_STRONG_CRYPTO; -#endif - - /* By default, enable soft failing. - * A certificate with no revocation check is a soft failure. */ - schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK; - /* An offline OCSP responder / CRL distribution list is a soft failure. */ - schannel_cred.dwFlags |= SCH_CRED_IGNORE_REVOCATION_OFFLINE; - if (opt->weak_cert_validation) { - schannel_cred.dwFlags |= SCH_CRED_MANUAL_CRED_VALIDATION; - TRACE ("%s", "disabled server certificate checks"); - } else { - schannel_cred.dwFlags |= SCH_CRED_AUTO_CRED_VALIDATION; - if (!_mongoc_ssl_opts_disable_certificate_revocation_check (opt)) { - schannel_cred.dwFlags |= SCH_CRED_REVOCATION_CHECK_CHAIN; - TRACE ("%s", "enabled server certificate revocation checks"); - } - TRACE ("%s", "enabled server certificate checks"); - } - - if (opt->allow_invalid_hostname) { - schannel_cred.dwFlags |= SCH_CRED_NO_SERVERNAME_CHECK; - } - - if (opt->ca_file) { - mongoc_secure_channel_setup_ca (secure_channel, opt); - } - - if (opt->crl_file) { - mongoc_secure_channel_setup_crl (secure_channel, opt); - } - - if (opt->pem_file) { - cert = mongoc_secure_channel_setup_certificate (secure_channel, opt); - - if (cert) { - schannel_cred.cCreds = 1; - schannel_cred.paCred = &cert; - } - } - - - schannel_cred.grbitEnabledProtocols = - SP_PROT_TLS1_1_CLIENT | SP_PROT_TLS1_2_CLIENT; - - secure_channel->cred = (mongoc_secure_channel_cred *) bson_malloc0 ( - sizeof (mongoc_secure_channel_cred)); - - /* Example: - * https://msdn.microsoft.com/en-us/library/windows/desktop/aa375454%28v=vs.85%29.aspx - * AcquireCredentialsHandle: - * https://msdn.microsoft.com/en-us/library/windows/desktop/aa374716.aspx - */ - sspi_status = AcquireCredentialsHandle ( - NULL, /* principal */ - UNISP_NAME, /* security package */ - SECPKG_CRED_OUTBOUND, /* we are preparing outbound connection */ - NULL, /* Optional logon */ - &schannel_cred, /* TLS "configuration", "auth data" */ - NULL, /* unused */ - NULL, /* unused */ - &secure_channel->cred->cred_handle, /* credential OUT param */ - &secure_channel->cred->time_stamp); /* certificate expiration time */ - - if (sspi_status != SEC_E_OK) { - LPTSTR msg = NULL; - FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_ARGUMENT_ARRAY, - NULL, - GetLastError (), - LANG_NEUTRAL, - (LPTSTR) &msg, - 0, - NULL); - MONGOC_ERROR ( - "Failed to initialize security context, error code: 0x%04X%04X: '%s'", - (unsigned int) (sspi_status >> 16) & 0xffff, - (unsigned int) sspi_status & 0xffff, - msg); - LocalFree (msg); - RETURN (NULL); - } - - if (opt->ca_dir) { - MONGOC_ERROR ("Setting mongoc_ssl_opt_t.ca_dir has no effect when built " - "against Secure Channel"); - } - - if (_mongoc_ssl_opts_disable_ocsp_endpoint_check (opt)) { - MONGOC_ERROR ("Setting tlsDisableOCSPEndpointCheck has no effect when " - "built against Secure Channel"); - } - - mongoc_counter_streams_active_inc (); - RETURN ((mongoc_stream_t *) tls); -} -#endif /* MONGOC_ENABLE_SSL_SECURE_CHANNEL */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.c deleted file mode 100644 index f20ec6b08..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.c +++ /dev/null @@ -1,760 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SSL_SECURE_TRANSPORT - -#include -#include -#include - - -#include - -#include "mongoc-trace-private.h" -#include "mongoc-log.h" -#include "mongoc-secure-transport-private.h" -#include "mongoc-ssl.h" -#include "mongoc-ssl-private.h" -#include "mongoc-error.h" -#include "mongoc-counters-private.h" -#include "mongoc-stream-tls.h" -#include "mongoc-stream-tls-private.h" -#include "mongoc-stream-private.h" -#include "mongoc-stream-tls-secure-transport-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "stream-tls-secure_transport" - -static void -_mongoc_stream_tls_secure_transport_destroy (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_transport); - - SSLClose (secure_transport->ssl_ctx_ref); - CFRelease (secure_transport->ssl_ctx_ref); - secure_transport->ssl_ctx_ref = NULL; - - /* SSLClose will do IO so destroy must come after */ - mongoc_stream_destroy (tls->base_stream); - - if (secure_transport->anchors) { - CFRelease (secure_transport->anchors); - } - if (secure_transport->my_cert) { - CFRelease (secure_transport->my_cert); - } - bson_free (secure_transport); - bson_free (stream); - - mongoc_counter_streams_active_dec (); - mongoc_counter_streams_disposed_inc (); - EXIT; -} - -static void -_mongoc_stream_tls_secure_transport_failed (mongoc_stream_t *stream) -{ - ENTRY; - _mongoc_stream_tls_secure_transport_destroy (stream); - EXIT; -} - -static int -_mongoc_stream_tls_secure_transport_close (mongoc_stream_t *stream) -{ - int ret = 0; - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_transport); - - ret = mongoc_stream_close (tls->base_stream); - RETURN (ret); -} - -static int -_mongoc_stream_tls_secure_transport_flush (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_transport); - RETURN (0); -} - -static ssize_t -_mongoc_stream_tls_secure_transport_write (mongoc_stream_t *stream, - char *buf, - size_t buf_len) -{ - OSStatus status; - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - ssize_t write_ret; - int64_t now; - int64_t expire = 0; - - ENTRY; - BSON_ASSERT (secure_transport); - - if (tls->timeout_msec >= 0) { - expire = bson_get_monotonic_time () + (tls->timeout_msec * 1000UL); - } - - status = SSLWrite ( - secure_transport->ssl_ctx_ref, buf, buf_len, (size_t *) &write_ret); - - switch (status) { - case errSSLWouldBlock: - case noErr: - break; - - case errSSLClosedAbort: - errno = ECONNRESET; - - default: - RETURN (-1); - } - - if (expire) { - now = bson_get_monotonic_time (); - - if ((expire - now) < 0) { - if (write_ret < buf_len) { - mongoc_counter_streams_timeout_inc (); - } - - tls->timeout_msec = 0; - } else { - tls->timeout_msec = (expire - now) / 1000L; - } - } - - RETURN (write_ret); -} - -/* This is copypasta from _mongoc_stream_tls_openssl_writev */ -#define MONGOC_STREAM_TLS_BUFFER_SIZE 4096 -static ssize_t -_mongoc_stream_tls_secure_transport_writev (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - int32_t timeout_msec) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - char buf[MONGOC_STREAM_TLS_BUFFER_SIZE]; - ssize_t ret = 0; - ssize_t child_ret; - size_t i; - size_t iov_pos = 0; - - /* There's a bit of a dance to coalesce vectorized writes into - * MONGOC_STREAM_TLS_BUFFER_SIZE'd writes to avoid lots of small tls - * packets. - * - * The basic idea is that we want to combine writes in the buffer if they're - * smaller than the buffer, flushing as it gets full. For larger writes, or - * the last write in the iovec array, we want to ignore the buffer and just - * write immediately. We take care of doing buffer writes by re-invoking - * ourself with a single iovec_t, pointing at our stack buffer. - */ - char *buf_head = buf; - char *buf_tail = buf; - char *buf_end = buf + MONGOC_STREAM_TLS_BUFFER_SIZE; - size_t bytes; - - char *to_write = NULL; - size_t to_write_len; - - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - BSON_ASSERT (secure_transport); - ENTRY; - - tls->timeout_msec = timeout_msec; - - for (i = 0; i < iovcnt; i++) { - iov_pos = 0; - - while (iov_pos < iov[i].iov_len) { - if (buf_head != buf_tail || - ((i + 1 < iovcnt) && - ((buf_end - buf_tail) > (iov[i].iov_len - iov_pos)))) { - /* If we have either of: - * - buffered bytes already - * - another iovec to send after this one and we don't have more - * bytes to send than the size of the buffer. - * - * copy into the buffer */ - - bytes = BSON_MIN (iov[i].iov_len - iov_pos, buf_end - buf_tail); - - memcpy (buf_tail, (char *) iov[i].iov_base + iov_pos, bytes); - buf_tail += bytes; - iov_pos += bytes; - - if (buf_tail == buf_end) { - /* If we're full, request send */ - - to_write = buf_head; - to_write_len = buf_tail - buf_head; - - buf_tail = buf_head = buf; - } - } else { - /* Didn't buffer, so just write it through */ - - to_write = (char *) iov[i].iov_base + iov_pos; - to_write_len = iov[i].iov_len - iov_pos; - - iov_pos += to_write_len; - } - - if (to_write) { - /* We get here if we buffered some bytes and filled the buffer, or - * if we didn't buffer and have to send out of the iovec */ - - child_ret = _mongoc_stream_tls_secure_transport_write ( - stream, to_write, to_write_len); - - if (child_ret < 0) { - RETURN (ret); - } - - ret += child_ret; - - if (child_ret < to_write_len) { - /* we timed out, so send back what we could send */ - - RETURN (ret); - } - - to_write = NULL; - } - } - } - - if (buf_head != buf_tail) { - /* If we have any bytes buffered, send */ - - child_ret = _mongoc_stream_tls_secure_transport_write ( - stream, buf_head, buf_tail - buf_head); - - if (child_ret < 0) { - RETURN (child_ret); - } - - ret += child_ret; - } - - if (ret >= 0) { - mongoc_counter_streams_egress_add (ret); - } - - TRACE ("Returning %d", (int) ret); - RETURN (ret); -} - -/* This function is copypasta of _mongoc_stream_tls_openssl_readv */ -static ssize_t -_mongoc_stream_tls_secure_transport_readv (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - size_t min_bytes, - int32_t timeout_msec) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - ssize_t ret = 0; - size_t i; - size_t read_ret; - size_t iov_pos = 0; - int64_t now; - int64_t expire = 0; - size_t to_read; - size_t remaining_buf_size; - size_t remaining_to_read; - - BSON_ASSERT (iov); - BSON_ASSERT (iovcnt); - BSON_ASSERT (secure_transport); - ENTRY; - - tls->timeout_msec = timeout_msec; - - if (timeout_msec >= 0) { - expire = bson_get_monotonic_time () + (timeout_msec * 1000UL); - } - - for (i = 0; i < iovcnt; i++) { - iov_pos = 0; - - while (iov_pos < iov[i].iov_len) { - remaining_buf_size = iov[i].iov_len - iov_pos; - remaining_to_read = min_bytes - ret; - - /* The third argument passed to SSLRead is an all-or-nothing - dataLength, which it will attempt to read until it succeeds or - times out. If our buffer is larger than the message we expect - to read, choose the smaller number of the two. */ - if (remaining_to_read > 0 && remaining_to_read < remaining_buf_size) { - to_read = remaining_to_read; - } else { - to_read = remaining_buf_size; - } - - OSStatus status = SSLRead (secure_transport->ssl_ctx_ref, - (char *) iov[i].iov_base + iov_pos, - to_read, - &read_ret); - - if (status != noErr) { - RETURN (-1); - } - - if (expire) { - now = bson_get_monotonic_time (); - - if ((expire - now) < 0) { - if (read_ret == 0) { - mongoc_counter_streams_timeout_inc (); - errno = ETIMEDOUT; - RETURN (-1); - } - - tls->timeout_msec = 0; - } else { - tls->timeout_msec = (expire - now) / 1000L; - } - } - - ret += read_ret; - - if ((size_t) ret >= min_bytes) { - mongoc_counter_streams_ingress_add (ret); - RETURN (ret); - } - - iov_pos += read_ret; - } - } - - if (ret >= 0) { - mongoc_counter_streams_ingress_add (ret); - } - - RETURN (ret); -} - -static int -_mongoc_stream_tls_secure_transport_setsockopt (mongoc_stream_t *stream, - int level, - int optname, - void *optval, - mongoc_socklen_t optlen) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_transport); - RETURN (mongoc_stream_setsockopt ( - tls->base_stream, level, optname, optval, optlen)); -} - -static mongoc_stream_t * -_mongoc_stream_tls_secure_transport_get_base_stream (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_transport); - RETURN (tls->base_stream); -} - - -static bool -_mongoc_stream_tls_secure_transport_check_closed ( - mongoc_stream_t *stream) /* IN */ -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_transport); - RETURN (mongoc_stream_check_closed (tls->base_stream)); -} - -static void -_set_error_from_osstatus (OSStatus status, - const char *prefix, - bson_error_t *error) -{ - CFStringRef err; - char *err_str; - - err = SecCopyErrorMessageString (status, NULL); - err_str = _mongoc_cfstringref_to_cstring (err); - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "%s: %s (%d)", - prefix, - err_str, - status); - - bson_free (err_str); - CFRelease (err); -} - -/* Always returns a string that must be freed. */ -static char * -explain_trust_result (SecTrustRef trust, SecTrustResultType trust_result) -{ - bson_string_t *reason; - CFArrayRef cfprops = NULL; - CFIndex count, i; - - reason = bson_string_new (""); - switch (trust_result) { - case kSecTrustResultDeny: - bson_string_append (reason, "Certificate trust denied"); - break; - case kSecTrustResultRecoverableTrustFailure: - bson_string_append (reason, "Certificate trust failure"); - break; - case kSecTrustResultFatalTrustFailure: - bson_string_append (reason, "Certificate trust fatal failure"); - break; - case kSecTrustResultInvalid: - bson_string_append (reason, "Certificate trust evaluation failure"); - break; - default: - bson_string_append_printf ( - reason, "Certificate trust failure #%d", (int) trust_result); - break; - } - bson_string_append (reason, ": "); - - cfprops = SecTrustCopyProperties (trust); - /* This contains an array of dictionaries, each representing a cert in the - * chain. Append the first failure reason found. */ - if (!cfprops) { - bson_string_append (reason, "Unable to retreive cause for trust failure"); - goto done; - } - - count = CFArrayGetCount (cfprops); - for (i = 0; i < count; ++i) { - const void *elem = NULL; - const void *reason_elem = NULL; - char *reason_str; - CFDictionaryRef dict; - - elem = CFArrayGetValueAtIndex (cfprops, i); - if (CFGetTypeID (elem) != CFDictionaryGetTypeID ()) { - bson_string_append (reason, "Unable to parse cause for trust failure"); - goto done; - } - - dict = (CFDictionaryRef) elem; - reason_elem = CFDictionaryGetValue (dict, kSecPropertyTypeError); - if (!reason_elem) { - continue; - } - if (CFGetTypeID (reason_elem) != CFStringGetTypeID ()) { - bson_string_append (reason, "Unable to parse trust failure error"); - goto done; - } - reason_str = _mongoc_cfstringref_to_cstring (reason_elem); - if (reason_str) { - bson_string_append (reason, reason_str); - bson_free (reason_str); - goto done; - } else { - bson_string_append (reason, "Unable to express trust failure error"); - goto done; - } - } - - bson_string_append (reason, "No trust failure reason available"); -done: - CFReleaseSafe (cfprops); - return bson_string_free (reason, false); -} - -/* Returns a boolean indicating success. If false is returned, then an error is - * set. - */ -static bool -_verify_peer (mongoc_stream_t *stream, bson_error_t *error) -{ - CFArrayRef policies = NULL; - SecTrustRef trust = NULL; - OSStatus status; - CFMutableArrayRef policies_mutable = NULL; - SecPolicyRef rev_policy = NULL; - SecTrustResultType trust_result; - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - bool ret = false; - - status = SSLCopyPeerTrust (secure_transport->ssl_ctx_ref, &trust); - if (status != noErr) { - _set_error_from_osstatus ( - status, "Certificate validation errored", error); - goto fail; - } - - status = SecTrustCopyPolicies (trust, &policies); - - if (status != noErr) { - _set_error_from_osstatus ( - status, "Certificate validation errored", error); - goto fail; - } - - /* Add explicit OCSP revocation policy. */ - policies_mutable = CFArrayCreateMutableCopy (NULL, 0, policies); - - /* TODO: possibly disable endpoint checking by adding the flag - * kSecRevocationNetworkAccessDisabled once the option - * tlsDisableOCSPEndpointCheck is implemented. */ - rev_policy = SecPolicyCreateRevocation (kSecRevocationOCSPMethod); - CFArrayAppendValue (policies_mutable, rev_policy); - - status = SecTrustSetPolicies (trust, policies_mutable); - - if (status != noErr) { - _set_error_from_osstatus ( - status, "Certificate validation errored", error); - goto fail; - } - - /* TODO: SecTrustEvaluate is blocking. When making Secure Transport's - * handshake is made non-blocking in CDRIVER-2885, this will need to be - * addressed. */ - status = SecTrustEvaluate (trust, &trust_result); - if (status != noErr) { - _set_error_from_osstatus ( - status, "Certificate validation errored", error); - goto fail; - } - - if (trust_result != kSecTrustResultProceed && - trust_result != kSecTrustResultUnspecified) { - char *reason = explain_trust_result (trust, trust_result); - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "TLS handshake failed (%s)", - reason); - bson_free (reason); - goto fail; - } - - ret = true; -fail: - CFReleaseSafe (trust); - CFReleaseSafe (policies); - CFReleaseSafe (policies_mutable); - CFReleaseSafe (rev_policy); - return ret; -} - -bool -mongoc_stream_tls_secure_transport_handshake (mongoc_stream_t *stream, - const char *host, - int *events, - bson_error_t *error) -{ - OSStatus ret = 0; - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - mongoc_stream_tls_secure_transport_t *secure_transport = - (mongoc_stream_tls_secure_transport_t *) tls->ctx; - - ENTRY; - BSON_ASSERT (secure_transport); - - ret = SSLHandshake (secure_transport->ssl_ctx_ref); - - if (ret == errSSLServerAuthCompleted) { - if (!tls->ssl_opts.weak_cert_validation && - !_verify_peer (stream, error)) { - *events = 0; - RETURN (false); - } - ret = errSSLWouldBlock; - } - - if (ret == noErr) { - RETURN (true); - } - - if (ret == errSSLWouldBlock) { - *events = POLLIN | POLLOUT; - } else { - *events = 0; - _set_error_from_osstatus (ret, "TLS handshake failed", error); - } - - RETURN (false); -} - -static bool -_mongoc_stream_tls_secure_channel_timed_out (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - - ENTRY; - - RETURN (mongoc_stream_timed_out (tls->base_stream)); -} - -static bool -_mongoc_stream_tls_secure_channel_should_retry (mongoc_stream_t *stream) -{ - mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *) stream; - - ENTRY; - - RETURN (mongoc_stream_should_retry (tls->base_stream)); -} - -mongoc_stream_t * -mongoc_stream_tls_secure_transport_new (mongoc_stream_t *base_stream, - const char *host, - mongoc_ssl_opt_t *opt, - int client) -{ - mongoc_stream_tls_t *tls; - mongoc_stream_tls_secure_transport_t *secure_transport; - - ENTRY; - BSON_ASSERT (base_stream); - BSON_ASSERT (opt); - - if (opt->ca_dir) { - MONGOC_ERROR ("Setting mongoc_ssl_opt_t.ca_dir has no effect when built " - "against Secure Transport"); - RETURN (NULL); - } - if (opt->crl_file) { - MONGOC_ERROR ( - "Setting mongoc_ssl_opt_t.crl_file has no effect when built " - "against Secure Transport"); - RETURN (NULL); - } - - secure_transport = (mongoc_stream_tls_secure_transport_t *) bson_malloc0 ( - sizeof *secure_transport); - - tls = (mongoc_stream_tls_t *) bson_malloc0 (sizeof *tls); - tls->parent.type = MONGOC_STREAM_TLS; - tls->parent.destroy = _mongoc_stream_tls_secure_transport_destroy; - tls->parent.failed = _mongoc_stream_tls_secure_transport_failed; - tls->parent.close = _mongoc_stream_tls_secure_transport_close; - tls->parent.flush = _mongoc_stream_tls_secure_transport_flush; - tls->parent.writev = _mongoc_stream_tls_secure_transport_writev; - tls->parent.readv = _mongoc_stream_tls_secure_transport_readv; - tls->parent.setsockopt = _mongoc_stream_tls_secure_transport_setsockopt; - tls->parent.get_base_stream = - _mongoc_stream_tls_secure_transport_get_base_stream; - tls->parent.check_closed = _mongoc_stream_tls_secure_transport_check_closed; - tls->parent.timed_out = _mongoc_stream_tls_secure_channel_timed_out; - tls->parent.should_retry = _mongoc_stream_tls_secure_channel_should_retry; - memcpy (&tls->ssl_opts, opt, sizeof tls->ssl_opts); - tls->handshake = mongoc_stream_tls_secure_transport_handshake; - tls->ctx = (void *) secure_transport; - tls->timeout_msec = -1; - - secure_transport->ssl_ctx_ref = - SSLCreateContext (kCFAllocatorDefault, - client ? kSSLClientSide : kSSLServerSide, - kSSLStreamType); - - SSLSetIOFuncs (secure_transport->ssl_ctx_ref, - mongoc_secure_transport_read, - mongoc_secure_transport_write); - SSLSetProtocolVersionMin (secure_transport->ssl_ctx_ref, kTLSProtocol1); - - if (opt->pem_file && - !mongoc_secure_transport_setup_certificate (secure_transport, opt)) { - mongoc_stream_destroy ((mongoc_stream_t *) tls); - RETURN (NULL); - } - - if (opt->ca_file && - !mongoc_secure_transport_setup_ca (secure_transport, opt)) { - mongoc_stream_destroy ((mongoc_stream_t *) tls); - RETURN (NULL); - } - - /* don't link base_stream to tls until we're sure we won't destroy tls */ - tls->base_stream = base_stream; - - if (client) { - /* This option has SSL_Handshake stop before it verifies peer cert. Set - * this since we verify peer cert manually later. */ - SSLSetSessionOption (secure_transport->ssl_ctx_ref, - kSSLSessionOptionBreakOnServerAuth, - true); - } else if (!opt->allow_invalid_hostname) { - /* used only in mock_server_t tests */ - SSLSetClientSideAuthenticate (secure_transport->ssl_ctx_ref, - kAlwaysAuthenticate); - } - - if (!opt->allow_invalid_hostname) { - SSLSetPeerDomainName (secure_transport->ssl_ctx_ref, host, strlen (host)); - } - SSLSetConnection (secure_transport->ssl_ctx_ref, tls); - - - mongoc_counter_streams_active_inc (); - - if (_mongoc_ssl_opts_disable_certificate_revocation_check (opt)) { - MONGOC_ERROR ("Setting tlsDisableCertificateRevocationCheck has no " - "effect when built against Secure Transport"); - } - - if (_mongoc_ssl_opts_disable_ocsp_endpoint_check (opt)) { - MONGOC_ERROR ("Setting tlsDisableOCSPEndpointCheck has no effect when " - "built against Secure Transport"); - } - RETURN ((mongoc_stream_t *) tls); -} -#endif /* MONGOC_ENABLE_SSL_SECURE_TRANSPORT */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls.c deleted file mode 100644 index dcf9b4bd4..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#ifdef MONGOC_ENABLE_SSL - -#include -#include -#include - -#include "mongoc-log.h" -#include "mongoc-trace-private.h" -#include "mongoc-error.h" - -#include "mongoc-stream-tls-private.h" -#include "mongoc-stream-private.h" -#if defined(MONGOC_ENABLE_SSL_OPENSSL) -#include "mongoc-stream-tls-openssl.h" -#include "mongoc-openssl-private.h" -#elif defined(MONGOC_ENABLE_SSL_LIBRESSL) -#include "mongoc-libressl-private.h" -#include "mongoc-stream-tls-libressl.h" -#elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) -#include "mongoc-secure-transport-private.h" -#include "mongoc-stream-tls-secure-transport.h" -#elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) -#include "mongoc-secure-channel-private.h" -#include "mongoc-stream-tls-secure-channel.h" -#endif -#include "mongoc-stream-tls.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "stream-tls" - - -/** - * mongoc_stream_tls_handshake: - * - * Performs TLS handshake dance - */ -bool -mongoc_stream_tls_handshake (mongoc_stream_t *stream, - const char *host, - int32_t timeout_msec, - int *events, - bson_error_t *error) -{ - mongoc_stream_tls_t *stream_tls = - (mongoc_stream_tls_t *) mongoc_stream_get_tls_stream (stream); - - BSON_ASSERT (stream_tls); - BSON_ASSERT (stream_tls->handshake); - - stream_tls->timeout_msec = timeout_msec; - - return stream_tls->handshake (stream, host, events, error); -} - -bool -mongoc_stream_tls_handshake_block (mongoc_stream_t *stream, - const char *host, - int32_t timeout_msec, - bson_error_t *error) -{ - int events; - ssize_t ret = 0; - mongoc_stream_poll_t poller; - int64_t expire = 0; - - if (timeout_msec >= 0) { - expire = bson_get_monotonic_time () + (timeout_msec * 1000); - } - - /* - * error variables get re-used a lot. To prevent cross-contamination of error - * messages, and still be able to provide a generic failure message when - * mongoc_stream_tls_handshake fails without a specific reason, we need to - * init - * the error code to 0. - */ - if (error) { - error->code = 0; - } - do { - events = 0; - - if (mongoc_stream_tls_handshake ( - stream, host, timeout_msec, &events, error)) { - return true; - } - - if (events) { - poller.stream = stream; - poller.events = events; - poller.revents = 0; - - if (expire >= 0) { - const int64_t now = bson_get_monotonic_time (); - const int64_t remaining = expire - now; - if (remaining < 0) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "TLS handshake timed out."); - return false; - } else { - const int64_t msec = remaining / 1000; - BSON_ASSERT (bson_in_range_signed (int32_t, msec)); - timeout_msec = (int32_t) msec; - } - } - ret = mongoc_stream_poll (&poller, 1, timeout_msec); - } - } while (events && ret > 0); - - if (error && !error->code) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "TLS handshake failed."); - } - return false; -} -/** - * Deprecated. Was never supposed to be part of the public API. - * See mongoc_stream_tls_handshake. - */ -bool -mongoc_stream_tls_do_handshake (mongoc_stream_t *stream, int32_t timeout_msec) -{ - mongoc_stream_tls_t *stream_tls = - (mongoc_stream_tls_t *) mongoc_stream_get_tls_stream (stream); - - BSON_UNUSED (timeout_msec); - - BSON_ASSERT (stream_tls); - - MONGOC_ERROR ("This function doesn't do anything. Please call " - "mongoc_stream_tls_handshake()"); - return false; -} - - -/** - * Deprecated. Was never supposed to be part of the public API. - * See mongoc_stream_tls_handshake. - */ -bool -mongoc_stream_tls_check_cert (mongoc_stream_t *stream, const char *host) -{ - mongoc_stream_tls_t *stream_tls = - (mongoc_stream_tls_t *) mongoc_stream_get_tls_stream (stream); - - BSON_UNUSED (host); - - BSON_ASSERT (stream_tls); - - MONGOC_ERROR ("This function doesn't do anything. Please call " - "mongoc_stream_tls_handshake()"); - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_stream_tls_new_with_hostname -- - * - * Creates a new mongoc_stream_tls_t to communicate with a remote - * server using a TLS stream. - * - * @host the hostname we are connected to and to verify the - * server certificate against - * - * @base_stream should be a stream that will become owned by the - * resulting tls stream. It will be used for raw I/O. - * - * @trust_store_dir should be a path to the SSL cert db to use for - * verifying trust of the remote server. - * - * Returns: - * NULL on failure, otherwise a mongoc_stream_t. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -mongoc_stream_t * -mongoc_stream_tls_new_with_hostname (mongoc_stream_t *base_stream, - const char *host, - mongoc_ssl_opt_t *opt, - int client) -{ - BSON_ASSERT (base_stream); - - /* !client is only used for testing, - * when the streams are pretending to be the server */ - if (!client || opt->weak_cert_validation) { - opt->allow_invalid_hostname = true; - } - -#ifndef _WIN32 - /* Silly check for Unix Domain Sockets */ - if (!host || (host[0] == '/' && !access (host, F_OK))) { - opt->allow_invalid_hostname = true; - } -#endif - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) - return mongoc_stream_tls_openssl_new (base_stream, host, opt, client); -#elif defined(MONGOC_ENABLE_SSL_LIBRESSL) - return mongoc_stream_tls_libressl_new (base_stream, host, opt, client); -#elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) - return mongoc_stream_tls_secure_transport_new ( - base_stream, host, opt, client); -#elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) - return mongoc_stream_tls_secure_channel_new (base_stream, host, opt, client); -#else -#error "Don't know how to create TLS stream" -#endif -} - -mongoc_stream_t * -mongoc_stream_tls_new (mongoc_stream_t *base_stream, - mongoc_ssl_opt_t *opt, - int client) -{ - return mongoc_stream_tls_new_with_hostname (base_stream, NULL, opt, client); -} - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls.h deleted file mode 100644 index 3d41f3e65..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream-tls.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_STREAM_TLS_H -#define MONGOC_STREAM_TLS_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-ssl.h" -#include "mongoc-stream.h" - - -BSON_BEGIN_DECLS - -typedef struct _mongoc_stream_tls_t mongoc_stream_tls_t; - -MONGOC_EXPORT (bool) -mongoc_stream_tls_handshake (mongoc_stream_t *stream, - const char *host, - int32_t timeout_msec, - int *events, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_stream_tls_handshake_block (mongoc_stream_t *stream, - const char *host, - int32_t timeout_msec, - bson_error_t *error); -MONGOC_EXPORT (bool) -mongoc_stream_tls_do_handshake (mongoc_stream_t *stream, int32_t timeout_msec) - BSON_GNUC_DEPRECATED_FOR (mongoc_stream_tls_handshake); -MONGOC_EXPORT (bool) -mongoc_stream_tls_check_cert (mongoc_stream_t *stream, const char *host) - BSON_GNUC_DEPRECATED_FOR (mongoc_stream_tls_handshake); -MONGOC_EXPORT (mongoc_stream_t *) -mongoc_stream_tls_new_with_hostname (mongoc_stream_t *base_stream, - const char *host, - mongoc_ssl_opt_t *opt, - int client) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_stream_t *) -mongoc_stream_tls_new (mongoc_stream_t *base_stream, - mongoc_ssl_opt_t *opt, - int client) BSON_GNUC_WARN_UNUSED_RESULT - BSON_GNUC_DEPRECATED_FOR (mongoc_stream_tls_new_with_hostname); - - -BSON_END_DECLS - - -#endif /* MONGOC_STREAM_TLS_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream.c deleted file mode 100644 index 99a619fb7..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream.c +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - -#include "mongoc-array-private.h" -#include "mongoc-buffer-private.h" -#include "mongoc-error.h" -#include "mongoc-errno-private.h" -#include "mongoc-flags.h" -#include "mongoc-log.h" -#include "mongoc-opcode.h" -#include "mongoc-rpc-private.h" -#include "mongoc-stream.h" -#include "mongoc-stream-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-util-private.h" - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "stream" - -#ifndef MONGOC_DEFAULT_TIMEOUT_MSEC -#define MONGOC_DEFAULT_TIMEOUT_MSEC (60L * 60L * 1000L) -#endif - - -/** - * mongoc_stream_close: - * @stream: A mongoc_stream_t. - * - * Closes the underlying file-descriptor used by @stream. - * - * Returns: 0 on success, -1 on failure. - */ -int -mongoc_stream_close (mongoc_stream_t *stream) -{ - int ret; - - ENTRY; - - BSON_ASSERT_PARAM (stream); - - BSON_ASSERT (stream->close); - - ret = stream->close (stream); - - RETURN (ret); -} - - -/** - * mongoc_stream_failed: - * @stream: A mongoc_stream_t. - * - * Frees any resources referenced by @stream, including the memory allocation - * for @stream. - * This handler is called upon stream failure, such as network errors, invalid - * replies - * or replicaset reconfigures deleting the stream - */ -void -mongoc_stream_failed (mongoc_stream_t *stream) -{ - ENTRY; - - BSON_ASSERT_PARAM (stream); - - if (stream->failed) { - stream->failed (stream); - } else { - stream->destroy (stream); - } - - EXIT; -} - - -/** - * mongoc_stream_destroy: - * @stream: A mongoc_stream_t. - * - * Frees any resources referenced by @stream, including the memory allocation - * for @stream. - */ -void -mongoc_stream_destroy (mongoc_stream_t *stream) -{ - ENTRY; - - if (!stream) { - EXIT; - } - - BSON_ASSERT (stream->destroy); - - stream->destroy (stream); - - EXIT; -} - - -/** - * mongoc_stream_flush: - * @stream: A mongoc_stream_t. - * - * Flushes the data in the underlying stream to the transport. - * - * Returns: 0 on success, -1 on failure. - */ -int -mongoc_stream_flush (mongoc_stream_t *stream) -{ - BSON_ASSERT_PARAM (stream); - return stream->flush (stream); -} - - -/** - * mongoc_stream_writev: - * @stream: A mongoc_stream_t. - * @iov: An array of iovec to write to the stream. - * @iovcnt: The number of elements in @iov. - * - * Writes an array of iovec buffers to the underlying stream. - * - * Returns: the number of bytes written, or -1 upon failure. - */ -ssize_t -mongoc_stream_writev (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - int32_t timeout_msec) -{ - ssize_t ret; - - ENTRY; - - BSON_ASSERT_PARAM (stream); - BSON_ASSERT_PARAM (iov); - BSON_ASSERT (iovcnt); - - BSON_ASSERT (stream->writev); - - // CDRIVER-4781: for backward compatibility. - if (timeout_msec < 0) { - timeout_msec = MONGOC_DEFAULT_TIMEOUT_MSEC; - } - - DUMP_IOVEC (writev, iov, iovcnt); - ret = stream->writev (stream, iov, iovcnt, timeout_msec); - - RETURN (ret); -} - -/** - * mongoc_stream_write: - * @stream: A mongoc_stream_t. - * @buf: A buffer to write. - * @count: The number of bytes to write into @buf. - * - * Simplified access to mongoc_stream_writev(). Creates a single iovec - * with the buffer provided. - * - * Returns: -1 on failure, otherwise the number of bytes written. - */ -ssize_t -mongoc_stream_write (mongoc_stream_t *stream, - void *buf, - size_t count, - int32_t timeout_msec) -{ - mongoc_iovec_t iov; - ssize_t ret; - - ENTRY; - - BSON_ASSERT_PARAM (stream); - BSON_ASSERT_PARAM (buf); - - iov.iov_base = buf; - iov.iov_len = count; - - BSON_ASSERT (stream->writev); - - ret = mongoc_stream_writev (stream, &iov, 1, timeout_msec); - - RETURN (ret); -} - -/** - * mongoc_stream_readv: - * @stream: A mongoc_stream_t. - * @iov: An array of iovec containing the location and sizes to read. - * @iovcnt: the number of elements in @iov. - * @min_bytes: the minimum number of bytes to return, or -1. - * - * Reads into the various buffers pointed to by @iov and associated - * buffer lengths. - * - * If @min_bytes is specified, then at least min_bytes will be returned unless - * eof is encountered. This may result in ETIMEDOUT - * - * Returns: the number of bytes read or -1 on failure. - */ -ssize_t -mongoc_stream_readv (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - size_t min_bytes, - int32_t timeout_msec) -{ - ssize_t ret; - - ENTRY; - - BSON_ASSERT_PARAM (stream); - BSON_ASSERT_PARAM (iov); - BSON_ASSERT (iovcnt); - - BSON_ASSERT (stream->readv); - - ret = stream->readv (stream, iov, iovcnt, min_bytes, timeout_msec); - if (ret >= 0) { - DUMP_IOVEC (readv, iov, iovcnt); - } - - RETURN (ret); -} - - -/** - * mongoc_stream_read: - * @stream: A mongoc_stream_t. - * @buf: A buffer to write into. - * @count: The number of bytes to write into @buf. - * @min_bytes: The minimum number of bytes to receive - * - * Simplified access to mongoc_stream_readv(). Creates a single iovec - * with the buffer provided. - * - * If @min_bytes is specified, then at least min_bytes will be returned unless - * eof is encountered. This may result in ETIMEDOUT - * - * Returns: -1 on failure, otherwise the number of bytes read. - */ -ssize_t -mongoc_stream_read (mongoc_stream_t *stream, - void *buf, - size_t count, - size_t min_bytes, - int32_t timeout_msec) -{ - mongoc_iovec_t iov; - ssize_t ret; - - ENTRY; - - BSON_ASSERT_PARAM (stream); - BSON_ASSERT_PARAM (buf); - - iov.iov_base = buf; - iov.iov_len = count; - - BSON_ASSERT (stream->readv); - - ret = mongoc_stream_readv (stream, &iov, 1, min_bytes, timeout_msec); - - RETURN (ret); -} - - -int -mongoc_stream_setsockopt (mongoc_stream_t *stream, - int level, - int optname, - void *optval, - mongoc_socklen_t optlen) -{ - BSON_ASSERT_PARAM (stream); - - if (stream->setsockopt) { - return stream->setsockopt (stream, level, optname, optval, optlen); - } - - return 0; -} - - -mongoc_stream_t * -mongoc_stream_get_base_stream (mongoc_stream_t *stream) /* IN */ -{ - BSON_ASSERT_PARAM (stream); - - if (stream->get_base_stream) { - return stream->get_base_stream (stream); - } - - return stream; -} - - -mongoc_stream_t * -mongoc_stream_get_root_stream (mongoc_stream_t *stream) -{ - BSON_ASSERT_PARAM (stream); - - while (stream->get_base_stream) { - stream = stream->get_base_stream (stream); - } - - return stream; -} - -mongoc_stream_t * -mongoc_stream_get_tls_stream (mongoc_stream_t *stream) /* IN */ -{ - BSON_ASSERT_PARAM (stream); - - for (; stream && stream->type != MONGOC_STREAM_TLS; - stream = stream->get_base_stream (stream)) - ; - - return stream; -} - -ssize_t -mongoc_stream_poll (mongoc_stream_poll_t *streams, - size_t nstreams, - int32_t timeout) -{ - mongoc_stream_poll_t *poller = - (mongoc_stream_poll_t *) bson_malloc (sizeof (*poller) * nstreams); - - int last_type = 0; - ssize_t rval = -1; - - errno = 0; - - for (size_t i = 0u; i < nstreams; i++) { - poller[i].stream = mongoc_stream_get_root_stream (streams[i].stream); - poller[i].events = streams[i].events; - poller[i].revents = 0; - - if (i == 0u) { - last_type = poller[i].stream->type; - } else if (last_type != poller[i].stream->type) { - errno = EINVAL; - goto CLEANUP; - } - } - - if (!poller[0].stream->poll) { - errno = EINVAL; - goto CLEANUP; - } - - rval = poller[0].stream->poll (poller, nstreams, timeout); - - if (rval > 0) { - for (size_t i = 0u; i < nstreams; i++) { - streams[i].revents = poller[i].revents; - } - } - -CLEANUP: - bson_free (poller); - - return rval; -} - -bool -mongoc_stream_check_closed (mongoc_stream_t *stream) -{ - int ret; - - ENTRY; - - if (!stream) { - return true; - } - - ret = stream->check_closed (stream); - - RETURN (ret); -} - -bool -mongoc_stream_timed_out (mongoc_stream_t *stream) -{ - ENTRY; - - BSON_ASSERT_PARAM (stream); - - /* for e.g. a file stream there is no timed_out function */ - RETURN (stream->timed_out && stream->timed_out (stream)); -} - -bool -mongoc_stream_should_retry (mongoc_stream_t *stream) -{ - ENTRY; - - BSON_ASSERT_PARAM (stream); - - /* for e.g. a file stream there is no should_retry function */ - RETURN (stream->should_retry && stream->should_retry (stream)); -} - -bool -_mongoc_stream_writev_full (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - int64_t timeout_msec, - bson_error_t *error) -{ - size_t total_bytes = 0; - ssize_t r; - ENTRY; - - for (size_t i = 0u; i < iovcnt; i++) { - total_bytes += iov[i].iov_len; - } - - if (BSON_UNLIKELY (!bson_in_range_signed (int32_t, timeout_msec))) { - // CDRIVER-4589 - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "timeout_msec value %" PRId64 - " exceeds supported 32-bit range", - timeout_msec); - RETURN (false); - } - - r = mongoc_stream_writev (stream, iov, iovcnt, (int32_t) timeout_msec); - TRACE ("writev returned: %zd", r); - - if (r < 0) { - if (error) { - char buf[128]; - char *errstr; - - errstr = bson_strerror_r (errno, buf, sizeof (buf)); - - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failure during socket delivery: %s (%d)", - errstr, - errno); - } - - RETURN (false); - } - - if (bson_cmp_not_equal_su (r, total_bytes)) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failure to send all requested bytes (only sent: %" PRIu64 - "/%zu in %" PRId64 "ms) during socket delivery", - (uint64_t) r, - total_bytes, - timeout_msec); - - RETURN (false); - } - - RETURN (true); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream.h deleted file mode 100644 index 402fc5092..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-stream.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2013-2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_STREAM_H -#define MONGOC_STREAM_H - -#include "mongoc-macros.h" -#include "mongoc-iovec.h" -#include "mongoc-socket.h" - - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_stream_t mongoc_stream_t; - -typedef struct _mongoc_stream_poll_t { - mongoc_stream_t *stream; - int events; - int revents; -} mongoc_stream_poll_t; - -struct _mongoc_stream_t { - int type; - void (*destroy) (mongoc_stream_t *stream); - int (*close) (mongoc_stream_t *stream); - int (*flush) (mongoc_stream_t *stream); - ssize_t (*writev) (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - int32_t timeout_msec); - ssize_t (*readv) (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - size_t min_bytes, - int32_t timeout_msec); - int (*setsockopt) (mongoc_stream_t *stream, - int level, - int optname, - void *optval, - mongoc_socklen_t optlen); - mongoc_stream_t *(*get_base_stream) (mongoc_stream_t *stream); - bool (*check_closed) (mongoc_stream_t *stream); - ssize_t (*poll) (mongoc_stream_poll_t *streams, - size_t nstreams, - int32_t timeout); - void (*failed) (mongoc_stream_t *stream); - bool (*timed_out) (mongoc_stream_t *stream); - bool (*should_retry) (mongoc_stream_t *stream); - void *padding[3]; -}; - - -MONGOC_EXPORT (mongoc_stream_t *) -mongoc_stream_get_base_stream (mongoc_stream_t *stream); -MONGOC_EXPORT (mongoc_stream_t *) -mongoc_stream_get_tls_stream (mongoc_stream_t *stream); -MONGOC_EXPORT (int) -mongoc_stream_close (mongoc_stream_t *stream); -MONGOC_EXPORT (void) -mongoc_stream_destroy (mongoc_stream_t *stream); -MONGOC_EXPORT (void) -mongoc_stream_failed (mongoc_stream_t *stream); -MONGOC_EXPORT (int) -mongoc_stream_flush (mongoc_stream_t *stream); -MONGOC_EXPORT (ssize_t) -mongoc_stream_writev (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - int32_t timeout_msec); -MONGOC_EXPORT (ssize_t) -mongoc_stream_write (mongoc_stream_t *stream, - void *buf, - size_t count, - int32_t timeout_msec); -MONGOC_EXPORT (ssize_t) -mongoc_stream_readv (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - size_t min_bytes, - int32_t timeout_msec); -MONGOC_EXPORT (ssize_t) -mongoc_stream_read (mongoc_stream_t *stream, - void *buf, - size_t count, - size_t min_bytes, - int32_t timeout_msec); -MONGOC_EXPORT (int) -mongoc_stream_setsockopt (mongoc_stream_t *stream, - int level, - int optname, - void *optval, - mongoc_socklen_t optlen); -MONGOC_EXPORT (bool) -mongoc_stream_check_closed (mongoc_stream_t *stream); -MONGOC_EXPORT (bool) -mongoc_stream_timed_out (mongoc_stream_t *stream); -MONGOC_EXPORT (bool) -mongoc_stream_should_retry (mongoc_stream_t *stream); -MONGOC_EXPORT (ssize_t) -mongoc_stream_poll (mongoc_stream_poll_t *streams, - size_t nstreams, - int32_t timeout); - - -BSON_END_DECLS - - -#endif /* MONGOC_STREAM_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-background-monitoring-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-background-monitoring-private.h deleted file mode 100644 index bf441549c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-background-monitoring-private.h +++ /dev/null @@ -1,46 +0,0 @@ - -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_TOPOLOGY_BACKGROUND_MONITORING_PRIVATE_H -#define MONGOC_TOPOLOGY_BACKGROUND_MONITORING_PRIVATE_H - -#include "mongoc.h" -#include "mongoc-topology-private.h" - -/* Methods of mongoc_topology_t for managing background monitoring. */ - -void -_mongoc_topology_background_monitoring_start (mongoc_topology_t *topology); - -void -_mongoc_topology_background_monitoring_reconcile ( - mongoc_topology_t *topology, mongoc_topology_description_t *td); - -void -_mongoc_topology_background_monitoring_request_scan ( - mongoc_topology_t *topology); - -void -_mongoc_topology_background_monitoring_stop (mongoc_topology_t *topology); - -void -_mongoc_topology_background_monitoring_cancel_check ( - mongoc_topology_t *topology, uint32_t server_id); - -#endif /* MONGOC_TOPOLOGY_BACKGROUND_MONITORING_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description-apm-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description-apm-private.h deleted file mode 100644 index 9c914248f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description-apm-private.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_TOPOLOGY_DESCRIPTION_APM_PRIVATE_H -#define MONGOC_TOPOLOGY_DESCRIPTION_APM_PRIVATE_H - -#include -#include "mongoc-topology-description-private.h" - -/* Application Performance Monitoring for topology events, complies with the - * SDAM Monitoring Spec: - -https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring-monitoring.rst - - */ - -void -_mongoc_topology_description_monitor_server_opening ( - const mongoc_topology_description_t *td, mongoc_server_description_t *sd); - -void -_mongoc_topology_description_monitor_server_changed ( - const mongoc_topology_description_t *td, - const mongoc_server_description_t *prev_sd, - const mongoc_server_description_t *new_sd); - -void -_mongoc_topology_description_monitor_server_closed ( - const mongoc_topology_description_t *td, - const mongoc_server_description_t *sd); - -/* td is not const: we set its "opened" field here */ -void -_mongoc_topology_description_monitor_opening ( - mongoc_topology_description_t *td); - -void -_mongoc_topology_description_monitor_changed ( - const mongoc_topology_description_t *prev_td, - const mongoc_topology_description_t *new_td); - -void -_mongoc_topology_description_monitor_closed ( - const mongoc_topology_description_t *td); - -#endif /* MONGOC_TOPOLOGY_DESCRIPTION_APM_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description-apm.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description-apm.c deleted file mode 100644 index 318dac413..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description-apm.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-topology-description-apm-private.h" -#include "mongoc-server-description-private.h" - -/* Application Performance Monitoring for topology events, complies with the - * SDAM Monitoring Spec: - -https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring-monitoring.rst - - */ - -/* ServerOpeningEvent */ -void -_mongoc_topology_description_monitor_server_opening ( - const mongoc_topology_description_t *td, mongoc_server_description_t *sd) -{ - if (td->apm_callbacks.server_opening && !sd->opened) { - mongoc_apm_server_opening_t event; - - bson_oid_copy (&td->topology_id, &event.topology_id); - event.host = &sd->host; - event.context = td->apm_context; - sd->opened = true; - td->apm_callbacks.server_opening (&event); - } -} - -/* ServerDescriptionChangedEvent */ -void -_mongoc_topology_description_monitor_server_changed ( - const mongoc_topology_description_t *td, - const mongoc_server_description_t *prev_sd, - const mongoc_server_description_t *new_sd) -{ - if (td->apm_callbacks.server_changed) { - mongoc_apm_server_changed_t event; - - /* address is same in previous and new sd */ - bson_oid_copy (&td->topology_id, &event.topology_id); - event.host = &new_sd->host; - event.previous_description = prev_sd; - event.new_description = new_sd; - event.context = td->apm_context; - td->apm_callbacks.server_changed (&event); - } -} - -/* ServerClosedEvent */ -void -_mongoc_topology_description_monitor_server_closed ( - const mongoc_topology_description_t *td, - const mongoc_server_description_t *sd) -{ - if (td->apm_callbacks.server_closed) { - mongoc_apm_server_closed_t event; - - bson_oid_copy (&td->topology_id, &event.topology_id); - event.host = &sd->host; - event.context = td->apm_context; - td->apm_callbacks.server_closed (&event); - } -} - - -/* Send TopologyOpeningEvent when first called on this topology description. - * td is not const: we set its "opened" field here */ -void -_mongoc_topology_description_monitor_opening (mongoc_topology_description_t *td) -{ - mongoc_topology_description_t *prev_td = NULL; - mongoc_server_description_t *sd; - - if (td->opened) { - return; - } - - if (td->apm_callbacks.topology_changed) { - /* prepare to call monitor_changed */ - prev_td = BSON_ALIGNED_ALLOC0 (mongoc_topology_description_t); - mongoc_topology_description_init (prev_td, td->heartbeat_msec); - } - - td->opened = true; - - if (td->apm_callbacks.topology_opening) { - mongoc_apm_topology_opening_t event; - - bson_oid_copy (&td->topology_id, &event.topology_id); - event.context = td->apm_context; - td->apm_callbacks.topology_opening (&event); - } - - if (td->apm_callbacks.topology_changed) { - /* send initial description-changed event */ - _mongoc_topology_description_monitor_changed (prev_td, td); - } - - for (size_t i = 0u; i < mc_tpld_servers (td)->items_len; i++) { - sd = mongoc_set_get_item (mc_tpld_servers (td), i); - _mongoc_topology_description_monitor_server_opening (td, sd); - } - - /* If this is a load balanced topology: - * - update the one server description to be LoadBalancer - * - emit a server changed event Unknown => LoadBalancer - * - emit a topology changed event - */ - if (td->type == MONGOC_TOPOLOGY_LOAD_BALANCED) { - mongoc_server_description_t *prev_sd; - - /* LoadBalanced deployments must have exactly one host listed. Otherwise, - * an error would have occurred when constructing the topology. */ - BSON_ASSERT (mc_tpld_servers (td)->items_len == 1); - sd = mongoc_set_get_item (mc_tpld_servers (td), 0); - prev_sd = mongoc_server_description_new_copy (sd); - BSON_ASSERT (prev_sd); - if (td->apm_callbacks.topology_changed) { - mongoc_topology_description_cleanup (prev_td); - _mongoc_topology_description_copy_to (td, prev_td); - } - sd->type = MONGOC_SERVER_LOAD_BALANCER; - _mongoc_topology_description_monitor_server_changed (td, prev_sd, sd); - mongoc_server_description_destroy (prev_sd); - if (td->apm_callbacks.topology_changed) { - _mongoc_topology_description_monitor_changed (prev_td, td); - } - } - - if (prev_td) { - mongoc_topology_description_cleanup (prev_td); - bson_free (prev_td); - } -} - -/* TopologyDescriptionChangedEvent */ -void -_mongoc_topology_description_monitor_changed ( - const mongoc_topology_description_t *prev_td, - const mongoc_topology_description_t *new_td) -{ - if (new_td->apm_callbacks.topology_changed) { - mongoc_apm_topology_changed_t event; - - /* callbacks, context, and id are the same in previous and new td */ - bson_oid_copy (&new_td->topology_id, &event.topology_id); - event.context = new_td->apm_context; - event.previous_description = prev_td; - event.new_description = new_td; - - new_td->apm_callbacks.topology_changed (&event); - } -} - -/* TopologyClosedEvent */ -void -_mongoc_topology_description_monitor_closed ( - const mongoc_topology_description_t *td) -{ - if (td->apm_callbacks.topology_closed) { - mongoc_apm_topology_closed_t event; - - if (td->type == MONGOC_TOPOLOGY_LOAD_BALANCED) { - const mongoc_server_description_t *sd; - - /* LoadBalanced deployments must have exactly one host listed. */ - BSON_ASSERT (mc_tpld_servers_const (td)->items_len == 1); - sd = mongoc_set_get_item_const (mc_tpld_servers_const (td), 0); - _mongoc_topology_description_monitor_server_closed (td, sd); - } - bson_oid_copy (&td->topology_id, &event.topology_id); - event.context = td->apm_context; - td->apm_callbacks.topology_closed (&event); - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description-private.h deleted file mode 100644 index edafc7695..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description-private.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_TOPOLOGY_DESCRIPTION_PRIVATE_H -#define MONGOC_TOPOLOGY_DESCRIPTION_PRIVATE_H - -#include "mongoc-set-private.h" -#include "mongoc-server-description.h" -#include "mongoc-array-private.h" -#include "mongoc-topology-description.h" -#include "mongoc-apm-private.h" -#include "mongoc-deprioritized-servers-private.h" - - -typedef enum { - MONGOC_TOPOLOGY_UNKNOWN, - MONGOC_TOPOLOGY_SHARDED, - MONGOC_TOPOLOGY_RS_NO_PRIMARY, - MONGOC_TOPOLOGY_RS_WITH_PRIMARY, - MONGOC_TOPOLOGY_SINGLE, - MONGOC_TOPOLOGY_LOAD_BALANCED, - MONGOC_TOPOLOGY_DESCRIPTION_TYPES -} mongoc_topology_description_type_t; - -struct _mongoc_topology_description_t { - bson_oid_t topology_id; - bool opened; - mongoc_topology_description_type_t type; - int64_t heartbeat_msec; - mongoc_set_t *_servers_; - char *set_name; - int64_t max_set_version; - bson_oid_t max_election_id; - bson_error_t compatibility_error; - uint32_t max_server_id; - int32_t max_hosts; /* srvMaxHosts */ - bool stale; - unsigned int rand_seed; - - /* the greatest seen cluster time, for a MongoDB 3.6+ sharded cluster. - * see Driver Sessions Spec. */ - bson_t cluster_time; - - /* smallest seen logicalSessionTimeoutMinutes, or -1 if any server has no - * logicalSessionTimeoutMinutes. see Server Discovery and Monitoring Spec */ - int64_t session_timeout_minutes; - - mongoc_apm_callbacks_t apm_callbacks; - void *apm_context; -}; - -typedef enum { - MONGOC_SS_READ, - MONGOC_SS_WRITE, - MONGOC_SS_AGGREGATE_WITH_WRITE -} mongoc_ss_optype_t; - -void -mongoc_topology_description_init (mongoc_topology_description_t *description, - int64_t heartbeat_msec); - - -/** - * @brief Get a pointer to the set of server descriptions in the topology - * description. - */ -static BSON_INLINE mongoc_set_t * -mc_tpld_servers (mongoc_topology_description_t *tpld) -{ - BSON_ASSERT_PARAM (tpld); - return tpld->_servers_; -} - -static BSON_INLINE const mongoc_set_t * -mc_tpld_servers_const (const mongoc_topology_description_t *tpld) -{ - BSON_ASSERT_PARAM (tpld); - return tpld->_servers_; -} - -void -_mongoc_topology_description_copy_to (const mongoc_topology_description_t *src, - mongoc_topology_description_t *dst); - -void -mongoc_topology_description_cleanup ( - mongoc_topology_description_t *description); - -void -mongoc_topology_description_handle_hello ( - mongoc_topology_description_t *topology, - uint32_t server_id, - const bson_t *hello_response, - int64_t rtt_msec, - const bson_error_t *error /* IN */); - -mongoc_server_description_t const * -mongoc_topology_description_select ( - const mongoc_topology_description_t *description, - mongoc_ss_optype_t optype, - const mongoc_read_prefs_t *read_pref, - bool *must_use_primary, - const mongoc_deprioritized_servers_t *ds, - int64_t local_threshold_ms); - -mongoc_server_description_t * -mongoc_topology_description_server_by_id ( - mongoc_topology_description_t *description, - uint32_t id, - bson_error_t *error); - -const mongoc_server_description_t * -mongoc_topology_description_server_by_id_const ( - const mongoc_topology_description_t *description, - uint32_t id, - bson_error_t *error); - -int32_t -mongoc_topology_description_lowest_max_wire_version ( - const mongoc_topology_description_t *td); - -bool -mongoc_topology_description_all_sds_have_write_date ( - const mongoc_topology_description_t *td); - -bool -_mongoc_topology_description_validate_max_staleness ( - const mongoc_topology_description_t *td, - int64_t max_staleness_seconds, - bson_error_t *error); - -void -mongoc_topology_description_suitable_servers ( - mongoc_array_t *set, /* OUT */ - mongoc_ss_optype_t optype, - const mongoc_topology_description_t *topology, - const mongoc_read_prefs_t *read_pref, - bool *must_use_primary, - const mongoc_deprioritized_servers_t *ds, - int64_t local_threshold_ms); - -bool -mongoc_topology_description_has_data_node ( - const mongoc_topology_description_t *td); - -void -mongoc_topology_description_invalidate_server ( - mongoc_topology_description_t *topology, - uint32_t id, - const bson_error_t *error /* IN */); - -bool -mongoc_topology_description_add_server (mongoc_topology_description_t *topology, - const char *server, - uint32_t *id /* OUT */); - -void -mongoc_topology_description_update_cluster_time ( - mongoc_topology_description_t *td, const bson_t *reply); - -void -mongoc_topology_description_reconcile (mongoc_topology_description_t *td, - mongoc_host_list_t *host_list); - -/** - * @brief Invalidate open connnections to a server. - * - * Pooled clients with open connections will discover the invalidation - * the next time they fetch a stream to the server. - * - * @param td The topology description that will be updated. - * @param server_id The ID of the server to invalidate. - * @param service_id A service ID for load-balanced deployments. Use - * kZeroServiceID if not applicable. - * - * @note Not applicable to single-threaded clients, which only maintain a - * single connection per server and therefore have no connection pool. - */ -void -_mongoc_topology_description_clear_connection_pool ( - mongoc_topology_description_t *td, - uint32_t server_id, - const bson_oid_t *service_id); - -void -mongoc_deprioritized_servers_add_if_sharded ( - mongoc_deprioritized_servers_t *ds, - mongoc_topology_description_type_t topology_type, - const mongoc_server_description_t *sd); - -#endif /* MONGOC_TOPOLOGY_DESCRIPTION_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description.c deleted file mode 100644 index fb885d694..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ /dev/null @@ -1,2713 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-array-private.h" -#include "mongoc-error.h" -#include "mongoc-server-description-private.h" -#include "mongoc-topology-description-apm-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-util-private.h" -#include "mongoc-read-prefs-private.h" -#include "mongoc-set-private.h" -#include "mongoc-client-private.h" -#include "mongoc-thread-private.h" -#include "mongoc-host-list-private.h" -#include "utlist.h" - - -static bool -_is_data_node (const mongoc_server_description_t *sd) -{ - switch (sd->type) { - case MONGOC_SERVER_MONGOS: - case MONGOC_SERVER_STANDALONE: - case MONGOC_SERVER_RS_SECONDARY: - case MONGOC_SERVER_RS_PRIMARY: - case MONGOC_SERVER_LOAD_BALANCER: - return true; - case MONGOC_SERVER_RS_OTHER: - case MONGOC_SERVER_RS_ARBITER: - case MONGOC_SERVER_UNKNOWN: - case MONGOC_SERVER_POSSIBLE_PRIMARY: - case MONGOC_SERVER_RS_GHOST: - case MONGOC_SERVER_DESCRIPTION_TYPES: - default: - return false; - } -} - - -static void -_mongoc_topology_server_dtor (void *server_, void *ctx_) -{ - BSON_UNUSED (ctx_); - - mongoc_server_description_destroy ((mongoc_server_description_t *) server_); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_init -- - * - * Initialize the given topology description - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_topology_description_init (mongoc_topology_description_t *description, - int64_t heartbeat_msec) -{ - ENTRY; - - BSON_ASSERT (description); - - memset (description, 0, sizeof (*description)); - - bson_oid_init (&description->topology_id, NULL); - description->opened = false; - description->type = MONGOC_TOPOLOGY_UNKNOWN; - description->heartbeat_msec = heartbeat_msec; - description->_servers_ = - mongoc_set_new (8, _mongoc_topology_server_dtor, NULL); - description->set_name = NULL; - description->max_set_version = MONGOC_NO_SET_VERSION; - description->stale = true; - description->rand_seed = (unsigned int) bson_get_monotonic_time (); - bson_init (&description->cluster_time); - description->session_timeout_minutes = MONGOC_NO_SESSIONS; - - EXIT; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_copy_to -- - * - * Deep-copy @src to an uninitialized topology description @dst. - * @dst must not already point to any allocated resources. Clean - * up with mongoc_topology_description_cleanup. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -void -_mongoc_topology_description_copy_to (const mongoc_topology_description_t *src, - mongoc_topology_description_t *dst) -{ - size_t nitems; - const mongoc_server_description_t *sd; - uint32_t id; - - ENTRY; - - BSON_ASSERT (src); - BSON_ASSERT (dst); - - bson_oid_copy (&src->topology_id, &dst->topology_id); - bson_oid_copy (&src->max_election_id, &dst->max_election_id); - dst->opened = src->opened; - dst->type = src->type; - dst->heartbeat_msec = src->heartbeat_msec; - dst->rand_seed = src->rand_seed; - - nitems = bson_next_power_of_two (mc_tpld_servers_const (src)->items_len); - dst->_servers_ = mongoc_set_new (nitems, _mongoc_topology_server_dtor, NULL); - for (size_t i = 0u; i < mc_tpld_servers_const (src)->items_len; i++) { - sd = - mongoc_set_get_item_and_id_const (mc_tpld_servers_const (src), i, &id); - mongoc_set_add ( - mc_tpld_servers (dst), id, mongoc_server_description_new_copy (sd)); - } - - dst->set_name = bson_strdup (src->set_name); - dst->max_set_version = src->max_set_version; - memcpy (&dst->compatibility_error, - &src->compatibility_error, - sizeof (bson_error_t)); - dst->max_server_id = src->max_server_id; - dst->max_hosts = src->max_hosts; - dst->stale = src->stale; - memcpy (&dst->apm_callbacks, - &src->apm_callbacks, - sizeof (mongoc_apm_callbacks_t)); - - dst->apm_context = src->apm_context; - - bson_copy_to (&src->cluster_time, &dst->cluster_time); - - dst->session_timeout_minutes = src->session_timeout_minutes; - - EXIT; -} - -/* - *------------------------------------------------------------------------- - * - * mongoc_topology_description_new_copy -- - * - * Allocates a new topology description and deep-copies @description to it - * using _mongoc_topology_description_copy_to. - * - * Returns: - * A copy of a topology description that you must destroy with - * mongoc_topology_description_destroy, or NULL if @description is NULL. - * - * Side effects: - * None. - * - *------------------------------------------------------------------------- - */ -mongoc_topology_description_t * -mongoc_topology_description_new_copy ( - const mongoc_topology_description_t *description) -{ - mongoc_topology_description_t *copy; - - if (!description) { - return NULL; - } - - copy = BSON_ALIGNED_ALLOC0 (mongoc_topology_description_t); - - _mongoc_topology_description_copy_to (description, copy); - - return copy; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_cleanup -- - * - * Destroy allocated resources within @description but don't free it. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_topology_description_cleanup (mongoc_topology_description_t *description) -{ - ENTRY; - - BSON_ASSERT (description); - - if (mc_tpld_servers (description)) { - mongoc_set_destroy (mc_tpld_servers (description)); - } - - if (description->set_name) { - bson_free (description->set_name); - } - - bson_destroy (&description->cluster_time); - - EXIT; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_destroy -- - * - * Destroy allocated resources within @description and free - * @description. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -void -mongoc_topology_description_destroy (mongoc_topology_description_t *description) -{ - ENTRY; - - if (!description) { - EXIT; - } - - mongoc_topology_description_cleanup (description); - bson_free (description); - - EXIT; -} - -/* find the primary, then stop iterating */ -static bool -_mongoc_topology_description_has_primary_cb (const void *item, - void *ctx /* OUT */) -{ - const mongoc_server_description_t *server = item; - const mongoc_server_description_t **primary = ctx; - - /* TODO should this include MONGOS? */ - if (server->type == MONGOC_SERVER_RS_PRIMARY || - server->type == MONGOC_SERVER_STANDALONE) { - *primary = (mongoc_server_description_t *) item; - return false; - } - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_has_primary -- - * - * If topology has a primary, return it. - * - * Returns: - * A pointer to the primary, or NULL. - * - * Side effects: - * None - * - *-------------------------------------------------------------------------- - */ -static const mongoc_server_description_t * -_mongoc_topology_description_has_primary ( - const mongoc_topology_description_t *description) -{ - mongoc_server_description_t *primary = NULL; - - mongoc_set_for_each_const (mc_tpld_servers_const (description), - _mongoc_topology_description_has_primary_cb, - &primary); - - return primary; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_server_description_primary_is_not_stale -- - * - * Checks if a primary server is not stale by comparing the electionId and - * setVersion. - * - * Returns: - * True if the server's electionId is larger or the server's version is - * later than the topology max version. - * - * Side effects: - * None - * - *-------------------------------------------------------------------------- - */ -static bool -_mongoc_server_description_primary_is_not_stale ( - mongoc_topology_description_t *td, const mongoc_server_description_t *sd) -{ - /* initially max_set_version is -1 and max_election_id is zeroed */ - return (bson_oid_compare (&sd->election_id, &td->max_election_id) > 0) || - ((bson_oid_compare (&sd->election_id, &td->max_election_id) == 0) && - sd->set_version >= td->max_set_version); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_later_election -- - * - * Check if we've seen a more recent election in the replica set - * than this server has. - * - * Returns: - * True if the topology description's max replica set version plus - * election id is later than the server description's. - * - * Side effects: - * None - * - *-------------------------------------------------------------------------- - */ -static bool -_mongoc_topology_description_later_election ( - mongoc_topology_description_t *td, const mongoc_server_description_t *sd) -{ - /* initially max_set_version is -1 and max_election_id is zeroed */ - return td->max_set_version > sd->set_version || - (td->max_set_version == sd->set_version && - bson_oid_compare (&td->max_election_id, &sd->election_id) > 0); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_set_max_set_version -- - * - * Remember that we've seen a new replica set version. Unconditionally - * sets td->set_version to sd->set_version. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_set_max_set_version ( - mongoc_topology_description_t *td, const mongoc_server_description_t *sd) -{ - td->max_set_version = sd->set_version; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_set_max_election_id -- - * - * Remember that we've seen a new election id. Unconditionally sets - * td->max_election_id to sd->election_id. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_set_max_election_id ( - mongoc_topology_description_t *td, const mongoc_server_description_t *sd) -{ - bson_oid_copy (&sd->election_id, &td->max_election_id); -} - -static bool -_mongoc_topology_description_server_is_candidate ( - mongoc_server_description_type_t desc_type, - mongoc_read_mode_t read_mode, - mongoc_topology_description_type_t topology_type) -{ - switch ((int) topology_type) { - case MONGOC_TOPOLOGY_SINGLE: - switch ((int) desc_type) { - case MONGOC_SERVER_STANDALONE: - return true; - default: - return false; - } - - case MONGOC_TOPOLOGY_RS_NO_PRIMARY: - case MONGOC_TOPOLOGY_RS_WITH_PRIMARY: - switch ((int) read_mode) { - case MONGOC_READ_PRIMARY: - switch ((int) desc_type) { - case MONGOC_SERVER_RS_PRIMARY: - return true; - default: - return false; - } - case MONGOC_READ_SECONDARY: - switch ((int) desc_type) { - case MONGOC_SERVER_RS_SECONDARY: - return true; - default: - return false; - } - default: - switch ((int) desc_type) { - case MONGOC_SERVER_RS_PRIMARY: - case MONGOC_SERVER_RS_SECONDARY: - return true; - default: - return false; - } - } - - case MONGOC_TOPOLOGY_SHARDED: - switch ((int) desc_type) { - case MONGOC_SERVER_MONGOS: - return true; - default: - return false; - } - - /* Note, there is no call path that leads to the - * MONGOC_TOPOLOGY_LOAD_BALANCED case. Server selection for load balanced - * topologies bypasses this logic. This silences compiler warnings on - * unhandled enum values. */ - case MONGOC_TOPOLOGY_LOAD_BALANCED: - return desc_type == MONGOC_SERVER_LOAD_BALANCER; - - default: - return false; - } -} - -typedef struct _mongoc_suitable_data_t { - mongoc_read_mode_t read_mode; - mongoc_topology_description_type_t topology_type; - const mongoc_server_description_t *primary; /* OUT */ - const mongoc_server_description_t **candidates; /* OUT */ - size_t candidates_len; /* OUT */ - bool has_secondary; /* OUT */ -} mongoc_suitable_data_t; - -static bool -_mongoc_replica_set_read_suitable_cb (const void *item, void *ctx) -{ - const mongoc_server_description_t *server = item; - mongoc_suitable_data_t *data = (mongoc_suitable_data_t *) ctx; - - /* primary's used in staleness calculation, even with mode SECONDARY */ - if (server->type == MONGOC_SERVER_RS_PRIMARY) { - data->primary = server; - } - - if (_mongoc_topology_description_server_is_candidate ( - server->type, data->read_mode, data->topology_type)) { - if (server->type == MONGOC_SERVER_RS_PRIMARY) { - if (data->read_mode == MONGOC_READ_PRIMARY || - data->read_mode == MONGOC_READ_PRIMARY_PREFERRED) { - /* we want a primary and we have one, done! */ - return false; - } - } - - if (server->type == MONGOC_SERVER_RS_SECONDARY) { - data->has_secondary = true; - } - - /* add to our candidates */ - data->candidates[data->candidates_len++] = server; - } else { - TRACE ("Rejected [%s] [%s] for mode [%s]", - mongoc_server_description_type (server), - server->host.host_and_port, - _mongoc_read_mode_as_str (data->read_mode)); - } - - return true; -} - - -/* if any mongos are candidates, add them to the candidates array */ -static void -_mongoc_try_mode_secondary (mongoc_array_t *set, /* OUT */ - const mongoc_topology_description_t *topology, - const mongoc_read_prefs_t *read_pref, - bool *must_use_primary, - const mongoc_deprioritized_servers_t *ds, - int64_t local_threshold_ms) -{ - mongoc_read_prefs_t *secondary; - - secondary = mongoc_read_prefs_copy (read_pref); - mongoc_read_prefs_set_mode (secondary, MONGOC_READ_SECONDARY); - - mongoc_topology_description_suitable_servers (set, - MONGOC_SS_READ, - topology, - secondary, - must_use_primary, - ds, - local_threshold_ms); - - mongoc_read_prefs_destroy (secondary); -} - - -static bool -_mongoc_td_servers_to_candidates_array (const void *item, void *ctx) -{ - BSON_ASSERT_PARAM (item); - BSON_ASSERT_PARAM (ctx); - - const mongoc_server_description_t *const server = item; - mongoc_suitable_data_t *const data = (mongoc_suitable_data_t *) ctx; - - data->candidates[data->candidates_len++] = server; - - return true; -} - -// Server Selection Spec: If a list of deprioritized servers is provided, and -// the topology is a sharded cluster, these servers should be selected only if -// there are no other suitable servers. The server selection algorithm MUST -// ignore the deprioritized servers if the topology is not a sharded cluster. -static void -_mongoc_filter_deprioritized_servers (mongoc_suitable_data_t *data, - const mongoc_deprioritized_servers_t *ds) -{ - BSON_ASSERT_PARAM (data); - BSON_ASSERT_PARAM (ds); - - TRACE ("%s", "deprioritization: filtering list of candidates"); - - mongoc_array_t filtered_servers; - _mongoc_array_init (&filtered_servers, - sizeof (const mongoc_server_description_t *)); - - for (size_t idx = 0u; idx < data->candidates_len; ++idx) { - mongoc_server_description_t const *const sd = data->candidates[idx]; - - if (!mongoc_deprioritized_servers_contains (ds, sd)) { - TRACE ("deprioritization: - kept: %s (id: %" PRIu32 ")", - sd->host.host_and_port, - sd->id); - _mongoc_array_append_val (&filtered_servers, sd); - } else { - TRACE ("deprioritization: - removed: %s (id: %" PRIu32 ")", - sd->host.host_and_port, - sd->id); - } - } - - if (filtered_servers.len == 0u) { - TRACE ("%s", - "deprioritization: reverted due to no other suitable servers"); - _mongoc_array_destroy (&filtered_servers); - } else if (filtered_servers.len == data->candidates_len) { - TRACE ("%s", "deprioritization: none found in list of candidates"); - _mongoc_array_destroy (&filtered_servers); - } else { - TRACE ("%s", "deprioritization: using filtered list of candidates"); - data->candidates_len = filtered_servers.len; - // `(void*)`: avoid MSVC error C4090: - // 'function': different 'const' qualifiers - memmove ((void *) data->candidates, - filtered_servers.data, - filtered_servers.len * filtered_servers.element_size); - _mongoc_array_destroy (&filtered_servers); - } -} - - -// Keep only suitable mongoses in the candidates array. -static void -_mongoc_filter_suitable_mongos (mongoc_suitable_data_t *data) -{ - size_t idx = 0u; - - while (idx < data->candidates_len) { - if (_mongoc_topology_description_server_is_candidate ( - data->candidates[idx]->type, - data->read_mode, - data->topology_type)) { - // All candidates in the latency window are suitable. - ++idx; - } else { - // Remove from list using swap+pop. - // Order doesn't matter; the list will be randomized in - // mongoc_topology_description_select prior to server selection. - data->candidates[idx] = data->candidates[--data->candidates_len]; - } - } -} - - -/* - *------------------------------------------------------------------------- - * - * mongoc_topology_description_lowest_max_wire_version -- - * - * The topology's max wire version. - * - * Returns: - * The minimum of all known servers' max wire versions, or INT32_MAX - * if there are no known servers. - * - * Side effects: - * None. - * - *------------------------------------------------------------------------- - */ -int32_t -mongoc_topology_description_lowest_max_wire_version ( - const mongoc_topology_description_t *td) -{ - int32_t ret = INT32_MAX; - const mongoc_set_t *servers = mc_tpld_servers_const (td); - - for (size_t i = 0u; (size_t) i < servers->items_len; i++) { - const mongoc_server_description_t *sd = - mongoc_set_get_item_const (servers, i); - if (sd->type != MONGOC_SERVER_UNKNOWN && - sd->type != MONGOC_SERVER_POSSIBLE_PRIMARY && - sd->max_wire_version < ret) { - ret = sd->max_wire_version; - } - } - - return ret; -} - - -/* - *------------------------------------------------------------------------- - * - * mongoc_topology_description_all_sds_have_write_date -- - * - * Whether the primary and all secondaries' server descriptions have - * last_write_date_ms. - * - * Side effects: - * None. - * - *------------------------------------------------------------------------- - */ -bool -mongoc_topology_description_all_sds_have_write_date ( - const mongoc_topology_description_t *td) -{ - for (size_t i = 0u; (size_t) i < mc_tpld_servers_const (td)->items_len; - i++) { - const mongoc_server_description_t *sd = - mongoc_set_get_item_const (mc_tpld_servers_const (td), i); - - if (sd->last_write_date_ms <= 0 && - (sd->type == MONGOC_SERVER_RS_PRIMARY || - sd->type == MONGOC_SERVER_RS_SECONDARY)) { - return false; - } - } - - return true; -} - -/* - *------------------------------------------------------------------------- - * - * _mongoc_topology_description_validate_max_staleness -- - * - * If the provided "maxStalenessSeconds" component of the read - * preference is not valid for this topology, fill out @error and - * return false. - * - * Side effects: - * None. - * - *------------------------------------------------------------------------- - */ -bool -_mongoc_topology_description_validate_max_staleness ( - const mongoc_topology_description_t *td, - int64_t max_staleness_seconds, - bson_error_t *error) -{ - mongoc_topology_description_type_t td_type; - - /* Server Selection Spec: A driver MUST raise an error if the TopologyType - * is ReplicaSetWithPrimary or ReplicaSetNoPrimary and either of these - * conditions is false: - * - * maxStalenessSeconds * 1000 >= heartbeatFrequencyMS + idleWritePeriodMS - * maxStalenessSeconds >= smallestMaxStalenessSeconds - */ - - td_type = td->type; - - if (td_type != MONGOC_TOPOLOGY_RS_WITH_PRIMARY && - td_type != MONGOC_TOPOLOGY_RS_NO_PRIMARY) { - return true; - } - - if (max_staleness_seconds * 1000 < - td->heartbeat_msec + MONGOC_IDLE_WRITE_PERIOD_MS) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "maxStalenessSeconds is set to %" PRId64 - ", it must be at least heartbeatFrequencyMS (%" PRId64 - ") + server's idle write period (%d seconds)", - max_staleness_seconds, - td->heartbeat_msec, - MONGOC_IDLE_WRITE_PERIOD_MS / 1000); - return false; - } - - if (max_staleness_seconds < MONGOC_SMALLEST_MAX_STALENESS_SECONDS) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "maxStalenessSeconds is set to %" PRId64 - ", it must be at least %d seconds", - max_staleness_seconds, - MONGOC_SMALLEST_MAX_STALENESS_SECONDS); - return false; - } - - return true; -} - -static bool -_check_any_server_less_than_wire_version_13 (const void *sd_, - void *any_too_old_) -{ - const mongoc_server_description_t *sd = sd_; - bool *any_too_old = any_too_old_; - if (sd->max_wire_version < WIRE_VERSION_5_0) { - *any_too_old = true; - return false /* Stop searching */; - } - - return true /* Keep searching */; -} - -/** - * @brief Calculate the read mode that we should be using, based on what was - * requested and what is available in the topology. - * - * Per the CRUD spec, if the requested read mode is *not* primary, and *any* - * server in the topology has a wire version < server v5.0, we must override the - * read mode preference with "primary." Server v5.0 indicates support on a - * secondary server for using aggregate pipelines that contain writing stages - * (i.e. '$out' and '$merge'). - */ -static bool -_must_use_primary (const mongoc_topology_description_t *td, - mongoc_ss_optype_t optype, - mongoc_read_mode_t requested_read_mode) -{ - if (requested_read_mode == MONGOC_READ_PRIMARY) { - /* We never alter from a primary read mode. This early-return is just an - * optimization to skip scanning for old servers, as we would end up - * returning MONGOC_READ_PRIMARY regardless. */ - return requested_read_mode; - } - switch (optype) { - case MONGOC_SS_WRITE: - /* We don't deal with write operations */ - return false; - case MONGOC_SS_READ: - /* Maintain the requested read mode if it is a regular read operation */ - return false; - case MONGOC_SS_AGGREGATE_WITH_WRITE: { - /* Check if any of the servers are too old to support the - * aggregate-with-write on a secondary server */ - bool any_too_old = false; - mongoc_set_for_each_const (mc_tpld_servers_const (td), - _check_any_server_less_than_wire_version_13, - &any_too_old); - if (any_too_old) { - /* Force the read preference back to reading from a primary server, as - * one or more servers in the system may not support the operation */ - return true; - } - /* We're okay to send an aggr-with-write to a secondary server, so permit - * the caller's read mode preference */ - return false; - } - default: - BSON_UNREACHABLE ("Invalid mongoc_ss_optype_t for _must_use_primary()"); - } -} - -/* - *------------------------------------------------------------------------- - * - * mongoc_topology_description_suitable_servers -- - * - * Fill out an array of servers matching the read preference and - * localThresholdMS. - * - * Side effects: - * None. - * - *------------------------------------------------------------------------- - */ - -void -mongoc_topology_description_suitable_servers ( - mongoc_array_t *set, /* OUT */ - mongoc_ss_optype_t optype, - const mongoc_topology_description_t *topology, - const mongoc_read_prefs_t *read_pref, - bool *must_use_primary, - const mongoc_deprioritized_servers_t *ds, - int64_t local_threshold_ms) -{ - const mongoc_set_t *td_servers = mc_tpld_servers_const (topology); - const mongoc_read_mode_t given_read_mode = - mongoc_read_prefs_get_mode (read_pref); - const bool override_use_primary = - _must_use_primary (topology, optype, given_read_mode); - - mongoc_suitable_data_t data = { - .primary = NULL, - .topology_type = topology->type, - .has_secondary = false, - .candidates_len = 0, - .candidates = bson_malloc0 (sizeof (mongoc_server_description_t *) * - td_servers->items_len), - }; - - /* The "effective" read mode is the read mode that we should behave for, and - * depends on the user's provided read mode, the type of operation that the - * user wishes to perform, and the server versions that we are talking to. - * - * If the operation is a write operation, read mode is irrelevant. - * - * If the operation is a regular read, we just use the caller's read mode. - * - * If the operation is an aggregate that contains writing stages, we need to - * be more careful about selecting an appropriate server. - */ - data.read_mode = - override_use_primary ? MONGOC_READ_PRIMARY : given_read_mode; - if (must_use_primary) { - /* The caller wants to know if we have overriden their read preference */ - *must_use_primary = override_use_primary; - } - - /* Single server -- - * Either it is suitable or it isn't */ - if (topology->type == MONGOC_TOPOLOGY_SINGLE) { - const mongoc_server_description_t *server = - mongoc_set_get_item_const (td_servers, 0); - if (_mongoc_topology_description_server_is_candidate ( - server->type, data.read_mode, topology->type)) { - _mongoc_array_append_val (set, server); - } else { - TRACE ( - "Rejected [%s] [%s] for read mode [%s] with topology type Single", - mongoc_server_description_type (server), - server->host.host_and_port, - _mongoc_read_mode_as_str (data.read_mode)); - } - goto DONE; - } - - /* Replica sets -- - * Find suitable servers based on read mode */ - if (topology->type == MONGOC_TOPOLOGY_RS_NO_PRIMARY || - topology->type == MONGOC_TOPOLOGY_RS_WITH_PRIMARY) { - switch (optype) { - case MONGOC_SS_AGGREGATE_WITH_WRITE: - case MONGOC_SS_READ: { - mongoc_set_for_each_const ( - td_servers, _mongoc_replica_set_read_suitable_cb, &data); - - if (data.read_mode == MONGOC_READ_PRIMARY) { - if (data.primary) { - _mongoc_array_append_val (set, data.primary); - } - - goto DONE; - } - - if (data.read_mode == MONGOC_READ_PRIMARY_PREFERRED && data.primary) { - _mongoc_array_append_val (set, data.primary); - goto DONE; - } - - if (data.read_mode == MONGOC_READ_SECONDARY_PREFERRED) { - /* try read_mode SECONDARY */ - _mongoc_try_mode_secondary (set, - topology, - read_pref, - must_use_primary, - NULL, - local_threshold_ms); - - /* otherwise fall back to primary */ - if (!set->len && data.primary) { - _mongoc_array_append_val (set, data.primary); - } - - goto DONE; - } - - if (data.read_mode == MONGOC_READ_SECONDARY) { - for (size_t i = 0u; i < data.candidates_len; i++) { - if (data.candidates[i] && - data.candidates[i]->type != MONGOC_SERVER_RS_SECONDARY) { - TRACE ("Rejected [%s] [%s] for mode [%s] with RS topology", - mongoc_server_description_type (data.candidates[i]), - data.candidates[i]->host.host_and_port, - _mongoc_read_mode_as_str (data.read_mode)); - data.candidates[i] = NULL; - } - } - } - - /* mode is SECONDARY or NEAREST, filter by staleness and tags */ - mongoc_server_description_filter_stale (data.candidates, - data.candidates_len, - data.primary, - topology->heartbeat_msec, - read_pref); - - mongoc_server_description_filter_tags ( - data.candidates, data.candidates_len, read_pref); - } break; - case MONGOC_SS_WRITE: { - if (topology->type == MONGOC_TOPOLOGY_RS_WITH_PRIMARY) { - mongoc_set_for_each_const ( - td_servers, - _mongoc_topology_description_has_primary_cb, - (void *) &data.primary); - if (data.primary) { - _mongoc_array_append_val (set, data.primary); - goto DONE; - } - } - } break; - default: - BSON_UNREACHABLE ("Invalid optype"); - } - } - - // Sharded clusters -- - if (topology->type == MONGOC_TOPOLOGY_SHARDED) { - mongoc_set_for_each_const ( - td_servers, _mongoc_td_servers_to_candidates_array, &data); - - if (ds) { - _mongoc_filter_deprioritized_servers (&data, ds); - } - - _mongoc_filter_suitable_mongos (&data); - } - - /* Load balanced clusters -- - * Always select the only server. */ - if (topology->type == MONGOC_TOPOLOGY_LOAD_BALANCED) { - const mongoc_server_description_t *server; - BSON_ASSERT (td_servers->items_len == 1); - server = mongoc_set_get_item_const (td_servers, 0); - _mongoc_array_append_val (set, server); - goto DONE; - } - - /* Ways to get here: - * - secondary read - * - secondary preferred read - * - primary_preferred and no primary read - * - sharded anything - * Find the nearest, then select within the window */ - int64_t nearest = INT64_MAX; - bool found = false; - for (size_t i = 0u; i < data.candidates_len; i++) { - if (data.candidates[i]) { - nearest = BSON_MIN (nearest, data.candidates[i]->round_trip_time_msec); - found = true; - } - } - - // No candidates remaining. - if (!found) { - goto DONE; - } - - const int64_t rtt_limit = nearest + local_threshold_ms; - - for (size_t i = 0u; i < data.candidates_len; i++) { - if (data.candidates[i] && - (data.candidates[i]->round_trip_time_msec <= rtt_limit)) { - _mongoc_array_append_val (set, data.candidates[i]); - } - } - -DONE: - - bson_free ((mongoc_server_description_t *) data.candidates); - - return; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_has_data_node -- - * - * Internal method: are any servers not Arbiter, Ghost, or Unknown? - * - *-------------------------------------------------------------------------- - */ -bool -mongoc_topology_description_has_data_node ( - const mongoc_topology_description_t *td) -{ - const mongoc_set_t *servers = mc_tpld_servers_const (td); - - for (size_t i = 0u; i < servers->items_len; i++) { - const mongoc_server_description_t *sd = - mongoc_set_get_item_const (servers, i); - if (_is_data_node (sd)) { - return true; - } - } - - return false; -} - -/* - *------------------------------------------------------------------------- - * - * mongoc_topology_description_select -- - * - * Return a server description of a node that is appropriate for - * the given read preference and operation type. - * - * NOTE: this method simply attempts to select a server from the - * current topology, it does not retry or trigger topology checks. - * - * Returns: - * Selected server description, or NULL upon failure. - * - * Side effects: - * None. - * - *------------------------------------------------------------------------- - */ -mongoc_server_description_t const * -mongoc_topology_description_select ( - const mongoc_topology_description_t *topology, - mongoc_ss_optype_t optype, - const mongoc_read_prefs_t *read_pref, - bool *must_use_primary, - const mongoc_deprioritized_servers_t *ds, - int64_t local_threshold_ms) -{ - mongoc_array_t suitable_servers; - - ENTRY; - - if (topology->type == MONGOC_TOPOLOGY_SINGLE) { - mongoc_server_description_t const *const sd = - mongoc_set_get_item_const (mc_tpld_servers_const (topology), 0); - - if (optype == MONGOC_SS_AGGREGATE_WITH_WRITE && - sd->max_wire_version < WIRE_VERSION_5_0) { - /* The single server may be part of an unseen replica set that may not - * support aggr-with-write operations on secondaries. Force the read - * preference to use a primary. */ - if (must_use_primary) { - *must_use_primary = true; - } - } - - if (sd->has_hello_response) { - RETURN (sd); - } else { - TRACE ("Topology type single, [%s] is down", sd->host.host_and_port); - RETURN (NULL); - } - } - - _mongoc_array_init (&suitable_servers, - sizeof (mongoc_server_description_t *)); - - mongoc_topology_description_suitable_servers (&suitable_servers, - optype, - topology, - read_pref, - must_use_primary, - ds, - local_threshold_ms); - - mongoc_server_description_t const *sd = NULL; - - if (suitable_servers.len != 0) { - const int rand_n = - _mongoc_rand_simple ((unsigned *) &topology->rand_seed); - sd = _mongoc_array_index (&suitable_servers, - mongoc_server_description_t *, - (size_t) rand_n % suitable_servers.len); - } - - _mongoc_array_destroy (&suitable_servers); - - if (sd) { - TRACE ("Topology type [%s], selected [%s] [%s]", - mongoc_topology_description_type (topology), - mongoc_server_description_type (sd), - sd->host.host_and_port); - } - - RETURN (sd); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_server_by_id -- - * - * Get the server description for @id, if that server is present - * in @description. Otherwise, return NULL and fill out optional - * @error. - * - * NOTE: In most cases, caller should create a duplicate of the - * returned server description. - * - * Returns: - * A mongoc_server_description_t *, or NULL. - * - * Side effects: - * Fills out optional @error if server not found. - * - *-------------------------------------------------------------------------- - */ - -mongoc_server_description_t * -mongoc_topology_description_server_by_id ( - mongoc_topology_description_t *description, uint32_t id, bson_error_t *error) -{ - return (mongoc_server_description_t *) - mongoc_topology_description_server_by_id_const (description, id, error); -} - -const mongoc_server_description_t * -mongoc_topology_description_server_by_id_const ( - const mongoc_topology_description_t *td, uint32_t id, bson_error_t *error) -{ - const mongoc_server_description_t *sd; - - BSON_ASSERT_PARAM (td); - - sd = mongoc_set_get_const (mc_tpld_servers_const (td), id); - if (!sd) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NOT_ESTABLISHED, - "Could not find description for node %u", - id); - } - - return sd; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_remove_server -- - * - * If present, remove this server from this topology description. - * - * Returns: - * None. - * - * Side effects: - * Removes the server description from topology and destroys it. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_remove_server ( - mongoc_topology_description_t *description, - const mongoc_server_description_t *server) -{ - BSON_ASSERT (description); - BSON_ASSERT (server); - - _mongoc_topology_description_monitor_server_closed (description, server); - mongoc_set_rm (mc_tpld_servers (description), server->id); - - /* Check if removing server resulted in an empty set of servers */ - if (mc_tpld_servers_const (description)->items_len == 0) { - MONGOC_WARNING ("Last server removed from topology"); - } -} - -typedef struct _mongoc_address_and_id_t { - const char *address; /* IN */ - bool found; /* OUT */ - uint32_t id; /* OUT */ -} mongoc_address_and_id_t; - -/* find the given server and stop iterating */ -static bool -_mongoc_topology_description_has_server_cb (const void *item, - void *ctx /* IN - OUT */) -{ - const mongoc_server_description_t *server = item; - mongoc_address_and_id_t *data = (mongoc_address_and_id_t *) ctx; - - if (strcasecmp (data->address, server->connection_address) == 0) { - data->found = true; - data->id = server->id; - return false; - } - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_has_set_version -- - * - * Whether @topology's max replica set version has been set. - * - * Returns: - * True if the max setVersion was ever set. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -static bool -_mongoc_topology_description_has_set_version (mongoc_topology_description_t *td) -{ - return td->max_set_version != MONGOC_NO_SET_VERSION; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_topology_has_server -- - * - * Return true if @server is in @topology. If so, place its id in - * @id if given. - * - * Returns: - * True if server is in topology, false otherwise. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -static bool -_mongoc_topology_description_has_server ( - mongoc_topology_description_t *description, - const char *address, - uint32_t *id /* OUT */) -{ - mongoc_address_and_id_t data; - - BSON_ASSERT (description); - BSON_ASSERT (address); - - data.address = address; - data.found = false; - mongoc_set_for_each_const (mc_tpld_servers_const (description), - _mongoc_topology_description_has_server_cb, - &data); - - if (data.found && id) { - *id = data.id; - } - - return data.found; -} - -typedef struct _mongoc_address_and_type_t { - const char *address; - mongoc_server_description_type_t type; -} mongoc_address_and_type_t; - -static bool -_mongoc_label_unknown_member_cb (void *item, void *ctx) -{ - mongoc_server_description_t *server = (mongoc_server_description_t *) item; - mongoc_address_and_type_t *data = (mongoc_address_and_type_t *) ctx; - - if (strcasecmp (server->connection_address, data->address) == 0 && - server->type == MONGOC_SERVER_UNKNOWN) { - mongoc_server_description_set_state (server, data->type); - return false; - } - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_label_unknown_member -- - * - * Find the server description with the given @address and if its - * type is UNKNOWN, set its type to @type. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_label_unknown_member ( - mongoc_topology_description_t *description, - const char *address, - mongoc_server_description_type_t type) -{ - mongoc_address_and_type_t data; - - BSON_ASSERT (description); - BSON_ASSERT (address); - - data.type = type; - data.address = address; - - mongoc_set_for_each ( - mc_tpld_servers (description), _mongoc_label_unknown_member_cb, &data); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_set_state -- - * - * Change the state of this cluster and unblock things waiting - * on a change of topology type. - * - * Returns: - * None. - * - * Side effects: - * Unblocks anything waiting on this description to change states. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_set_state ( - mongoc_topology_description_t *description, - mongoc_topology_description_type_t type) -{ - description->type = type; -} - - -static void -_update_rs_type (mongoc_topology_description_t *topology) -{ - if (_mongoc_topology_description_has_primary (topology)) { - _mongoc_topology_description_set_state (topology, - MONGOC_TOPOLOGY_RS_WITH_PRIMARY); - } else { - _mongoc_topology_description_set_state (topology, - MONGOC_TOPOLOGY_RS_NO_PRIMARY); - } -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_check_if_has_primary -- - * - * If there is a primary in topology, set topology - * type to RS_WITH_PRIMARY, otherwise set it to - * RS_NO_PRIMARY. - * - * Returns: - * None. - * - * Side effects: - * Changes the topology type. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_check_if_has_primary ( - mongoc_topology_description_t *topology, - const mongoc_server_description_t *server) -{ - BSON_UNUSED (server); - - _update_rs_type (topology); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_invalidate_server -- - * - * Invalidate a server if a network error occurred while using it in - * another part of the client. Server description is set to type - * UNKNOWN, the error is recorded, and other parameters are reset to - * defaults. Pass in the reason for invalidation in @error. - * - * @todo Try to remove this function when CDRIVER-3654 is complete. - * It is only called when an application thread needs to mark a server Unknown. - * But an application error is also tied to other behavior, and should also - * consider the connection generation. This logic is captured in - * _mongoc_topology_handle_app_error. This should not be called directly - */ -void -mongoc_topology_description_invalidate_server ( - mongoc_topology_description_t *td, - uint32_t id, - const bson_error_t *error /* IN */) -{ - BSON_ASSERT (error); - - if (td->type == MONGOC_TOPOLOGY_LOAD_BALANCED) { - /* Load balancers must never be marked unknown. */ - return; - } - - /* send NULL hello reply */ - mongoc_topology_description_handle_hello ( - td, id, NULL, MONGOC_RTT_UNSET, error); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_add_server -- - * - * Add the specified server to the cluster topology if it is not - * already a member. If @id, place its id in @id. - * - * Return: - * True if the server was added or already existed in the topology, - * false if an error occurred. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -bool -mongoc_topology_description_add_server (mongoc_topology_description_t *topology, - const char *server, - uint32_t *id /* OUT */) -{ - uint32_t server_id; - mongoc_server_description_t *description; - - BSON_ASSERT (topology); - BSON_ASSERT (server); - - if (!_mongoc_topology_description_has_server ( - topology, server, &server_id)) { - /* TODO this might not be an accurate count in all cases */ - server_id = ++topology->max_server_id; - - description = BSON_ALIGNED_ALLOC0 (mongoc_server_description_t); - mongoc_server_description_init (description, server, server_id); - - mongoc_set_add (mc_tpld_servers (topology), server_id, description); - - /* if we're in topology_new then no callbacks are registered and this is - * a no-op. later, if we discover a new RS member this sends an event. */ - _mongoc_topology_description_monitor_server_opening (topology, - description); - } - - if (id) { - *id = server_id; - } - - return true; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_update_cluster_time -- - * - * Drivers Session Spec: Drivers MUST examine responses to server commands to - * see if they contain a top level field named $clusterTime formatted as - * follows: - * - * { - * ... - * $clusterTime : { - * clusterTime : , - * signature : { - * hash : , - * keyId : - * } - * }, - * ... - * } - * - * Whenever a driver receives a clusterTime from a server it MUST compare it - * to the current highest seen clusterTime for the cluster. If the new - * clusterTime is higher than the highest seen clusterTime it MUST become - * the new highest seen clusterTime. Two clusterTimes are compared using - * only the BsonTimestamp value of the clusterTime embedded field (be sure to - * include both the timestamp and the increment of the BsonTimestamp in the - * comparison). The signature field does not participate in the comparison. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_topology_description_update_cluster_time ( - mongoc_topology_description_t *td, const bson_t *reply) -{ - bson_iter_t iter; - bson_iter_t child; - const uint8_t *data; - uint32_t size; - bson_t cluster_time; - - if (!reply || !bson_iter_init_find (&iter, reply, "$clusterTime")) { - return; - } - - if (!BSON_ITER_HOLDS_DOCUMENT (&iter) || - !bson_iter_recurse (&iter, &child)) { - MONGOC_ERROR ("Can't parse $clusterTime"); - return; - } - - bson_iter_document (&iter, &size, &data); - BSON_ASSERT (bson_init_static (&cluster_time, data, (size_t) size)); - - if (bson_empty (&td->cluster_time) || - _mongoc_cluster_time_greater (&cluster_time, &td->cluster_time)) { - bson_destroy (&td->cluster_time); - bson_copy_to (&cluster_time, &td->cluster_time); - } -} - - -static void -_mongoc_topology_description_add_new_servers ( - mongoc_topology_description_t *topology, - const mongoc_server_description_t *server) -{ - bson_iter_t member_iter; - const bson_t *rs_members[3]; - int i; - - rs_members[0] = &server->hosts; - rs_members[1] = &server->arbiters; - rs_members[2] = &server->passives; - - for (i = 0; i < 3; i++) { - BSON_ASSERT (bson_iter_init (&member_iter, rs_members[i])); - - while (bson_iter_next (&member_iter)) { - mongoc_topology_description_add_server ( - topology, bson_iter_utf8 (&member_iter, NULL), NULL); - } - } -} - -typedef struct _mongoc_primary_and_topology_t { - mongoc_topology_description_t *topology; - const mongoc_server_description_t *primary; -} mongoc_primary_and_topology_t; - -/* invalidate old primaries */ -static bool -_mongoc_topology_description_invalidate_primaries_cb (void *item, void *ctx) -{ - mongoc_server_description_t *server = (mongoc_server_description_t *) item; - mongoc_primary_and_topology_t *data = (mongoc_primary_and_topology_t *) ctx; - - if (server->id != data->primary->id && - server->type == MONGOC_SERVER_RS_PRIMARY) { - mongoc_server_description_set_state (server, MONGOC_SERVER_UNKNOWN); - mongoc_server_description_set_set_version (server, MONGOC_NO_SET_VERSION); - mongoc_server_description_set_election_id (server, NULL); - mongoc_server_description_reset (server); - } - return true; -} - - -/* Remove and destroy all replica set members not in primary's hosts lists */ -static void -_mongoc_topology_description_remove_unreported_servers ( - mongoc_topology_description_t *topology, - const mongoc_server_description_t *primary) -{ - mongoc_array_t to_remove; - - _mongoc_array_init (&to_remove, sizeof (mongoc_server_description_t *)); - - /* Accumulate servers to be removed - do this before calling - * _mongoc_topology_description_remove_server, which could call - * mongoc_server_description_cleanup on the primary itself if it - * doesn't report its own connection_address in its hosts list. - * See hosts_differ_from_seeds.json */ - for (size_t i = 0u; i < mc_tpld_servers_const (topology)->items_len; i++) { - const mongoc_server_description_t *member = - mongoc_set_get_item_const (mc_tpld_servers_const (topology), i); - const char *address = member->connection_address; - if (!mongoc_server_description_has_rs_member (primary, address)) { - _mongoc_array_append_val (&to_remove, member); - } - } - - /* now it's safe to call _mongoc_topology_description_remove_server, - * even on the primary */ - for (size_t i = 0u; i < to_remove.len; i++) { - const mongoc_server_description_t *member = - _mongoc_array_index (&to_remove, mongoc_server_description_t *, i); - - _mongoc_topology_description_remove_server (topology, member); - } - - _mongoc_array_destroy (&to_remove); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_matches_me -- - * - * Server Discovery And Monitoring Spec: "Removal from the topology of - * seed list members where the "me" property does not match the address - * used to connect prevents clients from being able to select a server, - * only to fail to re-select that server once the primary has responded. - * - * Returns: - * True if "me" matches "connection_address". - * - * Side Effects: - * None. - * - *-------------------------------------------------------------------------- - */ -static bool -_mongoc_topology_description_matches_me ( - const mongoc_server_description_t *server) -{ - BSON_ASSERT (server->connection_address); - - if (!server->me) { - /* "me" is unknown: consider it a match */ - return true; - } - - return strcasecmp (server->connection_address, server->me) == 0; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_update_rs_from_primary -- - * - * First, determine that this is really the primary: - * -If this node isn't in the cluster, do nothing. - * -If the cluster's set name is null, set it to node's set name. - * Otherwise if the cluster's set name is different from node's, - * we found a rogue primary, so remove it from the cluster and - * check the cluster for a primary, then return. - * -If any of the members of cluster reports an address different - * from node's, node cannot be the primary. - * Now that we know this is the primary: - * -If any hosts, passives, or arbiters in node's description aren't - * in the cluster, add them as UNKNOWN servers. - * -If the cluster has any servers that aren't in node's description, - * remove and destroy them. - * Finally, check the cluster for the new primary. - * - * Returns: - * None. - * - * Side effects: - * Changes to the cluster, possible removal of cluster nodes. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_update_rs_from_primary ( - mongoc_topology_description_t *topology, - const mongoc_server_description_t *server) -{ - mongoc_primary_and_topology_t data; - bson_error_t error; - - BSON_ASSERT (topology); - BSON_ASSERT (server); - - if (!_mongoc_topology_description_has_server ( - topology, server->connection_address, NULL)) - return; - - /* If server->set_name was null this function wouldn't be called from - * mongoc_server_description_handle_hello(). static code analyzers however - * don't know that so we check for it explicitly. */ - if (server->set_name) { - /* 'Server' can only be the primary if it has the right rs name */ - - if (!topology->set_name) { - topology->set_name = bson_strdup (server->set_name); - } else if (strcmp (topology->set_name, server->set_name) != 0) { - _mongoc_topology_description_remove_server (topology, server); - _update_rs_type (topology); - return; - } - } - if (server->max_wire_version >= WIRE_VERSION_6_0) { - /* MongoDB 6.0+ */ - if (_mongoc_server_description_primary_is_not_stale (topology, server)) { - _mongoc_topology_description_set_max_election_id (topology, server); - _mongoc_topology_description_set_max_set_version (topology, server); - - } else { - bson_set_error (&error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "member's setVersion or electionId is stale"); - mongoc_topology_description_invalidate_server ( - topology, server->id, &error); - _update_rs_type (topology); - return; - } - } else { - // old comparison rules, namely setVersion is checked before electionId - if (mongoc_server_description_has_set_version (server) && - mongoc_server_description_has_election_id (server)) { - /* Server Discovery And Monitoring Spec: "The client remembers the - * greatest electionId reported by a primary, and distrusts primaries - * with lesser electionIds. This prevents the client from oscillating - * between the old and new primary during a split-brain period." - */ - if (_mongoc_topology_description_later_election (topology, server)) { - // stale primary code return: - bson_set_error (&error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "member's setVersion or electionId is stale"); - mongoc_topology_description_invalidate_server ( - topology, server->id, &error); - _update_rs_type (topology); - return; - } - - /* server's electionId >= topology's max electionId */ - _mongoc_topology_description_set_max_election_id (topology, server); - } - - if (mongoc_server_description_has_set_version (server) && - (!_mongoc_topology_description_has_set_version (topology) || - server->set_version > topology->max_set_version)) { - _mongoc_topology_description_set_max_set_version (topology, server); - } - } - /* 'Server' is the primary! Invalidate other primaries if found */ - data.primary = server; - data.topology = topology; - mongoc_set_for_each (mc_tpld_servers (topology), - _mongoc_topology_description_invalidate_primaries_cb, - &data); - - /* Add to topology description any new servers primary knows about */ - _mongoc_topology_description_add_new_servers (topology, server); - - /* Remove from topology description any servers primary doesn't know about */ - _mongoc_topology_description_remove_unreported_servers (topology, server); - - /* Finally, set topology type */ - _update_rs_type (topology); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_update_rs_without_primary -- - * - * Update cluster's information when there is no primary. - * - * Returns: - * None. - * - * Side Effects: - * Alters cluster state, may remove node from cluster. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_update_rs_without_primary ( - mongoc_topology_description_t *topology, - const mongoc_server_description_t *server) -{ - BSON_ASSERT (topology); - BSON_ASSERT (server); - - if (!_mongoc_topology_description_has_server ( - topology, server->connection_address, NULL)) { - return; - } - - /* make sure we're talking about the same replica set */ - if (server->set_name) { - if (!topology->set_name) { - topology->set_name = bson_strdup (server->set_name); - } else if (strcmp (topology->set_name, server->set_name) != 0) { - _mongoc_topology_description_remove_server (topology, server); - return; - } - } - - /* Add new servers that this replica set member knows about */ - _mongoc_topology_description_add_new_servers (topology, server); - - /* If this server thinks there is a primary, label it POSSIBLE_PRIMARY */ - if (server->current_primary) { - _mongoc_topology_description_label_unknown_member ( - topology, server->current_primary, MONGOC_SERVER_POSSIBLE_PRIMARY); - } - - if (!_mongoc_topology_description_matches_me (server)) { - _mongoc_topology_description_remove_server (topology, server); - return; - } -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_update_rs_with_primary_from_member -- - * - * Update cluster's information when there is a primary, but the - * update is coming from another replica set member. - * - * Returns: - * None. - * - * Side Effects: - * Alters cluster state. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_update_rs_with_primary_from_member ( - mongoc_topology_description_t *topology, - const mongoc_server_description_t *server) -{ - BSON_ASSERT (topology); - BSON_ASSERT (server); - - if (!_mongoc_topology_description_has_server ( - topology, server->connection_address, NULL)) { - return; - } - - /* set_name should never be null here */ - if (strcmp (topology->set_name, server->set_name) != 0) { - _mongoc_topology_description_remove_server (topology, server); - _update_rs_type (topology); - return; - } - - if (!_mongoc_topology_description_matches_me (server)) { - _mongoc_topology_description_remove_server (topology, server); - return; - } - - /* If there is no primary, label server's current_primary as the - * POSSIBLE_PRIMARY */ - if (!_mongoc_topology_description_has_primary (topology) && - server->current_primary) { - _mongoc_topology_description_set_state (topology, - MONGOC_TOPOLOGY_RS_NO_PRIMARY); - _mongoc_topology_description_label_unknown_member ( - topology, server->current_primary, MONGOC_SERVER_POSSIBLE_PRIMARY); - } -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_set_topology_type_to_sharded -- - * - * Sets topology's type to SHARDED. - * - * Returns: - * None - * - * Side effects: - * Alter's topology's type - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_set_topology_type_to_sharded ( - mongoc_topology_description_t *topology, - const mongoc_server_description_t *server) -{ - BSON_UNUSED (server); - - _mongoc_topology_description_set_state (topology, MONGOC_TOPOLOGY_SHARDED); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_transition_unknown_to_rs_no_primary -- - * - * Encapsulates transition from cluster state UNKNOWN to - * RS_NO_PRIMARY. Sets the type to RS_NO_PRIMARY, - * then updates the replica set accordingly. - * - * Returns: - * None. - * - * Side effects: - * Changes topology state. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_transition_unknown_to_rs_no_primary ( - mongoc_topology_description_t *topology, - const mongoc_server_description_t *server) -{ - _mongoc_topology_description_set_state (topology, - MONGOC_TOPOLOGY_RS_NO_PRIMARY); - _mongoc_topology_description_update_rs_without_primary (topology, server); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_remove_and_check_primary -- - * - * Remove the server and check if the topology still has a primary. - * - * Returns: - * None. - * - * Side effects: - * Removes server from topology and destroys it. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_remove_and_check_primary ( - mongoc_topology_description_t *topology, - const mongoc_server_description_t *server) -{ - _mongoc_topology_description_remove_server (topology, server); - _update_rs_type (topology); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_update_unknown_with_standalone -- - * - * If the cluster doesn't contain this server, do nothing. - * Otherwise, if the topology only has one seed, change its - * type to SINGLE. If the topology has multiple seeds, it does not - * include us, so remove this server and destroy it. - * - * Returns: - * None. - * - * Side effects: - * Changes the topology type, might remove server from topology. - * - *-------------------------------------------------------------------------- - */ -static void -_mongoc_topology_description_update_unknown_with_standalone ( - mongoc_topology_description_t *topology, - const mongoc_server_description_t *server) -{ - BSON_ASSERT (topology); - BSON_ASSERT (server); - - if (!_mongoc_topology_description_has_server ( - topology, server->connection_address, NULL)) - return; - - if (mc_tpld_servers_const (topology)->items_len > 1) { - /* This cluster contains other servers, it cannot be a standalone. */ - _mongoc_topology_description_remove_server (topology, server); - } else { - _mongoc_topology_description_set_state (topology, MONGOC_TOPOLOGY_SINGLE); - } -} - -/* - *-------------------------------------------------------------------------- - * - * This table implements the 'ToplogyType' table outlined in the Server - * Discovery and Monitoring spec. Each row represents a server type, - * and each column represents the topology type. Given a current topology - * type T and a newly-observed server type S, use the function at - * state_transions[S][T] to transition to a new state. - * - * Rows should be read like so: - * { server type for this row - * UNKNOWN, - * SHARDED, - * RS_NO_PRIMARY, - * RS_WITH_PRIMARY - * } - * - *-------------------------------------------------------------------------- - */ - -typedef void (*transition_t) (mongoc_topology_description_t *topology, - const mongoc_server_description_t *server); - -transition_t gSDAMTransitionTable - [MONGOC_SERVER_DESCRIPTION_TYPES][MONGOC_TOPOLOGY_DESCRIPTION_TYPES] = { - { - /* UNKNOWN */ - NULL, /* MONGOC_TOPOLOGY_UNKNOWN */ - NULL, /* MONGOC_TOPOLOGY_SHARDED */ - NULL, /* MONGOC_TOPOLOGY_RS_NO_PRIMARY */ - _mongoc_topology_description_check_if_has_primary /* MONGOC_TOPOLOGY_RS_WITH_PRIMARY - */ - }, - {/* STANDALONE */ - _mongoc_topology_description_update_unknown_with_standalone, - _mongoc_topology_description_remove_server, - _mongoc_topology_description_remove_server, - _mongoc_topology_description_remove_and_check_primary}, - {/* MONGOS */ - _mongoc_topology_description_set_topology_type_to_sharded, - NULL, - _mongoc_topology_description_remove_server, - _mongoc_topology_description_remove_and_check_primary}, - {/* POSSIBLE_PRIMARY */ - NULL, - NULL, - NULL, - NULL}, - {/* PRIMARY */ - _mongoc_topology_description_update_rs_from_primary, - _mongoc_topology_description_remove_server, - _mongoc_topology_description_update_rs_from_primary, - _mongoc_topology_description_update_rs_from_primary}, - {/* SECONDARY */ - _mongoc_topology_description_transition_unknown_to_rs_no_primary, - _mongoc_topology_description_remove_server, - _mongoc_topology_description_update_rs_without_primary, - _mongoc_topology_description_update_rs_with_primary_from_member}, - {/* ARBITER */ - _mongoc_topology_description_transition_unknown_to_rs_no_primary, - _mongoc_topology_description_remove_server, - _mongoc_topology_description_update_rs_without_primary, - _mongoc_topology_description_update_rs_with_primary_from_member}, - {/* RS_OTHER */ - _mongoc_topology_description_transition_unknown_to_rs_no_primary, - _mongoc_topology_description_remove_server, - _mongoc_topology_description_update_rs_without_primary, - _mongoc_topology_description_update_rs_with_primary_from_member}, - {/* RS_GHOST */ - NULL, - _mongoc_topology_description_remove_server, - NULL, - _mongoc_topology_description_check_if_has_primary}}; - -/* - *-------------------------------------------------------------------------- - * - * _tpld_type_str -- - * - * Get this topology's type, one of the types defined in the Server - * Discovery And Monitoring Spec. - * - * Returns: - * A string. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -static const char * -_tpld_type_str (mongoc_topology_description_type_t type) -{ - switch (type) { - case MONGOC_TOPOLOGY_UNKNOWN: - return "Unknown"; - case MONGOC_TOPOLOGY_SHARDED: - return "Sharded"; - case MONGOC_TOPOLOGY_RS_NO_PRIMARY: - return "RSNoPrimary"; - case MONGOC_TOPOLOGY_RS_WITH_PRIMARY: - return "RSWithPrimary"; - case MONGOC_TOPOLOGY_SINGLE: - return "Single"; - case MONGOC_TOPOLOGY_LOAD_BALANCED: - return "LoadBalanced"; - case MONGOC_TOPOLOGY_DESCRIPTION_TYPES: - default: - MONGOC_ERROR ("Invalid mongoc_topology_description_type_t type"); - return "Invalid"; - } -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_update_session_timeout -- - * - * Fill out td.session_timeout_minutes. - * - * Server Discovery and Monitoring Spec: "set logicalSessionTimeoutMinutes - * to the smallest logicalSessionTimeoutMinutes value among all - * ServerDescriptions of known ServerType. If any ServerDescription of - * known ServerType has a null logicalSessionTimeoutMinutes, then - * logicalSessionTimeoutMinutes MUST be set to null." - * - * -------------------------------------------------------------------------- - */ - -static void -_mongoc_topology_description_update_session_timeout ( - mongoc_topology_description_t *td) -{ - mongoc_set_t *set; - mongoc_server_description_t *sd; - - set = mc_tpld_servers (td); - - td->session_timeout_minutes = MONGOC_NO_SESSIONS; - - for (size_t i = 0; i < set->items_len; i++) { - sd = (mongoc_server_description_t *) mongoc_set_get_item (set, i); - if (!_is_data_node (sd)) { - continue; - } - - if (sd->session_timeout_minutes == MONGOC_NO_SESSIONS) { - td->session_timeout_minutes = MONGOC_NO_SESSIONS; - return; - } else if (td->session_timeout_minutes == MONGOC_NO_SESSIONS) { - td->session_timeout_minutes = sd->session_timeout_minutes; - } else if (td->session_timeout_minutes > sd->session_timeout_minutes) { - td->session_timeout_minutes = sd->session_timeout_minutes; - } - } -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_description_check_compatible -- - * - * Fill out td.compatibility_error if any server's wire versions do - * not overlap with ours. Otherwise clear td.compatibility_error. - * - * If any server is incompatible, the topology as a whole is considered - * incompatible. - * - *-------------------------------------------------------------------------- - */ - -static void -_mongoc_topology_description_check_compatible ( - mongoc_topology_description_t *td) -{ - mongoc_set_t const *const servers = mc_tpld_servers_const (td); - - memset (&td->compatibility_error, 0, sizeof (bson_error_t)); - - for (size_t i = 0; i < servers->items_len; i++) { - mongoc_server_description_t const *const sd = - mongoc_set_get_item_const (servers, i); - if (sd->type == MONGOC_SERVER_UNKNOWN || - sd->type == MONGOC_SERVER_POSSIBLE_PRIMARY) { - continue; - } - - if (sd->min_wire_version > WIRE_VERSION_MAX) { - bson_set_error ( - &td->compatibility_error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "Server at %s requires wire version %d," - " but this version of libmongoc only supports up to %d", - sd->host.host_and_port, - sd->min_wire_version, - WIRE_VERSION_MAX); - } else if (sd->max_wire_version < WIRE_VERSION_MIN) { - bson_set_error ( - &td->compatibility_error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "Server at %s reports wire version %d, but this" - " version of libmongoc requires at least %d (MongoDB %s)", - sd->host.host_and_port, - sd->max_wire_version, - WIRE_VERSION_MIN, - _mongoc_wire_version_to_server_version (WIRE_VERSION_MIN)); - } - } -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_handle_hello -- - * - * Handle a hello. This is called by the background SDAM process, - * and by client when performing a handshake or invalidating servers. - * If there was an error calling hello, pass it in as @error. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_topology_description_handle_hello ( - mongoc_topology_description_t *topology, - uint32_t server_id, - const bson_t *hello_response, - int64_t rtt_msec, - const bson_error_t *error /* IN */) -{ - mongoc_topology_description_t *prev_td = NULL; - mongoc_server_description_t *prev_sd = NULL; - mongoc_server_description_t *sd; - bson_iter_t iter; - /* sd_changed is set if the server description meaningfully changed AND - * callbacks are registered. */ - bool sd_changed = false; - - BSON_ASSERT (topology); - BSON_ASSERT (server_id != 0); - - sd = mongoc_topology_description_server_by_id (topology, server_id, NULL); - if (!sd) { - return; /* server already removed from topology */ - } - - if (topology->apm_callbacks.topology_changed) { - prev_td = BSON_ALIGNED_ALLOC0 (mongoc_topology_description_t); - _mongoc_topology_description_copy_to (topology, prev_td); - } - - if (hello_response && - bson_iter_init_find (&iter, hello_response, "topologyVersion") && - BSON_ITER_HOLDS_DOCUMENT (&iter)) { - bson_t incoming_topology_version; - const uint8_t *bytes; - uint32_t len; - - bson_iter_document (&iter, &len, &bytes); - BSON_ASSERT (bson_init_static (&incoming_topology_version, bytes, len)); - - if (mongoc_server_description_topology_version_cmp ( - &sd->topology_version, &incoming_topology_version) == 1) { - TRACE ("%s", "topology version is strictly less. Skipping."); - if (prev_td) { - mongoc_topology_description_cleanup (prev_td); - bson_free (prev_td); - } - return; - } - } - - if (topology->apm_callbacks.topology_changed || - topology->apm_callbacks.server_changed) { - /* Only copy the previous server description if a monitoring callback is - * registered. */ - prev_sd = mongoc_server_description_new_copy (sd); - } - - DUMP_BSON (hello_response); - /* pass the current error in */ - - mongoc_server_description_handle_hello (sd, hello_response, rtt_msec, error); - - /* if the user specified a set_name in the connection string - * and they are in topology type single, check that the set name - * matches. */ - if (topology->set_name && topology->type == MONGOC_TOPOLOGY_SINGLE) { - bool wrong_set_name = false; - bson_error_t set_name_err = {0}; - - if (!sd->set_name) { - wrong_set_name = true; - bson_set_error (&set_name_err, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "no reported set name, but expected '%s'", - topology->set_name); - } else if (0 != strcmp (sd->set_name, topology->set_name)) { - wrong_set_name = true; - bson_set_error (&set_name_err, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "reported set name '%s' does not match '%s'", - sd->set_name, - topology->set_name); - } - - if (wrong_set_name) { - /* Replace with unknown. */ - TRACE ("%s", "wrong set name"); - mongoc_server_description_handle_hello ( - sd, NULL, MONGOC_RTT_UNSET, &set_name_err); - } - } - - mongoc_topology_description_update_cluster_time (topology, hello_response); - - if (prev_sd) { - sd_changed = !_mongoc_server_description_equal (prev_sd, sd); - } - if (sd_changed) { - _mongoc_topology_description_monitor_server_changed ( - topology, prev_sd, sd); - } - - if (gSDAMTransitionTable[sd->type][topology->type]) { - TRACE ("Topology description %s handling server description %s", - _tpld_type_str (topology->type), - mongoc_server_description_type (sd)); - gSDAMTransitionTable[sd->type][topology->type](topology, sd); - } else { - TRACE ("Topology description %s ignoring server description %s", - _tpld_type_str (topology->type), - mongoc_server_description_type (sd)); - } - - _mongoc_topology_description_update_session_timeout (topology); - - /* Don't bother checking wire version compatibility if we already errored */ - if (hello_response && (!error || !error->code)) { - _mongoc_topology_description_check_compatible (topology); - } - - /* If server description did not change, then neither did topology - * description */ - if (sd_changed) { - _mongoc_topology_description_monitor_changed (prev_td, topology); - } - - if (prev_td) { - mongoc_topology_description_cleanup (prev_td); - bson_free (prev_td); - } - - mongoc_server_description_destroy (prev_sd); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_has_readable_server -- - * - * SDAM Monitoring Spec: - * "Determines if the topology has a readable server available." - * - * NOTE: this method should only be called by user code in an SDAM - * Monitoring callback. - * - *-------------------------------------------------------------------------- - */ -bool -mongoc_topology_description_has_readable_server ( - const mongoc_topology_description_t *td, const mongoc_read_prefs_t *prefs) -{ - bson_error_t error; - - if (!mongoc_topology_compatible (td, NULL, &error)) { - return false; - } - - /* local threshold argument doesn't matter */ - return mongoc_topology_description_select ( - td, MONGOC_SS_READ, prefs, NULL, NULL, 0) != NULL; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_has_writable_server -- - * - * SDAM Monitoring Spec: - * "Determines if the topology has a writable server available." - * - * NOTE: this method should only be called by user code in an SDAM - * Monitoring callback. - * - *-------------------------------------------------------------------------- - */ -bool -mongoc_topology_description_has_writable_server ( - const mongoc_topology_description_t *td) -{ - bson_error_t error; - - if (!mongoc_topology_compatible (td, NULL, &error)) { - return false; - } - - return mongoc_topology_description_select ( - td, MONGOC_SS_WRITE, NULL, NULL, NULL, 0) != NULL; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_type -- - * - * Get this topology's type, one of the types defined in the Server - * Discovery And Monitoring Spec. - * - * NOTE: this method should only be called by user code in an SDAM - * Monitoring callback. - * - * Returns: - * A string. - * - *-------------------------------------------------------------------------- - */ -const char * -mongoc_topology_description_type (const mongoc_topology_description_t *td) -{ - switch (td->type) { - case MONGOC_TOPOLOGY_UNKNOWN: - return "Unknown"; - case MONGOC_TOPOLOGY_SHARDED: - return "Sharded"; - case MONGOC_TOPOLOGY_RS_NO_PRIMARY: - return "ReplicaSetNoPrimary"; - case MONGOC_TOPOLOGY_RS_WITH_PRIMARY: - return "ReplicaSetWithPrimary"; - case MONGOC_TOPOLOGY_SINGLE: - return "Single"; - case MONGOC_TOPOLOGY_LOAD_BALANCED: - return "LoadBalanced"; - case MONGOC_TOPOLOGY_DESCRIPTION_TYPES: - default: - fprintf (stderr, "ERROR: Unknown topology type %d\n", td->type); - BSON_ASSERT (0); - } - - return NULL; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_description_get_servers -- - * - * Fetch an array of server descriptions for all known servers in the - * topology. - * - * Returns: - * An array you must free with mongoc_server_descriptions_destroy_all. - * - *-------------------------------------------------------------------------- - */ -mongoc_server_description_t ** -mongoc_topology_description_get_servers ( - const mongoc_topology_description_t *td, size_t *n /* OUT */) -{ - const mongoc_set_t *const set = - mc_tpld_servers_const (BSON_ASSERT_PTR_INLINE (td)); - /* enough room for all descriptions, even if some are unknown */ - mongoc_server_description_t **sds = - bson_malloc0 (sizeof (mongoc_server_description_t *) * set->items_len); - - BSON_ASSERT_PARAM (n); - - *n = 0; - - for (size_t i = 0; i < set->items_len; ++i) { - const mongoc_server_description_t *sd = - mongoc_set_get_item_const (set, i); - - if (sd->type != MONGOC_SERVER_UNKNOWN) { - sds[*n] = mongoc_server_description_new_copy (sd); - ++(*n); - } - } - - return sds; -} - -typedef struct { - mongoc_host_list_t *host_list; - size_t num_missing; -} _count_num_hosts_to_remove_ctx_t; - -static bool -_count_num_hosts_to_remove (void *sd_void, void *ctx_void) -{ - mongoc_server_description_t *sd; - _count_num_hosts_to_remove_ctx_t *ctx; - mongoc_host_list_t *host_list; - - sd = sd_void; - ctx = ctx_void; - host_list = ctx->host_list; - - if (!_mongoc_host_list_contains_one (host_list, &sd->host)) { - ++ctx->num_missing; - } - - return true; -} - -typedef struct { - mongoc_host_list_t *host_list; - mongoc_topology_description_t *td; -} _remove_if_not_in_host_list_ctx_t; - -static bool -_remove_if_not_in_host_list_cb (void *sd_void, void *ctx_void) -{ - _remove_if_not_in_host_list_ctx_t *ctx; - mongoc_topology_description_t *td; - mongoc_server_description_t *sd; - mongoc_host_list_t *host_list; - - ctx = ctx_void; - sd = sd_void; - host_list = ctx->host_list; - td = ctx->td; - - if (_mongoc_host_list_contains_one (host_list, &sd->host)) { - return true; - } - _mongoc_topology_description_remove_server (td, sd); - return true; -} - -void -mongoc_topology_description_reconcile (mongoc_topology_description_t *td, - mongoc_host_list_t *host_list) -{ - mongoc_set_t *servers; - size_t host_list_length; - size_t num_missing; - - BSON_ASSERT_PARAM (td); - - servers = mc_tpld_servers (td); - host_list_length = _mongoc_host_list_length (host_list); - - /* Avoid removing all servers in topology, even temporarily, by deferring - * actual removal until after new hosts have been added. */ - { - _count_num_hosts_to_remove_ctx_t ctx; - - ctx.host_list = host_list; - ctx.num_missing = 0u; - - mongoc_set_for_each (servers, _count_num_hosts_to_remove, &ctx); - - num_missing = ctx.num_missing; - } - - /* Polling SRV Records for mongos Discovery Spec: If srvMaxHosts is zero or - * greater than or equal to the number of valid hosts, each valid new host - * MUST be added to the topology as Unknown. */ - if (td->max_hosts == 0 || (size_t) td->max_hosts >= host_list_length) { - mongoc_host_list_t *host; - - LL_FOREACH (host_list, host) - { - /* "add" is really an "upsert" */ - mongoc_topology_description_add_server (td, host->host_and_port, NULL); - } - } - - /* Polling SRV Records for mongos Discovery Spec: If srvMaxHosts is greater - * than zero and less than the number of valid hosts, valid new hosts MUST be - * randomly selected and added to the topology as Unknown until the topology - * has srvMaxHosts hosts. */ - else { - const size_t max_with_missing = td->max_hosts + num_missing; - - size_t idx = 0u; - size_t hl_array_size = 0u; - - /* Polling SRV Records for mongos Discovery Spec: Drivers MUST use the - * same randomization algorithm as they do for initial selection. - * Do not limit size of results yet (pass host_list_length) as we want to - * update any existing hosts in the topology, but add new hosts. - */ - const mongoc_host_list_t *const *hl_array = _mongoc_apply_srv_max_hosts ( - host_list, host_list_length, &hl_array_size); - - for (idx = 0u; - servers->items_len < max_with_missing && idx < hl_array_size; - ++idx) { - const mongoc_host_list_t *const elem = hl_array[idx]; - - /* "add" is really an "upsert" */ - mongoc_topology_description_add_server (td, elem->host_and_port, NULL); - } - - /* There should not be a situation where all items in the valid host list - * were traversed without the number of hosts in the topology reaching - * srvMaxHosts. */ - BSON_ASSERT (servers->items_len == max_with_missing); - - bson_free ((void *) hl_array); - } - - /* Polling SRV Records for mongos Discovery Spec: For all verified host - * names, as returned through the DNS SRV query, the driver MUST remove - * all hosts that are part of the topology, but are no longer in the - * returned set of valid hosts. */ - { - _remove_if_not_in_host_list_ctx_t ctx; - - ctx.host_list = host_list; - ctx.td = td; - - mongoc_set_for_each (servers, _remove_if_not_in_host_list_cb, &ctx); - } - - /* At this point, the number of hosts in the host list should not exceed - * srvMaxHosts. */ - BSON_ASSERT (td->max_hosts == 0 || - servers->items_len <= (size_t) td->max_hosts); -} - - -void -_mongoc_topology_description_clear_connection_pool ( - mongoc_topology_description_t *td, - uint32_t server_id, - const bson_oid_t *service_id) -{ - mongoc_server_description_t *sd; - bson_error_t error; - - BSON_ASSERT (service_id); - - sd = mongoc_topology_description_server_by_id (td, server_id, &error); - if (!sd) { - /* Server removed, ignore and ignore error. */ - return; - } - - TRACE ("clearing pool for server: %s", sd->host.host_and_port); - - mc_tpl_sd_increment_generation (sd, service_id); -} - - -void -mongoc_deprioritized_servers_add_if_sharded ( - mongoc_deprioritized_servers_t *ds, - mongoc_topology_description_type_t topology_type, - const mongoc_server_description_t *sd) -{ - // In a sharded cluster, the server on which the operation failed MUST - // be provided to the server selection mechanism as a deprioritized - // server. - if (topology_type == MONGOC_TOPOLOGY_SHARDED) { - TRACE ("deprioritization: add to list: %s (id: %" PRIu32 ")", - sd->host.host_and_port, - sd->id); - mongoc_deprioritized_servers_add (ds, sd); - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description.h deleted file mode 100644 index 75b7fbca2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-description.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_TOPOLOGY_DESCRIPTION_H -#define MONGOC_TOPOLOGY_DESCRIPTION_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-read-prefs.h" - - -BSON_BEGIN_DECLS - -typedef struct _mongoc_topology_description_t mongoc_topology_description_t; - -MONGOC_EXPORT (void) -mongoc_topology_description_destroy ( - mongoc_topology_description_t *description); - -MONGOC_EXPORT (mongoc_topology_description_t *) -mongoc_topology_description_new_copy ( - const mongoc_topology_description_t *description) - BSON_GNUC_WARN_UNUSED_RESULT; - -MONGOC_EXPORT (bool) -mongoc_topology_description_has_readable_server ( - const mongoc_topology_description_t *td, const mongoc_read_prefs_t *prefs); - -MONGOC_EXPORT (bool) -mongoc_topology_description_has_writable_server ( - const mongoc_topology_description_t *td); - -MONGOC_EXPORT (const char *) -mongoc_topology_description_type (const mongoc_topology_description_t *td); - -MONGOC_EXPORT (mongoc_server_description_t **) -mongoc_topology_description_get_servers ( - const mongoc_topology_description_t *td, - size_t *n) BSON_GNUC_WARN_UNUSED_RESULT; - -BSON_END_DECLS - -#endif /* MONGOC_TOPOLOGY_DESCRIPTION_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-scanner-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-scanner-private.h deleted file mode 100644 index 01e826fef..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-scanner-private.h +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_TOPOLOGY_SCANNER_PRIVATE_H -#define MONGOC_TOPOLOGY_SCANNER_PRIVATE_H - -/* TODO: rename to TOPOLOGY scanner */ - -#include -#include "mongoc-async-private.h" -#include "mongoc-async-cmd-private.h" -#include "mongoc-handshake-private.h" -#include "mongoc-host-list.h" -#include "mongoc-apm-private.h" -#include "mongoc-scram-private.h" -#include "mongoc-ssl.h" -#include "mongoc-crypto-private.h" -#include "mongoc-server-description-private.h" -#include "common-thread-private.h" - -BSON_BEGIN_DECLS - -typedef void (*mongoc_topology_scanner_setup_err_cb_t) ( - uint32_t id, void *data, const bson_error_t *error /* IN */); - -typedef void (*mongoc_topology_scanner_cb_t) ( - uint32_t id, - const bson_t *bson, - int64_t rtt, - void *data, - const bson_error_t *error /* IN */); - -struct mongoc_topology_scanner; -struct mongoc_topology_scanner_node; - -typedef struct mongoc_topology_scanner_node { - uint32_t id; - /* after scanning, this is set to the successful stream if one exists. */ - mongoc_stream_t *stream; - - int64_t last_used; - /* last_failed is set upon a network error trying to check a server. - * last_failed is used to enforce cooldownMS. - * last_failed is not set upon a network error during an application - * operation on @stream. */ - int64_t last_failed; - bool has_auth; - bool hello_ok; - mongoc_host_list_t host; - struct mongoc_topology_scanner *ts; - - struct mongoc_topology_scanner_node *next; - struct mongoc_topology_scanner_node *prev; - - bool retired; - bson_error_t last_error; - - /* the hostname for a node may resolve to multiple DNS results. - * dns_results has the full list of DNS results, ordered by host preference. - * successful_dns_result is the most recent successful DNS result. - */ - struct addrinfo *dns_results; - struct addrinfo *successful_dns_result; - int64_t last_dns_cache; - - /* used by single-threaded clients to store negotiated sasl mechanisms on a - * node. */ - mongoc_handshake_sasl_supported_mechs_t sasl_supported_mechs; - bool negotiated_sasl_supported_mechs; - bson_t speculative_auth_response; - mongoc_scram_t scram; - - /* handshake_sd is a server description constructed from the response of the - * initial handshake. It is bound to the lifetime of stream. */ - mongoc_server_description_t *handshake_sd; -} mongoc_topology_scanner_node_t; - -typedef enum handshake_state_t { - /** - * The handshake command has no value. The handshake_cmd pointer will be - * NULL. - */ - HANDSHAKE_CMD_UNINITIALIZED, - /** - * The handshake command could not be constructed because it would be too - * large. The handshake_cmd pointer will be NULL. - */ - HANDSHAKE_CMD_TOO_BIG, - /** - * The handshake command is valid and ready to be copied-from. - */ - HANDSHAKE_CMD_OKAY, -} handshake_state_t; - -typedef struct mongoc_topology_scanner { - mongoc_async_t *async; - int64_t connect_timeout_msec; - mongoc_topology_scanner_node_t *nodes; - bson_t hello_cmd; - bson_t legacy_hello_cmd; - bson_mutex_t handshake_cmd_mtx; - bson_t *handshake_cmd; - handshake_state_t handshake_state; - bson_t cluster_time; - const char *appname; - - mongoc_topology_scanner_setup_err_cb_t setup_err_cb; - mongoc_topology_scanner_cb_t cb; - void *cb_data; - const mongoc_uri_t *uri; - mongoc_async_cmd_setup_t setup; - mongoc_stream_initiator_t initiator; - void *initiator_context; - bson_error_t error; - -#ifdef MONGOC_ENABLE_SSL - mongoc_ssl_opt_t *ssl_opts; -#endif - - mongoc_apm_callbacks_t apm_callbacks; - void *apm_context; - int64_t dns_cache_timeout_ms; - /* only used by single-threaded clients to negotiate auth mechanisms. */ - bool negotiate_sasl_supported_mechs; - bool bypass_cooldown; - bool speculative_authentication; - - mongoc_server_api_t *api; - bool loadbalanced; -} mongoc_topology_scanner_t; - -mongoc_topology_scanner_t * -mongoc_topology_scanner_new ( - const mongoc_uri_t *uri, - mongoc_topology_scanner_setup_err_cb_t setup_err_cb, - mongoc_topology_scanner_cb_t cb, - void *data, - int64_t connect_timeout_msec); - -void -mongoc_topology_scanner_destroy (mongoc_topology_scanner_t *ts); - -bool -mongoc_topology_scanner_valid (mongoc_topology_scanner_t *ts); - -void -mongoc_topology_scanner_add (mongoc_topology_scanner_t *ts, - const mongoc_host_list_t *host, - uint32_t id, - bool hello_ok); - -void -mongoc_topology_scanner_scan (mongoc_topology_scanner_t *ts, uint32_t id); - -void -mongoc_topology_scanner_disconnect (mongoc_topology_scanner_t *scanner); - -void -mongoc_topology_scanner_node_retire (mongoc_topology_scanner_node_t *node); - -void -mongoc_topology_scanner_node_disconnect (mongoc_topology_scanner_node_t *node, - bool failed); - -void -mongoc_topology_scanner_node_destroy (mongoc_topology_scanner_node_t *node, - bool failed); - -bool -mongoc_topology_scanner_in_cooldown (mongoc_topology_scanner_t *ts, - int64_t when); - -void -mongoc_topology_scanner_start (mongoc_topology_scanner_t *ts, - bool obey_cooldown); - -void -mongoc_topology_scanner_work (mongoc_topology_scanner_t *ts); - -void -_mongoc_topology_scanner_finish (mongoc_topology_scanner_t *ts); - -void -mongoc_topology_scanner_get_error (mongoc_topology_scanner_t *ts, - bson_error_t *error); - -void -mongoc_topology_scanner_reset (mongoc_topology_scanner_t *ts); - -void -mongoc_topology_scanner_node_setup (mongoc_topology_scanner_node_t *node, - bson_error_t *error); - -mongoc_topology_scanner_node_t * -mongoc_topology_scanner_get_node (mongoc_topology_scanner_t *ts, uint32_t id); - -void -_mongoc_topology_scanner_add_speculative_authentication ( - bson_t *cmd, - const mongoc_uri_t *uri, - const mongoc_ssl_opt_t *ssl_opts, - mongoc_scram_t *scram /* OUT */); - -void -_mongoc_topology_scanner_parse_speculative_authentication ( - const bson_t *hello, bson_t *speculative_authenticate); - -const char * -_mongoc_topology_scanner_get_speculative_auth_mechanism ( - const mongoc_uri_t *uri); - -const bson_t * -_mongoc_topology_scanner_get_monitoring_cmd (mongoc_topology_scanner_t *ts, - bool hello_ok); - -/** - * @brief Get the scanner's associated handshake command BSON document. - * - * @param ts The scanner to inspect - * @param copy_into A pointer to an initialized bson_t. The handshake command - * will be copied into the pointee. - */ -void -_mongoc_topology_scanner_dup_handshake_cmd (mongoc_topology_scanner_t *ts, - bson_t *copy_into); - -bool -mongoc_topology_scanner_has_node_for_host (mongoc_topology_scanner_t *ts, - mongoc_host_list_t *host); - -void -mongoc_topology_scanner_set_stream_initiator (mongoc_topology_scanner_t *ts, - mongoc_stream_initiator_t si, - void *ctx); -bool -_mongoc_topology_scanner_set_appname (mongoc_topology_scanner_t *ts, - const char *name); -void -_mongoc_topology_scanner_set_cluster_time (mongoc_topology_scanner_t *ts, - const bson_t *cluster_time); - -void -_mongoc_topology_scanner_set_dns_cache_timeout (mongoc_topology_scanner_t *ts, - int64_t timeout_ms); - -#ifdef MONGOC_ENABLE_SSL -void -mongoc_topology_scanner_set_ssl_opts (mongoc_topology_scanner_t *ts, - mongoc_ssl_opt_t *opts); -#endif - -bool -mongoc_topology_scanner_node_in_cooldown (mongoc_topology_scanner_node_t *node, - int64_t when); - -void -_mongoc_topology_scanner_set_server_api (mongoc_topology_scanner_t *ts, - const mongoc_server_api_t *api); - -void -_mongoc_topology_scanner_set_loadbalanced (mongoc_topology_scanner_t *ts, - bool val); - -/* for testing. */ -mongoc_stream_t * -_mongoc_topology_scanner_tcp_initiate (mongoc_async_cmd_t *acmd); - -/* Returns true if versioned server API has been selected, otherwise - * false. */ -bool -mongoc_topology_scanner_uses_server_api (const mongoc_topology_scanner_t *ts); - -/* Returns true if load balancing mode has been selected, otherwise false. */ -bool -mongoc_topology_scanner_uses_loadbalanced (const mongoc_topology_scanner_t *ts); - -BSON_END_DECLS - -#endif /* MONGOC_TOPOLOGY_SCANNER_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-scanner.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-scanner.c deleted file mode 100644 index f8065b57b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology-scanner.c +++ /dev/null @@ -1,1516 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "mongoc-config.h" -#include "mongoc-error.h" -#include "mongoc-trace-private.h" -#include "mongoc-topology-scanner-private.h" -#include "mongoc-stream-private.h" -#include "mongoc-stream-socket.h" - -#include "mongoc-handshake.h" -#include "mongoc-handshake-private.h" - -#ifdef MONGOC_ENABLE_SSL -#include "mongoc-stream-tls.h" -#endif - -#include "mongoc-counters-private.h" -#include "utlist.h" -#include "mongoc-topology-private.h" -#include "mongoc-host-list-private.h" -#include "mongoc-uri-private.h" -#include "mongoc-cluster-private.h" -#include "mongoc-client-private.h" -#include "mongoc-util-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "topology_scanner" - -#define DNS_CACHE_TIMEOUT_MS 10 * 60 * 1000 -#define HAPPY_EYEBALLS_DELAY_MS 250 - -/* forward declarations */ -static void -_async_connected (mongoc_async_cmd_t *acmd); - -static void -_async_success (mongoc_async_cmd_t *acmd, - const bson_t *hello_response, - int64_t duration_usec); - -static void -_async_error_or_timeout (mongoc_async_cmd_t *acmd, - int64_t duration_usec, - const char *default_err_msg); - -static void -_async_handler (mongoc_async_cmd_t *acmd, - mongoc_async_cmd_result_t async_status, - const bson_t *hello_response, - int64_t duration_usec); - -static void -_mongoc_topology_scanner_monitor_heartbeat_started ( - const mongoc_topology_scanner_t *ts, const mongoc_host_list_t *host); - -static void -_mongoc_topology_scanner_monitor_heartbeat_succeeded ( - const mongoc_topology_scanner_t *ts, - const mongoc_host_list_t *host, - const bson_t *reply, - int64_t duration_usec); - -static void -_mongoc_topology_scanner_monitor_heartbeat_failed ( - const mongoc_topology_scanner_t *ts, - const mongoc_host_list_t *host, - const bson_error_t *error, - int64_t duration_usec); - - -/* reset "retired" nodes that failed or were removed in the previous scan */ -static void -_delete_retired_nodes (mongoc_topology_scanner_t *ts); - -/* cancel any pending async commands for a specific node excluding acmd. - * If acmd is NULL, cancel all async commands on the node. */ -static void -_cancel_commands_excluding (mongoc_topology_scanner_node_t *node, - mongoc_async_cmd_t *acmd); - -/* return the number of pending async commands for a node. */ -static int -_count_acmds (mongoc_topology_scanner_node_t *node); - -/* if acmd fails, schedule the sibling commands sooner. */ -static void -_jumpstart_other_acmds (mongoc_topology_scanner_node_t *node, - mongoc_async_cmd_t *acmd); - -static void -_add_hello (mongoc_topology_scanner_t *ts) -{ - BSON_APPEND_INT32 (&ts->hello_cmd, "hello", 1); - BSON_APPEND_BOOL (&ts->hello_cmd, "helloOk", true); - - BSON_APPEND_INT32 (&ts->legacy_hello_cmd, HANDSHAKE_CMD_LEGACY_HELLO, 1); - BSON_APPEND_BOOL (&ts->legacy_hello_cmd, "helloOk", true); - - /* Append appropriate server API metadata (such as "serverApi") if selected: - */ - if (mongoc_topology_scanner_uses_server_api (ts)) { - _mongoc_cmd_append_server_api (&ts->hello_cmd, ts->api); - } -} - -static void -_init_hello (mongoc_topology_scanner_t *ts) -{ - bson_init (&ts->hello_cmd); - bson_init (&ts->legacy_hello_cmd); - bson_init (&ts->cluster_time); - ts->handshake_cmd = NULL; - - _add_hello (ts); -} - -static void -_reset_hello (mongoc_topology_scanner_t *ts) -{ - bson_t *prev_cmd; - bson_reinit (&ts->hello_cmd); - bson_reinit (&ts->legacy_hello_cmd); - - bson_mutex_lock (&ts->handshake_cmd_mtx); - prev_cmd = ts->handshake_cmd; - ts->handshake_cmd = NULL; - ts->handshake_state = HANDSHAKE_CMD_UNINITIALIZED; - bson_mutex_unlock (&ts->handshake_cmd_mtx); - bson_destroy (prev_cmd); - - _add_hello (ts); -} - -const char * -_mongoc_topology_scanner_get_speculative_auth_mechanism ( - const mongoc_uri_t *uri) -{ - const char *mechanism = mongoc_uri_get_auth_mechanism (uri); - bool requires_auth = mechanism || mongoc_uri_get_username (uri); - - if (!requires_auth) { - return NULL; - } - - if (!mechanism) { - return "SCRAM-SHA-256"; - } - - return mechanism; -} - -void -_mongoc_topology_scanner_add_speculative_authentication ( - bson_t *cmd, - const mongoc_uri_t *uri, - const mongoc_ssl_opt_t *ssl_opts, - mongoc_scram_t *scram /* OUT */) -{ - bson_t auth_cmd; - bson_error_t error; - bool has_auth = false; - const char *mechanism = - _mongoc_topology_scanner_get_speculative_auth_mechanism (uri); - - if (!mechanism) { - return; - } - - if (strcasecmp (mechanism, "MONGODB-X509") == 0) { - /* Ignore errors while building authentication document: we proceed with - * the handshake as usual and let the subsequent authenticate command - * fail. */ - if (_mongoc_cluster_get_auth_cmd_x509 ( - uri, ssl_opts, &auth_cmd, &error)) { - has_auth = true; - BSON_APPEND_UTF8 (&auth_cmd, "db", "$external"); - } - } - -#ifdef MONGOC_ENABLE_CRYPTO - if (strcasecmp (mechanism, "SCRAM-SHA-1") == 0 || - strcasecmp (mechanism, "SCRAM-SHA-256") == 0) { - mongoc_crypto_hash_algorithm_t algo = - strcasecmp (mechanism, "SCRAM-SHA-1") == 0 - ? MONGOC_CRYPTO_ALGORITHM_SHA_1 - : MONGOC_CRYPTO_ALGORITHM_SHA_256; - - _mongoc_uri_init_scram (uri, scram, algo); - - if (_mongoc_cluster_get_auth_cmd_scram (algo, scram, &auth_cmd, &error)) { - const char *auth_source; - - if (!(auth_source = mongoc_uri_get_auth_source (uri)) || - (*auth_source == '\0')) { - auth_source = "admin"; - } - - has_auth = true; - BSON_APPEND_UTF8 (&auth_cmd, "db", auth_source); - } - } -#endif - - if (has_auth) { - BSON_APPEND_DOCUMENT (cmd, "speculativeAuthenticate", &auth_cmd); - bson_destroy (&auth_cmd); - } -} - -void -_mongoc_topology_scanner_parse_speculative_authentication ( - const bson_t *hello, bson_t *speculative_authenticate) -{ - bson_iter_t iter; - uint32_t data_len; - const uint8_t *data; - bson_t auth_response; - - BSON_ASSERT (hello); - BSON_ASSERT (speculative_authenticate); - - if (!bson_iter_init_find (&iter, hello, "speculativeAuthenticate")) { - return; - } - - bson_iter_document (&iter, &data_len, &data); - BSON_ASSERT (bson_init_static (&auth_response, data, data_len)); - - bson_destroy (speculative_authenticate); - bson_copy_to (&auth_response, speculative_authenticate); -} - -static bson_t * -_build_handshake_cmd (const bson_t *basis_cmd, - const char *appname, - const mongoc_uri_t *uri, - bool is_loadbalanced) -{ - bson_t *doc = bson_copy (basis_cmd); - bson_iter_t iter; - const bson_t *compressors; - bson_array_builder_t *subarray; - - BSON_ASSERT (doc); - bson_t *handshake_doc = - _mongoc_handshake_build_doc_with_application (appname); - - if (!handshake_doc) { - bson_destroy (doc); - return NULL; - } - bson_append_document (doc, HANDSHAKE_FIELD, -1, handshake_doc); - bson_destroy (handshake_doc); - - BSON_APPEND_ARRAY_BUILDER_BEGIN (doc, "compression", &subarray); - if (uri) { - compressors = mongoc_uri_get_compressors (uri); - - if (bson_iter_init (&iter, compressors)) { - while (bson_iter_next (&iter)) { - bson_array_builder_append_utf8 ( - subarray, bson_iter_key (&iter), -1); - } - } - } - bson_append_array_builder_end (doc, subarray); - - if (is_loadbalanced) { - BSON_APPEND_BOOL (doc, "loadBalanced", true); - } - - /* Return whether the handshake doc fit the size limit */ - return doc; -} - -static bool -_should_use_op_msg (const mongoc_topology_scanner_t *ts) -{ - return mongoc_topology_scanner_uses_server_api (ts) || - mongoc_topology_scanner_uses_loadbalanced (ts); -} - -const bson_t * -_mongoc_topology_scanner_get_monitoring_cmd (mongoc_topology_scanner_t *ts, - bool hello_ok) -{ - return hello_ok || _should_use_op_msg (ts) ? &ts->hello_cmd - : &ts->legacy_hello_cmd; -} - -void -_mongoc_topology_scanner_dup_handshake_cmd (mongoc_topology_scanner_t *ts, - bson_t *copy_into) -{ - bson_t *new_cmd; - const char *appname; - BSON_ASSERT_PARAM (ts); - BSON_ASSERT_PARAM (copy_into); - - /* appname will only be changed from NULL, so a non-null pointer will never - * be invalidated after this fetch. */ - appname = - bson_atomic_ptr_fetch ((void *) &ts->appname, bson_memory_order_relaxed); - - bson_mutex_lock (&ts->handshake_cmd_mtx); - /* If this is the first time using the node or if it's the first time - * using it after a failure, build handshake doc */ - if (ts->handshake_state != HANDSHAKE_CMD_UNINITIALIZED) { - /* We're good to just return the handshake now */ - goto after_init; - } - - /* There is not yet a handshake command associated with this scanner. - * Initialize one and set it now. */ - /* Note: Don't hold the mutex while we build our command */ - /* Construct a new handshake command to be sent */ - BSON_ASSERT (ts->handshake_cmd == NULL); - bson_mutex_unlock (&ts->handshake_cmd_mtx); - new_cmd = _build_handshake_cmd ( - _should_use_op_msg (ts) ? &ts->hello_cmd : &ts->legacy_hello_cmd, - appname, - ts->uri, - ts->loadbalanced); - bson_mutex_lock (&ts->handshake_cmd_mtx); - if (ts->handshake_state != HANDSHAKE_CMD_UNINITIALIZED) { - /* Someone else updated the handshake_cmd while we were building ours. - * Defer to their copy and just destroy the one we created. */ - bson_destroy (new_cmd); - goto after_init; - } - BSON_ASSERT (ts->handshake_cmd == NULL); - /* We're still the one updating the command */ - ts->handshake_cmd = new_cmd; - /* The "_build" may have failed. */ - /* Even if new_cmd is NULL, this is still what we want */ - ts->handshake_state = - new_cmd == NULL ? HANDSHAKE_CMD_TOO_BIG : HANDSHAKE_CMD_OKAY; - if (ts->handshake_state == HANDSHAKE_CMD_TOO_BIG) { - MONGOC_WARNING ("Handshake doc too big, not including in hello"); - } - -after_init: - /* If the doc turned out to be too big */ - if (ts->handshake_state == HANDSHAKE_CMD_TOO_BIG) { - bson_t *ret = - _should_use_op_msg (ts) ? &ts->hello_cmd : &ts->legacy_hello_cmd; - bson_copy_to (ret, copy_into); - } else { - BSON_ASSERT (ts->handshake_cmd != NULL); - bson_copy_to (ts->handshake_cmd, copy_into); - } - bson_mutex_unlock (&ts->handshake_cmd_mtx); -} - -static void -_begin_hello_cmd (mongoc_topology_scanner_node_t *node, - mongoc_stream_t *stream, - bool is_setup_done, - struct addrinfo *dns_result, - int64_t initiate_delay_ms, - bool use_handshake) -{ - mongoc_topology_scanner_t *ts = node->ts; - bson_t cmd; - - /* If we're asked to use a specific API version, we should send our - hello handshake via op_msg rather than the legacy op_query: */ - const int32_t cmd_opcode = - _should_use_op_msg (ts) ? MONGOC_OP_CODE_MSG : MONGOC_OP_CODE_QUERY; - - if (node->last_used != -1 && node->last_failed == -1 && !use_handshake) { - /* The node's been used before and not failed recently */ - bson_copy_to ( - _mongoc_topology_scanner_get_monitoring_cmd (ts, node->hello_ok), - &cmd); - } else { - _mongoc_topology_scanner_dup_handshake_cmd (ts, &cmd); - } - - if (node->ts->negotiate_sasl_supported_mechs && - !node->negotiated_sasl_supported_mechs) { - _mongoc_handshake_append_sasl_supported_mechs (ts->uri, &cmd); - } - - if (node->ts->speculative_authentication && !node->has_auth && - bson_empty (&node->speculative_auth_response) && node->scram.step == 0) { - mongoc_ssl_opt_t *ssl_opts = NULL; - -#ifdef MONGOC_ENABLE_SSL - ssl_opts = ts->ssl_opts; -#endif - - _mongoc_topology_scanner_add_speculative_authentication ( - &cmd, ts->uri, ssl_opts, &node->scram); - } - - if (!bson_empty (&ts->cluster_time)) { - bson_append_document (&cmd, "$clusterTime", 12, &ts->cluster_time); - } - - /* if the node should connect with a TCP socket, stream will be null, and - * dns_result will be set. The async loop is responsible for calling the - * _tcp_initiator to construct TCP sockets. */ - mongoc_async_cmd_new (ts->async, - stream, - is_setup_done, - dns_result, - _mongoc_topology_scanner_tcp_initiate, - initiate_delay_ms, - ts->setup, - node->host.host, - "admin", - &cmd, - cmd_opcode, - &_async_handler, - node, - ts->connect_timeout_msec); - - bson_destroy (&cmd); -} - - -mongoc_topology_scanner_t * -mongoc_topology_scanner_new ( - const mongoc_uri_t *uri, - mongoc_topology_scanner_setup_err_cb_t setup_err_cb, - mongoc_topology_scanner_cb_t cb, - void *data, - int64_t connect_timeout_msec) -{ - mongoc_topology_scanner_t *ts = - BSON_ALIGNED_ALLOC0 (mongoc_topology_scanner_t); - - ts->async = mongoc_async_new (); - - ts->setup_err_cb = setup_err_cb; - ts->cb = cb; - ts->cb_data = data; - ts->uri = uri; - ts->appname = NULL; - ts->api = NULL; - ts->handshake_state = HANDSHAKE_CMD_UNINITIALIZED; - ts->connect_timeout_msec = connect_timeout_msec; - /* may be overridden for testing. */ - ts->dns_cache_timeout_ms = DNS_CACHE_TIMEOUT_MS; - bson_mutex_init (&ts->handshake_cmd_mtx); - - _init_hello (ts); - - return ts; -} - -#ifdef MONGOC_ENABLE_SSL -void -mongoc_topology_scanner_set_ssl_opts (mongoc_topology_scanner_t *ts, - mongoc_ssl_opt_t *opts) -{ - ts->ssl_opts = opts; - ts->setup = mongoc_async_cmd_tls_setup; -} -#endif - -void -mongoc_topology_scanner_set_stream_initiator (mongoc_topology_scanner_t *ts, - mongoc_stream_initiator_t si, - void *ctx) -{ - ts->initiator = si; - ts->initiator_context = ctx; - ts->setup = NULL; -} - -void -mongoc_topology_scanner_destroy (mongoc_topology_scanner_t *ts) -{ - mongoc_topology_scanner_node_t *ele, *tmp; - - DL_FOREACH_SAFE (ts->nodes, ele, tmp) - { - mongoc_topology_scanner_node_destroy (ele, false); - } - - mongoc_async_destroy (ts->async); - bson_destroy (&ts->hello_cmd); - bson_destroy (&ts->legacy_hello_cmd); - bson_destroy (ts->handshake_cmd); - bson_destroy (&ts->cluster_time); - mongoc_server_api_destroy (ts->api); - bson_mutex_destroy (&ts->handshake_cmd_mtx); - - /* This field can be set by a mongoc_client */ - bson_free ((char *) ts->appname); - - bson_free (ts); -} - -/* whether the scanner was successfully initialized - false if a mongodb+srv - * URI failed to resolve to any hosts */ -bool -mongoc_topology_scanner_valid (mongoc_topology_scanner_t *ts) -{ - return ts->nodes != NULL; -} - -void -mongoc_topology_scanner_add (mongoc_topology_scanner_t *ts, - const mongoc_host_list_t *host, - uint32_t id, - bool hello_ok) -{ - mongoc_topology_scanner_node_t *node; - - node = BSON_ALIGNED_ALLOC0 (mongoc_topology_scanner_node_t); - - memcpy (&node->host, host, sizeof (*host)); - - node->id = id; - node->ts = ts; - node->last_failed = -1; - node->last_used = -1; - node->hello_ok = hello_ok; - bson_init (&node->speculative_auth_response); - - DL_APPEND (ts->nodes, node); -} - -void -mongoc_topology_scanner_scan (mongoc_topology_scanner_t *ts, uint32_t id) -{ - mongoc_topology_scanner_node_t *node; - - node = mongoc_topology_scanner_get_node (ts, id); - - /* begin non-blocking connection, don't wait for success */ - if (node) { - mongoc_topology_scanner_node_setup (node, &node->last_error); - } - - /* if setup fails the node stays in the scanner. destroyed after the scan. */ -} - -void -mongoc_topology_scanner_disconnect (mongoc_topology_scanner_t *scanner) -{ - mongoc_topology_scanner_node_t *node; - - BSON_ASSERT (scanner); - node = scanner->nodes; - - while (node) { - mongoc_topology_scanner_node_disconnect (node, false); - node = node->next; - } -} - -void -mongoc_topology_scanner_node_retire (mongoc_topology_scanner_node_t *node) -{ - /* cancel any pending commands. */ - _cancel_commands_excluding (node, NULL); - - node->retired = true; -} - -void -mongoc_topology_scanner_node_disconnect (mongoc_topology_scanner_node_t *node, - bool failed) -{ - /* the node may or may not have succeeded in finding a working stream. */ - if (node->stream) { - if (failed) { - mongoc_stream_failed (node->stream); - } else { - mongoc_stream_destroy (node->stream); - } - - node->stream = NULL; - } - mongoc_server_description_destroy (node->handshake_sd); - node->handshake_sd = NULL; -} - -void -mongoc_topology_scanner_node_destroy (mongoc_topology_scanner_node_t *node, - bool failed) -{ - DL_DELETE (node->ts->nodes, node); - mongoc_topology_scanner_node_disconnect (node, failed); - if (node->dns_results) { - freeaddrinfo (node->dns_results); - } - - bson_destroy (&node->speculative_auth_response); - -#ifdef MONGOC_ENABLE_CRYPTO - _mongoc_scram_destroy (&node->scram); -#endif - - bson_free (node); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scanner_get_node -- - * - * Return the scanner node with the given id. - * - *-------------------------------------------------------------------------- - */ -mongoc_topology_scanner_node_t * -mongoc_topology_scanner_get_node (mongoc_topology_scanner_t *ts, uint32_t id) -{ - mongoc_topology_scanner_node_t *ele, *tmp; - - DL_FOREACH_SAFE (ts->nodes, ele, tmp) - { - if (ele->id == id) { - return ele; - } - - if (ele->id > id) { - break; - } - } - - return NULL; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scanner_has_node_for_host -- - * - * Whether the scanner has a node for the given host and port. - * - *-------------------------------------------------------------------------- - */ -bool -mongoc_topology_scanner_has_node_for_host (mongoc_topology_scanner_t *ts, - mongoc_host_list_t *host) -{ - mongoc_topology_scanner_node_t *ele, *tmp; - - DL_FOREACH_SAFE (ts->nodes, ele, tmp) - { - if (_mongoc_host_list_compare_one (&ele->host, host)) { - return true; - } - } - - return false; -} - -static void -_async_connected (mongoc_async_cmd_t *acmd) -{ - mongoc_topology_scanner_node_t *node = - (mongoc_topology_scanner_node_t *) acmd->data; - /* this cmd connected successfully, cancel other cmds on this node. */ - _cancel_commands_excluding (node, acmd); - node->successful_dns_result = acmd->dns_result; -} - -static void -_async_success (mongoc_async_cmd_t *acmd, - const bson_t *hello_response, - int64_t duration_usec) -{ - void *data = acmd->data; - mongoc_topology_scanner_node_t *node = - (mongoc_topology_scanner_node_t *) data; - mongoc_stream_t *stream = acmd->stream; - mongoc_topology_scanner_t *ts = node->ts; - - if (node->retired) { - if (stream) { - mongoc_stream_failed (stream); - } - return; - } - - node->last_used = bson_get_monotonic_time (); - node->last_failed = -1; - - _mongoc_topology_scanner_monitor_heartbeat_succeeded ( - ts, &node->host, hello_response, duration_usec); - - /* set our successful stream. */ - BSON_ASSERT (!node->stream); - node->stream = stream; - - if (!node->handshake_sd) { - mongoc_server_description_t sd; - - /* Store a server description associated with the handshake. */ - mongoc_server_description_init (&sd, node->host.host_and_port, node->id); - mongoc_server_description_handle_hello ( - &sd, hello_response, duration_usec / 1000, &acmd->error); - node->handshake_sd = mongoc_server_description_new_copy (&sd); - mongoc_server_description_cleanup (&sd); - } - - if (ts->negotiate_sasl_supported_mechs && - !node->negotiated_sasl_supported_mechs) { - _mongoc_handshake_parse_sasl_supported_mechs ( - hello_response, &node->sasl_supported_mechs); - } - - if (ts->speculative_authentication) { - _mongoc_topology_scanner_parse_speculative_authentication ( - hello_response, &node->speculative_auth_response); - } - - /* mongoc_topology_scanner_cb_t takes rtt_msec, not usec */ - ts->cb (node->id, - hello_response, - duration_usec / 1000, - ts->cb_data, - &acmd->error); -} - -static void -_async_error_or_timeout (mongoc_async_cmd_t *acmd, - int64_t duration_usec, - const char *default_err_msg) -{ - void *data = acmd->data; - mongoc_topology_scanner_node_t *node = - (mongoc_topology_scanner_node_t *) data; - mongoc_stream_t *stream = acmd->stream; - mongoc_topology_scanner_t *ts = node->ts; - bson_error_t *error = &acmd->error; - int64_t now = bson_get_monotonic_time (); - const char *message; - - /* the stream may have failed on initiation. */ - if (stream) { - mongoc_stream_failed (stream); - } - - if (node->retired) { - return; - } - - node->last_used = now; - - if (!node->stream && _count_acmds (node) == 1) { - /* there are no remaining streams, connecting has failed. */ - node->last_failed = now; - if (error->code) { - message = error->message; - } else { - message = default_err_msg; - } - - /* invalidate any cached DNS results. */ - if (node->dns_results) { - freeaddrinfo (node->dns_results); - node->dns_results = NULL; - node->successful_dns_result = NULL; - } - - bson_set_error (&node->last_error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_STREAM_CONNECT, - "%s calling hello on \'%s\'", - message, - node->host.host_and_port); - - _mongoc_topology_scanner_monitor_heartbeat_failed ( - ts, &node->host, &node->last_error, duration_usec); - - /* call the topology scanner callback. cannot connect to this node. - * callback takes rtt_msec, not usec. */ - ts->cb (node->id, NULL, duration_usec / 1000, ts->cb_data, error); - - mongoc_server_description_destroy (node->handshake_sd); - node->handshake_sd = NULL; - } else { - /* there are still more commands left for this node or it succeeded - * with another stream. skip the topology scanner callback. */ - _jumpstart_other_acmds (node, acmd); - } -} - -/* - *----------------------------------------------------------------------- - * - * This is the callback passed to async_cmd when we're running - * hellos from within the topology monitor. - * - *----------------------------------------------------------------------- - */ - -static void -_async_handler (mongoc_async_cmd_t *acmd, - mongoc_async_cmd_result_t async_status, - const bson_t *hello_response, - int64_t duration_usec) -{ - BSON_ASSERT (acmd->data); - - switch (async_status) { - case MONGOC_ASYNC_CMD_CONNECTED: - _async_connected (acmd); - return; - case MONGOC_ASYNC_CMD_SUCCESS: - _async_success (acmd, hello_response, duration_usec); - return; - case MONGOC_ASYNC_CMD_TIMEOUT: - _async_error_or_timeout (acmd, duration_usec, "connection timeout"); - return; - case MONGOC_ASYNC_CMD_ERROR: - _async_error_or_timeout (acmd, duration_usec, "connection error"); - return; - case MONGOC_ASYNC_CMD_IN_PROGRESS: - default: - fprintf (stderr, "unexpected async status: %d\n", async_status); - BSON_ASSERT (false); - return; - } -} - -mongoc_stream_t * -_mongoc_topology_scanner_node_setup_stream_for_tls ( - mongoc_topology_scanner_node_t *node, mongoc_stream_t *stream) -{ -#ifdef MONGOC_ENABLE_SSL - mongoc_stream_t *tls_stream; -#endif - if (!stream) { - return NULL; - } -#ifdef MONGOC_ENABLE_SSL - if (node->ts->ssl_opts) { - tls_stream = mongoc_stream_tls_new_with_hostname ( - stream, node->host.host, node->ts->ssl_opts, 1); - if (!tls_stream) { - mongoc_stream_destroy (stream); - return NULL; - } else { - return tls_stream; - } - } -#endif - return stream; -} - -/* attempt to create a new socket stream using this dns result. */ -mongoc_stream_t * -_mongoc_topology_scanner_tcp_initiate (mongoc_async_cmd_t *acmd) -{ - mongoc_topology_scanner_node_t *node = - (mongoc_topology_scanner_node_t *) acmd->data; - struct addrinfo *res = acmd->dns_result; - mongoc_socket_t *sock = NULL; - - BSON_ASSERT (acmd->dns_result); - /* create a new non-blocking socket. */ - if (!(sock = mongoc_socket_new ( - res->ai_family, res->ai_socktype, res->ai_protocol))) { - return NULL; - } - - (void) mongoc_socket_connect ( - sock, res->ai_addr, (mongoc_socklen_t) res->ai_addrlen, 0); - - return _mongoc_topology_scanner_node_setup_stream_for_tls ( - node, mongoc_stream_socket_new (sock)); -} -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scanner_node_setup_tcp -- - * - * Create an async command for each DNS record found for this node. - * - * Returns: - * A bool. On failure error is set. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_topology_scanner_node_setup_tcp (mongoc_topology_scanner_node_t *node, - bson_error_t *error) -{ - struct addrinfo hints; - struct addrinfo *iter; - char portstr[8]; - mongoc_host_list_t *host; - int s; - int64_t delay = 0; - int64_t now = bson_get_monotonic_time (); - - ENTRY; - - host = &node->host; - - /* if cached dns results are expired, flush. */ - if (node->dns_results && - (now - node->last_dns_cache) > node->ts->dns_cache_timeout_ms * 1000) { - freeaddrinfo (node->dns_results); - node->dns_results = NULL; - node->successful_dns_result = NULL; - } - - if (!node->dns_results) { - bson_snprintf (portstr, sizeof portstr, "%hu", host->port); - - memset (&hints, 0, sizeof hints); - hints.ai_family = host->family; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = 0; - hints.ai_protocol = 0; - - s = getaddrinfo (host->host, portstr, &hints, &node->dns_results); - - if (s != 0) { - mongoc_counter_dns_failure_inc (); - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "Failed to resolve '%s'", - host->host); - RETURN (false); - } - - mongoc_counter_dns_success_inc (); - node->last_dns_cache = now; - } - - if (node->successful_dns_result) { - _begin_hello_cmd (node, - NULL /* stream */, - false /* is_setup_done */, - node->successful_dns_result, - 0 /* initiate_delay_ms */, - true /* use_handshake */); - } else { - LL_FOREACH2 (node->dns_results, iter, ai_next) - { - _begin_hello_cmd (node, - NULL /* stream */, - false /* is_setup_done */, - iter, - delay, - true /* use_handshake */); - /* each subsequent DNS result will have an additional 250ms delay. */ - delay += HAPPY_EYEBALLS_DELAY_MS; - } - } - - RETURN (true); -} - -bool -mongoc_topology_scanner_node_connect_unix (mongoc_topology_scanner_node_t *node, - bson_error_t *error) -{ -#ifdef _WIN32 - ENTRY; - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "UNIX domain sockets not supported on win32."); - RETURN (false); -#else - struct sockaddr_un saddr; - mongoc_socket_t *sock; - mongoc_stream_t *stream; - mongoc_host_list_t *host; - - ENTRY; - - host = &node->host; - - memset (&saddr, 0, sizeof saddr); - saddr.sun_family = AF_UNIX; - bson_snprintf (saddr.sun_path, sizeof saddr.sun_path - 1, "%s", host->host); - - sock = mongoc_socket_new (AF_UNIX, SOCK_STREAM, 0); - - if (sock == NULL) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to create socket."); - RETURN (false); - } - - if (-1 == mongoc_socket_connect ( - sock, (struct sockaddr *) &saddr, sizeof saddr, -1)) { - char buf[128]; - char *errstr; - - errstr = bson_strerror_r (mongoc_socket_errno (sock), buf, sizeof (buf)); - - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "Failed to connect to UNIX domain socket: %s", - errstr); - mongoc_socket_destroy (sock); - RETURN (false); - } - - stream = _mongoc_topology_scanner_node_setup_stream_for_tls ( - node, mongoc_stream_socket_new (sock)); - if (stream) { - _begin_hello_cmd (node, - stream, - false /* is_setup_done */, - NULL /* dns result */, - 0 /* delay */, - true /* use_handshake */); - RETURN (true); - } - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "Failed to create TLS stream"); - RETURN (false); -#endif -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scanner_node_setup -- - * - * Create a stream and begin a non-blocking connect. - * - * Returns: - * true on success, or false and error is set. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_topology_scanner_node_setup (mongoc_topology_scanner_node_t *node, - bson_error_t *error) -{ - bool success = false; - mongoc_stream_t *stream; - int64_t start; - - _mongoc_topology_scanner_monitor_heartbeat_started (node->ts, &node->host); - start = bson_get_monotonic_time (); - - /* if there is already a working stream, push it back to be re-scanned. */ - if (node->stream) { - _begin_hello_cmd (node, - node->stream, - true /* is_setup_done */, - NULL /* dns_result */, - 0 /* initiate_delay_ms */, - false /* use_handshake */); - node->stream = NULL; - return; - } - - BSON_ASSERT (!node->retired); - - // If a new stream is needed, reset state authentication state. - // Authentication state is tied to a stream. - { - node->has_auth = false; - bson_reinit (&node->speculative_auth_response); -#ifdef MONGOC_ENABLE_CRYPTO - // Destroy and zero `node->scram`. - _mongoc_scram_destroy (&node->scram); -#endif - memset ( - &node->sasl_supported_mechs, 0, sizeof (node->sasl_supported_mechs)); - node->negotiated_sasl_supported_mechs = false; - } - - if (node->ts->initiator) { - stream = node->ts->initiator ( - node->ts->uri, &node->host, node->ts->initiator_context, error); - if (stream) { - success = true; - _begin_hello_cmd (node, - stream, - false /* is_setup_done */, - NULL /* dns_result */, - 0 /* initiate_delay_ms */, - true /* use_handshake */); - } - } else { - if (node->host.family == AF_UNIX) { - success = mongoc_topology_scanner_node_connect_unix (node, error); - } else { - success = mongoc_topology_scanner_node_setup_tcp (node, error); - } - } - - if (!success) { - _mongoc_topology_scanner_monitor_heartbeat_failed ( - node->ts, - &node->host, - error, - (bson_get_monotonic_time () - start) / 1000); - - node->ts->setup_err_cb (node->id, node->ts->cb_data, error); - return; - } -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scanner_node_in_cooldown -- - * - * Return true if @node has experienced a network error attempting - * to call "hello" less than 5 seconds before @when, a timestamp in - * microseconds. - * - * Server Discovery and Monitoring Spec: "After a single-threaded client - * gets a network error trying to check a server, the client skips - * re-checking the server until cooldownMS has passed. This avoids - * spending connectTimeoutMS on each unavailable server during each scan. - * This value MUST be 5000 ms, and it MUST NOT be configurable." - * - *-------------------------------------------------------------------------- - */ -bool -mongoc_topology_scanner_node_in_cooldown (mongoc_topology_scanner_node_t *node, - int64_t when) -{ - if (node->last_failed == -1 || node->ts->bypass_cooldown) { - return false; /* node is new, or connected */ - } - - return node->last_failed + 1000 * MONGOC_TOPOLOGY_COOLDOWN_MS >= when; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scanner_in_cooldown -- - * - * Return true if all nodes will be in cooldown at time @when, a - * timestamp in microseconds. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_topology_scanner_in_cooldown (mongoc_topology_scanner_t *ts, - int64_t when) -{ - mongoc_topology_scanner_node_t *node; - - if (ts->bypass_cooldown) { - return false; - } - DL_FOREACH (ts->nodes, node) - { - if (!mongoc_topology_scanner_node_in_cooldown (node, when)) { - return false; - } - } - - return true; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scanner_start -- - * - * Initializes the scanner and begins a full topology check. This - * should be called once before calling mongoc_topology_scanner_work() - * to complete the scan. - * - * If "obey_cooldown" is true, this is a single-threaded blocking scan - * that must obey the Server Discovery And Monitoring Spec's cooldownMS: - * - * "After a single-threaded client gets a network error trying to check - * a server, the client skips re-checking the server until cooldownMS has - * passed. - * - * "This avoids spending connectTimeoutMS on each unavailable server - * during each scan. - * - * "This value MUST be 5000 ms, and it MUST NOT be configurable." - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_topology_scanner_start (mongoc_topology_scanner_t *ts, - bool obey_cooldown) -{ - mongoc_topology_scanner_node_t *node, *tmp; - bool skip; - int64_t now; - - BSON_ASSERT (ts); - - _delete_retired_nodes (ts); - - now = bson_get_monotonic_time (); - - DL_FOREACH_SAFE (ts->nodes, node, tmp) - { - skip = - obey_cooldown && mongoc_topology_scanner_node_in_cooldown (node, now); - - if (!skip) { - mongoc_topology_scanner_node_setup (node, &node->last_error); - } - } -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scanner_finish_scan -- - * - * Summarizes all scanner node errors into one error message, - * deletes retired nodes. - * - *-------------------------------------------------------------------------- - */ - -void -_mongoc_topology_scanner_finish (mongoc_topology_scanner_t *ts) -{ - mongoc_topology_scanner_node_t *node, *tmp; - bson_error_t *error = &ts->error; - bson_string_t *msg; - - memset (&ts->error, 0, sizeof (bson_error_t)); - - msg = bson_string_new (NULL); - - DL_FOREACH_SAFE (ts->nodes, node, tmp) - { - if (node->last_error.code) { - if (msg->len) { - bson_string_append_c (msg, ' '); - } - - bson_string_append_printf (msg, "[%s]", node->last_error.message); - - /* last error domain and code win */ - error->domain = node->last_error.domain; - error->code = node->last_error.code; - } - } - - bson_strncpy ((char *) &error->message, msg->str, sizeof (error->message)); - bson_string_free (msg, true); - - _delete_retired_nodes (ts); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scanner_work -- - * - * Crank the knob on the topology scanner state machine. This should - * be called only after mongoc_topology_scanner_start() has been used - * to begin the scan. - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_topology_scanner_work (mongoc_topology_scanner_t *ts) -{ - mongoc_async_run (ts->async); - BSON_ASSERT (ts->async->ncmds == 0); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scanner_get_error -- - * - * Copy the scanner's current error; which may no-error (code 0). - * - *-------------------------------------------------------------------------- - */ - -void -mongoc_topology_scanner_get_error (mongoc_topology_scanner_t *ts, - bson_error_t *error) -{ - BSON_ASSERT (ts); - BSON_ASSERT (error); - - memcpy (error, &ts->error, sizeof (bson_error_t)); -} - -/* - * Set a field in the topology scanner. - */ -bool -_mongoc_topology_scanner_set_appname (mongoc_topology_scanner_t *ts, - const char *appname) -{ - char *s; - const char *prev; - if (!_mongoc_handshake_appname_is_valid (appname)) { - MONGOC_ERROR ("Cannot set appname: %s is invalid", appname); - return false; - } - - s = bson_strdup (appname); - prev = bson_atomic_ptr_compare_exchange_strong ( - (void *) &ts->appname, NULL, s, bson_memory_order_relaxed); - if (prev == NULL) { - return true; - } - - MONGOC_ERROR ("Cannot set appname more than once"); - bson_free (s); - return false; -} - -/* - * Set the scanner's clusterTime unconditionally: don't compare with prior - * @cluster_time is like {clusterTime: } - */ -void -_mongoc_topology_scanner_set_cluster_time (mongoc_topology_scanner_t *ts, - const bson_t *cluster_time) -{ - bson_destroy (&ts->cluster_time); - bson_copy_to (cluster_time, &ts->cluster_time); -} - -/* SDAM Monitoring Spec: send HeartbeatStartedEvent */ -static void -_mongoc_topology_scanner_monitor_heartbeat_started ( - const mongoc_topology_scanner_t *ts, const mongoc_host_list_t *host) -{ - if (ts->apm_callbacks.server_heartbeat_started) { - mongoc_apm_server_heartbeat_started_t event; - event.host = host; - event.context = ts->apm_context; - event.awaited = false; - ts->apm_callbacks.server_heartbeat_started (&event); - } -} - -/* SDAM Monitoring Spec: send HeartbeatSucceededEvent */ -static void -_mongoc_topology_scanner_monitor_heartbeat_succeeded ( - const mongoc_topology_scanner_t *ts, - const mongoc_host_list_t *host, - const bson_t *reply, - int64_t duration_usec) -{ - if (ts->apm_callbacks.server_heartbeat_succeeded) { - mongoc_apm_server_heartbeat_succeeded_t event; - bson_t hello_redacted; - - bson_init (&hello_redacted); - bson_copy_to_excluding_noinit ( - reply, &hello_redacted, "speculativeAuthenticate", NULL); - - event.host = host; - event.context = ts->apm_context; - event.reply = reply; - event.duration_usec = duration_usec; - event.awaited = false; - ts->apm_callbacks.server_heartbeat_succeeded (&event); - - bson_destroy (&hello_redacted); - } -} - -/* SDAM Monitoring Spec: send HeartbeatFailedEvent */ -static void -_mongoc_topology_scanner_monitor_heartbeat_failed ( - const mongoc_topology_scanner_t *ts, - const mongoc_host_list_t *host, - const bson_error_t *error, - int64_t duration_usec) -{ - if (ts->apm_callbacks.server_heartbeat_failed) { - mongoc_apm_server_heartbeat_failed_t event; - event.host = host; - event.context = ts->apm_context; - event.error = error; - event.duration_usec = duration_usec; - event.awaited = false; - ts->apm_callbacks.server_heartbeat_failed (&event); - } -} - -/* this is for testing the dns cache timeout. */ -void -_mongoc_topology_scanner_set_dns_cache_timeout (mongoc_topology_scanner_t *ts, - int64_t timeout_ms) -{ - ts->dns_cache_timeout_ms = timeout_ms; -} - -/* reset "retired" nodes that failed or were removed in the previous scan */ -static void -_delete_retired_nodes (mongoc_topology_scanner_t *ts) -{ - mongoc_topology_scanner_node_t *node, *tmp; - - DL_FOREACH_SAFE (ts->nodes, node, tmp) - { - if (node->retired) { - mongoc_topology_scanner_node_destroy (node, true); - } - } -} - -static void -_cancel_commands_excluding (mongoc_topology_scanner_node_t *node, - mongoc_async_cmd_t *acmd) -{ - mongoc_async_cmd_t *iter; - DL_FOREACH (node->ts->async->cmds, iter) - { - if ((mongoc_topology_scanner_node_t *) iter->data == node && - iter != acmd) { - iter->state = MONGOC_ASYNC_CMD_CANCELED_STATE; - } - } -} - -static int -_count_acmds (mongoc_topology_scanner_node_t *node) -{ - mongoc_async_cmd_t *iter; - int count = 0; - DL_FOREACH (node->ts->async->cmds, iter) - { - if ((mongoc_topology_scanner_node_t *) iter->data == node) { - ++count; - } - } - return count; -} - -static void -_jumpstart_other_acmds (mongoc_topology_scanner_node_t *node, - mongoc_async_cmd_t *acmd) -{ - mongoc_async_cmd_t *iter; - DL_FOREACH (node->ts->async->cmds, iter) - { - if ((mongoc_topology_scanner_node_t *) iter->data == node && - iter != acmd && acmd->initiate_delay_ms < iter->initiate_delay_ms) { - iter->initiate_delay_ms = - BSON_MAX (iter->initiate_delay_ms - HAPPY_EYEBALLS_DELAY_MS, 0); - } - } -} - -void -_mongoc_topology_scanner_set_server_api (mongoc_topology_scanner_t *ts, - const mongoc_server_api_t *api) -{ - BSON_ASSERT (ts); - BSON_ASSERT (api); - mongoc_server_api_destroy (ts->api); - ts->api = mongoc_server_api_copy (api); - _reset_hello (ts); -} - -/* This must be called before the handshake command is constructed. */ -void -_mongoc_topology_scanner_set_loadbalanced (mongoc_topology_scanner_t *ts, - bool val) -{ - BSON_UNUSED (val); - - BSON_ASSERT (ts->handshake_cmd == NULL); - ts->loadbalanced = true; -} - -bool -mongoc_topology_scanner_uses_server_api (const mongoc_topology_scanner_t *ts) -{ - BSON_ASSERT_PARAM (ts); - return NULL != ts->api; -} - -bool -mongoc_topology_scanner_uses_loadbalanced (const mongoc_topology_scanner_t *ts) -{ - BSON_ASSERT_PARAM (ts); - return ts->loadbalanced; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology.c deleted file mode 100644 index 6b7dc1c37..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-topology.c +++ /dev/null @@ -1,2099 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-config.h" - -#include "mongoc-handshake.h" -#include "mongoc-handshake-private.h" - -#include "mongoc-error.h" -#include "mongoc-host-list-private.h" -#include "mongoc-log.h" -#include "mongoc-topology-private.h" -#include "mongoc-topology-description-apm-private.h" -#include "mongoc-client-private.h" -#include "mongoc-cmd-private.h" -#include "mongoc-uri-private.h" -#include "mongoc-util-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-error-private.h" -#include "mongoc-topology-background-monitoring-private.h" -#include "mongoc-read-prefs-private.h" - -#include "utlist.h" - -#include - -static void -_topology_collect_errors (const mongoc_topology_description_t *topology, - bson_error_t *error_out); - -static bool -_mongoc_topology_reconcile_add_nodes (mongoc_server_description_t *sd, - mongoc_topology_scanner_t *scanner) -{ - mongoc_topology_scanner_node_t *node; - - /* Search by ID and update hello_ok */ - node = mongoc_topology_scanner_get_node (scanner, sd->id); - if (node) { - node->hello_ok = sd->hello_ok; - } else if (!mongoc_topology_scanner_has_node_for_host (scanner, &sd->host)) { - /* A node for this host was retired in this scan. */ - mongoc_topology_scanner_add (scanner, &sd->host, sd->id, sd->hello_ok); - mongoc_topology_scanner_scan (scanner, sd->id); - } - - return true; -} - -/* Called from: - * - the topology scanner callback (when a hello was just received) - * - at the start of a single-threaded scan (mongoc_topology_scan_once) - * Not called for multi threaded monitoring. - */ -void -mongoc_topology_reconcile (const mongoc_topology_t *topology, - mongoc_topology_description_t *td) -{ - mongoc_set_t *servers; - mongoc_server_description_t *sd; - mongoc_topology_scanner_node_t *ele, *tmp; - - BSON_ASSERT (topology->single_threaded); - servers = mc_tpld_servers (td); - /* Add newly discovered nodes */ - for (size_t i = 0u; i < servers->items_len; i++) { - sd = mongoc_set_get_item (servers, i); - _mongoc_topology_reconcile_add_nodes (sd, topology->scanner); - } - - /* Remove removed nodes */ - DL_FOREACH_SAFE (topology->scanner->nodes, ele, tmp) - { - if (!mongoc_topology_description_server_by_id (td, ele->id, NULL)) { - mongoc_topology_scanner_node_retire (ele); - } - } -} - - -/* call this while already holding the lock */ -static bool -_mongoc_topology_update_no_lock (uint32_t id, - const bson_t *hello_response, - int64_t rtt_msec, - mongoc_topology_description_t *td, - const bson_error_t *error /* IN */) -{ - mongoc_topology_description_handle_hello ( - td, id, hello_response, rtt_msec, error); - - /* return false if server removed from topology */ - return mongoc_topology_description_server_by_id (td, id, NULL) != NULL; -} - - -/* - *------------------------------------------------------------------------- - * - * _mongoc_topology_scanner_setup_err_cb -- - * - * Callback method to handle errors during topology scanner node - * setup, typically DNS or SSL errors. - * - *------------------------------------------------------------------------- - */ - -void -_mongoc_topology_scanner_setup_err_cb (uint32_t id, - void *data, - const bson_error_t *error /* IN */) -{ - mongoc_topology_t *topology = BSON_ASSERT_PTR_INLINE (data); - - BSON_ASSERT (topology->single_threaded); - if (_mongoc_topology_get_type (topology) == MONGOC_TOPOLOGY_LOAD_BALANCED) { - /* In load balanced mode, scanning is only for connection establishment. - * It must not modify the topology description. */ - } else { - // Use `mc_tpld_unsafe_get_mutable` to get a mutable topology description - // without locking. This function only applies to single-threaded clients. - mongoc_topology_description_t *td = mc_tpld_unsafe_get_mutable (topology); - mongoc_topology_description_handle_hello ( - td, id, NULL /* hello reply */, -1 /* rtt_msec */, error); - } -} - - -/* - *------------------------------------------------------------------------- - * - * _mongoc_topology_scanner_cb -- - * - * Callback method to handle hello responses received by async - * command objects. - * - * Only called for single-threaded monitoring. - * - *------------------------------------------------------------------------- - */ - -void -_mongoc_topology_scanner_cb (uint32_t id, - const bson_t *hello_response, - int64_t rtt_msec, - void *data, - const bson_error_t *error /* IN */) -{ - mongoc_topology_t *const topology = BSON_ASSERT_PTR_INLINE (data); - mongoc_server_description_t *sd; - mongoc_topology_description_t *td; - - BSON_ASSERT (topology->single_threaded); - if (_mongoc_topology_get_type (topology) == MONGOC_TOPOLOGY_LOAD_BALANCED) { - /* In load balanced mode, scanning is only for connection establishment. - * It must not modify the topology description. */ - return; - } - - // Use `mc_tpld_unsafe_get_mutable` to get a mutable topology description - // without locking. This function only applies to single-threaded clients. - td = mc_tpld_unsafe_get_mutable (topology); - - sd = mongoc_topology_description_server_by_id (td, id, NULL); - - if (!hello_response) { - /* Server monitoring: When a server check fails due to a network error - * (including a network timeout), the client MUST clear its connection - * pool for the server */ - _mongoc_topology_description_clear_connection_pool ( - td, id, &kZeroServiceId); - } - - /* Server Discovery and Monitoring Spec: "Once a server is connected, the - * client MUST change its type to Unknown only after it has retried the - * server once." */ - if (!hello_response && sd && sd->type != MONGOC_SERVER_UNKNOWN) { - _mongoc_topology_update_no_lock (id, hello_response, rtt_msec, td, error); - - /* add another hello call to the current scan - the scan continues - * until all commands are done */ - mongoc_topology_scanner_scan (topology->scanner, sd->id); - } else { - _mongoc_topology_update_no_lock (id, hello_response, rtt_msec, td, error); - - /* The processing of the hello results above may have added, changed, or - * removed server descriptions. We need to reconcile that with our - * monitoring agents - */ - mongoc_topology_reconcile (topology, td); - } -} - -static void -_server_session_init (mongoc_server_session_t *session, - mongoc_topology_t *unused, - bson_error_t *error) -{ - BSON_UNUSED (unused); - - _mongoc_server_session_init (session, error); -} - -static void -_server_session_destroy (mongoc_server_session_t *session, - mongoc_topology_t *unused) -{ - BSON_UNUSED (unused); - - _mongoc_server_session_destroy (session); -} - -static int -_server_session_should_prune (mongoc_server_session_t *session, - mongoc_topology_t *topo) -{ - BSON_ASSERT_PARAM (session); - BSON_ASSERT_PARAM (topo); - - /** If "dirty" (i.e. contains a network error), it should be dropped */ - if (session->dirty) { - return true; - } - - /** If the session has never been used, it should be dropped */ - if (session->last_used_usec == SESSION_NEVER_USED) { - return true; - } - - /* Check for a timeout */ - mc_shared_tpld td = mc_tpld_take_ref (topo); - const int64_t timeout = td.ptr->session_timeout_minutes; - const bool is_loadbalanced = td.ptr->type == MONGOC_TOPOLOGY_LOAD_BALANCED; - mc_tpld_drop_ref (&td); - - /** Load balanced topology sessions never expire */ - if (is_loadbalanced) { - return false; - } - - /* Prune the session if it has hit a timeout */ - return _mongoc_server_session_timed_out (session, timeout); -} - -static void -_tpld_destroy_and_free (void *tpl_descr) -{ - mongoc_topology_description_t *td = tpl_descr; - mongoc_topology_description_destroy (td); -} - -const mongoc_host_list_t ** -_mongoc_apply_srv_max_hosts (const mongoc_host_list_t *hl, - size_t max_hosts, - size_t *hl_array_size) -{ - const mongoc_host_list_t **hl_array; - - BSON_ASSERT_PARAM (hl_array_size); - - const size_t hl_size = _mongoc_host_list_length (hl); - - if (hl_size == 0u) { - *hl_array_size = 0u; - return NULL; - } - - hl_array = bson_malloc (hl_size * sizeof (mongoc_host_list_t *)); - - for (size_t idx = 0u; hl; hl = hl->next) { - hl_array[idx++] = hl; - } - - if (max_hosts == 0u || // Unlimited. - hl_size == 1u || // Trivial case. - hl_size <= max_hosts // Already satisfies limit. - ) { - /* No random shuffle or selection required. */ - *hl_array_size = hl_size; - return hl_array; - } - - /* Initial DNS Seedlist Discovery Spec: If `srvMaxHosts` is greater than zero - * and less than the number of hosts in the DNS result, the driver MUST - * randomly select that many hosts and use them to populate the seedlist. - * Drivers SHOULD use the `Fisher-Yates shuffle` for randomization. */ - for (size_t idx = hl_size - 1u; idx > 0u; --idx) { - /* 0 <= swap_pos <= idx */ - const size_t swap_pos = - _mongoc_rand_size_t (0u, idx, _mongoc_simple_rand_size_t); - - const mongoc_host_list_t *tmp = hl_array[swap_pos]; - hl_array[swap_pos] = hl_array[idx]; - hl_array[idx] = tmp; - } - - *hl_array_size = max_hosts; - - return hl_array; -} - -// `_detect_nongenuine_host` logs if the host string suggests use of CosmosDB or -// DocumentDB. See DRIVERS-2583 for behavior requirements. Returns true if a -// CosmosDB or DocumentDB host is detected. -static bool -_detect_nongenuine_host (const char *host) -{ - char *const host_lowercase = bson_strdup (host); - - mongoc_lowercase (host, host_lowercase); - - if (mongoc_ends_with (host_lowercase, ".cosmos.azure.com")) { - MONGOC_INFO ( - "You appear to be connected to a CosmosDB cluster. For more " - "information regarding feature compatibility and support please " - "visit https://www.mongodb.com/supportability/cosmosdb"); - bson_free (host_lowercase); - return true; - } - - if (mongoc_ends_with (host_lowercase, ".docdb.amazonaws.com") || - mongoc_ends_with (host_lowercase, ".docdb-elastic.amazonaws.com")) { - MONGOC_INFO ( - "You appear to be connected to a DocumentDB cluster. For more " - "information regarding feature compatibility and support please " - "visit https://www.mongodb.com/supportability/documentdb"); - bson_free (host_lowercase); - return true; - } - - bson_free (host_lowercase); - return false; -} - -static void -_detect_nongenuine_hosts (const mongoc_uri_t *uri) -{ - const char *srv_hostname = mongoc_uri_get_srv_hostname (uri); - if (srv_hostname) { - _detect_nongenuine_host (srv_hostname); - return; - } - - const mongoc_host_list_t *iter; - - LL_FOREACH (mongoc_uri_get_hosts (uri), iter) - { - if (_detect_nongenuine_host (iter->host)) { - return; - } - } -} - -/* - *------------------------------------------------------------------------- - * - * mongoc_topology_new -- - * - * Creates and returns a new topology object. - * - * Returns: - * A new topology object. - * - * Side effects: - * None. - * - *------------------------------------------------------------------------- - */ -mongoc_topology_t * -mongoc_topology_new (const mongoc_uri_t *uri, bool single_threaded) -{ - mongoc_topology_t *topology; - mongoc_topology_description_type_t init_type; - mongoc_topology_description_t *td; - const char *srv_hostname; - const mongoc_host_list_t *hl; - mongoc_rr_data_t rr_data; - bool has_directconnection; - bool directconnection; - - BSON_ASSERT (uri); - - _detect_nongenuine_hosts (uri); - -#ifndef MONGOC_ENABLE_CRYPTO - if (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_RETRYWRITES, MONGOC_DEFAULT_RETRYWRITES)) { - /* retryWrites requires sessions, which require crypto - just warn */ - MONGOC_WARNING ( - "retryWrites not supported without an SSL crypto library"); - } -#endif - - topology = (mongoc_topology_t *) bson_malloc0 (sizeof *topology); - topology->usleep_fn = mongoc_usleep_default_impl; - topology->session_pool = - mongoc_server_session_pool_new_with_params (_server_session_init, - _server_session_destroy, - _server_session_should_prune, - topology); - - topology->valid = false; - - const int32_t heartbeat_default = - single_threaded ? MONGOC_TOPOLOGY_HEARTBEAT_FREQUENCY_MS_SINGLE_THREADED - : MONGOC_TOPOLOGY_HEARTBEAT_FREQUENCY_MS_MULTI_THREADED; - - const int32_t heartbeat = mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, heartbeat_default); - - topology->_shared_descr_._sptr_ = mongoc_shared_ptr_create ( - BSON_ALIGNED_ALLOC0 (mongoc_topology_description_t), - _tpld_destroy_and_free); - td = mc_tpld_unsafe_get_mutable (topology); - mongoc_topology_description_init (td, heartbeat); - - td->set_name = bson_strdup (mongoc_uri_get_replica_set (uri)); - - topology->uri = mongoc_uri_copy (uri); - topology->cse_state = MONGOC_CSE_DISABLED; - topology->single_threaded = single_threaded; - if (single_threaded) { - /* Server Selection Spec: - * - * "Single-threaded drivers MUST provide a "serverSelectionTryOnce" - * mode, in which the driver scans the topology exactly once after - * server selection fails, then either selects a server or raises an - * error. - * - * "The serverSelectionTryOnce option MUST be true by default." - */ - topology->server_selection_try_once = mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_SERVERSELECTIONTRYONCE, true); - } else { - topology->server_selection_try_once = false; - } - - topology->server_selection_timeout_msec = mongoc_uri_get_option_as_int32 ( - topology->uri, - MONGOC_URI_SERVERSELECTIONTIMEOUTMS, - MONGOC_TOPOLOGY_SERVER_SELECTION_TIMEOUT_MS); - - /* tests can override this */ - topology->min_heartbeat_frequency_msec = - MONGOC_TOPOLOGY_MIN_HEARTBEAT_FREQUENCY_MS; - - topology->local_threshold_msec = - mongoc_uri_get_local_threshold_option (topology->uri); - - /* Total time allowed to check a server is connectTimeoutMS. - * Server Discovery And Monitoring Spec: - * - * "The socket used to check a server MUST use the same connectTimeoutMS as - * regular sockets. Multi-threaded clients SHOULD set monitoring sockets' - * socketTimeoutMS to the connectTimeoutMS." - */ - topology->connect_timeout_msec = - mongoc_uri_get_option_as_int32 (topology->uri, - MONGOC_URI_CONNECTTIMEOUTMS, - MONGOC_DEFAULT_CONNECTTIMEOUTMS); - - topology->scanner_state = MONGOC_TOPOLOGY_SCANNER_OFF; - topology->scanner = - mongoc_topology_scanner_new (topology->uri, - _mongoc_topology_scanner_setup_err_cb, - _mongoc_topology_scanner_cb, - topology, - topology->connect_timeout_msec); - - bson_mutex_init (&topology->tpld_modification_mtx); - mongoc_cond_init (&topology->cond_client); - - if (single_threaded) { - /* single threaded drivers attempt speculative authentication during a - * topology scan */ - topology->scanner->speculative_authentication = true; - - /* single threaded clients negotiate sasl supported mechanisms during - * a topology scan. */ - if (_mongoc_uri_requires_auth_negotiation (uri)) { - topology->scanner->negotiate_sasl_supported_mechs = true; - } - } - - srv_hostname = mongoc_uri_get_srv_hostname (uri); - if (srv_hostname) { - char *prefixed_hostname; - - memset (&rr_data, 0, sizeof (mongoc_rr_data_t)); - /* Set the default resource record resolver */ - topology->rr_resolver = _mongoc_client_get_rr; - - /* Initialize the last scan time and interval. Even if the initial DNS - * lookup fails, SRV polling will still start when background monitoring - * starts. */ - topology->srv_polling_last_scan_ms = bson_get_monotonic_time () / 1000; - topology->srv_polling_rescan_interval_ms = - MONGOC_TOPOLOGY_MIN_RESCAN_SRV_INTERVAL_MS; - - /* a mongodb+srv URI. try SRV lookup, if no error then also try TXT */ - prefixed_hostname = bson_strdup_printf ( - "_%s._tcp.%s", mongoc_uri_get_srv_service_name (uri), srv_hostname); - if (!topology->rr_resolver (prefixed_hostname, - MONGOC_RR_SRV, - &rr_data, - MONGOC_RR_DEFAULT_BUFFER_SIZE, - &topology->scanner->error)) { - GOTO (srv_fail); - } - - /* Failure to find TXT records will not return an error (since it is only - * for options). But _mongoc_client_get_rr may return an error if - * there is more than one TXT record returned. */ - if (!topology->rr_resolver (srv_hostname, - MONGOC_RR_TXT, - &rr_data, - MONGOC_RR_DEFAULT_BUFFER_SIZE, - &topology->scanner->error)) { - GOTO (srv_fail); - } - - /* Use rr_data to update the topology's URI. */ - if (rr_data.txt_record_opts && - !mongoc_uri_parse_options (topology->uri, - rr_data.txt_record_opts, - true /* from_dns */, - &topology->scanner->error)) { - GOTO (srv_fail); - } - - if (!mongoc_uri_init_with_srv_host_list ( - topology->uri, rr_data.hosts, &topology->scanner->error)) { - GOTO (srv_fail); - } - - topology->srv_polling_last_scan_ms = bson_get_monotonic_time () / 1000; - /* TODO (CDRIVER-4047) use BSON_MIN */ - topology->srv_polling_rescan_interval_ms = BSON_MAX ( - rr_data.min_ttl * 1000, MONGOC_TOPOLOGY_MIN_RESCAN_SRV_INTERVAL_MS); - - topology->valid = true; - srv_fail: - bson_free (rr_data.txt_record_opts); - bson_free (prefixed_hostname); - _mongoc_host_list_destroy_all (rr_data.hosts); - } else { - topology->valid = true; - } - - if (!mongoc_uri_finalize (topology->uri, &topology->scanner->error)) { - topology->valid = false; - } - - td->max_hosts = - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_SRVMAXHOSTS, 0); - - if (td->max_hosts < 0) { - topology->valid = false; - } - - /* - * Set topology type from URI: - * + if directConnection=true - * - whether or not we have a replicaSet name, initialize to SINGLE - * (directConnect with SRV or multiple hosts triggers a URI parse error) - * + if directConnection=false - * - if we've got a replicaSet name, initialize to RS_NO_PRIMARY - * - otherwise, initialize to UNKNOWN - * + if directConnection was not specified in the URI (old behavior) - * - if we've got a replicaSet name, initialize to RS_NO_PRIMARY - * - otherwise, if the seed list has a single host, initialize to SINGLE - * - everything else gets initialized to UNKNOWN - */ - has_directconnection = - mongoc_uri_has_option (uri, MONGOC_URI_DIRECTCONNECTION); - directconnection = - has_directconnection && - mongoc_uri_get_option_as_bool (uri, MONGOC_URI_DIRECTCONNECTION, false); - hl = mongoc_uri_get_hosts (topology->uri); - /* If loadBalanced is enabled, directConnection is disabled. This was - * validated in mongoc_uri_finalize_loadbalanced, which is called by - * mongoc_uri_finalize. */ - if (mongoc_uri_get_option_as_bool ( - topology->uri, MONGOC_URI_LOADBALANCED, false)) { - init_type = MONGOC_TOPOLOGY_LOAD_BALANCED; - if (topology->single_threaded) { - /* Cooldown only applies to server monitoring for single-threaded - * clients. In load balanced mode, the topology scanner is used to - * create connections. The cooldown period does not apply. A network - * error to a load balanced connection does not imply subsequent - * connection attempts will be to the same server and that a delay - * should occur. */ - _mongoc_topology_bypass_cooldown (topology); - } - _mongoc_topology_scanner_set_loadbalanced (topology->scanner, true); - } else if (srv_hostname && !has_directconnection) { - init_type = MONGOC_TOPOLOGY_UNKNOWN; - } else if (has_directconnection) { - if (directconnection) { - init_type = MONGOC_TOPOLOGY_SINGLE; - } else { - if (mongoc_uri_get_replica_set (topology->uri)) { - init_type = MONGOC_TOPOLOGY_RS_NO_PRIMARY; - } else { - init_type = MONGOC_TOPOLOGY_UNKNOWN; - } - } - } else if (mongoc_uri_get_replica_set (topology->uri)) { - init_type = MONGOC_TOPOLOGY_RS_NO_PRIMARY; - } else { - if (hl && hl->next) { - init_type = MONGOC_TOPOLOGY_UNKNOWN; - } else { - init_type = MONGOC_TOPOLOGY_SINGLE; - } - } - - td->type = init_type; - - if (!topology->single_threaded) { - topology->server_monitors = mongoc_set_new (1, NULL, NULL); - topology->rtt_monitors = mongoc_set_new (1, NULL, NULL); - bson_mutex_init (&topology->apm_mutex); - bson_mutex_init (&topology->srv_polling_mtx); - mongoc_cond_init (&topology->srv_polling_cond); - } - - if (!topology->valid) { - TRACE ("%s", "topology invalid"); - /* add no nodes */ - return topology; - } - - size_t hl_array_size = 0u; - - BSON_ASSERT (bson_in_range_signed (size_t, td->max_hosts)); - const mongoc_host_list_t *const *hl_array = - _mongoc_apply_srv_max_hosts (hl, (size_t) td->max_hosts, &hl_array_size); - - for (size_t idx = 0u; idx < hl_array_size; ++idx) { - const mongoc_host_list_t *const elem = hl_array[idx]; - - uint32_t id = 0u; - - mongoc_topology_description_add_server (td, elem->host_and_port, &id); - mongoc_topology_scanner_add (topology->scanner, elem, id, false); - } - - bson_free ((void *) hl_array); - - return topology; -} - -/* - *------------------------------------------------------------------------- - * - * mongoc_topology_set_apm_callbacks -- - * - * Set Application Performance Monitoring callbacks. - * - *------------------------------------------------------------------------- - */ -void -mongoc_topology_set_apm_callbacks (mongoc_topology_t *topology, - mongoc_topology_description_t *td, - mongoc_apm_callbacks_t *callbacks, - void *context) -{ - if (callbacks) { - memcpy (&td->apm_callbacks, callbacks, sizeof (mongoc_apm_callbacks_t)); - memcpy (&topology->scanner->apm_callbacks, - callbacks, - sizeof (mongoc_apm_callbacks_t)); - } else { - memset (&td->apm_callbacks, 0, sizeof (mongoc_apm_callbacks_t)); - memset ( - &topology->scanner->apm_callbacks, 0, sizeof (mongoc_apm_callbacks_t)); - } - - td->apm_context = context; - topology->scanner->apm_context = context; -} - -/* - *------------------------------------------------------------------------- - * - * mongoc_topology_destroy -- - * - * Free the memory associated with this topology object. - * - * Returns: - * None. - * - * Side effects: - * @topology will be cleaned up. - * - *------------------------------------------------------------------------- - */ -void -mongoc_topology_destroy (mongoc_topology_t *topology) -{ - if (!topology) { - return; - } - -#ifdef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION - bson_free (topology->keyvault_db); - bson_free (topology->keyvault_coll); - mongoc_client_destroy (topology->mongocryptd_client); - mongoc_client_pool_destroy (topology->mongocryptd_client_pool); - _mongoc_crypt_destroy (topology->crypt); - bson_destroy (topology->mongocryptd_spawn_args); - bson_free (topology->mongocryptd_spawn_path); -#endif - - if (!topology->single_threaded) { - _mongoc_topology_background_monitoring_stop (topology); - BSON_ASSERT (topology->scanner_state == MONGOC_TOPOLOGY_SCANNER_OFF); - mongoc_set_destroy (topology->server_monitors); - mongoc_set_destroy (topology->rtt_monitors); - bson_mutex_destroy (&topology->apm_mutex); - bson_mutex_destroy (&topology->srv_polling_mtx); - mongoc_cond_destroy (&topology->srv_polling_cond); - } - - if (topology->valid) { - /* Do not emit a topology_closed event. A topology opening event was not - * emitted. */ - _mongoc_topology_description_monitor_closed ( - mc_tpld_unsafe_get_const (topology)); - } - - mongoc_uri_destroy (topology->uri); - mongoc_shared_ptr_reset_null (&topology->_shared_descr_._sptr_); - mongoc_topology_scanner_destroy (topology->scanner); - mongoc_server_session_pool_free (topology->session_pool); - bson_free (topology->clientSideEncryption.autoOptions.extraOptions - .cryptSharedLibPath); - - mongoc_cond_destroy (&topology->cond_client); - bson_mutex_destroy (&topology->tpld_modification_mtx); - - bson_destroy (topology->encrypted_fields_map); - - bson_free (topology); -} - -/* Returns false if none of the hosts were valid. */ -bool -mongoc_topology_apply_scanned_srv_hosts (mongoc_uri_t *uri, - mongoc_topology_description_t *td, - mongoc_host_list_t *hosts, - bson_error_t *error) -{ - mongoc_host_list_t *host; - mongoc_host_list_t *valid_hosts = NULL; - bool had_valid_hosts = false; - - /* Validate that the hosts have a matching domain. - * If validation fails, log it. - * If no valid hosts remain, do not update the topology description. - */ - LL_FOREACH (hosts, host) - { - if (mongoc_uri_validate_srv_result (uri, host->host, error)) { - _mongoc_host_list_upsert (&valid_hosts, host); - } else { - MONGOC_ERROR ("Invalid host returned by SRV: %s", host->host_and_port); - /* Continue on, there may still be valid hosts returned. */ - } - } - - if (valid_hosts) { - /* Reconcile with the topology description. Newly found servers will start - * getting monitored and are eligible to be used by clients. */ - mongoc_topology_description_reconcile (td, valid_hosts); - had_valid_hosts = true; - } else { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "SRV response did not contain any valid hosts"); - } - - _mongoc_host_list_destroy_all (valid_hosts); - return had_valid_hosts; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_should_rescan_srv -- - * - * Checks whether it is valid to rescan SRV records on the topology. - * Namely, that the topology type is Sharded or Unknown, and that - * the topology URI was configured with SRV. - * - * If this returns false, caller can stop scanning SRV records - * and does not need to try again in the future. - * - * -------------------------------------------------------------------------- - */ -bool -mongoc_topology_should_rescan_srv (mongoc_topology_t *topology) -{ - const char *srv_hostname = mongoc_uri_get_srv_hostname (topology->uri); - mongoc_topology_description_type_t type; - - if (!srv_hostname) { - /* Only rescan if we have a mongodb+srv:// URI. */ - return false; - } - - type = _mongoc_topology_get_type (topology); - - /* Only perform rescan for sharded topology. */ - return type == MONGOC_TOPOLOGY_SHARDED || type == MONGOC_TOPOLOGY_UNKNOWN; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_rescan_srv -- - * - * Queries SRV records for new hosts in a mongos cluster. - * Caller must call mongoc_topology_should_rescan_srv before calling - * to ensure preconditions are met. - * - * NOTE: This method may update the topology description. - * - * -------------------------------------------------------------------------- - */ -void -mongoc_topology_rescan_srv (mongoc_topology_t *topology) -{ - mongoc_rr_data_t rr_data = {0}; - const char *srv_hostname; - char *prefixed_hostname = NULL; - int64_t scan_time_ms; - bool ret; - mc_shared_tpld td; - mc_tpld_modification tdmod; - - BSON_ASSERT (mongoc_topology_should_rescan_srv (topology)); - - srv_hostname = mongoc_uri_get_srv_hostname (topology->uri); - scan_time_ms = topology->srv_polling_last_scan_ms + - topology->srv_polling_rescan_interval_ms; - if (bson_get_monotonic_time () / 1000 < scan_time_ms) { - /* Query SRV no more frequently than srv_polling_rescan_interval_ms. */ - return; - } - - TRACE ("%s", "Polling for SRV records"); - - /* Go forth and query... */ - prefixed_hostname = - bson_strdup_printf ("_%s._tcp.%s", - mongoc_uri_get_srv_service_name (topology->uri), - srv_hostname); - - ret = topology->rr_resolver (prefixed_hostname, - MONGOC_RR_SRV, - &rr_data, - MONGOC_RR_DEFAULT_BUFFER_SIZE, - &topology->scanner->error); - - td = mc_tpld_take_ref (topology); - topology->srv_polling_last_scan_ms = bson_get_monotonic_time () / 1000; - if (!ret) { - /* Failed querying, soldier on and try again next time. */ - topology->srv_polling_rescan_interval_ms = td.ptr->heartbeat_msec; - MONGOC_ERROR ("SRV polling error: %s", topology->scanner->error.message); - GOTO (done); - } - - /* TODO (CDRIVER-4047) use BSON_MIN */ - topology->srv_polling_rescan_interval_ms = BSON_MAX ( - rr_data.min_ttl * 1000, MONGOC_TOPOLOGY_MIN_RESCAN_SRV_INTERVAL_MS); - - tdmod = mc_tpld_modify_begin (topology); - if (!mongoc_topology_apply_scanned_srv_hosts (topology->uri, - tdmod.new_td, - rr_data.hosts, - &topology->scanner->error)) { - MONGOC_ERROR ("%s", topology->scanner->error.message); - /* Special case when DNS returns zero records successfully or no valid - * hosts exist. - * Leave the toplogy alone and perform another scan at the next interval - * rather than removing all records and having nothing to connect to. - * For no verified hosts drivers "MUST temporarily set - * srv_polling_rescan_interval_ms - * to heartbeatFrequencyMS until at least one verified SRV record is - * obtained." - */ - topology->srv_polling_rescan_interval_ms = td.ptr->heartbeat_msec; - } - mc_tpld_modify_commit (tdmod); - -done: - mc_tpld_drop_ref (&td); - bson_free (prefixed_hostname); - _mongoc_host_list_destroy_all (rr_data.hosts); -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_topology_scan_once -- - * - * Runs a single complete scan. - * - * NOTE: This method updates the topology description. - * - * Only runs for single threaded monitoring. (obey_cooldown is always - * true). - * - *-------------------------------------------------------------------------- - */ -static void -mongoc_topology_scan_once (mongoc_topology_t *topology, bool obey_cooldown) -{ - mongoc_topology_description_t *td; - BSON_ASSERT (topology->single_threaded); - if (mongoc_topology_should_rescan_srv (topology)) { - /* Prior to scanning hosts, update the list of SRV hosts, if applicable. - */ - mongoc_topology_rescan_srv (topology); - } - - /* since the last scan, members may be added or removed from the topology - * description based on hello responses in connection handshakes, see - * _mongoc_topology_update_from_handshake. retire scanner nodes for removed - * members and create scanner nodes for new ones. */ - // Use `mc_tpld_unsafe_get_mutable` to get a mutable topology description - // without locking. This function only applies to single-threaded clients. - td = mc_tpld_unsafe_get_mutable (topology); - mongoc_topology_reconcile (topology, td); - - mongoc_topology_scanner_start (topology->scanner, obey_cooldown); - mongoc_topology_scanner_work (topology->scanner); - - _mongoc_topology_scanner_finish (topology->scanner); - - topology->last_scan = bson_get_monotonic_time (); - topology->stale = false; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_do_blocking_scan -- - * - * Monitoring entry for single-threaded use case. Assumes the caller - * has checked that it's the right time to scan. - * - *-------------------------------------------------------------------------- - */ -void -_mongoc_topology_do_blocking_scan (mongoc_topology_t *topology, - bson_error_t *error) -{ - BSON_ASSERT (topology->single_threaded); - _mongoc_handshake_freeze (); - - mongoc_topology_scan_once (topology, true /* obey cooldown */); - mongoc_topology_scanner_get_error (topology->scanner, error); -} - - -bool -mongoc_topology_compatible (const mongoc_topology_description_t *td, - const mongoc_read_prefs_t *read_prefs, - bson_error_t *error) -{ - if (td->compatibility_error.code) { - if (error) { - memcpy (error, &td->compatibility_error, sizeof (bson_error_t)); - } - return false; - } - - if (!read_prefs) { - /* NULL means read preference Primary */ - return true; - } - - const int64_t max_staleness_seconds = - mongoc_read_prefs_get_max_staleness_seconds (read_prefs); - - if (max_staleness_seconds != MONGOC_NO_MAX_STALENESS) { - /* shouldn't happen if we've properly enforced wire version */ - if (!mongoc_topology_description_all_sds_have_write_date (td)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "Not all servers have lastWriteDate"); - return false; - } - - if (!_mongoc_topology_description_validate_max_staleness ( - td, max_staleness_seconds, error)) { - return false; - } - } - - return true; -} - - -static void -_mongoc_server_selection_error (const char *msg, - const bson_error_t *scanner_error, - bson_error_t *error) -{ - if (scanner_error && scanner_error->code) { - bson_set_error (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "%s: %s", - msg, - scanner_error->message); - } else { - bson_set_error (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "%s", - msg); - } -} - - -mongoc_server_description_t * -mongoc_topology_select (mongoc_topology_t *topology, - mongoc_ss_optype_t optype, - const mongoc_read_prefs_t *read_prefs, - bool *must_use_primary, - bson_error_t *error) -{ - uint32_t server_id = mongoc_topology_select_server_id ( - topology, optype, read_prefs, must_use_primary, NULL, error); - - if (server_id) { - /* new copy of the server description */ - mongoc_server_description_t *ret; - mc_shared_tpld td = mc_tpld_take_ref (topology); - mongoc_server_description_t const *sd = - mongoc_topology_description_server_by_id_const ( - td.ptr, server_id, error); - ret = mongoc_server_description_new_copy (sd); - mc_tpld_drop_ref (&td); - return ret; - } else { - return NULL; - } -} - -/* Bypasses normal server selection behavior for a load balanced topology. - * Returns the id of the one load balancer server. Returns 0 on failure. - * Successful post-condition: On a single threaded client, a connection will - * have been established. */ -static uint32_t -_mongoc_topology_select_server_id_loadbalanced (mongoc_topology_t *topology, - bson_error_t *error) -{ - mongoc_server_description_t const *selected_server; - int32_t selected_server_id; - mongoc_topology_scanner_node_t *node; - bson_error_t scanner_error = {0}; - mc_shared_tpld td = mc_tpld_take_ref (topology); - - BSON_ASSERT (td.ptr->type == MONGOC_TOPOLOGY_LOAD_BALANCED); - - /* Emit the opening SDAM events if they have not emitted already. */ - if (!td.ptr->opened) { - mc_tpld_modification tdmod = mc_tpld_modify_begin (topology); - _mongoc_topology_description_monitor_opening (tdmod.new_td); - mc_tpld_modify_commit (tdmod); - mc_tpld_renew_ref (&td, topology); - } - selected_server = - mongoc_topology_description_select (td.ptr, - MONGOC_SS_WRITE, - NULL /* read prefs */, - NULL /* chosen read mode */, - NULL /* deprioritized servers */, - 0 /* local threshold */); - - if (!selected_server) { - _mongoc_server_selection_error ( - "No suitable server found in load balanced deployment", NULL, error); - selected_server_id = 0; - goto done; - } - - selected_server_id = selected_server->id; - - if (!topology->single_threaded) { - goto done; - } - - /* If this is a single threaded topology, we must ensure that a connection is - * available to this server. Wrapping drivers make the assumption that - * successful server selection implies a connection is available. */ - node = - mongoc_topology_scanner_get_node (topology->scanner, selected_server_id); - if (!node) { - _mongoc_server_selection_error ( - "Topology scanner in invalid state; cannot find load balancer", - NULL, - error); - selected_server_id = 0; - goto done; - } - - if (!node->stream) { - TRACE ("%s", - "Server selection performing scan since no connection has " - "been established"); - _mongoc_topology_do_blocking_scan (topology, &scanner_error); - } - - if (!node->stream) { - /* Use the same error domain / code that is returned in mongoc-cluster.c - * when fetching a stream fails. */ - if (scanner_error.code) { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NOT_ESTABLISHED, - "Could not establish stream for node %s: %s", - node->host.host_and_port, - scanner_error.message); - } else { - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NOT_ESTABLISHED, - "Could not establish stream for node %s", - node->host.host_and_port); - } - selected_server_id = 0; - goto done; - } - -done: - mc_tpld_drop_ref (&td); - return selected_server_id; -} - - -uint32_t -mongoc_topology_select_server_id (mongoc_topology_t *topology, - mongoc_ss_optype_t optype, - const mongoc_read_prefs_t *read_prefs, - bool *must_use_primary, - const mongoc_deprioritized_servers_t *ds, - bson_error_t *error) -{ - static const char *timeout_msg = - "No suitable servers found: `serverSelectionTimeoutMS` expired"; - - mongoc_topology_scanner_t *ts; - int r; - int64_t local_threshold_ms; - const mongoc_server_description_t *selected_server = NULL; - bool try_once; - int64_t sleep_usec; - bool tried_once; - bson_error_t scanner_error = {0}; - int64_t heartbeat_msec; - uint32_t server_id; - mc_shared_tpld td = mc_tpld_take_ref (topology); - - /* These names come from the Server Selection Spec pseudocode */ - int64_t loop_start; /* when we entered this function */ - int64_t loop_end; /* when we last completed a loop (single-threaded) */ - int64_t scan_ready; /* the soonest we can do a blocking scan */ - int64_t next_update; /* the latest we must do a blocking scan */ - int64_t expire_at; /* when server selection timeout expires */ - - BSON_ASSERT (topology); - ts = topology->scanner; - - if (!mongoc_topology_scanner_valid (ts)) { - if (error) { - mongoc_topology_scanner_get_error (ts, error); - error->domain = MONGOC_ERROR_SERVER_SELECTION; - error->code = MONGOC_ERROR_SERVER_SELECTION_FAILURE; - } - server_id = 0; - goto done; - } - - if (td.ptr->type == MONGOC_TOPOLOGY_LOAD_BALANCED) { - server_id = - _mongoc_topology_select_server_id_loadbalanced (topology, error); - goto done; - } - - heartbeat_msec = td.ptr->heartbeat_msec; - local_threshold_ms = topology->local_threshold_msec; - try_once = topology->server_selection_try_once; - loop_start = loop_end = bson_get_monotonic_time (); - expire_at = - loop_start + ((int64_t) topology->server_selection_timeout_msec * 1000); - - if (topology->single_threaded) { - if (!td.ptr->opened) { - // Use `mc_tpld_unsafe_get_mutable` to get a mutable topology - // description without locking. This block only applies to - // single-threaded clients. - _mongoc_topology_description_monitor_opening ( - mc_tpld_unsafe_get_mutable (topology)); - mc_tpld_renew_ref (&td, topology); - } - - tried_once = false; - next_update = topology->last_scan + heartbeat_msec * 1000; - if (next_update < loop_start) { - /* we must scan now */ - topology->stale = true; - } - - /* until we find a server or time out */ - for (;;) { - if (topology->stale) { - /* how soon are we allowed to scan? */ - scan_ready = topology->last_scan + - topology->min_heartbeat_frequency_msec * 1000; - - if (scan_ready > expire_at && !try_once) { - /* selection timeout will expire before min heartbeat passes */ - _mongoc_server_selection_error ( - "No suitable servers found: " - "`serverselectiontimeoutms` timed out", - &scanner_error, - error); - - server_id = 0; - goto done; - } - - sleep_usec = scan_ready - loop_end; - if (sleep_usec > 0) { - if (try_once && - mongoc_topology_scanner_in_cooldown (ts, scan_ready)) { - _mongoc_server_selection_error ( - "No servers yet eligible for rescan", - &scanner_error, - error); - - server_id = 0; - goto done; - } - topology->usleep_fn (sleep_usec, topology->usleep_data); - } - - /* takes up to connectTimeoutMS. sets "last_scan", clears "stale" */ - _mongoc_topology_do_blocking_scan (topology, &scanner_error); - loop_end = topology->last_scan; - tried_once = true; - } - - /* Topology may have just been updated by a scan. */ - mc_tpld_renew_ref (&td, topology); - - if (!mongoc_topology_compatible (td.ptr, read_prefs, error)) { - server_id = 0; - goto done; - } - - selected_server = - mongoc_topology_description_select (td.ptr, - optype, - read_prefs, - must_use_primary, - ds, - local_threshold_ms); - - if (selected_server) { - server_id = selected_server->id; - goto done; - } - - topology->stale = true; - - if (try_once) { - if (tried_once) { - _mongoc_server_selection_error ( - "No suitable servers found (`serverSelectionTryOnce` set)", - &scanner_error, - error); - - server_id = 0; - goto done; - } - } else { - loop_end = bson_get_monotonic_time (); - - if (loop_end > expire_at) { - /* no time left in server_selection_timeout_msec */ - _mongoc_server_selection_error ( - timeout_msg, &scanner_error, error); - - server_id = 0; - goto done; - } - } - } - } - - /* With background thread */ - /* we break out when we've found a server or timed out */ - for (;;) { - /* Topology may have been updated on a previous loop iteration */ - mc_tpld_renew_ref (&td, topology); - - if (!mongoc_topology_compatible (td.ptr, read_prefs, error)) { - server_id = 0; - goto done; - } - - selected_server = mongoc_topology_description_select ( - td.ptr, optype, read_prefs, must_use_primary, ds, local_threshold_ms); - - if (selected_server) { - server_id = selected_server->id; - goto done; - } - - /* tlpd_modification_mtx is used to synchronize updates to the topology. - * Take that lock to do a wait on the topology to become up-to-date and - * synchronize with a condition variable that will be signalled upon - * topology changes. */ - bson_mutex_lock (&topology->tpld_modification_mtx); - /* Now that we have the lock, check again, since a scan may have - * occurred while we were waiting on the lock. */ - mc_tpld_renew_ref (&td, topology); - selected_server = mongoc_topology_description_select ( - td.ptr, optype, read_prefs, must_use_primary, ds, local_threshold_ms); - if (selected_server) { - server_id = selected_server->id; - bson_mutex_unlock (&topology->tpld_modification_mtx); - goto done; - } - - /* Still nothing. Request that the scanner do a scan now. */ - TRACE ( - "server selection requesting an immediate scan, want %s", - _mongoc_read_mode_as_str (mongoc_read_prefs_get_mode (read_prefs))); - _mongoc_topology_request_scan (topology); - - TRACE ("server selection about to wait for %" PRId64 "ms", - (expire_at - loop_start) / 1000); - r = mongoc_cond_timedwait (&topology->cond_client, - &topology->tpld_modification_mtx, - (expire_at - loop_start) / 1000); - TRACE ("%s", "server selection awake"); - /* Refresh our topology handle */ - mc_tpld_renew_ref (&td, topology); - _topology_collect_errors (td.ptr, &scanner_error); - - bson_mutex_unlock (&topology->tpld_modification_mtx); - -#ifdef _WIN32 - if (r == WSAETIMEDOUT) { -#else - if (r == ETIMEDOUT) { -#endif - /* handle timeouts */ - _mongoc_server_selection_error (timeout_msg, &scanner_error, error); - - server_id = 0; - goto done; - } else if (r) { - bson_set_error (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "Unknown error '%d' received while waiting on " - "thread condition", - r); - server_id = 0; - goto done; - } - - loop_start = bson_get_monotonic_time (); - - if (loop_start > expire_at) { - _mongoc_server_selection_error (timeout_msg, &scanner_error, error); - - server_id = 0; - goto done; - } - } - -done: - mc_tpld_drop_ref (&td); - return server_id; -} - - -mongoc_host_list_t * -_mongoc_topology_host_by_id (const mongoc_topology_description_t *td, - uint32_t id, - bson_error_t *error) -{ - mongoc_server_description_t const *sd; - mongoc_host_list_t *host = NULL; - - /* not a copy - direct pointer into topology description data */ - sd = mongoc_topology_description_server_by_id_const (td, id, error); - - if (sd) { - host = bson_malloc0 (sizeof (mongoc_host_list_t)); - memcpy (host, &sd->host, sizeof (mongoc_host_list_t)); - } - - return host; -} - - -void -_mongoc_topology_request_scan (mongoc_topology_t *topology) -{ - _mongoc_topology_background_monitoring_request_scan (topology); -} - -bool -_mongoc_topology_update_from_handshake (mongoc_topology_t *topology, - const mongoc_server_description_t *sd) -{ - bool has_server; - mc_tpld_modification tdmod; - - BSON_ASSERT (topology); - BSON_ASSERT (sd); - BSON_ASSERT (!topology->single_threaded); - - if (_mongoc_topology_get_type (topology) == MONGOC_TOPOLOGY_LOAD_BALANCED) { - /* In load balanced mode, scanning is only for connection establishment. - * It must not modify the topology description. */ - return true; - } - - tdmod = mc_tpld_modify_begin (topology); - - /* return false if server was removed from topology */ - has_server = _mongoc_topology_update_no_lock (sd->id, - &sd->last_hello_response, - sd->round_trip_time_msec, - tdmod.new_td, - NULL); - - /* if pooled, wake threads waiting in mongoc_topology_server_by_id */ - mongoc_cond_broadcast (&topology->cond_client); - /* Update background monitoring. */ - _mongoc_topology_background_monitoring_reconcile (topology, tdmod.new_td); - mc_tpld_modify_commit (tdmod); - - return has_server; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_update_last_used -- - * - * Internal function. In single-threaded mode only, track when the socket - * to a particular server was last used. This is required for - * mongoc_cluster_check_interval to know when a socket has been idle. - * - *-------------------------------------------------------------------------- - */ - -void -_mongoc_topology_update_last_used (mongoc_topology_t *topology, - uint32_t server_id) -{ - mongoc_topology_scanner_node_t *node; - - if (!topology->single_threaded) { - return; - } - - node = mongoc_topology_scanner_get_node (topology->scanner, server_id); - if (node) { - node->last_used = bson_get_monotonic_time (); - } -} - - -mongoc_topology_description_type_t -_mongoc_topology_get_type (const mongoc_topology_t *topology) -{ - mc_shared_tpld td = mc_tpld_take_ref (topology); - mongoc_topology_description_type_t td_type = td.ptr->type; - mc_tpld_drop_ref (&td); - return td_type; -} - -bool -_mongoc_topology_set_appname (mongoc_topology_t *topology, const char *appname) -{ - bool ret = false; - - if (topology->scanner_state == MONGOC_TOPOLOGY_SCANNER_OFF) { - ret = _mongoc_topology_scanner_set_appname (topology->scanner, appname); - } else { - MONGOC_ERROR ("Cannot set appname after handshake initiated"); - } - return ret; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_update_cluster_time -- - * - * Internal function. If the server reply has a later $clusterTime than - * any seen before, update the topology's clusterTime. See the Driver - * Sessions Spec. - * - *-------------------------------------------------------------------------- - */ - -void -_mongoc_topology_update_cluster_time (mongoc_topology_t *topology, - const bson_t *reply) -{ - bson_iter_t iter; - bson_iter_t child; - const uint8_t *data; - uint32_t size; - bson_t cluster_time; - mc_shared_tpld td; - - if (!reply || !bson_iter_init_find (&iter, reply, "$clusterTime")) { - return; - } - - if (!BSON_ITER_HOLDS_DOCUMENT (&iter) || - !bson_iter_recurse (&iter, &child)) { - MONGOC_ERROR ("Can't parse $clusterTime"); - return; - } - - bson_iter_document (&iter, &size, &data); - BSON_ASSERT (bson_init_static (&cluster_time, data, (size_t) size)); - - td = mc_tpld_take_ref (topology); - - /* This func is called frequently and repeatedly, but the cluster time itself - * is infrequently updated. mc_tpld_modify_begin() is very expensive, so we - * only want to actually call it if we anticipate performing an update to the - * cluster time. - * - * Check that the cluster time has actually changed from what we have on - * record before opening a topology modification to update it. */ - if (bson_empty (&td.ptr->cluster_time) || - _mongoc_cluster_time_greater (&cluster_time, &td.ptr->cluster_time)) { - mc_tpld_modification tdmod = mc_tpld_modify_begin (topology); - /* Check again if we need to update the cluster time, since it may have - * been updated behind our back. */ - if (bson_empty (&tdmod.new_td->cluster_time) || - _mongoc_cluster_time_greater (&cluster_time, - &tdmod.new_td->cluster_time)) { - bson_destroy (&tdmod.new_td->cluster_time); - bson_copy_to (&cluster_time, &tdmod.new_td->cluster_time); - _mongoc_topology_scanner_set_cluster_time ( - topology->scanner, &tdmod.new_td->cluster_time); - mc_tpld_modify_commit (tdmod); - } else { - mc_tpld_modify_drop (tdmod); - } - } - mc_tpld_drop_ref (&td); -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_pop_server_session -- - * - * Internal function. Get a server session from the pool or create - * one. On error, return NULL and fill out @error. - * - *-------------------------------------------------------------------------- - */ - -mongoc_server_session_t * -_mongoc_topology_pop_server_session (mongoc_topology_t *topology, - bson_error_t *error) -{ - int64_t timeout; - mongoc_server_session_t *ss = NULL; - bool loadbalanced; - mc_shared_tpld td = mc_tpld_take_ref (topology); - - ENTRY; - - timeout = td.ptr->session_timeout_minutes; - loadbalanced = td.ptr->type == MONGOC_TOPOLOGY_LOAD_BALANCED; - - /* When the topology type is LoadBalanced, sessions are always supported. */ - if (!loadbalanced && timeout == MONGOC_NO_SESSIONS) { - /* if needed, connect and check for session timeout again */ - if (!mongoc_topology_description_has_data_node (td.ptr)) { - if (!mongoc_topology_select_server_id ( - topology, - MONGOC_SS_READ, - NULL /* read prefs */, - NULL /* chosen read mode */, - NULL /* deprioritized servers */, - error)) { - ss = NULL; - goto done; - } - - /* Topology may have been updated by a scan */ - mc_tpld_renew_ref (&td, topology); - - timeout = td.ptr->session_timeout_minutes; - } - - if (timeout == MONGOC_NO_SESSIONS) { - bson_set_error (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_SESSION_FAILURE, - "Server does not support sessions"); - ss = NULL; - goto done; - } - } - - ss = mongoc_server_session_pool_get (topology->session_pool, error); - -done: - mc_tpld_drop_ref (&td); - RETURN (ss); -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_push_server_session -- - * - * Internal function. Return a server session to the pool. - * - *-------------------------------------------------------------------------- - */ - -void -_mongoc_topology_push_server_session (mongoc_topology_t *topology, - mongoc_server_session_t *server_session) -{ - ENTRY; - - /** - * ! note: - * At time of writing, this diverges from the spec: - * https://github.com/mongodb/specifications/blob/df6be82f865e9b72444488fd62ae1eb5fca18569/source/sessions/driver-sessions.rst#algorithm-to-return-a-serversession-instance-to-the-server-session-pool - * - * The spec notes that before returning a session, we should first inspect - * the back of the pool for expired items and delete them. In this case, we - * simply return the item to the top of the pool and leave the remainder - * unchanged. - * - * The next pop operation that encounters an expired session will clear the - * entire session pool, thus preventing unbounded growth of the pool. - */ - mongoc_server_session_pool_return (topology->session_pool, server_session); - - EXIT; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_topology_end_sessions_cmd -- - * - * Internal function. End up to 10,000 server sessions. @cmd is an - * uninitialized document. Sessions are destroyed as their ids are - * appended to @cmd. - * - * Driver Sessions Spec: "If the number of sessions is very large the - * endSessions command SHOULD be run multiple times to end 10,000 - * sessions at a time (in order to avoid creating excessively large - * commands)." - * - * Returns: - * true if any session ids were appended to @cmd. - * - *-------------------------------------------------------------------------- - */ - -bool -_mongoc_topology_end_sessions_cmd (mongoc_topology_t *topology, bson_t *cmd) -{ - bson_array_builder_t *ar; - /* Only end up to 10'000 sessions */ - const int ENDED_SESSION_PRUNING_LIMIT = 10000; - int i = 0; - mongoc_server_session_t *ss = - mongoc_server_session_pool_get_existing (topology->session_pool); - - bson_init (cmd); - BSON_APPEND_ARRAY_BUILDER_BEGIN (cmd, "endSessions", &ar); - - for (; i < ENDED_SESSION_PRUNING_LIMIT && ss != NULL; - ++i, - ss = mongoc_server_session_pool_get_existing (topology->session_pool)) { - bson_array_builder_append_document (ar, &ss->lsid); - mongoc_server_session_pool_drop (topology->session_pool, ss); - } - - if (ss) { - /* We deleted at least 10'000 sessions, so we will need to return the - * final session that we didn't drop */ - mongoc_server_session_pool_return (topology->session_pool, ss); - } - - bson_append_array_builder_end (cmd, ar); - - return i > 0; -} - -void -_mongoc_topology_dup_handshake_cmd (const mongoc_topology_t *topology, - bson_t *copy_into) -{ - _mongoc_topology_scanner_dup_handshake_cmd (topology->scanner, copy_into); -} - -void -_mongoc_topology_bypass_cooldown (mongoc_topology_t *topology) -{ - BSON_ASSERT (topology->single_threaded); - topology->scanner->bypass_cooldown = true; -} - -static void -_find_topology_version (const bson_t *reply, bson_t *topology_version) -{ - bson_iter_t iter; - const uint8_t *bytes; - uint32_t len; - - if (!bson_iter_init_find (&iter, reply, "topologyVersion") || - !BSON_ITER_HOLDS_DOCUMENT (&iter)) { - bson_init (topology_version); - return; - } - bson_iter_document (&iter, &len, &bytes); - BSON_ASSERT (bson_init_static (topology_version, bytes, len)); -} - - -static bool -_handle_sdam_app_error_command (mongoc_topology_t *topology, - const mongoc_topology_description_t *td, - uint32_t server_id, - uint32_t generation, - const bson_oid_t *service_id, - const mongoc_server_description_t *sd, - uint32_t max_wire_version, - const bson_t *reply) -{ - bson_error_t cmd_error; - bson_t incoming_topology_version; - bool pool_cleared = false; - bool should_clear_pool = false; - mc_tpld_modification tdmod; - mongoc_server_description_t *mut_sd; - - BSON_UNUSED (td); - - if (_mongoc_cmd_check_ok_no_wce ( - reply, MONGOC_ERROR_API_VERSION_2, &cmd_error)) { - /* No error. */ - return false; - } - - if (!_mongoc_error_is_state_change (&cmd_error)) { - /* Not a "not primary" or "node is recovering" error. */ - return false; - } - - /* Check if the error is "stale", i.e. the topologyVersion refers to an - * older - * version of the server than we have stored in the topology description. - */ - _find_topology_version (reply, &incoming_topology_version); - if (mongoc_server_description_topology_version_cmp ( - &sd->topology_version, &incoming_topology_version) >= 0) { - /* The server description is greater or equal, ignore the error. */ - bson_destroy (&incoming_topology_version); - return false; - } - - should_clear_pool = (max_wire_version <= WIRE_VERSION_4_0 || - _mongoc_error_is_shutdown (&cmd_error)); - - tdmod = mc_tpld_modify_begin (topology); - - /* Get the server handle again, which might have been removed. */ - mut_sd = - mongoc_topology_description_server_by_id (tdmod.new_td, server_id, NULL); - - if (!mut_sd) { - /* Server was already removed/invalidated */ - mc_tpld_modify_drop (tdmod); - bson_destroy (&incoming_topology_version); - return false; - } - - /* Check the topology version a second time, now that we have an exclusive - * lock on the latest topology description. */ - if (mongoc_server_description_topology_version_cmp ( - &mut_sd->topology_version, &incoming_topology_version) >= 0) { - /* The server description is greater or equal, ignore the error. */ - mc_tpld_modify_drop (tdmod); - bson_destroy (&incoming_topology_version); - return false; - } - - if (generation < mc_tpl_sd_get_generation (mut_sd, service_id)) { - /* Our view of the server description is stale. Ignore it. */ - mc_tpld_modify_drop (tdmod); - bson_destroy (&incoming_topology_version); - return false; - } - - /* Overwrite the topology version. */ - mongoc_server_description_set_topology_version (mut_sd, - &incoming_topology_version); - - /* SDAM: When handling a "not primary" or "node is recovering" error, the - * client MUST clear the server's connection pool if and only if the error - * is "node is shutting down" or the error originated from server version - * < 4.2. - */ - if (should_clear_pool) { - _mongoc_topology_description_clear_connection_pool ( - tdmod.new_td, server_id, service_id); - pool_cleared = true; - } - - /* - * SDAM: When the client sees a "not primary" or "node is recovering" - * error and the error's topologyVersion is strictly greater than the - * current ServerDescription's topologyVersion it MUST replace the - * server's description with a ServerDescription of type Unknown. - */ - mongoc_topology_description_invalidate_server ( - tdmod.new_td, server_id, &cmd_error); - - if (topology->single_threaded) { - /* SDAM: For single-threaded clients, in the case of a "not primary" or - * "node is shutting down" error, the client MUST mark the topology as - * "stale" - */ - if (_mongoc_error_is_not_primary (&cmd_error)) { - topology->stale = true; - } - } else { - /* SDAM Spec: "Multi-threaded and asynchronous clients MUST request an - * immediate check of the server." - * Instead of requesting a check of the one server, request a scan - * to all servers (to find the new primary). - */ - _mongoc_topology_request_scan (topology); - } - - mc_tpld_modify_commit (tdmod); - bson_destroy (&incoming_topology_version); - - return pool_cleared; -} - - -bool -_mongoc_topology_handle_app_error (mongoc_topology_t *topology, - uint32_t server_id, - bool handshake_complete, - _mongoc_sdam_app_error_type_t type, - const bson_t *reply, - const bson_error_t *why, - uint32_t max_wire_version, - uint32_t generation, - const bson_oid_t *service_id) -{ - bson_error_t server_selection_error; - const mongoc_server_description_t *sd; - bool cleared_pool = false; - mc_shared_tpld td = mc_tpld_take_ref (topology); - - /* Start by checking every condition in which we should ignore the error */ - sd = mongoc_topology_description_server_by_id_const ( - td.ptr, server_id, &server_selection_error); - - if (!sd) { - /* The server was already removed from the topology. Ignore error. */ - goto ignore_error; - } - - /* When establishing a new connection in load balanced mode, drivers MUST NOT - * perform SDAM error handling for any errors that occur before the MongoDB - * Handshake. */ - if (td.ptr->type == MONGOC_TOPOLOGY_LOAD_BALANCED && !handshake_complete) { - goto ignore_error; - } - - if (generation < mc_tpl_sd_get_generation (sd, service_id)) { - /* This is a stale connection. Ignore. */ - goto ignore_error; - } - - if (type == MONGOC_SDAM_APP_ERROR_TIMEOUT && handshake_complete) { - /* Timeout errors after handshake are ok, do nothing. */ - goto ignore_error; - } - - /* Do something with the error */ - if (type == MONGOC_SDAM_APP_ERROR_COMMAND) { - cleared_pool = _handle_sdam_app_error_command (topology, - td.ptr, - server_id, - generation, - service_id, - sd, - max_wire_version, - reply); - } else { - /* Invalidate the server that saw the error. */ - mc_tpld_modification tdmod = mc_tpld_modify_begin (topology); - sd = mongoc_topology_description_server_by_id_const ( - tdmod.new_td, server_id, NULL); - /* Check if the server has already been invalidated */ - if (!sd || generation < mc_tpl_sd_get_generation (sd, service_id)) { - mc_tpld_modify_drop (tdmod); - goto ignore_error; - } - /* Mark server as unknown. */ - mongoc_topology_description_invalidate_server ( - tdmod.new_td, server_id, why); - /* Clear the connection pool */ - _mongoc_topology_description_clear_connection_pool ( - tdmod.new_td, server_id, service_id); - cleared_pool = true; - if (!topology->single_threaded) { - _mongoc_topology_background_monitoring_cancel_check (topology, - server_id); - } - mc_tpld_modify_commit (tdmod); - } - -ignore_error: /* <- Jump taken if we should ignore the error */ - - mc_tpld_drop_ref (&td); - return cleared_pool; -} - -/* Called from application threads - * Caller must hold topology lock. - * For single-threaded monitoring, the topology scanner may include errors for - * servers that were removed from the topology. - */ -static void -_topology_collect_errors (const mongoc_topology_description_t *td, - bson_error_t *error_out) -{ - const mongoc_server_description_t *server_description; - bson_string_t *error_message; - - memset (error_out, 0, sizeof (bson_error_t)); - error_message = bson_string_new (""); - - for (size_t i = 0u; i < mc_tpld_servers_const (td)->items_len; i++) { - const bson_error_t *error; - - server_description = mc_tpld_servers_const (td)->items[i].item; - error = &server_description->error; - if (error->code) { - if (error_message->len > 0) { - bson_string_append_c (error_message, ' '); - } - bson_string_append_printf ( - error_message, "[%s]", server_description->error.message); - /* The last error's code and domain wins. */ - error_out->code = error->code; - error_out->domain = error->domain; - } - } - - bson_strncpy ((char *) &error_out->message, - error_message->str, - sizeof (error_out->message)); - bson_string_free (error_message, true); -} - -void -_mongoc_topology_set_rr_resolver (mongoc_topology_t *topology, - _mongoc_rr_resolver_fn rr_resolver) -{ - topology->rr_resolver = rr_resolver; -} - -void -_mongoc_topology_set_srv_polling_rescan_interval_ms ( - mongoc_topology_t *topology, int64_t val) -{ - topology->srv_polling_rescan_interval_ms = val; -} - -uint32_t -_mongoc_topology_get_connection_pool_generation ( - const mongoc_topology_description_t *td, - uint32_t server_id, - const bson_oid_t *service_id) -{ - const mongoc_server_description_t *sd; - bson_error_t error; - - BSON_ASSERT (service_id); - - sd = mongoc_topology_description_server_by_id_const (td, server_id, &error); - if (!sd) { - /* Server removed, ignore and ignore error. */ - return 0; - } - - return mc_tpl_sd_get_generation (sd, service_id); -} - -mc_tpld_modification -mc_tpld_modify_begin (mongoc_topology_t *tpl) -{ - mc_shared_tpld prev_td; - mongoc_topology_description_t *new_td; - bson_mutex_lock (&tpl->tpld_modification_mtx); - prev_td = mc_tpld_take_ref (tpl); - new_td = mongoc_topology_description_new_copy (prev_td.ptr), - mc_tpld_drop_ref (&prev_td); - return (mc_tpld_modification){ - .new_td = new_td, - .topology = tpl, - }; -} - -void -mc_tpld_modify_commit (mc_tpld_modification mod) -{ - mongoc_shared_ptr old_sptr = - mongoc_shared_ptr_copy (mod.topology->_shared_descr_._sptr_); - mongoc_shared_ptr new_sptr = - mongoc_shared_ptr_create (mod.new_td, _tpld_destroy_and_free); - mongoc_atomic_shared_ptr_store (&mod.topology->_shared_descr_._sptr_, - new_sptr); - bson_mutex_unlock (&mod.topology->tpld_modification_mtx); - mongoc_shared_ptr_reset_null (&new_sptr); - mongoc_shared_ptr_reset_null (&old_sptr); -} - -void -mc_tpld_modify_drop (mc_tpld_modification mod) -{ - bson_mutex_unlock (&mod.topology->tpld_modification_mtx); - mongoc_topology_description_destroy (mod.new_td); -} - -bool -mongoc_topology_uses_server_api (const mongoc_topology_t *topology) -{ - BSON_ASSERT_PARAM (topology); - return mongoc_topology_scanner_uses_server_api (topology->scanner); -} - -bool -mongoc_topology_uses_loadbalanced (const mongoc_topology_t *topology) -{ - BSON_ASSERT_PARAM (topology); - return mongoc_topology_scanner_uses_loadbalanced (topology->scanner); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-trace-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-trace-private.h deleted file mode 100644 index 604b27621..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-trace-private.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - - -#ifndef MONGOC_TRACE_PRIVATE_H -#define MONGOC_TRACE_PRIVATE_H - - -#include -#include - -#include "mongoc-log.h" -#include "mongoc-log-private.h" -#include "mongoc-config.h" - - -BSON_BEGIN_DECLS - -#define TRACE(msg, ...) \ - do { \ - if (MONGOC_TRACE_ENABLED) { \ - mongoc_log (MONGOC_LOG_LEVEL_TRACE, \ - MONGOC_LOG_DOMAIN, \ - "TRACE: %s():%d " msg, \ - BSON_FUNC, \ - __LINE__, \ - __VA_ARGS__); \ - } \ - } while (0) -#define ENTRY \ - do { \ - if (MONGOC_TRACE_ENABLED) { \ - mongoc_log (MONGOC_LOG_LEVEL_TRACE, \ - MONGOC_LOG_DOMAIN, \ - "ENTRY: %s():%d", \ - BSON_FUNC, \ - __LINE__); \ - } \ - } while (0) -#define EXIT \ - do { \ - if (MONGOC_TRACE_ENABLED) { \ - mongoc_log (MONGOC_LOG_LEVEL_TRACE, \ - MONGOC_LOG_DOMAIN, \ - " EXIT: %s():%d", \ - BSON_FUNC, \ - __LINE__); \ - } \ - return; \ - } while (0) -#define RETURN(ret) \ - do { \ - if (MONGOC_TRACE_ENABLED) { \ - mongoc_log (MONGOC_LOG_LEVEL_TRACE, \ - MONGOC_LOG_DOMAIN, \ - " EXIT: %s():%d", \ - BSON_FUNC, \ - __LINE__); \ - } \ - return ret; \ - } while (0) -#define GOTO(label) \ - do { \ - if (MONGOC_TRACE_ENABLED) { \ - mongoc_log (MONGOC_LOG_LEVEL_TRACE, \ - MONGOC_LOG_DOMAIN, \ - " GOTO: %s():%d %s", \ - BSON_FUNC, \ - __LINE__, \ - #label); \ - } \ - goto label; \ - } while (0) -#define DUMP_BYTES(_n, _b, _l) \ - do { \ - if (MONGOC_TRACE_ENABLED) { \ - mongoc_log (MONGOC_LOG_LEVEL_TRACE, \ - MONGOC_LOG_DOMAIN, \ - "TRACE: %s():%d %s = %p [%d]", \ - BSON_FUNC, \ - __LINE__, \ - #_n, \ - _b, \ - (int) _l); \ - mongoc_log_trace_bytes (MONGOC_LOG_DOMAIN, _b, _l); \ - } \ - } while (0) -#define DUMP_BSON(_bson) \ - do { \ - if (MONGOC_TRACE_ENABLED) { \ - char *_bson_str; \ - if (_bson) { \ - _bson_str = bson_as_canonical_extended_json (_bson, NULL); \ - } else { \ - _bson_str = bson_strdup (""); \ - } \ - mongoc_log (MONGOC_LOG_LEVEL_TRACE, \ - MONGOC_LOG_DOMAIN, \ - "TRACE: %s():%d %s = %s", \ - BSON_FUNC, \ - __LINE__, \ - #_bson, \ - _bson_str); \ - bson_free (_bson_str); \ - } \ - } while (0) -#define DUMP_IOVEC(_n, _iov, _iovcnt) \ - do { \ - if (MONGOC_TRACE_ENABLED) { \ - mongoc_log (MONGOC_LOG_LEVEL_TRACE, \ - MONGOC_LOG_DOMAIN, \ - "TRACE: %s():%d %s = %p [%d]", \ - BSON_FUNC, \ - __LINE__, \ - #_n, \ - (void *) _iov, \ - (int) _iovcnt); \ - mongoc_log_trace_iovec (MONGOC_LOG_DOMAIN, _iov, _iovcnt); \ - } \ - } while (0) - - -BSON_END_DECLS - - -#endif /* MONGOC_TRACE_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-ts-pool-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-ts-pool-private.h deleted file mode 100644 index 9a4c51516..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-ts-pool-private.h +++ /dev/null @@ -1,344 +0,0 @@ -#include "mongoc-prelude.h" - -#ifndef MONGOC_TS_POOL_PRIVATE_H -#define MONGOC_TS_POOL_PRIVATE_H - -#include - -#include - -struct _bson_error_t; - -/** Type of an object constructor function */ -typedef void (*_erased_constructor_fn) (void *self, - void *userdata, - struct _bson_error_t *error_out); -/** Type of an object destructor function */ -typedef void (*_erased_destructor_fn) (void *self, void *userdata); -/** Type of an object pruning predicate */ -typedef int (*_erased_prune_predicate) (const void *self, void *userdata); - -/** - * @brief Construction parameters for creating a new object pool. - */ -typedef struct mongoc_ts_pool_params { - /** - * @brief The alignment of the objects that are managed by the pool - */ - size_t element_alignment; - /** - * @brief The size of the objects that are managed by the pool - */ - size_t element_size; - /** - * @brief Arbitrary data pointer that is passed to the - * constructor/destructor/prune_predicate functions - */ - void *userdata; - /** - * @brief A function that is called on a newly-allocated object in the pool. - * - * If `NULL`, newly created objects are just zero-initialized. - * - * Called as `constructor(item_ptr, userdata_ptr, bson_error_ptr)`. - * - * The `bson_error_ptr` is never `NULL`. If the bson_error_ptr->code is - * non-zero, the pool will consider the constructor to have failed, and will - * deallocate the item without destroying it, and then report that failure to - * the caller of `mongoc_ts_pool_get()` that caused the creation of the new - * item. - */ - _erased_constructor_fn constructor; - /** - * @brief A function that will destroy an item before it is deallocated. - * - * If `NULL`, destructing an object is a no-op. - * - * Called as `destructor(item_ptr, userdata_ptr)`. - */ - _erased_destructor_fn destructor; - /** - * @brief A predicate function that is used to automatically drop items from - * the pool. - * - * If `NULL`, item are never automatically dropped from the pool, and - * can only be discarded by use of `mongoc_ts_pool_drop()`. Items will still - * be dropped when the pool is freed, though. - * - * Called as `prune_predicate(item_ptr, userdata_ptr)`. - * - * If this function returns non-zero, this informs the pool that the item - * should not be returned to the pool nor yielded to a pool user. Instead, - * the item will be given to `mongoc_ts_pool_drop`. - */ - _erased_prune_predicate prune_predicate; -} mongoc_ts_pool_params; - -/** - * @brief A thread-safe object pool. - * - * Object pools act as a thread-safe stack of reusable objects. The pool can be - * given a prune-predicate function that will be used to discard elements - * automatically if they meet some user-specified condition. - * - * When an item is taken from a pool, the pool will either create a new item or - * return the *most-recently-returned* *non-pruned* item. i.e. The pool acts as - * a LIFO stack. - * - * Objects are created *automatically* by the pool: Only objects obtained from a - * pool instance can be returned to that pool, and all objects obtained from - * a given pool must either be returned to that same pool, or dropped using - * `mongoc_ts_pool_drop`. - * - * Refer to `mongoc_ts_pool_params` for more information on the construction, - * destruction, and pruning of pool items. - */ -typedef struct mongoc_ts_pool mongoc_ts_pool; - -/** - * @brief Create a new thread-safe pool - * - * @param params The operating parameters for the pool. @see - * mongoc_ts_pool_params - * - * @returns A new thread-safe pool constructed with the given parameters. - * - * @note The pool must be destroyed using `mongoc_ts_pool_free` - */ -mongoc_ts_pool * -mongoc_ts_pool_new (mongoc_ts_pool_params params); - -/** - * @brief Destroy a pool of objects previously created with `mongo_ts_pool_new` - * - * Any objects remaining in the pool will also be destroyed. - * - * @note All objects that have been obtained from the pool must be returned to - * the pool before it is freed. - */ -void -mongoc_ts_pool_free (mongoc_ts_pool *pool); - -/** - * @brief Obtain an object from the pool. - * - * If the pool is empty, the pool will try to create a new item and return it. - * If the constructor of that item fails, this function will return `NULL` and - * set an error in `error`. - * - * @param pool The pool of objects. - * @param error An error out-parameter. If the constructor of an object is - * called and fails, it will set an error through this parameter. - * @returns A pointer to an object associated with the pool, or `NULL` if the - * object's constructor fails. - * - * @note Returns the most-recently-returned non-pruned item from the pool (i.e. - * the pool is a LIFO stack). - * - * @note If the return value is `NULL`, then an error will be set in `*error`. - * If the return value is non-`NULL`, then the value of `*error` is unspecified. - * - * @note A non-NULL returned item MUST be passed to either - * `mongo_ts_pool_return` or `mongo_ts_pool_drop` BEFORE the pool is destroyed - * with `mongo_ts_pool_free`. - */ -void * -mongoc_ts_pool_get (mongoc_ts_pool *pool, struct _bson_error_t *error); - -/** - * @brief Attempt to pop an object from the pool. - * - * Unlike `mongoc_ts_pool_get`, if the pool is empty, this function returns - * `NULL` unconditionally. - * - * @param pool The pool of objects. - * @returns A pointer to an object previously passed to `mongo_ts_pool_push`, - * or `NULL` if the pool is empty. - * - * @note Returns the most-recently-returned non-pruned item from the pool - * (i.e. the pool is a LIFO stack). - */ -void * -mongoc_ts_pool_get_existing (mongoc_ts_pool *pool); - -/** - * @brief Return an object obtained from a pool back to the pool that manages it - * - * @param item A pointer that was previously returned from a call to - * `mongoc_ts_pool_get` or `mongoc_ts_pool_get_existing` - */ -void -mongoc_ts_pool_return (mongoc_ts_pool *pool, void *item); - -/** - * @brief Obtain the number of elements in the pool. - * - * @note If the pool could be modified by another thread simultaneously, then - * the return value may become immediately stale. - */ -size_t -mongoc_ts_pool_size (const mongoc_ts_pool *pool); - -/** - * @brief Determine whether the pool is empty. - * - * @note If the pool could be modified by another thread simultaneously, then - * the result may become immediately stale. - */ -int -mongoc_ts_pool_is_empty (const mongoc_ts_pool *pool); - -/** - * @brief Destroy all items currently in the given pool. - * - * Objects that are "checked-out" of the pool are unaffected. - * - * @note This does not free the pool. For that purpose, us `mongoc_ts_pool_free` - */ -void -mongoc_ts_pool_clear (mongoc_ts_pool *pool); - -/** - * @brief Destroy an item that was created by a pool - * - * Instead of returning to the pool, the item will be destroyed and deallocated. - * - * @param item A pointer returned by `mongoc_ts_pool_get` or - * `mongo_ts_pool_get_existing`. - */ -void -mongoc_ts_pool_drop (mongoc_ts_pool *pool, void *item); - -/** - * @brief Visit each element of the pool, optionally pruning items. - * - * @note While this visit function is executing, all pool operations are - * blocked on all threads. Attempting to return/get/drop items in the pool from - * within the visit callback will deadlock. - * - * The visit function will be called as: - * - * visit(pool_item, pool_userdata, visit_userdata) - * - * If the visitor function returns non-zero for an item, then that item will be - * removed from the pool. - * - * @param pool The pool of items to visit - * @param visit_userdata Optional additional context for the visitor - * @param visitor The visit function - * - */ -void -mongoc_ts_pool_visit_each (mongoc_ts_pool *pool, - void *visit_userdata, - int (*visitor) (void *item, - void *pool_userdata, - void *visit_userdata)); - -/** - * @brief Declare a thread-safe pool type that contains elements of a specific - * type. Wraps a `mongoc_ts_pool`. - * - * @param ElementType The type of object contained in the pool - * @param PoolName The name of the pool type. All methods of the pool will be - * prefixed by this name. - * @param UserDataType The type of the userdata associated with the constructor, - * destructor, and prune predicate. May be `void`. - * @param Constructor A function that constructs new elements for the pool, or - * `NULL` - * @param Destructor An element destructor function, or `NULL` - * @param PrunePredicate A function that checks whether elements should be - * dropped from the pool, or `NULL` - */ -#define MONGOC_DECL_SPECIAL_TS_POOL(ElementType, \ - PoolName, \ - UserDataType, \ - Constructor, \ - Destructor, \ - PrunePredicate) \ - typedef struct PoolName { \ - mongoc_ts_pool *pool; \ - } PoolName; \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE PoolName PoolName##_new_with_params ( \ - void (*constructor) ( \ - ElementType *, UserDataType *, struct _bson_error_t *), \ - void (*destructor) (ElementType *, UserDataType *), \ - int (*prune_predicate) (ElementType *, UserDataType *), \ - UserDataType *userdata) \ - { \ - PoolName ret; \ - mongoc_ts_pool_params params = {0}; \ - params.userdata = userdata; \ - params.constructor = (_erased_constructor_fn) constructor; \ - params.destructor = (_erased_destructor_fn) destructor; \ - params.prune_predicate = (_erased_prune_predicate) prune_predicate; \ - params.element_alignment = BSON_ALIGNOF (ElementType); \ - params.element_size = sizeof (ElementType); \ - ret.pool = mongoc_ts_pool_new (params); \ - return ret; \ - } \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE PoolName PoolName##_new ( \ - UserDataType *userdata) \ - { \ - return PoolName##_new_with_params ( \ - Constructor, Destructor, PrunePredicate, userdata); \ - } \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE void PoolName##_free (PoolName p) \ - { \ - mongoc_ts_pool_free (p.pool); \ - } \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE void PoolName##_clear (PoolName p) \ - { \ - mongoc_ts_pool_clear (p.pool); \ - } \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE ElementType *PoolName##_get_existing ( \ - PoolName p) \ - { \ - return (ElementType *) mongoc_ts_pool_get_existing (p.pool); \ - } \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE ElementType *PoolName##_get ( \ - PoolName p, struct _bson_error_t *error) \ - { \ - return (ElementType *) mongoc_ts_pool_get (p.pool, error); \ - } \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE void PoolName##_return ( \ - PoolName p, ElementType *elem) \ - { \ - mongoc_ts_pool_return (p.pool, elem); \ - } \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE void PoolName##_drop ( \ - PoolName p, ElementType *elem) \ - { \ - mongoc_ts_pool_drop (p.pool, elem); \ - } \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE size_t PoolName##_size (PoolName p) \ - { \ - return mongoc_ts_pool_size (p.pool); \ - } \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE int PoolName##_is_empty (PoolName p) \ - { \ - return mongoc_ts_pool_is_empty (p.pool); \ - } \ - \ - BSON_MAYBE_UNUSED static BSON_INLINE void PoolName##_visit_each ( \ - PoolName p, \ - void *visit_userdata, \ - int (*visitor) (ElementType * elem, \ - UserDataType * pool_userdata, \ - void *visit_userdata)) \ - { \ - mongoc_ts_pool_visit_each ( \ - p.pool, visit_userdata, (int (*) (void *, void *, void *)) visitor); \ - } - -#endif /* MONGOC_TS_POOL_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-uri-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-uri-private.h deleted file mode 100644 index 37182bf0d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-uri-private.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_URI_PRIVATE_H -#define MONGOC_URI_PRIVATE_H - -#include "mongoc-uri.h" -#include "mongoc-scram-private.h" -#include "mongoc-crypto-private.h" - - -BSON_BEGIN_DECLS - - -bool -mongoc_uri_upsert_host_and_port (mongoc_uri_t *uri, - const char *host_and_port, - bson_error_t *error); -bool -mongoc_uri_upsert_host (mongoc_uri_t *uri, - const char *host, - uint16_t port, - bson_error_t *error); -void -mongoc_uri_remove_host (mongoc_uri_t *uri, const char *host, uint16_t port); - -bool -mongoc_uri_parse_host (mongoc_uri_t *uri, const char *str); -bool -mongoc_uri_parse_options (mongoc_uri_t *uri, - const char *str, - bool from_dns, - bson_error_t *error); -int32_t -mongoc_uri_get_local_threshold_option (const mongoc_uri_t *uri); - -bool -_mongoc_uri_requires_auth_negotiation (const mongoc_uri_t *uri); - -const char * -mongoc_uri_canonicalize_option (const char *key); - -mongoc_uri_t * -_mongoc_uri_copy_and_replace_host_list (const mongoc_uri_t *original, - const char *host); - -bool -mongoc_uri_init_with_srv_host_list (mongoc_uri_t *uri, - mongoc_host_list_t *hosts, - bson_error_t *error); - -bool -mongoc_uri_validate_srv_result (const mongoc_uri_t *uri, - const char *host, - bson_error_t *error); - -#ifdef MONGOC_ENABLE_CRYPTO -void -_mongoc_uri_init_scram (const mongoc_uri_t *uri, - mongoc_scram_t *scram, - mongoc_crypto_hash_algorithm_t algo); -#endif - -bool -mongoc_uri_finalize (mongoc_uri_t *uri, bson_error_t *error); - -BSON_END_DECLS - - -#endif /* MONGOC_URI_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-uri.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-uri.c deleted file mode 100644 index bf3ed673f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-uri.c +++ /dev/null @@ -1,3314 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include - -/* strcasecmp on windows */ -#include "mongoc-util-private.h" - -#include "mongoc-config.h" -#include "mongoc-host-list.h" -#include "mongoc-host-list-private.h" -#include "mongoc-log.h" -#include "mongoc-handshake-private.h" -#include "mongoc-socket.h" -#include "mongoc-topology-private.h" -#include "mongoc-uri-private.h" -#include "mongoc-read-concern-private.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-compression-private.h" -#include "utlist.h" - -#include - -struct _mongoc_uri_t { - char *str; - bool is_srv; - char srv[BSON_HOST_NAME_MAX + 1]; - mongoc_host_list_t *hosts; - char *username; - char *password; - char *database; - bson_t raw; /* Unparsed options, see mongoc_uri_parse_options */ - bson_t options; /* Type-coerced and canonicalized options */ - bson_t credentials; - bson_t compressors; - mongoc_read_prefs_t *read_prefs; - mongoc_read_concern_t *read_concern; - mongoc_write_concern_t *write_concern; -}; - -#define MONGOC_URI_ERROR(error, format, ...) \ - bson_set_error (error, \ - MONGOC_ERROR_COMMAND, \ - MONGOC_ERROR_COMMAND_INVALID_ARG, \ - format, \ - __VA_ARGS__); - - -static const char *escape_instructions = "Percent-encode username and password" - " according to RFC 3986"; - -static bool -_mongoc_uri_set_option_as_int32 (mongoc_uri_t *uri, - const char *option, - int32_t value); - -static bool -_mongoc_uri_set_option_as_int32_with_error (mongoc_uri_t *uri, - const char *option, - int32_t value, - bson_error_t *error); - -static bool -_mongoc_uri_set_option_as_int64_with_error (mongoc_uri_t *uri, - const char *option, - int64_t value, - bson_error_t *error); - -static void -mongoc_uri_do_unescape (char **str) -{ - char *tmp; - - if ((tmp = *str)) { - *str = mongoc_uri_unescape (tmp); - bson_free (tmp); - } -} - - -#define VALIDATE_SRV_ERR() \ - do { \ - bson_set_error (error, \ - MONGOC_ERROR_STREAM, \ - MONGOC_ERROR_STREAM_NAME_RESOLUTION, \ - "Invalid host \"%s\" returned for service \"%s\": " \ - "host must be subdomain of service name", \ - host, \ - srv_hostname); \ - return false; \ - } while (0) - - -static int -count_dots (const char *s) -{ - int n = 0; - const char *dot = s; - - while ((dot = strchr (dot + 1, '.'))) { - n++; - } - - return n; -} - -static char * -lowercase_str_new (const char *key) -{ - char *ret = bson_strdup (key); - mongoc_lowercase (key, ret); - return ret; -} - -/* at least one character, and does not start with dot */ -static bool -valid_hostname (const char *s) -{ - size_t len = strlen (s); - - return len > 1 && s[0] != '.'; -} - - -bool -mongoc_uri_validate_srv_result (const mongoc_uri_t *uri, - const char *host, - bson_error_t *error) -{ - const char *srv_hostname; - const char *srv_host; - - srv_hostname = mongoc_uri_get_srv_hostname (uri); - BSON_ASSERT (srv_hostname); - - if (!valid_hostname (host)) { - VALIDATE_SRV_ERR (); - } - - srv_host = strchr (srv_hostname, '.'); - BSON_ASSERT (srv_host); - - /* host must be descendent of service root: if service is - * "a.foo.co" host can be like "a.foo.co", "b.foo.co", "a.b.foo.co", etc. - */ - if (strlen (host) < strlen (srv_host)) { - VALIDATE_SRV_ERR (); - } - - if (!mongoc_ends_with (host, srv_host)) { - VALIDATE_SRV_ERR (); - } - - return true; -} - -/* copy and upsert @host into @uri's host list. */ -static bool -_upsert_into_host_list (mongoc_uri_t *uri, - mongoc_host_list_t *host, - bson_error_t *error) -{ - if (uri->is_srv && - !mongoc_uri_validate_srv_result (uri, host->host, error)) { - return false; - } - - _mongoc_host_list_upsert (&uri->hosts, host); - - return true; -} - -bool -mongoc_uri_upsert_host_and_port (mongoc_uri_t *uri, - const char *host_and_port, - bson_error_t *error) -{ - mongoc_host_list_t temp; - - memset (&temp, 0, sizeof (mongoc_host_list_t)); - if (!_mongoc_host_list_from_string_with_err (&temp, host_and_port, error)) { - return false; - } - - return _upsert_into_host_list (uri, &temp, error); -} - -bool -mongoc_uri_upsert_host (mongoc_uri_t *uri, - const char *host, - uint16_t port, - bson_error_t *error) -{ - mongoc_host_list_t temp; - - memset (&temp, 0, sizeof (mongoc_host_list_t)); - if (!_mongoc_host_list_from_hostport_with_err (&temp, host, port, error)) { - return false; - } - - return _upsert_into_host_list (uri, &temp, error); -} - -void -mongoc_uri_remove_host (mongoc_uri_t *uri, const char *host, uint16_t port) -{ - _mongoc_host_list_remove_host (&(uri->hosts), host, port); -} - -/* - *-------------------------------------------------------------------------- - * - * scan_to_unichar -- - * - * Scans 'str' until either a character matching 'match' is found, - * until one of the characters in 'terminators' is encountered, or - * until we reach the end of 'str'. - * - * NOTE: 'terminators' may not include multibyte UTF-8 characters. - * - * Returns: - * If 'match' is found, returns a copy of the section of 'str' before - * that character. Otherwise, returns NULL. - * - * Side Effects: - * If 'match' is found, sets 'end' to begin at the matching character - * in 'str'. - * - *-------------------------------------------------------------------------- - */ - -static char * -scan_to_unichar (const char *str, - bson_unichar_t match, - const char *terminators, - const char **end) -{ - bson_unichar_t c; - const char *iter; - - for (iter = str; iter && *iter && (c = bson_utf8_get_char (iter)); - iter = bson_utf8_next_char (iter)) { - if (c == match) { - *end = iter; - return bson_strndup (str, iter - str); - } else if (c == '\\') { - iter = bson_utf8_next_char (iter); - if (!bson_utf8_get_char (iter)) { - break; - } - } else { - const char *term_iter; - for (term_iter = terminators; *term_iter; term_iter++) { - if (c == *term_iter) { - return NULL; - } - } - } - } - - return NULL; -} - - -static bool -mongoc_uri_parse_scheme (mongoc_uri_t *uri, const char *str, const char **end) -{ - if (!strncmp (str, "mongodb+srv://", 14)) { - uri->is_srv = true; - *end = str + 14; - return true; - } - - if (!strncmp (str, "mongodb://", 10)) { - uri->is_srv = false; - *end = str + 10; - return true; - } - - return false; -} - - -static bool -mongoc_uri_has_unescaped_chars (const char *str, const char *chars) -{ - const char *c; - const char *tmp; - char *s; - - for (c = chars; *c; c++) { - s = scan_to_unichar (str, (bson_unichar_t) *c, "", &tmp); - if (s) { - bson_free (s); - return true; - } - } - - return false; -} - - -/* "str" is non-NULL, the part of URI between "mongodb://" and first "@" */ -static bool -mongoc_uri_parse_userpass (mongoc_uri_t *uri, - const char *str, - bson_error_t *error) -{ - const char *prohibited = "@:/"; - const char *end_user; - - BSON_ASSERT (str); - BSON_ASSERT (uri); - - if ((uri->username = scan_to_unichar (str, ':', "", &end_user))) { - uri->password = bson_strdup (end_user + 1); - } else { - uri->username = bson_strdup (str); - uri->password = NULL; - } - - if (mongoc_uri_has_unescaped_chars (uri->username, prohibited)) { - MONGOC_URI_ERROR (error, - "Username \"%s\" must not have unescaped chars. %s", - uri->username, - escape_instructions); - return false; - } - - mongoc_uri_do_unescape (&uri->username); - if (!uri->username) { - MONGOC_URI_ERROR ( - error, "Incorrect URI escapes in username. %s", escape_instructions); - return false; - } - - /* Providing password at all is optional */ - if (uri->password) { - if (mongoc_uri_has_unescaped_chars (uri->password, prohibited)) { - MONGOC_URI_ERROR (error, - "Password \"%s\" must not have unescaped chars. %s", - uri->password, - escape_instructions); - return false; - } - - mongoc_uri_do_unescape (&uri->password); - if (!uri->password) { - MONGOC_URI_ERROR (error, "%s", "Incorrect URI escapes in password"); - return false; - } - } - - return true; -} - -bool -mongoc_uri_parse_host (mongoc_uri_t *uri, const char *host_and_port_in) -{ - char *host_and_port = bson_strdup (host_and_port_in); - bson_error_t err = {0}; - bool r; - - /* unescape host. It doesn't hurt including port. */ - if (mongoc_uri_has_unescaped_chars (host_and_port, "/")) { - MONGOC_WARNING ("Unix Domain Sockets must be escaped (e.g. / = %%2F)"); - bson_free (host_and_port); - return false; - } - - mongoc_uri_do_unescape (&host_and_port); - if (!host_and_port) { - /* invalid */ - bson_free (host_and_port); - return false; - } - - r = mongoc_uri_upsert_host_and_port (uri, host_and_port, &err); - - if (!r) { - MONGOC_ERROR ("%s", err.message); - bson_free (host_and_port); - return false; - } - - bson_free (host_and_port); - return true; -} - - -static bool -mongoc_uri_parse_srv (mongoc_uri_t *uri, const char *str, bson_error_t *error) -{ - if (*str == '\0') { - MONGOC_URI_ERROR (error, "%s", "Missing service name in SRV URI"); - return false; - } - - { - char *service = bson_strdup (str); - - mongoc_uri_do_unescape (&service); - - if (!service || !valid_hostname (service) || count_dots (service) < 2) { - MONGOC_URI_ERROR (error, "%s", "Invalid service name in URI"); - bson_free (service); - return false; - } - - bson_strncpy (uri->srv, service, sizeof uri->srv); - - bson_free (service); - } - - if (strchr (uri->srv, ',')) { - MONGOC_URI_ERROR ( - error, "%s", "Multiple service names are prohibited in an SRV URI"); - return false; - } - - if (strchr (uri->srv, ':')) { - MONGOC_URI_ERROR ( - error, "%s", "Port numbers are prohibited in an SRV URI"); - return false; - } - - return true; -} - - -/* "hosts" is non-NULL, the part between "mongodb://" or "@" and last "/" */ -static bool -mongoc_uri_parse_hosts (mongoc_uri_t *uri, const char *hosts) -{ - const char *next; - const char *end_hostport; - char *s; - BSON_ASSERT (hosts); - /* - * Parsing the series of hosts is a lot more complicated than you might - * imagine. This is due to some characters being both separators as well as - * valid characters within the "hostname". In particularly, we can have file - * paths to specify paths to UNIX domain sockets. We impose the restriction - * that they must be suffixed with ".sock" to simplify the parsing. - * - * You can separate hosts and file system paths to UNIX domain sockets with - * ",". - */ - s = scan_to_unichar (hosts, '?', "", &end_hostport); - if (s) { - MONGOC_WARNING ( - "%s", "A '/' is required between the host list and any options."); - goto error; - } - next = hosts; - do { - /* makes a copy of the section of the string */ - s = scan_to_unichar (next, ',', "", &end_hostport); - if (s) { - next = (char *) end_hostport + 1; - } else { - s = bson_strdup (next); - next = NULL; - } - if (!mongoc_uri_parse_host (uri, s)) { - goto error; - } - bson_free (s); - } while (next); - return true; -error: - bson_free (s); - return false; -} - -/* ----------------------------------------------------------------------------- - * - * mongoc_uri_parse_database -- - * - * Parse the database after @str. @str is expected to point after the - * host list to the character immediately after the / in the uri string. - * If no database is specified in the uri, e.g. the uri has a form like: - * mongodb://localhost/?option=X then uri->database remains NULL after - * parsing. - * - * Return: - * True if the parsed database is valid. An empty database is considered - * valid. - * ----------------------------------------------------------------------------- - */ -static bool -mongoc_uri_parse_database (mongoc_uri_t *uri, const char *str, const char **end) -{ - const char *end_database; - const char *c; - char *invalid_c; - const char *tmp; - - if ((uri->database = scan_to_unichar (str, '?', "", &end_database))) { - if (strcmp (uri->database, "") == 0) { - /* no database is found, don't store the empty string. */ - bson_free (uri->database); - uri->database = NULL; - /* but it is valid to have an empty database. */ - return true; - } - *end = end_database; - } else if (*str) { - uri->database = bson_strdup (str); - *end = str + strlen (str); - } - - mongoc_uri_do_unescape (&uri->database); - if (!uri->database) { - /* invalid */ - return false; - } - - /* invalid characters in database name */ - for (c = "/\\. \"$"; *c; c++) { - invalid_c = - scan_to_unichar (uri->database, (bson_unichar_t) *c, "", &tmp); - if (invalid_c) { - bson_free (invalid_c); - return false; - } - } - - return true; -} - - -static bool -mongoc_uri_parse_auth_mechanism_properties (mongoc_uri_t *uri, const char *str) -{ - char *field; - char *value; - const char *end_scan; - bson_t properties; - - bson_init (&properties); - - /* build up the properties document */ - while ((field = scan_to_unichar (str, ':', "&", &end_scan))) { - str = end_scan + 1; - if (!(value = scan_to_unichar (str, ',', ":&", &end_scan))) { - value = bson_strdup (str); - str = ""; - } else { - str = end_scan + 1; - } - bson_append_utf8 (&properties, field, -1, value, -1); - bson_free (field); - bson_free (value); - } - - /* append our auth properties to our credentials */ - if (!mongoc_uri_set_mechanism_properties (uri, &properties)) { - bson_destroy (&properties); - return false; - } - bson_destroy (&properties); - return true; -} - - -static bool -mongoc_uri_check_srv_service_name (mongoc_uri_t *uri, const char *str) -{ - /* 63 character DNS query limit, excluding prepended underscore. */ - const size_t mongoc_srv_service_name_max = 62u; - - size_t length = 0u; - size_t num_alpha = 0u; - size_t i = 0u; - char prev = '\0'; - - BSON_ASSERT_PARAM (uri); - BSON_ASSERT_PARAM (str); - - length = strlen (str); - - /* Initial DNS Seedlist Discovery Spec: This option specifies a valid SRV - * service name according to RFC 6335, with the exception that it may exceed - * 15 characters as long as the 63rd (62nd with prepended underscore) - * character DNS query limit is not surpassed. */ - if (length > mongoc_srv_service_name_max) { - return false; - } - - /* RFC 6335: MUST be at least 1 character. */ - if (length == 0u) { - return false; - } - - for (i = 0u; i < length; ++i) { - const char c = str[i]; - - /* RFC 6335: MUST contain only US-ASCII letters 'A' - 'Z' and 'a' - 'z', - * digits '0' - '9', and hyphens ('-', ASCII 0x2D or decimal 45). */ - if (!isalpha (c) && !isdigit (c) && c != '-') { - return false; - } - - /* RFC 6335: hyphens MUST NOT be adjacent to other hyphens. */ - if (c == '-' && prev == '-') { - return false; - } - - num_alpha += isalpha (c) ? 1u : 0u; - prev = c; - } - - /* RFC 6335: MUST contain at least one letter ('A' - 'Z' or 'a' - 'z') */ - if (num_alpha == 0u) { - return false; - } - - /* RFC 6335: MUST NOT begin or end with a hyphen. */ - if (str[0] == '-' || str[length - 1u] == '-') { - return false; - } - - return true; -} - -static bool -mongoc_uri_parse_tags (mongoc_uri_t *uri, /* IN */ - const char *str) /* IN */ -{ - const char *end_keyval; - const char *end_key; - bson_t b; - char *keyval; - char *key; - - bson_init (&b); - -again: - if ((keyval = scan_to_unichar (str, ',', "", &end_keyval))) { - if (!(key = scan_to_unichar (keyval, ':', "", &end_key))) { - bson_free (keyval); - goto fail; - } - - bson_append_utf8 (&b, key, -1, end_key + 1, -1); - bson_free (key); - bson_free (keyval); - str = end_keyval + 1; - goto again; - } else if ((key = scan_to_unichar (str, ':', "", &end_key))) { - bson_append_utf8 (&b, key, -1, end_key + 1, -1); - bson_free (key); - } else if (strlen (str)) { - /* we're not finished but we couldn't parse the string */ - goto fail; - } - - mongoc_read_prefs_add_tag (uri->read_prefs, &b); - bson_destroy (&b); - - return true; - -fail: - MONGOC_WARNING ("Unsupported value for \"" MONGOC_URI_READPREFERENCETAGS - "\": \"%s\"", - str); - bson_destroy (&b); - return false; -} - - -/* - *-------------------------------------------------------------------------- - * - * mongoc_uri_bson_append_or_replace_key -- - * - * - * Appends 'option' to the end of 'options' if not already set. - * - * Since we cannot grow utf8 strings inline, we have to allocate a - * temporary bson variable and splice in the new value if the key - * is already set. - * - * NOTE: This function keeps the order of the BSON keys. - * - * NOTE: 'option' is case*in*sensitive. - * - * - *-------------------------------------------------------------------------- - */ - -static void -mongoc_uri_bson_append_or_replace_key (bson_t *options, - const char *option, - const char *value) -{ - bson_iter_t iter; - bool found = false; - - if (bson_iter_init (&iter, options)) { - bson_t tmp = BSON_INITIALIZER; - - while (bson_iter_next (&iter)) { - const bson_value_t *bvalue; - - if (!strcasecmp (bson_iter_key (&iter), option)) { - bson_append_utf8 (&tmp, option, -1, value, -1); - found = true; - continue; - } - - bvalue = bson_iter_value (&iter); - BSON_APPEND_VALUE (&tmp, bson_iter_key (&iter), bvalue); - } - - if (!found) { - bson_append_utf8 (&tmp, option, -1, value, -1); - } - - bson_destroy (options); - bson_copy_to (&tmp, options); - bson_destroy (&tmp); - } -} - - -bool -mongoc_uri_has_option (const mongoc_uri_t *uri, const char *key) -{ - bson_iter_t iter; - - return bson_iter_init_find_case (&iter, &uri->options, key); -} - -bool -mongoc_uri_option_is_int32 (const char *key) -{ - return mongoc_uri_option_is_int64 (key) || - !strcasecmp (key, MONGOC_URI_CONNECTTIMEOUTMS) || - !strcasecmp (key, MONGOC_URI_HEARTBEATFREQUENCYMS) || - !strcasecmp (key, MONGOC_URI_SERVERSELECTIONTIMEOUTMS) || - !strcasecmp (key, MONGOC_URI_SOCKETCHECKINTERVALMS) || - !strcasecmp (key, MONGOC_URI_SOCKETTIMEOUTMS) || - !strcasecmp (key, MONGOC_URI_LOCALTHRESHOLDMS) || - !strcasecmp (key, MONGOC_URI_MAXPOOLSIZE) || - !strcasecmp (key, MONGOC_URI_MAXSTALENESSSECONDS) || - !strcasecmp (key, MONGOC_URI_MINPOOLSIZE) || - !strcasecmp (key, MONGOC_URI_MAXIDLETIMEMS) || - !strcasecmp (key, MONGOC_URI_WAITQUEUEMULTIPLE) || - !strcasecmp (key, MONGOC_URI_WAITQUEUETIMEOUTMS) || - !strcasecmp (key, MONGOC_URI_ZLIBCOMPRESSIONLEVEL) || - !strcasecmp (key, MONGOC_URI_SRVMAXHOSTS); -} - -bool -mongoc_uri_option_is_int64 (const char *key) -{ - return !strcasecmp (key, MONGOC_URI_WTIMEOUTMS); -} - -bool -mongoc_uri_option_is_bool (const char *key) -{ - return !strcasecmp (key, MONGOC_URI_CANONICALIZEHOSTNAME) || - !strcasecmp (key, MONGOC_URI_DIRECTCONNECTION) || - !strcasecmp (key, MONGOC_URI_JOURNAL) || - !strcasecmp (key, MONGOC_URI_RETRYREADS) || - !strcasecmp (key, MONGOC_URI_RETRYWRITES) || - !strcasecmp (key, MONGOC_URI_SAFE) || - !strcasecmp (key, MONGOC_URI_SERVERSELECTIONTRYONCE) || - !strcasecmp (key, MONGOC_URI_TLS) || - !strcasecmp (key, MONGOC_URI_TLSINSECURE) || - !strcasecmp (key, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES) || - !strcasecmp (key, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES) || - !strcasecmp (key, MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK) || - !strcasecmp (key, MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK) || - !strcasecmp (key, MONGOC_URI_LOADBALANCED) || - /* deprecated options */ - !strcasecmp (key, MONGOC_URI_SSL) || - !strcasecmp (key, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES) || - !strcasecmp (key, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES); -} - -bool -mongoc_uri_option_is_utf8 (const char *key) -{ - return !strcasecmp (key, MONGOC_URI_APPNAME) || - !strcasecmp (key, MONGOC_URI_REPLICASET) || - !strcasecmp (key, MONGOC_URI_READPREFERENCE) || - !strcasecmp (key, MONGOC_URI_SRVSERVICENAME) || - !strcasecmp (key, MONGOC_URI_TLSCERTIFICATEKEYFILE) || - !strcasecmp (key, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD) || - !strcasecmp (key, MONGOC_URI_TLSCAFILE) || - /* deprecated options */ - !strcasecmp (key, MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE) || - !strcasecmp (key, MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD) || - !strcasecmp (key, MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE); -} - -const char * -mongoc_uri_canonicalize_option (const char *key) -{ - if (!strcasecmp (key, MONGOC_URI_SSL)) { - return MONGOC_URI_TLS; - } else if (!strcasecmp (key, MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE)) { - return MONGOC_URI_TLSCERTIFICATEKEYFILE; - } else if (!strcasecmp (key, MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD)) { - return MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD; - } else if (!strcasecmp (key, MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE)) { - return MONGOC_URI_TLSCAFILE; - } else if (!strcasecmp (key, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES)) { - return MONGOC_URI_TLSALLOWINVALIDCERTIFICATES; - } else if (!strcasecmp (key, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES)) { - return MONGOC_URI_TLSALLOWINVALIDHOSTNAMES; - } else { - return key; - } -} - -static bool -_mongoc_uri_parse_int64 (const char *key, const char *value, int64_t *result) -{ - char *endptr; - int64_t i; - - errno = 0; - i = bson_ascii_strtoll (value, &endptr, 10); - if (errno || endptr < value + strlen (value)) { - MONGOC_WARNING ("Invalid %s: cannot parse integer\n", key); - return false; - } - - *result = i; - return true; -} - - -static bool -mongoc_uri_parse_int32 (const char *key, const char *value, int32_t *result) -{ - int64_t i; - - if (!_mongoc_uri_parse_int64 (key, value, &i)) { - /* _mongoc_uri_parse_int64 emits a warning if it could not parse the - * given value, so we don't have to add one here. - */ - return false; - } - - if (i > INT32_MAX || i < INT32_MIN) { - MONGOC_WARNING ("Invalid %s: cannot fit in int32\n", key); - return false; - } - - *result = (int32_t) i; - return true; -} - - -static bool -dns_option_allowed (const char *lkey) -{ - /* Initial DNS Seedlist Discovery Spec: "A Client MUST only support the - * authSource, replicaSet, and loadBalanced options through a TXT record, and - * MUST raise an error if any other option is encountered." - */ - return !strcmp (lkey, MONGOC_URI_AUTHSOURCE) || - !strcmp (lkey, MONGOC_URI_REPLICASET) || - !strcmp (lkey, MONGOC_URI_LOADBALANCED); -} - - -/* Decompose a key=val pair and place them into a document. - * Includes case-folding for key portion. - */ -static bool -mongoc_uri_split_option (mongoc_uri_t *uri, - bson_t *options, - const char *str, - bool from_dns, - bson_error_t *error) -{ - bson_iter_t iter; - const char *end_key; - char *key = NULL; - char *lkey = NULL; - char *value = NULL; - const char *opt; - char *opt_end; - size_t opt_len; - bool ret = false; - - if (!(key = scan_to_unichar (str, '=', "", &end_key))) { - MONGOC_URI_ERROR (error, "URI option \"%s\" contains no \"=\" sign", str); - goto CLEANUP; - } - - value = bson_strdup (end_key + 1); - mongoc_uri_do_unescape (&value); - if (!value) { - /* do_unescape detected invalid UTF-8 and freed value */ - MONGOC_URI_ERROR ( - error, "Value for URI option \"%s\" contains invalid UTF-8", key); - goto CLEANUP; - } - - lkey = bson_strdup (key); - mongoc_lowercase (key, lkey); - - /* Initial DNS Seedlist Discovery Spec: "A Client MUST only support the - * authSource, replicaSet, and loadBalanced options through a TXT record, and - * MUST raise an error if any other option is encountered."*/ - if (from_dns && !dns_option_allowed (lkey)) { - MONGOC_URI_ERROR ( - error, "URI option \"%s\" prohibited in TXT record", key); - goto CLEANUP; - } - - /* Special case: READPREFERENCETAGS is a composing option. - * Multiple instances should append, not overwrite. - * Encode them directly to the options field, - * bypassing canonicalization and duplicate checks. - */ - if (!strcmp (lkey, MONGOC_URI_READPREFERENCETAGS)) { - if (!mongoc_uri_parse_tags (uri, value)) { - MONGOC_URI_ERROR ( - error, "Unsupported value for \"%s\": \"%s\"", key, value); - goto CLEANUP; - } - } else if (bson_iter_init_find (&iter, &uri->raw, lkey) || - bson_iter_init_find (&iter, options, lkey)) { - /* Special case, MONGOC_URI_W == "any non-int" is not overridden - * by later values. - */ - if (!strcmp (lkey, MONGOC_URI_W) && - (opt = bson_iter_utf8_unsafe (&iter, &opt_len))) { - strtol (opt, &opt_end, 10); - if (*opt_end != '\0') { - ret = true; - goto CLEANUP; - } - } - - /* Initial DNS Seedlist Discovery Spec: "Client MUST use options - * specified in the Connection String to override options provided - * through TXT records." So, do NOT override existing options with TXT - * options. */ - if (from_dns) { - MONGOC_WARNING ( - "Cannot override URI option \"%s\" from TXT record \"%s\"", - key, - str); - ret = true; - goto CLEANUP; - } - MONGOC_WARNING ("Overwriting previously provided value for '%s'", key); - } - - if (!(strcmp (lkey, MONGOC_URI_REPLICASET)) && *value == '\0') { - MONGOC_URI_ERROR ( - error, "Value for URI option \"%s\" cannot be empty string", lkey); - goto CLEANUP; - } - - mongoc_uri_bson_append_or_replace_key (options, lkey, value); - ret = true; - -CLEANUP: - bson_free (key); - bson_free (lkey); - bson_free (value); - - return ret; -} - - -/* Check for canonical/deprecated conflicts - * between the option list a, and b. - * If both names exist either way with differing values, error. - */ -static bool -mongoc_uri_options_validate_names (const bson_t *a, - const bson_t *b, - bson_error_t *error) -{ - bson_iter_t key_iter, canon_iter; - const char *key = NULL; - const char *canon = NULL; - const char *value = NULL; - const char *cval = NULL; - size_t value_len = 0; - size_t cval_len = 0; - - /* Scan `a` looking for deprecated names - * where the canonical name was also used in `a`, - * or was used in `b`. */ - bson_iter_init (&key_iter, a); - while (bson_iter_next (&key_iter)) { - key = bson_iter_key (&key_iter); - value = bson_iter_utf8_unsafe (&key_iter, &value_len); - canon = mongoc_uri_canonicalize_option (key); - - if (key == canon) { - /* Canonical form, no point checking `b`. */ - continue; - } - - /* Check for a conflict in `a`. */ - if (bson_iter_init_find (&canon_iter, a, canon)) { - cval = bson_iter_utf8_unsafe (&canon_iter, &cval_len); - if ((value_len != cval_len) || strcmp (value, cval)) { - goto HANDLE_CONFLICT; - } - } - - /* Check for a conflict in `b`. */ - if (bson_iter_init_find (&canon_iter, b, canon)) { - cval = bson_iter_utf8_unsafe (&canon_iter, &cval_len); - if ((value_len != cval_len) || strcmp (value, cval)) { - goto HANDLE_CONFLICT; - } - } - } - - return true; - -HANDLE_CONFLICT: - MONGOC_URI_ERROR (error, - "Deprecated option '%s=%s' conflicts with " - "canonical name '%s=%s'", - key, - value, - canon, - cval); - - return false; -} - - -#define HANDLE_DUPE() \ - if (from_dns) { \ - MONGOC_WARNING ("Cannot override URI option \"%s\" from TXT record", \ - key); \ - continue; \ - } else { \ - MONGOC_WARNING ("Overwriting previously provided value for '%s'", key); \ - } - -static bool -mongoc_uri_apply_options (mongoc_uri_t *uri, - const bson_t *options, - bool from_dns, - bson_error_t *error) -{ - bson_iter_t iter; - int32_t v_int; - int64_t v_int64; - const char *key = NULL; - const char *canon = NULL; - const char *value = NULL; - size_t value_len; - bool bval; - - bson_iter_init (&iter, options); - while (bson_iter_next (&iter)) { - key = bson_iter_key (&iter); - canon = mongoc_uri_canonicalize_option (key); - value = bson_iter_utf8_unsafe (&iter, &value_len); - - /* Keep a record of how the option was originally presented. */ - mongoc_uri_bson_append_or_replace_key (&uri->raw, key, value); - - /* This check precedes mongoc_uri_option_is_int32 as all 64-bit values are - * also recognised as 32-bit ints. - */ - if (mongoc_uri_option_is_int64 (key)) { - if (0 < strlen (value)) { - if (!_mongoc_uri_parse_int64 (key, value, &v_int64)) { - goto UNSUPPORTED_VALUE; - } - - if (!_mongoc_uri_set_option_as_int64_with_error ( - uri, canon, v_int64, error)) { - return false; - } - } else { - MONGOC_WARNING ("Empty value provided for \"%s\"", key); - } - } else if (mongoc_uri_option_is_int32 (key)) { - if (0 < strlen (value)) { - if (!mongoc_uri_parse_int32 (key, value, &v_int)) { - goto UNSUPPORTED_VALUE; - } - - if (!_mongoc_uri_set_option_as_int32_with_error ( - uri, canon, v_int, error)) { - return false; - } - } else { - MONGOC_WARNING ("Empty value provided for \"%s\"", key); - } - } else if (!strcmp (key, MONGOC_URI_W)) { - if (*value == '-' || isdigit (*value)) { - v_int = (int) strtol (value, NULL, 10); - _mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_W, v_int); - } else if (0 == strcasecmp (value, "majority")) { - mongoc_uri_bson_append_or_replace_key ( - &uri->options, MONGOC_URI_W, "majority"); - } else if (*value) { - mongoc_uri_bson_append_or_replace_key ( - &uri->options, MONGOC_URI_W, value); - } - - } else if (mongoc_uri_option_is_bool (key)) { - if (0 < strlen (value)) { - if (0 == strcasecmp (value, "true")) { - bval = true; - } else if (0 == strcasecmp (value, "false")) { - bval = false; - } else if ((0 == strcmp (value, "1")) || - (0 == strcasecmp (value, "yes")) || - (0 == strcasecmp (value, "y")) || - (0 == strcasecmp (value, "t"))) { - MONGOC_WARNING ("Deprecated boolean value for \"%s\": \"%s\", " - "please update to \"%s=true\"", - key, - value, - key); - bval = true; - } else if ((0 == strcasecmp (value, "0")) || - (0 == strcasecmp (value, "-1")) || - (0 == strcmp (value, "no")) || - (0 == strcmp (value, "n")) || - (0 == strcmp (value, "f"))) { - MONGOC_WARNING ("Deprecated boolean value for \"%s\": \"%s\", " - "please update to \"%s=false\"", - key, - value, - key); - bval = false; - } else { - goto UNSUPPORTED_VALUE; - } - - if (!mongoc_uri_set_option_as_bool (uri, canon, bval)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Failed to set %s to %d", - canon, - bval); - return false; - } - } else { - MONGOC_WARNING ("Empty value provided for \"%s\"", key); - } - - } else if (!strcmp (key, MONGOC_URI_READPREFERENCETAGS)) { - /* Skip this option here. - * It was marshalled during mongoc_uri_split_option() - * as a special case composing option. - */ - - } else if (!strcmp (key, MONGOC_URI_AUTHMECHANISM) || - !strcmp (key, MONGOC_URI_AUTHSOURCE)) { - if (bson_has_field (&uri->credentials, key)) { - HANDLE_DUPE (); - } - mongoc_uri_bson_append_or_replace_key ( - &uri->credentials, canon, value); - - } else if (!strcmp (key, MONGOC_URI_READCONCERNLEVEL)) { - if (!mongoc_read_concern_is_default (uri->read_concern)) { - HANDLE_DUPE (); - } - mongoc_read_concern_set_level (uri->read_concern, value); - - } else if (!strcmp (key, MONGOC_URI_GSSAPISERVICENAME)) { - char *tmp = bson_strdup_printf ("SERVICE_NAME:%s", value); - if (bson_has_field (&uri->credentials, - MONGOC_URI_AUTHMECHANISMPROPERTIES)) { - MONGOC_WARNING ("authMechanismProperties SERVICE_NAME already set, " - "ignoring '%s'", - key); - } else if (!mongoc_uri_parse_auth_mechanism_properties (uri, tmp)) { - bson_free (tmp); - goto UNSUPPORTED_VALUE; - } - bson_free (tmp); - - } else if (!strcmp (key, MONGOC_URI_SRVSERVICENAME)) { - if (!mongoc_uri_check_srv_service_name (uri, value)) { - goto UNSUPPORTED_VALUE; - } - mongoc_uri_bson_append_or_replace_key (&uri->options, canon, value); - - } else if (!strcmp (key, MONGOC_URI_AUTHMECHANISMPROPERTIES)) { - if (bson_has_field (&uri->credentials, key)) { - HANDLE_DUPE (); - } - if (!mongoc_uri_parse_auth_mechanism_properties (uri, value)) { - goto UNSUPPORTED_VALUE; - } - - } else if (!strcmp (key, MONGOC_URI_APPNAME)) { - /* Part of uri->options */ - if (!mongoc_uri_set_appname (uri, value)) { - goto UNSUPPORTED_VALUE; - } - - } else if (!strcmp (key, MONGOC_URI_COMPRESSORS)) { - if (!bson_empty (mongoc_uri_get_compressors (uri))) { - HANDLE_DUPE (); - } - if (!mongoc_uri_set_compressors (uri, value)) { - goto UNSUPPORTED_VALUE; - } - - } else if (mongoc_uri_option_is_utf8 (key)) { - mongoc_uri_bson_append_or_replace_key (&uri->options, canon, value); - - } else { - /* - * Keys that aren't supported by a driver MUST be ignored. - * - * A WARN level logging message MUST be issued - * https://github.com/mongodb/specifications/blob/master/source/connection-string/connection-string-spec.rst#keys - */ - MONGOC_WARNING ("Unsupported URI option \"%s\"", key); - } - } - - return true; - -UNSUPPORTED_VALUE: - MONGOC_URI_ERROR (error, "Unsupported value for \"%s\": \"%s\"", key, value); - - return false; -} - - -/* Processes a query string formatted set of driver options - * (i.e. tls=true&connectTimeoutMS=250 ) into a BSON dict of values. - * uri->raw is initially populated with the raw split of key/value pairs, - * then the keys are canonicalized and the values coerced - * to their appropriate type and stored in uri->options. - */ -bool -mongoc_uri_parse_options (mongoc_uri_t *uri, - const char *str, - bool from_dns, - bson_error_t *error) -{ - bson_t options; - const char *end_option; - char *option; - - bson_init (&options); - while ((option = scan_to_unichar (str, '&', "", &end_option))) { - if (!mongoc_uri_split_option (uri, &options, option, from_dns, error)) { - bson_free (option); - bson_destroy (&options); - return false; - } - bson_free (option); - str = end_option + 1; - } - - if (*str && !mongoc_uri_split_option (uri, &options, str, from_dns, error)) { - bson_destroy (&options); - return false; - } - - /* Walk both sides of this map to handle each ordering: - * deprecated first canonical later, and vice-versa. - * Then finalize parse by writing final values to uri->options. - */ - if (!mongoc_uri_options_validate_names (&uri->options, &options, error) || - !mongoc_uri_options_validate_names (&options, &uri->options, error) || - !mongoc_uri_apply_options (uri, &options, from_dns, error)) { - bson_destroy (&options); - return false; - } - - bson_destroy (&options); - return true; -} - - -static bool -mongoc_uri_finalize_tls (mongoc_uri_t *uri, bson_error_t *error) -{ - /* Initial DNS Seedlist Discovery Spec: "If mongodb+srv is used, a driver - * MUST implicitly also enable TLS." */ - if (uri->is_srv && !bson_has_field (&uri->options, MONGOC_URI_TLS)) { - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_TLS, true); - } - - /* tlsInsecure implies tlsAllowInvalidCertificates, tlsAllowInvalidHostnames, - * tlsDisableOCSPEndpointCheck, and tlsDisableCertificateRevocationCheck, so - * consider it an error to have both. The user might have the wrong idea. */ - if (bson_has_field (&uri->options, MONGOC_URI_TLSINSECURE) && - (bson_has_field (&uri->options, - MONGOC_URI_TLSALLOWINVALIDCERTIFICATES) || - bson_has_field (&uri->options, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES) || - bson_has_field (&uri->options, - MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK) || - bson_has_field (&uri->options, - MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK))) { - MONGOC_URI_ERROR (error, - "%s may not be specified with %s, %s, %s, or %s", - MONGOC_URI_TLSINSECURE, - MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, - MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, - MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK, - MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK); - return false; - } - - /* tlsAllowInvalidCertificates implies tlsDisableOCSPEndpointCheck and - * tlsDisableCertificateRevocationCheck, so consider it an error to have - * both. The user might have the wrong idea. */ - if (bson_has_field (&uri->options, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES) && - (bson_has_field (&uri->options, - MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK) || - bson_has_field (&uri->options, - MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK))) { - MONGOC_URI_ERROR (error, - "%s may not be specified with %s or %s", - MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, - MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK, - MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK); - return false; - } - - /* tlsDisableCertificateRevocationCheck implies tlsDisableOCSPEndpointCheck, - * so consider it an error to have both. The user might have the wrong idea. - */ - if (bson_has_field (&uri->options, - MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK) && - bson_has_field (&uri->options, MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK)) { - MONGOC_URI_ERROR (error, - "%s may not be specified with %s", - MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK, - MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK); - return false; - } - - return true; -} - - -static bool -mongoc_uri_finalize_auth (mongoc_uri_t *uri, bson_error_t *error) -{ - bson_iter_t iter; - const char *source = NULL; - const bool require_auth = uri->username != NULL; - - if (bson_iter_init_find_case ( - &iter, &uri->credentials, MONGOC_URI_AUTHSOURCE)) { - source = bson_iter_utf8 (&iter, NULL); - } - - if (mongoc_uri_get_auth_mechanism (uri)) { - /* authSource with GSSAPI or X509 should always be external */ - if (!strcasecmp (mongoc_uri_get_auth_mechanism (uri), "GSSAPI") || - !strcasecmp (mongoc_uri_get_auth_mechanism (uri), "MONGODB-X509")) { - if (source) { - if (strcasecmp (source, "$external")) { - MONGOC_URI_ERROR ( - error, - "%s", - "GSSAPI and X509 require \"$external\" authSource"); - return false; - } - } else { - bson_append_utf8 ( - &uri->credentials, MONGOC_URI_AUTHSOURCE, -1, "$external", -1); - } - } - /* MONGODB-X509 and MONGODB-AWS are the only mechanisms that don't require - * username */ - if (!(strcasecmp (mongoc_uri_get_auth_mechanism (uri), "MONGODB-X509") == - 0 || - strcasecmp (mongoc_uri_get_auth_mechanism (uri), "MONGODB-AWS") == - 0)) { - if (!mongoc_uri_get_username (uri) || - strcmp (mongoc_uri_get_username (uri), "") == 0) { - MONGOC_URI_ERROR (error, - "'%s' authentication mechanism requires username", - mongoc_uri_get_auth_mechanism (uri)); - return false; - } - } - /* MONGODB-X509 errors if a password is supplied. */ - if (strcasecmp (mongoc_uri_get_auth_mechanism (uri), "MONGODB-X509") == - 0) { - if (mongoc_uri_get_password (uri)) { - MONGOC_URI_ERROR ( - error, - "'%s' authentication mechanism does not accept a password", - mongoc_uri_get_auth_mechanism (uri)); - return false; - } - } - /* GSSAPI uses 'mongodb' as the default service name */ - if (strcasecmp (mongoc_uri_get_auth_mechanism (uri), "GSSAPI") == 0 && - !(bson_iter_init_find ( - &iter, &uri->credentials, MONGOC_URI_AUTHMECHANISMPROPERTIES) && - BSON_ITER_HOLDS_DOCUMENT (&iter) && - bson_iter_recurse (&iter, &iter) && - bson_iter_find_case (&iter, "SERVICE_NAME"))) { - bson_t tmp; - bson_t *props = NULL; - - props = mongoc_uri_get_mechanism_properties (uri, &tmp) - ? bson_copy (&tmp) - : bson_new (); - - BSON_APPEND_UTF8 (props, "SERVICE_NAME", "mongodb"); - mongoc_uri_set_mechanism_properties (uri, props); - - bson_destroy (props); - } - - } else if (require_auth) /* Default auth mechanism is used */ { - if (!mongoc_uri_get_username (uri) || - strcmp (mongoc_uri_get_username (uri), "") == 0) { - MONGOC_URI_ERROR ( - error, "%s", "Default authentication mechanism requires username"); - return false; - } - } - return true; -} - -static bool -mongoc_uri_finalize_directconnection (mongoc_uri_t *uri, bson_error_t *error) -{ - bool directconnection = false; - - directconnection = - mongoc_uri_get_option_as_bool (uri, MONGOC_URI_DIRECTCONNECTION, false); - if (!directconnection) { - return true; - } - - /* URI options spec: "The driver MUST report an error if the - * directConnection=true URI option is specified with an SRV URI, because - * the URI may resolve to multiple hosts. The driver MUST allow specifying - * directConnection=false URI option with an SRV URI." */ - if (uri->is_srv) { - MONGOC_URI_ERROR ( - error, "%s", "SRV URI not allowed with directConnection option"); - return false; - } - - /* URI options spec: "The driver MUST report an error if the - * directConnection=true URI option is specified with multiple seeds." */ - if (uri->hosts && uri->hosts->next) { - MONGOC_URI_ERROR ( - error, - "%s", - "Multiple seeds not allowed with directConnection option"); - return false; - } - - return true; -} - -static bool -mongoc_uri_parse_before_slash (mongoc_uri_t *uri, - const char *before_slash, - bson_error_t *error) -{ - char *userpass; - const char *hosts; - - userpass = scan_to_unichar (before_slash, '@', "", &hosts); - if (userpass) { - if (!mongoc_uri_parse_userpass (uri, userpass, error)) { - goto error; - } - - hosts++; /* advance past "@" */ - if (*hosts == '@') { - /* special case: "mongodb://alice@@localhost" */ - MONGOC_URI_ERROR ( - error, "Invalid username or password. %s", escape_instructions); - goto error; - } - } else { - hosts = before_slash; - } - - if (uri->is_srv) { - if (!mongoc_uri_parse_srv (uri, hosts, error)) { - goto error; - } - } else { - if (!mongoc_uri_parse_hosts (uri, hosts)) { - MONGOC_URI_ERROR (error, "%s", "Invalid host string in URI"); - goto error; - } - } - - bson_free (userpass); - return true; - -error: - bson_free (userpass); - return false; -} - - -static bool -mongoc_uri_parse (mongoc_uri_t *uri, const char *str, bson_error_t *error) -{ - BSON_ASSERT_PARAM (str); - - char *before_slash = NULL; - const char *tmp; - - if (!bson_utf8_validate (str, strlen (str), false /* allow_null */)) { - MONGOC_URI_ERROR (error, "%s", "Invalid UTF-8 in URI"); - goto error; - } - - if (!mongoc_uri_parse_scheme (uri, str, &str)) { - MONGOC_URI_ERROR ( - error, - "%s", - "Invalid URI Schema, expecting 'mongodb://' or 'mongodb+srv://'"); - goto error; - } - - before_slash = scan_to_unichar (str, '/', "", &tmp); - if (!before_slash) { - before_slash = bson_strdup (str); - str += strlen (before_slash); - } else { - str = tmp; - } - - if (!mongoc_uri_parse_before_slash (uri, before_slash, error)) { - goto error; - } - - BSON_ASSERT (str); - - if (*str) { - if (*str == '/') { - str++; - if (*str) { - if (!mongoc_uri_parse_database (uri, str, &str)) { - MONGOC_URI_ERROR (error, "%s", "Invalid database name in URI"); - goto error; - } - } - - if (*str == '?') { - str++; - if (*str) { - if (!mongoc_uri_parse_options ( - uri, str, false /* from DNS */, error)) { - goto error; - } - } - } - } else { - MONGOC_URI_ERROR (error, "%s", "Expected end of hostname delimiter"); - goto error; - } - } - - if (!mongoc_uri_finalize (uri, error)) { - goto error; - } - - bson_free (before_slash); - return true; - -error: - bson_free (before_slash); - return false; -} - - -const mongoc_host_list_t * -mongoc_uri_get_hosts (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - return uri->hosts; -} - - -const char * -mongoc_uri_get_replica_set (const mongoc_uri_t *uri) -{ - bson_iter_t iter; - - BSON_ASSERT (uri); - - if (bson_iter_init_find_case (&iter, &uri->options, MONGOC_URI_REPLICASET) && - BSON_ITER_HOLDS_UTF8 (&iter)) { - return bson_iter_utf8 (&iter, NULL); - } - - return NULL; -} - - -const bson_t * -mongoc_uri_get_credentials (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - return &uri->credentials; -} - - -const char * -mongoc_uri_get_auth_mechanism (const mongoc_uri_t *uri) -{ - bson_iter_t iter; - - BSON_ASSERT (uri); - - if (bson_iter_init_find_case ( - &iter, &uri->credentials, MONGOC_URI_AUTHMECHANISM) && - BSON_ITER_HOLDS_UTF8 (&iter)) { - return bson_iter_utf8 (&iter, NULL); - } - - return NULL; -} - - -bool -mongoc_uri_set_auth_mechanism (mongoc_uri_t *uri, const char *value) -{ - size_t len; - - BSON_ASSERT (value); - - len = strlen (value); - - if (!bson_utf8_validate (value, len, false)) { - return false; - } - - mongoc_uri_bson_append_or_replace_key ( - &uri->credentials, MONGOC_URI_AUTHMECHANISM, value); - - return true; -} - - -bool -mongoc_uri_get_mechanism_properties (const mongoc_uri_t *uri, - bson_t *properties /* OUT */) -{ - bson_iter_t iter; - - BSON_ASSERT (uri); - BSON_ASSERT (properties); - - if (bson_iter_init_find_case ( - &iter, &uri->credentials, MONGOC_URI_AUTHMECHANISMPROPERTIES) && - BSON_ITER_HOLDS_DOCUMENT (&iter)) { - uint32_t len = 0; - const uint8_t *data = NULL; - - bson_iter_document (&iter, &len, &data); - BSON_ASSERT (bson_init_static (properties, data, len)); - - return true; - } - - return false; -} - - -bool -mongoc_uri_set_mechanism_properties (mongoc_uri_t *uri, - const bson_t *properties) -{ - BSON_ASSERT (uri); - BSON_ASSERT (properties); - - bson_t tmp = BSON_INITIALIZER; - bsonBuildAppend ( - tmp, - // Copy the existing credentials, dropping the existing properties if - // present - insert (uri->credentials, not(key (MONGOC_URI_AUTHMECHANISMPROPERTIES))), - // Append the new properties - kv (MONGOC_URI_AUTHMECHANISMPROPERTIES, bson (*properties))); - bson_reinit (&uri->credentials); - bsonBuildAppend (uri->credentials, insert (tmp, true)); - bson_destroy (&tmp); - return bsonBuildError == NULL; -} - - -static bool -_mongoc_uri_assign_read_prefs_mode (mongoc_uri_t *uri, bson_error_t *error) -{ - BSON_ASSERT (uri); - - mongoc_read_mode_t mode = 0; - const char *pref = NULL; - bsonParse ( - uri->options, - find ( - // Find the 'readPreference' string - iKeyWithType (MONGOC_URI_READPREFERENCE, utf8), - case ( // Switch on the string content: - when (iStrEqual ("primary"), do(mode = MONGOC_READ_PRIMARY)), - when (iStrEqual ("primaryPreferred"), - do(mode = MONGOC_READ_PRIMARY_PREFERRED)), - when (iStrEqual ("secondary"), do(mode = MONGOC_READ_SECONDARY)), - when (iStrEqual ("secondaryPreferred"), - do(mode = MONGOC_READ_SECONDARY_PREFERRED)), - when (iStrEqual ("nearest"), do(mode = MONGOC_READ_NEAREST)), - else(do({ - pref = bsonAs (cstr); - bsonParseError = "Unsupported readPreference value"; - }))))); - - if (bsonParseError) { - const char *prefix = "Error while assigning URI read preference"; - if (pref) { - MONGOC_URI_ERROR ( - error, "%s: %s [readPreference=%s]", prefix, bsonParseError, pref); - } else { - MONGOC_URI_ERROR (error, "%s: %s", prefix, bsonParseError); - } - return false; - } - - if (mode != 0) { - mongoc_read_prefs_set_mode (uri->read_prefs, mode); - } - return true; -} - - -static bool -_mongoc_uri_build_write_concern (mongoc_uri_t *uri, bson_error_t *error) -{ - mongoc_write_concern_t *write_concern; - int64_t wtimeoutms; - - BSON_ASSERT (uri); - - write_concern = mongoc_write_concern_new (); - uri->write_concern = write_concern; - - bsonParse ( - uri->options, - find (iKeyWithType (MONGOC_URI_SAFE, bool), - do(mongoc_write_concern_set_w ( - write_concern, - bsonAs (bool) ? 1 : MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED)))); - - if (bsonParseError) { - MONGOC_URI_ERROR ( - error, "Error while parsing 'safe' URI option: %s", bsonParseError); - return false; - } - - wtimeoutms = mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 0); - if (wtimeoutms < 0) { - MONGOC_URI_ERROR ( - error, "Unsupported wtimeoutMS value [w=%" PRId64 "]", wtimeoutms); - return false; - } else if (wtimeoutms > 0) { - mongoc_write_concern_set_wtimeout_int64 (write_concern, wtimeoutms); - } - - bsonParse (uri->options, - find (iKeyWithType (MONGOC_URI_JOURNAL, bool), - do(mongoc_write_concern_set_journal (write_concern, - bsonAs (bool))))); - if (bsonParseError) { - MONGOC_URI_ERROR ( - error, "Error while parsing 'journal' URI option: %s", bsonParseError); - return false; - } - - int w_int = INT_MAX; - const char *w_str = NULL; - bsonParse ( - uri->options, - find ( - iKey ("w"), // - storeInt32 (w_int), - storeStrRef (w_str), - case ( - // Special W options: - when ( - anyOf (eq (int32, MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED), - eq (int32, MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED)), - // These conflict with journalling: - if (eval (mongoc_write_concern_get_journal (write_concern)), - then (error ("Journal conflicts with w value"))), - do(mongoc_write_concern_set_w (write_concern, bsonAs (int32)))), - // Other positive 'w' value: - when ( - allOf (type (int32), eval (bsonAs (int32) > 0)), - do(mongoc_write_concern_set_w (write_concern, bsonAs (int32)))), - // Special "majority" string: - when (iStrEqual ("majority"), - do(mongoc_write_concern_set_w ( - write_concern, MONGOC_WRITE_CONCERN_W_MAJORITY))), - // Other string: - when (type (utf8), - do(mongoc_write_concern_set_wtag (write_concern, - bsonAs (cstr)))), - // Invalid value: - else(error ("Unsupported w value"))))); - - if (bsonParseError) { - const char *const prefix = "Error while parsing the 'w' URI option"; - if (w_str) { - MONGOC_URI_ERROR ( - error, "%s: %s [w=%s]", prefix, bsonParseError, w_str); - } else if (w_int != INT_MAX) { - MONGOC_URI_ERROR ( - error, "%s: %s [w=%d]", prefix, bsonParseError, w_int); - } else { - MONGOC_URI_ERROR (error, "%s: %s", prefix, bsonParseError); - } - return false; - } - return true; -} - -/* can't use mongoc_uri_get_option_as_int32, it treats 0 specially */ -static int32_t -_mongoc_uri_get_max_staleness_option (const mongoc_uri_t *uri) -{ - const bson_t *options; - bson_iter_t iter; - int32_t retval = MONGOC_NO_MAX_STALENESS; - - if ((options = mongoc_uri_get_options (uri)) && - bson_iter_init_find_case ( - &iter, options, MONGOC_URI_MAXSTALENESSSECONDS) && - BSON_ITER_HOLDS_INT32 (&iter)) { - retval = bson_iter_int32 (&iter); - if (retval == 0) { - MONGOC_WARNING ( - "Unsupported value for \"" MONGOC_URI_MAXSTALENESSSECONDS - "\": \"%d\"", - retval); - retval = -1; - } else if (retval < 0 && retval != -1) { - MONGOC_WARNING ( - "Unsupported value for \"" MONGOC_URI_MAXSTALENESSSECONDS - "\": \"%d\"", - retval); - retval = MONGOC_NO_MAX_STALENESS; - } - } - - return retval; -} - -mongoc_uri_t * -mongoc_uri_new_with_error (const char *uri_string, bson_error_t *error) -{ - mongoc_uri_t *uri; - int32_t max_staleness_seconds; - - uri = BSON_ALIGNED_ALLOC0 (mongoc_uri_t); - bson_init (&uri->raw); - bson_init (&uri->options); - bson_init (&uri->credentials); - bson_init (&uri->compressors); - - /* Initialize read_prefs, since parsing may add to it */ - uri->read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - /* Initialize empty read_concern */ - uri->read_concern = mongoc_read_concern_new (); - - if (!uri_string) { - uri_string = "mongodb://127.0.0.1/"; - } - - if (!mongoc_uri_parse (uri, uri_string, error)) { - mongoc_uri_destroy (uri); - return NULL; - } - - uri->str = bson_strdup (uri_string); - - if (!_mongoc_uri_assign_read_prefs_mode (uri, error)) { - mongoc_uri_destroy (uri); - return NULL; - } - max_staleness_seconds = _mongoc_uri_get_max_staleness_option (uri); - mongoc_read_prefs_set_max_staleness_seconds (uri->read_prefs, - max_staleness_seconds); - - if (!mongoc_read_prefs_is_valid (uri->read_prefs)) { - mongoc_uri_destroy (uri); - MONGOC_URI_ERROR (error, "%s", "Invalid readPreferences"); - return NULL; - } - - if (!_mongoc_uri_build_write_concern (uri, error)) { - mongoc_uri_destroy (uri); - return NULL; - } - - if (!mongoc_write_concern_is_valid (uri->write_concern)) { - mongoc_uri_destroy (uri); - MONGOC_URI_ERROR (error, "%s", "Invalid writeConcern"); - return NULL; - } - - return uri; -} - -mongoc_uri_t * -mongoc_uri_new (const char *uri_string) -{ - bson_error_t error = {0}; - mongoc_uri_t *uri; - - uri = mongoc_uri_new_with_error (uri_string, &error); - if (error.domain) { - MONGOC_WARNING ("Error parsing URI: '%s'", error.message); - } - - return uri; -} - - -mongoc_uri_t * -mongoc_uri_new_for_host_port (const char *hostname, uint16_t port) -{ - mongoc_uri_t *uri; - char *str; - - BSON_ASSERT (hostname); - BSON_ASSERT (port); - - str = bson_strdup_printf ("mongodb://%s:%hu/", hostname, port); - uri = mongoc_uri_new (str); - bson_free (str); - - return uri; -} - - -const char * -mongoc_uri_get_username (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - - return uri->username; -} - -bool -mongoc_uri_set_username (mongoc_uri_t *uri, const char *username) -{ - size_t len; - - BSON_ASSERT (username); - - len = strlen (username); - - if (!bson_utf8_validate (username, len, false)) { - return false; - } - - if (uri->username) { - bson_free (uri->username); - } - - uri->username = bson_strdup (username); - return true; -} - - -const char * -mongoc_uri_get_password (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - - return uri->password; -} - -bool -mongoc_uri_set_password (mongoc_uri_t *uri, const char *password) -{ - size_t len; - - BSON_ASSERT (password); - - len = strlen (password); - - if (!bson_utf8_validate (password, len, false)) { - return false; - } - - if (uri->password) { - bson_free (uri->password); - } - - uri->password = bson_strdup (password); - return true; -} - - -const char * -mongoc_uri_get_database (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - return uri->database; -} - -bool -mongoc_uri_set_database (mongoc_uri_t *uri, const char *database) -{ - size_t len; - - BSON_ASSERT (database); - - len = strlen (database); - - if (!bson_utf8_validate (database, len, false)) { - return false; - } - - if (uri->database) { - bson_free (uri->database); - } - - uri->database = bson_strdup (database); - return true; -} - - -const char * -mongoc_uri_get_auth_source (const mongoc_uri_t *uri) -{ - bson_iter_t iter; - const char *mechanism; - - BSON_ASSERT (uri); - - if (bson_iter_init_find_case ( - &iter, &uri->credentials, MONGOC_URI_AUTHSOURCE)) { - return bson_iter_utf8 (&iter, NULL); - } - - /* Auth spec: - * "For GSSAPI and MONGODB-X509 authMechanisms the authSource defaults to - * $external. For PLAIN the authSource defaults to the database name if - * supplied on the connection string or $external. For MONGODB-CR, - * SCRAM-SHA-1 and SCRAM-SHA-256 authMechanisms, the authSource defaults to - * the database name if supplied on the connection string or admin." - */ - mechanism = mongoc_uri_get_auth_mechanism (uri); - if (mechanism) { - if (!strcasecmp (mechanism, "GSSAPI") || - !strcasecmp (mechanism, "MONGODB-X509")) { - return "$external"; - } - if (!strcasecmp (mechanism, "PLAIN")) { - return uri->database ? uri->database : "$external"; - } - } - - return uri->database ? uri->database : "admin"; -} - - -bool -mongoc_uri_set_auth_source (mongoc_uri_t *uri, const char *value) -{ - size_t len; - - BSON_ASSERT (value); - - len = strlen (value); - - if (!bson_utf8_validate (value, len, false)) { - return false; - } - - mongoc_uri_bson_append_or_replace_key ( - &uri->credentials, MONGOC_URI_AUTHSOURCE, value); - - return true; -} - - -const char * -mongoc_uri_get_appname (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - - return mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_APPNAME, NULL); -} - - -bool -mongoc_uri_set_appname (mongoc_uri_t *uri, const char *value) -{ - BSON_ASSERT (value); - - if (!bson_utf8_validate (value, strlen (value), false)) { - return false; - } - - if (!_mongoc_handshake_appname_is_valid (value)) { - return false; - } - - mongoc_uri_bson_append_or_replace_key ( - &uri->options, MONGOC_URI_APPNAME, value); - - return true; -} - -bool -mongoc_uri_set_compressors (mongoc_uri_t *uri, const char *value) -{ - const char *end_compressor; - char *entry; - - bson_destroy (&uri->compressors); - bson_init (&uri->compressors); - - if (value && !bson_utf8_validate (value, strlen (value), false)) { - return false; - } - while ((entry = scan_to_unichar (value, ',', "", &end_compressor))) { - if (mongoc_compressor_supported (entry)) { - mongoc_uri_bson_append_or_replace_key ( - &uri->compressors, entry, "yes"); - } else { - MONGOC_WARNING ("Unsupported compressor: '%s'", entry); - } - value = end_compressor + 1; - bson_free (entry); - } - if (value) { - if (mongoc_compressor_supported (value)) { - mongoc_uri_bson_append_or_replace_key ( - &uri->compressors, value, "yes"); - } else { - MONGOC_WARNING ("Unsupported compressor: '%s'", value); - } - } - - return true; -} - -const bson_t * -mongoc_uri_get_compressors (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - return &uri->compressors; -} - - -/* can't use mongoc_uri_get_option_as_int32, it treats 0 specially */ -int32_t -mongoc_uri_get_local_threshold_option (const mongoc_uri_t *uri) -{ - const bson_t *options; - bson_iter_t iter; - int32_t retval = MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS; - - if ((options = mongoc_uri_get_options (uri)) && - bson_iter_init_find_case (&iter, options, "localthresholdms") && - BSON_ITER_HOLDS_INT32 (&iter)) { - retval = bson_iter_int32 (&iter); - - if (retval < 0) { - MONGOC_WARNING ("Invalid localThresholdMS: %d", retval); - retval = MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS; - } - } - - return retval; -} - - -const char * -mongoc_uri_get_srv_hostname (const mongoc_uri_t *uri) -{ - if (uri->is_srv) { - return uri->srv; - } - - return NULL; -} - - -const char * -mongoc_uri_get_service (const mongoc_uri_t *uri) -{ - return mongoc_uri_get_srv_hostname (uri); -} - - -/* Initial DNS Seedlist Discovery Spec: `srvServiceName` requires a string value - * and defaults to "mongodb". */ -static const char *const mongoc_default_srv_service_name = "mongodb"; - - -const char * -mongoc_uri_get_srv_service_name (const mongoc_uri_t *uri) -{ - bson_iter_t iter; - - BSON_ASSERT_PARAM (uri); - - if (bson_iter_init_find_case ( - &iter, &uri->options, MONGOC_URI_SRVSERVICENAME)) { - BSON_ASSERT (BSON_ITER_HOLDS_UTF8 (&iter)); - return bson_iter_utf8 (&iter, NULL); - } - - return mongoc_default_srv_service_name; -} - - -const bson_t * -mongoc_uri_get_options (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - return &uri->options; -} - - -void -mongoc_uri_destroy (mongoc_uri_t *uri) -{ - if (uri) { - _mongoc_host_list_destroy_all (uri->hosts); - bson_free (uri->str); - bson_free (uri->database); - bson_free (uri->username); - bson_destroy (&uri->raw); - bson_destroy (&uri->options); - bson_destroy (&uri->credentials); - bson_destroy (&uri->compressors); - mongoc_read_prefs_destroy (uri->read_prefs); - mongoc_read_concern_destroy (uri->read_concern); - mongoc_write_concern_destroy (uri->write_concern); - - if (uri->password) { - bson_zero_free (uri->password, strlen (uri->password)); - } - - bson_free (uri); - } -} - - -mongoc_uri_t * -mongoc_uri_copy (const mongoc_uri_t *uri) -{ - mongoc_uri_t *copy; - mongoc_host_list_t *iter; - bson_error_t error; - - BSON_ASSERT (uri); - - copy = BSON_ALIGNED_ALLOC0 (mongoc_uri_t); - - copy->str = bson_strdup (uri->str); - copy->is_srv = uri->is_srv; - bson_strncpy (copy->srv, uri->srv, sizeof uri->srv); - copy->username = bson_strdup (uri->username); - copy->password = bson_strdup (uri->password); - copy->database = bson_strdup (uri->database); - - copy->read_prefs = mongoc_read_prefs_copy (uri->read_prefs); - copy->read_concern = mongoc_read_concern_copy (uri->read_concern); - copy->write_concern = mongoc_write_concern_copy (uri->write_concern); - - LL_FOREACH (uri->hosts, iter) - { - if (!mongoc_uri_upsert_host (copy, iter->host, iter->port, &error)) { - MONGOC_ERROR ("%s", error.message); - mongoc_uri_destroy (copy); - return NULL; - } - } - - bson_copy_to (&uri->raw, ©->raw); - bson_copy_to (&uri->options, ©->options); - bson_copy_to (&uri->credentials, ©->credentials); - bson_copy_to (&uri->compressors, ©->compressors); - - return copy; -} - - -const char * -mongoc_uri_get_string (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - return uri->str; -} - - -const bson_t * -mongoc_uri_get_read_prefs (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - return mongoc_read_prefs_get_tags (uri->read_prefs); -} - -char * -mongoc_uri_unescape (const char *escaped_string) -{ - bson_unichar_t c; - bson_string_t *str; - unsigned int hex = 0; - const char *ptr; - const char *end; - size_t len; - bool unescape_occurred = false; - - BSON_ASSERT (escaped_string); - - len = strlen (escaped_string); - - /* - * Double check that this is a UTF-8 valid string. Bail out if necessary. - */ - if (!bson_utf8_validate (escaped_string, len, false)) { - MONGOC_WARNING ("%s(): escaped_string contains invalid UTF-8", BSON_FUNC); - return NULL; - } - - ptr = escaped_string; - end = ptr + len; - str = bson_string_new (NULL); - - for (; *ptr; ptr = bson_utf8_next_char (ptr)) { - c = bson_utf8_get_char (ptr); - switch (c) { - case '%': - if (((end - ptr) < 2) || !isxdigit (ptr[1]) || !isxdigit (ptr[2]) || -#ifdef _MSC_VER - (1 != sscanf_s (&ptr[1], "%02x", &hex)) -#else - (1 != sscanf (&ptr[1], "%02x", &hex)) -#endif - || 0 == hex) { - bson_string_free (str, true); - MONGOC_WARNING ("Invalid %% escape sequence"); - return NULL; - } - bson_string_append_c (str, hex); - ptr += 2; - unescape_occurred = true; - break; - default: - bson_string_append_unichar (str, c); - break; - } - } - - /* Check that after unescaping, it is still valid UTF-8 */ - if (unescape_occurred && !bson_utf8_validate (str->str, str->len, false)) { - MONGOC_WARNING ( - "Invalid %% escape sequence: unescaped string contains invalid UTF-8"); - bson_string_free (str, true); - return NULL; - } - - return bson_string_free (str, false); -} - - -const mongoc_read_prefs_t * -mongoc_uri_get_read_prefs_t (const mongoc_uri_t *uri) /* IN */ -{ - BSON_ASSERT (uri); - - return uri->read_prefs; -} - - -void -mongoc_uri_set_read_prefs_t (mongoc_uri_t *uri, - const mongoc_read_prefs_t *prefs) -{ - BSON_ASSERT (uri); - BSON_ASSERT (prefs); - - mongoc_read_prefs_destroy (uri->read_prefs); - uri->read_prefs = mongoc_read_prefs_copy (prefs); -} - - -const mongoc_read_concern_t * -mongoc_uri_get_read_concern (const mongoc_uri_t *uri) /* IN */ -{ - BSON_ASSERT (uri); - - return uri->read_concern; -} - - -void -mongoc_uri_set_read_concern (mongoc_uri_t *uri, const mongoc_read_concern_t *rc) -{ - BSON_ASSERT (uri); - BSON_ASSERT (rc); - - mongoc_read_concern_destroy (uri->read_concern); - uri->read_concern = mongoc_read_concern_copy (rc); -} - - -const mongoc_write_concern_t * -mongoc_uri_get_write_concern (const mongoc_uri_t *uri) /* IN */ -{ - BSON_ASSERT (uri); - - return uri->write_concern; -} - - -void -mongoc_uri_set_write_concern (mongoc_uri_t *uri, - const mongoc_write_concern_t *wc) -{ - BSON_ASSERT (uri); - BSON_ASSERT (wc); - - mongoc_write_concern_destroy (uri->write_concern); - uri->write_concern = mongoc_write_concern_copy (wc); -} - - -bool -mongoc_uri_get_tls (const mongoc_uri_t *uri) /* IN */ -{ - bson_iter_t iter; - - BSON_ASSERT (uri); - - if (bson_iter_init_find_case (&iter, &uri->options, MONGOC_URI_TLS) && - BSON_ITER_HOLDS_BOOL (&iter)) { - return bson_iter_bool (&iter); - } - - if (bson_iter_init_find_case ( - &iter, &uri->options, MONGOC_URI_TLSCERTIFICATEKEYFILE) || - bson_iter_init_find_case (&iter, &uri->options, MONGOC_URI_TLSCAFILE) || - bson_iter_init_find_case ( - &iter, &uri->options, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES) || - bson_iter_init_find_case ( - &iter, &uri->options, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES) || - bson_iter_init_find_case ( - &iter, &uri->options, MONGOC_URI_TLSINSECURE) || - bson_iter_init_find_case ( - &iter, &uri->options, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD) || - bson_iter_init_find_case ( - &iter, &uri->options, MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK) || - bson_iter_init_find_case ( - &iter, - &uri->options, - MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK)) { - return true; - } - - return false; -} - -bool -mongoc_uri_get_ssl (const mongoc_uri_t *uri) /* IN */ -{ - return mongoc_uri_get_tls (uri); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_uri_get_option_as_int32 -- - * - * Checks if the URI 'option' is set and of correct type (int32). - * The special value '0' is considered as "unset". - * This is so users can provide - * sprintf("mongodb://localhost/?option=%d", myvalue) style connection - * strings, and still apply default values. - * - * If not set, or set to invalid type, 'fallback' is returned. - * - * NOTE: 'option' is case*in*sensitive. - * - * Returns: - * The value of 'option' if available as int32 (and not 0), or - * 'fallback'. - * - *-------------------------------------------------------------------------- - */ - -int32_t -mongoc_uri_get_option_as_int32 (const mongoc_uri_t *uri, - const char *option_orig, - int32_t fallback) -{ - const char *option; - const bson_t *options; - bson_iter_t iter; - int64_t retval = 0; - - option = mongoc_uri_canonicalize_option (option_orig); - - /* BC layer to allow retrieving 32-bit values stored in 64-bit options */ - if (mongoc_uri_option_is_int64 (option_orig)) { - retval = mongoc_uri_get_option_as_int64 (uri, option_orig, 0); - - if (retval > INT32_MAX || retval < INT32_MIN) { - MONGOC_WARNING ("Cannot read 64-bit value for \"%s\": %" PRId64, - option_orig, - retval); - - retval = 0; - } - } else if ((options = mongoc_uri_get_options (uri)) && - bson_iter_init_find_case (&iter, options, option) && - BSON_ITER_HOLDS_INT32 (&iter)) { - retval = bson_iter_int32 (&iter); - } - - if (!retval) { - retval = fallback; - } - - return (int32_t) retval; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_uri_set_option_as_int32 -- - * - * Sets a URI option 'after the fact'. Allows users to set individual - * URI options without passing them as a connection string. - * - * Only allows a set of known options to be set. - * @see mongoc_uri_option_is_int32 (). - * - * Does in-place-update of the option BSON if 'option' is already set. - * Appends the option to the end otherwise. - * - * NOTE: If 'option' is already set, and is of invalid type, this - * function will return false. - * - * NOTE: 'option' is case*in*sensitive. - * - * Returns: - * true on successfully setting the option, false on failure. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_uri_set_option_as_int32 (mongoc_uri_t *uri, - const char *option_orig, - int32_t value) -{ - const char *option; - bson_error_t error; - bool r; - - if (mongoc_uri_option_is_int64 (option_orig)) { - return mongoc_uri_set_option_as_int64 (uri, option_orig, value); - } - - option = mongoc_uri_canonicalize_option (option_orig); - - if (!mongoc_uri_option_is_int32 (option)) { - MONGOC_WARNING ( - "Unsupported value for \"%s\": %d, \"%s\" is not an int32 option", - option_orig, - value, - option); - return false; - } - - r = _mongoc_uri_set_option_as_int32_with_error (uri, option, value, &error); - if (!r) { - MONGOC_WARNING ("%s", error.message); - } - - return r; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_uri_set_option_as_int32_with_error -- - * - * Same as mongoc_uri_set_option_as_int32, with error reporting. - * - * Precondition: - * mongoc_uri_option_is_int32(option) must be true. - * - * Returns: - * true on successfully setting the option, false on failure. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_uri_set_option_as_int32_with_error (mongoc_uri_t *uri, - const char *option_orig, - int32_t value, - bson_error_t *error) -{ - const char *option; - const bson_t *options; - bson_iter_t iter; - char *option_lowercase = NULL; - - option = mongoc_uri_canonicalize_option (option_orig); - /* Server Discovery and Monitoring Spec: "the driver MUST NOT permit users - * to configure it less than minHeartbeatFrequencyMS (500ms)." */ - if (!bson_strcasecmp (option, MONGOC_URI_HEARTBEATFREQUENCYMS) && - value < MONGOC_TOPOLOGY_MIN_HEARTBEAT_FREQUENCY_MS) { - MONGOC_URI_ERROR (error, - "Invalid \"%s\" of %d: must be at least %d", - option_orig, - value, - MONGOC_TOPOLOGY_MIN_HEARTBEAT_FREQUENCY_MS); - return false; - } - - /* zlib levels are from -1 (default) through 9 (best compression) */ - if (!bson_strcasecmp (option, MONGOC_URI_ZLIBCOMPRESSIONLEVEL) && - (value < -1 || value > 9)) { - MONGOC_URI_ERROR (error, - "Invalid \"%s\" of %d: must be between -1 and 9", - option_orig, - value); - return false; - } - - if ((options = mongoc_uri_get_options (uri)) && - bson_iter_init_find_case (&iter, options, option)) { - if (BSON_ITER_HOLDS_INT32 (&iter)) { - bson_iter_overwrite_int32 (&iter, value); - return true; - } else { - MONGOC_URI_ERROR (error, - "Cannot set URI option \"%s\" to %d, it already has " - "a non-32-bit integer value", - option, - value); - return false; - } - } - option_lowercase = lowercase_str_new (option); - if (!bson_append_int32 (&uri->options, option_lowercase, -1, value)) { - bson_free (option_lowercase); - MONGOC_URI_ERROR ( - error, "Failed to set URI option \"%s\" to %d", option_orig, value); - - return false; - } - - bson_free (option_lowercase); - return true; -} - - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_uri_set_option_as_int32 -- - * - * Same as mongoc_uri_set_option_as_int32, except the option is not - * validated against valid int32 options - * - * Returns: - * true on successfully setting the option, false on failure. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_uri_set_option_as_int32 (mongoc_uri_t *uri, - const char *option_orig, - int32_t value) -{ - const char *option; - const bson_t *options; - bson_iter_t iter; - char *option_lowercase = NULL; - - option = mongoc_uri_canonicalize_option (option_orig); - if ((options = mongoc_uri_get_options (uri)) && - bson_iter_init_find_case (&iter, options, option)) { - if (BSON_ITER_HOLDS_INT32 (&iter)) { - bson_iter_overwrite_int32 (&iter, value); - return true; - } else { - return false; - } - } - - option_lowercase = lowercase_str_new (option); - bson_append_int32 (&uri->options, option_lowercase, -1, value); - bson_free (option_lowercase); - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_uri_get_option_as_int64 -- - * - * Checks if the URI 'option' is set and of correct type (int32 or - * int64). - * The special value '0' is considered as "unset". - * This is so users can provide - * sprintf("mongodb://localhost/?option=%" PRId64, myvalue) style - * connection strings, and still apply default values. - * - * If not set, or set to invalid type, 'fallback' is returned. - * - * NOTE: 'option' is case*in*sensitive. - * - * Returns: - * The value of 'option' if available as int64 or int32 (and not 0), or - * 'fallback'. - * - *-------------------------------------------------------------------------- - */ - -int64_t -mongoc_uri_get_option_as_int64 (const mongoc_uri_t *uri, - const char *option_orig, - int64_t fallback) -{ - const char *option; - const bson_t *options; - bson_iter_t iter; - int64_t retval = fallback; - - option = mongoc_uri_canonicalize_option (option_orig); - if ((options = mongoc_uri_get_options (uri)) && - bson_iter_init_find_case (&iter, options, option)) { - if (BSON_ITER_HOLDS_INT (&iter)) { - if (!(retval = bson_iter_as_int64 (&iter))) { - retval = fallback; - } - } - } - - return retval; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_uri_set_option_as_int64 -- - * - * Sets a URI option 'after the fact'. Allows users to set individual - * URI options without passing them as a connection string. - * - * Only allows a set of known options to be set. - * @see mongoc_uri_option_is_int64 (). - * - * Does in-place-update of the option BSON if 'option' is already set. - * Appends the option to the end otherwise. - * - * NOTE: If 'option' is already set, and is of invalid type, this - * function will return false. - * - * NOTE: 'option' is case*in*sensitive. - * - * Returns: - * true on successfully setting the option, false on failure. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_uri_set_option_as_int64 (mongoc_uri_t *uri, - const char *option_orig, - int64_t value) -{ - const char *option; - bson_error_t error; - bool r; - - option = mongoc_uri_canonicalize_option (option_orig); - if (!mongoc_uri_option_is_int64 (option)) { - if (mongoc_uri_option_is_int32 (option_orig)) { - if (value >= INT32_MIN && value <= INT32_MAX) { - MONGOC_WARNING ( - "Setting value for 32-bit option \"%s\" through 64-bit method", - option_orig); - - return mongoc_uri_set_option_as_int32 ( - uri, option_orig, (int32_t) value); - } - - MONGOC_WARNING ("Unsupported value for \"%s\": %" PRId64 - ", \"%s\" is not an int64 option", - option_orig, - value, - option); - return false; - } - } - - r = _mongoc_uri_set_option_as_int64_with_error (uri, option, value, &error); - if (!r) { - MONGOC_WARNING ("%s", error.message); - } - - return r; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_uri_set_option_as_int64_with_error -- - * - * Same as mongoc_uri_set_option_as_int64, with error reporting. - * - * Precondition: - * mongoc_uri_option_is_int64(option) must be true. - * - * Returns: - * true on successfully setting the option, false on failure. - * - *-------------------------------------------------------------------------- - */ - -static bool -_mongoc_uri_set_option_as_int64_with_error (mongoc_uri_t *uri, - const char *option_orig, - int64_t value, - bson_error_t *error) -{ - const char *option; - const bson_t *options; - bson_iter_t iter; - char *option_lowercase = NULL; - - option = mongoc_uri_canonicalize_option (option_orig); - - if ((options = mongoc_uri_get_options (uri)) && - bson_iter_init_find_case (&iter, options, option)) { - if (BSON_ITER_HOLDS_INT64 (&iter)) { - bson_iter_overwrite_int64 (&iter, value); - return true; - } else { - MONGOC_URI_ERROR (error, - "Cannot set URI option \"%s\" to %" PRId64 - ", it already has " - "a non-64-bit integer value", - option, - value); - return false; - } - } - - option_lowercase = lowercase_str_new (option); - if (!bson_append_int64 (&uri->options, option_lowercase, -1, value)) { - bson_free (option_lowercase); - MONGOC_URI_ERROR (error, - "Failed to set URI option \"%s\" to %" PRId64, - option_orig, - value); - - return false; - } - bson_free (option_lowercase); - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_uri_get_option_as_bool -- - * - * Checks if the URI 'option' is set and of correct type (bool). - * - * If not set, or set to invalid type, 'fallback' is returned. - * - * NOTE: 'option' is case*in*sensitive. - * - * Returns: - * The value of 'option' if available as bool, or 'fallback'. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_uri_get_option_as_bool (const mongoc_uri_t *uri, - const char *option_orig, - bool fallback) -{ - const char *option; - const bson_t *options; - bson_iter_t iter; - - option = mongoc_uri_canonicalize_option (option_orig); - if ((options = mongoc_uri_get_options (uri)) && - bson_iter_init_find_case (&iter, options, option) && - BSON_ITER_HOLDS_BOOL (&iter)) { - return bson_iter_bool (&iter); - } - - return fallback; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_uri_set_option_as_bool -- - * - * Sets a URI option 'after the fact'. Allows users to set individual - * URI options without passing them as a connection string. - * - * Only allows a set of known options to be set. - * @see mongoc_uri_option_is_bool (). - * - * Does in-place-update of the option BSON if 'option' is already set. - * Appends the option to the end otherwise. - * - * NOTE: If 'option' is already set, and is of invalid type, this - * function will return false. - * - * NOTE: 'option' is case*in*sensitive. - * - * Returns: - * true on successfully setting the option, false on failure. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_uri_set_option_as_bool (mongoc_uri_t *uri, - const char *option_orig, - bool value) -{ - const char *option; - char *option_lowercase; - const bson_t *options; - bson_iter_t iter; - - option = mongoc_uri_canonicalize_option (option_orig); - BSON_ASSERT (option); - - if (!mongoc_uri_option_is_bool (option)) { - return false; - } - - if ((options = mongoc_uri_get_options (uri)) && - bson_iter_init_find_case (&iter, options, option)) { - if (BSON_ITER_HOLDS_BOOL (&iter)) { - bson_iter_overwrite_bool (&iter, value); - return true; - } else { - return false; - } - } - option_lowercase = lowercase_str_new (option); - bson_append_bool (&uri->options, option_lowercase, -1, value); - bson_free (option_lowercase); - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_uri_get_option_as_utf8 -- - * - * Checks if the URI 'option' is set and of correct type (utf8). - * - * If not set, or set to invalid type, 'fallback' is returned. - * - * NOTE: 'option' is case*in*sensitive. - * - * Returns: - * The value of 'option' if available as utf8, or 'fallback'. - * - *-------------------------------------------------------------------------- - */ - -const char * -mongoc_uri_get_option_as_utf8 (const mongoc_uri_t *uri, - const char *option_orig, - const char *fallback) -{ - const char *option; - const bson_t *options; - bson_iter_t iter; - - option = mongoc_uri_canonicalize_option (option_orig); - if ((options = mongoc_uri_get_options (uri)) && - bson_iter_init_find_case (&iter, options, option) && - BSON_ITER_HOLDS_UTF8 (&iter)) { - return bson_iter_utf8 (&iter, NULL); - } - - return fallback; -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_uri_set_option_as_utf8 -- - * - * Sets a URI option 'after the fact'. Allows users to set individual - * URI options without passing them as a connection string. - * - * Only allows a set of known options to be set. - * @see mongoc_uri_option_is_utf8 (). - * - * If the option is not already set, this function will append it to - *the end of the options bson. NOTE: If the option is already set the entire - *options bson will be overwritten, containing the new option=value - *(at the same position). - * - * NOTE: If 'option' is already set, and is of invalid type, this - * function will return false. - * - * NOTE: 'option' must be valid utf8. - * - * NOTE: 'option' is case*in*sensitive. - * - * Returns: - * true on successfully setting the option, false on failure. - * - *-------------------------------------------------------------------------- - */ - -bool -mongoc_uri_set_option_as_utf8 (mongoc_uri_t *uri, - const char *option_orig, - const char *value) -{ - const char *option; - size_t len; - char *option_lowercase = NULL; - - option = mongoc_uri_canonicalize_option (option_orig); - BSON_ASSERT (option); - - len = strlen (value); - - if (!bson_utf8_validate (value, len, false)) { - return false; - } - - if (!mongoc_uri_option_is_utf8 (option)) { - return false; - } - if (!bson_strcasecmp (option, MONGOC_URI_APPNAME)) { - return mongoc_uri_set_appname (uri, value); - } else { - option_lowercase = lowercase_str_new (option); - mongoc_uri_bson_append_or_replace_key ( - &uri->options, option_lowercase, value); - bson_free (option_lowercase); - } - - return true; -} - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_uri_requires_auth_negotiation -- - * - * Returns true if auth mechanism is necessary for this uri. According - * to the auth spec: "If an application provides a username but does - * not provide an authentication mechanism, drivers MUST negotiate a - * mechanism". - * - * Returns: - * true if the driver should negotiate the auth mechanism for the uri - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_uri_requires_auth_negotiation (const mongoc_uri_t *uri) -{ - return mongoc_uri_get_username (uri) && !mongoc_uri_get_auth_mechanism (uri); -} - - -/* A bit of a hack. Needed for multi mongos tests to create a URI with the same - * auth, SSL, and compressors settings but with only one specific host. */ -mongoc_uri_t * -_mongoc_uri_copy_and_replace_host_list (const mongoc_uri_t *original, - const char *host) -{ - mongoc_uri_t *uri = mongoc_uri_copy (original); - _mongoc_host_list_destroy_all (uri->hosts); - uri->hosts = bson_malloc0 (sizeof (mongoc_host_list_t)); - _mongoc_host_list_from_string (uri->hosts, host); - return uri; -} - -bool -mongoc_uri_init_with_srv_host_list (mongoc_uri_t *uri, - mongoc_host_list_t *host_list, - bson_error_t *error) -{ - mongoc_host_list_t *host; - - BSON_ASSERT (uri->is_srv); - BSON_ASSERT (!uri->hosts); - - LL_FOREACH (host_list, host) - { - if (!mongoc_uri_upsert_host_and_port (uri, host->host_and_port, error)) { - return false; - } - } - - return true; -} - -#ifdef MONGOC_ENABLE_CRYPTO -void -_mongoc_uri_init_scram (const mongoc_uri_t *uri, - mongoc_scram_t *scram, - mongoc_crypto_hash_algorithm_t algo) -{ - BSON_ASSERT (uri); - BSON_ASSERT (scram); - - _mongoc_scram_init (scram, algo); - - _mongoc_scram_set_pass (scram, mongoc_uri_get_password (uri)); - _mongoc_scram_set_user (scram, mongoc_uri_get_username (uri)); -} -#endif - -static bool -mongoc_uri_finalize_loadbalanced (const mongoc_uri_t *uri, bson_error_t *error) -{ - if (!mongoc_uri_get_option_as_bool (uri, MONGOC_URI_LOADBALANCED, false)) { - return true; - } - - /* Load Balancer Spec: When `loadBalanced=true` is provided in the connection - * string, the driver MUST throw an exception if the connection string - * contains more than one host/port. */ - if (uri->hosts && uri->hosts->next) { - MONGOC_URI_ERROR ( - error, - "URI with \"%s\" enabled must not contain more than one host", - MONGOC_URI_LOADBALANCED); - return false; - } - - if (mongoc_uri_has_option (uri, MONGOC_URI_REPLICASET)) { - MONGOC_URI_ERROR ( - error, - "URI with \"%s\" enabled must not contain option \"%s\"", - MONGOC_URI_LOADBALANCED, - MONGOC_URI_REPLICASET); - return false; - } - - if (mongoc_uri_has_option (uri, MONGOC_URI_DIRECTCONNECTION) && - mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_DIRECTCONNECTION, false)) { - MONGOC_URI_ERROR ( - error, - "URI with \"%s\" enabled must not contain option \"%s\" enabled", - MONGOC_URI_LOADBALANCED, - MONGOC_URI_DIRECTCONNECTION); - return false; - } - - return true; -} - -static bool -mongoc_uri_finalize_srv (const mongoc_uri_t *uri, bson_error_t *error) -{ - /* Initial DNS Seedlist Discovery Spec: The driver MUST report an error if - * either the `srvServiceName` or `srvMaxHosts` URI options are specified - * with a non-SRV URI. */ - if (!uri->is_srv) { - const char *option = NULL; - - if (mongoc_uri_has_option (uri, MONGOC_URI_SRVSERVICENAME)) { - option = MONGOC_URI_SRVSERVICENAME; - } else if (mongoc_uri_has_option (uri, MONGOC_URI_SRVMAXHOSTS)) { - option = MONGOC_URI_SRVMAXHOSTS; - } - - if (option) { - MONGOC_URI_ERROR ( - error, "%s must not be specified with a non-SRV URI", option); - return false; - } - } - - if (uri->is_srv) { - const int32_t max_hosts = - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_SRVMAXHOSTS, 0); - - /* Initial DNS Seedless Discovery Spec: This option requires a - * non-negative integer and defaults to zero (i.e. no limit). */ - if (max_hosts < 0) { - MONGOC_URI_ERROR (error, - "%s is required to be a non-negative integer, but " - "has value %" PRId32, - MONGOC_URI_SRVMAXHOSTS, - max_hosts); - return false; - } - - if (max_hosts > 0) { - /* Initial DNS Seedless Discovery spec: If srvMaxHosts is a positive - * integer, the driver MUST throw an error if the connection string - * contains a `replicaSet` option. */ - if (mongoc_uri_has_option (uri, MONGOC_URI_REPLICASET)) { - MONGOC_URI_ERROR (error, - "%s must not be specified with %s", - MONGOC_URI_SRVMAXHOSTS, - MONGOC_URI_REPLICASET); - return false; - } - - /* Initial DNS Seedless Discovery Spec: If srvMaxHosts is a positive - * integer, the driver MUST throw an error if the connection string - * contains a `loadBalanced` option with a value of `true`. - */ - if (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_LOADBALANCED, false)) { - MONGOC_URI_ERROR (error, - "%s must not be specified with %s=true", - MONGOC_URI_SRVMAXHOSTS, - MONGOC_URI_LOADBALANCED); - return false; - } - } - } - - return true; -} - -/* This should be called whenever URI options change (e.g. parsing a new URI - * string, after setting one or more options explicitly, applying TXT records). - * While the primary purpose of this function is to validate the URI, it may - * also alter the URI (e.g. implicitly enable TLS when SRV is used). Returns - * true on success; otherwise, returns false and sets @error. */ -bool -mongoc_uri_finalize (mongoc_uri_t *uri, bson_error_t *error) -{ - BSON_ASSERT_PARAM (uri); - - if (!mongoc_uri_finalize_tls (uri, error)) { - return false; - } - - if (!mongoc_uri_finalize_auth (uri, error)) { - return false; - } - - if (!mongoc_uri_finalize_directconnection (uri, error)) { - return false; - } - - if (!mongoc_uri_finalize_loadbalanced (uri, error)) { - return false; - } - - if (!mongoc_uri_finalize_srv (uri, error)) { - return false; - } - - return true; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-uri.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-uri.h deleted file mode 100644 index 183c42d57..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-uri.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_URI_H -#define MONGOC_URI_H - -#include - -#include "mongoc-macros.h" -#include "mongoc-host-list.h" -#include "mongoc-read-prefs.h" -#include "mongoc-read-concern.h" -#include "mongoc-write-concern.h" -#include "mongoc-config.h" - - -#ifndef MONGOC_DEFAULT_PORT -#define MONGOC_DEFAULT_PORT 27017 -#endif - -#define MONGOC_URI_APPNAME "appname" -#define MONGOC_URI_AUTHMECHANISM "authmechanism" -#define MONGOC_URI_AUTHMECHANISMPROPERTIES "authmechanismproperties" -#define MONGOC_URI_AUTHSOURCE "authsource" -#define MONGOC_URI_CANONICALIZEHOSTNAME "canonicalizehostname" -#define MONGOC_URI_CONNECTTIMEOUTMS "connecttimeoutms" -#define MONGOC_URI_COMPRESSORS "compressors" -#define MONGOC_URI_DIRECTCONNECTION "directconnection" -#define MONGOC_URI_GSSAPISERVICENAME "gssapiservicename" -#define MONGOC_URI_HEARTBEATFREQUENCYMS "heartbeatfrequencyms" -#define MONGOC_URI_JOURNAL "journal" -#define MONGOC_URI_LOADBALANCED "loadbalanced" -#define MONGOC_URI_LOCALTHRESHOLDMS "localthresholdms" -#define MONGOC_URI_MAXIDLETIMEMS "maxidletimems" -#define MONGOC_URI_MAXPOOLSIZE "maxpoolsize" -#define MONGOC_URI_MAXSTALENESSSECONDS "maxstalenessseconds" -#define MONGOC_URI_MINPOOLSIZE "minpoolsize" -#define MONGOC_URI_READCONCERNLEVEL "readconcernlevel" -#define MONGOC_URI_READPREFERENCE "readpreference" -#define MONGOC_URI_READPREFERENCETAGS "readpreferencetags" -#define MONGOC_URI_REPLICASET "replicaset" -#define MONGOC_URI_RETRYREADS "retryreads" -#define MONGOC_URI_RETRYWRITES "retrywrites" -#define MONGOC_URI_SAFE "safe" -#define MONGOC_URI_SERVERSELECTIONTIMEOUTMS "serverselectiontimeoutms" -#define MONGOC_URI_SERVERSELECTIONTRYONCE "serverselectiontryonce" -#define MONGOC_URI_SLAVEOK "slaveok" -#define MONGOC_URI_SOCKETCHECKINTERVALMS "socketcheckintervalms" -#define MONGOC_URI_SOCKETTIMEOUTMS "sockettimeoutms" -#define MONGOC_URI_SRVSERVICENAME "srvservicename" -#define MONGOC_URI_SRVMAXHOSTS "srvmaxhosts" -#define MONGOC_URI_TLS "tls" -#define MONGOC_URI_TLSCERTIFICATEKEYFILE "tlscertificatekeyfile" -#define MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD "tlscertificatekeyfilepassword" -#define MONGOC_URI_TLSCAFILE "tlscafile" -#define MONGOC_URI_TLSALLOWINVALIDCERTIFICATES "tlsallowinvalidcertificates" -#define MONGOC_URI_TLSALLOWINVALIDHOSTNAMES "tlsallowinvalidhostnames" -#define MONGOC_URI_TLSINSECURE "tlsinsecure" -#define MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK \ - "tlsdisablecertificaterevocationcheck" -#define MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK "tlsdisableocspendpointcheck" -#define MONGOC_URI_W "w" -#define MONGOC_URI_WAITQUEUEMULTIPLE "waitqueuemultiple" -#define MONGOC_URI_WAITQUEUETIMEOUTMS "waitqueuetimeoutms" -#define MONGOC_URI_WTIMEOUTMS "wtimeoutms" -#define MONGOC_URI_ZLIBCOMPRESSIONLEVEL "zlibcompressionlevel" - -/* Deprecated in MongoDB 4.2, use "tls" variants instead. */ -#define MONGOC_URI_SSL "ssl" -#define MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE "sslclientcertificatekeyfile" -#define MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD \ - "sslclientcertificatekeypassword" -#define MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE "sslcertificateauthorityfile" -#define MONGOC_URI_SSLALLOWINVALIDCERTIFICATES "sslallowinvalidcertificates" -#define MONGOC_URI_SSLALLOWINVALIDHOSTNAMES "sslallowinvalidhostnames" - -BSON_BEGIN_DECLS - - -typedef struct _mongoc_uri_t mongoc_uri_t; - - -MONGOC_EXPORT (mongoc_uri_t *) -mongoc_uri_copy (const mongoc_uri_t *uri) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_uri_destroy (mongoc_uri_t *uri); -MONGOC_EXPORT (mongoc_uri_t *) -mongoc_uri_new (const char *uri_string) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_uri_t *) -mongoc_uri_new_with_error (const char *uri_string, - bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_uri_t *) -mongoc_uri_new_for_host_port (const char *hostname, - uint16_t port) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (const mongoc_host_list_t *) -mongoc_uri_get_hosts (const mongoc_uri_t *uri); -MONGOC_EXPORT (const char *) -mongoc_uri_get_service (const mongoc_uri_t *uri) - BSON_GNUC_DEPRECATED_FOR (mongoc_uri_get_srv_hostname); -MONGOC_EXPORT (const char *) -mongoc_uri_get_srv_hostname (const mongoc_uri_t *uri); -MONGOC_EXPORT (const char *) -mongoc_uri_get_srv_service_name (const mongoc_uri_t *uri); -MONGOC_EXPORT (const char *) -mongoc_uri_get_database (const mongoc_uri_t *uri); -MONGOC_EXPORT (bool) -mongoc_uri_set_database (mongoc_uri_t *uri, const char *database); -MONGOC_EXPORT (const bson_t *) -mongoc_uri_get_compressors (const mongoc_uri_t *uri); -MONGOC_EXPORT (const bson_t *) -mongoc_uri_get_options (const mongoc_uri_t *uri); -MONGOC_EXPORT (const char *) -mongoc_uri_get_password (const mongoc_uri_t *uri); -MONGOC_EXPORT (bool) -mongoc_uri_set_password (mongoc_uri_t *uri, const char *password); -MONGOC_EXPORT (bool) -mongoc_uri_has_option (const mongoc_uri_t *uri, const char *key); -MONGOC_EXPORT (bool) -mongoc_uri_option_is_int32 (const char *key); -MONGOC_EXPORT (bool) -mongoc_uri_option_is_int64 (const char *key); -MONGOC_EXPORT (bool) -mongoc_uri_option_is_bool (const char *key); -MONGOC_EXPORT (bool) -mongoc_uri_option_is_utf8 (const char *key); -MONGOC_EXPORT (int32_t) -mongoc_uri_get_option_as_int32 (const mongoc_uri_t *uri, - const char *option, - int32_t fallback); -MONGOC_EXPORT (int64_t) -mongoc_uri_get_option_as_int64 (const mongoc_uri_t *uri, - const char *option, - int64_t fallback); -MONGOC_EXPORT (bool) -mongoc_uri_get_option_as_bool (const mongoc_uri_t *uri, - const char *option, - bool fallback); -MONGOC_EXPORT (const char *) -mongoc_uri_get_option_as_utf8 (const mongoc_uri_t *uri, - const char *option, - const char *fallback); -MONGOC_EXPORT (bool) -mongoc_uri_set_option_as_int32 (mongoc_uri_t *uri, - const char *option, - int32_t value); -MONGOC_EXPORT (bool) -mongoc_uri_set_option_as_int64 (mongoc_uri_t *uri, - const char *option, - int64_t value); -MONGOC_EXPORT (bool) -mongoc_uri_set_option_as_bool (mongoc_uri_t *uri, - const char *option, - bool value); -MONGOC_EXPORT (bool) -mongoc_uri_set_option_as_utf8 (mongoc_uri_t *uri, - const char *option, - const char *value); -MONGOC_EXPORT (const bson_t *) -mongoc_uri_get_read_prefs (const mongoc_uri_t *uri) - BSON_GNUC_DEPRECATED_FOR (mongoc_uri_get_read_prefs_t); -MONGOC_EXPORT (const char *) -mongoc_uri_get_replica_set (const mongoc_uri_t *uri); -MONGOC_EXPORT (const char *) -mongoc_uri_get_string (const mongoc_uri_t *uri); -MONGOC_EXPORT (const char *) -mongoc_uri_get_username (const mongoc_uri_t *uri); -MONGOC_EXPORT (bool) -mongoc_uri_set_username (mongoc_uri_t *uri, const char *username); -MONGOC_EXPORT (const bson_t *) -mongoc_uri_get_credentials (const mongoc_uri_t *uri); -MONGOC_EXPORT (const char *) -mongoc_uri_get_auth_source (const mongoc_uri_t *uri); -MONGOC_EXPORT (bool) -mongoc_uri_set_auth_source (mongoc_uri_t *uri, const char *value); -MONGOC_EXPORT (const char *) -mongoc_uri_get_appname (const mongoc_uri_t *uri); -MONGOC_EXPORT (bool) -mongoc_uri_set_appname (mongoc_uri_t *uri, const char *value); -MONGOC_EXPORT (bool) -mongoc_uri_set_compressors (mongoc_uri_t *uri, const char *value); -MONGOC_EXPORT (const char *) -mongoc_uri_get_auth_mechanism (const mongoc_uri_t *uri); -MONGOC_EXPORT (bool) -mongoc_uri_set_auth_mechanism (mongoc_uri_t *uri, const char *value); -MONGOC_EXPORT (bool) -mongoc_uri_get_mechanism_properties (const mongoc_uri_t *uri, - bson_t *properties); -MONGOC_EXPORT (bool) -mongoc_uri_set_mechanism_properties (mongoc_uri_t *uri, - const bson_t *properties); -MONGOC_EXPORT (bool) -mongoc_uri_get_ssl (const mongoc_uri_t *uri) - BSON_GNUC_DEPRECATED_FOR (mongoc_uri_get_tls); -MONGOC_EXPORT (bool) -mongoc_uri_get_tls (const mongoc_uri_t *uri); -MONGOC_EXPORT (char *) -mongoc_uri_unescape (const char *escaped_string) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (const mongoc_read_prefs_t *) -mongoc_uri_get_read_prefs_t (const mongoc_uri_t *uri); -MONGOC_EXPORT (void) -mongoc_uri_set_read_prefs_t (mongoc_uri_t *uri, - const mongoc_read_prefs_t *prefs); -MONGOC_EXPORT (const mongoc_write_concern_t *) -mongoc_uri_get_write_concern (const mongoc_uri_t *uri); -MONGOC_EXPORT (void) -mongoc_uri_set_write_concern (mongoc_uri_t *uri, - const mongoc_write_concern_t *wc); -MONGOC_EXPORT (const mongoc_read_concern_t *) -mongoc_uri_get_read_concern (const mongoc_uri_t *uri); -MONGOC_EXPORT (void) -mongoc_uri_set_read_concern (mongoc_uri_t *uri, - const mongoc_read_concern_t *rc); - -BSON_END_DECLS - - -#endif /* MONGOC_URI_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-util-private.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-util-private.h deleted file mode 100644 index 19517104f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-util-private.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_UTIL_PRIVATE_H -#define MONGOC_UTIL_PRIVATE_H - -#include -#include "mongoc.h" - -#ifdef BSON_HAVE_STRINGS_H -#include -#endif - -#include - -/* string comparison functions for Windows */ -#ifdef _WIN32 -#define strcasecmp _stricmp -#define strncasecmp _strnicmp -#endif - -#if BSON_GNUC_CHECK_VERSION(4, 6) -#define BEGIN_IGNORE_DEPRECATIONS \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#define END_IGNORE_DEPRECATIONS _Pragma ("GCC diagnostic pop") -#elif defined(__clang__) -#define BEGIN_IGNORE_DEPRECATIONS \ - _Pragma ("clang diagnostic push") \ - _Pragma ("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#define END_IGNORE_DEPRECATIONS _Pragma ("clang diagnostic pop") -#else -#define BEGIN_IGNORE_DEPRECATIONS -#define END_IGNORE_DEPRECATIONS -#endif - -#ifndef _WIN32 -#define MONGOC_PRINTF_FORMAT(a, b) __attribute__ ((format (__printf__, a, b))) -#else -#define MONGOC_PRINTF_FORMAT(a, b) /* no-op */ -#endif - -#define COALESCE(x, y) ((x == 0) ? (y) : (x)) - - -/* Helper macros for stringifying things */ -#define MONGOC_STR(s) #s -#define MONGOC_EVALUATE_STR(s) MONGOC_STR (s) - -BSON_BEGIN_DECLS - -extern const bson_validate_flags_t _mongoc_default_insert_vflags; -extern const bson_validate_flags_t _mongoc_default_replace_vflags; -extern const bson_validate_flags_t _mongoc_default_update_vflags; - -int -_mongoc_rand_simple (unsigned int *seed); - -char * -_mongoc_hex_md5 (const char *input); - -void -_mongoc_usleep (int64_t usec); - -/* Get the current time as a number of milliseconds since the Unix Epoch. */ -int64_t -_mongoc_get_real_time_ms (void); - -const char * -_mongoc_get_command_name (const bson_t *command); - -const char * -_mongoc_get_documents_field_name (const char *command_name); - -bool -_mongoc_lookup_bool (const bson_t *bson, const char *key, bool default_value); - -/* Returns a database name that the caller must free. */ -char * -_mongoc_get_db_name (const char *ns); - -void -_mongoc_bson_init_if_set (bson_t *bson); - -const char * -_mongoc_bson_type_to_str (bson_type_t t); - -const char * -_mongoc_wire_version_to_server_version (int32_t version); - -bool -_mongoc_get_server_id_from_opts (const bson_t *opts, - mongoc_error_domain_t domain, - mongoc_error_code_t code, - uint32_t *server_id, - bson_error_t *error); - -bool -_mongoc_validate_new_document (const bson_t *insert, - bson_validate_flags_t vflags, - bson_error_t *error); - -bool -_mongoc_validate_replace (const bson_t *insert, - bson_validate_flags_t vflags, - bson_error_t *error); - -bool -_mongoc_validate_update (const bson_t *update, - bson_validate_flags_t vflags, - bson_error_t *error); - -bool -mongoc_ends_with (const char *str, const char *suffix); - -void -mongoc_lowercase (const char *src, char *buf /* OUT */); - -bool -mongoc_parse_port (uint16_t *port, const char *str); - -void -_mongoc_bson_array_add_label (bson_t *bson, const char *label); - -void -_mongoc_bson_array_copy_labels_to (const bson_t *reply, bson_t *dst); - -void -_mongoc_add_transient_txn_error (const mongoc_client_session_t *cs, - bson_t *reply); - -bool -_mongoc_document_is_pipeline (const bson_t *document); - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_getenv -- - * - * Get the value of an environment variable. - * - * Returns: - * A string you must bson_free, or NULL if the variable is not set. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -char * -_mongoc_getenv (const char *name); - -/* - *-------------------------------------------------------------------------- - * - * _mongoc_setenv -- - * - * Set or overwrite the value of an environment variable. - * - * Returns: - * False if setting the variable was unsuccessful. - * - *-------------------------------------------------------------------------- - */ -bool -_mongoc_setenv (const char *name, const char *value); - -void -bson_copy_to_including_noinit (const bson_t *src, - bson_t *dst, - const char *first_include, - ...) BSON_GNUC_NULL_TERMINATED; - -void -bson_copy_to_including_noinit_va (const bson_t *src, - bson_t *dst, - const char *first_include, - va_list args); - -/* Returns a uniformly-distributed uint32_t generated using - * `_mongoc_rand_bytes()` if a source of cryptographic randomness is available - * (defined only if `MONGOC_ENABLE_CRYPTO` is defined). - */ -uint32_t -_mongoc_crypto_rand_uint32_t (void); - -/* Returns a uniformly-distributed uint64_t generated using - * `_mongoc_rand_bytes()` if a source of cryptographic randomness is available - * (defined only if `MONGOC_ENABLE_CRYPTO` is defined). - */ -uint64_t -_mongoc_crypto_rand_uint64_t (void); - -/* Returns a uniformly-distributed size_t generated using - * `_mongoc_rand_bytes()` if a source of cryptographic randomness is available - * (defined only if `MONGOC_ENABLE_CRYPTO` is defined). - */ -size_t -_mongoc_crypto_rand_size_t (void); - -/* Returns a uniformly-distributed random uint32_t generated using `rand()`. - * Note: may invoke `srand()`, which may not be thread-safe. Concurrent calls to - * `_mongoc_simple_rand_*()` functions, however, is thread-safe. */ -uint32_t -_mongoc_simple_rand_uint32_t (void); - -/* Returns a uniformly-distributed random uint64_t generated using `rand()`. - * Note: may invoke `srand()`, which may not be thread-safe. Concurrent calls to - * `_mongoc_simple_rand_*()` functions, however, is thread-safe. */ -uint64_t -_mongoc_simple_rand_uint64_t (void); - -/* Returns a uniformly-distributed random size_t generated using `rand()`. - * Note: may invoke `srand()`, which may not be thread-safe. Concurrent calls to - * `_mongoc_simple_rand_*()` functions, however, is thread-safe. */ -size_t -_mongoc_simple_rand_size_t (void); - -/* Returns a uniformly-distributed random integer in the range [min, max]. - * - * The size of the range [min, max] must not equal the size of the representable - * range of uint32_t (`min == 0 && max == UINT32_MAX` must not be true). - * - * The generator `rand` must return a random integer uniformly distributed in - * the full range of representable values of uint32_t. - */ -uint32_t -_mongoc_rand_uint32_t (uint32_t min, uint32_t max, uint32_t (*rand) (void)); - -/* Returns a uniformly-distributed random integer in the range [min, max]. - * - * The size of the range [min, max] must not equal the size of the representable - * range of uint64_t (`min == 0 && max == UINT64_MAX` must not be true). - * - * The generator `rand` must return a random integer uniformly distributed in - * the full range of representable values of uint64_t. - */ -uint64_t -_mongoc_rand_uint64_t (uint64_t min, uint64_t max, uint64_t (*rand) (void)); - -/* Returns a uniformly-distributed random integer in the range [min, max]. - * - * The size of the range [min, max] must not equal the size of the representable - * range of size_t (`min == 0 && max == SIZE_MAX` must not be true). - * - * The generator `rand` must return a random integer uniformly distributed in - * the full range of representable values of size_t. - */ -size_t -_mongoc_rand_size_t (size_t min, size_t max, size_t (*rand) (void)); - -/* _mongoc_iter_document_as_bson attempts to read the document from @iter into - * @bson. */ -bool -_mongoc_iter_document_as_bson (const bson_iter_t *iter, - bson_t *bson, - bson_error_t *error); - -uint8_t * -hex_to_bin (const char *hex, uint32_t *len); - -char * -bin_to_hex (const uint8_t *bin, uint32_t len); - -BSON_END_DECLS - -#endif /* MONGOC_UTIL_PRIVATE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-util.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-util.c deleted file mode 100644 index 73fe534af..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-util.c +++ /dev/null @@ -1,1074 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef _WIN32 -#define _CRT_RAND_S -#endif - -#include - -#include "bson/bson.h" - -#include "common-md5-private.h" -#include "common-thread-private.h" -#include "mongoc-rand-private.h" -#include "mongoc-util-private.h" -#include "mongoc-client.h" -#include "mongoc-client-private.h" // WIRE_VERSION_* macros. -#include "mongoc-client-session-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-sleep.h" - -const bson_validate_flags_t _mongoc_default_insert_vflags = - BSON_VALIDATE_UTF8 | BSON_VALIDATE_UTF8_ALLOW_NULL | - BSON_VALIDATE_EMPTY_KEYS; - -const bson_validate_flags_t _mongoc_default_replace_vflags = - BSON_VALIDATE_UTF8 | BSON_VALIDATE_UTF8_ALLOW_NULL | - BSON_VALIDATE_EMPTY_KEYS; - -const bson_validate_flags_t _mongoc_default_update_vflags = - BSON_VALIDATE_UTF8 | BSON_VALIDATE_UTF8_ALLOW_NULL | - BSON_VALIDATE_EMPTY_KEYS; - -int -_mongoc_rand_simple (unsigned int *seed) -{ -#ifdef _WIN32 - /* ignore the seed */ - unsigned int ret = 0; - errno_t err; - - err = rand_s (&ret); - if (0 != err) { - MONGOC_ERROR ("rand_s failed: %s", strerror (err)); - } - - return (int) ret; -#else - return rand_r (seed); -#endif -} - - -char * -_mongoc_hex_md5 (const char *input) -{ - uint8_t digest[16]; - bson_md5_t md5; - char digest_str[33]; - int i; - - mcommon_md5_init (&md5); - mcommon_md5_append ( - &md5, (const uint8_t *) input, (uint32_t) strlen (input)); - mcommon_md5_finish (&md5, digest); - - for (i = 0; i < sizeof digest; i++) { - bson_snprintf (&digest_str[i * 2], 3, "%02x", digest[i]); - } - digest_str[sizeof digest_str - 1] = '\0'; - - return bson_strdup (digest_str); -} - -void -mongoc_client_set_usleep_impl (mongoc_client_t *client, - mongoc_usleep_func_t usleep_func, - void *user_data) -{ - client->topology->usleep_fn = usleep_func; - client->topology->usleep_data = user_data; -} - -void -mongoc_usleep_default_impl (int64_t usec, void *user_data) -{ - BSON_UNUSED (user_data); - -#ifdef _WIN32 - LARGE_INTEGER ft; - HANDLE timer; - - BSON_ASSERT (usec >= 0); - - ft.QuadPart = -(10 * usec); - timer = CreateWaitableTimer (NULL, true, NULL); - SetWaitableTimer (timer, &ft, 0, NULL, NULL, 0); - WaitForSingleObject (timer, INFINITE); - CloseHandle (timer); -#else - BSON_ASSERT (usec >= 0); - usleep ((useconds_t) usec); -#endif -} - -void -_mongoc_usleep (int64_t usec) -{ - mongoc_usleep_default_impl (usec, NULL); -} - - -int64_t -_mongoc_get_real_time_ms (void) -{ - struct timeval tv; - const bool rc = bson_gettimeofday (&tv); - if (rc != 0) { - return -1; - } - return tv.tv_sec * (int64_t) 1000 + tv.tv_usec / (int64_t) 1000; -} - - -const char * -_mongoc_get_command_name (const bson_t *command) -{ - bson_iter_t iter; - const char *name; - bson_iter_t child; - const char *wrapper_name = NULL; - - BSON_ASSERT (command); - - if (!bson_iter_init (&iter, command) || !bson_iter_next (&iter)) { - return NULL; - } - - name = bson_iter_key (&iter); - - /* wrapped in "$query" or "query"? - * - * {$query: {count: "collection"}, $readPreference: {...}} - */ - if (name[0] == '$') { - wrapper_name = "$query"; - } else if (!strcmp (name, "query")) { - wrapper_name = "query"; - } - - if (wrapper_name && bson_iter_init_find (&iter, command, wrapper_name) && - BSON_ITER_HOLDS_DOCUMENT (&iter) && bson_iter_recurse (&iter, &child) && - bson_iter_next (&child)) { - name = bson_iter_key (&child); - } - - return name; -} - - -const char * -_mongoc_get_documents_field_name (const char *command_name) -{ - if (!strcmp (command_name, "insert")) { - return "documents"; - } - - if (!strcmp (command_name, "update")) { - return "updates"; - } - - if (!strcmp (command_name, "delete")) { - return "deletes"; - } - - return NULL; -} - -bool -_mongoc_lookup_bool (const bson_t *bson, const char *key, bool default_value) -{ - bson_iter_t iter; - bson_iter_t child; - - if (!bson) { - return default_value; - } - - BSON_ASSERT (bson_iter_init (&iter, bson)); - if (!bson_iter_find_descendant (&iter, key, &child)) { - return default_value; - } - - return bson_iter_as_bool (&child); -} - -char * -_mongoc_get_db_name (const char *ns) -{ - size_t dblen; - const char *dot; - - BSON_ASSERT (ns); - - dot = strstr (ns, "."); - - if (dot) { - dblen = dot - ns; - return bson_strndup (ns, dblen); - } else { - return bson_strdup (ns); - } -} - -void -_mongoc_bson_init_if_set (bson_t *bson) -{ - if (bson) { - bson_init (bson); - } -} - -const char * -_mongoc_bson_type_to_str (bson_type_t t) -{ - switch (t) { - case BSON_TYPE_EOD: - return "EOD"; - case BSON_TYPE_DOUBLE: - return "DOUBLE"; - case BSON_TYPE_UTF8: - return "UTF8"; - case BSON_TYPE_DOCUMENT: - return "DOCUMENT"; - case BSON_TYPE_ARRAY: - return "ARRAY"; - case BSON_TYPE_BINARY: - return "BINARY"; - case BSON_TYPE_UNDEFINED: - return "UNDEFINED"; - case BSON_TYPE_OID: - return "OID"; - case BSON_TYPE_BOOL: - return "BOOL"; - case BSON_TYPE_DATE_TIME: - return "DATE_TIME"; - case BSON_TYPE_NULL: - return "NULL"; - case BSON_TYPE_REGEX: - return "REGEX"; - case BSON_TYPE_DBPOINTER: - return "DBPOINTER"; - case BSON_TYPE_CODE: - return "CODE"; - case BSON_TYPE_SYMBOL: - return "SYMBOL"; - case BSON_TYPE_CODEWSCOPE: - return "CODEWSCOPE"; - case BSON_TYPE_INT32: - return "INT32"; - case BSON_TYPE_TIMESTAMP: - return "TIMESTAMP"; - case BSON_TYPE_INT64: - return "INT64"; - case BSON_TYPE_MAXKEY: - return "MAXKEY"; - case BSON_TYPE_MINKEY: - return "MINKEY"; - case BSON_TYPE_DECIMAL128: - return "DECIMAL128"; - default: - return "Unknown"; - } -} - - -/* Refer to: - * https://github.com/mongodb/specifications/blob/master/source/wireversion-featurelist.rst - * and: - * https://github.com/mongodb/mongo/blob/master/src/mongo/db/wire_version.h#L57 - */ -const char * -_mongoc_wire_version_to_server_version (int32_t version) -{ - switch (version) { - case 1: - case 2: - return "2.6"; - case 3: - return "3.0"; - case 4: - return "3.2"; - case 5: - return "3.4"; - case 6: - return "3.6"; - case WIRE_VERSION_4_0: - return "4.0"; - case WIRE_VERSION_4_2: - return "4.2"; - case WIRE_VERSION_4_4: - return "4.4"; - case 10: - return "4.7"; - case 11: - return "4.8"; - case WIRE_VERSION_4_9: - return "4.9"; - case WIRE_VERSION_5_0: - return "5.0"; - case WIRE_VERSION_5_1: - return "5.1"; - case 15: - return "5.2"; - case 16: - return "5.3"; - case WIRE_VERSION_6_0: - return "6.0"; - case WIRE_VERSION_7_0: - return "7.0"; - default: - return "Unknown"; - } -} - - -/* Get "serverId" from opts. Sets *server_id to the serverId from "opts" or 0 - * if absent. On error, fills out *error with domain and code and return false. - */ -bool -_mongoc_get_server_id_from_opts (const bson_t *opts, - mongoc_error_domain_t domain, - mongoc_error_code_t code, - uint32_t *server_id, - bson_error_t *error) -{ - bson_iter_t iter; - - ENTRY; - - BSON_ASSERT (server_id); - - *server_id = 0; - - if (!opts || !bson_iter_init_find (&iter, opts, "serverId")) { - RETURN (true); - } - - if (!BSON_ITER_HOLDS_INT (&iter)) { - bson_set_error ( - error, domain, code, "The serverId option must be an integer"); - RETURN (false); - } - - if (bson_iter_as_int64 (&iter) <= 0) { - bson_set_error (error, domain, code, "The serverId option must be >= 1"); - RETURN (false); - } - - *server_id = (uint32_t) bson_iter_as_int64 (&iter); - - RETURN (true); -} - - -bool -_mongoc_validate_new_document (const bson_t *doc, - bson_validate_flags_t vflags, - bson_error_t *error) -{ - bson_error_t validate_err; - - if (vflags == BSON_VALIDATE_NONE) { - return true; - } - - if (!bson_validate_with_error (doc, vflags, &validate_err)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "invalid document for insert: %s", - validate_err.message); - return false; - } - - return true; -} - - -bool -_mongoc_validate_replace (const bson_t *doc, - bson_validate_flags_t vflags, - bson_error_t *error) -{ - bson_error_t validate_err; - bson_iter_t iter; - const char *key; - - if (vflags == BSON_VALIDATE_NONE) { - return true; - } - - if (!bson_validate_with_error (doc, vflags, &validate_err)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "invalid argument for replace: %s", - validate_err.message); - return false; - } - - if (!bson_iter_init (&iter, doc)) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "replace document is corrupt"); - return false; - } - - while (bson_iter_next (&iter)) { - key = bson_iter_key (&iter); - if (key[0] == '$') { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid key '%s': replace prohibits $ operators", - key); - - return false; - } - } - - return true; -} - - -bool -_mongoc_validate_update (const bson_t *update, - bson_validate_flags_t vflags, - bson_error_t *error) -{ - bson_error_t validate_err; - bson_iter_t iter; - const char *key; - - if (vflags == BSON_VALIDATE_NONE) { - return true; - } - - if (!bson_validate_with_error (update, vflags, &validate_err)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "invalid argument for update: %s", - validate_err.message); - return false; - } - - if (_mongoc_document_is_pipeline (update)) { - return true; - } - - if (!bson_iter_init (&iter, update)) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "update document is corrupt"); - return false; - } - - while (bson_iter_next (&iter)) { - key = bson_iter_key (&iter); - if (key[0] != '$') { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid key '%s': update only works with $ operators" - " and pipelines", - key); - - return false; - } - } - - return true; -} - - -static bool -should_include (const char *first_include, va_list args, const char *name) -{ - bool ret = false; - const char *include = first_include; - va_list args_copy; - - va_copy (args_copy, args); - - do { - if (!strcmp (name, include)) { - ret = true; - break; - } - } while ((include = va_arg (args_copy, const char *))); - - va_end (args_copy); - - return ret; -} - - -void -bson_copy_to_including_noinit_va (const bson_t *src, - bson_t *dst, - const char *first_include, - va_list args) -{ - BSON_ASSERT_PARAM (src); - BSON_ASSERT_PARAM (dst); - BSON_ASSERT_PARAM (first_include); - bson_iter_t iter; - - if (bson_iter_init (&iter, src)) { - while (bson_iter_next (&iter)) { - if (should_include (first_include, args, bson_iter_key (&iter))) { - if (!bson_append_iter (dst, NULL, 0, &iter)) { - /* - * This should not be able to happen since we are copying - * from within a valid bson_t. - */ - BSON_ASSERT (false); - return; - } - } - } - } -} - -void -bson_copy_to_including_noinit (const bson_t *src, - bson_t *dst, - const char *first_include, - ...) -{ - BSON_ASSERT_PARAM (src); - BSON_ASSERT_PARAM (dst); - BSON_ASSERT_PARAM (first_include); - - va_list args; - va_start (args, first_include); - bson_copy_to_including_noinit_va (src, dst, first_include, args); - va_end (args); -} - -/* - *-------------------------------------------------------------------------- - * - * mongoc_ends_with -- - * - * Return true if str ends with suffix. - * - *-------------------------------------------------------------------------- - */ -bool -mongoc_ends_with (const char *str, const char *suffix) -{ - BSON_ASSERT_PARAM (str); - BSON_ASSERT_PARAM (suffix); - - const size_t str_len = strlen (str); - const size_t suffix_len = strlen (suffix); - - if (str_len < suffix_len) { - return false; - } - - return strcmp (str + (str_len - suffix_len), suffix) == 0; -} - -void -mongoc_lowercase (const char *src, char *buf /* OUT */) -{ - for (; *src; ++src, ++buf) { - /* UTF8 non-ascii characters have a 1 at the leftmost bit. If this is the - * case, just copy */ - if ((*src & (0x1 << 7)) == 0) { - *buf = (char) tolower (*src); - } else { - *buf = *src; - } - } -} - -bool -mongoc_parse_port (uint16_t *port, const char *str) -{ - unsigned long ul_port; - - ul_port = strtoul (str, NULL, 10); - - if (ul_port == 0 || ul_port > UINT16_MAX) { - /* Parse error or port number out of range. mongod prohibits port 0. */ - return false; - } - - *port = (uint16_t) ul_port; - return true; -} - - -/*-------------------------------------------------------------------------- - * - * _mongoc_bson_array_add_label -- - * - * Append an error label like "TransientTransactionError" to a BSON - * array iff the array does not already contain it. - * - * Side effects: - * Aborts if the array is invalid or contains non-string elements. - * - *-------------------------------------------------------------------------- - */ - -void -_mongoc_bson_array_add_label (bson_t *bson, const char *label) -{ - bson_iter_t iter; - char buf[16]; - uint32_t i = 0; - const char *key; - - BSON_ASSERT (bson_iter_init (&iter, bson)); - while (bson_iter_next (&iter)) { - if (!strcmp (bson_iter_utf8 (&iter, NULL), label)) { - /* already included once */ - return; - } - - i++; - } - - bson_uint32_to_string (i, &key, buf, sizeof buf); - BSON_APPEND_UTF8 (bson, key, label); -} - - -/*-------------------------------------------------------------------------- - * - * _mongoc_bson_array_copy_labels_to -- - * - * Copy error labels like "TransientTransactionError" from a server - * reply to a BSON array iff the array does not already contain it. - * - * Side effects: - * Aborts if @dst is invalid or contains non-string elements. - * - *-------------------------------------------------------------------------- - */ - -void -_mongoc_bson_array_copy_labels_to (const bson_t *reply, bson_t *dst) -{ - bson_iter_t iter; - bson_iter_t label; - - if (bson_iter_init_find (&iter, reply, "errorLabels")) { - BSON_ASSERT (bson_iter_recurse (&iter, &label)); - while (bson_iter_next (&label)) { - if (BSON_ITER_HOLDS_UTF8 (&label)) { - _mongoc_bson_array_add_label (dst, bson_iter_utf8 (&label, NULL)); - } - } - } -} - - -/*-------------------------------------------------------------------------- - * - * _mongoc_add_transient_txn_error -- - * - * If @cs is not NULL and in a transaction, add errorLabels: - * ["TransientTransactionError"] to @reply. - * - * Transactions Spec: TransientTransactionError includes "server - * selection error encountered running any command besides - * commitTransaction in a transaction. ...in the case of network errors - * or server selection errors where the client receives no server reply, - * the client adds the label." - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -_mongoc_add_transient_txn_error (const mongoc_client_session_t *cs, - bson_t *reply) -{ - if (!reply) { - return; - } - - if (_mongoc_client_session_in_txn (cs)) { - bson_t labels = BSON_INITIALIZER; - _mongoc_bson_array_copy_labels_to (reply, &labels); - _mongoc_bson_array_add_label (&labels, TRANSIENT_TXN_ERR); - - bson_t new_reply = BSON_INITIALIZER; - bson_copy_to_excluding_noinit (reply, &new_reply, "errorLabels", NULL); - BSON_APPEND_ARRAY (&new_reply, "errorLabels", &labels); - - bson_reinit (reply); - bson_concat (reply, &new_reply); - - bson_destroy (&labels); - bson_destroy (&new_reply); - } -} - -bool -_mongoc_document_is_pipeline (const bson_t *document) -{ - bson_iter_t iter; - bson_iter_t child; - const char *key; - int i = 0; - char *i_str; - - if (!bson_iter_init (&iter, document)) { - return false; - } - - while (bson_iter_next (&iter)) { - key = bson_iter_key (&iter); - i_str = bson_strdup_printf ("%d", i++); - - if (strcmp (key, i_str)) { - bson_free (i_str); - return false; - } - - bson_free (i_str); - - if (BSON_ITER_HOLDS_DOCUMENT (&iter)) { - if (!bson_iter_recurse (&iter, &child)) { - return false; - } - if (!bson_iter_next (&child)) { - return false; - } - key = bson_iter_key (&child); - if (key[0] != '$') { - return false; - } - } else { - return false; - } - } - - /* should return false when the document is empty */ - return i != 0; -} - -char * -_mongoc_getenv (const char *name) -{ -#ifdef _MSC_VER - char buf[2048]; - size_t buflen; - - if ((0 == getenv_s (&buflen, buf, sizeof buf, name)) && buflen) { - return bson_strdup (buf); - } else { - return NULL; - } -#else - char *const var = getenv (name); - if (var && strlen (var)) { - return bson_strdup (var); - } else { - return NULL; - } - -#endif -} - -bool -_mongoc_setenv (const char *name, const char *value) -{ -#ifdef _WIN32 - return SetEnvironmentVariableA (name, value) != 0; -#else - - if (0 != setenv (name, value, 1)) { - return false; - } - - return true; -#endif -} - - -/* Nearly Divisionless (Algorithm 5): https://arxiv.org/abs/1805.10941 */ -static uint32_t -_mongoc_rand_nduid32 (uint32_t s, uint32_t (*rand32) (void)) -{ - const uint64_t limit = UINT32_MAX; /* 2^L */ - uint64_t x, m, l; - - x = rand32 (); - m = x * s; - l = m % limit; - - if (l < s) { - const uint64_t t = (limit - s) % s; - - while (l < t) { - x = rand32 (); - m = x * s; - l = m % limit; - } - } - - return (uint32_t) (m / limit); -} - -/* Java Algorithm (Algorithm 4): https://arxiv.org/abs/1805.10941 - * The 64-bit version of the nearly divisionless algorithm requires 128-bit - * integer arithmetic. Instead of trying to deal with cross-platform support for - * `__int128`, fallback to using the Java algorithm for 64-bit instead. */ -static uint64_t -_mongoc_rand_java64 (uint64_t s, uint64_t (*rand64) (void)) -{ - const uint64_t limit = UINT64_MAX; /* 2^L */ - uint64_t x, r; - - x = rand64 (); - r = x % s; - - while ((x - r) > (limit - s)) { - x = rand64 (); - r = x % s; - } - - return r; -} - -#if defined(MONGOC_ENABLE_CRYPTO) - -uint32_t -_mongoc_crypto_rand_uint32_t (void) -{ - uint32_t res; - - (void) _mongoc_rand_bytes ((uint8_t *) &res, sizeof (res)); - - return res; -} - -uint64_t -_mongoc_crypto_rand_uint64_t (void) -{ - uint64_t res; - - (void) _mongoc_rand_bytes ((uint8_t *) &res, sizeof (res)); - - return res; -} - -size_t -_mongoc_crypto_rand_size_t (void) -{ - size_t res; - - (void) _mongoc_rand_bytes ((uint8_t *) &res, sizeof (res)); - - return res; -} - -#endif /* defined(MONGOC_ENABLE_CRYPTO) */ - -static BSON_ONCE_FUN (_mongoc_simple_rand_init) -{ - struct timeval tv; - unsigned int seed = 0; - - bson_gettimeofday (&tv); - - seed ^= (unsigned int) tv.tv_sec; - seed ^= (unsigned int) tv.tv_usec; - - srand (seed); - - BSON_ONCE_RETURN; -} - -static bson_once_t _mongoc_simple_rand_init_once = BSON_ONCE_INIT; - -uint32_t -_mongoc_simple_rand_uint32_t (void) -{ - bson_once (&_mongoc_simple_rand_init_once, _mongoc_simple_rand_init); - - /* Ensure *all* bits are random, as RAND_MAX is only required to be at least - * 32767 (2^15). */ - return (((uint32_t) rand () & 0x7FFFu) << 0u) | - (((uint32_t) rand () & 0x7FFFu) << 15u) | - (((uint32_t) rand () & 0x0003u) << 30u); -} - -uint64_t -_mongoc_simple_rand_uint64_t (void) -{ - bson_once (&_mongoc_simple_rand_init_once, _mongoc_simple_rand_init); - - /* Ensure *all* bits are random, as RAND_MAX is only required to be at least - * 32767 (2^15). */ - return (((uint64_t) rand () & 0x7FFFu) << 0u) | - (((uint64_t) rand () & 0x7FFFu) << 15u) | - (((uint64_t) rand () & 0x7FFFu) << 30u) | - (((uint64_t) rand () & 0x7FFFu) << 45u) | - (((uint64_t) rand () & 0x0003u) << 60u); -} - -uint32_t -_mongoc_rand_uint32_t (uint32_t min, uint32_t max, uint32_t (*rand) (void)) -{ - BSON_ASSERT (min <= max); - BSON_ASSERT (min != 0u || max != UINT32_MAX); - - return _mongoc_rand_nduid32 (max - min + 1u, rand) + min; -} - -uint64_t -_mongoc_rand_uint64_t (uint64_t min, uint64_t max, uint64_t (*rand) (void)) -{ - BSON_ASSERT (min <= max); - BSON_ASSERT (min != 0u || max != UINT64_MAX); - - return _mongoc_rand_java64 (max - min + 1u, rand) + min; -} - -#if SIZE_MAX == UINT64_MAX - -BSON_STATIC_ASSERT2 (_mongoc_simple_rand_size_t, - sizeof (size_t) == sizeof (uint64_t)); - -size_t -_mongoc_simple_rand_size_t (void) -{ - return (size_t) _mongoc_simple_rand_uint64_t (); -} - -size_t -_mongoc_rand_size_t (size_t min, size_t max, size_t (*rand) (void)) -{ - BSON_ASSERT (min <= max); - BSON_ASSERT (min != 0u || max != UINT64_MAX); - - return _mongoc_rand_java64 (max - min + 1u, (uint64_t (*) (void)) rand) + - min; -} - -#elif SIZE_MAX == UINT32_MAX - -BSON_STATIC_ASSERT2 (_mongoc_simple_rand_size_t, - sizeof (size_t) == sizeof (uint32_t)); - -size_t -_mongoc_simple_rand_size_t (void) -{ - return (size_t) _mongoc_simple_rand_uint32_t (); -} - -size_t -_mongoc_rand_size_t (size_t min, size_t max, size_t (*rand) (void)) -{ - BSON_ASSERT (min <= max); - BSON_ASSERT (min != 0u || max != UINT32_MAX); - - return _mongoc_rand_nduid32 (max - min + 1u, (uint32_t (*) (void)) rand) + - min; -} - -#else - -#error \ - "Implementation of _mongoc_simple_rand_size_t() requires size_t be exactly 32-bit or 64-bit" - -#endif - -bool -_mongoc_iter_document_as_bson (const bson_iter_t *iter, - bson_t *bson, - bson_error_t *error) -{ - uint32_t len; - const uint8_t *data; - - if (!BSON_ITER_HOLDS_DOCUMENT (iter)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "expected BSON document for field: %s", - bson_iter_key (iter)); - return false; - } - - bson_iter_document (iter, &len, &data); - if (!bson_init_static (bson, data, len)) { - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "unable to initialize BSON document from field: %s", - bson_iter_key (iter)); - return false; - } - - return true; -} - -uint8_t * -hex_to_bin (const char *hex, uint32_t *len) -{ - uint8_t *out; - - const size_t hex_len = strlen (hex); - if (hex_len % 2u != 0u) { - return NULL; - } - - BSON_ASSERT (bson_in_range_unsigned (uint32_t, hex_len / 2u)); - - *len = (uint32_t) (hex_len / 2u); - out = bson_malloc0 (*len); - - for (uint32_t i = 0; i < hex_len; i += 2u) { - uint32_t hex_char; - - if (1 != sscanf (hex + i, "%2x", &hex_char)) { - bson_free (out); - return NULL; - } - - BSON_ASSERT (bson_in_range_unsigned (uint8_t, hex_char)); - out[i / 2u] = (uint8_t) hex_char; - } - return out; -} - -char * -bin_to_hex (const uint8_t *bin, uint32_t len) -{ - char *out = bson_malloc0 (2u * len + 1u); - - for (uint32_t i = 0u; i < len; i++) { - bson_snprintf (out + (2u * i), 3, "%02x", bin[i]); - } - - return out; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-write-command.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-write-command.c deleted file mode 100644 index 83c71179c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-write-command.c +++ /dev/null @@ -1,1352 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "mongoc-client-private.h" -#include "mongoc-client-session-private.h" -#include "mongoc-client-side-encryption-private.h" -#include "mongoc-error.h" -#include "mongoc-error-private.h" -#include "mongoc-trace-private.h" -#include "mongoc-write-command-private.h" -#include "mongoc-write-concern-private.h" -#include "mongoc-util-private.h" -#include "mongoc-opts-private.h" - - -/* indexed by MONGOC_WRITE_COMMAND_DELETE, INSERT, UPDATE */ -static const char *gCommandNames[] = {"delete", "insert", "update"}; -static const char *gCommandFields[] = {"deletes", "documents", "updates"}; -static const uint32_t gCommandFieldLens[] = {7, 9, 7}; - - -void -_mongoc_write_command_insert_append (mongoc_write_command_t *command, - const bson_t *document) -{ - bson_iter_t iter; - bson_oid_t oid; - bson_t tmp; - - ENTRY; - - BSON_ASSERT (command); - BSON_ASSERT (command->type == MONGOC_WRITE_COMMAND_INSERT); - BSON_ASSERT (document); - BSON_ASSERT (document->len >= 5); - - /* - * If the document does not contain an "_id" field, we need to generate - * a new oid for "_id". - */ - if (!bson_iter_init_find (&iter, document, "_id")) { - bson_init (&tmp); - bson_oid_init (&oid, NULL); - BSON_APPEND_OID (&tmp, "_id", &oid); - bson_concat (&tmp, document); - _mongoc_buffer_append (&command->payload, bson_get_data (&tmp), tmp.len); - bson_destroy (&tmp); - } else { - _mongoc_buffer_append ( - &command->payload, bson_get_data (document), document->len); - } - - command->n_documents++; - - EXIT; -} - -void -_mongoc_write_command_update_append (mongoc_write_command_t *command, - const bson_t *selector, - const bson_t *update, - const bson_t *opts) -{ - bson_t document; - - ENTRY; - - BSON_ASSERT (command); - BSON_ASSERT (command->type == MONGOC_WRITE_COMMAND_UPDATE); - BSON_ASSERT (selector && update); - - bson_init (&document); - BSON_APPEND_DOCUMENT (&document, "q", selector); - if (_mongoc_document_is_pipeline (update)) { - BSON_APPEND_ARRAY (&document, "u", update); - } else { - BSON_APPEND_DOCUMENT (&document, "u", update); - } - if (opts) { - bson_concat (&document, opts); - } - - _mongoc_buffer_append ( - &command->payload, bson_get_data (&document), document.len); - command->n_documents++; - - bson_destroy (&document); - - EXIT; -} - -void -_mongoc_write_command_delete_append (mongoc_write_command_t *command, - const bson_t *selector, - const bson_t *opts) -{ - bson_t document; - - ENTRY; - - BSON_ASSERT (command); - BSON_ASSERT (command->type == MONGOC_WRITE_COMMAND_DELETE); - BSON_ASSERT (selector); - - BSON_ASSERT (selector->len >= 5); - - bson_init (&document); - BSON_APPEND_DOCUMENT (&document, "q", selector); - if (opts) { - bson_concat (&document, opts); - } - - _mongoc_buffer_append ( - &command->payload, bson_get_data (&document), document.len); - command->n_documents++; - - bson_destroy (&document); - - EXIT; -} - -static void -_mongoc_write_command_init_bulk (mongoc_write_command_t *command, - int type, - mongoc_bulk_write_flags_t flags, - int64_t operation_id, - const bson_t *opts) -{ - ENTRY; - - BSON_ASSERT (command); - - command->type = type; - command->flags = flags; - command->operation_id = operation_id; - if (!bson_empty0 (opts)) { - bson_copy_to (opts, &command->cmd_opts); - } else { - bson_init (&command->cmd_opts); - } - - _mongoc_buffer_init (&command->payload, NULL, 0, NULL, NULL); - command->n_documents = 0; - - EXIT; -} - - -void -_mongoc_write_command_init_insert (mongoc_write_command_t *command, /* IN */ - const bson_t *document, /* IN */ - const bson_t *cmd_opts, /* IN */ - mongoc_bulk_write_flags_t flags, /* IN */ - int64_t operation_id) /* IN */ -{ - ENTRY; - - BSON_ASSERT (command); - - _mongoc_write_command_init_bulk ( - command, MONGOC_WRITE_COMMAND_INSERT, flags, operation_id, cmd_opts); - - /* must handle NULL document from mongoc_collection_insert_bulk */ - if (document) { - _mongoc_write_command_insert_append (command, document); - } - - EXIT; -} - - -void -_mongoc_write_command_init_insert_idl (mongoc_write_command_t *command, - const bson_t *document, - const bson_t *cmd_opts, - int64_t operation_id) -{ - mongoc_bulk_write_flags_t flags = MONGOC_BULK_WRITE_FLAGS_INIT; - - ENTRY; - - BSON_ASSERT (command); - - _mongoc_write_command_init_bulk ( - command, MONGOC_WRITE_COMMAND_INSERT, flags, operation_id, cmd_opts); - - /* must handle NULL document from mongoc_collection_insert_bulk */ - if (document) { - _mongoc_write_command_insert_append (command, document); - } - - EXIT; -} - - -void -_mongoc_write_command_init_delete (mongoc_write_command_t *command, /* IN */ - const bson_t *selector, /* IN */ - const bson_t *cmd_opts, /* IN */ - const bson_t *opts, /* IN */ - mongoc_bulk_write_flags_t flags, /* IN */ - int64_t operation_id) /* IN */ -{ - ENTRY; - - BSON_ASSERT (command); - BSON_ASSERT (selector); - - _mongoc_write_command_init_bulk ( - command, MONGOC_WRITE_COMMAND_DELETE, flags, operation_id, cmd_opts); - _mongoc_write_command_delete_append (command, selector, opts); - - EXIT; -} - - -void -_mongoc_write_command_init_delete_idl (mongoc_write_command_t *command, - const bson_t *selector, - const bson_t *cmd_opts, - const bson_t *opts, - int64_t operation_id) -{ - mongoc_bulk_write_flags_t flags = MONGOC_BULK_WRITE_FLAGS_INIT; - - ENTRY; - - BSON_ASSERT (command); - BSON_ASSERT (selector); - - _mongoc_write_command_init_bulk ( - command, MONGOC_WRITE_COMMAND_DELETE, flags, operation_id, cmd_opts); - - _mongoc_write_command_delete_append (command, selector, opts); - - EXIT; -} - - -void -_mongoc_write_command_init_update (mongoc_write_command_t *command, /* IN */ - const bson_t *selector, /* IN */ - const bson_t *update, /* IN */ - const bson_t *cmd_opts, /* IN */ - const bson_t *opts, /* IN */ - mongoc_bulk_write_flags_t flags, /* IN */ - int64_t operation_id) /* IN */ -{ - ENTRY; - - BSON_ASSERT (command); - BSON_ASSERT (selector); - BSON_ASSERT (update); - - _mongoc_write_command_init_bulk ( - command, MONGOC_WRITE_COMMAND_UPDATE, flags, operation_id, cmd_opts); - _mongoc_write_command_update_append (command, selector, update, opts); - - EXIT; -} - - -void -_mongoc_write_command_init_update_idl (mongoc_write_command_t *command, - const bson_t *selector, - const bson_t *update, - const bson_t *cmd_opts, - const bson_t *opts, - int64_t operation_id) -{ - mongoc_bulk_write_flags_t flags = MONGOC_BULK_WRITE_FLAGS_INIT; - - ENTRY; - - BSON_ASSERT (command); - - _mongoc_write_command_init_bulk ( - command, MONGOC_WRITE_COMMAND_UPDATE, flags, operation_id, cmd_opts); - _mongoc_write_command_update_append (command, selector, update, opts); - - EXIT; -} - - -/* takes initialized bson_t *doc and begins formatting a write command */ -void -_mongoc_write_command_init (bson_t *doc, - mongoc_write_command_t *command, - const char *collection) -{ - ENTRY; - - if (!command->n_documents) { - EXIT; - } - - BSON_APPEND_UTF8 (doc, gCommandNames[command->type], collection); - BSON_APPEND_BOOL (doc, "ordered", command->flags.ordered); - - if (command->flags.bypass_document_validation) { - BSON_APPEND_BOOL (doc, - "bypassDocumentValidation", - command->flags.bypass_document_validation); - } - - EXIT; -} - - -/* - *------------------------------------------------------------------------- - * - * _mongoc_write_command_too_large_error -- - * - * Fill a bson_error_t and optional bson_t with error info after - * receiving a document for bulk insert, update, or remove that is - * larger than max_bson_size. - * - * "err_doc" should be NULL or an empty initialized bson_t. - * - * Returns: - * None. - * - * Side effects: - * "error" and optionally "err_doc" are filled out. - * - *------------------------------------------------------------------------- - */ - -static void -_mongoc_write_command_too_large_error (bson_error_t *error, - int32_t idx, - int32_t len, - int32_t max_bson_size) -{ - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Document %u is too large for the cluster. " - "Document is %u bytes, max is %d.", - idx, - len, - max_bson_size); -} - - -static void -_empty_error (mongoc_write_command_t *command, bson_error_t *error) -{ - static const uint32_t codes[] = {MONGOC_ERROR_COLLECTION_DELETE_FAILED, - MONGOC_ERROR_COLLECTION_INSERT_FAILED, - MONGOC_ERROR_COLLECTION_UPDATE_FAILED}; - - bson_set_error (error, - MONGOC_ERROR_COLLECTION, - codes[command->type], - "Cannot do an empty %s", - gCommandNames[command->type]); -} - - -static int32_t -_mongoc_write_result_merge_arrays (uint32_t offset, - mongoc_write_result_t *result, /* IN */ - bson_t *dest, /* IN */ - bson_iter_t *iter) /* IN */ -{ - const bson_value_t *value; - bson_iter_t ar; - bson_iter_t citer; - int32_t idx; - int32_t count = 0; - int32_t aridx; - bson_t child; - const char *keyptr = NULL; - char key[12]; - int len; - - ENTRY; - - BSON_ASSERT (result); - BSON_ASSERT (dest); - BSON_ASSERT (iter); - BSON_ASSERT (BSON_ITER_HOLDS_ARRAY (iter)); - - aridx = bson_count_keys (dest); - - if (bson_iter_recurse (iter, &ar)) { - while (bson_iter_next (&ar)) { - if (BSON_ITER_HOLDS_DOCUMENT (&ar) && - bson_iter_recurse (&ar, &citer)) { - len = - (int) bson_uint32_to_string (aridx++, &keyptr, key, sizeof key); - bson_append_document_begin (dest, keyptr, len, &child); - while (bson_iter_next (&citer)) { - if (BSON_ITER_IS_KEY (&citer, "index")) { - idx = bson_iter_int32 (&citer) + offset; - BSON_APPEND_INT32 (&child, "index", idx); - } else { - value = bson_iter_value (&citer); - BSON_APPEND_VALUE (&child, bson_iter_key (&citer), value); - } - } - bson_append_document_end (dest, &child); - count++; - } - } - } - - RETURN (count); -} - - -static void -_mongoc_write_result_append_upsert (mongoc_write_result_t *result, - int32_t idx, - const bson_value_t *value) -{ - bson_t child; - const char *keyptr = NULL; - char key[12]; - int len; - - BSON_ASSERT (result); - BSON_ASSERT (value); - - len = (int) bson_uint32_to_string ( - result->upsert_append_count, &keyptr, key, sizeof key); - - bson_append_document_begin (&result->upserted, keyptr, len, &child); - BSON_APPEND_INT32 (&child, "index", idx); - BSON_APPEND_VALUE (&child, "_id", value); - bson_append_document_end (&result->upserted, &child); - - result->upsert_append_count++; -} - - -static void -_mongoc_write_result_merge (mongoc_write_result_t *result, /* IN */ - mongoc_write_command_t *command, /* IN */ - const bson_t *reply, /* IN */ - uint32_t offset) -{ - int32_t server_index = 0; - const bson_value_t *value; - bson_iter_t iter; - bson_iter_t citer; - bson_iter_t ar; - int32_t n_upserted = 0; - int32_t affected = 0; - - ENTRY; - - BSON_ASSERT (result); - BSON_ASSERT (reply); - - if (bson_iter_init_find (&iter, reply, "n") && - BSON_ITER_HOLDS_INT32 (&iter)) { - affected = bson_iter_int32 (&iter); - } - - if (bson_iter_init_find (&iter, reply, "writeErrors") && - BSON_ITER_HOLDS_ARRAY (&iter) && bson_iter_recurse (&iter, &citer) && - bson_iter_next (&citer)) { - result->failed = true; - } - - switch (command->type) { - case MONGOC_WRITE_COMMAND_INSERT: - result->nInserted += affected; - break; - case MONGOC_WRITE_COMMAND_DELETE: - result->nRemoved += affected; - break; - case MONGOC_WRITE_COMMAND_UPDATE: - - /* server returns each upserted _id with its index into this batch - * look for "upserted": [{"index": 4, "_id": ObjectId()}, ...] */ - if (bson_iter_init_find (&iter, reply, "upserted")) { - if (BSON_ITER_HOLDS_ARRAY (&iter) && - (bson_iter_recurse (&iter, &ar))) { - while (bson_iter_next (&ar)) { - if (BSON_ITER_HOLDS_DOCUMENT (&ar) && - bson_iter_recurse (&ar, &citer) && - bson_iter_find (&citer, "index") && - BSON_ITER_HOLDS_INT32 (&citer)) { - server_index = bson_iter_int32 (&citer); - - if (bson_iter_recurse (&ar, &citer) && - bson_iter_find (&citer, "_id")) { - value = bson_iter_value (&citer); - _mongoc_write_result_append_upsert ( - result, offset + server_index, value); - n_upserted++; - } - } - } - } - result->nUpserted += n_upserted; - /* - * XXX: The following addition to nMatched needs some checking. - * I'm highly skeptical of it. - */ - result->nMatched += BSON_MAX (0, (affected - n_upserted)); - } else { - result->nMatched += affected; - } - if (bson_iter_init_find (&iter, reply, "nModified") && - BSON_ITER_HOLDS_INT32 (&iter)) { - result->nModified += bson_iter_int32 (&iter); - } - break; - default: - BSON_ASSERT (false); - break; - } - - if (bson_iter_init_find (&iter, reply, "writeErrors") && - BSON_ITER_HOLDS_ARRAY (&iter)) { - _mongoc_write_result_merge_arrays ( - offset, result, &result->writeErrors, &iter); - } - - if (bson_iter_init_find (&iter, reply, "writeConcernError") && - BSON_ITER_HOLDS_DOCUMENT (&iter)) { - uint32_t len; - const uint8_t *data; - bson_t write_concern_error; - char str[16]; - const char *key; - - /* writeConcernError is a subdocument in the server response - * append it to the result->writeConcernErrors array */ - bson_iter_document (&iter, &len, &data); - BSON_ASSERT (bson_init_static (&write_concern_error, data, len)); - - bson_uint32_to_string ( - result->n_writeConcernErrors, &key, str, sizeof str); - - if (!bson_append_document ( - &result->writeConcernErrors, key, -1, &write_concern_error)) { - MONGOC_ERROR ("Error adding \"%s\" to writeConcernErrors.\n", key); - } - - result->n_writeConcernErrors++; - } - - /* If a server error ocurred, then append the raw response to the - * error_replies array. */ - if (!_mongoc_cmd_check_ok ( - reply, MONGOC_ERROR_API_VERSION_2, NULL /* error */)) { - char str[16]; - const char *key; - - bson_uint32_to_string (result->n_errorReplies, &key, str, sizeof str); - - if (!bson_append_document (&result->rawErrorReplies, key, -1, reply)) { - MONGOC_ERROR ("Error adding \"%s\" to errorReplies.\n", key); - } - - result->n_errorReplies++; - } - - /* inefficient if there are ever large numbers: for each label in each err, - * we linear-search result->errorLabels to see if it's included yet */ - _mongoc_bson_array_copy_labels_to (reply, &result->errorLabels); - - EXIT; -} - - -static void -_mongoc_write_opmsg (mongoc_write_command_t *command, - mongoc_client_t *client, - mongoc_server_stream_t *server_stream, - const char *database, - const char *collection, - const mongoc_write_concern_t *write_concern, - uint32_t index_offset, - mongoc_client_session_t *cs, - mongoc_write_result_t *result, - bson_error_t *error) -{ - mongoc_cmd_parts_t parts; - bson_iter_t iter; - bson_t cmd; - bson_t reply; - bool ret = false; - int32_t max_msg_size; - int32_t max_bson_obj_size; - int32_t max_document_count; - uint32_t header; - uint32_t payload_batch_size = 0; - uint32_t payload_total_offset = 0; - bool ship_it = false; - int document_count = 0; - mongoc_server_stream_t *retry_server_stream = NULL; - - ENTRY; - - BSON_ASSERT (command); - BSON_ASSERT_PARAM (client); - BSON_ASSERT (database); - BSON_ASSERT (server_stream); - BSON_ASSERT (collection); - - max_bson_obj_size = mongoc_server_stream_max_bson_obj_size (server_stream); - max_msg_size = mongoc_server_stream_max_msg_size (server_stream); - if (_mongoc_cse_is_enabled (client)) { - max_msg_size = MONGOC_REDUCED_MAX_MSG_SIZE_FOR_FLE; - } - max_document_count = - mongoc_server_stream_max_write_batch_size (server_stream); - - bson_init (&cmd); - _mongoc_write_command_init (&cmd, command, collection); - mongoc_cmd_parts_init (&parts, client, database, MONGOC_QUERY_NONE, &cmd); - parts.assembled.operation_id = command->operation_id; - parts.is_write_command = true; - if (!mongoc_cmd_parts_set_write_concern (&parts, write_concern, error)) { - bson_destroy (&cmd); - mongoc_cmd_parts_cleanup (&parts); - EXIT; - } - - if (parts.assembled.is_acknowledged) { - mongoc_cmd_parts_set_session (&parts, cs); - } - - /* Write commands that include multi-document operations are not retryable. - * Set this explicitly so that mongoc_cmd_parts_assemble does not need to - * inspect the command body later. */ - parts.allow_txn_number = - (command->flags.has_multi_write || !parts.assembled.is_acknowledged) - ? MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_NO - : MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_YES; - - BSON_ASSERT (bson_iter_init (&iter, &command->cmd_opts)); - if (!mongoc_cmd_parts_append_opts (&parts, &iter, error)) { - bson_destroy (&cmd); - mongoc_cmd_parts_cleanup (&parts); - EXIT; - } - - if (!mongoc_cmd_parts_assemble (&parts, server_stream, error)) { - bson_destroy (&cmd); - mongoc_cmd_parts_cleanup (&parts); - EXIT; - } - - /* - * OP_MSG header == 16 byte - * + 4 bytes flagBits - * + 1 byte payload type = 1 - * + 1 byte payload type = 2 - * + 4 byte size of payload - * == 26 bytes opcode overhead - * + X Full command document {insert: "test", writeConcern: {...}} - * + Y command identifier ("documents", "deletes", "updates") ( + \0) - */ - - header = - 26 + parts.assembled.command->len + gCommandFieldLens[command->type] + 1; - - do { - uint32_t ulen; - memcpy (&ulen, - command->payload.data + payload_batch_size + payload_total_offset, - 4); - ulen = BSON_UINT32_FROM_LE (ulen); - - // Although messageLength is an int32, it should never be negative. - BSON_ASSERT (bson_in_range_unsigned (int32_t, ulen)); - const int32_t slen = (int32_t) ulen; - - if (slen > max_bson_obj_size + BSON_OBJECT_ALLOWANCE) { - /* Quit if the document is too large */ - _mongoc_write_command_too_large_error ( - error, index_offset, slen, max_bson_obj_size); - result->failed = true; - break; - - } else if (bson_cmp_less_equal_us (payload_batch_size + header + ulen, - max_msg_size) || - document_count == 0) { - /* The current batch is still under max batch size in bytes */ - payload_batch_size += ulen; - - /* If this document filled the maximum document count */ - if (++document_count == max_document_count) { - ship_it = true; - /* If this document is the last document we have */ - } else if (payload_batch_size + payload_total_offset == - command->payload.len) { - ship_it = true; - } else { - ship_it = false; - } - } else { - ship_it = true; - } - - if (ship_it) { - bool is_retryable = parts.is_retryable_write; - mongoc_write_err_type_t error_type; - - /* Seek past the document offset we have already sent */ - parts.assembled.payload = command->payload.data + payload_total_offset; - /* Only send the documents up to this size */ - parts.assembled.payload_size = payload_batch_size; - parts.assembled.payload_identifier = gCommandFields[command->type]; - - /* increment the transaction number for the first attempt of each - * retryable write command */ - if (is_retryable) { - bson_iter_t txn_number_iter; - BSON_ASSERT (bson_iter_init_find ( - &txn_number_iter, parts.assembled.command, "txnNumber")); - bson_iter_overwrite_int64 ( - &txn_number_iter, - ++parts.assembled.session->server_session->txn_number); - } - - // Store the original error and reply if needed. - struct { - bson_t reply; - bson_error_t error; - bool set; - } original_error = {.reply = {0}, .error = {0}, .set = false}; - - retry: - ret = mongoc_cluster_run_command_monitored ( - &client->cluster, &parts.assembled, &reply, error); - - if (parts.is_retryable_write) { - _mongoc_write_error_handle_labels ( - ret, error, &reply, server_stream->sd); - } - - /* Add this batch size so we skip these documents next time */ - payload_total_offset += payload_batch_size; - payload_batch_size = 0; - - /* If a retryable error is encountered and the write is retryable, - * select a new writable stream and retry. If server selection fails or - * the selected server does not support retryable writes, fall through - * and allow the original error to be reported. */ - error_type = _mongoc_write_error_get_type (&reply); - if (is_retryable) { - _mongoc_write_error_update_if_unsupported_storage_engine ( - ret, error, &reply); - } - if (is_retryable && error_type == MONGOC_WRITE_ERR_RETRY) { - bson_error_t ignored_error; - - /* each write command may be retried at most once */ - is_retryable = false; - - { - mongoc_deprioritized_servers_t *const ds = - mongoc_deprioritized_servers_new (); - - if (retry_server_stream) { - mongoc_deprioritized_servers_add_if_sharded ( - ds, - retry_server_stream->topology_type, - retry_server_stream->sd); - mongoc_server_stream_cleanup (retry_server_stream); - } else { - mongoc_deprioritized_servers_add_if_sharded ( - ds, server_stream->topology_type, server_stream->sd); - } - - retry_server_stream = mongoc_cluster_stream_for_writes ( - &client->cluster, cs, ds, NULL, &ignored_error); - - mongoc_deprioritized_servers_destroy (ds); - } - - if (retry_server_stream) { - parts.assembled.server_stream = retry_server_stream; - { - // Store the original error and reply before retry. - BSON_ASSERT (!original_error.set); // Retry only happens once. - original_error.set = true; - bson_copy_to (&reply, &original_error.reply); - if (error) { - original_error.error = *error; - } - } - bson_destroy (&reply); - GOTO (retry); - } - } - - if (!ret) { - result->failed = true; - /* Stop for ordered bulk writes or when the server stream has been - * properly invalidated (e.g., due to a network error). */ - if (command->flags.ordered || !mongoc_cluster_stream_valid ( - &client->cluster, server_stream)) { - result->must_stop = true; - } - } - - // If a retry attempt fails with an error labeled NoWritesPerformed, - // drivers MUST return the original error. - if (original_error.set && - mongoc_error_has_label (&reply, "NoWritesPerformed")) { - if (error) { - *error = original_error.error; - } - bson_destroy (&reply); - bson_copy_to (&original_error.reply, &reply); - } - - /* Result merge needs to know the absolute index for a document - * so it can rewrite the error message which contains the relative - * document index per batch - */ - _mongoc_write_result_merge (result, command, &reply, index_offset); - index_offset += document_count; - document_count = 0; - bson_destroy (&reply); - if (original_error.set) { - bson_destroy (&original_error.reply); - } - } - /* While we have more documents to write */ - } while (payload_total_offset < command->payload.len && !result->must_stop); - - bson_destroy (&cmd); - mongoc_cmd_parts_cleanup (&parts); - - if (retry_server_stream) { - if (ret) { - /* if a retry succeeded, report that in the result so bulk write can - * use the newly selected server. */ - result->retry_server_id = - mongoc_server_description_id (retry_server_stream->sd); - } - mongoc_server_stream_cleanup (retry_server_stream); - } - - if (ret) { - /* if a retry succeeded, clear the initial error */ - memset (&result->error, 0, sizeof (bson_error_t)); - } - - EXIT; -} - - -void -_mongoc_write_command_execute ( - mongoc_write_command_t *command, /* IN */ - mongoc_client_t *client, /* IN */ - mongoc_server_stream_t *server_stream, /* IN */ - const char *database, /* IN */ - const char *collection, /* IN */ - const mongoc_write_concern_t *write_concern, /* IN */ - uint32_t offset, /* IN */ - mongoc_client_session_t *cs, /* IN */ - mongoc_write_result_t *result) /* OUT */ -{ - mongoc_crud_opts_t crud = {0}; - - ENTRY; - - BSON_ASSERT (command); - BSON_ASSERT_PARAM (client); - BSON_ASSERT (server_stream); - BSON_ASSERT (database); - BSON_ASSERT (collection); - BSON_ASSERT (result); - - if (!write_concern) { - write_concern = client->write_concern; - } - - if (!mongoc_write_concern_is_valid (write_concern)) { - bson_set_error (&result->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The write concern is invalid."); - result->failed = true; - EXIT; - } - - crud.client_session = cs; - crud.writeConcern = (mongoc_write_concern_t *) write_concern; - - _mongoc_write_command_execute_idl (command, - client, - server_stream, - database, - collection, - offset, - &crud, - result); - EXIT; -} - -void -_mongoc_write_command_execute_idl (mongoc_write_command_t *command, - mongoc_client_t *client, - mongoc_server_stream_t *server_stream, - const char *database, - const char *collection, - uint32_t offset, - const mongoc_crud_opts_t *crud, - mongoc_write_result_t *result) -{ - ENTRY; - - BSON_ASSERT (command); - BSON_ASSERT_PARAM (client); - BSON_ASSERT (server_stream); - BSON_ASSERT (database); - BSON_ASSERT (collection); - BSON_ASSERT (result); - - if (command->flags.has_collation) { - if (!mongoc_write_concern_is_acknowledged (crud->writeConcern)) { - result->failed = true; - bson_set_error (&result->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot set collation for unacknowledged writes"); - EXIT; - } - } - - if (command->flags.has_array_filters) { - if (!mongoc_write_concern_is_acknowledged (crud->writeConcern)) { - result->failed = true; - bson_set_error (&result->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot use array filters with unacknowledged writes"); - EXIT; - } - } - - if (command->flags.has_update_hint) { - if (server_stream->sd->max_wire_version < WIRE_VERSION_UPDATE_HINT && - !mongoc_write_concern_is_acknowledged (crud->writeConcern)) { - bson_set_error ( - &result->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "The selected server does not support hint for update"); - result->failed = true; - EXIT; - } - } - - if (command->flags.has_delete_hint) { - if (server_stream->sd->max_wire_version < WIRE_VERSION_DELETE_HINT && - !mongoc_write_concern_is_acknowledged (crud->writeConcern)) { - bson_set_error ( - &result->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "The selected server does not support hint for delete"); - result->failed = true; - EXIT; - } - } - - if (command->flags.bypass_document_validation) { - if (!mongoc_write_concern_is_acknowledged (crud->writeConcern)) { - result->failed = true; - bson_set_error ( - &result->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot set bypassDocumentValidation for unacknowledged writes"); - EXIT; - } - } - - if (crud->client_session && - !mongoc_write_concern_is_acknowledged (crud->writeConcern)) { - result->failed = true; - bson_set_error (&result->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot use client session with unacknowledged writes"); - EXIT; - } - - if (command->payload.len == 0) { - _empty_error (command, &result->error); - EXIT; - } - - _mongoc_write_opmsg (command, - client, - server_stream, - database, - collection, - crud->writeConcern, - offset, - crud->client_session, - result, - &result->error); - - EXIT; -} - - -void -_mongoc_write_command_destroy (mongoc_write_command_t *command) -{ - ENTRY; - - if (command) { - bson_destroy (&command->cmd_opts); - _mongoc_buffer_destroy (&command->payload); - } - - EXIT; -} - - -void -_mongoc_write_result_init (mongoc_write_result_t *result) /* IN */ -{ - ENTRY; - - BSON_ASSERT (result); - - memset (result, 0, sizeof *result); - - bson_init (&result->upserted); - bson_init (&result->writeConcernErrors); - bson_init (&result->writeErrors); - bson_init (&result->errorLabels); - bson_init (&result->rawErrorReplies); - - EXIT; -} - - -void -_mongoc_write_result_destroy (mongoc_write_result_t *result) -{ - ENTRY; - - BSON_ASSERT (result); - - bson_destroy (&result->upserted); - bson_destroy (&result->writeConcernErrors); - bson_destroy (&result->writeErrors); - bson_destroy (&result->errorLabels); - bson_destroy (&result->rawErrorReplies); - - EXIT; -} - - -/* - * If error is not set, set code from first document in array like - * [{"code": 64, "errmsg": "duplicate"}, ...]. Format the error message - * from all errors in array. - */ -static void -_set_error_from_response (bson_t *bson_array, - mongoc_error_domain_t domain, - const char *error_type, - bson_error_t *error /* OUT */) -{ - bson_iter_t array_iter; - bson_iter_t doc_iter; - bson_string_t *compound_err; - const char *errmsg = NULL; - int32_t code = 0; - uint32_t n_keys, i; - - compound_err = bson_string_new (NULL); - n_keys = bson_count_keys (bson_array); - if (n_keys > 1) { - bson_string_append_printf ( - compound_err, "Multiple %s errors: ", error_type); - } - - if (!bson_empty0 (bson_array) && bson_iter_init (&array_iter, bson_array)) { - /* get first code and all error messages */ - i = 0; - - while (bson_iter_next (&array_iter)) { - if (BSON_ITER_HOLDS_DOCUMENT (&array_iter) && - bson_iter_recurse (&array_iter, &doc_iter)) { - /* parse doc, which is like {"code": 64, "errmsg": "duplicate"} */ - while (bson_iter_next (&doc_iter)) { - /* use the first error code we find */ - if (BSON_ITER_IS_KEY (&doc_iter, "code") && code == 0) { - code = (uint32_t) bson_iter_as_int64 (&doc_iter); - } else if (BSON_ITER_IS_KEY (&doc_iter, "errmsg")) { - errmsg = bson_iter_utf8 (&doc_iter, NULL); - - /* build message like 'Multiple write errors: "foo", "bar"' */ - if (n_keys > 1) { - bson_string_append_printf (compound_err, "\"%s\"", errmsg); - if (i < n_keys - 1) { - bson_string_append (compound_err, ", "); - } - } else { - /* single error message */ - bson_string_append (compound_err, errmsg); - } - } - } - - i++; - } - } - - if (code && compound_err->len) { - bson_set_error ( - error, domain, (uint32_t) code, "%s", compound_err->str); - } - } - - bson_string_free (compound_err, true); -} - - -/* complete a write result, including only certain fields */ -bool -_mongoc_write_result_complete ( - mongoc_write_result_t *result, /* IN */ - int32_t error_api_version, /* IN */ - const mongoc_write_concern_t *wc, /* IN */ - mongoc_error_domain_t err_domain_override, /* IN */ - bson_t *bson, /* OUT */ - bson_error_t *error, /* OUT */ - ...) -{ - mongoc_error_domain_t domain; - va_list args; - const char *field; - int n_args; - bson_iter_t iter; - bson_iter_t child; - - ENTRY; - - BSON_ASSERT (result); - - if (error_api_version >= MONGOC_ERROR_API_VERSION_2) { - domain = MONGOC_ERROR_SERVER; - } else if (err_domain_override) { - domain = err_domain_override; - } else if (result->error.domain) { - domain = (mongoc_error_domain_t) result->error.domain; - } else { - domain = MONGOC_ERROR_COLLECTION; - } - - /* produce either old fields like nModified from the deprecated Bulk API Spec - * or new fields like modifiedCount from the CRUD Spec, which we partly obey - */ - - if (bson && mongoc_write_concern_is_acknowledged (wc)) { - n_args = 0; - va_start (args, error); - while ((field = va_arg (args, const char *))) { - n_args++; - - if (!strcmp (field, "nInserted")) { - BSON_APPEND_INT32 (bson, field, result->nInserted); - } else if (!strcmp (field, "insertedCount")) { - BSON_APPEND_INT32 (bson, field, result->nInserted); - } else if (!strcmp (field, "nMatched")) { - BSON_APPEND_INT32 (bson, field, result->nMatched); - } else if (!strcmp (field, "matchedCount")) { - BSON_APPEND_INT32 (bson, field, result->nMatched); - } else if (!strcmp (field, "nModified")) { - BSON_APPEND_INT32 (bson, field, result->nModified); - } else if (!strcmp (field, "modifiedCount")) { - BSON_APPEND_INT32 (bson, field, result->nModified); - } else if (!strcmp (field, "nRemoved")) { - BSON_APPEND_INT32 (bson, field, result->nRemoved); - } else if (!strcmp (field, "deletedCount")) { - BSON_APPEND_INT32 (bson, field, result->nRemoved); - } else if (!strcmp (field, "nUpserted")) { - BSON_APPEND_INT32 (bson, field, result->nUpserted); - } else if (!strcmp (field, "upsertedCount")) { - BSON_APPEND_INT32 (bson, field, result->nUpserted); - } else if (!strcmp (field, "upserted") && - !bson_empty0 (&result->upserted)) { - BSON_APPEND_ARRAY (bson, field, &result->upserted); - } else if (!strcmp (field, "upsertedId") && - !bson_empty0 (&result->upserted) && - bson_iter_init_find (&iter, &result->upserted, "0") && - bson_iter_recurse (&iter, &child) && - bson_iter_find (&child, "_id")) { - /* "upsertedId", singular, for update_one() */ - BSON_APPEND_VALUE (bson, "upsertedId", bson_iter_value (&child)); - } - } - - va_end (args); - - /* default: a standard result includes all Bulk API fields */ - if (!n_args) { - BSON_APPEND_INT32 (bson, "nInserted", result->nInserted); - BSON_APPEND_INT32 (bson, "nMatched", result->nMatched); - BSON_APPEND_INT32 (bson, "nModified", result->nModified); - BSON_APPEND_INT32 (bson, "nRemoved", result->nRemoved); - BSON_APPEND_INT32 (bson, "nUpserted", result->nUpserted); - if (!bson_empty0 (&result->upserted)) { - BSON_APPEND_ARRAY (bson, "upserted", &result->upserted); - } - } - - /* always append errors if there are any */ - if (!n_args || !bson_empty (&result->writeErrors)) { - BSON_APPEND_ARRAY (bson, "writeErrors", &result->writeErrors); - } - - if (result->n_writeConcernErrors) { - BSON_APPEND_ARRAY ( - bson, "writeConcernErrors", &result->writeConcernErrors); - } - } - - /* If there is a raw error response then we know a server error has occurred. - * We should add the raw result to the reply. */ - if (bson && !bson_empty (&result->rawErrorReplies)) { - BSON_APPEND_ARRAY (bson, "errorReplies", &result->rawErrorReplies); - } - - /* set bson_error_t from first write error or write concern error */ - _set_error_from_response ( - &result->writeErrors, domain, "write", &result->error); - - if (!result->error.code) { - _set_error_from_response (&result->writeConcernErrors, - MONGOC_ERROR_WRITE_CONCERN, - "write concern", - &result->error); - } - - if (bson && !bson_empty (&result->errorLabels)) { - BSON_APPEND_ARRAY (bson, "errorLabels", &result->errorLabels); - } - - if (error) { - memcpy (error, &result->error, sizeof *error); - } - - RETURN (!result->failed && result->error.code == 0); -} - - -/*-------------------------------------------------------------------------- - * - * _mongoc_write_error_get_type -- - * - * Checks if the error or reply from a write command is considered - * retryable according to the retryable writes spec. Checks both - * for a client error (a network exception) and a server error in - * the reply. @cmd_ret and @cmd_err come from the result of a - * write_command function. This function should be called after - * error labels are appended in _mongoc_write_error_handle_labels, - * which should be called after mongoc_cluster_run_command_monitored. - * - * - * Return: - * A mongoc_write_error_type_t indicating the type of error (if any). - * - *-------------------------------------------------------------------------- - */ -mongoc_write_err_type_t -_mongoc_write_error_get_type (bson_t *reply) -{ - bson_error_t error; - - if (mongoc_error_has_label (reply, RETRYABLE_WRITE_ERROR)) { - return MONGOC_WRITE_ERR_RETRY; - } - - /* check for a server error. */ - if (_mongoc_cmd_check_ok_no_wce ( - reply, MONGOC_ERROR_API_VERSION_2, &error)) { - return MONGOC_WRITE_ERR_NONE; - } - - switch (error.code) { - case 64: /* WriteConcernFailed */ - return MONGOC_WRITE_ERR_WRITE_CONCERN; - default: - return MONGOC_WRITE_ERR_OTHER; - } -} - -/* Returns true and modifies reply and cmd_err. */ -bool -_mongoc_write_error_update_if_unsupported_storage_engine (bool cmd_ret, - bson_error_t *cmd_err, - bson_t *reply) -{ - bson_error_t server_error; - - if (cmd_ret) { - return false; - } - - if (_mongoc_cmd_check_ok_no_wce ( - reply, MONGOC_ERROR_API_VERSION_2, &server_error)) { - return false; - } - - if (server_error.code == 20 && - strstr (server_error.message, "Transaction numbers") == - server_error.message) { - const char *replacement = "This MongoDB deployment does not support " - "retryable writes. Please add " - "retryWrites=false to your connection string."; - - strcpy (cmd_err->message, replacement); - - if (reply) { - bson_t *new_reply = bson_new (); - bson_copy_to_excluding_noinit (reply, new_reply, "errmsg", NULL); - BSON_APPEND_UTF8 (new_reply, "errmsg", replacement); - bson_destroy (reply); - bson_steal (reply, new_reply); - } - return true; - } - return false; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-write-concern.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-write-concern.h deleted file mode 100644 index 7961361ea..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc-write-concern.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc-prelude.h" - -#ifndef MONGOC_WRITE_CONCERN_H -#define MONGOC_WRITE_CONCERN_H - -#include - -#include "mongoc-macros.h" - -BSON_BEGIN_DECLS - - -#define MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED 0 -#define MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED -1 /* deprecated */ -#define MONGOC_WRITE_CONCERN_W_DEFAULT -2 -#define MONGOC_WRITE_CONCERN_W_MAJORITY -3 -#define MONGOC_WRITE_CONCERN_W_TAG -4 - - -typedef struct _mongoc_write_concern_t mongoc_write_concern_t; - - -MONGOC_EXPORT (mongoc_write_concern_t *) -mongoc_write_concern_new (void) BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (mongoc_write_concern_t *) -mongoc_write_concern_copy (const mongoc_write_concern_t *write_concern) - BSON_GNUC_WARN_UNUSED_RESULT; -MONGOC_EXPORT (void) -mongoc_write_concern_destroy (mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (bool) -mongoc_write_concern_get_fsync (const mongoc_write_concern_t *write_concern) - BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (void) -mongoc_write_concern_set_fsync (mongoc_write_concern_t *write_concern, - bool fsync_) BSON_GNUC_DEPRECATED; -MONGOC_EXPORT (bool) -mongoc_write_concern_get_journal (const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (bool) -mongoc_write_concern_journal_is_set ( - const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (void) -mongoc_write_concern_set_journal (mongoc_write_concern_t *write_concern, - bool journal); -MONGOC_EXPORT (int32_t) -mongoc_write_concern_get_w (const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (void) -mongoc_write_concern_set_w (mongoc_write_concern_t *write_concern, int32_t w); -MONGOC_EXPORT (const char *) -mongoc_write_concern_get_wtag (const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (void) -mongoc_write_concern_set_wtag (mongoc_write_concern_t *write_concern, - const char *tag); -MONGOC_EXPORT (int32_t) -mongoc_write_concern_get_wtimeout (const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (int64_t) -mongoc_write_concern_get_wtimeout_int64 ( - const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (void) -mongoc_write_concern_set_wtimeout (mongoc_write_concern_t *write_concern, - int32_t wtimeout_msec); -MONGOC_EXPORT (void) -mongoc_write_concern_set_wtimeout_int64 (mongoc_write_concern_t *write_concern, - int64_t wtimeout_msec); -MONGOC_EXPORT (bool) -mongoc_write_concern_get_wmajority ( - const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (void) -mongoc_write_concern_set_wmajority (mongoc_write_concern_t *write_concern, - int32_t wtimeout_msec); -MONGOC_EXPORT (bool) -mongoc_write_concern_is_acknowledged ( - const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (bool) -mongoc_write_concern_is_valid (const mongoc_write_concern_t *write_concern); -MONGOC_EXPORT (bool) -mongoc_write_concern_append (mongoc_write_concern_t *write_concern, - bson_t *doc); -MONGOC_EXPORT (bool) -mongoc_write_concern_is_default (const mongoc_write_concern_t *write_concern); - -BSON_END_DECLS - - -#endif /* MONGOC_WRITE_CONCERN_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc.h deleted file mode 100644 index a43304cec..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/mongoc.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2013 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef MONGOC_H -#define MONGOC_H - - -#include - -#define MONGOC_INSIDE -#include "mongoc-macros.h" -#include "mongoc-apm.h" -#include "mongoc-bulk-operation.h" -#include "mongoc-change-stream.h" -#include "mongoc-client.h" -#include "mongoc-client-pool.h" -#include "mongoc-client-side-encryption.h" -#include "mongoc-collection.h" -#include "mongoc-config.h" -#include "mongoc-cursor.h" -#include "mongoc-database.h" -#include "mongoc-index.h" -#include "mongoc-error.h" -#include "mongoc-flags.h" -#include "mongoc-gridfs.h" -#include "mongoc-gridfs-bucket.h" -#include "mongoc-gridfs-file.h" -#include "mongoc-gridfs-file-list.h" -#include "mongoc-gridfs-file-page.h" -#include "mongoc-host-list.h" -#include "mongoc-init.h" -#include "mongoc-matcher.h" -#include "mongoc-handshake.h" -#include "mongoc-opcode.h" -#include "mongoc-log.h" -#include "mongoc-sleep.h" -#include "mongoc-socket.h" -#include "mongoc-client-session.h" -#include "mongoc-stream.h" -#include "mongoc-stream-buffered.h" -#include "mongoc-stream-file.h" -#include "mongoc-stream-gridfs.h" -#include "mongoc-stream-socket.h" -#include "mongoc-uri.h" -#include "mongoc-write-concern.h" -#include "mongoc-version.h" -#include "mongoc-version-functions.h" -#ifdef MONGOC_ENABLE_SSL -#include "mongoc-rand.h" -#include "mongoc-stream-tls.h" -#include "mongoc-ssl.h" -#endif -#undef MONGOC_INSIDE - - -#endif /* MONGOC_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/service-gcp.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/service-gcp.c deleted file mode 100644 index d709610eb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/service-gcp.c +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Copyright 2022 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "./service-gcp.h" - -#include "mongoc-util-private.h" - -#define HOST "metadata.google.internal" - -static const char *const DEFAULT_METADATA_PATH = - "/computeMetadata/v1/instance/service-accounts/default/token"; - -void -gcp_request_init (gcp_request *req, - const char *const opt_host, - int opt_port, - const char *const opt_extra_headers) -{ - BSON_ASSERT_PARAM (req); - _mongoc_http_request_init (&req->req); - - // The HTTP host of the Google metadata server - req->req.host = req->_owned_host = bson_strdup (opt_host ? opt_host : HOST); - - if (opt_port) { - req->req.port = opt_port; - } else { - req->req.port = 80; - } - - // Empty body - req->req.body = ""; - // We GET - req->req.method = "GET"; - - req->req.extra_headers = req->_owned_headers = - bson_strdup_printf ("Metadata-Flavor: Google\r\n%s", - opt_extra_headers ? opt_extra_headers : ""); - - req->req.path = req->_owned_path = bson_strdup (DEFAULT_METADATA_PATH); -} - -void -gcp_request_destroy (gcp_request *req) -{ - BSON_ASSERT_PARAM (req); - bson_free (req->_owned_headers); - bson_free (req->_owned_host); - bson_free (req->_owned_path); - *req = (gcp_request){ - .req = {0}, - ._owned_path = NULL, - ._owned_host = NULL, - ._owned_headers = NULL, - }; -} - -void -gcp_access_token_destroy (gcp_service_account_token *token) -{ - bson_free (token->access_token); - bson_free (token->token_type); - token->access_token = NULL; - token->token_type = NULL; -} - -bool -gcp_access_token_try_parse_from_json (gcp_service_account_token *out, - const char *json, - int len, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (out); - BSON_ASSERT_PARAM (json); - bool okay = false; - - // Zero the output - *out = (gcp_service_account_token){0}; - - // Parse the JSON data - bson_t bson; - if (!bson_init_from_json (&bson, json, len, error)) { - return false; - } - - bson_iter_t iter; - // access_token - bool found = bson_iter_init_find (&iter, &bson, "access_token"); - const char *const access_token = - !found ? NULL : bson_iter_utf8 (&iter, NULL); - // token_type - found = bson_iter_init_find (&iter, &bson, "token_type"); - const char *const token_type = !found ? NULL : bson_iter_utf8 (&iter, NULL); - - if (!(access_token && token_type)) { - bson_set_error (error, - MONGOC_ERROR_GCP, - MONGOC_ERROR_KMS_SERVER_BAD_JSON, - "One or more required JSON properties are " - "missing/invalid: data: %.*s", - len, - json); - goto done; - } - - *out = (gcp_service_account_token){ - .access_token = bson_strdup (access_token), - .token_type = bson_strdup (token_type), - }; - okay = true; - -done: - bson_destroy (&bson); - return okay; -} - -bool -gcp_access_token_from_gcp_server (gcp_service_account_token *out, - const char *opt_host, - int opt_port, - const char *opt_extra_headers, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (out); - bool okay = false; - - // Clear the output - *out = (gcp_service_account_token){0}; - - mongoc_http_response_t resp; - _mongoc_http_response_init (&resp); - - gcp_request req = { - .req = {0}, - ._owned_path = NULL, - ._owned_host = NULL, - ._owned_headers = NULL, - }; - gcp_request_init (&req, opt_host, opt_port, opt_extra_headers); - - if (!_mongoc_http_send (&req.req, 3 * 1000, false, NULL, &resp, error)) { - goto fail; - } - - // Only accept an HTTP 200 as success - if (resp.status != 200) { - bson_set_error (error, - MONGOC_ERROR_GCP, - MONGOC_ERROR_KMS_SERVER_HTTP, - "Error from the GCP metadata server while looking for " - "access token: %.*s", - resp.body_len, - resp.body); - goto fail; - } - - if (!gcp_access_token_try_parse_from_json ( - out, resp.body, resp.body_len, error)) { - goto fail; - } - - okay = true; - -fail: - gcp_request_destroy (&req); - _mongoc_http_response_cleanup (&resp); - return okay; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/utlist.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/utlist.h deleted file mode 100644 index ee2d25e95..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/src/mongoc/utlist.h +++ /dev/null @@ -1,841 +0,0 @@ -/* -Copyright (c) 2007-2014, Troy D. Hanson http://troydhanson.github.com/uthash/ -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "mongoc-prelude.h" - -#ifndef UTLIST_H -#define UTLIST_H - -#define UTLIST_VERSION 1.9.9 - -/* - * This file contains macros to manipulate singly and doubly-linked lists. - * - * 1. LL_ macros: singly-linked lists. - * 2. DL_ macros: doubly-linked lists. - * 3. CDL_ macros: circular doubly-linked lists. - * - * To use singly-linked lists, your structure must have a "next" pointer. - * To use doubly-linked lists, your structure must "prev" and "next" pointers. - * Either way, the pointer to the head of the list must be initialized to NULL. - * - * ----------------.EXAMPLE ------------------------- - * struct item { - * int id; - * struct item *prev, *next; - * } - * - * struct item *list = NULL: - * - * int main() { - * struct item *item; - * ... allocate and populate item ... - * DL_APPEND(list, item); - * } - * -------------------------------------------------- - * - * For doubly-linked lists, the append and delete macros are O(1) - * For singly-linked lists, append and delete are O(n) but prepend is O(1) - * The sort macro is O(n log(n)) for all types of single/double/circular lists. - */ - -/* These macros use decltype or the earlier __typeof GNU extension. - As decltype is only available in newer compilers (VS2010 or gcc 4.3+ - when compiling c++ code), this code uses whatever method is needed - or, for VS2008 where neither is available, uses casting workarounds. */ -#ifdef _MSC_VER /* MS compiler */ -#if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ -#define LDECLTYPE(x) decltype (x) -#else /* VS2008 or older (or VS2010 in C mode) */ -#define NO_DECLTYPE -#define LDECLTYPE(x) char * -#endif -#elif defined(__ICCARM__) -#define NO_DECLTYPE -#define LDECLTYPE(x) char * -#else /* GNU, Sun and other compilers */ -#define LDECLTYPE(x) __typeof(x) -#endif - -/* for VS2008 we use some workarounds to get around the lack of decltype, - * namely, we always reassign our tmp variable to the list head if we need - * to dereference its prev/next pointers, and save/restore the real head.*/ -#ifdef NO_DECLTYPE -#define _SV(elt, list) \ - _tmp = (char *) (list); \ - { \ - char **_alias = (char **) &(list); \ - *_alias = (elt); \ - } -#define _NEXT(elt, list, next) ((char *) ((list)->next)) -#define _NEXTASGN(elt, list, to, next) \ - { \ - char **_alias = (char **) &((list)->next); \ - *_alias = (char *) (to); \ - } -/* #define _PREV(elt,list,prev) ((char*)((list)->prev)) */ -#define _PREVASGN(elt, list, to, prev) \ - { \ - char **_alias = (char **) &((list)->prev); \ - *_alias = (char *) (to); \ - } -#define _RS(list) \ - { \ - char **_alias = (char **) &(list); \ - *_alias = _tmp; \ - } -#define _CASTASGN(a, b) \ - { \ - char **_alias = (char **) &(a); \ - *_alias = (char *) (b); \ - } -#else -#define _SV(elt, list) -#define _NEXT(elt, list, next) ((elt)->next) -#define _NEXTASGN(elt, list, to, next) ((elt)->next) = (to) -/* #define _PREV(elt,list,prev) ((elt)->prev) */ -#define _PREVASGN(elt, list, to, prev) ((elt)->prev) = (to) -#define _RS(list) -#define _CASTASGN(a, b) (a) = (b) -#endif - -/****************************************************************************** - * The sort macro is an adaptation of Simon Tatham's O(n log(n)) mergesort * - * Unwieldy variable names used here to avoid shadowing passed-in variables. * - *****************************************************************************/ -#define LL_SORT(list, cmp) LL_SORT2 (list, cmp, next) - -#define LL_SORT2(list, cmp, next) \ - do { \ - LDECLTYPE (list) _ls_p; \ - LDECLTYPE (list) _ls_q; \ - LDECLTYPE (list) _ls_e; \ - LDECLTYPE (list) _ls_tail; \ - int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ - if (list) { \ - _ls_insize = 1; \ - _ls_looping = 1; \ - while (_ls_looping) { \ - _CASTASGN (_ls_p, list); \ - list = NULL; \ - _ls_tail = NULL; \ - _ls_nmerges = 0; \ - while (_ls_p) { \ - _ls_nmerges++; \ - _ls_q = _ls_p; \ - _ls_psize = 0; \ - for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ - _ls_psize++; \ - _SV (_ls_q, list); \ - _ls_q = _NEXT (_ls_q, list, next); \ - _RS (list); \ - if (!_ls_q) \ - break; \ - } \ - _ls_qsize = _ls_insize; \ - while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ - if (_ls_psize == 0) { \ - _ls_e = _ls_q; \ - _SV (_ls_q, list); \ - _ls_q = _NEXT (_ls_q, list, next); \ - _RS (list); \ - _ls_qsize--; \ - } else if (_ls_qsize == 0 || !_ls_q) { \ - _ls_e = _ls_p; \ - _SV (_ls_p, list); \ - _ls_p = _NEXT (_ls_p, list, next); \ - _RS (list); \ - _ls_psize--; \ - } else if (cmp (_ls_p, _ls_q) <= 0) { \ - _ls_e = _ls_p; \ - _SV (_ls_p, list); \ - _ls_p = _NEXT (_ls_p, list, next); \ - _RS (list); \ - _ls_psize--; \ - } else { \ - _ls_e = _ls_q; \ - _SV (_ls_q, list); \ - _ls_q = _NEXT (_ls_q, list, next); \ - _RS (list); \ - _ls_qsize--; \ - } \ - if (_ls_tail) { \ - _SV (_ls_tail, list); \ - _NEXTASGN (_ls_tail, list, _ls_e, next); \ - _RS (list); \ - } else { \ - _CASTASGN (list, _ls_e); \ - } \ - _ls_tail = _ls_e; \ - } \ - _ls_p = _ls_q; \ - } \ - if (_ls_tail) { \ - _SV (_ls_tail, list); \ - _NEXTASGN (_ls_tail, list, NULL, next); \ - _RS (list); \ - } \ - if (_ls_nmerges <= 1) { \ - _ls_looping = 0; \ - } \ - _ls_insize *= 2; \ - } \ - } \ - } while (0) - - -#define DL_SORT(list, cmp) DL_SORT2 (list, cmp, prev, next) - -#define DL_SORT2(list, cmp, prev, next) \ - do { \ - LDECLTYPE (list) _ls_p; \ - LDECLTYPE (list) _ls_q; \ - LDECLTYPE (list) _ls_e; \ - LDECLTYPE (list) _ls_tail; \ - int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ - if (list) { \ - _ls_insize = 1; \ - _ls_looping = 1; \ - while (_ls_looping) { \ - _CASTASGN (_ls_p, list); \ - list = NULL; \ - _ls_tail = NULL; \ - _ls_nmerges = 0; \ - while (_ls_p) { \ - _ls_nmerges++; \ - _ls_q = _ls_p; \ - _ls_psize = 0; \ - for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ - _ls_psize++; \ - _SV (_ls_q, list); \ - _ls_q = _NEXT (_ls_q, list, next); \ - _RS (list); \ - if (!_ls_q) \ - break; \ - } \ - _ls_qsize = _ls_insize; \ - while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ - if (_ls_psize == 0) { \ - _ls_e = _ls_q; \ - _SV (_ls_q, list); \ - _ls_q = _NEXT (_ls_q, list, next); \ - _RS (list); \ - _ls_qsize--; \ - } else if (_ls_qsize == 0 || !_ls_q) { \ - _ls_e = _ls_p; \ - _SV (_ls_p, list); \ - _ls_p = _NEXT (_ls_p, list, next); \ - _RS (list); \ - _ls_psize--; \ - } else if (cmp (_ls_p, _ls_q) <= 0) { \ - _ls_e = _ls_p; \ - _SV (_ls_p, list); \ - _ls_p = _NEXT (_ls_p, list, next); \ - _RS (list); \ - _ls_psize--; \ - } else { \ - _ls_e = _ls_q; \ - _SV (_ls_q, list); \ - _ls_q = _NEXT (_ls_q, list, next); \ - _RS (list); \ - _ls_qsize--; \ - } \ - if (_ls_tail) { \ - _SV (_ls_tail, list); \ - _NEXTASGN (_ls_tail, list, _ls_e, next); \ - _RS (list); \ - } else { \ - _CASTASGN (list, _ls_e); \ - } \ - _SV (_ls_e, list); \ - _PREVASGN (_ls_e, list, _ls_tail, prev); \ - _RS (list); \ - _ls_tail = _ls_e; \ - } \ - _ls_p = _ls_q; \ - } \ - _CASTASGN (list->prev, _ls_tail); \ - _SV (_ls_tail, list); \ - _NEXTASGN (_ls_tail, list, NULL, next); \ - _RS (list); \ - if (_ls_nmerges <= 1) { \ - _ls_looping = 0; \ - } \ - _ls_insize *= 2; \ - } \ - } \ - } while (0) - -#define CDL_SORT(list, cmp) CDL_SORT2 (list, cmp, prev, next) - -#define CDL_SORT2(list, cmp, prev, next) \ - do { \ - LDECLTYPE (list) _ls_p; \ - LDECLTYPE (list) _ls_q; \ - LDECLTYPE (list) _ls_e; \ - LDECLTYPE (list) _ls_tail; \ - LDECLTYPE (list) _ls_oldhead; \ - LDECLTYPE (list) _tmp; \ - int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ - if (list) { \ - _ls_insize = 1; \ - _ls_looping = 1; \ - while (_ls_looping) { \ - _CASTASGN (_ls_p, list); \ - _CASTASGN (_ls_oldhead, list); \ - list = NULL; \ - _ls_tail = NULL; \ - _ls_nmerges = 0; \ - while (_ls_p) { \ - _ls_nmerges++; \ - _ls_q = _ls_p; \ - _ls_psize = 0; \ - for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ - _ls_psize++; \ - _SV (_ls_q, list); \ - if (_NEXT (_ls_q, list, next) == _ls_oldhead) { \ - _ls_q = NULL; \ - } else { \ - _ls_q = _NEXT (_ls_q, list, next); \ - } \ - _RS (list); \ - if (!_ls_q) \ - break; \ - } \ - _ls_qsize = _ls_insize; \ - while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ - if (_ls_psize == 0) { \ - _ls_e = _ls_q; \ - _SV (_ls_q, list); \ - _ls_q = _NEXT (_ls_q, list, next); \ - _RS (list); \ - _ls_qsize--; \ - if (_ls_q == _ls_oldhead) { \ - _ls_q = NULL; \ - } \ - } else if (_ls_qsize == 0 || !_ls_q) { \ - _ls_e = _ls_p; \ - _SV (_ls_p, list); \ - _ls_p = _NEXT (_ls_p, list, next); \ - _RS (list); \ - _ls_psize--; \ - if (_ls_p == _ls_oldhead) { \ - _ls_p = NULL; \ - } \ - } else if (cmp (_ls_p, _ls_q) <= 0) { \ - _ls_e = _ls_p; \ - _SV (_ls_p, list); \ - _ls_p = _NEXT (_ls_p, list, next); \ - _RS (list); \ - _ls_psize--; \ - if (_ls_p == _ls_oldhead) { \ - _ls_p = NULL; \ - } \ - } else { \ - _ls_e = _ls_q; \ - _SV (_ls_q, list); \ - _ls_q = _NEXT (_ls_q, list, next); \ - _RS (list); \ - _ls_qsize--; \ - if (_ls_q == _ls_oldhead) { \ - _ls_q = NULL; \ - } \ - } \ - if (_ls_tail) { \ - _SV (_ls_tail, list); \ - _NEXTASGN (_ls_tail, list, _ls_e, next); \ - _RS (list); \ - } else { \ - _CASTASGN (list, _ls_e); \ - } \ - _SV (_ls_e, list); \ - _PREVASGN (_ls_e, list, _ls_tail, prev); \ - _RS (list); \ - _ls_tail = _ls_e; \ - } \ - _ls_p = _ls_q; \ - } \ - _CASTASGN (list->prev, _ls_tail); \ - _CASTASGN (_tmp, list); \ - _SV (_ls_tail, list); \ - _NEXTASGN (_ls_tail, list, _tmp, next); \ - _RS (list); \ - if (_ls_nmerges <= 1) { \ - _ls_looping = 0; \ - } \ - _ls_insize *= 2; \ - } \ - } \ - } while (0) - -/****************************************************************************** - * singly linked list macros (non-circular) * - *****************************************************************************/ -#define LL_PREPEND(head, add) LL_PREPEND2 (head, add, next) - -#define LL_PREPEND2(head, add, next) \ - do { \ - (add)->next = head; \ - head = add; \ - } while (0) - -#define LL_CONCAT(head1, head2) LL_CONCAT2 (head1, head2, next) - -#define LL_CONCAT2(head1, head2, next) \ - do { \ - LDECLTYPE (head1) _tmp; \ - if (head1) { \ - _tmp = head1; \ - while (_tmp->next) { \ - _tmp = _tmp->next; \ - } \ - _tmp->next = (head2); \ - } else { \ - (head1) = (head2); \ - } \ - } while (0) - -#define LL_APPEND(head, add) LL_APPEND2 (head, add, next) - -#define LL_APPEND2(head, add, next) \ - do { \ - LDECLTYPE (head) _tmp; \ - (add)->next = NULL; \ - if (head) { \ - _tmp = head; \ - while (_tmp->next) { \ - _tmp = _tmp->next; \ - } \ - _tmp->next = (add); \ - } else { \ - (head) = (add); \ - } \ - } while (0) - -#define LL_DELETE(head, del) LL_DELETE2 (head, del, next) - -#define LL_DELETE2(head, del, next) \ - do { \ - LDECLTYPE (head) _tmp; \ - if ((head) == (del)) { \ - (head) = (head)->next; \ - } else { \ - _tmp = head; \ - while (_tmp->next && (_tmp->next != (del))) { \ - _tmp = _tmp->next; \ - } \ - if (_tmp->next) { \ - _tmp->next = ((del)->next); \ - } \ - } \ - } while (0) - -/* Here are VS2008 replacements for LL_APPEND and LL_DELETE */ -#define LL_APPEND_VS2008(head, add) LL_APPEND2_VS2008 (head, add, next) - -#define LL_APPEND2_VS2008(head, add, next) \ - do { \ - if (head) { \ - (add)->next = head; /* use add->next as a temp variable */ \ - while ((add)->next->next) { \ - (add)->next = (add)->next->next; \ - } \ - (add)->next->next = (add); \ - } else { \ - (head) = (add); \ - } \ - (add)->next = NULL; \ - } while (0) - -#define LL_DELETE_VS2008(head, del) LL_DELETE2_VS2008 (head, del, next) - -#define LL_DELETE2_VS2008(head, del, next) \ - do { \ - if ((head) == (del)) { \ - (head) = (head)->next; \ - } else { \ - char *_tmp = (char *) (head); \ - while ((head)->next && ((head)->next != (del))) { \ - head = (head)->next; \ - } \ - if ((head)->next) { \ - (head)->next = ((del)->next); \ - } \ - { \ - char **_head_alias = (char **) &(head); \ - *_head_alias = _tmp; \ - } \ - } \ - } while (0) -#ifdef NO_DECLTYPE -#undef LL_APPEND -#define LL_APPEND LL_APPEND_VS2008 -#undef LL_DELETE -#define LL_DELETE LL_DELETE_VS2008 -#undef LL_DELETE2 -#define LL_DELETE2 LL_DELETE2_VS2008 -#undef LL_APPEND2 -#define LL_APPEND2 LL_APPEND2_VS2008 -#undef LL_CONCAT /* no LL_CONCAT_VS2008 */ -#undef DL_CONCAT /* no DL_CONCAT_VS2008 */ -#endif -/* end VS2008 replacements */ - -#define LL_COUNT(head, el, counter) LL_COUNT2 (head, el, counter, next) - -#define LL_COUNT2(head, el, counter, next) \ - { \ - counter = 0; \ - LL_FOREACH2 (head, el, next) \ - { \ - ++counter; \ - } \ - } - -#define LL_FOREACH(head, el) LL_FOREACH2 (head, el, next) - -#define LL_FOREACH2(head, el, next) for (el = head; el; el = (el)->next) - -#define LL_FOREACH_SAFE(head, el, tmp) LL_FOREACH_SAFE2 (head, el, tmp, next) - -#define LL_FOREACH_SAFE2(head, el, tmp, next) \ - for ((el) = (head); (el) && (tmp = (el)->next, 1); (el) = tmp) - -#define LL_SEARCH_SCALAR(head, out, field, val) \ - LL_SEARCH_SCALAR2 (head, out, field, val, next) - -#define LL_SEARCH_SCALAR2(head, out, field, val, next) \ - do { \ - LL_FOREACH2 (head, out, next) \ - { \ - if ((out)->field == (val)) \ - break; \ - } \ - } while (0) - -#define LL_SEARCH(head, out, elt, cmp) LL_SEARCH2 (head, out, elt, cmp, next) - -#define LL_SEARCH2(head, out, elt, cmp, next) \ - do { \ - LL_FOREACH2 (head, out, next) \ - { \ - if ((cmp (out, elt)) == 0) \ - break; \ - } \ - } while (0) - -#define LL_REPLACE_ELEM(head, el, add) \ - do { \ - LDECLTYPE (head) _tmp; \ - BSON_ASSERT (head != NULL); \ - BSON_ASSERT (el != NULL); \ - BSON_ASSERT (add != NULL); \ - (add)->next = (el)->next; \ - if ((head) == (el)) { \ - (head) = (add); \ - } else { \ - _tmp = head; \ - while (_tmp->next && (_tmp->next != (el))) { \ - _tmp = _tmp->next; \ - } \ - if (_tmp->next) { \ - _tmp->next = (add); \ - } \ - } \ - } while (0) - -#define LL_PREPEND_ELEM(head, el, add) \ - do { \ - LDECLTYPE (head) _tmp; \ - BSON_ASSERT (head != NULL); \ - BSON_ASSERT (el != NULL); \ - BSON_ASSERT (add != NULL); \ - (add)->next = (el); \ - if ((head) == (el)) { \ - (head) = (add); \ - } else { \ - _tmp = head; \ - while (_tmp->next && (_tmp->next != (el))) { \ - _tmp = _tmp->next; \ - } \ - if (_tmp->next) { \ - _tmp->next = (add); \ - } \ - } \ - } while (0) - - -/****************************************************************************** - * doubly linked list macros (non-circular) * - *****************************************************************************/ -#define DL_PREPEND(head, add) DL_PREPEND2 (head, add, prev, next) - -#define DL_PREPEND2(head, add, prev, next) \ - do { \ - (add)->next = head; \ - if (head) { \ - (add)->prev = (head)->prev; \ - (head)->prev = (add); \ - } else { \ - (add)->prev = (add); \ - } \ - (head) = (add); \ - } while (0) - -#define DL_APPEND(head, add) DL_APPEND2 (head, add, prev, next) - -#define DL_APPEND2(head, add, prev, next) \ - do { \ - if (head) { \ - (add)->prev = (head)->prev; \ - (head)->prev->next = (add); \ - (head)->prev = (add); \ - (add)->next = NULL; \ - } else { \ - (head) = (add); \ - (head)->prev = (head); \ - (head)->next = NULL; \ - } \ - } while (0) - -#define DL_CONCAT(head1, head2) DL_CONCAT2 (head1, head2, prev, next) - -#define DL_CONCAT2(head1, head2, prev, next) \ - do { \ - LDECLTYPE (head1) _tmp; \ - if (head2) { \ - if (head1) { \ - _tmp = (head2)->prev; \ - (head2)->prev = (head1)->prev; \ - (head1)->prev->next = (head2); \ - (head1)->prev = _tmp; \ - } else { \ - (head1) = (head2); \ - } \ - } \ - } while (0) - -#define DL_DELETE(head, del) DL_DELETE2 (head, del, prev, next) - -#define DL_DELETE2(head, del, prev, next) \ - do { \ - BSON_ASSERT ((del)->prev != NULL); \ - if ((del)->prev == (del)) { \ - (head) = NULL; \ - } else if ((del) == (head)) { \ - (del)->next->prev = (del)->prev; \ - (head) = (del)->next; \ - } else { \ - (del)->prev->next = (del)->next; \ - if ((del)->next) { \ - (del)->next->prev = (del)->prev; \ - } else { \ - (head)->prev = (del)->prev; \ - } \ - } \ - } while (0) - -#define DL_COUNT(head, el, counter) DL_COUNT2 (head, el, counter, next) - -#define DL_COUNT2(head, el, counter, next) \ - { \ - counter = 0; \ - DL_FOREACH2 (head, el, next) \ - { \ - ++counter; \ - } \ - } - -#define DL_FOREACH(head, el) DL_FOREACH2 (head, el, next) - -#define DL_FOREACH2(head, el, next) for (el = head; el; el = (el)->next) - -/* this version is safe for deleting the elements during iteration */ -#define DL_FOREACH_SAFE(head, el, tmp) DL_FOREACH_SAFE2 (head, el, tmp, next) - -#define DL_FOREACH_SAFE2(head, el, tmp, next) \ - for ((el) = (head); (el) && (tmp = (el)->next, 1); (el) = tmp) - -/* these are identical to their singly-linked list counterparts */ -#define DL_SEARCH_SCALAR LL_SEARCH_SCALAR -#define DL_SEARCH LL_SEARCH -#define DL_SEARCH_SCALAR2 LL_SEARCH_SCALAR2 -#define DL_SEARCH2 LL_SEARCH2 - -#define DL_REPLACE_ELEM(head, el, add) \ - do { \ - BSON_ASSERT (head != NULL); \ - BSON_ASSERT (el != NULL); \ - BSON_ASSERT (add != NULL); \ - if ((head) == (el)) { \ - (head) = (add); \ - (add)->next = (el)->next; \ - if ((el)->next == NULL) { \ - (add)->prev = (add); \ - } else { \ - (add)->prev = (el)->prev; \ - (add)->next->prev = (add); \ - } \ - } else { \ - (add)->next = (el)->next; \ - (add)->prev = (el)->prev; \ - (add)->prev->next = (add); \ - if ((el)->next == NULL) { \ - (head)->prev = (add); \ - } else { \ - (add)->next->prev = (add); \ - } \ - } \ - } while (0) - -#define DL_PREPEND_ELEM(head, el, add) \ - do { \ - BSON_ASSERT (head != NULL); \ - BSON_ASSERT (el != NULL); \ - BSON_ASSERT (add != NULL); \ - (add)->next = (el); \ - (add)->prev = (el)->prev; \ - (el)->prev = (add); \ - if ((head) == (el)) { \ - (head) = (add); \ - } else { \ - (add)->prev->next = (add); \ - } \ - } while (0) - - -/****************************************************************************** - * circular doubly linked list macros * - *****************************************************************************/ -#define CDL_PREPEND(head, add) CDL_PREPEND2 (head, add, prev, next) - -#define CDL_PREPEND2(head, add, prev, next) \ - do { \ - if (head) { \ - (add)->prev = (head)->prev; \ - (add)->next = (head); \ - (head)->prev = (add); \ - (add)->prev->next = (add); \ - } else { \ - (add)->prev = (add); \ - (add)->next = (add); \ - } \ - (head) = (add); \ - } while (0) - -#define CDL_DELETE(head, del) CDL_DELETE2 (head, del, prev, next) - -#define CDL_DELETE2(head, del, prev, next) \ - do { \ - if (((head) == (del)) && ((head)->next == (head))) { \ - (head) = 0L; \ - } else { \ - (del)->next->prev = (del)->prev; \ - (del)->prev->next = (del)->next; \ - if ((del) == (head)) \ - (head) = (del)->next; \ - } \ - } while (0) - -#define CDL_COUNT(head, el, counter) CDL_COUNT2 (head, el, counter, next) - -#define CDL_COUNT2(head, el, counter, next) \ - { \ - counter = 0; \ - CDL_FOREACH2 (head, el, next) \ - { \ - ++counter; \ - } \ - } - -#define CDL_FOREACH(head, el) CDL_FOREACH2 (head, el, next) - -#define CDL_FOREACH2(head, el, next) \ - for (el = head; el; el = ((el)->next == head ? 0L : (el)->next)) - -#define CDL_FOREACH_SAFE(head, el, tmp1, tmp2) \ - CDL_FOREACH_SAFE2 (head, el, tmp1, tmp2, prev, next) - -#define CDL_FOREACH_SAFE2(head, el, tmp1, tmp2, prev, next) \ - for ((el) = (head), ((tmp1) = (head) ? ((head)->prev) : NULL); \ - (el) && ((tmp2) = (el)->next, 1); \ - ((el) = (((el) == (tmp1)) ? 0L : (tmp2)))) - -#define CDL_SEARCH_SCALAR(head, out, field, val) \ - CDL_SEARCH_SCALAR2 (head, out, field, val, next) - -#define CDL_SEARCH_SCALAR2(head, out, field, val, next) \ - do { \ - CDL_FOREACH2 (head, out, next) \ - { \ - if ((out)->field == (val)) \ - break; \ - } \ - } while (0) - -#define CDL_SEARCH(head, out, elt, cmp) CDL_SEARCH2 (head, out, elt, cmp, next) - -#define CDL_SEARCH2(head, out, elt, cmp, next) \ - do { \ - CDL_FOREACH2 (head, out, next) \ - { \ - if ((cmp (out, elt)) == 0) \ - break; \ - } \ - } while (0) - -#define CDL_REPLACE_ELEM(head, el, add) \ - do { \ - BSON_ASSERT (head != NULL); \ - BSON_ASSERT (el != NULL); \ - BSON_ASSERT (add != NULL); \ - if ((el)->next == (el)) { \ - (add)->next = (add); \ - (add)->prev = (add); \ - (head) = (add); \ - } else { \ - (add)->next = (el)->next; \ - (add)->prev = (el)->prev; \ - (add)->next->prev = (add); \ - (add)->prev->next = (add); \ - if ((head) == (el)) { \ - (head) = (add); \ - } \ - } \ - } while (0) - -#define CDL_PREPEND_ELEM(head, el, add) \ - do { \ - BSON_ASSERT (head != NULL); \ - BSON_ASSERT (el != NULL); \ - BSON_ASSERT (add != NULL); \ - (add)->next = (el); \ - (add)->prev = (el)->prev; \ - (el)->prev = (add); \ - (add)->prev->next = (add); \ - if ((head) == (el)) { \ - (head) = (add); \ - } \ - } while (0) - -#endif /* UTLIST_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/TestSuite.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/TestSuite.c deleted file mode 100644 index e691accc8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/TestSuite.c +++ /dev/null @@ -1,1279 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include -#include - -#include "mongoc/mongoc-thread-private.h" - -#include -#include -#include -#include -#include -#if !defined(_WIN32) -#include -#include -#include -#include -#include -#include - -#else -#include -#endif - -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "TestSuite.h" - -#define SKIP_LINE_BUFFER_SIZE 1024 - -static bson_once_t once = BSON_ONCE_INIT; -static bson_mutex_t gTestMutex; -static TestSuite *gTestSuite; - - -MONGOC_PRINTF_FORMAT (1, 2) -static void -test_msg (const char *format, ...) -{ - va_list ap; - - va_start (ap, format); - vprintf (format, ap); - printf ("\n"); - va_end (ap); - fflush (stdout); -} - - -void -_test_error (const char *format, ...) -{ - va_list ap; - - fflush (stdout); - va_start (ap, format); - vfprintf (stderr, format, ap); - fprintf (stderr, "\n"); - va_end (ap); - fflush (stderr); - abort (); -} - -static void -TestSuite_SeedRand (TestSuite *suite, /* IN */ - Test *test) /* IN */ -{ - BSON_UNUSED (suite); - -#ifndef BSON_OS_WIN32 - int fd = open ("/dev/urandom", O_RDONLY); - int n_read; - unsigned seed; - if (fd != -1) { - n_read = read (fd, &seed, 4); - BSON_ASSERT (n_read == 4); - close (fd); - test->seed = seed; - return; - } else { - test->seed = (unsigned) time (NULL) * (unsigned) getpid (); - } -#else - test->seed = (unsigned) time (NULL); -#endif -} - - -static BSON_ONCE_FUN (_test_suite_ensure_mutex_once) -{ - bson_mutex_init (&gTestMutex); - - BSON_ONCE_RETURN; -} - - -void -TestSuite_Init (TestSuite *suite, const char *name, int argc, char **argv) -{ - const char *filename; - int i; - char *mock_server_log; - - memset (suite, 0, sizeof *suite); - - suite->name = bson_strdup (name); - suite->flags = 0; - suite->prgname = bson_strdup (argv[0]); - suite->silent = false; - suite->ctest_run = NULL; - _mongoc_array_init (&suite->match_patterns, sizeof (char *)); - _mongoc_array_init (&suite->failing_flaky_skips, sizeof (TestSkip *)); - - for (i = 1; i < argc; i++) { - if (0 == strcmp ("-d", argv[i])) { - suite->flags |= TEST_DEBUGOUTPUT; - } else if ((0 == strcmp ("-f", argv[i])) || - (0 == strcmp ("--no-fork", argv[i]))) { - suite->flags |= TEST_NOFORK; - } else if ((0 == strcmp ("-t", argv[i])) || - (0 == strcmp ("--trace", argv[i]))) { - if (!MONGOC_TRACE_ENABLED) { - test_error ( - "-t requires mongoc compiled with -DENABLE_TRACING=ON."); - } - suite->flags |= TEST_TRACE; - } else if (0 == strcmp ("-F", argv[i])) { - if (argc - 1 == i) { - test_error ("-F requires a filename argument."); - } - filename = argv[++i]; - if (0 != strcmp ("-", filename)) { -#ifdef _WIN32 - if (0 != fopen_s (&suite->outfile, filename, "w")) { - suite->outfile = NULL; - } -#else - suite->outfile = fopen (filename, "w"); -#endif - if (!suite->outfile) { - test_error ("Failed to open log file: %s", filename); - } - } - } else if ((0 == strcmp ("-h", argv[i])) || - (0 == strcmp ("--help", argv[i]))) { - suite->flags |= TEST_HELPTEXT; - } else if (0 == strcmp ("--list-tests", argv[i])) { - suite->flags |= TEST_LISTTESTS; - } else if ((0 == strcmp ("-s", argv[i])) || - (0 == strcmp ("--silent", argv[i]))) { - suite->silent = true; - } else if ((0 == strcmp ("--ctest-run", argv[i]))) { - if (suite->ctest_run) { - test_error ("'--ctest-run' can only be specified once"); - } - if (argc - 1 == i) { - test_error ("'--ctest-run' requires an argument"); - } - suite->flags |= TEST_NOFORK; - suite->silent = true; - suite->ctest_run = bson_strdup (argv[++i]); - } else if ((0 == strcmp ("-l", argv[i])) || - (0 == strcmp ("--match", argv[i]))) { - char *val; - if (argc - 1 == i) { - test_error ("%s requires an argument.", argv[i]); - } - val = bson_strdup (argv[++i]); - _mongoc_array_append_val (&suite->match_patterns, val); - } else if (0 == strcmp ("--skip-tests", argv[i])) { - if (argc - 1 == i) { - test_error ("%s requires an argument.", argv[i]); - } - filename = argv[++i]; - _process_skip_file (filename, &suite->failing_flaky_skips); - } else { - test_error ("Unknown option: %s\n" - "Try using the --help option.", - argv[i]); - } - } - - if (suite->match_patterns.len != 0 && suite->ctest_run != NULL) { - test_error ("'--ctest-run' cannot be specified with '-l' or '--match'"); - } - - mock_server_log = test_framework_getenv ("MONGOC_TEST_SERVER_LOG"); - if (mock_server_log) { - if (!strcmp (mock_server_log, "stdout")) { - suite->mock_server_log = stdout; - } else if (!strcmp (mock_server_log, "stderr")) { - suite->mock_server_log = stderr; - } else if (!strcmp (mock_server_log, "json")) { - suite->mock_server_log_buf = bson_string_new (NULL); - } else { - test_error ("Unrecognized option: MONGOC_TEST_SERVER_LOG=%s", - mock_server_log); - } - - bson_free (mock_server_log); - } - - if (suite->silent) { - if (suite->outfile) { - test_error ("Cannot combine -F with --silent"); - } - - suite->flags &= ~(TEST_DEBUGOUTPUT); - } - - bson_once (&once, &_test_suite_ensure_mutex_once); - bson_mutex_lock (&gTestMutex); - gTestSuite = suite; - bson_mutex_unlock (&gTestMutex); -} - - -int -TestSuite_CheckLive (void) -{ - return test_framework_getenv_bool ("MONGOC_TEST_SKIP_LIVE") ? 0 : 1; -} - -static int -TestSuite_CheckDummy (void) -{ - return 1; -} - -int -TestSuite_CheckMockServerAllowed (void) -{ - if (test_framework_getenv_bool ("MONGOC_TEST_SKIP_MOCK")) { - return 0; - } - return 1; -} - -static void -TestSuite_AddHelper (void *ctx) -{ - TestFunc cb = (TestFunc) ((TestFnCtx *) ctx)->test_fn; - - cb (); -} - -void -TestSuite_Add (TestSuite *suite, /* IN */ - const char *name, /* IN */ - TestFunc func) /* IN */ -{ - TestSuite_AddFullWithTestFn ( - suite, name, TestSuite_AddHelper, NULL, func, TestSuite_CheckDummy); -} - - -void -TestSuite_AddLive (TestSuite *suite, /* IN */ - const char *name, /* IN */ - TestFunc func) /* IN */ -{ - TestSuite_AddFullWithTestFn ( - suite, name, TestSuite_AddHelper, NULL, func, TestSuite_CheckLive); -} - - -static void -_TestSuite_AddCheck (Test *test, CheckFunc check, const char *name) -{ - test->checks[test->num_checks] = check; - if (++test->num_checks > MAX_TEST_CHECK_FUNCS) { - MONGOC_STDERR_PRINTF ( - "Too many check funcs for %s, increase MAX_TEST_CHECK_FUNCS " - "to more than %d\n", - name, - MAX_TEST_CHECK_FUNCS); - abort (); - } -} - - -Test * -_V_TestSuite_AddFull (TestSuite *suite, - const char *name, - TestFuncWC func, - TestFuncDtor dtor, - void *ctx, - va_list ap) -{ - CheckFunc check; - Test *test; - Test *iter; - - if (suite->ctest_run && (0 != strcmp (suite->ctest_run, name))) { - if (dtor) { - dtor (ctx); - } - return NULL; - } - - test = (Test *) bson_malloc0 (sizeof *test); - test->name = bson_strdup (name); - test->func = func; - test->num_checks = 0; - - while ((check = va_arg (ap, CheckFunc))) { - _TestSuite_AddCheck (test, check, name); - } - - test->next = NULL; - test->dtor = dtor; - test->ctx = ctx; - TestSuite_SeedRand (suite, test); - - if (!suite->tests) { - suite->tests = test; - return test; - } - - for (iter = suite->tests; iter->next; iter = iter->next) { - } - - iter->next = test; - return test; -} - - -void -_TestSuite_AddMockServerTest (TestSuite *suite, - const char *name, - TestFunc func, - ...) -{ - Test *test; - va_list ap; - - va_start (ap, func); - test = _V_TestSuite_AddFull (suite, name, (TestFuncWC) func, NULL, NULL, ap); - va_end (ap); - - if (test) { - _TestSuite_AddCheck (test, TestSuite_CheckMockServerAllowed, name); - } -} - - -void -TestSuite_AddWC (TestSuite *suite, /* IN */ - const char *name, /* IN */ - TestFuncWC func, /* IN */ - TestFuncDtor dtor, /* IN */ - void *ctx) /* IN */ -{ - TestSuite_AddFull (suite, name, func, dtor, ctx, TestSuite_CheckDummy); -} - - -void -_TestSuite_AddFull (TestSuite *suite, /* IN */ - const char *name, /* IN */ - TestFuncWC func, /* IN */ - TestFuncDtor dtor, /* IN */ - void *ctx, - ...) /* IN */ -{ - va_list ap; - - va_start (ap, ctx); - _V_TestSuite_AddFull (suite, name, func, dtor, ctx, ap); - va_end (ap); -} - - -void -_TestSuite_TestFnCtxDtor (void *ctx) -{ - TestFuncDtor dtor = ((TestFnCtx *) ctx)->dtor; - if (dtor) { - dtor (ctx); - } - bson_free (ctx); -} - - -#if defined(_WIN32) -static void -_print_getlasterror_win (const char *msg) -{ - LPTSTR err_msg; - - FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError (), - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - /* FormatMessage is weird about this param. */ - (LPTSTR) &err_msg, - 0, - NULL); - - test_error ("%s: %s", msg, err_msg); - - LocalFree (err_msg); -} - - -static int -TestSuite_RunFuncInChild (TestSuite *suite, /* IN */ - Test *test) /* IN */ -{ - STARTUPINFO si; - PROCESS_INFORMATION pi; - char *cmdline; - DWORD exit_code = -1; - - ZeroMemory (&si, sizeof (si)); - si.cb = sizeof (si); - ZeroMemory (&pi, sizeof (pi)); - - cmdline = bson_strdup_printf ( - "%s --silent --no-fork -l %s", suite->prgname, test->name); - - if (!CreateProcess (NULL, - cmdline, - NULL, /* Process handle not inheritable */ - NULL, /* Thread handle not inheritable */ - FALSE, /* Set handle inheritance to FALSE */ - 0, /* No creation flags */ - NULL, /* Use parent's environment block */ - NULL, /* Use parent's starting directory */ - &si, - &pi)) { - test_error ("CreateProcess failed (%ld).", GetLastError ()); - bson_free (cmdline); - - return -1; - } - - if (WaitForSingleObject (pi.hProcess, INFINITE) != WAIT_OBJECT_0) { - _print_getlasterror_win ("Couldn't await process"); - goto done; - } - - if (!GetExitCodeProcess (pi.hProcess, &exit_code)) { - _print_getlasterror_win ("Couldn't get exit code"); - goto done; - } - -done: - CloseHandle (pi.hProcess); - CloseHandle (pi.hThread); - bson_free (cmdline); - - return exit_code; -} -#else /* Unix */ -static int -TestSuite_RunFuncInChild (TestSuite *suite, /* IN */ - Test *test) /* IN */ -{ - pid_t child; - int exit_code = -1; - int fd; - int pipefd[2]; - const char *envp[] = {"MONGOC_TEST_SERVER_LOG=stdout", NULL}; - char buf[4096]; - ssize_t nread; - - if (suite->outfile) { - fflush (suite->outfile); - } - - if (suite->mock_server_log_buf) { - if (pipe (pipefd) == -1) { - perror ("pipe"); - exit (-1); - } - } - - if (-1 == (child = fork ())) { - return -1; - } - - if (!child) { - if (suite->outfile) { - fclose (suite->outfile); - suite->outfile = NULL; - } - - if (suite->mock_server_log_buf) { - /* tell mock server to log to stdout, and read its output */ - dup2 (pipefd[1], STDOUT_FILENO); - close (pipefd[0]); - close (pipefd[1]); - execle (suite->prgname, - suite->prgname, - "--no-fork", - "--silent", - "-l", - test->name, - (char *) 0, - envp); - } else { - /* suppress child output */ - fd = open ("/dev/null", O_WRONLY); - dup2 (fd, STDOUT_FILENO); - close (fd); - - execl (suite->prgname, - suite->prgname, - "--no-fork", - "-l", - test->name, - (char *) 0); - } - - exit (-1); - } - - if (suite->mock_server_log_buf) { - close (pipefd[1]); - while ((nread = read (pipefd[0], buf, sizeof (buf) - 1)) > 0) { - buf[nread] = '\0'; - bson_string_append (suite->mock_server_log_buf, buf); - } - } - - if (-1 == waitpid (child, &exit_code, 0)) { - perror ("waitpid()"); - } - - return exit_code; -} -#endif - - -/* replace " with \", newline with \n, tab with four spaces */ -static void -_append_json_escaped (bson_string_t *buf, const char *s) -{ - char *escaped = bson_utf8_escape_for_json (s, -1); - bson_string_append (buf, escaped); - bson_free (escaped); -} - - -/* returns 1 on failure, 0 on success */ -static int -TestSuite_RunTest (TestSuite *suite, /* IN */ - Test *test, /* IN */ - int *count) /* INOUT */ -{ - int64_t t1, t2, t3; - char name[MAX_TEST_NAME_LENGTH]; - bson_string_t *buf; - bson_string_t *mock_server_log_buf; - size_t i; - int status = 0; - - bson_snprintf (name, sizeof name, "%s%s", suite->name, test->name); - - buf = bson_string_new (NULL); - - if (suite->flags & TEST_DEBUGOUTPUT) { - test_msg ("Begin %s, seed %u", name, test->seed); - } - - for (i = 0; i < suite->failing_flaky_skips.len; i++) { - TestSkip *skip = - _mongoc_array_index (&suite->failing_flaky_skips, TestSkip *, i); - if (0 == strcmp (name, skip->test_name) && skip->subtest_desc == NULL) { - if (suite->ctest_run) { - /* Write a marker that tells CTest that we are skipping this test */ - test_msg ("@@ctest-skipped@@"); - } - if (!suite->silent) { - bson_string_append_printf ( - buf, - " { \"status\": \"skip\", \"test_file\": \"%s\"," - " \"reason\": \"%s\" }%s", - test->name, - skip->reason, - ((*count) == 1) ? "" : ","); - test_msg ("%s", buf->str); - if (suite->outfile) { - fprintf (suite->outfile, "%s", buf->str); - fflush (suite->outfile); - } - } - - goto done; - } - } - - for (i = 0; i < test->num_checks; i++) { - if (!test->checks[i]()) { - if (suite->ctest_run) { - /* Write a marker that tells CTest that we are skipping this test */ - test_msg ("@@ctest-skipped@@"); - } - if (!suite->silent) { - bson_string_append_printf ( - buf, - " { \"status\": \"skip\", \"test_file\": \"%s\" }%s", - test->name, - ((*count) == 1) ? "" : ","); - test_msg ("%s", buf->str); - if (suite->outfile) { - fprintf (suite->outfile, "%s", buf->str); - fflush (suite->outfile); - } - } - - goto done; - } - } - - t1 = bson_get_monotonic_time (); - - - if (suite->flags & TEST_NOFORK) { - if (suite->flags & TEST_TRACE) { - mongoc_log_set_handler (mongoc_log_default_handler, NULL); - mongoc_log_trace_enable (); - } else { - mongoc_log_trace_disable (); - } - - srand (test->seed); - test_conveniences_init (); - test->func (test->ctx); - test_conveniences_cleanup (); - } else { - status = TestSuite_RunFuncInChild (suite, test); - } - - capture_logs (false); - - if (suite->silent) { - goto done; - } - - t2 = bson_get_monotonic_time (); - // CDRIVER-2567: check that bson_get_monotonic_time does not wrap. - ASSERT_CMPINT64 (t2, >=, t1); - t3 = t2 - t1; - - bson_string_append_printf (buf, - " { \"status\": \"%s\", " - "\"test_file\": \"%s\", " - "\"seed\": \"%u\", " - "\"start\": %u.%06u, " - "\"end\": %u.%06u, " - "\"elapsed\": %u.%06u ", - (status == 0) ? "pass" : "fail", - name, - test->seed, - (unsigned) t1 / (1000 * 1000), - (unsigned) t1 % (1000 * 1000), - (unsigned) t2 / (1000 * 1000), - (unsigned) t2 % (1000 * 1000), - (unsigned) t3 / (1000 * 1000), - (unsigned) t3 % (1000 * 1000)); - - mock_server_log_buf = suite->mock_server_log_buf; - - if (mock_server_log_buf && mock_server_log_buf->len) { - bson_string_append (buf, ", \"log_raw\": \""); - _append_json_escaped (buf, mock_server_log_buf->str); - bson_string_append (buf, "\""); - - bson_string_truncate (mock_server_log_buf, 0); - } - - bson_string_append_printf (buf, " }"); - - if (*count > 1) { - bson_string_append_printf (buf, ","); - } - - test_msg ("%s", buf->str); - if (suite->outfile) { - fprintf (suite->outfile, "%s", buf->str); - fflush (suite->outfile); - } - -done: - bson_string_free (buf, true); - - return status ? 1 : 0; -} - - -static void -TestSuite_PrintHelp (TestSuite *suite) /* IN */ -{ - printf ( - "usage: %s [OPTIONS]\n" - "\n" - "Options:\n" - " -h, --help Show this help menu.\n" - " --list-tests Print list of available tests.\n" - " -f, --no-fork Do not spawn a process per test (abort on " - "first error).\n" - " -l, --match PATTERN Run test by name, e.g. \"/Client/command\" or " - "\"/Client/*\". May be repeated.\n" - " --ctest-run TEST Run only the named TEST for CTest\n" - " integration.\n" - " -s, --silent Suppress all output.\n" - " -F FILENAME Write test results (JSON) to FILENAME.\n" - " -d Print debug output (useful if a test hangs).\n" - " --skip-tests FILE Skip known failing or flaky tests.\n" - " -t, --trace Enable mongoc tracing (useful to debug " - "tests).\n" - "\n", - suite->prgname); -} - - -static void -TestSuite_PrintTests (TestSuite *suite) /* IN */ -{ - Test *iter; - - printf ("\nTests:\n"); - for (iter = suite->tests; iter; iter = iter->next) { - printf ("%s%s\n", suite->name, iter->name); - } - - printf ("\n"); -} - - -static void -TestSuite_PrintJsonSystemHeader (FILE *stream) -{ -#ifdef _WIN32 -#define INFO_BUFFER_SIZE 32767 - - SYSTEM_INFO si; - - GetSystemInfo (&si); - -#if defined(_MSC_VER) - // CDRIVER-4263: GetVersionEx is deprecated. -#pragma warning(suppress : 4996) - const DWORD version = GetVersion (); -#else - const DWORD version = GetVersion (); -#endif - - const DWORD major_version = (DWORD) (LOBYTE (LOWORD (version))); - const DWORD minor_version = (DWORD) (HIBYTE (LOWORD (version))); - const DWORD build = version < 0x80000000u ? (DWORD) (HIWORD (version)) : 0u; - - fprintf (stream, - " \"host\": {\n" - " \"sysname\": \"Windows\",\n" - " \"release\": \"%ld.%ld (%ld)\",\n" - " \"machine\": \"%ld\",\n" - " \"memory\": {\n" - " \"pagesize\": %ld,\n" - " \"npages\": %d\n" - " }\n" - " },\n", - major_version, - minor_version, - build, - si.dwProcessorType, - si.dwPageSize, - 0); -#else - struct utsname u; - uint64_t pagesize; - uint64_t npages = 0; - - if (uname (&u) == -1) { - perror ("uname()"); - return; - } - - pagesize = sysconf (_SC_PAGE_SIZE); - -#if defined(_SC_PHYS_PAGES) - npages = sysconf (_SC_PHYS_PAGES); -#endif - fprintf (stream, - " \"host\": {\n" - " \"sysname\": \"%s\",\n" - " \"release\": \"%s\",\n" - " \"machine\": \"%s\",\n" - " \"memory\": {\n" - " \"pagesize\": %" PRIu64 ",\n" - " \"npages\": %" PRIu64 "\n" - " }\n" - " },\n", - u.sysname, - u.release, - u.machine, - pagesize, - npages); -#endif -} - -static const char * -getenv_or (const char *name, const char *dflt) -{ - const char *s = getenv (name); - return s ? s : dflt; -} - -static const char * -egetenv (const char *name) -{ - return getenv_or (name, ""); -} - -static void -TestSuite_PrintJsonHeader (TestSuite *suite, /* IN */ - FILE *stream) /* IN */ -{ - char *hostname = test_framework_get_host (); - char *udspath = test_framework_get_unix_domain_socket_path_escaped (); - int port = test_framework_get_port (); - bool ssl = test_framework_get_ssl (); - - ASSERT (suite); - - fprintf (stream, "{\n"); - TestSuite_PrintJsonSystemHeader (stream); - fprintf (stream, - " \"auth\": { \"user\": \"%s\", \"pass\": \"%s\" }, \n" - " \"addr\": { \"host\": \"%s\", \"port\": %d, \"uri\": \"%s\" },\n" - " \"gssapi\": { \"host\": \"%s\", \"user\": \"%s\" }, \n" - " \"uds\": \"%s\", \n" - " \"compressors\": \"%s\", \n" - " \"SSL\": {\n" - " \"enabled\": %s,\n" - " \"weak_cert_validation\": %s,\n" - " \"pem_file\": \"%s\",\n" - " \"pem_pwd\": \"%s\",\n" - " \"ca_file\": \"%s\",\n" - " \"ca_dir\": \"%s\",\n" - " \"crl_file\": \"%s\"\n" - " },\n" - " \"framework\": {\n" - " \"monitoringVerbose\": %s,\n" - " \"mockServerLog\": \"%s\",\n" - " \"futureTimeoutMS\": %" PRIu64 ",\n" - " \"majorityReadConcern\": %s,\n" - " \"skipLiveTests\": %s,\n" - " \"IPv6\": %s\n" - " },\n" - " \"options\": {\n" - " \"fork\": %s,\n" - " \"tracing\": %s,\n" - " \"apiVersion\": %s\n" - " },\n" - " \"results\": [\n", - egetenv ("MONGOC_TEST_USER"), - egetenv ("MONGOC_TEST_PASSWORD"), - hostname, - port, - egetenv ("MONGOC_TEST_URI"), - egetenv ("MONGOC_TEST_GSSAPI_HOST"), - egetenv ("MONGOC_TEST_GSSAPI_USER"), - udspath, - egetenv ("MONGOC_TEST_COMPRESSORS"), - ssl ? "true" : "false", - test_framework_getenv_bool ("MONGOC_TEST_SSL_WEAK_CERT_VALIDATION") - ? "true" - : "false", - egetenv ("MONGOC_TEST_SSL_PEM_FILE"), - egetenv ("MONGOC_TEST_SSL_PEM_PWD"), - egetenv ("MONGOC_TEST_SSL_CA_FILE"), - egetenv ("MONGOC_TEST_SSL_CA_DIR"), - egetenv ("MONGOC_TEST_SSL_CRL_FILE"), - getenv ("MONGOC_TEST_MONITORING_VERBOSE") ? "true" : "false", - egetenv ("MONGOC_TEST_SERVER_LOG"), - get_future_timeout_ms (), - test_framework_getenv_bool ("MONGOC_ENABLE_MAJORITY_READ_CONCERN") - ? "true" - : "false", - test_framework_getenv_bool ("MONGOC_TEST_SKIP_LIVE") ? "true" - : "false", - test_framework_getenv_bool ("MONGOC_CHECK_IPV6") ? "true" : "false", - (suite->flags & TEST_NOFORK) ? "false" : "true", - (suite->flags & TEST_TRACE) ? "true" : "false", - getenv_or ("MONGODB_API_VERSION", "null")); - - bson_free (hostname); - bson_free (udspath); - - fflush (stream); -} - - -static void -TestSuite_PrintJsonFooter (FILE *stream) /* IN */ -{ - fprintf (stream, " ]\n}\n"); - fflush (stream); -} - -static bool -TestSuite_TestMatchesName (const TestSuite *suite, - const Test *test, - const char *testname) -{ - char name[128]; - bool star = strlen (testname) && testname[strlen (testname) - 1] == '*'; - - bson_snprintf (name, sizeof name, "%s%s", suite->name, test->name); - - if (star) { - /* e.g. testname is "/Client*" and name is "/Client/authenticate" */ - return (0 == strncmp (name, testname, strlen (testname) - 1)); - } else { - return (0 == strcmp (name, testname)); - } -} - - -bool -test_matches (TestSuite *suite, Test *test) -{ - if (suite->ctest_run) { - /* We only want exactly the named test */ - return strcmp (test->name, suite->ctest_run) == 0; - } - - /* If no match patterns were provided, then assume all match. */ - if (suite->match_patterns.len == 0) { - return true; - } - - for (size_t i = 0u; i < suite->match_patterns.len; i++) { - char *pattern = _mongoc_array_index (&suite->match_patterns, char *, i); - if (TestSuite_TestMatchesName (suite, test, pattern)) { - return true; - } - } - - return false; -} - -void -_process_skip_file (const char *filename, mongoc_array_t *skips) -{ - const int max_lines = 1000; - int lines_read = 0; - char buffer[SKIP_LINE_BUFFER_SIZE]; - size_t buflen; - FILE *skip_file; - char *fgets_ret; - TestSkip *skip; - char *test_name_end; - size_t comment_len; - char *comment_char; - char *comment_text; - size_t subtest_len; - size_t new_buflen; - char *subtest_start; - char *subtest_end; - -#ifdef _WIN32 - if (0 != fopen_s (&skip_file, filename, "r")) { - skip_file = NULL; - } -#else - skip_file = fopen (filename, "r"); -#endif - if (!skip_file) { - test_error ("Failed to open skip file: %s: errno: %d", filename, errno); - } - - while (lines_read < max_lines) { - fgets_ret = fgets (buffer, sizeof (buffer), skip_file); - buflen = strlen (buffer); - - if (buflen == 0 || !fgets_ret) { - break; /* error or EOF */ - } - - if (buffer[0] == '#' || buffer[0] == ' ' || buffer[0] == '\n') { - continue; /* Comment line or blank line */ - } - - skip = (TestSkip *) bson_malloc0 (sizeof *skip); - if (buffer[buflen - 1] == '\n') - buflen--; - test_name_end = buffer + buflen; - - /* First get the comment, starting at '#' to EOL */ - comment_len = 0; - comment_char = strchr (buffer, '#'); - if (comment_char) { - test_name_end = comment_char; - comment_text = comment_char; - while (comment_text[0] == '#' || comment_text[0] == ' ' || - comment_text[0] == '\t') { - if (++comment_text >= (buffer + buflen)) - break; - } - skip->reason = - bson_strndup (comment_text, buflen - (comment_text - buffer)); - comment_len = buflen - (comment_char - buffer); - } else { - skip->reason = NULL; - } - - /* Next get the subtest name, from first '"' until last '"' */ - new_buflen = buflen - comment_len; - subtest_start = strstr (buffer, "/\""); - if (subtest_start && (!comment_char || (subtest_start < comment_char))) { - test_name_end = subtest_start; - subtest_start++; - /* find the second '"' that marks end of subtest name */ - subtest_end = subtest_start + 1; - while (subtest_end[0] != '\0' && subtest_end[0] != '"' && - (subtest_end < buffer + new_buflen)) { - subtest_end++; - } - /* 'subtest_start + 1' to trim leading and trailing '"' */ - subtest_len = subtest_end - (subtest_start + 1); - skip->subtest_desc = bson_strndup (subtest_start + 1, subtest_len); - } else { - skip->subtest_desc = NULL; - } - - /* Next get the test name */ - while (test_name_end[-1] == ' ' && test_name_end > buffer) { - /* trailing space might be between test name and '#' */ - test_name_end--; - } - skip->test_name = bson_strndup (buffer, test_name_end - buffer); - - _mongoc_array_append_val (skips, skip); - - lines_read++; - } - if (lines_read == max_lines) { - test_error ("Skip file: %s exceeded maximum lines: %d. Increase " - "max_lines in _process_skip_file", - filename, - max_lines); - } - fclose (skip_file); -} - -static int -TestSuite_RunAll (TestSuite *suite /* IN */) -{ - Test *test; - int count = 0; - int status = 0; - - ASSERT (suite); - - /* initialize "count" so we can omit comma after last test output */ - for (test = suite->tests; test; test = test->next) { - if (test_matches (suite, test)) { - count++; - } - } - - if (suite->ctest_run) { - /* We should have matched *at most* one test */ - ASSERT (count <= 1); - if (count == 0) { - test_error ("No such test '%s'", suite->ctest_run); - } - } - - for (test = suite->tests; test; test = test->next) { - if (test_matches (suite, test)) { - status += TestSuite_RunTest (suite, test, &count); - count--; - } - } - - if (suite->silent) { - return status; - } - - TestSuite_PrintJsonFooter (stdout); - if (suite->outfile) { - TestSuite_PrintJsonFooter (suite->outfile); - } - - return status; -} - - -int -TestSuite_Run (TestSuite *suite) /* IN */ -{ - int failures = 0; - int64_t start_us; - - if (suite->flags & TEST_HELPTEXT) { - TestSuite_PrintHelp (suite); - } - - if (suite->flags & TEST_LISTTESTS) { - TestSuite_PrintTests (suite); - } - - if ((suite->flags & TEST_HELPTEXT) || (suite->flags & TEST_LISTTESTS)) { - return 0; - } - - if (!suite->silent) { - TestSuite_PrintJsonHeader (suite, stdout); - if (suite->outfile) { - TestSuite_PrintJsonHeader (suite, suite->outfile); - } - } - - start_us = bson_get_monotonic_time (); - if (suite->tests) { - failures += TestSuite_RunAll (suite); - } else if (!suite->silent) { - TestSuite_PrintJsonFooter (stdout); - if (suite->outfile) { - TestSuite_PrintJsonFooter (suite->outfile); - } - } - MONGOC_DEBUG ("Duration of all tests (s): %" PRId64, - (bson_get_monotonic_time () - start_us) / (1000 * 1000)); - - return failures; -} - - -void -TestSuite_Destroy (TestSuite *suite) -{ - Test *test; - Test *tmp; - - bson_mutex_lock (&gTestMutex); - gTestSuite = NULL; - bson_mutex_unlock (&gTestMutex); - - for (test = suite->tests; test; test = tmp) { - tmp = test->next; - - if (test->dtor) { - test->dtor (test->ctx); - } - bson_free (test->name); - bson_free (test); - } - - if (suite->outfile) { - fclose (suite->outfile); - } - - if (suite->mock_server_log_buf) { - bson_string_free (suite->mock_server_log_buf, true); - } - - bson_free (suite->name); - bson_free (suite->prgname); - bson_free (suite->ctest_run); - for (size_t i = 0u; i < suite->match_patterns.len; i++) { - char *val = _mongoc_array_index (&suite->match_patterns, char *, i); - bson_free (val); - } - - _mongoc_array_destroy (&suite->match_patterns); - - for (size_t i = 0u; i < suite->failing_flaky_skips.len; i++) { - TestSkip *val = - _mongoc_array_index (&suite->failing_flaky_skips, TestSkip *, i); - bson_free (val->test_name); - bson_free (val->subtest_desc); - bson_free (val->reason); - bson_free (val); - } - - _mongoc_array_destroy (&suite->failing_flaky_skips); -} - - -int -test_suite_debug_output (void) -{ - int ret; - - bson_mutex_lock (&gTestMutex); - ret = gTestSuite->flags & TEST_DEBUGOUTPUT; - bson_mutex_unlock (&gTestMutex); - - return ret; -} - - -MONGOC_PRINTF_FORMAT (1, 2) -void -test_suite_mock_server_log (const char *msg, ...) -{ - va_list ap; - char *formatted_msg; - - bson_mutex_lock (&gTestMutex); - - if (gTestSuite->mock_server_log || gTestSuite->mock_server_log_buf) { - va_start (ap, msg); - formatted_msg = bson_strdupv_printf (msg, ap); - va_end (ap); - - if (gTestSuite->mock_server_log_buf) { - bson_string_append_printf ( - gTestSuite->mock_server_log_buf, "%s\n", formatted_msg); - } else { - fprintf (gTestSuite->mock_server_log, "%s\n", formatted_msg); - fflush (gTestSuite->mock_server_log); - } - - bson_free (formatted_msg); - } - - bson_mutex_unlock (&gTestMutex); -} - -bool -TestSuite_NoFork (TestSuite *suite) -{ - if (suite->flags & TEST_NOFORK) { - return true; - } - return false; -} - -char * -bson_value_to_str (const bson_value_t *val) -{ - bson_t *tmp = bson_new (); - BSON_APPEND_VALUE (tmp, "v", val); - char *str = bson_as_canonical_extended_json (tmp, NULL); - // str is the string: { "v": ... } - // remove the prefix and suffix. - char *ret = bson_strndup (str + 6, strlen (str) - (6 + 1)); - bson_free (str); - bson_destroy (tmp); - return ret; -} - -bool -bson_value_eq (const bson_value_t *a, const bson_value_t *b) -{ - bson_t *tmp_a = bson_new (); - bson_t *tmp_b = bson_new (); - BSON_APPEND_VALUE (tmp_a, "v", a); - BSON_APPEND_VALUE (tmp_b, "v", b); - bool ret = bson_equal (tmp_a, tmp_b); - bson_destroy (tmp_b); - bson_destroy (tmp_a); - return ret; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/TestSuite.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/TestSuite.h deleted file mode 100644 index bb1fe4274..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/TestSuite.h +++ /dev/null @@ -1,794 +0,0 @@ -/* - * Copyright 2014 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef TEST_SUITE_H -#define TEST_SUITE_H - - -#include -#include -#include -#include - -#include "mongoc/mongoc-array-private.h" -#include "mongoc/mongoc-util-private.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef OS_RELEASE_FILE_DIR -#define OS_RELEASE_FILE_DIR "src/libmongoc/tests/release_files" -#endif - - -#ifndef BINARY_DIR -#define BINARY_DIR "src/libmongoc/tests/binary" -#endif - -#ifndef BSON_BINARY_DIR -#define BSON_BINARY_DIR "src/libbson/tests/binary" -#endif - -#ifndef JSON_DIR -#define JSON_DIR "src/libmongoc/tests/json" -#endif - -#ifndef BSON_JSON_DIR -#define BSON_JSON_DIR "src/libbson/tests/json" -#endif - -#ifndef CERT_TEST_DIR -#define CERT_TEST_DIR "src/libmongoc/tests/x509gen" -#endif - - -#ifdef BSON_OS_WIN32 -#include -#include -static __inline int -bson_open (const char *filename, int flags, ...) -{ - int fd = -1; - - if (_sopen_s ( - &fd, filename, flags | _O_BINARY, _SH_DENYNO, _S_IREAD | _S_IWRITE) == - NO_ERROR) { - return fd; - } - - return -1; -} -#define bson_close _close -#define bson_read(f, b, c) ((ssize_t) _read ((f), (b), (int) (c))) -#define bson_write _write -#else -#define bson_open open -#define bson_read read -#define bson_close close -#define bson_write write -#endif - - -#define TEST_NOFORK (1 << 1) -#define TEST_HELPTEXT (1 << 2) -#define TEST_DEBUGOUTPUT (1 << 3) -#define TEST_TRACE (1 << 4) -#define TEST_LISTTESTS (1 << 5) - - -#define CERT_CA CERT_TEST_DIR "/ca.pem" -#define CERT_CRL CERT_TEST_DIR "/crl.pem" -#define CERT_SERVER CERT_TEST_DIR "/server.pem" /* 127.0.0.1 & localhost */ -#define CERT_CLIENT CERT_TEST_DIR "/client.pem" -#define CERT_ALTNAME \ - CERT_TEST_DIR "/altname.pem" /* alternative.mongodb.org \ - */ -#define CERT_WILD CERT_TEST_DIR "/wild.pem" /* *.mongodb.org */ -#define CERT_COMMONNAME \ - CERT_TEST_DIR "/commonName.pem" /* 127.0.0.1 & localhost */ -#define CERT_EXPIRED CERT_TEST_DIR "/expired.pem" /* 127.0.0.1 & localhost */ -#define CERT_PASSWORD "qwerty" -#define CERT_PASSWORD_PROTECTED CERT_TEST_DIR "/password_protected.pem" - - -#ifdef ASSERT -#undef ASSERT -#endif - -// Ensure stdout and stderr are flushed prior to possible following abort(). -#define MONGOC_STDERR_PRINTF(format, ...) \ - if (1) { \ - fflush (stdout); \ - fprintf (stderr, format, __VA_ARGS__); \ - fflush (stderr); \ - } else \ - ((void) 0) - -#define ASSERT(Cond) \ - do { \ - if (!(Cond)) { \ - MONGOC_STDERR_PRINTF ("FAIL:%s:%d %s()\n Condition '%s' failed.\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - BSON_STR (Cond)); \ - abort (); \ - } \ - } while (0) - - -void -_test_error (const char *format, ...) BSON_GNUC_PRINTF (1, 2); - -#define test_error(...) \ - if (1) { \ - MONGOC_STDERR_PRINTF ( \ - "test error in: %s %d:%s()\n", __FILE__, __LINE__, BSON_FUNC); \ - _test_error (__VA_ARGS__); \ - abort (); /* suppress missing return errors in non-void functions */ \ - } else \ - ((void) 0) - -#define bson_eq_bson(bson, expected) \ - do { \ - char *bson_json, *expected_json; \ - const uint8_t *bson_data = bson_get_data ((bson)); \ - const uint8_t *expected_data = bson_get_data ((expected)); \ - int unequal; \ - unsigned o; \ - int off = -1; \ - unequal = ((expected)->len != (bson)->len) || \ - memcmp (bson_get_data ((expected)), \ - bson_get_data ((bson)), \ - (expected)->len); \ - if (unequal) { \ - bson_json = bson_as_canonical_extended_json (bson, NULL); \ - expected_json = bson_as_canonical_extended_json ((expected), NULL); \ - for (o = 0; o < (bson)->len && o < (expected)->len; o++) { \ - if (bson_data[o] != expected_data[o]) { \ - off = o; \ - break; \ - } \ - } \ - if (off == -1) { \ - off = BSON_MAX ((expected)->len, (bson)->len) - 1; \ - } \ - MONGOC_STDERR_PRINTF ( \ - "bson objects unequal (byte %u):\n(%s)\n(%s)\n", \ - off, \ - bson_json, \ - expected_json); \ - { \ - int fd1 = bson_open ("failure.bad.bson", O_RDWR | O_CREAT, 0640); \ - int fd2 = \ - bson_open ("failure.expected.bson", O_RDWR | O_CREAT, 0640); \ - ASSERT (fd1 != -1); \ - ASSERT (fd2 != -1); \ - ASSERT ((bson)->len == bson_write (fd1, bson_data, (bson)->len)); \ - ASSERT ((expected)->len == \ - bson_write (fd2, expected_data, (expected)->len)); \ - bson_close (fd1); \ - bson_close (fd2); \ - } \ - abort (); \ - } \ - } while (0) - - -#ifdef ASSERT_OR_PRINT -#undef ASSERT_OR_PRINT -#endif - -#define ASSERT_OR_PRINT(_statement, _err) \ - do { \ - if (!(_statement)) { \ - MONGOC_STDERR_PRINTF ("FAIL:%s:%d %s()\n %s\n %s\n\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - BSON_STR (_statement), \ - _err.message); \ - abort (); \ - } \ - } while (0) - -#define ASSERT_CURSOR_NEXT(_cursor, _doc) \ - do { \ - bson_error_t _err; \ - if (!mongoc_cursor_next ((_cursor), (_doc))) { \ - if (mongoc_cursor_error ((_cursor), &_err)) { \ - MONGOC_STDERR_PRINTF ("FAIL:%s:%d %s()\n %s\n\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - _err.message); \ - } else { \ - MONGOC_STDERR_PRINTF ("FAIL:%s:%d %s()\n %s\n\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - "empty cursor"); \ - } \ - abort (); \ - } \ - } while (0) - - -#define ASSERT_CURSOR_DONE(_cursor) \ - do { \ - bson_error_t _err; \ - const bson_t *_doc; \ - if (mongoc_cursor_next ((_cursor), &_doc)) { \ - MONGOC_STDERR_PRINTF ("FAIL:%s:%d %s()\n %s\n\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - "non-empty cursor"); \ - abort (); \ - } \ - if (mongoc_cursor_error ((_cursor), &_err)) { \ - MONGOC_STDERR_PRINTF ("FAIL:%s:%d %s()\n %s\n\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - _err.message); \ - abort (); \ - } \ - } while (0) - - -#define ASSERT_CMPINT_HELPER(a, eq, b, fmt, type) \ - do { \ - /* evaluate once */ \ - type _a = a; \ - type _b = b; \ - if (!((_a) eq (_b))) { \ - MONGOC_STDERR_PRINTF ("FAIL\n\nAssert Failure: %" fmt " %s %" fmt \ - "\n" \ - "%s:%d %s()\n", \ - _a, \ - BSON_STR (eq), \ - _b, \ - __FILE__, \ - __LINE__, \ - BSON_FUNC); \ - abort (); \ - } \ - } while (0) - - -#define ASSERT_CMPINT(a, eq, b) ASSERT_CMPINT_HELPER (a, eq, b, "d", int) -#define ASSERT_CMPUINT(a, eq, b) \ - ASSERT_CMPINT_HELPER (a, eq, b, "u", unsigned int) -#define ASSERT_CMPLONG(a, eq, b) ASSERT_CMPINT_HELPER (a, eq, b, "ld", long) -#define ASSERT_CMPULONG(a, eq, b) \ - ASSERT_CMPINT_HELPER (a, eq, b, "lu", unsigned long) -#define ASSERT_CMPINT32(a, eq, b) \ - ASSERT_CMPINT_HELPER (a, eq, b, PRId32, int32_t) -#define ASSERT_CMPINT64(a, eq, b) \ - ASSERT_CMPINT_HELPER (a, eq, b, PRId64, int64_t) -#define ASSERT_CMPUINT16(a, eq, b) \ - ASSERT_CMPINT_HELPER (a, eq, b, "hu", uint16_t) -#define ASSERT_CMPUINT32(a, eq, b) \ - ASSERT_CMPINT_HELPER (a, eq, b, PRIu32, uint32_t) -#define ASSERT_CMPUINT64(a, eq, b) \ - ASSERT_CMPINT_HELPER (a, eq, b, PRIu64, uint64_t) -#define ASSERT_CMPSIZE_T(a, eq, b) ASSERT_CMPINT_HELPER (a, eq, b, "zu", size_t) -#define ASSERT_CMPSSIZE_T(a, eq, b) \ - ASSERT_CMPINT_HELPER (a, eq, b, "zd", ssize_t) -#define ASSERT_CMPDOUBLE(a, eq, b) ASSERT_CMPINT_HELPER (a, eq, b, "f", double) -#define ASSERT_CMPVOID(a, eq, b) ASSERT_CMPINT_HELPER (a, eq, b, "p", void *) - -#define ASSERT_MEMCMP(a, b, n) \ - do { \ - if (0 != memcmp (a, b, n)) { \ - MONGOC_STDERR_PRINTF ( \ - "Failed comparing %d bytes: \"%.*s\" != \"%.*s\"", \ - n, \ - n, \ - (char *) a, \ - n, \ - (char *) b); \ - abort (); \ - } \ - } while (0) - - -#ifdef ASSERT_ALMOST_EQUAL -#undef ASSERT_ALMOST_EQUAL -#endif -#define ASSERT_ALMOST_EQUAL(a, b) \ - do { \ - /* evaluate once */ \ - int64_t _a = (a); \ - int64_t _b = (b); \ - if (!(_a > (_b * 2) / 3 && (_a < (_b * 3) / 2))) { \ - MONGOC_STDERR_PRINTF ("FAIL\n\nAssert Failure: %" PRId64 \ - " not within 50%% of %" PRId64 "\n" \ - "%s:%d %s()\n", \ - _a, \ - _b, \ - __FILE__, \ - __LINE__, \ - BSON_FUNC); \ - abort (); \ - } \ - } while (0) - -#ifdef ASSERT_EQUAL_DOUBLE -#undef ASSERT_EQUAL_DOUBLE -#endif -#define ASSERT_EQUAL_DOUBLE(a, b) \ - do { \ - double _a = fabs ((double) a); \ - double _b = fabs ((double) b); \ - if (!(_a > (_b * 4) / 5 && (_a < (_b * 6) / 5))) { \ - MONGOC_STDERR_PRINTF ( \ - "FAIL\n\nAssert Failure: %f not within 20%% of %f\n" \ - "%s:%d %s()\n", \ - (double) a, \ - (double) b, \ - __FILE__, \ - __LINE__, \ - BSON_FUNC); \ - abort (); \ - } \ - } while (0) - - -#define ASSERT_CMPSTR(a, b) \ - do { \ - /* evaluate once */ \ - const char *_a = a; \ - const char *_b = b; \ - if ((_a != _b) && (!_a || !_b || (strcmp (_a, _b) != 0))) { \ - MONGOC_STDERR_PRINTF ( \ - "FAIL\n\nAssert Failure:\n \"%s\"\n !=\n \"%s\"\n %s:%d " \ - " %s()\n", \ - _a ? _a : "(null)", \ - _b ? _b : "(null)", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC); \ - abort (); \ - } \ - } while (0) - -#define ASSERT_CMPJSON(_a, _b) \ - do { \ - size_t i = 0; \ - char *__a = (char *) (_a); \ - char *__b = (char *) (_b); \ - char *__aa = bson_malloc0 (strlen (__a) + 1); \ - char *__bb = bson_malloc0 (strlen (__b) + 1); \ - char *f = __a; \ - do { \ - while (bson_isspace (*__a)) \ - __a++; \ - __aa[i++] = *__a++; \ - } while (*__a); \ - i = 0; \ - do { \ - while (bson_isspace (*__b)) \ - __b++; \ - __bb[i++] = *__b++; \ - } while (*__b); \ - if (!!strcmp ((__aa), (__bb))) { \ - MONGOC_STDERR_PRINTF ("FAIL\n\nAssert Failure: \"%s\" != \"%s\"\n" \ - "%s:%d %s()\n", \ - __aa, \ - __bb, \ - __FILE__, \ - __LINE__, \ - BSON_FUNC); \ - abort (); \ - } \ - bson_free (__aa); \ - bson_free (__bb); \ - bson_free (f); \ - } while (0) - -#define ASSERT_CMPOID(a, b) \ - do { \ - if (bson_oid_compare ((a), (b))) { \ - char oid_a[25]; \ - char oid_b[25]; \ - bson_oid_to_string ((a), oid_a); \ - bson_oid_to_string ((b), oid_b); \ - MONGOC_STDERR_PRINTF ("FAIL\n\nAssert Failure: " \ - "ObjectId(\"%s\") != ObjectId(\"%s\")\n", \ - oid_a, \ - oid_b); \ - abort (); \ - } \ - } while (0) - - -#define ASSERT_CONTAINS(a, b) \ - do { \ - char *_a_lower = bson_strdup (a); \ - char *_b_lower = bson_strdup (b); \ - mongoc_lowercase (_a_lower, _a_lower); \ - mongoc_lowercase (_b_lower, _b_lower); \ - if (NULL == strstr ((_a_lower), (_b_lower))) { \ - MONGOC_STDERR_PRINTF ("%s:%d %s(): [%s] does not contain [%s]\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - a, \ - b); \ - abort (); \ - } \ - bson_free (_a_lower); \ - bson_free (_b_lower); \ - } while (0) - -#define ASSERT_STARTSWITH(a, b) \ - do { \ - /* evaluate once */ \ - const char *_a = a; \ - const char *_b = b; \ - if ((_a) != strstr ((_a), (_b))) { \ - MONGOC_STDERR_PRINTF ( \ - "%s:%d %s(): : [%s] does not start with [%s]\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - _a, \ - _b); \ - abort (); \ - } \ - } while (0) - -#define ASSERT_ERROR_CONTAINS(error, _domain, _code, _message) \ - do { \ - if (error.domain != _domain) { \ - MONGOC_STDERR_PRINTF ( \ - "%s:%d %s(): error domain %d doesn't match expected %d\n" \ - "error: \"%s\"", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - error.domain, \ - _domain, \ - error.message); \ - abort (); \ - }; \ - if (error.code != _code) { \ - MONGOC_STDERR_PRINTF ( \ - "%s:%d %s(): error code %d doesn't match expected %d\n" \ - "error: \"%s\"", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - error.code, \ - _code, \ - error.message); \ - abort (); \ - }; \ - ASSERT_CONTAINS (error.message, _message); \ - } while (0); - -#define ASSERT_CAPTURED_LOG(_info, _level, _msg) \ - do { \ - if (!has_captured_log (_level, _msg)) { \ - MONGOC_STDERR_PRINTF ("%s:%d %s(): testing %s didn't log \"%s\"\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - _info, \ - _msg); \ - print_captured_logs ("\t"); \ - abort (); \ - } \ - } while (0); - -#define ASSERT_NO_CAPTURED_LOGS(_info) \ - do { \ - if (has_captured_logs ()) { \ - MONGOC_STDERR_PRINTF ( \ - "%s:%d %s(): testing %s shouldn't have logged:\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - _info); \ - print_captured_logs ("\t"); \ - abort (); \ - } \ - } while (0); - -#define ASSERT_HAS_FIELD(_bson, _field) \ - do { \ - if (!bson_has_field ((_bson), (_field))) { \ - MONGOC_STDERR_PRINTF ( \ - "FAIL\n\nAssert Failure: No field \"%s\" in \"%s\"\n", \ - (_field), \ - bson_as_canonical_extended_json (_bson, NULL)); \ - abort (); \ - } \ - } while (0) - -#define ASSERT_HAS_NOT_FIELD(_bson, _field) \ - do { \ - if (bson_has_field ((_bson), (_field))) { \ - MONGOC_STDERR_PRINTF ( \ - "FAIL\n\nAssert Failure: Unexpected field \"%s\" in \"%s\"\n", \ - (_field), \ - bson_as_canonical_extended_json (_bson, NULL)); \ - abort (); \ - } \ - } while (0) - -#define ASSERT_CMPTIME(actual, maxduration) \ - do { \ - ASSERT_CMPINT64 (actual, <, maxduration); \ - } while (0) - -#define ASSERT_WITHIN_TIME_INTERVAL(actual, minduration, maxduration) \ - do { \ - ASSERT_CMPINT64 (actual, >=, minduration); \ - ASSERT_CMPINT64 (actual, <, maxduration); \ - } while (0) - -#if defined(_WIN32) && !defined(__MINGW32__) -#define gettestpid _getpid -#else -#ifdef __MINGW32__ -#include -#endif -#define gettestpid getpid -#endif - -#define ASSERT_OR_PRINT_ERRNO(_statement, _errcode) \ - do { \ - if (!(_statement)) { \ - MONGOC_STDERR_PRINTF ( \ - "FAIL:%s:%d %s()\n %s\n Failed with error code: %d (%s)\n\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - BSON_STR (_statement), \ - _errcode, \ - strerror (_errcode)); \ - abort (); \ - } \ - } while (0) - -#define ASSERT_COUNT(n, collection) \ - do { \ - int count = (int) mongoc_collection_count_documents ( \ - collection, tmp_bson ("{}"), NULL, NULL, NULL, NULL); \ - if ((n) != count) { \ - MONGOC_STDERR_PRINTF ( \ - "FAIL\n\nAssert Failure: count of %s is %d, not %d\n" \ - "%s:%d %s()\n", \ - mongoc_collection_get_name (collection), \ - count, \ - n, \ - __FILE__, \ - __LINE__, \ - BSON_FUNC); \ - abort (); \ - } \ - } while (0) - -#define ASSERT_CURSOR_COUNT(_n, _cursor) \ - do { \ - int _count = 0; \ - const bson_t *_doc; \ - while (mongoc_cursor_next (_cursor, &_doc)) { \ - _count++; \ - } \ - if ((_n) != _count) { \ - MONGOC_STDERR_PRINTF ( \ - "FAIL\n\nAssert Failure: cursor count is %d, not %d\n" \ - "%s:%d %s()\n", \ - _count, \ - _n, \ - __FILE__, \ - __LINE__, \ - BSON_FUNC); \ - abort (); \ - } \ - } while (0) - -#define WAIT_UNTIL(_pred) \ - do { \ - int64_t _start = bson_get_monotonic_time (); \ - while (!(_pred)) { \ - if (bson_get_monotonic_time () - _start > 10 * 1000 * 1000) { \ - MONGOC_STDERR_PRINTF ("Predicate \"%s\" timed out\n" \ - " %s:%d %s()\n", \ - BSON_STR (_pred), \ - __FILE__, \ - __LINE__, \ - BSON_FUNC); \ - abort (); \ - } \ - _mongoc_usleep (10 * 1000); \ - } \ - } while (0) - -#define ASSERT_WITH_MSG(_statement, ...) \ - do { \ - if (!(_statement)) { \ - MONGOC_STDERR_PRINTF ("FAIL:%s:%d %s()\n %s\n\n", \ - __FILE__, \ - __LINE__, \ - BSON_FUNC, \ - BSON_STR (_statement)); \ - fprintf (stderr, __VA_ARGS__); \ - fprintf (stderr, "\n"); \ - fflush (stderr); \ - abort (); \ - } \ - } while (0) - -// bson_value_to_str returns a string representation of a BSON value. -// Example: { "$numberInt": "123" } -// The return string must be freed with bson_free. -char * -bson_value_to_str (const bson_value_t *val); - -// bson_value_eq returns true if both bson_value_t contain equal values. -bool -bson_value_eq (const bson_value_t *a, const bson_value_t *b); - -// ASSERT_BSONVALUE_EQ asserts that two const bson_value_t* contain equal -// values. -#define ASSERT_BSONVALUE_EQ(a, b) \ - if (1) { \ - if (!bson_value_eq ((a), (b))) { \ - test_error ( \ - "%s != %s", bson_value_to_str (a), bson_value_to_str (b)); \ - } \ - } else \ - (void) 0 - -#define MAX_TEST_NAME_LENGTH 500 -#define MAX_TEST_CHECK_FUNCS 10 - - -typedef void (*TestFunc) (void); -typedef void (*TestFuncWC) (void *); -typedef void (*TestFuncDtor) (void *); -typedef int (*CheckFunc) (void); -typedef struct _Test Test; -typedef struct _TestSuite TestSuite; -typedef struct _TestFnCtx TestFnCtx; -typedef struct _TestSkip TestSkip; - - -struct _Test { - Test *next; - char *name; - TestFuncWC func; - TestFuncDtor dtor; - void *ctx; - int exit_code; - unsigned seed; - CheckFunc checks[MAX_TEST_CHECK_FUNCS]; - size_t num_checks; -}; - - -struct _TestSuite { - char *prgname; - char *name; - mongoc_array_t match_patterns; - char *ctest_run; - Test *tests; - FILE *outfile; - int flags; - int silent; - bson_string_t *mock_server_log_buf; - FILE *mock_server_log; - mongoc_array_t failing_flaky_skips; -}; - - -struct _TestFnCtx { - TestFunc test_fn; - TestFuncDtor dtor; -}; - - -struct _TestSkip { - char *test_name; - char *subtest_desc; - char *reason; -}; - - -void -TestSuite_Init (TestSuite *suite, const char *name, int argc, char **argv); -void -TestSuite_Add (TestSuite *suite, const char *name, TestFunc func); -int -TestSuite_CheckLive (void); -void -TestSuite_AddLive (TestSuite *suite, const char *name, TestFunc func); -int -TestSuite_CheckMockServerAllowed (void); -void -_TestSuite_AddMockServerTest (TestSuite *suite, - const char *name, - TestFunc func, - ...); -#define TestSuite_AddMockServerTest(_suite, _name, ...) \ - _TestSuite_AddMockServerTest (_suite, _name, __VA_ARGS__, NULL) -void -TestSuite_AddWC (TestSuite *suite, - const char *name, - TestFuncWC func, - TestFuncDtor dtor, - void *ctx); -Test * -_V_TestSuite_AddFull (TestSuite *suite, - const char *name, - TestFuncWC func, - TestFuncDtor dtor, - void *ctx, - va_list ap); -void -_TestSuite_AddFull (TestSuite *suite, - const char *name, - TestFuncWC func, - TestFuncDtor dtor, - void *ctx, - ...); -void -_TestSuite_TestFnCtxDtor (void *ctx); -#define TestSuite_AddFull(_suite, _name, _func, _dtor, _ctx, ...) \ - _TestSuite_AddFull (_suite, _name, _func, _dtor, _ctx, __VA_ARGS__, NULL) -#define TestSuite_AddFullWithTestFn( \ - _suite, _name, _func, _dtor, _test_fn, ...) \ - do { \ - TestFnCtx *ctx = bson_malloc (sizeof (TestFnCtx)); \ - ctx->test_fn = (TestFunc) (_test_fn); \ - ctx->dtor = _dtor; \ - _TestSuite_AddFull (_suite, \ - _name, \ - _func, \ - _TestSuite_TestFnCtxDtor, \ - ctx, \ - __VA_ARGS__, \ - NULL); \ - } while (0) -int -TestSuite_Run (TestSuite *suite); -void -TestSuite_Destroy (TestSuite *suite); - -int -test_suite_debug_output (void); -void -test_suite_mock_server_log (const char *msg, ...); -void -_process_skip_file (const char *, mongoc_array_t *); - -bool -TestSuite_NoFork (TestSuite *suite); - -#ifdef __cplusplus -} -#endif - - -#endif /* TEST_SUITE_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/bsonutil/bson-match.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/bsonutil/bson-match.c deleted file mode 100644 index ed129ab16..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/bsonutil/bson-match.c +++ /dev/null @@ -1,661 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "bsonutil/bson-match.h" -#include "mongoc-util-private.h" // hex_to_bin -#include "test-conveniences.h" -#include "TestSuite.h" -#include "unified/util.h" -#include "utlist.h" - -typedef struct _special_functor_t { - special_fn fn; - void *ctx; - char *keyword; - struct _special_functor_t *next; -} special_functor_t; - -struct _bson_matcher_t { - special_functor_t *specials; -}; - -#define MATCH_ERR(format, ...) \ - test_set_error (error, "match error at '%s': " format, path, __VA_ARGS__) - -static char * -get_first_key (const bson_t *bson) -{ - bson_iter_t iter; - - bson_iter_init (&iter, bson); - if (!bson_iter_next (&iter)) { - return ""; - } - - return (char *) bson_iter_key (&iter); -} - -static bool -is_special_match (const bson_t *bson) -{ - char *first_key = get_first_key (bson); - if (strstr (first_key, "$$") != first_key) { - return false; - } - if (bson_count_keys (bson) != 1) { - return false; - } - return true; -} - -/* implements $$placeholder */ -static bool -special_placeholder (bson_matcher_t *matcher, - const bson_t *assertion, - const bson_val_t *actual, - void *ctx, - const char *path, - bson_error_t *error) -{ - BSON_UNUSED (matcher); - BSON_UNUSED (assertion); - BSON_UNUSED (actual); - BSON_UNUSED (ctx); - BSON_UNUSED (path); - BSON_UNUSED (error); - - /* Nothing to do (not an operator, just a reserved key value). The meaning - * and corresponding behavior of $$placeholder depends on context. */ - return true; -} - -/* implements $$exists */ -static bool -special_exists (bson_matcher_t *matcher, - const bson_t *assertion, - const bson_val_t *actual, - void *ctx, - const char *path, - bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - bool should_exist; - - BSON_UNUSED (matcher); - BSON_UNUSED (ctx); - - bson_iter_init (&iter, assertion); - BSON_ASSERT (bson_iter_next (&iter)); - - if (!BSON_ITER_HOLDS_BOOL (&iter)) { - MATCH_ERR ("%s", "unexpected non-bool $$exists assertion"); - } - should_exist = bson_iter_bool (&iter); - - if (should_exist && NULL == actual) { - MATCH_ERR ("%s", "should exist but does not"); - goto done; - } - - if (!should_exist && NULL != actual) { - MATCH_ERR ("%s", "should not exist but does"); - goto done; - } - - ret = true; -done: - return ret; -} - -/* implements $$type */ -static bool -special_type (bson_matcher_t *matcher, - const bson_t *assertion, - const bson_val_t *actual, - void *ctx, - const char *path, - bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - - BSON_UNUSED (matcher); - BSON_UNUSED (ctx); - - bson_iter_init (&iter, assertion); - BSON_ASSERT (bson_iter_next (&iter)); - - if (!actual) { - MATCH_ERR ("%s", "does not exist but should"); - goto done; - } - - if (BSON_ITER_HOLDS_UTF8 (&iter)) { - bson_type_t expected_type = - bson_type_from_string (bson_iter_utf8 (&iter, NULL)); - if (expected_type != bson_val_type (actual)) { - MATCH_ERR ("expected type: %s, got: %s", - bson_type_to_string (expected_type), - bson_type_to_string (bson_val_type (actual))); - goto done; - } - } - - if (BSON_ITER_HOLDS_ARRAY (&iter)) { - bson_t arr; - bson_iter_t arriter; - bool found = false; - - bson_iter_bson (&iter, &arr); - BSON_FOREACH (&arr, arriter) - { - bson_type_t expected_type; - - if (!BSON_ITER_HOLDS_UTF8 (&arriter)) { - MATCH_ERR ("%s", "unexpected non-UTF8 $$type assertion"); - goto done; - } - - expected_type = - bson_type_from_string (bson_iter_utf8 (&arriter, NULL)); - if (expected_type == bson_val_type (actual)) { - found = true; - break; - } - } - if (!found) { - MATCH_ERR ("expected one of type: %s, got %s", - tmp_json (&arr), - bson_type_to_string (bson_val_type (actual))); - goto done; - } - } - - ret = true; -done: - return ret; -} - -/* implements $$unsetOrMatches */ -static bool -special_unset_or_matches (bson_matcher_t *matcher, - const bson_t *assertion, - const bson_val_t *actual, - void *ctx, - const char *path, - bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - bson_val_t *expected = NULL; - - BSON_UNUSED (ctx); - - bson_iter_init (&iter, assertion); - BSON_ASSERT (bson_iter_next (&iter)); - expected = bson_val_from_iter (&iter); - - if (actual == NULL) { - ret = true; - goto done; - } - - if (!bson_matcher_match (matcher, expected, actual, path, false, error)) { - goto done; - } - - ret = true; -done: - bson_val_destroy (expected); - return ret; -} - -/* implements $$matchesHexBytes */ -static bool -special_matches_hex_bytes (bson_matcher_t *matcher, - const bson_t *assertion, - const bson_val_t *actual, - void *ctx, - const char *path, - bson_error_t *error) -{ - bool ret = false; - uint8_t *expected_bytes; - uint32_t expected_bytes_len; - const uint8_t *actual_bytes; - uint32_t actual_bytes_len; - char *expected_bytes_string = NULL; - char *actual_bytes_string = NULL; - bson_iter_t iter; - - BSON_UNUSED (matcher); - BSON_UNUSED (ctx); - - bson_iter_init (&iter, assertion); - BSON_ASSERT (bson_iter_next (&iter)); - - if (!actual) { - MATCH_ERR ("%s", "does not exist but should"); - goto done; - } - - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - MATCH_ERR ("%s", "$$matchesHexBytes does not contain utf8"); - goto done; - } - - if (bson_val_type (actual) != BSON_TYPE_BINARY) { - MATCH_ERR ("%s", "value does not contain binary"); - goto done; - } - - expected_bytes = - hex_to_bin (bson_iter_utf8 (&iter, NULL), &expected_bytes_len); - actual_bytes = bson_val_to_binary (actual, &actual_bytes_len); - expected_bytes_string = bin_to_hex (expected_bytes, expected_bytes_len); - actual_bytes_string = bin_to_hex (actual_bytes, actual_bytes_len); - - if (expected_bytes_len != actual_bytes_len) { - MATCH_ERR ("expected %" PRIu32 " (%s) but got %" PRIu32 " (%s) bytes", - expected_bytes_len, - expected_bytes_string, - actual_bytes_len, - actual_bytes_string); - bson_free (expected_bytes); - bson_free (expected_bytes_string); - bson_free (actual_bytes_string); - goto done; - } - - if (0 != memcmp (expected_bytes, actual_bytes, expected_bytes_len)) { - MATCH_ERR ( - "expected %s, but got %s", expected_bytes_string, actual_bytes_string); - bson_free (expected_bytes); - bson_free (expected_bytes_string); - bson_free (actual_bytes_string); - goto done; - } - - bson_free (expected_bytes); - bson_free (expected_bytes_string); - bson_free (actual_bytes_string); - - ret = true; - goto done; -done: - return ret; -} - -static bool -evaluate_special (bson_matcher_t *matcher, - const bson_t *assertion, - const bson_val_t *actual, - const char *path, - bson_error_t *error) -{ - bson_iter_t iter; - const char *assertion_key; - special_functor_t *special_iter; - - bson_iter_init (&iter, assertion); - BSON_ASSERT (bson_iter_next (&iter)); - assertion_key = bson_iter_key (&iter); - - LL_FOREACH (matcher->specials, special_iter) - { - if (0 == strcmp (assertion_key, special_iter->keyword)) { - return special_iter->fn ( - matcher, assertion, actual, special_iter->ctx, path, error); - } - } - - MATCH_ERR ("unrecognized special operator: %s", assertion_key); - return false; -} - - -bson_matcher_t * -bson_matcher_new (void) -{ - bson_matcher_t *matcher = bson_malloc0 (sizeof (bson_matcher_t)); - /* Add default special functions. */ - bson_matcher_add_special ( - matcher, "$$placeholder", special_placeholder, NULL); - bson_matcher_add_special (matcher, "$$exists", special_exists, NULL); - bson_matcher_add_special (matcher, "$$type", special_type, NULL); - bson_matcher_add_special ( - matcher, "$$unsetOrMatches", special_unset_or_matches, NULL); - bson_matcher_add_special ( - matcher, "$$matchesHexBytes", special_matches_hex_bytes, NULL); - return matcher; -} - -/* Add a hook function for matching a special $$ operator */ -void -bson_matcher_add_special (bson_matcher_t *matcher, - const char *keyword, - special_fn special, - void *ctx) -{ - special_functor_t *functor; - - if (strstr (keyword, "$$") != keyword) { - test_error ( - "unexpected special match keyword: %s. Should start with '$$'", - keyword); - } - - functor = bson_malloc (sizeof (special_functor_t)); - functor->keyword = bson_strdup (keyword); - functor->fn = special; - functor->ctx = ctx; - LL_PREPEND (matcher->specials, functor); -} - -void -bson_matcher_destroy (bson_matcher_t *matcher) -{ - special_functor_t *special_iter, *tmp; - - if (!matcher) { - return; - } - - LL_FOREACH_SAFE (matcher->specials, special_iter, tmp) - { - bson_free (special_iter->keyword); - bson_free (special_iter); - } - bson_free (matcher); -} - -bool -bson_matcher_match (bson_matcher_t *matcher, - const bson_val_t *expected, - const bson_val_t *actual, - const char *path, - bool array_of_root_docs, - bson_error_t *error) -{ - bool ret = false; - bool is_root = (0 == strcmp (path, "")); - - if (bson_val_type (expected) == BSON_TYPE_DOCUMENT) { - bson_iter_t expected_iter; - const bson_t *expected_bson = bson_val_to_document (expected); - const bson_t *actual_bson = NULL; - uint32_t expected_keys; - uint32_t actual_keys; - - /* handle special operators (e.g. $$type) */ - if (is_special_match (expected_bson)) { - ret = evaluate_special (matcher, expected_bson, actual, path, error); - goto done; - } - - if (bson_val_type (actual) != BSON_TYPE_DOCUMENT) { - MATCH_ERR ("expected type document, got %s", - bson_type_to_string (bson_val_type (actual))); - goto done; - } - - actual_bson = bson_val_to_document (actual); - - BSON_FOREACH (expected_bson, expected_iter) - { - const char *key; - bson_val_t *expected_val = NULL; - bson_val_t *actual_val = NULL; - bson_iter_t actual_iter; - char *path_child = NULL; - - key = bson_iter_key (&expected_iter); - expected_val = bson_val_from_iter (&expected_iter); - - if (bson_iter_init_find (&actual_iter, actual_bson, key)) { - actual_val = bson_val_from_iter (&actual_iter); - } - - if (bson_val_type (expected_val) == BSON_TYPE_DOCUMENT && - is_special_match (bson_val_to_document (expected_val))) { - bool special_ret; - path_child = bson_strdup_printf ("%s.%s", path, key); - special_ret = evaluate_special (matcher, - bson_val_to_document (expected_val), - actual_val, - path, - error); - bson_free (path_child); - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - if (!special_ret) { - goto done; - } - continue; - } - - if (NULL == actual_val) { - MATCH_ERR ("key %s is not present", key); - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - goto done; - } - - path_child = bson_strdup_printf ("%s.%s", path, key); - if (!bson_matcher_match ( - matcher, expected_val, actual_val, path_child, false, error)) { - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - bson_free (path_child); - goto done; - } - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - bson_free (path_child); - } - - expected_keys = bson_count_keys (expected_bson); - actual_keys = bson_count_keys (actual_bson); - - /* Unified test format spec: "When matching root-level documents, test - * runners MUST permit the actual document to contain additional fields - * not present in the expected document."" - * - * This logic must also handle the case where `expected` is one of any - * number of root documents within an array (i.e. cursor result). */ - if (!(is_root || array_of_root_docs) && expected_keys < actual_keys) { - MATCH_ERR ("expected %" PRIu32 " keys in document, got: %" PRIu32, - expected_keys, - actual_keys); - goto done; - } - - ret = true; - goto done; - } - - if (bson_val_type (expected) == BSON_TYPE_ARRAY) { - bson_iter_t expected_iter; - const bson_t *expected_bson = bson_val_to_array (expected); - const bson_t *actual_bson = NULL; - char *path_child = NULL; - uint32_t expected_keys = bson_count_keys (expected_bson); - uint32_t actual_keys; - - if (bson_val_type (actual) != BSON_TYPE_ARRAY) { - MATCH_ERR ("expected array, but got: %s", - bson_type_to_string (bson_val_type (actual))); - goto done; - } - - actual_bson = bson_val_to_array (actual); - actual_keys = bson_count_keys (actual_bson); - - if (expected_keys != actual_keys) { - MATCH_ERR ("expected array of size %" PRIu32 - ", but got array of size: %" PRIu32, - expected_keys, - actual_keys); - goto done; - } - - BSON_FOREACH (expected_bson, expected_iter) - { - bson_val_t *expected_val = bson_val_from_iter (&expected_iter); - bson_val_t *actual_val = NULL; - bson_iter_t actual_iter; - const char *key; - - key = bson_iter_key (&expected_iter); - if (!bson_iter_init_find (&actual_iter, actual_bson, key)) { - MATCH_ERR ("expected array index: %s, but did not exist", key); - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - goto done; - } - - actual_val = bson_val_from_iter (&actual_iter); - - path_child = bson_strdup_printf ("%s.%s", path, key); - if (!bson_matcher_match (matcher, - expected_val, - actual_val, - path_child, - (is_root && array_of_root_docs), - error)) { - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - bson_free (path_child); - goto done; - } - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - bson_free (path_child); - } - ret = true; - goto done; - } - - if (!bson_val_eq (expected, actual, BSON_VAL_FLEXIBLE_NUMERICS)) { - MATCH_ERR ("value %s != %s", - bson_val_to_json (expected), - bson_val_to_json (actual)); - goto done; - } - - ret = true; -done: - if (!ret && is_root) { - /* Append the error with more context at the root match. */ - bson_error_t tmp_error; - - memcpy (&tmp_error, error, sizeof (bson_error_t)); - test_set_error (error, - "BSON match failed: %s\n" - "Expected: %s\n" - "Actual: %s", - tmp_error.message, - bson_val_to_json (expected), - bson_val_to_json (actual)); - } - return ret; -} - -bool -bson_match (const bson_val_t *expected, - const bson_val_t *actual, - bool array_of_root_docs, - bson_error_t *error) -{ - bson_matcher_t *matcher = bson_matcher_new (); - bool matched = bson_matcher_match ( - matcher, expected, actual, "", array_of_root_docs, error); - bson_matcher_destroy (matcher); - return matched; -} - -typedef struct { - const char *desc; - const char *expected; - const char *actual; - bool expect_match; -} testcase_t; - -static void -test_match (void) -{ - testcase_t tests[] = { - {"int32 ==", "{'a': 1}", "{'a': 1}", true}, - {"int32 !=", "{'a': 1}", "{'a': 0}", false}, - {"$$exists", "{'a': {'$$exists': true}}", "{'a': 0}", true}, - {"$$exists fail", "{'a': {'$$exists': true}}", "{'b': 0}", false}, - {"does not $$exists", "{'a': {'$$exists': false}}", "{'b': 0}", true}, - {"$$unsetOrMatches match", - "{'a': {'$$unsetOrMatches': 1}}", - "{'a': 1}", - true}, - {"$$unsetOrMatches unset", "{'a': {'$$unsetOrMatches': 1}}", "{}", true}, - {"$$unsetOrMatches mismatch", - "{'a': {'$$unsetOrMatches': 'abc'}}", - "{'a': 1}", - false}, - {"$$type match", "{'a': {'$$type': 'string'}}", "{'a': 'abc'}", true}, - {"$$type mismatch", "{'a': {'$$type': 'string'}}", "{'a': 1}", false}, - {"$$type array match", - "{'a': {'$$type': ['string', 'int']}}", - "{'a': 1}", - true}, - {"$$type array mismatch", - "{'a': {'$$type': ['string', 'int']}}", - "{'a': 1.2}", - false}, - {"extra keys in root ok", "{'a': 1}", "{'a': 1, 'b': 2}", true}, - {"extra keys in subdoc not ok", - "{'a': {'b': 1}}", - "{'a': {'b': 1, 'c': 2}}", - false}}; - int i; - - for (i = 0; i < sizeof (tests) / sizeof (testcase_t); i++) { - testcase_t *test = tests + i; - bson_error_t error; - bson_val_t *expected = bson_val_from_json (test->expected); - bson_val_t *actual = bson_val_from_json (test->actual); - bool ret; - - ret = bson_match (expected, actual, false, &error); - if (test->expect_match) { - if (!ret) { - test_error ("%s: did not match with error: %s, but should have", - test->desc, - error.message); - } - } else { - if (ret) { - test_error ("%s: matched, but should not have", test->desc); - } - } - bson_val_destroy (expected); - bson_val_destroy (actual); - } -} - -void -test_bson_match_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/unified/selftest/bson/match", test_match); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/bsonutil/bson-match.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/bsonutil/bson-match.h deleted file mode 100644 index 1fc1bda21..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/bsonutil/bson-match.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BSONUTIL_BSON_MATCH_H -#define BSONUTIL_BSON_MATCH_H - -#include "bsonutil/bson-val.h" - -/* Matches bson values in accordance with the unified test format's "Evaluating - * Matches" rules. */ -bool -bson_match (const bson_val_t *expected, - const bson_val_t *actual, - bool array_of_root_docs, - bson_error_t *error); - -/* A bson_matcher_t may be used to extend the default matching behavior. */ -typedef struct _bson_matcher_t bson_matcher_t; - -bson_matcher_t * -bson_matcher_new (void); - -typedef bool (*special_fn) (bson_matcher_t *matcher, - const bson_t *assertion, - const bson_val_t *actual, - void *ctx, - const char *path, - bson_error_t *error); - -/* Adds a handler function for matching a special $$ operator. - * - * Example: - * bson_matcher_add_special (matcher, "$$custom", custom_matcher, NULL); - * This would call custom_matcher whenever a "$$custom" key is encountered in an - * expectation. - */ -void -bson_matcher_add_special (bson_matcher_t *matcher, - const char *keyword, - special_fn special, - void *ctx); - -bool -bson_matcher_match (bson_matcher_t *matcher, - const bson_val_t *expected, - const bson_val_t *actual, - const char *path, - bool array_of_root_docs, - bson_error_t *error); - -void -bson_matcher_destroy (bson_matcher_t *matcher); - -#endif /* BSONUTIL_BSON_MATCH_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/debug-stream.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/debug-stream.c deleted file mode 100644 index 8d4b8c92c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/debug-stream.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef DEBUG_STREAM_H -#define DEBUG_STREAM_H - -#include -#include - -#include "test-libmongoc.h" - - -#define MONGOC_STREAM_DEBUG 7 -typedef struct _mongoc_stream_debug_t { - mongoc_stream_t vtable; - mongoc_stream_t *wrapped; - debug_stream_stats_t *stats; -} mongoc_stream_debug_t; - - -static int -_mongoc_stream_debug_close (mongoc_stream_t *stream) -{ - return mongoc_stream_close (((mongoc_stream_debug_t *) stream)->wrapped); -} - - -static void -_mongoc_stream_debug_destroy (mongoc_stream_t *stream) -{ - mongoc_stream_debug_t *debug_stream = (mongoc_stream_debug_t *) stream; - - debug_stream->stats->n_destroyed++; - - mongoc_stream_destroy (debug_stream->wrapped); - bson_free (debug_stream); -} - - -static void -_mongoc_stream_debug_failed (mongoc_stream_t *stream) -{ - mongoc_stream_debug_t *debug_stream = (mongoc_stream_debug_t *) stream; - - debug_stream->stats->n_failed++; - - mongoc_stream_failed (debug_stream->wrapped); - bson_free (debug_stream); -} - - -static int -_mongoc_stream_debug_setsockopt (mongoc_stream_t *stream, - int level, - int optname, - void *optval, - mongoc_socklen_t optlen) -{ - return mongoc_stream_setsockopt (((mongoc_stream_debug_t *) stream)->wrapped, - level, - optname, - optval, - optlen); -} - - -static int -_mongoc_stream_debug_flush (mongoc_stream_t *stream) -{ - return mongoc_stream_flush (((mongoc_stream_debug_t *) stream)->wrapped); -} - - -static ssize_t -_mongoc_stream_debug_readv (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - size_t min_bytes, - int32_t timeout_msec) -{ - return mongoc_stream_readv (((mongoc_stream_debug_t *) stream)->wrapped, - iov, - iovcnt, - min_bytes, - timeout_msec); -} - - -static ssize_t -_mongoc_stream_debug_writev (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - int32_t timeout_msec) -{ - return mongoc_stream_writev ( - ((mongoc_stream_debug_t *) stream)->wrapped, iov, iovcnt, timeout_msec); -} - - -static bool -_mongoc_stream_debug_check_closed (mongoc_stream_t *stream) -{ - return mongoc_stream_check_closed ( - ((mongoc_stream_debug_t *) stream)->wrapped); -} - - -static bool -_mongoc_stream_debug_timed_out (mongoc_stream_t *stream) -{ - return mongoc_stream_timed_out (((mongoc_stream_debug_t *) stream)->wrapped); -} - - -static bool -_mongoc_stream_debug_should_retry (mongoc_stream_t *stream) -{ - return mongoc_stream_should_retry ( - ((mongoc_stream_debug_t *) stream)->wrapped); -} - - -static mongoc_stream_t * -_mongoc_stream_debug_get_base_stream (mongoc_stream_t *stream) -{ - mongoc_stream_t *wrapped = ((mongoc_stream_debug_t *) stream)->wrapped; - - /* "wrapped" is typically a mongoc_stream_buffered_t, get the real - * base stream */ - if (wrapped->get_base_stream) { - return wrapped->get_base_stream (wrapped); - } - - return wrapped; -} - - -mongoc_stream_t * -debug_stream_new (mongoc_stream_t *stream, debug_stream_stats_t *stats) -{ - mongoc_stream_debug_t *debug_stream; - - if (!stream) { - return NULL; - } - - debug_stream = (mongoc_stream_debug_t *) bson_malloc0 (sizeof *debug_stream); - - debug_stream->vtable.type = MONGOC_STREAM_DEBUG; - debug_stream->vtable.close = _mongoc_stream_debug_close; - debug_stream->vtable.destroy = _mongoc_stream_debug_destroy; - debug_stream->vtable.failed = _mongoc_stream_debug_failed; - debug_stream->vtable.flush = _mongoc_stream_debug_flush; - debug_stream->vtable.readv = _mongoc_stream_debug_readv; - debug_stream->vtable.writev = _mongoc_stream_debug_writev; - debug_stream->vtable.setsockopt = _mongoc_stream_debug_setsockopt; - debug_stream->vtable.check_closed = _mongoc_stream_debug_check_closed; - debug_stream->vtable.timed_out = _mongoc_stream_debug_timed_out; - debug_stream->vtable.should_retry = _mongoc_stream_debug_should_retry; - debug_stream->vtable.get_base_stream = _mongoc_stream_debug_get_base_stream; - - debug_stream->wrapped = stream; - debug_stream->stats = stats; - - return (mongoc_stream_t *) debug_stream; -} - - -mongoc_stream_t * -debug_stream_initiator (const mongoc_uri_t *uri, - const mongoc_host_list_t *host, - void *user_data, - bson_error_t *error) -{ - debug_stream_stats_t *stats; - mongoc_stream_t *default_stream; - - stats = (debug_stream_stats_t *) user_data; - - default_stream = - mongoc_client_default_stream_initiator (uri, host, stats->client, error); - - return debug_stream_new (default_stream, stats); -} - - -void -test_framework_set_debug_stream (mongoc_client_t *client, - debug_stream_stats_t *stats) -{ - BSON_ASSERT_PARAM (client); - - stats->client = client; - mongoc_client_set_stream_initiator (client, debug_stream_initiator, stats); -} - -#endif /* DEBUG_STREAM_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json-test.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json-test.h deleted file mode 100644 index 669e9b3f8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json-test.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2015-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef JSON_TEST_H -#define JSON_TEST_H - -#include "TestSuite.h" - -#include -#include - -#include "test-conveniences.h" -#include "json-test-monitoring.h" -#include "json-test-operations.h" - -#define MAX_NUM_TESTS 150 - -typedef void (*test_hook) (bson_t *test); - -typedef struct { - const char *description; - const char *reason; -} test_skip_t; - -typedef struct _json_test_config_t { - void *ctx; - const bson_t *scenario; - json_test_cb_t before_test_cb, after_test_cb; - json_test_operation_cb_t run_operation_cb; - json_test_events_check_cb_t events_check_cb; - bool command_started_events_only; - bool command_monitoring_allow_subset; - const char *uri_str; - /* skips is a NULL terminated list of tests to skip identified by the test - * "description" */ - test_skip_t *skips; -} json_test_config_t; - - -#define JSON_TEST_CONFIG_INIT \ - { \ - NULL, NULL, NULL, NULL, NULL, NULL, false, false, NULL, NULL \ - } - -bson_t * -get_bson_from_json_file (char *filename); - -int -collect_tests_from_dir (char (*paths)[MAX_TEST_NAME_LENGTH] /* OUT */, - const char *dir_path, - int paths_index, - int max_paths); - -void -assemble_path (const char *parent_path, - const char *child_name, - char *dst /* OUT */); - -mongoc_topology_description_type_t -topology_type_from_test (const char *type); - -const mongoc_server_description_t * -server_description_by_hostname (const mongoc_topology_description_t *topology, - const char *address); - -void -process_sdam_test_hello_responses (bson_t *phase, mongoc_topology_t *topology); - -void -test_server_selection_logic_cb (bson_t *test); - -mongoc_server_description_type_t -server_type_from_test (const char *type); - -void -activate_fail_point (mongoc_client_t *client, - const uint32_t server_id, - const bson_t *test, - const char *key); - -void -deactivate_fail_points (mongoc_client_t *client, uint32_t server_id); - -void -run_json_general_test (const json_test_config_t *config); - -void -json_test_config_cleanup (json_test_config_t *config); - -void -_install_json_test_suite_with_check (TestSuite *suite, - const char *base, - const char *subdir, - test_hook callback, - ...); - -void -install_json_test_suite (TestSuite *suite, - const char *base, - const char *subdir, - test_hook callback); - -#define install_json_test_suite_with_check(_suite, _base, _subdir, ...) \ - _install_json_test_suite_with_check ( \ - _suite, _base, _subdir, __VA_ARGS__, NULL) - -void -set_uri_opts_from_bson (mongoc_uri_t *uri, const bson_t *opts); - -void -insert_data (const char *db_name, - const char *collection_name, - const bson_t *scenario); - -bool -check_scenario_version (const bson_t *scenario); - -void -check_outcome_collection (mongoc_collection_t *collection, bson_t *test); - -#endif diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/auth/connection-string.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/auth/connection-string.json deleted file mode 100644 index 7b556a410..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/auth/connection-string.json +++ /dev/null @@ -1,372 +0,0 @@ -{ - "tests": [ - { - "description": "should use the default source and mechanism", - "uri": "mongodb://user:password@localhost", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "admin", - "mechanism": null, - "mechanism_properties": null - } - }, - { - "description": "should use the database when no authSource is specified", - "uri": "mongodb://user:password@localhost/foo", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "foo", - "mechanism": null, - "mechanism_properties": null - } - }, - { - "description": "should use the authSource when specified", - "uri": "mongodb://user:password@localhost/foo?authSource=bar", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "bar", - "mechanism": null, - "mechanism_properties": null - } - }, - { - "description": "should recognise the mechanism (GSSAPI)", - "uri": "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI", - "valid": true, - "credential": { - "username": "user@DOMAIN.COM", - "password": null, - "source": "$external", - "mechanism": "GSSAPI", - "mechanism_properties": { - "SERVICE_NAME": "mongodb" - } - } - }, - { - "description": "should ignore the database (GSSAPI)", - "uri": "mongodb://user%40DOMAIN.COM@localhost/foo?authMechanism=GSSAPI", - "valid": true, - "credential": { - "username": "user@DOMAIN.COM", - "password": null, - "source": "$external", - "mechanism": "GSSAPI", - "mechanism_properties": { - "SERVICE_NAME": "mongodb" - } - } - }, - { - "description": "should accept valid authSource (GSSAPI)", - "uri": "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authSource=$external", - "valid": true, - "credential": { - "username": "user@DOMAIN.COM", - "password": null, - "source": "$external", - "mechanism": "GSSAPI", - "mechanism_properties": { - "SERVICE_NAME": "mongodb" - } - } - }, - { - "description": "should accept generic mechanism property (GSSAPI)", - "uri": "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true", - "valid": true, - "credential": { - "username": "user@DOMAIN.COM", - "password": null, - "source": "$external", - "mechanism": "GSSAPI", - "mechanism_properties": { - "SERVICE_NAME": "other", - "CANONICALIZE_HOST_NAME": true - } - } - }, - { - "description": "should accept the password (GSSAPI)", - "uri": "mongodb://user%40DOMAIN.COM:password@localhost/?authMechanism=GSSAPI&authSource=$external", - "valid": true, - "credential": { - "username": "user@DOMAIN.COM", - "password": "password", - "source": "$external", - "mechanism": "GSSAPI", - "mechanism_properties": { - "SERVICE_NAME": "mongodb" - } - } - }, - { - "description": "should throw an exception if authSource is invalid (GSSAPI)", - "uri": "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authSource=foo", - "valid": false - }, - { - "description": "should throw an exception if no username (GSSAPI)", - "uri": "mongodb://localhost/?authMechanism=GSSAPI", - "valid": false - }, - { - "description": "should recognize the mechanism (MONGODB-CR)", - "uri": "mongodb://user:password@localhost/?authMechanism=MONGODB-CR", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "admin", - "mechanism": "MONGODB-CR", - "mechanism_properties": null - } - }, - { - "description": "should use the database when no authSource is specified (MONGODB-CR)", - "uri": "mongodb://user:password@localhost/foo?authMechanism=MONGODB-CR", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "foo", - "mechanism": "MONGODB-CR", - "mechanism_properties": null - } - }, - { - "description": "should use the authSource when specified (MONGODB-CR)", - "uri": "mongodb://user:password@localhost/foo?authMechanism=MONGODB-CR&authSource=bar", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "bar", - "mechanism": "MONGODB-CR", - "mechanism_properties": null - } - }, - { - "description": "should throw an exception if no username is supplied (MONGODB-CR)", - "uri": "mongodb://localhost/?authMechanism=MONGODB-CR", - "valid": false - }, - { - "description": "should recognize the mechanism (MONGODB-X509)", - "uri": "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/?authMechanism=MONGODB-X509", - "valid": true, - "credential": { - "username": "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry", - "password": null, - "source": "$external", - "mechanism": "MONGODB-X509", - "mechanism_properties": null - } - }, - { - "description": "should ignore the database (MONGODB-X509)", - "uri": "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/foo?authMechanism=MONGODB-X509", - "valid": true, - "credential": { - "username": "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry", - "password": null, - "source": "$external", - "mechanism": "MONGODB-X509", - "mechanism_properties": null - } - }, - { - "description": "should accept valid authSource (MONGODB-X509)", - "uri": "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/?authMechanism=MONGODB-X509&authSource=$external", - "valid": true, - "credential": { - "username": "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry", - "password": null, - "source": "$external", - "mechanism": "MONGODB-X509", - "mechanism_properties": null - } - }, - { - "description": "should recognize the mechanism with no username (MONGODB-X509)", - "uri": "mongodb://localhost/?authMechanism=MONGODB-X509", - "valid": true, - "credential": { - "username": null, - "password": null, - "source": "$external", - "mechanism": "MONGODB-X509", - "mechanism_properties": null - } - }, - { - "description": "should throw an exception if supplied a password (MONGODB-X509)", - "uri": "mongodb://user:password@localhost/?authMechanism=MONGODB-X509", - "valid": false - }, - { - "description": "should throw an exception if authSource is invalid (MONGODB-X509)", - "uri": "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/foo?authMechanism=MONGODB-X509&authSource=bar", - "valid": false - }, - { - "description": "should recognize the mechanism (PLAIN)", - "uri": "mongodb://user:password@localhost/?authMechanism=PLAIN", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "$external", - "mechanism": "PLAIN", - "mechanism_properties": null - } - }, - { - "description": "should use the database when no authSource is specified (PLAIN)", - "uri": "mongodb://user:password@localhost/foo?authMechanism=PLAIN", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "foo", - "mechanism": "PLAIN", - "mechanism_properties": null - } - }, - { - "description": "should use the authSource when specified (PLAIN)", - "uri": "mongodb://user:password@localhost/foo?authMechanism=PLAIN&authSource=bar", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "bar", - "mechanism": "PLAIN", - "mechanism_properties": null - } - }, - { - "description": "should throw an exception if no username (PLAIN)", - "uri": "mongodb://localhost/?authMechanism=PLAIN", - "valid": false - }, - { - "description": "should recognize the mechanism (SCRAM-SHA-1)", - "uri": "mongodb://user:password@localhost/?authMechanism=SCRAM-SHA-1", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "admin", - "mechanism": "SCRAM-SHA-1", - "mechanism_properties": null - } - }, - { - "description": "should use the database when no authSource is specified (SCRAM-SHA-1)", - "uri": "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-1", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "foo", - "mechanism": "SCRAM-SHA-1", - "mechanism_properties": null - } - }, - { - "description": "should accept valid authSource (SCRAM-SHA-1)", - "uri": "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-1&authSource=bar", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "bar", - "mechanism": "SCRAM-SHA-1", - "mechanism_properties": null - } - }, - { - "description": "should throw an exception if no username (SCRAM-SHA-1)", - "uri": "mongodb://localhost/?authMechanism=SCRAM-SHA-1", - "valid": false - }, - { - "description": "should recognize the mechanism (SCRAM-SHA-256)", - "uri": "mongodb://user:password@localhost/?authMechanism=SCRAM-SHA-256", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "admin", - "mechanism": "SCRAM-SHA-256", - "mechanism_properties": null - } - }, - { - "description": "should use the database when no authSource is specified (SCRAM-SHA-256)", - "uri": "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-256", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "foo", - "mechanism": "SCRAM-SHA-256", - "mechanism_properties": null - } - }, - { - "description": "should accept valid authSource (SCRAM-SHA-256)", - "uri": "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-256&authSource=bar", - "valid": true, - "credential": { - "username": "user", - "password": "password", - "source": "bar", - "mechanism": "SCRAM-SHA-256", - "mechanism_properties": null - } - }, - { - "description": "should throw an exception if no username (SCRAM-SHA-256)", - "uri": "mongodb://localhost/?authMechanism=SCRAM-SHA-256", - "valid": false - }, - { - "description": "URI with no auth-related info doesn't create credential", - "uri": "mongodb://localhost/", - "valid": true, - "credential": null - }, - { - "description": "database in URI path doesn't create credentials", - "uri": "mongodb://localhost/foo", - "valid": true, - "credential": null - }, - { - "description": "authSource without username doesn't create credential (default mechanism)", - "uri": "mongodb://localhost/?authSource=foo", - "valid": true, - "credential": null - }, - { - "description": "should throw an exception if no username provided (userinfo implies default mechanism)", - "uri": "mongodb://@localhost.com/", - "valid": false - }, - { - "description": "should throw an exception if no username/password provided (userinfo implies default mechanism)", - "uri": "mongodb://:@localhost.com/", - "valid": false - } - ] -} - diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams-errors.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams-errors.json deleted file mode 100644 index 7b3fa8068..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams-errors.json +++ /dev/null @@ -1,153 +0,0 @@ -{ - "collection_name": "test", - "database_name": "change-stream-tests", - "collection2_name": "test2", - "database2_name": "change-stream-tests-2", - "tests": [ - { - "description": "The watch helper must not throw a custom exception when executed against a single server topology, but instead depend on a server error", - "minServerVersion": "3.6.0", - "target": "collection", - "topology": [ - "single" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [], - "expectations": null, - "result": { - "error": { - "code": 40573 - } - } - }, - { - "description": "Change Stream should error when an invalid aggregation stage is passed in", - "minServerVersion": "3.6.0", - "target": "collection", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [ - { - "$unsupported": "foo" - } - ], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "z": 3 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - }, - { - "$unsupported": "foo" - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "error": { - "code": 40324 - } - } - }, - { - "description": "Change Stream should error when _id is projected out", - "minServerVersion": "4.1.11", - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [ - { - "$project": { - "_id": 0 - } - } - ], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "z": 3 - } - } - } - ], - "result": { - "error": { - "code": 280 - } - } - }, - { - "description": "change stream errors on ElectionInProgress", - "minServerVersion": "4.2", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 216, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "z": 3 - } - } - } - ], - "result": { - "error": { - "code": 216 - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams-resume-allowlist.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams-resume-allowlist.json deleted file mode 100644 index baffc8fba..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams-resume-allowlist.json +++ /dev/null @@ -1,1750 +0,0 @@ -{ - "collection_name": "test", - "database_name": "change-stream-tests", - "tests": [ - { - "description": "change stream resumes after a network error", - "minServerVersion": "4.2", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "closeConnection": true - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after HostUnreachable", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 6, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after HostNotFound", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 7, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after NetworkTimeout", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 89, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after ShutdownInProgress", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 91, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after PrimarySteppedDown", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 189, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after ExceededTimeLimit", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 262, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after SocketException", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 9001, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after NotWritablePrimary", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 10107, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after InterruptedAtShutdown", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 11600, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after InterruptedDueToReplStateChange", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 11602, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after NotPrimaryNoSecondaryOk", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 13435, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after NotPrimaryOrSecondary", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 13436, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after StaleShardVersion", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 63, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after StaleEpoch", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 150, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after RetryChangeStream", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 234, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after FailedToSatisfyReadPreference", - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 133, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after CursorNotFound", - "minServerVersion": "4.2", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 43, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams-resume-errorLabels.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams-resume-errorLabels.json deleted file mode 100644 index 2bac61d3b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams-resume-errorLabels.json +++ /dev/null @@ -1,1652 +0,0 @@ -{ - "collection_name": "test", - "database_name": "change-stream-tests", - "tests": [ - { - "description": "change stream resumes after HostUnreachable", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 6, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after HostNotFound", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 7, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after NetworkTimeout", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 89, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after ShutdownInProgress", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 91, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after PrimarySteppedDown", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 189, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after ExceededTimeLimit", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 262, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after SocketException", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 9001, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after NotWritablePrimary", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 10107, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after InterruptedAtShutdown", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 11600, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after InterruptedDueToReplStateChange", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 11602, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after NotPrimaryNoSecondaryOk", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 13435, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after NotPrimaryOrSecondary", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 13436, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after StaleShardVersion", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 63, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after StaleEpoch", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 150, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after RetryChangeStream", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 234, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes after FailedToSatisfyReadPreference", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 133, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream resumes if error contains ResumableChangeStreamError", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 50, - "closeConnection": false, - "errorLabels": [ - "ResumableChangeStreamError" - ] - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": 42, - "collection": "test" - }, - "command_name": "getMore", - "database_name": "change-stream-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "change stream does not resume if error does not contain ResumableChangeStreamError", - "minServerVersion": "4.3.1", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 6, - "closeConnection": false - } - }, - "target": "collection", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "result": { - "error": { - "code": 6 - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams.json deleted file mode 100644 index 54b76af0a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/legacy/change-streams.json +++ /dev/null @@ -1,795 +0,0 @@ -{ - "collection_name": "test", - "database_name": "change-stream-tests", - "collection2_name": "test2", - "database2_name": "change-stream-tests-2", - "tests": [ - { - "description": "$changeStream must be the first stage in a change stream pipeline sent to the server", - "minServerVersion": "3.6.0", - "target": "collection", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "The server returns change stream responses in the specified server response format", - "minServerVersion": "3.6.0", - "target": "collection", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - } - ], - "expectations": null, - "result": { - "success": [ - { - "_id": "42", - "documentKey": "42", - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - } - ] - } - }, - { - "description": "Executing a watch helper on a Collection results in notifications for changes to the specified collection", - "minServerVersion": "3.6.0", - "target": "collection", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test2", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "database": "change-stream-tests-2", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "y": 2 - } - } - }, - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "z": 3 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "z": { - "$numberInt": "3" - } - } - } - ] - } - }, - { - "description": "Change Stream should allow valid aggregate pipeline stages", - "minServerVersion": "3.6.0", - "target": "collection", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [ - { - "$match": { - "fullDocument.z": 3 - } - } - ], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "y": 2 - } - } - }, - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "z": 3 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - }, - { - "$match": { - "fullDocument.z": { - "$numberInt": "3" - } - } - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "z": { - "$numberInt": "3" - } - } - } - ] - } - }, - { - "description": "Executing a watch helper on a Database results in notifications for changes to all collections in the specified database.", - "minServerVersion": "3.8.0", - "target": "database", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test2", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "database": "change-stream-tests-2", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "y": 2 - } - } - }, - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "z": 3 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": { - "$numberInt": "1" - }, - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test2" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - }, - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "z": { - "$numberInt": "3" - } - } - } - ] - } - }, - { - "description": "Executing a watch helper on a MongoClient results in notifications for changes to all collections in all databases in the cluster.", - "minServerVersion": "3.8.0", - "target": "client", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test2", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "database": "change-stream-tests-2", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "y": 2 - } - } - }, - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "z": 3 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": { - "$numberInt": "1" - }, - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "allChangesForCluster": true - } - } - ] - }, - "command_name": "aggregate", - "database_name": "admin" - } - } - ], - "result": { - "success": [ - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test2" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - }, - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests-2", - "coll": "test" - }, - "fullDocument": { - "y": { - "$numberInt": "2" - } - } - }, - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "z": { - "$numberInt": "3" - } - } - } - ] - } - }, - { - "description": "Test insert, update, replace, and delete event types", - "minServerVersion": "3.6.0", - "target": "collection", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "database": "change-stream-tests", - "collection": "test", - "name": "updateOne", - "arguments": { - "filter": { - "x": 1 - }, - "update": { - "$set": { - "x": 2 - } - } - } - }, - { - "database": "change-stream-tests", - "collection": "test", - "name": "replaceOne", - "arguments": { - "filter": { - "x": 2 - }, - "replacement": { - "x": 3 - } - } - }, - { - "database": "change-stream-tests", - "collection": "test", - "name": "deleteOne", - "arguments": { - "filter": { - "x": 3 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - }, - { - "operationType": "update", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "updateDescription": { - "updatedFields": { - "x": { - "$numberInt": "2" - } - } - } - }, - { - "operationType": "replace", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "3" - } - } - }, - { - "operationType": "delete", - "ns": { - "db": "change-stream-tests", - "coll": "test" - } - } - ] - } - }, - { - "description": "Test rename and invalidate event types", - "minServerVersion": "4.0.1", - "target": "collection", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "rename", - "arguments": { - "to": "test2" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "operationType": "rename", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "to": { - "db": "change-stream-tests", - "coll": "test2" - } - }, - { - "operationType": "invalidate" - } - ] - } - }, - { - "description": "Test drop and invalidate event types", - "minServerVersion": "4.0.1", - "target": "collection", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [], - "changeStreamOptions": {}, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "drop" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "operationType": "drop", - "ns": { - "db": "change-stream-tests", - "coll": "test" - } - }, - { - "operationType": "invalidate" - } - ] - } - }, - { - "description": "Test consecutive resume", - "minServerVersion": "4.1.7", - "target": "collection", - "topology": [ - "replicaset" - ], - "changeStreamPipeline": [], - "changeStreamOptions": { - "batchSize": 1 - }, - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "getMore" - ], - "closeConnection": true - } - }, - "operations": [ - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 2 - } - } - }, - { - "database": "change-stream-tests", - "collection": "test", - "name": "insertOne", - "arguments": { - "document": { - "x": 3 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "cursor": { - "batchSize": 1 - }, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "command_name": "aggregate", - "database_name": "change-stream-tests" - } - } - ], - "result": { - "success": [ - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "1" - } - } - }, - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "2" - } - } - }, - { - "operationType": "insert", - "ns": { - "db": "change-stream-tests", - "coll": "test" - }, - "fullDocument": { - "x": { - "$numberInt": "3" - } - } - } - ] - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-disambiguatedPaths.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-disambiguatedPaths.json deleted file mode 100644 index b177e1ff5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-disambiguatedPaths.json +++ /dev/null @@ -1,252 +0,0 @@ -{ - "description": "disambiguatedPaths", - "schemaVersion": "1.3", - "createEntities": [ - { - "client": { - "id": "client0", - "useMultipleMongoses": false - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "collection0" - } - } - ], - "runOnRequirements": [ - { - "minServerVersion": "6.1.0", - "topologies": [ - "replicaset", - "sharded-replicaset", - "load-balanced", - "sharded" - ] - } - ], - "initialData": [ - { - "collectionName": "collection0", - "databaseName": "database0", - "documents": [] - } - ], - "tests": [ - { - "description": "disambiguatedPaths is not present when showExpandedEvents is false/unset", - "operations": [ - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": { - "1": 1 - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "updateOne", - "object": "collection0", - "arguments": { - "filter": { - "_id": 1 - }, - "update": { - "$set": { - "a.1": 2 - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "update", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "updateDescription": { - "updatedFields": { - "$$exists": true - }, - "removedFields": { - "$$exists": true - }, - "truncatedArrays": { - "$$exists": true - }, - "disambiguatedPaths": { - "$$exists": false - } - } - } - } - ] - }, - { - "description": "disambiguatedPaths is present on updateDescription when an ambiguous path is present", - "operations": [ - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": { - "1": 1 - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [], - "showExpandedEvents": true - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "updateOne", - "object": "collection0", - "arguments": { - "filter": { - "_id": 1 - }, - "update": { - "$set": { - "a.1": 2 - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "update", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "updateDescription": { - "updatedFields": { - "$$exists": true - }, - "removedFields": { - "$$exists": true - }, - "truncatedArrays": { - "$$exists": true - }, - "disambiguatedPaths": { - "a.1": [ - "a", - "1" - ] - } - } - } - } - ] - }, - { - "description": "disambiguatedPaths returns array indices as integers", - "operations": [ - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": [ - { - "1": 1 - } - ] - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [], - "showExpandedEvents": true - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "updateOne", - "object": "collection0", - "arguments": { - "filter": { - "_id": 1 - }, - "update": { - "$set": { - "a.0.1": 2 - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "update", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "updateDescription": { - "updatedFields": { - "$$exists": true - }, - "removedFields": { - "$$exists": true - }, - "truncatedArrays": { - "$$exists": true - }, - "disambiguatedPaths": { - "a.0.1": [ - "a", - { - "$$type": "int" - }, - "1" - ] - } - } - } - } - ] - } - ] - } - \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-errors.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-errors.json deleted file mode 100644 index 04fe8f04f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-errors.json +++ /dev/null @@ -1,246 +0,0 @@ -{ - "description": "change-streams-errors", - "schemaVersion": "1.7", - "runOnRequirements": [ - { - "serverless": "forbid" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ], - "ignoreCommandMonitoringEvents": [ - "killCursors" - ], - "useMultipleMongoses": false - } - }, - { - "client": { - "id": "globalClient", - "useMultipleMongoses": false - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "collection0" - } - }, - { - "database": { - "id": "globalDatabase0", - "client": "globalClient", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "globalCollection0", - "database": "globalDatabase0", - "collectionName": "collection0" - } - } - ], - "initialData": [ - { - "collectionName": "collection0", - "databaseName": "database0", - "documents": [] - } - ], - "tests": [ - { - "description": "The watch helper must not throw a custom exception when executed against a single server topology, but instead depend on a server error", - "runOnRequirements": [ - { - "minServerVersion": "3.6.0", - "topologies": [ - "single" - ] - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "expectError": { - "errorCode": 40573 - } - } - ] - }, - { - "description": "Change Stream should error when an invalid aggregation stage is passed in", - "runOnRequirements": [ - { - "minServerVersion": "3.6.0", - "topologies": [ - "replicaset" - ] - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [ - { - "$unsupported": "foo" - } - ] - }, - "expectError": { - "errorCode": 40324 - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - }, - { - "$unsupported": "foo" - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "Change Stream should error when _id is projected out", - "runOnRequirements": [ - { - "minServerVersion": "4.1.11", - "topologies": [ - "replicaset", - "sharded-replicaset", - "load-balanced" - ] - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [ - { - "$project": { - "_id": 0 - } - } - ] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "z": 3 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectError": { - "errorCode": 280 - } - } - ] - }, - { - "description": "change stream errors on ElectionInProgress", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "topologies": [ - "replicaset", - "sharded-replicaset", - "load-balanced" - ] - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 216, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "z": 3 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectError": { - "errorCode": 216 - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-resume-allowlist.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-resume-allowlist.json deleted file mode 100644 index b4953ec73..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-resume-allowlist.json +++ /dev/null @@ -1,2348 +0,0 @@ -{ - "description": "change-streams-resume-allowlist", - "schemaVersion": "1.7", - "runOnRequirements": [ - { - "minServerVersion": "3.6", - "topologies": [ - "replicaset", - "sharded-replicaset", - "load-balanced" - ], - "serverless": "forbid" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ], - "ignoreCommandMonitoringEvents": [ - "killCursors" - ], - "useMultipleMongoses": false - } - }, - { - "client": { - "id": "globalClient", - "useMultipleMongoses": false - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "collection0" - } - }, - { - "database": { - "id": "globalDatabase0", - "client": "globalClient", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "globalCollection0", - "database": "globalDatabase0", - "collectionName": "collection0" - } - } - ], - "tests": [ - { - "description": "change stream resumes after a network error", - "runOnRequirements": [ - { - "minServerVersion": "4.2" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "closeConnection": true - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after HostUnreachable", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 6, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after HostNotFound", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 7, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after NetworkTimeout", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 89, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after ShutdownInProgress", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 91, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after PrimarySteppedDown", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 189, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after ExceededTimeLimit", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 262, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after SocketException", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 9001, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after NotWritablePrimary", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 10107, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after InterruptedAtShutdown", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 11600, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after InterruptedDueToReplStateChange", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 11602, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after NotPrimaryNoSecondaryOk", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 13435, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after NotPrimaryOrSecondary", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 13436, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after StaleShardVersion", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 63, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after StaleEpoch", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 150, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after RetryChangeStream", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 234, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after FailedToSatisfyReadPreference", - "runOnRequirements": [ - { - "minServerVersion": "4.2", - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 133, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after CursorNotFound", - "runOnRequirements": [ - { - "minServerVersion": "4.2" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 43, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-resume-errorLabels.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-resume-errorLabels.json deleted file mode 100644 index f5f4505a9..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams-resume-errorLabels.json +++ /dev/null @@ -1,2130 +0,0 @@ -{ - "description": "change-streams-resume-errorlabels", - "schemaVersion": "1.7", - "runOnRequirements": [ - { - "minServerVersion": "4.3.1", - "topologies": [ - "replicaset", - "sharded-replicaset", - "load-balanced" - ], - "serverless": "forbid" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ], - "ignoreCommandMonitoringEvents": [ - "killCursors" - ], - "useMultipleMongoses": false - } - }, - { - "client": { - "id": "globalClient", - "useMultipleMongoses": false - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "collection0" - } - }, - { - "database": { - "id": "globalDatabase0", - "client": "globalClient", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "globalCollection0", - "database": "globalDatabase0", - "collectionName": "collection0" - } - } - ], - "tests": [ - { - "description": "change stream resumes after HostUnreachable", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 6, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after HostNotFound", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 7, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after NetworkTimeout", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 89, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after ShutdownInProgress", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 91, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after PrimarySteppedDown", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 189, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after ExceededTimeLimit", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 262, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after SocketException", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 9001, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after NotWritablePrimary", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 10107, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after InterruptedAtShutdown", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 11600, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after InterruptedDueToReplStateChange", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 11602, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after NotPrimaryNoSecondaryOk", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 13435, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after NotPrimaryOrSecondary", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 13436, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after StaleShardVersion", - "runOnRequirements": [ - { - "maxServerVersion": "6.0.99" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 63, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after StaleEpoch", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 150, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after RetryChangeStream", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 234, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes after FailedToSatisfyReadPreference", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failGetMoreAfterCursorCheckout", - "mode": { - "times": 1 - }, - "data": { - "errorCode": 133, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream resumes if error contains ResumableChangeStreamError", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 50, - "closeConnection": false, - "errorLabels": [ - "ResumableChangeStreamError" - ] - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$exists": true - }, - "collection": "collection0" - }, - "commandName": "getMore", - "databaseName": "database0" - } - }, - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "resumeAfter": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "change stream does not resume if error does not contain ResumableChangeStreamError", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "getMore" - ], - "errorCode": 6, - "closeConnection": false - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectError": { - "errorCode": 6 - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams.json deleted file mode 100644 index 25d868962..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/change_streams/unified/change-streams.json +++ /dev/null @@ -1,1795 +0,0 @@ -{ - "description": "change-streams", - "schemaVersion": "1.7", - "runOnRequirements": [ - { - "minServerVersion": "3.6", - "topologies": [ - "replicaset" - ], - "serverless": "forbid" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ], - "ignoreCommandMonitoringEvents": [ - "killCursors" - ], - "useMultipleMongoses": false - } - }, - { - "client": { - "id": "globalClient", - "useMultipleMongoses": false - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "collection0" - } - }, - { - "database": { - "id": "database1", - "client": "client0", - "databaseName": "database1" - } - }, - { - "collection": { - "id": "collection1", - "database": "database1", - "collectionName": "collection1" - } - }, - { - "database": { - "id": "globalDatabase0", - "client": "globalClient", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "globalCollection0", - "database": "globalDatabase0", - "collectionName": "collection0" - } - }, - { - "database": { - "id": "globalDatabase1", - "client": "globalClient", - "databaseName": "database1" - } - }, - { - "collection": { - "id": "globalCollection1", - "database": "globalDatabase1", - "collectionName": "collection1" - } - }, - { - "collection": { - "id": "globalDb1Collection0", - "database": "globalDatabase1", - "collectionName": "collection0" - } - }, - { - "collection": { - "id": "globalDb0Collection1", - "database": "globalDatabase0", - "collectionName": "collection1" - } - } - ], - "initialData": [ - { - "collectionName": "collection0", - "databaseName": "database0", - "documents": [] - } - ], - "tests": [ - { - "description": "Test array truncation", - "runOnRequirements": [ - { - "minServerVersion": "4.7" - } - ], - "operations": [ - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": 1, - "array": [ - "foo", - { - "a": "bar" - }, - 1, - 2, - 3 - ] - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "updateOne", - "object": "collection0", - "arguments": { - "filter": { - "_id": 1 - }, - "update": [ - { - "$set": { - "array": [ - "foo", - { - "a": "bar" - } - ] - } - } - ] - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "update", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "updateDescription": { - "updatedFields": {}, - "removedFields": [], - "truncatedArrays": [ - { - "field": "array", - "newSize": 2 - } - ] - } - } - } - ] - }, - { - "description": "Test with document comment", - "runOnRequirements": [ - { - "minServerVersion": "4.4" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [], - "comment": { - "name": "test1" - } - }, - "saveResultAsEntity": "changeStream0" - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "pipeline": [ - { - "$changeStream": {} - } - ], - "comment": { - "name": "test1" - } - } - } - } - ] - } - ] - }, - { - "description": "Test with document comment - pre 4.4", - "runOnRequirements": [ - { - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [], - "comment": { - "name": "test1" - } - }, - "expectError": { - "isClientError": false - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "pipeline": [ - { - "$changeStream": {} - } - ], - "comment": { - "name": "test1" - } - } - } - } - ] - } - ] - }, - { - "description": "Test with string comment", - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [], - "comment": "comment" - }, - "saveResultAsEntity": "changeStream0" - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "pipeline": [ - { - "$changeStream": {} - } - ], - "comment": "comment" - } - } - } - ] - } - ] - }, - { - "description": "Test that comment is set on getMore", - "runOnRequirements": [ - { - "minServerVersion": "4.4.0" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [], - "comment": { - "key": "value" - } - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0" - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "pipeline": [ - { - "$changeStream": {} - } - ], - "comment": { - "key": "value" - } - } - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "collection0", - "documents": [ - { - "_id": 1, - "a": 1 - } - ] - } - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$type": [ - "int", - "long" - ] - }, - "collection": "collection0", - "comment": { - "key": "value" - } - }, - "commandName": "getMore", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "Test that comment is not set on getMore - pre 4.4", - "runOnRequirements": [ - { - "maxServerVersion": "4.3.99" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [], - "comment": "comment" - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0" - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "pipeline": [ - { - "$changeStream": {} - } - ], - "comment": "comment" - } - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "collection0", - "documents": [ - { - "_id": 1, - "a": 1 - } - ] - } - } - }, - { - "commandStartedEvent": { - "command": { - "getMore": { - "$$type": [ - "int", - "long" - ] - }, - "collection": "collection0", - "comment": { - "$$exists": false - } - }, - "commandName": "getMore", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "to field is set in a rename change event", - "runOnRequirements": [ - { - "minServerVersion": "4.0.1" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "dropCollection", - "object": "database0", - "arguments": { - "collection": "collection1" - } - }, - { - "name": "rename", - "object": "collection0", - "arguments": { - "to": "collection1" - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "rename", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "to": { - "db": "database0", - "coll": "collection1" - } - } - } - ] - }, - { - "description": "Test unknown operationType MUST NOT err", - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [ - { - "$project": { - "operationType": "addedInFutureMongoDBVersion", - "ns": 1 - } - } - ] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "addedInFutureMongoDBVersion", - "ns": { - "db": "database0", - "coll": "collection0" - } - } - } - ] - }, - { - "description": "Test newField added in response MUST NOT err", - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [ - { - "$project": { - "operationType": 1, - "ns": 1, - "newField": "newFieldValue" - } - } - ] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "newField": "newFieldValue" - } - } - ] - }, - { - "description": "Test new structure in ns document MUST NOT err", - "runOnRequirements": [ - { - "minServerVersion": "3.6", - "maxServerVersion": "5.2.99" - }, - { - "minServerVersion": "6.0" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [ - { - "$project": { - "operationType": "insert", - "ns.viewOn": "db.coll" - } - } - ] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "viewOn": "db.coll" - } - } - } - ] - }, - { - "description": "Test modified structure in ns document MUST NOT err", - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [ - { - "$project": { - "operationType": "insert", - "ns": { - "db": "$ns.db", - "coll": "$ns.coll", - "viewOn": "db.coll" - } - } - } - ] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0", - "viewOn": "db.coll" - } - } - } - ] - }, - { - "description": "Test server error on projecting out _id", - "runOnRequirements": [ - { - "minServerVersion": "4.2" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [ - { - "$project": { - "_id": 0 - } - } - ] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectError": { - "errorCode": 280, - "errorCodeName": "ChangeStreamFatalError", - "errorLabelsContain": [ - "NonResumableChangeStreamError" - ] - } - } - ] - }, - { - "description": "Test projection in change stream returns expected fields", - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [ - { - "$project": { - "optype": "$operationType", - "ns": 1, - "newField": "value" - } - } - ] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "optype": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "newField": "value" - } - } - ] - }, - { - "description": "$changeStream must be the first stage in a change stream pipeline sent to the server", - "runOnRequirements": [ - { - "minServerVersion": "3.6.0" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "The server returns change stream responses in the specified server response format", - "runOnRequirements": [ - { - "minServerVersion": "3.6.0" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "_id": { - "$$exists": true - }, - "documentKey": { - "$$exists": true - }, - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - } - ] - }, - { - "description": "Executing a watch helper on a Collection results in notifications for changes to the specified collection", - "runOnRequirements": [ - { - "minServerVersion": "3.6.0" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalDb0Collection1", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "insertOne", - "object": "globalDb1Collection0", - "arguments": { - "document": { - "y": 2 - } - } - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "z": 3 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "z": 3, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "Change Stream should allow valid aggregate pipeline stages", - "runOnRequirements": [ - { - "minServerVersion": "3.6.0" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [ - { - "$match": { - "fullDocument.z": 3 - } - } - ] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "y": 2 - } - } - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "z": 3 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "z": 3, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - }, - { - "$match": { - "fullDocument.z": 3 - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "Executing a watch helper on a Database results in notifications for changes to all collections in the specified database.", - "runOnRequirements": [ - { - "minServerVersion": "3.8.0" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "database0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalDb0Collection1", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "insertOne", - "object": "globalDb1Collection0", - "arguments": { - "document": { - "y": 2 - } - } - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "z": 3 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection1" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "z": 3, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": 1, - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "Executing a watch helper on a MongoClient results in notifications for changes to all collections in all databases in the cluster.", - "runOnRequirements": [ - { - "minServerVersion": "3.8.0" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "client0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalDb0Collection1", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "insertOne", - "object": "globalDb1Collection0", - "arguments": { - "document": { - "y": 2 - } - } - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "z": 3 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection1" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database1", - "coll": "collection0" - }, - "fullDocument": { - "y": 2, - "_id": { - "$$exists": true - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "z": 3, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": 1, - "cursor": {}, - "pipeline": [ - { - "$changeStream": { - "allChangesForCluster": true - } - } - ] - }, - "commandName": "aggregate", - "databaseName": "admin" - } - } - ] - } - ] - }, - { - "description": "Test insert, update, replace, and delete event types", - "runOnRequirements": [ - { - "minServerVersion": "3.6.0" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "updateOne", - "object": "globalCollection0", - "arguments": { - "filter": { - "x": 1 - }, - "update": { - "$set": { - "x": 2 - } - } - } - }, - { - "name": "replaceOne", - "object": "globalCollection0", - "arguments": { - "filter": { - "x": 2 - }, - "replacement": { - "x": 3 - } - } - }, - { - "name": "deleteOne", - "object": "globalCollection0", - "arguments": { - "filter": { - "x": 3 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "update", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "updateDescription": { - "updatedFields": { - "x": 2 - }, - "removedFields": [], - "truncatedArrays": { - "$$unsetOrMatches": { - "$$exists": true - } - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "replace", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 3, - "_id": { - "$$exists": true - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "delete", - "ns": { - "db": "database0", - "coll": "collection0" - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "Test rename and invalidate event types", - "runOnRequirements": [ - { - "minServerVersion": "4.0.1" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "dropCollection", - "object": "database0", - "arguments": { - "collection": "collection1" - } - }, - { - "name": "rename", - "object": "globalCollection0", - "arguments": { - "to": "collection1" - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "rename", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "to": { - "db": "database0", - "coll": "collection1" - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "invalidate" - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "Test drop and invalidate event types", - "runOnRequirements": [ - { - "minServerVersion": "4.0.1" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "dropCollection", - "object": "database0", - "arguments": { - "collection": "collection0" - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "drop", - "ns": { - "db": "database0", - "coll": "collection0" - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "invalidate" - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": {}, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "Test consecutive resume", - "runOnRequirements": [ - { - "minServerVersion": "4.1.7" - } - ], - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "globalClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "getMore" - ], - "closeConnection": true - } - } - } - }, - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [], - "batchSize": 1 - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 1 - } - } - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 2 - } - } - }, - { - "name": "insertOne", - "object": "globalCollection0", - "arguments": { - "document": { - "x": 3 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 1, - "_id": { - "$$exists": true - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 2, - "_id": { - "$$exists": true - } - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "fullDocument": { - "x": 3, - "_id": { - "$$exists": true - } - } - } - } - ], - "expectEvents": [ - { - "client": "client0", - "ignoreExtraEvents": true, - "events": [ - { - "commandStartedEvent": { - "command": { - "aggregate": "collection0", - "cursor": { - "batchSize": 1 - }, - "pipeline": [ - { - "$changeStream": {} - } - ] - }, - "commandName": "aggregate", - "databaseName": "database0" - } - } - ] - } - ] - }, - { - "description": "Test wallTime field is set in a change event", - "runOnRequirements": [ - { - "minServerVersion": "6.0.0" - } - ], - "operations": [ - { - "name": "createChangeStream", - "object": "collection0", - "arguments": { - "pipeline": [] - }, - "saveResultAsEntity": "changeStream0" - }, - { - "name": "insertOne", - "object": "collection0", - "arguments": { - "document": { - "_id": 1, - "a": 1 - } - } - }, - { - "name": "iterateUntilDocumentOrError", - "object": "changeStream0", - "expectResult": { - "operationType": "insert", - "ns": { - "db": "database0", - "coll": "collection0" - }, - "wallTime": { - "$$exists": true - } - } - } - ] - } - ] -} \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-BypassQueryAnalysis.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-BypassQueryAnalysis.json deleted file mode 100644 index dcc3983ae..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-BypassQueryAnalysis.json +++ /dev/null @@ -1,262 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "serverless": "forbid", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ] - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedIndexed", - "bsonType": "string", - "queries": { - "queryType": "equality", - "contention": { - "$numberLong": "0" - } - } - }, - { - "keyId": { - "$binary": { - "base64": "q83vqxI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedUnindexed", - "bsonType": "string" - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "BypassQueryAnalysis decrypts", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - }, - "bypassQueryAnalysis": true - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedIndexed": { - "$binary": { - "base64": "C18BAAAFZAAgAAAAANnt+eLTkv4GdDPl8IAfJOvTzArOgFJQ2S/DcLza4W0DBXMAIAAAAAD2u+omZme3P2gBPehMQyQHQ153tPN1+z7bksYA9jKTpAVwADAAAAAAUnCOQqIvmR65YKyYnsiVfVrg9hwUVO3RhhKExo3RWOzgaS0QdsBL5xKFS0JhZSoWBXUAEAAAAAQSNFZ4EjSYdhI0EjRWeJASEHQAAgAAAAV2AFAAAAAAEjRWeBI0mHYSNBI0VniQEpQbp/ZJpWBKeDtKLiXb0P2E9wvc0g3f373jnYQYlJquOrlPOoEy3ngsHPJuSUijvWDsrQzqYa349K7G/66qaXEFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsBWwAIAAAAACkm0o9bj6j0HuADKc0svbqO2UHj6GrlNdF6yKNxh63xRJrAAAAAAAAAAAAAA==", - "subType": "06" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "_id": 1 - } - }, - "result": [ - { - "_id": 1, - "encryptedIndexed": "123" - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedIndexed": { - "$binary": { - "base64": "C18BAAAFZAAgAAAAANnt+eLTkv4GdDPl8IAfJOvTzArOgFJQ2S/DcLza4W0DBXMAIAAAAAD2u+omZme3P2gBPehMQyQHQ153tPN1+z7bksYA9jKTpAVwADAAAAAAUnCOQqIvmR65YKyYnsiVfVrg9hwUVO3RhhKExo3RWOzgaS0QdsBL5xKFS0JhZSoWBXUAEAAAAAQSNFZ4EjSYdhI0EjRWeJASEHQAAgAAAAV2AFAAAAAAEjRWeBI0mHYSNBI0VniQEpQbp/ZJpWBKeDtKLiXb0P2E9wvc0g3f373jnYQYlJquOrlPOoEy3ngsHPJuSUijvWDsrQzqYa349K7G/66qaXEFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsBWwAIAAAAACkm0o9bj6j0HuADKc0svbqO2UHj6GrlNdF6yKNxh63xRJrAAAAAAAAAAAAAA==", - "subType": "06" - } - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedIndexed", - "bsonType": "string", - "queries": { - "queryType": "equality", - "contention": { - "$numberLong": "0" - } - } - }, - { - "keyId": { - "$binary": { - "base64": "q83vqxI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedUnindexed", - "bsonType": "string" - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "find": "default", - "filter": { - "_id": 1 - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "encryptedIndexed": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "31eCYlbQoVboc5zwC8IoyJVSkag9PxREka8dkmbXJeY=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-EncryptedFields-vs-EncryptedFieldsMap.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-EncryptedFields-vs-EncryptedFieldsMap.json deleted file mode 100644 index b579979e9..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-EncryptedFields-vs-EncryptedFieldsMap.json +++ /dev/null @@ -1,213 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "serverless": "forbid", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ] - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedIndexed", - "bsonType": "string", - "queries": { - "queryType": "equality", - "contention": { - "$numberLong": "0" - } - } - }, - { - "keyId": { - "$binary": { - "base64": "q83vqxI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedUnindexed", - "bsonType": "string" - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "q83vqxI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "HBk9BWihXExNDvTp1lUxOuxuZK2Pe2ZdVdlsxPEBkiO1bS4mG5NNDsQ7zVxJAH8BtdOYp72Ku4Y3nwc0BUpIKsvAKX4eYXtlhv5zUQxWdeNFhg9qK7qb8nqhnnLeT0f25jFSqzWJoT379hfwDeu0bebJHr35QrJ8myZdPMTEDYF08QYQ48ShRBli0S+QzBHHAQiM2iJNr4svg2WR8JSeWQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "encryptedFieldsMap is preferred over remote encryptedFields", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - }, - "encryptedFieldsMap": { - "default.default": { - "fields": [] - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedUnindexed": { - "$binary": { - "base64": "BqvN76sSNJh2EjQSNFZ4kBICTQaVZPWgXp41I7mPV1rLFTtw1tXzjcdSEyxpKKqujlko5TeizkB9hHQ009dVY1+fgIiDcefh+eQrm3CkhQ==", - "subType": "06" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "_id": 1 - } - }, - "result": [ - { - "_id": 1, - "encryptedUnindexed": "value123" - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedUnindexed": { - "$binary": { - "base64": "BqvN76sSNJh2EjQSNFZ4kBICTQaVZPWgXp41I7mPV1rLFTtw1tXzjcdSEyxpKKqujlko5TeizkB9hHQ009dVY1+fgIiDcefh+eQrm3CkhQ==", - "subType": "06" - } - } - } - ], - "ordered": true - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "find": "default", - "filter": { - "_id": 1 - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "q83vqxI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "encryptedUnindexed": { - "$binary": { - "base64": "BqvN76sSNJh2EjQSNFZ4kBICTQaVZPWgXp41I7mPV1rLFTtw1tXzjcdSEyxpKKqujlko5TeizkB9hHQ009dVY1+fgIiDcefh+eQrm3CkhQ==", - "subType": "06" - } - } - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Aggregate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Aggregate.json deleted file mode 100644 index 9eaabe0d7..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Aggregate.json +++ /dev/null @@ -1,509 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Date. Aggregate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "0" - } - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDate": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDate": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "default", - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - } - } - ], - "cursor": {}, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "aggregate" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDate": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDate": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FA74j21GUEJb1DJBOpR9nVnjaDZnd8yAQNuaW9Qi26g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kJv//KVkbrobIBf+QeWC5jxn20mx/P0R1N6aCSMgKM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB+Whi9IUUGxfLEe+lGuIzLX4LFbIhaIAm5lRk65QTc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ybO1QU3CgvhO8JgRXH+HxKszWcpl5aGDYYVa75fHa1g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X3Y3eSAbbMg//JgiHHiFpYOpV61t8kkDexI+CQyitH4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SlNHXyqVFGDPrX/2ppwog6l4pwj3PKda2TkZbqgfSfA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "McjV8xwTF3xI7863DYOBdyvIv6UpzThl6v9vBRk05bI=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Correctness.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Correctness.json deleted file mode 100644 index fa887e089..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Correctness.json +++ /dev/null @@ -1,1840 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "Find with $gt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Find with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$gte": { - "$date": { - "$numberLong": "0" - } - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - }, - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Find with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - "result": [] - } - ] - }, - { - "description": "Find with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$lt": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - ] - } - ] - }, - { - "description": "Find with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$lte": { - "$date": { - "$numberLong": "1" - } - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - }, - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Find with $lt below min", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$lt": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - "result": { - "errorContains": "must be greater than the range minimum" - } - } - ] - }, - { - "description": "Find with $gt above max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "200" - } - } - } - } - }, - "result": { - "errorContains": "must be less than the range maximum" - } - } - ] - }, - { - "description": "Find with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "0" - } - }, - "$lt": { - "$date": { - "$numberLong": "2" - } - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Find with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - ] - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Find with full range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$gte": { - "$date": { - "$numberLong": "0" - } - }, - "$lte": { - "$date": { - "$numberLong": "200" - } - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - }, - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Find with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$in": [ - { - "$date": { - "$numberLong": "0" - } - } - ] - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - ] - } - ] - }, - { - "description": "Insert out of range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "-1" - } - } - } - }, - "result": { - "errorContains": "value must be greater than or equal to the minimum value" - } - } - ] - }, - { - "description": "Insert min and max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 200, - "encryptedDate": { - "$date": { - "$numberLong": "200" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": {}, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - }, - { - "_id": 200, - "encryptedDate": { - "$date": { - "$numberLong": "200" - } - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$gte": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - }, - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "1" - } - } - } - } - } - ] - }, - "result": [] - } - ] - }, - { - "description": "Aggregate with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$lt": { - "$date": { - "$numberLong": "1" - } - } - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$lte": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - }, - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lt below min", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$lt": { - "$date": { - "$numberLong": "0" - } - } - } - } - } - ] - }, - "result": { - "errorContains": "must be greater than the range minimum" - } - } - ] - }, - { - "description": "Aggregate with $gt above max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "200" - } - } - } - } - } - ] - }, - "result": { - "errorContains": "must be less than the range maximum" - } - } - ] - }, - { - "description": "Aggregate with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "0" - } - }, - "$lt": { - "$date": { - "$numberLong": "2" - } - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Aggregate with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - ] - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Aggregate with full range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$gte": { - "$date": { - "$numberLong": "0" - } - }, - "$lte": { - "$date": { - "$numberLong": "200" - } - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - }, - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ] - }, - { - "description": "Aggregate with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDate": { - "$in": [ - { - "$date": { - "$numberLong": "0" - } - } - ] - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - ] - } - ] - }, - { - "description": "Wrong type: Insert Double", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$numberDouble": "0" - } - } - }, - "result": { - "errorContains": "cannot encrypt element" - } - } - ] - }, - { - "description": "Wrong type: Find Double", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$gte": { - "$numberDouble": "0" - } - } - } - }, - "result": { - "errorContains": "value type is a date" - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Delete.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Delete.json deleted file mode 100644 index cce4faf18..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Delete.json +++ /dev/null @@ -1,437 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Date. Delete.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "deleteOne", - "arguments": { - "filter": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - "result": { - "deletedCount": 1 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDate": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDate": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "delete": "default", - "deletes": [ - { - "q": { - "encryptedDate": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "limit": 1 - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "delete" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDate": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-FindOneAndUpdate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-FindOneAndUpdate.json deleted file mode 100644 index 4392b6768..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-FindOneAndUpdate.json +++ /dev/null @@ -1,515 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Date. FindOneAndUpdate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "findOneAndUpdate", - "arguments": { - "filter": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "0" - } - } - } - }, - "update": { - "$set": { - "encryptedDate": { - "$date": { - "$numberLong": "2" - } - } - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDate": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDate": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "default", - "query": { - "encryptedDate": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "update": { - "$set": { - "encryptedDate": { - "$$type": "binData" - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "findAndModify" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDate": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDate": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hyDcE6QQjPrYJaIS/n7evEZFYcm31Tj89CpEYGF45cI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F08nMDWDZc+DbWM7XCEJNNCEYyinRmrvGP7EWhmp4is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cXH4688amcDc8kZOJq4UP8cE3R58Zl7e+Qo/1jyspps=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uURBxvTp3FBCVkd+LPqyuY7d6rMW6SGIJQEPY/wtkZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jG3hax1L3RBp9t38vUt53FsBxgr/+Si/vVISpAylYpE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kwtIW8MhH9Ky5xNjBx8gFA/SHh2YVphie7g5FGBzals=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FHflwFuEMu4xX0ZApHi+pdlBH+oevAtXckCUb5Wv0xU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ty4cnzJdAlbQKnh7px3GEYjBnvO+jIOaKjoTRDtmh3M=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-InsertFind.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-InsertFind.json deleted file mode 100644 index 27ce7881d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-InsertFind.json +++ /dev/null @@ -1,500 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Date. Insert and Find.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDate": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDate": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "find": "default", - "filter": { - "encryptedDate": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "find" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDate": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDate": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FA74j21GUEJb1DJBOpR9nVnjaDZnd8yAQNuaW9Qi26g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kJv//KVkbrobIBf+QeWC5jxn20mx/P0R1N6aCSMgKM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB+Whi9IUUGxfLEe+lGuIzLX4LFbIhaIAm5lRk65QTc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ybO1QU3CgvhO8JgRXH+HxKszWcpl5aGDYYVa75fHa1g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X3Y3eSAbbMg//JgiHHiFpYOpV61t8kkDexI+CQyitH4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SlNHXyqVFGDPrX/2ppwog6l4pwj3PKda2TkZbqgfSfA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "McjV8xwTF3xI7863DYOBdyvIv6UpzThl6v9vBRk05bI=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Update.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Update.json deleted file mode 100644 index f7d5a6af6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Date-Update.json +++ /dev/null @@ -1,517 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Date. Update.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDate": { - "$date": { - "$numberLong": "0" - } - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDate": { - "$date": { - "$numberLong": "1" - } - } - } - } - }, - { - "name": "updateOne", - "arguments": { - "filter": { - "encryptedDate": { - "$gt": { - "$date": { - "$numberLong": "0" - } - } - } - }, - "update": { - "$set": { - "encryptedDate": { - "$date": { - "$numberLong": "2" - } - } - } - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDate": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDate": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command_name": "update", - "command": { - "update": "default", - "ordered": true, - "updates": [ - { - "q": { - "encryptedDate": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "u": { - "$set": { - "encryptedDate": { - "$$type": "binData" - } - } - } - } - ], - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDate", - "bsonType": "date", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$date": { - "$numberLong": "0" - } - }, - "max": { - "$date": { - "$numberLong": "200" - } - } - } - } - ] - } - } - }, - "$db": "default" - } - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDate": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDate": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hyDcE6QQjPrYJaIS/n7evEZFYcm31Tj89CpEYGF45cI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F08nMDWDZc+DbWM7XCEJNNCEYyinRmrvGP7EWhmp4is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cXH4688amcDc8kZOJq4UP8cE3R58Zl7e+Qo/1jyspps=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uURBxvTp3FBCVkd+LPqyuY7d6rMW6SGIJQEPY/wtkZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jG3hax1L3RBp9t38vUt53FsBxgr/+Si/vVISpAylYpE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kwtIW8MhH9Ky5xNjBx8gFA/SHh2YVphie7g5FGBzals=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FHflwFuEMu4xX0ZApHi+pdlBH+oevAtXckCUb5Wv0xU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ty4cnzJdAlbQKnh7px3GEYjBnvO+jIOaKjoTRDtmh3M=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Aggregate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Aggregate.json deleted file mode 100644 index 401ee34e3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Aggregate.json +++ /dev/null @@ -1,1903 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Decimal. Aggregate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$numberDecimal": "0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "default", - "pipeline": [ - { - "$match": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$binary": { - "base64": "DeFiAAADcGF5bG9hZACxYgAABGcAnWIAAAMwAH0AAAAFZAAgAAAAAJu2KgiI8vM+kz9qD3ZQzFQY5qbgYqCqHG5R4jAlnlwXBXMAIAAAAAAAUXxFXsz764T79sGCdhxvNd5b6E/9p61FonsHyEIhogVsACAAAAAAt19RL3Oo5ni5L8kcvgOJYLgVYyXJExwP8pkuzLG7f/kAAzEAfQAAAAVkACAAAAAAPQPvL0ARjujSv2Rkm8r7spVsgeC1K3FWcskGGZ3OdDIFcwAgAAAAACgNn660GmefR8jLqzgR1u5O+Uocx9GyEHiBqVGko5FZBWwAIAAAAADflr+fsnZngm6KRWYgHa9JzK+bXogWl9evBU9sQUHPHQADMgB9AAAABWQAIAAAAAD2Zi6kcxmaD2mY3VWrP+wYJMPg6cSBIYPapxaFQxYFdQVzACAAAAAAM/cV36BLBY3xFBXsXJY8M9EHHOc/qrmdc2CJmj3M89gFbAAgAAAAAOpydOrKxx6m2gquSDV2Vv3w10GocmNCFeOo/fRhRH9JAAMzAH0AAAAFZAAgAAAAAOaNqI9srQ/mI9gwbk+VkizGBBH/PPWOVusgnfPk3tY1BXMAIAAAAAAc96O/pwKCmHCagT6T/QV/wz4vqO+R22GsZ1dse2Vg6QVsACAAAAAAgzIak+Q3UFLTHXPmJ+MuEklFtR3eLtvM+jdKkmGCV/YAAzQAfQAAAAVkACAAAAAA0XlQgy/Yu97EQOjronl9b3dcR1DFn3deuVhtTLbJZHkFcwAgAAAAACoMnpVl6EFJak8A+t5N4RFnQhkQEBnNAx8wDqmq5U/dBWwAIAAAAACR26FJif673qpwF1J1FEkQGJ1Ywcr/ZW6JQ7meGqzt1QADNQB9AAAABWQAIAAAAAAOtpNexRxfv0yRFvZO9DhlkpU4mDuAb8ykdLnE5Vf1VAVzACAAAAAAeblFKm/30orP16uQpZslvsoS8s0xfNPIBlw3VkHeekYFbAAgAAAAAPEoHj87sYE+nBut52/LPvleWQBzB/uaJFnosxp4NRO2AAM2AH0AAAAFZAAgAAAAAIr8xAFm1zPmrvW4Vy5Ct0W8FxMmyPmFzdWVzesBhAJFBXMAIAAAAABYeeXjJEzTHwxab6pUiCRiZjxgtN59a1y8Szy3hfkg+gVsACAAAAAAJuoY4rF8mbI+nKb+5XbZShJ8191o/e8ZCRHE0O4Ey8MAAzcAfQAAAAVkACAAAAAAl+ibLk0/+EwoqeC8S8cGgAtjtpQWGEZDsybMPnrrkwEFcwAgAAAAAHPPBudWgQ+HUorLDpJMqhS9VBF2VF5aLcxgrM1s+yU7BWwAIAAAAAAcCcBR2Vyv5pAFbaOU97yovuOi1+ATDnLLcAUqHecXcAADOAB9AAAABWQAIAAAAACR9erwLTb+tcWFZgJ2MEfM0PKI9uuwIjDTHADRFgD+SQVzACAAAAAAcOop8TXsGUVQoKhzUllMYWxL93xCOkwtIpV8Q6hiSYYFbAAgAAAAAKXKmh4V8veYwob1H03Q3p3PN8SRAaQwDT34KlNVUjiDAAM5AH0AAAAFZAAgAAAAALv0vCPgh7QpmM8Ug6ad5ioZJCh7pLMdT8FYyQioBQ6KBXMAIAAAAADsCPyIG8t6ApQkRk1fX/sfc1kpuWCWP8gAEpnYoBSHrQVsACAAAAAAJe/r67N6d8uTiogvfoR9rEXbIDjyLb9EVdqkayFFGaYAAzEwAH0AAAAFZAAgAAAAAIW4AxJgYoM0pcNTwk1RSbyjZGIqgKL1hcTJmNrnZmoPBXMAIAAAAAAZpfx3EFO0vY0f1eHnE0PazgqeNDTaj+pPJMUNW8lFrAVsACAAAAAAP+Um2vwW6Bj6vuz9DKz6+6aWkoKoEmFNoiz/xXm7lOsAAzExAH0AAAAFZAAgAAAAAKliO6L9zgeuufjj174hvmQGNRbmYYs9yAirL7OxwEW3BXMAIAAAAAAqU7vs3DWUQ95Eq8OejwWnD0GuXd+ASi/uD6S0l8MM1QVsACAAAAAAb9legYzsfctBPpHyl7YWpPmLr5QiNZFND/50N1vv2MUAAzEyAH0AAAAFZAAgAAAAAOGQcCBkk+j/Kzjt/Cs6g3BZPJG81wIHBS8JewHGpgk+BXMAIAAAAABjrxZXWCkdzrExwCgyHaafuPSQ4V4x2k9kUCAqUaYKDQVsACAAAAAADBU6KefT0v8zSmseaMNmQxKjJar72y7MojLFhkEHqrUAAzEzAH0AAAAFZAAgAAAAAPmCNEt4t97waOSd5hNi2fNCdWEkmcFJ37LI9k4Az4/5BXMAIAAAAABX7DuDPNg+duvELf3NbLWkPMFw2HGLgWGHyVWcPvSNCAVsACAAAAAAS7El1FtZ5STh8Q1FguvieyYX9b2DF1DFVsb9hzxXYRsAAzE0AH0AAAAFZAAgAAAAAD4vtVUYRNB+FD9yoQ2FVJH3nMeJeKbi6eZfth638YqbBXMAIAAAAAANCuUB4OdmuD6LaDK2f3vaqfgYYvg40wDXOBbcFjTqLwVsACAAAAAA9hqC2VoJBjwR7hcQ45xO8ZVojwC83jiRacCaDj6Px2gAAzE1AH0AAAAFZAAgAAAAAJPIRzjmTjbdIvshG6UslbEOd797ZSIdjGAhGWxVQvK1BXMAIAAAAABgmJ0Jh8WLs9IYs/a7DBjDWd8J3thW/AGJK7zDnMeYOAVsACAAAAAAi9zAsyAuou2oiCUHGc6QefLUkACa9IgeBhGu9W/r0X8AAzE2AH0AAAAFZAAgAAAAAABQyKQPoW8wGPIqnsTv69+DzIdRkohRhOhDmyVHkw9WBXMAIAAAAAAqWA2X4tB/h3O1Xlawtz6ndI6WaTwgU1QYflL35opu5gVsACAAAAAAWI/Gj5aZMwDIxztqmVL0g5LBcI8EdKEc2UA28pnekQoAAzE3AH0AAAAFZAAgAAAAACB7NOyGQ1Id3MYnxtBXqyZ5Ul/lHH6p1b10U63DfT6bBXMAIAAAAADpOryIcndxztkHSfLN3Kzq29sD8djS0PspDSqERMqokQVsACAAAAAADatsMW4ezgnyi1PiP7xk+gA4AFIN/fb5uJqfVkjg4UoAAzE4AH0AAAAFZAAgAAAAAKVfXLfs8XA14CRTB56oZwV+bFJN5BHraTXbqEXZDmTkBXMAIAAAAAASRWTsfGOpqdffiOodoqIgBzG/yzFyjR5CfUsIUIWGpgVsACAAAAAAkgCHbCwyX640/0Ni8+MoYxeHUiC+FSU4Mn9jTLYtgZgAAzE5AH0AAAAFZAAgAAAAAH/aZr4EuS0/noQR9rcF8vwoaxnxrwgOsSJ0ys8PkHhGBXMAIAAAAACd7ObGQW7qfddcvyxRTkPuvq/PHu7+6I5dxwS1Lzy5XAVsACAAAAAA3q0eKdV7KeU3pc+CtfypKR7BPxwaf30yu0j9FXeOOboAAzIwAH0AAAAFZAAgAAAAAKvlcpFFNq0oA+urq3w6d80PK1HHHw0H0yVWvU9aHijXBXMAIAAAAADWnAHQ5Fhlcjawki7kWzdqjM2f6IdGJblojrYElWjsZgVsACAAAAAAO0wvY66l24gx8nRxyVGC0QcTztIi81Kx3ndRhuZr6W4AAzIxAH0AAAAFZAAgAAAAAH/2aMezEOddrq+dNOkDrdqf13h2ttOnexZsJxG1G6PNBXMAIAAAAABNtgnibjC4VKy5poYjvdsBBnVvDTF/4mmEAxsXVgZVKgVsACAAAAAAqvadzJFLqQbs8WxgZ2D2X+XnaPSDMLCVVgWxx5jnLcYAAzIyAH0AAAAFZAAgAAAAAF2wZoDL6/V59QqO8vdRZWDpXpkV4h4KOCSn5e7x7nmzBXMAIAAAAADLZBu7LCYjbThaVUqMK14H/elrVOYIKJQCx4C9Yjw37gVsACAAAAAAEh6Vs81jLU204aGpL90fmYTm5i5R8/RT1uIbg6VU3HwAAzIzAH0AAAAFZAAgAAAAAH27yYaLn9zh2CpvaoomUPercSfJRUmBY6XFqmhcXi9QBXMAIAAAAAAUwumVlIYIs9JhDhSj0R0+59psCMsFk94E62VxkPt42QVsACAAAAAAT5x2hCCd2bpmpnyWaxas8nSxTc8e4C9DfKaqr0ABEysAAzI0AH0AAAAFZAAgAAAAALMg2kNAO4AFFs/mW3In04yFeN4AP6Vo0klyUoT06RquBXMAIAAAAAAgGWJbeIdwlpqXCyVIYSs0dt54Rfc8JF4b8uYc+YUj0AVsACAAAAAAWHeWxIkyvXTOWvfZzqtPXjfGaWWKjGSIQENTU3zBCrsAAzI1AH0AAAAFZAAgAAAAALas/i1T2DFCEmrrLEi7O2ngJZyFHialOoedVXS+OjenBXMAIAAAAAA1kK0QxY4REcGxHeMkgumyF7iwlsRFtw9MlbSSoQY7uAVsACAAAAAAUNlpMJZs1p4HfsD4Q4WZ4TBEi6Oc2fX34rzyynqWCdwAAzI2AH0AAAAFZAAgAAAAAP1TejmWg1CEuNSMt6NUgeQ5lT+oBoeyF7d2l5xQrbXWBXMAIAAAAABPX0kj6obggdJShmqtVfueKHplH4ZrXusiwrRDHMOKeQVsACAAAAAAIYOsNwC3DA7fLcOzqdr0bOFdHCfmK8tLwPoaE9uKOosAAzI3AH0AAAAFZAAgAAAAAMrKn+QPa/NxYezNhlOX9nyEkN1kE/gW7EuZkVqYl0b8BXMAIAAAAABUoZMSPUywRGfX2EEencJEKH5x/P9ySUVrhStAwgR/LgVsACAAAAAAMgZFH6lQIIDrgHnFeslv3ld20ynwQjQJt3cAp4GgrFkAAzI4AH0AAAAFZAAgAAAAAMmD1+a+oVbiUZd1HuZqdgtdVsVKwuWAn3/M1B6QGBM3BXMAIAAAAACLyytOYuZ9WEsIrrtJbXUx4QgipbaAbmlJvSZVkGi0CAVsACAAAAAA4v1lSp5H9BB+HYJ4bH43tC8aeuPZMf78Ng1JOhJh190AAzI5AH0AAAAFZAAgAAAAAOVKV7IuFwmYP1qVv8h0NvJmfPICu8yQhzjG7oJdTLDoBXMAIAAAAABL70XLfQLKRsw1deJ2MUvxSWKxpF/Ez73jqtbLvqbuogVsACAAAAAAvfgzIorXxE91dDt4nQxYfntTsx0M8Gzdsao5naQqcRUAAzMwAH0AAAAFZAAgAAAAAKS/1RSAQma+xV9rz04IcdzmavtrBDjOKPM+Z2NEyYfPBXMAIAAAAAAOJDWGORDgfRv8+w5nunh41wXb2hCA0MRzwnLnQtIqPgVsACAAAAAAf42C1+T7xdHEFF83+c2mF5S8PuuL22ogXXELnRAZ4boAAzMxAH0AAAAFZAAgAAAAAFeq8o82uNY1X8cH6OhdTzHNBUnCChsEDs5tm0kPBz3qBXMAIAAAAABaxMBbsaeEj/EDtr8nZfrhhhirBRPJwVamDo5WwbgvTQVsACAAAAAAMbH453A+BYAaDOTo5kdhV1VdND1avNwvshEG/4MIJjQAAzMyAH0AAAAFZAAgAAAAAI8IKIfDrohHh2cjspJHCovqroSr5N3QyVtNzFvT5+FzBXMAIAAAAABXHXteKG0DoOMmECKp6ro1MZNQvXGzqTDdZ0DUc8QfFAVsACAAAAAA/w5s++XYmO+9TWTbtGc3n3ndV4T9JUribIbF4jmDLSMAAzMzAH0AAAAFZAAgAAAAAJkHvm15kIu1OtAiaByj5ieWqzxiu/epK6c/9+KYIrB0BXMAIAAAAACzg5TcyANk0nes/wCJudd1BwlkWWF6zw3nGclq5v3SJQVsACAAAAAAvruXHTT3irPJLyWpI1j/Xwf2FeIE/IV+6Z49pqRzISoAAzM0AH0AAAAFZAAgAAAAAAYSOvEWWuSg1Aym7EssNLR+xsY7e9BcwsX4JKlnSHJcBXMAIAAAAABT48eY3PXVDOjw7JpNjOe1j2JyI3LjDnQoqZ8Je5B2KgVsACAAAAAAU2815RR57TQ9uDg0XjWjBkAKvf8yssxDMzrM4+FqP6AAAzM1AH0AAAAFZAAgAAAAAGQxC9L1e9DfO5XZvX1yvc3hTLtQEdKO9FPMkyg0Y9ZABXMAIAAAAADtmcMNJwdWLxQEArMGZQyzpnu+Z5yMmPAkvgq4eAKwNQVsACAAAAAAJ88zt4Y/Hoqh+zrf6KCOiUwHbOzCxSfp6k/qsZaYGEgAAzM2AH0AAAAFZAAgAAAAADLHK2LNCNRO0pv8n4fAsxwtUqCNnVK8rRgNiQfXpHSdBXMAIAAAAACf16EBIHRKD3SzjRW+LMOl+47QXA3CJhMzlcqyFRW22AVsACAAAAAAMGz4fAOa0EoVv90fUffwLjBrQhHATf+NdlgCR65vujAAAzM3AH0AAAAFZAAgAAAAAHiZJiXKNF8bbukQGsdYkEi95I+FSBHy1I5/hK2uEZruBXMAIAAAAADE+lZBa8HDUJPN+bF6xI9x4N7GF9pj3vBR7y0BcfFhBAVsACAAAAAAGIEN6sfqq30nyxW4dxDgXr/jz5HmvA9T1jx/pKCn4zgAAzM4AH0AAAAFZAAgAAAAAI1oa2OIw5TvhT14tYCGmhanUoYcCZtNbrVbeoMldHNZBXMAIAAAAAAx2nS0Ipblf2XOgBiUOuJFBupBhe7nb6QPLZlA4aMPCgVsACAAAAAA9xu828hugIgo0E3de9dZD+gTpVUGlwtDba+tw/WcbUoAAzM5AH0AAAAFZAAgAAAAABgTWS3Yap7Q59hii/uPPimHWXsr+DUmsqfwt/X73qsOBXMAIAAAAACKK05liW5KrmEAvtpCB1WUltruzUylDDpjea//UlWoOAVsACAAAAAAcgN4P/wakJ5aJK5c1bvJBqpVGND221dli2YicPFfuAYAAzQwAH0AAAAFZAAgAAAAABOAnBPXDp6i9TISQXvcNKwGDLepZTu3cKrB4vKnSCjBBXMAIAAAAADjjzZO7UowAAvpwyG8BNOVqLCccMFk3aDK4unUeft5ywVsACAAAAAA4zkCd4k9gvfXoD1C7vwTjNcdVJwEARh8h/cxZ4PNMfgAAzQxAH0AAAAFZAAgAAAAAHN8hyvT1lYrAsdiV5GBdd5jhtrAYE/KnSjw2Ka9hjz9BXMAIAAAAAD794JK7EeXBs+D7yOVK7nWF8SbZ/7U8gZ7nnT9JFNwTAVsACAAAAAAg8Wt1HO3NhByq2ggux2a4Lo6Gryr24rEFIqh2acrwWMAAzQyAH0AAAAFZAAgAAAAAO93bPrq8bsnp1AtNd9ETnXIz0lH/2HYN/vuw9wA3fyFBXMAIAAAAABHlls5fbaF2oAGqptC481XQ4eYxInTC29aElfmVZgDUgVsACAAAAAANoQXEWpXJpgrSNK/cKi/m7oYhuSRlp1IZBF0bqTEATcAAzQzAH0AAAAFZAAgAAAAAL1YsAZm1SA0ztU6ySIrQgCCA74V6rr0/4iIygCcaJL6BXMAIAAAAADTXWTHWovGmUR1Zg9l/Aqq9H5mOCJQQrb/Dfae7e3wKAVsACAAAAAA5dunyJK6/SVfDD0t9QlNBcFqoZnf9legRjHaLSKAoQMAAzQ0AH0AAAAFZAAgAAAAAEoFAeHk0RZ9kD+cJRD3j7PcE5gzWKnyBrF1I/MDNp5mBXMAIAAAAACgHtc2hMBRSZjKw8RAdDHK+Pi1HeyjiBuAslGVNcW5tAVsACAAAAAAXzBLfq+GxRtX4Wa9fazA49DBLG6AjZm2XODStJKH8D0AAzQ1AH0AAAAFZAAgAAAAAAW+7DmSN/LX+/0uBVJDHIc2dhxAGz4+ehyyz8fAnNGoBXMAIAAAAAA6Ilw42EvvfLJ3Eq8Afd+FjPoPcQutZO6ltmCLEr8kxQVsACAAAAAAbbZalyo07BbFjPFlYmbmv0z023eT9eLkHqeVUnfUAUAAAzQ2AH0AAAAFZAAgAAAAANBdV7M7kuYO3EMoQItAbXv4t2cIhfaT9V6+s4cg9djlBXMAIAAAAABvz4MIvZWxxrcJCL5qxLfFhXiUYB1OLHdKEjco94SgDgVsACAAAAAAK2GVGvyPIKolF/ECcmfmkVcf1/IZNcaTv96N92yGrkEAAzQ3AH0AAAAFZAAgAAAAAMoAoiAn1kc79j5oPZtlMWHMhhgwNhLUnvqkqIFvcH1NBXMAIAAAAADcJTW7WiCyW0Z9YDUYwppXhLj4Ac1povpJvcAq+i48MQVsACAAAAAAIGxGDzoeB3PTmudl4+j6piQB++e33EEzuzAiXcqGxvUAAzQ4AH0AAAAFZAAgAAAAACI3j5QP7dWHpcT6WO/OhsWwRJNASBYqIBDNzW8IorEyBXMAIAAAAABxUpBSjXwCKDdGP9hYU+RvyR+96kChfvyyRC4jZmztqAVsACAAAAAAvBCHguWswb4X0xdcAryCvZgQuthXzt7597bJ5VxAMdgAAzQ5AH0AAAAFZAAgAAAAAKsbycEuQSeNrF8Qnxqw3x3og8JmQabwGqnDbqzFRVrrBXMAIAAAAACno/3ef2JZJS93SVVzmOZSN+jjJHT8s0XYq2M46d2sLAVsACAAAAAAAt5zLJG+/j4K8rnkFtAn8IvdUVNefe6utJ3rdzgwudIAAzUwAH0AAAAFZAAgAAAAAPXIcoO8TiULqlxzb74NFg+I8kWX5uXIDUPnh2DobIoMBXMAIAAAAADR6/drkdTpnr9g1XNvKDwtBRBdKn7c2c4ZNUVK5CThdQVsACAAAAAAJqOA1c6KVog3F4Hb/GfDb3jCxXDRTqpXWSbMH4ePIJsAAzUxAH0AAAAFZAAgAAAAAEa03ZOJmfHT6/nVadvIw71jVxEuIloyvxXraYEW7u7pBXMAIAAAAADzRlBJK75FLiKjz3djqcgjCLo/e3yntI3MnPS48OORhgVsACAAAAAAnQhx4Rnyj081XrLRLD5NLpWmRWCsd0M9Hl7Jl19R0h8AAzUyAH0AAAAFZAAgAAAAAKx8NLSZUU04pSSGmHa5fh2oLHsEN5mmNMNHL95/tuC9BXMAIAAAAAA59hcXVaN3MNdHoo11OcH1aPRzHCwpVjO9mGfMz4xh3QVsACAAAAAAYIPdjV2XbPj7dBeHPwnwhVU7zMuJ+xtMUW5mIOYtmdAAAzUzAH0AAAAFZAAgAAAAAHNKAUxUqBFNS9Ea9NgCZoXMWgwhP4x0/OvoaPRWMquXBXMAIAAAAABUZ551mnP4ZjX+PXU9ttomzuOpo427MVynpkyq+nsYCQVsACAAAAAALnVK5p2tTTeZEh1zYt4iqKIQT9Z0si//Hy1L85oF+5IAAzU0AH0AAAAFZAAgAAAAALfGXDlyDVcGaqtyHkLT0qpuRhJQLgCxtznazhFtuyn/BXMAIAAAAABipxlXDq14C62pXhwAeen5+syA+/C6bN4rtZYcO4zKwAVsACAAAAAAXUf0pzUq0NhLYagWDap4uEiwq5rLpcx29rWbt1NYMsMAAzU1AH0AAAAFZAAgAAAAANoEr8sheJjg4UCfBkuUzarU9NFoy1xwbXjs5ifVDeA9BXMAIAAAAABPoyTf6M+xeZVGES4aNzVlq7LgjqZXJ/QunjYVusGUEAVsACAAAAAA1hA2gMeZZPUNytk9K+lB1RCqWRudRr7GtadJlExJf8oAAzU2AH0AAAAFZAAgAAAAAKvDiK+xjlBe1uQ3SZTNQl2lClIIvpP/5CHwY6Kb3WlgBXMAIAAAAAANnxImq5MFbWaRBHdJp+yD09bVlcFtiFDYsy1eDZj+iQVsACAAAAAAWtsyO+FxMPSIezwsV1TJD8ZrXAdRnQM6DJ+f+1V3qEkAAzU3AH0AAAAFZAAgAAAAAF49IlFH9RmSUSvUQpEPUedEksrQUcjsOv44nMkwXhjzBXMAIAAAAADJtWGbk0bZzmk20obz+mNsp86UCu/nLLlbg7ppxYn7PgVsACAAAAAA3k0Tj/XgPQtcYijH8cIlQoe/VXf15q1nrZNmg7yWYEgAAzU4AH0AAAAFZAAgAAAAAOuSJyuvz50lp3BzXlFKnq62QkN2quNU1Gq1IDsnFoJCBXMAIAAAAAAqavH1d93XV3IzshWlMnzznucadBF0ND092/2ApI1AcAVsACAAAAAAzUrK4kpoKCmcpdZlZNI13fddjdoAseVe67jaX1LobIIAAzU5AH0AAAAFZAAgAAAAALtgC4Whb4ZdkCiI30zY6fwlsxSa7lEaOAU3SfUXr02XBXMAIAAAAACgdZ6U1ZVgUaZZwbIaCdlANpCw6TZV0bwg3DS1NC/mnAVsACAAAAAAzI49hdpp0PbO7S2KexISxC16sE73EUAEyuqUFAC/J48AAzYwAH0AAAAFZAAgAAAAAF6PfplcGp6vek1ThwenMHVkbZgrc/dHgdsgx1VdPqZ5BXMAIAAAAACha3qhWkqmuwJSEXPozDO8y1ZdRLyzt9Crt2vjGnT7AAVsACAAAAAA7nvcU59+LwxGupSF21jAeAE0x7JE94tjRkJfgM1yKU8AAzYxAH0AAAAFZAAgAAAAAKoLEhLvLjKc7lhOJfx+VrGJCx9tXlOSa9bxQzGR6rfbBXMAIAAAAAAIDK5wNnjRMBzET7x/KAMExL/zi1IumJM92XTgXfoPoAVsACAAAAAAFkUYWFwNr815dEdFqp+TiIozDcq5IBNVkyMoDjharDQAAzYyAH0AAAAFZAAgAAAAADoQv6lutRmh5scQFvIW6K5JBquLxszuygM1tzBiGknIBXMAIAAAAADAD+JjW7FoBQ76/rsECmmcL76bmyfXpUU/awqIsZdO+wVsACAAAAAAPFHdLw3jssmEXsgtvl/RBNaUCRA1kgSwsofG364VOvQAAzYzAH0AAAAFZAAgAAAAAJNHUGAgn56KekghO19d11nai3lAh0JAlWfeP+6w4lJBBXMAIAAAAAD9XGJlvz59msJvA6St9fKW9CG4JoHV61rlWWnkdBRLzwVsACAAAAAAxwP/X/InJJHmrjznvahIMgj6pQR30B62UtHCthSjrP0AAzY0AH0AAAAFZAAgAAAAAHgYoMGjEE6fAlAhICv0+doHcVX8CmMVxyq7+jlyGrvmBXMAIAAAAAC/5MQZgTHuIr/O5Z3mXPvqrom5JTQ8IeSpQGhO9sB+8gVsACAAAAAAuPSXVmJUAUpTQg/A9Bu1hYczZF58KEhVofakygbsvJQAAzY1AH0AAAAFZAAgAAAAANpIljbxHOM7pydY877gpRQvYY2TGK7igqgGsavqGPBABXMAIAAAAAAqHyEu9gpurPOulApPnr0x9wrygY/7mXe9rAC+tPK80wVsACAAAAAA7gkPzNsS3gCxdFBWbSW9tkBjoR5ib+saDvpGSB3A3ogAAzY2AH0AAAAFZAAgAAAAAGR+gEaZTeGNgG9BuM1bX2R9ed4FCxBA9F9QvdQDAjZwBXMAIAAAAABSkrYFQ6pf8MZ1flgmeIRkxaSh/Eep4Btdx4QYnGGnwAVsACAAAAAApRovMiV00hm/pEcT4XBsyPNw0eo8RLAX/fuabjdU+uwAAzY3AH0AAAAFZAAgAAAAAFNprhQ3ZwIcYbuzLolAT5n/vc14P9kUUQComDu6eFyKBXMAIAAAAAAcx9z9pk32YbPV/sfPZl9ALIEVsqoLXgqWLVK/tP+heAVsACAAAAAA/qxvuvJbAHwwhfrPVpmCFzNvg2cU/NXaWgqgYUZpgXwAAzY4AH0AAAAFZAAgAAAAADgyPqQdqQrgfmJjRFAILTHzXbdw5kpKyfeoEcy6YYG/BXMAIAAAAAAE+3XsBQ8VAxAkN81au+f3FDeCD/s7KoZD+fnM1MJSSAVsACAAAAAAhRnjrXecwV0yeCWKJ5J/x12Xx4qVJahsCEVHB/1U2rcAAzY5AH0AAAAFZAAgAAAAAI0CT7JNngTCTUSei1Arw7eHWCD0jumv2rb7imjWIlWABXMAIAAAAABSP8t6ya0SyCphXMwnru6ZUDXWElN0NfBvEOhDvW9bJQVsACAAAAAAGWeGmBNDRaMtvm7Rv+8TJ2sJ4WNXKcp3tqpv5Se9Ut4AAzcwAH0AAAAFZAAgAAAAAD/FIrGYFDjyYmVb7oTMVwweWP7A6F9LnyIuNO4MjBnXBXMAIAAAAACIZgJCQRZu7NhuNMyOqCn1tf+DfU1qm10TPCfj5JYV3wVsACAAAAAA5hmY4ptuNxULGf87SUFXQWGAONsL9U29duh8xqsHtxoAAzcxAH0AAAAFZAAgAAAAAHIkVuNDkSS1cHIThKc/O0r2/ubaABTOi8Q1r/dvBAsEBXMAIAAAAADdHYqchEiJLM340c3Q4vJABmmth3+MKzwLYlsG6GS7sQVsACAAAAAADa+KP/pdTiG22l+ZWd30P1iHjnBF4zSNRdFm0oEK82kAAzcyAH0AAAAFZAAgAAAAAJmoDILNhC6kn3masElfnjIjP1VjsjRavGk1gSUIjh1NBXMAIAAAAAD97Ilvp3XF8T6MmVVcxMPcdL80RgQ09UoC6PnoOvZ1IQVsACAAAAAA2RK3Xng6v8kpvfVW9tkVXjpE+BSnx9/+Fw85Evs+kUEAAzczAH0AAAAFZAAgAAAAAI5bm3YO0Xgf0VT+qjVTTfvckecM3Cwqj7DTKZXf8/NXBXMAIAAAAAD/m+h8fBhWaHm6Ykuz0WX1xL4Eme3ErLObyEVJf8NCywVsACAAAAAAfb1VZZCqs2ivYbRzX4p5CtaCkKW+g20Pr57FWXzEZi8AAzc0AH0AAAAFZAAgAAAAANqo4+p6qdtCzcB4BX1wQ6llU7eFBnuu4MtZwp4B6mDlBXMAIAAAAAAGiz+VaukMZ+6IH4jtn4KWWdKK4/W+O+gRioQDrfzpMgVsACAAAAAAG4YYkTp80EKo59mlHExDodRQFR7njhR5dmISwUJ6ukAAAzc1AH0AAAAFZAAgAAAAAPrFXmHP2Y4YAm7b/aqsdn/DPoDkv7B8egWkfe23XsM1BXMAIAAAAAAGhwpKAr7skeqHm3oseSbO7qKNhmYsuUrECBxJ5k+D2AVsACAAAAAAAqPQi9luYAu3GrFCEsVjd9z2zIDcp6SPTR2w6KQEr+IAAzc2AH0AAAAFZAAgAAAAABzjYxwAjXxXc0Uxv18rH8I3my0Aguow0kTwKyxbrm+cBXMAIAAAAADVbqJVr6IdokuhXkEtXF0C2gINLiAjMVN20lE20Vmp2QVsACAAAAAAD7K1Fx4gFaaizkIUrf+EGXQeG7QX1jadhGc6Ji471H8AAzc3AH0AAAAFZAAgAAAAAFMm2feF2fFCm/UC6AfIyepX/xJDSmnnolQIBnHcPmb5BXMAIAAAAABLI11kFrQoaNVZFmq/38aRNImPOjdJh0Lo6irI8M/AaAVsACAAAAAAOWul0oVqJ9CejD2RqphhTC98DJeRQy5EwbNerU2+4l8AAzc4AH0AAAAFZAAgAAAAAJvXB3KyNiNtQko4SSzo/9b2qmM2zU9CQTTDfLSBWMgRBXMAIAAAAAAvjuVP7KsLRDeqVqRziTKpBrjVyqKiIbO9Gw8Wl2wFTAVsACAAAAAADlE+oc1ins+paNcaOZJhBlKlObDJ4VQORWjFYocM4LgAAzc5AH0AAAAFZAAgAAAAAPGdcxDiid8z8XYnfdDivNMYVPgBKdGOUw6UStU+48CdBXMAIAAAAAARj6g1Ap0eEfuCZ4X2TsEw+Djrhto3fA5nLwPaY0vCTgVsACAAAAAAoHqiwGOUkBu8SX5U1yHho+UIFdSN2MdQN5s6bQ0EsJYAAzgwAH0AAAAFZAAgAAAAAP5rGPrYGt3aKob5f/ldP0qrW7bmWvqnKY4QwdDWz400BXMAIAAAAADTQkW2ymaaf/bhteOOGmSrIR97bAnJx+yN3yMj1bTeewVsACAAAAAADyQnHGH2gF4w4L8axUsSTf6Ubk7L5/eoFOJk12MtZAoAAzgxAH0AAAAFZAAgAAAAAAlz6wJze5UkIxKpJOZFGCOf3v2KByWyI6NB6JM9wNcBBXMAIAAAAABUC7P/neUIHHoZtq0jFVBHY75tSFYr1Y5S16YN5XxC1QVsACAAAAAAgvxRbXDisNnLY3pfsjDdnFLtkvYUC4lhA68eBXc7KAwAAzgyAH0AAAAFZAAgAAAAAFJ8AtHcjia/9Y5pLEc3qVgH5xKiXw12G9Kn2A1EY8McBXMAIAAAAAAxe7Bdw7eUSBk/oAawa7uicTEDgXLymRNhBy1LAxhDvwVsACAAAAAAxKPaIBKVx3jTA+R/el7P7AZ7efrmTGjJs3Hj/YdMddwAAzgzAH0AAAAFZAAgAAAAAO8uwQUaKFb6vqR3Sv3Wn4QAonC2exOC9lGG1juqP5DtBXMAIAAAAABZf1KyJgQg8/Rf5c02DgDK2aQu0rNCOvaL60ohDHyY+gVsACAAAAAAqyEjfKC8lYoIfoXYHUqHZPoaA6EK5BAZy5dxXZmay4kAAzg0AH0AAAAFZAAgAAAAAE8YtqyRsGCeiR6hhiyisR/hccmK4nZqIMzO4lUBmEFzBXMAIAAAAAC1UYOSKqAeG1UJiKjWFVskRhuFKpj9Ezy+lICZvFlN5AVsACAAAAAA6Ct9nNMKyRazn1OKnRKagm746CGu+jyhbL1qJnZxGi0AAzg1AH0AAAAFZAAgAAAAAPhCrMausDx1QUIEqp9rUdRKyM6a9AAx7jQ3ILIu8wNIBXMAIAAAAACmH8lotGCiF2q9VQxhsS+7LAZv79VUAsOUALaGxE/EpAVsACAAAAAAnc1xCKfdvbUEc8F7XZqlNn1C+hZTtC0I9I3LL06iaNkAAzg2AH0AAAAFZAAgAAAAAOBi/GAYFcstMSJPgp3VkMiuuUUCrZytvqYaU8dwm8v2BXMAIAAAAACEZSZVyD3pKzGlbdwlYmWQhHHTV5SnNLknl2Gw8IaUTQVsACAAAAAAfsLZsEDcWSuNsIo/TD1ReyQW75HPMgmuKZuWFOLKRLoAAzg3AH0AAAAFZAAgAAAAAIQuup+YGfH3mflzWopN8J1X8o8a0d9CSGIvrA5HOzraBXMAIAAAAADYvNLURXsC2ITMqK14LABQBI+hZZ5wNf24JMcKLW+84AVsACAAAAAACzfjbTBH7IwDU91OqLAz94RFkoqBOkzKAqQb55gT4/MAAzg4AH0AAAAFZAAgAAAAAKsh0ADyOnVocFrOrf6MpTrNvAj8iaiE923DPryu124gBXMAIAAAAADg24a8NVE1GyScc6tmnTbmu5ulzO+896fE92lN08MeswVsACAAAAAAaPxcOIxnU7But88/yadOuDJDMcCywwrRitaxMODT4msAAzg5AH0AAAAFZAAgAAAAAKkVC2Y6HtRmv72tDnPUSjJBvse7SxLqnr09/Uuj9sVVBXMAIAAAAABYNFUkH7ylPMN+Bc3HWX1e0flGYNbtJNCY9SltJCW/UAVsACAAAAAAZYK/f9H4OeihmpiFMH7Wm7uLvs2s92zNA8wyrNZTsuMAAzkwAH0AAAAFZAAgAAAAADDggcwcb/Yn1Kk39sOHsv7BO/MfP3m/AJzjGH506Wf9BXMAIAAAAAAYZIsdjICS0+BDyRUPnrSAZfPrwtuMaEDEn0/ijLNQmAVsACAAAAAAGPnYVvo2ulO9z4LGd/69NAklfIcZqZvFX2KK0s+FcTUAAzkxAH0AAAAFZAAgAAAAAEWY7dEUOJBgjOoWVht1wLehsWAzB3rSOBtLgTuM2HC8BXMAIAAAAAAAoswiHRROurjwUW8u8D5EUT+67yvrgpB/j6PzBDAfVwVsACAAAAAA6NhRTYFL/Sz4tao7vpPjLNgAJ0FX6P/IyMW65qT6YsMAAzkyAH0AAAAFZAAgAAAAAPZaapeAUUFPA7JTCMOWHJa9lnPFh0/gXfAPjA1ezm4ZBXMAIAAAAACmJvLY2nivw7/b3DOKH/X7bBXjJwoowqb1GtEFO3OYgAVsACAAAAAA/JcUoyKacCB1NfmH8vYqC1f7rd13KShrQqV2r9QBP44AAzkzAH0AAAAFZAAgAAAAAK00u6jadxCZAiA+fTsPVDsnW5p5LCr4+kZZZOTDuZlfBXMAIAAAAAAote4zTEYMDgaaQbAdN8Dzv93ljPLdGjJzvnRn3KXgtQVsACAAAAAAxXd9Mh6R3mnJy8m7UfqMKi6oD5DlZpkaOz6bEjMOdiwAAzk0AH0AAAAFZAAgAAAAAFbgabdyymiEVYYwtJSWa7lfl/oYuj/SukzJeDOR6wPVBXMAIAAAAADAFGFjS1vPbN6mQEhkDYTD6V2V23Ys9gUEUMGNvMPkaAVsACAAAAAAL/D5Sze/ZoEanZLK0IeEkhgVkxEjMWVCfmJaD3a8uNIAAzk1AH0AAAAFZAAgAAAAABNMR6UBv2E627CqLtQ/eDYx7OEwQ7JrR4mSHFa1N8tLBXMAIAAAAAAxH4gucI4UmNVB7625C6hFSVCuIpJO3lusJlPuL8H5EQVsACAAAAAAVLHNg0OUVqZ7WGOP53BkTap9FOw9dr1P4J8HxqFqU04AAzk2AH0AAAAFZAAgAAAAAG8cd6WBneNunlqrQ2EmNf35W7OGObGq9WL4ePX+LUDmBXMAIAAAAAAjJ2+sX87NSis9hBsgb1QprVRnO7Bf+GObCGoUqyPE4wVsACAAAAAAs9c9SM49/pWmyUQKslpt3RTMBNSRppfNO0JBvUqHPg0AAzk3AH0AAAAFZAAgAAAAAFWOUGkUpy8yf6gB3dio/aOfRKh7XuhvsUj48iESFJrGBXMAIAAAAAAY7sCDMcrUXvNuL6dO0m11WyijzXZvPIcOKob6IpC4PQVsACAAAAAAJOP+EHz6awDb1qK2bZQ3kTV7wsj5Daj/IGAWh4g7omAAAzk4AH0AAAAFZAAgAAAAAGUrIdKxOihwNmo6B+aG+Ag1qa0+iqdksHOjQj+Oy9bZBXMAIAAAAABwa5dbI2KmzBDNBTQBEkjZv4sPaeRkRNejcjdVymRFKQVsACAAAAAA4ml/nm0gJNTcJ4vuD+T2Qfq2fQZlibJp/j6MOGDrbHMAAzk5AH0AAAAFZAAgAAAAAOx89xV/hRk64/CkM9N2EMK6aldII0c8smdcsZ46NbP8BXMAIAAAAADBF6tfQ+7q9kTuLyuyrSnDgmrdmrXkdhl980i1KHuGHgVsACAAAAAACUqiFqHZdGbwAA+hN0YUE5zFg+H+dabIB4dj5/75W/YAAzEwMAB9AAAABWQAIAAAAADJDdC9aEFl4Y8J/awHbnXGHjfP+VXQilPHJg7ewaJI7AVzACAAAAAAE+tqRl6EcBMXvbr4GDiNIYObTsYpa1n6BJk9EjIJVicFbAAgAAAAAJVc+HYYqa0m1Hq6OiRX8c0iRnJYOt6AJAJoG0sG3GMSAAMxMDEAfQAAAAVkACAAAAAA3F9rjEKhpoHuTULVGgfUsGGwJs3bISrXkFP1v6KoQLgFcwAgAAAAAIBf0tXw96Z/Ds0XSIHX/zk3MzUR/7WZR/J6FpxRWChtBWwAIAAAAABWrjGlvKYuTS2s8L9rYy8Hf0juFGJfwQmxVIjkTmFIGQADMTAyAH0AAAAFZAAgAAAAAOYIYoWkX7dGuyKfi3XssUlc7u/gWzqrR9KMkikKVdmSBXMAIAAAAABVF2OYjRTGi9Tw8XCAwZWLpX35Yl271TlNWp6N/nROhAVsACAAAAAA0nWwYzXQ1+EkDvnGq+SMlq20z+j32Su+i/A95SggPb4AAzEwMwB9AAAABWQAIAAAAACMtPm12YtdEAvqu6Eji1yuRXnu1RJP6h0l7pH3lSH4MwVzACAAAAAAENyCFfyUAh1veQBGx+cxiB7Sasrj41jzCGflZkB5cRMFbAAgAAAAAKdI2LMqISr/T5vuJPg6ZRBm5fVi2aQCc4ra3A4+AjbDAAMxMDQAfQAAAAVkACAAAAAAvlI4lDcs6GB1cnm/Tzo014CXWqidCdyE5t2lknWQd4QFcwAgAAAAAD60SpNc4O2KT7J0llKdSpcX1/Xxs97N715a1HsTFkmBBWwAIAAAAABuuRkJWAH1CynggBt1/5sPh9PoGiqTlS24D/OE2uHXLQADMTA1AH0AAAAFZAAgAAAAAKl8zcHJRDjSjJeV/WvMxulW1zrTFtaeBy/aKKhadc6UBXMAIAAAAADBdWQl5SBIvtZZLIHszePwkO14W1mQ0izUk2Ov21cPNAVsACAAAAAAHErCYycpqiIcCZHdmPL1hi+ovLQk4TAvENpfLdTRamQAAzEwNgB9AAAABWQAIAAAAABb6LXDWqCp1beQgQjj8I3sRTtFhlrmiBi+h/+ikmrvugVzACAAAAAA9stpgTecT7uTyaGNs3K9Bp0A7R0QaIAOfscyMXHBPX8FbAAgAAAAAHUt+McyXrJ1H8SwnHNVO181Ki8vDAM1f7XI26mg95ZDAAMxMDcAfQAAAAVkACAAAAAA97NTT+81PhDhgptNtp4epzA0tP4iNb9j1AWkiiiKGM8FcwAgAAAAAKPbHg7ise16vxmdPCzksA/2Mn/qST0L9Xe8vnQugVkcBWwAIAAAAABB0EMXfvju4JU/mUH/OvxWbPEl9NJkcEp4iCbkXI41fAADMTA4AH0AAAAFZAAgAAAAAMqpayM2XotEFmm0gwQd9rIzApy0X+7HfOhNk6VU7F5lBXMAIAAAAACJR9+q5T9qFHXFNgGbZnPubG8rkO6cwWhzITQTmd6VgwVsACAAAAAAOZLQ6o7e4mVfDzbpQioa4d3RoTvqwgnbmc5Qh2wsZuoAAzEwOQB9AAAABWQAIAAAAADQnslvt6Hm2kJPmqsTVYQHE/wWeZ4bE1XSkt7TKy0r1gVzACAAAAAA8URTA4ZMrhHPvlp53TH6FDCzS+0+61qHm5XK6UiOrKEFbAAgAAAAAHQbgTCdZcbdA0avaTmZXUKnIS7Nwf1tNrcXDCw+PdBRAAMxMTAAfQAAAAVkACAAAAAAhujlgFPFczsdCGXtQ/002Ck8YWQHHzvWvUHrkbjv4rwFcwAgAAAAALbV0lLGcSGfE7mDM3n/fgEvi+ifjl7WZ5b3aqjDNvx9BWwAIAAAAACbceTZy8E3QA1pHmPN5kTlOx3EO8kJM5PUjTVftw1VpgADMTExAH0AAAAFZAAgAAAAABm/6pF96j26Jm7z5KkY1y33zcAEXLx2n0DwC03bs/ixBXMAIAAAAAD01OMvTZI/mqMgxIhA5nLs068mW+GKl3OW3ilf2D8+LgVsACAAAAAAaLvJDrqBESTNZSdcXsd+8GXPl8ZkUsGpeYuyYVv/kygAAzExMgB9AAAABWQAIAAAAACfw9/te4GkHZAapC9sDMHHHZgmlTrccyJDPFciOMSOcwVzACAAAAAAIIC1ZpHObvmMwUfqDRPl4C1aeuHwujM1G/yJbvybMNAFbAAgAAAAAAs9x1SnVpMfNv5Bm1aXGwHmbbI9keWa9HRD35XuCBK5AAMxMTMAfQAAAAVkACAAAAAAkxHJRbnShpPOylLoDdNShfILeA1hChKFQY9qQyZ5VmsFcwAgAAAAAKidrY+rC3hTY+YWu2a7fuMH2RD/XaiTIBW1hrxNCQOJBWwAIAAAAACW0kkqMIzIFMn7g+R0MI8l15fr3k/w/mHtY5n6SYTEwAADMTE0AH0AAAAFZAAgAAAAAByuYl8dBvfaZ0LO/81JW4hYypeNmvLMaxsIdvqMPrWoBXMAIAAAAABNddwobOUJzm9HOUD8BMZJqkNCUCqstHZkC76FIdNg9AVsACAAAAAAQQOkIQtkyNavqCnhQbNg3HfqrJdsAGaoxSJePJl1qXsAAzExNQB9AAAABWQAIAAAAABxMy7X5hf7AXGDz3Y/POu1ZpkMlNcSvSP92NOO/Gs7wAVzACAAAAAAHJshWo2T5wU2zvqCyJzcJQKQaHFHpCpMc9oWBXkpUPoFbAAgAAAAAGeiJKzlUXAvL0gOlW+Hz1mSa2HsV4RGmyLmCHlzbAkoAAMxMTYAfQAAAAVkACAAAAAAlqbslixl7Zw3bRlibZbe/WmKw23k8uKeIzPKYEtbIy0FcwAgAAAAAHEKwpUxkxOfef5HYvulXPmdbzTivwdwrSYIHDeNRcpcBWwAIAAAAADuPckac21Hrg/h0kt5ShJwVEZ9rx6SOHd2+HDjqxEWTQADMTE3AH0AAAAFZAAgAAAAAMXrXx0saZ+5gORmwM2FLuZG6iuO2YS+1IGPoAtDKoKBBXMAIAAAAADIQsxCr8CfFKaBcx8kIeSywnGh7JHjKRJ9vJd9x79y7wVsACAAAAAAcvBV+SykDYhmRFyVYwFYB9oBKBSHr55Jdz2cXeowsUQAAzExOAB9AAAABWQAIAAAAAAm83FA9yDUpwkbKTihe7m53u+DivS9BU2b4vQMtCVQ2AVzACAAAAAAz3m1UB/AbZPa4QSKFDnUgHaT78+6iGOFAtouiBorEgEFbAAgAAAAAIgbpyYtJj5513Z5XYqviH/HXG/5+mqR52iBbfqMmDtZAAMxMTkAfQAAAAVkACAAAAAAJRzYK0PUwr9RPG2/7yID0WgcTJPB2Xjccp5LAPDYunkFcwAgAAAAAIIh24h3DrltAzNFhF+MEmPrZtzr1PhCofhChZqfCW+jBWwAIAAAAAAzRNXtL5o9VXMk5D5ylI0odPDJDSZZry1wfN+TedH70gADMTIwAH0AAAAFZAAgAAAAAHSaHWs/dnmI9sc7nB50VB2Bzs0kHapMHCQdyVEYY30TBXMAIAAAAACkV22lhEjWv/9/DubfHBAcwJggKI5mIbSK5L2nyqloqQVsACAAAAAAS19m7DccQxgryOsBJ3GsCs37yfQqNi1G+S6fCXpEhn4AAzEyMQB9AAAABWQAIAAAAAAC/I4TQRtCl12YZmdGz17X4GqSQgfwCPgRBwdHmdwu+QVzACAAAAAAx8f3z2ut/RAZhleari4vCEE+tNIn4ikjoUwzitfQ588FbAAgAAAAAJci0w1ZB8W2spJQ+kMpod6HSCtSR2jrabOH+B0fj3A4AAMxMjIAfQAAAAVkACAAAAAADGB5yU2XT0fse/MPWgvBvZikVxrl5pf3S5K1hceKWooFcwAgAAAAAIxTmlLHMjNaVDEfJbXvRez0SEPWFREBJCT6qTHsrljoBWwAIAAAAAAlswzAl81+0DteibwHD+CG5mZJrfHXa9NnEFRtXybzzwADMTIzAH0AAAAFZAAgAAAAABmO7QD9vxWMmFjIHz13lyOeV6vHT6mYCsWxF7hb/yOjBXMAIAAAAACT9lmgkiqzuWG24afuzYiCeK9gmJqacmxAruIukd0xEAVsACAAAAAAZa0/FI/GkZR7CtX18Xg9Tn9zfxkD0UoaSt+pIO5t1t4AAzEyNAB9AAAABWQAIAAAAAAfPUoy7QyZKhIIURso+mkP9qr1izbjETqF5s22GwjCjAVzACAAAAAAvLMsIDQ/go4VUxeh50UHmsvMvfx51cwyONnRD2odvC0FbAAgAAAAAKMb+1CodEalAFnDrEL1Ndt8ztamZ+9134m9Kp3GQgd+AAMxMjUAfQAAAAVkACAAAAAAE3ZqUar0Bq2zWbARE0bAv98jBlK9UJ73/xcwdMWWlSkFcwAgAAAAAK4M+MmC+9sFiFsumMyJZQKxWmmJiuG9H7IzKw083xxkBWwAIAAAAAAqkAONzhvMhkyL1D/6h7QQxEkdhC3p2WjXH+VGq5qCqQADMTI2AH0AAAAFZAAgAAAAAMo8FJiOq63cAmyk2O7eI7GcbQh/1j4RrMTqly3rexftBXMAIAAAAADjVmpd0WiRGTw/gAqEgGolt2EI7Csv14vKdmYoMD0aAgVsACAAAAAA07XQBzBUQMNw7F2/YxJjZNuPVpHTTgbLd1oGk77+bygAAzEyNwB9AAAABWQAIAAAAACu5IGaIx7A3Jvly/kzlCsSA4s3iJwuIl8jEdRH0k93NwVzACAAAAAA9NRUyxYE+t0Xyosyt6vIfMFW/vBoYg6sR+jBNs4JAxIFbAAgAAAAAAzyZ91dx+0oMlOVAjRGiMrPySikY/U9eMEB4WJb3uWtAAMxMjgAfQAAAAVkACAAAAAALkRy0GJInXYLA+cgjs6Myb0a+Gu9hgXhHvhLNoGWfckFcwAgAAAAANbALyt9zCSvwnLaWCd2/y2eoB7qkWTvv1Ldu8r40JPuBWwAIAAAAAD4Fl5bV5sz4isIE9bX+lmAp+aAKaZgVYVZeVfrItkCZAADMTI5AH0AAAAFZAAgAAAAAGoUK/DSWhT8LZhszSUqDbTrp8cSA7rdqmADKL+MILtTBXMAIAAAAABHnEE9bVa6lvhfhEMkkV2kzSSxH/sMW/FIJuw3CzWs6wVsACAAAAAAanavcBdqZxgRGKvEK95wTmeL1K1CeDSXZsXUAs81uOgAAzEzMAB9AAAABWQAIAAAAAC922ZDQE3h2fQKibGMZ9hV0WNlmrPYYSdtaSyYxsWYqgVzACAAAAAAagMovciKK6WVjIc2cCj8nK5O/gVOFFVeVAJpRp89tmQFbAAgAAAAAKcTFfPQzaFiAtSFhqbN02sCE1BKWJSrRfGN5L6oZwzkAAMxMzEAfQAAAAVkACAAAAAAtK+JqX3K/z2txjAU15DgX4y90DS2YLfIJFolCOkJJJwFcwAgAAAAAMnR5V7gfX7MNqqUdL5AkWlkhyFXaBRVNej+Rcn8lrQkBWwAIAAAAAA2cDNRXZuiC241TGRvdFyctJnrNcdbZOP9zHio81tkngADMTMyAH0AAAAFZAAgAAAAAAeGrIMK/bac6kPczxbvRYqKMkcpeI2FjdMpD91FDWIvBXMAIAAAAAAix62z1LeS8yvSXCl5gHSIomjyx76fF3S1lp9k900hygVsACAAAAAAiYwzf2m71aWFD5ajcXyW2JX2EzQOkBroTGMg29nLPYIAAzEzMwB9AAAABWQAIAAAAACphf298InM0Us4HT8o1W1MGw0D/02vd7Jh+U0h7qaFaQVzACAAAAAAFXtk7YpqsOJxsqGWSIL+YcBE96G3Zz9D31gPqDW94y8FbAAgAAAAAAOrS1KVA94rjB1jZ1pPocpCeBG+B14RzWoHqVDpp7JbAAMxMzQAfQAAAAVkACAAAAAATLDS2cuDVM3yDMuWNgk2iGKBTzPpfJMbvxVOSY39ZfcFcwAgAAAAAPT5wRi2cLHIUflXzm6EQB/m7xdThP80ir1VV/JBBqvxBWwAIAAAAAB9lEtZS0aXCFbCtSbhnis27S5IPcfWGygHW8AHn3QqzwADMTM1AH0AAAAFZAAgAAAAAJNjExiZVX7jfFGfYpQu16qxLN0YPqVU/5CQ/Y67YSinBXMAIAAAAABMpm2+6KrkRUlXzQoMPHrQmIO6dkQz66tYdfTeA3dKqQVsACAAAAAAFXobHiMLvNZuEPr8jtewCX2J93EZG3JNeyVg92fue6YAAzEzNgB9AAAABWQAIAAAAABlFkYtLCx901X6QVVMkSn6Z7k30UF4xHaA0OZJJ9bdyQVzACAAAAAATez+F9GHcGzTp7jjv4feboUNb8JCkIp4EqcPFisnq7MFbAAgAAAAACE7JvOpBgMoZ7kRd4QbxIhxukPTUxXpzhjnBHiR7XoRAAMxMzcAfQAAAAVkACAAAAAA8NJKN0IxZnruhswGQkiruv8Ih0EMwDcSZx/Xasup9dkFcwAgAAAAAKaJZRxzA+Igeydvuk6cSwUHXcrmT4PjhuPu//FslpdnBWwAIAAAAAD53Rok1Vq/PMAnXmarqoHJ0PEyYUBmVESa9hIpCv/G9QADMTM4AH0AAAAFZAAgAAAAABHxHdEClz7hbSSgE58+dWLlSMJnoPz+jFxp4bB1GmLQBXMAIAAAAAD3nSvT6aGD+A110J/NwEfp0nPutlmuB5B+wA3CC3noGAVsACAAAAAA3Apjd+TapONB7k5wBVwTWgn8t+Sq2oyyU5/+as109RcAAzEzOQB9AAAABWQAIAAAAAC/o8qW/ifk3KuJ01VFkyNLgQafxB5/bGs2G5VyyVafOwVzACAAAAAA1bMqAFGDHSl6BYNLbxApvkAv2K1/oafywiX0MDz1dGUFbAAgAAAAAHJXLlId3edFoniLD/9K2A5973MeP2Ro31flDyqm3l5QAAMxNDAAfQAAAAVkACAAAAAAY2V8I1bz3a1AxTtmED6UhdhA09huFkuuEX8R+d/WDPUFcwAgAAAAAPTVoNRiI76tcRKqd+JBBVyy4+YcKST42p0QX2BtmQ2VBWwAIAAAAACcxt9hg14WqPNiDv1MkqVljM2e2KJEv53lA17LhV6ZigADMTQxAH0AAAAFZAAgAAAAAO2kSsW0WGN9AOtK4xK2SHrGhWiaAbMEKT4iZkRpaDN/BXMAIAAAAABKGzQcPM8LT2dwOggxoWjv/1imYWabbG/G4kBw8OWaxAVsACAAAAAAC9hLK1dScQTAqg+YAG3ObdPzg2Xet57HmOFpGmyUR9UAAzE0MgB9AAAABWQAIAAAAAAiCwzNEEaH/mDam68IdDftnhthyUFdb+ZCNSBQ91WlHQVzACAAAAAA7tHyHcxCzmbJeFYZyPm4mEgkTGKOvwY4MX82OvH0Jn8FbAAgAAAAAAb5IAbZ1hXCNegQ+S+C9i/Z8y6sS8KeU04V6hXa2ml6AAMxNDMAfQAAAAVkACAAAAAAGuCHVNJSuoVkpPOnS5s89GuA+BLi2IPBUr2Bg1sWEPIFcwAgAAAAAEl1gncS5/xO7bQ/KQSstRV3rOT2SW6nV92ZANeG2SR6BWwAIAAAAAA9LOcKmhek8F2wAh8yvT/vjp2gaouuO+Hmv10lwAeWPAADMTQ0AH0AAAAFZAAgAAAAAMfxz7gEaoCdPvXrubDhCZUS0ARLZc1svgbXgMDlVBPgBXMAIAAAAAB6a5dDA3fuT5Vz2KvAcbUEFX/+B7Nw2p1QqbPoQ5TTuAVsACAAAAAAcf/y75UOuI62A6vWH7bYr/5Jz+nirZVYK/81trN6XOQAAzE0NQB9AAAABWQAIAAAAACnYsqF/VzmjIImC9+dqrHO1TM6lJ6fRwM0mM6Wf6paOwVzACAAAAAA5tgZzch8uDCR1ky3SllVaKVpxAlbrhvlNDTazZZRZOAFbAAgAAAAALeGiLJS4z2zhgVpxzyPdRYyACP9QzQBOob34YrIZumCAAMxNDYAfQAAAAVkACAAAAAAEC0sIVmadtW4YMuRXH7RpAhXclsd+3bmqGXCMeaT014FcwAgAAAAABPpXh0uzpsJJB+IRUNajmMB9WGwswfpw5T9xk3Xj6ANBWwAIAAAAAAmf+NYh9TZ/QRu3w/GQz66n7DtfbJijN3G7KzeL8lstAADMTQ3AH0AAAAFZAAgAAAAABaIB3n49Xm9cOafSrQsE0WCcYp8rMIO/qVwIlMF5YLRBXMAIAAAAAC9EyWJV3xOu9bzgdJ/yX+ko7qLf1u3AxNMataW2C9EzQVsACAAAAAAvVbDkLxXx2DcMLifIQ3K0IIJcLcAG9DUrNfI6aoUjNcAAzE0OAB9AAAABWQAIAAAAAA5rZItA/cocRnngYqcJ3nBXQ+l688aKz3EQyLbYYunPAVzACAAAAAAwKyA+L7TgxztPClLrIMk2JXR+w7c04N3ZOqPgjvrIvsFbAAgAAAAACzvZ33h6aWEe8hmo+1f6OXJ72FY5hvWaUuha64ZV3KFAAMxNDkAfQAAAAVkACAAAAAA3htn7oHJ0YYpIrs+Mzyh85Ys67HwAdv5LQl1mCdoMWkFcwAgAAAAAEHjCtNNLenHuSIYux6ezAHsXDaj2DlTF67ToDhDDe6HBWwAIAAAAAD+P4H0sk9jOd+7vOANt2/1Ectb+4ZRGPE8GkHWNXW3MgADMTUwAH0AAAAFZAAgAAAAAEnt18Km/nqggfIJWxzTr9r3hnXNaueG6XO9A5G11LnGBXMAIAAAAAD7QxzGMN/ard5TfFLecE6uusMmXG2+RBsBR+/NCQHUwAVsACAAAAAAQEZ1ZZ8GC8rdbg7s87OM5Gr9qkTXS9+P5DuAZxj5Gl4AAzE1MQB9AAAABWQAIAAAAAAVAKK/GoY8AACu/hyMpO4hdLq6JnEyWNzkyci9sbaD/wVzACAAAAAA2HmeqpMlvvBpV2zQTYIRmsc4MFlfHRwLof0ycJgMg/MFbAAgAAAAACdltCeWi5E/q1Li1eXLChpM2D9QQSGLBZ82NklQSc0oAAMxNTIAfQAAAAVkACAAAAAAhHyq1GQC/GiMwpYjcsfkNxolJ10ARKjIjfkW1Wipzi0FcwAgAAAAAD/uaGWxTDq87F8XZ6CrFI+RNa8yMqfSZdqK00Kj833BBWwAIAAAAAD6aEdOO0CsQGagioOCvANPCEHSpJ8BSixlPBq5ERhB7AADMTUzAH0AAAAFZAAgAAAAABAJJxHoZD+MQBWqm9UM9Dd3z5ZohIZGWRaRVRsMptKQBXMAIAAAAADrE/ca+gqj/SH4oao4wE4qn2ovoTydzcMbDbrfnUs3zAVsACAAAAAAeNCIQN6hVnGJinytQRFGlQ2ocoprXNqpia+BSxzl+uwAAzE1NAB9AAAABWQAIAAAAAAv01wz7VG9mTepjXQi6Zma+7b/OVBaKVkWNbgDLr1mFgVzACAAAAAA0I5sxz8r6wkCp5Tgvr+iL4p6MxSOq5d3e1kZG+0b7NkFbAAgAAAAAIA32v6oGkAOS96HexGouNTex+tLahtx9QF2dgGClk6WAAMxNTUAfQAAAAVkACAAAAAAWXecRwxSon68xaa9THXnRDw5ZfzARKnvvjTjtbae6T0FcwAgAAAAAPh0UfUMEo7eILCMv2tiJQe1bF9qtXq7GJtC6H5Va4fIBWwAIAAAAADqFr1ThRrTXNgIOrJWScO9mk86Ufi95IDu5gi4vP+HWQADMTU2AH0AAAAFZAAgAAAAAEY5WL8/LpX36iAB1wlQrMO/xHVjoO9BePVzbUlBYo+bBXMAIAAAAABoKcpadDXUARedDvTmzUzWPe1jTuvD0z9oIcZmKuiSXwVsACAAAAAAJuJbwuaMrAFoI+jU/IYr+k4RzAqITrOjAd3HWCpJHqEAAzE1NwB9AAAABWQAIAAAAADnJnWqsfx0xqNnqfFGCxIplVu8mXjaHTViJT9+y2RuTgVzACAAAAAAWAaSCwIXDwdYxWf2NZTly/iKVfG/KDjHUcA1BokN5sMFbAAgAAAAAJVxavipE0H4/JQvhagdytXBZ8qGooeXpkbPQ1RfYMVHAAMxNTgAfQAAAAVkACAAAAAAsPG7LaIpJvcwqcbtfFUpIjj+vpNj70Zjaw3eV9T+QYsFcwAgAAAAAJQ71zi0NlCyY8ZQs3IasJ4gB1PmWx57HpnlCf3+hmhqBWwAIAAAAACD58TO6d+71GaOoS+r73rAxliAO9GMs4Uc8JbOTmC0OwADMTU5AH0AAAAFZAAgAAAAAAGiSqKaQDakMi1W87rFAhkogfRAevnwQ41onWNUJKtuBXMAIAAAAAASgiDpXfGh7E47KkOD8MAcX8+BnDShlnU5JAGdnPdqOAVsACAAAAAAI+2TTQIgbFq4Yr3lkzGwhG/tqChP7hRAx2W0fNaH6jcAAzE2MAB9AAAABWQAIAAAAAB7L4EnhjKA5xJD3ORhH2wOA1BvpnQ+7IjRYi+jjVEaJAVzACAAAAAAuhBIm0nL3FJnVJId+7CKDASEo+l2E89Z9/5aWSITK4AFbAAgAAAAALtSICOzQDfV9d+gZuYxpEj6cCeHnKTT+2G3ceP2H65kAAMxNjEAfQAAAAVkACAAAAAAaROn1NaDZFOGEWw724dsXBAm6bgmL5i0cki6QZQNrOoFcwAgAAAAANVT8R6UvhrAlyqYlxtmnvkR4uYK/hlvyQmBu/LP6/3ZBWwAIAAAAAD+aHNMP/X+jcRHyUtrCNkk1KfMtoD3GTmShS8pWGLt+AADMTYyAH0AAAAFZAAgAAAAADqSR5e0/Th59LrauDA7OnGD1Xr3H3NokfVxzDWOFaN7BXMAIAAAAACt30faNwTWRbvmykDpiDYUOCwA6QDbBBYBFWS7rdOB4AVsACAAAAAAF7SvnjjRk5v2flFOKaBAEDvjXaL1cpjsQLtK2fv9zdQAAzE2MwB9AAAABWQAIAAAAADmtb1ZgpZjSeodPG/hIVlsnS8hoRRwRbrTVx89VwL62AVzACAAAAAAi38e1g6sEyVfSDkzZbaZXGxKI/zKNbMasOl2LYoWrq8FbAAgAAAAAALACk0KcCDN/Kv8WuazY8ORtUGkOZ5Dsm0ys1oOppp/AAMxNjQAfQAAAAVkACAAAAAAf/f7AWVgBxoKjr7YsEQ4w/fqSvuQWV2HMiA3rQ7ur0sFcwAgAAAAADkkeJozP6FFhUdRIN74H4UhIHue+eVbOs1NvbdWYFQrBWwAIAAAAAB55FlHAkmTzAYj/TWrGkRJw2EhrVWUnZXDoMYjyfB/ZwADMTY1AH0AAAAFZAAgAAAAAI2WEOymtuFpdKi4ctanPLnlQud+yMKKb8p/nfKmIy56BXMAIAAAAADVKrJmhjr1rfF3p+T+tl7UFd1B7+BfJRk0e7a4im7ozgVsACAAAAAA5E7Ti3PnFiBQoCcb/DN7V1uM3Xd6VKiexPKntssFL7kAAzE2NgB9AAAABWQAIAAAAAAuHU9Qd79hjyvKOujGanSGDIQlxzsql8JytTZhEnPw+AVzACAAAAAAjF2gV/4+sOHVgDd/oR5wDi9zL7NGpGD+NsEpGXy/a4QFbAAgAAAAAJzMoyojYV6Ed/LpVN5zge93Odv3U7JgP7wxeRaJZGTdAAMxNjcAfQAAAAVkACAAAAAA7dQDkt3iyWYCT94d7yqUtPPwp4qkC0ddu+HFdHgVKEkFcwAgAAAAANuYvtvZBTEq4Rm9+5eb7VuFopowkrAuv86PGP8Q8/QvBWwAIAAAAACeqXoAOQOE4j0zRMlkVd8plaW0RX1npsFvB38Xmzv7sAADMTY4AH0AAAAFZAAgAAAAAAwnZSDhL4tNGYxlHPhKYB8s28dY5ScSwiKZm3UhT8U3BXMAIAAAAABDoY6dhivufTURQExyC9Gx3ocpl09bgbbQLChj3qVGbgVsACAAAAAAF+1nS7O0v85s3CCy+9HkdeoEfm2C6ZiNbPMMnSfsMHUAAzE2OQB9AAAABWQAIAAAAAC2VuRdaC4ZJmLdNOvD6R2tnvkyARteqXouJmI46V306QVzACAAAAAAMn1Z6B35wFTX9mEYAPM+IiJ5hauEwfD0CyIvBrxHg7IFbAAgAAAAAOG6DvDZkT9B/xZWmjao2AevN7MMbs3Oh9YJeSd/hZ+hAAMxNzAAfQAAAAVkACAAAAAAVerb7qVNy457rNOHOgDSKyWl5ojun7iWrv1uHPXrIZQFcwAgAAAAAIDcYS9j5z+gx0xdJj09L7876r/vjvKTi/d3bXDE3PhyBWwAIAAAAADuhVLqb1Bkrx8aNymS+bx2cL8GvLFNH4SAi690DUgnWQADMTcxAH0AAAAFZAAgAAAAAH/E44yLxKCJjuSmU9A8SEhbmkDOx1PqqtYcZtgOzJdrBXMAIAAAAABgLh9v2HjBbogrRoQ82LS6KjZQnzjxyJH4PH+F3jupSAVsACAAAAAAIlO46ehXp4TqpDV0t6op++KO+uWBFh8iFORZjmx2IjkAAzE3MgB9AAAABWQAIAAAAAAlNUdDL+f/SSQ5074mrq0JNh7CTXwTbbhsQyDwWeDVMwVzACAAAAAANIH2IlSNG0kUw4qz0budjcWn8mNR9cJlYUqPYdonucAFbAAgAAAAAJMrOUOyiu5Y3sV76zwEFct8L7+i8WGlQI2+8z2W2kzaAAMxNzMAfQAAAAVkACAAAAAASZ+CvUDtlk/R4HAQ3a+PHrKeY/8ifAfh0oXYFqliu80FcwAgAAAAAJelpzPgM65OZFt/mvGGpwibclQ49wH+1gbUGzd9OindBWwAIAAAAAD9qeDchteEpVXWcycmD9kl9449C1dOw0r60TBm5jK+cQADMTc0AH0AAAAFZAAgAAAAAN9fkoUVbvFV2vMNMAkak4gYfEnzwKI3eDM3pnDK5q3lBXMAIAAAAACnDkgVNVNUlbQ9RhR6Aot2nVy+U4km6+GHPkLr631jEAVsACAAAAAANzg/BnkvkmvOr8nS4omF+q9EG/4oisB+ul4YHi938hwAAzE3NQB9AAAABWQAIAAAAAASyK3b1nmNCMptVEGOjwoxYLLS9fYWm/Zxilqea0jpEQVzACAAAAAADDHsGrbqlKGEpxlvfyqOJKQJjwJrzsrB7k3HG0AUJbkFbAAgAAAAAKwx3S4XfDZh4+LuI9jf7XgUh5qiefNv87JD4qvVRfPSAAMxNzYAfQAAAAVkACAAAAAAlSP9iK31GlcG9MKGbLmq+VXMslURr+As736rrVNXcsUFcwAgAAAAAAvbj0zfq9zzi8XReheKFbCB+h9IsOLgXPPpI5vrEJNZBWwAIAAAAABXvoZhaQE7ogWjeBjceVkp03N20cKYP3TA8vuNsgpfAgADMTc3AH0AAAAFZAAgAAAAAOJNORH8Bev97gVU7y6bznOxJ+E6Qoykur1QP76hG1/7BXMAIAAAAAC+C1PtOOrSZgzBAGhr+dPe/kR0JUw9GTwLVNr61xC1aAVsACAAAAAAeA/L8MQIXkamaObtMPLpoDoi5FypA5WAPtMeMrgi0eQAAzE3OAB9AAAABWQAIAAAAAAKcHzLUomavInN6upPkyWhAqYQACP/vdVCIYpiy6U6HgVzACAAAAAATsR4KItY6R2+U7Gg6sJdaEcf58gjd1OulyWovIqfxKcFbAAgAAAAAFbm10ko67ahboAejQdAV0U2uA5OhZYdb8XUFJ8OL46LAAMxNzkAfQAAAAVkACAAAAAAqTOLiMpCdR59tLZzzIPqJvbCNvz2XQL9ust0qYaehtcFcwAgAAAAAArefox/3k5xGOeiw2m6NUdzuGxmPwcu5IFcj+jMwHgHBWwAIAAAAADLZGFJ7MQd5JXMgMXjqZO5LDLxcFClcXPlnRMWRn+1oAADMTgwAH0AAAAFZAAgAAAAAIPSqSeVzSRgNVNmrPYHmUMgykCY27NbdDUNhE5kx/SgBXMAIAAAAAAhX90nNfxyXmZe/+btZ7q6xMX4PFyj0paM1ccJ/5IUUQVsACAAAAAA419oHmD2W0SYoOMwhrhrp8jf68fg9hTkaRdCuVd3CN0AAzE4MQB9AAAABWQAIAAAAACLn5DxiqAosHGXIAY96FwFKjeqrzXWf3VJIQMwx1fl4gVzACAAAAAAindvU27nveutopdvuHmzdENBbeGFtI3Qcsr07jxmvm8FbAAgAAAAAPvl9pBStQvP4OGkN5v0MghUY6djm9n7XdKKfrW0l1sMAAMxODIAfQAAAAVkACAAAAAA7i2S6rHRSPBwZEn59yxaS7HiYBOmObIkeyCcFU42kf8FcwAgAAAAAGb3RSEyBmgarkTvyLWtOLJcPwCKbCRkESG4RZjVmY4iBWwAIAAAAADB2/wo5CSHR4ANtifY6ZRXNTO5+O8qP82DfAiAeanpZwADMTgzAH0AAAAFZAAgAAAAAFz+M+H/Z94mdPW5oP51B4HWptp1rxcMWAjnlHvWJDWrBXMAIAAAAACBFEOQyL7ZHu4Cq33QvXkmKuH5ibG/Md3RaED9CtG5HwVsACAAAAAAfggtJTprQ/yZzj7y5z9KvXsdeXMWP0yUXMMJqpOwI88AAzE4NAB9AAAABWQAIAAAAAAE7c2x3Z3aM1XGfLNk/XQ9jCazNRbGhVm7H8c2NjS5ywVzACAAAAAARJ9h8fdcwA19velF3L/Wcvi2rCzewlKZ2nA0p8bT9uwFbAAgAAAAAJtWe6b4wK2Hae2dZm/OEpYQnvoZjz4Sz5IgJC2wInecAAMxODUAfQAAAAVkACAAAAAAVoRt9B9dNVvIMGN+ea5TzRzQC+lqSZ8dd/170zU5o9cFcwAgAAAAAEwM95XZin5mv2yhCI8+ugtKuvRVmNgzzIQN0yi1+9aIBWwAIAAAAAAMGBq72n00rox3uqhxSB98mkenTGCdbbUF1gXrgottzgADMTg2AH0AAAAFZAAgAAAAAKRDkjyWv/etlYT4GyoXrmBED2FgZHnhc+l9Wsl06cH2BXMAIAAAAABohlpm3K850Vndf3NmNE0hHqDlNbSR8/IvMidQ3LnIZAVsACAAAAAAW42nGHa6q2MCAaaPVwaIDfr8QLyQwjKq23onZJYsqVsAAzE4NwB9AAAABWQAIAAAAAC3DFh5oklLCNLY90bgWm68dFXz65JpAZSp1K99MBTPAQVzACAAAAAAQgZecmxEUZVHoptEQClDwAf8smI3WynQ/i+JBP0g+kQFbAAgAAAAAEUSQGVnAPISD6voD0DiBUqyWKgt2rta0tjmoe+LNt6IAAMxODgAfQAAAAVkACAAAAAAQ5WKvWSB503qeNlOI2Tpjd5blheNr6OBO8pfJfPNstcFcwAgAAAAAKwHgQLSDJ5NwLBQbY5OnblQIsVDpGV7q3RCbFLD1U4/BWwAIAAAAACQ5nED99LnpbqXZuUOUjnO2HTphEAFBjLD4OZeDEYybgADMTg5AH0AAAAFZAAgAAAAAGfhFY3RGRm5ZgWRQef1tXxHBq5Y6fXaLAR4yJhrTBplBXMAIAAAAACKEF0ApLoB6lP2UqTFsTQYNc9OdDrs/vziPGzttGVLKQVsACAAAAAArOO6FyfNRyBi0sPT5iye7M8d16MTLcwRfodZq4uCYKEAAzE5MAB9AAAABWQAIAAAAAAIM73gPcgzgotYHLeMa2zAU4mFsr7CbILUZWfnuKSwagVzACAAAAAAJCSu98uV8xv88f2BIOWzt6p+6EjQStMBdkGPUkgN79cFbAAgAAAAAMGqPGMPxXbmYbVfSa/japvUljht1zZT33TY7ZjAiuPfAAMxOTEAfQAAAAVkACAAAAAAkWmHCUsiMy1pwZTHxVPBzPTrWFBUDqHNrVqcyyt7nO8FcwAgAAAAAMv2CebFRG/br7USELR98sIdgE9OQCRBGV5JZCO+uPMgBWwAIAAAAABt7qSmn3gxJu7aswsbUiwvO+G6lXj/Xhx+J/zQyZxzLAADMTkyAH0AAAAFZAAgAAAAAGInUYv0lP/rK7McM8taEHXRefk8Q2AunrvWqdfSV7UaBXMAIAAAAACE+WPxJ3gan7iRTbIxXXx+bKVcaf8kP4JD8DcwU0aL7wVsACAAAAAAUC4eTprX4DUZn2X+UXYU6QjtiXk+u57yoOPBbPQUmDkAAzE5MwB9AAAABWQAIAAAAACmHlg2ud3cplXlTsNTpvNnY6Qm1Fce0m899COamoDjaQVzACAAAAAArtJQeJIlepBWRU2aYar7+YGYVQ7dfDc1oxgTmA8r9q0FbAAgAAAAAOk45vg5VqZHAFCO3i0Z52SZi5RADf8NXwf68T5yad/DAAMxOTQAfQAAAAVkACAAAAAApzcWSAbZWV/Rq+ylRNqqlJqNVR4fhXrz4633/MQOQgcFcwAgAAAAAN/jz/bsEleiuCl+li83EWlG6UMHA8CyaOMRKCkXkSCPBWwAIAAAAAC3Sd+Qg+uFDKpGZHbrQgokXHQ1az1aFl4YK343OB6hcQAAEmNtAAAAAAAAAAAAABBwYXlsb2FkSWQAAAAAABBmaXJzdE9wZXJhdG9yAAEAAAAA", - "subType": "06" - } - } - } - } - } - ], - "cursor": {}, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "aggregate" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": { - "$numberInt": "0" - }, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rbf3AeBEv4wWFAKknqDxRW5cLNkFvbIs6iJjc6LShQY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "n+XAuFnP8Dov9TnhGFxNx0K/MnVM9WbJ7RouEu0ndO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yRXojuVdn5GQtD97qYlaCL6cOLmZ7Cvcb3wFjkLUIdM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DuIkdRPITRs55I4SZmgomAHCIsDQmXRhW8+MOznkzSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SsBk+Et1lTbU+QRPx+xyJ/jMkmfG+QCvQEpip2YYrzA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "crCIzOd8KhHvvUlX7M1v9bhvU4pLdTc+X2SuqoKU5Ek=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YOWdCw4UrqnxkAaVjqmC4sKQDMVMHEpFGnlxpxdaU6E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M3SShp81Ff8tQ632qKbv9MUcN6wjDaBReI0VXNu6Xh4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gzHlSPxpM0hT75kQvWFzGlOxKvDoiKQZOr19V6l2zXI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s3JnppOGYw9SL2Q1kMAZs948v2F5PrpXjGei/HioDWs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cG6+3Gk/zEH68P/uuuwiAUVCuyJwa1LeV+t29FlPPAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dupdvR3AyJtM+g9NDKiaLVOtGca387JQp8w+V03m7Ig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JqEQc5svj2jTvZ6LLA5ivE+kTb/0aRemSEmxk4G7Zrg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "szcXXXKnob+p3SoM4yED2R920LeJ7cVsclPMFTe4CeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o1QoGVXmuBdHwHm7aCtGMlMVKrjFdYvJXpoq6uhIAZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Jfm5wPlqqLCJRGQIqRq2NGmpn7s0Vrih2H3YAOoI2YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zMHLb8ARbsYo8Ld05bqnGFf1Usha6EGb8QKwdSAyps0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yQdtq9lh5pugL7/i0Bj/PuZUUBUIzf+7wj1rl5y736w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wGWVZdO7qIuyDg/BqDgqjgoQ02h5YYgwXQB1oCin2NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "by9HMLj6NTEpgztZ5HSN6GxImkXPcaFINYDzgZY33X8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tWo0vbasi7bXmn/MsOx13VC1IsWtpx/nYp0uj4iMzdA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tQQpndUYd5O87lOtrGjH3wl9VsOK0ray7RMasL90sBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cQjXEDCMsOpKLLf+vlTgIHA+cbSJdzqhbSX9Wvh95aA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7yMpU48IxK9SzP2cx3VnTownGEwFmeFofuuFT97SuuY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kSOx1kz0CmBgzKQHZlo65ZUY1DIv9A99JRm+Us2y6Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubQpdPBe6/xvtr+AcXdfYLSvYCR4ot0tivehkCsupb4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xal+iCJ6FTefRQToyoNksc9NCZShyn04NDGi4IYrcoM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d7jU4iOK50xHxlkSifcxlZFCM46TSgQzoYivxG3HNLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJvl2nsBLBVzL3pp6sKWCL4UXeh3q/roYBJjSb74ve0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OIUCaKRvIx9t1w6Hxlz1IcQTdPNCfdRNwnnTm10W+X0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A9tvzsiElotOUVIB4CqfQp9mAwqvTM35YkmAR170aHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lI8gpK7hpb7c9x4RQugsxMnQay5LZJmwslZdvMx/dcE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dNCzh40U0XvdKnSDi3HRQOWQftEsDVqc4uUvsVFGoq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IP+iwEBWBwVVZIdpaMu8k5+soFCz+TZkYn3drKZ9grE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnqyh6e0y5svHkJDShlN9CHV0WvMBE4QbtJpQw5ZCXc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "elEl42tbVDoRTLjAhZUFEtXiut4b3PVhg/1ZLZSQdtE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vHuu2FxwclMHqyE6JBYbTYgbEkB0dqb/JuaxsvfwsmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xTf7NCe3Gf8QpE78HR5OknlLTKfs9J+RN9UZpH6fnso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XiWSasRnJAulGR6+LCVD3mwRObXylqYWR9jvpywq12c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MZMxEQ5ikx0PG1YFIExv0UnTZogsvgeOEZTpzvBDn4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yZMyMZBDrWbAhvnic7vvIYhmO9m5H2iuv0c8KNZrBzY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xxM14hTPY5j0vvcK2C7YAEjzdsfUTFHozHC0hEo1bxI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+01rqR1xVwkpGXcstbk1ItJqFVjH6Q8MGxEN3Cm9Y1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xOpLV0Z2VTRJ3iWtnWZcsyjXubTIkYWo31cO+HV1o1k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BWUOLqgLBqc5NwxVlSV5H3KFQPXbCp7mdo+jF+8cJqY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fuQb1S6xZDGlrEbK+kI23aL53PP1PVNwqICnZNt9Yzg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfscnoibFttahLdPVC4Ee+47ewGFKpDSU7M6HX19bKE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rpSW2awybNVeKtat91VFxqbINoTfNhPfQAu+d73Xtf8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9M/CP9ccOIIj2LLFmE0GFDO0Ban2wsNalEXfM6+h+1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WrEMG49l1ye4MhXs5ZS9tz8P6h+hDvthIg/2wW9ne1Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ImNhbfeyfH8qIEeA5ic0s3dAQBdzzTBS+CPsNih9vZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dWP33YDSn04UKJN2ogh2Rui0iW/0q2y18OCDRVcfyoo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lYv0isAtfGh6H9tdp3cp2eHU7q2J+uk7QrgcxtK3w7Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VGMoamB/+7zTOYcY/pqJc96xlv2PdW4hwsIAEIslTDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yNeBWMF7BnD9wVwz2PgJsvWr77QiVvvWUvJF0+fqBug=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfpvObJ+tJBXSvqeN7vlOfmhYign635lciYAJIjUtY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dsen4NqjzVGjpjufiTMs3+gqeD09EbnuogPgxrJECwg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pxCWVM3sn19NsFEpgHbgLa+PmYlhN3mMiP0Wk8kJhYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q11KNvJszjYIB9n9HcC+N4uz11a3eRj1L3BH9scKMDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A1PmkgcEToWh1JiVWE6mI5jUu7poxWWuCUt/cgRUUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qJo3Hu4PJeanL7XEaWXO/n3YsodhZyd+MJOOmB9Kpd8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BkBKLO8URFscfRY9Bav/1+L9mLohDgNr/MkZtGiraIs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rZq5WA3Hx3xthOyHAJXK//f8pE2qbz7YKu3TIMp9GFY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X07a/Lm80p5xd4RFs1dNmw+90tmPDPdGiAKVZkxd4zY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6YrBn2ofIw1b5ooakrLOwF41BWrps8OO0H9WH4/rtlE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0l86Ag5OszXpa78SlOUV3K9nff5iC1p0mRXtLg9M1s4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Hn6yuxFHodeyu7ISlhYrbSf9pTiH4TDEvbYLWjTwFO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zdf4y2etKBuIpkEU1zMwoCkCsdisfXZCh8QPamm+drY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rOQ9oMdiK5xxGH+jPzOvwVqdGGnF3+HkJXxn81s6hp4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "61aKKsE3+BJHHWYvs3xSIBvlRmKswmaOo5rygQJguUg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KuDb/GIzqDM8wv7m7m8AECiWJbae5EKKtJRugZx7kR0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Q+t8t2TmNUiCIorVr9F3AlVnX+Mpt2ZYvN+s8UGict8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJRZIpKxUgHyL83kW8cvfjkxN3z6WoNnUg+SQw+LK+k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnUsYjip8SvW0+m9mR5WWTkpK+p6uwJ6yBUAlBnFKMk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PArHlz+yPRYDycAP/PgnI/AkP8Wgmfg++Vf4UG1Bf0E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wnIh53Q3jeK8jEBe1n8kJLa89/H0BxO26ZU8SRIAs9Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4F8U59gzBLGhq58PEWQk2nch+R0Va7eTUoxMneReUIA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ihKagIW3uT1dm22ROr/g5QaCpxZVj2+Fs/YSdM2Noco=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EJtUOOwjkrPUi9mavYAi+Gom9Y2DuFll7aDwo4mq0M0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dIkr8dbaVRQFskAVT6B286BbcBBt1pZPEOcTZqk4ZcI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aYVAcZYkH/Tieoa1XOjE/zCy5AJcVTHjS0NG2QB7muA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sBidL6y8TenseetpioIAAtn0lK/7C8MoW4JXpVYi3z8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0Dd2klU/t4R86c2WJcJDAd57k/N7OjvYSO5Vf8KH8sw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I3jZ92WEVmZmgaIkLbuWhBxl7EM6bEjiEttgBJunArA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aGHoQMlgJoGvArjfIbc3nnkoc8SWBxcrN7hSmjMRzos=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bpiWPnF/KVBQr5F6MEwc5ZZayzIRvQOLDAm4ntwOi8g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tI7QVKbE6avWgDD9h4QKyFlnTxFCwd2iLySKakxNR/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XGsge0CnoaXgE3rcpKm8AEeku5QVfokS3kcI+JKV1lk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JQxlryW2Q5WOwfrjAnaZxDvC83Dg6sjRVP5zegf2WiM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YFuHKJOfoqp1iGVxoFjx7bLYgVdsN4GuUFxEgO9HJ5s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Z6vUdiCR18ylKomf08uxcQHeRtmyav7/Ecvzz4av3k4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SPGo1Ib5AiP/tSllL7Z5PAypvnKdwJLzt8imfIMSEJQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "m94Nh6PFFQFLIib9Cu5LAKavhXnagSHG6F5EF8lD96I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pfEkQI98mB+gm1+JbmVurPAODMFPJ4E8DnqfVyUWbSo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DNj3OVRLbr43s0vd+rgWghOL3FqeO/60npdojC8Ry/M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kAYIQrjHVu49W8FTxyxJeiLVRWWjC9fPcBn+Hx1F+Ss=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aCSO7UVOpoQvu/iridarxkxV1SVxU1i9HVSYXUAeXk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Gh6hTP/yj1IKlXQ+Q69KTfMlGZjEcXoRLGbQHNFo/1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/gDgIFQ4tAlJk3GN48IS5Qa5IPmErwGk8CHxAbp6gs0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PICyimwPjxpusyKxNssOOwUotAUbygpyEtORsVGXT8g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4lu+cBHyAUvuxC6JUNyHLzHsCogGSWFFnUCkDwfQdgI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pSndkmoNUJwXjgkbkgOrT5f9nSvuoMEZOkwAN9ElRaE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tyW+D4i26QihNM5MuBM+wnt5AdWGSJaJ4X5ydc9iWTU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9Syjr8RoxUgPKr+O5rsCu07AvcebA4P8IVKyS1NVLWc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "67tPfDYnK2tmrioI51fOBG0ygajcV0pLo5+Zm/rEW7U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "y0EiPRxYTuS1eVTIaPQUQBBxwkyxNckbePvKgChwd0M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NWd+2veAaeXQgR3vCvzlI4R1WW67D5YsVLdoXfdb8qg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PY5RQqKQsL2GqBBSPNOEVpojNFRX/NijCghIpxD6CZk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lcvwTyEjFlssCJtdjRpdN6oY+C7bxZY+WA+QAqzj9zg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWE7XRNylvTwO/9Fv56dNqUaQWMmESNS/GNIwgBaEI0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ijwlrUeS8nRYqK1F8kiCYF0mNDolEZS+/lJO1Lg93C8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8KzV+qYGYuIjoNj8eEpnTuHrMYuhzphl80rS6wrODuU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wDyTLjSEFF895hSQsHvmoEQVS6KIkZOtq1c9dVogm9I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SGrtPuMYCjUrfKF0Pq/thdaQzmGBMUvlwN3ORIu9tHU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KySHON3hIoUk4xWcwTqk6IL0kgjzjxgMBObVIkCGvk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hBIdS9j0XJPeT4ot73ngELkpUoSixvRBvdOL9z48jY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Tx6um0q9HjS5ZvlFhvukpI6ORnyrXMWVW1OoxvgqII0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zFKlyfX5H81+d4A4J3FKn4T5JfG+OWtR06ddyX4Mxas=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cGgCDuPV7MeMMYEDpgOupqyNP4BQ4H7rBnd2QygumgM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IPaUoy98v11EoglTpJ4kBlEawoZ8y7BPwzjLYBpkvHQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Pfo4Am6tOWAyZNn8G9W5HWWGC3ZWmX0igI/RRB870Ro=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fnTSjd7bC1Udoq6iM7UDnHAC/lsIXSHp/Gy332qw+/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fApBgVRrTDyEumkeWs5p3ag9KB48SbU4Si0dl7Ns9rc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QxudfBItgoCnUj5NXVnSmWH3HK76YtKkMmzn4lyyUYY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sSOvwhKa29Wq94bZ5jGIiJQGbG1uBrKSBfOYBz/oZeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FdaMgwwJ0NKsqmPZLC5oE+/0D74Dfpvig3LaI5yW5Fs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sRWBy12IERN43BSZIrnBfC9+zFBUdvjTlkqIH81NGt4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/4tIRpxKhoOwnXAiFn1Z7Xmric4USOIfKvTYQXk3QTc=", - "subType": "00" - } - } - ] - }, - { - "_id": { - "$numberInt": "1" - }, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RGTjNVEsNJb+DG7DpPOam8rQWD5HZAMpRyiTQaw7tk8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I93Md7QNPGmEEGYU1+VVCqBPBEvXdqHPtTJtMOn06Yk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "GecBFQ1PemlECWZWCl7f74vmsL6eB6mzQ9n6tK6FYfs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QpjhZl+O1ORifgtCZuWAdcP6OKL7IZ2cA46v8FJcV28=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RlQWwhU+uVv0a+9IB5cUkEfvHBvOw3B1Sx6WfPWMqes=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubb81XTC7U+4tcNzf1oYvOY6gR5hC2Izqx54f4GuJ0E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6M4Q5NMQ9TqNnjzGOxIkiUIY8TEL0I3XD1QnhefQUqU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BtInzk9t2FFMCEY6AQ7zN8jwrrZEs2irSv6q0Q4NaIw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vxXfETu9cuBIpRBo3jUUU04mJIH/aAhLX8K6VI5Xv0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wXPCdS+q23zi1bkPnaVG2j0PsVtxdeSLJ//h6J1x8RU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KY3KkfBAsN2l80wbpj41G0gwBR5KmmFnZcagg7D3ENk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tI8NFAxXCX4VOnY5X73K6KI/Yspd3aR94KV39MhJlAw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "nFxH0UC3mATKA6Vboz+QX/hAjj19kF/SH6H5Cne7qC0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q8hYqIYaIi7nOdG/7qQZYnz8Bsacfi66M1nVku4SH08=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4saA92R4arp4anvD9xFtze+sNcQqTEhPHyl1h70A8NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DbIziOBRRyeQS6RtBR09E37LV+CTKrEjGoRMLSpG6eE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Fv80Plp/7w2gnVqrwawLd6qhJ10G4NCDm3re67cNq4Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "T/T2oiQCBBES4YN7EodzPRdabZSFlYIClHBym+bQUZE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ZQgHD3l46Ujqtbnj1VbbeM29C9wJzOhz+yZ/7XdSrxk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ltlFKzWvyZvHxDFOYDd/XXJ6kUiJj0ln2HTCEz2o4Z4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "flW8A7bltC1u8bzx0WJtxosGJdOVsJFfbx33jxnpFGg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SXO+92QbMKwUSG2t27ciunV1c3VvFkUuDmSczpRe008=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+KioGs1GM+xRBzFE67ePTWj04KMSE5/Y6qUF7nJ5kvU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L3xNVbh6YH+RzqABN+5Jgb7T234Efpn766DmUvxIxgg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hPF+60mBYPjh21dEmPlBhKgyc9S2qLtTkypYvnqP2Fc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EletRsETy2HcjaPIm2c8CkT7ch/P3pJJDC8hasepcSU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "r5bMXUaNKqLPxZ+TG9HYTG4aSDgcpim27rN8rQFkM0w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0Q7Erdr8+/S0wUEDDIqlS5XjBVWvhZY65K0uUDb6+Ns=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xEcnhXy35hbXNVBPOOt3TUHbxvKfQ48KjA9b6/rbMqQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "T8bEpiQNgsEudXvyKE9SZlSvbpV/LUaslsdqgSFltyo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hIoiaF2YjnxDbODfhFEB+JGZ5nf8suD3Shck5bwQ3N0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qnA6qzejeRJ0rsZaZ0zOvKAaXyxt5lpscKQNYFZNl4k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "anAKCL2DN/le2VaP0n2ucYSEH/DaaEH/8Sa4OqTZsRA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JCZlBJaFm618oWYSnT9Jr1MtwFVw4BZjOzO+5yWgR90=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yxyk4n9762WzcDVGnTn4jCqUnSMIVCrLDIjCX1QVj34=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fDI6fdKvDJwim5/CQwWZEzcrXE3LHgy7FTtffcC7tXE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Vex+gcz5T+WkzsVZQrkqUR2ryyZbnaOGuWpYvjN0zCw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8TLEXz+Gbbp6llHpZXVjLsdlYY9f6hrKpHVpyfDe0RY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7fTyt5BrunypS65TfOzFW2E2qdIuT4SLeDeGlbQoJCs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8fKGrkqN0/KuSjyXgDBmRauDKrSa//JBKRWHEB9xBf4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s4codmG7uN4ss6P357jL21lazEe90M9GOK5WrOknSV0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RkSpua8XF+NUdxVDU90EbLUTTyZFX3tt3atBTroFaRk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "LnTCuCDyAHK5B9KXzjtwGmWB+qergQk2OCjnIx9MI2A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cBFh0virAX4pVXf/udIGI2951i0+0aZAdJcBVGtYnT4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "G54X6myQXWZ5fw/G31en3QbdgfXzL9+hFTtJpnWMqDI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EdsiiuezcsFJFnYIyGjCOhnqMj1BOwTB5EFxN+ERUkg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dVH9MXLtk0WTwGQ3xmrhOqfropMUkDW3o6paNPGl3NU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sB3HqXKWY3pKbuEH8BTbfNIGfbY+7/ZbOc3XC+JRNNI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WHyDk62Xhqbo4/iie2aLIM4x2uuAjv6102dJSHI58oM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pNUFuHpeNRDUZ/NrtII2c6sNc9eGR1lIUlIyXKERA+0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UPa+pdCqnN0bfAptdzldQOSd01gidrDKy8KhWrpSKAI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "l+7dOAlo+HUffMqFYXL6pgUFeTbwOM9CjKQLxEoLtc4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SRnDXV/rN6C8xwMutv9E1luv3DOUio3VkgPr8Cpm7Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QcH6gl+gX7xZ7OWhUNQMbndJy0Piz49pDo6RsnLkVSA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "t+uL4DnfsI/Zll/KXWW1cOKX3Hu8WIkm3pt9efCVSAQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "myutHDctku/+Uug/nD8gRbYvmx/IovtoAAC2/fz2oHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6C+cjD0e0nSCP6cPqQYbNG7SlOd6Mfvi8hyfm7Ng+D8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zg01JSoOj9oBKT0S1ldJucXzY5AKgreS+h2xJreWTOs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7qQ80/FjodHl1m1py/Oii0/9C/xWbLdhaRXQ+kkCP10=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YwWMNH07vL6c5Nhg+MRnVByhzUunu8y0VLM9z/XvR5U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dle8bU98+fudAbc14SToZFkwvV3tcYVsjDug0NWljpc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "J+eKL1vPJmlzltvhI6Li5Fz/TJmi3Ng+ehRTcs46API=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB3XzfFygLwC3WHkj0up+VbEd25KKoce1vOpG/5bwK4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vnVnmOnL+z2pqwE+A6cVKS0Iwy4F4/2IiElJca9bUQM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+lG5r/Fpqry3BtFuvY67+RntmHAMDoLVOSGc6ZoXPb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L5MXQertqc6uj7ADe8aWKbd1sYHPCE7P1VYVg9Zc3VI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "imKONuZgopt0bhM3GMX2WVPwQYMTobuUUEdhcLfHs4c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "eOkU1J1uVbiVFWBerbXsSIVcF2nqiicTkFy4x7kFHB8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gI0uDhXeoH/UatDQKEf4qo8FHzWZDhb/wuWTqbq/ID4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cOkd5Aa3btYhtojE/smsF/PJnULqQ4NNqTkU6KXTFmo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "AWNJMs1MTe294oFipp8Y6P0CjpkZ4qCZoClQF3XcHq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6gJtlzXOFhGYrVbTuRMmvMlDTwXdNtR9aGBlHZPwIMw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "LEmwVGA/xsEG7UrcOoYLFu6KCXgijzFznenknuDacm8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "mIRFPTXRrGaPtp/Ydij2jgkRe4uoUvAKxW2d8b9zYL0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "B+Uv2u48WALOO0L311z+eryjYQzKJVMfdHMZPhOAFmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "INXXp0wDyVCq+NtfIrrC2ciETmyW/dWB/48/u4yLEZ4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "se7DGo8XrlrQDLEcco1tZrQt9kDe+0RTyl2bw/quG4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vr0m2+Zk9lbN6UgWCyn8xJWJOokU3IDYab5U5q1+CgQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XI+eJ8Gy2JktG1gICgoj1qpsfy1tKmH0kglWbaQH6DA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A+UCuNnuAUqnQzspA6TVqUPRmtZmpSex5HFw7THRxs0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xaH2Ehfljd19uo0Fvb3iwkdaiWEVQd2YPoitgEPkhSM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "S/iZBJGcc8+qZxyMtab65MMBoSglybwk3x58Nb86gnY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "w14ZE5qqY5YgkS4Zcs9YNbrQbY1XfGOOHNn9bOYnFVQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0MhGd/jEF1vjkKGp+ZMn9SjLK54jkp9W4Hg+Sp/oxaI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "92QZ73e/NRTYgCm4aifaKth6aAsKnLLccBc0zx/qUTY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WOjzemCgFJOiGIp81RSVh/tFlzSTj9eFWcBnsiv2Ycs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DrsP9CmfKPjw5yLL8bnSeAxfNzAwlb+Z8OqCiKgBY7o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lMogqg8veBv6mri3/drMe9afJiKMvevkmGcw9BedfLo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "TxqwNcY8Tg2MPpNdkPBwvfpuTttSYRHU26DGECKYQ9o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "l0u1b4b4vYACWIwfnB7PZac4oDEgjQZCzHruNPTgAIY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "iVSGQ+cCfhbWIrY/v/WBORK92elu9gfRKyGhr6r/k00=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yK1forG50diEXte8ECzjfpHeYsPyuQ/dgxbxn/nzY5k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gIfTLCD3VwnOwkC0zPXWTqaITxX6ZplA69PO2a6zolc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "O/Zxlgh3WqpzJ7+Sd8XWMVID4/GXJUUWaSqfgDUi3b0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ZQ6yv368zwahUqSUYH/StL0Qgz/TwS1CzlMjVDvCciI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "m2rPEYkjwyiKdonMrKlcF7hya4lFOAUwEePJ3SgrNx8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Mq0yl5iVKlq71bT/dT/fXOWf2n90bTnXFnOdGDN0JOc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6qDGMXipPLC2O6EAAMjO2F9xx4rdqZso4IkPpH2304U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jvQHRQQa2RIszE2LX2Hv2LbRhYawJ6qmtRt8HZzFQXg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ovJXQrkZlpeHRciKyE/WWNm5O389gRgzx1W+Dw596X4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "a4kgRNvYctGYqyQv9qScL/WkljTYVylJ9pE9KDULlxU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qV4Q48vPiCJMTjljotzYKI/zfExWpkKOSHGcAjGyDig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jtI7zbBF+QW/aYYTkn90zzyHLXLgmy7l1bzgMb2oqic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q0KmJl9txPdn962UNvnfe6UFhdk9YaFZuTm33F+csso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ULNdEqeZJgtmNOhN/Y9INzsE9AnxWYwOMn+pIbRXIFs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "R4oz9+wkdjpKe5tE1jpG7IURAnfvS5fLP4LrD5cZfTE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qG5Z7VhwSu/HT/YFTgDzyAAzJKq51xPw2HeEV5btYC4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OM/1DmIIZ5Qyhtq8TGkHTBEMVKjAnKRZMRXYtTG8ctc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2R5vZbljLXnDFA99YfGuRB7pAdPJVKsT25zLNMC0fUk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OMbavF2EmdAz1fHkLV3ctFEUDfriKhoT2gidwHZ9z1o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MWT4Zrw3/vVvTYMa1Is5Pjr3wEwnBfnEAPPUAHKQhNU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tBkRPfG9yxfKocQx5pAJX0oEHKPL0Tgtr+0UYe09InE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lqxpnDR/H0YgH7RcfKoNoaaRhe1SIazIeMbQ1fu9y3Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "utT1UdR22PWOTrOkZauztX613lAplV4eh/ejTRb7ZSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "S+Y2yFyKi/a6FXhih4yGo29X8I8OT6/zwEoX6NMKT4o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QSjVppg29x6oS5yBg8OFjrFt0tuTpWCuKxfIy0k8YnE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "y3r6/Xsfvsl3HksXlVYkJgHUqpQGfICxg3x9f8Zw1qM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BSltHzEwDjFN4du9rDHAPvl22atlcTioEtt+gC5L1tk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0arGXjSN0006UnXbrWsGqhvBair569DeFDUME3Df3rA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s/DumaMad08S+PBUUcrS+v42K0z8HgcdiQtrFAEu2Qs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EzJ8Y8N0OQBTlnvrK82PdevDNZZO4E6CNgYVu8Cj6Ks=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VA4vr8jBPI5QdiPrULzzZjBMIUbG3V7Slg5zm0bFcKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YAOvEB2ZLtq9LQiFViBHWaxxWVVonC2rNYj9tN9s3L0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hgaHMo9aAGS+nBwvqnTjZO+YkiQPY1c1XcIYeaYKHyI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YvaoLt3ZpH0atB0tNzwMjpoxRYJXl0DqSjisMJiGVBE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EMmW6CptFsiLoPOi5/uAJQ2FmeLg6mCpuVLLrRWk7Mc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1jQsNMarSnarlYmXEuoFokeBMg/090qUD9wqo1Zn8Gs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hupXNKhRpJxpyDAAP1TgJ5JMZh9lhbMk6s7D7dMS3C8=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Correctness.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Correctness.json deleted file mode 100644 index 758d3e573..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Correctness.json +++ /dev/null @@ -1,1156 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "Find with $gt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$numberDecimal": "0.0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$gte": { - "$numberDecimal": "0.0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$numberDecimal": "1.0" - } - } - } - }, - "result": [] - } - ] - }, - { - "description": "Find with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$lt": { - "$numberDecimal": "1.0" - } - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - ] - } - ] - }, - { - "description": "Find with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$lte": { - "$numberDecimal": "1.0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$numberDecimal": "0.0" - }, - "$lt": { - "$numberDecimal": "2.0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - ] - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$in": [ - { - "$numberDecimal": "0.0" - } - ] - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalNoPrecision": { - "$gte": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$numberDecimal": "1.0" - } - } - } - } - ] - }, - "result": [] - } - ] - }, - { - "description": "Aggregate with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalNoPrecision": { - "$lt": { - "$numberDecimal": "1.0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalNoPrecision": { - "$lte": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$numberDecimal": "0.0" - }, - "$lt": { - "$numberDecimal": "2.0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - ] - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalNoPrecision": { - "$in": [ - { - "$numberDecimal": "0.0" - } - ] - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0.0" - } - } - ] - } - ] - }, - { - "description": "Wrong type: Insert Int", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberInt": "0" - } - } - }, - "result": { - "errorContains": "cannot encrypt element" - } - } - ] - }, - { - "description": "Wrong type: Find Int", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$gte": { - "$numberInt": "0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": { - "errorContains": "field type is not supported" - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Delete.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Delete.json deleted file mode 100644 index 24a08f318..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Delete.json +++ /dev/null @@ -1,1111 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Decimal. Delete.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1" - } - } - } - }, - { - "name": "deleteOne", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$numberDecimal": "0" - } - } - } - }, - "result": { - "deletedCount": 1 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "delete": "default", - "deletes": [ - { - "q": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$binary": { - "base64": "DeFiAAADcGF5bG9hZACxYgAABGcAnWIAAAMwAH0AAAAFZAAgAAAAAJu2KgiI8vM+kz9qD3ZQzFQY5qbgYqCqHG5R4jAlnlwXBXMAIAAAAAAAUXxFXsz764T79sGCdhxvNd5b6E/9p61FonsHyEIhogVsACAAAAAAt19RL3Oo5ni5L8kcvgOJYLgVYyXJExwP8pkuzLG7f/kAAzEAfQAAAAVkACAAAAAAPQPvL0ARjujSv2Rkm8r7spVsgeC1K3FWcskGGZ3OdDIFcwAgAAAAACgNn660GmefR8jLqzgR1u5O+Uocx9GyEHiBqVGko5FZBWwAIAAAAADflr+fsnZngm6KRWYgHa9JzK+bXogWl9evBU9sQUHPHQADMgB9AAAABWQAIAAAAAD2Zi6kcxmaD2mY3VWrP+wYJMPg6cSBIYPapxaFQxYFdQVzACAAAAAAM/cV36BLBY3xFBXsXJY8M9EHHOc/qrmdc2CJmj3M89gFbAAgAAAAAOpydOrKxx6m2gquSDV2Vv3w10GocmNCFeOo/fRhRH9JAAMzAH0AAAAFZAAgAAAAAOaNqI9srQ/mI9gwbk+VkizGBBH/PPWOVusgnfPk3tY1BXMAIAAAAAAc96O/pwKCmHCagT6T/QV/wz4vqO+R22GsZ1dse2Vg6QVsACAAAAAAgzIak+Q3UFLTHXPmJ+MuEklFtR3eLtvM+jdKkmGCV/YAAzQAfQAAAAVkACAAAAAA0XlQgy/Yu97EQOjronl9b3dcR1DFn3deuVhtTLbJZHkFcwAgAAAAACoMnpVl6EFJak8A+t5N4RFnQhkQEBnNAx8wDqmq5U/dBWwAIAAAAACR26FJif673qpwF1J1FEkQGJ1Ywcr/ZW6JQ7meGqzt1QADNQB9AAAABWQAIAAAAAAOtpNexRxfv0yRFvZO9DhlkpU4mDuAb8ykdLnE5Vf1VAVzACAAAAAAeblFKm/30orP16uQpZslvsoS8s0xfNPIBlw3VkHeekYFbAAgAAAAAPEoHj87sYE+nBut52/LPvleWQBzB/uaJFnosxp4NRO2AAM2AH0AAAAFZAAgAAAAAIr8xAFm1zPmrvW4Vy5Ct0W8FxMmyPmFzdWVzesBhAJFBXMAIAAAAABYeeXjJEzTHwxab6pUiCRiZjxgtN59a1y8Szy3hfkg+gVsACAAAAAAJuoY4rF8mbI+nKb+5XbZShJ8191o/e8ZCRHE0O4Ey8MAAzcAfQAAAAVkACAAAAAAl+ibLk0/+EwoqeC8S8cGgAtjtpQWGEZDsybMPnrrkwEFcwAgAAAAAHPPBudWgQ+HUorLDpJMqhS9VBF2VF5aLcxgrM1s+yU7BWwAIAAAAAAcCcBR2Vyv5pAFbaOU97yovuOi1+ATDnLLcAUqHecXcAADOAB9AAAABWQAIAAAAACR9erwLTb+tcWFZgJ2MEfM0PKI9uuwIjDTHADRFgD+SQVzACAAAAAAcOop8TXsGUVQoKhzUllMYWxL93xCOkwtIpV8Q6hiSYYFbAAgAAAAAKXKmh4V8veYwob1H03Q3p3PN8SRAaQwDT34KlNVUjiDAAM5AH0AAAAFZAAgAAAAALv0vCPgh7QpmM8Ug6ad5ioZJCh7pLMdT8FYyQioBQ6KBXMAIAAAAADsCPyIG8t6ApQkRk1fX/sfc1kpuWCWP8gAEpnYoBSHrQVsACAAAAAAJe/r67N6d8uTiogvfoR9rEXbIDjyLb9EVdqkayFFGaYAAzEwAH0AAAAFZAAgAAAAAIW4AxJgYoM0pcNTwk1RSbyjZGIqgKL1hcTJmNrnZmoPBXMAIAAAAAAZpfx3EFO0vY0f1eHnE0PazgqeNDTaj+pPJMUNW8lFrAVsACAAAAAAP+Um2vwW6Bj6vuz9DKz6+6aWkoKoEmFNoiz/xXm7lOsAAzExAH0AAAAFZAAgAAAAAKliO6L9zgeuufjj174hvmQGNRbmYYs9yAirL7OxwEW3BXMAIAAAAAAqU7vs3DWUQ95Eq8OejwWnD0GuXd+ASi/uD6S0l8MM1QVsACAAAAAAb9legYzsfctBPpHyl7YWpPmLr5QiNZFND/50N1vv2MUAAzEyAH0AAAAFZAAgAAAAAOGQcCBkk+j/Kzjt/Cs6g3BZPJG81wIHBS8JewHGpgk+BXMAIAAAAABjrxZXWCkdzrExwCgyHaafuPSQ4V4x2k9kUCAqUaYKDQVsACAAAAAADBU6KefT0v8zSmseaMNmQxKjJar72y7MojLFhkEHqrUAAzEzAH0AAAAFZAAgAAAAAPmCNEt4t97waOSd5hNi2fNCdWEkmcFJ37LI9k4Az4/5BXMAIAAAAABX7DuDPNg+duvELf3NbLWkPMFw2HGLgWGHyVWcPvSNCAVsACAAAAAAS7El1FtZ5STh8Q1FguvieyYX9b2DF1DFVsb9hzxXYRsAAzE0AH0AAAAFZAAgAAAAAD4vtVUYRNB+FD9yoQ2FVJH3nMeJeKbi6eZfth638YqbBXMAIAAAAAANCuUB4OdmuD6LaDK2f3vaqfgYYvg40wDXOBbcFjTqLwVsACAAAAAA9hqC2VoJBjwR7hcQ45xO8ZVojwC83jiRacCaDj6Px2gAAzE1AH0AAAAFZAAgAAAAAJPIRzjmTjbdIvshG6UslbEOd797ZSIdjGAhGWxVQvK1BXMAIAAAAABgmJ0Jh8WLs9IYs/a7DBjDWd8J3thW/AGJK7zDnMeYOAVsACAAAAAAi9zAsyAuou2oiCUHGc6QefLUkACa9IgeBhGu9W/r0X8AAzE2AH0AAAAFZAAgAAAAAABQyKQPoW8wGPIqnsTv69+DzIdRkohRhOhDmyVHkw9WBXMAIAAAAAAqWA2X4tB/h3O1Xlawtz6ndI6WaTwgU1QYflL35opu5gVsACAAAAAAWI/Gj5aZMwDIxztqmVL0g5LBcI8EdKEc2UA28pnekQoAAzE3AH0AAAAFZAAgAAAAACB7NOyGQ1Id3MYnxtBXqyZ5Ul/lHH6p1b10U63DfT6bBXMAIAAAAADpOryIcndxztkHSfLN3Kzq29sD8djS0PspDSqERMqokQVsACAAAAAADatsMW4ezgnyi1PiP7xk+gA4AFIN/fb5uJqfVkjg4UoAAzE4AH0AAAAFZAAgAAAAAKVfXLfs8XA14CRTB56oZwV+bFJN5BHraTXbqEXZDmTkBXMAIAAAAAASRWTsfGOpqdffiOodoqIgBzG/yzFyjR5CfUsIUIWGpgVsACAAAAAAkgCHbCwyX640/0Ni8+MoYxeHUiC+FSU4Mn9jTLYtgZgAAzE5AH0AAAAFZAAgAAAAAH/aZr4EuS0/noQR9rcF8vwoaxnxrwgOsSJ0ys8PkHhGBXMAIAAAAACd7ObGQW7qfddcvyxRTkPuvq/PHu7+6I5dxwS1Lzy5XAVsACAAAAAA3q0eKdV7KeU3pc+CtfypKR7BPxwaf30yu0j9FXeOOboAAzIwAH0AAAAFZAAgAAAAAKvlcpFFNq0oA+urq3w6d80PK1HHHw0H0yVWvU9aHijXBXMAIAAAAADWnAHQ5Fhlcjawki7kWzdqjM2f6IdGJblojrYElWjsZgVsACAAAAAAO0wvY66l24gx8nRxyVGC0QcTztIi81Kx3ndRhuZr6W4AAzIxAH0AAAAFZAAgAAAAAH/2aMezEOddrq+dNOkDrdqf13h2ttOnexZsJxG1G6PNBXMAIAAAAABNtgnibjC4VKy5poYjvdsBBnVvDTF/4mmEAxsXVgZVKgVsACAAAAAAqvadzJFLqQbs8WxgZ2D2X+XnaPSDMLCVVgWxx5jnLcYAAzIyAH0AAAAFZAAgAAAAAF2wZoDL6/V59QqO8vdRZWDpXpkV4h4KOCSn5e7x7nmzBXMAIAAAAADLZBu7LCYjbThaVUqMK14H/elrVOYIKJQCx4C9Yjw37gVsACAAAAAAEh6Vs81jLU204aGpL90fmYTm5i5R8/RT1uIbg6VU3HwAAzIzAH0AAAAFZAAgAAAAAH27yYaLn9zh2CpvaoomUPercSfJRUmBY6XFqmhcXi9QBXMAIAAAAAAUwumVlIYIs9JhDhSj0R0+59psCMsFk94E62VxkPt42QVsACAAAAAAT5x2hCCd2bpmpnyWaxas8nSxTc8e4C9DfKaqr0ABEysAAzI0AH0AAAAFZAAgAAAAALMg2kNAO4AFFs/mW3In04yFeN4AP6Vo0klyUoT06RquBXMAIAAAAAAgGWJbeIdwlpqXCyVIYSs0dt54Rfc8JF4b8uYc+YUj0AVsACAAAAAAWHeWxIkyvXTOWvfZzqtPXjfGaWWKjGSIQENTU3zBCrsAAzI1AH0AAAAFZAAgAAAAALas/i1T2DFCEmrrLEi7O2ngJZyFHialOoedVXS+OjenBXMAIAAAAAA1kK0QxY4REcGxHeMkgumyF7iwlsRFtw9MlbSSoQY7uAVsACAAAAAAUNlpMJZs1p4HfsD4Q4WZ4TBEi6Oc2fX34rzyynqWCdwAAzI2AH0AAAAFZAAgAAAAAP1TejmWg1CEuNSMt6NUgeQ5lT+oBoeyF7d2l5xQrbXWBXMAIAAAAABPX0kj6obggdJShmqtVfueKHplH4ZrXusiwrRDHMOKeQVsACAAAAAAIYOsNwC3DA7fLcOzqdr0bOFdHCfmK8tLwPoaE9uKOosAAzI3AH0AAAAFZAAgAAAAAMrKn+QPa/NxYezNhlOX9nyEkN1kE/gW7EuZkVqYl0b8BXMAIAAAAABUoZMSPUywRGfX2EEencJEKH5x/P9ySUVrhStAwgR/LgVsACAAAAAAMgZFH6lQIIDrgHnFeslv3ld20ynwQjQJt3cAp4GgrFkAAzI4AH0AAAAFZAAgAAAAAMmD1+a+oVbiUZd1HuZqdgtdVsVKwuWAn3/M1B6QGBM3BXMAIAAAAACLyytOYuZ9WEsIrrtJbXUx4QgipbaAbmlJvSZVkGi0CAVsACAAAAAA4v1lSp5H9BB+HYJ4bH43tC8aeuPZMf78Ng1JOhJh190AAzI5AH0AAAAFZAAgAAAAAOVKV7IuFwmYP1qVv8h0NvJmfPICu8yQhzjG7oJdTLDoBXMAIAAAAABL70XLfQLKRsw1deJ2MUvxSWKxpF/Ez73jqtbLvqbuogVsACAAAAAAvfgzIorXxE91dDt4nQxYfntTsx0M8Gzdsao5naQqcRUAAzMwAH0AAAAFZAAgAAAAAKS/1RSAQma+xV9rz04IcdzmavtrBDjOKPM+Z2NEyYfPBXMAIAAAAAAOJDWGORDgfRv8+w5nunh41wXb2hCA0MRzwnLnQtIqPgVsACAAAAAAf42C1+T7xdHEFF83+c2mF5S8PuuL22ogXXELnRAZ4boAAzMxAH0AAAAFZAAgAAAAAFeq8o82uNY1X8cH6OhdTzHNBUnCChsEDs5tm0kPBz3qBXMAIAAAAABaxMBbsaeEj/EDtr8nZfrhhhirBRPJwVamDo5WwbgvTQVsACAAAAAAMbH453A+BYAaDOTo5kdhV1VdND1avNwvshEG/4MIJjQAAzMyAH0AAAAFZAAgAAAAAI8IKIfDrohHh2cjspJHCovqroSr5N3QyVtNzFvT5+FzBXMAIAAAAABXHXteKG0DoOMmECKp6ro1MZNQvXGzqTDdZ0DUc8QfFAVsACAAAAAA/w5s++XYmO+9TWTbtGc3n3ndV4T9JUribIbF4jmDLSMAAzMzAH0AAAAFZAAgAAAAAJkHvm15kIu1OtAiaByj5ieWqzxiu/epK6c/9+KYIrB0BXMAIAAAAACzg5TcyANk0nes/wCJudd1BwlkWWF6zw3nGclq5v3SJQVsACAAAAAAvruXHTT3irPJLyWpI1j/Xwf2FeIE/IV+6Z49pqRzISoAAzM0AH0AAAAFZAAgAAAAAAYSOvEWWuSg1Aym7EssNLR+xsY7e9BcwsX4JKlnSHJcBXMAIAAAAABT48eY3PXVDOjw7JpNjOe1j2JyI3LjDnQoqZ8Je5B2KgVsACAAAAAAU2815RR57TQ9uDg0XjWjBkAKvf8yssxDMzrM4+FqP6AAAzM1AH0AAAAFZAAgAAAAAGQxC9L1e9DfO5XZvX1yvc3hTLtQEdKO9FPMkyg0Y9ZABXMAIAAAAADtmcMNJwdWLxQEArMGZQyzpnu+Z5yMmPAkvgq4eAKwNQVsACAAAAAAJ88zt4Y/Hoqh+zrf6KCOiUwHbOzCxSfp6k/qsZaYGEgAAzM2AH0AAAAFZAAgAAAAADLHK2LNCNRO0pv8n4fAsxwtUqCNnVK8rRgNiQfXpHSdBXMAIAAAAACf16EBIHRKD3SzjRW+LMOl+47QXA3CJhMzlcqyFRW22AVsACAAAAAAMGz4fAOa0EoVv90fUffwLjBrQhHATf+NdlgCR65vujAAAzM3AH0AAAAFZAAgAAAAAHiZJiXKNF8bbukQGsdYkEi95I+FSBHy1I5/hK2uEZruBXMAIAAAAADE+lZBa8HDUJPN+bF6xI9x4N7GF9pj3vBR7y0BcfFhBAVsACAAAAAAGIEN6sfqq30nyxW4dxDgXr/jz5HmvA9T1jx/pKCn4zgAAzM4AH0AAAAFZAAgAAAAAI1oa2OIw5TvhT14tYCGmhanUoYcCZtNbrVbeoMldHNZBXMAIAAAAAAx2nS0Ipblf2XOgBiUOuJFBupBhe7nb6QPLZlA4aMPCgVsACAAAAAA9xu828hugIgo0E3de9dZD+gTpVUGlwtDba+tw/WcbUoAAzM5AH0AAAAFZAAgAAAAABgTWS3Yap7Q59hii/uPPimHWXsr+DUmsqfwt/X73qsOBXMAIAAAAACKK05liW5KrmEAvtpCB1WUltruzUylDDpjea//UlWoOAVsACAAAAAAcgN4P/wakJ5aJK5c1bvJBqpVGND221dli2YicPFfuAYAAzQwAH0AAAAFZAAgAAAAABOAnBPXDp6i9TISQXvcNKwGDLepZTu3cKrB4vKnSCjBBXMAIAAAAADjjzZO7UowAAvpwyG8BNOVqLCccMFk3aDK4unUeft5ywVsACAAAAAA4zkCd4k9gvfXoD1C7vwTjNcdVJwEARh8h/cxZ4PNMfgAAzQxAH0AAAAFZAAgAAAAAHN8hyvT1lYrAsdiV5GBdd5jhtrAYE/KnSjw2Ka9hjz9BXMAIAAAAAD794JK7EeXBs+D7yOVK7nWF8SbZ/7U8gZ7nnT9JFNwTAVsACAAAAAAg8Wt1HO3NhByq2ggux2a4Lo6Gryr24rEFIqh2acrwWMAAzQyAH0AAAAFZAAgAAAAAO93bPrq8bsnp1AtNd9ETnXIz0lH/2HYN/vuw9wA3fyFBXMAIAAAAABHlls5fbaF2oAGqptC481XQ4eYxInTC29aElfmVZgDUgVsACAAAAAANoQXEWpXJpgrSNK/cKi/m7oYhuSRlp1IZBF0bqTEATcAAzQzAH0AAAAFZAAgAAAAAL1YsAZm1SA0ztU6ySIrQgCCA74V6rr0/4iIygCcaJL6BXMAIAAAAADTXWTHWovGmUR1Zg9l/Aqq9H5mOCJQQrb/Dfae7e3wKAVsACAAAAAA5dunyJK6/SVfDD0t9QlNBcFqoZnf9legRjHaLSKAoQMAAzQ0AH0AAAAFZAAgAAAAAEoFAeHk0RZ9kD+cJRD3j7PcE5gzWKnyBrF1I/MDNp5mBXMAIAAAAACgHtc2hMBRSZjKw8RAdDHK+Pi1HeyjiBuAslGVNcW5tAVsACAAAAAAXzBLfq+GxRtX4Wa9fazA49DBLG6AjZm2XODStJKH8D0AAzQ1AH0AAAAFZAAgAAAAAAW+7DmSN/LX+/0uBVJDHIc2dhxAGz4+ehyyz8fAnNGoBXMAIAAAAAA6Ilw42EvvfLJ3Eq8Afd+FjPoPcQutZO6ltmCLEr8kxQVsACAAAAAAbbZalyo07BbFjPFlYmbmv0z023eT9eLkHqeVUnfUAUAAAzQ2AH0AAAAFZAAgAAAAANBdV7M7kuYO3EMoQItAbXv4t2cIhfaT9V6+s4cg9djlBXMAIAAAAABvz4MIvZWxxrcJCL5qxLfFhXiUYB1OLHdKEjco94SgDgVsACAAAAAAK2GVGvyPIKolF/ECcmfmkVcf1/IZNcaTv96N92yGrkEAAzQ3AH0AAAAFZAAgAAAAAMoAoiAn1kc79j5oPZtlMWHMhhgwNhLUnvqkqIFvcH1NBXMAIAAAAADcJTW7WiCyW0Z9YDUYwppXhLj4Ac1povpJvcAq+i48MQVsACAAAAAAIGxGDzoeB3PTmudl4+j6piQB++e33EEzuzAiXcqGxvUAAzQ4AH0AAAAFZAAgAAAAACI3j5QP7dWHpcT6WO/OhsWwRJNASBYqIBDNzW8IorEyBXMAIAAAAABxUpBSjXwCKDdGP9hYU+RvyR+96kChfvyyRC4jZmztqAVsACAAAAAAvBCHguWswb4X0xdcAryCvZgQuthXzt7597bJ5VxAMdgAAzQ5AH0AAAAFZAAgAAAAAKsbycEuQSeNrF8Qnxqw3x3og8JmQabwGqnDbqzFRVrrBXMAIAAAAACno/3ef2JZJS93SVVzmOZSN+jjJHT8s0XYq2M46d2sLAVsACAAAAAAAt5zLJG+/j4K8rnkFtAn8IvdUVNefe6utJ3rdzgwudIAAzUwAH0AAAAFZAAgAAAAAPXIcoO8TiULqlxzb74NFg+I8kWX5uXIDUPnh2DobIoMBXMAIAAAAADR6/drkdTpnr9g1XNvKDwtBRBdKn7c2c4ZNUVK5CThdQVsACAAAAAAJqOA1c6KVog3F4Hb/GfDb3jCxXDRTqpXWSbMH4ePIJsAAzUxAH0AAAAFZAAgAAAAAEa03ZOJmfHT6/nVadvIw71jVxEuIloyvxXraYEW7u7pBXMAIAAAAADzRlBJK75FLiKjz3djqcgjCLo/e3yntI3MnPS48OORhgVsACAAAAAAnQhx4Rnyj081XrLRLD5NLpWmRWCsd0M9Hl7Jl19R0h8AAzUyAH0AAAAFZAAgAAAAAKx8NLSZUU04pSSGmHa5fh2oLHsEN5mmNMNHL95/tuC9BXMAIAAAAAA59hcXVaN3MNdHoo11OcH1aPRzHCwpVjO9mGfMz4xh3QVsACAAAAAAYIPdjV2XbPj7dBeHPwnwhVU7zMuJ+xtMUW5mIOYtmdAAAzUzAH0AAAAFZAAgAAAAAHNKAUxUqBFNS9Ea9NgCZoXMWgwhP4x0/OvoaPRWMquXBXMAIAAAAABUZ551mnP4ZjX+PXU9ttomzuOpo427MVynpkyq+nsYCQVsACAAAAAALnVK5p2tTTeZEh1zYt4iqKIQT9Z0si//Hy1L85oF+5IAAzU0AH0AAAAFZAAgAAAAALfGXDlyDVcGaqtyHkLT0qpuRhJQLgCxtznazhFtuyn/BXMAIAAAAABipxlXDq14C62pXhwAeen5+syA+/C6bN4rtZYcO4zKwAVsACAAAAAAXUf0pzUq0NhLYagWDap4uEiwq5rLpcx29rWbt1NYMsMAAzU1AH0AAAAFZAAgAAAAANoEr8sheJjg4UCfBkuUzarU9NFoy1xwbXjs5ifVDeA9BXMAIAAAAABPoyTf6M+xeZVGES4aNzVlq7LgjqZXJ/QunjYVusGUEAVsACAAAAAA1hA2gMeZZPUNytk9K+lB1RCqWRudRr7GtadJlExJf8oAAzU2AH0AAAAFZAAgAAAAAKvDiK+xjlBe1uQ3SZTNQl2lClIIvpP/5CHwY6Kb3WlgBXMAIAAAAAANnxImq5MFbWaRBHdJp+yD09bVlcFtiFDYsy1eDZj+iQVsACAAAAAAWtsyO+FxMPSIezwsV1TJD8ZrXAdRnQM6DJ+f+1V3qEkAAzU3AH0AAAAFZAAgAAAAAF49IlFH9RmSUSvUQpEPUedEksrQUcjsOv44nMkwXhjzBXMAIAAAAADJtWGbk0bZzmk20obz+mNsp86UCu/nLLlbg7ppxYn7PgVsACAAAAAA3k0Tj/XgPQtcYijH8cIlQoe/VXf15q1nrZNmg7yWYEgAAzU4AH0AAAAFZAAgAAAAAOuSJyuvz50lp3BzXlFKnq62QkN2quNU1Gq1IDsnFoJCBXMAIAAAAAAqavH1d93XV3IzshWlMnzznucadBF0ND092/2ApI1AcAVsACAAAAAAzUrK4kpoKCmcpdZlZNI13fddjdoAseVe67jaX1LobIIAAzU5AH0AAAAFZAAgAAAAALtgC4Whb4ZdkCiI30zY6fwlsxSa7lEaOAU3SfUXr02XBXMAIAAAAACgdZ6U1ZVgUaZZwbIaCdlANpCw6TZV0bwg3DS1NC/mnAVsACAAAAAAzI49hdpp0PbO7S2KexISxC16sE73EUAEyuqUFAC/J48AAzYwAH0AAAAFZAAgAAAAAF6PfplcGp6vek1ThwenMHVkbZgrc/dHgdsgx1VdPqZ5BXMAIAAAAACha3qhWkqmuwJSEXPozDO8y1ZdRLyzt9Crt2vjGnT7AAVsACAAAAAA7nvcU59+LwxGupSF21jAeAE0x7JE94tjRkJfgM1yKU8AAzYxAH0AAAAFZAAgAAAAAKoLEhLvLjKc7lhOJfx+VrGJCx9tXlOSa9bxQzGR6rfbBXMAIAAAAAAIDK5wNnjRMBzET7x/KAMExL/zi1IumJM92XTgXfoPoAVsACAAAAAAFkUYWFwNr815dEdFqp+TiIozDcq5IBNVkyMoDjharDQAAzYyAH0AAAAFZAAgAAAAADoQv6lutRmh5scQFvIW6K5JBquLxszuygM1tzBiGknIBXMAIAAAAADAD+JjW7FoBQ76/rsECmmcL76bmyfXpUU/awqIsZdO+wVsACAAAAAAPFHdLw3jssmEXsgtvl/RBNaUCRA1kgSwsofG364VOvQAAzYzAH0AAAAFZAAgAAAAAJNHUGAgn56KekghO19d11nai3lAh0JAlWfeP+6w4lJBBXMAIAAAAAD9XGJlvz59msJvA6St9fKW9CG4JoHV61rlWWnkdBRLzwVsACAAAAAAxwP/X/InJJHmrjznvahIMgj6pQR30B62UtHCthSjrP0AAzY0AH0AAAAFZAAgAAAAAHgYoMGjEE6fAlAhICv0+doHcVX8CmMVxyq7+jlyGrvmBXMAIAAAAAC/5MQZgTHuIr/O5Z3mXPvqrom5JTQ8IeSpQGhO9sB+8gVsACAAAAAAuPSXVmJUAUpTQg/A9Bu1hYczZF58KEhVofakygbsvJQAAzY1AH0AAAAFZAAgAAAAANpIljbxHOM7pydY877gpRQvYY2TGK7igqgGsavqGPBABXMAIAAAAAAqHyEu9gpurPOulApPnr0x9wrygY/7mXe9rAC+tPK80wVsACAAAAAA7gkPzNsS3gCxdFBWbSW9tkBjoR5ib+saDvpGSB3A3ogAAzY2AH0AAAAFZAAgAAAAAGR+gEaZTeGNgG9BuM1bX2R9ed4FCxBA9F9QvdQDAjZwBXMAIAAAAABSkrYFQ6pf8MZ1flgmeIRkxaSh/Eep4Btdx4QYnGGnwAVsACAAAAAApRovMiV00hm/pEcT4XBsyPNw0eo8RLAX/fuabjdU+uwAAzY3AH0AAAAFZAAgAAAAAFNprhQ3ZwIcYbuzLolAT5n/vc14P9kUUQComDu6eFyKBXMAIAAAAAAcx9z9pk32YbPV/sfPZl9ALIEVsqoLXgqWLVK/tP+heAVsACAAAAAA/qxvuvJbAHwwhfrPVpmCFzNvg2cU/NXaWgqgYUZpgXwAAzY4AH0AAAAFZAAgAAAAADgyPqQdqQrgfmJjRFAILTHzXbdw5kpKyfeoEcy6YYG/BXMAIAAAAAAE+3XsBQ8VAxAkN81au+f3FDeCD/s7KoZD+fnM1MJSSAVsACAAAAAAhRnjrXecwV0yeCWKJ5J/x12Xx4qVJahsCEVHB/1U2rcAAzY5AH0AAAAFZAAgAAAAAI0CT7JNngTCTUSei1Arw7eHWCD0jumv2rb7imjWIlWABXMAIAAAAABSP8t6ya0SyCphXMwnru6ZUDXWElN0NfBvEOhDvW9bJQVsACAAAAAAGWeGmBNDRaMtvm7Rv+8TJ2sJ4WNXKcp3tqpv5Se9Ut4AAzcwAH0AAAAFZAAgAAAAAD/FIrGYFDjyYmVb7oTMVwweWP7A6F9LnyIuNO4MjBnXBXMAIAAAAACIZgJCQRZu7NhuNMyOqCn1tf+DfU1qm10TPCfj5JYV3wVsACAAAAAA5hmY4ptuNxULGf87SUFXQWGAONsL9U29duh8xqsHtxoAAzcxAH0AAAAFZAAgAAAAAHIkVuNDkSS1cHIThKc/O0r2/ubaABTOi8Q1r/dvBAsEBXMAIAAAAADdHYqchEiJLM340c3Q4vJABmmth3+MKzwLYlsG6GS7sQVsACAAAAAADa+KP/pdTiG22l+ZWd30P1iHjnBF4zSNRdFm0oEK82kAAzcyAH0AAAAFZAAgAAAAAJmoDILNhC6kn3masElfnjIjP1VjsjRavGk1gSUIjh1NBXMAIAAAAAD97Ilvp3XF8T6MmVVcxMPcdL80RgQ09UoC6PnoOvZ1IQVsACAAAAAA2RK3Xng6v8kpvfVW9tkVXjpE+BSnx9/+Fw85Evs+kUEAAzczAH0AAAAFZAAgAAAAAI5bm3YO0Xgf0VT+qjVTTfvckecM3Cwqj7DTKZXf8/NXBXMAIAAAAAD/m+h8fBhWaHm6Ykuz0WX1xL4Eme3ErLObyEVJf8NCywVsACAAAAAAfb1VZZCqs2ivYbRzX4p5CtaCkKW+g20Pr57FWXzEZi8AAzc0AH0AAAAFZAAgAAAAANqo4+p6qdtCzcB4BX1wQ6llU7eFBnuu4MtZwp4B6mDlBXMAIAAAAAAGiz+VaukMZ+6IH4jtn4KWWdKK4/W+O+gRioQDrfzpMgVsACAAAAAAG4YYkTp80EKo59mlHExDodRQFR7njhR5dmISwUJ6ukAAAzc1AH0AAAAFZAAgAAAAAPrFXmHP2Y4YAm7b/aqsdn/DPoDkv7B8egWkfe23XsM1BXMAIAAAAAAGhwpKAr7skeqHm3oseSbO7qKNhmYsuUrECBxJ5k+D2AVsACAAAAAAAqPQi9luYAu3GrFCEsVjd9z2zIDcp6SPTR2w6KQEr+IAAzc2AH0AAAAFZAAgAAAAABzjYxwAjXxXc0Uxv18rH8I3my0Aguow0kTwKyxbrm+cBXMAIAAAAADVbqJVr6IdokuhXkEtXF0C2gINLiAjMVN20lE20Vmp2QVsACAAAAAAD7K1Fx4gFaaizkIUrf+EGXQeG7QX1jadhGc6Ji471H8AAzc3AH0AAAAFZAAgAAAAAFMm2feF2fFCm/UC6AfIyepX/xJDSmnnolQIBnHcPmb5BXMAIAAAAABLI11kFrQoaNVZFmq/38aRNImPOjdJh0Lo6irI8M/AaAVsACAAAAAAOWul0oVqJ9CejD2RqphhTC98DJeRQy5EwbNerU2+4l8AAzc4AH0AAAAFZAAgAAAAAJvXB3KyNiNtQko4SSzo/9b2qmM2zU9CQTTDfLSBWMgRBXMAIAAAAAAvjuVP7KsLRDeqVqRziTKpBrjVyqKiIbO9Gw8Wl2wFTAVsACAAAAAADlE+oc1ins+paNcaOZJhBlKlObDJ4VQORWjFYocM4LgAAzc5AH0AAAAFZAAgAAAAAPGdcxDiid8z8XYnfdDivNMYVPgBKdGOUw6UStU+48CdBXMAIAAAAAARj6g1Ap0eEfuCZ4X2TsEw+Djrhto3fA5nLwPaY0vCTgVsACAAAAAAoHqiwGOUkBu8SX5U1yHho+UIFdSN2MdQN5s6bQ0EsJYAAzgwAH0AAAAFZAAgAAAAAP5rGPrYGt3aKob5f/ldP0qrW7bmWvqnKY4QwdDWz400BXMAIAAAAADTQkW2ymaaf/bhteOOGmSrIR97bAnJx+yN3yMj1bTeewVsACAAAAAADyQnHGH2gF4w4L8axUsSTf6Ubk7L5/eoFOJk12MtZAoAAzgxAH0AAAAFZAAgAAAAAAlz6wJze5UkIxKpJOZFGCOf3v2KByWyI6NB6JM9wNcBBXMAIAAAAABUC7P/neUIHHoZtq0jFVBHY75tSFYr1Y5S16YN5XxC1QVsACAAAAAAgvxRbXDisNnLY3pfsjDdnFLtkvYUC4lhA68eBXc7KAwAAzgyAH0AAAAFZAAgAAAAAFJ8AtHcjia/9Y5pLEc3qVgH5xKiXw12G9Kn2A1EY8McBXMAIAAAAAAxe7Bdw7eUSBk/oAawa7uicTEDgXLymRNhBy1LAxhDvwVsACAAAAAAxKPaIBKVx3jTA+R/el7P7AZ7efrmTGjJs3Hj/YdMddwAAzgzAH0AAAAFZAAgAAAAAO8uwQUaKFb6vqR3Sv3Wn4QAonC2exOC9lGG1juqP5DtBXMAIAAAAABZf1KyJgQg8/Rf5c02DgDK2aQu0rNCOvaL60ohDHyY+gVsACAAAAAAqyEjfKC8lYoIfoXYHUqHZPoaA6EK5BAZy5dxXZmay4kAAzg0AH0AAAAFZAAgAAAAAE8YtqyRsGCeiR6hhiyisR/hccmK4nZqIMzO4lUBmEFzBXMAIAAAAAC1UYOSKqAeG1UJiKjWFVskRhuFKpj9Ezy+lICZvFlN5AVsACAAAAAA6Ct9nNMKyRazn1OKnRKagm746CGu+jyhbL1qJnZxGi0AAzg1AH0AAAAFZAAgAAAAAPhCrMausDx1QUIEqp9rUdRKyM6a9AAx7jQ3ILIu8wNIBXMAIAAAAACmH8lotGCiF2q9VQxhsS+7LAZv79VUAsOUALaGxE/EpAVsACAAAAAAnc1xCKfdvbUEc8F7XZqlNn1C+hZTtC0I9I3LL06iaNkAAzg2AH0AAAAFZAAgAAAAAOBi/GAYFcstMSJPgp3VkMiuuUUCrZytvqYaU8dwm8v2BXMAIAAAAACEZSZVyD3pKzGlbdwlYmWQhHHTV5SnNLknl2Gw8IaUTQVsACAAAAAAfsLZsEDcWSuNsIo/TD1ReyQW75HPMgmuKZuWFOLKRLoAAzg3AH0AAAAFZAAgAAAAAIQuup+YGfH3mflzWopN8J1X8o8a0d9CSGIvrA5HOzraBXMAIAAAAADYvNLURXsC2ITMqK14LABQBI+hZZ5wNf24JMcKLW+84AVsACAAAAAACzfjbTBH7IwDU91OqLAz94RFkoqBOkzKAqQb55gT4/MAAzg4AH0AAAAFZAAgAAAAAKsh0ADyOnVocFrOrf6MpTrNvAj8iaiE923DPryu124gBXMAIAAAAADg24a8NVE1GyScc6tmnTbmu5ulzO+896fE92lN08MeswVsACAAAAAAaPxcOIxnU7But88/yadOuDJDMcCywwrRitaxMODT4msAAzg5AH0AAAAFZAAgAAAAAKkVC2Y6HtRmv72tDnPUSjJBvse7SxLqnr09/Uuj9sVVBXMAIAAAAABYNFUkH7ylPMN+Bc3HWX1e0flGYNbtJNCY9SltJCW/UAVsACAAAAAAZYK/f9H4OeihmpiFMH7Wm7uLvs2s92zNA8wyrNZTsuMAAzkwAH0AAAAFZAAgAAAAADDggcwcb/Yn1Kk39sOHsv7BO/MfP3m/AJzjGH506Wf9BXMAIAAAAAAYZIsdjICS0+BDyRUPnrSAZfPrwtuMaEDEn0/ijLNQmAVsACAAAAAAGPnYVvo2ulO9z4LGd/69NAklfIcZqZvFX2KK0s+FcTUAAzkxAH0AAAAFZAAgAAAAAEWY7dEUOJBgjOoWVht1wLehsWAzB3rSOBtLgTuM2HC8BXMAIAAAAAAAoswiHRROurjwUW8u8D5EUT+67yvrgpB/j6PzBDAfVwVsACAAAAAA6NhRTYFL/Sz4tao7vpPjLNgAJ0FX6P/IyMW65qT6YsMAAzkyAH0AAAAFZAAgAAAAAPZaapeAUUFPA7JTCMOWHJa9lnPFh0/gXfAPjA1ezm4ZBXMAIAAAAACmJvLY2nivw7/b3DOKH/X7bBXjJwoowqb1GtEFO3OYgAVsACAAAAAA/JcUoyKacCB1NfmH8vYqC1f7rd13KShrQqV2r9QBP44AAzkzAH0AAAAFZAAgAAAAAK00u6jadxCZAiA+fTsPVDsnW5p5LCr4+kZZZOTDuZlfBXMAIAAAAAAote4zTEYMDgaaQbAdN8Dzv93ljPLdGjJzvnRn3KXgtQVsACAAAAAAxXd9Mh6R3mnJy8m7UfqMKi6oD5DlZpkaOz6bEjMOdiwAAzk0AH0AAAAFZAAgAAAAAFbgabdyymiEVYYwtJSWa7lfl/oYuj/SukzJeDOR6wPVBXMAIAAAAADAFGFjS1vPbN6mQEhkDYTD6V2V23Ys9gUEUMGNvMPkaAVsACAAAAAAL/D5Sze/ZoEanZLK0IeEkhgVkxEjMWVCfmJaD3a8uNIAAzk1AH0AAAAFZAAgAAAAABNMR6UBv2E627CqLtQ/eDYx7OEwQ7JrR4mSHFa1N8tLBXMAIAAAAAAxH4gucI4UmNVB7625C6hFSVCuIpJO3lusJlPuL8H5EQVsACAAAAAAVLHNg0OUVqZ7WGOP53BkTap9FOw9dr1P4J8HxqFqU04AAzk2AH0AAAAFZAAgAAAAAG8cd6WBneNunlqrQ2EmNf35W7OGObGq9WL4ePX+LUDmBXMAIAAAAAAjJ2+sX87NSis9hBsgb1QprVRnO7Bf+GObCGoUqyPE4wVsACAAAAAAs9c9SM49/pWmyUQKslpt3RTMBNSRppfNO0JBvUqHPg0AAzk3AH0AAAAFZAAgAAAAAFWOUGkUpy8yf6gB3dio/aOfRKh7XuhvsUj48iESFJrGBXMAIAAAAAAY7sCDMcrUXvNuL6dO0m11WyijzXZvPIcOKob6IpC4PQVsACAAAAAAJOP+EHz6awDb1qK2bZQ3kTV7wsj5Daj/IGAWh4g7omAAAzk4AH0AAAAFZAAgAAAAAGUrIdKxOihwNmo6B+aG+Ag1qa0+iqdksHOjQj+Oy9bZBXMAIAAAAABwa5dbI2KmzBDNBTQBEkjZv4sPaeRkRNejcjdVymRFKQVsACAAAAAA4ml/nm0gJNTcJ4vuD+T2Qfq2fQZlibJp/j6MOGDrbHMAAzk5AH0AAAAFZAAgAAAAAOx89xV/hRk64/CkM9N2EMK6aldII0c8smdcsZ46NbP8BXMAIAAAAADBF6tfQ+7q9kTuLyuyrSnDgmrdmrXkdhl980i1KHuGHgVsACAAAAAACUqiFqHZdGbwAA+hN0YUE5zFg+H+dabIB4dj5/75W/YAAzEwMAB9AAAABWQAIAAAAADJDdC9aEFl4Y8J/awHbnXGHjfP+VXQilPHJg7ewaJI7AVzACAAAAAAE+tqRl6EcBMXvbr4GDiNIYObTsYpa1n6BJk9EjIJVicFbAAgAAAAAJVc+HYYqa0m1Hq6OiRX8c0iRnJYOt6AJAJoG0sG3GMSAAMxMDEAfQAAAAVkACAAAAAA3F9rjEKhpoHuTULVGgfUsGGwJs3bISrXkFP1v6KoQLgFcwAgAAAAAIBf0tXw96Z/Ds0XSIHX/zk3MzUR/7WZR/J6FpxRWChtBWwAIAAAAABWrjGlvKYuTS2s8L9rYy8Hf0juFGJfwQmxVIjkTmFIGQADMTAyAH0AAAAFZAAgAAAAAOYIYoWkX7dGuyKfi3XssUlc7u/gWzqrR9KMkikKVdmSBXMAIAAAAABVF2OYjRTGi9Tw8XCAwZWLpX35Yl271TlNWp6N/nROhAVsACAAAAAA0nWwYzXQ1+EkDvnGq+SMlq20z+j32Su+i/A95SggPb4AAzEwMwB9AAAABWQAIAAAAACMtPm12YtdEAvqu6Eji1yuRXnu1RJP6h0l7pH3lSH4MwVzACAAAAAAENyCFfyUAh1veQBGx+cxiB7Sasrj41jzCGflZkB5cRMFbAAgAAAAAKdI2LMqISr/T5vuJPg6ZRBm5fVi2aQCc4ra3A4+AjbDAAMxMDQAfQAAAAVkACAAAAAAvlI4lDcs6GB1cnm/Tzo014CXWqidCdyE5t2lknWQd4QFcwAgAAAAAD60SpNc4O2KT7J0llKdSpcX1/Xxs97N715a1HsTFkmBBWwAIAAAAABuuRkJWAH1CynggBt1/5sPh9PoGiqTlS24D/OE2uHXLQADMTA1AH0AAAAFZAAgAAAAAKl8zcHJRDjSjJeV/WvMxulW1zrTFtaeBy/aKKhadc6UBXMAIAAAAADBdWQl5SBIvtZZLIHszePwkO14W1mQ0izUk2Ov21cPNAVsACAAAAAAHErCYycpqiIcCZHdmPL1hi+ovLQk4TAvENpfLdTRamQAAzEwNgB9AAAABWQAIAAAAABb6LXDWqCp1beQgQjj8I3sRTtFhlrmiBi+h/+ikmrvugVzACAAAAAA9stpgTecT7uTyaGNs3K9Bp0A7R0QaIAOfscyMXHBPX8FbAAgAAAAAHUt+McyXrJ1H8SwnHNVO181Ki8vDAM1f7XI26mg95ZDAAMxMDcAfQAAAAVkACAAAAAA97NTT+81PhDhgptNtp4epzA0tP4iNb9j1AWkiiiKGM8FcwAgAAAAAKPbHg7ise16vxmdPCzksA/2Mn/qST0L9Xe8vnQugVkcBWwAIAAAAABB0EMXfvju4JU/mUH/OvxWbPEl9NJkcEp4iCbkXI41fAADMTA4AH0AAAAFZAAgAAAAAMqpayM2XotEFmm0gwQd9rIzApy0X+7HfOhNk6VU7F5lBXMAIAAAAACJR9+q5T9qFHXFNgGbZnPubG8rkO6cwWhzITQTmd6VgwVsACAAAAAAOZLQ6o7e4mVfDzbpQioa4d3RoTvqwgnbmc5Qh2wsZuoAAzEwOQB9AAAABWQAIAAAAADQnslvt6Hm2kJPmqsTVYQHE/wWeZ4bE1XSkt7TKy0r1gVzACAAAAAA8URTA4ZMrhHPvlp53TH6FDCzS+0+61qHm5XK6UiOrKEFbAAgAAAAAHQbgTCdZcbdA0avaTmZXUKnIS7Nwf1tNrcXDCw+PdBRAAMxMTAAfQAAAAVkACAAAAAAhujlgFPFczsdCGXtQ/002Ck8YWQHHzvWvUHrkbjv4rwFcwAgAAAAALbV0lLGcSGfE7mDM3n/fgEvi+ifjl7WZ5b3aqjDNvx9BWwAIAAAAACbceTZy8E3QA1pHmPN5kTlOx3EO8kJM5PUjTVftw1VpgADMTExAH0AAAAFZAAgAAAAABm/6pF96j26Jm7z5KkY1y33zcAEXLx2n0DwC03bs/ixBXMAIAAAAAD01OMvTZI/mqMgxIhA5nLs068mW+GKl3OW3ilf2D8+LgVsACAAAAAAaLvJDrqBESTNZSdcXsd+8GXPl8ZkUsGpeYuyYVv/kygAAzExMgB9AAAABWQAIAAAAACfw9/te4GkHZAapC9sDMHHHZgmlTrccyJDPFciOMSOcwVzACAAAAAAIIC1ZpHObvmMwUfqDRPl4C1aeuHwujM1G/yJbvybMNAFbAAgAAAAAAs9x1SnVpMfNv5Bm1aXGwHmbbI9keWa9HRD35XuCBK5AAMxMTMAfQAAAAVkACAAAAAAkxHJRbnShpPOylLoDdNShfILeA1hChKFQY9qQyZ5VmsFcwAgAAAAAKidrY+rC3hTY+YWu2a7fuMH2RD/XaiTIBW1hrxNCQOJBWwAIAAAAACW0kkqMIzIFMn7g+R0MI8l15fr3k/w/mHtY5n6SYTEwAADMTE0AH0AAAAFZAAgAAAAAByuYl8dBvfaZ0LO/81JW4hYypeNmvLMaxsIdvqMPrWoBXMAIAAAAABNddwobOUJzm9HOUD8BMZJqkNCUCqstHZkC76FIdNg9AVsACAAAAAAQQOkIQtkyNavqCnhQbNg3HfqrJdsAGaoxSJePJl1qXsAAzExNQB9AAAABWQAIAAAAABxMy7X5hf7AXGDz3Y/POu1ZpkMlNcSvSP92NOO/Gs7wAVzACAAAAAAHJshWo2T5wU2zvqCyJzcJQKQaHFHpCpMc9oWBXkpUPoFbAAgAAAAAGeiJKzlUXAvL0gOlW+Hz1mSa2HsV4RGmyLmCHlzbAkoAAMxMTYAfQAAAAVkACAAAAAAlqbslixl7Zw3bRlibZbe/WmKw23k8uKeIzPKYEtbIy0FcwAgAAAAAHEKwpUxkxOfef5HYvulXPmdbzTivwdwrSYIHDeNRcpcBWwAIAAAAADuPckac21Hrg/h0kt5ShJwVEZ9rx6SOHd2+HDjqxEWTQADMTE3AH0AAAAFZAAgAAAAAMXrXx0saZ+5gORmwM2FLuZG6iuO2YS+1IGPoAtDKoKBBXMAIAAAAADIQsxCr8CfFKaBcx8kIeSywnGh7JHjKRJ9vJd9x79y7wVsACAAAAAAcvBV+SykDYhmRFyVYwFYB9oBKBSHr55Jdz2cXeowsUQAAzExOAB9AAAABWQAIAAAAAAm83FA9yDUpwkbKTihe7m53u+DivS9BU2b4vQMtCVQ2AVzACAAAAAAz3m1UB/AbZPa4QSKFDnUgHaT78+6iGOFAtouiBorEgEFbAAgAAAAAIgbpyYtJj5513Z5XYqviH/HXG/5+mqR52iBbfqMmDtZAAMxMTkAfQAAAAVkACAAAAAAJRzYK0PUwr9RPG2/7yID0WgcTJPB2Xjccp5LAPDYunkFcwAgAAAAAIIh24h3DrltAzNFhF+MEmPrZtzr1PhCofhChZqfCW+jBWwAIAAAAAAzRNXtL5o9VXMk5D5ylI0odPDJDSZZry1wfN+TedH70gADMTIwAH0AAAAFZAAgAAAAAHSaHWs/dnmI9sc7nB50VB2Bzs0kHapMHCQdyVEYY30TBXMAIAAAAACkV22lhEjWv/9/DubfHBAcwJggKI5mIbSK5L2nyqloqQVsACAAAAAAS19m7DccQxgryOsBJ3GsCs37yfQqNi1G+S6fCXpEhn4AAzEyMQB9AAAABWQAIAAAAAAC/I4TQRtCl12YZmdGz17X4GqSQgfwCPgRBwdHmdwu+QVzACAAAAAAx8f3z2ut/RAZhleari4vCEE+tNIn4ikjoUwzitfQ588FbAAgAAAAAJci0w1ZB8W2spJQ+kMpod6HSCtSR2jrabOH+B0fj3A4AAMxMjIAfQAAAAVkACAAAAAADGB5yU2XT0fse/MPWgvBvZikVxrl5pf3S5K1hceKWooFcwAgAAAAAIxTmlLHMjNaVDEfJbXvRez0SEPWFREBJCT6qTHsrljoBWwAIAAAAAAlswzAl81+0DteibwHD+CG5mZJrfHXa9NnEFRtXybzzwADMTIzAH0AAAAFZAAgAAAAABmO7QD9vxWMmFjIHz13lyOeV6vHT6mYCsWxF7hb/yOjBXMAIAAAAACT9lmgkiqzuWG24afuzYiCeK9gmJqacmxAruIukd0xEAVsACAAAAAAZa0/FI/GkZR7CtX18Xg9Tn9zfxkD0UoaSt+pIO5t1t4AAzEyNAB9AAAABWQAIAAAAAAfPUoy7QyZKhIIURso+mkP9qr1izbjETqF5s22GwjCjAVzACAAAAAAvLMsIDQ/go4VUxeh50UHmsvMvfx51cwyONnRD2odvC0FbAAgAAAAAKMb+1CodEalAFnDrEL1Ndt8ztamZ+9134m9Kp3GQgd+AAMxMjUAfQAAAAVkACAAAAAAE3ZqUar0Bq2zWbARE0bAv98jBlK9UJ73/xcwdMWWlSkFcwAgAAAAAK4M+MmC+9sFiFsumMyJZQKxWmmJiuG9H7IzKw083xxkBWwAIAAAAAAqkAONzhvMhkyL1D/6h7QQxEkdhC3p2WjXH+VGq5qCqQADMTI2AH0AAAAFZAAgAAAAAMo8FJiOq63cAmyk2O7eI7GcbQh/1j4RrMTqly3rexftBXMAIAAAAADjVmpd0WiRGTw/gAqEgGolt2EI7Csv14vKdmYoMD0aAgVsACAAAAAA07XQBzBUQMNw7F2/YxJjZNuPVpHTTgbLd1oGk77+bygAAzEyNwB9AAAABWQAIAAAAACu5IGaIx7A3Jvly/kzlCsSA4s3iJwuIl8jEdRH0k93NwVzACAAAAAA9NRUyxYE+t0Xyosyt6vIfMFW/vBoYg6sR+jBNs4JAxIFbAAgAAAAAAzyZ91dx+0oMlOVAjRGiMrPySikY/U9eMEB4WJb3uWtAAMxMjgAfQAAAAVkACAAAAAALkRy0GJInXYLA+cgjs6Myb0a+Gu9hgXhHvhLNoGWfckFcwAgAAAAANbALyt9zCSvwnLaWCd2/y2eoB7qkWTvv1Ldu8r40JPuBWwAIAAAAAD4Fl5bV5sz4isIE9bX+lmAp+aAKaZgVYVZeVfrItkCZAADMTI5AH0AAAAFZAAgAAAAAGoUK/DSWhT8LZhszSUqDbTrp8cSA7rdqmADKL+MILtTBXMAIAAAAABHnEE9bVa6lvhfhEMkkV2kzSSxH/sMW/FIJuw3CzWs6wVsACAAAAAAanavcBdqZxgRGKvEK95wTmeL1K1CeDSXZsXUAs81uOgAAzEzMAB9AAAABWQAIAAAAAC922ZDQE3h2fQKibGMZ9hV0WNlmrPYYSdtaSyYxsWYqgVzACAAAAAAagMovciKK6WVjIc2cCj8nK5O/gVOFFVeVAJpRp89tmQFbAAgAAAAAKcTFfPQzaFiAtSFhqbN02sCE1BKWJSrRfGN5L6oZwzkAAMxMzEAfQAAAAVkACAAAAAAtK+JqX3K/z2txjAU15DgX4y90DS2YLfIJFolCOkJJJwFcwAgAAAAAMnR5V7gfX7MNqqUdL5AkWlkhyFXaBRVNej+Rcn8lrQkBWwAIAAAAAA2cDNRXZuiC241TGRvdFyctJnrNcdbZOP9zHio81tkngADMTMyAH0AAAAFZAAgAAAAAAeGrIMK/bac6kPczxbvRYqKMkcpeI2FjdMpD91FDWIvBXMAIAAAAAAix62z1LeS8yvSXCl5gHSIomjyx76fF3S1lp9k900hygVsACAAAAAAiYwzf2m71aWFD5ajcXyW2JX2EzQOkBroTGMg29nLPYIAAzEzMwB9AAAABWQAIAAAAACphf298InM0Us4HT8o1W1MGw0D/02vd7Jh+U0h7qaFaQVzACAAAAAAFXtk7YpqsOJxsqGWSIL+YcBE96G3Zz9D31gPqDW94y8FbAAgAAAAAAOrS1KVA94rjB1jZ1pPocpCeBG+B14RzWoHqVDpp7JbAAMxMzQAfQAAAAVkACAAAAAATLDS2cuDVM3yDMuWNgk2iGKBTzPpfJMbvxVOSY39ZfcFcwAgAAAAAPT5wRi2cLHIUflXzm6EQB/m7xdThP80ir1VV/JBBqvxBWwAIAAAAAB9lEtZS0aXCFbCtSbhnis27S5IPcfWGygHW8AHn3QqzwADMTM1AH0AAAAFZAAgAAAAAJNjExiZVX7jfFGfYpQu16qxLN0YPqVU/5CQ/Y67YSinBXMAIAAAAABMpm2+6KrkRUlXzQoMPHrQmIO6dkQz66tYdfTeA3dKqQVsACAAAAAAFXobHiMLvNZuEPr8jtewCX2J93EZG3JNeyVg92fue6YAAzEzNgB9AAAABWQAIAAAAABlFkYtLCx901X6QVVMkSn6Z7k30UF4xHaA0OZJJ9bdyQVzACAAAAAATez+F9GHcGzTp7jjv4feboUNb8JCkIp4EqcPFisnq7MFbAAgAAAAACE7JvOpBgMoZ7kRd4QbxIhxukPTUxXpzhjnBHiR7XoRAAMxMzcAfQAAAAVkACAAAAAA8NJKN0IxZnruhswGQkiruv8Ih0EMwDcSZx/Xasup9dkFcwAgAAAAAKaJZRxzA+Igeydvuk6cSwUHXcrmT4PjhuPu//FslpdnBWwAIAAAAAD53Rok1Vq/PMAnXmarqoHJ0PEyYUBmVESa9hIpCv/G9QADMTM4AH0AAAAFZAAgAAAAABHxHdEClz7hbSSgE58+dWLlSMJnoPz+jFxp4bB1GmLQBXMAIAAAAAD3nSvT6aGD+A110J/NwEfp0nPutlmuB5B+wA3CC3noGAVsACAAAAAA3Apjd+TapONB7k5wBVwTWgn8t+Sq2oyyU5/+as109RcAAzEzOQB9AAAABWQAIAAAAAC/o8qW/ifk3KuJ01VFkyNLgQafxB5/bGs2G5VyyVafOwVzACAAAAAA1bMqAFGDHSl6BYNLbxApvkAv2K1/oafywiX0MDz1dGUFbAAgAAAAAHJXLlId3edFoniLD/9K2A5973MeP2Ro31flDyqm3l5QAAMxNDAAfQAAAAVkACAAAAAAY2V8I1bz3a1AxTtmED6UhdhA09huFkuuEX8R+d/WDPUFcwAgAAAAAPTVoNRiI76tcRKqd+JBBVyy4+YcKST42p0QX2BtmQ2VBWwAIAAAAACcxt9hg14WqPNiDv1MkqVljM2e2KJEv53lA17LhV6ZigADMTQxAH0AAAAFZAAgAAAAAO2kSsW0WGN9AOtK4xK2SHrGhWiaAbMEKT4iZkRpaDN/BXMAIAAAAABKGzQcPM8LT2dwOggxoWjv/1imYWabbG/G4kBw8OWaxAVsACAAAAAAC9hLK1dScQTAqg+YAG3ObdPzg2Xet57HmOFpGmyUR9UAAzE0MgB9AAAABWQAIAAAAAAiCwzNEEaH/mDam68IdDftnhthyUFdb+ZCNSBQ91WlHQVzACAAAAAA7tHyHcxCzmbJeFYZyPm4mEgkTGKOvwY4MX82OvH0Jn8FbAAgAAAAAAb5IAbZ1hXCNegQ+S+C9i/Z8y6sS8KeU04V6hXa2ml6AAMxNDMAfQAAAAVkACAAAAAAGuCHVNJSuoVkpPOnS5s89GuA+BLi2IPBUr2Bg1sWEPIFcwAgAAAAAEl1gncS5/xO7bQ/KQSstRV3rOT2SW6nV92ZANeG2SR6BWwAIAAAAAA9LOcKmhek8F2wAh8yvT/vjp2gaouuO+Hmv10lwAeWPAADMTQ0AH0AAAAFZAAgAAAAAMfxz7gEaoCdPvXrubDhCZUS0ARLZc1svgbXgMDlVBPgBXMAIAAAAAB6a5dDA3fuT5Vz2KvAcbUEFX/+B7Nw2p1QqbPoQ5TTuAVsACAAAAAAcf/y75UOuI62A6vWH7bYr/5Jz+nirZVYK/81trN6XOQAAzE0NQB9AAAABWQAIAAAAACnYsqF/VzmjIImC9+dqrHO1TM6lJ6fRwM0mM6Wf6paOwVzACAAAAAA5tgZzch8uDCR1ky3SllVaKVpxAlbrhvlNDTazZZRZOAFbAAgAAAAALeGiLJS4z2zhgVpxzyPdRYyACP9QzQBOob34YrIZumCAAMxNDYAfQAAAAVkACAAAAAAEC0sIVmadtW4YMuRXH7RpAhXclsd+3bmqGXCMeaT014FcwAgAAAAABPpXh0uzpsJJB+IRUNajmMB9WGwswfpw5T9xk3Xj6ANBWwAIAAAAAAmf+NYh9TZ/QRu3w/GQz66n7DtfbJijN3G7KzeL8lstAADMTQ3AH0AAAAFZAAgAAAAABaIB3n49Xm9cOafSrQsE0WCcYp8rMIO/qVwIlMF5YLRBXMAIAAAAAC9EyWJV3xOu9bzgdJ/yX+ko7qLf1u3AxNMataW2C9EzQVsACAAAAAAvVbDkLxXx2DcMLifIQ3K0IIJcLcAG9DUrNfI6aoUjNcAAzE0OAB9AAAABWQAIAAAAAA5rZItA/cocRnngYqcJ3nBXQ+l688aKz3EQyLbYYunPAVzACAAAAAAwKyA+L7TgxztPClLrIMk2JXR+w7c04N3ZOqPgjvrIvsFbAAgAAAAACzvZ33h6aWEe8hmo+1f6OXJ72FY5hvWaUuha64ZV3KFAAMxNDkAfQAAAAVkACAAAAAA3htn7oHJ0YYpIrs+Mzyh85Ys67HwAdv5LQl1mCdoMWkFcwAgAAAAAEHjCtNNLenHuSIYux6ezAHsXDaj2DlTF67ToDhDDe6HBWwAIAAAAAD+P4H0sk9jOd+7vOANt2/1Ectb+4ZRGPE8GkHWNXW3MgADMTUwAH0AAAAFZAAgAAAAAEnt18Km/nqggfIJWxzTr9r3hnXNaueG6XO9A5G11LnGBXMAIAAAAAD7QxzGMN/ard5TfFLecE6uusMmXG2+RBsBR+/NCQHUwAVsACAAAAAAQEZ1ZZ8GC8rdbg7s87OM5Gr9qkTXS9+P5DuAZxj5Gl4AAzE1MQB9AAAABWQAIAAAAAAVAKK/GoY8AACu/hyMpO4hdLq6JnEyWNzkyci9sbaD/wVzACAAAAAA2HmeqpMlvvBpV2zQTYIRmsc4MFlfHRwLof0ycJgMg/MFbAAgAAAAACdltCeWi5E/q1Li1eXLChpM2D9QQSGLBZ82NklQSc0oAAMxNTIAfQAAAAVkACAAAAAAhHyq1GQC/GiMwpYjcsfkNxolJ10ARKjIjfkW1Wipzi0FcwAgAAAAAD/uaGWxTDq87F8XZ6CrFI+RNa8yMqfSZdqK00Kj833BBWwAIAAAAAD6aEdOO0CsQGagioOCvANPCEHSpJ8BSixlPBq5ERhB7AADMTUzAH0AAAAFZAAgAAAAABAJJxHoZD+MQBWqm9UM9Dd3z5ZohIZGWRaRVRsMptKQBXMAIAAAAADrE/ca+gqj/SH4oao4wE4qn2ovoTydzcMbDbrfnUs3zAVsACAAAAAAeNCIQN6hVnGJinytQRFGlQ2ocoprXNqpia+BSxzl+uwAAzE1NAB9AAAABWQAIAAAAAAv01wz7VG9mTepjXQi6Zma+7b/OVBaKVkWNbgDLr1mFgVzACAAAAAA0I5sxz8r6wkCp5Tgvr+iL4p6MxSOq5d3e1kZG+0b7NkFbAAgAAAAAIA32v6oGkAOS96HexGouNTex+tLahtx9QF2dgGClk6WAAMxNTUAfQAAAAVkACAAAAAAWXecRwxSon68xaa9THXnRDw5ZfzARKnvvjTjtbae6T0FcwAgAAAAAPh0UfUMEo7eILCMv2tiJQe1bF9qtXq7GJtC6H5Va4fIBWwAIAAAAADqFr1ThRrTXNgIOrJWScO9mk86Ufi95IDu5gi4vP+HWQADMTU2AH0AAAAFZAAgAAAAAEY5WL8/LpX36iAB1wlQrMO/xHVjoO9BePVzbUlBYo+bBXMAIAAAAABoKcpadDXUARedDvTmzUzWPe1jTuvD0z9oIcZmKuiSXwVsACAAAAAAJuJbwuaMrAFoI+jU/IYr+k4RzAqITrOjAd3HWCpJHqEAAzE1NwB9AAAABWQAIAAAAADnJnWqsfx0xqNnqfFGCxIplVu8mXjaHTViJT9+y2RuTgVzACAAAAAAWAaSCwIXDwdYxWf2NZTly/iKVfG/KDjHUcA1BokN5sMFbAAgAAAAAJVxavipE0H4/JQvhagdytXBZ8qGooeXpkbPQ1RfYMVHAAMxNTgAfQAAAAVkACAAAAAAsPG7LaIpJvcwqcbtfFUpIjj+vpNj70Zjaw3eV9T+QYsFcwAgAAAAAJQ71zi0NlCyY8ZQs3IasJ4gB1PmWx57HpnlCf3+hmhqBWwAIAAAAACD58TO6d+71GaOoS+r73rAxliAO9GMs4Uc8JbOTmC0OwADMTU5AH0AAAAFZAAgAAAAAAGiSqKaQDakMi1W87rFAhkogfRAevnwQ41onWNUJKtuBXMAIAAAAAASgiDpXfGh7E47KkOD8MAcX8+BnDShlnU5JAGdnPdqOAVsACAAAAAAI+2TTQIgbFq4Yr3lkzGwhG/tqChP7hRAx2W0fNaH6jcAAzE2MAB9AAAABWQAIAAAAAB7L4EnhjKA5xJD3ORhH2wOA1BvpnQ+7IjRYi+jjVEaJAVzACAAAAAAuhBIm0nL3FJnVJId+7CKDASEo+l2E89Z9/5aWSITK4AFbAAgAAAAALtSICOzQDfV9d+gZuYxpEj6cCeHnKTT+2G3ceP2H65kAAMxNjEAfQAAAAVkACAAAAAAaROn1NaDZFOGEWw724dsXBAm6bgmL5i0cki6QZQNrOoFcwAgAAAAANVT8R6UvhrAlyqYlxtmnvkR4uYK/hlvyQmBu/LP6/3ZBWwAIAAAAAD+aHNMP/X+jcRHyUtrCNkk1KfMtoD3GTmShS8pWGLt+AADMTYyAH0AAAAFZAAgAAAAADqSR5e0/Th59LrauDA7OnGD1Xr3H3NokfVxzDWOFaN7BXMAIAAAAACt30faNwTWRbvmykDpiDYUOCwA6QDbBBYBFWS7rdOB4AVsACAAAAAAF7SvnjjRk5v2flFOKaBAEDvjXaL1cpjsQLtK2fv9zdQAAzE2MwB9AAAABWQAIAAAAADmtb1ZgpZjSeodPG/hIVlsnS8hoRRwRbrTVx89VwL62AVzACAAAAAAi38e1g6sEyVfSDkzZbaZXGxKI/zKNbMasOl2LYoWrq8FbAAgAAAAAALACk0KcCDN/Kv8WuazY8ORtUGkOZ5Dsm0ys1oOppp/AAMxNjQAfQAAAAVkACAAAAAAf/f7AWVgBxoKjr7YsEQ4w/fqSvuQWV2HMiA3rQ7ur0sFcwAgAAAAADkkeJozP6FFhUdRIN74H4UhIHue+eVbOs1NvbdWYFQrBWwAIAAAAAB55FlHAkmTzAYj/TWrGkRJw2EhrVWUnZXDoMYjyfB/ZwADMTY1AH0AAAAFZAAgAAAAAI2WEOymtuFpdKi4ctanPLnlQud+yMKKb8p/nfKmIy56BXMAIAAAAADVKrJmhjr1rfF3p+T+tl7UFd1B7+BfJRk0e7a4im7ozgVsACAAAAAA5E7Ti3PnFiBQoCcb/DN7V1uM3Xd6VKiexPKntssFL7kAAzE2NgB9AAAABWQAIAAAAAAuHU9Qd79hjyvKOujGanSGDIQlxzsql8JytTZhEnPw+AVzACAAAAAAjF2gV/4+sOHVgDd/oR5wDi9zL7NGpGD+NsEpGXy/a4QFbAAgAAAAAJzMoyojYV6Ed/LpVN5zge93Odv3U7JgP7wxeRaJZGTdAAMxNjcAfQAAAAVkACAAAAAA7dQDkt3iyWYCT94d7yqUtPPwp4qkC0ddu+HFdHgVKEkFcwAgAAAAANuYvtvZBTEq4Rm9+5eb7VuFopowkrAuv86PGP8Q8/QvBWwAIAAAAACeqXoAOQOE4j0zRMlkVd8plaW0RX1npsFvB38Xmzv7sAADMTY4AH0AAAAFZAAgAAAAAAwnZSDhL4tNGYxlHPhKYB8s28dY5ScSwiKZm3UhT8U3BXMAIAAAAABDoY6dhivufTURQExyC9Gx3ocpl09bgbbQLChj3qVGbgVsACAAAAAAF+1nS7O0v85s3CCy+9HkdeoEfm2C6ZiNbPMMnSfsMHUAAzE2OQB9AAAABWQAIAAAAAC2VuRdaC4ZJmLdNOvD6R2tnvkyARteqXouJmI46V306QVzACAAAAAAMn1Z6B35wFTX9mEYAPM+IiJ5hauEwfD0CyIvBrxHg7IFbAAgAAAAAOG6DvDZkT9B/xZWmjao2AevN7MMbs3Oh9YJeSd/hZ+hAAMxNzAAfQAAAAVkACAAAAAAVerb7qVNy457rNOHOgDSKyWl5ojun7iWrv1uHPXrIZQFcwAgAAAAAIDcYS9j5z+gx0xdJj09L7876r/vjvKTi/d3bXDE3PhyBWwAIAAAAADuhVLqb1Bkrx8aNymS+bx2cL8GvLFNH4SAi690DUgnWQADMTcxAH0AAAAFZAAgAAAAAH/E44yLxKCJjuSmU9A8SEhbmkDOx1PqqtYcZtgOzJdrBXMAIAAAAABgLh9v2HjBbogrRoQ82LS6KjZQnzjxyJH4PH+F3jupSAVsACAAAAAAIlO46ehXp4TqpDV0t6op++KO+uWBFh8iFORZjmx2IjkAAzE3MgB9AAAABWQAIAAAAAAlNUdDL+f/SSQ5074mrq0JNh7CTXwTbbhsQyDwWeDVMwVzACAAAAAANIH2IlSNG0kUw4qz0budjcWn8mNR9cJlYUqPYdonucAFbAAgAAAAAJMrOUOyiu5Y3sV76zwEFct8L7+i8WGlQI2+8z2W2kzaAAMxNzMAfQAAAAVkACAAAAAASZ+CvUDtlk/R4HAQ3a+PHrKeY/8ifAfh0oXYFqliu80FcwAgAAAAAJelpzPgM65OZFt/mvGGpwibclQ49wH+1gbUGzd9OindBWwAIAAAAAD9qeDchteEpVXWcycmD9kl9449C1dOw0r60TBm5jK+cQADMTc0AH0AAAAFZAAgAAAAAN9fkoUVbvFV2vMNMAkak4gYfEnzwKI3eDM3pnDK5q3lBXMAIAAAAACnDkgVNVNUlbQ9RhR6Aot2nVy+U4km6+GHPkLr631jEAVsACAAAAAANzg/BnkvkmvOr8nS4omF+q9EG/4oisB+ul4YHi938hwAAzE3NQB9AAAABWQAIAAAAAASyK3b1nmNCMptVEGOjwoxYLLS9fYWm/Zxilqea0jpEQVzACAAAAAADDHsGrbqlKGEpxlvfyqOJKQJjwJrzsrB7k3HG0AUJbkFbAAgAAAAAKwx3S4XfDZh4+LuI9jf7XgUh5qiefNv87JD4qvVRfPSAAMxNzYAfQAAAAVkACAAAAAAlSP9iK31GlcG9MKGbLmq+VXMslURr+As736rrVNXcsUFcwAgAAAAAAvbj0zfq9zzi8XReheKFbCB+h9IsOLgXPPpI5vrEJNZBWwAIAAAAABXvoZhaQE7ogWjeBjceVkp03N20cKYP3TA8vuNsgpfAgADMTc3AH0AAAAFZAAgAAAAAOJNORH8Bev97gVU7y6bznOxJ+E6Qoykur1QP76hG1/7BXMAIAAAAAC+C1PtOOrSZgzBAGhr+dPe/kR0JUw9GTwLVNr61xC1aAVsACAAAAAAeA/L8MQIXkamaObtMPLpoDoi5FypA5WAPtMeMrgi0eQAAzE3OAB9AAAABWQAIAAAAAAKcHzLUomavInN6upPkyWhAqYQACP/vdVCIYpiy6U6HgVzACAAAAAATsR4KItY6R2+U7Gg6sJdaEcf58gjd1OulyWovIqfxKcFbAAgAAAAAFbm10ko67ahboAejQdAV0U2uA5OhZYdb8XUFJ8OL46LAAMxNzkAfQAAAAVkACAAAAAAqTOLiMpCdR59tLZzzIPqJvbCNvz2XQL9ust0qYaehtcFcwAgAAAAAArefox/3k5xGOeiw2m6NUdzuGxmPwcu5IFcj+jMwHgHBWwAIAAAAADLZGFJ7MQd5JXMgMXjqZO5LDLxcFClcXPlnRMWRn+1oAADMTgwAH0AAAAFZAAgAAAAAIPSqSeVzSRgNVNmrPYHmUMgykCY27NbdDUNhE5kx/SgBXMAIAAAAAAhX90nNfxyXmZe/+btZ7q6xMX4PFyj0paM1ccJ/5IUUQVsACAAAAAA419oHmD2W0SYoOMwhrhrp8jf68fg9hTkaRdCuVd3CN0AAzE4MQB9AAAABWQAIAAAAACLn5DxiqAosHGXIAY96FwFKjeqrzXWf3VJIQMwx1fl4gVzACAAAAAAindvU27nveutopdvuHmzdENBbeGFtI3Qcsr07jxmvm8FbAAgAAAAAPvl9pBStQvP4OGkN5v0MghUY6djm9n7XdKKfrW0l1sMAAMxODIAfQAAAAVkACAAAAAA7i2S6rHRSPBwZEn59yxaS7HiYBOmObIkeyCcFU42kf8FcwAgAAAAAGb3RSEyBmgarkTvyLWtOLJcPwCKbCRkESG4RZjVmY4iBWwAIAAAAADB2/wo5CSHR4ANtifY6ZRXNTO5+O8qP82DfAiAeanpZwADMTgzAH0AAAAFZAAgAAAAAFz+M+H/Z94mdPW5oP51B4HWptp1rxcMWAjnlHvWJDWrBXMAIAAAAACBFEOQyL7ZHu4Cq33QvXkmKuH5ibG/Md3RaED9CtG5HwVsACAAAAAAfggtJTprQ/yZzj7y5z9KvXsdeXMWP0yUXMMJqpOwI88AAzE4NAB9AAAABWQAIAAAAAAE7c2x3Z3aM1XGfLNk/XQ9jCazNRbGhVm7H8c2NjS5ywVzACAAAAAARJ9h8fdcwA19velF3L/Wcvi2rCzewlKZ2nA0p8bT9uwFbAAgAAAAAJtWe6b4wK2Hae2dZm/OEpYQnvoZjz4Sz5IgJC2wInecAAMxODUAfQAAAAVkACAAAAAAVoRt9B9dNVvIMGN+ea5TzRzQC+lqSZ8dd/170zU5o9cFcwAgAAAAAEwM95XZin5mv2yhCI8+ugtKuvRVmNgzzIQN0yi1+9aIBWwAIAAAAAAMGBq72n00rox3uqhxSB98mkenTGCdbbUF1gXrgottzgADMTg2AH0AAAAFZAAgAAAAAKRDkjyWv/etlYT4GyoXrmBED2FgZHnhc+l9Wsl06cH2BXMAIAAAAABohlpm3K850Vndf3NmNE0hHqDlNbSR8/IvMidQ3LnIZAVsACAAAAAAW42nGHa6q2MCAaaPVwaIDfr8QLyQwjKq23onZJYsqVsAAzE4NwB9AAAABWQAIAAAAAC3DFh5oklLCNLY90bgWm68dFXz65JpAZSp1K99MBTPAQVzACAAAAAAQgZecmxEUZVHoptEQClDwAf8smI3WynQ/i+JBP0g+kQFbAAgAAAAAEUSQGVnAPISD6voD0DiBUqyWKgt2rta0tjmoe+LNt6IAAMxODgAfQAAAAVkACAAAAAAQ5WKvWSB503qeNlOI2Tpjd5blheNr6OBO8pfJfPNstcFcwAgAAAAAKwHgQLSDJ5NwLBQbY5OnblQIsVDpGV7q3RCbFLD1U4/BWwAIAAAAACQ5nED99LnpbqXZuUOUjnO2HTphEAFBjLD4OZeDEYybgADMTg5AH0AAAAFZAAgAAAAAGfhFY3RGRm5ZgWRQef1tXxHBq5Y6fXaLAR4yJhrTBplBXMAIAAAAACKEF0ApLoB6lP2UqTFsTQYNc9OdDrs/vziPGzttGVLKQVsACAAAAAArOO6FyfNRyBi0sPT5iye7M8d16MTLcwRfodZq4uCYKEAAzE5MAB9AAAABWQAIAAAAAAIM73gPcgzgotYHLeMa2zAU4mFsr7CbILUZWfnuKSwagVzACAAAAAAJCSu98uV8xv88f2BIOWzt6p+6EjQStMBdkGPUkgN79cFbAAgAAAAAMGqPGMPxXbmYbVfSa/japvUljht1zZT33TY7ZjAiuPfAAMxOTEAfQAAAAVkACAAAAAAkWmHCUsiMy1pwZTHxVPBzPTrWFBUDqHNrVqcyyt7nO8FcwAgAAAAAMv2CebFRG/br7USELR98sIdgE9OQCRBGV5JZCO+uPMgBWwAIAAAAABt7qSmn3gxJu7aswsbUiwvO+G6lXj/Xhx+J/zQyZxzLAADMTkyAH0AAAAFZAAgAAAAAGInUYv0lP/rK7McM8taEHXRefk8Q2AunrvWqdfSV7UaBXMAIAAAAACE+WPxJ3gan7iRTbIxXXx+bKVcaf8kP4JD8DcwU0aL7wVsACAAAAAAUC4eTprX4DUZn2X+UXYU6QjtiXk+u57yoOPBbPQUmDkAAzE5MwB9AAAABWQAIAAAAACmHlg2ud3cplXlTsNTpvNnY6Qm1Fce0m899COamoDjaQVzACAAAAAArtJQeJIlepBWRU2aYar7+YGYVQ7dfDc1oxgTmA8r9q0FbAAgAAAAAOk45vg5VqZHAFCO3i0Z52SZi5RADf8NXwf68T5yad/DAAMxOTQAfQAAAAVkACAAAAAApzcWSAbZWV/Rq+ylRNqqlJqNVR4fhXrz4633/MQOQgcFcwAgAAAAAN/jz/bsEleiuCl+li83EWlG6UMHA8CyaOMRKCkXkSCPBWwAIAAAAAC3Sd+Qg+uFDKpGZHbrQgokXHQ1az1aFl4YK343OB6hcQAAEmNtAAAAAAAAAAAAABBwYXlsb2FkSWQAAAAAABBmaXJzdE9wZXJhdG9yAAEAAAAA", - "subType": "06" - } - } - } - }, - "limit": 1 - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "delete" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": { - "$numberInt": "0" - }, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rbf3AeBEv4wWFAKknqDxRW5cLNkFvbIs6iJjc6LShQY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "n+XAuFnP8Dov9TnhGFxNx0K/MnVM9WbJ7RouEu0ndO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yRXojuVdn5GQtD97qYlaCL6cOLmZ7Cvcb3wFjkLUIdM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DuIkdRPITRs55I4SZmgomAHCIsDQmXRhW8+MOznkzSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SsBk+Et1lTbU+QRPx+xyJ/jMkmfG+QCvQEpip2YYrzA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "crCIzOd8KhHvvUlX7M1v9bhvU4pLdTc+X2SuqoKU5Ek=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YOWdCw4UrqnxkAaVjqmC4sKQDMVMHEpFGnlxpxdaU6E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M3SShp81Ff8tQ632qKbv9MUcN6wjDaBReI0VXNu6Xh4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gzHlSPxpM0hT75kQvWFzGlOxKvDoiKQZOr19V6l2zXI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s3JnppOGYw9SL2Q1kMAZs948v2F5PrpXjGei/HioDWs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cG6+3Gk/zEH68P/uuuwiAUVCuyJwa1LeV+t29FlPPAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dupdvR3AyJtM+g9NDKiaLVOtGca387JQp8w+V03m7Ig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JqEQc5svj2jTvZ6LLA5ivE+kTb/0aRemSEmxk4G7Zrg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "szcXXXKnob+p3SoM4yED2R920LeJ7cVsclPMFTe4CeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o1QoGVXmuBdHwHm7aCtGMlMVKrjFdYvJXpoq6uhIAZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Jfm5wPlqqLCJRGQIqRq2NGmpn7s0Vrih2H3YAOoI2YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zMHLb8ARbsYo8Ld05bqnGFf1Usha6EGb8QKwdSAyps0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yQdtq9lh5pugL7/i0Bj/PuZUUBUIzf+7wj1rl5y736w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wGWVZdO7qIuyDg/BqDgqjgoQ02h5YYgwXQB1oCin2NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "by9HMLj6NTEpgztZ5HSN6GxImkXPcaFINYDzgZY33X8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tWo0vbasi7bXmn/MsOx13VC1IsWtpx/nYp0uj4iMzdA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tQQpndUYd5O87lOtrGjH3wl9VsOK0ray7RMasL90sBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cQjXEDCMsOpKLLf+vlTgIHA+cbSJdzqhbSX9Wvh95aA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7yMpU48IxK9SzP2cx3VnTownGEwFmeFofuuFT97SuuY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kSOx1kz0CmBgzKQHZlo65ZUY1DIv9A99JRm+Us2y6Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubQpdPBe6/xvtr+AcXdfYLSvYCR4ot0tivehkCsupb4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xal+iCJ6FTefRQToyoNksc9NCZShyn04NDGi4IYrcoM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d7jU4iOK50xHxlkSifcxlZFCM46TSgQzoYivxG3HNLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJvl2nsBLBVzL3pp6sKWCL4UXeh3q/roYBJjSb74ve0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OIUCaKRvIx9t1w6Hxlz1IcQTdPNCfdRNwnnTm10W+X0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A9tvzsiElotOUVIB4CqfQp9mAwqvTM35YkmAR170aHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lI8gpK7hpb7c9x4RQugsxMnQay5LZJmwslZdvMx/dcE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dNCzh40U0XvdKnSDi3HRQOWQftEsDVqc4uUvsVFGoq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IP+iwEBWBwVVZIdpaMu8k5+soFCz+TZkYn3drKZ9grE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnqyh6e0y5svHkJDShlN9CHV0WvMBE4QbtJpQw5ZCXc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "elEl42tbVDoRTLjAhZUFEtXiut4b3PVhg/1ZLZSQdtE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vHuu2FxwclMHqyE6JBYbTYgbEkB0dqb/JuaxsvfwsmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xTf7NCe3Gf8QpE78HR5OknlLTKfs9J+RN9UZpH6fnso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XiWSasRnJAulGR6+LCVD3mwRObXylqYWR9jvpywq12c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MZMxEQ5ikx0PG1YFIExv0UnTZogsvgeOEZTpzvBDn4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yZMyMZBDrWbAhvnic7vvIYhmO9m5H2iuv0c8KNZrBzY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xxM14hTPY5j0vvcK2C7YAEjzdsfUTFHozHC0hEo1bxI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+01rqR1xVwkpGXcstbk1ItJqFVjH6Q8MGxEN3Cm9Y1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xOpLV0Z2VTRJ3iWtnWZcsyjXubTIkYWo31cO+HV1o1k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BWUOLqgLBqc5NwxVlSV5H3KFQPXbCp7mdo+jF+8cJqY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fuQb1S6xZDGlrEbK+kI23aL53PP1PVNwqICnZNt9Yzg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfscnoibFttahLdPVC4Ee+47ewGFKpDSU7M6HX19bKE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rpSW2awybNVeKtat91VFxqbINoTfNhPfQAu+d73Xtf8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9M/CP9ccOIIj2LLFmE0GFDO0Ban2wsNalEXfM6+h+1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WrEMG49l1ye4MhXs5ZS9tz8P6h+hDvthIg/2wW9ne1Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ImNhbfeyfH8qIEeA5ic0s3dAQBdzzTBS+CPsNih9vZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dWP33YDSn04UKJN2ogh2Rui0iW/0q2y18OCDRVcfyoo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lYv0isAtfGh6H9tdp3cp2eHU7q2J+uk7QrgcxtK3w7Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VGMoamB/+7zTOYcY/pqJc96xlv2PdW4hwsIAEIslTDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yNeBWMF7BnD9wVwz2PgJsvWr77QiVvvWUvJF0+fqBug=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfpvObJ+tJBXSvqeN7vlOfmhYign635lciYAJIjUtY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dsen4NqjzVGjpjufiTMs3+gqeD09EbnuogPgxrJECwg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pxCWVM3sn19NsFEpgHbgLa+PmYlhN3mMiP0Wk8kJhYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q11KNvJszjYIB9n9HcC+N4uz11a3eRj1L3BH9scKMDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A1PmkgcEToWh1JiVWE6mI5jUu7poxWWuCUt/cgRUUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qJo3Hu4PJeanL7XEaWXO/n3YsodhZyd+MJOOmB9Kpd8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BkBKLO8URFscfRY9Bav/1+L9mLohDgNr/MkZtGiraIs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rZq5WA3Hx3xthOyHAJXK//f8pE2qbz7YKu3TIMp9GFY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X07a/Lm80p5xd4RFs1dNmw+90tmPDPdGiAKVZkxd4zY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6YrBn2ofIw1b5ooakrLOwF41BWrps8OO0H9WH4/rtlE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0l86Ag5OszXpa78SlOUV3K9nff5iC1p0mRXtLg9M1s4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Hn6yuxFHodeyu7ISlhYrbSf9pTiH4TDEvbYLWjTwFO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zdf4y2etKBuIpkEU1zMwoCkCsdisfXZCh8QPamm+drY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rOQ9oMdiK5xxGH+jPzOvwVqdGGnF3+HkJXxn81s6hp4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "61aKKsE3+BJHHWYvs3xSIBvlRmKswmaOo5rygQJguUg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KuDb/GIzqDM8wv7m7m8AECiWJbae5EKKtJRugZx7kR0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Q+t8t2TmNUiCIorVr9F3AlVnX+Mpt2ZYvN+s8UGict8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJRZIpKxUgHyL83kW8cvfjkxN3z6WoNnUg+SQw+LK+k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnUsYjip8SvW0+m9mR5WWTkpK+p6uwJ6yBUAlBnFKMk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PArHlz+yPRYDycAP/PgnI/AkP8Wgmfg++Vf4UG1Bf0E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wnIh53Q3jeK8jEBe1n8kJLa89/H0BxO26ZU8SRIAs9Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4F8U59gzBLGhq58PEWQk2nch+R0Va7eTUoxMneReUIA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ihKagIW3uT1dm22ROr/g5QaCpxZVj2+Fs/YSdM2Noco=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EJtUOOwjkrPUi9mavYAi+Gom9Y2DuFll7aDwo4mq0M0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dIkr8dbaVRQFskAVT6B286BbcBBt1pZPEOcTZqk4ZcI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aYVAcZYkH/Tieoa1XOjE/zCy5AJcVTHjS0NG2QB7muA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sBidL6y8TenseetpioIAAtn0lK/7C8MoW4JXpVYi3z8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0Dd2klU/t4R86c2WJcJDAd57k/N7OjvYSO5Vf8KH8sw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I3jZ92WEVmZmgaIkLbuWhBxl7EM6bEjiEttgBJunArA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aGHoQMlgJoGvArjfIbc3nnkoc8SWBxcrN7hSmjMRzos=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bpiWPnF/KVBQr5F6MEwc5ZZayzIRvQOLDAm4ntwOi8g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tI7QVKbE6avWgDD9h4QKyFlnTxFCwd2iLySKakxNR/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XGsge0CnoaXgE3rcpKm8AEeku5QVfokS3kcI+JKV1lk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JQxlryW2Q5WOwfrjAnaZxDvC83Dg6sjRVP5zegf2WiM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YFuHKJOfoqp1iGVxoFjx7bLYgVdsN4GuUFxEgO9HJ5s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Z6vUdiCR18ylKomf08uxcQHeRtmyav7/Ecvzz4av3k4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SPGo1Ib5AiP/tSllL7Z5PAypvnKdwJLzt8imfIMSEJQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "m94Nh6PFFQFLIib9Cu5LAKavhXnagSHG6F5EF8lD96I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pfEkQI98mB+gm1+JbmVurPAODMFPJ4E8DnqfVyUWbSo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DNj3OVRLbr43s0vd+rgWghOL3FqeO/60npdojC8Ry/M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kAYIQrjHVu49W8FTxyxJeiLVRWWjC9fPcBn+Hx1F+Ss=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aCSO7UVOpoQvu/iridarxkxV1SVxU1i9HVSYXUAeXk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Gh6hTP/yj1IKlXQ+Q69KTfMlGZjEcXoRLGbQHNFo/1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/gDgIFQ4tAlJk3GN48IS5Qa5IPmErwGk8CHxAbp6gs0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PICyimwPjxpusyKxNssOOwUotAUbygpyEtORsVGXT8g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4lu+cBHyAUvuxC6JUNyHLzHsCogGSWFFnUCkDwfQdgI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pSndkmoNUJwXjgkbkgOrT5f9nSvuoMEZOkwAN9ElRaE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tyW+D4i26QihNM5MuBM+wnt5AdWGSJaJ4X5ydc9iWTU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9Syjr8RoxUgPKr+O5rsCu07AvcebA4P8IVKyS1NVLWc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "67tPfDYnK2tmrioI51fOBG0ygajcV0pLo5+Zm/rEW7U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "y0EiPRxYTuS1eVTIaPQUQBBxwkyxNckbePvKgChwd0M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NWd+2veAaeXQgR3vCvzlI4R1WW67D5YsVLdoXfdb8qg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PY5RQqKQsL2GqBBSPNOEVpojNFRX/NijCghIpxD6CZk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lcvwTyEjFlssCJtdjRpdN6oY+C7bxZY+WA+QAqzj9zg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWE7XRNylvTwO/9Fv56dNqUaQWMmESNS/GNIwgBaEI0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ijwlrUeS8nRYqK1F8kiCYF0mNDolEZS+/lJO1Lg93C8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8KzV+qYGYuIjoNj8eEpnTuHrMYuhzphl80rS6wrODuU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wDyTLjSEFF895hSQsHvmoEQVS6KIkZOtq1c9dVogm9I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SGrtPuMYCjUrfKF0Pq/thdaQzmGBMUvlwN3ORIu9tHU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KySHON3hIoUk4xWcwTqk6IL0kgjzjxgMBObVIkCGvk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hBIdS9j0XJPeT4ot73ngELkpUoSixvRBvdOL9z48jY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Tx6um0q9HjS5ZvlFhvukpI6ORnyrXMWVW1OoxvgqII0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zFKlyfX5H81+d4A4J3FKn4T5JfG+OWtR06ddyX4Mxas=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cGgCDuPV7MeMMYEDpgOupqyNP4BQ4H7rBnd2QygumgM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IPaUoy98v11EoglTpJ4kBlEawoZ8y7BPwzjLYBpkvHQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Pfo4Am6tOWAyZNn8G9W5HWWGC3ZWmX0igI/RRB870Ro=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fnTSjd7bC1Udoq6iM7UDnHAC/lsIXSHp/Gy332qw+/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fApBgVRrTDyEumkeWs5p3ag9KB48SbU4Si0dl7Ns9rc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QxudfBItgoCnUj5NXVnSmWH3HK76YtKkMmzn4lyyUYY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sSOvwhKa29Wq94bZ5jGIiJQGbG1uBrKSBfOYBz/oZeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FdaMgwwJ0NKsqmPZLC5oE+/0D74Dfpvig3LaI5yW5Fs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sRWBy12IERN43BSZIrnBfC9+zFBUdvjTlkqIH81NGt4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/4tIRpxKhoOwnXAiFn1Z7Xmric4USOIfKvTYQXk3QTc=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-FindOneAndUpdate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-FindOneAndUpdate.json deleted file mode 100644 index 2a8070ecf..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-FindOneAndUpdate.json +++ /dev/null @@ -1,1907 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Decimal. FindOneAndUpdate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1" - } - } - } - }, - { - "name": "findOneAndUpdate", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$numberDecimal": "0" - } - } - }, - "update": { - "$set": { - "encryptedDecimalNoPrecision": { - "$numberDecimal": "2" - } - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1" - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "default", - "query": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$binary": { - "base64": "DeFiAAADcGF5bG9hZACxYgAABGcAnWIAAAMwAH0AAAAFZAAgAAAAAJu2KgiI8vM+kz9qD3ZQzFQY5qbgYqCqHG5R4jAlnlwXBXMAIAAAAAAAUXxFXsz764T79sGCdhxvNd5b6E/9p61FonsHyEIhogVsACAAAAAAt19RL3Oo5ni5L8kcvgOJYLgVYyXJExwP8pkuzLG7f/kAAzEAfQAAAAVkACAAAAAAPQPvL0ARjujSv2Rkm8r7spVsgeC1K3FWcskGGZ3OdDIFcwAgAAAAACgNn660GmefR8jLqzgR1u5O+Uocx9GyEHiBqVGko5FZBWwAIAAAAADflr+fsnZngm6KRWYgHa9JzK+bXogWl9evBU9sQUHPHQADMgB9AAAABWQAIAAAAAD2Zi6kcxmaD2mY3VWrP+wYJMPg6cSBIYPapxaFQxYFdQVzACAAAAAAM/cV36BLBY3xFBXsXJY8M9EHHOc/qrmdc2CJmj3M89gFbAAgAAAAAOpydOrKxx6m2gquSDV2Vv3w10GocmNCFeOo/fRhRH9JAAMzAH0AAAAFZAAgAAAAAOaNqI9srQ/mI9gwbk+VkizGBBH/PPWOVusgnfPk3tY1BXMAIAAAAAAc96O/pwKCmHCagT6T/QV/wz4vqO+R22GsZ1dse2Vg6QVsACAAAAAAgzIak+Q3UFLTHXPmJ+MuEklFtR3eLtvM+jdKkmGCV/YAAzQAfQAAAAVkACAAAAAA0XlQgy/Yu97EQOjronl9b3dcR1DFn3deuVhtTLbJZHkFcwAgAAAAACoMnpVl6EFJak8A+t5N4RFnQhkQEBnNAx8wDqmq5U/dBWwAIAAAAACR26FJif673qpwF1J1FEkQGJ1Ywcr/ZW6JQ7meGqzt1QADNQB9AAAABWQAIAAAAAAOtpNexRxfv0yRFvZO9DhlkpU4mDuAb8ykdLnE5Vf1VAVzACAAAAAAeblFKm/30orP16uQpZslvsoS8s0xfNPIBlw3VkHeekYFbAAgAAAAAPEoHj87sYE+nBut52/LPvleWQBzB/uaJFnosxp4NRO2AAM2AH0AAAAFZAAgAAAAAIr8xAFm1zPmrvW4Vy5Ct0W8FxMmyPmFzdWVzesBhAJFBXMAIAAAAABYeeXjJEzTHwxab6pUiCRiZjxgtN59a1y8Szy3hfkg+gVsACAAAAAAJuoY4rF8mbI+nKb+5XbZShJ8191o/e8ZCRHE0O4Ey8MAAzcAfQAAAAVkACAAAAAAl+ibLk0/+EwoqeC8S8cGgAtjtpQWGEZDsybMPnrrkwEFcwAgAAAAAHPPBudWgQ+HUorLDpJMqhS9VBF2VF5aLcxgrM1s+yU7BWwAIAAAAAAcCcBR2Vyv5pAFbaOU97yovuOi1+ATDnLLcAUqHecXcAADOAB9AAAABWQAIAAAAACR9erwLTb+tcWFZgJ2MEfM0PKI9uuwIjDTHADRFgD+SQVzACAAAAAAcOop8TXsGUVQoKhzUllMYWxL93xCOkwtIpV8Q6hiSYYFbAAgAAAAAKXKmh4V8veYwob1H03Q3p3PN8SRAaQwDT34KlNVUjiDAAM5AH0AAAAFZAAgAAAAALv0vCPgh7QpmM8Ug6ad5ioZJCh7pLMdT8FYyQioBQ6KBXMAIAAAAADsCPyIG8t6ApQkRk1fX/sfc1kpuWCWP8gAEpnYoBSHrQVsACAAAAAAJe/r67N6d8uTiogvfoR9rEXbIDjyLb9EVdqkayFFGaYAAzEwAH0AAAAFZAAgAAAAAIW4AxJgYoM0pcNTwk1RSbyjZGIqgKL1hcTJmNrnZmoPBXMAIAAAAAAZpfx3EFO0vY0f1eHnE0PazgqeNDTaj+pPJMUNW8lFrAVsACAAAAAAP+Um2vwW6Bj6vuz9DKz6+6aWkoKoEmFNoiz/xXm7lOsAAzExAH0AAAAFZAAgAAAAAKliO6L9zgeuufjj174hvmQGNRbmYYs9yAirL7OxwEW3BXMAIAAAAAAqU7vs3DWUQ95Eq8OejwWnD0GuXd+ASi/uD6S0l8MM1QVsACAAAAAAb9legYzsfctBPpHyl7YWpPmLr5QiNZFND/50N1vv2MUAAzEyAH0AAAAFZAAgAAAAAOGQcCBkk+j/Kzjt/Cs6g3BZPJG81wIHBS8JewHGpgk+BXMAIAAAAABjrxZXWCkdzrExwCgyHaafuPSQ4V4x2k9kUCAqUaYKDQVsACAAAAAADBU6KefT0v8zSmseaMNmQxKjJar72y7MojLFhkEHqrUAAzEzAH0AAAAFZAAgAAAAAPmCNEt4t97waOSd5hNi2fNCdWEkmcFJ37LI9k4Az4/5BXMAIAAAAABX7DuDPNg+duvELf3NbLWkPMFw2HGLgWGHyVWcPvSNCAVsACAAAAAAS7El1FtZ5STh8Q1FguvieyYX9b2DF1DFVsb9hzxXYRsAAzE0AH0AAAAFZAAgAAAAAD4vtVUYRNB+FD9yoQ2FVJH3nMeJeKbi6eZfth638YqbBXMAIAAAAAANCuUB4OdmuD6LaDK2f3vaqfgYYvg40wDXOBbcFjTqLwVsACAAAAAA9hqC2VoJBjwR7hcQ45xO8ZVojwC83jiRacCaDj6Px2gAAzE1AH0AAAAFZAAgAAAAAJPIRzjmTjbdIvshG6UslbEOd797ZSIdjGAhGWxVQvK1BXMAIAAAAABgmJ0Jh8WLs9IYs/a7DBjDWd8J3thW/AGJK7zDnMeYOAVsACAAAAAAi9zAsyAuou2oiCUHGc6QefLUkACa9IgeBhGu9W/r0X8AAzE2AH0AAAAFZAAgAAAAAABQyKQPoW8wGPIqnsTv69+DzIdRkohRhOhDmyVHkw9WBXMAIAAAAAAqWA2X4tB/h3O1Xlawtz6ndI6WaTwgU1QYflL35opu5gVsACAAAAAAWI/Gj5aZMwDIxztqmVL0g5LBcI8EdKEc2UA28pnekQoAAzE3AH0AAAAFZAAgAAAAACB7NOyGQ1Id3MYnxtBXqyZ5Ul/lHH6p1b10U63DfT6bBXMAIAAAAADpOryIcndxztkHSfLN3Kzq29sD8djS0PspDSqERMqokQVsACAAAAAADatsMW4ezgnyi1PiP7xk+gA4AFIN/fb5uJqfVkjg4UoAAzE4AH0AAAAFZAAgAAAAAKVfXLfs8XA14CRTB56oZwV+bFJN5BHraTXbqEXZDmTkBXMAIAAAAAASRWTsfGOpqdffiOodoqIgBzG/yzFyjR5CfUsIUIWGpgVsACAAAAAAkgCHbCwyX640/0Ni8+MoYxeHUiC+FSU4Mn9jTLYtgZgAAzE5AH0AAAAFZAAgAAAAAH/aZr4EuS0/noQR9rcF8vwoaxnxrwgOsSJ0ys8PkHhGBXMAIAAAAACd7ObGQW7qfddcvyxRTkPuvq/PHu7+6I5dxwS1Lzy5XAVsACAAAAAA3q0eKdV7KeU3pc+CtfypKR7BPxwaf30yu0j9FXeOOboAAzIwAH0AAAAFZAAgAAAAAKvlcpFFNq0oA+urq3w6d80PK1HHHw0H0yVWvU9aHijXBXMAIAAAAADWnAHQ5Fhlcjawki7kWzdqjM2f6IdGJblojrYElWjsZgVsACAAAAAAO0wvY66l24gx8nRxyVGC0QcTztIi81Kx3ndRhuZr6W4AAzIxAH0AAAAFZAAgAAAAAH/2aMezEOddrq+dNOkDrdqf13h2ttOnexZsJxG1G6PNBXMAIAAAAABNtgnibjC4VKy5poYjvdsBBnVvDTF/4mmEAxsXVgZVKgVsACAAAAAAqvadzJFLqQbs8WxgZ2D2X+XnaPSDMLCVVgWxx5jnLcYAAzIyAH0AAAAFZAAgAAAAAF2wZoDL6/V59QqO8vdRZWDpXpkV4h4KOCSn5e7x7nmzBXMAIAAAAADLZBu7LCYjbThaVUqMK14H/elrVOYIKJQCx4C9Yjw37gVsACAAAAAAEh6Vs81jLU204aGpL90fmYTm5i5R8/RT1uIbg6VU3HwAAzIzAH0AAAAFZAAgAAAAAH27yYaLn9zh2CpvaoomUPercSfJRUmBY6XFqmhcXi9QBXMAIAAAAAAUwumVlIYIs9JhDhSj0R0+59psCMsFk94E62VxkPt42QVsACAAAAAAT5x2hCCd2bpmpnyWaxas8nSxTc8e4C9DfKaqr0ABEysAAzI0AH0AAAAFZAAgAAAAALMg2kNAO4AFFs/mW3In04yFeN4AP6Vo0klyUoT06RquBXMAIAAAAAAgGWJbeIdwlpqXCyVIYSs0dt54Rfc8JF4b8uYc+YUj0AVsACAAAAAAWHeWxIkyvXTOWvfZzqtPXjfGaWWKjGSIQENTU3zBCrsAAzI1AH0AAAAFZAAgAAAAALas/i1T2DFCEmrrLEi7O2ngJZyFHialOoedVXS+OjenBXMAIAAAAAA1kK0QxY4REcGxHeMkgumyF7iwlsRFtw9MlbSSoQY7uAVsACAAAAAAUNlpMJZs1p4HfsD4Q4WZ4TBEi6Oc2fX34rzyynqWCdwAAzI2AH0AAAAFZAAgAAAAAP1TejmWg1CEuNSMt6NUgeQ5lT+oBoeyF7d2l5xQrbXWBXMAIAAAAABPX0kj6obggdJShmqtVfueKHplH4ZrXusiwrRDHMOKeQVsACAAAAAAIYOsNwC3DA7fLcOzqdr0bOFdHCfmK8tLwPoaE9uKOosAAzI3AH0AAAAFZAAgAAAAAMrKn+QPa/NxYezNhlOX9nyEkN1kE/gW7EuZkVqYl0b8BXMAIAAAAABUoZMSPUywRGfX2EEencJEKH5x/P9ySUVrhStAwgR/LgVsACAAAAAAMgZFH6lQIIDrgHnFeslv3ld20ynwQjQJt3cAp4GgrFkAAzI4AH0AAAAFZAAgAAAAAMmD1+a+oVbiUZd1HuZqdgtdVsVKwuWAn3/M1B6QGBM3BXMAIAAAAACLyytOYuZ9WEsIrrtJbXUx4QgipbaAbmlJvSZVkGi0CAVsACAAAAAA4v1lSp5H9BB+HYJ4bH43tC8aeuPZMf78Ng1JOhJh190AAzI5AH0AAAAFZAAgAAAAAOVKV7IuFwmYP1qVv8h0NvJmfPICu8yQhzjG7oJdTLDoBXMAIAAAAABL70XLfQLKRsw1deJ2MUvxSWKxpF/Ez73jqtbLvqbuogVsACAAAAAAvfgzIorXxE91dDt4nQxYfntTsx0M8Gzdsao5naQqcRUAAzMwAH0AAAAFZAAgAAAAAKS/1RSAQma+xV9rz04IcdzmavtrBDjOKPM+Z2NEyYfPBXMAIAAAAAAOJDWGORDgfRv8+w5nunh41wXb2hCA0MRzwnLnQtIqPgVsACAAAAAAf42C1+T7xdHEFF83+c2mF5S8PuuL22ogXXELnRAZ4boAAzMxAH0AAAAFZAAgAAAAAFeq8o82uNY1X8cH6OhdTzHNBUnCChsEDs5tm0kPBz3qBXMAIAAAAABaxMBbsaeEj/EDtr8nZfrhhhirBRPJwVamDo5WwbgvTQVsACAAAAAAMbH453A+BYAaDOTo5kdhV1VdND1avNwvshEG/4MIJjQAAzMyAH0AAAAFZAAgAAAAAI8IKIfDrohHh2cjspJHCovqroSr5N3QyVtNzFvT5+FzBXMAIAAAAABXHXteKG0DoOMmECKp6ro1MZNQvXGzqTDdZ0DUc8QfFAVsACAAAAAA/w5s++XYmO+9TWTbtGc3n3ndV4T9JUribIbF4jmDLSMAAzMzAH0AAAAFZAAgAAAAAJkHvm15kIu1OtAiaByj5ieWqzxiu/epK6c/9+KYIrB0BXMAIAAAAACzg5TcyANk0nes/wCJudd1BwlkWWF6zw3nGclq5v3SJQVsACAAAAAAvruXHTT3irPJLyWpI1j/Xwf2FeIE/IV+6Z49pqRzISoAAzM0AH0AAAAFZAAgAAAAAAYSOvEWWuSg1Aym7EssNLR+xsY7e9BcwsX4JKlnSHJcBXMAIAAAAABT48eY3PXVDOjw7JpNjOe1j2JyI3LjDnQoqZ8Je5B2KgVsACAAAAAAU2815RR57TQ9uDg0XjWjBkAKvf8yssxDMzrM4+FqP6AAAzM1AH0AAAAFZAAgAAAAAGQxC9L1e9DfO5XZvX1yvc3hTLtQEdKO9FPMkyg0Y9ZABXMAIAAAAADtmcMNJwdWLxQEArMGZQyzpnu+Z5yMmPAkvgq4eAKwNQVsACAAAAAAJ88zt4Y/Hoqh+zrf6KCOiUwHbOzCxSfp6k/qsZaYGEgAAzM2AH0AAAAFZAAgAAAAADLHK2LNCNRO0pv8n4fAsxwtUqCNnVK8rRgNiQfXpHSdBXMAIAAAAACf16EBIHRKD3SzjRW+LMOl+47QXA3CJhMzlcqyFRW22AVsACAAAAAAMGz4fAOa0EoVv90fUffwLjBrQhHATf+NdlgCR65vujAAAzM3AH0AAAAFZAAgAAAAAHiZJiXKNF8bbukQGsdYkEi95I+FSBHy1I5/hK2uEZruBXMAIAAAAADE+lZBa8HDUJPN+bF6xI9x4N7GF9pj3vBR7y0BcfFhBAVsACAAAAAAGIEN6sfqq30nyxW4dxDgXr/jz5HmvA9T1jx/pKCn4zgAAzM4AH0AAAAFZAAgAAAAAI1oa2OIw5TvhT14tYCGmhanUoYcCZtNbrVbeoMldHNZBXMAIAAAAAAx2nS0Ipblf2XOgBiUOuJFBupBhe7nb6QPLZlA4aMPCgVsACAAAAAA9xu828hugIgo0E3de9dZD+gTpVUGlwtDba+tw/WcbUoAAzM5AH0AAAAFZAAgAAAAABgTWS3Yap7Q59hii/uPPimHWXsr+DUmsqfwt/X73qsOBXMAIAAAAACKK05liW5KrmEAvtpCB1WUltruzUylDDpjea//UlWoOAVsACAAAAAAcgN4P/wakJ5aJK5c1bvJBqpVGND221dli2YicPFfuAYAAzQwAH0AAAAFZAAgAAAAABOAnBPXDp6i9TISQXvcNKwGDLepZTu3cKrB4vKnSCjBBXMAIAAAAADjjzZO7UowAAvpwyG8BNOVqLCccMFk3aDK4unUeft5ywVsACAAAAAA4zkCd4k9gvfXoD1C7vwTjNcdVJwEARh8h/cxZ4PNMfgAAzQxAH0AAAAFZAAgAAAAAHN8hyvT1lYrAsdiV5GBdd5jhtrAYE/KnSjw2Ka9hjz9BXMAIAAAAAD794JK7EeXBs+D7yOVK7nWF8SbZ/7U8gZ7nnT9JFNwTAVsACAAAAAAg8Wt1HO3NhByq2ggux2a4Lo6Gryr24rEFIqh2acrwWMAAzQyAH0AAAAFZAAgAAAAAO93bPrq8bsnp1AtNd9ETnXIz0lH/2HYN/vuw9wA3fyFBXMAIAAAAABHlls5fbaF2oAGqptC481XQ4eYxInTC29aElfmVZgDUgVsACAAAAAANoQXEWpXJpgrSNK/cKi/m7oYhuSRlp1IZBF0bqTEATcAAzQzAH0AAAAFZAAgAAAAAL1YsAZm1SA0ztU6ySIrQgCCA74V6rr0/4iIygCcaJL6BXMAIAAAAADTXWTHWovGmUR1Zg9l/Aqq9H5mOCJQQrb/Dfae7e3wKAVsACAAAAAA5dunyJK6/SVfDD0t9QlNBcFqoZnf9legRjHaLSKAoQMAAzQ0AH0AAAAFZAAgAAAAAEoFAeHk0RZ9kD+cJRD3j7PcE5gzWKnyBrF1I/MDNp5mBXMAIAAAAACgHtc2hMBRSZjKw8RAdDHK+Pi1HeyjiBuAslGVNcW5tAVsACAAAAAAXzBLfq+GxRtX4Wa9fazA49DBLG6AjZm2XODStJKH8D0AAzQ1AH0AAAAFZAAgAAAAAAW+7DmSN/LX+/0uBVJDHIc2dhxAGz4+ehyyz8fAnNGoBXMAIAAAAAA6Ilw42EvvfLJ3Eq8Afd+FjPoPcQutZO6ltmCLEr8kxQVsACAAAAAAbbZalyo07BbFjPFlYmbmv0z023eT9eLkHqeVUnfUAUAAAzQ2AH0AAAAFZAAgAAAAANBdV7M7kuYO3EMoQItAbXv4t2cIhfaT9V6+s4cg9djlBXMAIAAAAABvz4MIvZWxxrcJCL5qxLfFhXiUYB1OLHdKEjco94SgDgVsACAAAAAAK2GVGvyPIKolF/ECcmfmkVcf1/IZNcaTv96N92yGrkEAAzQ3AH0AAAAFZAAgAAAAAMoAoiAn1kc79j5oPZtlMWHMhhgwNhLUnvqkqIFvcH1NBXMAIAAAAADcJTW7WiCyW0Z9YDUYwppXhLj4Ac1povpJvcAq+i48MQVsACAAAAAAIGxGDzoeB3PTmudl4+j6piQB++e33EEzuzAiXcqGxvUAAzQ4AH0AAAAFZAAgAAAAACI3j5QP7dWHpcT6WO/OhsWwRJNASBYqIBDNzW8IorEyBXMAIAAAAABxUpBSjXwCKDdGP9hYU+RvyR+96kChfvyyRC4jZmztqAVsACAAAAAAvBCHguWswb4X0xdcAryCvZgQuthXzt7597bJ5VxAMdgAAzQ5AH0AAAAFZAAgAAAAAKsbycEuQSeNrF8Qnxqw3x3og8JmQabwGqnDbqzFRVrrBXMAIAAAAACno/3ef2JZJS93SVVzmOZSN+jjJHT8s0XYq2M46d2sLAVsACAAAAAAAt5zLJG+/j4K8rnkFtAn8IvdUVNefe6utJ3rdzgwudIAAzUwAH0AAAAFZAAgAAAAAPXIcoO8TiULqlxzb74NFg+I8kWX5uXIDUPnh2DobIoMBXMAIAAAAADR6/drkdTpnr9g1XNvKDwtBRBdKn7c2c4ZNUVK5CThdQVsACAAAAAAJqOA1c6KVog3F4Hb/GfDb3jCxXDRTqpXWSbMH4ePIJsAAzUxAH0AAAAFZAAgAAAAAEa03ZOJmfHT6/nVadvIw71jVxEuIloyvxXraYEW7u7pBXMAIAAAAADzRlBJK75FLiKjz3djqcgjCLo/e3yntI3MnPS48OORhgVsACAAAAAAnQhx4Rnyj081XrLRLD5NLpWmRWCsd0M9Hl7Jl19R0h8AAzUyAH0AAAAFZAAgAAAAAKx8NLSZUU04pSSGmHa5fh2oLHsEN5mmNMNHL95/tuC9BXMAIAAAAAA59hcXVaN3MNdHoo11OcH1aPRzHCwpVjO9mGfMz4xh3QVsACAAAAAAYIPdjV2XbPj7dBeHPwnwhVU7zMuJ+xtMUW5mIOYtmdAAAzUzAH0AAAAFZAAgAAAAAHNKAUxUqBFNS9Ea9NgCZoXMWgwhP4x0/OvoaPRWMquXBXMAIAAAAABUZ551mnP4ZjX+PXU9ttomzuOpo427MVynpkyq+nsYCQVsACAAAAAALnVK5p2tTTeZEh1zYt4iqKIQT9Z0si//Hy1L85oF+5IAAzU0AH0AAAAFZAAgAAAAALfGXDlyDVcGaqtyHkLT0qpuRhJQLgCxtznazhFtuyn/BXMAIAAAAABipxlXDq14C62pXhwAeen5+syA+/C6bN4rtZYcO4zKwAVsACAAAAAAXUf0pzUq0NhLYagWDap4uEiwq5rLpcx29rWbt1NYMsMAAzU1AH0AAAAFZAAgAAAAANoEr8sheJjg4UCfBkuUzarU9NFoy1xwbXjs5ifVDeA9BXMAIAAAAABPoyTf6M+xeZVGES4aNzVlq7LgjqZXJ/QunjYVusGUEAVsACAAAAAA1hA2gMeZZPUNytk9K+lB1RCqWRudRr7GtadJlExJf8oAAzU2AH0AAAAFZAAgAAAAAKvDiK+xjlBe1uQ3SZTNQl2lClIIvpP/5CHwY6Kb3WlgBXMAIAAAAAANnxImq5MFbWaRBHdJp+yD09bVlcFtiFDYsy1eDZj+iQVsACAAAAAAWtsyO+FxMPSIezwsV1TJD8ZrXAdRnQM6DJ+f+1V3qEkAAzU3AH0AAAAFZAAgAAAAAF49IlFH9RmSUSvUQpEPUedEksrQUcjsOv44nMkwXhjzBXMAIAAAAADJtWGbk0bZzmk20obz+mNsp86UCu/nLLlbg7ppxYn7PgVsACAAAAAA3k0Tj/XgPQtcYijH8cIlQoe/VXf15q1nrZNmg7yWYEgAAzU4AH0AAAAFZAAgAAAAAOuSJyuvz50lp3BzXlFKnq62QkN2quNU1Gq1IDsnFoJCBXMAIAAAAAAqavH1d93XV3IzshWlMnzznucadBF0ND092/2ApI1AcAVsACAAAAAAzUrK4kpoKCmcpdZlZNI13fddjdoAseVe67jaX1LobIIAAzU5AH0AAAAFZAAgAAAAALtgC4Whb4ZdkCiI30zY6fwlsxSa7lEaOAU3SfUXr02XBXMAIAAAAACgdZ6U1ZVgUaZZwbIaCdlANpCw6TZV0bwg3DS1NC/mnAVsACAAAAAAzI49hdpp0PbO7S2KexISxC16sE73EUAEyuqUFAC/J48AAzYwAH0AAAAFZAAgAAAAAF6PfplcGp6vek1ThwenMHVkbZgrc/dHgdsgx1VdPqZ5BXMAIAAAAACha3qhWkqmuwJSEXPozDO8y1ZdRLyzt9Crt2vjGnT7AAVsACAAAAAA7nvcU59+LwxGupSF21jAeAE0x7JE94tjRkJfgM1yKU8AAzYxAH0AAAAFZAAgAAAAAKoLEhLvLjKc7lhOJfx+VrGJCx9tXlOSa9bxQzGR6rfbBXMAIAAAAAAIDK5wNnjRMBzET7x/KAMExL/zi1IumJM92XTgXfoPoAVsACAAAAAAFkUYWFwNr815dEdFqp+TiIozDcq5IBNVkyMoDjharDQAAzYyAH0AAAAFZAAgAAAAADoQv6lutRmh5scQFvIW6K5JBquLxszuygM1tzBiGknIBXMAIAAAAADAD+JjW7FoBQ76/rsECmmcL76bmyfXpUU/awqIsZdO+wVsACAAAAAAPFHdLw3jssmEXsgtvl/RBNaUCRA1kgSwsofG364VOvQAAzYzAH0AAAAFZAAgAAAAAJNHUGAgn56KekghO19d11nai3lAh0JAlWfeP+6w4lJBBXMAIAAAAAD9XGJlvz59msJvA6St9fKW9CG4JoHV61rlWWnkdBRLzwVsACAAAAAAxwP/X/InJJHmrjznvahIMgj6pQR30B62UtHCthSjrP0AAzY0AH0AAAAFZAAgAAAAAHgYoMGjEE6fAlAhICv0+doHcVX8CmMVxyq7+jlyGrvmBXMAIAAAAAC/5MQZgTHuIr/O5Z3mXPvqrom5JTQ8IeSpQGhO9sB+8gVsACAAAAAAuPSXVmJUAUpTQg/A9Bu1hYczZF58KEhVofakygbsvJQAAzY1AH0AAAAFZAAgAAAAANpIljbxHOM7pydY877gpRQvYY2TGK7igqgGsavqGPBABXMAIAAAAAAqHyEu9gpurPOulApPnr0x9wrygY/7mXe9rAC+tPK80wVsACAAAAAA7gkPzNsS3gCxdFBWbSW9tkBjoR5ib+saDvpGSB3A3ogAAzY2AH0AAAAFZAAgAAAAAGR+gEaZTeGNgG9BuM1bX2R9ed4FCxBA9F9QvdQDAjZwBXMAIAAAAABSkrYFQ6pf8MZ1flgmeIRkxaSh/Eep4Btdx4QYnGGnwAVsACAAAAAApRovMiV00hm/pEcT4XBsyPNw0eo8RLAX/fuabjdU+uwAAzY3AH0AAAAFZAAgAAAAAFNprhQ3ZwIcYbuzLolAT5n/vc14P9kUUQComDu6eFyKBXMAIAAAAAAcx9z9pk32YbPV/sfPZl9ALIEVsqoLXgqWLVK/tP+heAVsACAAAAAA/qxvuvJbAHwwhfrPVpmCFzNvg2cU/NXaWgqgYUZpgXwAAzY4AH0AAAAFZAAgAAAAADgyPqQdqQrgfmJjRFAILTHzXbdw5kpKyfeoEcy6YYG/BXMAIAAAAAAE+3XsBQ8VAxAkN81au+f3FDeCD/s7KoZD+fnM1MJSSAVsACAAAAAAhRnjrXecwV0yeCWKJ5J/x12Xx4qVJahsCEVHB/1U2rcAAzY5AH0AAAAFZAAgAAAAAI0CT7JNngTCTUSei1Arw7eHWCD0jumv2rb7imjWIlWABXMAIAAAAABSP8t6ya0SyCphXMwnru6ZUDXWElN0NfBvEOhDvW9bJQVsACAAAAAAGWeGmBNDRaMtvm7Rv+8TJ2sJ4WNXKcp3tqpv5Se9Ut4AAzcwAH0AAAAFZAAgAAAAAD/FIrGYFDjyYmVb7oTMVwweWP7A6F9LnyIuNO4MjBnXBXMAIAAAAACIZgJCQRZu7NhuNMyOqCn1tf+DfU1qm10TPCfj5JYV3wVsACAAAAAA5hmY4ptuNxULGf87SUFXQWGAONsL9U29duh8xqsHtxoAAzcxAH0AAAAFZAAgAAAAAHIkVuNDkSS1cHIThKc/O0r2/ubaABTOi8Q1r/dvBAsEBXMAIAAAAADdHYqchEiJLM340c3Q4vJABmmth3+MKzwLYlsG6GS7sQVsACAAAAAADa+KP/pdTiG22l+ZWd30P1iHjnBF4zSNRdFm0oEK82kAAzcyAH0AAAAFZAAgAAAAAJmoDILNhC6kn3masElfnjIjP1VjsjRavGk1gSUIjh1NBXMAIAAAAAD97Ilvp3XF8T6MmVVcxMPcdL80RgQ09UoC6PnoOvZ1IQVsACAAAAAA2RK3Xng6v8kpvfVW9tkVXjpE+BSnx9/+Fw85Evs+kUEAAzczAH0AAAAFZAAgAAAAAI5bm3YO0Xgf0VT+qjVTTfvckecM3Cwqj7DTKZXf8/NXBXMAIAAAAAD/m+h8fBhWaHm6Ykuz0WX1xL4Eme3ErLObyEVJf8NCywVsACAAAAAAfb1VZZCqs2ivYbRzX4p5CtaCkKW+g20Pr57FWXzEZi8AAzc0AH0AAAAFZAAgAAAAANqo4+p6qdtCzcB4BX1wQ6llU7eFBnuu4MtZwp4B6mDlBXMAIAAAAAAGiz+VaukMZ+6IH4jtn4KWWdKK4/W+O+gRioQDrfzpMgVsACAAAAAAG4YYkTp80EKo59mlHExDodRQFR7njhR5dmISwUJ6ukAAAzc1AH0AAAAFZAAgAAAAAPrFXmHP2Y4YAm7b/aqsdn/DPoDkv7B8egWkfe23XsM1BXMAIAAAAAAGhwpKAr7skeqHm3oseSbO7qKNhmYsuUrECBxJ5k+D2AVsACAAAAAAAqPQi9luYAu3GrFCEsVjd9z2zIDcp6SPTR2w6KQEr+IAAzc2AH0AAAAFZAAgAAAAABzjYxwAjXxXc0Uxv18rH8I3my0Aguow0kTwKyxbrm+cBXMAIAAAAADVbqJVr6IdokuhXkEtXF0C2gINLiAjMVN20lE20Vmp2QVsACAAAAAAD7K1Fx4gFaaizkIUrf+EGXQeG7QX1jadhGc6Ji471H8AAzc3AH0AAAAFZAAgAAAAAFMm2feF2fFCm/UC6AfIyepX/xJDSmnnolQIBnHcPmb5BXMAIAAAAABLI11kFrQoaNVZFmq/38aRNImPOjdJh0Lo6irI8M/AaAVsACAAAAAAOWul0oVqJ9CejD2RqphhTC98DJeRQy5EwbNerU2+4l8AAzc4AH0AAAAFZAAgAAAAAJvXB3KyNiNtQko4SSzo/9b2qmM2zU9CQTTDfLSBWMgRBXMAIAAAAAAvjuVP7KsLRDeqVqRziTKpBrjVyqKiIbO9Gw8Wl2wFTAVsACAAAAAADlE+oc1ins+paNcaOZJhBlKlObDJ4VQORWjFYocM4LgAAzc5AH0AAAAFZAAgAAAAAPGdcxDiid8z8XYnfdDivNMYVPgBKdGOUw6UStU+48CdBXMAIAAAAAARj6g1Ap0eEfuCZ4X2TsEw+Djrhto3fA5nLwPaY0vCTgVsACAAAAAAoHqiwGOUkBu8SX5U1yHho+UIFdSN2MdQN5s6bQ0EsJYAAzgwAH0AAAAFZAAgAAAAAP5rGPrYGt3aKob5f/ldP0qrW7bmWvqnKY4QwdDWz400BXMAIAAAAADTQkW2ymaaf/bhteOOGmSrIR97bAnJx+yN3yMj1bTeewVsACAAAAAADyQnHGH2gF4w4L8axUsSTf6Ubk7L5/eoFOJk12MtZAoAAzgxAH0AAAAFZAAgAAAAAAlz6wJze5UkIxKpJOZFGCOf3v2KByWyI6NB6JM9wNcBBXMAIAAAAABUC7P/neUIHHoZtq0jFVBHY75tSFYr1Y5S16YN5XxC1QVsACAAAAAAgvxRbXDisNnLY3pfsjDdnFLtkvYUC4lhA68eBXc7KAwAAzgyAH0AAAAFZAAgAAAAAFJ8AtHcjia/9Y5pLEc3qVgH5xKiXw12G9Kn2A1EY8McBXMAIAAAAAAxe7Bdw7eUSBk/oAawa7uicTEDgXLymRNhBy1LAxhDvwVsACAAAAAAxKPaIBKVx3jTA+R/el7P7AZ7efrmTGjJs3Hj/YdMddwAAzgzAH0AAAAFZAAgAAAAAO8uwQUaKFb6vqR3Sv3Wn4QAonC2exOC9lGG1juqP5DtBXMAIAAAAABZf1KyJgQg8/Rf5c02DgDK2aQu0rNCOvaL60ohDHyY+gVsACAAAAAAqyEjfKC8lYoIfoXYHUqHZPoaA6EK5BAZy5dxXZmay4kAAzg0AH0AAAAFZAAgAAAAAE8YtqyRsGCeiR6hhiyisR/hccmK4nZqIMzO4lUBmEFzBXMAIAAAAAC1UYOSKqAeG1UJiKjWFVskRhuFKpj9Ezy+lICZvFlN5AVsACAAAAAA6Ct9nNMKyRazn1OKnRKagm746CGu+jyhbL1qJnZxGi0AAzg1AH0AAAAFZAAgAAAAAPhCrMausDx1QUIEqp9rUdRKyM6a9AAx7jQ3ILIu8wNIBXMAIAAAAACmH8lotGCiF2q9VQxhsS+7LAZv79VUAsOUALaGxE/EpAVsACAAAAAAnc1xCKfdvbUEc8F7XZqlNn1C+hZTtC0I9I3LL06iaNkAAzg2AH0AAAAFZAAgAAAAAOBi/GAYFcstMSJPgp3VkMiuuUUCrZytvqYaU8dwm8v2BXMAIAAAAACEZSZVyD3pKzGlbdwlYmWQhHHTV5SnNLknl2Gw8IaUTQVsACAAAAAAfsLZsEDcWSuNsIo/TD1ReyQW75HPMgmuKZuWFOLKRLoAAzg3AH0AAAAFZAAgAAAAAIQuup+YGfH3mflzWopN8J1X8o8a0d9CSGIvrA5HOzraBXMAIAAAAADYvNLURXsC2ITMqK14LABQBI+hZZ5wNf24JMcKLW+84AVsACAAAAAACzfjbTBH7IwDU91OqLAz94RFkoqBOkzKAqQb55gT4/MAAzg4AH0AAAAFZAAgAAAAAKsh0ADyOnVocFrOrf6MpTrNvAj8iaiE923DPryu124gBXMAIAAAAADg24a8NVE1GyScc6tmnTbmu5ulzO+896fE92lN08MeswVsACAAAAAAaPxcOIxnU7But88/yadOuDJDMcCywwrRitaxMODT4msAAzg5AH0AAAAFZAAgAAAAAKkVC2Y6HtRmv72tDnPUSjJBvse7SxLqnr09/Uuj9sVVBXMAIAAAAABYNFUkH7ylPMN+Bc3HWX1e0flGYNbtJNCY9SltJCW/UAVsACAAAAAAZYK/f9H4OeihmpiFMH7Wm7uLvs2s92zNA8wyrNZTsuMAAzkwAH0AAAAFZAAgAAAAADDggcwcb/Yn1Kk39sOHsv7BO/MfP3m/AJzjGH506Wf9BXMAIAAAAAAYZIsdjICS0+BDyRUPnrSAZfPrwtuMaEDEn0/ijLNQmAVsACAAAAAAGPnYVvo2ulO9z4LGd/69NAklfIcZqZvFX2KK0s+FcTUAAzkxAH0AAAAFZAAgAAAAAEWY7dEUOJBgjOoWVht1wLehsWAzB3rSOBtLgTuM2HC8BXMAIAAAAAAAoswiHRROurjwUW8u8D5EUT+67yvrgpB/j6PzBDAfVwVsACAAAAAA6NhRTYFL/Sz4tao7vpPjLNgAJ0FX6P/IyMW65qT6YsMAAzkyAH0AAAAFZAAgAAAAAPZaapeAUUFPA7JTCMOWHJa9lnPFh0/gXfAPjA1ezm4ZBXMAIAAAAACmJvLY2nivw7/b3DOKH/X7bBXjJwoowqb1GtEFO3OYgAVsACAAAAAA/JcUoyKacCB1NfmH8vYqC1f7rd13KShrQqV2r9QBP44AAzkzAH0AAAAFZAAgAAAAAK00u6jadxCZAiA+fTsPVDsnW5p5LCr4+kZZZOTDuZlfBXMAIAAAAAAote4zTEYMDgaaQbAdN8Dzv93ljPLdGjJzvnRn3KXgtQVsACAAAAAAxXd9Mh6R3mnJy8m7UfqMKi6oD5DlZpkaOz6bEjMOdiwAAzk0AH0AAAAFZAAgAAAAAFbgabdyymiEVYYwtJSWa7lfl/oYuj/SukzJeDOR6wPVBXMAIAAAAADAFGFjS1vPbN6mQEhkDYTD6V2V23Ys9gUEUMGNvMPkaAVsACAAAAAAL/D5Sze/ZoEanZLK0IeEkhgVkxEjMWVCfmJaD3a8uNIAAzk1AH0AAAAFZAAgAAAAABNMR6UBv2E627CqLtQ/eDYx7OEwQ7JrR4mSHFa1N8tLBXMAIAAAAAAxH4gucI4UmNVB7625C6hFSVCuIpJO3lusJlPuL8H5EQVsACAAAAAAVLHNg0OUVqZ7WGOP53BkTap9FOw9dr1P4J8HxqFqU04AAzk2AH0AAAAFZAAgAAAAAG8cd6WBneNunlqrQ2EmNf35W7OGObGq9WL4ePX+LUDmBXMAIAAAAAAjJ2+sX87NSis9hBsgb1QprVRnO7Bf+GObCGoUqyPE4wVsACAAAAAAs9c9SM49/pWmyUQKslpt3RTMBNSRppfNO0JBvUqHPg0AAzk3AH0AAAAFZAAgAAAAAFWOUGkUpy8yf6gB3dio/aOfRKh7XuhvsUj48iESFJrGBXMAIAAAAAAY7sCDMcrUXvNuL6dO0m11WyijzXZvPIcOKob6IpC4PQVsACAAAAAAJOP+EHz6awDb1qK2bZQ3kTV7wsj5Daj/IGAWh4g7omAAAzk4AH0AAAAFZAAgAAAAAGUrIdKxOihwNmo6B+aG+Ag1qa0+iqdksHOjQj+Oy9bZBXMAIAAAAABwa5dbI2KmzBDNBTQBEkjZv4sPaeRkRNejcjdVymRFKQVsACAAAAAA4ml/nm0gJNTcJ4vuD+T2Qfq2fQZlibJp/j6MOGDrbHMAAzk5AH0AAAAFZAAgAAAAAOx89xV/hRk64/CkM9N2EMK6aldII0c8smdcsZ46NbP8BXMAIAAAAADBF6tfQ+7q9kTuLyuyrSnDgmrdmrXkdhl980i1KHuGHgVsACAAAAAACUqiFqHZdGbwAA+hN0YUE5zFg+H+dabIB4dj5/75W/YAAzEwMAB9AAAABWQAIAAAAADJDdC9aEFl4Y8J/awHbnXGHjfP+VXQilPHJg7ewaJI7AVzACAAAAAAE+tqRl6EcBMXvbr4GDiNIYObTsYpa1n6BJk9EjIJVicFbAAgAAAAAJVc+HYYqa0m1Hq6OiRX8c0iRnJYOt6AJAJoG0sG3GMSAAMxMDEAfQAAAAVkACAAAAAA3F9rjEKhpoHuTULVGgfUsGGwJs3bISrXkFP1v6KoQLgFcwAgAAAAAIBf0tXw96Z/Ds0XSIHX/zk3MzUR/7WZR/J6FpxRWChtBWwAIAAAAABWrjGlvKYuTS2s8L9rYy8Hf0juFGJfwQmxVIjkTmFIGQADMTAyAH0AAAAFZAAgAAAAAOYIYoWkX7dGuyKfi3XssUlc7u/gWzqrR9KMkikKVdmSBXMAIAAAAABVF2OYjRTGi9Tw8XCAwZWLpX35Yl271TlNWp6N/nROhAVsACAAAAAA0nWwYzXQ1+EkDvnGq+SMlq20z+j32Su+i/A95SggPb4AAzEwMwB9AAAABWQAIAAAAACMtPm12YtdEAvqu6Eji1yuRXnu1RJP6h0l7pH3lSH4MwVzACAAAAAAENyCFfyUAh1veQBGx+cxiB7Sasrj41jzCGflZkB5cRMFbAAgAAAAAKdI2LMqISr/T5vuJPg6ZRBm5fVi2aQCc4ra3A4+AjbDAAMxMDQAfQAAAAVkACAAAAAAvlI4lDcs6GB1cnm/Tzo014CXWqidCdyE5t2lknWQd4QFcwAgAAAAAD60SpNc4O2KT7J0llKdSpcX1/Xxs97N715a1HsTFkmBBWwAIAAAAABuuRkJWAH1CynggBt1/5sPh9PoGiqTlS24D/OE2uHXLQADMTA1AH0AAAAFZAAgAAAAAKl8zcHJRDjSjJeV/WvMxulW1zrTFtaeBy/aKKhadc6UBXMAIAAAAADBdWQl5SBIvtZZLIHszePwkO14W1mQ0izUk2Ov21cPNAVsACAAAAAAHErCYycpqiIcCZHdmPL1hi+ovLQk4TAvENpfLdTRamQAAzEwNgB9AAAABWQAIAAAAABb6LXDWqCp1beQgQjj8I3sRTtFhlrmiBi+h/+ikmrvugVzACAAAAAA9stpgTecT7uTyaGNs3K9Bp0A7R0QaIAOfscyMXHBPX8FbAAgAAAAAHUt+McyXrJ1H8SwnHNVO181Ki8vDAM1f7XI26mg95ZDAAMxMDcAfQAAAAVkACAAAAAA97NTT+81PhDhgptNtp4epzA0tP4iNb9j1AWkiiiKGM8FcwAgAAAAAKPbHg7ise16vxmdPCzksA/2Mn/qST0L9Xe8vnQugVkcBWwAIAAAAABB0EMXfvju4JU/mUH/OvxWbPEl9NJkcEp4iCbkXI41fAADMTA4AH0AAAAFZAAgAAAAAMqpayM2XotEFmm0gwQd9rIzApy0X+7HfOhNk6VU7F5lBXMAIAAAAACJR9+q5T9qFHXFNgGbZnPubG8rkO6cwWhzITQTmd6VgwVsACAAAAAAOZLQ6o7e4mVfDzbpQioa4d3RoTvqwgnbmc5Qh2wsZuoAAzEwOQB9AAAABWQAIAAAAADQnslvt6Hm2kJPmqsTVYQHE/wWeZ4bE1XSkt7TKy0r1gVzACAAAAAA8URTA4ZMrhHPvlp53TH6FDCzS+0+61qHm5XK6UiOrKEFbAAgAAAAAHQbgTCdZcbdA0avaTmZXUKnIS7Nwf1tNrcXDCw+PdBRAAMxMTAAfQAAAAVkACAAAAAAhujlgFPFczsdCGXtQ/002Ck8YWQHHzvWvUHrkbjv4rwFcwAgAAAAALbV0lLGcSGfE7mDM3n/fgEvi+ifjl7WZ5b3aqjDNvx9BWwAIAAAAACbceTZy8E3QA1pHmPN5kTlOx3EO8kJM5PUjTVftw1VpgADMTExAH0AAAAFZAAgAAAAABm/6pF96j26Jm7z5KkY1y33zcAEXLx2n0DwC03bs/ixBXMAIAAAAAD01OMvTZI/mqMgxIhA5nLs068mW+GKl3OW3ilf2D8+LgVsACAAAAAAaLvJDrqBESTNZSdcXsd+8GXPl8ZkUsGpeYuyYVv/kygAAzExMgB9AAAABWQAIAAAAACfw9/te4GkHZAapC9sDMHHHZgmlTrccyJDPFciOMSOcwVzACAAAAAAIIC1ZpHObvmMwUfqDRPl4C1aeuHwujM1G/yJbvybMNAFbAAgAAAAAAs9x1SnVpMfNv5Bm1aXGwHmbbI9keWa9HRD35XuCBK5AAMxMTMAfQAAAAVkACAAAAAAkxHJRbnShpPOylLoDdNShfILeA1hChKFQY9qQyZ5VmsFcwAgAAAAAKidrY+rC3hTY+YWu2a7fuMH2RD/XaiTIBW1hrxNCQOJBWwAIAAAAACW0kkqMIzIFMn7g+R0MI8l15fr3k/w/mHtY5n6SYTEwAADMTE0AH0AAAAFZAAgAAAAAByuYl8dBvfaZ0LO/81JW4hYypeNmvLMaxsIdvqMPrWoBXMAIAAAAABNddwobOUJzm9HOUD8BMZJqkNCUCqstHZkC76FIdNg9AVsACAAAAAAQQOkIQtkyNavqCnhQbNg3HfqrJdsAGaoxSJePJl1qXsAAzExNQB9AAAABWQAIAAAAABxMy7X5hf7AXGDz3Y/POu1ZpkMlNcSvSP92NOO/Gs7wAVzACAAAAAAHJshWo2T5wU2zvqCyJzcJQKQaHFHpCpMc9oWBXkpUPoFbAAgAAAAAGeiJKzlUXAvL0gOlW+Hz1mSa2HsV4RGmyLmCHlzbAkoAAMxMTYAfQAAAAVkACAAAAAAlqbslixl7Zw3bRlibZbe/WmKw23k8uKeIzPKYEtbIy0FcwAgAAAAAHEKwpUxkxOfef5HYvulXPmdbzTivwdwrSYIHDeNRcpcBWwAIAAAAADuPckac21Hrg/h0kt5ShJwVEZ9rx6SOHd2+HDjqxEWTQADMTE3AH0AAAAFZAAgAAAAAMXrXx0saZ+5gORmwM2FLuZG6iuO2YS+1IGPoAtDKoKBBXMAIAAAAADIQsxCr8CfFKaBcx8kIeSywnGh7JHjKRJ9vJd9x79y7wVsACAAAAAAcvBV+SykDYhmRFyVYwFYB9oBKBSHr55Jdz2cXeowsUQAAzExOAB9AAAABWQAIAAAAAAm83FA9yDUpwkbKTihe7m53u+DivS9BU2b4vQMtCVQ2AVzACAAAAAAz3m1UB/AbZPa4QSKFDnUgHaT78+6iGOFAtouiBorEgEFbAAgAAAAAIgbpyYtJj5513Z5XYqviH/HXG/5+mqR52iBbfqMmDtZAAMxMTkAfQAAAAVkACAAAAAAJRzYK0PUwr9RPG2/7yID0WgcTJPB2Xjccp5LAPDYunkFcwAgAAAAAIIh24h3DrltAzNFhF+MEmPrZtzr1PhCofhChZqfCW+jBWwAIAAAAAAzRNXtL5o9VXMk5D5ylI0odPDJDSZZry1wfN+TedH70gADMTIwAH0AAAAFZAAgAAAAAHSaHWs/dnmI9sc7nB50VB2Bzs0kHapMHCQdyVEYY30TBXMAIAAAAACkV22lhEjWv/9/DubfHBAcwJggKI5mIbSK5L2nyqloqQVsACAAAAAAS19m7DccQxgryOsBJ3GsCs37yfQqNi1G+S6fCXpEhn4AAzEyMQB9AAAABWQAIAAAAAAC/I4TQRtCl12YZmdGz17X4GqSQgfwCPgRBwdHmdwu+QVzACAAAAAAx8f3z2ut/RAZhleari4vCEE+tNIn4ikjoUwzitfQ588FbAAgAAAAAJci0w1ZB8W2spJQ+kMpod6HSCtSR2jrabOH+B0fj3A4AAMxMjIAfQAAAAVkACAAAAAADGB5yU2XT0fse/MPWgvBvZikVxrl5pf3S5K1hceKWooFcwAgAAAAAIxTmlLHMjNaVDEfJbXvRez0SEPWFREBJCT6qTHsrljoBWwAIAAAAAAlswzAl81+0DteibwHD+CG5mZJrfHXa9NnEFRtXybzzwADMTIzAH0AAAAFZAAgAAAAABmO7QD9vxWMmFjIHz13lyOeV6vHT6mYCsWxF7hb/yOjBXMAIAAAAACT9lmgkiqzuWG24afuzYiCeK9gmJqacmxAruIukd0xEAVsACAAAAAAZa0/FI/GkZR7CtX18Xg9Tn9zfxkD0UoaSt+pIO5t1t4AAzEyNAB9AAAABWQAIAAAAAAfPUoy7QyZKhIIURso+mkP9qr1izbjETqF5s22GwjCjAVzACAAAAAAvLMsIDQ/go4VUxeh50UHmsvMvfx51cwyONnRD2odvC0FbAAgAAAAAKMb+1CodEalAFnDrEL1Ndt8ztamZ+9134m9Kp3GQgd+AAMxMjUAfQAAAAVkACAAAAAAE3ZqUar0Bq2zWbARE0bAv98jBlK9UJ73/xcwdMWWlSkFcwAgAAAAAK4M+MmC+9sFiFsumMyJZQKxWmmJiuG9H7IzKw083xxkBWwAIAAAAAAqkAONzhvMhkyL1D/6h7QQxEkdhC3p2WjXH+VGq5qCqQADMTI2AH0AAAAFZAAgAAAAAMo8FJiOq63cAmyk2O7eI7GcbQh/1j4RrMTqly3rexftBXMAIAAAAADjVmpd0WiRGTw/gAqEgGolt2EI7Csv14vKdmYoMD0aAgVsACAAAAAA07XQBzBUQMNw7F2/YxJjZNuPVpHTTgbLd1oGk77+bygAAzEyNwB9AAAABWQAIAAAAACu5IGaIx7A3Jvly/kzlCsSA4s3iJwuIl8jEdRH0k93NwVzACAAAAAA9NRUyxYE+t0Xyosyt6vIfMFW/vBoYg6sR+jBNs4JAxIFbAAgAAAAAAzyZ91dx+0oMlOVAjRGiMrPySikY/U9eMEB4WJb3uWtAAMxMjgAfQAAAAVkACAAAAAALkRy0GJInXYLA+cgjs6Myb0a+Gu9hgXhHvhLNoGWfckFcwAgAAAAANbALyt9zCSvwnLaWCd2/y2eoB7qkWTvv1Ldu8r40JPuBWwAIAAAAAD4Fl5bV5sz4isIE9bX+lmAp+aAKaZgVYVZeVfrItkCZAADMTI5AH0AAAAFZAAgAAAAAGoUK/DSWhT8LZhszSUqDbTrp8cSA7rdqmADKL+MILtTBXMAIAAAAABHnEE9bVa6lvhfhEMkkV2kzSSxH/sMW/FIJuw3CzWs6wVsACAAAAAAanavcBdqZxgRGKvEK95wTmeL1K1CeDSXZsXUAs81uOgAAzEzMAB9AAAABWQAIAAAAAC922ZDQE3h2fQKibGMZ9hV0WNlmrPYYSdtaSyYxsWYqgVzACAAAAAAagMovciKK6WVjIc2cCj8nK5O/gVOFFVeVAJpRp89tmQFbAAgAAAAAKcTFfPQzaFiAtSFhqbN02sCE1BKWJSrRfGN5L6oZwzkAAMxMzEAfQAAAAVkACAAAAAAtK+JqX3K/z2txjAU15DgX4y90DS2YLfIJFolCOkJJJwFcwAgAAAAAMnR5V7gfX7MNqqUdL5AkWlkhyFXaBRVNej+Rcn8lrQkBWwAIAAAAAA2cDNRXZuiC241TGRvdFyctJnrNcdbZOP9zHio81tkngADMTMyAH0AAAAFZAAgAAAAAAeGrIMK/bac6kPczxbvRYqKMkcpeI2FjdMpD91FDWIvBXMAIAAAAAAix62z1LeS8yvSXCl5gHSIomjyx76fF3S1lp9k900hygVsACAAAAAAiYwzf2m71aWFD5ajcXyW2JX2EzQOkBroTGMg29nLPYIAAzEzMwB9AAAABWQAIAAAAACphf298InM0Us4HT8o1W1MGw0D/02vd7Jh+U0h7qaFaQVzACAAAAAAFXtk7YpqsOJxsqGWSIL+YcBE96G3Zz9D31gPqDW94y8FbAAgAAAAAAOrS1KVA94rjB1jZ1pPocpCeBG+B14RzWoHqVDpp7JbAAMxMzQAfQAAAAVkACAAAAAATLDS2cuDVM3yDMuWNgk2iGKBTzPpfJMbvxVOSY39ZfcFcwAgAAAAAPT5wRi2cLHIUflXzm6EQB/m7xdThP80ir1VV/JBBqvxBWwAIAAAAAB9lEtZS0aXCFbCtSbhnis27S5IPcfWGygHW8AHn3QqzwADMTM1AH0AAAAFZAAgAAAAAJNjExiZVX7jfFGfYpQu16qxLN0YPqVU/5CQ/Y67YSinBXMAIAAAAABMpm2+6KrkRUlXzQoMPHrQmIO6dkQz66tYdfTeA3dKqQVsACAAAAAAFXobHiMLvNZuEPr8jtewCX2J93EZG3JNeyVg92fue6YAAzEzNgB9AAAABWQAIAAAAABlFkYtLCx901X6QVVMkSn6Z7k30UF4xHaA0OZJJ9bdyQVzACAAAAAATez+F9GHcGzTp7jjv4feboUNb8JCkIp4EqcPFisnq7MFbAAgAAAAACE7JvOpBgMoZ7kRd4QbxIhxukPTUxXpzhjnBHiR7XoRAAMxMzcAfQAAAAVkACAAAAAA8NJKN0IxZnruhswGQkiruv8Ih0EMwDcSZx/Xasup9dkFcwAgAAAAAKaJZRxzA+Igeydvuk6cSwUHXcrmT4PjhuPu//FslpdnBWwAIAAAAAD53Rok1Vq/PMAnXmarqoHJ0PEyYUBmVESa9hIpCv/G9QADMTM4AH0AAAAFZAAgAAAAABHxHdEClz7hbSSgE58+dWLlSMJnoPz+jFxp4bB1GmLQBXMAIAAAAAD3nSvT6aGD+A110J/NwEfp0nPutlmuB5B+wA3CC3noGAVsACAAAAAA3Apjd+TapONB7k5wBVwTWgn8t+Sq2oyyU5/+as109RcAAzEzOQB9AAAABWQAIAAAAAC/o8qW/ifk3KuJ01VFkyNLgQafxB5/bGs2G5VyyVafOwVzACAAAAAA1bMqAFGDHSl6BYNLbxApvkAv2K1/oafywiX0MDz1dGUFbAAgAAAAAHJXLlId3edFoniLD/9K2A5973MeP2Ro31flDyqm3l5QAAMxNDAAfQAAAAVkACAAAAAAY2V8I1bz3a1AxTtmED6UhdhA09huFkuuEX8R+d/WDPUFcwAgAAAAAPTVoNRiI76tcRKqd+JBBVyy4+YcKST42p0QX2BtmQ2VBWwAIAAAAACcxt9hg14WqPNiDv1MkqVljM2e2KJEv53lA17LhV6ZigADMTQxAH0AAAAFZAAgAAAAAO2kSsW0WGN9AOtK4xK2SHrGhWiaAbMEKT4iZkRpaDN/BXMAIAAAAABKGzQcPM8LT2dwOggxoWjv/1imYWabbG/G4kBw8OWaxAVsACAAAAAAC9hLK1dScQTAqg+YAG3ObdPzg2Xet57HmOFpGmyUR9UAAzE0MgB9AAAABWQAIAAAAAAiCwzNEEaH/mDam68IdDftnhthyUFdb+ZCNSBQ91WlHQVzACAAAAAA7tHyHcxCzmbJeFYZyPm4mEgkTGKOvwY4MX82OvH0Jn8FbAAgAAAAAAb5IAbZ1hXCNegQ+S+C9i/Z8y6sS8KeU04V6hXa2ml6AAMxNDMAfQAAAAVkACAAAAAAGuCHVNJSuoVkpPOnS5s89GuA+BLi2IPBUr2Bg1sWEPIFcwAgAAAAAEl1gncS5/xO7bQ/KQSstRV3rOT2SW6nV92ZANeG2SR6BWwAIAAAAAA9LOcKmhek8F2wAh8yvT/vjp2gaouuO+Hmv10lwAeWPAADMTQ0AH0AAAAFZAAgAAAAAMfxz7gEaoCdPvXrubDhCZUS0ARLZc1svgbXgMDlVBPgBXMAIAAAAAB6a5dDA3fuT5Vz2KvAcbUEFX/+B7Nw2p1QqbPoQ5TTuAVsACAAAAAAcf/y75UOuI62A6vWH7bYr/5Jz+nirZVYK/81trN6XOQAAzE0NQB9AAAABWQAIAAAAACnYsqF/VzmjIImC9+dqrHO1TM6lJ6fRwM0mM6Wf6paOwVzACAAAAAA5tgZzch8uDCR1ky3SllVaKVpxAlbrhvlNDTazZZRZOAFbAAgAAAAALeGiLJS4z2zhgVpxzyPdRYyACP9QzQBOob34YrIZumCAAMxNDYAfQAAAAVkACAAAAAAEC0sIVmadtW4YMuRXH7RpAhXclsd+3bmqGXCMeaT014FcwAgAAAAABPpXh0uzpsJJB+IRUNajmMB9WGwswfpw5T9xk3Xj6ANBWwAIAAAAAAmf+NYh9TZ/QRu3w/GQz66n7DtfbJijN3G7KzeL8lstAADMTQ3AH0AAAAFZAAgAAAAABaIB3n49Xm9cOafSrQsE0WCcYp8rMIO/qVwIlMF5YLRBXMAIAAAAAC9EyWJV3xOu9bzgdJ/yX+ko7qLf1u3AxNMataW2C9EzQVsACAAAAAAvVbDkLxXx2DcMLifIQ3K0IIJcLcAG9DUrNfI6aoUjNcAAzE0OAB9AAAABWQAIAAAAAA5rZItA/cocRnngYqcJ3nBXQ+l688aKz3EQyLbYYunPAVzACAAAAAAwKyA+L7TgxztPClLrIMk2JXR+w7c04N3ZOqPgjvrIvsFbAAgAAAAACzvZ33h6aWEe8hmo+1f6OXJ72FY5hvWaUuha64ZV3KFAAMxNDkAfQAAAAVkACAAAAAA3htn7oHJ0YYpIrs+Mzyh85Ys67HwAdv5LQl1mCdoMWkFcwAgAAAAAEHjCtNNLenHuSIYux6ezAHsXDaj2DlTF67ToDhDDe6HBWwAIAAAAAD+P4H0sk9jOd+7vOANt2/1Ectb+4ZRGPE8GkHWNXW3MgADMTUwAH0AAAAFZAAgAAAAAEnt18Km/nqggfIJWxzTr9r3hnXNaueG6XO9A5G11LnGBXMAIAAAAAD7QxzGMN/ard5TfFLecE6uusMmXG2+RBsBR+/NCQHUwAVsACAAAAAAQEZ1ZZ8GC8rdbg7s87OM5Gr9qkTXS9+P5DuAZxj5Gl4AAzE1MQB9AAAABWQAIAAAAAAVAKK/GoY8AACu/hyMpO4hdLq6JnEyWNzkyci9sbaD/wVzACAAAAAA2HmeqpMlvvBpV2zQTYIRmsc4MFlfHRwLof0ycJgMg/MFbAAgAAAAACdltCeWi5E/q1Li1eXLChpM2D9QQSGLBZ82NklQSc0oAAMxNTIAfQAAAAVkACAAAAAAhHyq1GQC/GiMwpYjcsfkNxolJ10ARKjIjfkW1Wipzi0FcwAgAAAAAD/uaGWxTDq87F8XZ6CrFI+RNa8yMqfSZdqK00Kj833BBWwAIAAAAAD6aEdOO0CsQGagioOCvANPCEHSpJ8BSixlPBq5ERhB7AADMTUzAH0AAAAFZAAgAAAAABAJJxHoZD+MQBWqm9UM9Dd3z5ZohIZGWRaRVRsMptKQBXMAIAAAAADrE/ca+gqj/SH4oao4wE4qn2ovoTydzcMbDbrfnUs3zAVsACAAAAAAeNCIQN6hVnGJinytQRFGlQ2ocoprXNqpia+BSxzl+uwAAzE1NAB9AAAABWQAIAAAAAAv01wz7VG9mTepjXQi6Zma+7b/OVBaKVkWNbgDLr1mFgVzACAAAAAA0I5sxz8r6wkCp5Tgvr+iL4p6MxSOq5d3e1kZG+0b7NkFbAAgAAAAAIA32v6oGkAOS96HexGouNTex+tLahtx9QF2dgGClk6WAAMxNTUAfQAAAAVkACAAAAAAWXecRwxSon68xaa9THXnRDw5ZfzARKnvvjTjtbae6T0FcwAgAAAAAPh0UfUMEo7eILCMv2tiJQe1bF9qtXq7GJtC6H5Va4fIBWwAIAAAAADqFr1ThRrTXNgIOrJWScO9mk86Ufi95IDu5gi4vP+HWQADMTU2AH0AAAAFZAAgAAAAAEY5WL8/LpX36iAB1wlQrMO/xHVjoO9BePVzbUlBYo+bBXMAIAAAAABoKcpadDXUARedDvTmzUzWPe1jTuvD0z9oIcZmKuiSXwVsACAAAAAAJuJbwuaMrAFoI+jU/IYr+k4RzAqITrOjAd3HWCpJHqEAAzE1NwB9AAAABWQAIAAAAADnJnWqsfx0xqNnqfFGCxIplVu8mXjaHTViJT9+y2RuTgVzACAAAAAAWAaSCwIXDwdYxWf2NZTly/iKVfG/KDjHUcA1BokN5sMFbAAgAAAAAJVxavipE0H4/JQvhagdytXBZ8qGooeXpkbPQ1RfYMVHAAMxNTgAfQAAAAVkACAAAAAAsPG7LaIpJvcwqcbtfFUpIjj+vpNj70Zjaw3eV9T+QYsFcwAgAAAAAJQ71zi0NlCyY8ZQs3IasJ4gB1PmWx57HpnlCf3+hmhqBWwAIAAAAACD58TO6d+71GaOoS+r73rAxliAO9GMs4Uc8JbOTmC0OwADMTU5AH0AAAAFZAAgAAAAAAGiSqKaQDakMi1W87rFAhkogfRAevnwQ41onWNUJKtuBXMAIAAAAAASgiDpXfGh7E47KkOD8MAcX8+BnDShlnU5JAGdnPdqOAVsACAAAAAAI+2TTQIgbFq4Yr3lkzGwhG/tqChP7hRAx2W0fNaH6jcAAzE2MAB9AAAABWQAIAAAAAB7L4EnhjKA5xJD3ORhH2wOA1BvpnQ+7IjRYi+jjVEaJAVzACAAAAAAuhBIm0nL3FJnVJId+7CKDASEo+l2E89Z9/5aWSITK4AFbAAgAAAAALtSICOzQDfV9d+gZuYxpEj6cCeHnKTT+2G3ceP2H65kAAMxNjEAfQAAAAVkACAAAAAAaROn1NaDZFOGEWw724dsXBAm6bgmL5i0cki6QZQNrOoFcwAgAAAAANVT8R6UvhrAlyqYlxtmnvkR4uYK/hlvyQmBu/LP6/3ZBWwAIAAAAAD+aHNMP/X+jcRHyUtrCNkk1KfMtoD3GTmShS8pWGLt+AADMTYyAH0AAAAFZAAgAAAAADqSR5e0/Th59LrauDA7OnGD1Xr3H3NokfVxzDWOFaN7BXMAIAAAAACt30faNwTWRbvmykDpiDYUOCwA6QDbBBYBFWS7rdOB4AVsACAAAAAAF7SvnjjRk5v2flFOKaBAEDvjXaL1cpjsQLtK2fv9zdQAAzE2MwB9AAAABWQAIAAAAADmtb1ZgpZjSeodPG/hIVlsnS8hoRRwRbrTVx89VwL62AVzACAAAAAAi38e1g6sEyVfSDkzZbaZXGxKI/zKNbMasOl2LYoWrq8FbAAgAAAAAALACk0KcCDN/Kv8WuazY8ORtUGkOZ5Dsm0ys1oOppp/AAMxNjQAfQAAAAVkACAAAAAAf/f7AWVgBxoKjr7YsEQ4w/fqSvuQWV2HMiA3rQ7ur0sFcwAgAAAAADkkeJozP6FFhUdRIN74H4UhIHue+eVbOs1NvbdWYFQrBWwAIAAAAAB55FlHAkmTzAYj/TWrGkRJw2EhrVWUnZXDoMYjyfB/ZwADMTY1AH0AAAAFZAAgAAAAAI2WEOymtuFpdKi4ctanPLnlQud+yMKKb8p/nfKmIy56BXMAIAAAAADVKrJmhjr1rfF3p+T+tl7UFd1B7+BfJRk0e7a4im7ozgVsACAAAAAA5E7Ti3PnFiBQoCcb/DN7V1uM3Xd6VKiexPKntssFL7kAAzE2NgB9AAAABWQAIAAAAAAuHU9Qd79hjyvKOujGanSGDIQlxzsql8JytTZhEnPw+AVzACAAAAAAjF2gV/4+sOHVgDd/oR5wDi9zL7NGpGD+NsEpGXy/a4QFbAAgAAAAAJzMoyojYV6Ed/LpVN5zge93Odv3U7JgP7wxeRaJZGTdAAMxNjcAfQAAAAVkACAAAAAA7dQDkt3iyWYCT94d7yqUtPPwp4qkC0ddu+HFdHgVKEkFcwAgAAAAANuYvtvZBTEq4Rm9+5eb7VuFopowkrAuv86PGP8Q8/QvBWwAIAAAAACeqXoAOQOE4j0zRMlkVd8plaW0RX1npsFvB38Xmzv7sAADMTY4AH0AAAAFZAAgAAAAAAwnZSDhL4tNGYxlHPhKYB8s28dY5ScSwiKZm3UhT8U3BXMAIAAAAABDoY6dhivufTURQExyC9Gx3ocpl09bgbbQLChj3qVGbgVsACAAAAAAF+1nS7O0v85s3CCy+9HkdeoEfm2C6ZiNbPMMnSfsMHUAAzE2OQB9AAAABWQAIAAAAAC2VuRdaC4ZJmLdNOvD6R2tnvkyARteqXouJmI46V306QVzACAAAAAAMn1Z6B35wFTX9mEYAPM+IiJ5hauEwfD0CyIvBrxHg7IFbAAgAAAAAOG6DvDZkT9B/xZWmjao2AevN7MMbs3Oh9YJeSd/hZ+hAAMxNzAAfQAAAAVkACAAAAAAVerb7qVNy457rNOHOgDSKyWl5ojun7iWrv1uHPXrIZQFcwAgAAAAAIDcYS9j5z+gx0xdJj09L7876r/vjvKTi/d3bXDE3PhyBWwAIAAAAADuhVLqb1Bkrx8aNymS+bx2cL8GvLFNH4SAi690DUgnWQADMTcxAH0AAAAFZAAgAAAAAH/E44yLxKCJjuSmU9A8SEhbmkDOx1PqqtYcZtgOzJdrBXMAIAAAAABgLh9v2HjBbogrRoQ82LS6KjZQnzjxyJH4PH+F3jupSAVsACAAAAAAIlO46ehXp4TqpDV0t6op++KO+uWBFh8iFORZjmx2IjkAAzE3MgB9AAAABWQAIAAAAAAlNUdDL+f/SSQ5074mrq0JNh7CTXwTbbhsQyDwWeDVMwVzACAAAAAANIH2IlSNG0kUw4qz0budjcWn8mNR9cJlYUqPYdonucAFbAAgAAAAAJMrOUOyiu5Y3sV76zwEFct8L7+i8WGlQI2+8z2W2kzaAAMxNzMAfQAAAAVkACAAAAAASZ+CvUDtlk/R4HAQ3a+PHrKeY/8ifAfh0oXYFqliu80FcwAgAAAAAJelpzPgM65OZFt/mvGGpwibclQ49wH+1gbUGzd9OindBWwAIAAAAAD9qeDchteEpVXWcycmD9kl9449C1dOw0r60TBm5jK+cQADMTc0AH0AAAAFZAAgAAAAAN9fkoUVbvFV2vMNMAkak4gYfEnzwKI3eDM3pnDK5q3lBXMAIAAAAACnDkgVNVNUlbQ9RhR6Aot2nVy+U4km6+GHPkLr631jEAVsACAAAAAANzg/BnkvkmvOr8nS4omF+q9EG/4oisB+ul4YHi938hwAAzE3NQB9AAAABWQAIAAAAAASyK3b1nmNCMptVEGOjwoxYLLS9fYWm/Zxilqea0jpEQVzACAAAAAADDHsGrbqlKGEpxlvfyqOJKQJjwJrzsrB7k3HG0AUJbkFbAAgAAAAAKwx3S4XfDZh4+LuI9jf7XgUh5qiefNv87JD4qvVRfPSAAMxNzYAfQAAAAVkACAAAAAAlSP9iK31GlcG9MKGbLmq+VXMslURr+As736rrVNXcsUFcwAgAAAAAAvbj0zfq9zzi8XReheKFbCB+h9IsOLgXPPpI5vrEJNZBWwAIAAAAABXvoZhaQE7ogWjeBjceVkp03N20cKYP3TA8vuNsgpfAgADMTc3AH0AAAAFZAAgAAAAAOJNORH8Bev97gVU7y6bznOxJ+E6Qoykur1QP76hG1/7BXMAIAAAAAC+C1PtOOrSZgzBAGhr+dPe/kR0JUw9GTwLVNr61xC1aAVsACAAAAAAeA/L8MQIXkamaObtMPLpoDoi5FypA5WAPtMeMrgi0eQAAzE3OAB9AAAABWQAIAAAAAAKcHzLUomavInN6upPkyWhAqYQACP/vdVCIYpiy6U6HgVzACAAAAAATsR4KItY6R2+U7Gg6sJdaEcf58gjd1OulyWovIqfxKcFbAAgAAAAAFbm10ko67ahboAejQdAV0U2uA5OhZYdb8XUFJ8OL46LAAMxNzkAfQAAAAVkACAAAAAAqTOLiMpCdR59tLZzzIPqJvbCNvz2XQL9ust0qYaehtcFcwAgAAAAAArefox/3k5xGOeiw2m6NUdzuGxmPwcu5IFcj+jMwHgHBWwAIAAAAADLZGFJ7MQd5JXMgMXjqZO5LDLxcFClcXPlnRMWRn+1oAADMTgwAH0AAAAFZAAgAAAAAIPSqSeVzSRgNVNmrPYHmUMgykCY27NbdDUNhE5kx/SgBXMAIAAAAAAhX90nNfxyXmZe/+btZ7q6xMX4PFyj0paM1ccJ/5IUUQVsACAAAAAA419oHmD2W0SYoOMwhrhrp8jf68fg9hTkaRdCuVd3CN0AAzE4MQB9AAAABWQAIAAAAACLn5DxiqAosHGXIAY96FwFKjeqrzXWf3VJIQMwx1fl4gVzACAAAAAAindvU27nveutopdvuHmzdENBbeGFtI3Qcsr07jxmvm8FbAAgAAAAAPvl9pBStQvP4OGkN5v0MghUY6djm9n7XdKKfrW0l1sMAAMxODIAfQAAAAVkACAAAAAA7i2S6rHRSPBwZEn59yxaS7HiYBOmObIkeyCcFU42kf8FcwAgAAAAAGb3RSEyBmgarkTvyLWtOLJcPwCKbCRkESG4RZjVmY4iBWwAIAAAAADB2/wo5CSHR4ANtifY6ZRXNTO5+O8qP82DfAiAeanpZwADMTgzAH0AAAAFZAAgAAAAAFz+M+H/Z94mdPW5oP51B4HWptp1rxcMWAjnlHvWJDWrBXMAIAAAAACBFEOQyL7ZHu4Cq33QvXkmKuH5ibG/Md3RaED9CtG5HwVsACAAAAAAfggtJTprQ/yZzj7y5z9KvXsdeXMWP0yUXMMJqpOwI88AAzE4NAB9AAAABWQAIAAAAAAE7c2x3Z3aM1XGfLNk/XQ9jCazNRbGhVm7H8c2NjS5ywVzACAAAAAARJ9h8fdcwA19velF3L/Wcvi2rCzewlKZ2nA0p8bT9uwFbAAgAAAAAJtWe6b4wK2Hae2dZm/OEpYQnvoZjz4Sz5IgJC2wInecAAMxODUAfQAAAAVkACAAAAAAVoRt9B9dNVvIMGN+ea5TzRzQC+lqSZ8dd/170zU5o9cFcwAgAAAAAEwM95XZin5mv2yhCI8+ugtKuvRVmNgzzIQN0yi1+9aIBWwAIAAAAAAMGBq72n00rox3uqhxSB98mkenTGCdbbUF1gXrgottzgADMTg2AH0AAAAFZAAgAAAAAKRDkjyWv/etlYT4GyoXrmBED2FgZHnhc+l9Wsl06cH2BXMAIAAAAABohlpm3K850Vndf3NmNE0hHqDlNbSR8/IvMidQ3LnIZAVsACAAAAAAW42nGHa6q2MCAaaPVwaIDfr8QLyQwjKq23onZJYsqVsAAzE4NwB9AAAABWQAIAAAAAC3DFh5oklLCNLY90bgWm68dFXz65JpAZSp1K99MBTPAQVzACAAAAAAQgZecmxEUZVHoptEQClDwAf8smI3WynQ/i+JBP0g+kQFbAAgAAAAAEUSQGVnAPISD6voD0DiBUqyWKgt2rta0tjmoe+LNt6IAAMxODgAfQAAAAVkACAAAAAAQ5WKvWSB503qeNlOI2Tpjd5blheNr6OBO8pfJfPNstcFcwAgAAAAAKwHgQLSDJ5NwLBQbY5OnblQIsVDpGV7q3RCbFLD1U4/BWwAIAAAAACQ5nED99LnpbqXZuUOUjnO2HTphEAFBjLD4OZeDEYybgADMTg5AH0AAAAFZAAgAAAAAGfhFY3RGRm5ZgWRQef1tXxHBq5Y6fXaLAR4yJhrTBplBXMAIAAAAACKEF0ApLoB6lP2UqTFsTQYNc9OdDrs/vziPGzttGVLKQVsACAAAAAArOO6FyfNRyBi0sPT5iye7M8d16MTLcwRfodZq4uCYKEAAzE5MAB9AAAABWQAIAAAAAAIM73gPcgzgotYHLeMa2zAU4mFsr7CbILUZWfnuKSwagVzACAAAAAAJCSu98uV8xv88f2BIOWzt6p+6EjQStMBdkGPUkgN79cFbAAgAAAAAMGqPGMPxXbmYbVfSa/japvUljht1zZT33TY7ZjAiuPfAAMxOTEAfQAAAAVkACAAAAAAkWmHCUsiMy1pwZTHxVPBzPTrWFBUDqHNrVqcyyt7nO8FcwAgAAAAAMv2CebFRG/br7USELR98sIdgE9OQCRBGV5JZCO+uPMgBWwAIAAAAABt7qSmn3gxJu7aswsbUiwvO+G6lXj/Xhx+J/zQyZxzLAADMTkyAH0AAAAFZAAgAAAAAGInUYv0lP/rK7McM8taEHXRefk8Q2AunrvWqdfSV7UaBXMAIAAAAACE+WPxJ3gan7iRTbIxXXx+bKVcaf8kP4JD8DcwU0aL7wVsACAAAAAAUC4eTprX4DUZn2X+UXYU6QjtiXk+u57yoOPBbPQUmDkAAzE5MwB9AAAABWQAIAAAAACmHlg2ud3cplXlTsNTpvNnY6Qm1Fce0m899COamoDjaQVzACAAAAAArtJQeJIlepBWRU2aYar7+YGYVQ7dfDc1oxgTmA8r9q0FbAAgAAAAAOk45vg5VqZHAFCO3i0Z52SZi5RADf8NXwf68T5yad/DAAMxOTQAfQAAAAVkACAAAAAApzcWSAbZWV/Rq+ylRNqqlJqNVR4fhXrz4633/MQOQgcFcwAgAAAAAN/jz/bsEleiuCl+li83EWlG6UMHA8CyaOMRKCkXkSCPBWwAIAAAAAC3Sd+Qg+uFDKpGZHbrQgokXHQ1az1aFl4YK343OB6hcQAAEmNtAAAAAAAAAAAAABBwYXlsb2FkSWQAAAAAABBmaXJzdE9wZXJhdG9yAAEAAAAA", - "subType": "06" - } - } - } - }, - "update": { - "$set": { - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "findAndModify" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": { - "$numberInt": "0" - }, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rbf3AeBEv4wWFAKknqDxRW5cLNkFvbIs6iJjc6LShQY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "n+XAuFnP8Dov9TnhGFxNx0K/MnVM9WbJ7RouEu0ndO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yRXojuVdn5GQtD97qYlaCL6cOLmZ7Cvcb3wFjkLUIdM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DuIkdRPITRs55I4SZmgomAHCIsDQmXRhW8+MOznkzSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SsBk+Et1lTbU+QRPx+xyJ/jMkmfG+QCvQEpip2YYrzA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "crCIzOd8KhHvvUlX7M1v9bhvU4pLdTc+X2SuqoKU5Ek=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YOWdCw4UrqnxkAaVjqmC4sKQDMVMHEpFGnlxpxdaU6E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M3SShp81Ff8tQ632qKbv9MUcN6wjDaBReI0VXNu6Xh4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gzHlSPxpM0hT75kQvWFzGlOxKvDoiKQZOr19V6l2zXI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s3JnppOGYw9SL2Q1kMAZs948v2F5PrpXjGei/HioDWs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cG6+3Gk/zEH68P/uuuwiAUVCuyJwa1LeV+t29FlPPAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dupdvR3AyJtM+g9NDKiaLVOtGca387JQp8w+V03m7Ig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JqEQc5svj2jTvZ6LLA5ivE+kTb/0aRemSEmxk4G7Zrg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "szcXXXKnob+p3SoM4yED2R920LeJ7cVsclPMFTe4CeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o1QoGVXmuBdHwHm7aCtGMlMVKrjFdYvJXpoq6uhIAZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Jfm5wPlqqLCJRGQIqRq2NGmpn7s0Vrih2H3YAOoI2YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zMHLb8ARbsYo8Ld05bqnGFf1Usha6EGb8QKwdSAyps0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yQdtq9lh5pugL7/i0Bj/PuZUUBUIzf+7wj1rl5y736w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wGWVZdO7qIuyDg/BqDgqjgoQ02h5YYgwXQB1oCin2NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "by9HMLj6NTEpgztZ5HSN6GxImkXPcaFINYDzgZY33X8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tWo0vbasi7bXmn/MsOx13VC1IsWtpx/nYp0uj4iMzdA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tQQpndUYd5O87lOtrGjH3wl9VsOK0ray7RMasL90sBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cQjXEDCMsOpKLLf+vlTgIHA+cbSJdzqhbSX9Wvh95aA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7yMpU48IxK9SzP2cx3VnTownGEwFmeFofuuFT97SuuY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kSOx1kz0CmBgzKQHZlo65ZUY1DIv9A99JRm+Us2y6Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubQpdPBe6/xvtr+AcXdfYLSvYCR4ot0tivehkCsupb4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xal+iCJ6FTefRQToyoNksc9NCZShyn04NDGi4IYrcoM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d7jU4iOK50xHxlkSifcxlZFCM46TSgQzoYivxG3HNLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJvl2nsBLBVzL3pp6sKWCL4UXeh3q/roYBJjSb74ve0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OIUCaKRvIx9t1w6Hxlz1IcQTdPNCfdRNwnnTm10W+X0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A9tvzsiElotOUVIB4CqfQp9mAwqvTM35YkmAR170aHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lI8gpK7hpb7c9x4RQugsxMnQay5LZJmwslZdvMx/dcE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dNCzh40U0XvdKnSDi3HRQOWQftEsDVqc4uUvsVFGoq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IP+iwEBWBwVVZIdpaMu8k5+soFCz+TZkYn3drKZ9grE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnqyh6e0y5svHkJDShlN9CHV0WvMBE4QbtJpQw5ZCXc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "elEl42tbVDoRTLjAhZUFEtXiut4b3PVhg/1ZLZSQdtE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vHuu2FxwclMHqyE6JBYbTYgbEkB0dqb/JuaxsvfwsmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xTf7NCe3Gf8QpE78HR5OknlLTKfs9J+RN9UZpH6fnso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XiWSasRnJAulGR6+LCVD3mwRObXylqYWR9jvpywq12c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MZMxEQ5ikx0PG1YFIExv0UnTZogsvgeOEZTpzvBDn4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yZMyMZBDrWbAhvnic7vvIYhmO9m5H2iuv0c8KNZrBzY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xxM14hTPY5j0vvcK2C7YAEjzdsfUTFHozHC0hEo1bxI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+01rqR1xVwkpGXcstbk1ItJqFVjH6Q8MGxEN3Cm9Y1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xOpLV0Z2VTRJ3iWtnWZcsyjXubTIkYWo31cO+HV1o1k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BWUOLqgLBqc5NwxVlSV5H3KFQPXbCp7mdo+jF+8cJqY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fuQb1S6xZDGlrEbK+kI23aL53PP1PVNwqICnZNt9Yzg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfscnoibFttahLdPVC4Ee+47ewGFKpDSU7M6HX19bKE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rpSW2awybNVeKtat91VFxqbINoTfNhPfQAu+d73Xtf8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9M/CP9ccOIIj2LLFmE0GFDO0Ban2wsNalEXfM6+h+1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WrEMG49l1ye4MhXs5ZS9tz8P6h+hDvthIg/2wW9ne1Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ImNhbfeyfH8qIEeA5ic0s3dAQBdzzTBS+CPsNih9vZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dWP33YDSn04UKJN2ogh2Rui0iW/0q2y18OCDRVcfyoo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lYv0isAtfGh6H9tdp3cp2eHU7q2J+uk7QrgcxtK3w7Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VGMoamB/+7zTOYcY/pqJc96xlv2PdW4hwsIAEIslTDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yNeBWMF7BnD9wVwz2PgJsvWr77QiVvvWUvJF0+fqBug=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfpvObJ+tJBXSvqeN7vlOfmhYign635lciYAJIjUtY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dsen4NqjzVGjpjufiTMs3+gqeD09EbnuogPgxrJECwg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pxCWVM3sn19NsFEpgHbgLa+PmYlhN3mMiP0Wk8kJhYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q11KNvJszjYIB9n9HcC+N4uz11a3eRj1L3BH9scKMDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A1PmkgcEToWh1JiVWE6mI5jUu7poxWWuCUt/cgRUUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qJo3Hu4PJeanL7XEaWXO/n3YsodhZyd+MJOOmB9Kpd8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BkBKLO8URFscfRY9Bav/1+L9mLohDgNr/MkZtGiraIs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rZq5WA3Hx3xthOyHAJXK//f8pE2qbz7YKu3TIMp9GFY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X07a/Lm80p5xd4RFs1dNmw+90tmPDPdGiAKVZkxd4zY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6YrBn2ofIw1b5ooakrLOwF41BWrps8OO0H9WH4/rtlE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0l86Ag5OszXpa78SlOUV3K9nff5iC1p0mRXtLg9M1s4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Hn6yuxFHodeyu7ISlhYrbSf9pTiH4TDEvbYLWjTwFO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zdf4y2etKBuIpkEU1zMwoCkCsdisfXZCh8QPamm+drY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rOQ9oMdiK5xxGH+jPzOvwVqdGGnF3+HkJXxn81s6hp4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "61aKKsE3+BJHHWYvs3xSIBvlRmKswmaOo5rygQJguUg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KuDb/GIzqDM8wv7m7m8AECiWJbae5EKKtJRugZx7kR0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Q+t8t2TmNUiCIorVr9F3AlVnX+Mpt2ZYvN+s8UGict8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJRZIpKxUgHyL83kW8cvfjkxN3z6WoNnUg+SQw+LK+k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnUsYjip8SvW0+m9mR5WWTkpK+p6uwJ6yBUAlBnFKMk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PArHlz+yPRYDycAP/PgnI/AkP8Wgmfg++Vf4UG1Bf0E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wnIh53Q3jeK8jEBe1n8kJLa89/H0BxO26ZU8SRIAs9Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4F8U59gzBLGhq58PEWQk2nch+R0Va7eTUoxMneReUIA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ihKagIW3uT1dm22ROr/g5QaCpxZVj2+Fs/YSdM2Noco=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EJtUOOwjkrPUi9mavYAi+Gom9Y2DuFll7aDwo4mq0M0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dIkr8dbaVRQFskAVT6B286BbcBBt1pZPEOcTZqk4ZcI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aYVAcZYkH/Tieoa1XOjE/zCy5AJcVTHjS0NG2QB7muA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sBidL6y8TenseetpioIAAtn0lK/7C8MoW4JXpVYi3z8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0Dd2klU/t4R86c2WJcJDAd57k/N7OjvYSO5Vf8KH8sw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I3jZ92WEVmZmgaIkLbuWhBxl7EM6bEjiEttgBJunArA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aGHoQMlgJoGvArjfIbc3nnkoc8SWBxcrN7hSmjMRzos=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bpiWPnF/KVBQr5F6MEwc5ZZayzIRvQOLDAm4ntwOi8g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tI7QVKbE6avWgDD9h4QKyFlnTxFCwd2iLySKakxNR/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XGsge0CnoaXgE3rcpKm8AEeku5QVfokS3kcI+JKV1lk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JQxlryW2Q5WOwfrjAnaZxDvC83Dg6sjRVP5zegf2WiM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YFuHKJOfoqp1iGVxoFjx7bLYgVdsN4GuUFxEgO9HJ5s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Z6vUdiCR18ylKomf08uxcQHeRtmyav7/Ecvzz4av3k4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SPGo1Ib5AiP/tSllL7Z5PAypvnKdwJLzt8imfIMSEJQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "m94Nh6PFFQFLIib9Cu5LAKavhXnagSHG6F5EF8lD96I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pfEkQI98mB+gm1+JbmVurPAODMFPJ4E8DnqfVyUWbSo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DNj3OVRLbr43s0vd+rgWghOL3FqeO/60npdojC8Ry/M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kAYIQrjHVu49W8FTxyxJeiLVRWWjC9fPcBn+Hx1F+Ss=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aCSO7UVOpoQvu/iridarxkxV1SVxU1i9HVSYXUAeXk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Gh6hTP/yj1IKlXQ+Q69KTfMlGZjEcXoRLGbQHNFo/1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/gDgIFQ4tAlJk3GN48IS5Qa5IPmErwGk8CHxAbp6gs0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PICyimwPjxpusyKxNssOOwUotAUbygpyEtORsVGXT8g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4lu+cBHyAUvuxC6JUNyHLzHsCogGSWFFnUCkDwfQdgI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pSndkmoNUJwXjgkbkgOrT5f9nSvuoMEZOkwAN9ElRaE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tyW+D4i26QihNM5MuBM+wnt5AdWGSJaJ4X5ydc9iWTU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9Syjr8RoxUgPKr+O5rsCu07AvcebA4P8IVKyS1NVLWc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "67tPfDYnK2tmrioI51fOBG0ygajcV0pLo5+Zm/rEW7U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "y0EiPRxYTuS1eVTIaPQUQBBxwkyxNckbePvKgChwd0M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NWd+2veAaeXQgR3vCvzlI4R1WW67D5YsVLdoXfdb8qg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PY5RQqKQsL2GqBBSPNOEVpojNFRX/NijCghIpxD6CZk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lcvwTyEjFlssCJtdjRpdN6oY+C7bxZY+WA+QAqzj9zg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWE7XRNylvTwO/9Fv56dNqUaQWMmESNS/GNIwgBaEI0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ijwlrUeS8nRYqK1F8kiCYF0mNDolEZS+/lJO1Lg93C8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8KzV+qYGYuIjoNj8eEpnTuHrMYuhzphl80rS6wrODuU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wDyTLjSEFF895hSQsHvmoEQVS6KIkZOtq1c9dVogm9I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SGrtPuMYCjUrfKF0Pq/thdaQzmGBMUvlwN3ORIu9tHU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KySHON3hIoUk4xWcwTqk6IL0kgjzjxgMBObVIkCGvk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hBIdS9j0XJPeT4ot73ngELkpUoSixvRBvdOL9z48jY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Tx6um0q9HjS5ZvlFhvukpI6ORnyrXMWVW1OoxvgqII0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zFKlyfX5H81+d4A4J3FKn4T5JfG+OWtR06ddyX4Mxas=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cGgCDuPV7MeMMYEDpgOupqyNP4BQ4H7rBnd2QygumgM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IPaUoy98v11EoglTpJ4kBlEawoZ8y7BPwzjLYBpkvHQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Pfo4Am6tOWAyZNn8G9W5HWWGC3ZWmX0igI/RRB870Ro=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fnTSjd7bC1Udoq6iM7UDnHAC/lsIXSHp/Gy332qw+/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fApBgVRrTDyEumkeWs5p3ag9KB48SbU4Si0dl7Ns9rc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QxudfBItgoCnUj5NXVnSmWH3HK76YtKkMmzn4lyyUYY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sSOvwhKa29Wq94bZ5jGIiJQGbG1uBrKSBfOYBz/oZeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FdaMgwwJ0NKsqmPZLC5oE+/0D74Dfpvig3LaI5yW5Fs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sRWBy12IERN43BSZIrnBfC9+zFBUdvjTlkqIH81NGt4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/4tIRpxKhoOwnXAiFn1Z7Xmric4USOIfKvTYQXk3QTc=", - "subType": "00" - } - } - ] - }, - { - "_id": { - "$numberInt": "1" - }, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Mr/laWHUijZT5VT3x2a7crb7wgd/UXOGz8jr8BVqBpM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wXVD/HSbBljko0jJcaxJ1nrzs2+pchLQqYR3vywS8SU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VDCpBYsJIxTfcI6Zgf7FTmKMxUffQv+Ys8zt5dlK76I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zYDslUwOUVNwTYkETfjceH/PU3bac9X3UuQyYJ19qK0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rAOmHSz18Jx107xpbv9fYcPOmh/KPAqge0PAtuhIRnc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BFOB1OGVUen7VsOuS0g8Ti7oDsTt2Yj/k/7ta8YAdGM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2fckE5SPs0GU+akDkUEM6mm0EtcV3WDE/sQsnTtodlk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "mi9+aNjuwIvaMpSHENvKzKRAmX9cYguo2mXLvOoftHQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "K6TWn4VcWWkz/gkUkLmbtwkG7SNeABICmLDnoYJFlLU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Z+2/cEtGU0Fq7QJFNGA/0y4aWAsw0ncG6X0LYRqwS3c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rrSIf+lgcNZFbbUkS9BmE045jRWBpcBJXHzfMVEFuzE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KlHL3Kyje1/LMIfgbCqw1SolxffJvvgsYBV5y77wxuA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hzJ1YBoETmYeCh352dBmG8d8Wse/bUcqojTWpWQlgsc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lSdcllDXx8MA+s0GULjDA1lQkcV0L8/aHtZ6dM2pZ2c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "HGr7JLTTA7ksAnlmjSIwwdBVvgr3fv46/FTdiCPYpos=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "mMr25v1VwOEVZ8xaNUTHJCcsYqV+kwK6RzGYilxPtJ4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "129hJbziPJzNo0IoTU3bECdge0FtaPW8dm4dyNVNwYU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "doiLJ96qoo+v7NqIAZLq6BI5axV8Id8gT5vyJ1ZZ0PM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cW/Lcul3xYmfyvI/0x/+ybN78aQmBK1XIGs1EEU09N8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1aVIwzu9N5EJV9yEES+/g6hOTH7cA2NTcLIc59cu0wU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kw5tyl7Ew0r1wFyrN1mB9FiVW2hK2BxxxUuJDNWjyjQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ADAY2YBrm6RJBDY/eLLcfNxmSJku+mefz74gH66oyco=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8gkqB1LojzPrstpFG7RHYmWxXpIlPDTqWnNsXH7XDRU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "TESfVQMDQjfTZmHmUeYUE2XrokJ6CcrsKx/GmypGjOw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qFM+HFVQ539S0Ouynd1fBHoemFxtU9PRxE5+Dq7Ljy4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jPiFgUZteSmOg4wf3bsEKCZzcnxmMoILsgp/GaZD+dM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YaWUgJhYgPNN7TkFK16H8SsQS226JguaVhOIQxZwQNQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x90/Qk3AgyaFsvWf2KUCu5XF3j76WFSjt/GrnG01060=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ZGWybWL/xlEdMYRFCZDUoz10sywTf7U/7wufsb78lH0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8l4ganN66jIcdxfHAdYLaym/mdzUUQ8TViw3MDRySPc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c8p5XEGTqxqvRGVlR+nkxw9uUdoqDqTB0jlYQ361qMA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1ZGFLlpQBcU3zIUg8MmgWwFKVz/SaA7eSYFrfe3Hb70=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "34529174M77rHr3Ftn9r8jU4a5ztYtyVhMn1wryZSkU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YkQ4pxFWzc49MS0vZM6S8mNo4wAwo21rePBeF3C+9mI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MhOf4mYY00KKVhptOcXf0bXB7WfuuM801MRJg4vXPgc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7pbbD8ihNIYIBJ3tAUPGzHpFPpIeCTAk5L88qCB0/9w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "C9Q5PoNJTQo6pmNzXEEXUEqH22//UUWY1gqILcIywec=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "AqGVk1QjDNDLYWGRBX/nv9QdGR2SEgXZEhF0EWBAiSE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/sGI3VCbJUKATULJmhTayPOeVW+5MjWSvVCqS77sRbU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yOtbL0ih7gsuoxVtRrACMz+4N5uo7jIR7zzmtih2Beo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uA6dkb2Iyg9Su8UNDvZzkPx33kPZtWr/CCuEY+XgzUM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1DoSFPdHIplqZk+DyWAmEPckWwXw/GdB25NLmzeEZhk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OfDVS0T3ZuIXI/LNbTp6C9UbPIWLKiMy6Wx+9tqNl+g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "3PZjHXbmG6GtPz+iapKtQ3yY4PoFFgjIy+fV2xQv1YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kaoLN0BoBWsmqE7kKkJQejATmLShd8qffcAmlhsxsGY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vpiw9KgQdegGmp7IJnSGX2miujRLU0xzs0ITTqbPW7c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NuXFf7xGUefYjIUTuMxNUTCfVHrF8oL0AT7dPv5Plk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8Tz53LxtfEBJ9eR+d2690kwNsqPV6XyKo2PlqZCbUrc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "e6zsOmHSyV8tyQtSX6BSwui6wK9v1xG3giY/IILJQ2w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2fedFMCxa2DzmIpfbDKGXhQg0PPwbUv6vIWdwwlvhms=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yEJKMFnWXTC8tJUfzCInzQRByNEPjHxpw4L4m8No91Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YbFuWwOiFuQyOzIJXDbOkCWC2DyrG+248TBuVCa1pXU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "w7IkwGdrguwDrar5+w0Z3va5wXyZ4VXJkDMISyRjPGo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YmJUoILTRJPhyIyWyXJTsQ6KSZHHbEpwPVup6Ldm/Ko=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FvMjcwVZJmfh6FP/yBg2wgskK+KHD8YVUY6WtrE8xbg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "h4HCtD4HyYz0nci49IVAa10Z4NJD/FHnRMV4sRX6qro=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "nC7BpXCmym+a0Is2kReM9cYN2M1Eh5rVo8fjms14Oiw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1qtVWaeVo649ZZZtN8gXbwLgMWGLhz8beODbvru0I7Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Ej+mC0QFyMNIiSjR939S+iGBm7dm+1xObu5IcF/OpbU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UQ8LbUG3cMegbr9yKfKanAPQE1EfPkFciVDrNqZ5GHY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4iI3mXIDjnX+ralk1HhJY43mZx2uTJM7hsv9MQzTX7E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0WQCcs3rvsasgohERHHCaBM4Iy6yomS4qJ5To3/yYiw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qDCTVPoue1/DOAGNAlUstdA9Sid8MgEY4e5EzHcVHRk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9F9Mus0UnlzHb8E8ImxgXtz6SU98YXD0JqswOKw/Bzs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pctHpHKVBBcsahQ6TNh6/1V1ZrqOtKSAPtATV6BJqh0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vfR3C/4cPkVdxtNaqtF/v635ONbhTf5WbwJM6s4EXNE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ejP43xUBIex6szDcqExAFpx1IE/Ksi5ywJ84GKDFRrs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jbP4AWYd3S2f3ejmMG7dS5IbrFol48UUoT+ve3JLN6U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CiDifI7958sUjNqJUBQULeyF7x0Up3loPWvYKw9uAuw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "e2dQFsiHqd2BFHNhlSxocjd+cPs4wkcUW/CnCz4KNuM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PJFckVmzBipqaEqsuP2mkjhJE4qhw36NhfQ9DcOHyEU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "S3MeuJhET/B8VcfZYDR9fvX0nscDj416jdDekhmK11s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CGVHZRXpuNtQviDB2Kj03Q8uvs4w3RwTgV847R7GwPw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yUGgmgyLrxbEpDVy89XN3c2cmFpZXWWmuJ/35zVZ+Jw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "inb6Q97mL1a9onfNTT8v9wsoi/fz7KXKq3p8j90AU9c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CCyYx/4npq9xGO1lsCo8ZJhFO9/tN7DB+/DTE778rYg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "LNnYw4fwbiAZu0kBdAHPEm/OFnreS+oArdB5O/l/I98=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "P006SxmUS/RjiQJVYPdMFnNo3827GIEmSzagggkg05Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "oyvwY+WsnYV6UHuPki1o0ILJ2jN4uyXf9yaUNtZJyBA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "36Lk3RHWh1wmtCWC/Yj6jNIo17U5y6SofAgQjzjVxD8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vOOo8FqeHnuO9mqOYjIb4vgwIwVyXZ5Y+bY5d9tGFUM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bJiDJjwQRNxqxlGjRm5lLziFhcfTDCnQ/qU1V85qcRg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2Qgrm1n0wUELAQnpkEiIHB856yv76q8jLbpiucetcm0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "5ciPOYxTK0WDwwYyfs7yiVymwtYQXDELLxmM4JLl4/o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "31dC2WUSIOKQc4jwT6PikfeYTwi80mTlh7P31T5KNQU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YluTV2Mu53EGCKLcWfHZb0BM/IPW2xJdG3vYlDMEsM4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dh/8lGo2Ek6KukSwutH6Q35iy8TgV0FN0SJqe0ZVHN8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EVw6HpIs3BKen2qY2gz4y5dw1JpXilfh07msZfQqJpc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FYolLla9L8EZMROEdWetozroU40Dnmwwx2jIMrr7c1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8M6k4QIutSIj6CM41vvkQtuFsaGrjoR9SZJVSLbfGKQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9LM0VoddDNHway442MqY+Z7vohB2UHau/cddshhzf40=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "66i8Ytco4Yq/FMl6pIRZazz3CZlu8fO2OI6Pne0pvHU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2a/HgX+MjZxjXtSvHgF1yEpHMJBkl8Caee8XrJtn0WM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "frhBM662c4ZVG7mWP8K/HhRjd01lydW/cPcHnDjifqc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6k1T7Q1t668PBqv6fwpVnT1HWh7Am5LtbKvwPJKcpGU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UlJ5Edfusp8S/Pyhw6KTglIejmbr1HO0zUeHn/qFETA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jsxsB+1ECB3assUdoC333do9tYH+LglHmVSJHy4N8Hg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2nzIQxGYF7j3bGsIesECEOqhObKs/9ywknPHeJ3yges=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xJYKtuWrX90JrJVoYtnwP7Ce59XQGFYoalxpNfBXEH0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NLI5lriBTleGCELcHBtNnmnvwSRkHHaLOX4cKboMgTw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hUOQV0RmE5aJdJww1AR9rirJG4zOYPo+6cCkgn/BGvQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "h4G2Of76AgxcUziBwCyH+ayMOpdBWzg4yFrTfehSC2c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VuamM75RzGfQpj2/Y1jSVuQLrhy6OAwlZxjuQLB/9Ss=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kn9+hLq7hvw02xr9vrplOCDXKBTuFhfbX7d5v/l85Pg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fAiGqKyLZpGngBYFbtYUYt8LUrJ49vYafiboifTDjxs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BxRILymgfVJCczqjUIWXcfrfSgrrYkxTM5VTg0HkZLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CrFY/PzfPU2zsFkGLu/dI6mEeizZzCR+uYgjZBAHro0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "AEbrIuwvXLTtYgMjOqnGQ8y8axUn5Ukrn7UZRSyfQVw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ouWeVH3PEFg+dKWlXc6BmqirJOaVWjJbMzZbCsce4dA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+hd6xFB+EG+kVP7WH4uMd1CLaWMnt5xJRaY/Guuga9Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zmpGalfAOL3gmcUMJYcLYIRT/2VDO/1Dw4KdYZoNcng=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2PbHAoM/46J2UIZ/vyksKzmVVfxA7YUyIxWeL/N/vBk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7fD9x+zk5MVFesb59Klqiwwmve7P5ON/5COURXj5smE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tlrNQ4jaq051iaWonuv1sSrYhKkL1LtNZuHsvATha3s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fBodm28iClNpvlRyVq0dOdXQ08S7/N3aDwid+PdWvRo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "O+/nnRqT3Zv7yMMGug8GhKHaWy6u7BfRGtZoj0sdN1c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "5AZZ/RTMY4Photnm/cpXZr/HnFRi3eljacMsipkJLHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "oFVyo/kgoMxBIk2VE52ySSimeyU+Gr0EfCwapXnTpKA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Z8v59DfcnviA0mzvnUk+URVO0UuqAWvtarEgJva/n1c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "P64GOntZ+zBJEHkigoh9FSxSO+rJTqR20z5aiGQ9an4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xMbSuDPfWuO/Dm7wuVl06GnzG9uzTlJJX9vFy7boGlY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kXPB19mRClxdH2UsHwlttS6lLU2uHvzuZgZz7kC45jU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NDVjVYXAw4k0w4tFzvs7QDq39aaU3HQor4I2XMKKnCk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uKw/+ErVfpTO1dGUfd3T/eWfZW3nUxXCdBGdjvHtZ88=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "av0uxEzWkizYWm0QUM/MN1hLibnxPvCWJKwjOV4yVQY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ERwUC47dvgOBzIsEESMIioLYbFOxOe8PtJTnmDkKuHM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2gseKlG5Le12fS/vj4eaED4lturF16kAgJ1TpW3HxEE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7Cvg0Y3j/5i2F1TeXxlMmU7xwif5dCmwkZAOrVC5K2Y=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-InsertFind.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-InsertFind.json deleted file mode 100644 index 2ef63f42b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-InsertFind.json +++ /dev/null @@ -1,1894 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Decimal. Insert and Find.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$numberDecimal": "0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "find": "default", - "filter": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$binary": { - "base64": "DeFiAAADcGF5bG9hZACxYgAABGcAnWIAAAMwAH0AAAAFZAAgAAAAAJu2KgiI8vM+kz9qD3ZQzFQY5qbgYqCqHG5R4jAlnlwXBXMAIAAAAAAAUXxFXsz764T79sGCdhxvNd5b6E/9p61FonsHyEIhogVsACAAAAAAt19RL3Oo5ni5L8kcvgOJYLgVYyXJExwP8pkuzLG7f/kAAzEAfQAAAAVkACAAAAAAPQPvL0ARjujSv2Rkm8r7spVsgeC1K3FWcskGGZ3OdDIFcwAgAAAAACgNn660GmefR8jLqzgR1u5O+Uocx9GyEHiBqVGko5FZBWwAIAAAAADflr+fsnZngm6KRWYgHa9JzK+bXogWl9evBU9sQUHPHQADMgB9AAAABWQAIAAAAAD2Zi6kcxmaD2mY3VWrP+wYJMPg6cSBIYPapxaFQxYFdQVzACAAAAAAM/cV36BLBY3xFBXsXJY8M9EHHOc/qrmdc2CJmj3M89gFbAAgAAAAAOpydOrKxx6m2gquSDV2Vv3w10GocmNCFeOo/fRhRH9JAAMzAH0AAAAFZAAgAAAAAOaNqI9srQ/mI9gwbk+VkizGBBH/PPWOVusgnfPk3tY1BXMAIAAAAAAc96O/pwKCmHCagT6T/QV/wz4vqO+R22GsZ1dse2Vg6QVsACAAAAAAgzIak+Q3UFLTHXPmJ+MuEklFtR3eLtvM+jdKkmGCV/YAAzQAfQAAAAVkACAAAAAA0XlQgy/Yu97EQOjronl9b3dcR1DFn3deuVhtTLbJZHkFcwAgAAAAACoMnpVl6EFJak8A+t5N4RFnQhkQEBnNAx8wDqmq5U/dBWwAIAAAAACR26FJif673qpwF1J1FEkQGJ1Ywcr/ZW6JQ7meGqzt1QADNQB9AAAABWQAIAAAAAAOtpNexRxfv0yRFvZO9DhlkpU4mDuAb8ykdLnE5Vf1VAVzACAAAAAAeblFKm/30orP16uQpZslvsoS8s0xfNPIBlw3VkHeekYFbAAgAAAAAPEoHj87sYE+nBut52/LPvleWQBzB/uaJFnosxp4NRO2AAM2AH0AAAAFZAAgAAAAAIr8xAFm1zPmrvW4Vy5Ct0W8FxMmyPmFzdWVzesBhAJFBXMAIAAAAABYeeXjJEzTHwxab6pUiCRiZjxgtN59a1y8Szy3hfkg+gVsACAAAAAAJuoY4rF8mbI+nKb+5XbZShJ8191o/e8ZCRHE0O4Ey8MAAzcAfQAAAAVkACAAAAAAl+ibLk0/+EwoqeC8S8cGgAtjtpQWGEZDsybMPnrrkwEFcwAgAAAAAHPPBudWgQ+HUorLDpJMqhS9VBF2VF5aLcxgrM1s+yU7BWwAIAAAAAAcCcBR2Vyv5pAFbaOU97yovuOi1+ATDnLLcAUqHecXcAADOAB9AAAABWQAIAAAAACR9erwLTb+tcWFZgJ2MEfM0PKI9uuwIjDTHADRFgD+SQVzACAAAAAAcOop8TXsGUVQoKhzUllMYWxL93xCOkwtIpV8Q6hiSYYFbAAgAAAAAKXKmh4V8veYwob1H03Q3p3PN8SRAaQwDT34KlNVUjiDAAM5AH0AAAAFZAAgAAAAALv0vCPgh7QpmM8Ug6ad5ioZJCh7pLMdT8FYyQioBQ6KBXMAIAAAAADsCPyIG8t6ApQkRk1fX/sfc1kpuWCWP8gAEpnYoBSHrQVsACAAAAAAJe/r67N6d8uTiogvfoR9rEXbIDjyLb9EVdqkayFFGaYAAzEwAH0AAAAFZAAgAAAAAIW4AxJgYoM0pcNTwk1RSbyjZGIqgKL1hcTJmNrnZmoPBXMAIAAAAAAZpfx3EFO0vY0f1eHnE0PazgqeNDTaj+pPJMUNW8lFrAVsACAAAAAAP+Um2vwW6Bj6vuz9DKz6+6aWkoKoEmFNoiz/xXm7lOsAAzExAH0AAAAFZAAgAAAAAKliO6L9zgeuufjj174hvmQGNRbmYYs9yAirL7OxwEW3BXMAIAAAAAAqU7vs3DWUQ95Eq8OejwWnD0GuXd+ASi/uD6S0l8MM1QVsACAAAAAAb9legYzsfctBPpHyl7YWpPmLr5QiNZFND/50N1vv2MUAAzEyAH0AAAAFZAAgAAAAAOGQcCBkk+j/Kzjt/Cs6g3BZPJG81wIHBS8JewHGpgk+BXMAIAAAAABjrxZXWCkdzrExwCgyHaafuPSQ4V4x2k9kUCAqUaYKDQVsACAAAAAADBU6KefT0v8zSmseaMNmQxKjJar72y7MojLFhkEHqrUAAzEzAH0AAAAFZAAgAAAAAPmCNEt4t97waOSd5hNi2fNCdWEkmcFJ37LI9k4Az4/5BXMAIAAAAABX7DuDPNg+duvELf3NbLWkPMFw2HGLgWGHyVWcPvSNCAVsACAAAAAAS7El1FtZ5STh8Q1FguvieyYX9b2DF1DFVsb9hzxXYRsAAzE0AH0AAAAFZAAgAAAAAD4vtVUYRNB+FD9yoQ2FVJH3nMeJeKbi6eZfth638YqbBXMAIAAAAAANCuUB4OdmuD6LaDK2f3vaqfgYYvg40wDXOBbcFjTqLwVsACAAAAAA9hqC2VoJBjwR7hcQ45xO8ZVojwC83jiRacCaDj6Px2gAAzE1AH0AAAAFZAAgAAAAAJPIRzjmTjbdIvshG6UslbEOd797ZSIdjGAhGWxVQvK1BXMAIAAAAABgmJ0Jh8WLs9IYs/a7DBjDWd8J3thW/AGJK7zDnMeYOAVsACAAAAAAi9zAsyAuou2oiCUHGc6QefLUkACa9IgeBhGu9W/r0X8AAzE2AH0AAAAFZAAgAAAAAABQyKQPoW8wGPIqnsTv69+DzIdRkohRhOhDmyVHkw9WBXMAIAAAAAAqWA2X4tB/h3O1Xlawtz6ndI6WaTwgU1QYflL35opu5gVsACAAAAAAWI/Gj5aZMwDIxztqmVL0g5LBcI8EdKEc2UA28pnekQoAAzE3AH0AAAAFZAAgAAAAACB7NOyGQ1Id3MYnxtBXqyZ5Ul/lHH6p1b10U63DfT6bBXMAIAAAAADpOryIcndxztkHSfLN3Kzq29sD8djS0PspDSqERMqokQVsACAAAAAADatsMW4ezgnyi1PiP7xk+gA4AFIN/fb5uJqfVkjg4UoAAzE4AH0AAAAFZAAgAAAAAKVfXLfs8XA14CRTB56oZwV+bFJN5BHraTXbqEXZDmTkBXMAIAAAAAASRWTsfGOpqdffiOodoqIgBzG/yzFyjR5CfUsIUIWGpgVsACAAAAAAkgCHbCwyX640/0Ni8+MoYxeHUiC+FSU4Mn9jTLYtgZgAAzE5AH0AAAAFZAAgAAAAAH/aZr4EuS0/noQR9rcF8vwoaxnxrwgOsSJ0ys8PkHhGBXMAIAAAAACd7ObGQW7qfddcvyxRTkPuvq/PHu7+6I5dxwS1Lzy5XAVsACAAAAAA3q0eKdV7KeU3pc+CtfypKR7BPxwaf30yu0j9FXeOOboAAzIwAH0AAAAFZAAgAAAAAKvlcpFFNq0oA+urq3w6d80PK1HHHw0H0yVWvU9aHijXBXMAIAAAAADWnAHQ5Fhlcjawki7kWzdqjM2f6IdGJblojrYElWjsZgVsACAAAAAAO0wvY66l24gx8nRxyVGC0QcTztIi81Kx3ndRhuZr6W4AAzIxAH0AAAAFZAAgAAAAAH/2aMezEOddrq+dNOkDrdqf13h2ttOnexZsJxG1G6PNBXMAIAAAAABNtgnibjC4VKy5poYjvdsBBnVvDTF/4mmEAxsXVgZVKgVsACAAAAAAqvadzJFLqQbs8WxgZ2D2X+XnaPSDMLCVVgWxx5jnLcYAAzIyAH0AAAAFZAAgAAAAAF2wZoDL6/V59QqO8vdRZWDpXpkV4h4KOCSn5e7x7nmzBXMAIAAAAADLZBu7LCYjbThaVUqMK14H/elrVOYIKJQCx4C9Yjw37gVsACAAAAAAEh6Vs81jLU204aGpL90fmYTm5i5R8/RT1uIbg6VU3HwAAzIzAH0AAAAFZAAgAAAAAH27yYaLn9zh2CpvaoomUPercSfJRUmBY6XFqmhcXi9QBXMAIAAAAAAUwumVlIYIs9JhDhSj0R0+59psCMsFk94E62VxkPt42QVsACAAAAAAT5x2hCCd2bpmpnyWaxas8nSxTc8e4C9DfKaqr0ABEysAAzI0AH0AAAAFZAAgAAAAALMg2kNAO4AFFs/mW3In04yFeN4AP6Vo0klyUoT06RquBXMAIAAAAAAgGWJbeIdwlpqXCyVIYSs0dt54Rfc8JF4b8uYc+YUj0AVsACAAAAAAWHeWxIkyvXTOWvfZzqtPXjfGaWWKjGSIQENTU3zBCrsAAzI1AH0AAAAFZAAgAAAAALas/i1T2DFCEmrrLEi7O2ngJZyFHialOoedVXS+OjenBXMAIAAAAAA1kK0QxY4REcGxHeMkgumyF7iwlsRFtw9MlbSSoQY7uAVsACAAAAAAUNlpMJZs1p4HfsD4Q4WZ4TBEi6Oc2fX34rzyynqWCdwAAzI2AH0AAAAFZAAgAAAAAP1TejmWg1CEuNSMt6NUgeQ5lT+oBoeyF7d2l5xQrbXWBXMAIAAAAABPX0kj6obggdJShmqtVfueKHplH4ZrXusiwrRDHMOKeQVsACAAAAAAIYOsNwC3DA7fLcOzqdr0bOFdHCfmK8tLwPoaE9uKOosAAzI3AH0AAAAFZAAgAAAAAMrKn+QPa/NxYezNhlOX9nyEkN1kE/gW7EuZkVqYl0b8BXMAIAAAAABUoZMSPUywRGfX2EEencJEKH5x/P9ySUVrhStAwgR/LgVsACAAAAAAMgZFH6lQIIDrgHnFeslv3ld20ynwQjQJt3cAp4GgrFkAAzI4AH0AAAAFZAAgAAAAAMmD1+a+oVbiUZd1HuZqdgtdVsVKwuWAn3/M1B6QGBM3BXMAIAAAAACLyytOYuZ9WEsIrrtJbXUx4QgipbaAbmlJvSZVkGi0CAVsACAAAAAA4v1lSp5H9BB+HYJ4bH43tC8aeuPZMf78Ng1JOhJh190AAzI5AH0AAAAFZAAgAAAAAOVKV7IuFwmYP1qVv8h0NvJmfPICu8yQhzjG7oJdTLDoBXMAIAAAAABL70XLfQLKRsw1deJ2MUvxSWKxpF/Ez73jqtbLvqbuogVsACAAAAAAvfgzIorXxE91dDt4nQxYfntTsx0M8Gzdsao5naQqcRUAAzMwAH0AAAAFZAAgAAAAAKS/1RSAQma+xV9rz04IcdzmavtrBDjOKPM+Z2NEyYfPBXMAIAAAAAAOJDWGORDgfRv8+w5nunh41wXb2hCA0MRzwnLnQtIqPgVsACAAAAAAf42C1+T7xdHEFF83+c2mF5S8PuuL22ogXXELnRAZ4boAAzMxAH0AAAAFZAAgAAAAAFeq8o82uNY1X8cH6OhdTzHNBUnCChsEDs5tm0kPBz3qBXMAIAAAAABaxMBbsaeEj/EDtr8nZfrhhhirBRPJwVamDo5WwbgvTQVsACAAAAAAMbH453A+BYAaDOTo5kdhV1VdND1avNwvshEG/4MIJjQAAzMyAH0AAAAFZAAgAAAAAI8IKIfDrohHh2cjspJHCovqroSr5N3QyVtNzFvT5+FzBXMAIAAAAABXHXteKG0DoOMmECKp6ro1MZNQvXGzqTDdZ0DUc8QfFAVsACAAAAAA/w5s++XYmO+9TWTbtGc3n3ndV4T9JUribIbF4jmDLSMAAzMzAH0AAAAFZAAgAAAAAJkHvm15kIu1OtAiaByj5ieWqzxiu/epK6c/9+KYIrB0BXMAIAAAAACzg5TcyANk0nes/wCJudd1BwlkWWF6zw3nGclq5v3SJQVsACAAAAAAvruXHTT3irPJLyWpI1j/Xwf2FeIE/IV+6Z49pqRzISoAAzM0AH0AAAAFZAAgAAAAAAYSOvEWWuSg1Aym7EssNLR+xsY7e9BcwsX4JKlnSHJcBXMAIAAAAABT48eY3PXVDOjw7JpNjOe1j2JyI3LjDnQoqZ8Je5B2KgVsACAAAAAAU2815RR57TQ9uDg0XjWjBkAKvf8yssxDMzrM4+FqP6AAAzM1AH0AAAAFZAAgAAAAAGQxC9L1e9DfO5XZvX1yvc3hTLtQEdKO9FPMkyg0Y9ZABXMAIAAAAADtmcMNJwdWLxQEArMGZQyzpnu+Z5yMmPAkvgq4eAKwNQVsACAAAAAAJ88zt4Y/Hoqh+zrf6KCOiUwHbOzCxSfp6k/qsZaYGEgAAzM2AH0AAAAFZAAgAAAAADLHK2LNCNRO0pv8n4fAsxwtUqCNnVK8rRgNiQfXpHSdBXMAIAAAAACf16EBIHRKD3SzjRW+LMOl+47QXA3CJhMzlcqyFRW22AVsACAAAAAAMGz4fAOa0EoVv90fUffwLjBrQhHATf+NdlgCR65vujAAAzM3AH0AAAAFZAAgAAAAAHiZJiXKNF8bbukQGsdYkEi95I+FSBHy1I5/hK2uEZruBXMAIAAAAADE+lZBa8HDUJPN+bF6xI9x4N7GF9pj3vBR7y0BcfFhBAVsACAAAAAAGIEN6sfqq30nyxW4dxDgXr/jz5HmvA9T1jx/pKCn4zgAAzM4AH0AAAAFZAAgAAAAAI1oa2OIw5TvhT14tYCGmhanUoYcCZtNbrVbeoMldHNZBXMAIAAAAAAx2nS0Ipblf2XOgBiUOuJFBupBhe7nb6QPLZlA4aMPCgVsACAAAAAA9xu828hugIgo0E3de9dZD+gTpVUGlwtDba+tw/WcbUoAAzM5AH0AAAAFZAAgAAAAABgTWS3Yap7Q59hii/uPPimHWXsr+DUmsqfwt/X73qsOBXMAIAAAAACKK05liW5KrmEAvtpCB1WUltruzUylDDpjea//UlWoOAVsACAAAAAAcgN4P/wakJ5aJK5c1bvJBqpVGND221dli2YicPFfuAYAAzQwAH0AAAAFZAAgAAAAABOAnBPXDp6i9TISQXvcNKwGDLepZTu3cKrB4vKnSCjBBXMAIAAAAADjjzZO7UowAAvpwyG8BNOVqLCccMFk3aDK4unUeft5ywVsACAAAAAA4zkCd4k9gvfXoD1C7vwTjNcdVJwEARh8h/cxZ4PNMfgAAzQxAH0AAAAFZAAgAAAAAHN8hyvT1lYrAsdiV5GBdd5jhtrAYE/KnSjw2Ka9hjz9BXMAIAAAAAD794JK7EeXBs+D7yOVK7nWF8SbZ/7U8gZ7nnT9JFNwTAVsACAAAAAAg8Wt1HO3NhByq2ggux2a4Lo6Gryr24rEFIqh2acrwWMAAzQyAH0AAAAFZAAgAAAAAO93bPrq8bsnp1AtNd9ETnXIz0lH/2HYN/vuw9wA3fyFBXMAIAAAAABHlls5fbaF2oAGqptC481XQ4eYxInTC29aElfmVZgDUgVsACAAAAAANoQXEWpXJpgrSNK/cKi/m7oYhuSRlp1IZBF0bqTEATcAAzQzAH0AAAAFZAAgAAAAAL1YsAZm1SA0ztU6ySIrQgCCA74V6rr0/4iIygCcaJL6BXMAIAAAAADTXWTHWovGmUR1Zg9l/Aqq9H5mOCJQQrb/Dfae7e3wKAVsACAAAAAA5dunyJK6/SVfDD0t9QlNBcFqoZnf9legRjHaLSKAoQMAAzQ0AH0AAAAFZAAgAAAAAEoFAeHk0RZ9kD+cJRD3j7PcE5gzWKnyBrF1I/MDNp5mBXMAIAAAAACgHtc2hMBRSZjKw8RAdDHK+Pi1HeyjiBuAslGVNcW5tAVsACAAAAAAXzBLfq+GxRtX4Wa9fazA49DBLG6AjZm2XODStJKH8D0AAzQ1AH0AAAAFZAAgAAAAAAW+7DmSN/LX+/0uBVJDHIc2dhxAGz4+ehyyz8fAnNGoBXMAIAAAAAA6Ilw42EvvfLJ3Eq8Afd+FjPoPcQutZO6ltmCLEr8kxQVsACAAAAAAbbZalyo07BbFjPFlYmbmv0z023eT9eLkHqeVUnfUAUAAAzQ2AH0AAAAFZAAgAAAAANBdV7M7kuYO3EMoQItAbXv4t2cIhfaT9V6+s4cg9djlBXMAIAAAAABvz4MIvZWxxrcJCL5qxLfFhXiUYB1OLHdKEjco94SgDgVsACAAAAAAK2GVGvyPIKolF/ECcmfmkVcf1/IZNcaTv96N92yGrkEAAzQ3AH0AAAAFZAAgAAAAAMoAoiAn1kc79j5oPZtlMWHMhhgwNhLUnvqkqIFvcH1NBXMAIAAAAADcJTW7WiCyW0Z9YDUYwppXhLj4Ac1povpJvcAq+i48MQVsACAAAAAAIGxGDzoeB3PTmudl4+j6piQB++e33EEzuzAiXcqGxvUAAzQ4AH0AAAAFZAAgAAAAACI3j5QP7dWHpcT6WO/OhsWwRJNASBYqIBDNzW8IorEyBXMAIAAAAABxUpBSjXwCKDdGP9hYU+RvyR+96kChfvyyRC4jZmztqAVsACAAAAAAvBCHguWswb4X0xdcAryCvZgQuthXzt7597bJ5VxAMdgAAzQ5AH0AAAAFZAAgAAAAAKsbycEuQSeNrF8Qnxqw3x3og8JmQabwGqnDbqzFRVrrBXMAIAAAAACno/3ef2JZJS93SVVzmOZSN+jjJHT8s0XYq2M46d2sLAVsACAAAAAAAt5zLJG+/j4K8rnkFtAn8IvdUVNefe6utJ3rdzgwudIAAzUwAH0AAAAFZAAgAAAAAPXIcoO8TiULqlxzb74NFg+I8kWX5uXIDUPnh2DobIoMBXMAIAAAAADR6/drkdTpnr9g1XNvKDwtBRBdKn7c2c4ZNUVK5CThdQVsACAAAAAAJqOA1c6KVog3F4Hb/GfDb3jCxXDRTqpXWSbMH4ePIJsAAzUxAH0AAAAFZAAgAAAAAEa03ZOJmfHT6/nVadvIw71jVxEuIloyvxXraYEW7u7pBXMAIAAAAADzRlBJK75FLiKjz3djqcgjCLo/e3yntI3MnPS48OORhgVsACAAAAAAnQhx4Rnyj081XrLRLD5NLpWmRWCsd0M9Hl7Jl19R0h8AAzUyAH0AAAAFZAAgAAAAAKx8NLSZUU04pSSGmHa5fh2oLHsEN5mmNMNHL95/tuC9BXMAIAAAAAA59hcXVaN3MNdHoo11OcH1aPRzHCwpVjO9mGfMz4xh3QVsACAAAAAAYIPdjV2XbPj7dBeHPwnwhVU7zMuJ+xtMUW5mIOYtmdAAAzUzAH0AAAAFZAAgAAAAAHNKAUxUqBFNS9Ea9NgCZoXMWgwhP4x0/OvoaPRWMquXBXMAIAAAAABUZ551mnP4ZjX+PXU9ttomzuOpo427MVynpkyq+nsYCQVsACAAAAAALnVK5p2tTTeZEh1zYt4iqKIQT9Z0si//Hy1L85oF+5IAAzU0AH0AAAAFZAAgAAAAALfGXDlyDVcGaqtyHkLT0qpuRhJQLgCxtznazhFtuyn/BXMAIAAAAABipxlXDq14C62pXhwAeen5+syA+/C6bN4rtZYcO4zKwAVsACAAAAAAXUf0pzUq0NhLYagWDap4uEiwq5rLpcx29rWbt1NYMsMAAzU1AH0AAAAFZAAgAAAAANoEr8sheJjg4UCfBkuUzarU9NFoy1xwbXjs5ifVDeA9BXMAIAAAAABPoyTf6M+xeZVGES4aNzVlq7LgjqZXJ/QunjYVusGUEAVsACAAAAAA1hA2gMeZZPUNytk9K+lB1RCqWRudRr7GtadJlExJf8oAAzU2AH0AAAAFZAAgAAAAAKvDiK+xjlBe1uQ3SZTNQl2lClIIvpP/5CHwY6Kb3WlgBXMAIAAAAAANnxImq5MFbWaRBHdJp+yD09bVlcFtiFDYsy1eDZj+iQVsACAAAAAAWtsyO+FxMPSIezwsV1TJD8ZrXAdRnQM6DJ+f+1V3qEkAAzU3AH0AAAAFZAAgAAAAAF49IlFH9RmSUSvUQpEPUedEksrQUcjsOv44nMkwXhjzBXMAIAAAAADJtWGbk0bZzmk20obz+mNsp86UCu/nLLlbg7ppxYn7PgVsACAAAAAA3k0Tj/XgPQtcYijH8cIlQoe/VXf15q1nrZNmg7yWYEgAAzU4AH0AAAAFZAAgAAAAAOuSJyuvz50lp3BzXlFKnq62QkN2quNU1Gq1IDsnFoJCBXMAIAAAAAAqavH1d93XV3IzshWlMnzznucadBF0ND092/2ApI1AcAVsACAAAAAAzUrK4kpoKCmcpdZlZNI13fddjdoAseVe67jaX1LobIIAAzU5AH0AAAAFZAAgAAAAALtgC4Whb4ZdkCiI30zY6fwlsxSa7lEaOAU3SfUXr02XBXMAIAAAAACgdZ6U1ZVgUaZZwbIaCdlANpCw6TZV0bwg3DS1NC/mnAVsACAAAAAAzI49hdpp0PbO7S2KexISxC16sE73EUAEyuqUFAC/J48AAzYwAH0AAAAFZAAgAAAAAF6PfplcGp6vek1ThwenMHVkbZgrc/dHgdsgx1VdPqZ5BXMAIAAAAACha3qhWkqmuwJSEXPozDO8y1ZdRLyzt9Crt2vjGnT7AAVsACAAAAAA7nvcU59+LwxGupSF21jAeAE0x7JE94tjRkJfgM1yKU8AAzYxAH0AAAAFZAAgAAAAAKoLEhLvLjKc7lhOJfx+VrGJCx9tXlOSa9bxQzGR6rfbBXMAIAAAAAAIDK5wNnjRMBzET7x/KAMExL/zi1IumJM92XTgXfoPoAVsACAAAAAAFkUYWFwNr815dEdFqp+TiIozDcq5IBNVkyMoDjharDQAAzYyAH0AAAAFZAAgAAAAADoQv6lutRmh5scQFvIW6K5JBquLxszuygM1tzBiGknIBXMAIAAAAADAD+JjW7FoBQ76/rsECmmcL76bmyfXpUU/awqIsZdO+wVsACAAAAAAPFHdLw3jssmEXsgtvl/RBNaUCRA1kgSwsofG364VOvQAAzYzAH0AAAAFZAAgAAAAAJNHUGAgn56KekghO19d11nai3lAh0JAlWfeP+6w4lJBBXMAIAAAAAD9XGJlvz59msJvA6St9fKW9CG4JoHV61rlWWnkdBRLzwVsACAAAAAAxwP/X/InJJHmrjznvahIMgj6pQR30B62UtHCthSjrP0AAzY0AH0AAAAFZAAgAAAAAHgYoMGjEE6fAlAhICv0+doHcVX8CmMVxyq7+jlyGrvmBXMAIAAAAAC/5MQZgTHuIr/O5Z3mXPvqrom5JTQ8IeSpQGhO9sB+8gVsACAAAAAAuPSXVmJUAUpTQg/A9Bu1hYczZF58KEhVofakygbsvJQAAzY1AH0AAAAFZAAgAAAAANpIljbxHOM7pydY877gpRQvYY2TGK7igqgGsavqGPBABXMAIAAAAAAqHyEu9gpurPOulApPnr0x9wrygY/7mXe9rAC+tPK80wVsACAAAAAA7gkPzNsS3gCxdFBWbSW9tkBjoR5ib+saDvpGSB3A3ogAAzY2AH0AAAAFZAAgAAAAAGR+gEaZTeGNgG9BuM1bX2R9ed4FCxBA9F9QvdQDAjZwBXMAIAAAAABSkrYFQ6pf8MZ1flgmeIRkxaSh/Eep4Btdx4QYnGGnwAVsACAAAAAApRovMiV00hm/pEcT4XBsyPNw0eo8RLAX/fuabjdU+uwAAzY3AH0AAAAFZAAgAAAAAFNprhQ3ZwIcYbuzLolAT5n/vc14P9kUUQComDu6eFyKBXMAIAAAAAAcx9z9pk32YbPV/sfPZl9ALIEVsqoLXgqWLVK/tP+heAVsACAAAAAA/qxvuvJbAHwwhfrPVpmCFzNvg2cU/NXaWgqgYUZpgXwAAzY4AH0AAAAFZAAgAAAAADgyPqQdqQrgfmJjRFAILTHzXbdw5kpKyfeoEcy6YYG/BXMAIAAAAAAE+3XsBQ8VAxAkN81au+f3FDeCD/s7KoZD+fnM1MJSSAVsACAAAAAAhRnjrXecwV0yeCWKJ5J/x12Xx4qVJahsCEVHB/1U2rcAAzY5AH0AAAAFZAAgAAAAAI0CT7JNngTCTUSei1Arw7eHWCD0jumv2rb7imjWIlWABXMAIAAAAABSP8t6ya0SyCphXMwnru6ZUDXWElN0NfBvEOhDvW9bJQVsACAAAAAAGWeGmBNDRaMtvm7Rv+8TJ2sJ4WNXKcp3tqpv5Se9Ut4AAzcwAH0AAAAFZAAgAAAAAD/FIrGYFDjyYmVb7oTMVwweWP7A6F9LnyIuNO4MjBnXBXMAIAAAAACIZgJCQRZu7NhuNMyOqCn1tf+DfU1qm10TPCfj5JYV3wVsACAAAAAA5hmY4ptuNxULGf87SUFXQWGAONsL9U29duh8xqsHtxoAAzcxAH0AAAAFZAAgAAAAAHIkVuNDkSS1cHIThKc/O0r2/ubaABTOi8Q1r/dvBAsEBXMAIAAAAADdHYqchEiJLM340c3Q4vJABmmth3+MKzwLYlsG6GS7sQVsACAAAAAADa+KP/pdTiG22l+ZWd30P1iHjnBF4zSNRdFm0oEK82kAAzcyAH0AAAAFZAAgAAAAAJmoDILNhC6kn3masElfnjIjP1VjsjRavGk1gSUIjh1NBXMAIAAAAAD97Ilvp3XF8T6MmVVcxMPcdL80RgQ09UoC6PnoOvZ1IQVsACAAAAAA2RK3Xng6v8kpvfVW9tkVXjpE+BSnx9/+Fw85Evs+kUEAAzczAH0AAAAFZAAgAAAAAI5bm3YO0Xgf0VT+qjVTTfvckecM3Cwqj7DTKZXf8/NXBXMAIAAAAAD/m+h8fBhWaHm6Ykuz0WX1xL4Eme3ErLObyEVJf8NCywVsACAAAAAAfb1VZZCqs2ivYbRzX4p5CtaCkKW+g20Pr57FWXzEZi8AAzc0AH0AAAAFZAAgAAAAANqo4+p6qdtCzcB4BX1wQ6llU7eFBnuu4MtZwp4B6mDlBXMAIAAAAAAGiz+VaukMZ+6IH4jtn4KWWdKK4/W+O+gRioQDrfzpMgVsACAAAAAAG4YYkTp80EKo59mlHExDodRQFR7njhR5dmISwUJ6ukAAAzc1AH0AAAAFZAAgAAAAAPrFXmHP2Y4YAm7b/aqsdn/DPoDkv7B8egWkfe23XsM1BXMAIAAAAAAGhwpKAr7skeqHm3oseSbO7qKNhmYsuUrECBxJ5k+D2AVsACAAAAAAAqPQi9luYAu3GrFCEsVjd9z2zIDcp6SPTR2w6KQEr+IAAzc2AH0AAAAFZAAgAAAAABzjYxwAjXxXc0Uxv18rH8I3my0Aguow0kTwKyxbrm+cBXMAIAAAAADVbqJVr6IdokuhXkEtXF0C2gINLiAjMVN20lE20Vmp2QVsACAAAAAAD7K1Fx4gFaaizkIUrf+EGXQeG7QX1jadhGc6Ji471H8AAzc3AH0AAAAFZAAgAAAAAFMm2feF2fFCm/UC6AfIyepX/xJDSmnnolQIBnHcPmb5BXMAIAAAAABLI11kFrQoaNVZFmq/38aRNImPOjdJh0Lo6irI8M/AaAVsACAAAAAAOWul0oVqJ9CejD2RqphhTC98DJeRQy5EwbNerU2+4l8AAzc4AH0AAAAFZAAgAAAAAJvXB3KyNiNtQko4SSzo/9b2qmM2zU9CQTTDfLSBWMgRBXMAIAAAAAAvjuVP7KsLRDeqVqRziTKpBrjVyqKiIbO9Gw8Wl2wFTAVsACAAAAAADlE+oc1ins+paNcaOZJhBlKlObDJ4VQORWjFYocM4LgAAzc5AH0AAAAFZAAgAAAAAPGdcxDiid8z8XYnfdDivNMYVPgBKdGOUw6UStU+48CdBXMAIAAAAAARj6g1Ap0eEfuCZ4X2TsEw+Djrhto3fA5nLwPaY0vCTgVsACAAAAAAoHqiwGOUkBu8SX5U1yHho+UIFdSN2MdQN5s6bQ0EsJYAAzgwAH0AAAAFZAAgAAAAAP5rGPrYGt3aKob5f/ldP0qrW7bmWvqnKY4QwdDWz400BXMAIAAAAADTQkW2ymaaf/bhteOOGmSrIR97bAnJx+yN3yMj1bTeewVsACAAAAAADyQnHGH2gF4w4L8axUsSTf6Ubk7L5/eoFOJk12MtZAoAAzgxAH0AAAAFZAAgAAAAAAlz6wJze5UkIxKpJOZFGCOf3v2KByWyI6NB6JM9wNcBBXMAIAAAAABUC7P/neUIHHoZtq0jFVBHY75tSFYr1Y5S16YN5XxC1QVsACAAAAAAgvxRbXDisNnLY3pfsjDdnFLtkvYUC4lhA68eBXc7KAwAAzgyAH0AAAAFZAAgAAAAAFJ8AtHcjia/9Y5pLEc3qVgH5xKiXw12G9Kn2A1EY8McBXMAIAAAAAAxe7Bdw7eUSBk/oAawa7uicTEDgXLymRNhBy1LAxhDvwVsACAAAAAAxKPaIBKVx3jTA+R/el7P7AZ7efrmTGjJs3Hj/YdMddwAAzgzAH0AAAAFZAAgAAAAAO8uwQUaKFb6vqR3Sv3Wn4QAonC2exOC9lGG1juqP5DtBXMAIAAAAABZf1KyJgQg8/Rf5c02DgDK2aQu0rNCOvaL60ohDHyY+gVsACAAAAAAqyEjfKC8lYoIfoXYHUqHZPoaA6EK5BAZy5dxXZmay4kAAzg0AH0AAAAFZAAgAAAAAE8YtqyRsGCeiR6hhiyisR/hccmK4nZqIMzO4lUBmEFzBXMAIAAAAAC1UYOSKqAeG1UJiKjWFVskRhuFKpj9Ezy+lICZvFlN5AVsACAAAAAA6Ct9nNMKyRazn1OKnRKagm746CGu+jyhbL1qJnZxGi0AAzg1AH0AAAAFZAAgAAAAAPhCrMausDx1QUIEqp9rUdRKyM6a9AAx7jQ3ILIu8wNIBXMAIAAAAACmH8lotGCiF2q9VQxhsS+7LAZv79VUAsOUALaGxE/EpAVsACAAAAAAnc1xCKfdvbUEc8F7XZqlNn1C+hZTtC0I9I3LL06iaNkAAzg2AH0AAAAFZAAgAAAAAOBi/GAYFcstMSJPgp3VkMiuuUUCrZytvqYaU8dwm8v2BXMAIAAAAACEZSZVyD3pKzGlbdwlYmWQhHHTV5SnNLknl2Gw8IaUTQVsACAAAAAAfsLZsEDcWSuNsIo/TD1ReyQW75HPMgmuKZuWFOLKRLoAAzg3AH0AAAAFZAAgAAAAAIQuup+YGfH3mflzWopN8J1X8o8a0d9CSGIvrA5HOzraBXMAIAAAAADYvNLURXsC2ITMqK14LABQBI+hZZ5wNf24JMcKLW+84AVsACAAAAAACzfjbTBH7IwDU91OqLAz94RFkoqBOkzKAqQb55gT4/MAAzg4AH0AAAAFZAAgAAAAAKsh0ADyOnVocFrOrf6MpTrNvAj8iaiE923DPryu124gBXMAIAAAAADg24a8NVE1GyScc6tmnTbmu5ulzO+896fE92lN08MeswVsACAAAAAAaPxcOIxnU7But88/yadOuDJDMcCywwrRitaxMODT4msAAzg5AH0AAAAFZAAgAAAAAKkVC2Y6HtRmv72tDnPUSjJBvse7SxLqnr09/Uuj9sVVBXMAIAAAAABYNFUkH7ylPMN+Bc3HWX1e0flGYNbtJNCY9SltJCW/UAVsACAAAAAAZYK/f9H4OeihmpiFMH7Wm7uLvs2s92zNA8wyrNZTsuMAAzkwAH0AAAAFZAAgAAAAADDggcwcb/Yn1Kk39sOHsv7BO/MfP3m/AJzjGH506Wf9BXMAIAAAAAAYZIsdjICS0+BDyRUPnrSAZfPrwtuMaEDEn0/ijLNQmAVsACAAAAAAGPnYVvo2ulO9z4LGd/69NAklfIcZqZvFX2KK0s+FcTUAAzkxAH0AAAAFZAAgAAAAAEWY7dEUOJBgjOoWVht1wLehsWAzB3rSOBtLgTuM2HC8BXMAIAAAAAAAoswiHRROurjwUW8u8D5EUT+67yvrgpB/j6PzBDAfVwVsACAAAAAA6NhRTYFL/Sz4tao7vpPjLNgAJ0FX6P/IyMW65qT6YsMAAzkyAH0AAAAFZAAgAAAAAPZaapeAUUFPA7JTCMOWHJa9lnPFh0/gXfAPjA1ezm4ZBXMAIAAAAACmJvLY2nivw7/b3DOKH/X7bBXjJwoowqb1GtEFO3OYgAVsACAAAAAA/JcUoyKacCB1NfmH8vYqC1f7rd13KShrQqV2r9QBP44AAzkzAH0AAAAFZAAgAAAAAK00u6jadxCZAiA+fTsPVDsnW5p5LCr4+kZZZOTDuZlfBXMAIAAAAAAote4zTEYMDgaaQbAdN8Dzv93ljPLdGjJzvnRn3KXgtQVsACAAAAAAxXd9Mh6R3mnJy8m7UfqMKi6oD5DlZpkaOz6bEjMOdiwAAzk0AH0AAAAFZAAgAAAAAFbgabdyymiEVYYwtJSWa7lfl/oYuj/SukzJeDOR6wPVBXMAIAAAAADAFGFjS1vPbN6mQEhkDYTD6V2V23Ys9gUEUMGNvMPkaAVsACAAAAAAL/D5Sze/ZoEanZLK0IeEkhgVkxEjMWVCfmJaD3a8uNIAAzk1AH0AAAAFZAAgAAAAABNMR6UBv2E627CqLtQ/eDYx7OEwQ7JrR4mSHFa1N8tLBXMAIAAAAAAxH4gucI4UmNVB7625C6hFSVCuIpJO3lusJlPuL8H5EQVsACAAAAAAVLHNg0OUVqZ7WGOP53BkTap9FOw9dr1P4J8HxqFqU04AAzk2AH0AAAAFZAAgAAAAAG8cd6WBneNunlqrQ2EmNf35W7OGObGq9WL4ePX+LUDmBXMAIAAAAAAjJ2+sX87NSis9hBsgb1QprVRnO7Bf+GObCGoUqyPE4wVsACAAAAAAs9c9SM49/pWmyUQKslpt3RTMBNSRppfNO0JBvUqHPg0AAzk3AH0AAAAFZAAgAAAAAFWOUGkUpy8yf6gB3dio/aOfRKh7XuhvsUj48iESFJrGBXMAIAAAAAAY7sCDMcrUXvNuL6dO0m11WyijzXZvPIcOKob6IpC4PQVsACAAAAAAJOP+EHz6awDb1qK2bZQ3kTV7wsj5Daj/IGAWh4g7omAAAzk4AH0AAAAFZAAgAAAAAGUrIdKxOihwNmo6B+aG+Ag1qa0+iqdksHOjQj+Oy9bZBXMAIAAAAABwa5dbI2KmzBDNBTQBEkjZv4sPaeRkRNejcjdVymRFKQVsACAAAAAA4ml/nm0gJNTcJ4vuD+T2Qfq2fQZlibJp/j6MOGDrbHMAAzk5AH0AAAAFZAAgAAAAAOx89xV/hRk64/CkM9N2EMK6aldII0c8smdcsZ46NbP8BXMAIAAAAADBF6tfQ+7q9kTuLyuyrSnDgmrdmrXkdhl980i1KHuGHgVsACAAAAAACUqiFqHZdGbwAA+hN0YUE5zFg+H+dabIB4dj5/75W/YAAzEwMAB9AAAABWQAIAAAAADJDdC9aEFl4Y8J/awHbnXGHjfP+VXQilPHJg7ewaJI7AVzACAAAAAAE+tqRl6EcBMXvbr4GDiNIYObTsYpa1n6BJk9EjIJVicFbAAgAAAAAJVc+HYYqa0m1Hq6OiRX8c0iRnJYOt6AJAJoG0sG3GMSAAMxMDEAfQAAAAVkACAAAAAA3F9rjEKhpoHuTULVGgfUsGGwJs3bISrXkFP1v6KoQLgFcwAgAAAAAIBf0tXw96Z/Ds0XSIHX/zk3MzUR/7WZR/J6FpxRWChtBWwAIAAAAABWrjGlvKYuTS2s8L9rYy8Hf0juFGJfwQmxVIjkTmFIGQADMTAyAH0AAAAFZAAgAAAAAOYIYoWkX7dGuyKfi3XssUlc7u/gWzqrR9KMkikKVdmSBXMAIAAAAABVF2OYjRTGi9Tw8XCAwZWLpX35Yl271TlNWp6N/nROhAVsACAAAAAA0nWwYzXQ1+EkDvnGq+SMlq20z+j32Su+i/A95SggPb4AAzEwMwB9AAAABWQAIAAAAACMtPm12YtdEAvqu6Eji1yuRXnu1RJP6h0l7pH3lSH4MwVzACAAAAAAENyCFfyUAh1veQBGx+cxiB7Sasrj41jzCGflZkB5cRMFbAAgAAAAAKdI2LMqISr/T5vuJPg6ZRBm5fVi2aQCc4ra3A4+AjbDAAMxMDQAfQAAAAVkACAAAAAAvlI4lDcs6GB1cnm/Tzo014CXWqidCdyE5t2lknWQd4QFcwAgAAAAAD60SpNc4O2KT7J0llKdSpcX1/Xxs97N715a1HsTFkmBBWwAIAAAAABuuRkJWAH1CynggBt1/5sPh9PoGiqTlS24D/OE2uHXLQADMTA1AH0AAAAFZAAgAAAAAKl8zcHJRDjSjJeV/WvMxulW1zrTFtaeBy/aKKhadc6UBXMAIAAAAADBdWQl5SBIvtZZLIHszePwkO14W1mQ0izUk2Ov21cPNAVsACAAAAAAHErCYycpqiIcCZHdmPL1hi+ovLQk4TAvENpfLdTRamQAAzEwNgB9AAAABWQAIAAAAABb6LXDWqCp1beQgQjj8I3sRTtFhlrmiBi+h/+ikmrvugVzACAAAAAA9stpgTecT7uTyaGNs3K9Bp0A7R0QaIAOfscyMXHBPX8FbAAgAAAAAHUt+McyXrJ1H8SwnHNVO181Ki8vDAM1f7XI26mg95ZDAAMxMDcAfQAAAAVkACAAAAAA97NTT+81PhDhgptNtp4epzA0tP4iNb9j1AWkiiiKGM8FcwAgAAAAAKPbHg7ise16vxmdPCzksA/2Mn/qST0L9Xe8vnQugVkcBWwAIAAAAABB0EMXfvju4JU/mUH/OvxWbPEl9NJkcEp4iCbkXI41fAADMTA4AH0AAAAFZAAgAAAAAMqpayM2XotEFmm0gwQd9rIzApy0X+7HfOhNk6VU7F5lBXMAIAAAAACJR9+q5T9qFHXFNgGbZnPubG8rkO6cwWhzITQTmd6VgwVsACAAAAAAOZLQ6o7e4mVfDzbpQioa4d3RoTvqwgnbmc5Qh2wsZuoAAzEwOQB9AAAABWQAIAAAAADQnslvt6Hm2kJPmqsTVYQHE/wWeZ4bE1XSkt7TKy0r1gVzACAAAAAA8URTA4ZMrhHPvlp53TH6FDCzS+0+61qHm5XK6UiOrKEFbAAgAAAAAHQbgTCdZcbdA0avaTmZXUKnIS7Nwf1tNrcXDCw+PdBRAAMxMTAAfQAAAAVkACAAAAAAhujlgFPFczsdCGXtQ/002Ck8YWQHHzvWvUHrkbjv4rwFcwAgAAAAALbV0lLGcSGfE7mDM3n/fgEvi+ifjl7WZ5b3aqjDNvx9BWwAIAAAAACbceTZy8E3QA1pHmPN5kTlOx3EO8kJM5PUjTVftw1VpgADMTExAH0AAAAFZAAgAAAAABm/6pF96j26Jm7z5KkY1y33zcAEXLx2n0DwC03bs/ixBXMAIAAAAAD01OMvTZI/mqMgxIhA5nLs068mW+GKl3OW3ilf2D8+LgVsACAAAAAAaLvJDrqBESTNZSdcXsd+8GXPl8ZkUsGpeYuyYVv/kygAAzExMgB9AAAABWQAIAAAAACfw9/te4GkHZAapC9sDMHHHZgmlTrccyJDPFciOMSOcwVzACAAAAAAIIC1ZpHObvmMwUfqDRPl4C1aeuHwujM1G/yJbvybMNAFbAAgAAAAAAs9x1SnVpMfNv5Bm1aXGwHmbbI9keWa9HRD35XuCBK5AAMxMTMAfQAAAAVkACAAAAAAkxHJRbnShpPOylLoDdNShfILeA1hChKFQY9qQyZ5VmsFcwAgAAAAAKidrY+rC3hTY+YWu2a7fuMH2RD/XaiTIBW1hrxNCQOJBWwAIAAAAACW0kkqMIzIFMn7g+R0MI8l15fr3k/w/mHtY5n6SYTEwAADMTE0AH0AAAAFZAAgAAAAAByuYl8dBvfaZ0LO/81JW4hYypeNmvLMaxsIdvqMPrWoBXMAIAAAAABNddwobOUJzm9HOUD8BMZJqkNCUCqstHZkC76FIdNg9AVsACAAAAAAQQOkIQtkyNavqCnhQbNg3HfqrJdsAGaoxSJePJl1qXsAAzExNQB9AAAABWQAIAAAAABxMy7X5hf7AXGDz3Y/POu1ZpkMlNcSvSP92NOO/Gs7wAVzACAAAAAAHJshWo2T5wU2zvqCyJzcJQKQaHFHpCpMc9oWBXkpUPoFbAAgAAAAAGeiJKzlUXAvL0gOlW+Hz1mSa2HsV4RGmyLmCHlzbAkoAAMxMTYAfQAAAAVkACAAAAAAlqbslixl7Zw3bRlibZbe/WmKw23k8uKeIzPKYEtbIy0FcwAgAAAAAHEKwpUxkxOfef5HYvulXPmdbzTivwdwrSYIHDeNRcpcBWwAIAAAAADuPckac21Hrg/h0kt5ShJwVEZ9rx6SOHd2+HDjqxEWTQADMTE3AH0AAAAFZAAgAAAAAMXrXx0saZ+5gORmwM2FLuZG6iuO2YS+1IGPoAtDKoKBBXMAIAAAAADIQsxCr8CfFKaBcx8kIeSywnGh7JHjKRJ9vJd9x79y7wVsACAAAAAAcvBV+SykDYhmRFyVYwFYB9oBKBSHr55Jdz2cXeowsUQAAzExOAB9AAAABWQAIAAAAAAm83FA9yDUpwkbKTihe7m53u+DivS9BU2b4vQMtCVQ2AVzACAAAAAAz3m1UB/AbZPa4QSKFDnUgHaT78+6iGOFAtouiBorEgEFbAAgAAAAAIgbpyYtJj5513Z5XYqviH/HXG/5+mqR52iBbfqMmDtZAAMxMTkAfQAAAAVkACAAAAAAJRzYK0PUwr9RPG2/7yID0WgcTJPB2Xjccp5LAPDYunkFcwAgAAAAAIIh24h3DrltAzNFhF+MEmPrZtzr1PhCofhChZqfCW+jBWwAIAAAAAAzRNXtL5o9VXMk5D5ylI0odPDJDSZZry1wfN+TedH70gADMTIwAH0AAAAFZAAgAAAAAHSaHWs/dnmI9sc7nB50VB2Bzs0kHapMHCQdyVEYY30TBXMAIAAAAACkV22lhEjWv/9/DubfHBAcwJggKI5mIbSK5L2nyqloqQVsACAAAAAAS19m7DccQxgryOsBJ3GsCs37yfQqNi1G+S6fCXpEhn4AAzEyMQB9AAAABWQAIAAAAAAC/I4TQRtCl12YZmdGz17X4GqSQgfwCPgRBwdHmdwu+QVzACAAAAAAx8f3z2ut/RAZhleari4vCEE+tNIn4ikjoUwzitfQ588FbAAgAAAAAJci0w1ZB8W2spJQ+kMpod6HSCtSR2jrabOH+B0fj3A4AAMxMjIAfQAAAAVkACAAAAAADGB5yU2XT0fse/MPWgvBvZikVxrl5pf3S5K1hceKWooFcwAgAAAAAIxTmlLHMjNaVDEfJbXvRez0SEPWFREBJCT6qTHsrljoBWwAIAAAAAAlswzAl81+0DteibwHD+CG5mZJrfHXa9NnEFRtXybzzwADMTIzAH0AAAAFZAAgAAAAABmO7QD9vxWMmFjIHz13lyOeV6vHT6mYCsWxF7hb/yOjBXMAIAAAAACT9lmgkiqzuWG24afuzYiCeK9gmJqacmxAruIukd0xEAVsACAAAAAAZa0/FI/GkZR7CtX18Xg9Tn9zfxkD0UoaSt+pIO5t1t4AAzEyNAB9AAAABWQAIAAAAAAfPUoy7QyZKhIIURso+mkP9qr1izbjETqF5s22GwjCjAVzACAAAAAAvLMsIDQ/go4VUxeh50UHmsvMvfx51cwyONnRD2odvC0FbAAgAAAAAKMb+1CodEalAFnDrEL1Ndt8ztamZ+9134m9Kp3GQgd+AAMxMjUAfQAAAAVkACAAAAAAE3ZqUar0Bq2zWbARE0bAv98jBlK9UJ73/xcwdMWWlSkFcwAgAAAAAK4M+MmC+9sFiFsumMyJZQKxWmmJiuG9H7IzKw083xxkBWwAIAAAAAAqkAONzhvMhkyL1D/6h7QQxEkdhC3p2WjXH+VGq5qCqQADMTI2AH0AAAAFZAAgAAAAAMo8FJiOq63cAmyk2O7eI7GcbQh/1j4RrMTqly3rexftBXMAIAAAAADjVmpd0WiRGTw/gAqEgGolt2EI7Csv14vKdmYoMD0aAgVsACAAAAAA07XQBzBUQMNw7F2/YxJjZNuPVpHTTgbLd1oGk77+bygAAzEyNwB9AAAABWQAIAAAAACu5IGaIx7A3Jvly/kzlCsSA4s3iJwuIl8jEdRH0k93NwVzACAAAAAA9NRUyxYE+t0Xyosyt6vIfMFW/vBoYg6sR+jBNs4JAxIFbAAgAAAAAAzyZ91dx+0oMlOVAjRGiMrPySikY/U9eMEB4WJb3uWtAAMxMjgAfQAAAAVkACAAAAAALkRy0GJInXYLA+cgjs6Myb0a+Gu9hgXhHvhLNoGWfckFcwAgAAAAANbALyt9zCSvwnLaWCd2/y2eoB7qkWTvv1Ldu8r40JPuBWwAIAAAAAD4Fl5bV5sz4isIE9bX+lmAp+aAKaZgVYVZeVfrItkCZAADMTI5AH0AAAAFZAAgAAAAAGoUK/DSWhT8LZhszSUqDbTrp8cSA7rdqmADKL+MILtTBXMAIAAAAABHnEE9bVa6lvhfhEMkkV2kzSSxH/sMW/FIJuw3CzWs6wVsACAAAAAAanavcBdqZxgRGKvEK95wTmeL1K1CeDSXZsXUAs81uOgAAzEzMAB9AAAABWQAIAAAAAC922ZDQE3h2fQKibGMZ9hV0WNlmrPYYSdtaSyYxsWYqgVzACAAAAAAagMovciKK6WVjIc2cCj8nK5O/gVOFFVeVAJpRp89tmQFbAAgAAAAAKcTFfPQzaFiAtSFhqbN02sCE1BKWJSrRfGN5L6oZwzkAAMxMzEAfQAAAAVkACAAAAAAtK+JqX3K/z2txjAU15DgX4y90DS2YLfIJFolCOkJJJwFcwAgAAAAAMnR5V7gfX7MNqqUdL5AkWlkhyFXaBRVNej+Rcn8lrQkBWwAIAAAAAA2cDNRXZuiC241TGRvdFyctJnrNcdbZOP9zHio81tkngADMTMyAH0AAAAFZAAgAAAAAAeGrIMK/bac6kPczxbvRYqKMkcpeI2FjdMpD91FDWIvBXMAIAAAAAAix62z1LeS8yvSXCl5gHSIomjyx76fF3S1lp9k900hygVsACAAAAAAiYwzf2m71aWFD5ajcXyW2JX2EzQOkBroTGMg29nLPYIAAzEzMwB9AAAABWQAIAAAAACphf298InM0Us4HT8o1W1MGw0D/02vd7Jh+U0h7qaFaQVzACAAAAAAFXtk7YpqsOJxsqGWSIL+YcBE96G3Zz9D31gPqDW94y8FbAAgAAAAAAOrS1KVA94rjB1jZ1pPocpCeBG+B14RzWoHqVDpp7JbAAMxMzQAfQAAAAVkACAAAAAATLDS2cuDVM3yDMuWNgk2iGKBTzPpfJMbvxVOSY39ZfcFcwAgAAAAAPT5wRi2cLHIUflXzm6EQB/m7xdThP80ir1VV/JBBqvxBWwAIAAAAAB9lEtZS0aXCFbCtSbhnis27S5IPcfWGygHW8AHn3QqzwADMTM1AH0AAAAFZAAgAAAAAJNjExiZVX7jfFGfYpQu16qxLN0YPqVU/5CQ/Y67YSinBXMAIAAAAABMpm2+6KrkRUlXzQoMPHrQmIO6dkQz66tYdfTeA3dKqQVsACAAAAAAFXobHiMLvNZuEPr8jtewCX2J93EZG3JNeyVg92fue6YAAzEzNgB9AAAABWQAIAAAAABlFkYtLCx901X6QVVMkSn6Z7k30UF4xHaA0OZJJ9bdyQVzACAAAAAATez+F9GHcGzTp7jjv4feboUNb8JCkIp4EqcPFisnq7MFbAAgAAAAACE7JvOpBgMoZ7kRd4QbxIhxukPTUxXpzhjnBHiR7XoRAAMxMzcAfQAAAAVkACAAAAAA8NJKN0IxZnruhswGQkiruv8Ih0EMwDcSZx/Xasup9dkFcwAgAAAAAKaJZRxzA+Igeydvuk6cSwUHXcrmT4PjhuPu//FslpdnBWwAIAAAAAD53Rok1Vq/PMAnXmarqoHJ0PEyYUBmVESa9hIpCv/G9QADMTM4AH0AAAAFZAAgAAAAABHxHdEClz7hbSSgE58+dWLlSMJnoPz+jFxp4bB1GmLQBXMAIAAAAAD3nSvT6aGD+A110J/NwEfp0nPutlmuB5B+wA3CC3noGAVsACAAAAAA3Apjd+TapONB7k5wBVwTWgn8t+Sq2oyyU5/+as109RcAAzEzOQB9AAAABWQAIAAAAAC/o8qW/ifk3KuJ01VFkyNLgQafxB5/bGs2G5VyyVafOwVzACAAAAAA1bMqAFGDHSl6BYNLbxApvkAv2K1/oafywiX0MDz1dGUFbAAgAAAAAHJXLlId3edFoniLD/9K2A5973MeP2Ro31flDyqm3l5QAAMxNDAAfQAAAAVkACAAAAAAY2V8I1bz3a1AxTtmED6UhdhA09huFkuuEX8R+d/WDPUFcwAgAAAAAPTVoNRiI76tcRKqd+JBBVyy4+YcKST42p0QX2BtmQ2VBWwAIAAAAACcxt9hg14WqPNiDv1MkqVljM2e2KJEv53lA17LhV6ZigADMTQxAH0AAAAFZAAgAAAAAO2kSsW0WGN9AOtK4xK2SHrGhWiaAbMEKT4iZkRpaDN/BXMAIAAAAABKGzQcPM8LT2dwOggxoWjv/1imYWabbG/G4kBw8OWaxAVsACAAAAAAC9hLK1dScQTAqg+YAG3ObdPzg2Xet57HmOFpGmyUR9UAAzE0MgB9AAAABWQAIAAAAAAiCwzNEEaH/mDam68IdDftnhthyUFdb+ZCNSBQ91WlHQVzACAAAAAA7tHyHcxCzmbJeFYZyPm4mEgkTGKOvwY4MX82OvH0Jn8FbAAgAAAAAAb5IAbZ1hXCNegQ+S+C9i/Z8y6sS8KeU04V6hXa2ml6AAMxNDMAfQAAAAVkACAAAAAAGuCHVNJSuoVkpPOnS5s89GuA+BLi2IPBUr2Bg1sWEPIFcwAgAAAAAEl1gncS5/xO7bQ/KQSstRV3rOT2SW6nV92ZANeG2SR6BWwAIAAAAAA9LOcKmhek8F2wAh8yvT/vjp2gaouuO+Hmv10lwAeWPAADMTQ0AH0AAAAFZAAgAAAAAMfxz7gEaoCdPvXrubDhCZUS0ARLZc1svgbXgMDlVBPgBXMAIAAAAAB6a5dDA3fuT5Vz2KvAcbUEFX/+B7Nw2p1QqbPoQ5TTuAVsACAAAAAAcf/y75UOuI62A6vWH7bYr/5Jz+nirZVYK/81trN6XOQAAzE0NQB9AAAABWQAIAAAAACnYsqF/VzmjIImC9+dqrHO1TM6lJ6fRwM0mM6Wf6paOwVzACAAAAAA5tgZzch8uDCR1ky3SllVaKVpxAlbrhvlNDTazZZRZOAFbAAgAAAAALeGiLJS4z2zhgVpxzyPdRYyACP9QzQBOob34YrIZumCAAMxNDYAfQAAAAVkACAAAAAAEC0sIVmadtW4YMuRXH7RpAhXclsd+3bmqGXCMeaT014FcwAgAAAAABPpXh0uzpsJJB+IRUNajmMB9WGwswfpw5T9xk3Xj6ANBWwAIAAAAAAmf+NYh9TZ/QRu3w/GQz66n7DtfbJijN3G7KzeL8lstAADMTQ3AH0AAAAFZAAgAAAAABaIB3n49Xm9cOafSrQsE0WCcYp8rMIO/qVwIlMF5YLRBXMAIAAAAAC9EyWJV3xOu9bzgdJ/yX+ko7qLf1u3AxNMataW2C9EzQVsACAAAAAAvVbDkLxXx2DcMLifIQ3K0IIJcLcAG9DUrNfI6aoUjNcAAzE0OAB9AAAABWQAIAAAAAA5rZItA/cocRnngYqcJ3nBXQ+l688aKz3EQyLbYYunPAVzACAAAAAAwKyA+L7TgxztPClLrIMk2JXR+w7c04N3ZOqPgjvrIvsFbAAgAAAAACzvZ33h6aWEe8hmo+1f6OXJ72FY5hvWaUuha64ZV3KFAAMxNDkAfQAAAAVkACAAAAAA3htn7oHJ0YYpIrs+Mzyh85Ys67HwAdv5LQl1mCdoMWkFcwAgAAAAAEHjCtNNLenHuSIYux6ezAHsXDaj2DlTF67ToDhDDe6HBWwAIAAAAAD+P4H0sk9jOd+7vOANt2/1Ectb+4ZRGPE8GkHWNXW3MgADMTUwAH0AAAAFZAAgAAAAAEnt18Km/nqggfIJWxzTr9r3hnXNaueG6XO9A5G11LnGBXMAIAAAAAD7QxzGMN/ard5TfFLecE6uusMmXG2+RBsBR+/NCQHUwAVsACAAAAAAQEZ1ZZ8GC8rdbg7s87OM5Gr9qkTXS9+P5DuAZxj5Gl4AAzE1MQB9AAAABWQAIAAAAAAVAKK/GoY8AACu/hyMpO4hdLq6JnEyWNzkyci9sbaD/wVzACAAAAAA2HmeqpMlvvBpV2zQTYIRmsc4MFlfHRwLof0ycJgMg/MFbAAgAAAAACdltCeWi5E/q1Li1eXLChpM2D9QQSGLBZ82NklQSc0oAAMxNTIAfQAAAAVkACAAAAAAhHyq1GQC/GiMwpYjcsfkNxolJ10ARKjIjfkW1Wipzi0FcwAgAAAAAD/uaGWxTDq87F8XZ6CrFI+RNa8yMqfSZdqK00Kj833BBWwAIAAAAAD6aEdOO0CsQGagioOCvANPCEHSpJ8BSixlPBq5ERhB7AADMTUzAH0AAAAFZAAgAAAAABAJJxHoZD+MQBWqm9UM9Dd3z5ZohIZGWRaRVRsMptKQBXMAIAAAAADrE/ca+gqj/SH4oao4wE4qn2ovoTydzcMbDbrfnUs3zAVsACAAAAAAeNCIQN6hVnGJinytQRFGlQ2ocoprXNqpia+BSxzl+uwAAzE1NAB9AAAABWQAIAAAAAAv01wz7VG9mTepjXQi6Zma+7b/OVBaKVkWNbgDLr1mFgVzACAAAAAA0I5sxz8r6wkCp5Tgvr+iL4p6MxSOq5d3e1kZG+0b7NkFbAAgAAAAAIA32v6oGkAOS96HexGouNTex+tLahtx9QF2dgGClk6WAAMxNTUAfQAAAAVkACAAAAAAWXecRwxSon68xaa9THXnRDw5ZfzARKnvvjTjtbae6T0FcwAgAAAAAPh0UfUMEo7eILCMv2tiJQe1bF9qtXq7GJtC6H5Va4fIBWwAIAAAAADqFr1ThRrTXNgIOrJWScO9mk86Ufi95IDu5gi4vP+HWQADMTU2AH0AAAAFZAAgAAAAAEY5WL8/LpX36iAB1wlQrMO/xHVjoO9BePVzbUlBYo+bBXMAIAAAAABoKcpadDXUARedDvTmzUzWPe1jTuvD0z9oIcZmKuiSXwVsACAAAAAAJuJbwuaMrAFoI+jU/IYr+k4RzAqITrOjAd3HWCpJHqEAAzE1NwB9AAAABWQAIAAAAADnJnWqsfx0xqNnqfFGCxIplVu8mXjaHTViJT9+y2RuTgVzACAAAAAAWAaSCwIXDwdYxWf2NZTly/iKVfG/KDjHUcA1BokN5sMFbAAgAAAAAJVxavipE0H4/JQvhagdytXBZ8qGooeXpkbPQ1RfYMVHAAMxNTgAfQAAAAVkACAAAAAAsPG7LaIpJvcwqcbtfFUpIjj+vpNj70Zjaw3eV9T+QYsFcwAgAAAAAJQ71zi0NlCyY8ZQs3IasJ4gB1PmWx57HpnlCf3+hmhqBWwAIAAAAACD58TO6d+71GaOoS+r73rAxliAO9GMs4Uc8JbOTmC0OwADMTU5AH0AAAAFZAAgAAAAAAGiSqKaQDakMi1W87rFAhkogfRAevnwQ41onWNUJKtuBXMAIAAAAAASgiDpXfGh7E47KkOD8MAcX8+BnDShlnU5JAGdnPdqOAVsACAAAAAAI+2TTQIgbFq4Yr3lkzGwhG/tqChP7hRAx2W0fNaH6jcAAzE2MAB9AAAABWQAIAAAAAB7L4EnhjKA5xJD3ORhH2wOA1BvpnQ+7IjRYi+jjVEaJAVzACAAAAAAuhBIm0nL3FJnVJId+7CKDASEo+l2E89Z9/5aWSITK4AFbAAgAAAAALtSICOzQDfV9d+gZuYxpEj6cCeHnKTT+2G3ceP2H65kAAMxNjEAfQAAAAVkACAAAAAAaROn1NaDZFOGEWw724dsXBAm6bgmL5i0cki6QZQNrOoFcwAgAAAAANVT8R6UvhrAlyqYlxtmnvkR4uYK/hlvyQmBu/LP6/3ZBWwAIAAAAAD+aHNMP/X+jcRHyUtrCNkk1KfMtoD3GTmShS8pWGLt+AADMTYyAH0AAAAFZAAgAAAAADqSR5e0/Th59LrauDA7OnGD1Xr3H3NokfVxzDWOFaN7BXMAIAAAAACt30faNwTWRbvmykDpiDYUOCwA6QDbBBYBFWS7rdOB4AVsACAAAAAAF7SvnjjRk5v2flFOKaBAEDvjXaL1cpjsQLtK2fv9zdQAAzE2MwB9AAAABWQAIAAAAADmtb1ZgpZjSeodPG/hIVlsnS8hoRRwRbrTVx89VwL62AVzACAAAAAAi38e1g6sEyVfSDkzZbaZXGxKI/zKNbMasOl2LYoWrq8FbAAgAAAAAALACk0KcCDN/Kv8WuazY8ORtUGkOZ5Dsm0ys1oOppp/AAMxNjQAfQAAAAVkACAAAAAAf/f7AWVgBxoKjr7YsEQ4w/fqSvuQWV2HMiA3rQ7ur0sFcwAgAAAAADkkeJozP6FFhUdRIN74H4UhIHue+eVbOs1NvbdWYFQrBWwAIAAAAAB55FlHAkmTzAYj/TWrGkRJw2EhrVWUnZXDoMYjyfB/ZwADMTY1AH0AAAAFZAAgAAAAAI2WEOymtuFpdKi4ctanPLnlQud+yMKKb8p/nfKmIy56BXMAIAAAAADVKrJmhjr1rfF3p+T+tl7UFd1B7+BfJRk0e7a4im7ozgVsACAAAAAA5E7Ti3PnFiBQoCcb/DN7V1uM3Xd6VKiexPKntssFL7kAAzE2NgB9AAAABWQAIAAAAAAuHU9Qd79hjyvKOujGanSGDIQlxzsql8JytTZhEnPw+AVzACAAAAAAjF2gV/4+sOHVgDd/oR5wDi9zL7NGpGD+NsEpGXy/a4QFbAAgAAAAAJzMoyojYV6Ed/LpVN5zge93Odv3U7JgP7wxeRaJZGTdAAMxNjcAfQAAAAVkACAAAAAA7dQDkt3iyWYCT94d7yqUtPPwp4qkC0ddu+HFdHgVKEkFcwAgAAAAANuYvtvZBTEq4Rm9+5eb7VuFopowkrAuv86PGP8Q8/QvBWwAIAAAAACeqXoAOQOE4j0zRMlkVd8plaW0RX1npsFvB38Xmzv7sAADMTY4AH0AAAAFZAAgAAAAAAwnZSDhL4tNGYxlHPhKYB8s28dY5ScSwiKZm3UhT8U3BXMAIAAAAABDoY6dhivufTURQExyC9Gx3ocpl09bgbbQLChj3qVGbgVsACAAAAAAF+1nS7O0v85s3CCy+9HkdeoEfm2C6ZiNbPMMnSfsMHUAAzE2OQB9AAAABWQAIAAAAAC2VuRdaC4ZJmLdNOvD6R2tnvkyARteqXouJmI46V306QVzACAAAAAAMn1Z6B35wFTX9mEYAPM+IiJ5hauEwfD0CyIvBrxHg7IFbAAgAAAAAOG6DvDZkT9B/xZWmjao2AevN7MMbs3Oh9YJeSd/hZ+hAAMxNzAAfQAAAAVkACAAAAAAVerb7qVNy457rNOHOgDSKyWl5ojun7iWrv1uHPXrIZQFcwAgAAAAAIDcYS9j5z+gx0xdJj09L7876r/vjvKTi/d3bXDE3PhyBWwAIAAAAADuhVLqb1Bkrx8aNymS+bx2cL8GvLFNH4SAi690DUgnWQADMTcxAH0AAAAFZAAgAAAAAH/E44yLxKCJjuSmU9A8SEhbmkDOx1PqqtYcZtgOzJdrBXMAIAAAAABgLh9v2HjBbogrRoQ82LS6KjZQnzjxyJH4PH+F3jupSAVsACAAAAAAIlO46ehXp4TqpDV0t6op++KO+uWBFh8iFORZjmx2IjkAAzE3MgB9AAAABWQAIAAAAAAlNUdDL+f/SSQ5074mrq0JNh7CTXwTbbhsQyDwWeDVMwVzACAAAAAANIH2IlSNG0kUw4qz0budjcWn8mNR9cJlYUqPYdonucAFbAAgAAAAAJMrOUOyiu5Y3sV76zwEFct8L7+i8WGlQI2+8z2W2kzaAAMxNzMAfQAAAAVkACAAAAAASZ+CvUDtlk/R4HAQ3a+PHrKeY/8ifAfh0oXYFqliu80FcwAgAAAAAJelpzPgM65OZFt/mvGGpwibclQ49wH+1gbUGzd9OindBWwAIAAAAAD9qeDchteEpVXWcycmD9kl9449C1dOw0r60TBm5jK+cQADMTc0AH0AAAAFZAAgAAAAAN9fkoUVbvFV2vMNMAkak4gYfEnzwKI3eDM3pnDK5q3lBXMAIAAAAACnDkgVNVNUlbQ9RhR6Aot2nVy+U4km6+GHPkLr631jEAVsACAAAAAANzg/BnkvkmvOr8nS4omF+q9EG/4oisB+ul4YHi938hwAAzE3NQB9AAAABWQAIAAAAAASyK3b1nmNCMptVEGOjwoxYLLS9fYWm/Zxilqea0jpEQVzACAAAAAADDHsGrbqlKGEpxlvfyqOJKQJjwJrzsrB7k3HG0AUJbkFbAAgAAAAAKwx3S4XfDZh4+LuI9jf7XgUh5qiefNv87JD4qvVRfPSAAMxNzYAfQAAAAVkACAAAAAAlSP9iK31GlcG9MKGbLmq+VXMslURr+As736rrVNXcsUFcwAgAAAAAAvbj0zfq9zzi8XReheKFbCB+h9IsOLgXPPpI5vrEJNZBWwAIAAAAABXvoZhaQE7ogWjeBjceVkp03N20cKYP3TA8vuNsgpfAgADMTc3AH0AAAAFZAAgAAAAAOJNORH8Bev97gVU7y6bznOxJ+E6Qoykur1QP76hG1/7BXMAIAAAAAC+C1PtOOrSZgzBAGhr+dPe/kR0JUw9GTwLVNr61xC1aAVsACAAAAAAeA/L8MQIXkamaObtMPLpoDoi5FypA5WAPtMeMrgi0eQAAzE3OAB9AAAABWQAIAAAAAAKcHzLUomavInN6upPkyWhAqYQACP/vdVCIYpiy6U6HgVzACAAAAAATsR4KItY6R2+U7Gg6sJdaEcf58gjd1OulyWovIqfxKcFbAAgAAAAAFbm10ko67ahboAejQdAV0U2uA5OhZYdb8XUFJ8OL46LAAMxNzkAfQAAAAVkACAAAAAAqTOLiMpCdR59tLZzzIPqJvbCNvz2XQL9ust0qYaehtcFcwAgAAAAAArefox/3k5xGOeiw2m6NUdzuGxmPwcu5IFcj+jMwHgHBWwAIAAAAADLZGFJ7MQd5JXMgMXjqZO5LDLxcFClcXPlnRMWRn+1oAADMTgwAH0AAAAFZAAgAAAAAIPSqSeVzSRgNVNmrPYHmUMgykCY27NbdDUNhE5kx/SgBXMAIAAAAAAhX90nNfxyXmZe/+btZ7q6xMX4PFyj0paM1ccJ/5IUUQVsACAAAAAA419oHmD2W0SYoOMwhrhrp8jf68fg9hTkaRdCuVd3CN0AAzE4MQB9AAAABWQAIAAAAACLn5DxiqAosHGXIAY96FwFKjeqrzXWf3VJIQMwx1fl4gVzACAAAAAAindvU27nveutopdvuHmzdENBbeGFtI3Qcsr07jxmvm8FbAAgAAAAAPvl9pBStQvP4OGkN5v0MghUY6djm9n7XdKKfrW0l1sMAAMxODIAfQAAAAVkACAAAAAA7i2S6rHRSPBwZEn59yxaS7HiYBOmObIkeyCcFU42kf8FcwAgAAAAAGb3RSEyBmgarkTvyLWtOLJcPwCKbCRkESG4RZjVmY4iBWwAIAAAAADB2/wo5CSHR4ANtifY6ZRXNTO5+O8qP82DfAiAeanpZwADMTgzAH0AAAAFZAAgAAAAAFz+M+H/Z94mdPW5oP51B4HWptp1rxcMWAjnlHvWJDWrBXMAIAAAAACBFEOQyL7ZHu4Cq33QvXkmKuH5ibG/Md3RaED9CtG5HwVsACAAAAAAfggtJTprQ/yZzj7y5z9KvXsdeXMWP0yUXMMJqpOwI88AAzE4NAB9AAAABWQAIAAAAAAE7c2x3Z3aM1XGfLNk/XQ9jCazNRbGhVm7H8c2NjS5ywVzACAAAAAARJ9h8fdcwA19velF3L/Wcvi2rCzewlKZ2nA0p8bT9uwFbAAgAAAAAJtWe6b4wK2Hae2dZm/OEpYQnvoZjz4Sz5IgJC2wInecAAMxODUAfQAAAAVkACAAAAAAVoRt9B9dNVvIMGN+ea5TzRzQC+lqSZ8dd/170zU5o9cFcwAgAAAAAEwM95XZin5mv2yhCI8+ugtKuvRVmNgzzIQN0yi1+9aIBWwAIAAAAAAMGBq72n00rox3uqhxSB98mkenTGCdbbUF1gXrgottzgADMTg2AH0AAAAFZAAgAAAAAKRDkjyWv/etlYT4GyoXrmBED2FgZHnhc+l9Wsl06cH2BXMAIAAAAABohlpm3K850Vndf3NmNE0hHqDlNbSR8/IvMidQ3LnIZAVsACAAAAAAW42nGHa6q2MCAaaPVwaIDfr8QLyQwjKq23onZJYsqVsAAzE4NwB9AAAABWQAIAAAAAC3DFh5oklLCNLY90bgWm68dFXz65JpAZSp1K99MBTPAQVzACAAAAAAQgZecmxEUZVHoptEQClDwAf8smI3WynQ/i+JBP0g+kQFbAAgAAAAAEUSQGVnAPISD6voD0DiBUqyWKgt2rta0tjmoe+LNt6IAAMxODgAfQAAAAVkACAAAAAAQ5WKvWSB503qeNlOI2Tpjd5blheNr6OBO8pfJfPNstcFcwAgAAAAAKwHgQLSDJ5NwLBQbY5OnblQIsVDpGV7q3RCbFLD1U4/BWwAIAAAAACQ5nED99LnpbqXZuUOUjnO2HTphEAFBjLD4OZeDEYybgADMTg5AH0AAAAFZAAgAAAAAGfhFY3RGRm5ZgWRQef1tXxHBq5Y6fXaLAR4yJhrTBplBXMAIAAAAACKEF0ApLoB6lP2UqTFsTQYNc9OdDrs/vziPGzttGVLKQVsACAAAAAArOO6FyfNRyBi0sPT5iye7M8d16MTLcwRfodZq4uCYKEAAzE5MAB9AAAABWQAIAAAAAAIM73gPcgzgotYHLeMa2zAU4mFsr7CbILUZWfnuKSwagVzACAAAAAAJCSu98uV8xv88f2BIOWzt6p+6EjQStMBdkGPUkgN79cFbAAgAAAAAMGqPGMPxXbmYbVfSa/japvUljht1zZT33TY7ZjAiuPfAAMxOTEAfQAAAAVkACAAAAAAkWmHCUsiMy1pwZTHxVPBzPTrWFBUDqHNrVqcyyt7nO8FcwAgAAAAAMv2CebFRG/br7USELR98sIdgE9OQCRBGV5JZCO+uPMgBWwAIAAAAABt7qSmn3gxJu7aswsbUiwvO+G6lXj/Xhx+J/zQyZxzLAADMTkyAH0AAAAFZAAgAAAAAGInUYv0lP/rK7McM8taEHXRefk8Q2AunrvWqdfSV7UaBXMAIAAAAACE+WPxJ3gan7iRTbIxXXx+bKVcaf8kP4JD8DcwU0aL7wVsACAAAAAAUC4eTprX4DUZn2X+UXYU6QjtiXk+u57yoOPBbPQUmDkAAzE5MwB9AAAABWQAIAAAAACmHlg2ud3cplXlTsNTpvNnY6Qm1Fce0m899COamoDjaQVzACAAAAAArtJQeJIlepBWRU2aYar7+YGYVQ7dfDc1oxgTmA8r9q0FbAAgAAAAAOk45vg5VqZHAFCO3i0Z52SZi5RADf8NXwf68T5yad/DAAMxOTQAfQAAAAVkACAAAAAApzcWSAbZWV/Rq+ylRNqqlJqNVR4fhXrz4633/MQOQgcFcwAgAAAAAN/jz/bsEleiuCl+li83EWlG6UMHA8CyaOMRKCkXkSCPBWwAIAAAAAC3Sd+Qg+uFDKpGZHbrQgokXHQ1az1aFl4YK343OB6hcQAAEmNtAAAAAAAAAAAAABBwYXlsb2FkSWQAAAAAABBmaXJzdE9wZXJhdG9yAAEAAAAA", - "subType": "06" - } - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "find" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": { - "$numberInt": "0" - }, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rbf3AeBEv4wWFAKknqDxRW5cLNkFvbIs6iJjc6LShQY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "n+XAuFnP8Dov9TnhGFxNx0K/MnVM9WbJ7RouEu0ndO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yRXojuVdn5GQtD97qYlaCL6cOLmZ7Cvcb3wFjkLUIdM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DuIkdRPITRs55I4SZmgomAHCIsDQmXRhW8+MOznkzSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SsBk+Et1lTbU+QRPx+xyJ/jMkmfG+QCvQEpip2YYrzA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "crCIzOd8KhHvvUlX7M1v9bhvU4pLdTc+X2SuqoKU5Ek=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YOWdCw4UrqnxkAaVjqmC4sKQDMVMHEpFGnlxpxdaU6E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M3SShp81Ff8tQ632qKbv9MUcN6wjDaBReI0VXNu6Xh4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gzHlSPxpM0hT75kQvWFzGlOxKvDoiKQZOr19V6l2zXI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s3JnppOGYw9SL2Q1kMAZs948v2F5PrpXjGei/HioDWs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cG6+3Gk/zEH68P/uuuwiAUVCuyJwa1LeV+t29FlPPAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dupdvR3AyJtM+g9NDKiaLVOtGca387JQp8w+V03m7Ig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JqEQc5svj2jTvZ6LLA5ivE+kTb/0aRemSEmxk4G7Zrg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "szcXXXKnob+p3SoM4yED2R920LeJ7cVsclPMFTe4CeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o1QoGVXmuBdHwHm7aCtGMlMVKrjFdYvJXpoq6uhIAZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Jfm5wPlqqLCJRGQIqRq2NGmpn7s0Vrih2H3YAOoI2YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zMHLb8ARbsYo8Ld05bqnGFf1Usha6EGb8QKwdSAyps0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yQdtq9lh5pugL7/i0Bj/PuZUUBUIzf+7wj1rl5y736w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wGWVZdO7qIuyDg/BqDgqjgoQ02h5YYgwXQB1oCin2NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "by9HMLj6NTEpgztZ5HSN6GxImkXPcaFINYDzgZY33X8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tWo0vbasi7bXmn/MsOx13VC1IsWtpx/nYp0uj4iMzdA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tQQpndUYd5O87lOtrGjH3wl9VsOK0ray7RMasL90sBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cQjXEDCMsOpKLLf+vlTgIHA+cbSJdzqhbSX9Wvh95aA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7yMpU48IxK9SzP2cx3VnTownGEwFmeFofuuFT97SuuY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kSOx1kz0CmBgzKQHZlo65ZUY1DIv9A99JRm+Us2y6Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubQpdPBe6/xvtr+AcXdfYLSvYCR4ot0tivehkCsupb4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xal+iCJ6FTefRQToyoNksc9NCZShyn04NDGi4IYrcoM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d7jU4iOK50xHxlkSifcxlZFCM46TSgQzoYivxG3HNLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJvl2nsBLBVzL3pp6sKWCL4UXeh3q/roYBJjSb74ve0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OIUCaKRvIx9t1w6Hxlz1IcQTdPNCfdRNwnnTm10W+X0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A9tvzsiElotOUVIB4CqfQp9mAwqvTM35YkmAR170aHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lI8gpK7hpb7c9x4RQugsxMnQay5LZJmwslZdvMx/dcE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dNCzh40U0XvdKnSDi3HRQOWQftEsDVqc4uUvsVFGoq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IP+iwEBWBwVVZIdpaMu8k5+soFCz+TZkYn3drKZ9grE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnqyh6e0y5svHkJDShlN9CHV0WvMBE4QbtJpQw5ZCXc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "elEl42tbVDoRTLjAhZUFEtXiut4b3PVhg/1ZLZSQdtE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vHuu2FxwclMHqyE6JBYbTYgbEkB0dqb/JuaxsvfwsmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xTf7NCe3Gf8QpE78HR5OknlLTKfs9J+RN9UZpH6fnso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XiWSasRnJAulGR6+LCVD3mwRObXylqYWR9jvpywq12c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MZMxEQ5ikx0PG1YFIExv0UnTZogsvgeOEZTpzvBDn4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yZMyMZBDrWbAhvnic7vvIYhmO9m5H2iuv0c8KNZrBzY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xxM14hTPY5j0vvcK2C7YAEjzdsfUTFHozHC0hEo1bxI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+01rqR1xVwkpGXcstbk1ItJqFVjH6Q8MGxEN3Cm9Y1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xOpLV0Z2VTRJ3iWtnWZcsyjXubTIkYWo31cO+HV1o1k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BWUOLqgLBqc5NwxVlSV5H3KFQPXbCp7mdo+jF+8cJqY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fuQb1S6xZDGlrEbK+kI23aL53PP1PVNwqICnZNt9Yzg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfscnoibFttahLdPVC4Ee+47ewGFKpDSU7M6HX19bKE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rpSW2awybNVeKtat91VFxqbINoTfNhPfQAu+d73Xtf8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9M/CP9ccOIIj2LLFmE0GFDO0Ban2wsNalEXfM6+h+1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WrEMG49l1ye4MhXs5ZS9tz8P6h+hDvthIg/2wW9ne1Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ImNhbfeyfH8qIEeA5ic0s3dAQBdzzTBS+CPsNih9vZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dWP33YDSn04UKJN2ogh2Rui0iW/0q2y18OCDRVcfyoo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lYv0isAtfGh6H9tdp3cp2eHU7q2J+uk7QrgcxtK3w7Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VGMoamB/+7zTOYcY/pqJc96xlv2PdW4hwsIAEIslTDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yNeBWMF7BnD9wVwz2PgJsvWr77QiVvvWUvJF0+fqBug=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfpvObJ+tJBXSvqeN7vlOfmhYign635lciYAJIjUtY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dsen4NqjzVGjpjufiTMs3+gqeD09EbnuogPgxrJECwg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pxCWVM3sn19NsFEpgHbgLa+PmYlhN3mMiP0Wk8kJhYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q11KNvJszjYIB9n9HcC+N4uz11a3eRj1L3BH9scKMDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A1PmkgcEToWh1JiVWE6mI5jUu7poxWWuCUt/cgRUUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qJo3Hu4PJeanL7XEaWXO/n3YsodhZyd+MJOOmB9Kpd8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BkBKLO8URFscfRY9Bav/1+L9mLohDgNr/MkZtGiraIs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rZq5WA3Hx3xthOyHAJXK//f8pE2qbz7YKu3TIMp9GFY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X07a/Lm80p5xd4RFs1dNmw+90tmPDPdGiAKVZkxd4zY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6YrBn2ofIw1b5ooakrLOwF41BWrps8OO0H9WH4/rtlE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0l86Ag5OszXpa78SlOUV3K9nff5iC1p0mRXtLg9M1s4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Hn6yuxFHodeyu7ISlhYrbSf9pTiH4TDEvbYLWjTwFO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zdf4y2etKBuIpkEU1zMwoCkCsdisfXZCh8QPamm+drY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rOQ9oMdiK5xxGH+jPzOvwVqdGGnF3+HkJXxn81s6hp4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "61aKKsE3+BJHHWYvs3xSIBvlRmKswmaOo5rygQJguUg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KuDb/GIzqDM8wv7m7m8AECiWJbae5EKKtJRugZx7kR0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Q+t8t2TmNUiCIorVr9F3AlVnX+Mpt2ZYvN+s8UGict8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJRZIpKxUgHyL83kW8cvfjkxN3z6WoNnUg+SQw+LK+k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnUsYjip8SvW0+m9mR5WWTkpK+p6uwJ6yBUAlBnFKMk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PArHlz+yPRYDycAP/PgnI/AkP8Wgmfg++Vf4UG1Bf0E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wnIh53Q3jeK8jEBe1n8kJLa89/H0BxO26ZU8SRIAs9Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4F8U59gzBLGhq58PEWQk2nch+R0Va7eTUoxMneReUIA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ihKagIW3uT1dm22ROr/g5QaCpxZVj2+Fs/YSdM2Noco=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EJtUOOwjkrPUi9mavYAi+Gom9Y2DuFll7aDwo4mq0M0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dIkr8dbaVRQFskAVT6B286BbcBBt1pZPEOcTZqk4ZcI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aYVAcZYkH/Tieoa1XOjE/zCy5AJcVTHjS0NG2QB7muA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sBidL6y8TenseetpioIAAtn0lK/7C8MoW4JXpVYi3z8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0Dd2klU/t4R86c2WJcJDAd57k/N7OjvYSO5Vf8KH8sw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I3jZ92WEVmZmgaIkLbuWhBxl7EM6bEjiEttgBJunArA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aGHoQMlgJoGvArjfIbc3nnkoc8SWBxcrN7hSmjMRzos=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bpiWPnF/KVBQr5F6MEwc5ZZayzIRvQOLDAm4ntwOi8g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tI7QVKbE6avWgDD9h4QKyFlnTxFCwd2iLySKakxNR/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XGsge0CnoaXgE3rcpKm8AEeku5QVfokS3kcI+JKV1lk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JQxlryW2Q5WOwfrjAnaZxDvC83Dg6sjRVP5zegf2WiM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YFuHKJOfoqp1iGVxoFjx7bLYgVdsN4GuUFxEgO9HJ5s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Z6vUdiCR18ylKomf08uxcQHeRtmyav7/Ecvzz4av3k4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SPGo1Ib5AiP/tSllL7Z5PAypvnKdwJLzt8imfIMSEJQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "m94Nh6PFFQFLIib9Cu5LAKavhXnagSHG6F5EF8lD96I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pfEkQI98mB+gm1+JbmVurPAODMFPJ4E8DnqfVyUWbSo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DNj3OVRLbr43s0vd+rgWghOL3FqeO/60npdojC8Ry/M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kAYIQrjHVu49W8FTxyxJeiLVRWWjC9fPcBn+Hx1F+Ss=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aCSO7UVOpoQvu/iridarxkxV1SVxU1i9HVSYXUAeXk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Gh6hTP/yj1IKlXQ+Q69KTfMlGZjEcXoRLGbQHNFo/1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/gDgIFQ4tAlJk3GN48IS5Qa5IPmErwGk8CHxAbp6gs0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PICyimwPjxpusyKxNssOOwUotAUbygpyEtORsVGXT8g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4lu+cBHyAUvuxC6JUNyHLzHsCogGSWFFnUCkDwfQdgI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pSndkmoNUJwXjgkbkgOrT5f9nSvuoMEZOkwAN9ElRaE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tyW+D4i26QihNM5MuBM+wnt5AdWGSJaJ4X5ydc9iWTU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9Syjr8RoxUgPKr+O5rsCu07AvcebA4P8IVKyS1NVLWc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "67tPfDYnK2tmrioI51fOBG0ygajcV0pLo5+Zm/rEW7U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "y0EiPRxYTuS1eVTIaPQUQBBxwkyxNckbePvKgChwd0M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NWd+2veAaeXQgR3vCvzlI4R1WW67D5YsVLdoXfdb8qg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PY5RQqKQsL2GqBBSPNOEVpojNFRX/NijCghIpxD6CZk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lcvwTyEjFlssCJtdjRpdN6oY+C7bxZY+WA+QAqzj9zg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWE7XRNylvTwO/9Fv56dNqUaQWMmESNS/GNIwgBaEI0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ijwlrUeS8nRYqK1F8kiCYF0mNDolEZS+/lJO1Lg93C8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8KzV+qYGYuIjoNj8eEpnTuHrMYuhzphl80rS6wrODuU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wDyTLjSEFF895hSQsHvmoEQVS6KIkZOtq1c9dVogm9I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SGrtPuMYCjUrfKF0Pq/thdaQzmGBMUvlwN3ORIu9tHU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KySHON3hIoUk4xWcwTqk6IL0kgjzjxgMBObVIkCGvk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hBIdS9j0XJPeT4ot73ngELkpUoSixvRBvdOL9z48jY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Tx6um0q9HjS5ZvlFhvukpI6ORnyrXMWVW1OoxvgqII0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zFKlyfX5H81+d4A4J3FKn4T5JfG+OWtR06ddyX4Mxas=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cGgCDuPV7MeMMYEDpgOupqyNP4BQ4H7rBnd2QygumgM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IPaUoy98v11EoglTpJ4kBlEawoZ8y7BPwzjLYBpkvHQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Pfo4Am6tOWAyZNn8G9W5HWWGC3ZWmX0igI/RRB870Ro=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fnTSjd7bC1Udoq6iM7UDnHAC/lsIXSHp/Gy332qw+/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fApBgVRrTDyEumkeWs5p3ag9KB48SbU4Si0dl7Ns9rc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QxudfBItgoCnUj5NXVnSmWH3HK76YtKkMmzn4lyyUYY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sSOvwhKa29Wq94bZ5jGIiJQGbG1uBrKSBfOYBz/oZeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FdaMgwwJ0NKsqmPZLC5oE+/0D74Dfpvig3LaI5yW5Fs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sRWBy12IERN43BSZIrnBfC9+zFBUdvjTlkqIH81NGt4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/4tIRpxKhoOwnXAiFn1Z7Xmric4USOIfKvTYQXk3QTc=", - "subType": "00" - } - } - ] - }, - { - "_id": { - "$numberInt": "1" - }, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RGTjNVEsNJb+DG7DpPOam8rQWD5HZAMpRyiTQaw7tk8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I93Md7QNPGmEEGYU1+VVCqBPBEvXdqHPtTJtMOn06Yk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "GecBFQ1PemlECWZWCl7f74vmsL6eB6mzQ9n6tK6FYfs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QpjhZl+O1ORifgtCZuWAdcP6OKL7IZ2cA46v8FJcV28=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RlQWwhU+uVv0a+9IB5cUkEfvHBvOw3B1Sx6WfPWMqes=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubb81XTC7U+4tcNzf1oYvOY6gR5hC2Izqx54f4GuJ0E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6M4Q5NMQ9TqNnjzGOxIkiUIY8TEL0I3XD1QnhefQUqU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BtInzk9t2FFMCEY6AQ7zN8jwrrZEs2irSv6q0Q4NaIw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vxXfETu9cuBIpRBo3jUUU04mJIH/aAhLX8K6VI5Xv0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wXPCdS+q23zi1bkPnaVG2j0PsVtxdeSLJ//h6J1x8RU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KY3KkfBAsN2l80wbpj41G0gwBR5KmmFnZcagg7D3ENk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tI8NFAxXCX4VOnY5X73K6KI/Yspd3aR94KV39MhJlAw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "nFxH0UC3mATKA6Vboz+QX/hAjj19kF/SH6H5Cne7qC0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q8hYqIYaIi7nOdG/7qQZYnz8Bsacfi66M1nVku4SH08=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4saA92R4arp4anvD9xFtze+sNcQqTEhPHyl1h70A8NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DbIziOBRRyeQS6RtBR09E37LV+CTKrEjGoRMLSpG6eE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Fv80Plp/7w2gnVqrwawLd6qhJ10G4NCDm3re67cNq4Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "T/T2oiQCBBES4YN7EodzPRdabZSFlYIClHBym+bQUZE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ZQgHD3l46Ujqtbnj1VbbeM29C9wJzOhz+yZ/7XdSrxk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ltlFKzWvyZvHxDFOYDd/XXJ6kUiJj0ln2HTCEz2o4Z4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "flW8A7bltC1u8bzx0WJtxosGJdOVsJFfbx33jxnpFGg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SXO+92QbMKwUSG2t27ciunV1c3VvFkUuDmSczpRe008=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+KioGs1GM+xRBzFE67ePTWj04KMSE5/Y6qUF7nJ5kvU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L3xNVbh6YH+RzqABN+5Jgb7T234Efpn766DmUvxIxgg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hPF+60mBYPjh21dEmPlBhKgyc9S2qLtTkypYvnqP2Fc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EletRsETy2HcjaPIm2c8CkT7ch/P3pJJDC8hasepcSU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "r5bMXUaNKqLPxZ+TG9HYTG4aSDgcpim27rN8rQFkM0w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0Q7Erdr8+/S0wUEDDIqlS5XjBVWvhZY65K0uUDb6+Ns=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xEcnhXy35hbXNVBPOOt3TUHbxvKfQ48KjA9b6/rbMqQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "T8bEpiQNgsEudXvyKE9SZlSvbpV/LUaslsdqgSFltyo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hIoiaF2YjnxDbODfhFEB+JGZ5nf8suD3Shck5bwQ3N0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qnA6qzejeRJ0rsZaZ0zOvKAaXyxt5lpscKQNYFZNl4k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "anAKCL2DN/le2VaP0n2ucYSEH/DaaEH/8Sa4OqTZsRA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JCZlBJaFm618oWYSnT9Jr1MtwFVw4BZjOzO+5yWgR90=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yxyk4n9762WzcDVGnTn4jCqUnSMIVCrLDIjCX1QVj34=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fDI6fdKvDJwim5/CQwWZEzcrXE3LHgy7FTtffcC7tXE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Vex+gcz5T+WkzsVZQrkqUR2ryyZbnaOGuWpYvjN0zCw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8TLEXz+Gbbp6llHpZXVjLsdlYY9f6hrKpHVpyfDe0RY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7fTyt5BrunypS65TfOzFW2E2qdIuT4SLeDeGlbQoJCs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8fKGrkqN0/KuSjyXgDBmRauDKrSa//JBKRWHEB9xBf4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s4codmG7uN4ss6P357jL21lazEe90M9GOK5WrOknSV0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RkSpua8XF+NUdxVDU90EbLUTTyZFX3tt3atBTroFaRk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "LnTCuCDyAHK5B9KXzjtwGmWB+qergQk2OCjnIx9MI2A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cBFh0virAX4pVXf/udIGI2951i0+0aZAdJcBVGtYnT4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "G54X6myQXWZ5fw/G31en3QbdgfXzL9+hFTtJpnWMqDI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EdsiiuezcsFJFnYIyGjCOhnqMj1BOwTB5EFxN+ERUkg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dVH9MXLtk0WTwGQ3xmrhOqfropMUkDW3o6paNPGl3NU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sB3HqXKWY3pKbuEH8BTbfNIGfbY+7/ZbOc3XC+JRNNI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WHyDk62Xhqbo4/iie2aLIM4x2uuAjv6102dJSHI58oM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pNUFuHpeNRDUZ/NrtII2c6sNc9eGR1lIUlIyXKERA+0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UPa+pdCqnN0bfAptdzldQOSd01gidrDKy8KhWrpSKAI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "l+7dOAlo+HUffMqFYXL6pgUFeTbwOM9CjKQLxEoLtc4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SRnDXV/rN6C8xwMutv9E1luv3DOUio3VkgPr8Cpm7Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QcH6gl+gX7xZ7OWhUNQMbndJy0Piz49pDo6RsnLkVSA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "t+uL4DnfsI/Zll/KXWW1cOKX3Hu8WIkm3pt9efCVSAQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "myutHDctku/+Uug/nD8gRbYvmx/IovtoAAC2/fz2oHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6C+cjD0e0nSCP6cPqQYbNG7SlOd6Mfvi8hyfm7Ng+D8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zg01JSoOj9oBKT0S1ldJucXzY5AKgreS+h2xJreWTOs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7qQ80/FjodHl1m1py/Oii0/9C/xWbLdhaRXQ+kkCP10=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YwWMNH07vL6c5Nhg+MRnVByhzUunu8y0VLM9z/XvR5U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dle8bU98+fudAbc14SToZFkwvV3tcYVsjDug0NWljpc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "J+eKL1vPJmlzltvhI6Li5Fz/TJmi3Ng+ehRTcs46API=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB3XzfFygLwC3WHkj0up+VbEd25KKoce1vOpG/5bwK4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vnVnmOnL+z2pqwE+A6cVKS0Iwy4F4/2IiElJca9bUQM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+lG5r/Fpqry3BtFuvY67+RntmHAMDoLVOSGc6ZoXPb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L5MXQertqc6uj7ADe8aWKbd1sYHPCE7P1VYVg9Zc3VI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "imKONuZgopt0bhM3GMX2WVPwQYMTobuUUEdhcLfHs4c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "eOkU1J1uVbiVFWBerbXsSIVcF2nqiicTkFy4x7kFHB8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gI0uDhXeoH/UatDQKEf4qo8FHzWZDhb/wuWTqbq/ID4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cOkd5Aa3btYhtojE/smsF/PJnULqQ4NNqTkU6KXTFmo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "AWNJMs1MTe294oFipp8Y6P0CjpkZ4qCZoClQF3XcHq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6gJtlzXOFhGYrVbTuRMmvMlDTwXdNtR9aGBlHZPwIMw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "LEmwVGA/xsEG7UrcOoYLFu6KCXgijzFznenknuDacm8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "mIRFPTXRrGaPtp/Ydij2jgkRe4uoUvAKxW2d8b9zYL0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "B+Uv2u48WALOO0L311z+eryjYQzKJVMfdHMZPhOAFmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "INXXp0wDyVCq+NtfIrrC2ciETmyW/dWB/48/u4yLEZ4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "se7DGo8XrlrQDLEcco1tZrQt9kDe+0RTyl2bw/quG4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vr0m2+Zk9lbN6UgWCyn8xJWJOokU3IDYab5U5q1+CgQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XI+eJ8Gy2JktG1gICgoj1qpsfy1tKmH0kglWbaQH6DA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A+UCuNnuAUqnQzspA6TVqUPRmtZmpSex5HFw7THRxs0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xaH2Ehfljd19uo0Fvb3iwkdaiWEVQd2YPoitgEPkhSM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "S/iZBJGcc8+qZxyMtab65MMBoSglybwk3x58Nb86gnY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "w14ZE5qqY5YgkS4Zcs9YNbrQbY1XfGOOHNn9bOYnFVQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0MhGd/jEF1vjkKGp+ZMn9SjLK54jkp9W4Hg+Sp/oxaI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "92QZ73e/NRTYgCm4aifaKth6aAsKnLLccBc0zx/qUTY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WOjzemCgFJOiGIp81RSVh/tFlzSTj9eFWcBnsiv2Ycs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DrsP9CmfKPjw5yLL8bnSeAxfNzAwlb+Z8OqCiKgBY7o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lMogqg8veBv6mri3/drMe9afJiKMvevkmGcw9BedfLo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "TxqwNcY8Tg2MPpNdkPBwvfpuTttSYRHU26DGECKYQ9o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "l0u1b4b4vYACWIwfnB7PZac4oDEgjQZCzHruNPTgAIY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "iVSGQ+cCfhbWIrY/v/WBORK92elu9gfRKyGhr6r/k00=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yK1forG50diEXte8ECzjfpHeYsPyuQ/dgxbxn/nzY5k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gIfTLCD3VwnOwkC0zPXWTqaITxX6ZplA69PO2a6zolc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "O/Zxlgh3WqpzJ7+Sd8XWMVID4/GXJUUWaSqfgDUi3b0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ZQ6yv368zwahUqSUYH/StL0Qgz/TwS1CzlMjVDvCciI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "m2rPEYkjwyiKdonMrKlcF7hya4lFOAUwEePJ3SgrNx8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Mq0yl5iVKlq71bT/dT/fXOWf2n90bTnXFnOdGDN0JOc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6qDGMXipPLC2O6EAAMjO2F9xx4rdqZso4IkPpH2304U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jvQHRQQa2RIszE2LX2Hv2LbRhYawJ6qmtRt8HZzFQXg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ovJXQrkZlpeHRciKyE/WWNm5O389gRgzx1W+Dw596X4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "a4kgRNvYctGYqyQv9qScL/WkljTYVylJ9pE9KDULlxU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qV4Q48vPiCJMTjljotzYKI/zfExWpkKOSHGcAjGyDig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jtI7zbBF+QW/aYYTkn90zzyHLXLgmy7l1bzgMb2oqic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q0KmJl9txPdn962UNvnfe6UFhdk9YaFZuTm33F+csso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ULNdEqeZJgtmNOhN/Y9INzsE9AnxWYwOMn+pIbRXIFs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "R4oz9+wkdjpKe5tE1jpG7IURAnfvS5fLP4LrD5cZfTE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qG5Z7VhwSu/HT/YFTgDzyAAzJKq51xPw2HeEV5btYC4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OM/1DmIIZ5Qyhtq8TGkHTBEMVKjAnKRZMRXYtTG8ctc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2R5vZbljLXnDFA99YfGuRB7pAdPJVKsT25zLNMC0fUk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OMbavF2EmdAz1fHkLV3ctFEUDfriKhoT2gidwHZ9z1o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MWT4Zrw3/vVvTYMa1Is5Pjr3wEwnBfnEAPPUAHKQhNU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tBkRPfG9yxfKocQx5pAJX0oEHKPL0Tgtr+0UYe09InE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lqxpnDR/H0YgH7RcfKoNoaaRhe1SIazIeMbQ1fu9y3Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "utT1UdR22PWOTrOkZauztX613lAplV4eh/ejTRb7ZSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "S+Y2yFyKi/a6FXhih4yGo29X8I8OT6/zwEoX6NMKT4o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QSjVppg29x6oS5yBg8OFjrFt0tuTpWCuKxfIy0k8YnE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "y3r6/Xsfvsl3HksXlVYkJgHUqpQGfICxg3x9f8Zw1qM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BSltHzEwDjFN4du9rDHAPvl22atlcTioEtt+gC5L1tk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0arGXjSN0006UnXbrWsGqhvBair569DeFDUME3Df3rA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s/DumaMad08S+PBUUcrS+v42K0z8HgcdiQtrFAEu2Qs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EzJ8Y8N0OQBTlnvrK82PdevDNZZO4E6CNgYVu8Cj6Ks=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VA4vr8jBPI5QdiPrULzzZjBMIUbG3V7Slg5zm0bFcKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YAOvEB2ZLtq9LQiFViBHWaxxWVVonC2rNYj9tN9s3L0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hgaHMo9aAGS+nBwvqnTjZO+YkiQPY1c1XcIYeaYKHyI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YvaoLt3ZpH0atB0tNzwMjpoxRYJXl0DqSjisMJiGVBE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EMmW6CptFsiLoPOi5/uAJQ2FmeLg6mCpuVLLrRWk7Mc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1jQsNMarSnarlYmXEuoFokeBMg/090qUD9wqo1Zn8Gs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hupXNKhRpJxpyDAAP1TgJ5JMZh9lhbMk6s7D7dMS3C8=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Update.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Update.json deleted file mode 100644 index 8064eb1b1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Decimal-Update.json +++ /dev/null @@ -1,1911 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Decimal. Update.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$numberDecimal": "1" - } - } - } - }, - { - "name": "updateOne", - "arguments": { - "filter": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$numberDecimal": "0" - } - } - }, - "update": { - "$set": { - "encryptedDecimalNoPrecision": { - "$numberDecimal": "2" - } - } - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command_name": "update", - "command": { - "update": "default", - "ordered": true, - "updates": [ - { - "q": { - "encryptedDecimalNoPrecision": { - "$gt": { - "$binary": { - "base64": "DeFiAAADcGF5bG9hZACxYgAABGcAnWIAAAMwAH0AAAAFZAAgAAAAAJu2KgiI8vM+kz9qD3ZQzFQY5qbgYqCqHG5R4jAlnlwXBXMAIAAAAAAAUXxFXsz764T79sGCdhxvNd5b6E/9p61FonsHyEIhogVsACAAAAAAt19RL3Oo5ni5L8kcvgOJYLgVYyXJExwP8pkuzLG7f/kAAzEAfQAAAAVkACAAAAAAPQPvL0ARjujSv2Rkm8r7spVsgeC1K3FWcskGGZ3OdDIFcwAgAAAAACgNn660GmefR8jLqzgR1u5O+Uocx9GyEHiBqVGko5FZBWwAIAAAAADflr+fsnZngm6KRWYgHa9JzK+bXogWl9evBU9sQUHPHQADMgB9AAAABWQAIAAAAAD2Zi6kcxmaD2mY3VWrP+wYJMPg6cSBIYPapxaFQxYFdQVzACAAAAAAM/cV36BLBY3xFBXsXJY8M9EHHOc/qrmdc2CJmj3M89gFbAAgAAAAAOpydOrKxx6m2gquSDV2Vv3w10GocmNCFeOo/fRhRH9JAAMzAH0AAAAFZAAgAAAAAOaNqI9srQ/mI9gwbk+VkizGBBH/PPWOVusgnfPk3tY1BXMAIAAAAAAc96O/pwKCmHCagT6T/QV/wz4vqO+R22GsZ1dse2Vg6QVsACAAAAAAgzIak+Q3UFLTHXPmJ+MuEklFtR3eLtvM+jdKkmGCV/YAAzQAfQAAAAVkACAAAAAA0XlQgy/Yu97EQOjronl9b3dcR1DFn3deuVhtTLbJZHkFcwAgAAAAACoMnpVl6EFJak8A+t5N4RFnQhkQEBnNAx8wDqmq5U/dBWwAIAAAAACR26FJif673qpwF1J1FEkQGJ1Ywcr/ZW6JQ7meGqzt1QADNQB9AAAABWQAIAAAAAAOtpNexRxfv0yRFvZO9DhlkpU4mDuAb8ykdLnE5Vf1VAVzACAAAAAAeblFKm/30orP16uQpZslvsoS8s0xfNPIBlw3VkHeekYFbAAgAAAAAPEoHj87sYE+nBut52/LPvleWQBzB/uaJFnosxp4NRO2AAM2AH0AAAAFZAAgAAAAAIr8xAFm1zPmrvW4Vy5Ct0W8FxMmyPmFzdWVzesBhAJFBXMAIAAAAABYeeXjJEzTHwxab6pUiCRiZjxgtN59a1y8Szy3hfkg+gVsACAAAAAAJuoY4rF8mbI+nKb+5XbZShJ8191o/e8ZCRHE0O4Ey8MAAzcAfQAAAAVkACAAAAAAl+ibLk0/+EwoqeC8S8cGgAtjtpQWGEZDsybMPnrrkwEFcwAgAAAAAHPPBudWgQ+HUorLDpJMqhS9VBF2VF5aLcxgrM1s+yU7BWwAIAAAAAAcCcBR2Vyv5pAFbaOU97yovuOi1+ATDnLLcAUqHecXcAADOAB9AAAABWQAIAAAAACR9erwLTb+tcWFZgJ2MEfM0PKI9uuwIjDTHADRFgD+SQVzACAAAAAAcOop8TXsGUVQoKhzUllMYWxL93xCOkwtIpV8Q6hiSYYFbAAgAAAAAKXKmh4V8veYwob1H03Q3p3PN8SRAaQwDT34KlNVUjiDAAM5AH0AAAAFZAAgAAAAALv0vCPgh7QpmM8Ug6ad5ioZJCh7pLMdT8FYyQioBQ6KBXMAIAAAAADsCPyIG8t6ApQkRk1fX/sfc1kpuWCWP8gAEpnYoBSHrQVsACAAAAAAJe/r67N6d8uTiogvfoR9rEXbIDjyLb9EVdqkayFFGaYAAzEwAH0AAAAFZAAgAAAAAIW4AxJgYoM0pcNTwk1RSbyjZGIqgKL1hcTJmNrnZmoPBXMAIAAAAAAZpfx3EFO0vY0f1eHnE0PazgqeNDTaj+pPJMUNW8lFrAVsACAAAAAAP+Um2vwW6Bj6vuz9DKz6+6aWkoKoEmFNoiz/xXm7lOsAAzExAH0AAAAFZAAgAAAAAKliO6L9zgeuufjj174hvmQGNRbmYYs9yAirL7OxwEW3BXMAIAAAAAAqU7vs3DWUQ95Eq8OejwWnD0GuXd+ASi/uD6S0l8MM1QVsACAAAAAAb9legYzsfctBPpHyl7YWpPmLr5QiNZFND/50N1vv2MUAAzEyAH0AAAAFZAAgAAAAAOGQcCBkk+j/Kzjt/Cs6g3BZPJG81wIHBS8JewHGpgk+BXMAIAAAAABjrxZXWCkdzrExwCgyHaafuPSQ4V4x2k9kUCAqUaYKDQVsACAAAAAADBU6KefT0v8zSmseaMNmQxKjJar72y7MojLFhkEHqrUAAzEzAH0AAAAFZAAgAAAAAPmCNEt4t97waOSd5hNi2fNCdWEkmcFJ37LI9k4Az4/5BXMAIAAAAABX7DuDPNg+duvELf3NbLWkPMFw2HGLgWGHyVWcPvSNCAVsACAAAAAAS7El1FtZ5STh8Q1FguvieyYX9b2DF1DFVsb9hzxXYRsAAzE0AH0AAAAFZAAgAAAAAD4vtVUYRNB+FD9yoQ2FVJH3nMeJeKbi6eZfth638YqbBXMAIAAAAAANCuUB4OdmuD6LaDK2f3vaqfgYYvg40wDXOBbcFjTqLwVsACAAAAAA9hqC2VoJBjwR7hcQ45xO8ZVojwC83jiRacCaDj6Px2gAAzE1AH0AAAAFZAAgAAAAAJPIRzjmTjbdIvshG6UslbEOd797ZSIdjGAhGWxVQvK1BXMAIAAAAABgmJ0Jh8WLs9IYs/a7DBjDWd8J3thW/AGJK7zDnMeYOAVsACAAAAAAi9zAsyAuou2oiCUHGc6QefLUkACa9IgeBhGu9W/r0X8AAzE2AH0AAAAFZAAgAAAAAABQyKQPoW8wGPIqnsTv69+DzIdRkohRhOhDmyVHkw9WBXMAIAAAAAAqWA2X4tB/h3O1Xlawtz6ndI6WaTwgU1QYflL35opu5gVsACAAAAAAWI/Gj5aZMwDIxztqmVL0g5LBcI8EdKEc2UA28pnekQoAAzE3AH0AAAAFZAAgAAAAACB7NOyGQ1Id3MYnxtBXqyZ5Ul/lHH6p1b10U63DfT6bBXMAIAAAAADpOryIcndxztkHSfLN3Kzq29sD8djS0PspDSqERMqokQVsACAAAAAADatsMW4ezgnyi1PiP7xk+gA4AFIN/fb5uJqfVkjg4UoAAzE4AH0AAAAFZAAgAAAAAKVfXLfs8XA14CRTB56oZwV+bFJN5BHraTXbqEXZDmTkBXMAIAAAAAASRWTsfGOpqdffiOodoqIgBzG/yzFyjR5CfUsIUIWGpgVsACAAAAAAkgCHbCwyX640/0Ni8+MoYxeHUiC+FSU4Mn9jTLYtgZgAAzE5AH0AAAAFZAAgAAAAAH/aZr4EuS0/noQR9rcF8vwoaxnxrwgOsSJ0ys8PkHhGBXMAIAAAAACd7ObGQW7qfddcvyxRTkPuvq/PHu7+6I5dxwS1Lzy5XAVsACAAAAAA3q0eKdV7KeU3pc+CtfypKR7BPxwaf30yu0j9FXeOOboAAzIwAH0AAAAFZAAgAAAAAKvlcpFFNq0oA+urq3w6d80PK1HHHw0H0yVWvU9aHijXBXMAIAAAAADWnAHQ5Fhlcjawki7kWzdqjM2f6IdGJblojrYElWjsZgVsACAAAAAAO0wvY66l24gx8nRxyVGC0QcTztIi81Kx3ndRhuZr6W4AAzIxAH0AAAAFZAAgAAAAAH/2aMezEOddrq+dNOkDrdqf13h2ttOnexZsJxG1G6PNBXMAIAAAAABNtgnibjC4VKy5poYjvdsBBnVvDTF/4mmEAxsXVgZVKgVsACAAAAAAqvadzJFLqQbs8WxgZ2D2X+XnaPSDMLCVVgWxx5jnLcYAAzIyAH0AAAAFZAAgAAAAAF2wZoDL6/V59QqO8vdRZWDpXpkV4h4KOCSn5e7x7nmzBXMAIAAAAADLZBu7LCYjbThaVUqMK14H/elrVOYIKJQCx4C9Yjw37gVsACAAAAAAEh6Vs81jLU204aGpL90fmYTm5i5R8/RT1uIbg6VU3HwAAzIzAH0AAAAFZAAgAAAAAH27yYaLn9zh2CpvaoomUPercSfJRUmBY6XFqmhcXi9QBXMAIAAAAAAUwumVlIYIs9JhDhSj0R0+59psCMsFk94E62VxkPt42QVsACAAAAAAT5x2hCCd2bpmpnyWaxas8nSxTc8e4C9DfKaqr0ABEysAAzI0AH0AAAAFZAAgAAAAALMg2kNAO4AFFs/mW3In04yFeN4AP6Vo0klyUoT06RquBXMAIAAAAAAgGWJbeIdwlpqXCyVIYSs0dt54Rfc8JF4b8uYc+YUj0AVsACAAAAAAWHeWxIkyvXTOWvfZzqtPXjfGaWWKjGSIQENTU3zBCrsAAzI1AH0AAAAFZAAgAAAAALas/i1T2DFCEmrrLEi7O2ngJZyFHialOoedVXS+OjenBXMAIAAAAAA1kK0QxY4REcGxHeMkgumyF7iwlsRFtw9MlbSSoQY7uAVsACAAAAAAUNlpMJZs1p4HfsD4Q4WZ4TBEi6Oc2fX34rzyynqWCdwAAzI2AH0AAAAFZAAgAAAAAP1TejmWg1CEuNSMt6NUgeQ5lT+oBoeyF7d2l5xQrbXWBXMAIAAAAABPX0kj6obggdJShmqtVfueKHplH4ZrXusiwrRDHMOKeQVsACAAAAAAIYOsNwC3DA7fLcOzqdr0bOFdHCfmK8tLwPoaE9uKOosAAzI3AH0AAAAFZAAgAAAAAMrKn+QPa/NxYezNhlOX9nyEkN1kE/gW7EuZkVqYl0b8BXMAIAAAAABUoZMSPUywRGfX2EEencJEKH5x/P9ySUVrhStAwgR/LgVsACAAAAAAMgZFH6lQIIDrgHnFeslv3ld20ynwQjQJt3cAp4GgrFkAAzI4AH0AAAAFZAAgAAAAAMmD1+a+oVbiUZd1HuZqdgtdVsVKwuWAn3/M1B6QGBM3BXMAIAAAAACLyytOYuZ9WEsIrrtJbXUx4QgipbaAbmlJvSZVkGi0CAVsACAAAAAA4v1lSp5H9BB+HYJ4bH43tC8aeuPZMf78Ng1JOhJh190AAzI5AH0AAAAFZAAgAAAAAOVKV7IuFwmYP1qVv8h0NvJmfPICu8yQhzjG7oJdTLDoBXMAIAAAAABL70XLfQLKRsw1deJ2MUvxSWKxpF/Ez73jqtbLvqbuogVsACAAAAAAvfgzIorXxE91dDt4nQxYfntTsx0M8Gzdsao5naQqcRUAAzMwAH0AAAAFZAAgAAAAAKS/1RSAQma+xV9rz04IcdzmavtrBDjOKPM+Z2NEyYfPBXMAIAAAAAAOJDWGORDgfRv8+w5nunh41wXb2hCA0MRzwnLnQtIqPgVsACAAAAAAf42C1+T7xdHEFF83+c2mF5S8PuuL22ogXXELnRAZ4boAAzMxAH0AAAAFZAAgAAAAAFeq8o82uNY1X8cH6OhdTzHNBUnCChsEDs5tm0kPBz3qBXMAIAAAAABaxMBbsaeEj/EDtr8nZfrhhhirBRPJwVamDo5WwbgvTQVsACAAAAAAMbH453A+BYAaDOTo5kdhV1VdND1avNwvshEG/4MIJjQAAzMyAH0AAAAFZAAgAAAAAI8IKIfDrohHh2cjspJHCovqroSr5N3QyVtNzFvT5+FzBXMAIAAAAABXHXteKG0DoOMmECKp6ro1MZNQvXGzqTDdZ0DUc8QfFAVsACAAAAAA/w5s++XYmO+9TWTbtGc3n3ndV4T9JUribIbF4jmDLSMAAzMzAH0AAAAFZAAgAAAAAJkHvm15kIu1OtAiaByj5ieWqzxiu/epK6c/9+KYIrB0BXMAIAAAAACzg5TcyANk0nes/wCJudd1BwlkWWF6zw3nGclq5v3SJQVsACAAAAAAvruXHTT3irPJLyWpI1j/Xwf2FeIE/IV+6Z49pqRzISoAAzM0AH0AAAAFZAAgAAAAAAYSOvEWWuSg1Aym7EssNLR+xsY7e9BcwsX4JKlnSHJcBXMAIAAAAABT48eY3PXVDOjw7JpNjOe1j2JyI3LjDnQoqZ8Je5B2KgVsACAAAAAAU2815RR57TQ9uDg0XjWjBkAKvf8yssxDMzrM4+FqP6AAAzM1AH0AAAAFZAAgAAAAAGQxC9L1e9DfO5XZvX1yvc3hTLtQEdKO9FPMkyg0Y9ZABXMAIAAAAADtmcMNJwdWLxQEArMGZQyzpnu+Z5yMmPAkvgq4eAKwNQVsACAAAAAAJ88zt4Y/Hoqh+zrf6KCOiUwHbOzCxSfp6k/qsZaYGEgAAzM2AH0AAAAFZAAgAAAAADLHK2LNCNRO0pv8n4fAsxwtUqCNnVK8rRgNiQfXpHSdBXMAIAAAAACf16EBIHRKD3SzjRW+LMOl+47QXA3CJhMzlcqyFRW22AVsACAAAAAAMGz4fAOa0EoVv90fUffwLjBrQhHATf+NdlgCR65vujAAAzM3AH0AAAAFZAAgAAAAAHiZJiXKNF8bbukQGsdYkEi95I+FSBHy1I5/hK2uEZruBXMAIAAAAADE+lZBa8HDUJPN+bF6xI9x4N7GF9pj3vBR7y0BcfFhBAVsACAAAAAAGIEN6sfqq30nyxW4dxDgXr/jz5HmvA9T1jx/pKCn4zgAAzM4AH0AAAAFZAAgAAAAAI1oa2OIw5TvhT14tYCGmhanUoYcCZtNbrVbeoMldHNZBXMAIAAAAAAx2nS0Ipblf2XOgBiUOuJFBupBhe7nb6QPLZlA4aMPCgVsACAAAAAA9xu828hugIgo0E3de9dZD+gTpVUGlwtDba+tw/WcbUoAAzM5AH0AAAAFZAAgAAAAABgTWS3Yap7Q59hii/uPPimHWXsr+DUmsqfwt/X73qsOBXMAIAAAAACKK05liW5KrmEAvtpCB1WUltruzUylDDpjea//UlWoOAVsACAAAAAAcgN4P/wakJ5aJK5c1bvJBqpVGND221dli2YicPFfuAYAAzQwAH0AAAAFZAAgAAAAABOAnBPXDp6i9TISQXvcNKwGDLepZTu3cKrB4vKnSCjBBXMAIAAAAADjjzZO7UowAAvpwyG8BNOVqLCccMFk3aDK4unUeft5ywVsACAAAAAA4zkCd4k9gvfXoD1C7vwTjNcdVJwEARh8h/cxZ4PNMfgAAzQxAH0AAAAFZAAgAAAAAHN8hyvT1lYrAsdiV5GBdd5jhtrAYE/KnSjw2Ka9hjz9BXMAIAAAAAD794JK7EeXBs+D7yOVK7nWF8SbZ/7U8gZ7nnT9JFNwTAVsACAAAAAAg8Wt1HO3NhByq2ggux2a4Lo6Gryr24rEFIqh2acrwWMAAzQyAH0AAAAFZAAgAAAAAO93bPrq8bsnp1AtNd9ETnXIz0lH/2HYN/vuw9wA3fyFBXMAIAAAAABHlls5fbaF2oAGqptC481XQ4eYxInTC29aElfmVZgDUgVsACAAAAAANoQXEWpXJpgrSNK/cKi/m7oYhuSRlp1IZBF0bqTEATcAAzQzAH0AAAAFZAAgAAAAAL1YsAZm1SA0ztU6ySIrQgCCA74V6rr0/4iIygCcaJL6BXMAIAAAAADTXWTHWovGmUR1Zg9l/Aqq9H5mOCJQQrb/Dfae7e3wKAVsACAAAAAA5dunyJK6/SVfDD0t9QlNBcFqoZnf9legRjHaLSKAoQMAAzQ0AH0AAAAFZAAgAAAAAEoFAeHk0RZ9kD+cJRD3j7PcE5gzWKnyBrF1I/MDNp5mBXMAIAAAAACgHtc2hMBRSZjKw8RAdDHK+Pi1HeyjiBuAslGVNcW5tAVsACAAAAAAXzBLfq+GxRtX4Wa9fazA49DBLG6AjZm2XODStJKH8D0AAzQ1AH0AAAAFZAAgAAAAAAW+7DmSN/LX+/0uBVJDHIc2dhxAGz4+ehyyz8fAnNGoBXMAIAAAAAA6Ilw42EvvfLJ3Eq8Afd+FjPoPcQutZO6ltmCLEr8kxQVsACAAAAAAbbZalyo07BbFjPFlYmbmv0z023eT9eLkHqeVUnfUAUAAAzQ2AH0AAAAFZAAgAAAAANBdV7M7kuYO3EMoQItAbXv4t2cIhfaT9V6+s4cg9djlBXMAIAAAAABvz4MIvZWxxrcJCL5qxLfFhXiUYB1OLHdKEjco94SgDgVsACAAAAAAK2GVGvyPIKolF/ECcmfmkVcf1/IZNcaTv96N92yGrkEAAzQ3AH0AAAAFZAAgAAAAAMoAoiAn1kc79j5oPZtlMWHMhhgwNhLUnvqkqIFvcH1NBXMAIAAAAADcJTW7WiCyW0Z9YDUYwppXhLj4Ac1povpJvcAq+i48MQVsACAAAAAAIGxGDzoeB3PTmudl4+j6piQB++e33EEzuzAiXcqGxvUAAzQ4AH0AAAAFZAAgAAAAACI3j5QP7dWHpcT6WO/OhsWwRJNASBYqIBDNzW8IorEyBXMAIAAAAABxUpBSjXwCKDdGP9hYU+RvyR+96kChfvyyRC4jZmztqAVsACAAAAAAvBCHguWswb4X0xdcAryCvZgQuthXzt7597bJ5VxAMdgAAzQ5AH0AAAAFZAAgAAAAAKsbycEuQSeNrF8Qnxqw3x3og8JmQabwGqnDbqzFRVrrBXMAIAAAAACno/3ef2JZJS93SVVzmOZSN+jjJHT8s0XYq2M46d2sLAVsACAAAAAAAt5zLJG+/j4K8rnkFtAn8IvdUVNefe6utJ3rdzgwudIAAzUwAH0AAAAFZAAgAAAAAPXIcoO8TiULqlxzb74NFg+I8kWX5uXIDUPnh2DobIoMBXMAIAAAAADR6/drkdTpnr9g1XNvKDwtBRBdKn7c2c4ZNUVK5CThdQVsACAAAAAAJqOA1c6KVog3F4Hb/GfDb3jCxXDRTqpXWSbMH4ePIJsAAzUxAH0AAAAFZAAgAAAAAEa03ZOJmfHT6/nVadvIw71jVxEuIloyvxXraYEW7u7pBXMAIAAAAADzRlBJK75FLiKjz3djqcgjCLo/e3yntI3MnPS48OORhgVsACAAAAAAnQhx4Rnyj081XrLRLD5NLpWmRWCsd0M9Hl7Jl19R0h8AAzUyAH0AAAAFZAAgAAAAAKx8NLSZUU04pSSGmHa5fh2oLHsEN5mmNMNHL95/tuC9BXMAIAAAAAA59hcXVaN3MNdHoo11OcH1aPRzHCwpVjO9mGfMz4xh3QVsACAAAAAAYIPdjV2XbPj7dBeHPwnwhVU7zMuJ+xtMUW5mIOYtmdAAAzUzAH0AAAAFZAAgAAAAAHNKAUxUqBFNS9Ea9NgCZoXMWgwhP4x0/OvoaPRWMquXBXMAIAAAAABUZ551mnP4ZjX+PXU9ttomzuOpo427MVynpkyq+nsYCQVsACAAAAAALnVK5p2tTTeZEh1zYt4iqKIQT9Z0si//Hy1L85oF+5IAAzU0AH0AAAAFZAAgAAAAALfGXDlyDVcGaqtyHkLT0qpuRhJQLgCxtznazhFtuyn/BXMAIAAAAABipxlXDq14C62pXhwAeen5+syA+/C6bN4rtZYcO4zKwAVsACAAAAAAXUf0pzUq0NhLYagWDap4uEiwq5rLpcx29rWbt1NYMsMAAzU1AH0AAAAFZAAgAAAAANoEr8sheJjg4UCfBkuUzarU9NFoy1xwbXjs5ifVDeA9BXMAIAAAAABPoyTf6M+xeZVGES4aNzVlq7LgjqZXJ/QunjYVusGUEAVsACAAAAAA1hA2gMeZZPUNytk9K+lB1RCqWRudRr7GtadJlExJf8oAAzU2AH0AAAAFZAAgAAAAAKvDiK+xjlBe1uQ3SZTNQl2lClIIvpP/5CHwY6Kb3WlgBXMAIAAAAAANnxImq5MFbWaRBHdJp+yD09bVlcFtiFDYsy1eDZj+iQVsACAAAAAAWtsyO+FxMPSIezwsV1TJD8ZrXAdRnQM6DJ+f+1V3qEkAAzU3AH0AAAAFZAAgAAAAAF49IlFH9RmSUSvUQpEPUedEksrQUcjsOv44nMkwXhjzBXMAIAAAAADJtWGbk0bZzmk20obz+mNsp86UCu/nLLlbg7ppxYn7PgVsACAAAAAA3k0Tj/XgPQtcYijH8cIlQoe/VXf15q1nrZNmg7yWYEgAAzU4AH0AAAAFZAAgAAAAAOuSJyuvz50lp3BzXlFKnq62QkN2quNU1Gq1IDsnFoJCBXMAIAAAAAAqavH1d93XV3IzshWlMnzznucadBF0ND092/2ApI1AcAVsACAAAAAAzUrK4kpoKCmcpdZlZNI13fddjdoAseVe67jaX1LobIIAAzU5AH0AAAAFZAAgAAAAALtgC4Whb4ZdkCiI30zY6fwlsxSa7lEaOAU3SfUXr02XBXMAIAAAAACgdZ6U1ZVgUaZZwbIaCdlANpCw6TZV0bwg3DS1NC/mnAVsACAAAAAAzI49hdpp0PbO7S2KexISxC16sE73EUAEyuqUFAC/J48AAzYwAH0AAAAFZAAgAAAAAF6PfplcGp6vek1ThwenMHVkbZgrc/dHgdsgx1VdPqZ5BXMAIAAAAACha3qhWkqmuwJSEXPozDO8y1ZdRLyzt9Crt2vjGnT7AAVsACAAAAAA7nvcU59+LwxGupSF21jAeAE0x7JE94tjRkJfgM1yKU8AAzYxAH0AAAAFZAAgAAAAAKoLEhLvLjKc7lhOJfx+VrGJCx9tXlOSa9bxQzGR6rfbBXMAIAAAAAAIDK5wNnjRMBzET7x/KAMExL/zi1IumJM92XTgXfoPoAVsACAAAAAAFkUYWFwNr815dEdFqp+TiIozDcq5IBNVkyMoDjharDQAAzYyAH0AAAAFZAAgAAAAADoQv6lutRmh5scQFvIW6K5JBquLxszuygM1tzBiGknIBXMAIAAAAADAD+JjW7FoBQ76/rsECmmcL76bmyfXpUU/awqIsZdO+wVsACAAAAAAPFHdLw3jssmEXsgtvl/RBNaUCRA1kgSwsofG364VOvQAAzYzAH0AAAAFZAAgAAAAAJNHUGAgn56KekghO19d11nai3lAh0JAlWfeP+6w4lJBBXMAIAAAAAD9XGJlvz59msJvA6St9fKW9CG4JoHV61rlWWnkdBRLzwVsACAAAAAAxwP/X/InJJHmrjznvahIMgj6pQR30B62UtHCthSjrP0AAzY0AH0AAAAFZAAgAAAAAHgYoMGjEE6fAlAhICv0+doHcVX8CmMVxyq7+jlyGrvmBXMAIAAAAAC/5MQZgTHuIr/O5Z3mXPvqrom5JTQ8IeSpQGhO9sB+8gVsACAAAAAAuPSXVmJUAUpTQg/A9Bu1hYczZF58KEhVofakygbsvJQAAzY1AH0AAAAFZAAgAAAAANpIljbxHOM7pydY877gpRQvYY2TGK7igqgGsavqGPBABXMAIAAAAAAqHyEu9gpurPOulApPnr0x9wrygY/7mXe9rAC+tPK80wVsACAAAAAA7gkPzNsS3gCxdFBWbSW9tkBjoR5ib+saDvpGSB3A3ogAAzY2AH0AAAAFZAAgAAAAAGR+gEaZTeGNgG9BuM1bX2R9ed4FCxBA9F9QvdQDAjZwBXMAIAAAAABSkrYFQ6pf8MZ1flgmeIRkxaSh/Eep4Btdx4QYnGGnwAVsACAAAAAApRovMiV00hm/pEcT4XBsyPNw0eo8RLAX/fuabjdU+uwAAzY3AH0AAAAFZAAgAAAAAFNprhQ3ZwIcYbuzLolAT5n/vc14P9kUUQComDu6eFyKBXMAIAAAAAAcx9z9pk32YbPV/sfPZl9ALIEVsqoLXgqWLVK/tP+heAVsACAAAAAA/qxvuvJbAHwwhfrPVpmCFzNvg2cU/NXaWgqgYUZpgXwAAzY4AH0AAAAFZAAgAAAAADgyPqQdqQrgfmJjRFAILTHzXbdw5kpKyfeoEcy6YYG/BXMAIAAAAAAE+3XsBQ8VAxAkN81au+f3FDeCD/s7KoZD+fnM1MJSSAVsACAAAAAAhRnjrXecwV0yeCWKJ5J/x12Xx4qVJahsCEVHB/1U2rcAAzY5AH0AAAAFZAAgAAAAAI0CT7JNngTCTUSei1Arw7eHWCD0jumv2rb7imjWIlWABXMAIAAAAABSP8t6ya0SyCphXMwnru6ZUDXWElN0NfBvEOhDvW9bJQVsACAAAAAAGWeGmBNDRaMtvm7Rv+8TJ2sJ4WNXKcp3tqpv5Se9Ut4AAzcwAH0AAAAFZAAgAAAAAD/FIrGYFDjyYmVb7oTMVwweWP7A6F9LnyIuNO4MjBnXBXMAIAAAAACIZgJCQRZu7NhuNMyOqCn1tf+DfU1qm10TPCfj5JYV3wVsACAAAAAA5hmY4ptuNxULGf87SUFXQWGAONsL9U29duh8xqsHtxoAAzcxAH0AAAAFZAAgAAAAAHIkVuNDkSS1cHIThKc/O0r2/ubaABTOi8Q1r/dvBAsEBXMAIAAAAADdHYqchEiJLM340c3Q4vJABmmth3+MKzwLYlsG6GS7sQVsACAAAAAADa+KP/pdTiG22l+ZWd30P1iHjnBF4zSNRdFm0oEK82kAAzcyAH0AAAAFZAAgAAAAAJmoDILNhC6kn3masElfnjIjP1VjsjRavGk1gSUIjh1NBXMAIAAAAAD97Ilvp3XF8T6MmVVcxMPcdL80RgQ09UoC6PnoOvZ1IQVsACAAAAAA2RK3Xng6v8kpvfVW9tkVXjpE+BSnx9/+Fw85Evs+kUEAAzczAH0AAAAFZAAgAAAAAI5bm3YO0Xgf0VT+qjVTTfvckecM3Cwqj7DTKZXf8/NXBXMAIAAAAAD/m+h8fBhWaHm6Ykuz0WX1xL4Eme3ErLObyEVJf8NCywVsACAAAAAAfb1VZZCqs2ivYbRzX4p5CtaCkKW+g20Pr57FWXzEZi8AAzc0AH0AAAAFZAAgAAAAANqo4+p6qdtCzcB4BX1wQ6llU7eFBnuu4MtZwp4B6mDlBXMAIAAAAAAGiz+VaukMZ+6IH4jtn4KWWdKK4/W+O+gRioQDrfzpMgVsACAAAAAAG4YYkTp80EKo59mlHExDodRQFR7njhR5dmISwUJ6ukAAAzc1AH0AAAAFZAAgAAAAAPrFXmHP2Y4YAm7b/aqsdn/DPoDkv7B8egWkfe23XsM1BXMAIAAAAAAGhwpKAr7skeqHm3oseSbO7qKNhmYsuUrECBxJ5k+D2AVsACAAAAAAAqPQi9luYAu3GrFCEsVjd9z2zIDcp6SPTR2w6KQEr+IAAzc2AH0AAAAFZAAgAAAAABzjYxwAjXxXc0Uxv18rH8I3my0Aguow0kTwKyxbrm+cBXMAIAAAAADVbqJVr6IdokuhXkEtXF0C2gINLiAjMVN20lE20Vmp2QVsACAAAAAAD7K1Fx4gFaaizkIUrf+EGXQeG7QX1jadhGc6Ji471H8AAzc3AH0AAAAFZAAgAAAAAFMm2feF2fFCm/UC6AfIyepX/xJDSmnnolQIBnHcPmb5BXMAIAAAAABLI11kFrQoaNVZFmq/38aRNImPOjdJh0Lo6irI8M/AaAVsACAAAAAAOWul0oVqJ9CejD2RqphhTC98DJeRQy5EwbNerU2+4l8AAzc4AH0AAAAFZAAgAAAAAJvXB3KyNiNtQko4SSzo/9b2qmM2zU9CQTTDfLSBWMgRBXMAIAAAAAAvjuVP7KsLRDeqVqRziTKpBrjVyqKiIbO9Gw8Wl2wFTAVsACAAAAAADlE+oc1ins+paNcaOZJhBlKlObDJ4VQORWjFYocM4LgAAzc5AH0AAAAFZAAgAAAAAPGdcxDiid8z8XYnfdDivNMYVPgBKdGOUw6UStU+48CdBXMAIAAAAAARj6g1Ap0eEfuCZ4X2TsEw+Djrhto3fA5nLwPaY0vCTgVsACAAAAAAoHqiwGOUkBu8SX5U1yHho+UIFdSN2MdQN5s6bQ0EsJYAAzgwAH0AAAAFZAAgAAAAAP5rGPrYGt3aKob5f/ldP0qrW7bmWvqnKY4QwdDWz400BXMAIAAAAADTQkW2ymaaf/bhteOOGmSrIR97bAnJx+yN3yMj1bTeewVsACAAAAAADyQnHGH2gF4w4L8axUsSTf6Ubk7L5/eoFOJk12MtZAoAAzgxAH0AAAAFZAAgAAAAAAlz6wJze5UkIxKpJOZFGCOf3v2KByWyI6NB6JM9wNcBBXMAIAAAAABUC7P/neUIHHoZtq0jFVBHY75tSFYr1Y5S16YN5XxC1QVsACAAAAAAgvxRbXDisNnLY3pfsjDdnFLtkvYUC4lhA68eBXc7KAwAAzgyAH0AAAAFZAAgAAAAAFJ8AtHcjia/9Y5pLEc3qVgH5xKiXw12G9Kn2A1EY8McBXMAIAAAAAAxe7Bdw7eUSBk/oAawa7uicTEDgXLymRNhBy1LAxhDvwVsACAAAAAAxKPaIBKVx3jTA+R/el7P7AZ7efrmTGjJs3Hj/YdMddwAAzgzAH0AAAAFZAAgAAAAAO8uwQUaKFb6vqR3Sv3Wn4QAonC2exOC9lGG1juqP5DtBXMAIAAAAABZf1KyJgQg8/Rf5c02DgDK2aQu0rNCOvaL60ohDHyY+gVsACAAAAAAqyEjfKC8lYoIfoXYHUqHZPoaA6EK5BAZy5dxXZmay4kAAzg0AH0AAAAFZAAgAAAAAE8YtqyRsGCeiR6hhiyisR/hccmK4nZqIMzO4lUBmEFzBXMAIAAAAAC1UYOSKqAeG1UJiKjWFVskRhuFKpj9Ezy+lICZvFlN5AVsACAAAAAA6Ct9nNMKyRazn1OKnRKagm746CGu+jyhbL1qJnZxGi0AAzg1AH0AAAAFZAAgAAAAAPhCrMausDx1QUIEqp9rUdRKyM6a9AAx7jQ3ILIu8wNIBXMAIAAAAACmH8lotGCiF2q9VQxhsS+7LAZv79VUAsOUALaGxE/EpAVsACAAAAAAnc1xCKfdvbUEc8F7XZqlNn1C+hZTtC0I9I3LL06iaNkAAzg2AH0AAAAFZAAgAAAAAOBi/GAYFcstMSJPgp3VkMiuuUUCrZytvqYaU8dwm8v2BXMAIAAAAACEZSZVyD3pKzGlbdwlYmWQhHHTV5SnNLknl2Gw8IaUTQVsACAAAAAAfsLZsEDcWSuNsIo/TD1ReyQW75HPMgmuKZuWFOLKRLoAAzg3AH0AAAAFZAAgAAAAAIQuup+YGfH3mflzWopN8J1X8o8a0d9CSGIvrA5HOzraBXMAIAAAAADYvNLURXsC2ITMqK14LABQBI+hZZ5wNf24JMcKLW+84AVsACAAAAAACzfjbTBH7IwDU91OqLAz94RFkoqBOkzKAqQb55gT4/MAAzg4AH0AAAAFZAAgAAAAAKsh0ADyOnVocFrOrf6MpTrNvAj8iaiE923DPryu124gBXMAIAAAAADg24a8NVE1GyScc6tmnTbmu5ulzO+896fE92lN08MeswVsACAAAAAAaPxcOIxnU7But88/yadOuDJDMcCywwrRitaxMODT4msAAzg5AH0AAAAFZAAgAAAAAKkVC2Y6HtRmv72tDnPUSjJBvse7SxLqnr09/Uuj9sVVBXMAIAAAAABYNFUkH7ylPMN+Bc3HWX1e0flGYNbtJNCY9SltJCW/UAVsACAAAAAAZYK/f9H4OeihmpiFMH7Wm7uLvs2s92zNA8wyrNZTsuMAAzkwAH0AAAAFZAAgAAAAADDggcwcb/Yn1Kk39sOHsv7BO/MfP3m/AJzjGH506Wf9BXMAIAAAAAAYZIsdjICS0+BDyRUPnrSAZfPrwtuMaEDEn0/ijLNQmAVsACAAAAAAGPnYVvo2ulO9z4LGd/69NAklfIcZqZvFX2KK0s+FcTUAAzkxAH0AAAAFZAAgAAAAAEWY7dEUOJBgjOoWVht1wLehsWAzB3rSOBtLgTuM2HC8BXMAIAAAAAAAoswiHRROurjwUW8u8D5EUT+67yvrgpB/j6PzBDAfVwVsACAAAAAA6NhRTYFL/Sz4tao7vpPjLNgAJ0FX6P/IyMW65qT6YsMAAzkyAH0AAAAFZAAgAAAAAPZaapeAUUFPA7JTCMOWHJa9lnPFh0/gXfAPjA1ezm4ZBXMAIAAAAACmJvLY2nivw7/b3DOKH/X7bBXjJwoowqb1GtEFO3OYgAVsACAAAAAA/JcUoyKacCB1NfmH8vYqC1f7rd13KShrQqV2r9QBP44AAzkzAH0AAAAFZAAgAAAAAK00u6jadxCZAiA+fTsPVDsnW5p5LCr4+kZZZOTDuZlfBXMAIAAAAAAote4zTEYMDgaaQbAdN8Dzv93ljPLdGjJzvnRn3KXgtQVsACAAAAAAxXd9Mh6R3mnJy8m7UfqMKi6oD5DlZpkaOz6bEjMOdiwAAzk0AH0AAAAFZAAgAAAAAFbgabdyymiEVYYwtJSWa7lfl/oYuj/SukzJeDOR6wPVBXMAIAAAAADAFGFjS1vPbN6mQEhkDYTD6V2V23Ys9gUEUMGNvMPkaAVsACAAAAAAL/D5Sze/ZoEanZLK0IeEkhgVkxEjMWVCfmJaD3a8uNIAAzk1AH0AAAAFZAAgAAAAABNMR6UBv2E627CqLtQ/eDYx7OEwQ7JrR4mSHFa1N8tLBXMAIAAAAAAxH4gucI4UmNVB7625C6hFSVCuIpJO3lusJlPuL8H5EQVsACAAAAAAVLHNg0OUVqZ7WGOP53BkTap9FOw9dr1P4J8HxqFqU04AAzk2AH0AAAAFZAAgAAAAAG8cd6WBneNunlqrQ2EmNf35W7OGObGq9WL4ePX+LUDmBXMAIAAAAAAjJ2+sX87NSis9hBsgb1QprVRnO7Bf+GObCGoUqyPE4wVsACAAAAAAs9c9SM49/pWmyUQKslpt3RTMBNSRppfNO0JBvUqHPg0AAzk3AH0AAAAFZAAgAAAAAFWOUGkUpy8yf6gB3dio/aOfRKh7XuhvsUj48iESFJrGBXMAIAAAAAAY7sCDMcrUXvNuL6dO0m11WyijzXZvPIcOKob6IpC4PQVsACAAAAAAJOP+EHz6awDb1qK2bZQ3kTV7wsj5Daj/IGAWh4g7omAAAzk4AH0AAAAFZAAgAAAAAGUrIdKxOihwNmo6B+aG+Ag1qa0+iqdksHOjQj+Oy9bZBXMAIAAAAABwa5dbI2KmzBDNBTQBEkjZv4sPaeRkRNejcjdVymRFKQVsACAAAAAA4ml/nm0gJNTcJ4vuD+T2Qfq2fQZlibJp/j6MOGDrbHMAAzk5AH0AAAAFZAAgAAAAAOx89xV/hRk64/CkM9N2EMK6aldII0c8smdcsZ46NbP8BXMAIAAAAADBF6tfQ+7q9kTuLyuyrSnDgmrdmrXkdhl980i1KHuGHgVsACAAAAAACUqiFqHZdGbwAA+hN0YUE5zFg+H+dabIB4dj5/75W/YAAzEwMAB9AAAABWQAIAAAAADJDdC9aEFl4Y8J/awHbnXGHjfP+VXQilPHJg7ewaJI7AVzACAAAAAAE+tqRl6EcBMXvbr4GDiNIYObTsYpa1n6BJk9EjIJVicFbAAgAAAAAJVc+HYYqa0m1Hq6OiRX8c0iRnJYOt6AJAJoG0sG3GMSAAMxMDEAfQAAAAVkACAAAAAA3F9rjEKhpoHuTULVGgfUsGGwJs3bISrXkFP1v6KoQLgFcwAgAAAAAIBf0tXw96Z/Ds0XSIHX/zk3MzUR/7WZR/J6FpxRWChtBWwAIAAAAABWrjGlvKYuTS2s8L9rYy8Hf0juFGJfwQmxVIjkTmFIGQADMTAyAH0AAAAFZAAgAAAAAOYIYoWkX7dGuyKfi3XssUlc7u/gWzqrR9KMkikKVdmSBXMAIAAAAABVF2OYjRTGi9Tw8XCAwZWLpX35Yl271TlNWp6N/nROhAVsACAAAAAA0nWwYzXQ1+EkDvnGq+SMlq20z+j32Su+i/A95SggPb4AAzEwMwB9AAAABWQAIAAAAACMtPm12YtdEAvqu6Eji1yuRXnu1RJP6h0l7pH3lSH4MwVzACAAAAAAENyCFfyUAh1veQBGx+cxiB7Sasrj41jzCGflZkB5cRMFbAAgAAAAAKdI2LMqISr/T5vuJPg6ZRBm5fVi2aQCc4ra3A4+AjbDAAMxMDQAfQAAAAVkACAAAAAAvlI4lDcs6GB1cnm/Tzo014CXWqidCdyE5t2lknWQd4QFcwAgAAAAAD60SpNc4O2KT7J0llKdSpcX1/Xxs97N715a1HsTFkmBBWwAIAAAAABuuRkJWAH1CynggBt1/5sPh9PoGiqTlS24D/OE2uHXLQADMTA1AH0AAAAFZAAgAAAAAKl8zcHJRDjSjJeV/WvMxulW1zrTFtaeBy/aKKhadc6UBXMAIAAAAADBdWQl5SBIvtZZLIHszePwkO14W1mQ0izUk2Ov21cPNAVsACAAAAAAHErCYycpqiIcCZHdmPL1hi+ovLQk4TAvENpfLdTRamQAAzEwNgB9AAAABWQAIAAAAABb6LXDWqCp1beQgQjj8I3sRTtFhlrmiBi+h/+ikmrvugVzACAAAAAA9stpgTecT7uTyaGNs3K9Bp0A7R0QaIAOfscyMXHBPX8FbAAgAAAAAHUt+McyXrJ1H8SwnHNVO181Ki8vDAM1f7XI26mg95ZDAAMxMDcAfQAAAAVkACAAAAAA97NTT+81PhDhgptNtp4epzA0tP4iNb9j1AWkiiiKGM8FcwAgAAAAAKPbHg7ise16vxmdPCzksA/2Mn/qST0L9Xe8vnQugVkcBWwAIAAAAABB0EMXfvju4JU/mUH/OvxWbPEl9NJkcEp4iCbkXI41fAADMTA4AH0AAAAFZAAgAAAAAMqpayM2XotEFmm0gwQd9rIzApy0X+7HfOhNk6VU7F5lBXMAIAAAAACJR9+q5T9qFHXFNgGbZnPubG8rkO6cwWhzITQTmd6VgwVsACAAAAAAOZLQ6o7e4mVfDzbpQioa4d3RoTvqwgnbmc5Qh2wsZuoAAzEwOQB9AAAABWQAIAAAAADQnslvt6Hm2kJPmqsTVYQHE/wWeZ4bE1XSkt7TKy0r1gVzACAAAAAA8URTA4ZMrhHPvlp53TH6FDCzS+0+61qHm5XK6UiOrKEFbAAgAAAAAHQbgTCdZcbdA0avaTmZXUKnIS7Nwf1tNrcXDCw+PdBRAAMxMTAAfQAAAAVkACAAAAAAhujlgFPFczsdCGXtQ/002Ck8YWQHHzvWvUHrkbjv4rwFcwAgAAAAALbV0lLGcSGfE7mDM3n/fgEvi+ifjl7WZ5b3aqjDNvx9BWwAIAAAAACbceTZy8E3QA1pHmPN5kTlOx3EO8kJM5PUjTVftw1VpgADMTExAH0AAAAFZAAgAAAAABm/6pF96j26Jm7z5KkY1y33zcAEXLx2n0DwC03bs/ixBXMAIAAAAAD01OMvTZI/mqMgxIhA5nLs068mW+GKl3OW3ilf2D8+LgVsACAAAAAAaLvJDrqBESTNZSdcXsd+8GXPl8ZkUsGpeYuyYVv/kygAAzExMgB9AAAABWQAIAAAAACfw9/te4GkHZAapC9sDMHHHZgmlTrccyJDPFciOMSOcwVzACAAAAAAIIC1ZpHObvmMwUfqDRPl4C1aeuHwujM1G/yJbvybMNAFbAAgAAAAAAs9x1SnVpMfNv5Bm1aXGwHmbbI9keWa9HRD35XuCBK5AAMxMTMAfQAAAAVkACAAAAAAkxHJRbnShpPOylLoDdNShfILeA1hChKFQY9qQyZ5VmsFcwAgAAAAAKidrY+rC3hTY+YWu2a7fuMH2RD/XaiTIBW1hrxNCQOJBWwAIAAAAACW0kkqMIzIFMn7g+R0MI8l15fr3k/w/mHtY5n6SYTEwAADMTE0AH0AAAAFZAAgAAAAAByuYl8dBvfaZ0LO/81JW4hYypeNmvLMaxsIdvqMPrWoBXMAIAAAAABNddwobOUJzm9HOUD8BMZJqkNCUCqstHZkC76FIdNg9AVsACAAAAAAQQOkIQtkyNavqCnhQbNg3HfqrJdsAGaoxSJePJl1qXsAAzExNQB9AAAABWQAIAAAAABxMy7X5hf7AXGDz3Y/POu1ZpkMlNcSvSP92NOO/Gs7wAVzACAAAAAAHJshWo2T5wU2zvqCyJzcJQKQaHFHpCpMc9oWBXkpUPoFbAAgAAAAAGeiJKzlUXAvL0gOlW+Hz1mSa2HsV4RGmyLmCHlzbAkoAAMxMTYAfQAAAAVkACAAAAAAlqbslixl7Zw3bRlibZbe/WmKw23k8uKeIzPKYEtbIy0FcwAgAAAAAHEKwpUxkxOfef5HYvulXPmdbzTivwdwrSYIHDeNRcpcBWwAIAAAAADuPckac21Hrg/h0kt5ShJwVEZ9rx6SOHd2+HDjqxEWTQADMTE3AH0AAAAFZAAgAAAAAMXrXx0saZ+5gORmwM2FLuZG6iuO2YS+1IGPoAtDKoKBBXMAIAAAAADIQsxCr8CfFKaBcx8kIeSywnGh7JHjKRJ9vJd9x79y7wVsACAAAAAAcvBV+SykDYhmRFyVYwFYB9oBKBSHr55Jdz2cXeowsUQAAzExOAB9AAAABWQAIAAAAAAm83FA9yDUpwkbKTihe7m53u+DivS9BU2b4vQMtCVQ2AVzACAAAAAAz3m1UB/AbZPa4QSKFDnUgHaT78+6iGOFAtouiBorEgEFbAAgAAAAAIgbpyYtJj5513Z5XYqviH/HXG/5+mqR52iBbfqMmDtZAAMxMTkAfQAAAAVkACAAAAAAJRzYK0PUwr9RPG2/7yID0WgcTJPB2Xjccp5LAPDYunkFcwAgAAAAAIIh24h3DrltAzNFhF+MEmPrZtzr1PhCofhChZqfCW+jBWwAIAAAAAAzRNXtL5o9VXMk5D5ylI0odPDJDSZZry1wfN+TedH70gADMTIwAH0AAAAFZAAgAAAAAHSaHWs/dnmI9sc7nB50VB2Bzs0kHapMHCQdyVEYY30TBXMAIAAAAACkV22lhEjWv/9/DubfHBAcwJggKI5mIbSK5L2nyqloqQVsACAAAAAAS19m7DccQxgryOsBJ3GsCs37yfQqNi1G+S6fCXpEhn4AAzEyMQB9AAAABWQAIAAAAAAC/I4TQRtCl12YZmdGz17X4GqSQgfwCPgRBwdHmdwu+QVzACAAAAAAx8f3z2ut/RAZhleari4vCEE+tNIn4ikjoUwzitfQ588FbAAgAAAAAJci0w1ZB8W2spJQ+kMpod6HSCtSR2jrabOH+B0fj3A4AAMxMjIAfQAAAAVkACAAAAAADGB5yU2XT0fse/MPWgvBvZikVxrl5pf3S5K1hceKWooFcwAgAAAAAIxTmlLHMjNaVDEfJbXvRez0SEPWFREBJCT6qTHsrljoBWwAIAAAAAAlswzAl81+0DteibwHD+CG5mZJrfHXa9NnEFRtXybzzwADMTIzAH0AAAAFZAAgAAAAABmO7QD9vxWMmFjIHz13lyOeV6vHT6mYCsWxF7hb/yOjBXMAIAAAAACT9lmgkiqzuWG24afuzYiCeK9gmJqacmxAruIukd0xEAVsACAAAAAAZa0/FI/GkZR7CtX18Xg9Tn9zfxkD0UoaSt+pIO5t1t4AAzEyNAB9AAAABWQAIAAAAAAfPUoy7QyZKhIIURso+mkP9qr1izbjETqF5s22GwjCjAVzACAAAAAAvLMsIDQ/go4VUxeh50UHmsvMvfx51cwyONnRD2odvC0FbAAgAAAAAKMb+1CodEalAFnDrEL1Ndt8ztamZ+9134m9Kp3GQgd+AAMxMjUAfQAAAAVkACAAAAAAE3ZqUar0Bq2zWbARE0bAv98jBlK9UJ73/xcwdMWWlSkFcwAgAAAAAK4M+MmC+9sFiFsumMyJZQKxWmmJiuG9H7IzKw083xxkBWwAIAAAAAAqkAONzhvMhkyL1D/6h7QQxEkdhC3p2WjXH+VGq5qCqQADMTI2AH0AAAAFZAAgAAAAAMo8FJiOq63cAmyk2O7eI7GcbQh/1j4RrMTqly3rexftBXMAIAAAAADjVmpd0WiRGTw/gAqEgGolt2EI7Csv14vKdmYoMD0aAgVsACAAAAAA07XQBzBUQMNw7F2/YxJjZNuPVpHTTgbLd1oGk77+bygAAzEyNwB9AAAABWQAIAAAAACu5IGaIx7A3Jvly/kzlCsSA4s3iJwuIl8jEdRH0k93NwVzACAAAAAA9NRUyxYE+t0Xyosyt6vIfMFW/vBoYg6sR+jBNs4JAxIFbAAgAAAAAAzyZ91dx+0oMlOVAjRGiMrPySikY/U9eMEB4WJb3uWtAAMxMjgAfQAAAAVkACAAAAAALkRy0GJInXYLA+cgjs6Myb0a+Gu9hgXhHvhLNoGWfckFcwAgAAAAANbALyt9zCSvwnLaWCd2/y2eoB7qkWTvv1Ldu8r40JPuBWwAIAAAAAD4Fl5bV5sz4isIE9bX+lmAp+aAKaZgVYVZeVfrItkCZAADMTI5AH0AAAAFZAAgAAAAAGoUK/DSWhT8LZhszSUqDbTrp8cSA7rdqmADKL+MILtTBXMAIAAAAABHnEE9bVa6lvhfhEMkkV2kzSSxH/sMW/FIJuw3CzWs6wVsACAAAAAAanavcBdqZxgRGKvEK95wTmeL1K1CeDSXZsXUAs81uOgAAzEzMAB9AAAABWQAIAAAAAC922ZDQE3h2fQKibGMZ9hV0WNlmrPYYSdtaSyYxsWYqgVzACAAAAAAagMovciKK6WVjIc2cCj8nK5O/gVOFFVeVAJpRp89tmQFbAAgAAAAAKcTFfPQzaFiAtSFhqbN02sCE1BKWJSrRfGN5L6oZwzkAAMxMzEAfQAAAAVkACAAAAAAtK+JqX3K/z2txjAU15DgX4y90DS2YLfIJFolCOkJJJwFcwAgAAAAAMnR5V7gfX7MNqqUdL5AkWlkhyFXaBRVNej+Rcn8lrQkBWwAIAAAAAA2cDNRXZuiC241TGRvdFyctJnrNcdbZOP9zHio81tkngADMTMyAH0AAAAFZAAgAAAAAAeGrIMK/bac6kPczxbvRYqKMkcpeI2FjdMpD91FDWIvBXMAIAAAAAAix62z1LeS8yvSXCl5gHSIomjyx76fF3S1lp9k900hygVsACAAAAAAiYwzf2m71aWFD5ajcXyW2JX2EzQOkBroTGMg29nLPYIAAzEzMwB9AAAABWQAIAAAAACphf298InM0Us4HT8o1W1MGw0D/02vd7Jh+U0h7qaFaQVzACAAAAAAFXtk7YpqsOJxsqGWSIL+YcBE96G3Zz9D31gPqDW94y8FbAAgAAAAAAOrS1KVA94rjB1jZ1pPocpCeBG+B14RzWoHqVDpp7JbAAMxMzQAfQAAAAVkACAAAAAATLDS2cuDVM3yDMuWNgk2iGKBTzPpfJMbvxVOSY39ZfcFcwAgAAAAAPT5wRi2cLHIUflXzm6EQB/m7xdThP80ir1VV/JBBqvxBWwAIAAAAAB9lEtZS0aXCFbCtSbhnis27S5IPcfWGygHW8AHn3QqzwADMTM1AH0AAAAFZAAgAAAAAJNjExiZVX7jfFGfYpQu16qxLN0YPqVU/5CQ/Y67YSinBXMAIAAAAABMpm2+6KrkRUlXzQoMPHrQmIO6dkQz66tYdfTeA3dKqQVsACAAAAAAFXobHiMLvNZuEPr8jtewCX2J93EZG3JNeyVg92fue6YAAzEzNgB9AAAABWQAIAAAAABlFkYtLCx901X6QVVMkSn6Z7k30UF4xHaA0OZJJ9bdyQVzACAAAAAATez+F9GHcGzTp7jjv4feboUNb8JCkIp4EqcPFisnq7MFbAAgAAAAACE7JvOpBgMoZ7kRd4QbxIhxukPTUxXpzhjnBHiR7XoRAAMxMzcAfQAAAAVkACAAAAAA8NJKN0IxZnruhswGQkiruv8Ih0EMwDcSZx/Xasup9dkFcwAgAAAAAKaJZRxzA+Igeydvuk6cSwUHXcrmT4PjhuPu//FslpdnBWwAIAAAAAD53Rok1Vq/PMAnXmarqoHJ0PEyYUBmVESa9hIpCv/G9QADMTM4AH0AAAAFZAAgAAAAABHxHdEClz7hbSSgE58+dWLlSMJnoPz+jFxp4bB1GmLQBXMAIAAAAAD3nSvT6aGD+A110J/NwEfp0nPutlmuB5B+wA3CC3noGAVsACAAAAAA3Apjd+TapONB7k5wBVwTWgn8t+Sq2oyyU5/+as109RcAAzEzOQB9AAAABWQAIAAAAAC/o8qW/ifk3KuJ01VFkyNLgQafxB5/bGs2G5VyyVafOwVzACAAAAAA1bMqAFGDHSl6BYNLbxApvkAv2K1/oafywiX0MDz1dGUFbAAgAAAAAHJXLlId3edFoniLD/9K2A5973MeP2Ro31flDyqm3l5QAAMxNDAAfQAAAAVkACAAAAAAY2V8I1bz3a1AxTtmED6UhdhA09huFkuuEX8R+d/WDPUFcwAgAAAAAPTVoNRiI76tcRKqd+JBBVyy4+YcKST42p0QX2BtmQ2VBWwAIAAAAACcxt9hg14WqPNiDv1MkqVljM2e2KJEv53lA17LhV6ZigADMTQxAH0AAAAFZAAgAAAAAO2kSsW0WGN9AOtK4xK2SHrGhWiaAbMEKT4iZkRpaDN/BXMAIAAAAABKGzQcPM8LT2dwOggxoWjv/1imYWabbG/G4kBw8OWaxAVsACAAAAAAC9hLK1dScQTAqg+YAG3ObdPzg2Xet57HmOFpGmyUR9UAAzE0MgB9AAAABWQAIAAAAAAiCwzNEEaH/mDam68IdDftnhthyUFdb+ZCNSBQ91WlHQVzACAAAAAA7tHyHcxCzmbJeFYZyPm4mEgkTGKOvwY4MX82OvH0Jn8FbAAgAAAAAAb5IAbZ1hXCNegQ+S+C9i/Z8y6sS8KeU04V6hXa2ml6AAMxNDMAfQAAAAVkACAAAAAAGuCHVNJSuoVkpPOnS5s89GuA+BLi2IPBUr2Bg1sWEPIFcwAgAAAAAEl1gncS5/xO7bQ/KQSstRV3rOT2SW6nV92ZANeG2SR6BWwAIAAAAAA9LOcKmhek8F2wAh8yvT/vjp2gaouuO+Hmv10lwAeWPAADMTQ0AH0AAAAFZAAgAAAAAMfxz7gEaoCdPvXrubDhCZUS0ARLZc1svgbXgMDlVBPgBXMAIAAAAAB6a5dDA3fuT5Vz2KvAcbUEFX/+B7Nw2p1QqbPoQ5TTuAVsACAAAAAAcf/y75UOuI62A6vWH7bYr/5Jz+nirZVYK/81trN6XOQAAzE0NQB9AAAABWQAIAAAAACnYsqF/VzmjIImC9+dqrHO1TM6lJ6fRwM0mM6Wf6paOwVzACAAAAAA5tgZzch8uDCR1ky3SllVaKVpxAlbrhvlNDTazZZRZOAFbAAgAAAAALeGiLJS4z2zhgVpxzyPdRYyACP9QzQBOob34YrIZumCAAMxNDYAfQAAAAVkACAAAAAAEC0sIVmadtW4YMuRXH7RpAhXclsd+3bmqGXCMeaT014FcwAgAAAAABPpXh0uzpsJJB+IRUNajmMB9WGwswfpw5T9xk3Xj6ANBWwAIAAAAAAmf+NYh9TZ/QRu3w/GQz66n7DtfbJijN3G7KzeL8lstAADMTQ3AH0AAAAFZAAgAAAAABaIB3n49Xm9cOafSrQsE0WCcYp8rMIO/qVwIlMF5YLRBXMAIAAAAAC9EyWJV3xOu9bzgdJ/yX+ko7qLf1u3AxNMataW2C9EzQVsACAAAAAAvVbDkLxXx2DcMLifIQ3K0IIJcLcAG9DUrNfI6aoUjNcAAzE0OAB9AAAABWQAIAAAAAA5rZItA/cocRnngYqcJ3nBXQ+l688aKz3EQyLbYYunPAVzACAAAAAAwKyA+L7TgxztPClLrIMk2JXR+w7c04N3ZOqPgjvrIvsFbAAgAAAAACzvZ33h6aWEe8hmo+1f6OXJ72FY5hvWaUuha64ZV3KFAAMxNDkAfQAAAAVkACAAAAAA3htn7oHJ0YYpIrs+Mzyh85Ys67HwAdv5LQl1mCdoMWkFcwAgAAAAAEHjCtNNLenHuSIYux6ezAHsXDaj2DlTF67ToDhDDe6HBWwAIAAAAAD+P4H0sk9jOd+7vOANt2/1Ectb+4ZRGPE8GkHWNXW3MgADMTUwAH0AAAAFZAAgAAAAAEnt18Km/nqggfIJWxzTr9r3hnXNaueG6XO9A5G11LnGBXMAIAAAAAD7QxzGMN/ard5TfFLecE6uusMmXG2+RBsBR+/NCQHUwAVsACAAAAAAQEZ1ZZ8GC8rdbg7s87OM5Gr9qkTXS9+P5DuAZxj5Gl4AAzE1MQB9AAAABWQAIAAAAAAVAKK/GoY8AACu/hyMpO4hdLq6JnEyWNzkyci9sbaD/wVzACAAAAAA2HmeqpMlvvBpV2zQTYIRmsc4MFlfHRwLof0ycJgMg/MFbAAgAAAAACdltCeWi5E/q1Li1eXLChpM2D9QQSGLBZ82NklQSc0oAAMxNTIAfQAAAAVkACAAAAAAhHyq1GQC/GiMwpYjcsfkNxolJ10ARKjIjfkW1Wipzi0FcwAgAAAAAD/uaGWxTDq87F8XZ6CrFI+RNa8yMqfSZdqK00Kj833BBWwAIAAAAAD6aEdOO0CsQGagioOCvANPCEHSpJ8BSixlPBq5ERhB7AADMTUzAH0AAAAFZAAgAAAAABAJJxHoZD+MQBWqm9UM9Dd3z5ZohIZGWRaRVRsMptKQBXMAIAAAAADrE/ca+gqj/SH4oao4wE4qn2ovoTydzcMbDbrfnUs3zAVsACAAAAAAeNCIQN6hVnGJinytQRFGlQ2ocoprXNqpia+BSxzl+uwAAzE1NAB9AAAABWQAIAAAAAAv01wz7VG9mTepjXQi6Zma+7b/OVBaKVkWNbgDLr1mFgVzACAAAAAA0I5sxz8r6wkCp5Tgvr+iL4p6MxSOq5d3e1kZG+0b7NkFbAAgAAAAAIA32v6oGkAOS96HexGouNTex+tLahtx9QF2dgGClk6WAAMxNTUAfQAAAAVkACAAAAAAWXecRwxSon68xaa9THXnRDw5ZfzARKnvvjTjtbae6T0FcwAgAAAAAPh0UfUMEo7eILCMv2tiJQe1bF9qtXq7GJtC6H5Va4fIBWwAIAAAAADqFr1ThRrTXNgIOrJWScO9mk86Ufi95IDu5gi4vP+HWQADMTU2AH0AAAAFZAAgAAAAAEY5WL8/LpX36iAB1wlQrMO/xHVjoO9BePVzbUlBYo+bBXMAIAAAAABoKcpadDXUARedDvTmzUzWPe1jTuvD0z9oIcZmKuiSXwVsACAAAAAAJuJbwuaMrAFoI+jU/IYr+k4RzAqITrOjAd3HWCpJHqEAAzE1NwB9AAAABWQAIAAAAADnJnWqsfx0xqNnqfFGCxIplVu8mXjaHTViJT9+y2RuTgVzACAAAAAAWAaSCwIXDwdYxWf2NZTly/iKVfG/KDjHUcA1BokN5sMFbAAgAAAAAJVxavipE0H4/JQvhagdytXBZ8qGooeXpkbPQ1RfYMVHAAMxNTgAfQAAAAVkACAAAAAAsPG7LaIpJvcwqcbtfFUpIjj+vpNj70Zjaw3eV9T+QYsFcwAgAAAAAJQ71zi0NlCyY8ZQs3IasJ4gB1PmWx57HpnlCf3+hmhqBWwAIAAAAACD58TO6d+71GaOoS+r73rAxliAO9GMs4Uc8JbOTmC0OwADMTU5AH0AAAAFZAAgAAAAAAGiSqKaQDakMi1W87rFAhkogfRAevnwQ41onWNUJKtuBXMAIAAAAAASgiDpXfGh7E47KkOD8MAcX8+BnDShlnU5JAGdnPdqOAVsACAAAAAAI+2TTQIgbFq4Yr3lkzGwhG/tqChP7hRAx2W0fNaH6jcAAzE2MAB9AAAABWQAIAAAAAB7L4EnhjKA5xJD3ORhH2wOA1BvpnQ+7IjRYi+jjVEaJAVzACAAAAAAuhBIm0nL3FJnVJId+7CKDASEo+l2E89Z9/5aWSITK4AFbAAgAAAAALtSICOzQDfV9d+gZuYxpEj6cCeHnKTT+2G3ceP2H65kAAMxNjEAfQAAAAVkACAAAAAAaROn1NaDZFOGEWw724dsXBAm6bgmL5i0cki6QZQNrOoFcwAgAAAAANVT8R6UvhrAlyqYlxtmnvkR4uYK/hlvyQmBu/LP6/3ZBWwAIAAAAAD+aHNMP/X+jcRHyUtrCNkk1KfMtoD3GTmShS8pWGLt+AADMTYyAH0AAAAFZAAgAAAAADqSR5e0/Th59LrauDA7OnGD1Xr3H3NokfVxzDWOFaN7BXMAIAAAAACt30faNwTWRbvmykDpiDYUOCwA6QDbBBYBFWS7rdOB4AVsACAAAAAAF7SvnjjRk5v2flFOKaBAEDvjXaL1cpjsQLtK2fv9zdQAAzE2MwB9AAAABWQAIAAAAADmtb1ZgpZjSeodPG/hIVlsnS8hoRRwRbrTVx89VwL62AVzACAAAAAAi38e1g6sEyVfSDkzZbaZXGxKI/zKNbMasOl2LYoWrq8FbAAgAAAAAALACk0KcCDN/Kv8WuazY8ORtUGkOZ5Dsm0ys1oOppp/AAMxNjQAfQAAAAVkACAAAAAAf/f7AWVgBxoKjr7YsEQ4w/fqSvuQWV2HMiA3rQ7ur0sFcwAgAAAAADkkeJozP6FFhUdRIN74H4UhIHue+eVbOs1NvbdWYFQrBWwAIAAAAAB55FlHAkmTzAYj/TWrGkRJw2EhrVWUnZXDoMYjyfB/ZwADMTY1AH0AAAAFZAAgAAAAAI2WEOymtuFpdKi4ctanPLnlQud+yMKKb8p/nfKmIy56BXMAIAAAAADVKrJmhjr1rfF3p+T+tl7UFd1B7+BfJRk0e7a4im7ozgVsACAAAAAA5E7Ti3PnFiBQoCcb/DN7V1uM3Xd6VKiexPKntssFL7kAAzE2NgB9AAAABWQAIAAAAAAuHU9Qd79hjyvKOujGanSGDIQlxzsql8JytTZhEnPw+AVzACAAAAAAjF2gV/4+sOHVgDd/oR5wDi9zL7NGpGD+NsEpGXy/a4QFbAAgAAAAAJzMoyojYV6Ed/LpVN5zge93Odv3U7JgP7wxeRaJZGTdAAMxNjcAfQAAAAVkACAAAAAA7dQDkt3iyWYCT94d7yqUtPPwp4qkC0ddu+HFdHgVKEkFcwAgAAAAANuYvtvZBTEq4Rm9+5eb7VuFopowkrAuv86PGP8Q8/QvBWwAIAAAAACeqXoAOQOE4j0zRMlkVd8plaW0RX1npsFvB38Xmzv7sAADMTY4AH0AAAAFZAAgAAAAAAwnZSDhL4tNGYxlHPhKYB8s28dY5ScSwiKZm3UhT8U3BXMAIAAAAABDoY6dhivufTURQExyC9Gx3ocpl09bgbbQLChj3qVGbgVsACAAAAAAF+1nS7O0v85s3CCy+9HkdeoEfm2C6ZiNbPMMnSfsMHUAAzE2OQB9AAAABWQAIAAAAAC2VuRdaC4ZJmLdNOvD6R2tnvkyARteqXouJmI46V306QVzACAAAAAAMn1Z6B35wFTX9mEYAPM+IiJ5hauEwfD0CyIvBrxHg7IFbAAgAAAAAOG6DvDZkT9B/xZWmjao2AevN7MMbs3Oh9YJeSd/hZ+hAAMxNzAAfQAAAAVkACAAAAAAVerb7qVNy457rNOHOgDSKyWl5ojun7iWrv1uHPXrIZQFcwAgAAAAAIDcYS9j5z+gx0xdJj09L7876r/vjvKTi/d3bXDE3PhyBWwAIAAAAADuhVLqb1Bkrx8aNymS+bx2cL8GvLFNH4SAi690DUgnWQADMTcxAH0AAAAFZAAgAAAAAH/E44yLxKCJjuSmU9A8SEhbmkDOx1PqqtYcZtgOzJdrBXMAIAAAAABgLh9v2HjBbogrRoQ82LS6KjZQnzjxyJH4PH+F3jupSAVsACAAAAAAIlO46ehXp4TqpDV0t6op++KO+uWBFh8iFORZjmx2IjkAAzE3MgB9AAAABWQAIAAAAAAlNUdDL+f/SSQ5074mrq0JNh7CTXwTbbhsQyDwWeDVMwVzACAAAAAANIH2IlSNG0kUw4qz0budjcWn8mNR9cJlYUqPYdonucAFbAAgAAAAAJMrOUOyiu5Y3sV76zwEFct8L7+i8WGlQI2+8z2W2kzaAAMxNzMAfQAAAAVkACAAAAAASZ+CvUDtlk/R4HAQ3a+PHrKeY/8ifAfh0oXYFqliu80FcwAgAAAAAJelpzPgM65OZFt/mvGGpwibclQ49wH+1gbUGzd9OindBWwAIAAAAAD9qeDchteEpVXWcycmD9kl9449C1dOw0r60TBm5jK+cQADMTc0AH0AAAAFZAAgAAAAAN9fkoUVbvFV2vMNMAkak4gYfEnzwKI3eDM3pnDK5q3lBXMAIAAAAACnDkgVNVNUlbQ9RhR6Aot2nVy+U4km6+GHPkLr631jEAVsACAAAAAANzg/BnkvkmvOr8nS4omF+q9EG/4oisB+ul4YHi938hwAAzE3NQB9AAAABWQAIAAAAAASyK3b1nmNCMptVEGOjwoxYLLS9fYWm/Zxilqea0jpEQVzACAAAAAADDHsGrbqlKGEpxlvfyqOJKQJjwJrzsrB7k3HG0AUJbkFbAAgAAAAAKwx3S4XfDZh4+LuI9jf7XgUh5qiefNv87JD4qvVRfPSAAMxNzYAfQAAAAVkACAAAAAAlSP9iK31GlcG9MKGbLmq+VXMslURr+As736rrVNXcsUFcwAgAAAAAAvbj0zfq9zzi8XReheKFbCB+h9IsOLgXPPpI5vrEJNZBWwAIAAAAABXvoZhaQE7ogWjeBjceVkp03N20cKYP3TA8vuNsgpfAgADMTc3AH0AAAAFZAAgAAAAAOJNORH8Bev97gVU7y6bznOxJ+E6Qoykur1QP76hG1/7BXMAIAAAAAC+C1PtOOrSZgzBAGhr+dPe/kR0JUw9GTwLVNr61xC1aAVsACAAAAAAeA/L8MQIXkamaObtMPLpoDoi5FypA5WAPtMeMrgi0eQAAzE3OAB9AAAABWQAIAAAAAAKcHzLUomavInN6upPkyWhAqYQACP/vdVCIYpiy6U6HgVzACAAAAAATsR4KItY6R2+U7Gg6sJdaEcf58gjd1OulyWovIqfxKcFbAAgAAAAAFbm10ko67ahboAejQdAV0U2uA5OhZYdb8XUFJ8OL46LAAMxNzkAfQAAAAVkACAAAAAAqTOLiMpCdR59tLZzzIPqJvbCNvz2XQL9ust0qYaehtcFcwAgAAAAAArefox/3k5xGOeiw2m6NUdzuGxmPwcu5IFcj+jMwHgHBWwAIAAAAADLZGFJ7MQd5JXMgMXjqZO5LDLxcFClcXPlnRMWRn+1oAADMTgwAH0AAAAFZAAgAAAAAIPSqSeVzSRgNVNmrPYHmUMgykCY27NbdDUNhE5kx/SgBXMAIAAAAAAhX90nNfxyXmZe/+btZ7q6xMX4PFyj0paM1ccJ/5IUUQVsACAAAAAA419oHmD2W0SYoOMwhrhrp8jf68fg9hTkaRdCuVd3CN0AAzE4MQB9AAAABWQAIAAAAACLn5DxiqAosHGXIAY96FwFKjeqrzXWf3VJIQMwx1fl4gVzACAAAAAAindvU27nveutopdvuHmzdENBbeGFtI3Qcsr07jxmvm8FbAAgAAAAAPvl9pBStQvP4OGkN5v0MghUY6djm9n7XdKKfrW0l1sMAAMxODIAfQAAAAVkACAAAAAA7i2S6rHRSPBwZEn59yxaS7HiYBOmObIkeyCcFU42kf8FcwAgAAAAAGb3RSEyBmgarkTvyLWtOLJcPwCKbCRkESG4RZjVmY4iBWwAIAAAAADB2/wo5CSHR4ANtifY6ZRXNTO5+O8qP82DfAiAeanpZwADMTgzAH0AAAAFZAAgAAAAAFz+M+H/Z94mdPW5oP51B4HWptp1rxcMWAjnlHvWJDWrBXMAIAAAAACBFEOQyL7ZHu4Cq33QvXkmKuH5ibG/Md3RaED9CtG5HwVsACAAAAAAfggtJTprQ/yZzj7y5z9KvXsdeXMWP0yUXMMJqpOwI88AAzE4NAB9AAAABWQAIAAAAAAE7c2x3Z3aM1XGfLNk/XQ9jCazNRbGhVm7H8c2NjS5ywVzACAAAAAARJ9h8fdcwA19velF3L/Wcvi2rCzewlKZ2nA0p8bT9uwFbAAgAAAAAJtWe6b4wK2Hae2dZm/OEpYQnvoZjz4Sz5IgJC2wInecAAMxODUAfQAAAAVkACAAAAAAVoRt9B9dNVvIMGN+ea5TzRzQC+lqSZ8dd/170zU5o9cFcwAgAAAAAEwM95XZin5mv2yhCI8+ugtKuvRVmNgzzIQN0yi1+9aIBWwAIAAAAAAMGBq72n00rox3uqhxSB98mkenTGCdbbUF1gXrgottzgADMTg2AH0AAAAFZAAgAAAAAKRDkjyWv/etlYT4GyoXrmBED2FgZHnhc+l9Wsl06cH2BXMAIAAAAABohlpm3K850Vndf3NmNE0hHqDlNbSR8/IvMidQ3LnIZAVsACAAAAAAW42nGHa6q2MCAaaPVwaIDfr8QLyQwjKq23onZJYsqVsAAzE4NwB9AAAABWQAIAAAAAC3DFh5oklLCNLY90bgWm68dFXz65JpAZSp1K99MBTPAQVzACAAAAAAQgZecmxEUZVHoptEQClDwAf8smI3WynQ/i+JBP0g+kQFbAAgAAAAAEUSQGVnAPISD6voD0DiBUqyWKgt2rta0tjmoe+LNt6IAAMxODgAfQAAAAVkACAAAAAAQ5WKvWSB503qeNlOI2Tpjd5blheNr6OBO8pfJfPNstcFcwAgAAAAAKwHgQLSDJ5NwLBQbY5OnblQIsVDpGV7q3RCbFLD1U4/BWwAIAAAAACQ5nED99LnpbqXZuUOUjnO2HTphEAFBjLD4OZeDEYybgADMTg5AH0AAAAFZAAgAAAAAGfhFY3RGRm5ZgWRQef1tXxHBq5Y6fXaLAR4yJhrTBplBXMAIAAAAACKEF0ApLoB6lP2UqTFsTQYNc9OdDrs/vziPGzttGVLKQVsACAAAAAArOO6FyfNRyBi0sPT5iye7M8d16MTLcwRfodZq4uCYKEAAzE5MAB9AAAABWQAIAAAAAAIM73gPcgzgotYHLeMa2zAU4mFsr7CbILUZWfnuKSwagVzACAAAAAAJCSu98uV8xv88f2BIOWzt6p+6EjQStMBdkGPUkgN79cFbAAgAAAAAMGqPGMPxXbmYbVfSa/japvUljht1zZT33TY7ZjAiuPfAAMxOTEAfQAAAAVkACAAAAAAkWmHCUsiMy1pwZTHxVPBzPTrWFBUDqHNrVqcyyt7nO8FcwAgAAAAAMv2CebFRG/br7USELR98sIdgE9OQCRBGV5JZCO+uPMgBWwAIAAAAABt7qSmn3gxJu7aswsbUiwvO+G6lXj/Xhx+J/zQyZxzLAADMTkyAH0AAAAFZAAgAAAAAGInUYv0lP/rK7McM8taEHXRefk8Q2AunrvWqdfSV7UaBXMAIAAAAACE+WPxJ3gan7iRTbIxXXx+bKVcaf8kP4JD8DcwU0aL7wVsACAAAAAAUC4eTprX4DUZn2X+UXYU6QjtiXk+u57yoOPBbPQUmDkAAzE5MwB9AAAABWQAIAAAAACmHlg2ud3cplXlTsNTpvNnY6Qm1Fce0m899COamoDjaQVzACAAAAAArtJQeJIlepBWRU2aYar7+YGYVQ7dfDc1oxgTmA8r9q0FbAAgAAAAAOk45vg5VqZHAFCO3i0Z52SZi5RADf8NXwf68T5yad/DAAMxOTQAfQAAAAVkACAAAAAApzcWSAbZWV/Rq+ylRNqqlJqNVR4fhXrz4633/MQOQgcFcwAgAAAAAN/jz/bsEleiuCl+li83EWlG6UMHA8CyaOMRKCkXkSCPBWwAIAAAAAC3Sd+Qg+uFDKpGZHbrQgokXHQ1az1aFl4YK343OB6hcQAAEmNtAAAAAAAAAAAAABBwYXlsb2FkSWQAAAAAABBmaXJzdE9wZXJhdG9yAAEAAAAA", - "subType": "06" - } - } - } - }, - "u": { - "$set": { - "encryptedDecimalNoPrecision": { - "$$type": "binData" - } - } - } - } - ], - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalNoPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - }, - "$db": "default" - } - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": { - "$numberInt": "0" - }, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rbf3AeBEv4wWFAKknqDxRW5cLNkFvbIs6iJjc6LShQY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "n+XAuFnP8Dov9TnhGFxNx0K/MnVM9WbJ7RouEu0ndO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yRXojuVdn5GQtD97qYlaCL6cOLmZ7Cvcb3wFjkLUIdM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DuIkdRPITRs55I4SZmgomAHCIsDQmXRhW8+MOznkzSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SsBk+Et1lTbU+QRPx+xyJ/jMkmfG+QCvQEpip2YYrzA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "crCIzOd8KhHvvUlX7M1v9bhvU4pLdTc+X2SuqoKU5Ek=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YOWdCw4UrqnxkAaVjqmC4sKQDMVMHEpFGnlxpxdaU6E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M3SShp81Ff8tQ632qKbv9MUcN6wjDaBReI0VXNu6Xh4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gzHlSPxpM0hT75kQvWFzGlOxKvDoiKQZOr19V6l2zXI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s3JnppOGYw9SL2Q1kMAZs948v2F5PrpXjGei/HioDWs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cG6+3Gk/zEH68P/uuuwiAUVCuyJwa1LeV+t29FlPPAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dupdvR3AyJtM+g9NDKiaLVOtGca387JQp8w+V03m7Ig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JqEQc5svj2jTvZ6LLA5ivE+kTb/0aRemSEmxk4G7Zrg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "szcXXXKnob+p3SoM4yED2R920LeJ7cVsclPMFTe4CeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o1QoGVXmuBdHwHm7aCtGMlMVKrjFdYvJXpoq6uhIAZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Jfm5wPlqqLCJRGQIqRq2NGmpn7s0Vrih2H3YAOoI2YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zMHLb8ARbsYo8Ld05bqnGFf1Usha6EGb8QKwdSAyps0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yQdtq9lh5pugL7/i0Bj/PuZUUBUIzf+7wj1rl5y736w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wGWVZdO7qIuyDg/BqDgqjgoQ02h5YYgwXQB1oCin2NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "by9HMLj6NTEpgztZ5HSN6GxImkXPcaFINYDzgZY33X8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tWo0vbasi7bXmn/MsOx13VC1IsWtpx/nYp0uj4iMzdA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tQQpndUYd5O87lOtrGjH3wl9VsOK0ray7RMasL90sBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cQjXEDCMsOpKLLf+vlTgIHA+cbSJdzqhbSX9Wvh95aA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7yMpU48IxK9SzP2cx3VnTownGEwFmeFofuuFT97SuuY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kSOx1kz0CmBgzKQHZlo65ZUY1DIv9A99JRm+Us2y6Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubQpdPBe6/xvtr+AcXdfYLSvYCR4ot0tivehkCsupb4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xal+iCJ6FTefRQToyoNksc9NCZShyn04NDGi4IYrcoM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d7jU4iOK50xHxlkSifcxlZFCM46TSgQzoYivxG3HNLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJvl2nsBLBVzL3pp6sKWCL4UXeh3q/roYBJjSb74ve0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OIUCaKRvIx9t1w6Hxlz1IcQTdPNCfdRNwnnTm10W+X0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A9tvzsiElotOUVIB4CqfQp9mAwqvTM35YkmAR170aHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lI8gpK7hpb7c9x4RQugsxMnQay5LZJmwslZdvMx/dcE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dNCzh40U0XvdKnSDi3HRQOWQftEsDVqc4uUvsVFGoq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IP+iwEBWBwVVZIdpaMu8k5+soFCz+TZkYn3drKZ9grE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnqyh6e0y5svHkJDShlN9CHV0WvMBE4QbtJpQw5ZCXc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "elEl42tbVDoRTLjAhZUFEtXiut4b3PVhg/1ZLZSQdtE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vHuu2FxwclMHqyE6JBYbTYgbEkB0dqb/JuaxsvfwsmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xTf7NCe3Gf8QpE78HR5OknlLTKfs9J+RN9UZpH6fnso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XiWSasRnJAulGR6+LCVD3mwRObXylqYWR9jvpywq12c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MZMxEQ5ikx0PG1YFIExv0UnTZogsvgeOEZTpzvBDn4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yZMyMZBDrWbAhvnic7vvIYhmO9m5H2iuv0c8KNZrBzY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xxM14hTPY5j0vvcK2C7YAEjzdsfUTFHozHC0hEo1bxI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+01rqR1xVwkpGXcstbk1ItJqFVjH6Q8MGxEN3Cm9Y1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xOpLV0Z2VTRJ3iWtnWZcsyjXubTIkYWo31cO+HV1o1k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BWUOLqgLBqc5NwxVlSV5H3KFQPXbCp7mdo+jF+8cJqY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fuQb1S6xZDGlrEbK+kI23aL53PP1PVNwqICnZNt9Yzg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfscnoibFttahLdPVC4Ee+47ewGFKpDSU7M6HX19bKE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rpSW2awybNVeKtat91VFxqbINoTfNhPfQAu+d73Xtf8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9M/CP9ccOIIj2LLFmE0GFDO0Ban2wsNalEXfM6+h+1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WrEMG49l1ye4MhXs5ZS9tz8P6h+hDvthIg/2wW9ne1Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ImNhbfeyfH8qIEeA5ic0s3dAQBdzzTBS+CPsNih9vZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dWP33YDSn04UKJN2ogh2Rui0iW/0q2y18OCDRVcfyoo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lYv0isAtfGh6H9tdp3cp2eHU7q2J+uk7QrgcxtK3w7Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VGMoamB/+7zTOYcY/pqJc96xlv2PdW4hwsIAEIslTDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yNeBWMF7BnD9wVwz2PgJsvWr77QiVvvWUvJF0+fqBug=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfpvObJ+tJBXSvqeN7vlOfmhYign635lciYAJIjUtY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dsen4NqjzVGjpjufiTMs3+gqeD09EbnuogPgxrJECwg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pxCWVM3sn19NsFEpgHbgLa+PmYlhN3mMiP0Wk8kJhYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q11KNvJszjYIB9n9HcC+N4uz11a3eRj1L3BH9scKMDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A1PmkgcEToWh1JiVWE6mI5jUu7poxWWuCUt/cgRUUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qJo3Hu4PJeanL7XEaWXO/n3YsodhZyd+MJOOmB9Kpd8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BkBKLO8URFscfRY9Bav/1+L9mLohDgNr/MkZtGiraIs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rZq5WA3Hx3xthOyHAJXK//f8pE2qbz7YKu3TIMp9GFY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X07a/Lm80p5xd4RFs1dNmw+90tmPDPdGiAKVZkxd4zY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6YrBn2ofIw1b5ooakrLOwF41BWrps8OO0H9WH4/rtlE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0l86Ag5OszXpa78SlOUV3K9nff5iC1p0mRXtLg9M1s4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Hn6yuxFHodeyu7ISlhYrbSf9pTiH4TDEvbYLWjTwFO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zdf4y2etKBuIpkEU1zMwoCkCsdisfXZCh8QPamm+drY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rOQ9oMdiK5xxGH+jPzOvwVqdGGnF3+HkJXxn81s6hp4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "61aKKsE3+BJHHWYvs3xSIBvlRmKswmaOo5rygQJguUg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KuDb/GIzqDM8wv7m7m8AECiWJbae5EKKtJRugZx7kR0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Q+t8t2TmNUiCIorVr9F3AlVnX+Mpt2ZYvN+s8UGict8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJRZIpKxUgHyL83kW8cvfjkxN3z6WoNnUg+SQw+LK+k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnUsYjip8SvW0+m9mR5WWTkpK+p6uwJ6yBUAlBnFKMk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PArHlz+yPRYDycAP/PgnI/AkP8Wgmfg++Vf4UG1Bf0E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wnIh53Q3jeK8jEBe1n8kJLa89/H0BxO26ZU8SRIAs9Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4F8U59gzBLGhq58PEWQk2nch+R0Va7eTUoxMneReUIA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ihKagIW3uT1dm22ROr/g5QaCpxZVj2+Fs/YSdM2Noco=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EJtUOOwjkrPUi9mavYAi+Gom9Y2DuFll7aDwo4mq0M0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dIkr8dbaVRQFskAVT6B286BbcBBt1pZPEOcTZqk4ZcI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aYVAcZYkH/Tieoa1XOjE/zCy5AJcVTHjS0NG2QB7muA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sBidL6y8TenseetpioIAAtn0lK/7C8MoW4JXpVYi3z8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0Dd2klU/t4R86c2WJcJDAd57k/N7OjvYSO5Vf8KH8sw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I3jZ92WEVmZmgaIkLbuWhBxl7EM6bEjiEttgBJunArA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aGHoQMlgJoGvArjfIbc3nnkoc8SWBxcrN7hSmjMRzos=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bpiWPnF/KVBQr5F6MEwc5ZZayzIRvQOLDAm4ntwOi8g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tI7QVKbE6avWgDD9h4QKyFlnTxFCwd2iLySKakxNR/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XGsge0CnoaXgE3rcpKm8AEeku5QVfokS3kcI+JKV1lk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JQxlryW2Q5WOwfrjAnaZxDvC83Dg6sjRVP5zegf2WiM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YFuHKJOfoqp1iGVxoFjx7bLYgVdsN4GuUFxEgO9HJ5s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Z6vUdiCR18ylKomf08uxcQHeRtmyav7/Ecvzz4av3k4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SPGo1Ib5AiP/tSllL7Z5PAypvnKdwJLzt8imfIMSEJQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "m94Nh6PFFQFLIib9Cu5LAKavhXnagSHG6F5EF8lD96I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pfEkQI98mB+gm1+JbmVurPAODMFPJ4E8DnqfVyUWbSo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DNj3OVRLbr43s0vd+rgWghOL3FqeO/60npdojC8Ry/M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kAYIQrjHVu49W8FTxyxJeiLVRWWjC9fPcBn+Hx1F+Ss=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "aCSO7UVOpoQvu/iridarxkxV1SVxU1i9HVSYXUAeXk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Gh6hTP/yj1IKlXQ+Q69KTfMlGZjEcXoRLGbQHNFo/1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/gDgIFQ4tAlJk3GN48IS5Qa5IPmErwGk8CHxAbp6gs0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PICyimwPjxpusyKxNssOOwUotAUbygpyEtORsVGXT8g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4lu+cBHyAUvuxC6JUNyHLzHsCogGSWFFnUCkDwfQdgI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pSndkmoNUJwXjgkbkgOrT5f9nSvuoMEZOkwAN9ElRaE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tyW+D4i26QihNM5MuBM+wnt5AdWGSJaJ4X5ydc9iWTU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9Syjr8RoxUgPKr+O5rsCu07AvcebA4P8IVKyS1NVLWc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "67tPfDYnK2tmrioI51fOBG0ygajcV0pLo5+Zm/rEW7U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "y0EiPRxYTuS1eVTIaPQUQBBxwkyxNckbePvKgChwd0M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NWd+2veAaeXQgR3vCvzlI4R1WW67D5YsVLdoXfdb8qg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PY5RQqKQsL2GqBBSPNOEVpojNFRX/NijCghIpxD6CZk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lcvwTyEjFlssCJtdjRpdN6oY+C7bxZY+WA+QAqzj9zg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWE7XRNylvTwO/9Fv56dNqUaQWMmESNS/GNIwgBaEI0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ijwlrUeS8nRYqK1F8kiCYF0mNDolEZS+/lJO1Lg93C8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8KzV+qYGYuIjoNj8eEpnTuHrMYuhzphl80rS6wrODuU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wDyTLjSEFF895hSQsHvmoEQVS6KIkZOtq1c9dVogm9I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SGrtPuMYCjUrfKF0Pq/thdaQzmGBMUvlwN3ORIu9tHU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KySHON3hIoUk4xWcwTqk6IL0kgjzjxgMBObVIkCGvk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hBIdS9j0XJPeT4ot73ngELkpUoSixvRBvdOL9z48jY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Tx6um0q9HjS5ZvlFhvukpI6ORnyrXMWVW1OoxvgqII0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zFKlyfX5H81+d4A4J3FKn4T5JfG+OWtR06ddyX4Mxas=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cGgCDuPV7MeMMYEDpgOupqyNP4BQ4H7rBnd2QygumgM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IPaUoy98v11EoglTpJ4kBlEawoZ8y7BPwzjLYBpkvHQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Pfo4Am6tOWAyZNn8G9W5HWWGC3ZWmX0igI/RRB870Ro=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fnTSjd7bC1Udoq6iM7UDnHAC/lsIXSHp/Gy332qw+/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fApBgVRrTDyEumkeWs5p3ag9KB48SbU4Si0dl7Ns9rc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QxudfBItgoCnUj5NXVnSmWH3HK76YtKkMmzn4lyyUYY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sSOvwhKa29Wq94bZ5jGIiJQGbG1uBrKSBfOYBz/oZeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FdaMgwwJ0NKsqmPZLC5oE+/0D74Dfpvig3LaI5yW5Fs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "sRWBy12IERN43BSZIrnBfC9+zFBUdvjTlkqIH81NGt4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/4tIRpxKhoOwnXAiFn1Z7Xmric4USOIfKvTYQXk3QTc=", - "subType": "00" - } - } - ] - }, - { - "_id": { - "$numberInt": "1" - }, - "encryptedDecimalNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Mr/laWHUijZT5VT3x2a7crb7wgd/UXOGz8jr8BVqBpM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wXVD/HSbBljko0jJcaxJ1nrzs2+pchLQqYR3vywS8SU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VDCpBYsJIxTfcI6Zgf7FTmKMxUffQv+Ys8zt5dlK76I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zYDslUwOUVNwTYkETfjceH/PU3bac9X3UuQyYJ19qK0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rAOmHSz18Jx107xpbv9fYcPOmh/KPAqge0PAtuhIRnc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BFOB1OGVUen7VsOuS0g8Ti7oDsTt2Yj/k/7ta8YAdGM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2fckE5SPs0GU+akDkUEM6mm0EtcV3WDE/sQsnTtodlk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "mi9+aNjuwIvaMpSHENvKzKRAmX9cYguo2mXLvOoftHQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "K6TWn4VcWWkz/gkUkLmbtwkG7SNeABICmLDnoYJFlLU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Z+2/cEtGU0Fq7QJFNGA/0y4aWAsw0ncG6X0LYRqwS3c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rrSIf+lgcNZFbbUkS9BmE045jRWBpcBJXHzfMVEFuzE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KlHL3Kyje1/LMIfgbCqw1SolxffJvvgsYBV5y77wxuA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hzJ1YBoETmYeCh352dBmG8d8Wse/bUcqojTWpWQlgsc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lSdcllDXx8MA+s0GULjDA1lQkcV0L8/aHtZ6dM2pZ2c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "HGr7JLTTA7ksAnlmjSIwwdBVvgr3fv46/FTdiCPYpos=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "mMr25v1VwOEVZ8xaNUTHJCcsYqV+kwK6RzGYilxPtJ4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "129hJbziPJzNo0IoTU3bECdge0FtaPW8dm4dyNVNwYU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "doiLJ96qoo+v7NqIAZLq6BI5axV8Id8gT5vyJ1ZZ0PM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cW/Lcul3xYmfyvI/0x/+ybN78aQmBK1XIGs1EEU09N8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1aVIwzu9N5EJV9yEES+/g6hOTH7cA2NTcLIc59cu0wU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kw5tyl7Ew0r1wFyrN1mB9FiVW2hK2BxxxUuJDNWjyjQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ADAY2YBrm6RJBDY/eLLcfNxmSJku+mefz74gH66oyco=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8gkqB1LojzPrstpFG7RHYmWxXpIlPDTqWnNsXH7XDRU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "TESfVQMDQjfTZmHmUeYUE2XrokJ6CcrsKx/GmypGjOw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qFM+HFVQ539S0Ouynd1fBHoemFxtU9PRxE5+Dq7Ljy4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jPiFgUZteSmOg4wf3bsEKCZzcnxmMoILsgp/GaZD+dM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YaWUgJhYgPNN7TkFK16H8SsQS226JguaVhOIQxZwQNQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x90/Qk3AgyaFsvWf2KUCu5XF3j76WFSjt/GrnG01060=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ZGWybWL/xlEdMYRFCZDUoz10sywTf7U/7wufsb78lH0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8l4ganN66jIcdxfHAdYLaym/mdzUUQ8TViw3MDRySPc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c8p5XEGTqxqvRGVlR+nkxw9uUdoqDqTB0jlYQ361qMA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1ZGFLlpQBcU3zIUg8MmgWwFKVz/SaA7eSYFrfe3Hb70=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "34529174M77rHr3Ftn9r8jU4a5ztYtyVhMn1wryZSkU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YkQ4pxFWzc49MS0vZM6S8mNo4wAwo21rePBeF3C+9mI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MhOf4mYY00KKVhptOcXf0bXB7WfuuM801MRJg4vXPgc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7pbbD8ihNIYIBJ3tAUPGzHpFPpIeCTAk5L88qCB0/9w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "C9Q5PoNJTQo6pmNzXEEXUEqH22//UUWY1gqILcIywec=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "AqGVk1QjDNDLYWGRBX/nv9QdGR2SEgXZEhF0EWBAiSE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/sGI3VCbJUKATULJmhTayPOeVW+5MjWSvVCqS77sRbU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yOtbL0ih7gsuoxVtRrACMz+4N5uo7jIR7zzmtih2Beo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uA6dkb2Iyg9Su8UNDvZzkPx33kPZtWr/CCuEY+XgzUM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1DoSFPdHIplqZk+DyWAmEPckWwXw/GdB25NLmzeEZhk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OfDVS0T3ZuIXI/LNbTp6C9UbPIWLKiMy6Wx+9tqNl+g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "3PZjHXbmG6GtPz+iapKtQ3yY4PoFFgjIy+fV2xQv1YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kaoLN0BoBWsmqE7kKkJQejATmLShd8qffcAmlhsxsGY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vpiw9KgQdegGmp7IJnSGX2miujRLU0xzs0ITTqbPW7c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NuXFf7xGUefYjIUTuMxNUTCfVHrF8oL0AT7dPv5Plk4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8Tz53LxtfEBJ9eR+d2690kwNsqPV6XyKo2PlqZCbUrc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "e6zsOmHSyV8tyQtSX6BSwui6wK9v1xG3giY/IILJQ2w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2fedFMCxa2DzmIpfbDKGXhQg0PPwbUv6vIWdwwlvhms=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yEJKMFnWXTC8tJUfzCInzQRByNEPjHxpw4L4m8No91Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YbFuWwOiFuQyOzIJXDbOkCWC2DyrG+248TBuVCa1pXU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "w7IkwGdrguwDrar5+w0Z3va5wXyZ4VXJkDMISyRjPGo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YmJUoILTRJPhyIyWyXJTsQ6KSZHHbEpwPVup6Ldm/Ko=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FvMjcwVZJmfh6FP/yBg2wgskK+KHD8YVUY6WtrE8xbg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "h4HCtD4HyYz0nci49IVAa10Z4NJD/FHnRMV4sRX6qro=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "nC7BpXCmym+a0Is2kReM9cYN2M1Eh5rVo8fjms14Oiw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1qtVWaeVo649ZZZtN8gXbwLgMWGLhz8beODbvru0I7Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Ej+mC0QFyMNIiSjR939S+iGBm7dm+1xObu5IcF/OpbU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UQ8LbUG3cMegbr9yKfKanAPQE1EfPkFciVDrNqZ5GHY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4iI3mXIDjnX+ralk1HhJY43mZx2uTJM7hsv9MQzTX7E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0WQCcs3rvsasgohERHHCaBM4Iy6yomS4qJ5To3/yYiw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qDCTVPoue1/DOAGNAlUstdA9Sid8MgEY4e5EzHcVHRk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9F9Mus0UnlzHb8E8ImxgXtz6SU98YXD0JqswOKw/Bzs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pctHpHKVBBcsahQ6TNh6/1V1ZrqOtKSAPtATV6BJqh0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vfR3C/4cPkVdxtNaqtF/v635ONbhTf5WbwJM6s4EXNE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ejP43xUBIex6szDcqExAFpx1IE/Ksi5ywJ84GKDFRrs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jbP4AWYd3S2f3ejmMG7dS5IbrFol48UUoT+ve3JLN6U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CiDifI7958sUjNqJUBQULeyF7x0Up3loPWvYKw9uAuw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "e2dQFsiHqd2BFHNhlSxocjd+cPs4wkcUW/CnCz4KNuM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PJFckVmzBipqaEqsuP2mkjhJE4qhw36NhfQ9DcOHyEU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "S3MeuJhET/B8VcfZYDR9fvX0nscDj416jdDekhmK11s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CGVHZRXpuNtQviDB2Kj03Q8uvs4w3RwTgV847R7GwPw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yUGgmgyLrxbEpDVy89XN3c2cmFpZXWWmuJ/35zVZ+Jw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "inb6Q97mL1a9onfNTT8v9wsoi/fz7KXKq3p8j90AU9c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CCyYx/4npq9xGO1lsCo8ZJhFO9/tN7DB+/DTE778rYg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "LNnYw4fwbiAZu0kBdAHPEm/OFnreS+oArdB5O/l/I98=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "P006SxmUS/RjiQJVYPdMFnNo3827GIEmSzagggkg05Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "oyvwY+WsnYV6UHuPki1o0ILJ2jN4uyXf9yaUNtZJyBA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "36Lk3RHWh1wmtCWC/Yj6jNIo17U5y6SofAgQjzjVxD8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vOOo8FqeHnuO9mqOYjIb4vgwIwVyXZ5Y+bY5d9tGFUM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bJiDJjwQRNxqxlGjRm5lLziFhcfTDCnQ/qU1V85qcRg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2Qgrm1n0wUELAQnpkEiIHB856yv76q8jLbpiucetcm0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "5ciPOYxTK0WDwwYyfs7yiVymwtYQXDELLxmM4JLl4/o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "31dC2WUSIOKQc4jwT6PikfeYTwi80mTlh7P31T5KNQU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YluTV2Mu53EGCKLcWfHZb0BM/IPW2xJdG3vYlDMEsM4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dh/8lGo2Ek6KukSwutH6Q35iy8TgV0FN0SJqe0ZVHN8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EVw6HpIs3BKen2qY2gz4y5dw1JpXilfh07msZfQqJpc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FYolLla9L8EZMROEdWetozroU40Dnmwwx2jIMrr7c1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "8M6k4QIutSIj6CM41vvkQtuFsaGrjoR9SZJVSLbfGKQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9LM0VoddDNHway442MqY+Z7vohB2UHau/cddshhzf40=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "66i8Ytco4Yq/FMl6pIRZazz3CZlu8fO2OI6Pne0pvHU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2a/HgX+MjZxjXtSvHgF1yEpHMJBkl8Caee8XrJtn0WM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "frhBM662c4ZVG7mWP8K/HhRjd01lydW/cPcHnDjifqc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6k1T7Q1t668PBqv6fwpVnT1HWh7Am5LtbKvwPJKcpGU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UlJ5Edfusp8S/Pyhw6KTglIejmbr1HO0zUeHn/qFETA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jsxsB+1ECB3assUdoC333do9tYH+LglHmVSJHy4N8Hg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2nzIQxGYF7j3bGsIesECEOqhObKs/9ywknPHeJ3yges=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xJYKtuWrX90JrJVoYtnwP7Ce59XQGFYoalxpNfBXEH0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NLI5lriBTleGCELcHBtNnmnvwSRkHHaLOX4cKboMgTw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hUOQV0RmE5aJdJww1AR9rirJG4zOYPo+6cCkgn/BGvQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "h4G2Of76AgxcUziBwCyH+ayMOpdBWzg4yFrTfehSC2c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VuamM75RzGfQpj2/Y1jSVuQLrhy6OAwlZxjuQLB/9Ss=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kn9+hLq7hvw02xr9vrplOCDXKBTuFhfbX7d5v/l85Pg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fAiGqKyLZpGngBYFbtYUYt8LUrJ49vYafiboifTDjxs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BxRILymgfVJCczqjUIWXcfrfSgrrYkxTM5VTg0HkZLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CrFY/PzfPU2zsFkGLu/dI6mEeizZzCR+uYgjZBAHro0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "AEbrIuwvXLTtYgMjOqnGQ8y8axUn5Ukrn7UZRSyfQVw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ouWeVH3PEFg+dKWlXc6BmqirJOaVWjJbMzZbCsce4dA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+hd6xFB+EG+kVP7WH4uMd1CLaWMnt5xJRaY/Guuga9Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zmpGalfAOL3gmcUMJYcLYIRT/2VDO/1Dw4KdYZoNcng=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2PbHAoM/46J2UIZ/vyksKzmVVfxA7YUyIxWeL/N/vBk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7fD9x+zk5MVFesb59Klqiwwmve7P5ON/5COURXj5smE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tlrNQ4jaq051iaWonuv1sSrYhKkL1LtNZuHsvATha3s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fBodm28iClNpvlRyVq0dOdXQ08S7/N3aDwid+PdWvRo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "O+/nnRqT3Zv7yMMGug8GhKHaWy6u7BfRGtZoj0sdN1c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "5AZZ/RTMY4Photnm/cpXZr/HnFRi3eljacMsipkJLHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "oFVyo/kgoMxBIk2VE52ySSimeyU+Gr0EfCwapXnTpKA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Z8v59DfcnviA0mzvnUk+URVO0UuqAWvtarEgJva/n1c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "P64GOntZ+zBJEHkigoh9FSxSO+rJTqR20z5aiGQ9an4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xMbSuDPfWuO/Dm7wuVl06GnzG9uzTlJJX9vFy7boGlY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kXPB19mRClxdH2UsHwlttS6lLU2uHvzuZgZz7kC45jU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NDVjVYXAw4k0w4tFzvs7QDq39aaU3HQor4I2XMKKnCk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uKw/+ErVfpTO1dGUfd3T/eWfZW3nUxXCdBGdjvHtZ88=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "av0uxEzWkizYWm0QUM/MN1hLibnxPvCWJKwjOV4yVQY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ERwUC47dvgOBzIsEESMIioLYbFOxOe8PtJTnmDkKuHM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2gseKlG5Le12fS/vj4eaED4lturF16kAgJ1TpW3HxEE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7Cvg0Y3j/5i2F1TeXxlMmU7xwif5dCmwkZAOrVC5K2Y=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Aggregate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Aggregate.json deleted file mode 100644 index 8cf143c09..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Aggregate.json +++ /dev/null @@ -1,585 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range DecimalPrecision. Aggregate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "default", - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$gt": { - "$binary": { - "base64": "DdIJAAADcGF5bG9hZACiCQAABGcAjgkAAAMwAH0AAAAFZAAgAAAAAHdJ2Vnb4MMzqVYVssjSdDy8XU4GVzMTfGifGETgQ2mYBXMAIAAAAAD7cFfKJGIXo6PjyeX2ria02CckW7dWFDoY/3FyBdm1NQVsACAAAAAAhEPSNv4M023A3hzNFuy83+hIKuZ2mKRY954N++aEOBUAAzEAfQAAAAVkACAAAAAAlmvfDrZoydUet4eCVMq7z6a58Ea+1HLJOWxN5lNcrWEFcwAgAAAAAEBo5AWZyC41b9ayjWNQSL4iYEAIwR/JG+ssN8bdoK9RBWwAIAAAAACEndE0SLxFSElOrNnqeX0EPmgDio3udZjVREy4JLS3sQADMgB9AAAABWQAIAAAAABbiLaoxAA6rinMJw1hC8ZUiq6UU1AQaPFn/py/Y06WuQVzACAAAAAAhtDasFkvYE7SCNu1je/hxdE9TJtAvvH3NtdEbKzNbCUFbAAgAAAAAIGepU1RSCF8sWODHEpKglsoqw3VBBH4a/URGxgGzbq2AAMzAH0AAAAFZAAgAAAAALORWwSr+tYNxcil2KIGSbNhTHvcPbdj+rLVQNx21S/KBXMAIAAAAAD6diZBkPEJ1cQy06LAxdbNK8Nlxbb44fH4Wk3Y3260nQVsACAAAAAA1eYAZBFHlDiaDAljWi8blGQ2nvvZa5AO5doeo0SFZsgAAzQAfQAAAAVkACAAAAAAG5XMK96PjClNlUvg82j4pMY1YxsznZfj4uNweD394FoFcwAgAAAAAKHgQLdGJHkrfFg9nB93Ac+3VgBw6aU44MTkKIQ91dZoBWwAIAAAAAAPxXmi+SDJ+40A0KdwfRczexlZQrHjIA+D3oUB0EY9tAADNQB9AAAABWQAIAAAAAA6M++b9I0YFemmWBAWAE3glu2Ah3Ta1FBxAQEIWS0toAVzACAAAAAANXYTqPf1Y6X3Ns6YQIX0C3FKCyWUo+Kk+fNcQvc0WSoFbAAgAAAAAA+uJUw1ICYgyeygSRe206VTWVtUnhdci3iHbyP5YtEVAAM2AH0AAAAFZAAgAAAAAKl8bV1riH/uyJ+X0HHd3+18k2cJl2dQFXCdoagutFcaBXMAIAAAAABm8F2Ew9f0VOABdcF+lP0Bi+zWvEUPniWgrxPq/Sx3uwVsACAAAAAAJfFErjZ6BPhsw5LjJLqNtKDLJ4zV0eIZppQpd9b0wZoAAzcAfQAAAAVkACAAAAAAsYZD8JEP6kYsPncFnNZwJxhu4YtUTKPNcjHtv67H+rYFcwAgAAAAAI4LqZcRkvbs/2F62Flu0pixNcor4WmBD0DHGaf039wLBWwAIAAAAAD4wUR3xd9lKltcqqo8LYvdMQWzCRobkV/ppKB/yn5dUgADOAB9AAAABWQAIAAAAAC0vdAi+dmoIXvZ5LqUqvyKV9/tHqSI2SWiSJO5pTnA2wVzACAAAAAAS2qvf9fvfVUH5WtsVxjxmskpGjYTQV34LwvQQw1y9wIFbAAgAAAAAE0+FKuK7HxbypvCeEJzMTcjOWE0ScYOlTBMUNlIv55hAAM5AH0AAAAFZAAgAAAAAH31lb/srBcrOXkzddCwAnclsR5/3QijEVgECs2JjOWBBXMAIAAAAABg7+prDT73YcCvLE5QbuIrqGcjLc5pQD2Miq0d29yrxgVsACAAAAAAetRiPwDSFWBzpWSWkOKWM6fKStRJ8SyObnpc79ux8p0AAzEwAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzExAH0AAAAFZAAgAAAAAFdthRhe2Q8CvxGIhjTJZv0Lk97GkHciTPxZ/mckLoNaBXMAIAAAAAAqOxsAr23LOVB0DIHbPf9UDJJRFXY2YoKbjhRqw5psbQVsACAAAAAA0G2GD8ZQjDBntjLpW4rqwKRS6HiUjL03g1N6chANozcAAzEyAH0AAAAFZAAgAAAAAMWymwwbvIeMqmnKWWifUqoCxOsdpnonM2qdLPyjqJO/BXMAIAAAAAB6IDmmpUhBD2zpRj8/y/kmOSXcjuIU14sNh6GKSsg2uwVsACAAAAAAWMFPNOk3EMSQDS9JGPSMIQP0oNGVugxXKKUrIPPlhHgAAzEzAH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzE0AH0AAAAFZAAgAAAAAJaRYmo8zqI2BEUzdSwp4tVRpPmVWsfydkYN3UHh6TMuBXMAIAAAAAAeD6mDnQeLlbC9i0sVgE8+RH6y+e94OJQ0tJ0PvblVSgVsACAAAAAAWp4jvretbDEsqEMzP/WLTnwOiJwCtfrCiB6m8k+yEMoAAzE1AH0AAAAFZAAgAAAAAAZZ538coNPwyRjhEwr5P8Xw32oWOJF+R+nfCGgy2qO3BXMAIAAAAACOPLnJlKwGNPDBReRKnHfteq0wFb3ezhrc7BVXs8RUHwVsACAAAAAA+lGesNk3+SyB/60rSvdQ2aN2vfJPR7llJVhufGTNhHkAAzE2AH0AAAAFZAAgAAAAAFH9l9GGA1I52atJV5jNUf1lx8jBjoEoVoME97v5GFJiBXMAIAAAAAC1qH3Kd78Dr9NGbw7y9D/XYBwv5h1LLO8la5OU7g8UkQVsACAAAAAArZ6atJCYrVfHB8dSNPOFf6nnDADBMJcIEj8ljPvxHp8AAzE3AH0AAAAFZAAgAAAAADtbVEI2tdkrowEMdkacD2w0Y3T3Ofi7PH6HmA6sP0c/BXMAIAAAAADuBSROnZHA+NgUPH8d0LnWFiDsM2bY8bzjC1+elSsIygVsACAAAAAAR0G2m+uANoWknkr/NerFcG+fECVxNIs0cqbY1t/U/0MAAzE4AH0AAAAFZAAgAAAAAAh3WpeMVlikPFYj9hLj+fmIqVt6omCSF75W3TPExyWpBXMAIAAAAAAsQkRmwqeVj2gGE03orb6PtrIzDt6dDU3hgSQi8E2wKgVsACAAAAAA3GHaRE2RAcaBRd8VzmYzWeBD2Gmy91eTK1k8YdWObZcAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - } - } - ], - "cursor": {}, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "aggregate" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": { - "$numberInt": "0" - }, - "encryptedDecimalPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dri0CXmL78L2DOgk9w0DwxHOMGMzih7m6l59vgy+WWo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b7d8mRzD1kI1tdc7uNL+YAUonJ6pODLsRLkArfEKSkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Xg8C1/A0KJaXOw4i+26Rv03/CydaaunOzXh0CIT+gn8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UoKUDw2wJYToUCcFaIs03YQSTksYR0MIOTJllwODqKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c/5cwAT0C5jber2xlJnWD3a5tVDy0nRtr5HG02hoFOY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wSUrRXavAGaajNeqC5mEUH1K67oYl5Wy9RNIzKjwLAM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vrp4wWDtHEgHWR99I70WVDzevg1Fk/Pw5U8gUDa0OU=", - "subType": "00" - } - } - ] - }, - { - "_id": { - "$numberInt": "1" - }, - "encryptedDecimalPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "mVZb+Ra0EYjQ4Zrh9X//E2T8MRj7NMqm5GUJXhRrBEI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FA74j21GUEJb1DJBOpR9nVnjaDZnd8yAQNuaW9Qi26g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kJv//KVkbrobIBf+QeWC5jxn20mx/P0R1N6aCSMgKM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB+Whi9IUUGxfLEe+lGuIzLX4LFbIhaIAm5lRk65QTc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ybO1QU3CgvhO8JgRXH+HxKszWcpl5aGDYYVa75fHa1g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X3Y3eSAbbMg//JgiHHiFpYOpV61t8kkDexI+CQyitH4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SlNHXyqVFGDPrX/2ppwog6l4pwj3PKda2TkZbqgfSfA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "McjV8xwTF3xI7863DYOBdyvIv6UpzThl6v9vBRk05bI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MgwakFvPyBlwqFTbhWUF79URJQWFoJTGotlEVSPPUsQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DyBERpMSD5lEM5Nhpcn4WGgxgn/mkUVJp+PYSLX5jsE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I43iazc0xj1WVbYB/V+uTL/tughN1bBlxh1iypBnNsA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wjOBa/ATMuOywFmuPgC0GF/oeLqu0Z7eK5udzkTPbis=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gRQVwiR+m+0Vg8ZDXqrQQcVnTyobwCXNaA4BCJVXtMc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WUZ6huwx0ZbLb0R00uiC9FOJzsUocUN8qE5+YRenkvQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7s79aKEuPgQcS/YPOOVcYNZvHIo7FFsWtFCrnDKXefA=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Correctness.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Correctness.json deleted file mode 100644 index a4b06998f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Correctness.json +++ /dev/null @@ -1,1648 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "Find with $gt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "0.0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gte": { - "$numberDecimal": "0.0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "1.0" - } - } - } - }, - "result": [] - } - ] - }, - { - "description": "Find with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$lt": { - "$numberDecimal": "1.0" - } - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - ] - } - ] - }, - { - "description": "Find with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$lte": { - "$numberDecimal": "1.0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $lt below min", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$lt": { - "$numberDecimal": "0.0" - } - } - } - }, - "result": { - "errorContains": "must be greater than the range minimum" - } - } - ] - }, - { - "description": "Find with $gt above max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "200.0" - } - } - } - }, - "result": { - "errorContains": "must be less than the range max" - } - } - ] - }, - { - "description": "Find with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "0.0" - }, - "$lt": { - "$numberDecimal": "2.0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - ] - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with full range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gte": { - "$numberDecimal": "0.0" - }, - "$lte": { - "$numberDecimal": "200.0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$in": [ - { - "$numberDecimal": "0.0" - } - ] - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - ] - } - ] - }, - { - "description": "Insert out of range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "-1" - } - } - }, - "result": { - "errorContains": "value must be greater than or equal to the minimum value" - } - } - ] - }, - { - "description": "Insert min and max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 200, - "encryptedDecimalPrecision": { - "$numberDecimal": "200.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": {}, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 200, - "encryptedDecimalPrecision": { - "$numberDecimal": "200.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$gte": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "1.0" - } - } - } - } - ] - }, - "result": [] - } - ] - }, - { - "description": "Aggregate with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$lt": { - "$numberDecimal": "1.0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$lte": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lt below min", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$lt": { - "$numberDecimal": "0.0" - } - } - } - } - ] - }, - "result": { - "errorContains": "must be greater than the range minimum" - } - } - ] - }, - { - "description": "Aggregate with $gt above max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "200.0" - } - } - } - } - ] - }, - "result": { - "errorContains": "must be less than the range max" - } - } - ] - }, - { - "description": "Aggregate with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "0.0" - }, - "$lt": { - "$numberDecimal": "2.0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - ] - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with full range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$gte": { - "$numberDecimal": "0.0" - }, - "$lte": { - "$numberDecimal": "200.0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - }, - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDecimalPrecision": { - "$in": [ - { - "$numberDecimal": "0.0" - } - ] - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0.0" - } - } - ] - } - ] - }, - { - "description": "Wrong type: Insert Int", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberInt": "0" - } - } - }, - "result": { - "errorContains": "cannot encrypt element" - } - } - ] - }, - { - "description": "Wrong type: Find Int", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gte": { - "$numberInt": "0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": { - "errorContains": "field type is not supported" - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Delete.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Delete.json deleted file mode 100644 index fad823483..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Delete.json +++ /dev/null @@ -1,471 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range DecimalPrecision. Delete.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1" - } - } - } - }, - { - "name": "deleteOne", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "0" - } - } - } - }, - "result": { - "deletedCount": 1 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "delete": "default", - "deletes": [ - { - "q": { - "encryptedDecimalPrecision": { - "$gt": { - "$binary": { - "base64": "DdIJAAADcGF5bG9hZACiCQAABGcAjgkAAAMwAH0AAAAFZAAgAAAAAHdJ2Vnb4MMzqVYVssjSdDy8XU4GVzMTfGifGETgQ2mYBXMAIAAAAAD7cFfKJGIXo6PjyeX2ria02CckW7dWFDoY/3FyBdm1NQVsACAAAAAAhEPSNv4M023A3hzNFuy83+hIKuZ2mKRY954N++aEOBUAAzEAfQAAAAVkACAAAAAAlmvfDrZoydUet4eCVMq7z6a58Ea+1HLJOWxN5lNcrWEFcwAgAAAAAEBo5AWZyC41b9ayjWNQSL4iYEAIwR/JG+ssN8bdoK9RBWwAIAAAAACEndE0SLxFSElOrNnqeX0EPmgDio3udZjVREy4JLS3sQADMgB9AAAABWQAIAAAAABbiLaoxAA6rinMJw1hC8ZUiq6UU1AQaPFn/py/Y06WuQVzACAAAAAAhtDasFkvYE7SCNu1je/hxdE9TJtAvvH3NtdEbKzNbCUFbAAgAAAAAIGepU1RSCF8sWODHEpKglsoqw3VBBH4a/URGxgGzbq2AAMzAH0AAAAFZAAgAAAAALORWwSr+tYNxcil2KIGSbNhTHvcPbdj+rLVQNx21S/KBXMAIAAAAAD6diZBkPEJ1cQy06LAxdbNK8Nlxbb44fH4Wk3Y3260nQVsACAAAAAA1eYAZBFHlDiaDAljWi8blGQ2nvvZa5AO5doeo0SFZsgAAzQAfQAAAAVkACAAAAAAG5XMK96PjClNlUvg82j4pMY1YxsznZfj4uNweD394FoFcwAgAAAAAKHgQLdGJHkrfFg9nB93Ac+3VgBw6aU44MTkKIQ91dZoBWwAIAAAAAAPxXmi+SDJ+40A0KdwfRczexlZQrHjIA+D3oUB0EY9tAADNQB9AAAABWQAIAAAAAA6M++b9I0YFemmWBAWAE3glu2Ah3Ta1FBxAQEIWS0toAVzACAAAAAANXYTqPf1Y6X3Ns6YQIX0C3FKCyWUo+Kk+fNcQvc0WSoFbAAgAAAAAA+uJUw1ICYgyeygSRe206VTWVtUnhdci3iHbyP5YtEVAAM2AH0AAAAFZAAgAAAAAKl8bV1riH/uyJ+X0HHd3+18k2cJl2dQFXCdoagutFcaBXMAIAAAAABm8F2Ew9f0VOABdcF+lP0Bi+zWvEUPniWgrxPq/Sx3uwVsACAAAAAAJfFErjZ6BPhsw5LjJLqNtKDLJ4zV0eIZppQpd9b0wZoAAzcAfQAAAAVkACAAAAAAsYZD8JEP6kYsPncFnNZwJxhu4YtUTKPNcjHtv67H+rYFcwAgAAAAAI4LqZcRkvbs/2F62Flu0pixNcor4WmBD0DHGaf039wLBWwAIAAAAAD4wUR3xd9lKltcqqo8LYvdMQWzCRobkV/ppKB/yn5dUgADOAB9AAAABWQAIAAAAAC0vdAi+dmoIXvZ5LqUqvyKV9/tHqSI2SWiSJO5pTnA2wVzACAAAAAAS2qvf9fvfVUH5WtsVxjxmskpGjYTQV34LwvQQw1y9wIFbAAgAAAAAE0+FKuK7HxbypvCeEJzMTcjOWE0ScYOlTBMUNlIv55hAAM5AH0AAAAFZAAgAAAAAH31lb/srBcrOXkzddCwAnclsR5/3QijEVgECs2JjOWBBXMAIAAAAABg7+prDT73YcCvLE5QbuIrqGcjLc5pQD2Miq0d29yrxgVsACAAAAAAetRiPwDSFWBzpWSWkOKWM6fKStRJ8SyObnpc79ux8p0AAzEwAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzExAH0AAAAFZAAgAAAAAFdthRhe2Q8CvxGIhjTJZv0Lk97GkHciTPxZ/mckLoNaBXMAIAAAAAAqOxsAr23LOVB0DIHbPf9UDJJRFXY2YoKbjhRqw5psbQVsACAAAAAA0G2GD8ZQjDBntjLpW4rqwKRS6HiUjL03g1N6chANozcAAzEyAH0AAAAFZAAgAAAAAMWymwwbvIeMqmnKWWifUqoCxOsdpnonM2qdLPyjqJO/BXMAIAAAAAB6IDmmpUhBD2zpRj8/y/kmOSXcjuIU14sNh6GKSsg2uwVsACAAAAAAWMFPNOk3EMSQDS9JGPSMIQP0oNGVugxXKKUrIPPlhHgAAzEzAH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzE0AH0AAAAFZAAgAAAAAJaRYmo8zqI2BEUzdSwp4tVRpPmVWsfydkYN3UHh6TMuBXMAIAAAAAAeD6mDnQeLlbC9i0sVgE8+RH6y+e94OJQ0tJ0PvblVSgVsACAAAAAAWp4jvretbDEsqEMzP/WLTnwOiJwCtfrCiB6m8k+yEMoAAzE1AH0AAAAFZAAgAAAAAAZZ538coNPwyRjhEwr5P8Xw32oWOJF+R+nfCGgy2qO3BXMAIAAAAACOPLnJlKwGNPDBReRKnHfteq0wFb3ezhrc7BVXs8RUHwVsACAAAAAA+lGesNk3+SyB/60rSvdQ2aN2vfJPR7llJVhufGTNhHkAAzE2AH0AAAAFZAAgAAAAAFH9l9GGA1I52atJV5jNUf1lx8jBjoEoVoME97v5GFJiBXMAIAAAAAC1qH3Kd78Dr9NGbw7y9D/XYBwv5h1LLO8la5OU7g8UkQVsACAAAAAArZ6atJCYrVfHB8dSNPOFf6nnDADBMJcIEj8ljPvxHp8AAzE3AH0AAAAFZAAgAAAAADtbVEI2tdkrowEMdkacD2w0Y3T3Ofi7PH6HmA6sP0c/BXMAIAAAAADuBSROnZHA+NgUPH8d0LnWFiDsM2bY8bzjC1+elSsIygVsACAAAAAAR0G2m+uANoWknkr/NerFcG+fECVxNIs0cqbY1t/U/0MAAzE4AH0AAAAFZAAgAAAAAAh3WpeMVlikPFYj9hLj+fmIqVt6omCSF75W3TPExyWpBXMAIAAAAAAsQkRmwqeVj2gGE03orb6PtrIzDt6dDU3hgSQi8E2wKgVsACAAAAAA3GHaRE2RAcaBRd8VzmYzWeBD2Gmy91eTK1k8YdWObZcAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "limit": 1 - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "delete" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": { - "$numberInt": "0" - }, - "encryptedDecimalPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dri0CXmL78L2DOgk9w0DwxHOMGMzih7m6l59vgy+WWo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b7d8mRzD1kI1tdc7uNL+YAUonJ6pODLsRLkArfEKSkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Xg8C1/A0KJaXOw4i+26Rv03/CydaaunOzXh0CIT+gn8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UoKUDw2wJYToUCcFaIs03YQSTksYR0MIOTJllwODqKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c/5cwAT0C5jber2xlJnWD3a5tVDy0nRtr5HG02hoFOY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wSUrRXavAGaajNeqC5mEUH1K67oYl5Wy9RNIzKjwLAM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vrp4wWDtHEgHWR99I70WVDzevg1Fk/Pw5U8gUDa0OU=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-FindOneAndUpdate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-FindOneAndUpdate.json deleted file mode 100644 index fb8f4f414..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-FindOneAndUpdate.json +++ /dev/null @@ -1,589 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range DecimalPrecision. FindOneAndUpdate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1" - } - } - } - }, - { - "name": "findOneAndUpdate", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "0" - } - } - }, - "update": { - "$set": { - "encryptedDecimalPrecision": { - "$numberDecimal": "2" - } - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1" - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "default", - "query": { - "encryptedDecimalPrecision": { - "$gt": { - "$binary": { - "base64": "DdIJAAADcGF5bG9hZACiCQAABGcAjgkAAAMwAH0AAAAFZAAgAAAAAHdJ2Vnb4MMzqVYVssjSdDy8XU4GVzMTfGifGETgQ2mYBXMAIAAAAAD7cFfKJGIXo6PjyeX2ria02CckW7dWFDoY/3FyBdm1NQVsACAAAAAAhEPSNv4M023A3hzNFuy83+hIKuZ2mKRY954N++aEOBUAAzEAfQAAAAVkACAAAAAAlmvfDrZoydUet4eCVMq7z6a58Ea+1HLJOWxN5lNcrWEFcwAgAAAAAEBo5AWZyC41b9ayjWNQSL4iYEAIwR/JG+ssN8bdoK9RBWwAIAAAAACEndE0SLxFSElOrNnqeX0EPmgDio3udZjVREy4JLS3sQADMgB9AAAABWQAIAAAAABbiLaoxAA6rinMJw1hC8ZUiq6UU1AQaPFn/py/Y06WuQVzACAAAAAAhtDasFkvYE7SCNu1je/hxdE9TJtAvvH3NtdEbKzNbCUFbAAgAAAAAIGepU1RSCF8sWODHEpKglsoqw3VBBH4a/URGxgGzbq2AAMzAH0AAAAFZAAgAAAAALORWwSr+tYNxcil2KIGSbNhTHvcPbdj+rLVQNx21S/KBXMAIAAAAAD6diZBkPEJ1cQy06LAxdbNK8Nlxbb44fH4Wk3Y3260nQVsACAAAAAA1eYAZBFHlDiaDAljWi8blGQ2nvvZa5AO5doeo0SFZsgAAzQAfQAAAAVkACAAAAAAG5XMK96PjClNlUvg82j4pMY1YxsznZfj4uNweD394FoFcwAgAAAAAKHgQLdGJHkrfFg9nB93Ac+3VgBw6aU44MTkKIQ91dZoBWwAIAAAAAAPxXmi+SDJ+40A0KdwfRczexlZQrHjIA+D3oUB0EY9tAADNQB9AAAABWQAIAAAAAA6M++b9I0YFemmWBAWAE3glu2Ah3Ta1FBxAQEIWS0toAVzACAAAAAANXYTqPf1Y6X3Ns6YQIX0C3FKCyWUo+Kk+fNcQvc0WSoFbAAgAAAAAA+uJUw1ICYgyeygSRe206VTWVtUnhdci3iHbyP5YtEVAAM2AH0AAAAFZAAgAAAAAKl8bV1riH/uyJ+X0HHd3+18k2cJl2dQFXCdoagutFcaBXMAIAAAAABm8F2Ew9f0VOABdcF+lP0Bi+zWvEUPniWgrxPq/Sx3uwVsACAAAAAAJfFErjZ6BPhsw5LjJLqNtKDLJ4zV0eIZppQpd9b0wZoAAzcAfQAAAAVkACAAAAAAsYZD8JEP6kYsPncFnNZwJxhu4YtUTKPNcjHtv67H+rYFcwAgAAAAAI4LqZcRkvbs/2F62Flu0pixNcor4WmBD0DHGaf039wLBWwAIAAAAAD4wUR3xd9lKltcqqo8LYvdMQWzCRobkV/ppKB/yn5dUgADOAB9AAAABWQAIAAAAAC0vdAi+dmoIXvZ5LqUqvyKV9/tHqSI2SWiSJO5pTnA2wVzACAAAAAAS2qvf9fvfVUH5WtsVxjxmskpGjYTQV34LwvQQw1y9wIFbAAgAAAAAE0+FKuK7HxbypvCeEJzMTcjOWE0ScYOlTBMUNlIv55hAAM5AH0AAAAFZAAgAAAAAH31lb/srBcrOXkzddCwAnclsR5/3QijEVgECs2JjOWBBXMAIAAAAABg7+prDT73YcCvLE5QbuIrqGcjLc5pQD2Miq0d29yrxgVsACAAAAAAetRiPwDSFWBzpWSWkOKWM6fKStRJ8SyObnpc79ux8p0AAzEwAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzExAH0AAAAFZAAgAAAAAFdthRhe2Q8CvxGIhjTJZv0Lk97GkHciTPxZ/mckLoNaBXMAIAAAAAAqOxsAr23LOVB0DIHbPf9UDJJRFXY2YoKbjhRqw5psbQVsACAAAAAA0G2GD8ZQjDBntjLpW4rqwKRS6HiUjL03g1N6chANozcAAzEyAH0AAAAFZAAgAAAAAMWymwwbvIeMqmnKWWifUqoCxOsdpnonM2qdLPyjqJO/BXMAIAAAAAB6IDmmpUhBD2zpRj8/y/kmOSXcjuIU14sNh6GKSsg2uwVsACAAAAAAWMFPNOk3EMSQDS9JGPSMIQP0oNGVugxXKKUrIPPlhHgAAzEzAH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzE0AH0AAAAFZAAgAAAAAJaRYmo8zqI2BEUzdSwp4tVRpPmVWsfydkYN3UHh6TMuBXMAIAAAAAAeD6mDnQeLlbC9i0sVgE8+RH6y+e94OJQ0tJ0PvblVSgVsACAAAAAAWp4jvretbDEsqEMzP/WLTnwOiJwCtfrCiB6m8k+yEMoAAzE1AH0AAAAFZAAgAAAAAAZZ538coNPwyRjhEwr5P8Xw32oWOJF+R+nfCGgy2qO3BXMAIAAAAACOPLnJlKwGNPDBReRKnHfteq0wFb3ezhrc7BVXs8RUHwVsACAAAAAA+lGesNk3+SyB/60rSvdQ2aN2vfJPR7llJVhufGTNhHkAAzE2AH0AAAAFZAAgAAAAAFH9l9GGA1I52atJV5jNUf1lx8jBjoEoVoME97v5GFJiBXMAIAAAAAC1qH3Kd78Dr9NGbw7y9D/XYBwv5h1LLO8la5OU7g8UkQVsACAAAAAArZ6atJCYrVfHB8dSNPOFf6nnDADBMJcIEj8ljPvxHp8AAzE3AH0AAAAFZAAgAAAAADtbVEI2tdkrowEMdkacD2w0Y3T3Ofi7PH6HmA6sP0c/BXMAIAAAAADuBSROnZHA+NgUPH8d0LnWFiDsM2bY8bzjC1+elSsIygVsACAAAAAAR0G2m+uANoWknkr/NerFcG+fECVxNIs0cqbY1t/U/0MAAzE4AH0AAAAFZAAgAAAAAAh3WpeMVlikPFYj9hLj+fmIqVt6omCSF75W3TPExyWpBXMAIAAAAAAsQkRmwqeVj2gGE03orb6PtrIzDt6dDU3hgSQi8E2wKgVsACAAAAAA3GHaRE2RAcaBRd8VzmYzWeBD2Gmy91eTK1k8YdWObZcAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "update": { - "$set": { - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "findAndModify" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": { - "$numberInt": "0" - }, - "encryptedDecimalPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dri0CXmL78L2DOgk9w0DwxHOMGMzih7m6l59vgy+WWo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b7d8mRzD1kI1tdc7uNL+YAUonJ6pODLsRLkArfEKSkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Xg8C1/A0KJaXOw4i+26Rv03/CydaaunOzXh0CIT+gn8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UoKUDw2wJYToUCcFaIs03YQSTksYR0MIOTJllwODqKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c/5cwAT0C5jber2xlJnWD3a5tVDy0nRtr5HG02hoFOY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wSUrRXavAGaajNeqC5mEUH1K67oYl5Wy9RNIzKjwLAM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vrp4wWDtHEgHWR99I70WVDzevg1Fk/Pw5U8gUDa0OU=", - "subType": "00" - } - } - ] - }, - { - "_id": { - "$numberInt": "1" - }, - "encryptedDecimalPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "V6knyt7Zq2CG3++l75UtBx2m32iGAPjHiAe439Bf02w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F08nMDWDZc+DbWM7XCEJNNCEYyinRmrvGP7EWhmp4is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cXH4688amcDc8kZOJq4UP8cE3R58Zl7e+Qo/1jyspps=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uURBxvTp3FBCVkd+LPqyuY7d6rMW6SGIJQEPY/wtkZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jG3hax1L3RBp9t38vUt53FsBxgr/+Si/vVISpAylYpE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kwtIW8MhH9Ky5xNjBx8gFA/SHh2YVphie7g5FGBzals=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FHflwFuEMu4xX0ZApHi+pdlBH+oevAtXckCUb5Wv0xU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0OKSXELxPP85SBVwDGf3LtMEQCJ8TTkFUl/+6jlkdb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uEw0lpQtBppR3vqV9j9+NQRSBF1BzZukb8c9IhyWvxc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zVhZ7Q59O087ji49oMJvBIgeir2oqvUpnh4p53GcTow=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dowrzKs+qJhRMZyKDbhjXbuX43FbmUKOaw9I8YlOZDw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ep5B6cska6THLIF7Mn3tn3RvV9EiwLSt0eZM/CLRUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "URNp/YmmDh5wIZUfAzzgPyJeMNiVx9PMsz52DZRujGY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wlM4IAQhhKQEzoVqS8b1Ddd50GB95OFb9LnzOwyjCP4=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-InsertFind.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-InsertFind.json deleted file mode 100644 index 79562802e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-InsertFind.json +++ /dev/null @@ -1,572 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range DecimalPrecision. Insert and Find.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "find": "default", - "filter": { - "encryptedDecimalPrecision": { - "$gt": { - "$binary": { - "base64": "DdIJAAADcGF5bG9hZACiCQAABGcAjgkAAAMwAH0AAAAFZAAgAAAAAHdJ2Vnb4MMzqVYVssjSdDy8XU4GVzMTfGifGETgQ2mYBXMAIAAAAAD7cFfKJGIXo6PjyeX2ria02CckW7dWFDoY/3FyBdm1NQVsACAAAAAAhEPSNv4M023A3hzNFuy83+hIKuZ2mKRY954N++aEOBUAAzEAfQAAAAVkACAAAAAAlmvfDrZoydUet4eCVMq7z6a58Ea+1HLJOWxN5lNcrWEFcwAgAAAAAEBo5AWZyC41b9ayjWNQSL4iYEAIwR/JG+ssN8bdoK9RBWwAIAAAAACEndE0SLxFSElOrNnqeX0EPmgDio3udZjVREy4JLS3sQADMgB9AAAABWQAIAAAAABbiLaoxAA6rinMJw1hC8ZUiq6UU1AQaPFn/py/Y06WuQVzACAAAAAAhtDasFkvYE7SCNu1je/hxdE9TJtAvvH3NtdEbKzNbCUFbAAgAAAAAIGepU1RSCF8sWODHEpKglsoqw3VBBH4a/URGxgGzbq2AAMzAH0AAAAFZAAgAAAAALORWwSr+tYNxcil2KIGSbNhTHvcPbdj+rLVQNx21S/KBXMAIAAAAAD6diZBkPEJ1cQy06LAxdbNK8Nlxbb44fH4Wk3Y3260nQVsACAAAAAA1eYAZBFHlDiaDAljWi8blGQ2nvvZa5AO5doeo0SFZsgAAzQAfQAAAAVkACAAAAAAG5XMK96PjClNlUvg82j4pMY1YxsznZfj4uNweD394FoFcwAgAAAAAKHgQLdGJHkrfFg9nB93Ac+3VgBw6aU44MTkKIQ91dZoBWwAIAAAAAAPxXmi+SDJ+40A0KdwfRczexlZQrHjIA+D3oUB0EY9tAADNQB9AAAABWQAIAAAAAA6M++b9I0YFemmWBAWAE3glu2Ah3Ta1FBxAQEIWS0toAVzACAAAAAANXYTqPf1Y6X3Ns6YQIX0C3FKCyWUo+Kk+fNcQvc0WSoFbAAgAAAAAA+uJUw1ICYgyeygSRe206VTWVtUnhdci3iHbyP5YtEVAAM2AH0AAAAFZAAgAAAAAKl8bV1riH/uyJ+X0HHd3+18k2cJl2dQFXCdoagutFcaBXMAIAAAAABm8F2Ew9f0VOABdcF+lP0Bi+zWvEUPniWgrxPq/Sx3uwVsACAAAAAAJfFErjZ6BPhsw5LjJLqNtKDLJ4zV0eIZppQpd9b0wZoAAzcAfQAAAAVkACAAAAAAsYZD8JEP6kYsPncFnNZwJxhu4YtUTKPNcjHtv67H+rYFcwAgAAAAAI4LqZcRkvbs/2F62Flu0pixNcor4WmBD0DHGaf039wLBWwAIAAAAAD4wUR3xd9lKltcqqo8LYvdMQWzCRobkV/ppKB/yn5dUgADOAB9AAAABWQAIAAAAAC0vdAi+dmoIXvZ5LqUqvyKV9/tHqSI2SWiSJO5pTnA2wVzACAAAAAAS2qvf9fvfVUH5WtsVxjxmskpGjYTQV34LwvQQw1y9wIFbAAgAAAAAE0+FKuK7HxbypvCeEJzMTcjOWE0ScYOlTBMUNlIv55hAAM5AH0AAAAFZAAgAAAAAH31lb/srBcrOXkzddCwAnclsR5/3QijEVgECs2JjOWBBXMAIAAAAABg7+prDT73YcCvLE5QbuIrqGcjLc5pQD2Miq0d29yrxgVsACAAAAAAetRiPwDSFWBzpWSWkOKWM6fKStRJ8SyObnpc79ux8p0AAzEwAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzExAH0AAAAFZAAgAAAAAFdthRhe2Q8CvxGIhjTJZv0Lk97GkHciTPxZ/mckLoNaBXMAIAAAAAAqOxsAr23LOVB0DIHbPf9UDJJRFXY2YoKbjhRqw5psbQVsACAAAAAA0G2GD8ZQjDBntjLpW4rqwKRS6HiUjL03g1N6chANozcAAzEyAH0AAAAFZAAgAAAAAMWymwwbvIeMqmnKWWifUqoCxOsdpnonM2qdLPyjqJO/BXMAIAAAAAB6IDmmpUhBD2zpRj8/y/kmOSXcjuIU14sNh6GKSsg2uwVsACAAAAAAWMFPNOk3EMSQDS9JGPSMIQP0oNGVugxXKKUrIPPlhHgAAzEzAH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzE0AH0AAAAFZAAgAAAAAJaRYmo8zqI2BEUzdSwp4tVRpPmVWsfydkYN3UHh6TMuBXMAIAAAAAAeD6mDnQeLlbC9i0sVgE8+RH6y+e94OJQ0tJ0PvblVSgVsACAAAAAAWp4jvretbDEsqEMzP/WLTnwOiJwCtfrCiB6m8k+yEMoAAzE1AH0AAAAFZAAgAAAAAAZZ538coNPwyRjhEwr5P8Xw32oWOJF+R+nfCGgy2qO3BXMAIAAAAACOPLnJlKwGNPDBReRKnHfteq0wFb3ezhrc7BVXs8RUHwVsACAAAAAA+lGesNk3+SyB/60rSvdQ2aN2vfJPR7llJVhufGTNhHkAAzE2AH0AAAAFZAAgAAAAAFH9l9GGA1I52atJV5jNUf1lx8jBjoEoVoME97v5GFJiBXMAIAAAAAC1qH3Kd78Dr9NGbw7y9D/XYBwv5h1LLO8la5OU7g8UkQVsACAAAAAArZ6atJCYrVfHB8dSNPOFf6nnDADBMJcIEj8ljPvxHp8AAzE3AH0AAAAFZAAgAAAAADtbVEI2tdkrowEMdkacD2w0Y3T3Ofi7PH6HmA6sP0c/BXMAIAAAAADuBSROnZHA+NgUPH8d0LnWFiDsM2bY8bzjC1+elSsIygVsACAAAAAAR0G2m+uANoWknkr/NerFcG+fECVxNIs0cqbY1t/U/0MAAzE4AH0AAAAFZAAgAAAAAAh3WpeMVlikPFYj9hLj+fmIqVt6omCSF75W3TPExyWpBXMAIAAAAAAsQkRmwqeVj2gGE03orb6PtrIzDt6dDU3hgSQi8E2wKgVsACAAAAAA3GHaRE2RAcaBRd8VzmYzWeBD2Gmy91eTK1k8YdWObZcAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "find" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dri0CXmL78L2DOgk9w0DwxHOMGMzih7m6l59vgy+WWo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b7d8mRzD1kI1tdc7uNL+YAUonJ6pODLsRLkArfEKSkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Xg8C1/A0KJaXOw4i+26Rv03/CydaaunOzXh0CIT+gn8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UoKUDw2wJYToUCcFaIs03YQSTksYR0MIOTJllwODqKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c/5cwAT0C5jber2xlJnWD3a5tVDy0nRtr5HG02hoFOY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wSUrRXavAGaajNeqC5mEUH1K67oYl5Wy9RNIzKjwLAM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vrp4wWDtHEgHWR99I70WVDzevg1Fk/Pw5U8gUDa0OU=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDecimalPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "mVZb+Ra0EYjQ4Zrh9X//E2T8MRj7NMqm5GUJXhRrBEI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FA74j21GUEJb1DJBOpR9nVnjaDZnd8yAQNuaW9Qi26g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kJv//KVkbrobIBf+QeWC5jxn20mx/P0R1N6aCSMgKM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB+Whi9IUUGxfLEe+lGuIzLX4LFbIhaIAm5lRk65QTc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ybO1QU3CgvhO8JgRXH+HxKszWcpl5aGDYYVa75fHa1g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X3Y3eSAbbMg//JgiHHiFpYOpV61t8kkDexI+CQyitH4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SlNHXyqVFGDPrX/2ppwog6l4pwj3PKda2TkZbqgfSfA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "McjV8xwTF3xI7863DYOBdyvIv6UpzThl6v9vBRk05bI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MgwakFvPyBlwqFTbhWUF79URJQWFoJTGotlEVSPPUsQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DyBERpMSD5lEM5Nhpcn4WGgxgn/mkUVJp+PYSLX5jsE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I43iazc0xj1WVbYB/V+uTL/tughN1bBlxh1iypBnNsA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wjOBa/ATMuOywFmuPgC0GF/oeLqu0Z7eK5udzkTPbis=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gRQVwiR+m+0Vg8ZDXqrQQcVnTyobwCXNaA4BCJVXtMc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WUZ6huwx0ZbLb0R00uiC9FOJzsUocUN8qE5+YRenkvQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7s79aKEuPgQcS/YPOOVcYNZvHIo7FFsWtFCrnDKXefA=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Update.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Update.json deleted file mode 100644 index cc93b7694..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DecimalPrecision-Update.json +++ /dev/null @@ -1,589 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range DecimalPrecision. Update.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDecimalPrecision": { - "$numberDecimal": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDecimalPrecision": { - "$numberDecimal": "1" - } - } - } - }, - { - "name": "updateOne", - "arguments": { - "filter": { - "encryptedDecimalPrecision": { - "$gt": { - "$numberDecimal": "0" - } - } - }, - "update": { - "$set": { - "encryptedDecimalPrecision": { - "$numberDecimal": "2" - } - } - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command_name": "update", - "command": { - "update": "default", - "ordered": true, - "updates": [ - { - "q": { - "encryptedDecimalPrecision": { - "$gt": { - "$binary": { - "base64": "DdIJAAADcGF5bG9hZACiCQAABGcAjgkAAAMwAH0AAAAFZAAgAAAAAHdJ2Vnb4MMzqVYVssjSdDy8XU4GVzMTfGifGETgQ2mYBXMAIAAAAAD7cFfKJGIXo6PjyeX2ria02CckW7dWFDoY/3FyBdm1NQVsACAAAAAAhEPSNv4M023A3hzNFuy83+hIKuZ2mKRY954N++aEOBUAAzEAfQAAAAVkACAAAAAAlmvfDrZoydUet4eCVMq7z6a58Ea+1HLJOWxN5lNcrWEFcwAgAAAAAEBo5AWZyC41b9ayjWNQSL4iYEAIwR/JG+ssN8bdoK9RBWwAIAAAAACEndE0SLxFSElOrNnqeX0EPmgDio3udZjVREy4JLS3sQADMgB9AAAABWQAIAAAAABbiLaoxAA6rinMJw1hC8ZUiq6UU1AQaPFn/py/Y06WuQVzACAAAAAAhtDasFkvYE7SCNu1je/hxdE9TJtAvvH3NtdEbKzNbCUFbAAgAAAAAIGepU1RSCF8sWODHEpKglsoqw3VBBH4a/URGxgGzbq2AAMzAH0AAAAFZAAgAAAAALORWwSr+tYNxcil2KIGSbNhTHvcPbdj+rLVQNx21S/KBXMAIAAAAAD6diZBkPEJ1cQy06LAxdbNK8Nlxbb44fH4Wk3Y3260nQVsACAAAAAA1eYAZBFHlDiaDAljWi8blGQ2nvvZa5AO5doeo0SFZsgAAzQAfQAAAAVkACAAAAAAG5XMK96PjClNlUvg82j4pMY1YxsznZfj4uNweD394FoFcwAgAAAAAKHgQLdGJHkrfFg9nB93Ac+3VgBw6aU44MTkKIQ91dZoBWwAIAAAAAAPxXmi+SDJ+40A0KdwfRczexlZQrHjIA+D3oUB0EY9tAADNQB9AAAABWQAIAAAAAA6M++b9I0YFemmWBAWAE3glu2Ah3Ta1FBxAQEIWS0toAVzACAAAAAANXYTqPf1Y6X3Ns6YQIX0C3FKCyWUo+Kk+fNcQvc0WSoFbAAgAAAAAA+uJUw1ICYgyeygSRe206VTWVtUnhdci3iHbyP5YtEVAAM2AH0AAAAFZAAgAAAAAKl8bV1riH/uyJ+X0HHd3+18k2cJl2dQFXCdoagutFcaBXMAIAAAAABm8F2Ew9f0VOABdcF+lP0Bi+zWvEUPniWgrxPq/Sx3uwVsACAAAAAAJfFErjZ6BPhsw5LjJLqNtKDLJ4zV0eIZppQpd9b0wZoAAzcAfQAAAAVkACAAAAAAsYZD8JEP6kYsPncFnNZwJxhu4YtUTKPNcjHtv67H+rYFcwAgAAAAAI4LqZcRkvbs/2F62Flu0pixNcor4WmBD0DHGaf039wLBWwAIAAAAAD4wUR3xd9lKltcqqo8LYvdMQWzCRobkV/ppKB/yn5dUgADOAB9AAAABWQAIAAAAAC0vdAi+dmoIXvZ5LqUqvyKV9/tHqSI2SWiSJO5pTnA2wVzACAAAAAAS2qvf9fvfVUH5WtsVxjxmskpGjYTQV34LwvQQw1y9wIFbAAgAAAAAE0+FKuK7HxbypvCeEJzMTcjOWE0ScYOlTBMUNlIv55hAAM5AH0AAAAFZAAgAAAAAH31lb/srBcrOXkzddCwAnclsR5/3QijEVgECs2JjOWBBXMAIAAAAABg7+prDT73YcCvLE5QbuIrqGcjLc5pQD2Miq0d29yrxgVsACAAAAAAetRiPwDSFWBzpWSWkOKWM6fKStRJ8SyObnpc79ux8p0AAzEwAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzExAH0AAAAFZAAgAAAAAFdthRhe2Q8CvxGIhjTJZv0Lk97GkHciTPxZ/mckLoNaBXMAIAAAAAAqOxsAr23LOVB0DIHbPf9UDJJRFXY2YoKbjhRqw5psbQVsACAAAAAA0G2GD8ZQjDBntjLpW4rqwKRS6HiUjL03g1N6chANozcAAzEyAH0AAAAFZAAgAAAAAMWymwwbvIeMqmnKWWifUqoCxOsdpnonM2qdLPyjqJO/BXMAIAAAAAB6IDmmpUhBD2zpRj8/y/kmOSXcjuIU14sNh6GKSsg2uwVsACAAAAAAWMFPNOk3EMSQDS9JGPSMIQP0oNGVugxXKKUrIPPlhHgAAzEzAH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzE0AH0AAAAFZAAgAAAAAJaRYmo8zqI2BEUzdSwp4tVRpPmVWsfydkYN3UHh6TMuBXMAIAAAAAAeD6mDnQeLlbC9i0sVgE8+RH6y+e94OJQ0tJ0PvblVSgVsACAAAAAAWp4jvretbDEsqEMzP/WLTnwOiJwCtfrCiB6m8k+yEMoAAzE1AH0AAAAFZAAgAAAAAAZZ538coNPwyRjhEwr5P8Xw32oWOJF+R+nfCGgy2qO3BXMAIAAAAACOPLnJlKwGNPDBReRKnHfteq0wFb3ezhrc7BVXs8RUHwVsACAAAAAA+lGesNk3+SyB/60rSvdQ2aN2vfJPR7llJVhufGTNhHkAAzE2AH0AAAAFZAAgAAAAAFH9l9GGA1I52atJV5jNUf1lx8jBjoEoVoME97v5GFJiBXMAIAAAAAC1qH3Kd78Dr9NGbw7y9D/XYBwv5h1LLO8la5OU7g8UkQVsACAAAAAArZ6atJCYrVfHB8dSNPOFf6nnDADBMJcIEj8ljPvxHp8AAzE3AH0AAAAFZAAgAAAAADtbVEI2tdkrowEMdkacD2w0Y3T3Ofi7PH6HmA6sP0c/BXMAIAAAAADuBSROnZHA+NgUPH8d0LnWFiDsM2bY8bzjC1+elSsIygVsACAAAAAAR0G2m+uANoWknkr/NerFcG+fECVxNIs0cqbY1t/U/0MAAzE4AH0AAAAFZAAgAAAAAAh3WpeMVlikPFYj9hLj+fmIqVt6omCSF75W3TPExyWpBXMAIAAAAAAsQkRmwqeVj2gGE03orb6PtrIzDt6dDU3hgSQi8E2wKgVsACAAAAAA3GHaRE2RAcaBRd8VzmYzWeBD2Gmy91eTK1k8YdWObZcAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "u": { - "$set": { - "encryptedDecimalPrecision": { - "$$type": "binData" - } - } - } - } - ], - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDecimalPrecision", - "bsonType": "decimal", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDecimal": "0.0" - }, - "max": { - "$numberDecimal": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - }, - "$db": "default" - } - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDecimalPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dri0CXmL78L2DOgk9w0DwxHOMGMzih7m6l59vgy+WWo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b7d8mRzD1kI1tdc7uNL+YAUonJ6pODLsRLkArfEKSkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Xg8C1/A0KJaXOw4i+26Rv03/CydaaunOzXh0CIT+gn8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UoKUDw2wJYToUCcFaIs03YQSTksYR0MIOTJllwODqKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c/5cwAT0C5jber2xlJnWD3a5tVDy0nRtr5HG02hoFOY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wSUrRXavAGaajNeqC5mEUH1K67oYl5Wy9RNIzKjwLAM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vrp4wWDtHEgHWR99I70WVDzevg1Fk/Pw5U8gUDa0OU=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDecimalPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "V6knyt7Zq2CG3++l75UtBx2m32iGAPjHiAe439Bf02w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F08nMDWDZc+DbWM7XCEJNNCEYyinRmrvGP7EWhmp4is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cXH4688amcDc8kZOJq4UP8cE3R58Zl7e+Qo/1jyspps=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uURBxvTp3FBCVkd+LPqyuY7d6rMW6SGIJQEPY/wtkZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jG3hax1L3RBp9t38vUt53FsBxgr/+Si/vVISpAylYpE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kwtIW8MhH9Ky5xNjBx8gFA/SHh2YVphie7g5FGBzals=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FHflwFuEMu4xX0ZApHi+pdlBH+oevAtXckCUb5Wv0xU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0OKSXELxPP85SBVwDGf3LtMEQCJ8TTkFUl/+6jlkdb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uEw0lpQtBppR3vqV9j9+NQRSBF1BzZukb8c9IhyWvxc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zVhZ7Q59O087ji49oMJvBIgeir2oqvUpnh4p53GcTow=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dowrzKs+qJhRMZyKDbhjXbuX43FbmUKOaw9I8YlOZDw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ep5B6cska6THLIF7Mn3tn3RvV9EiwLSt0eZM/CLRUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "URNp/YmmDh5wIZUfAzzgPyJeMNiVx9PMsz52DZRujGY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wlM4IAQhhKQEzoVqS8b1Ddd50GB95OFb9LnzOwyjCP4=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Aggregate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Aggregate.json deleted file mode 100644 index 79f26660f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Aggregate.json +++ /dev/null @@ -1,1133 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Double. Aggregate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$numberDouble": "0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "default", - "pipeline": [ - { - "$match": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$binary": { - "base64": "DYckAAADcGF5bG9hZABXJAAABGcAQyQAAAMwAH0AAAAFZAAgAAAAAHgYoMGjEE6fAlAhICv0+doHcVX8CmMVxyq7+jlyGrvmBXMAIAAAAAC/5MQZgTHuIr/O5Z3mXPvqrom5JTQ8IeSpQGhO9sB+8gVsACAAAAAAuPSXVmJUAUpTQg/A9Bu1hYczZF58KEhVofakygbsvJQAAzEAfQAAAAVkACAAAAAA2kiWNvEc4zunJ1jzvuClFC9hjZMYruKCqAaxq+oY8EAFcwAgAAAAACofIS72Cm6s866UCk+evTH3CvKBj/uZd72sAL608rzTBWwAIAAAAADuCQ/M2xLeALF0UFZtJb22QGOhHmJv6xoO+kZIHcDeiAADMgB9AAAABWQAIAAAAABkfoBGmU3hjYBvQbjNW19kfXneBQsQQPRfUL3UAwI2cAVzACAAAAAAUpK2BUOqX/DGdX5YJniEZMWkofxHqeAbXceEGJxhp8AFbAAgAAAAAKUaLzIldNIZv6RHE+FwbMjzcNHqPESwF/37mm43VPrsAAMzAH0AAAAFZAAgAAAAAFNprhQ3ZwIcYbuzLolAT5n/vc14P9kUUQComDu6eFyKBXMAIAAAAAAcx9z9pk32YbPV/sfPZl9ALIEVsqoLXgqWLVK/tP+heAVsACAAAAAA/qxvuvJbAHwwhfrPVpmCFzNvg2cU/NXaWgqgYUZpgXwAAzQAfQAAAAVkACAAAAAAODI+pB2pCuB+YmNEUAgtMfNdt3DmSkrJ96gRzLphgb8FcwAgAAAAAAT7dewFDxUDECQ3zVq75/cUN4IP+zsqhkP5+czUwlJIBWwAIAAAAACFGeOtd5zBXTJ4JYonkn/HXZfHipUlqGwIRUcH/VTatwADNQB9AAAABWQAIAAAAACNAk+yTZ4Ewk1EnotQK8O3h1gg9I7pr9q2+4po1iJVgAVzACAAAAAAUj/LesmtEsgqYVzMJ67umVA11hJTdDXwbxDoQ71vWyUFbAAgAAAAABlnhpgTQ0WjLb5u0b/vEydrCeFjVynKd7aqb+UnvVLeAAM2AH0AAAAFZAAgAAAAAD/FIrGYFDjyYmVb7oTMVwweWP7A6F9LnyIuNO4MjBnXBXMAIAAAAACIZgJCQRZu7NhuNMyOqCn1tf+DfU1qm10TPCfj5JYV3wVsACAAAAAA5hmY4ptuNxULGf87SUFXQWGAONsL9U29duh8xqsHtxoAAzcAfQAAAAVkACAAAAAAciRW40ORJLVwchOEpz87Svb+5toAFM6LxDWv928ECwQFcwAgAAAAAN0dipyESIkszfjRzdDi8kAGaa2Hf4wrPAtiWwboZLuxBWwAIAAAAAANr4o/+l1OIbbaX5lZ3fQ/WIeOcEXjNI1F0WbSgQrzaQADOAB9AAAABWQAIAAAAACZqAyCzYQupJ95mrBJX54yIz9VY7I0WrxpNYElCI4dTQVzACAAAAAA/eyJb6d1xfE+jJlVXMTD3HS/NEYENPVKAuj56Dr2dSEFbAAgAAAAANkSt154Or/JKb31VvbZFV46RPgUp8ff/hcPORL7PpFBAAM5AH0AAAAFZAAgAAAAAI5bm3YO0Xgf0VT+qjVTTfvckecM3Cwqj7DTKZXf8/NXBXMAIAAAAAD/m+h8fBhWaHm6Ykuz0WX1xL4Eme3ErLObyEVJf8NCywVsACAAAAAAfb1VZZCqs2ivYbRzX4p5CtaCkKW+g20Pr57FWXzEZi8AAzEwAH0AAAAFZAAgAAAAANqo4+p6qdtCzcB4BX1wQ6llU7eFBnuu4MtZwp4B6mDlBXMAIAAAAAAGiz+VaukMZ+6IH4jtn4KWWdKK4/W+O+gRioQDrfzpMgVsACAAAAAAG4YYkTp80EKo59mlHExDodRQFR7njhR5dmISwUJ6ukAAAzExAH0AAAAFZAAgAAAAAPrFXmHP2Y4YAm7b/aqsdn/DPoDkv7B8egWkfe23XsM1BXMAIAAAAAAGhwpKAr7skeqHm3oseSbO7qKNhmYsuUrECBxJ5k+D2AVsACAAAAAAAqPQi9luYAu3GrFCEsVjd9z2zIDcp6SPTR2w6KQEr+IAAzEyAH0AAAAFZAAgAAAAABzjYxwAjXxXc0Uxv18rH8I3my0Aguow0kTwKyxbrm+cBXMAIAAAAADVbqJVr6IdokuhXkEtXF0C2gINLiAjMVN20lE20Vmp2QVsACAAAAAAD7K1Fx4gFaaizkIUrf+EGXQeG7QX1jadhGc6Ji471H8AAzEzAH0AAAAFZAAgAAAAAFMm2feF2fFCm/UC6AfIyepX/xJDSmnnolQIBnHcPmb5BXMAIAAAAABLI11kFrQoaNVZFmq/38aRNImPOjdJh0Lo6irI8M/AaAVsACAAAAAAOWul0oVqJ9CejD2RqphhTC98DJeRQy5EwbNerU2+4l8AAzE0AH0AAAAFZAAgAAAAAJvXB3KyNiNtQko4SSzo/9b2qmM2zU9CQTTDfLSBWMgRBXMAIAAAAAAvjuVP7KsLRDeqVqRziTKpBrjVyqKiIbO9Gw8Wl2wFTAVsACAAAAAADlE+oc1ins+paNcaOZJhBlKlObDJ4VQORWjFYocM4LgAAzE1AH0AAAAFZAAgAAAAAPGdcxDiid8z8XYnfdDivNMYVPgBKdGOUw6UStU+48CdBXMAIAAAAAARj6g1Ap0eEfuCZ4X2TsEw+Djrhto3fA5nLwPaY0vCTgVsACAAAAAAoHqiwGOUkBu8SX5U1yHho+UIFdSN2MdQN5s6bQ0EsJYAAzE2AH0AAAAFZAAgAAAAAP5rGPrYGt3aKob5f/ldP0qrW7bmWvqnKY4QwdDWz400BXMAIAAAAADTQkW2ymaaf/bhteOOGmSrIR97bAnJx+yN3yMj1bTeewVsACAAAAAADyQnHGH2gF4w4L8axUsSTf6Ubk7L5/eoFOJk12MtZAoAAzE3AH0AAAAFZAAgAAAAAAlz6wJze5UkIxKpJOZFGCOf3v2KByWyI6NB6JM9wNcBBXMAIAAAAABUC7P/neUIHHoZtq0jFVBHY75tSFYr1Y5S16YN5XxC1QVsACAAAAAAgvxRbXDisNnLY3pfsjDdnFLtkvYUC4lhA68eBXc7KAwAAzE4AH0AAAAFZAAgAAAAAFJ8AtHcjia/9Y5pLEc3qVgH5xKiXw12G9Kn2A1EY8McBXMAIAAAAAAxe7Bdw7eUSBk/oAawa7uicTEDgXLymRNhBy1LAxhDvwVsACAAAAAAxKPaIBKVx3jTA+R/el7P7AZ7efrmTGjJs3Hj/YdMddwAAzE5AH0AAAAFZAAgAAAAAO8uwQUaKFb6vqR3Sv3Wn4QAonC2exOC9lGG1juqP5DtBXMAIAAAAABZf1KyJgQg8/Rf5c02DgDK2aQu0rNCOvaL60ohDHyY+gVsACAAAAAAqyEjfKC8lYoIfoXYHUqHZPoaA6EK5BAZy5dxXZmay4kAAzIwAH0AAAAFZAAgAAAAAE8YtqyRsGCeiR6hhiyisR/hccmK4nZqIMzO4lUBmEFzBXMAIAAAAAC1UYOSKqAeG1UJiKjWFVskRhuFKpj9Ezy+lICZvFlN5AVsACAAAAAA6Ct9nNMKyRazn1OKnRKagm746CGu+jyhbL1qJnZxGi0AAzIxAH0AAAAFZAAgAAAAAPhCrMausDx1QUIEqp9rUdRKyM6a9AAx7jQ3ILIu8wNIBXMAIAAAAACmH8lotGCiF2q9VQxhsS+7LAZv79VUAsOUALaGxE/EpAVsACAAAAAAnc1xCKfdvbUEc8F7XZqlNn1C+hZTtC0I9I3LL06iaNkAAzIyAH0AAAAFZAAgAAAAAOBi/GAYFcstMSJPgp3VkMiuuUUCrZytvqYaU8dwm8v2BXMAIAAAAACEZSZVyD3pKzGlbdwlYmWQhHHTV5SnNLknl2Gw8IaUTQVsACAAAAAAfsLZsEDcWSuNsIo/TD1ReyQW75HPMgmuKZuWFOLKRLoAAzIzAH0AAAAFZAAgAAAAAIQuup+YGfH3mflzWopN8J1X8o8a0d9CSGIvrA5HOzraBXMAIAAAAADYvNLURXsC2ITMqK14LABQBI+hZZ5wNf24JMcKLW+84AVsACAAAAAACzfjbTBH7IwDU91OqLAz94RFkoqBOkzKAqQb55gT4/MAAzI0AH0AAAAFZAAgAAAAAKsh0ADyOnVocFrOrf6MpTrNvAj8iaiE923DPryu124gBXMAIAAAAADg24a8NVE1GyScc6tmnTbmu5ulzO+896fE92lN08MeswVsACAAAAAAaPxcOIxnU7But88/yadOuDJDMcCywwrRitaxMODT4msAAzI1AH0AAAAFZAAgAAAAAKkVC2Y6HtRmv72tDnPUSjJBvse7SxLqnr09/Uuj9sVVBXMAIAAAAABYNFUkH7ylPMN+Bc3HWX1e0flGYNbtJNCY9SltJCW/UAVsACAAAAAAZYK/f9H4OeihmpiFMH7Wm7uLvs2s92zNA8wyrNZTsuMAAzI2AH0AAAAFZAAgAAAAADDggcwcb/Yn1Kk39sOHsv7BO/MfP3m/AJzjGH506Wf9BXMAIAAAAAAYZIsdjICS0+BDyRUPnrSAZfPrwtuMaEDEn0/ijLNQmAVsACAAAAAAGPnYVvo2ulO9z4LGd/69NAklfIcZqZvFX2KK0s+FcTUAAzI3AH0AAAAFZAAgAAAAAEWY7dEUOJBgjOoWVht1wLehsWAzB3rSOBtLgTuM2HC8BXMAIAAAAAAAoswiHRROurjwUW8u8D5EUT+67yvrgpB/j6PzBDAfVwVsACAAAAAA6NhRTYFL/Sz4tao7vpPjLNgAJ0FX6P/IyMW65qT6YsMAAzI4AH0AAAAFZAAgAAAAAPZaapeAUUFPA7JTCMOWHJa9lnPFh0/gXfAPjA1ezm4ZBXMAIAAAAACmJvLY2nivw7/b3DOKH/X7bBXjJwoowqb1GtEFO3OYgAVsACAAAAAA/JcUoyKacCB1NfmH8vYqC1f7rd13KShrQqV2r9QBP44AAzI5AH0AAAAFZAAgAAAAAK00u6jadxCZAiA+fTsPVDsnW5p5LCr4+kZZZOTDuZlfBXMAIAAAAAAote4zTEYMDgaaQbAdN8Dzv93ljPLdGjJzvnRn3KXgtQVsACAAAAAAxXd9Mh6R3mnJy8m7UfqMKi6oD5DlZpkaOz6bEjMOdiwAAzMwAH0AAAAFZAAgAAAAAFbgabdyymiEVYYwtJSWa7lfl/oYuj/SukzJeDOR6wPVBXMAIAAAAADAFGFjS1vPbN6mQEhkDYTD6V2V23Ys9gUEUMGNvMPkaAVsACAAAAAAL/D5Sze/ZoEanZLK0IeEkhgVkxEjMWVCfmJaD3a8uNIAAzMxAH0AAAAFZAAgAAAAABNMR6UBv2E627CqLtQ/eDYx7OEwQ7JrR4mSHFa1N8tLBXMAIAAAAAAxH4gucI4UmNVB7625C6hFSVCuIpJO3lusJlPuL8H5EQVsACAAAAAAVLHNg0OUVqZ7WGOP53BkTap9FOw9dr1P4J8HxqFqU04AAzMyAH0AAAAFZAAgAAAAAG8cd6WBneNunlqrQ2EmNf35W7OGObGq9WL4ePX+LUDmBXMAIAAAAAAjJ2+sX87NSis9hBsgb1QprVRnO7Bf+GObCGoUqyPE4wVsACAAAAAAs9c9SM49/pWmyUQKslpt3RTMBNSRppfNO0JBvUqHPg0AAzMzAH0AAAAFZAAgAAAAAFWOUGkUpy8yf6gB3dio/aOfRKh7XuhvsUj48iESFJrGBXMAIAAAAAAY7sCDMcrUXvNuL6dO0m11WyijzXZvPIcOKob6IpC4PQVsACAAAAAAJOP+EHz6awDb1qK2bZQ3kTV7wsj5Daj/IGAWh4g7omAAAzM0AH0AAAAFZAAgAAAAAGUrIdKxOihwNmo6B+aG+Ag1qa0+iqdksHOjQj+Oy9bZBXMAIAAAAABwa5dbI2KmzBDNBTQBEkjZv4sPaeRkRNejcjdVymRFKQVsACAAAAAA4ml/nm0gJNTcJ4vuD+T2Qfq2fQZlibJp/j6MOGDrbHMAAzM1AH0AAAAFZAAgAAAAAOx89xV/hRk64/CkM9N2EMK6aldII0c8smdcsZ46NbP8BXMAIAAAAADBF6tfQ+7q9kTuLyuyrSnDgmrdmrXkdhl980i1KHuGHgVsACAAAAAACUqiFqHZdGbwAA+hN0YUE5zFg+H+dabIB4dj5/75W/YAAzM2AH0AAAAFZAAgAAAAAMkN0L1oQWXhjwn9rAdudcYeN8/5VdCKU8cmDt7BokjsBXMAIAAAAAAT62pGXoRwExe9uvgYOI0hg5tOxilrWfoEmT0SMglWJwVsACAAAAAAlVz4dhiprSbUero6JFfxzSJGclg63oAkAmgbSwbcYxIAAzM3AH0AAAAFZAAgAAAAANxfa4xCoaaB7k1C1RoH1LBhsCbN2yEq15BT9b+iqEC4BXMAIAAAAACAX9LV8Pemfw7NF0iB1/85NzM1Ef+1mUfyehacUVgobQVsACAAAAAAVq4xpbymLk0trPC/a2MvB39I7hRiX8EJsVSI5E5hSBkAAzM4AH0AAAAFZAAgAAAAAOYIYoWkX7dGuyKfi3XssUlc7u/gWzqrR9KMkikKVdmSBXMAIAAAAABVF2OYjRTGi9Tw8XCAwZWLpX35Yl271TlNWp6N/nROhAVsACAAAAAA0nWwYzXQ1+EkDvnGq+SMlq20z+j32Su+i/A95SggPb4AAzM5AH0AAAAFZAAgAAAAAIy0+bXZi10QC+q7oSOLXK5Fee7VEk/qHSXukfeVIfgzBXMAIAAAAAAQ3IIV/JQCHW95AEbH5zGIHtJqyuPjWPMIZ+VmQHlxEwVsACAAAAAAp0jYsyohKv9Pm+4k+DplEGbl9WLZpAJzitrcDj4CNsMAAzQwAH0AAAAFZAAgAAAAAL5SOJQ3LOhgdXJ5v086NNeAl1qonQnchObdpZJ1kHeEBXMAIAAAAAA+tEqTXODtik+ydJZSnUqXF9f18bPeze9eWtR7ExZJgQVsACAAAAAAbrkZCVgB9Qsp4IAbdf+bD4fT6Boqk5UtuA/zhNrh1y0AAzQxAH0AAAAFZAAgAAAAAKl8zcHJRDjSjJeV/WvMxulW1zrTFtaeBy/aKKhadc6UBXMAIAAAAADBdWQl5SBIvtZZLIHszePwkO14W1mQ0izUk2Ov21cPNAVsACAAAAAAHErCYycpqiIcCZHdmPL1hi+ovLQk4TAvENpfLdTRamQAAzQyAH0AAAAFZAAgAAAAAFvotcNaoKnVt5CBCOPwjexFO0WGWuaIGL6H/6KSau+6BXMAIAAAAAD2y2mBN5xPu5PJoY2zcr0GnQDtHRBogA5+xzIxccE9fwVsACAAAAAAdS34xzJesnUfxLCcc1U7XzUqLy8MAzV/tcjbqaD3lkMAAzQzAH0AAAAFZAAgAAAAAPezU0/vNT4Q4YKbTbaeHqcwNLT+IjW/Y9QFpIooihjPBXMAIAAAAACj2x4O4rHter8ZnTws5LAP9jJ/6kk9C/V3vL50LoFZHAVsACAAAAAAQdBDF3747uCVP5lB/zr8VmzxJfTSZHBKeIgm5FyONXwAAzQ0AH0AAAAFZAAgAAAAAMqpayM2XotEFmm0gwQd9rIzApy0X+7HfOhNk6VU7F5lBXMAIAAAAACJR9+q5T9qFHXFNgGbZnPubG8rkO6cwWhzITQTmd6VgwVsACAAAAAAOZLQ6o7e4mVfDzbpQioa4d3RoTvqwgnbmc5Qh2wsZuoAAzQ1AH0AAAAFZAAgAAAAANCeyW+3oebaQk+aqxNVhAcT/BZ5nhsTVdKS3tMrLSvWBXMAIAAAAADxRFMDhkyuEc++WnndMfoUMLNL7T7rWoeblcrpSI6soQVsACAAAAAAdBuBMJ1lxt0DRq9pOZldQqchLs3B/W02txcMLD490FEAAzQ2AH0AAAAFZAAgAAAAAIbo5YBTxXM7HQhl7UP9NNgpPGFkBx871r1B65G47+K8BXMAIAAAAAC21dJSxnEhnxO5gzN5/34BL4von45e1meW92qowzb8fQVsACAAAAAAm3Hk2cvBN0ANaR5jzeZE5TsdxDvJCTOT1I01X7cNVaYAAzQ3AH0AAAAFZAAgAAAAABm/6pF96j26Jm7z5KkY1y33zcAEXLx2n0DwC03bs/ixBXMAIAAAAAD01OMvTZI/mqMgxIhA5nLs068mW+GKl3OW3ilf2D8+LgVsACAAAAAAaLvJDrqBESTNZSdcXsd+8GXPl8ZkUsGpeYuyYVv/kygAAzQ4AH0AAAAFZAAgAAAAAJ/D3+17gaQdkBqkL2wMwccdmCaVOtxzIkM8VyI4xI5zBXMAIAAAAAAggLVmkc5u+YzBR+oNE+XgLVp64fC6MzUb/Ilu/Jsw0AVsACAAAAAACz3HVKdWkx82/kGbVpcbAeZtsj2R5Zr0dEPfle4IErkAAzQ5AH0AAAAFZAAgAAAAAJMRyUW50oaTzspS6A3TUoXyC3gNYQoShUGPakMmeVZrBXMAIAAAAACona2Pqwt4U2PmFrtmu37jB9kQ/12okyAVtYa8TQkDiQVsACAAAAAAltJJKjCMyBTJ+4PkdDCPJdeX695P8P5h7WOZ+kmExMAAAzUwAH0AAAAFZAAgAAAAAByuYl8dBvfaZ0LO/81JW4hYypeNmvLMaxsIdvqMPrWoBXMAIAAAAABNddwobOUJzm9HOUD8BMZJqkNCUCqstHZkC76FIdNg9AVsACAAAAAAQQOkIQtkyNavqCnhQbNg3HfqrJdsAGaoxSJePJl1qXsAAzUxAH0AAAAFZAAgAAAAAHEzLtfmF/sBcYPPdj8867VmmQyU1xK9I/3Y0478azvABXMAIAAAAAAcmyFajZPnBTbO+oLInNwlApBocUekKkxz2hYFeSlQ+gVsACAAAAAAZ6IkrOVRcC8vSA6Vb4fPWZJrYexXhEabIuYIeXNsCSgAAzUyAH0AAAAFZAAgAAAAAJam7JYsZe2cN20ZYm2W3v1pisNt5PLiniMzymBLWyMtBXMAIAAAAABxCsKVMZMTn3n+R2L7pVz5nW804r8HcK0mCBw3jUXKXAVsACAAAAAA7j3JGnNtR64P4dJLeUoScFRGfa8ekjh3dvhw46sRFk0AAzUzAH0AAAAFZAAgAAAAAMXrXx0saZ+5gORmwM2FLuZG6iuO2YS+1IGPoAtDKoKBBXMAIAAAAADIQsxCr8CfFKaBcx8kIeSywnGh7JHjKRJ9vJd9x79y7wVsACAAAAAAcvBV+SykDYhmRFyVYwFYB9oBKBSHr55Jdz2cXeowsUQAAzU0AH0AAAAFZAAgAAAAACbzcUD3INSnCRspOKF7ubne74OK9L0FTZvi9Ay0JVDYBXMAIAAAAADPebVQH8Btk9rhBIoUOdSAdpPvz7qIY4UC2i6IGisSAQVsACAAAAAAiBunJi0mPnnXdnldiq+If8dcb/n6apHnaIFt+oyYO1kAAzU1AH0AAAAFZAAgAAAAACUc2CtD1MK/UTxtv+8iA9FoHEyTwdl43HKeSwDw2Lp5BXMAIAAAAACCIduIdw65bQMzRYRfjBJj62bc69T4QqH4QoWanwlvowVsACAAAAAAM0TV7S+aPVVzJOQ+cpSNKHTwyQ0mWa8tcHzfk3nR+9IAAzU2AH0AAAAFZAAgAAAAAHSaHWs/dnmI9sc7nB50VB2Bzs0kHapMHCQdyVEYY30TBXMAIAAAAACkV22lhEjWv/9/DubfHBAcwJggKI5mIbSK5L2nyqloqQVsACAAAAAAS19m7DccQxgryOsBJ3GsCs37yfQqNi1G+S6fCXpEhn4AAzU3AH0AAAAFZAAgAAAAAAL8jhNBG0KXXZhmZ0bPXtfgapJCB/AI+BEHB0eZ3C75BXMAIAAAAADHx/fPa639EBmGV5quLi8IQT600ifiKSOhTDOK19DnzwVsACAAAAAAlyLTDVkHxbayklD6Qymh3odIK1JHaOtps4f4HR+PcDgAAzU4AH0AAAAFZAAgAAAAAAxgeclNl09H7HvzD1oLwb2YpFca5eaX90uStYXHilqKBXMAIAAAAACMU5pSxzIzWlQxHyW170Xs9EhD1hURASQk+qkx7K5Y6AVsACAAAAAAJbMMwJfNftA7Xom8Bw/ghuZmSa3x12vTZxBUbV8m888AAzU5AH0AAAAFZAAgAAAAABmO7QD9vxWMmFjIHz13lyOeV6vHT6mYCsWxF7hb/yOjBXMAIAAAAACT9lmgkiqzuWG24afuzYiCeK9gmJqacmxAruIukd0xEAVsACAAAAAAZa0/FI/GkZR7CtX18Xg9Tn9zfxkD0UoaSt+pIO5t1t4AAzYwAH0AAAAFZAAgAAAAAB89SjLtDJkqEghRGyj6aQ/2qvWLNuMROoXmzbYbCMKMBXMAIAAAAAC8sywgND+CjhVTF6HnRQeay8y9/HnVzDI42dEPah28LQVsACAAAAAAoxv7UKh0RqUAWcOsQvU123zO1qZn73Xfib0qncZCB34AAzYxAH0AAAAFZAAgAAAAABN2alGq9Aats1mwERNGwL/fIwZSvVCe9/8XMHTFlpUpBXMAIAAAAACuDPjJgvvbBYhbLpjMiWUCsVppiYrhvR+yMysNPN8cZAVsACAAAAAAKpADjc4bzIZMi9Q/+oe0EMRJHYQt6dlo1x/lRquagqkAAzYyAH0AAAAFZAAgAAAAAL8YB6VAqGBiWD4CBv16IBscg5J7VQCTZu87n6pj+86KBXMAIAAAAAAmxm8e68geeyAdUjSMWBHzUjneVB0pG9TBXIoE6467hAVsACAAAAAAV76JZAlYpgC/Zl8awx2ArCg1uuyy2XVTSkp0wUMi/7UAAzYzAH0AAAAFZAAgAAAAAL4yLkCTV5Dmxa5toBu4JT8ge/cITAaURIOuFuOtFUkeBXMAIAAAAAAXoFNQOMGkAj7qEJP0wQafmFSXgWGeorDVbwyOxWLIsgVsACAAAAAAc4Un6dtIFe+AQ+RSfNWs3q63RTHhmyc+5GKRRdpWRv8AAzY0AH0AAAAFZAAgAAAAAEU8DoUp46YtYjNFS9kNXwdYxQ9IW27vCTb+VcqqfnKNBXMAIAAAAADe7vBOgYReE8X78k5ARuUnv4GmzPZzg6SbConf4L2G3wVsACAAAAAA78YHWVkp6HbZ0zS4UL2z/2pj9vPDcMDt7zTv6NcRsVsAAzY1AH0AAAAFZAAgAAAAAPa4yKTtkUtySuWo1ZQsp2QXtPb5SYqzA5vYDnS1P6c0BXMAIAAAAADKnF58R1sXlHlsHIvCBR3YWW/qk54z9CTDhZydkD1cOQVsACAAAAAAHW3ERalTFWKMzjuXF3nFh0pSrQxM/ojnPbPhc4v5MaQAAzY2AH0AAAAFZAAgAAAAAN5WJnMBmfgpuQPyonmY5X6OdRvuHw4nhsnGRnFAQ95VBXMAIAAAAACwftzu7KVV1rmGKwXtJjs3cJ1gE3apr8+N0SAg1F2cHwVsACAAAAAATDW0reyaCjbJuVLJzbSLx1OBuBoQu+090kgW4RurVacAAzY3AH0AAAAFZAAgAAAAACHvDsaPhoSb6DeGnKQ1QOpGYAgK82qpnqwcmzSeWaJHBXMAIAAAAABRq3C5+dOfnkAHM5Mg5hPB3O4jhwQlBgQWLA7Ph5bhgwVsACAAAAAAqkC8zYASvkVrp0pqmDyFCkPaDmD/ePAJpMuNOCBhni8AAzY4AH0AAAAFZAAgAAAAAOBePJvccPMJmy515KB1AkXF5Pi8NOG4V8psWy0SPRP+BXMAIAAAAAB3dOJG9xIDtEKCRzeNnPS3bFZepMj8UKBobKpSoCPqpgVsACAAAAAAPG3IxQVOdZrr509ggm5FKizWWoZPuVtOgOIGZ3m+pdEAAzY5AH0AAAAFZAAgAAAAABUvRrDQKEXLMdhnzXRdhiL6AGNs2TojPky+YVLXs+JnBXMAIAAAAAD1kYicbEEcPzD4QtuSYQQWDPq8fuUWGddpWayKn3dT9QVsACAAAAAA9+Sf7PbyFcY45hP9oTfjQiOUS3vEIAT8C0vOHymwYSUAAzcwAH0AAAAFZAAgAAAAAOvSnpujeKNen4pqc2HR63C5s5oJ1Vf4CsbKoYQvkwl5BXMAIAAAAACw2+vAMdibzd2YVVNfk81yXkFZP0WLJ82JBxJmXnYE+QVsACAAAAAArQ/E1ACyhK4ZyLqH9mNkCU7WClqRQTGyW9tciSGG/EMAAzcxAH0AAAAFZAAgAAAAAAo0xfGG7tJ3GWhgPVhW5Zn239nTD3PadShCNRc9TwdNBXMAIAAAAADZh243oOhenu0s/P/5KZLBDh9ADqKHtSWcXpO9D2sIjgVsACAAAAAAlgTPaoQKz+saU8rwCT3UiNOdG6hdpjzFx9GBn08ZkBEAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - } - } - ], - "cursor": {}, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "aggregate" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6YrBn2ofIw1b5ooakrLOwF41BWrps8OO0H9WH4/rtlE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "n+XAuFnP8Dov9TnhGFxNx0K/MnVM9WbJ7RouEu0ndO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yRXojuVdn5GQtD97qYlaCL6cOLmZ7Cvcb3wFjkLUIdM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DuIkdRPITRs55I4SZmgomAHCIsDQmXRhW8+MOznkzSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SsBk+Et1lTbU+QRPx+xyJ/jMkmfG+QCvQEpip2YYrzA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "crCIzOd8KhHvvUlX7M1v9bhvU4pLdTc+X2SuqoKU5Ek=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YOWdCw4UrqnxkAaVjqmC4sKQDMVMHEpFGnlxpxdaU6E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M3SShp81Ff8tQ632qKbv9MUcN6wjDaBReI0VXNu6Xh4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gzHlSPxpM0hT75kQvWFzGlOxKvDoiKQZOr19V6l2zXI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s3JnppOGYw9SL2Q1kMAZs948v2F5PrpXjGei/HioDWs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cG6+3Gk/zEH68P/uuuwiAUVCuyJwa1LeV+t29FlPPAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dupdvR3AyJtM+g9NDKiaLVOtGca387JQp8w+V03m7Ig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JqEQc5svj2jTvZ6LLA5ivE+kTb/0aRemSEmxk4G7Zrg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "szcXXXKnob+p3SoM4yED2R920LeJ7cVsclPMFTe4CeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o1QoGVXmuBdHwHm7aCtGMlMVKrjFdYvJXpoq6uhIAZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Jfm5wPlqqLCJRGQIqRq2NGmpn7s0Vrih2H3YAOoI2YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zMHLb8ARbsYo8Ld05bqnGFf1Usha6EGb8QKwdSAyps0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yQdtq9lh5pugL7/i0Bj/PuZUUBUIzf+7wj1rl5y736w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wGWVZdO7qIuyDg/BqDgqjgoQ02h5YYgwXQB1oCin2NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "by9HMLj6NTEpgztZ5HSN6GxImkXPcaFINYDzgZY33X8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tWo0vbasi7bXmn/MsOx13VC1IsWtpx/nYp0uj4iMzdA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tQQpndUYd5O87lOtrGjH3wl9VsOK0ray7RMasL90sBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cQjXEDCMsOpKLLf+vlTgIHA+cbSJdzqhbSX9Wvh95aA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7yMpU48IxK9SzP2cx3VnTownGEwFmeFofuuFT97SuuY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kSOx1kz0CmBgzKQHZlo65ZUY1DIv9A99JRm+Us2y6Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubQpdPBe6/xvtr+AcXdfYLSvYCR4ot0tivehkCsupb4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xal+iCJ6FTefRQToyoNksc9NCZShyn04NDGi4IYrcoM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d7jU4iOK50xHxlkSifcxlZFCM46TSgQzoYivxG3HNLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJvl2nsBLBVzL3pp6sKWCL4UXeh3q/roYBJjSb74ve0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OIUCaKRvIx9t1w6Hxlz1IcQTdPNCfdRNwnnTm10W+X0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A9tvzsiElotOUVIB4CqfQp9mAwqvTM35YkmAR170aHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lI8gpK7hpb7c9x4RQugsxMnQay5LZJmwslZdvMx/dcE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dNCzh40U0XvdKnSDi3HRQOWQftEsDVqc4uUvsVFGoq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IP+iwEBWBwVVZIdpaMu8k5+soFCz+TZkYn3drKZ9grE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnqyh6e0y5svHkJDShlN9CHV0WvMBE4QbtJpQw5ZCXc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "elEl42tbVDoRTLjAhZUFEtXiut4b3PVhg/1ZLZSQdtE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vHuu2FxwclMHqyE6JBYbTYgbEkB0dqb/JuaxsvfwsmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xTf7NCe3Gf8QpE78HR5OknlLTKfs9J+RN9UZpH6fnso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XiWSasRnJAulGR6+LCVD3mwRObXylqYWR9jvpywq12c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MZMxEQ5ikx0PG1YFIExv0UnTZogsvgeOEZTpzvBDn4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yZMyMZBDrWbAhvnic7vvIYhmO9m5H2iuv0c8KNZrBzY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xxM14hTPY5j0vvcK2C7YAEjzdsfUTFHozHC0hEo1bxI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+01rqR1xVwkpGXcstbk1ItJqFVjH6Q8MGxEN3Cm9Y1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xOpLV0Z2VTRJ3iWtnWZcsyjXubTIkYWo31cO+HV1o1k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BWUOLqgLBqc5NwxVlSV5H3KFQPXbCp7mdo+jF+8cJqY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fuQb1S6xZDGlrEbK+kI23aL53PP1PVNwqICnZNt9Yzg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfscnoibFttahLdPVC4Ee+47ewGFKpDSU7M6HX19bKE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rpSW2awybNVeKtat91VFxqbINoTfNhPfQAu+d73Xtf8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9M/CP9ccOIIj2LLFmE0GFDO0Ban2wsNalEXfM6+h+1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WrEMG49l1ye4MhXs5ZS9tz8P6h+hDvthIg/2wW9ne1Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ImNhbfeyfH8qIEeA5ic0s3dAQBdzzTBS+CPsNih9vZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dWP33YDSn04UKJN2ogh2Rui0iW/0q2y18OCDRVcfyoo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lYv0isAtfGh6H9tdp3cp2eHU7q2J+uk7QrgcxtK3w7Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VGMoamB/+7zTOYcY/pqJc96xlv2PdW4hwsIAEIslTDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yNeBWMF7BnD9wVwz2PgJsvWr77QiVvvWUvJF0+fqBug=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfpvObJ+tJBXSvqeN7vlOfmhYign635lciYAJIjUtY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dsen4NqjzVGjpjufiTMs3+gqeD09EbnuogPgxrJECwg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pxCWVM3sn19NsFEpgHbgLa+PmYlhN3mMiP0Wk8kJhYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q11KNvJszjYIB9n9HcC+N4uz11a3eRj1L3BH9scKMDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A1PmkgcEToWh1JiVWE6mI5jUu7poxWWuCUt/cgRUUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qJo3Hu4PJeanL7XEaWXO/n3YsodhZyd+MJOOmB9Kpd8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BkBKLO8URFscfRY9Bav/1+L9mLohDgNr/MkZtGiraIs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rZq5WA3Hx3xthOyHAJXK//f8pE2qbz7YKu3TIMp9GFY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X07a/Lm80p5xd4RFs1dNmw+90tmPDPdGiAKVZkxd4zY=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2FIZh/9N+NeJEQwxYIX5ikQT85xJzulBNReXk8PnG/s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I93Md7QNPGmEEGYU1+VVCqBPBEvXdqHPtTJtMOn06Yk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "GecBFQ1PemlECWZWCl7f74vmsL6eB6mzQ9n6tK6FYfs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QpjhZl+O1ORifgtCZuWAdcP6OKL7IZ2cA46v8FJcV28=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FWXI/yZ1M+2fIboeMCDMlp+I2NwPQDtoM/wWselOPYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uk26nvN/LdRLaBphiBgIZzT0sSpoO1z0RdDWRm/xrSA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hiiYSH1KZovAULc7rlmEU74wCjzDR+mm6ZnsgvFQjMw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hRzvMvWPX0sJme+wck67lwbKDFaWOa+Eyef+JSdc1s4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PSx5D+zqC9c295dguX4+EobT4IEzfffdfjzC8DWpB5Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QzfXQCVTjPQv2h21v95HYPq8uCsVJ2tPnjv79gAaM9M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XcGDO/dlTcEMLqwcm55UmOqK+KpBmbzZO1LIzX7GPaQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Lf+o4E7YB5ynzUPC6KTyW0lj6Cg9oLIu1Sdd1ODHctA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wAuVn02LAVo5Y+TUocvkoenFYWzpu38k0NmGZOsAjS4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yJGDtveLbbo/0HtCtiTSsvVI/0agg/U1bFaQ0yhK12o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KsEy0zgYcmkM+O/fWF9z3aJGIk22XCk+Aw96HB6JU68=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "p+AnMI5ZxdJMSIEJmXXya+FeH5yubmOdViwUO89j0Rc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/jLix56jzeywBtNuGw55lCXyebQoSIhbful0hOKxKDY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fvDvSPomtJsl1S3+8/tzFCE8scHIdJY5hB9CdTEsoFo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "oV5hOJzPXxfTuRdKIlF4uYEoMDuqH+G7/3qgndDr0PM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "3ALwcvLj3VOfgD6OqXAO13h1ZkOv46R6+Oy6SUKh53I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gxaB9FJj0IM+InhvAjwWaex3UIZ9SAnDiUd5WHSY/l0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "66NPvDygJzKJqddfNuDuNOpvGajjFRtvhkwfUkiYmXw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1dWcQIocRAcO9XnXYqbhl83jc0RgjQpsrWd8dC27trg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "npos0Uf1DT3ztSCjPVY9EImlRnTHB1KLrvmVSqBQ/8E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "TEI9qBx/tK1l1H0v1scMG8Srmtwo5VxWHADPBSlWrXk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "3wUN2ypQKoj+5ASkeIK9ycxhahVxyTmGopigoUAlyYs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o/oksSnUS+nIq6ozWTbB5bJh+NoaPj8deAA23uxiWCk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KExYPruhA31e8xuSwvfUfDcyY/H2Va6taUd0k4yFgLc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/x+dNfxdd/lkx8Z8VZVfoYl7LPoaZ/iKEzZXBrAtIJc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DE4cmjFLPqZlmRomO0qQiruUBtzoCe8ZdNRcfNH92pU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M6EKNcLPw/iojAChgYUSieaBYWcbsjKtB94SaHOr8vk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+qP49lDPeyhaduTvXJgtJEqHNEYANVu9Bg3Bxz7Td9w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ruMrC2VIS+VKbJwCFb3bfkaLTju9nE+yPONV9s0M0Vo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EbjDlSB5JKnDKff4d8hOmaOwJ7B9Q6NQFisLj+DPC+0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "C/yYOTB94edyqAbiQNu8/H7FoG3yRRjHDkMykz4+Mv0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CBxqrejG+qQQq2YTd6iP/06kiu2CxxzBFaZK3Ofb1CM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2ZOQ/fpho+AbDENWBZaln7wRoepIRdhyT648dr8O5cU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EghIgEPz01+myPgj8oid+PgncvobvC7vjvG3THEEQ0M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "92CysZYNF8riwAMhdrIPKxfODw9p07cKQy/Snn8XmVY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VO0LeTBQmsEf7sCHzTnZwUPNTqRZ49R8V5E9XnZ/5N4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "exs8BQMJq7U6ZXYgIizT7XN+X/hOmmn4YEuzev9zgSI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qHpS4k1I+gPniNp4CA8TY8lLN36vBYmgbKMFpbYMEqg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+7lWKCKAWFw6gPZdHE6E8KIfI14/fSvtWUmllb5WLi0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YiH/US0q6679hWblFDDKNqUjCgggoU8sUCssTIF1QbU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YgwkKElEubNfvXL9hJxzqQUQtHiXN/OCGxNL1MUZZlM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hZFST4INZTTuhvJlGJeMwlUAK270UCOTCDeBAnN4a7g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "24I1Zw35AuGnK3CqJhbCwYb0IPuu5sCRrM5iyeITOLc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vgD12JB4Q1S/kGPSQ1KOgp386KnG1GbM/5+60oRGcGw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+wNE+OL+CB9d4AUJdVxd56jUJCAXmmk9fapuB2TAc4g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uhQh1B2Pe4RkNw/kPEcgaLenuikKoRf1iyfZhpXdodc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "eu8gjAUIp8ybO204AgeOq5v1neI1yljqy5v3I6lo1lM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7QG6oVbASBAjrnCPxzzUNnuFSFNlKhbuBafkF8pr7Is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PUS1xb2oHSDTdYltutoSSxBiJ1NjxH3l2kA4P1CZLEs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XPMh/JDC/O93gJJCwwgJDb8ssWZvRvezNmKmyn3nIfk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jWz+KGwMk/GOvFAK2rOxF3OjxeZAWfmUQ1HGJ7icw4A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o7XbW68pc6flYigf3LW4WAGUWxpeqxaQLkHUhUR9RZ8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "nqR+g60+5U0okbqJadSqGgnC+j1JcP8rwMcfzOs2ACI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Hz43qVK95tSfbYFtaE/8fE97XMk1RiO8XpWjwZHB80o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "noZUWlZ8M6KXU5rkifyo8/duw5IL7/fXbJvT7bNmW9k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WONVHCuPSanXDRQQ/3tmyJ0Vq+Lu/4hRaMUf0g0kSuw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UEaj6vQRoIghE8Movd8AGXhtwIOXlP4cBsECIUvE5Y8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "D3n2YcO8+PB4C8brDo7kxKjF9Y844rVkdRMLTgsQkrw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "C+YA0G9KjxZVaWwOMuh/dcnHnHAlYnbFrRl0IEpmsY0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rUnmbmQanxrbFPYYrwyQ53x66OSt27yAvF+s48ezKDc=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Correctness.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Correctness.json deleted file mode 100644 index 117e56af6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Correctness.json +++ /dev/null @@ -1,1158 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "Find with $gt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$numberDouble": "0.0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$gte": { - "$numberDouble": "0.0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$numberDouble": "1.0" - } - } - } - }, - "result": [] - } - ] - }, - { - "description": "Find with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$lt": { - "$numberDouble": "1.0" - } - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - ] - } - ] - }, - { - "description": "Find with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$lte": { - "$numberDouble": "1.0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$numberDouble": "0.0" - }, - "$lt": { - "$numberDouble": "2.0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - ] - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$in": [ - { - "$numberDouble": "0.0" - } - ] - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoubleNoPrecision": { - "$gte": { - "$numberDouble": "0.0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$numberDouble": "1.0" - } - } - } - } - ] - }, - "result": [] - } - ] - }, - { - "description": "Aggregate with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoubleNoPrecision": { - "$lt": { - "$numberDouble": "1.0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoubleNoPrecision": { - "$lte": { - "$numberDouble": "1.0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$numberDouble": "0.0" - }, - "$lt": { - "$numberDouble": "2.0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - ] - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoubleNoPrecision": { - "$in": [ - { - "$numberDouble": "0.0" - } - ] - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0.0" - } - } - ] - } - ] - }, - { - "description": "Wrong type: Insert Int", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberInt": "0" - } - } - }, - "result": { - "errorContains": "cannot encrypt element" - } - } - ] - }, - { - "description": "Wrong type: Find Int", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$gte": { - "$numberInt": "0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": { - "errorContains": "field type is not supported" - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Delete.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Delete.json deleted file mode 100644 index 40d8ed5bb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Delete.json +++ /dev/null @@ -1,727 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Double. Delete.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1" - } - } - } - }, - { - "name": "deleteOne", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$numberDouble": "0" - } - } - } - }, - "result": { - "deletedCount": 1 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "delete": "default", - "deletes": [ - { - "q": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$binary": { - "base64": "DYckAAADcGF5bG9hZABXJAAABGcAQyQAAAMwAH0AAAAFZAAgAAAAAHgYoMGjEE6fAlAhICv0+doHcVX8CmMVxyq7+jlyGrvmBXMAIAAAAAC/5MQZgTHuIr/O5Z3mXPvqrom5JTQ8IeSpQGhO9sB+8gVsACAAAAAAuPSXVmJUAUpTQg/A9Bu1hYczZF58KEhVofakygbsvJQAAzEAfQAAAAVkACAAAAAA2kiWNvEc4zunJ1jzvuClFC9hjZMYruKCqAaxq+oY8EAFcwAgAAAAACofIS72Cm6s866UCk+evTH3CvKBj/uZd72sAL608rzTBWwAIAAAAADuCQ/M2xLeALF0UFZtJb22QGOhHmJv6xoO+kZIHcDeiAADMgB9AAAABWQAIAAAAABkfoBGmU3hjYBvQbjNW19kfXneBQsQQPRfUL3UAwI2cAVzACAAAAAAUpK2BUOqX/DGdX5YJniEZMWkofxHqeAbXceEGJxhp8AFbAAgAAAAAKUaLzIldNIZv6RHE+FwbMjzcNHqPESwF/37mm43VPrsAAMzAH0AAAAFZAAgAAAAAFNprhQ3ZwIcYbuzLolAT5n/vc14P9kUUQComDu6eFyKBXMAIAAAAAAcx9z9pk32YbPV/sfPZl9ALIEVsqoLXgqWLVK/tP+heAVsACAAAAAA/qxvuvJbAHwwhfrPVpmCFzNvg2cU/NXaWgqgYUZpgXwAAzQAfQAAAAVkACAAAAAAODI+pB2pCuB+YmNEUAgtMfNdt3DmSkrJ96gRzLphgb8FcwAgAAAAAAT7dewFDxUDECQ3zVq75/cUN4IP+zsqhkP5+czUwlJIBWwAIAAAAACFGeOtd5zBXTJ4JYonkn/HXZfHipUlqGwIRUcH/VTatwADNQB9AAAABWQAIAAAAACNAk+yTZ4Ewk1EnotQK8O3h1gg9I7pr9q2+4po1iJVgAVzACAAAAAAUj/LesmtEsgqYVzMJ67umVA11hJTdDXwbxDoQ71vWyUFbAAgAAAAABlnhpgTQ0WjLb5u0b/vEydrCeFjVynKd7aqb+UnvVLeAAM2AH0AAAAFZAAgAAAAAD/FIrGYFDjyYmVb7oTMVwweWP7A6F9LnyIuNO4MjBnXBXMAIAAAAACIZgJCQRZu7NhuNMyOqCn1tf+DfU1qm10TPCfj5JYV3wVsACAAAAAA5hmY4ptuNxULGf87SUFXQWGAONsL9U29duh8xqsHtxoAAzcAfQAAAAVkACAAAAAAciRW40ORJLVwchOEpz87Svb+5toAFM6LxDWv928ECwQFcwAgAAAAAN0dipyESIkszfjRzdDi8kAGaa2Hf4wrPAtiWwboZLuxBWwAIAAAAAANr4o/+l1OIbbaX5lZ3fQ/WIeOcEXjNI1F0WbSgQrzaQADOAB9AAAABWQAIAAAAACZqAyCzYQupJ95mrBJX54yIz9VY7I0WrxpNYElCI4dTQVzACAAAAAA/eyJb6d1xfE+jJlVXMTD3HS/NEYENPVKAuj56Dr2dSEFbAAgAAAAANkSt154Or/JKb31VvbZFV46RPgUp8ff/hcPORL7PpFBAAM5AH0AAAAFZAAgAAAAAI5bm3YO0Xgf0VT+qjVTTfvckecM3Cwqj7DTKZXf8/NXBXMAIAAAAAD/m+h8fBhWaHm6Ykuz0WX1xL4Eme3ErLObyEVJf8NCywVsACAAAAAAfb1VZZCqs2ivYbRzX4p5CtaCkKW+g20Pr57FWXzEZi8AAzEwAH0AAAAFZAAgAAAAANqo4+p6qdtCzcB4BX1wQ6llU7eFBnuu4MtZwp4B6mDlBXMAIAAAAAAGiz+VaukMZ+6IH4jtn4KWWdKK4/W+O+gRioQDrfzpMgVsACAAAAAAG4YYkTp80EKo59mlHExDodRQFR7njhR5dmISwUJ6ukAAAzExAH0AAAAFZAAgAAAAAPrFXmHP2Y4YAm7b/aqsdn/DPoDkv7B8egWkfe23XsM1BXMAIAAAAAAGhwpKAr7skeqHm3oseSbO7qKNhmYsuUrECBxJ5k+D2AVsACAAAAAAAqPQi9luYAu3GrFCEsVjd9z2zIDcp6SPTR2w6KQEr+IAAzEyAH0AAAAFZAAgAAAAABzjYxwAjXxXc0Uxv18rH8I3my0Aguow0kTwKyxbrm+cBXMAIAAAAADVbqJVr6IdokuhXkEtXF0C2gINLiAjMVN20lE20Vmp2QVsACAAAAAAD7K1Fx4gFaaizkIUrf+EGXQeG7QX1jadhGc6Ji471H8AAzEzAH0AAAAFZAAgAAAAAFMm2feF2fFCm/UC6AfIyepX/xJDSmnnolQIBnHcPmb5BXMAIAAAAABLI11kFrQoaNVZFmq/38aRNImPOjdJh0Lo6irI8M/AaAVsACAAAAAAOWul0oVqJ9CejD2RqphhTC98DJeRQy5EwbNerU2+4l8AAzE0AH0AAAAFZAAgAAAAAJvXB3KyNiNtQko4SSzo/9b2qmM2zU9CQTTDfLSBWMgRBXMAIAAAAAAvjuVP7KsLRDeqVqRziTKpBrjVyqKiIbO9Gw8Wl2wFTAVsACAAAAAADlE+oc1ins+paNcaOZJhBlKlObDJ4VQORWjFYocM4LgAAzE1AH0AAAAFZAAgAAAAAPGdcxDiid8z8XYnfdDivNMYVPgBKdGOUw6UStU+48CdBXMAIAAAAAARj6g1Ap0eEfuCZ4X2TsEw+Djrhto3fA5nLwPaY0vCTgVsACAAAAAAoHqiwGOUkBu8SX5U1yHho+UIFdSN2MdQN5s6bQ0EsJYAAzE2AH0AAAAFZAAgAAAAAP5rGPrYGt3aKob5f/ldP0qrW7bmWvqnKY4QwdDWz400BXMAIAAAAADTQkW2ymaaf/bhteOOGmSrIR97bAnJx+yN3yMj1bTeewVsACAAAAAADyQnHGH2gF4w4L8axUsSTf6Ubk7L5/eoFOJk12MtZAoAAzE3AH0AAAAFZAAgAAAAAAlz6wJze5UkIxKpJOZFGCOf3v2KByWyI6NB6JM9wNcBBXMAIAAAAABUC7P/neUIHHoZtq0jFVBHY75tSFYr1Y5S16YN5XxC1QVsACAAAAAAgvxRbXDisNnLY3pfsjDdnFLtkvYUC4lhA68eBXc7KAwAAzE4AH0AAAAFZAAgAAAAAFJ8AtHcjia/9Y5pLEc3qVgH5xKiXw12G9Kn2A1EY8McBXMAIAAAAAAxe7Bdw7eUSBk/oAawa7uicTEDgXLymRNhBy1LAxhDvwVsACAAAAAAxKPaIBKVx3jTA+R/el7P7AZ7efrmTGjJs3Hj/YdMddwAAzE5AH0AAAAFZAAgAAAAAO8uwQUaKFb6vqR3Sv3Wn4QAonC2exOC9lGG1juqP5DtBXMAIAAAAABZf1KyJgQg8/Rf5c02DgDK2aQu0rNCOvaL60ohDHyY+gVsACAAAAAAqyEjfKC8lYoIfoXYHUqHZPoaA6EK5BAZy5dxXZmay4kAAzIwAH0AAAAFZAAgAAAAAE8YtqyRsGCeiR6hhiyisR/hccmK4nZqIMzO4lUBmEFzBXMAIAAAAAC1UYOSKqAeG1UJiKjWFVskRhuFKpj9Ezy+lICZvFlN5AVsACAAAAAA6Ct9nNMKyRazn1OKnRKagm746CGu+jyhbL1qJnZxGi0AAzIxAH0AAAAFZAAgAAAAAPhCrMausDx1QUIEqp9rUdRKyM6a9AAx7jQ3ILIu8wNIBXMAIAAAAACmH8lotGCiF2q9VQxhsS+7LAZv79VUAsOUALaGxE/EpAVsACAAAAAAnc1xCKfdvbUEc8F7XZqlNn1C+hZTtC0I9I3LL06iaNkAAzIyAH0AAAAFZAAgAAAAAOBi/GAYFcstMSJPgp3VkMiuuUUCrZytvqYaU8dwm8v2BXMAIAAAAACEZSZVyD3pKzGlbdwlYmWQhHHTV5SnNLknl2Gw8IaUTQVsACAAAAAAfsLZsEDcWSuNsIo/TD1ReyQW75HPMgmuKZuWFOLKRLoAAzIzAH0AAAAFZAAgAAAAAIQuup+YGfH3mflzWopN8J1X8o8a0d9CSGIvrA5HOzraBXMAIAAAAADYvNLURXsC2ITMqK14LABQBI+hZZ5wNf24JMcKLW+84AVsACAAAAAACzfjbTBH7IwDU91OqLAz94RFkoqBOkzKAqQb55gT4/MAAzI0AH0AAAAFZAAgAAAAAKsh0ADyOnVocFrOrf6MpTrNvAj8iaiE923DPryu124gBXMAIAAAAADg24a8NVE1GyScc6tmnTbmu5ulzO+896fE92lN08MeswVsACAAAAAAaPxcOIxnU7But88/yadOuDJDMcCywwrRitaxMODT4msAAzI1AH0AAAAFZAAgAAAAAKkVC2Y6HtRmv72tDnPUSjJBvse7SxLqnr09/Uuj9sVVBXMAIAAAAABYNFUkH7ylPMN+Bc3HWX1e0flGYNbtJNCY9SltJCW/UAVsACAAAAAAZYK/f9H4OeihmpiFMH7Wm7uLvs2s92zNA8wyrNZTsuMAAzI2AH0AAAAFZAAgAAAAADDggcwcb/Yn1Kk39sOHsv7BO/MfP3m/AJzjGH506Wf9BXMAIAAAAAAYZIsdjICS0+BDyRUPnrSAZfPrwtuMaEDEn0/ijLNQmAVsACAAAAAAGPnYVvo2ulO9z4LGd/69NAklfIcZqZvFX2KK0s+FcTUAAzI3AH0AAAAFZAAgAAAAAEWY7dEUOJBgjOoWVht1wLehsWAzB3rSOBtLgTuM2HC8BXMAIAAAAAAAoswiHRROurjwUW8u8D5EUT+67yvrgpB/j6PzBDAfVwVsACAAAAAA6NhRTYFL/Sz4tao7vpPjLNgAJ0FX6P/IyMW65qT6YsMAAzI4AH0AAAAFZAAgAAAAAPZaapeAUUFPA7JTCMOWHJa9lnPFh0/gXfAPjA1ezm4ZBXMAIAAAAACmJvLY2nivw7/b3DOKH/X7bBXjJwoowqb1GtEFO3OYgAVsACAAAAAA/JcUoyKacCB1NfmH8vYqC1f7rd13KShrQqV2r9QBP44AAzI5AH0AAAAFZAAgAAAAAK00u6jadxCZAiA+fTsPVDsnW5p5LCr4+kZZZOTDuZlfBXMAIAAAAAAote4zTEYMDgaaQbAdN8Dzv93ljPLdGjJzvnRn3KXgtQVsACAAAAAAxXd9Mh6R3mnJy8m7UfqMKi6oD5DlZpkaOz6bEjMOdiwAAzMwAH0AAAAFZAAgAAAAAFbgabdyymiEVYYwtJSWa7lfl/oYuj/SukzJeDOR6wPVBXMAIAAAAADAFGFjS1vPbN6mQEhkDYTD6V2V23Ys9gUEUMGNvMPkaAVsACAAAAAAL/D5Sze/ZoEanZLK0IeEkhgVkxEjMWVCfmJaD3a8uNIAAzMxAH0AAAAFZAAgAAAAABNMR6UBv2E627CqLtQ/eDYx7OEwQ7JrR4mSHFa1N8tLBXMAIAAAAAAxH4gucI4UmNVB7625C6hFSVCuIpJO3lusJlPuL8H5EQVsACAAAAAAVLHNg0OUVqZ7WGOP53BkTap9FOw9dr1P4J8HxqFqU04AAzMyAH0AAAAFZAAgAAAAAG8cd6WBneNunlqrQ2EmNf35W7OGObGq9WL4ePX+LUDmBXMAIAAAAAAjJ2+sX87NSis9hBsgb1QprVRnO7Bf+GObCGoUqyPE4wVsACAAAAAAs9c9SM49/pWmyUQKslpt3RTMBNSRppfNO0JBvUqHPg0AAzMzAH0AAAAFZAAgAAAAAFWOUGkUpy8yf6gB3dio/aOfRKh7XuhvsUj48iESFJrGBXMAIAAAAAAY7sCDMcrUXvNuL6dO0m11WyijzXZvPIcOKob6IpC4PQVsACAAAAAAJOP+EHz6awDb1qK2bZQ3kTV7wsj5Daj/IGAWh4g7omAAAzM0AH0AAAAFZAAgAAAAAGUrIdKxOihwNmo6B+aG+Ag1qa0+iqdksHOjQj+Oy9bZBXMAIAAAAABwa5dbI2KmzBDNBTQBEkjZv4sPaeRkRNejcjdVymRFKQVsACAAAAAA4ml/nm0gJNTcJ4vuD+T2Qfq2fQZlibJp/j6MOGDrbHMAAzM1AH0AAAAFZAAgAAAAAOx89xV/hRk64/CkM9N2EMK6aldII0c8smdcsZ46NbP8BXMAIAAAAADBF6tfQ+7q9kTuLyuyrSnDgmrdmrXkdhl980i1KHuGHgVsACAAAAAACUqiFqHZdGbwAA+hN0YUE5zFg+H+dabIB4dj5/75W/YAAzM2AH0AAAAFZAAgAAAAAMkN0L1oQWXhjwn9rAdudcYeN8/5VdCKU8cmDt7BokjsBXMAIAAAAAAT62pGXoRwExe9uvgYOI0hg5tOxilrWfoEmT0SMglWJwVsACAAAAAAlVz4dhiprSbUero6JFfxzSJGclg63oAkAmgbSwbcYxIAAzM3AH0AAAAFZAAgAAAAANxfa4xCoaaB7k1C1RoH1LBhsCbN2yEq15BT9b+iqEC4BXMAIAAAAACAX9LV8Pemfw7NF0iB1/85NzM1Ef+1mUfyehacUVgobQVsACAAAAAAVq4xpbymLk0trPC/a2MvB39I7hRiX8EJsVSI5E5hSBkAAzM4AH0AAAAFZAAgAAAAAOYIYoWkX7dGuyKfi3XssUlc7u/gWzqrR9KMkikKVdmSBXMAIAAAAABVF2OYjRTGi9Tw8XCAwZWLpX35Yl271TlNWp6N/nROhAVsACAAAAAA0nWwYzXQ1+EkDvnGq+SMlq20z+j32Su+i/A95SggPb4AAzM5AH0AAAAFZAAgAAAAAIy0+bXZi10QC+q7oSOLXK5Fee7VEk/qHSXukfeVIfgzBXMAIAAAAAAQ3IIV/JQCHW95AEbH5zGIHtJqyuPjWPMIZ+VmQHlxEwVsACAAAAAAp0jYsyohKv9Pm+4k+DplEGbl9WLZpAJzitrcDj4CNsMAAzQwAH0AAAAFZAAgAAAAAL5SOJQ3LOhgdXJ5v086NNeAl1qonQnchObdpZJ1kHeEBXMAIAAAAAA+tEqTXODtik+ydJZSnUqXF9f18bPeze9eWtR7ExZJgQVsACAAAAAAbrkZCVgB9Qsp4IAbdf+bD4fT6Boqk5UtuA/zhNrh1y0AAzQxAH0AAAAFZAAgAAAAAKl8zcHJRDjSjJeV/WvMxulW1zrTFtaeBy/aKKhadc6UBXMAIAAAAADBdWQl5SBIvtZZLIHszePwkO14W1mQ0izUk2Ov21cPNAVsACAAAAAAHErCYycpqiIcCZHdmPL1hi+ovLQk4TAvENpfLdTRamQAAzQyAH0AAAAFZAAgAAAAAFvotcNaoKnVt5CBCOPwjexFO0WGWuaIGL6H/6KSau+6BXMAIAAAAAD2y2mBN5xPu5PJoY2zcr0GnQDtHRBogA5+xzIxccE9fwVsACAAAAAAdS34xzJesnUfxLCcc1U7XzUqLy8MAzV/tcjbqaD3lkMAAzQzAH0AAAAFZAAgAAAAAPezU0/vNT4Q4YKbTbaeHqcwNLT+IjW/Y9QFpIooihjPBXMAIAAAAACj2x4O4rHter8ZnTws5LAP9jJ/6kk9C/V3vL50LoFZHAVsACAAAAAAQdBDF3747uCVP5lB/zr8VmzxJfTSZHBKeIgm5FyONXwAAzQ0AH0AAAAFZAAgAAAAAMqpayM2XotEFmm0gwQd9rIzApy0X+7HfOhNk6VU7F5lBXMAIAAAAACJR9+q5T9qFHXFNgGbZnPubG8rkO6cwWhzITQTmd6VgwVsACAAAAAAOZLQ6o7e4mVfDzbpQioa4d3RoTvqwgnbmc5Qh2wsZuoAAzQ1AH0AAAAFZAAgAAAAANCeyW+3oebaQk+aqxNVhAcT/BZ5nhsTVdKS3tMrLSvWBXMAIAAAAADxRFMDhkyuEc++WnndMfoUMLNL7T7rWoeblcrpSI6soQVsACAAAAAAdBuBMJ1lxt0DRq9pOZldQqchLs3B/W02txcMLD490FEAAzQ2AH0AAAAFZAAgAAAAAIbo5YBTxXM7HQhl7UP9NNgpPGFkBx871r1B65G47+K8BXMAIAAAAAC21dJSxnEhnxO5gzN5/34BL4von45e1meW92qowzb8fQVsACAAAAAAm3Hk2cvBN0ANaR5jzeZE5TsdxDvJCTOT1I01X7cNVaYAAzQ3AH0AAAAFZAAgAAAAABm/6pF96j26Jm7z5KkY1y33zcAEXLx2n0DwC03bs/ixBXMAIAAAAAD01OMvTZI/mqMgxIhA5nLs068mW+GKl3OW3ilf2D8+LgVsACAAAAAAaLvJDrqBESTNZSdcXsd+8GXPl8ZkUsGpeYuyYVv/kygAAzQ4AH0AAAAFZAAgAAAAAJ/D3+17gaQdkBqkL2wMwccdmCaVOtxzIkM8VyI4xI5zBXMAIAAAAAAggLVmkc5u+YzBR+oNE+XgLVp64fC6MzUb/Ilu/Jsw0AVsACAAAAAACz3HVKdWkx82/kGbVpcbAeZtsj2R5Zr0dEPfle4IErkAAzQ5AH0AAAAFZAAgAAAAAJMRyUW50oaTzspS6A3TUoXyC3gNYQoShUGPakMmeVZrBXMAIAAAAACona2Pqwt4U2PmFrtmu37jB9kQ/12okyAVtYa8TQkDiQVsACAAAAAAltJJKjCMyBTJ+4PkdDCPJdeX695P8P5h7WOZ+kmExMAAAzUwAH0AAAAFZAAgAAAAAByuYl8dBvfaZ0LO/81JW4hYypeNmvLMaxsIdvqMPrWoBXMAIAAAAABNddwobOUJzm9HOUD8BMZJqkNCUCqstHZkC76FIdNg9AVsACAAAAAAQQOkIQtkyNavqCnhQbNg3HfqrJdsAGaoxSJePJl1qXsAAzUxAH0AAAAFZAAgAAAAAHEzLtfmF/sBcYPPdj8867VmmQyU1xK9I/3Y0478azvABXMAIAAAAAAcmyFajZPnBTbO+oLInNwlApBocUekKkxz2hYFeSlQ+gVsACAAAAAAZ6IkrOVRcC8vSA6Vb4fPWZJrYexXhEabIuYIeXNsCSgAAzUyAH0AAAAFZAAgAAAAAJam7JYsZe2cN20ZYm2W3v1pisNt5PLiniMzymBLWyMtBXMAIAAAAABxCsKVMZMTn3n+R2L7pVz5nW804r8HcK0mCBw3jUXKXAVsACAAAAAA7j3JGnNtR64P4dJLeUoScFRGfa8ekjh3dvhw46sRFk0AAzUzAH0AAAAFZAAgAAAAAMXrXx0saZ+5gORmwM2FLuZG6iuO2YS+1IGPoAtDKoKBBXMAIAAAAADIQsxCr8CfFKaBcx8kIeSywnGh7JHjKRJ9vJd9x79y7wVsACAAAAAAcvBV+SykDYhmRFyVYwFYB9oBKBSHr55Jdz2cXeowsUQAAzU0AH0AAAAFZAAgAAAAACbzcUD3INSnCRspOKF7ubne74OK9L0FTZvi9Ay0JVDYBXMAIAAAAADPebVQH8Btk9rhBIoUOdSAdpPvz7qIY4UC2i6IGisSAQVsACAAAAAAiBunJi0mPnnXdnldiq+If8dcb/n6apHnaIFt+oyYO1kAAzU1AH0AAAAFZAAgAAAAACUc2CtD1MK/UTxtv+8iA9FoHEyTwdl43HKeSwDw2Lp5BXMAIAAAAACCIduIdw65bQMzRYRfjBJj62bc69T4QqH4QoWanwlvowVsACAAAAAAM0TV7S+aPVVzJOQ+cpSNKHTwyQ0mWa8tcHzfk3nR+9IAAzU2AH0AAAAFZAAgAAAAAHSaHWs/dnmI9sc7nB50VB2Bzs0kHapMHCQdyVEYY30TBXMAIAAAAACkV22lhEjWv/9/DubfHBAcwJggKI5mIbSK5L2nyqloqQVsACAAAAAAS19m7DccQxgryOsBJ3GsCs37yfQqNi1G+S6fCXpEhn4AAzU3AH0AAAAFZAAgAAAAAAL8jhNBG0KXXZhmZ0bPXtfgapJCB/AI+BEHB0eZ3C75BXMAIAAAAADHx/fPa639EBmGV5quLi8IQT600ifiKSOhTDOK19DnzwVsACAAAAAAlyLTDVkHxbayklD6Qymh3odIK1JHaOtps4f4HR+PcDgAAzU4AH0AAAAFZAAgAAAAAAxgeclNl09H7HvzD1oLwb2YpFca5eaX90uStYXHilqKBXMAIAAAAACMU5pSxzIzWlQxHyW170Xs9EhD1hURASQk+qkx7K5Y6AVsACAAAAAAJbMMwJfNftA7Xom8Bw/ghuZmSa3x12vTZxBUbV8m888AAzU5AH0AAAAFZAAgAAAAABmO7QD9vxWMmFjIHz13lyOeV6vHT6mYCsWxF7hb/yOjBXMAIAAAAACT9lmgkiqzuWG24afuzYiCeK9gmJqacmxAruIukd0xEAVsACAAAAAAZa0/FI/GkZR7CtX18Xg9Tn9zfxkD0UoaSt+pIO5t1t4AAzYwAH0AAAAFZAAgAAAAAB89SjLtDJkqEghRGyj6aQ/2qvWLNuMROoXmzbYbCMKMBXMAIAAAAAC8sywgND+CjhVTF6HnRQeay8y9/HnVzDI42dEPah28LQVsACAAAAAAoxv7UKh0RqUAWcOsQvU123zO1qZn73Xfib0qncZCB34AAzYxAH0AAAAFZAAgAAAAABN2alGq9Aats1mwERNGwL/fIwZSvVCe9/8XMHTFlpUpBXMAIAAAAACuDPjJgvvbBYhbLpjMiWUCsVppiYrhvR+yMysNPN8cZAVsACAAAAAAKpADjc4bzIZMi9Q/+oe0EMRJHYQt6dlo1x/lRquagqkAAzYyAH0AAAAFZAAgAAAAAL8YB6VAqGBiWD4CBv16IBscg5J7VQCTZu87n6pj+86KBXMAIAAAAAAmxm8e68geeyAdUjSMWBHzUjneVB0pG9TBXIoE6467hAVsACAAAAAAV76JZAlYpgC/Zl8awx2ArCg1uuyy2XVTSkp0wUMi/7UAAzYzAH0AAAAFZAAgAAAAAL4yLkCTV5Dmxa5toBu4JT8ge/cITAaURIOuFuOtFUkeBXMAIAAAAAAXoFNQOMGkAj7qEJP0wQafmFSXgWGeorDVbwyOxWLIsgVsACAAAAAAc4Un6dtIFe+AQ+RSfNWs3q63RTHhmyc+5GKRRdpWRv8AAzY0AH0AAAAFZAAgAAAAAEU8DoUp46YtYjNFS9kNXwdYxQ9IW27vCTb+VcqqfnKNBXMAIAAAAADe7vBOgYReE8X78k5ARuUnv4GmzPZzg6SbConf4L2G3wVsACAAAAAA78YHWVkp6HbZ0zS4UL2z/2pj9vPDcMDt7zTv6NcRsVsAAzY1AH0AAAAFZAAgAAAAAPa4yKTtkUtySuWo1ZQsp2QXtPb5SYqzA5vYDnS1P6c0BXMAIAAAAADKnF58R1sXlHlsHIvCBR3YWW/qk54z9CTDhZydkD1cOQVsACAAAAAAHW3ERalTFWKMzjuXF3nFh0pSrQxM/ojnPbPhc4v5MaQAAzY2AH0AAAAFZAAgAAAAAN5WJnMBmfgpuQPyonmY5X6OdRvuHw4nhsnGRnFAQ95VBXMAIAAAAACwftzu7KVV1rmGKwXtJjs3cJ1gE3apr8+N0SAg1F2cHwVsACAAAAAATDW0reyaCjbJuVLJzbSLx1OBuBoQu+090kgW4RurVacAAzY3AH0AAAAFZAAgAAAAACHvDsaPhoSb6DeGnKQ1QOpGYAgK82qpnqwcmzSeWaJHBXMAIAAAAABRq3C5+dOfnkAHM5Mg5hPB3O4jhwQlBgQWLA7Ph5bhgwVsACAAAAAAqkC8zYASvkVrp0pqmDyFCkPaDmD/ePAJpMuNOCBhni8AAzY4AH0AAAAFZAAgAAAAAOBePJvccPMJmy515KB1AkXF5Pi8NOG4V8psWy0SPRP+BXMAIAAAAAB3dOJG9xIDtEKCRzeNnPS3bFZepMj8UKBobKpSoCPqpgVsACAAAAAAPG3IxQVOdZrr509ggm5FKizWWoZPuVtOgOIGZ3m+pdEAAzY5AH0AAAAFZAAgAAAAABUvRrDQKEXLMdhnzXRdhiL6AGNs2TojPky+YVLXs+JnBXMAIAAAAAD1kYicbEEcPzD4QtuSYQQWDPq8fuUWGddpWayKn3dT9QVsACAAAAAA9+Sf7PbyFcY45hP9oTfjQiOUS3vEIAT8C0vOHymwYSUAAzcwAH0AAAAFZAAgAAAAAOvSnpujeKNen4pqc2HR63C5s5oJ1Vf4CsbKoYQvkwl5BXMAIAAAAACw2+vAMdibzd2YVVNfk81yXkFZP0WLJ82JBxJmXnYE+QVsACAAAAAArQ/E1ACyhK4ZyLqH9mNkCU7WClqRQTGyW9tciSGG/EMAAzcxAH0AAAAFZAAgAAAAAAo0xfGG7tJ3GWhgPVhW5Zn239nTD3PadShCNRc9TwdNBXMAIAAAAADZh243oOhenu0s/P/5KZLBDh9ADqKHtSWcXpO9D2sIjgVsACAAAAAAlgTPaoQKz+saU8rwCT3UiNOdG6hdpjzFx9GBn08ZkBEAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "limit": 1 - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "delete" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6YrBn2ofIw1b5ooakrLOwF41BWrps8OO0H9WH4/rtlE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "n+XAuFnP8Dov9TnhGFxNx0K/MnVM9WbJ7RouEu0ndO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yRXojuVdn5GQtD97qYlaCL6cOLmZ7Cvcb3wFjkLUIdM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DuIkdRPITRs55I4SZmgomAHCIsDQmXRhW8+MOznkzSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SsBk+Et1lTbU+QRPx+xyJ/jMkmfG+QCvQEpip2YYrzA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "crCIzOd8KhHvvUlX7M1v9bhvU4pLdTc+X2SuqoKU5Ek=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YOWdCw4UrqnxkAaVjqmC4sKQDMVMHEpFGnlxpxdaU6E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M3SShp81Ff8tQ632qKbv9MUcN6wjDaBReI0VXNu6Xh4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gzHlSPxpM0hT75kQvWFzGlOxKvDoiKQZOr19V6l2zXI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s3JnppOGYw9SL2Q1kMAZs948v2F5PrpXjGei/HioDWs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cG6+3Gk/zEH68P/uuuwiAUVCuyJwa1LeV+t29FlPPAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dupdvR3AyJtM+g9NDKiaLVOtGca387JQp8w+V03m7Ig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JqEQc5svj2jTvZ6LLA5ivE+kTb/0aRemSEmxk4G7Zrg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "szcXXXKnob+p3SoM4yED2R920LeJ7cVsclPMFTe4CeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o1QoGVXmuBdHwHm7aCtGMlMVKrjFdYvJXpoq6uhIAZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Jfm5wPlqqLCJRGQIqRq2NGmpn7s0Vrih2H3YAOoI2YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zMHLb8ARbsYo8Ld05bqnGFf1Usha6EGb8QKwdSAyps0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yQdtq9lh5pugL7/i0Bj/PuZUUBUIzf+7wj1rl5y736w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wGWVZdO7qIuyDg/BqDgqjgoQ02h5YYgwXQB1oCin2NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "by9HMLj6NTEpgztZ5HSN6GxImkXPcaFINYDzgZY33X8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tWo0vbasi7bXmn/MsOx13VC1IsWtpx/nYp0uj4iMzdA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tQQpndUYd5O87lOtrGjH3wl9VsOK0ray7RMasL90sBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cQjXEDCMsOpKLLf+vlTgIHA+cbSJdzqhbSX9Wvh95aA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7yMpU48IxK9SzP2cx3VnTownGEwFmeFofuuFT97SuuY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kSOx1kz0CmBgzKQHZlo65ZUY1DIv9A99JRm+Us2y6Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubQpdPBe6/xvtr+AcXdfYLSvYCR4ot0tivehkCsupb4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xal+iCJ6FTefRQToyoNksc9NCZShyn04NDGi4IYrcoM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d7jU4iOK50xHxlkSifcxlZFCM46TSgQzoYivxG3HNLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJvl2nsBLBVzL3pp6sKWCL4UXeh3q/roYBJjSb74ve0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OIUCaKRvIx9t1w6Hxlz1IcQTdPNCfdRNwnnTm10W+X0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A9tvzsiElotOUVIB4CqfQp9mAwqvTM35YkmAR170aHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lI8gpK7hpb7c9x4RQugsxMnQay5LZJmwslZdvMx/dcE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dNCzh40U0XvdKnSDi3HRQOWQftEsDVqc4uUvsVFGoq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IP+iwEBWBwVVZIdpaMu8k5+soFCz+TZkYn3drKZ9grE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnqyh6e0y5svHkJDShlN9CHV0WvMBE4QbtJpQw5ZCXc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "elEl42tbVDoRTLjAhZUFEtXiut4b3PVhg/1ZLZSQdtE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vHuu2FxwclMHqyE6JBYbTYgbEkB0dqb/JuaxsvfwsmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xTf7NCe3Gf8QpE78HR5OknlLTKfs9J+RN9UZpH6fnso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XiWSasRnJAulGR6+LCVD3mwRObXylqYWR9jvpywq12c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MZMxEQ5ikx0PG1YFIExv0UnTZogsvgeOEZTpzvBDn4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yZMyMZBDrWbAhvnic7vvIYhmO9m5H2iuv0c8KNZrBzY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xxM14hTPY5j0vvcK2C7YAEjzdsfUTFHozHC0hEo1bxI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+01rqR1xVwkpGXcstbk1ItJqFVjH6Q8MGxEN3Cm9Y1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xOpLV0Z2VTRJ3iWtnWZcsyjXubTIkYWo31cO+HV1o1k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BWUOLqgLBqc5NwxVlSV5H3KFQPXbCp7mdo+jF+8cJqY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fuQb1S6xZDGlrEbK+kI23aL53PP1PVNwqICnZNt9Yzg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfscnoibFttahLdPVC4Ee+47ewGFKpDSU7M6HX19bKE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rpSW2awybNVeKtat91VFxqbINoTfNhPfQAu+d73Xtf8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9M/CP9ccOIIj2LLFmE0GFDO0Ban2wsNalEXfM6+h+1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WrEMG49l1ye4MhXs5ZS9tz8P6h+hDvthIg/2wW9ne1Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ImNhbfeyfH8qIEeA5ic0s3dAQBdzzTBS+CPsNih9vZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dWP33YDSn04UKJN2ogh2Rui0iW/0q2y18OCDRVcfyoo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lYv0isAtfGh6H9tdp3cp2eHU7q2J+uk7QrgcxtK3w7Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VGMoamB/+7zTOYcY/pqJc96xlv2PdW4hwsIAEIslTDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yNeBWMF7BnD9wVwz2PgJsvWr77QiVvvWUvJF0+fqBug=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfpvObJ+tJBXSvqeN7vlOfmhYign635lciYAJIjUtY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dsen4NqjzVGjpjufiTMs3+gqeD09EbnuogPgxrJECwg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pxCWVM3sn19NsFEpgHbgLa+PmYlhN3mMiP0Wk8kJhYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q11KNvJszjYIB9n9HcC+N4uz11a3eRj1L3BH9scKMDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A1PmkgcEToWh1JiVWE6mI5jUu7poxWWuCUt/cgRUUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qJo3Hu4PJeanL7XEaWXO/n3YsodhZyd+MJOOmB9Kpd8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BkBKLO8URFscfRY9Bav/1+L9mLohDgNr/MkZtGiraIs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rZq5WA3Hx3xthOyHAJXK//f8pE2qbz7YKu3TIMp9GFY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X07a/Lm80p5xd4RFs1dNmw+90tmPDPdGiAKVZkxd4zY=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-FindOneAndUpdate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-FindOneAndUpdate.json deleted file mode 100644 index f0893ce66..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-FindOneAndUpdate.json +++ /dev/null @@ -1,1137 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Double. FindOneAndUpdate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1" - } - } - } - }, - { - "name": "findOneAndUpdate", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$numberDouble": "0" - } - } - }, - "update": { - "$set": { - "encryptedDoubleNoPrecision": { - "$numberDouble": "2" - } - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1" - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "default", - "query": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$binary": { - "base64": "DYckAAADcGF5bG9hZABXJAAABGcAQyQAAAMwAH0AAAAFZAAgAAAAAHgYoMGjEE6fAlAhICv0+doHcVX8CmMVxyq7+jlyGrvmBXMAIAAAAAC/5MQZgTHuIr/O5Z3mXPvqrom5JTQ8IeSpQGhO9sB+8gVsACAAAAAAuPSXVmJUAUpTQg/A9Bu1hYczZF58KEhVofakygbsvJQAAzEAfQAAAAVkACAAAAAA2kiWNvEc4zunJ1jzvuClFC9hjZMYruKCqAaxq+oY8EAFcwAgAAAAACofIS72Cm6s866UCk+evTH3CvKBj/uZd72sAL608rzTBWwAIAAAAADuCQ/M2xLeALF0UFZtJb22QGOhHmJv6xoO+kZIHcDeiAADMgB9AAAABWQAIAAAAABkfoBGmU3hjYBvQbjNW19kfXneBQsQQPRfUL3UAwI2cAVzACAAAAAAUpK2BUOqX/DGdX5YJniEZMWkofxHqeAbXceEGJxhp8AFbAAgAAAAAKUaLzIldNIZv6RHE+FwbMjzcNHqPESwF/37mm43VPrsAAMzAH0AAAAFZAAgAAAAAFNprhQ3ZwIcYbuzLolAT5n/vc14P9kUUQComDu6eFyKBXMAIAAAAAAcx9z9pk32YbPV/sfPZl9ALIEVsqoLXgqWLVK/tP+heAVsACAAAAAA/qxvuvJbAHwwhfrPVpmCFzNvg2cU/NXaWgqgYUZpgXwAAzQAfQAAAAVkACAAAAAAODI+pB2pCuB+YmNEUAgtMfNdt3DmSkrJ96gRzLphgb8FcwAgAAAAAAT7dewFDxUDECQ3zVq75/cUN4IP+zsqhkP5+czUwlJIBWwAIAAAAACFGeOtd5zBXTJ4JYonkn/HXZfHipUlqGwIRUcH/VTatwADNQB9AAAABWQAIAAAAACNAk+yTZ4Ewk1EnotQK8O3h1gg9I7pr9q2+4po1iJVgAVzACAAAAAAUj/LesmtEsgqYVzMJ67umVA11hJTdDXwbxDoQ71vWyUFbAAgAAAAABlnhpgTQ0WjLb5u0b/vEydrCeFjVynKd7aqb+UnvVLeAAM2AH0AAAAFZAAgAAAAAD/FIrGYFDjyYmVb7oTMVwweWP7A6F9LnyIuNO4MjBnXBXMAIAAAAACIZgJCQRZu7NhuNMyOqCn1tf+DfU1qm10TPCfj5JYV3wVsACAAAAAA5hmY4ptuNxULGf87SUFXQWGAONsL9U29duh8xqsHtxoAAzcAfQAAAAVkACAAAAAAciRW40ORJLVwchOEpz87Svb+5toAFM6LxDWv928ECwQFcwAgAAAAAN0dipyESIkszfjRzdDi8kAGaa2Hf4wrPAtiWwboZLuxBWwAIAAAAAANr4o/+l1OIbbaX5lZ3fQ/WIeOcEXjNI1F0WbSgQrzaQADOAB9AAAABWQAIAAAAACZqAyCzYQupJ95mrBJX54yIz9VY7I0WrxpNYElCI4dTQVzACAAAAAA/eyJb6d1xfE+jJlVXMTD3HS/NEYENPVKAuj56Dr2dSEFbAAgAAAAANkSt154Or/JKb31VvbZFV46RPgUp8ff/hcPORL7PpFBAAM5AH0AAAAFZAAgAAAAAI5bm3YO0Xgf0VT+qjVTTfvckecM3Cwqj7DTKZXf8/NXBXMAIAAAAAD/m+h8fBhWaHm6Ykuz0WX1xL4Eme3ErLObyEVJf8NCywVsACAAAAAAfb1VZZCqs2ivYbRzX4p5CtaCkKW+g20Pr57FWXzEZi8AAzEwAH0AAAAFZAAgAAAAANqo4+p6qdtCzcB4BX1wQ6llU7eFBnuu4MtZwp4B6mDlBXMAIAAAAAAGiz+VaukMZ+6IH4jtn4KWWdKK4/W+O+gRioQDrfzpMgVsACAAAAAAG4YYkTp80EKo59mlHExDodRQFR7njhR5dmISwUJ6ukAAAzExAH0AAAAFZAAgAAAAAPrFXmHP2Y4YAm7b/aqsdn/DPoDkv7B8egWkfe23XsM1BXMAIAAAAAAGhwpKAr7skeqHm3oseSbO7qKNhmYsuUrECBxJ5k+D2AVsACAAAAAAAqPQi9luYAu3GrFCEsVjd9z2zIDcp6SPTR2w6KQEr+IAAzEyAH0AAAAFZAAgAAAAABzjYxwAjXxXc0Uxv18rH8I3my0Aguow0kTwKyxbrm+cBXMAIAAAAADVbqJVr6IdokuhXkEtXF0C2gINLiAjMVN20lE20Vmp2QVsACAAAAAAD7K1Fx4gFaaizkIUrf+EGXQeG7QX1jadhGc6Ji471H8AAzEzAH0AAAAFZAAgAAAAAFMm2feF2fFCm/UC6AfIyepX/xJDSmnnolQIBnHcPmb5BXMAIAAAAABLI11kFrQoaNVZFmq/38aRNImPOjdJh0Lo6irI8M/AaAVsACAAAAAAOWul0oVqJ9CejD2RqphhTC98DJeRQy5EwbNerU2+4l8AAzE0AH0AAAAFZAAgAAAAAJvXB3KyNiNtQko4SSzo/9b2qmM2zU9CQTTDfLSBWMgRBXMAIAAAAAAvjuVP7KsLRDeqVqRziTKpBrjVyqKiIbO9Gw8Wl2wFTAVsACAAAAAADlE+oc1ins+paNcaOZJhBlKlObDJ4VQORWjFYocM4LgAAzE1AH0AAAAFZAAgAAAAAPGdcxDiid8z8XYnfdDivNMYVPgBKdGOUw6UStU+48CdBXMAIAAAAAARj6g1Ap0eEfuCZ4X2TsEw+Djrhto3fA5nLwPaY0vCTgVsACAAAAAAoHqiwGOUkBu8SX5U1yHho+UIFdSN2MdQN5s6bQ0EsJYAAzE2AH0AAAAFZAAgAAAAAP5rGPrYGt3aKob5f/ldP0qrW7bmWvqnKY4QwdDWz400BXMAIAAAAADTQkW2ymaaf/bhteOOGmSrIR97bAnJx+yN3yMj1bTeewVsACAAAAAADyQnHGH2gF4w4L8axUsSTf6Ubk7L5/eoFOJk12MtZAoAAzE3AH0AAAAFZAAgAAAAAAlz6wJze5UkIxKpJOZFGCOf3v2KByWyI6NB6JM9wNcBBXMAIAAAAABUC7P/neUIHHoZtq0jFVBHY75tSFYr1Y5S16YN5XxC1QVsACAAAAAAgvxRbXDisNnLY3pfsjDdnFLtkvYUC4lhA68eBXc7KAwAAzE4AH0AAAAFZAAgAAAAAFJ8AtHcjia/9Y5pLEc3qVgH5xKiXw12G9Kn2A1EY8McBXMAIAAAAAAxe7Bdw7eUSBk/oAawa7uicTEDgXLymRNhBy1LAxhDvwVsACAAAAAAxKPaIBKVx3jTA+R/el7P7AZ7efrmTGjJs3Hj/YdMddwAAzE5AH0AAAAFZAAgAAAAAO8uwQUaKFb6vqR3Sv3Wn4QAonC2exOC9lGG1juqP5DtBXMAIAAAAABZf1KyJgQg8/Rf5c02DgDK2aQu0rNCOvaL60ohDHyY+gVsACAAAAAAqyEjfKC8lYoIfoXYHUqHZPoaA6EK5BAZy5dxXZmay4kAAzIwAH0AAAAFZAAgAAAAAE8YtqyRsGCeiR6hhiyisR/hccmK4nZqIMzO4lUBmEFzBXMAIAAAAAC1UYOSKqAeG1UJiKjWFVskRhuFKpj9Ezy+lICZvFlN5AVsACAAAAAA6Ct9nNMKyRazn1OKnRKagm746CGu+jyhbL1qJnZxGi0AAzIxAH0AAAAFZAAgAAAAAPhCrMausDx1QUIEqp9rUdRKyM6a9AAx7jQ3ILIu8wNIBXMAIAAAAACmH8lotGCiF2q9VQxhsS+7LAZv79VUAsOUALaGxE/EpAVsACAAAAAAnc1xCKfdvbUEc8F7XZqlNn1C+hZTtC0I9I3LL06iaNkAAzIyAH0AAAAFZAAgAAAAAOBi/GAYFcstMSJPgp3VkMiuuUUCrZytvqYaU8dwm8v2BXMAIAAAAACEZSZVyD3pKzGlbdwlYmWQhHHTV5SnNLknl2Gw8IaUTQVsACAAAAAAfsLZsEDcWSuNsIo/TD1ReyQW75HPMgmuKZuWFOLKRLoAAzIzAH0AAAAFZAAgAAAAAIQuup+YGfH3mflzWopN8J1X8o8a0d9CSGIvrA5HOzraBXMAIAAAAADYvNLURXsC2ITMqK14LABQBI+hZZ5wNf24JMcKLW+84AVsACAAAAAACzfjbTBH7IwDU91OqLAz94RFkoqBOkzKAqQb55gT4/MAAzI0AH0AAAAFZAAgAAAAAKsh0ADyOnVocFrOrf6MpTrNvAj8iaiE923DPryu124gBXMAIAAAAADg24a8NVE1GyScc6tmnTbmu5ulzO+896fE92lN08MeswVsACAAAAAAaPxcOIxnU7But88/yadOuDJDMcCywwrRitaxMODT4msAAzI1AH0AAAAFZAAgAAAAAKkVC2Y6HtRmv72tDnPUSjJBvse7SxLqnr09/Uuj9sVVBXMAIAAAAABYNFUkH7ylPMN+Bc3HWX1e0flGYNbtJNCY9SltJCW/UAVsACAAAAAAZYK/f9H4OeihmpiFMH7Wm7uLvs2s92zNA8wyrNZTsuMAAzI2AH0AAAAFZAAgAAAAADDggcwcb/Yn1Kk39sOHsv7BO/MfP3m/AJzjGH506Wf9BXMAIAAAAAAYZIsdjICS0+BDyRUPnrSAZfPrwtuMaEDEn0/ijLNQmAVsACAAAAAAGPnYVvo2ulO9z4LGd/69NAklfIcZqZvFX2KK0s+FcTUAAzI3AH0AAAAFZAAgAAAAAEWY7dEUOJBgjOoWVht1wLehsWAzB3rSOBtLgTuM2HC8BXMAIAAAAAAAoswiHRROurjwUW8u8D5EUT+67yvrgpB/j6PzBDAfVwVsACAAAAAA6NhRTYFL/Sz4tao7vpPjLNgAJ0FX6P/IyMW65qT6YsMAAzI4AH0AAAAFZAAgAAAAAPZaapeAUUFPA7JTCMOWHJa9lnPFh0/gXfAPjA1ezm4ZBXMAIAAAAACmJvLY2nivw7/b3DOKH/X7bBXjJwoowqb1GtEFO3OYgAVsACAAAAAA/JcUoyKacCB1NfmH8vYqC1f7rd13KShrQqV2r9QBP44AAzI5AH0AAAAFZAAgAAAAAK00u6jadxCZAiA+fTsPVDsnW5p5LCr4+kZZZOTDuZlfBXMAIAAAAAAote4zTEYMDgaaQbAdN8Dzv93ljPLdGjJzvnRn3KXgtQVsACAAAAAAxXd9Mh6R3mnJy8m7UfqMKi6oD5DlZpkaOz6bEjMOdiwAAzMwAH0AAAAFZAAgAAAAAFbgabdyymiEVYYwtJSWa7lfl/oYuj/SukzJeDOR6wPVBXMAIAAAAADAFGFjS1vPbN6mQEhkDYTD6V2V23Ys9gUEUMGNvMPkaAVsACAAAAAAL/D5Sze/ZoEanZLK0IeEkhgVkxEjMWVCfmJaD3a8uNIAAzMxAH0AAAAFZAAgAAAAABNMR6UBv2E627CqLtQ/eDYx7OEwQ7JrR4mSHFa1N8tLBXMAIAAAAAAxH4gucI4UmNVB7625C6hFSVCuIpJO3lusJlPuL8H5EQVsACAAAAAAVLHNg0OUVqZ7WGOP53BkTap9FOw9dr1P4J8HxqFqU04AAzMyAH0AAAAFZAAgAAAAAG8cd6WBneNunlqrQ2EmNf35W7OGObGq9WL4ePX+LUDmBXMAIAAAAAAjJ2+sX87NSis9hBsgb1QprVRnO7Bf+GObCGoUqyPE4wVsACAAAAAAs9c9SM49/pWmyUQKslpt3RTMBNSRppfNO0JBvUqHPg0AAzMzAH0AAAAFZAAgAAAAAFWOUGkUpy8yf6gB3dio/aOfRKh7XuhvsUj48iESFJrGBXMAIAAAAAAY7sCDMcrUXvNuL6dO0m11WyijzXZvPIcOKob6IpC4PQVsACAAAAAAJOP+EHz6awDb1qK2bZQ3kTV7wsj5Daj/IGAWh4g7omAAAzM0AH0AAAAFZAAgAAAAAGUrIdKxOihwNmo6B+aG+Ag1qa0+iqdksHOjQj+Oy9bZBXMAIAAAAABwa5dbI2KmzBDNBTQBEkjZv4sPaeRkRNejcjdVymRFKQVsACAAAAAA4ml/nm0gJNTcJ4vuD+T2Qfq2fQZlibJp/j6MOGDrbHMAAzM1AH0AAAAFZAAgAAAAAOx89xV/hRk64/CkM9N2EMK6aldII0c8smdcsZ46NbP8BXMAIAAAAADBF6tfQ+7q9kTuLyuyrSnDgmrdmrXkdhl980i1KHuGHgVsACAAAAAACUqiFqHZdGbwAA+hN0YUE5zFg+H+dabIB4dj5/75W/YAAzM2AH0AAAAFZAAgAAAAAMkN0L1oQWXhjwn9rAdudcYeN8/5VdCKU8cmDt7BokjsBXMAIAAAAAAT62pGXoRwExe9uvgYOI0hg5tOxilrWfoEmT0SMglWJwVsACAAAAAAlVz4dhiprSbUero6JFfxzSJGclg63oAkAmgbSwbcYxIAAzM3AH0AAAAFZAAgAAAAANxfa4xCoaaB7k1C1RoH1LBhsCbN2yEq15BT9b+iqEC4BXMAIAAAAACAX9LV8Pemfw7NF0iB1/85NzM1Ef+1mUfyehacUVgobQVsACAAAAAAVq4xpbymLk0trPC/a2MvB39I7hRiX8EJsVSI5E5hSBkAAzM4AH0AAAAFZAAgAAAAAOYIYoWkX7dGuyKfi3XssUlc7u/gWzqrR9KMkikKVdmSBXMAIAAAAABVF2OYjRTGi9Tw8XCAwZWLpX35Yl271TlNWp6N/nROhAVsACAAAAAA0nWwYzXQ1+EkDvnGq+SMlq20z+j32Su+i/A95SggPb4AAzM5AH0AAAAFZAAgAAAAAIy0+bXZi10QC+q7oSOLXK5Fee7VEk/qHSXukfeVIfgzBXMAIAAAAAAQ3IIV/JQCHW95AEbH5zGIHtJqyuPjWPMIZ+VmQHlxEwVsACAAAAAAp0jYsyohKv9Pm+4k+DplEGbl9WLZpAJzitrcDj4CNsMAAzQwAH0AAAAFZAAgAAAAAL5SOJQ3LOhgdXJ5v086NNeAl1qonQnchObdpZJ1kHeEBXMAIAAAAAA+tEqTXODtik+ydJZSnUqXF9f18bPeze9eWtR7ExZJgQVsACAAAAAAbrkZCVgB9Qsp4IAbdf+bD4fT6Boqk5UtuA/zhNrh1y0AAzQxAH0AAAAFZAAgAAAAAKl8zcHJRDjSjJeV/WvMxulW1zrTFtaeBy/aKKhadc6UBXMAIAAAAADBdWQl5SBIvtZZLIHszePwkO14W1mQ0izUk2Ov21cPNAVsACAAAAAAHErCYycpqiIcCZHdmPL1hi+ovLQk4TAvENpfLdTRamQAAzQyAH0AAAAFZAAgAAAAAFvotcNaoKnVt5CBCOPwjexFO0WGWuaIGL6H/6KSau+6BXMAIAAAAAD2y2mBN5xPu5PJoY2zcr0GnQDtHRBogA5+xzIxccE9fwVsACAAAAAAdS34xzJesnUfxLCcc1U7XzUqLy8MAzV/tcjbqaD3lkMAAzQzAH0AAAAFZAAgAAAAAPezU0/vNT4Q4YKbTbaeHqcwNLT+IjW/Y9QFpIooihjPBXMAIAAAAACj2x4O4rHter8ZnTws5LAP9jJ/6kk9C/V3vL50LoFZHAVsACAAAAAAQdBDF3747uCVP5lB/zr8VmzxJfTSZHBKeIgm5FyONXwAAzQ0AH0AAAAFZAAgAAAAAMqpayM2XotEFmm0gwQd9rIzApy0X+7HfOhNk6VU7F5lBXMAIAAAAACJR9+q5T9qFHXFNgGbZnPubG8rkO6cwWhzITQTmd6VgwVsACAAAAAAOZLQ6o7e4mVfDzbpQioa4d3RoTvqwgnbmc5Qh2wsZuoAAzQ1AH0AAAAFZAAgAAAAANCeyW+3oebaQk+aqxNVhAcT/BZ5nhsTVdKS3tMrLSvWBXMAIAAAAADxRFMDhkyuEc++WnndMfoUMLNL7T7rWoeblcrpSI6soQVsACAAAAAAdBuBMJ1lxt0DRq9pOZldQqchLs3B/W02txcMLD490FEAAzQ2AH0AAAAFZAAgAAAAAIbo5YBTxXM7HQhl7UP9NNgpPGFkBx871r1B65G47+K8BXMAIAAAAAC21dJSxnEhnxO5gzN5/34BL4von45e1meW92qowzb8fQVsACAAAAAAm3Hk2cvBN0ANaR5jzeZE5TsdxDvJCTOT1I01X7cNVaYAAzQ3AH0AAAAFZAAgAAAAABm/6pF96j26Jm7z5KkY1y33zcAEXLx2n0DwC03bs/ixBXMAIAAAAAD01OMvTZI/mqMgxIhA5nLs068mW+GKl3OW3ilf2D8+LgVsACAAAAAAaLvJDrqBESTNZSdcXsd+8GXPl8ZkUsGpeYuyYVv/kygAAzQ4AH0AAAAFZAAgAAAAAJ/D3+17gaQdkBqkL2wMwccdmCaVOtxzIkM8VyI4xI5zBXMAIAAAAAAggLVmkc5u+YzBR+oNE+XgLVp64fC6MzUb/Ilu/Jsw0AVsACAAAAAACz3HVKdWkx82/kGbVpcbAeZtsj2R5Zr0dEPfle4IErkAAzQ5AH0AAAAFZAAgAAAAAJMRyUW50oaTzspS6A3TUoXyC3gNYQoShUGPakMmeVZrBXMAIAAAAACona2Pqwt4U2PmFrtmu37jB9kQ/12okyAVtYa8TQkDiQVsACAAAAAAltJJKjCMyBTJ+4PkdDCPJdeX695P8P5h7WOZ+kmExMAAAzUwAH0AAAAFZAAgAAAAAByuYl8dBvfaZ0LO/81JW4hYypeNmvLMaxsIdvqMPrWoBXMAIAAAAABNddwobOUJzm9HOUD8BMZJqkNCUCqstHZkC76FIdNg9AVsACAAAAAAQQOkIQtkyNavqCnhQbNg3HfqrJdsAGaoxSJePJl1qXsAAzUxAH0AAAAFZAAgAAAAAHEzLtfmF/sBcYPPdj8867VmmQyU1xK9I/3Y0478azvABXMAIAAAAAAcmyFajZPnBTbO+oLInNwlApBocUekKkxz2hYFeSlQ+gVsACAAAAAAZ6IkrOVRcC8vSA6Vb4fPWZJrYexXhEabIuYIeXNsCSgAAzUyAH0AAAAFZAAgAAAAAJam7JYsZe2cN20ZYm2W3v1pisNt5PLiniMzymBLWyMtBXMAIAAAAABxCsKVMZMTn3n+R2L7pVz5nW804r8HcK0mCBw3jUXKXAVsACAAAAAA7j3JGnNtR64P4dJLeUoScFRGfa8ekjh3dvhw46sRFk0AAzUzAH0AAAAFZAAgAAAAAMXrXx0saZ+5gORmwM2FLuZG6iuO2YS+1IGPoAtDKoKBBXMAIAAAAADIQsxCr8CfFKaBcx8kIeSywnGh7JHjKRJ9vJd9x79y7wVsACAAAAAAcvBV+SykDYhmRFyVYwFYB9oBKBSHr55Jdz2cXeowsUQAAzU0AH0AAAAFZAAgAAAAACbzcUD3INSnCRspOKF7ubne74OK9L0FTZvi9Ay0JVDYBXMAIAAAAADPebVQH8Btk9rhBIoUOdSAdpPvz7qIY4UC2i6IGisSAQVsACAAAAAAiBunJi0mPnnXdnldiq+If8dcb/n6apHnaIFt+oyYO1kAAzU1AH0AAAAFZAAgAAAAACUc2CtD1MK/UTxtv+8iA9FoHEyTwdl43HKeSwDw2Lp5BXMAIAAAAACCIduIdw65bQMzRYRfjBJj62bc69T4QqH4QoWanwlvowVsACAAAAAAM0TV7S+aPVVzJOQ+cpSNKHTwyQ0mWa8tcHzfk3nR+9IAAzU2AH0AAAAFZAAgAAAAAHSaHWs/dnmI9sc7nB50VB2Bzs0kHapMHCQdyVEYY30TBXMAIAAAAACkV22lhEjWv/9/DubfHBAcwJggKI5mIbSK5L2nyqloqQVsACAAAAAAS19m7DccQxgryOsBJ3GsCs37yfQqNi1G+S6fCXpEhn4AAzU3AH0AAAAFZAAgAAAAAAL8jhNBG0KXXZhmZ0bPXtfgapJCB/AI+BEHB0eZ3C75BXMAIAAAAADHx/fPa639EBmGV5quLi8IQT600ifiKSOhTDOK19DnzwVsACAAAAAAlyLTDVkHxbayklD6Qymh3odIK1JHaOtps4f4HR+PcDgAAzU4AH0AAAAFZAAgAAAAAAxgeclNl09H7HvzD1oLwb2YpFca5eaX90uStYXHilqKBXMAIAAAAACMU5pSxzIzWlQxHyW170Xs9EhD1hURASQk+qkx7K5Y6AVsACAAAAAAJbMMwJfNftA7Xom8Bw/ghuZmSa3x12vTZxBUbV8m888AAzU5AH0AAAAFZAAgAAAAABmO7QD9vxWMmFjIHz13lyOeV6vHT6mYCsWxF7hb/yOjBXMAIAAAAACT9lmgkiqzuWG24afuzYiCeK9gmJqacmxAruIukd0xEAVsACAAAAAAZa0/FI/GkZR7CtX18Xg9Tn9zfxkD0UoaSt+pIO5t1t4AAzYwAH0AAAAFZAAgAAAAAB89SjLtDJkqEghRGyj6aQ/2qvWLNuMROoXmzbYbCMKMBXMAIAAAAAC8sywgND+CjhVTF6HnRQeay8y9/HnVzDI42dEPah28LQVsACAAAAAAoxv7UKh0RqUAWcOsQvU123zO1qZn73Xfib0qncZCB34AAzYxAH0AAAAFZAAgAAAAABN2alGq9Aats1mwERNGwL/fIwZSvVCe9/8XMHTFlpUpBXMAIAAAAACuDPjJgvvbBYhbLpjMiWUCsVppiYrhvR+yMysNPN8cZAVsACAAAAAAKpADjc4bzIZMi9Q/+oe0EMRJHYQt6dlo1x/lRquagqkAAzYyAH0AAAAFZAAgAAAAAL8YB6VAqGBiWD4CBv16IBscg5J7VQCTZu87n6pj+86KBXMAIAAAAAAmxm8e68geeyAdUjSMWBHzUjneVB0pG9TBXIoE6467hAVsACAAAAAAV76JZAlYpgC/Zl8awx2ArCg1uuyy2XVTSkp0wUMi/7UAAzYzAH0AAAAFZAAgAAAAAL4yLkCTV5Dmxa5toBu4JT8ge/cITAaURIOuFuOtFUkeBXMAIAAAAAAXoFNQOMGkAj7qEJP0wQafmFSXgWGeorDVbwyOxWLIsgVsACAAAAAAc4Un6dtIFe+AQ+RSfNWs3q63RTHhmyc+5GKRRdpWRv8AAzY0AH0AAAAFZAAgAAAAAEU8DoUp46YtYjNFS9kNXwdYxQ9IW27vCTb+VcqqfnKNBXMAIAAAAADe7vBOgYReE8X78k5ARuUnv4GmzPZzg6SbConf4L2G3wVsACAAAAAA78YHWVkp6HbZ0zS4UL2z/2pj9vPDcMDt7zTv6NcRsVsAAzY1AH0AAAAFZAAgAAAAAPa4yKTtkUtySuWo1ZQsp2QXtPb5SYqzA5vYDnS1P6c0BXMAIAAAAADKnF58R1sXlHlsHIvCBR3YWW/qk54z9CTDhZydkD1cOQVsACAAAAAAHW3ERalTFWKMzjuXF3nFh0pSrQxM/ojnPbPhc4v5MaQAAzY2AH0AAAAFZAAgAAAAAN5WJnMBmfgpuQPyonmY5X6OdRvuHw4nhsnGRnFAQ95VBXMAIAAAAACwftzu7KVV1rmGKwXtJjs3cJ1gE3apr8+N0SAg1F2cHwVsACAAAAAATDW0reyaCjbJuVLJzbSLx1OBuBoQu+090kgW4RurVacAAzY3AH0AAAAFZAAgAAAAACHvDsaPhoSb6DeGnKQ1QOpGYAgK82qpnqwcmzSeWaJHBXMAIAAAAABRq3C5+dOfnkAHM5Mg5hPB3O4jhwQlBgQWLA7Ph5bhgwVsACAAAAAAqkC8zYASvkVrp0pqmDyFCkPaDmD/ePAJpMuNOCBhni8AAzY4AH0AAAAFZAAgAAAAAOBePJvccPMJmy515KB1AkXF5Pi8NOG4V8psWy0SPRP+BXMAIAAAAAB3dOJG9xIDtEKCRzeNnPS3bFZepMj8UKBobKpSoCPqpgVsACAAAAAAPG3IxQVOdZrr509ggm5FKizWWoZPuVtOgOIGZ3m+pdEAAzY5AH0AAAAFZAAgAAAAABUvRrDQKEXLMdhnzXRdhiL6AGNs2TojPky+YVLXs+JnBXMAIAAAAAD1kYicbEEcPzD4QtuSYQQWDPq8fuUWGddpWayKn3dT9QVsACAAAAAA9+Sf7PbyFcY45hP9oTfjQiOUS3vEIAT8C0vOHymwYSUAAzcwAH0AAAAFZAAgAAAAAOvSnpujeKNen4pqc2HR63C5s5oJ1Vf4CsbKoYQvkwl5BXMAIAAAAACw2+vAMdibzd2YVVNfk81yXkFZP0WLJ82JBxJmXnYE+QVsACAAAAAArQ/E1ACyhK4ZyLqH9mNkCU7WClqRQTGyW9tciSGG/EMAAzcxAH0AAAAFZAAgAAAAAAo0xfGG7tJ3GWhgPVhW5Zn239nTD3PadShCNRc9TwdNBXMAIAAAAADZh243oOhenu0s/P/5KZLBDh9ADqKHtSWcXpO9D2sIjgVsACAAAAAAlgTPaoQKz+saU8rwCT3UiNOdG6hdpjzFx9GBn08ZkBEAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "update": { - "$set": { - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "findAndModify" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6YrBn2ofIw1b5ooakrLOwF41BWrps8OO0H9WH4/rtlE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "n+XAuFnP8Dov9TnhGFxNx0K/MnVM9WbJ7RouEu0ndO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yRXojuVdn5GQtD97qYlaCL6cOLmZ7Cvcb3wFjkLUIdM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DuIkdRPITRs55I4SZmgomAHCIsDQmXRhW8+MOznkzSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SsBk+Et1lTbU+QRPx+xyJ/jMkmfG+QCvQEpip2YYrzA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "crCIzOd8KhHvvUlX7M1v9bhvU4pLdTc+X2SuqoKU5Ek=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YOWdCw4UrqnxkAaVjqmC4sKQDMVMHEpFGnlxpxdaU6E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M3SShp81Ff8tQ632qKbv9MUcN6wjDaBReI0VXNu6Xh4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gzHlSPxpM0hT75kQvWFzGlOxKvDoiKQZOr19V6l2zXI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s3JnppOGYw9SL2Q1kMAZs948v2F5PrpXjGei/HioDWs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cG6+3Gk/zEH68P/uuuwiAUVCuyJwa1LeV+t29FlPPAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dupdvR3AyJtM+g9NDKiaLVOtGca387JQp8w+V03m7Ig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JqEQc5svj2jTvZ6LLA5ivE+kTb/0aRemSEmxk4G7Zrg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "szcXXXKnob+p3SoM4yED2R920LeJ7cVsclPMFTe4CeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o1QoGVXmuBdHwHm7aCtGMlMVKrjFdYvJXpoq6uhIAZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Jfm5wPlqqLCJRGQIqRq2NGmpn7s0Vrih2H3YAOoI2YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zMHLb8ARbsYo8Ld05bqnGFf1Usha6EGb8QKwdSAyps0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yQdtq9lh5pugL7/i0Bj/PuZUUBUIzf+7wj1rl5y736w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wGWVZdO7qIuyDg/BqDgqjgoQ02h5YYgwXQB1oCin2NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "by9HMLj6NTEpgztZ5HSN6GxImkXPcaFINYDzgZY33X8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tWo0vbasi7bXmn/MsOx13VC1IsWtpx/nYp0uj4iMzdA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tQQpndUYd5O87lOtrGjH3wl9VsOK0ray7RMasL90sBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cQjXEDCMsOpKLLf+vlTgIHA+cbSJdzqhbSX9Wvh95aA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7yMpU48IxK9SzP2cx3VnTownGEwFmeFofuuFT97SuuY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kSOx1kz0CmBgzKQHZlo65ZUY1DIv9A99JRm+Us2y6Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubQpdPBe6/xvtr+AcXdfYLSvYCR4ot0tivehkCsupb4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xal+iCJ6FTefRQToyoNksc9NCZShyn04NDGi4IYrcoM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d7jU4iOK50xHxlkSifcxlZFCM46TSgQzoYivxG3HNLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJvl2nsBLBVzL3pp6sKWCL4UXeh3q/roYBJjSb74ve0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OIUCaKRvIx9t1w6Hxlz1IcQTdPNCfdRNwnnTm10W+X0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A9tvzsiElotOUVIB4CqfQp9mAwqvTM35YkmAR170aHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lI8gpK7hpb7c9x4RQugsxMnQay5LZJmwslZdvMx/dcE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dNCzh40U0XvdKnSDi3HRQOWQftEsDVqc4uUvsVFGoq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IP+iwEBWBwVVZIdpaMu8k5+soFCz+TZkYn3drKZ9grE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnqyh6e0y5svHkJDShlN9CHV0WvMBE4QbtJpQw5ZCXc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "elEl42tbVDoRTLjAhZUFEtXiut4b3PVhg/1ZLZSQdtE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vHuu2FxwclMHqyE6JBYbTYgbEkB0dqb/JuaxsvfwsmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xTf7NCe3Gf8QpE78HR5OknlLTKfs9J+RN9UZpH6fnso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XiWSasRnJAulGR6+LCVD3mwRObXylqYWR9jvpywq12c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MZMxEQ5ikx0PG1YFIExv0UnTZogsvgeOEZTpzvBDn4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yZMyMZBDrWbAhvnic7vvIYhmO9m5H2iuv0c8KNZrBzY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xxM14hTPY5j0vvcK2C7YAEjzdsfUTFHozHC0hEo1bxI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+01rqR1xVwkpGXcstbk1ItJqFVjH6Q8MGxEN3Cm9Y1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xOpLV0Z2VTRJ3iWtnWZcsyjXubTIkYWo31cO+HV1o1k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BWUOLqgLBqc5NwxVlSV5H3KFQPXbCp7mdo+jF+8cJqY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fuQb1S6xZDGlrEbK+kI23aL53PP1PVNwqICnZNt9Yzg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfscnoibFttahLdPVC4Ee+47ewGFKpDSU7M6HX19bKE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rpSW2awybNVeKtat91VFxqbINoTfNhPfQAu+d73Xtf8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9M/CP9ccOIIj2LLFmE0GFDO0Ban2wsNalEXfM6+h+1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WrEMG49l1ye4MhXs5ZS9tz8P6h+hDvthIg/2wW9ne1Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ImNhbfeyfH8qIEeA5ic0s3dAQBdzzTBS+CPsNih9vZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dWP33YDSn04UKJN2ogh2Rui0iW/0q2y18OCDRVcfyoo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lYv0isAtfGh6H9tdp3cp2eHU7q2J+uk7QrgcxtK3w7Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VGMoamB/+7zTOYcY/pqJc96xlv2PdW4hwsIAEIslTDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yNeBWMF7BnD9wVwz2PgJsvWr77QiVvvWUvJF0+fqBug=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfpvObJ+tJBXSvqeN7vlOfmhYign635lciYAJIjUtY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dsen4NqjzVGjpjufiTMs3+gqeD09EbnuogPgxrJECwg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pxCWVM3sn19NsFEpgHbgLa+PmYlhN3mMiP0Wk8kJhYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q11KNvJszjYIB9n9HcC+N4uz11a3eRj1L3BH9scKMDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A1PmkgcEToWh1JiVWE6mI5jUu7poxWWuCUt/cgRUUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qJo3Hu4PJeanL7XEaWXO/n3YsodhZyd+MJOOmB9Kpd8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BkBKLO8URFscfRY9Bav/1+L9mLohDgNr/MkZtGiraIs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rZq5WA3Hx3xthOyHAJXK//f8pE2qbz7YKu3TIMp9GFY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X07a/Lm80p5xd4RFs1dNmw+90tmPDPdGiAKVZkxd4zY=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "HI88j1zrIsFoijIXKybr9mYubNV5uVeODyLHFH4Ueco=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wXVD/HSbBljko0jJcaxJ1nrzs2+pchLQqYR3vywS8SU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KhscCh+tt/pp8lxtKZQSPPUU94RvJYPKG/sjtzIa4Ws=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RISnuNrTTVNW5HnwCgQJ301pFw8DOcYrAMQIwVwjOkI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Ra5zukLh2boua0Bh74qA+mtIoixGXlsNsxiJqHtqdTI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "eqr0v+NNWXWszi9ni8qH58Q6gw5x737tJvH3lPaNHO4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d42QupriWIwGrFAquXNFi0ehEuidIbHLFZtg1Sm2nN8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2azRVxaaTIJKcgY2FU012gcyP8Y05cRDpfUaMnCBaQU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "3nlgkM4K/AAcHesRYYdEu24UGetHodVnVfHzw4yxZBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hqy91FNmAAac2zUaPO6eWFkx0/37rOWGrwXN+fzL0tU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "akX+fmscSDSF9pB5MPj56iaJPtohr0hfXNk/OPWsGv8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1ZvUb10Q7cN4cNLktd5yNjqgtawsYnkbeVBZV6WuY/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "otCwtuKiY4hCyXvYzXvo10OcnzZppebo38KsAlq49QM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Mty8EscckeT/dhMfrPFyDbLnmMOcYRUQ3mLK4KTu6V8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tnvgLLkJINO7csREYu4dEVe1ICrBeu7OP+HdfoX3M2E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kOefsHgEVhkJ17UuP7Dxogy6sAQbzf1SFPKCj6XRlrQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F+JQ79xavpaHdJzdhvwyHbzdZJLNHAymc/+67La3gao=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NCZ9zp5rDRceENuSgAfTLEyKg0YgmXAhK0B8WSj7+Pw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wL1CJ7cYR5slx8mHq++uMdjDfkt9037lQTUztEMF56M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "txefkzTMITZE+XvvRFZ7QcgwDT/7m8jNmxRk4QBaoZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jFunW3v1tSYMyZtQQD28eEy9qqDp4Kqo7gMN29N4bfQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QMO915KUiS3X3R1bU1YoafVM2s0NeHo3EjgTA9PnGwY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "nwdKJEXdilzvb7494vbuDJ+y6SrfJahza1dYIsHIWVI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vpWMX+T/VXXajFo0UbuYjtp0AEzBU0Y+lP+ih2EQ7mg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1lmzG0J1DhKDRhhq5y5Buygu4G8eV2X0t7kUY90EohM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SiKqpXqO0trwhFvBWK274hMklpCgMhNs/JY84yyn/NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7cPGPYCKPTay+ZR9Gx6oOueduOgaFrSuAXmNDpDHXdI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4THEYvAkjs2Fh7FIe5LC45P4i4N0L7ob67UOVbhp6Nk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "B+UGsChLLZR7iqnt8yq91OgmTgwiUKTJhFxY4NT0O6c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X1uYwBCsCg1H+PnKdwtBqXlt0zKEURi8bOM940GcPfk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xYOgT5l7shlNXCwHlguovmDkcEnF8dXyYlTyYrgZ8GE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vFMTZqV8bh1+gcKzTkXweMddJlgdUnwX0DWzUUaMok4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4HI0y9FrtleZxZ7M6INdNhLelrQ2Rv/+ykWCBl+tMC8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jpJ0bBE474OUkn1vUiLWumIBtYmwc7J5+LQU/nyeLQc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jQTPeXZvdxY/DjtPfYfKUArIDsf0E9MVFy2O26sv1ec=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QLLto0ExR2ZYMGqlyaMZc/hXFFTlwmgtKbiVq/xJIeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yBJNviU1nchbGbhx6InXCVRXa90sEepz1EwbYuKXu2U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jpEf0vHxrPu9gTJutNXSi2g/2Mc4WXFEN7yHonZEb7A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "E09kLFckMYwNuhggMxmPtwndyvIAx+Vl+b2CV6FP75s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "N+ue6/cLPb5NssmJCCeo18LlbKPz6r2z20AsnTKRvOo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yVQNZP8hhsvNGyDph2QP2qTNdXZTiIEVineKg+Qf33o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cSC9uI+9c5S8X+0G7amVyug1p0ZlgBsbEDYYyezBevQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1NpZGjoQzuQtekj80Rifxe9HbE08W07dfwxaFHaVn84=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "5Ghuq/8l11Ug9Uf/RTwf9On3OxOwIXUcb9soiy4J7/w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0LWKaEty6ywxLFhDaAqulqfMnYc+tgPfH4apyEeKg80=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OwSthmCBtt6NIAoAh7aCbj82Yr/+9t8U7WuBQhFT3AQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "iYiyg6/1isqbMdvFPIGucu3cNM4NAZNtJhHpGZ4eM+c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "waBgs8jWuGJPIF5zCRh6OmIyfK5GCBQgTMfmKSR2wyY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1Jdtbe2BKJXPU2G9ywOrlODZ/cNYEQlKzAW3aMe1Hy4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xaLEnNUS/2ySerBpb9dN/D31t+wYcKekwTfkwtni0Mc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bIVBrOhOvr6cL55Tr24+B+CC9MiG7U6K54aAr2IXXuw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6Cdq5wroGu2TEFnekuT7LhOpd/K/+PcipIljcHU9QL4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "K5l64vI4S/pLviLW6Pl0U3iQkI3ge0xg4RAHcEsyKJo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bzhuvZ0Ls22yIOX+Hz51eAHlSuDbWR/e0u4EhfdpHbc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Qv+fr6uD4o0bZRp69QJCFL6zvn3G82c7L+N1IFzj7H0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XAmISMbD3aEyQT+BQEphCKFNa0F0GDKFuhM9cGceKoQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4VLCokntMfm1AogpUnYGvhV7nllWSo3mS3hVESMy+hA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xiXNLj/CipEH63Vb5cidi8q9X47EF4f3HtJSOH7mfM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4XlCYfYBjI9XA5zOSgTiEBYcZsdwyXL+f5XtH2xUIOc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "k6DfQy7ZYJIkEly2B5hjOZznL4NcgMkllZjJLb7yq7w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ZzM6gwWesa3lxbZVZthpPFs2s3GV0RZREE2zOMhBRBo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "US+jeMeeOd7J0wR0efJtq2/18lcO8YFvhT4O3DeaonQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b6iSxiI1FM9SzxuG1bHqGA1i4+3GOi0/SPW00XB4L7o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kn3LsxAVkzIZKK9I6fi0Cctr0yjXOYgaQWMCoj4hLpM=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-InsertFind.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-InsertFind.json deleted file mode 100644 index d3dc2f830..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-InsertFind.json +++ /dev/null @@ -1,1124 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Double. Insert and Find.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$numberDouble": "0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "find": "default", - "filter": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$binary": { - "base64": "DYckAAADcGF5bG9hZABXJAAABGcAQyQAAAMwAH0AAAAFZAAgAAAAAHgYoMGjEE6fAlAhICv0+doHcVX8CmMVxyq7+jlyGrvmBXMAIAAAAAC/5MQZgTHuIr/O5Z3mXPvqrom5JTQ8IeSpQGhO9sB+8gVsACAAAAAAuPSXVmJUAUpTQg/A9Bu1hYczZF58KEhVofakygbsvJQAAzEAfQAAAAVkACAAAAAA2kiWNvEc4zunJ1jzvuClFC9hjZMYruKCqAaxq+oY8EAFcwAgAAAAACofIS72Cm6s866UCk+evTH3CvKBj/uZd72sAL608rzTBWwAIAAAAADuCQ/M2xLeALF0UFZtJb22QGOhHmJv6xoO+kZIHcDeiAADMgB9AAAABWQAIAAAAABkfoBGmU3hjYBvQbjNW19kfXneBQsQQPRfUL3UAwI2cAVzACAAAAAAUpK2BUOqX/DGdX5YJniEZMWkofxHqeAbXceEGJxhp8AFbAAgAAAAAKUaLzIldNIZv6RHE+FwbMjzcNHqPESwF/37mm43VPrsAAMzAH0AAAAFZAAgAAAAAFNprhQ3ZwIcYbuzLolAT5n/vc14P9kUUQComDu6eFyKBXMAIAAAAAAcx9z9pk32YbPV/sfPZl9ALIEVsqoLXgqWLVK/tP+heAVsACAAAAAA/qxvuvJbAHwwhfrPVpmCFzNvg2cU/NXaWgqgYUZpgXwAAzQAfQAAAAVkACAAAAAAODI+pB2pCuB+YmNEUAgtMfNdt3DmSkrJ96gRzLphgb8FcwAgAAAAAAT7dewFDxUDECQ3zVq75/cUN4IP+zsqhkP5+czUwlJIBWwAIAAAAACFGeOtd5zBXTJ4JYonkn/HXZfHipUlqGwIRUcH/VTatwADNQB9AAAABWQAIAAAAACNAk+yTZ4Ewk1EnotQK8O3h1gg9I7pr9q2+4po1iJVgAVzACAAAAAAUj/LesmtEsgqYVzMJ67umVA11hJTdDXwbxDoQ71vWyUFbAAgAAAAABlnhpgTQ0WjLb5u0b/vEydrCeFjVynKd7aqb+UnvVLeAAM2AH0AAAAFZAAgAAAAAD/FIrGYFDjyYmVb7oTMVwweWP7A6F9LnyIuNO4MjBnXBXMAIAAAAACIZgJCQRZu7NhuNMyOqCn1tf+DfU1qm10TPCfj5JYV3wVsACAAAAAA5hmY4ptuNxULGf87SUFXQWGAONsL9U29duh8xqsHtxoAAzcAfQAAAAVkACAAAAAAciRW40ORJLVwchOEpz87Svb+5toAFM6LxDWv928ECwQFcwAgAAAAAN0dipyESIkszfjRzdDi8kAGaa2Hf4wrPAtiWwboZLuxBWwAIAAAAAANr4o/+l1OIbbaX5lZ3fQ/WIeOcEXjNI1F0WbSgQrzaQADOAB9AAAABWQAIAAAAACZqAyCzYQupJ95mrBJX54yIz9VY7I0WrxpNYElCI4dTQVzACAAAAAA/eyJb6d1xfE+jJlVXMTD3HS/NEYENPVKAuj56Dr2dSEFbAAgAAAAANkSt154Or/JKb31VvbZFV46RPgUp8ff/hcPORL7PpFBAAM5AH0AAAAFZAAgAAAAAI5bm3YO0Xgf0VT+qjVTTfvckecM3Cwqj7DTKZXf8/NXBXMAIAAAAAD/m+h8fBhWaHm6Ykuz0WX1xL4Eme3ErLObyEVJf8NCywVsACAAAAAAfb1VZZCqs2ivYbRzX4p5CtaCkKW+g20Pr57FWXzEZi8AAzEwAH0AAAAFZAAgAAAAANqo4+p6qdtCzcB4BX1wQ6llU7eFBnuu4MtZwp4B6mDlBXMAIAAAAAAGiz+VaukMZ+6IH4jtn4KWWdKK4/W+O+gRioQDrfzpMgVsACAAAAAAG4YYkTp80EKo59mlHExDodRQFR7njhR5dmISwUJ6ukAAAzExAH0AAAAFZAAgAAAAAPrFXmHP2Y4YAm7b/aqsdn/DPoDkv7B8egWkfe23XsM1BXMAIAAAAAAGhwpKAr7skeqHm3oseSbO7qKNhmYsuUrECBxJ5k+D2AVsACAAAAAAAqPQi9luYAu3GrFCEsVjd9z2zIDcp6SPTR2w6KQEr+IAAzEyAH0AAAAFZAAgAAAAABzjYxwAjXxXc0Uxv18rH8I3my0Aguow0kTwKyxbrm+cBXMAIAAAAADVbqJVr6IdokuhXkEtXF0C2gINLiAjMVN20lE20Vmp2QVsACAAAAAAD7K1Fx4gFaaizkIUrf+EGXQeG7QX1jadhGc6Ji471H8AAzEzAH0AAAAFZAAgAAAAAFMm2feF2fFCm/UC6AfIyepX/xJDSmnnolQIBnHcPmb5BXMAIAAAAABLI11kFrQoaNVZFmq/38aRNImPOjdJh0Lo6irI8M/AaAVsACAAAAAAOWul0oVqJ9CejD2RqphhTC98DJeRQy5EwbNerU2+4l8AAzE0AH0AAAAFZAAgAAAAAJvXB3KyNiNtQko4SSzo/9b2qmM2zU9CQTTDfLSBWMgRBXMAIAAAAAAvjuVP7KsLRDeqVqRziTKpBrjVyqKiIbO9Gw8Wl2wFTAVsACAAAAAADlE+oc1ins+paNcaOZJhBlKlObDJ4VQORWjFYocM4LgAAzE1AH0AAAAFZAAgAAAAAPGdcxDiid8z8XYnfdDivNMYVPgBKdGOUw6UStU+48CdBXMAIAAAAAARj6g1Ap0eEfuCZ4X2TsEw+Djrhto3fA5nLwPaY0vCTgVsACAAAAAAoHqiwGOUkBu8SX5U1yHho+UIFdSN2MdQN5s6bQ0EsJYAAzE2AH0AAAAFZAAgAAAAAP5rGPrYGt3aKob5f/ldP0qrW7bmWvqnKY4QwdDWz400BXMAIAAAAADTQkW2ymaaf/bhteOOGmSrIR97bAnJx+yN3yMj1bTeewVsACAAAAAADyQnHGH2gF4w4L8axUsSTf6Ubk7L5/eoFOJk12MtZAoAAzE3AH0AAAAFZAAgAAAAAAlz6wJze5UkIxKpJOZFGCOf3v2KByWyI6NB6JM9wNcBBXMAIAAAAABUC7P/neUIHHoZtq0jFVBHY75tSFYr1Y5S16YN5XxC1QVsACAAAAAAgvxRbXDisNnLY3pfsjDdnFLtkvYUC4lhA68eBXc7KAwAAzE4AH0AAAAFZAAgAAAAAFJ8AtHcjia/9Y5pLEc3qVgH5xKiXw12G9Kn2A1EY8McBXMAIAAAAAAxe7Bdw7eUSBk/oAawa7uicTEDgXLymRNhBy1LAxhDvwVsACAAAAAAxKPaIBKVx3jTA+R/el7P7AZ7efrmTGjJs3Hj/YdMddwAAzE5AH0AAAAFZAAgAAAAAO8uwQUaKFb6vqR3Sv3Wn4QAonC2exOC9lGG1juqP5DtBXMAIAAAAABZf1KyJgQg8/Rf5c02DgDK2aQu0rNCOvaL60ohDHyY+gVsACAAAAAAqyEjfKC8lYoIfoXYHUqHZPoaA6EK5BAZy5dxXZmay4kAAzIwAH0AAAAFZAAgAAAAAE8YtqyRsGCeiR6hhiyisR/hccmK4nZqIMzO4lUBmEFzBXMAIAAAAAC1UYOSKqAeG1UJiKjWFVskRhuFKpj9Ezy+lICZvFlN5AVsACAAAAAA6Ct9nNMKyRazn1OKnRKagm746CGu+jyhbL1qJnZxGi0AAzIxAH0AAAAFZAAgAAAAAPhCrMausDx1QUIEqp9rUdRKyM6a9AAx7jQ3ILIu8wNIBXMAIAAAAACmH8lotGCiF2q9VQxhsS+7LAZv79VUAsOUALaGxE/EpAVsACAAAAAAnc1xCKfdvbUEc8F7XZqlNn1C+hZTtC0I9I3LL06iaNkAAzIyAH0AAAAFZAAgAAAAAOBi/GAYFcstMSJPgp3VkMiuuUUCrZytvqYaU8dwm8v2BXMAIAAAAACEZSZVyD3pKzGlbdwlYmWQhHHTV5SnNLknl2Gw8IaUTQVsACAAAAAAfsLZsEDcWSuNsIo/TD1ReyQW75HPMgmuKZuWFOLKRLoAAzIzAH0AAAAFZAAgAAAAAIQuup+YGfH3mflzWopN8J1X8o8a0d9CSGIvrA5HOzraBXMAIAAAAADYvNLURXsC2ITMqK14LABQBI+hZZ5wNf24JMcKLW+84AVsACAAAAAACzfjbTBH7IwDU91OqLAz94RFkoqBOkzKAqQb55gT4/MAAzI0AH0AAAAFZAAgAAAAAKsh0ADyOnVocFrOrf6MpTrNvAj8iaiE923DPryu124gBXMAIAAAAADg24a8NVE1GyScc6tmnTbmu5ulzO+896fE92lN08MeswVsACAAAAAAaPxcOIxnU7But88/yadOuDJDMcCywwrRitaxMODT4msAAzI1AH0AAAAFZAAgAAAAAKkVC2Y6HtRmv72tDnPUSjJBvse7SxLqnr09/Uuj9sVVBXMAIAAAAABYNFUkH7ylPMN+Bc3HWX1e0flGYNbtJNCY9SltJCW/UAVsACAAAAAAZYK/f9H4OeihmpiFMH7Wm7uLvs2s92zNA8wyrNZTsuMAAzI2AH0AAAAFZAAgAAAAADDggcwcb/Yn1Kk39sOHsv7BO/MfP3m/AJzjGH506Wf9BXMAIAAAAAAYZIsdjICS0+BDyRUPnrSAZfPrwtuMaEDEn0/ijLNQmAVsACAAAAAAGPnYVvo2ulO9z4LGd/69NAklfIcZqZvFX2KK0s+FcTUAAzI3AH0AAAAFZAAgAAAAAEWY7dEUOJBgjOoWVht1wLehsWAzB3rSOBtLgTuM2HC8BXMAIAAAAAAAoswiHRROurjwUW8u8D5EUT+67yvrgpB/j6PzBDAfVwVsACAAAAAA6NhRTYFL/Sz4tao7vpPjLNgAJ0FX6P/IyMW65qT6YsMAAzI4AH0AAAAFZAAgAAAAAPZaapeAUUFPA7JTCMOWHJa9lnPFh0/gXfAPjA1ezm4ZBXMAIAAAAACmJvLY2nivw7/b3DOKH/X7bBXjJwoowqb1GtEFO3OYgAVsACAAAAAA/JcUoyKacCB1NfmH8vYqC1f7rd13KShrQqV2r9QBP44AAzI5AH0AAAAFZAAgAAAAAK00u6jadxCZAiA+fTsPVDsnW5p5LCr4+kZZZOTDuZlfBXMAIAAAAAAote4zTEYMDgaaQbAdN8Dzv93ljPLdGjJzvnRn3KXgtQVsACAAAAAAxXd9Mh6R3mnJy8m7UfqMKi6oD5DlZpkaOz6bEjMOdiwAAzMwAH0AAAAFZAAgAAAAAFbgabdyymiEVYYwtJSWa7lfl/oYuj/SukzJeDOR6wPVBXMAIAAAAADAFGFjS1vPbN6mQEhkDYTD6V2V23Ys9gUEUMGNvMPkaAVsACAAAAAAL/D5Sze/ZoEanZLK0IeEkhgVkxEjMWVCfmJaD3a8uNIAAzMxAH0AAAAFZAAgAAAAABNMR6UBv2E627CqLtQ/eDYx7OEwQ7JrR4mSHFa1N8tLBXMAIAAAAAAxH4gucI4UmNVB7625C6hFSVCuIpJO3lusJlPuL8H5EQVsACAAAAAAVLHNg0OUVqZ7WGOP53BkTap9FOw9dr1P4J8HxqFqU04AAzMyAH0AAAAFZAAgAAAAAG8cd6WBneNunlqrQ2EmNf35W7OGObGq9WL4ePX+LUDmBXMAIAAAAAAjJ2+sX87NSis9hBsgb1QprVRnO7Bf+GObCGoUqyPE4wVsACAAAAAAs9c9SM49/pWmyUQKslpt3RTMBNSRppfNO0JBvUqHPg0AAzMzAH0AAAAFZAAgAAAAAFWOUGkUpy8yf6gB3dio/aOfRKh7XuhvsUj48iESFJrGBXMAIAAAAAAY7sCDMcrUXvNuL6dO0m11WyijzXZvPIcOKob6IpC4PQVsACAAAAAAJOP+EHz6awDb1qK2bZQ3kTV7wsj5Daj/IGAWh4g7omAAAzM0AH0AAAAFZAAgAAAAAGUrIdKxOihwNmo6B+aG+Ag1qa0+iqdksHOjQj+Oy9bZBXMAIAAAAABwa5dbI2KmzBDNBTQBEkjZv4sPaeRkRNejcjdVymRFKQVsACAAAAAA4ml/nm0gJNTcJ4vuD+T2Qfq2fQZlibJp/j6MOGDrbHMAAzM1AH0AAAAFZAAgAAAAAOx89xV/hRk64/CkM9N2EMK6aldII0c8smdcsZ46NbP8BXMAIAAAAADBF6tfQ+7q9kTuLyuyrSnDgmrdmrXkdhl980i1KHuGHgVsACAAAAAACUqiFqHZdGbwAA+hN0YUE5zFg+H+dabIB4dj5/75W/YAAzM2AH0AAAAFZAAgAAAAAMkN0L1oQWXhjwn9rAdudcYeN8/5VdCKU8cmDt7BokjsBXMAIAAAAAAT62pGXoRwExe9uvgYOI0hg5tOxilrWfoEmT0SMglWJwVsACAAAAAAlVz4dhiprSbUero6JFfxzSJGclg63oAkAmgbSwbcYxIAAzM3AH0AAAAFZAAgAAAAANxfa4xCoaaB7k1C1RoH1LBhsCbN2yEq15BT9b+iqEC4BXMAIAAAAACAX9LV8Pemfw7NF0iB1/85NzM1Ef+1mUfyehacUVgobQVsACAAAAAAVq4xpbymLk0trPC/a2MvB39I7hRiX8EJsVSI5E5hSBkAAzM4AH0AAAAFZAAgAAAAAOYIYoWkX7dGuyKfi3XssUlc7u/gWzqrR9KMkikKVdmSBXMAIAAAAABVF2OYjRTGi9Tw8XCAwZWLpX35Yl271TlNWp6N/nROhAVsACAAAAAA0nWwYzXQ1+EkDvnGq+SMlq20z+j32Su+i/A95SggPb4AAzM5AH0AAAAFZAAgAAAAAIy0+bXZi10QC+q7oSOLXK5Fee7VEk/qHSXukfeVIfgzBXMAIAAAAAAQ3IIV/JQCHW95AEbH5zGIHtJqyuPjWPMIZ+VmQHlxEwVsACAAAAAAp0jYsyohKv9Pm+4k+DplEGbl9WLZpAJzitrcDj4CNsMAAzQwAH0AAAAFZAAgAAAAAL5SOJQ3LOhgdXJ5v086NNeAl1qonQnchObdpZJ1kHeEBXMAIAAAAAA+tEqTXODtik+ydJZSnUqXF9f18bPeze9eWtR7ExZJgQVsACAAAAAAbrkZCVgB9Qsp4IAbdf+bD4fT6Boqk5UtuA/zhNrh1y0AAzQxAH0AAAAFZAAgAAAAAKl8zcHJRDjSjJeV/WvMxulW1zrTFtaeBy/aKKhadc6UBXMAIAAAAADBdWQl5SBIvtZZLIHszePwkO14W1mQ0izUk2Ov21cPNAVsACAAAAAAHErCYycpqiIcCZHdmPL1hi+ovLQk4TAvENpfLdTRamQAAzQyAH0AAAAFZAAgAAAAAFvotcNaoKnVt5CBCOPwjexFO0WGWuaIGL6H/6KSau+6BXMAIAAAAAD2y2mBN5xPu5PJoY2zcr0GnQDtHRBogA5+xzIxccE9fwVsACAAAAAAdS34xzJesnUfxLCcc1U7XzUqLy8MAzV/tcjbqaD3lkMAAzQzAH0AAAAFZAAgAAAAAPezU0/vNT4Q4YKbTbaeHqcwNLT+IjW/Y9QFpIooihjPBXMAIAAAAACj2x4O4rHter8ZnTws5LAP9jJ/6kk9C/V3vL50LoFZHAVsACAAAAAAQdBDF3747uCVP5lB/zr8VmzxJfTSZHBKeIgm5FyONXwAAzQ0AH0AAAAFZAAgAAAAAMqpayM2XotEFmm0gwQd9rIzApy0X+7HfOhNk6VU7F5lBXMAIAAAAACJR9+q5T9qFHXFNgGbZnPubG8rkO6cwWhzITQTmd6VgwVsACAAAAAAOZLQ6o7e4mVfDzbpQioa4d3RoTvqwgnbmc5Qh2wsZuoAAzQ1AH0AAAAFZAAgAAAAANCeyW+3oebaQk+aqxNVhAcT/BZ5nhsTVdKS3tMrLSvWBXMAIAAAAADxRFMDhkyuEc++WnndMfoUMLNL7T7rWoeblcrpSI6soQVsACAAAAAAdBuBMJ1lxt0DRq9pOZldQqchLs3B/W02txcMLD490FEAAzQ2AH0AAAAFZAAgAAAAAIbo5YBTxXM7HQhl7UP9NNgpPGFkBx871r1B65G47+K8BXMAIAAAAAC21dJSxnEhnxO5gzN5/34BL4von45e1meW92qowzb8fQVsACAAAAAAm3Hk2cvBN0ANaR5jzeZE5TsdxDvJCTOT1I01X7cNVaYAAzQ3AH0AAAAFZAAgAAAAABm/6pF96j26Jm7z5KkY1y33zcAEXLx2n0DwC03bs/ixBXMAIAAAAAD01OMvTZI/mqMgxIhA5nLs068mW+GKl3OW3ilf2D8+LgVsACAAAAAAaLvJDrqBESTNZSdcXsd+8GXPl8ZkUsGpeYuyYVv/kygAAzQ4AH0AAAAFZAAgAAAAAJ/D3+17gaQdkBqkL2wMwccdmCaVOtxzIkM8VyI4xI5zBXMAIAAAAAAggLVmkc5u+YzBR+oNE+XgLVp64fC6MzUb/Ilu/Jsw0AVsACAAAAAACz3HVKdWkx82/kGbVpcbAeZtsj2R5Zr0dEPfle4IErkAAzQ5AH0AAAAFZAAgAAAAAJMRyUW50oaTzspS6A3TUoXyC3gNYQoShUGPakMmeVZrBXMAIAAAAACona2Pqwt4U2PmFrtmu37jB9kQ/12okyAVtYa8TQkDiQVsACAAAAAAltJJKjCMyBTJ+4PkdDCPJdeX695P8P5h7WOZ+kmExMAAAzUwAH0AAAAFZAAgAAAAAByuYl8dBvfaZ0LO/81JW4hYypeNmvLMaxsIdvqMPrWoBXMAIAAAAABNddwobOUJzm9HOUD8BMZJqkNCUCqstHZkC76FIdNg9AVsACAAAAAAQQOkIQtkyNavqCnhQbNg3HfqrJdsAGaoxSJePJl1qXsAAzUxAH0AAAAFZAAgAAAAAHEzLtfmF/sBcYPPdj8867VmmQyU1xK9I/3Y0478azvABXMAIAAAAAAcmyFajZPnBTbO+oLInNwlApBocUekKkxz2hYFeSlQ+gVsACAAAAAAZ6IkrOVRcC8vSA6Vb4fPWZJrYexXhEabIuYIeXNsCSgAAzUyAH0AAAAFZAAgAAAAAJam7JYsZe2cN20ZYm2W3v1pisNt5PLiniMzymBLWyMtBXMAIAAAAABxCsKVMZMTn3n+R2L7pVz5nW804r8HcK0mCBw3jUXKXAVsACAAAAAA7j3JGnNtR64P4dJLeUoScFRGfa8ekjh3dvhw46sRFk0AAzUzAH0AAAAFZAAgAAAAAMXrXx0saZ+5gORmwM2FLuZG6iuO2YS+1IGPoAtDKoKBBXMAIAAAAADIQsxCr8CfFKaBcx8kIeSywnGh7JHjKRJ9vJd9x79y7wVsACAAAAAAcvBV+SykDYhmRFyVYwFYB9oBKBSHr55Jdz2cXeowsUQAAzU0AH0AAAAFZAAgAAAAACbzcUD3INSnCRspOKF7ubne74OK9L0FTZvi9Ay0JVDYBXMAIAAAAADPebVQH8Btk9rhBIoUOdSAdpPvz7qIY4UC2i6IGisSAQVsACAAAAAAiBunJi0mPnnXdnldiq+If8dcb/n6apHnaIFt+oyYO1kAAzU1AH0AAAAFZAAgAAAAACUc2CtD1MK/UTxtv+8iA9FoHEyTwdl43HKeSwDw2Lp5BXMAIAAAAACCIduIdw65bQMzRYRfjBJj62bc69T4QqH4QoWanwlvowVsACAAAAAAM0TV7S+aPVVzJOQ+cpSNKHTwyQ0mWa8tcHzfk3nR+9IAAzU2AH0AAAAFZAAgAAAAAHSaHWs/dnmI9sc7nB50VB2Bzs0kHapMHCQdyVEYY30TBXMAIAAAAACkV22lhEjWv/9/DubfHBAcwJggKI5mIbSK5L2nyqloqQVsACAAAAAAS19m7DccQxgryOsBJ3GsCs37yfQqNi1G+S6fCXpEhn4AAzU3AH0AAAAFZAAgAAAAAAL8jhNBG0KXXZhmZ0bPXtfgapJCB/AI+BEHB0eZ3C75BXMAIAAAAADHx/fPa639EBmGV5quLi8IQT600ifiKSOhTDOK19DnzwVsACAAAAAAlyLTDVkHxbayklD6Qymh3odIK1JHaOtps4f4HR+PcDgAAzU4AH0AAAAFZAAgAAAAAAxgeclNl09H7HvzD1oLwb2YpFca5eaX90uStYXHilqKBXMAIAAAAACMU5pSxzIzWlQxHyW170Xs9EhD1hURASQk+qkx7K5Y6AVsACAAAAAAJbMMwJfNftA7Xom8Bw/ghuZmSa3x12vTZxBUbV8m888AAzU5AH0AAAAFZAAgAAAAABmO7QD9vxWMmFjIHz13lyOeV6vHT6mYCsWxF7hb/yOjBXMAIAAAAACT9lmgkiqzuWG24afuzYiCeK9gmJqacmxAruIukd0xEAVsACAAAAAAZa0/FI/GkZR7CtX18Xg9Tn9zfxkD0UoaSt+pIO5t1t4AAzYwAH0AAAAFZAAgAAAAAB89SjLtDJkqEghRGyj6aQ/2qvWLNuMROoXmzbYbCMKMBXMAIAAAAAC8sywgND+CjhVTF6HnRQeay8y9/HnVzDI42dEPah28LQVsACAAAAAAoxv7UKh0RqUAWcOsQvU123zO1qZn73Xfib0qncZCB34AAzYxAH0AAAAFZAAgAAAAABN2alGq9Aats1mwERNGwL/fIwZSvVCe9/8XMHTFlpUpBXMAIAAAAACuDPjJgvvbBYhbLpjMiWUCsVppiYrhvR+yMysNPN8cZAVsACAAAAAAKpADjc4bzIZMi9Q/+oe0EMRJHYQt6dlo1x/lRquagqkAAzYyAH0AAAAFZAAgAAAAAL8YB6VAqGBiWD4CBv16IBscg5J7VQCTZu87n6pj+86KBXMAIAAAAAAmxm8e68geeyAdUjSMWBHzUjneVB0pG9TBXIoE6467hAVsACAAAAAAV76JZAlYpgC/Zl8awx2ArCg1uuyy2XVTSkp0wUMi/7UAAzYzAH0AAAAFZAAgAAAAAL4yLkCTV5Dmxa5toBu4JT8ge/cITAaURIOuFuOtFUkeBXMAIAAAAAAXoFNQOMGkAj7qEJP0wQafmFSXgWGeorDVbwyOxWLIsgVsACAAAAAAc4Un6dtIFe+AQ+RSfNWs3q63RTHhmyc+5GKRRdpWRv8AAzY0AH0AAAAFZAAgAAAAAEU8DoUp46YtYjNFS9kNXwdYxQ9IW27vCTb+VcqqfnKNBXMAIAAAAADe7vBOgYReE8X78k5ARuUnv4GmzPZzg6SbConf4L2G3wVsACAAAAAA78YHWVkp6HbZ0zS4UL2z/2pj9vPDcMDt7zTv6NcRsVsAAzY1AH0AAAAFZAAgAAAAAPa4yKTtkUtySuWo1ZQsp2QXtPb5SYqzA5vYDnS1P6c0BXMAIAAAAADKnF58R1sXlHlsHIvCBR3YWW/qk54z9CTDhZydkD1cOQVsACAAAAAAHW3ERalTFWKMzjuXF3nFh0pSrQxM/ojnPbPhc4v5MaQAAzY2AH0AAAAFZAAgAAAAAN5WJnMBmfgpuQPyonmY5X6OdRvuHw4nhsnGRnFAQ95VBXMAIAAAAACwftzu7KVV1rmGKwXtJjs3cJ1gE3apr8+N0SAg1F2cHwVsACAAAAAATDW0reyaCjbJuVLJzbSLx1OBuBoQu+090kgW4RurVacAAzY3AH0AAAAFZAAgAAAAACHvDsaPhoSb6DeGnKQ1QOpGYAgK82qpnqwcmzSeWaJHBXMAIAAAAABRq3C5+dOfnkAHM5Mg5hPB3O4jhwQlBgQWLA7Ph5bhgwVsACAAAAAAqkC8zYASvkVrp0pqmDyFCkPaDmD/ePAJpMuNOCBhni8AAzY4AH0AAAAFZAAgAAAAAOBePJvccPMJmy515KB1AkXF5Pi8NOG4V8psWy0SPRP+BXMAIAAAAAB3dOJG9xIDtEKCRzeNnPS3bFZepMj8UKBobKpSoCPqpgVsACAAAAAAPG3IxQVOdZrr509ggm5FKizWWoZPuVtOgOIGZ3m+pdEAAzY5AH0AAAAFZAAgAAAAABUvRrDQKEXLMdhnzXRdhiL6AGNs2TojPky+YVLXs+JnBXMAIAAAAAD1kYicbEEcPzD4QtuSYQQWDPq8fuUWGddpWayKn3dT9QVsACAAAAAA9+Sf7PbyFcY45hP9oTfjQiOUS3vEIAT8C0vOHymwYSUAAzcwAH0AAAAFZAAgAAAAAOvSnpujeKNen4pqc2HR63C5s5oJ1Vf4CsbKoYQvkwl5BXMAIAAAAACw2+vAMdibzd2YVVNfk81yXkFZP0WLJ82JBxJmXnYE+QVsACAAAAAArQ/E1ACyhK4ZyLqH9mNkCU7WClqRQTGyW9tciSGG/EMAAzcxAH0AAAAFZAAgAAAAAAo0xfGG7tJ3GWhgPVhW5Zn239nTD3PadShCNRc9TwdNBXMAIAAAAADZh243oOhenu0s/P/5KZLBDh9ADqKHtSWcXpO9D2sIjgVsACAAAAAAlgTPaoQKz+saU8rwCT3UiNOdG6hdpjzFx9GBn08ZkBEAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "find" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6YrBn2ofIw1b5ooakrLOwF41BWrps8OO0H9WH4/rtlE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "n+XAuFnP8Dov9TnhGFxNx0K/MnVM9WbJ7RouEu0ndO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yRXojuVdn5GQtD97qYlaCL6cOLmZ7Cvcb3wFjkLUIdM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DuIkdRPITRs55I4SZmgomAHCIsDQmXRhW8+MOznkzSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SsBk+Et1lTbU+QRPx+xyJ/jMkmfG+QCvQEpip2YYrzA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "crCIzOd8KhHvvUlX7M1v9bhvU4pLdTc+X2SuqoKU5Ek=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YOWdCw4UrqnxkAaVjqmC4sKQDMVMHEpFGnlxpxdaU6E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M3SShp81Ff8tQ632qKbv9MUcN6wjDaBReI0VXNu6Xh4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gzHlSPxpM0hT75kQvWFzGlOxKvDoiKQZOr19V6l2zXI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s3JnppOGYw9SL2Q1kMAZs948v2F5PrpXjGei/HioDWs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cG6+3Gk/zEH68P/uuuwiAUVCuyJwa1LeV+t29FlPPAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dupdvR3AyJtM+g9NDKiaLVOtGca387JQp8w+V03m7Ig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JqEQc5svj2jTvZ6LLA5ivE+kTb/0aRemSEmxk4G7Zrg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "szcXXXKnob+p3SoM4yED2R920LeJ7cVsclPMFTe4CeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o1QoGVXmuBdHwHm7aCtGMlMVKrjFdYvJXpoq6uhIAZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Jfm5wPlqqLCJRGQIqRq2NGmpn7s0Vrih2H3YAOoI2YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zMHLb8ARbsYo8Ld05bqnGFf1Usha6EGb8QKwdSAyps0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yQdtq9lh5pugL7/i0Bj/PuZUUBUIzf+7wj1rl5y736w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wGWVZdO7qIuyDg/BqDgqjgoQ02h5YYgwXQB1oCin2NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "by9HMLj6NTEpgztZ5HSN6GxImkXPcaFINYDzgZY33X8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tWo0vbasi7bXmn/MsOx13VC1IsWtpx/nYp0uj4iMzdA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tQQpndUYd5O87lOtrGjH3wl9VsOK0ray7RMasL90sBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cQjXEDCMsOpKLLf+vlTgIHA+cbSJdzqhbSX9Wvh95aA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7yMpU48IxK9SzP2cx3VnTownGEwFmeFofuuFT97SuuY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kSOx1kz0CmBgzKQHZlo65ZUY1DIv9A99JRm+Us2y6Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubQpdPBe6/xvtr+AcXdfYLSvYCR4ot0tivehkCsupb4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xal+iCJ6FTefRQToyoNksc9NCZShyn04NDGi4IYrcoM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d7jU4iOK50xHxlkSifcxlZFCM46TSgQzoYivxG3HNLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJvl2nsBLBVzL3pp6sKWCL4UXeh3q/roYBJjSb74ve0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OIUCaKRvIx9t1w6Hxlz1IcQTdPNCfdRNwnnTm10W+X0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A9tvzsiElotOUVIB4CqfQp9mAwqvTM35YkmAR170aHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lI8gpK7hpb7c9x4RQugsxMnQay5LZJmwslZdvMx/dcE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dNCzh40U0XvdKnSDi3HRQOWQftEsDVqc4uUvsVFGoq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IP+iwEBWBwVVZIdpaMu8k5+soFCz+TZkYn3drKZ9grE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnqyh6e0y5svHkJDShlN9CHV0WvMBE4QbtJpQw5ZCXc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "elEl42tbVDoRTLjAhZUFEtXiut4b3PVhg/1ZLZSQdtE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vHuu2FxwclMHqyE6JBYbTYgbEkB0dqb/JuaxsvfwsmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xTf7NCe3Gf8QpE78HR5OknlLTKfs9J+RN9UZpH6fnso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XiWSasRnJAulGR6+LCVD3mwRObXylqYWR9jvpywq12c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MZMxEQ5ikx0PG1YFIExv0UnTZogsvgeOEZTpzvBDn4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yZMyMZBDrWbAhvnic7vvIYhmO9m5H2iuv0c8KNZrBzY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xxM14hTPY5j0vvcK2C7YAEjzdsfUTFHozHC0hEo1bxI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+01rqR1xVwkpGXcstbk1ItJqFVjH6Q8MGxEN3Cm9Y1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xOpLV0Z2VTRJ3iWtnWZcsyjXubTIkYWo31cO+HV1o1k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BWUOLqgLBqc5NwxVlSV5H3KFQPXbCp7mdo+jF+8cJqY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fuQb1S6xZDGlrEbK+kI23aL53PP1PVNwqICnZNt9Yzg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfscnoibFttahLdPVC4Ee+47ewGFKpDSU7M6HX19bKE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rpSW2awybNVeKtat91VFxqbINoTfNhPfQAu+d73Xtf8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9M/CP9ccOIIj2LLFmE0GFDO0Ban2wsNalEXfM6+h+1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WrEMG49l1ye4MhXs5ZS9tz8P6h+hDvthIg/2wW9ne1Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ImNhbfeyfH8qIEeA5ic0s3dAQBdzzTBS+CPsNih9vZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dWP33YDSn04UKJN2ogh2Rui0iW/0q2y18OCDRVcfyoo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lYv0isAtfGh6H9tdp3cp2eHU7q2J+uk7QrgcxtK3w7Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VGMoamB/+7zTOYcY/pqJc96xlv2PdW4hwsIAEIslTDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yNeBWMF7BnD9wVwz2PgJsvWr77QiVvvWUvJF0+fqBug=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfpvObJ+tJBXSvqeN7vlOfmhYign635lciYAJIjUtY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dsen4NqjzVGjpjufiTMs3+gqeD09EbnuogPgxrJECwg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pxCWVM3sn19NsFEpgHbgLa+PmYlhN3mMiP0Wk8kJhYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q11KNvJszjYIB9n9HcC+N4uz11a3eRj1L3BH9scKMDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A1PmkgcEToWh1JiVWE6mI5jUu7poxWWuCUt/cgRUUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qJo3Hu4PJeanL7XEaWXO/n3YsodhZyd+MJOOmB9Kpd8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BkBKLO8URFscfRY9Bav/1+L9mLohDgNr/MkZtGiraIs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rZq5WA3Hx3xthOyHAJXK//f8pE2qbz7YKu3TIMp9GFY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X07a/Lm80p5xd4RFs1dNmw+90tmPDPdGiAKVZkxd4zY=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2FIZh/9N+NeJEQwxYIX5ikQT85xJzulBNReXk8PnG/s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I93Md7QNPGmEEGYU1+VVCqBPBEvXdqHPtTJtMOn06Yk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "GecBFQ1PemlECWZWCl7f74vmsL6eB6mzQ9n6tK6FYfs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QpjhZl+O1ORifgtCZuWAdcP6OKL7IZ2cA46v8FJcV28=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FWXI/yZ1M+2fIboeMCDMlp+I2NwPQDtoM/wWselOPYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uk26nvN/LdRLaBphiBgIZzT0sSpoO1z0RdDWRm/xrSA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hiiYSH1KZovAULc7rlmEU74wCjzDR+mm6ZnsgvFQjMw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hRzvMvWPX0sJme+wck67lwbKDFaWOa+Eyef+JSdc1s4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PSx5D+zqC9c295dguX4+EobT4IEzfffdfjzC8DWpB5Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QzfXQCVTjPQv2h21v95HYPq8uCsVJ2tPnjv79gAaM9M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XcGDO/dlTcEMLqwcm55UmOqK+KpBmbzZO1LIzX7GPaQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Lf+o4E7YB5ynzUPC6KTyW0lj6Cg9oLIu1Sdd1ODHctA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wAuVn02LAVo5Y+TUocvkoenFYWzpu38k0NmGZOsAjS4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yJGDtveLbbo/0HtCtiTSsvVI/0agg/U1bFaQ0yhK12o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KsEy0zgYcmkM+O/fWF9z3aJGIk22XCk+Aw96HB6JU68=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "p+AnMI5ZxdJMSIEJmXXya+FeH5yubmOdViwUO89j0Rc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/jLix56jzeywBtNuGw55lCXyebQoSIhbful0hOKxKDY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fvDvSPomtJsl1S3+8/tzFCE8scHIdJY5hB9CdTEsoFo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "oV5hOJzPXxfTuRdKIlF4uYEoMDuqH+G7/3qgndDr0PM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "3ALwcvLj3VOfgD6OqXAO13h1ZkOv46R6+Oy6SUKh53I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gxaB9FJj0IM+InhvAjwWaex3UIZ9SAnDiUd5WHSY/l0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "66NPvDygJzKJqddfNuDuNOpvGajjFRtvhkwfUkiYmXw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1dWcQIocRAcO9XnXYqbhl83jc0RgjQpsrWd8dC27trg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "npos0Uf1DT3ztSCjPVY9EImlRnTHB1KLrvmVSqBQ/8E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "TEI9qBx/tK1l1H0v1scMG8Srmtwo5VxWHADPBSlWrXk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "3wUN2ypQKoj+5ASkeIK9ycxhahVxyTmGopigoUAlyYs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o/oksSnUS+nIq6ozWTbB5bJh+NoaPj8deAA23uxiWCk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KExYPruhA31e8xuSwvfUfDcyY/H2Va6taUd0k4yFgLc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "/x+dNfxdd/lkx8Z8VZVfoYl7LPoaZ/iKEzZXBrAtIJc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DE4cmjFLPqZlmRomO0qQiruUBtzoCe8ZdNRcfNH92pU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M6EKNcLPw/iojAChgYUSieaBYWcbsjKtB94SaHOr8vk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+qP49lDPeyhaduTvXJgtJEqHNEYANVu9Bg3Bxz7Td9w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ruMrC2VIS+VKbJwCFb3bfkaLTju9nE+yPONV9s0M0Vo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EbjDlSB5JKnDKff4d8hOmaOwJ7B9Q6NQFisLj+DPC+0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "C/yYOTB94edyqAbiQNu8/H7FoG3yRRjHDkMykz4+Mv0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CBxqrejG+qQQq2YTd6iP/06kiu2CxxzBFaZK3Ofb1CM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2ZOQ/fpho+AbDENWBZaln7wRoepIRdhyT648dr8O5cU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "EghIgEPz01+myPgj8oid+PgncvobvC7vjvG3THEEQ0M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "92CysZYNF8riwAMhdrIPKxfODw9p07cKQy/Snn8XmVY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VO0LeTBQmsEf7sCHzTnZwUPNTqRZ49R8V5E9XnZ/5N4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "exs8BQMJq7U6ZXYgIizT7XN+X/hOmmn4YEuzev9zgSI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qHpS4k1I+gPniNp4CA8TY8lLN36vBYmgbKMFpbYMEqg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+7lWKCKAWFw6gPZdHE6E8KIfI14/fSvtWUmllb5WLi0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YiH/US0q6679hWblFDDKNqUjCgggoU8sUCssTIF1QbU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YgwkKElEubNfvXL9hJxzqQUQtHiXN/OCGxNL1MUZZlM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hZFST4INZTTuhvJlGJeMwlUAK270UCOTCDeBAnN4a7g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "24I1Zw35AuGnK3CqJhbCwYb0IPuu5sCRrM5iyeITOLc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vgD12JB4Q1S/kGPSQ1KOgp386KnG1GbM/5+60oRGcGw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+wNE+OL+CB9d4AUJdVxd56jUJCAXmmk9fapuB2TAc4g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uhQh1B2Pe4RkNw/kPEcgaLenuikKoRf1iyfZhpXdodc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "eu8gjAUIp8ybO204AgeOq5v1neI1yljqy5v3I6lo1lM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7QG6oVbASBAjrnCPxzzUNnuFSFNlKhbuBafkF8pr7Is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "PUS1xb2oHSDTdYltutoSSxBiJ1NjxH3l2kA4P1CZLEs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XPMh/JDC/O93gJJCwwgJDb8ssWZvRvezNmKmyn3nIfk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jWz+KGwMk/GOvFAK2rOxF3OjxeZAWfmUQ1HGJ7icw4A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o7XbW68pc6flYigf3LW4WAGUWxpeqxaQLkHUhUR9RZ8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "nqR+g60+5U0okbqJadSqGgnC+j1JcP8rwMcfzOs2ACI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Hz43qVK95tSfbYFtaE/8fE97XMk1RiO8XpWjwZHB80o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "noZUWlZ8M6KXU5rkifyo8/duw5IL7/fXbJvT7bNmW9k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WONVHCuPSanXDRQQ/3tmyJ0Vq+Lu/4hRaMUf0g0kSuw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UEaj6vQRoIghE8Movd8AGXhtwIOXlP4cBsECIUvE5Y8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "D3n2YcO8+PB4C8brDo7kxKjF9Y844rVkdRMLTgsQkrw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "C+YA0G9KjxZVaWwOMuh/dcnHnHAlYnbFrRl0IEpmsY0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rUnmbmQanxrbFPYYrwyQ53x66OSt27yAvF+s48ezKDc=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Update.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Update.json deleted file mode 100644 index 9d6a1fbfd..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Double-Update.json +++ /dev/null @@ -1,1141 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Double. Update.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$numberDouble": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$numberDouble": "1" - } - } - } - }, - { - "name": "updateOne", - "arguments": { - "filter": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$numberDouble": "0" - } - } - }, - "update": { - "$set": { - "encryptedDoubleNoPrecision": { - "$numberDouble": "2" - } - } - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command_name": "update", - "command": { - "update": "default", - "ordered": true, - "updates": [ - { - "q": { - "encryptedDoubleNoPrecision": { - "$gt": { - "$binary": { - "base64": "DYckAAADcGF5bG9hZABXJAAABGcAQyQAAAMwAH0AAAAFZAAgAAAAAHgYoMGjEE6fAlAhICv0+doHcVX8CmMVxyq7+jlyGrvmBXMAIAAAAAC/5MQZgTHuIr/O5Z3mXPvqrom5JTQ8IeSpQGhO9sB+8gVsACAAAAAAuPSXVmJUAUpTQg/A9Bu1hYczZF58KEhVofakygbsvJQAAzEAfQAAAAVkACAAAAAA2kiWNvEc4zunJ1jzvuClFC9hjZMYruKCqAaxq+oY8EAFcwAgAAAAACofIS72Cm6s866UCk+evTH3CvKBj/uZd72sAL608rzTBWwAIAAAAADuCQ/M2xLeALF0UFZtJb22QGOhHmJv6xoO+kZIHcDeiAADMgB9AAAABWQAIAAAAABkfoBGmU3hjYBvQbjNW19kfXneBQsQQPRfUL3UAwI2cAVzACAAAAAAUpK2BUOqX/DGdX5YJniEZMWkofxHqeAbXceEGJxhp8AFbAAgAAAAAKUaLzIldNIZv6RHE+FwbMjzcNHqPESwF/37mm43VPrsAAMzAH0AAAAFZAAgAAAAAFNprhQ3ZwIcYbuzLolAT5n/vc14P9kUUQComDu6eFyKBXMAIAAAAAAcx9z9pk32YbPV/sfPZl9ALIEVsqoLXgqWLVK/tP+heAVsACAAAAAA/qxvuvJbAHwwhfrPVpmCFzNvg2cU/NXaWgqgYUZpgXwAAzQAfQAAAAVkACAAAAAAODI+pB2pCuB+YmNEUAgtMfNdt3DmSkrJ96gRzLphgb8FcwAgAAAAAAT7dewFDxUDECQ3zVq75/cUN4IP+zsqhkP5+czUwlJIBWwAIAAAAACFGeOtd5zBXTJ4JYonkn/HXZfHipUlqGwIRUcH/VTatwADNQB9AAAABWQAIAAAAACNAk+yTZ4Ewk1EnotQK8O3h1gg9I7pr9q2+4po1iJVgAVzACAAAAAAUj/LesmtEsgqYVzMJ67umVA11hJTdDXwbxDoQ71vWyUFbAAgAAAAABlnhpgTQ0WjLb5u0b/vEydrCeFjVynKd7aqb+UnvVLeAAM2AH0AAAAFZAAgAAAAAD/FIrGYFDjyYmVb7oTMVwweWP7A6F9LnyIuNO4MjBnXBXMAIAAAAACIZgJCQRZu7NhuNMyOqCn1tf+DfU1qm10TPCfj5JYV3wVsACAAAAAA5hmY4ptuNxULGf87SUFXQWGAONsL9U29duh8xqsHtxoAAzcAfQAAAAVkACAAAAAAciRW40ORJLVwchOEpz87Svb+5toAFM6LxDWv928ECwQFcwAgAAAAAN0dipyESIkszfjRzdDi8kAGaa2Hf4wrPAtiWwboZLuxBWwAIAAAAAANr4o/+l1OIbbaX5lZ3fQ/WIeOcEXjNI1F0WbSgQrzaQADOAB9AAAABWQAIAAAAACZqAyCzYQupJ95mrBJX54yIz9VY7I0WrxpNYElCI4dTQVzACAAAAAA/eyJb6d1xfE+jJlVXMTD3HS/NEYENPVKAuj56Dr2dSEFbAAgAAAAANkSt154Or/JKb31VvbZFV46RPgUp8ff/hcPORL7PpFBAAM5AH0AAAAFZAAgAAAAAI5bm3YO0Xgf0VT+qjVTTfvckecM3Cwqj7DTKZXf8/NXBXMAIAAAAAD/m+h8fBhWaHm6Ykuz0WX1xL4Eme3ErLObyEVJf8NCywVsACAAAAAAfb1VZZCqs2ivYbRzX4p5CtaCkKW+g20Pr57FWXzEZi8AAzEwAH0AAAAFZAAgAAAAANqo4+p6qdtCzcB4BX1wQ6llU7eFBnuu4MtZwp4B6mDlBXMAIAAAAAAGiz+VaukMZ+6IH4jtn4KWWdKK4/W+O+gRioQDrfzpMgVsACAAAAAAG4YYkTp80EKo59mlHExDodRQFR7njhR5dmISwUJ6ukAAAzExAH0AAAAFZAAgAAAAAPrFXmHP2Y4YAm7b/aqsdn/DPoDkv7B8egWkfe23XsM1BXMAIAAAAAAGhwpKAr7skeqHm3oseSbO7qKNhmYsuUrECBxJ5k+D2AVsACAAAAAAAqPQi9luYAu3GrFCEsVjd9z2zIDcp6SPTR2w6KQEr+IAAzEyAH0AAAAFZAAgAAAAABzjYxwAjXxXc0Uxv18rH8I3my0Aguow0kTwKyxbrm+cBXMAIAAAAADVbqJVr6IdokuhXkEtXF0C2gINLiAjMVN20lE20Vmp2QVsACAAAAAAD7K1Fx4gFaaizkIUrf+EGXQeG7QX1jadhGc6Ji471H8AAzEzAH0AAAAFZAAgAAAAAFMm2feF2fFCm/UC6AfIyepX/xJDSmnnolQIBnHcPmb5BXMAIAAAAABLI11kFrQoaNVZFmq/38aRNImPOjdJh0Lo6irI8M/AaAVsACAAAAAAOWul0oVqJ9CejD2RqphhTC98DJeRQy5EwbNerU2+4l8AAzE0AH0AAAAFZAAgAAAAAJvXB3KyNiNtQko4SSzo/9b2qmM2zU9CQTTDfLSBWMgRBXMAIAAAAAAvjuVP7KsLRDeqVqRziTKpBrjVyqKiIbO9Gw8Wl2wFTAVsACAAAAAADlE+oc1ins+paNcaOZJhBlKlObDJ4VQORWjFYocM4LgAAzE1AH0AAAAFZAAgAAAAAPGdcxDiid8z8XYnfdDivNMYVPgBKdGOUw6UStU+48CdBXMAIAAAAAARj6g1Ap0eEfuCZ4X2TsEw+Djrhto3fA5nLwPaY0vCTgVsACAAAAAAoHqiwGOUkBu8SX5U1yHho+UIFdSN2MdQN5s6bQ0EsJYAAzE2AH0AAAAFZAAgAAAAAP5rGPrYGt3aKob5f/ldP0qrW7bmWvqnKY4QwdDWz400BXMAIAAAAADTQkW2ymaaf/bhteOOGmSrIR97bAnJx+yN3yMj1bTeewVsACAAAAAADyQnHGH2gF4w4L8axUsSTf6Ubk7L5/eoFOJk12MtZAoAAzE3AH0AAAAFZAAgAAAAAAlz6wJze5UkIxKpJOZFGCOf3v2KByWyI6NB6JM9wNcBBXMAIAAAAABUC7P/neUIHHoZtq0jFVBHY75tSFYr1Y5S16YN5XxC1QVsACAAAAAAgvxRbXDisNnLY3pfsjDdnFLtkvYUC4lhA68eBXc7KAwAAzE4AH0AAAAFZAAgAAAAAFJ8AtHcjia/9Y5pLEc3qVgH5xKiXw12G9Kn2A1EY8McBXMAIAAAAAAxe7Bdw7eUSBk/oAawa7uicTEDgXLymRNhBy1LAxhDvwVsACAAAAAAxKPaIBKVx3jTA+R/el7P7AZ7efrmTGjJs3Hj/YdMddwAAzE5AH0AAAAFZAAgAAAAAO8uwQUaKFb6vqR3Sv3Wn4QAonC2exOC9lGG1juqP5DtBXMAIAAAAABZf1KyJgQg8/Rf5c02DgDK2aQu0rNCOvaL60ohDHyY+gVsACAAAAAAqyEjfKC8lYoIfoXYHUqHZPoaA6EK5BAZy5dxXZmay4kAAzIwAH0AAAAFZAAgAAAAAE8YtqyRsGCeiR6hhiyisR/hccmK4nZqIMzO4lUBmEFzBXMAIAAAAAC1UYOSKqAeG1UJiKjWFVskRhuFKpj9Ezy+lICZvFlN5AVsACAAAAAA6Ct9nNMKyRazn1OKnRKagm746CGu+jyhbL1qJnZxGi0AAzIxAH0AAAAFZAAgAAAAAPhCrMausDx1QUIEqp9rUdRKyM6a9AAx7jQ3ILIu8wNIBXMAIAAAAACmH8lotGCiF2q9VQxhsS+7LAZv79VUAsOUALaGxE/EpAVsACAAAAAAnc1xCKfdvbUEc8F7XZqlNn1C+hZTtC0I9I3LL06iaNkAAzIyAH0AAAAFZAAgAAAAAOBi/GAYFcstMSJPgp3VkMiuuUUCrZytvqYaU8dwm8v2BXMAIAAAAACEZSZVyD3pKzGlbdwlYmWQhHHTV5SnNLknl2Gw8IaUTQVsACAAAAAAfsLZsEDcWSuNsIo/TD1ReyQW75HPMgmuKZuWFOLKRLoAAzIzAH0AAAAFZAAgAAAAAIQuup+YGfH3mflzWopN8J1X8o8a0d9CSGIvrA5HOzraBXMAIAAAAADYvNLURXsC2ITMqK14LABQBI+hZZ5wNf24JMcKLW+84AVsACAAAAAACzfjbTBH7IwDU91OqLAz94RFkoqBOkzKAqQb55gT4/MAAzI0AH0AAAAFZAAgAAAAAKsh0ADyOnVocFrOrf6MpTrNvAj8iaiE923DPryu124gBXMAIAAAAADg24a8NVE1GyScc6tmnTbmu5ulzO+896fE92lN08MeswVsACAAAAAAaPxcOIxnU7But88/yadOuDJDMcCywwrRitaxMODT4msAAzI1AH0AAAAFZAAgAAAAAKkVC2Y6HtRmv72tDnPUSjJBvse7SxLqnr09/Uuj9sVVBXMAIAAAAABYNFUkH7ylPMN+Bc3HWX1e0flGYNbtJNCY9SltJCW/UAVsACAAAAAAZYK/f9H4OeihmpiFMH7Wm7uLvs2s92zNA8wyrNZTsuMAAzI2AH0AAAAFZAAgAAAAADDggcwcb/Yn1Kk39sOHsv7BO/MfP3m/AJzjGH506Wf9BXMAIAAAAAAYZIsdjICS0+BDyRUPnrSAZfPrwtuMaEDEn0/ijLNQmAVsACAAAAAAGPnYVvo2ulO9z4LGd/69NAklfIcZqZvFX2KK0s+FcTUAAzI3AH0AAAAFZAAgAAAAAEWY7dEUOJBgjOoWVht1wLehsWAzB3rSOBtLgTuM2HC8BXMAIAAAAAAAoswiHRROurjwUW8u8D5EUT+67yvrgpB/j6PzBDAfVwVsACAAAAAA6NhRTYFL/Sz4tao7vpPjLNgAJ0FX6P/IyMW65qT6YsMAAzI4AH0AAAAFZAAgAAAAAPZaapeAUUFPA7JTCMOWHJa9lnPFh0/gXfAPjA1ezm4ZBXMAIAAAAACmJvLY2nivw7/b3DOKH/X7bBXjJwoowqb1GtEFO3OYgAVsACAAAAAA/JcUoyKacCB1NfmH8vYqC1f7rd13KShrQqV2r9QBP44AAzI5AH0AAAAFZAAgAAAAAK00u6jadxCZAiA+fTsPVDsnW5p5LCr4+kZZZOTDuZlfBXMAIAAAAAAote4zTEYMDgaaQbAdN8Dzv93ljPLdGjJzvnRn3KXgtQVsACAAAAAAxXd9Mh6R3mnJy8m7UfqMKi6oD5DlZpkaOz6bEjMOdiwAAzMwAH0AAAAFZAAgAAAAAFbgabdyymiEVYYwtJSWa7lfl/oYuj/SukzJeDOR6wPVBXMAIAAAAADAFGFjS1vPbN6mQEhkDYTD6V2V23Ys9gUEUMGNvMPkaAVsACAAAAAAL/D5Sze/ZoEanZLK0IeEkhgVkxEjMWVCfmJaD3a8uNIAAzMxAH0AAAAFZAAgAAAAABNMR6UBv2E627CqLtQ/eDYx7OEwQ7JrR4mSHFa1N8tLBXMAIAAAAAAxH4gucI4UmNVB7625C6hFSVCuIpJO3lusJlPuL8H5EQVsACAAAAAAVLHNg0OUVqZ7WGOP53BkTap9FOw9dr1P4J8HxqFqU04AAzMyAH0AAAAFZAAgAAAAAG8cd6WBneNunlqrQ2EmNf35W7OGObGq9WL4ePX+LUDmBXMAIAAAAAAjJ2+sX87NSis9hBsgb1QprVRnO7Bf+GObCGoUqyPE4wVsACAAAAAAs9c9SM49/pWmyUQKslpt3RTMBNSRppfNO0JBvUqHPg0AAzMzAH0AAAAFZAAgAAAAAFWOUGkUpy8yf6gB3dio/aOfRKh7XuhvsUj48iESFJrGBXMAIAAAAAAY7sCDMcrUXvNuL6dO0m11WyijzXZvPIcOKob6IpC4PQVsACAAAAAAJOP+EHz6awDb1qK2bZQ3kTV7wsj5Daj/IGAWh4g7omAAAzM0AH0AAAAFZAAgAAAAAGUrIdKxOihwNmo6B+aG+Ag1qa0+iqdksHOjQj+Oy9bZBXMAIAAAAABwa5dbI2KmzBDNBTQBEkjZv4sPaeRkRNejcjdVymRFKQVsACAAAAAA4ml/nm0gJNTcJ4vuD+T2Qfq2fQZlibJp/j6MOGDrbHMAAzM1AH0AAAAFZAAgAAAAAOx89xV/hRk64/CkM9N2EMK6aldII0c8smdcsZ46NbP8BXMAIAAAAADBF6tfQ+7q9kTuLyuyrSnDgmrdmrXkdhl980i1KHuGHgVsACAAAAAACUqiFqHZdGbwAA+hN0YUE5zFg+H+dabIB4dj5/75W/YAAzM2AH0AAAAFZAAgAAAAAMkN0L1oQWXhjwn9rAdudcYeN8/5VdCKU8cmDt7BokjsBXMAIAAAAAAT62pGXoRwExe9uvgYOI0hg5tOxilrWfoEmT0SMglWJwVsACAAAAAAlVz4dhiprSbUero6JFfxzSJGclg63oAkAmgbSwbcYxIAAzM3AH0AAAAFZAAgAAAAANxfa4xCoaaB7k1C1RoH1LBhsCbN2yEq15BT9b+iqEC4BXMAIAAAAACAX9LV8Pemfw7NF0iB1/85NzM1Ef+1mUfyehacUVgobQVsACAAAAAAVq4xpbymLk0trPC/a2MvB39I7hRiX8EJsVSI5E5hSBkAAzM4AH0AAAAFZAAgAAAAAOYIYoWkX7dGuyKfi3XssUlc7u/gWzqrR9KMkikKVdmSBXMAIAAAAABVF2OYjRTGi9Tw8XCAwZWLpX35Yl271TlNWp6N/nROhAVsACAAAAAA0nWwYzXQ1+EkDvnGq+SMlq20z+j32Su+i/A95SggPb4AAzM5AH0AAAAFZAAgAAAAAIy0+bXZi10QC+q7oSOLXK5Fee7VEk/qHSXukfeVIfgzBXMAIAAAAAAQ3IIV/JQCHW95AEbH5zGIHtJqyuPjWPMIZ+VmQHlxEwVsACAAAAAAp0jYsyohKv9Pm+4k+DplEGbl9WLZpAJzitrcDj4CNsMAAzQwAH0AAAAFZAAgAAAAAL5SOJQ3LOhgdXJ5v086NNeAl1qonQnchObdpZJ1kHeEBXMAIAAAAAA+tEqTXODtik+ydJZSnUqXF9f18bPeze9eWtR7ExZJgQVsACAAAAAAbrkZCVgB9Qsp4IAbdf+bD4fT6Boqk5UtuA/zhNrh1y0AAzQxAH0AAAAFZAAgAAAAAKl8zcHJRDjSjJeV/WvMxulW1zrTFtaeBy/aKKhadc6UBXMAIAAAAADBdWQl5SBIvtZZLIHszePwkO14W1mQ0izUk2Ov21cPNAVsACAAAAAAHErCYycpqiIcCZHdmPL1hi+ovLQk4TAvENpfLdTRamQAAzQyAH0AAAAFZAAgAAAAAFvotcNaoKnVt5CBCOPwjexFO0WGWuaIGL6H/6KSau+6BXMAIAAAAAD2y2mBN5xPu5PJoY2zcr0GnQDtHRBogA5+xzIxccE9fwVsACAAAAAAdS34xzJesnUfxLCcc1U7XzUqLy8MAzV/tcjbqaD3lkMAAzQzAH0AAAAFZAAgAAAAAPezU0/vNT4Q4YKbTbaeHqcwNLT+IjW/Y9QFpIooihjPBXMAIAAAAACj2x4O4rHter8ZnTws5LAP9jJ/6kk9C/V3vL50LoFZHAVsACAAAAAAQdBDF3747uCVP5lB/zr8VmzxJfTSZHBKeIgm5FyONXwAAzQ0AH0AAAAFZAAgAAAAAMqpayM2XotEFmm0gwQd9rIzApy0X+7HfOhNk6VU7F5lBXMAIAAAAACJR9+q5T9qFHXFNgGbZnPubG8rkO6cwWhzITQTmd6VgwVsACAAAAAAOZLQ6o7e4mVfDzbpQioa4d3RoTvqwgnbmc5Qh2wsZuoAAzQ1AH0AAAAFZAAgAAAAANCeyW+3oebaQk+aqxNVhAcT/BZ5nhsTVdKS3tMrLSvWBXMAIAAAAADxRFMDhkyuEc++WnndMfoUMLNL7T7rWoeblcrpSI6soQVsACAAAAAAdBuBMJ1lxt0DRq9pOZldQqchLs3B/W02txcMLD490FEAAzQ2AH0AAAAFZAAgAAAAAIbo5YBTxXM7HQhl7UP9NNgpPGFkBx871r1B65G47+K8BXMAIAAAAAC21dJSxnEhnxO5gzN5/34BL4von45e1meW92qowzb8fQVsACAAAAAAm3Hk2cvBN0ANaR5jzeZE5TsdxDvJCTOT1I01X7cNVaYAAzQ3AH0AAAAFZAAgAAAAABm/6pF96j26Jm7z5KkY1y33zcAEXLx2n0DwC03bs/ixBXMAIAAAAAD01OMvTZI/mqMgxIhA5nLs068mW+GKl3OW3ilf2D8+LgVsACAAAAAAaLvJDrqBESTNZSdcXsd+8GXPl8ZkUsGpeYuyYVv/kygAAzQ4AH0AAAAFZAAgAAAAAJ/D3+17gaQdkBqkL2wMwccdmCaVOtxzIkM8VyI4xI5zBXMAIAAAAAAggLVmkc5u+YzBR+oNE+XgLVp64fC6MzUb/Ilu/Jsw0AVsACAAAAAACz3HVKdWkx82/kGbVpcbAeZtsj2R5Zr0dEPfle4IErkAAzQ5AH0AAAAFZAAgAAAAAJMRyUW50oaTzspS6A3TUoXyC3gNYQoShUGPakMmeVZrBXMAIAAAAACona2Pqwt4U2PmFrtmu37jB9kQ/12okyAVtYa8TQkDiQVsACAAAAAAltJJKjCMyBTJ+4PkdDCPJdeX695P8P5h7WOZ+kmExMAAAzUwAH0AAAAFZAAgAAAAAByuYl8dBvfaZ0LO/81JW4hYypeNmvLMaxsIdvqMPrWoBXMAIAAAAABNddwobOUJzm9HOUD8BMZJqkNCUCqstHZkC76FIdNg9AVsACAAAAAAQQOkIQtkyNavqCnhQbNg3HfqrJdsAGaoxSJePJl1qXsAAzUxAH0AAAAFZAAgAAAAAHEzLtfmF/sBcYPPdj8867VmmQyU1xK9I/3Y0478azvABXMAIAAAAAAcmyFajZPnBTbO+oLInNwlApBocUekKkxz2hYFeSlQ+gVsACAAAAAAZ6IkrOVRcC8vSA6Vb4fPWZJrYexXhEabIuYIeXNsCSgAAzUyAH0AAAAFZAAgAAAAAJam7JYsZe2cN20ZYm2W3v1pisNt5PLiniMzymBLWyMtBXMAIAAAAABxCsKVMZMTn3n+R2L7pVz5nW804r8HcK0mCBw3jUXKXAVsACAAAAAA7j3JGnNtR64P4dJLeUoScFRGfa8ekjh3dvhw46sRFk0AAzUzAH0AAAAFZAAgAAAAAMXrXx0saZ+5gORmwM2FLuZG6iuO2YS+1IGPoAtDKoKBBXMAIAAAAADIQsxCr8CfFKaBcx8kIeSywnGh7JHjKRJ9vJd9x79y7wVsACAAAAAAcvBV+SykDYhmRFyVYwFYB9oBKBSHr55Jdz2cXeowsUQAAzU0AH0AAAAFZAAgAAAAACbzcUD3INSnCRspOKF7ubne74OK9L0FTZvi9Ay0JVDYBXMAIAAAAADPebVQH8Btk9rhBIoUOdSAdpPvz7qIY4UC2i6IGisSAQVsACAAAAAAiBunJi0mPnnXdnldiq+If8dcb/n6apHnaIFt+oyYO1kAAzU1AH0AAAAFZAAgAAAAACUc2CtD1MK/UTxtv+8iA9FoHEyTwdl43HKeSwDw2Lp5BXMAIAAAAACCIduIdw65bQMzRYRfjBJj62bc69T4QqH4QoWanwlvowVsACAAAAAAM0TV7S+aPVVzJOQ+cpSNKHTwyQ0mWa8tcHzfk3nR+9IAAzU2AH0AAAAFZAAgAAAAAHSaHWs/dnmI9sc7nB50VB2Bzs0kHapMHCQdyVEYY30TBXMAIAAAAACkV22lhEjWv/9/DubfHBAcwJggKI5mIbSK5L2nyqloqQVsACAAAAAAS19m7DccQxgryOsBJ3GsCs37yfQqNi1G+S6fCXpEhn4AAzU3AH0AAAAFZAAgAAAAAAL8jhNBG0KXXZhmZ0bPXtfgapJCB/AI+BEHB0eZ3C75BXMAIAAAAADHx/fPa639EBmGV5quLi8IQT600ifiKSOhTDOK19DnzwVsACAAAAAAlyLTDVkHxbayklD6Qymh3odIK1JHaOtps4f4HR+PcDgAAzU4AH0AAAAFZAAgAAAAAAxgeclNl09H7HvzD1oLwb2YpFca5eaX90uStYXHilqKBXMAIAAAAACMU5pSxzIzWlQxHyW170Xs9EhD1hURASQk+qkx7K5Y6AVsACAAAAAAJbMMwJfNftA7Xom8Bw/ghuZmSa3x12vTZxBUbV8m888AAzU5AH0AAAAFZAAgAAAAABmO7QD9vxWMmFjIHz13lyOeV6vHT6mYCsWxF7hb/yOjBXMAIAAAAACT9lmgkiqzuWG24afuzYiCeK9gmJqacmxAruIukd0xEAVsACAAAAAAZa0/FI/GkZR7CtX18Xg9Tn9zfxkD0UoaSt+pIO5t1t4AAzYwAH0AAAAFZAAgAAAAAB89SjLtDJkqEghRGyj6aQ/2qvWLNuMROoXmzbYbCMKMBXMAIAAAAAC8sywgND+CjhVTF6HnRQeay8y9/HnVzDI42dEPah28LQVsACAAAAAAoxv7UKh0RqUAWcOsQvU123zO1qZn73Xfib0qncZCB34AAzYxAH0AAAAFZAAgAAAAABN2alGq9Aats1mwERNGwL/fIwZSvVCe9/8XMHTFlpUpBXMAIAAAAACuDPjJgvvbBYhbLpjMiWUCsVppiYrhvR+yMysNPN8cZAVsACAAAAAAKpADjc4bzIZMi9Q/+oe0EMRJHYQt6dlo1x/lRquagqkAAzYyAH0AAAAFZAAgAAAAAL8YB6VAqGBiWD4CBv16IBscg5J7VQCTZu87n6pj+86KBXMAIAAAAAAmxm8e68geeyAdUjSMWBHzUjneVB0pG9TBXIoE6467hAVsACAAAAAAV76JZAlYpgC/Zl8awx2ArCg1uuyy2XVTSkp0wUMi/7UAAzYzAH0AAAAFZAAgAAAAAL4yLkCTV5Dmxa5toBu4JT8ge/cITAaURIOuFuOtFUkeBXMAIAAAAAAXoFNQOMGkAj7qEJP0wQafmFSXgWGeorDVbwyOxWLIsgVsACAAAAAAc4Un6dtIFe+AQ+RSfNWs3q63RTHhmyc+5GKRRdpWRv8AAzY0AH0AAAAFZAAgAAAAAEU8DoUp46YtYjNFS9kNXwdYxQ9IW27vCTb+VcqqfnKNBXMAIAAAAADe7vBOgYReE8X78k5ARuUnv4GmzPZzg6SbConf4L2G3wVsACAAAAAA78YHWVkp6HbZ0zS4UL2z/2pj9vPDcMDt7zTv6NcRsVsAAzY1AH0AAAAFZAAgAAAAAPa4yKTtkUtySuWo1ZQsp2QXtPb5SYqzA5vYDnS1P6c0BXMAIAAAAADKnF58R1sXlHlsHIvCBR3YWW/qk54z9CTDhZydkD1cOQVsACAAAAAAHW3ERalTFWKMzjuXF3nFh0pSrQxM/ojnPbPhc4v5MaQAAzY2AH0AAAAFZAAgAAAAAN5WJnMBmfgpuQPyonmY5X6OdRvuHw4nhsnGRnFAQ95VBXMAIAAAAACwftzu7KVV1rmGKwXtJjs3cJ1gE3apr8+N0SAg1F2cHwVsACAAAAAATDW0reyaCjbJuVLJzbSLx1OBuBoQu+090kgW4RurVacAAzY3AH0AAAAFZAAgAAAAACHvDsaPhoSb6DeGnKQ1QOpGYAgK82qpnqwcmzSeWaJHBXMAIAAAAABRq3C5+dOfnkAHM5Mg5hPB3O4jhwQlBgQWLA7Ph5bhgwVsACAAAAAAqkC8zYASvkVrp0pqmDyFCkPaDmD/ePAJpMuNOCBhni8AAzY4AH0AAAAFZAAgAAAAAOBePJvccPMJmy515KB1AkXF5Pi8NOG4V8psWy0SPRP+BXMAIAAAAAB3dOJG9xIDtEKCRzeNnPS3bFZepMj8UKBobKpSoCPqpgVsACAAAAAAPG3IxQVOdZrr509ggm5FKizWWoZPuVtOgOIGZ3m+pdEAAzY5AH0AAAAFZAAgAAAAABUvRrDQKEXLMdhnzXRdhiL6AGNs2TojPky+YVLXs+JnBXMAIAAAAAD1kYicbEEcPzD4QtuSYQQWDPq8fuUWGddpWayKn3dT9QVsACAAAAAA9+Sf7PbyFcY45hP9oTfjQiOUS3vEIAT8C0vOHymwYSUAAzcwAH0AAAAFZAAgAAAAAOvSnpujeKNen4pqc2HR63C5s5oJ1Vf4CsbKoYQvkwl5BXMAIAAAAACw2+vAMdibzd2YVVNfk81yXkFZP0WLJ82JBxJmXnYE+QVsACAAAAAArQ/E1ACyhK4ZyLqH9mNkCU7WClqRQTGyW9tciSGG/EMAAzcxAH0AAAAFZAAgAAAAAAo0xfGG7tJ3GWhgPVhW5Zn239nTD3PadShCNRc9TwdNBXMAIAAAAADZh243oOhenu0s/P/5KZLBDh9ADqKHtSWcXpO9D2sIjgVsACAAAAAAlgTPaoQKz+saU8rwCT3UiNOdG6hdpjzFx9GBn08ZkBEAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "u": { - "$set": { - "encryptedDoubleNoPrecision": { - "$$type": "binData" - } - } - } - } - ], - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoubleNoPrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - } - } - } - ] - } - } - }, - "$db": "default" - } - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6YrBn2ofIw1b5ooakrLOwF41BWrps8OO0H9WH4/rtlE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "n+XAuFnP8Dov9TnhGFxNx0K/MnVM9WbJ7RouEu0ndO0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yRXojuVdn5GQtD97qYlaCL6cOLmZ7Cvcb3wFjkLUIdM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DuIkdRPITRs55I4SZmgomAHCIsDQmXRhW8+MOznkzSk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SsBk+Et1lTbU+QRPx+xyJ/jMkmfG+QCvQEpip2YYrzA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "crCIzOd8KhHvvUlX7M1v9bhvU4pLdTc+X2SuqoKU5Ek=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "YOWdCw4UrqnxkAaVjqmC4sKQDMVMHEpFGnlxpxdaU6E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "M3SShp81Ff8tQ632qKbv9MUcN6wjDaBReI0VXNu6Xh4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gzHlSPxpM0hT75kQvWFzGlOxKvDoiKQZOr19V6l2zXI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "s3JnppOGYw9SL2Q1kMAZs948v2F5PrpXjGei/HioDWs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cG6+3Gk/zEH68P/uuuwiAUVCuyJwa1LeV+t29FlPPAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dupdvR3AyJtM+g9NDKiaLVOtGca387JQp8w+V03m7Ig=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JqEQc5svj2jTvZ6LLA5ivE+kTb/0aRemSEmxk4G7Zrg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "szcXXXKnob+p3SoM4yED2R920LeJ7cVsclPMFTe4CeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "o1QoGVXmuBdHwHm7aCtGMlMVKrjFdYvJXpoq6uhIAZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Jfm5wPlqqLCJRGQIqRq2NGmpn7s0Vrih2H3YAOoI2YU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zMHLb8ARbsYo8Ld05bqnGFf1Usha6EGb8QKwdSAyps0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yQdtq9lh5pugL7/i0Bj/PuZUUBUIzf+7wj1rl5y736w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wGWVZdO7qIuyDg/BqDgqjgoQ02h5YYgwXQB1oCin2NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "by9HMLj6NTEpgztZ5HSN6GxImkXPcaFINYDzgZY33X8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tWo0vbasi7bXmn/MsOx13VC1IsWtpx/nYp0uj4iMzdA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tQQpndUYd5O87lOtrGjH3wl9VsOK0ray7RMasL90sBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cQjXEDCMsOpKLLf+vlTgIHA+cbSJdzqhbSX9Wvh95aA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7yMpU48IxK9SzP2cx3VnTownGEwFmeFofuuFT97SuuY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kSOx1kz0CmBgzKQHZlo65ZUY1DIv9A99JRm+Us2y6Ew=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ubQpdPBe6/xvtr+AcXdfYLSvYCR4ot0tivehkCsupb4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xal+iCJ6FTefRQToyoNksc9NCZShyn04NDGi4IYrcoM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d7jU4iOK50xHxlkSifcxlZFCM46TSgQzoYivxG3HNLY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tJvl2nsBLBVzL3pp6sKWCL4UXeh3q/roYBJjSb74ve0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OIUCaKRvIx9t1w6Hxlz1IcQTdPNCfdRNwnnTm10W+X0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A9tvzsiElotOUVIB4CqfQp9mAwqvTM35YkmAR170aHA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lI8gpK7hpb7c9x4RQugsxMnQay5LZJmwslZdvMx/dcE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dNCzh40U0XvdKnSDi3HRQOWQftEsDVqc4uUvsVFGoq8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "IP+iwEBWBwVVZIdpaMu8k5+soFCz+TZkYn3drKZ9grE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pnqyh6e0y5svHkJDShlN9CHV0WvMBE4QbtJpQw5ZCXc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "elEl42tbVDoRTLjAhZUFEtXiut4b3PVhg/1ZLZSQdtE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vHuu2FxwclMHqyE6JBYbTYgbEkB0dqb/JuaxsvfwsmY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xTf7NCe3Gf8QpE78HR5OknlLTKfs9J+RN9UZpH6fnso=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XiWSasRnJAulGR6+LCVD3mwRObXylqYWR9jvpywq12c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MZMxEQ5ikx0PG1YFIExv0UnTZogsvgeOEZTpzvBDn4w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yZMyMZBDrWbAhvnic7vvIYhmO9m5H2iuv0c8KNZrBzY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xxM14hTPY5j0vvcK2C7YAEjzdsfUTFHozHC0hEo1bxI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+01rqR1xVwkpGXcstbk1ItJqFVjH6Q8MGxEN3Cm9Y1A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xOpLV0Z2VTRJ3iWtnWZcsyjXubTIkYWo31cO+HV1o1k=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BWUOLqgLBqc5NwxVlSV5H3KFQPXbCp7mdo+jF+8cJqY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "fuQb1S6xZDGlrEbK+kI23aL53PP1PVNwqICnZNt9Yzg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfscnoibFttahLdPVC4Ee+47ewGFKpDSU7M6HX19bKE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rpSW2awybNVeKtat91VFxqbINoTfNhPfQAu+d73Xtf8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "9M/CP9ccOIIj2LLFmE0GFDO0Ban2wsNalEXfM6+h+1s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WrEMG49l1ye4MhXs5ZS9tz8P6h+hDvthIg/2wW9ne1Q=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ImNhbfeyfH8qIEeA5ic0s3dAQBdzzTBS+CPsNih9vZ0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dWP33YDSn04UKJN2ogh2Rui0iW/0q2y18OCDRVcfyoo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "lYv0isAtfGh6H9tdp3cp2eHU7q2J+uk7QrgcxtK3w7Y=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "VGMoamB/+7zTOYcY/pqJc96xlv2PdW4hwsIAEIslTDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yNeBWMF7BnD9wVwz2PgJsvWr77QiVvvWUvJF0+fqBug=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SfpvObJ+tJBXSvqeN7vlOfmhYign635lciYAJIjUtY8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dsen4NqjzVGjpjufiTMs3+gqeD09EbnuogPgxrJECwg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "pxCWVM3sn19NsFEpgHbgLa+PmYlhN3mMiP0Wk8kJhYw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q11KNvJszjYIB9n9HcC+N4uz11a3eRj1L3BH9scKMDQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "A1PmkgcEToWh1JiVWE6mI5jUu7poxWWuCUt/cgRUUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "qJo3Hu4PJeanL7XEaWXO/n3YsodhZyd+MJOOmB9Kpd8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "BkBKLO8URFscfRY9Bav/1+L9mLohDgNr/MkZtGiraIs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "rZq5WA3Hx3xthOyHAJXK//f8pE2qbz7YKu3TIMp9GFY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X07a/Lm80p5xd4RFs1dNmw+90tmPDPdGiAKVZkxd4zY=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDoubleNoPrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "HI88j1zrIsFoijIXKybr9mYubNV5uVeODyLHFH4Ueco=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wXVD/HSbBljko0jJcaxJ1nrzs2+pchLQqYR3vywS8SU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "KhscCh+tt/pp8lxtKZQSPPUU94RvJYPKG/sjtzIa4Ws=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RISnuNrTTVNW5HnwCgQJ301pFw8DOcYrAMQIwVwjOkI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Ra5zukLh2boua0Bh74qA+mtIoixGXlsNsxiJqHtqdTI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "eqr0v+NNWXWszi9ni8qH58Q6gw5x737tJvH3lPaNHO4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "d42QupriWIwGrFAquXNFi0ehEuidIbHLFZtg1Sm2nN8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "2azRVxaaTIJKcgY2FU012gcyP8Y05cRDpfUaMnCBaQU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "3nlgkM4K/AAcHesRYYdEu24UGetHodVnVfHzw4yxZBM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hqy91FNmAAac2zUaPO6eWFkx0/37rOWGrwXN+fzL0tU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "akX+fmscSDSF9pB5MPj56iaJPtohr0hfXNk/OPWsGv8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1ZvUb10Q7cN4cNLktd5yNjqgtawsYnkbeVBZV6WuY/I=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "otCwtuKiY4hCyXvYzXvo10OcnzZppebo38KsAlq49QM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Mty8EscckeT/dhMfrPFyDbLnmMOcYRUQ3mLK4KTu6V8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "tnvgLLkJINO7csREYu4dEVe1ICrBeu7OP+HdfoX3M2E=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kOefsHgEVhkJ17UuP7Dxogy6sAQbzf1SFPKCj6XRlrQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F+JQ79xavpaHdJzdhvwyHbzdZJLNHAymc/+67La3gao=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "NCZ9zp5rDRceENuSgAfTLEyKg0YgmXAhK0B8WSj7+Pw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wL1CJ7cYR5slx8mHq++uMdjDfkt9037lQTUztEMF56M=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "txefkzTMITZE+XvvRFZ7QcgwDT/7m8jNmxRk4QBaoZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jFunW3v1tSYMyZtQQD28eEy9qqDp4Kqo7gMN29N4bfQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QMO915KUiS3X3R1bU1YoafVM2s0NeHo3EjgTA9PnGwY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "nwdKJEXdilzvb7494vbuDJ+y6SrfJahza1dYIsHIWVI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vpWMX+T/VXXajFo0UbuYjtp0AEzBU0Y+lP+ih2EQ7mg=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1lmzG0J1DhKDRhhq5y5Buygu4G8eV2X0t7kUY90EohM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SiKqpXqO0trwhFvBWK274hMklpCgMhNs/JY84yyn/NE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7cPGPYCKPTay+ZR9Gx6oOueduOgaFrSuAXmNDpDHXdI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4THEYvAkjs2Fh7FIe5LC45P4i4N0L7ob67UOVbhp6Nk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "B+UGsChLLZR7iqnt8yq91OgmTgwiUKTJhFxY4NT0O6c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X1uYwBCsCg1H+PnKdwtBqXlt0zKEURi8bOM940GcPfk=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xYOgT5l7shlNXCwHlguovmDkcEnF8dXyYlTyYrgZ8GE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "vFMTZqV8bh1+gcKzTkXweMddJlgdUnwX0DWzUUaMok4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4HI0y9FrtleZxZ7M6INdNhLelrQ2Rv/+ykWCBl+tMC8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jpJ0bBE474OUkn1vUiLWumIBtYmwc7J5+LQU/nyeLQc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jQTPeXZvdxY/DjtPfYfKUArIDsf0E9MVFy2O26sv1ec=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "QLLto0ExR2ZYMGqlyaMZc/hXFFTlwmgtKbiVq/xJIeI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yBJNviU1nchbGbhx6InXCVRXa90sEepz1EwbYuKXu2U=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jpEf0vHxrPu9gTJutNXSi2g/2Mc4WXFEN7yHonZEb7A=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "E09kLFckMYwNuhggMxmPtwndyvIAx+Vl+b2CV6FP75s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "N+ue6/cLPb5NssmJCCeo18LlbKPz6r2z20AsnTKRvOo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "yVQNZP8hhsvNGyDph2QP2qTNdXZTiIEVineKg+Qf33o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cSC9uI+9c5S8X+0G7amVyug1p0ZlgBsbEDYYyezBevQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1NpZGjoQzuQtekj80Rifxe9HbE08W07dfwxaFHaVn84=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "5Ghuq/8l11Ug9Uf/RTwf9On3OxOwIXUcb9soiy4J7/w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0LWKaEty6ywxLFhDaAqulqfMnYc+tgPfH4apyEeKg80=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "OwSthmCBtt6NIAoAh7aCbj82Yr/+9t8U7WuBQhFT3AQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "iYiyg6/1isqbMdvFPIGucu3cNM4NAZNtJhHpGZ4eM+c=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "waBgs8jWuGJPIF5zCRh6OmIyfK5GCBQgTMfmKSR2wyY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "1Jdtbe2BKJXPU2G9ywOrlODZ/cNYEQlKzAW3aMe1Hy4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xaLEnNUS/2ySerBpb9dN/D31t+wYcKekwTfkwtni0Mc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bIVBrOhOvr6cL55Tr24+B+CC9MiG7U6K54aAr2IXXuw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6Cdq5wroGu2TEFnekuT7LhOpd/K/+PcipIljcHU9QL4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "K5l64vI4S/pLviLW6Pl0U3iQkI3ge0xg4RAHcEsyKJo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "bzhuvZ0Ls22yIOX+Hz51eAHlSuDbWR/e0u4EhfdpHbc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Qv+fr6uD4o0bZRp69QJCFL6zvn3G82c7L+N1IFzj7H0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "XAmISMbD3aEyQT+BQEphCKFNa0F0GDKFuhM9cGceKoQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4VLCokntMfm1AogpUnYGvhV7nllWSo3mS3hVESMy+hA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "xiXNLj/CipEH63Vb5cidi8q9X47EF4f3HtJSOH7mfM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "4XlCYfYBjI9XA5zOSgTiEBYcZsdwyXL+f5XtH2xUIOc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "k6DfQy7ZYJIkEly2B5hjOZznL4NcgMkllZjJLb7yq7w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ZzM6gwWesa3lxbZVZthpPFs2s3GV0RZREE2zOMhBRBo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "US+jeMeeOd7J0wR0efJtq2/18lcO8YFvhT4O3DeaonQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b6iSxiI1FM9SzxuG1bHqGA1i4+3GOi0/SPW00XB4L7o=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kn3LsxAVkzIZKK9I6fi0Cctr0yjXOYgaQWMCoj4hLpM=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Aggregate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Aggregate.json deleted file mode 100644 index 4188685a2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Aggregate.json +++ /dev/null @@ -1,581 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range DoublePrecision. Aggregate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "default", - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$gt": { - "$binary": { - "base64": "DdIJAAADcGF5bG9hZACiCQAABGcAjgkAAAMwAH0AAAAFZAAgAAAAAHdJ2Vnb4MMzqVYVssjSdDy8XU4GVzMTfGifGETgQ2mYBXMAIAAAAAD7cFfKJGIXo6PjyeX2ria02CckW7dWFDoY/3FyBdm1NQVsACAAAAAAhEPSNv4M023A3hzNFuy83+hIKuZ2mKRY954N++aEOBUAAzEAfQAAAAVkACAAAAAAlmvfDrZoydUet4eCVMq7z6a58Ea+1HLJOWxN5lNcrWEFcwAgAAAAAEBo5AWZyC41b9ayjWNQSL4iYEAIwR/JG+ssN8bdoK9RBWwAIAAAAACEndE0SLxFSElOrNnqeX0EPmgDio3udZjVREy4JLS3sQADMgB9AAAABWQAIAAAAABbiLaoxAA6rinMJw1hC8ZUiq6UU1AQaPFn/py/Y06WuQVzACAAAAAAhtDasFkvYE7SCNu1je/hxdE9TJtAvvH3NtdEbKzNbCUFbAAgAAAAAIGepU1RSCF8sWODHEpKglsoqw3VBBH4a/URGxgGzbq2AAMzAH0AAAAFZAAgAAAAALORWwSr+tYNxcil2KIGSbNhTHvcPbdj+rLVQNx21S/KBXMAIAAAAAD6diZBkPEJ1cQy06LAxdbNK8Nlxbb44fH4Wk3Y3260nQVsACAAAAAA1eYAZBFHlDiaDAljWi8blGQ2nvvZa5AO5doeo0SFZsgAAzQAfQAAAAVkACAAAAAAG5XMK96PjClNlUvg82j4pMY1YxsznZfj4uNweD394FoFcwAgAAAAAKHgQLdGJHkrfFg9nB93Ac+3VgBw6aU44MTkKIQ91dZoBWwAIAAAAAAPxXmi+SDJ+40A0KdwfRczexlZQrHjIA+D3oUB0EY9tAADNQB9AAAABWQAIAAAAAA6M++b9I0YFemmWBAWAE3glu2Ah3Ta1FBxAQEIWS0toAVzACAAAAAANXYTqPf1Y6X3Ns6YQIX0C3FKCyWUo+Kk+fNcQvc0WSoFbAAgAAAAAA+uJUw1ICYgyeygSRe206VTWVtUnhdci3iHbyP5YtEVAAM2AH0AAAAFZAAgAAAAAKl8bV1riH/uyJ+X0HHd3+18k2cJl2dQFXCdoagutFcaBXMAIAAAAABm8F2Ew9f0VOABdcF+lP0Bi+zWvEUPniWgrxPq/Sx3uwVsACAAAAAAJfFErjZ6BPhsw5LjJLqNtKDLJ4zV0eIZppQpd9b0wZoAAzcAfQAAAAVkACAAAAAAsYZD8JEP6kYsPncFnNZwJxhu4YtUTKPNcjHtv67H+rYFcwAgAAAAAI4LqZcRkvbs/2F62Flu0pixNcor4WmBD0DHGaf039wLBWwAIAAAAAD4wUR3xd9lKltcqqo8LYvdMQWzCRobkV/ppKB/yn5dUgADOAB9AAAABWQAIAAAAAC0vdAi+dmoIXvZ5LqUqvyKV9/tHqSI2SWiSJO5pTnA2wVzACAAAAAAS2qvf9fvfVUH5WtsVxjxmskpGjYTQV34LwvQQw1y9wIFbAAgAAAAAE0+FKuK7HxbypvCeEJzMTcjOWE0ScYOlTBMUNlIv55hAAM5AH0AAAAFZAAgAAAAAH31lb/srBcrOXkzddCwAnclsR5/3QijEVgECs2JjOWBBXMAIAAAAABg7+prDT73YcCvLE5QbuIrqGcjLc5pQD2Miq0d29yrxgVsACAAAAAAetRiPwDSFWBzpWSWkOKWM6fKStRJ8SyObnpc79ux8p0AAzEwAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzExAH0AAAAFZAAgAAAAAFdthRhe2Q8CvxGIhjTJZv0Lk97GkHciTPxZ/mckLoNaBXMAIAAAAAAqOxsAr23LOVB0DIHbPf9UDJJRFXY2YoKbjhRqw5psbQVsACAAAAAA0G2GD8ZQjDBntjLpW4rqwKRS6HiUjL03g1N6chANozcAAzEyAH0AAAAFZAAgAAAAAMWymwwbvIeMqmnKWWifUqoCxOsdpnonM2qdLPyjqJO/BXMAIAAAAAB6IDmmpUhBD2zpRj8/y/kmOSXcjuIU14sNh6GKSsg2uwVsACAAAAAAWMFPNOk3EMSQDS9JGPSMIQP0oNGVugxXKKUrIPPlhHgAAzEzAH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzE0AH0AAAAFZAAgAAAAAJaRYmo8zqI2BEUzdSwp4tVRpPmVWsfydkYN3UHh6TMuBXMAIAAAAAAeD6mDnQeLlbC9i0sVgE8+RH6y+e94OJQ0tJ0PvblVSgVsACAAAAAAWp4jvretbDEsqEMzP/WLTnwOiJwCtfrCiB6m8k+yEMoAAzE1AH0AAAAFZAAgAAAAAAZZ538coNPwyRjhEwr5P8Xw32oWOJF+R+nfCGgy2qO3BXMAIAAAAACOPLnJlKwGNPDBReRKnHfteq0wFb3ezhrc7BVXs8RUHwVsACAAAAAA+lGesNk3+SyB/60rSvdQ2aN2vfJPR7llJVhufGTNhHkAAzE2AH0AAAAFZAAgAAAAAFH9l9GGA1I52atJV5jNUf1lx8jBjoEoVoME97v5GFJiBXMAIAAAAAC1qH3Kd78Dr9NGbw7y9D/XYBwv5h1LLO8la5OU7g8UkQVsACAAAAAArZ6atJCYrVfHB8dSNPOFf6nnDADBMJcIEj8ljPvxHp8AAzE3AH0AAAAFZAAgAAAAADtbVEI2tdkrowEMdkacD2w0Y3T3Ofi7PH6HmA6sP0c/BXMAIAAAAADuBSROnZHA+NgUPH8d0LnWFiDsM2bY8bzjC1+elSsIygVsACAAAAAAR0G2m+uANoWknkr/NerFcG+fECVxNIs0cqbY1t/U/0MAAzE4AH0AAAAFZAAgAAAAAAh3WpeMVlikPFYj9hLj+fmIqVt6omCSF75W3TPExyWpBXMAIAAAAAAsQkRmwqeVj2gGE03orb6PtrIzDt6dDU3hgSQi8E2wKgVsACAAAAAA3GHaRE2RAcaBRd8VzmYzWeBD2Gmy91eTK1k8YdWObZcAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - } - } - ], - "cursor": {}, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "aggregate" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dri0CXmL78L2DOgk9w0DwxHOMGMzih7m6l59vgy+WWo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b7d8mRzD1kI1tdc7uNL+YAUonJ6pODLsRLkArfEKSkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Xg8C1/A0KJaXOw4i+26Rv03/CydaaunOzXh0CIT+gn8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UoKUDw2wJYToUCcFaIs03YQSTksYR0MIOTJllwODqKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c/5cwAT0C5jber2xlJnWD3a5tVDy0nRtr5HG02hoFOY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wSUrRXavAGaajNeqC5mEUH1K67oYl5Wy9RNIzKjwLAM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vrp4wWDtHEgHWR99I70WVDzevg1Fk/Pw5U8gUDa0OU=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDoublePrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "mVZb+Ra0EYjQ4Zrh9X//E2T8MRj7NMqm5GUJXhRrBEI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FA74j21GUEJb1DJBOpR9nVnjaDZnd8yAQNuaW9Qi26g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kJv//KVkbrobIBf+QeWC5jxn20mx/P0R1N6aCSMgKM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB+Whi9IUUGxfLEe+lGuIzLX4LFbIhaIAm5lRk65QTc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ybO1QU3CgvhO8JgRXH+HxKszWcpl5aGDYYVa75fHa1g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X3Y3eSAbbMg//JgiHHiFpYOpV61t8kkDexI+CQyitH4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SlNHXyqVFGDPrX/2ppwog6l4pwj3PKda2TkZbqgfSfA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "McjV8xwTF3xI7863DYOBdyvIv6UpzThl6v9vBRk05bI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MgwakFvPyBlwqFTbhWUF79URJQWFoJTGotlEVSPPUsQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DyBERpMSD5lEM5Nhpcn4WGgxgn/mkUVJp+PYSLX5jsE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I43iazc0xj1WVbYB/V+uTL/tughN1bBlxh1iypBnNsA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wjOBa/ATMuOywFmuPgC0GF/oeLqu0Z7eK5udzkTPbis=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gRQVwiR+m+0Vg8ZDXqrQQcVnTyobwCXNaA4BCJVXtMc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WUZ6huwx0ZbLb0R00uiC9FOJzsUocUN8qE5+YRenkvQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7s79aKEuPgQcS/YPOOVcYNZvHIo7FFsWtFCrnDKXefA=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Correctness.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Correctness.json deleted file mode 100644 index 60f1ea7a3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Correctness.json +++ /dev/null @@ -1,1648 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "Find with $gt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "0.0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gte": { - "$numberDouble": "0.0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "1.0" - } - } - } - }, - "result": [] - } - ] - }, - { - "description": "Find with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$lt": { - "$numberDouble": "1.0" - } - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - ] - } - ] - }, - { - "description": "Find with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$lte": { - "$numberDouble": "1.0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $lt below min", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$lt": { - "$numberDouble": "0.0" - } - } - } - }, - "result": { - "errorContains": "must be greater than the range minimum" - } - } - ] - }, - { - "description": "Find with $gt above max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "200.0" - } - } - } - }, - "result": { - "errorContains": "must be less than the range max" - } - } - ] - }, - { - "description": "Find with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "0.0" - }, - "$lt": { - "$numberDouble": "2.0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - ] - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with full range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gte": { - "$numberDouble": "0.0" - }, - "$lte": { - "$numberDouble": "200.0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Find with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$in": [ - { - "$numberDouble": "0.0" - } - ] - } - } - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - ] - } - ] - }, - { - "description": "Insert out of range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "-1" - } - } - }, - "result": { - "errorContains": "value must be greater than or equal to the minimum value" - } - } - ] - }, - { - "description": "Insert min and max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 200, - "encryptedDoublePrecision": { - "$numberDouble": "200.0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": {}, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 200, - "encryptedDoublePrecision": { - "$numberDouble": "200.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$gte": { - "$numberDouble": "0.0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "1.0" - } - } - } - } - ] - }, - "result": [] - } - ] - }, - { - "description": "Aggregate with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$lt": { - "$numberDouble": "1.0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$lte": { - "$numberDouble": "1.0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lt below min", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$lt": { - "$numberDouble": "0.0" - } - } - } - } - ] - }, - "result": { - "errorContains": "must be greater than the range minimum" - } - } - ] - }, - { - "description": "Aggregate with $gt above max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "200.0" - } - } - } - } - ] - }, - "result": { - "errorContains": "must be less than the range max" - } - } - ] - }, - { - "description": "Aggregate with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "0.0" - }, - "$lt": { - "$numberDouble": "2.0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - ] - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with full range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$gte": { - "$numberDouble": "0.0" - }, - "$lte": { - "$numberDouble": "200.0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - }, - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1.0" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedDoublePrecision": { - "$in": [ - { - "$numberDouble": "0.0" - } - ] - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0.0" - } - } - ] - } - ] - }, - { - "description": "Wrong type: Insert Int", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberInt": "0" - } - } - }, - "result": { - "errorContains": "cannot encrypt element" - } - } - ] - }, - { - "description": "Wrong type: Find Int", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gte": { - "$numberInt": "0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": { - "errorContains": "field type is not supported" - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Delete.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Delete.json deleted file mode 100644 index 4ed591d3f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Delete.json +++ /dev/null @@ -1,469 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range DoublePrecision. Delete.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1" - } - } - } - }, - { - "name": "deleteOne", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "0" - } - } - } - }, - "result": { - "deletedCount": 1 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "delete": "default", - "deletes": [ - { - "q": { - "encryptedDoublePrecision": { - "$gt": { - "$binary": { - "base64": "DdIJAAADcGF5bG9hZACiCQAABGcAjgkAAAMwAH0AAAAFZAAgAAAAAHdJ2Vnb4MMzqVYVssjSdDy8XU4GVzMTfGifGETgQ2mYBXMAIAAAAAD7cFfKJGIXo6PjyeX2ria02CckW7dWFDoY/3FyBdm1NQVsACAAAAAAhEPSNv4M023A3hzNFuy83+hIKuZ2mKRY954N++aEOBUAAzEAfQAAAAVkACAAAAAAlmvfDrZoydUet4eCVMq7z6a58Ea+1HLJOWxN5lNcrWEFcwAgAAAAAEBo5AWZyC41b9ayjWNQSL4iYEAIwR/JG+ssN8bdoK9RBWwAIAAAAACEndE0SLxFSElOrNnqeX0EPmgDio3udZjVREy4JLS3sQADMgB9AAAABWQAIAAAAABbiLaoxAA6rinMJw1hC8ZUiq6UU1AQaPFn/py/Y06WuQVzACAAAAAAhtDasFkvYE7SCNu1je/hxdE9TJtAvvH3NtdEbKzNbCUFbAAgAAAAAIGepU1RSCF8sWODHEpKglsoqw3VBBH4a/URGxgGzbq2AAMzAH0AAAAFZAAgAAAAALORWwSr+tYNxcil2KIGSbNhTHvcPbdj+rLVQNx21S/KBXMAIAAAAAD6diZBkPEJ1cQy06LAxdbNK8Nlxbb44fH4Wk3Y3260nQVsACAAAAAA1eYAZBFHlDiaDAljWi8blGQ2nvvZa5AO5doeo0SFZsgAAzQAfQAAAAVkACAAAAAAG5XMK96PjClNlUvg82j4pMY1YxsznZfj4uNweD394FoFcwAgAAAAAKHgQLdGJHkrfFg9nB93Ac+3VgBw6aU44MTkKIQ91dZoBWwAIAAAAAAPxXmi+SDJ+40A0KdwfRczexlZQrHjIA+D3oUB0EY9tAADNQB9AAAABWQAIAAAAAA6M++b9I0YFemmWBAWAE3glu2Ah3Ta1FBxAQEIWS0toAVzACAAAAAANXYTqPf1Y6X3Ns6YQIX0C3FKCyWUo+Kk+fNcQvc0WSoFbAAgAAAAAA+uJUw1ICYgyeygSRe206VTWVtUnhdci3iHbyP5YtEVAAM2AH0AAAAFZAAgAAAAAKl8bV1riH/uyJ+X0HHd3+18k2cJl2dQFXCdoagutFcaBXMAIAAAAABm8F2Ew9f0VOABdcF+lP0Bi+zWvEUPniWgrxPq/Sx3uwVsACAAAAAAJfFErjZ6BPhsw5LjJLqNtKDLJ4zV0eIZppQpd9b0wZoAAzcAfQAAAAVkACAAAAAAsYZD8JEP6kYsPncFnNZwJxhu4YtUTKPNcjHtv67H+rYFcwAgAAAAAI4LqZcRkvbs/2F62Flu0pixNcor4WmBD0DHGaf039wLBWwAIAAAAAD4wUR3xd9lKltcqqo8LYvdMQWzCRobkV/ppKB/yn5dUgADOAB9AAAABWQAIAAAAAC0vdAi+dmoIXvZ5LqUqvyKV9/tHqSI2SWiSJO5pTnA2wVzACAAAAAAS2qvf9fvfVUH5WtsVxjxmskpGjYTQV34LwvQQw1y9wIFbAAgAAAAAE0+FKuK7HxbypvCeEJzMTcjOWE0ScYOlTBMUNlIv55hAAM5AH0AAAAFZAAgAAAAAH31lb/srBcrOXkzddCwAnclsR5/3QijEVgECs2JjOWBBXMAIAAAAABg7+prDT73YcCvLE5QbuIrqGcjLc5pQD2Miq0d29yrxgVsACAAAAAAetRiPwDSFWBzpWSWkOKWM6fKStRJ8SyObnpc79ux8p0AAzEwAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzExAH0AAAAFZAAgAAAAAFdthRhe2Q8CvxGIhjTJZv0Lk97GkHciTPxZ/mckLoNaBXMAIAAAAAAqOxsAr23LOVB0DIHbPf9UDJJRFXY2YoKbjhRqw5psbQVsACAAAAAA0G2GD8ZQjDBntjLpW4rqwKRS6HiUjL03g1N6chANozcAAzEyAH0AAAAFZAAgAAAAAMWymwwbvIeMqmnKWWifUqoCxOsdpnonM2qdLPyjqJO/BXMAIAAAAAB6IDmmpUhBD2zpRj8/y/kmOSXcjuIU14sNh6GKSsg2uwVsACAAAAAAWMFPNOk3EMSQDS9JGPSMIQP0oNGVugxXKKUrIPPlhHgAAzEzAH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzE0AH0AAAAFZAAgAAAAAJaRYmo8zqI2BEUzdSwp4tVRpPmVWsfydkYN3UHh6TMuBXMAIAAAAAAeD6mDnQeLlbC9i0sVgE8+RH6y+e94OJQ0tJ0PvblVSgVsACAAAAAAWp4jvretbDEsqEMzP/WLTnwOiJwCtfrCiB6m8k+yEMoAAzE1AH0AAAAFZAAgAAAAAAZZ538coNPwyRjhEwr5P8Xw32oWOJF+R+nfCGgy2qO3BXMAIAAAAACOPLnJlKwGNPDBReRKnHfteq0wFb3ezhrc7BVXs8RUHwVsACAAAAAA+lGesNk3+SyB/60rSvdQ2aN2vfJPR7llJVhufGTNhHkAAzE2AH0AAAAFZAAgAAAAAFH9l9GGA1I52atJV5jNUf1lx8jBjoEoVoME97v5GFJiBXMAIAAAAAC1qH3Kd78Dr9NGbw7y9D/XYBwv5h1LLO8la5OU7g8UkQVsACAAAAAArZ6atJCYrVfHB8dSNPOFf6nnDADBMJcIEj8ljPvxHp8AAzE3AH0AAAAFZAAgAAAAADtbVEI2tdkrowEMdkacD2w0Y3T3Ofi7PH6HmA6sP0c/BXMAIAAAAADuBSROnZHA+NgUPH8d0LnWFiDsM2bY8bzjC1+elSsIygVsACAAAAAAR0G2m+uANoWknkr/NerFcG+fECVxNIs0cqbY1t/U/0MAAzE4AH0AAAAFZAAgAAAAAAh3WpeMVlikPFYj9hLj+fmIqVt6omCSF75W3TPExyWpBXMAIAAAAAAsQkRmwqeVj2gGE03orb6PtrIzDt6dDU3hgSQi8E2wKgVsACAAAAAA3GHaRE2RAcaBRd8VzmYzWeBD2Gmy91eTK1k8YdWObZcAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "limit": 1 - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "delete" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dri0CXmL78L2DOgk9w0DwxHOMGMzih7m6l59vgy+WWo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b7d8mRzD1kI1tdc7uNL+YAUonJ6pODLsRLkArfEKSkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Xg8C1/A0KJaXOw4i+26Rv03/CydaaunOzXh0CIT+gn8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UoKUDw2wJYToUCcFaIs03YQSTksYR0MIOTJllwODqKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c/5cwAT0C5jber2xlJnWD3a5tVDy0nRtr5HG02hoFOY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wSUrRXavAGaajNeqC5mEUH1K67oYl5Wy9RNIzKjwLAM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vrp4wWDtHEgHWR99I70WVDzevg1Fk/Pw5U8gUDa0OU=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-FindOneAndUpdate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-FindOneAndUpdate.json deleted file mode 100644 index d8fbbfae7..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-FindOneAndUpdate.json +++ /dev/null @@ -1,585 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range DoublePrecision. FindOneAndUpdate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1" - } - } - } - }, - { - "name": "findOneAndUpdate", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "0" - } - } - }, - "update": { - "$set": { - "encryptedDoublePrecision": { - "$numberDouble": "2" - } - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1" - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "default", - "query": { - "encryptedDoublePrecision": { - "$gt": { - "$binary": { - "base64": "DdIJAAADcGF5bG9hZACiCQAABGcAjgkAAAMwAH0AAAAFZAAgAAAAAHdJ2Vnb4MMzqVYVssjSdDy8XU4GVzMTfGifGETgQ2mYBXMAIAAAAAD7cFfKJGIXo6PjyeX2ria02CckW7dWFDoY/3FyBdm1NQVsACAAAAAAhEPSNv4M023A3hzNFuy83+hIKuZ2mKRY954N++aEOBUAAzEAfQAAAAVkACAAAAAAlmvfDrZoydUet4eCVMq7z6a58Ea+1HLJOWxN5lNcrWEFcwAgAAAAAEBo5AWZyC41b9ayjWNQSL4iYEAIwR/JG+ssN8bdoK9RBWwAIAAAAACEndE0SLxFSElOrNnqeX0EPmgDio3udZjVREy4JLS3sQADMgB9AAAABWQAIAAAAABbiLaoxAA6rinMJw1hC8ZUiq6UU1AQaPFn/py/Y06WuQVzACAAAAAAhtDasFkvYE7SCNu1je/hxdE9TJtAvvH3NtdEbKzNbCUFbAAgAAAAAIGepU1RSCF8sWODHEpKglsoqw3VBBH4a/URGxgGzbq2AAMzAH0AAAAFZAAgAAAAALORWwSr+tYNxcil2KIGSbNhTHvcPbdj+rLVQNx21S/KBXMAIAAAAAD6diZBkPEJ1cQy06LAxdbNK8Nlxbb44fH4Wk3Y3260nQVsACAAAAAA1eYAZBFHlDiaDAljWi8blGQ2nvvZa5AO5doeo0SFZsgAAzQAfQAAAAVkACAAAAAAG5XMK96PjClNlUvg82j4pMY1YxsznZfj4uNweD394FoFcwAgAAAAAKHgQLdGJHkrfFg9nB93Ac+3VgBw6aU44MTkKIQ91dZoBWwAIAAAAAAPxXmi+SDJ+40A0KdwfRczexlZQrHjIA+D3oUB0EY9tAADNQB9AAAABWQAIAAAAAA6M++b9I0YFemmWBAWAE3glu2Ah3Ta1FBxAQEIWS0toAVzACAAAAAANXYTqPf1Y6X3Ns6YQIX0C3FKCyWUo+Kk+fNcQvc0WSoFbAAgAAAAAA+uJUw1ICYgyeygSRe206VTWVtUnhdci3iHbyP5YtEVAAM2AH0AAAAFZAAgAAAAAKl8bV1riH/uyJ+X0HHd3+18k2cJl2dQFXCdoagutFcaBXMAIAAAAABm8F2Ew9f0VOABdcF+lP0Bi+zWvEUPniWgrxPq/Sx3uwVsACAAAAAAJfFErjZ6BPhsw5LjJLqNtKDLJ4zV0eIZppQpd9b0wZoAAzcAfQAAAAVkACAAAAAAsYZD8JEP6kYsPncFnNZwJxhu4YtUTKPNcjHtv67H+rYFcwAgAAAAAI4LqZcRkvbs/2F62Flu0pixNcor4WmBD0DHGaf039wLBWwAIAAAAAD4wUR3xd9lKltcqqo8LYvdMQWzCRobkV/ppKB/yn5dUgADOAB9AAAABWQAIAAAAAC0vdAi+dmoIXvZ5LqUqvyKV9/tHqSI2SWiSJO5pTnA2wVzACAAAAAAS2qvf9fvfVUH5WtsVxjxmskpGjYTQV34LwvQQw1y9wIFbAAgAAAAAE0+FKuK7HxbypvCeEJzMTcjOWE0ScYOlTBMUNlIv55hAAM5AH0AAAAFZAAgAAAAAH31lb/srBcrOXkzddCwAnclsR5/3QijEVgECs2JjOWBBXMAIAAAAABg7+prDT73YcCvLE5QbuIrqGcjLc5pQD2Miq0d29yrxgVsACAAAAAAetRiPwDSFWBzpWSWkOKWM6fKStRJ8SyObnpc79ux8p0AAzEwAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzExAH0AAAAFZAAgAAAAAFdthRhe2Q8CvxGIhjTJZv0Lk97GkHciTPxZ/mckLoNaBXMAIAAAAAAqOxsAr23LOVB0DIHbPf9UDJJRFXY2YoKbjhRqw5psbQVsACAAAAAA0G2GD8ZQjDBntjLpW4rqwKRS6HiUjL03g1N6chANozcAAzEyAH0AAAAFZAAgAAAAAMWymwwbvIeMqmnKWWifUqoCxOsdpnonM2qdLPyjqJO/BXMAIAAAAAB6IDmmpUhBD2zpRj8/y/kmOSXcjuIU14sNh6GKSsg2uwVsACAAAAAAWMFPNOk3EMSQDS9JGPSMIQP0oNGVugxXKKUrIPPlhHgAAzEzAH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzE0AH0AAAAFZAAgAAAAAJaRYmo8zqI2BEUzdSwp4tVRpPmVWsfydkYN3UHh6TMuBXMAIAAAAAAeD6mDnQeLlbC9i0sVgE8+RH6y+e94OJQ0tJ0PvblVSgVsACAAAAAAWp4jvretbDEsqEMzP/WLTnwOiJwCtfrCiB6m8k+yEMoAAzE1AH0AAAAFZAAgAAAAAAZZ538coNPwyRjhEwr5P8Xw32oWOJF+R+nfCGgy2qO3BXMAIAAAAACOPLnJlKwGNPDBReRKnHfteq0wFb3ezhrc7BVXs8RUHwVsACAAAAAA+lGesNk3+SyB/60rSvdQ2aN2vfJPR7llJVhufGTNhHkAAzE2AH0AAAAFZAAgAAAAAFH9l9GGA1I52atJV5jNUf1lx8jBjoEoVoME97v5GFJiBXMAIAAAAAC1qH3Kd78Dr9NGbw7y9D/XYBwv5h1LLO8la5OU7g8UkQVsACAAAAAArZ6atJCYrVfHB8dSNPOFf6nnDADBMJcIEj8ljPvxHp8AAzE3AH0AAAAFZAAgAAAAADtbVEI2tdkrowEMdkacD2w0Y3T3Ofi7PH6HmA6sP0c/BXMAIAAAAADuBSROnZHA+NgUPH8d0LnWFiDsM2bY8bzjC1+elSsIygVsACAAAAAAR0G2m+uANoWknkr/NerFcG+fECVxNIs0cqbY1t/U/0MAAzE4AH0AAAAFZAAgAAAAAAh3WpeMVlikPFYj9hLj+fmIqVt6omCSF75W3TPExyWpBXMAIAAAAAAsQkRmwqeVj2gGE03orb6PtrIzDt6dDU3hgSQi8E2wKgVsACAAAAAA3GHaRE2RAcaBRd8VzmYzWeBD2Gmy91eTK1k8YdWObZcAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "update": { - "$set": { - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "findAndModify" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dri0CXmL78L2DOgk9w0DwxHOMGMzih7m6l59vgy+WWo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b7d8mRzD1kI1tdc7uNL+YAUonJ6pODLsRLkArfEKSkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Xg8C1/A0KJaXOw4i+26Rv03/CydaaunOzXh0CIT+gn8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UoKUDw2wJYToUCcFaIs03YQSTksYR0MIOTJllwODqKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c/5cwAT0C5jber2xlJnWD3a5tVDy0nRtr5HG02hoFOY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wSUrRXavAGaajNeqC5mEUH1K67oYl5Wy9RNIzKjwLAM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vrp4wWDtHEgHWR99I70WVDzevg1Fk/Pw5U8gUDa0OU=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDoublePrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "V6knyt7Zq2CG3++l75UtBx2m32iGAPjHiAe439Bf02w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F08nMDWDZc+DbWM7XCEJNNCEYyinRmrvGP7EWhmp4is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cXH4688amcDc8kZOJq4UP8cE3R58Zl7e+Qo/1jyspps=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uURBxvTp3FBCVkd+LPqyuY7d6rMW6SGIJQEPY/wtkZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jG3hax1L3RBp9t38vUt53FsBxgr/+Si/vVISpAylYpE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kwtIW8MhH9Ky5xNjBx8gFA/SHh2YVphie7g5FGBzals=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FHflwFuEMu4xX0ZApHi+pdlBH+oevAtXckCUb5Wv0xU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0OKSXELxPP85SBVwDGf3LtMEQCJ8TTkFUl/+6jlkdb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uEw0lpQtBppR3vqV9j9+NQRSBF1BzZukb8c9IhyWvxc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zVhZ7Q59O087ji49oMJvBIgeir2oqvUpnh4p53GcTow=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dowrzKs+qJhRMZyKDbhjXbuX43FbmUKOaw9I8YlOZDw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ep5B6cska6THLIF7Mn3tn3RvV9EiwLSt0eZM/CLRUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "URNp/YmmDh5wIZUfAzzgPyJeMNiVx9PMsz52DZRujGY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wlM4IAQhhKQEzoVqS8b1Ddd50GB95OFb9LnzOwyjCP4=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-InsertFind.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-InsertFind.json deleted file mode 100644 index 4213b066d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-InsertFind.json +++ /dev/null @@ -1,572 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range DoublePrecision. Insert and Find.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "find": "default", - "filter": { - "encryptedDoublePrecision": { - "$gt": { - "$binary": { - "base64": "DdIJAAADcGF5bG9hZACiCQAABGcAjgkAAAMwAH0AAAAFZAAgAAAAAHdJ2Vnb4MMzqVYVssjSdDy8XU4GVzMTfGifGETgQ2mYBXMAIAAAAAD7cFfKJGIXo6PjyeX2ria02CckW7dWFDoY/3FyBdm1NQVsACAAAAAAhEPSNv4M023A3hzNFuy83+hIKuZ2mKRY954N++aEOBUAAzEAfQAAAAVkACAAAAAAlmvfDrZoydUet4eCVMq7z6a58Ea+1HLJOWxN5lNcrWEFcwAgAAAAAEBo5AWZyC41b9ayjWNQSL4iYEAIwR/JG+ssN8bdoK9RBWwAIAAAAACEndE0SLxFSElOrNnqeX0EPmgDio3udZjVREy4JLS3sQADMgB9AAAABWQAIAAAAABbiLaoxAA6rinMJw1hC8ZUiq6UU1AQaPFn/py/Y06WuQVzACAAAAAAhtDasFkvYE7SCNu1je/hxdE9TJtAvvH3NtdEbKzNbCUFbAAgAAAAAIGepU1RSCF8sWODHEpKglsoqw3VBBH4a/URGxgGzbq2AAMzAH0AAAAFZAAgAAAAALORWwSr+tYNxcil2KIGSbNhTHvcPbdj+rLVQNx21S/KBXMAIAAAAAD6diZBkPEJ1cQy06LAxdbNK8Nlxbb44fH4Wk3Y3260nQVsACAAAAAA1eYAZBFHlDiaDAljWi8blGQ2nvvZa5AO5doeo0SFZsgAAzQAfQAAAAVkACAAAAAAG5XMK96PjClNlUvg82j4pMY1YxsznZfj4uNweD394FoFcwAgAAAAAKHgQLdGJHkrfFg9nB93Ac+3VgBw6aU44MTkKIQ91dZoBWwAIAAAAAAPxXmi+SDJ+40A0KdwfRczexlZQrHjIA+D3oUB0EY9tAADNQB9AAAABWQAIAAAAAA6M++b9I0YFemmWBAWAE3glu2Ah3Ta1FBxAQEIWS0toAVzACAAAAAANXYTqPf1Y6X3Ns6YQIX0C3FKCyWUo+Kk+fNcQvc0WSoFbAAgAAAAAA+uJUw1ICYgyeygSRe206VTWVtUnhdci3iHbyP5YtEVAAM2AH0AAAAFZAAgAAAAAKl8bV1riH/uyJ+X0HHd3+18k2cJl2dQFXCdoagutFcaBXMAIAAAAABm8F2Ew9f0VOABdcF+lP0Bi+zWvEUPniWgrxPq/Sx3uwVsACAAAAAAJfFErjZ6BPhsw5LjJLqNtKDLJ4zV0eIZppQpd9b0wZoAAzcAfQAAAAVkACAAAAAAsYZD8JEP6kYsPncFnNZwJxhu4YtUTKPNcjHtv67H+rYFcwAgAAAAAI4LqZcRkvbs/2F62Flu0pixNcor4WmBD0DHGaf039wLBWwAIAAAAAD4wUR3xd9lKltcqqo8LYvdMQWzCRobkV/ppKB/yn5dUgADOAB9AAAABWQAIAAAAAC0vdAi+dmoIXvZ5LqUqvyKV9/tHqSI2SWiSJO5pTnA2wVzACAAAAAAS2qvf9fvfVUH5WtsVxjxmskpGjYTQV34LwvQQw1y9wIFbAAgAAAAAE0+FKuK7HxbypvCeEJzMTcjOWE0ScYOlTBMUNlIv55hAAM5AH0AAAAFZAAgAAAAAH31lb/srBcrOXkzddCwAnclsR5/3QijEVgECs2JjOWBBXMAIAAAAABg7+prDT73YcCvLE5QbuIrqGcjLc5pQD2Miq0d29yrxgVsACAAAAAAetRiPwDSFWBzpWSWkOKWM6fKStRJ8SyObnpc79ux8p0AAzEwAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzExAH0AAAAFZAAgAAAAAFdthRhe2Q8CvxGIhjTJZv0Lk97GkHciTPxZ/mckLoNaBXMAIAAAAAAqOxsAr23LOVB0DIHbPf9UDJJRFXY2YoKbjhRqw5psbQVsACAAAAAA0G2GD8ZQjDBntjLpW4rqwKRS6HiUjL03g1N6chANozcAAzEyAH0AAAAFZAAgAAAAAMWymwwbvIeMqmnKWWifUqoCxOsdpnonM2qdLPyjqJO/BXMAIAAAAAB6IDmmpUhBD2zpRj8/y/kmOSXcjuIU14sNh6GKSsg2uwVsACAAAAAAWMFPNOk3EMSQDS9JGPSMIQP0oNGVugxXKKUrIPPlhHgAAzEzAH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzE0AH0AAAAFZAAgAAAAAJaRYmo8zqI2BEUzdSwp4tVRpPmVWsfydkYN3UHh6TMuBXMAIAAAAAAeD6mDnQeLlbC9i0sVgE8+RH6y+e94OJQ0tJ0PvblVSgVsACAAAAAAWp4jvretbDEsqEMzP/WLTnwOiJwCtfrCiB6m8k+yEMoAAzE1AH0AAAAFZAAgAAAAAAZZ538coNPwyRjhEwr5P8Xw32oWOJF+R+nfCGgy2qO3BXMAIAAAAACOPLnJlKwGNPDBReRKnHfteq0wFb3ezhrc7BVXs8RUHwVsACAAAAAA+lGesNk3+SyB/60rSvdQ2aN2vfJPR7llJVhufGTNhHkAAzE2AH0AAAAFZAAgAAAAAFH9l9GGA1I52atJV5jNUf1lx8jBjoEoVoME97v5GFJiBXMAIAAAAAC1qH3Kd78Dr9NGbw7y9D/XYBwv5h1LLO8la5OU7g8UkQVsACAAAAAArZ6atJCYrVfHB8dSNPOFf6nnDADBMJcIEj8ljPvxHp8AAzE3AH0AAAAFZAAgAAAAADtbVEI2tdkrowEMdkacD2w0Y3T3Ofi7PH6HmA6sP0c/BXMAIAAAAADuBSROnZHA+NgUPH8d0LnWFiDsM2bY8bzjC1+elSsIygVsACAAAAAAR0G2m+uANoWknkr/NerFcG+fECVxNIs0cqbY1t/U/0MAAzE4AH0AAAAFZAAgAAAAAAh3WpeMVlikPFYj9hLj+fmIqVt6omCSF75W3TPExyWpBXMAIAAAAAAsQkRmwqeVj2gGE03orb6PtrIzDt6dDU3hgSQi8E2wKgVsACAAAAAA3GHaRE2RAcaBRd8VzmYzWeBD2Gmy91eTK1k8YdWObZcAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "find" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dri0CXmL78L2DOgk9w0DwxHOMGMzih7m6l59vgy+WWo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b7d8mRzD1kI1tdc7uNL+YAUonJ6pODLsRLkArfEKSkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Xg8C1/A0KJaXOw4i+26Rv03/CydaaunOzXh0CIT+gn8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UoKUDw2wJYToUCcFaIs03YQSTksYR0MIOTJllwODqKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c/5cwAT0C5jber2xlJnWD3a5tVDy0nRtr5HG02hoFOY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wSUrRXavAGaajNeqC5mEUH1K67oYl5Wy9RNIzKjwLAM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vrp4wWDtHEgHWR99I70WVDzevg1Fk/Pw5U8gUDa0OU=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDoublePrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "mVZb+Ra0EYjQ4Zrh9X//E2T8MRj7NMqm5GUJXhRrBEI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FA74j21GUEJb1DJBOpR9nVnjaDZnd8yAQNuaW9Qi26g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kJv//KVkbrobIBf+QeWC5jxn20mx/P0R1N6aCSMgKM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB+Whi9IUUGxfLEe+lGuIzLX4LFbIhaIAm5lRk65QTc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ybO1QU3CgvhO8JgRXH+HxKszWcpl5aGDYYVa75fHa1g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X3Y3eSAbbMg//JgiHHiFpYOpV61t8kkDexI+CQyitH4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SlNHXyqVFGDPrX/2ppwog6l4pwj3PKda2TkZbqgfSfA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "McjV8xwTF3xI7863DYOBdyvIv6UpzThl6v9vBRk05bI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "MgwakFvPyBlwqFTbhWUF79URJQWFoJTGotlEVSPPUsQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "DyBERpMSD5lEM5Nhpcn4WGgxgn/mkUVJp+PYSLX5jsE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "I43iazc0xj1WVbYB/V+uTL/tughN1bBlxh1iypBnNsA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wjOBa/ATMuOywFmuPgC0GF/oeLqu0Z7eK5udzkTPbis=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "gRQVwiR+m+0Vg8ZDXqrQQcVnTyobwCXNaA4BCJVXtMc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "WUZ6huwx0ZbLb0R00uiC9FOJzsUocUN8qE5+YRenkvQ=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "7s79aKEuPgQcS/YPOOVcYNZvHIo7FFsWtFCrnDKXefA=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Update.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Update.json deleted file mode 100644 index 89eb4c338..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-DoublePrecision-Update.json +++ /dev/null @@ -1,589 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range DoublePrecision. Update.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedDoublePrecision": { - "$numberDouble": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedDoublePrecision": { - "$numberDouble": "1" - } - } - } - }, - { - "name": "updateOne", - "arguments": { - "filter": { - "encryptedDoublePrecision": { - "$gt": { - "$numberDouble": "0" - } - } - }, - "update": { - "$set": { - "encryptedDoublePrecision": { - "$numberDouble": "2" - } - } - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command_name": "update", - "command": { - "update": "default", - "ordered": true, - "updates": [ - { - "q": { - "encryptedDoublePrecision": { - "$gt": { - "$binary": { - "base64": "DdIJAAADcGF5bG9hZACiCQAABGcAjgkAAAMwAH0AAAAFZAAgAAAAAHdJ2Vnb4MMzqVYVssjSdDy8XU4GVzMTfGifGETgQ2mYBXMAIAAAAAD7cFfKJGIXo6PjyeX2ria02CckW7dWFDoY/3FyBdm1NQVsACAAAAAAhEPSNv4M023A3hzNFuy83+hIKuZ2mKRY954N++aEOBUAAzEAfQAAAAVkACAAAAAAlmvfDrZoydUet4eCVMq7z6a58Ea+1HLJOWxN5lNcrWEFcwAgAAAAAEBo5AWZyC41b9ayjWNQSL4iYEAIwR/JG+ssN8bdoK9RBWwAIAAAAACEndE0SLxFSElOrNnqeX0EPmgDio3udZjVREy4JLS3sQADMgB9AAAABWQAIAAAAABbiLaoxAA6rinMJw1hC8ZUiq6UU1AQaPFn/py/Y06WuQVzACAAAAAAhtDasFkvYE7SCNu1je/hxdE9TJtAvvH3NtdEbKzNbCUFbAAgAAAAAIGepU1RSCF8sWODHEpKglsoqw3VBBH4a/URGxgGzbq2AAMzAH0AAAAFZAAgAAAAALORWwSr+tYNxcil2KIGSbNhTHvcPbdj+rLVQNx21S/KBXMAIAAAAAD6diZBkPEJ1cQy06LAxdbNK8Nlxbb44fH4Wk3Y3260nQVsACAAAAAA1eYAZBFHlDiaDAljWi8blGQ2nvvZa5AO5doeo0SFZsgAAzQAfQAAAAVkACAAAAAAG5XMK96PjClNlUvg82j4pMY1YxsznZfj4uNweD394FoFcwAgAAAAAKHgQLdGJHkrfFg9nB93Ac+3VgBw6aU44MTkKIQ91dZoBWwAIAAAAAAPxXmi+SDJ+40A0KdwfRczexlZQrHjIA+D3oUB0EY9tAADNQB9AAAABWQAIAAAAAA6M++b9I0YFemmWBAWAE3glu2Ah3Ta1FBxAQEIWS0toAVzACAAAAAANXYTqPf1Y6X3Ns6YQIX0C3FKCyWUo+Kk+fNcQvc0WSoFbAAgAAAAAA+uJUw1ICYgyeygSRe206VTWVtUnhdci3iHbyP5YtEVAAM2AH0AAAAFZAAgAAAAAKl8bV1riH/uyJ+X0HHd3+18k2cJl2dQFXCdoagutFcaBXMAIAAAAABm8F2Ew9f0VOABdcF+lP0Bi+zWvEUPniWgrxPq/Sx3uwVsACAAAAAAJfFErjZ6BPhsw5LjJLqNtKDLJ4zV0eIZppQpd9b0wZoAAzcAfQAAAAVkACAAAAAAsYZD8JEP6kYsPncFnNZwJxhu4YtUTKPNcjHtv67H+rYFcwAgAAAAAI4LqZcRkvbs/2F62Flu0pixNcor4WmBD0DHGaf039wLBWwAIAAAAAD4wUR3xd9lKltcqqo8LYvdMQWzCRobkV/ppKB/yn5dUgADOAB9AAAABWQAIAAAAAC0vdAi+dmoIXvZ5LqUqvyKV9/tHqSI2SWiSJO5pTnA2wVzACAAAAAAS2qvf9fvfVUH5WtsVxjxmskpGjYTQV34LwvQQw1y9wIFbAAgAAAAAE0+FKuK7HxbypvCeEJzMTcjOWE0ScYOlTBMUNlIv55hAAM5AH0AAAAFZAAgAAAAAH31lb/srBcrOXkzddCwAnclsR5/3QijEVgECs2JjOWBBXMAIAAAAABg7+prDT73YcCvLE5QbuIrqGcjLc5pQD2Miq0d29yrxgVsACAAAAAAetRiPwDSFWBzpWSWkOKWM6fKStRJ8SyObnpc79ux8p0AAzEwAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzExAH0AAAAFZAAgAAAAAFdthRhe2Q8CvxGIhjTJZv0Lk97GkHciTPxZ/mckLoNaBXMAIAAAAAAqOxsAr23LOVB0DIHbPf9UDJJRFXY2YoKbjhRqw5psbQVsACAAAAAA0G2GD8ZQjDBntjLpW4rqwKRS6HiUjL03g1N6chANozcAAzEyAH0AAAAFZAAgAAAAAMWymwwbvIeMqmnKWWifUqoCxOsdpnonM2qdLPyjqJO/BXMAIAAAAAB6IDmmpUhBD2zpRj8/y/kmOSXcjuIU14sNh6GKSsg2uwVsACAAAAAAWMFPNOk3EMSQDS9JGPSMIQP0oNGVugxXKKUrIPPlhHgAAzEzAH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzE0AH0AAAAFZAAgAAAAAJaRYmo8zqI2BEUzdSwp4tVRpPmVWsfydkYN3UHh6TMuBXMAIAAAAAAeD6mDnQeLlbC9i0sVgE8+RH6y+e94OJQ0tJ0PvblVSgVsACAAAAAAWp4jvretbDEsqEMzP/WLTnwOiJwCtfrCiB6m8k+yEMoAAzE1AH0AAAAFZAAgAAAAAAZZ538coNPwyRjhEwr5P8Xw32oWOJF+R+nfCGgy2qO3BXMAIAAAAACOPLnJlKwGNPDBReRKnHfteq0wFb3ezhrc7BVXs8RUHwVsACAAAAAA+lGesNk3+SyB/60rSvdQ2aN2vfJPR7llJVhufGTNhHkAAzE2AH0AAAAFZAAgAAAAAFH9l9GGA1I52atJV5jNUf1lx8jBjoEoVoME97v5GFJiBXMAIAAAAAC1qH3Kd78Dr9NGbw7y9D/XYBwv5h1LLO8la5OU7g8UkQVsACAAAAAArZ6atJCYrVfHB8dSNPOFf6nnDADBMJcIEj8ljPvxHp8AAzE3AH0AAAAFZAAgAAAAADtbVEI2tdkrowEMdkacD2w0Y3T3Ofi7PH6HmA6sP0c/BXMAIAAAAADuBSROnZHA+NgUPH8d0LnWFiDsM2bY8bzjC1+elSsIygVsACAAAAAAR0G2m+uANoWknkr/NerFcG+fECVxNIs0cqbY1t/U/0MAAzE4AH0AAAAFZAAgAAAAAAh3WpeMVlikPFYj9hLj+fmIqVt6omCSF75W3TPExyWpBXMAIAAAAAAsQkRmwqeVj2gGE03orb6PtrIzDt6dDU3hgSQi8E2wKgVsACAAAAAA3GHaRE2RAcaBRd8VzmYzWeBD2Gmy91eTK1k8YdWObZcAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "u": { - "$set": { - "encryptedDoublePrecision": { - "$$type": "binData" - } - } - } - } - ], - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedDoublePrecision", - "bsonType": "double", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberDouble": "0.0" - }, - "max": { - "$numberDouble": "200.0" - }, - "precision": { - "$numberInt": "2" - } - } - } - ] - } - } - }, - "$db": "default" - } - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedDoublePrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Dri0CXmL78L2DOgk9w0DwxHOMGMzih7m6l59vgy+WWo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "b7d8mRzD1kI1tdc7uNL+YAUonJ6pODLsRLkArfEKSkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "Xg8C1/A0KJaXOw4i+26Rv03/CydaaunOzXh0CIT+gn8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "UoKUDw2wJYToUCcFaIs03YQSTksYR0MIOTJllwODqKc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "c/5cwAT0C5jber2xlJnWD3a5tVDy0nRtr5HG02hoFOY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wSUrRXavAGaajNeqC5mEUH1K67oYl5Wy9RNIzKjwLAM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6vrp4wWDtHEgHWR99I70WVDzevg1Fk/Pw5U8gUDa0OU=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedDoublePrecision": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "V6knyt7Zq2CG3++l75UtBx2m32iGAPjHiAe439Bf02w=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F08nMDWDZc+DbWM7XCEJNNCEYyinRmrvGP7EWhmp4is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cXH4688amcDc8kZOJq4UP8cE3R58Zl7e+Qo/1jyspps=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uURBxvTp3FBCVkd+LPqyuY7d6rMW6SGIJQEPY/wtkZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jG3hax1L3RBp9t38vUt53FsBxgr/+Si/vVISpAylYpE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kwtIW8MhH9Ky5xNjBx8gFA/SHh2YVphie7g5FGBzals=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FHflwFuEMu4xX0ZApHi+pdlBH+oevAtXckCUb5Wv0xU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "0OKSXELxPP85SBVwDGf3LtMEQCJ8TTkFUl/+6jlkdb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uEw0lpQtBppR3vqV9j9+NQRSBF1BzZukb8c9IhyWvxc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zVhZ7Q59O087ji49oMJvBIgeir2oqvUpnh4p53GcTow=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "dowrzKs+qJhRMZyKDbhjXbuX43FbmUKOaw9I8YlOZDw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ep5B6cska6THLIF7Mn3tn3RvV9EiwLSt0eZM/CLRUDc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "URNp/YmmDh5wIZUfAzzgPyJeMNiVx9PMsz52DZRujGY=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "wlM4IAQhhKQEzoVqS8b1Ddd50GB95OFb9LnzOwyjCP4=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Aggregate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Aggregate.json deleted file mode 100644 index 686f0241b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Aggregate.json +++ /dev/null @@ -1,485 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Int. Aggregate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$gt": { - "$numberInt": "0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedInt": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedInt": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "default", - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - } - } - ], - "cursor": {}, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "aggregate" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedInt": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedInt": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FA74j21GUEJb1DJBOpR9nVnjaDZnd8yAQNuaW9Qi26g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kJv//KVkbrobIBf+QeWC5jxn20mx/P0R1N6aCSMgKM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB+Whi9IUUGxfLEe+lGuIzLX4LFbIhaIAm5lRk65QTc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ybO1QU3CgvhO8JgRXH+HxKszWcpl5aGDYYVa75fHa1g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X3Y3eSAbbMg//JgiHHiFpYOpV61t8kkDexI+CQyitH4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SlNHXyqVFGDPrX/2ppwog6l4pwj3PKda2TkZbqgfSfA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "McjV8xwTF3xI7863DYOBdyvIv6UpzThl6v9vBRk05bI=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Correctness.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Correctness.json deleted file mode 100644 index 2964624f2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Correctness.json +++ /dev/null @@ -1,1642 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "Find with $gt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$gt": { - "$numberInt": "0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Find with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$gte": { - "$numberInt": "0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - }, - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Find with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$gt": { - "$numberInt": "1" - } - } - } - }, - "result": [] - } - ] - }, - { - "description": "Find with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$lt": { - "$numberInt": "1" - } - } - } - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - ] - } - ] - }, - { - "description": "Find with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$lte": { - "$numberInt": "1" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - }, - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Find with $lt below min", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$lt": { - "$numberInt": "0" - } - } - } - }, - "result": { - "errorContains": "must be greater than the range minimum" - } - } - ] - }, - { - "description": "Find with $gt above max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$gt": { - "$numberInt": "200" - } - } - } - }, - "result": { - "errorContains": "must be less than the range maximum" - } - } - ] - }, - { - "description": "Find with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$gt": { - "$numberInt": "0" - }, - "$lt": { - "$numberInt": "2" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Find with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$numberInt": "0" - } - } - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - ] - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$numberInt": "1" - } - } - }, - "result": [ - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Find with full range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$gte": { - "$numberInt": "0" - }, - "$lte": { - "$numberInt": "200" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - }, - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Find with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$in": [ - { - "$numberInt": "0" - } - ] - } - } - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - ] - } - ] - }, - { - "description": "Insert out of range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "-1" - } - } - }, - "result": { - "errorContains": "value must be greater than or equal to the minimum value" - } - } - ] - }, - { - "description": "Insert min and max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 200, - "encryptedInt": { - "$numberInt": "200" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": {}, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - }, - { - "_id": 200, - "encryptedInt": { - "$numberInt": "200" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$gte": { - "$numberInt": "0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - }, - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$gt": { - "$numberInt": "1" - } - } - } - } - ] - }, - "result": [] - } - ] - }, - { - "description": "Aggregate with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$lt": { - "$numberInt": "1" - } - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$lte": { - "$numberInt": "1" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - }, - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lt below min", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$lt": { - "$numberInt": "0" - } - } - } - } - ] - }, - "result": { - "errorContains": "must be greater than the range minimum" - } - } - ] - }, - { - "description": "Aggregate with $gt above max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$gt": { - "$numberInt": "200" - } - } - } - } - ] - }, - "result": { - "errorContains": "must be less than the range maximum" - } - } - ] - }, - { - "description": "Aggregate with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$gt": { - "$numberInt": "0" - }, - "$lt": { - "$numberInt": "2" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Aggregate with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$numberInt": "0" - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - ] - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$numberInt": "1" - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Aggregate with full range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$gte": { - "$numberInt": "0" - }, - "$lte": { - "$numberInt": "200" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - }, - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedInt": { - "$in": [ - { - "$numberInt": "0" - } - ] - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - ] - } - ] - }, - { - "description": "Wrong type: Insert Double", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberDouble": "0" - } - } - }, - "result": { - "errorContains": "cannot encrypt element" - } - } - ] - }, - { - "description": "Wrong type: Find Double", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$gte": { - "$numberDouble": "0" - } - } - } - }, - "result": { - "errorContains": "field type is not supported" - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Delete.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Delete.json deleted file mode 100644 index 531b3e759..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Delete.json +++ /dev/null @@ -1,415 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Int. Delete.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "deleteOne", - "arguments": { - "filter": { - "encryptedInt": { - "$gt": { - "$numberInt": "0" - } - } - } - }, - "result": { - "deletedCount": 1 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedInt": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedInt": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "delete": "default", - "deletes": [ - { - "q": { - "encryptedInt": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "limit": 1 - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "delete" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedInt": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-FindOneAndUpdate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-FindOneAndUpdate.json deleted file mode 100644 index 402086cdb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-FindOneAndUpdate.json +++ /dev/null @@ -1,489 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Int. FindOneAndUpdate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "findOneAndUpdate", - "arguments": { - "filter": { - "encryptedInt": { - "$gt": { - "$numberInt": "0" - } - } - }, - "update": { - "$set": { - "encryptedInt": { - "$numberInt": "2" - } - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedInt": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedInt": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "default", - "query": { - "encryptedInt": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "update": { - "$set": { - "encryptedInt": { - "$$type": "binData" - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "findAndModify" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedInt": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedInt": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hyDcE6QQjPrYJaIS/n7evEZFYcm31Tj89CpEYGF45cI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F08nMDWDZc+DbWM7XCEJNNCEYyinRmrvGP7EWhmp4is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cXH4688amcDc8kZOJq4UP8cE3R58Zl7e+Qo/1jyspps=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uURBxvTp3FBCVkd+LPqyuY7d6rMW6SGIJQEPY/wtkZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jG3hax1L3RBp9t38vUt53FsBxgr/+Si/vVISpAylYpE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kwtIW8MhH9Ky5xNjBx8gFA/SHh2YVphie7g5FGBzals=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FHflwFuEMu4xX0ZApHi+pdlBH+oevAtXckCUb5Wv0xU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ty4cnzJdAlbQKnh7px3GEYjBnvO+jIOaKjoTRDtmh3M=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-InsertFind.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-InsertFind.json deleted file mode 100644 index 965b8a551..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-InsertFind.json +++ /dev/null @@ -1,476 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Int. Insert and Find.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$gt": { - "$numberInt": "0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedInt": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedInt": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "find": "default", - "filter": { - "encryptedInt": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "find" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedInt": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedInt": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FA74j21GUEJb1DJBOpR9nVnjaDZnd8yAQNuaW9Qi26g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kJv//KVkbrobIBf+QeWC5jxn20mx/P0R1N6aCSMgKM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB+Whi9IUUGxfLEe+lGuIzLX4LFbIhaIAm5lRk65QTc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ybO1QU3CgvhO8JgRXH+HxKszWcpl5aGDYYVa75fHa1g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X3Y3eSAbbMg//JgiHHiFpYOpV61t8kkDexI+CQyitH4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SlNHXyqVFGDPrX/2ppwog6l4pwj3PKda2TkZbqgfSfA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "McjV8xwTF3xI7863DYOBdyvIv6UpzThl6v9vBRk05bI=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Update.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Update.json deleted file mode 100644 index 6cf44ac78..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Int-Update.json +++ /dev/null @@ -1,493 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Int. Update.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedInt": { - "$numberInt": "1" - } - } - } - }, - { - "name": "updateOne", - "arguments": { - "filter": { - "encryptedInt": { - "$gt": { - "$numberInt": "0" - } - } - }, - "update": { - "$set": { - "encryptedInt": { - "$numberInt": "2" - } - } - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedInt": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedInt": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command_name": "update", - "command": { - "update": "default", - "ordered": true, - "updates": [ - { - "q": { - "encryptedInt": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "u": { - "$set": { - "encryptedInt": { - "$$type": "binData" - } - } - } - } - ], - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - } - } - }, - "$db": "default" - } - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedInt": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedInt": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hyDcE6QQjPrYJaIS/n7evEZFYcm31Tj89CpEYGF45cI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F08nMDWDZc+DbWM7XCEJNNCEYyinRmrvGP7EWhmp4is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cXH4688amcDc8kZOJq4UP8cE3R58Zl7e+Qo/1jyspps=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uURBxvTp3FBCVkd+LPqyuY7d6rMW6SGIJQEPY/wtkZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jG3hax1L3RBp9t38vUt53FsBxgr/+Si/vVISpAylYpE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kwtIW8MhH9Ky5xNjBx8gFA/SHh2YVphie7g5FGBzals=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FHflwFuEMu4xX0ZApHi+pdlBH+oevAtXckCUb5Wv0xU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ty4cnzJdAlbQKnh7px3GEYjBnvO+jIOaKjoTRDtmh3M=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Aggregate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Aggregate.json deleted file mode 100644 index 6edb38a80..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Aggregate.json +++ /dev/null @@ -1,485 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Long. Aggregate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$gt": { - "$numberLong": "0" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedLong": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedLong": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "default", - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - } - } - ], - "cursor": {}, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "aggregate" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedLong": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedLong": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FA74j21GUEJb1DJBOpR9nVnjaDZnd8yAQNuaW9Qi26g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kJv//KVkbrobIBf+QeWC5jxn20mx/P0R1N6aCSMgKM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB+Whi9IUUGxfLEe+lGuIzLX4LFbIhaIAm5lRk65QTc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ybO1QU3CgvhO8JgRXH+HxKszWcpl5aGDYYVa75fHa1g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X3Y3eSAbbMg//JgiHHiFpYOpV61t8kkDexI+CQyitH4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SlNHXyqVFGDPrX/2ppwog6l4pwj3PKda2TkZbqgfSfA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "McjV8xwTF3xI7863DYOBdyvIv6UpzThl6v9vBRk05bI=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Correctness.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Correctness.json deleted file mode 100644 index 3d33f7381..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Correctness.json +++ /dev/null @@ -1,1642 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "Find with $gt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$gt": { - "$numberLong": "0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Find with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$gte": { - "$numberLong": "0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - }, - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Find with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$gt": { - "$numberLong": "1" - } - } - } - }, - "result": [] - } - ] - }, - { - "description": "Find with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$lt": { - "$numberLong": "1" - } - } - } - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - ] - } - ] - }, - { - "description": "Find with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$lte": { - "$numberLong": "1" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - }, - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Find with $lt below min", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$lt": { - "$numberLong": "0" - } - } - } - }, - "result": { - "errorContains": "must be greater than the range minimum" - } - } - ] - }, - { - "description": "Find with $gt above max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$gt": { - "$numberLong": "200" - } - } - } - }, - "result": { - "errorContains": "must be less than the range maximum" - } - } - ] - }, - { - "description": "Find with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$gt": { - "$numberLong": "0" - }, - "$lt": { - "$numberLong": "2" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Find with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$numberLong": "0" - } - } - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - ] - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$numberLong": "1" - } - } - }, - "result": [ - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Find with full range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$gte": { - "$numberLong": "0" - }, - "$lte": { - "$numberLong": "200" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - }, - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Find with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$in": [ - { - "$numberLong": "0" - } - ] - } - } - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - ] - } - ] - }, - { - "description": "Insert out of range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "-1" - } - } - }, - "result": { - "errorContains": "value must be greater than or equal to the minimum value" - } - } - ] - }, - { - "description": "Insert min and max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 200, - "encryptedLong": { - "$numberLong": "200" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": {}, - "sort": { - "_id": 1 - } - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - }, - { - "_id": 200, - "encryptedLong": { - "$numberLong": "200" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$gte": { - "$numberLong": "0" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - }, - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $gt with no results", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$gt": { - "$numberLong": "1" - } - } - } - } - ] - }, - "result": [] - } - ] - }, - { - "description": "Aggregate with $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$lt": { - "$numberLong": "1" - } - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lte", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$lte": { - "$numberLong": "1" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - }, - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $lt below min", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$lt": { - "$numberLong": "0" - } - } - } - } - ] - }, - "result": { - "errorContains": "must be greater than the range minimum" - } - } - ] - }, - { - "description": "Aggregate with $gt above max", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$gt": { - "$numberLong": "200" - } - } - } - } - ] - }, - "result": { - "errorContains": "must be less than the range maximum" - } - } - ] - }, - { - "description": "Aggregate with $gt and $lt", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$gt": { - "$numberLong": "0" - }, - "$lt": { - "$numberLong": "2" - } - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Aggregate with equality", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$numberLong": "0" - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - ] - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$numberLong": "1" - } - } - } - ] - }, - "result": [ - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Aggregate with full range", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$gte": { - "$numberLong": "0" - }, - "$lte": { - "$numberLong": "200" - } - } - } - }, - { - "$sort": { - "_id": 1 - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - }, - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ] - }, - { - "description": "Aggregate with $in", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "aggregate", - "arguments": { - "pipeline": [ - { - "$match": { - "encryptedLong": { - "$in": [ - { - "$numberLong": "0" - } - ] - } - } - } - ] - }, - "result": [ - { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - ] - } - ] - }, - { - "description": "Wrong type: Insert Double", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberDouble": "0" - } - } - }, - "result": { - "errorContains": "cannot encrypt element" - } - } - ] - }, - { - "description": "Wrong type: Find Double", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$gte": { - "$numberDouble": "0" - } - } - } - }, - "result": { - "errorContains": "field type is not supported" - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Delete.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Delete.json deleted file mode 100644 index 1b3278201..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Delete.json +++ /dev/null @@ -1,415 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Long. Delete.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "deleteOne", - "arguments": { - "filter": { - "encryptedLong": { - "$gt": { - "$numberLong": "0" - } - } - } - }, - "result": { - "deletedCount": 1 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedLong": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedLong": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "delete": "default", - "deletes": [ - { - "q": { - "encryptedLong": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "limit": 1 - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "delete" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedLong": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-FindOneAndUpdate.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-FindOneAndUpdate.json deleted file mode 100644 index b8e3b888a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-FindOneAndUpdate.json +++ /dev/null @@ -1,489 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Long. FindOneAndUpdate.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "findOneAndUpdate", - "arguments": { - "filter": { - "encryptedLong": { - "$gt": { - "$numberLong": "0" - } - } - }, - "update": { - "$set": { - "encryptedLong": { - "$numberLong": "2" - } - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedLong": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedLong": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "default", - "query": { - "encryptedLong": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "update": { - "$set": { - "encryptedLong": { - "$$type": "binData" - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "findAndModify" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedLong": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedLong": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hyDcE6QQjPrYJaIS/n7evEZFYcm31Tj89CpEYGF45cI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F08nMDWDZc+DbWM7XCEJNNCEYyinRmrvGP7EWhmp4is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cXH4688amcDc8kZOJq4UP8cE3R58Zl7e+Qo/1jyspps=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uURBxvTp3FBCVkd+LPqyuY7d6rMW6SGIJQEPY/wtkZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jG3hax1L3RBp9t38vUt53FsBxgr/+Si/vVISpAylYpE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kwtIW8MhH9Ky5xNjBx8gFA/SHh2YVphie7g5FGBzals=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FHflwFuEMu4xX0ZApHi+pdlBH+oevAtXckCUb5Wv0xU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ty4cnzJdAlbQKnh7px3GEYjBnvO+jIOaKjoTRDtmh3M=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-InsertFind.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-InsertFind.json deleted file mode 100644 index d637fcf9e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-InsertFind.json +++ /dev/null @@ -1,476 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Long. Insert and Find.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedLong": { - "$gt": { - "$numberLong": "0" - } - } - } - }, - "result": [ - { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedLong": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedLong": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "find": "default", - "filter": { - "encryptedLong": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "find" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedLong": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedLong": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "bE1vqWj3KNyM7cCYUv/cnYm8BPaUL3eMp5syTHq6NF4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "25j9sQXZCihCmHKvTHgaBsAVZFcGPn7JjHdrCGlwyyw=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FA74j21GUEJb1DJBOpR9nVnjaDZnd8yAQNuaW9Qi26g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kJv//KVkbrobIBf+QeWC5jxn20mx/P0R1N6aCSMgKM8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "zB+Whi9IUUGxfLEe+lGuIzLX4LFbIhaIAm5lRk65QTc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ybO1QU3CgvhO8JgRXH+HxKszWcpl5aGDYYVa75fHa1g=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "X3Y3eSAbbMg//JgiHHiFpYOpV61t8kkDexI+CQyitH4=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "SlNHXyqVFGDPrX/2ppwog6l4pwj3PKda2TkZbqgfSfA=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "McjV8xwTF3xI7863DYOBdyvIv6UpzThl6v9vBRk05bI=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Update.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Update.json deleted file mode 100644 index 1b76019a4..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-Long-Update.json +++ /dev/null @@ -1,493 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "FLE2 Range Long. Update.", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedLong": { - "$numberLong": "0" - } - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encryptedLong": { - "$numberLong": "1" - } - } - } - }, - { - "name": "updateOne", - "arguments": { - "filter": { - "encryptedLong": { - "$gt": { - "$numberLong": "0" - } - } - }, - "update": { - "$set": { - "encryptedLong": { - "$numberLong": "2" - } - } - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 0, - "encryptedLong": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encryptedLong": { - "$$type": "binData" - } - } - ], - "ordered": true, - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - } - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command_name": "update", - "command": { - "update": "default", - "ordered": true, - "updates": [ - { - "q": { - "encryptedLong": { - "$gt": { - "$binary": { - "base64": "DUkFAAADcGF5bG9hZAAZBQAABGcABQUAAAMwAH0AAAAFZAAgAAAAALGGQ/CRD+pGLD53BZzWcCcYbuGLVEyjzXIx7b+ux/q2BXMAIAAAAACOC6mXEZL27P9hethZbtKYsTXKK+FpgQ9Axxmn9N/cCwVsACAAAAAA+MFEd8XfZSpbXKqqPC2L3TEFswkaG5Ff6aSgf8p+XVIAAzEAfQAAAAVkACAAAAAAtL3QIvnZqCF72eS6lKr8ilff7R6kiNklokiTuaU5wNsFcwAgAAAAAEtqr3/X731VB+VrbFcY8ZrJKRo2E0Fd+C8L0EMNcvcCBWwAIAAAAABNPhSriux8W8qbwnhCczE3IzlhNEnGDpUwTFDZSL+eYQADMgB9AAAABWQAIAAAAAB99ZW/7KwXKzl5M3XQsAJ3JbEef90IoxFYBArNiYzlgQVzACAAAAAAYO/qaw0+92HAryxOUG7iK6hnIy3OaUA9jIqtHdvcq8YFbAAgAAAAAHrUYj8A0hVgc6VklpDiljOnykrUSfEsjm56XO/bsfKdAAMzAH0AAAAFZAAgAAAAAOK8brUuc2onBNDRtfYMR736dHj4dQqXod8JG7tAMTsDBXMAIAAAAAAW6SrGAL6Bx0s7ZlsYULFfOAiYIGhEWu6md3r+Rk40awVsACAAAAAAIHYXP8RLcCboUmHN3+OlnEw1DxaLSnbTB9PdF228fFAAAzQAfQAAAAVkACAAAAAAV22FGF7ZDwK/EYiGNMlm/QuT3saQdyJM/Fn+ZyQug1oFcwAgAAAAACo7GwCvbcs5UHQMgds9/1QMklEVdjZigpuOFGrDmmxtBWwAIAAAAADQbYYPxlCMMGe2MulbiurApFLoeJSMvTeDU3pyEA2jNwADNQB9AAAABWQAIAAAAADFspsMG7yHjKppyllon1KqAsTrHaZ6JzNqnSz8o6iTvwVzACAAAAAAeiA5pqVIQQ9s6UY/P8v5Jjkl3I7iFNeLDYehikrINrsFbAAgAAAAAFjBTzTpNxDEkA0vSRj0jCED9KDRlboMVyilKyDz5YR4AAM2AH0AAAAFZAAgAAAAAPcLmtq+V1e+MRlZ7NHq1+mrRVBQje5zj685ZvdsfKvSBXMAIAAAAABdHz/3w2k5km97QN9m7oLFYJaVJneNlMboIlz5yUASQAVsACAAAAAAWbp8JVJnx8fEVAJFa7WMfMa7wXeP5M3C8MX20J/i9n0AAzcAfQAAAAVkACAAAAAAYfLwnoxK6XAGQrJFy8+TIJoq38ldBaO75h4zA4ZX5tQFcwAgAAAAAC2wk8UcJH5X5XGnDBYmel6srpBkzBhHtt3Jw1u5TSJ1BWwAIAAAAAA9/YU9eI3D7QbXKIw/3/gzWJ6MZrCYhG0j1wNKgRQp5wADOAB9AAAABWQAIAAAAADGvyrtKkIcaV17ynZA7b2k5Pz6OhvxdWNkDvDWJIja8wVzACAAAAAAOLypVKNxf/wR1G8OZjUUsTQzDYeNNhhITxGMSp7euS4FbAAgAAAAAA9EsxoV1B2DcQ1NJRwuxXnvVR+vkD0wbbDYEI/zFEnDAAM5AH0AAAAFZAAgAAAAAEocREw1L0g+roFUchJI2Yd0M0ME2bnErNUYnpyJP1SqBXMAIAAAAAAcE2/JK/8MoSeOchIuAkKh1X3ImoA7p8ujAZIfvIDo6QVsACAAAAAA+W0+zgLr85/PD7P9a94wk6MgNgrizx/XU9aCxAkp1IwAABJjbQAAAAAAAAAAAAAQcGF5bG9hZElkAAAAAAAQZmlyc3RPcGVyYXRvcgABAAAAAA==", - "subType": "06" - } - } - } - }, - "u": { - "$set": { - "encryptedLong": { - "$$type": "binData" - } - } - } - } - ], - "encryptionInformation": { - "type": 1, - "schema": { - "default.default": { - "escCollection": "enxcol_.default.esc", - "ecocCollection": "enxcol_.default.ecoc", - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedLong", - "bsonType": "long", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberLong": "0" - }, - "max": { - "$numberLong": "200" - } - } - } - ] - } - } - }, - "$db": "default" - } - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "encryptedLong": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "5nRutVIyq7URVOVtbE4vM01APSIajAVnsShMwjBlzkM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "RjBYT2h3ZAoHxhf8DU6/dFbDkEBZp0IxREcsRTu2MXs=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "x7GR49EN0t3WXQDihkrbonK7qNIBYC87tpL/XEUyIYc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "JfYUqWF+OoGjiYkRI4L5iPlF+T1Eleul7Fki22jp4Qc=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "q1RyGfIgsaQHoZFRw+DD28V26rN5hweApPLwExncvT8=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "L2PFeKGvLS6C+DLudR6fGlBq3ERPvjWvRyNRIA2HVb0=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "CWxaNqL3iP1yCixDkcmf9bmW3E5VeN8TJkg1jJe528s=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "+vC6araOEo+fpW7PSIP40/EnzBCj1d2N10Jr3rrXJJM=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "6SV63Mf51Z6A6p2X3rCnJKCu6ku3Oeb45mBYbz+IoAo=", - "subType": "00" - } - } - ] - }, - { - "_id": 1, - "encryptedLong": { - "$$type": "binData" - }, - "__safeContent__": [ - { - "$binary": { - "base64": "DLCAJs+W2PL2DV5YChCL6dYrQNr+j4p3L7xhVaub4ic=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "hyDcE6QQjPrYJaIS/n7evEZFYcm31Tj89CpEYGF45cI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "F08nMDWDZc+DbWM7XCEJNNCEYyinRmrvGP7EWhmp4is=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "cXH4688amcDc8kZOJq4UP8cE3R58Zl7e+Qo/1jyspps=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "uURBxvTp3FBCVkd+LPqyuY7d6rMW6SGIJQEPY/wtkZI=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "jG3hax1L3RBp9t38vUt53FsBxgr/+Si/vVISpAylYpE=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "kwtIW8MhH9Ky5xNjBx8gFA/SHh2YVphie7g5FGBzals=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "FHflwFuEMu4xX0ZApHi+pdlBH+oevAtXckCUb5Wv0xU=", - "subType": "00" - } - }, - { - "$binary": { - "base64": "ty4cnzJdAlbQKnh7px3GEYjBnvO+jIOaKjoTRDtmh3M=", - "subType": "00" - } - } - ] - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-WrongType.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-WrongType.json deleted file mode 100644 index 704a693b8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/fle2v2-Range-WrongType.json +++ /dev/null @@ -1,160 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "7.0.0", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "maxServerVersion": "7.99.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "encrypted_fields": { - "fields": [ - { - "keyId": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "path": "encryptedInt", - "bsonType": "int", - "queries": { - "queryType": "rangePreview", - "contention": { - "$numberLong": "0" - }, - "sparsity": { - "$numberLong": "1" - }, - "min": { - "$numberInt": "0" - }, - "max": { - "$numberInt": "200" - } - } - } - ] - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "EjRWeBI0mHYSNBI0VniQEg==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1648914851981" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "local" - } - } - ], - "tests": [ - { - "description": "Wrong type: Insert Double", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberDouble": "0" - } - } - }, - "result": { - "errorContains": "cannot encrypt element" - } - } - ] - }, - { - "description": "Wrong type: Find Double", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "local": { - "key": { - "$binary": { - "base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk", - "subType": "00" - } - } - } - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 0, - "encryptedInt": { - "$numberInt": "0" - } - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "encryptedInt": { - "$gte": { - "$numberDouble": "0" - } - } - }, - "sort": { - "_id": 1 - } - }, - "result": { - "errorContains": "field type is not supported" - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/kmipKMS.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/kmipKMS.json deleted file mode 100644 index 5749d21ab..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/kmipKMS.json +++ /dev/null @@ -1,223 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.1.10" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "json_schema": { - "properties": { - "encrypted_string_aws": { - "encrypt": { - "keyId": [ - { - "$binary": { - "base64": "AAAAAAAAAAAAAAAAAAAAAA==", - "subType": "04" - } - } - ], - "bsonType": "string", - "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" - } - }, - "encrypted_string_azure": { - "encrypt": { - "keyId": [ - { - "$binary": { - "base64": "AZURE+AAAAAAAAAAAAAAAA==", - "subType": "04" - } - } - ], - "bsonType": "string", - "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" - } - }, - "encrypted_string_gcp": { - "encrypt": { - "keyId": [ - { - "$binary": { - "base64": "GCP+AAAAAAAAAAAAAAAAAA==", - "subType": "04" - } - } - ], - "bsonType": "string", - "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" - } - }, - "encrypted_string_local": { - "encrypt": { - "keyId": [ - { - "$binary": { - "base64": "AAAAAAAAAAAAAAAAAAAAAA==", - "subType": "04" - } - } - ], - "bsonType": "string", - "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" - } - }, - "encrypted_string_kmip": { - "encrypt": { - "keyId": [ - { - "$binary": { - "base64": "dBHpr8aITfeBQ15grpbLpQ==", - "subType": "04" - } - } - ], - "bsonType": "string", - "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" - } - } - }, - "bsonType": "object" - }, - "key_vault_data": [ - { - "_id": { - "$binary": { - "base64": "dBHpr8aITfeBQ15grpbLpQ==", - "subType": "04" - } - }, - "keyMaterial": { - "$binary": { - "base64": "eUYDyB0HuWb+lQgUwO+6qJQyTTDTY2gp9FbemL7ZFo0pvr0x6rm6Ff9OVUTGH6HyMKipaeHdiIJU1dzsLwvqKvi7Beh+U4iaIWX/K0oEg1GOsJc0+Z/in8gNHbGUYLmycHViM3LES3kdt7FdFSUl5rEBHrM71yoNEXImz17QJWMGOuT4x6yoi2pvnaRJwfrI4DjpmnnTrDMac92jgZehbg==", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1634220190041" - } - }, - "updateDate": { - "$date": { - "$numberLong": "1634220190041" - } - }, - "status": { - "$numberInt": "0" - }, - "masterKey": { - "provider": "kmip", - "keyId": "1" - }, - "keyAltNames": [ - "altname", - "kmip_altname" - ] - } - ], - "tests": [ - { - "description": "Insert a document with auto encryption using KMIP KMS provider", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "kmip": {} - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encrypted_string_kmip": "string0" - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "listCollections": 1, - "filter": { - "name": "default" - } - }, - "command_name": "listCollections" - } - }, - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "dBHpr8aITfeBQ15grpbLpQ==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault" - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encrypted_string_kmip": { - "$binary": { - "base64": "AXQR6a/GiE33gUNeYK6Wy6UCKCwtKFIsL8eKObDVxvqGupJNUk7kXswHhB7G5j/C1D+6no+Asra0KgSU43bTL3ooIBLVyIzbV5CDJYqzAsa4WQ==", - "subType": "06" - } - } - } - ], - "ordered": true - }, - "command_name": "insert" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "encrypted_string_kmip": { - "$binary": { - "base64": "AXQR6a/GiE33gUNeYK6Wy6UCKCwtKFIsL8eKObDVxvqGupJNUk7kXswHhB7G5j/C1D+6no+Asra0KgSU43bTL3ooIBLVyIzbV5CDJYqzAsa4WQ==", - "subType": "06" - } - } - } - ] - } - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/localSchema.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/localSchema.json deleted file mode 100644 index 4698520f6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/localSchema.json +++ /dev/null @@ -1,258 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.1.10" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "json_schema": {}, - "key_vault_data": [ - { - "status": 1, - "_id": { - "$binary": { - "base64": "AAAAAAAAAAAAAAAAAAAAAA==", - "subType": "04" - } - }, - "masterKey": { - "provider": "aws", - "key": "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0", - "region": "us-east-1" - }, - "updateDate": { - "$date": { - "$numberLong": "1552949630483" - } - }, - "keyMaterial": { - "$binary": { - "base64": "AQICAHhQNmWG2CzOm1dq3kWLM+iDUZhEqnhJwH9wZVpuZ94A8gEqnsxXlR51T5EbEVezUqqKAAAAwjCBvwYJKoZIhvcNAQcGoIGxMIGuAgEAMIGoBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDHa4jo6yp0Z18KgbUgIBEIB74sKxWtV8/YHje5lv5THTl0HIbhSwM6EqRlmBiFFatmEWaeMk4tO4xBX65eq670I5TWPSLMzpp8ncGHMmvHqRajNBnmFtbYxN3E3/WjxmdbOOe+OXpnGJPcGsftc7cB2shRfA4lICPnE26+oVNXT6p0Lo20nY5XC7jyCO", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1552949630483" - } - }, - "keyAltNames": [ - "altname", - "another_altname" - ] - } - ], - "tests": [ - { - "description": "A local schema should override", - "clientOptions": { - "autoEncryptOpts": { - "schemaMap": { - "default.default": { - "properties": { - "encrypted_w_altname": { - "encrypt": { - "keyId": "/altname", - "bsonType": "string", - "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Random" - } - }, - "encrypted_string": { - "encrypt": { - "keyId": [ - { - "$binary": { - "base64": "AAAAAAAAAAAAAAAAAAAAAA==", - "subType": "04" - } - } - ], - "bsonType": "string", - "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" - } - }, - "random": { - "encrypt": { - "keyId": [ - { - "$binary": { - "base64": "AAAAAAAAAAAAAAAAAAAAAA==", - "subType": "04" - } - } - ], - "bsonType": "string", - "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Random" - } - }, - "encrypted_string_equivalent": { - "encrypt": { - "keyId": [ - { - "$binary": { - "base64": "AAAAAAAAAAAAAAAAAAAAAA==", - "subType": "04" - } - } - ], - "bsonType": "string", - "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" - } - } - }, - "bsonType": "object" - } - }, - "kmsProviders": { - "aws": {} - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encrypted_string": "string0" - } - } - }, - { - "name": "find", - "arguments": { - "filter": { - "_id": 1 - } - }, - "result": [ - { - "_id": 1, - "encrypted_string": "string0" - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "find": "datakeys", - "filter": { - "$or": [ - { - "_id": { - "$in": [ - { - "$binary": { - "base64": "AAAAAAAAAAAAAAAAAAAAAA==", - "subType": "04" - } - } - ] - } - }, - { - "keyAltNames": { - "$in": [] - } - } - ] - }, - "$db": "keyvault", - "readConcern": { - "level": "majority" - } - }, - "command_name": "find" - } - }, - { - "command_started_event": { - "command": { - "insert": "default", - "documents": [ - { - "_id": 1, - "encrypted_string": { - "$binary": { - "base64": "AQAAAAAAAAAAAAAAAAAAAAACwj+3zkv2VM+aTfk60RqhXq6a/77WlLwu/BxXFkL7EppGsju/m8f0x5kBDD3EZTtGALGXlym5jnpZAoSIkswHoA==", - "subType": "06" - } - } - } - ], - "ordered": true - }, - "command_name": "insert" - } - }, - { - "command_started_event": { - "command": { - "find": "default", - "filter": { - "_id": 1 - } - }, - "command_name": "find" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "encrypted_string": { - "$binary": { - "base64": "AQAAAAAAAAAAAAAAAAAAAAACwj+3zkv2VM+aTfk60RqhXq6a/77WlLwu/BxXFkL7EppGsju/m8f0x5kBDD3EZTtGALGXlym5jnpZAoSIkswHoA==", - "subType": "06" - } - } - } - ] - } - } - }, - { - "description": "A local schema with no encryption is an error", - "clientOptions": { - "autoEncryptOpts": { - "schemaMap": { - "default.default": { - "properties": { - "test": { - "bsonType": "string" - } - }, - "bsonType": "object", - "required": [ - "test" - ] - } - }, - "kmsProviders": { - "aws": {} - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1, - "encrypted_string": "string0" - } - }, - "result": { - "errorContains": "JSON schema keyword 'required' is only allowed with a remote schema" - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/maxWireVersion.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/maxWireVersion.json deleted file mode 100644 index f04f58dff..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/client_side_encryption/legacy/maxWireVersion.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "runOn": [ - { - "maxServerVersion": "4.0.99" - } - ], - "database_name": "default", - "collection_name": "default", - "data": [], - "key_vault_data": [ - { - "status": 1, - "_id": { - "$binary": { - "base64": "AAAAAAAAAAAAAAAAAAAAAA==", - "subType": "04" - } - }, - "masterKey": { - "provider": "aws", - "key": "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0", - "region": "us-east-1" - }, - "updateDate": { - "$date": { - "$numberLong": "1552949630483" - } - }, - "keyMaterial": { - "$binary": { - "base64": "AQICAHhQNmWG2CzOm1dq3kWLM+iDUZhEqnhJwH9wZVpuZ94A8gEqnsxXlR51T5EbEVezUqqKAAAAwjCBvwYJKoZIhvcNAQcGoIGxMIGuAgEAMIGoBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDHa4jo6yp0Z18KgbUgIBEIB74sKxWtV8/YHje5lv5THTl0HIbhSwM6EqRlmBiFFatmEWaeMk4tO4xBX65eq670I5TWPSLMzpp8ncGHMmvHqRajNBnmFtbYxN3E3/WjxmdbOOe+OXpnGJPcGsftc7cB2shRfA4lICPnE26+oVNXT6p0Lo20nY5XC7jyCO", - "subType": "00" - } - }, - "creationDate": { - "$date": { - "$numberLong": "1552949630483" - } - }, - "keyAltNames": [ - "altname", - "another_altname" - ] - } - ], - "tests": [ - { - "description": "operation fails with maxWireVersion < 8", - "clientOptions": { - "autoEncryptOpts": { - "kmsProviders": { - "aws": {} - }, - "extraOptions": { - "mongocryptdBypassSpawn": true - } - } - }, - "operations": [ - { - "name": "insertOne", - "arguments": { - "document": { - "encrypted_string": "string0" - } - }, - "result": { - "errorContains": "Auto-encryption requires a minimum MongoDB version of 4.2" - } - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/connection_uri/additional-nonspec-tests.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/connection_uri/additional-nonspec-tests.json deleted file mode 100644 index 404e7fb41..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/connection_uri/additional-nonspec-tests.json +++ /dev/null @@ -1,157 +0,0 @@ -{ - "tests": [ - { - "description": "Repeated authSource key", - "uri": "mongodb://example.com/?authSource=bar&authSource=foo", - "valid": true, - "comment": "invalid URI (see SPEC-1424)", - "warning": true, - "hosts": [ - { - "type": "hostname", - "host": "example.com", - "port": null - } - ], - "auth": null, - "options": { - "authSource": "foo" - } - }, - { - "description": "Repeated readConcernLevel key", - "uri": "mongodb://example.com/?readConcernLevel=local&readConcernLevel=majority", - "valid": true, - "warning": true, - "hosts": [ - { - "type": "hostname", - "host": "example.com", - "port": null - } - ], - "auth": null, - "options": { - "readconcernlevel": "majority" - } - }, - { - "description": "Repeated authmechanismproperties: key", - "uri": "mongodb://example.com/?authmechanismproperties=SERVICE_NAME:42&authmechanismproperties=SERVICE_NAME:49", - "valid": true, - "warning": true, - "hosts": [ - { - "type": "hostname", - "host": "example.com", - "port": null - } - ], - "auth": null, - "options": { - "authmechanismproperties": { "SERVICE_NAME": "49" } - } - }, - { - "description": "Repeated appname key", - "uri": "mongodb://example.com/?appname=example&appname=example42", - "valid": true, - "warning": true, - "hosts": [ - { - "type": "hostname", - "host": "example.com", - "port": null - } - ], - "auth": null, - "options": { - "appname": "example42" - } - }, - { - "description": "Username containing an unescaped :", - "uri": "mongodb://alic::e@127.0.0.1:27017", - "valid": false, - "warning": null, - "hosts": null, - "auth": null, - "options": null - }, - { - "description": "Username containing an unescaped :", - "uri": "mongodb://alic::e@[::1]", - "valid": false, - "warning": null, - "hosts": null, - "auth": null, - "options": null - }, - { - "description": "Username containing an unescaped :", - "uri": "mongodb://alic::e@[::1]:27017", - "valid": false, - "warning": null, - "hosts": null, - "auth": null, - "options": null - }, - { - "description": "Username containing an unescaped :", - "uri": "mongodb://alic::e@%2Ftmp%2Fmongodb-27017.sock/", - "valid": false, - "warning": null, - "hosts": null, - "auth": null, - "options": null - }, - { - "description": "should default to SERVICE_NAME:mongodb even if other authMechanismProperties present", - "uri": "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authMechanismProperties=CANONICALIZE_HOST_NAME:true", - "valid": true, - "credential": { - "username": "user@DOMAIN.COM", - "password": null, - "source": "$external", - "mechanism": "GSSAPI", - "mechanism_properties": { - "SERVICE_NAME": "mongodb", - "CANONICALIZE_HOST_NAME": true - } - } - }, - { - "description": "should detect case-insensitive service_name", - "uri": "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authMechanismProperties=CANONICALIZE_HOST_NAME:true,service_name:abc", - "valid": true, - "credential": { - "username": "user@DOMAIN.COM", - "password": null, - "source": "$external", - "mechanism": "GSSAPI", - "mechanism_properties": { - "SERVICE_NAME": "abc", - "CANONICALIZE_HOST_NAME": true - } - } - }, - { - "description": "Username containing percent encoded multi-byte UTF-8 is valid", - "uri": "mongodb://%E2%98%83", - "valid": true, - "hosts": [ - { - "type": "hostname", - "host": "☃", - "port": null - } - ] - }, - { - "description": "Username containing percent encoded multi-byte UTF-8 is valid", - "uri": "mongodb://%E2%D8%83", - "valid": false, - "warning": true - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/connection_uri/valid-options.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/connection_uri/valid-options.json deleted file mode 100644 index 4c2bded9e..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/connection_uri/valid-options.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "tests": [ - { - "description": "Option names are normalized to lowercase", - "uri": "mongodb://alice:secret@example.com/admin?AUTHMechanism=MONGODB-CR", - "valid": true, - "warning": false, - "hosts": [ - { - "type": "hostname", - "host": "example.com", - "port": null - } - ], - "auth": { - "username": "alice", - "password": "secret", - "db": "admin" - }, - "options": { - "authmechanism": "MONGODB-CR" - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/index-management/createSearchIndex.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/index-management/createSearchIndex.json deleted file mode 100644 index f9c4e44d3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/index-management/createSearchIndex.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "description": "createSearchIndex", - "schemaVersion": "1.4", - "createEntities": [ - { - "client": { - "id": "client0", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "collection0" - } - } - ], - "runOnRequirements": [ - { - "minServerVersion": "7.0.0", - "topologies": [ - "replicaset", - "load-balanced", - "sharded" - ], - "serverless": "forbid" - } - ], - "tests": [ - { - "description": "no name provided for an index definition", - "operations": [ - { - "name": "createSearchIndex", - "object": "collection0", - "arguments": { - "model": { - "definition": { - "mappings": { - "dynamic": true - } - } - } - }, - "expectError": { - "isError": true, - "errorContains": "Atlas" - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "createSearchIndexes": "collection0", - "indexes": [ - { - "definition": { - "mappings": { - "dynamic": true - } - } - } - ], - "$db": "database0" - } - } - } - ] - } - ] - }, - { - "description": "name provided for an index definition", - "operations": [ - { - "name": "createSearchIndex", - "object": "collection0", - "arguments": { - "model": { - "definition": { - "mappings": { - "dynamic": true - } - }, - "name": "test index" - } - }, - "expectError": { - "isError": true, - "errorContains": "Atlas" - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "createSearchIndexes": "collection0", - "indexes": [ - { - "definition": { - "mappings": { - "dynamic": true - } - }, - "name": "test index" - } - ], - "$db": "database0" - } - } - } - ] - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/index-management/createSearchIndexes.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/index-management/createSearchIndexes.json deleted file mode 100644 index 3cf56ce12..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/index-management/createSearchIndexes.json +++ /dev/null @@ -1,172 +0,0 @@ -{ - "description": "createSearchIndexes", - "schemaVersion": "1.4", - "createEntities": [ - { - "client": { - "id": "client0", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "database0" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "collection0" - } - } - ], - "runOnRequirements": [ - { - "minServerVersion": "7.0.0", - "topologies": [ - "replicaset", - "load-balanced", - "sharded" - ], - "serverless": "forbid" - } - ], - "tests": [ - { - "description": "empty index definition array", - "operations": [ - { - "name": "createSearchIndexes", - "object": "collection0", - "arguments": { - "models": [] - }, - "expectError": { - "isError": true, - "errorContains": "Atlas" - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "createSearchIndexes": "collection0", - "indexes": [], - "$db": "database0" - } - } - } - ] - } - ] - }, - { - "description": "no name provided for an index definition", - "operations": [ - { - "name": "createSearchIndexes", - "object": "collection0", - "arguments": { - "models": [ - { - "definition": { - "mappings": { - "dynamic": true - } - } - } - ] - }, - "expectError": { - "isError": true, - "errorContains": "Atlas" - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "createSearchIndexes": "collection0", - "indexes": [ - { - "definition": { - "mappings": { - "dynamic": true - } - } - } - ], - "$db": "database0" - } - } - } - ] - } - ] - }, - { - "description": "name provided for an index definition", - "operations": [ - { - "name": "createSearchIndexes", - "object": "collection0", - "arguments": { - "models": [ - { - "definition": { - "mappings": { - "dynamic": true - } - }, - "name": "test index" - } - ] - }, - "expectError": { - "isError": true, - "errorContains": "Atlas" - } - } - ], - "expectEvents": [ - { - "client": "client0", - "events": [ - { - "commandStartedEvent": { - "command": { - "createSearchIndexes": "collection0", - "indexes": [ - { - "definition": { - "mappings": { - "dynamic": true - } - }, - "name": "test index" - } - ], - "$db": "database0" - } - } - } - ] - } - ] - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/monitoring/standalone.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/monitoring/standalone.json deleted file mode 100644 index 69a100f45..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/monitoring/standalone.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "description": "Monitoring a direct connection", - "uri": "mongodb://a:27017/?directConnection=true", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "isWritablePrimary": true, - "minWireVersion": 0, - "maxWireVersion": 4 - } - ] - ], - "outcome": { - "events": [ - { - "topology_opening_event": { - "topologyId": "42" - } - }, - { - "topology_description_changed_event": { - "topologyId": "42", - "previousDescription": { - "topologyType": "Unknown", - "servers": [] - }, - "newDescription": { - "topologyType": "Single", - "servers": [ - { - "address": "a:27017", - "arbiters": [], - "hosts": [], - "passives": [], - "type": "Unknown" - } - ] - } - } - }, - { - "server_opening_event": { - "topologyId": "42", - "address": "a:27017" - } - }, - { - "server_description_changed_event": { - "topologyId": "42", - "address": "a:27017", - "previousDescription": { - "address": "a:27017", - "arbiters": [], - "hosts": [], - "passives": [], - "type": "Unknown" - }, - "newDescription": { - "address": "a:27017", - "arbiters": [], - "hosts": [], - "passives": [], - "type": "Standalone" - } - } - }, - { - "topology_description_changed_event": { - "topologyId": "42", - "previousDescription": { - "topologyType": "Single", - "servers": [ - { - "address": "a:27017", - "arbiters": [], - "hosts": [], - "passives": [], - "type": "Unknown" - } - ] - }, - "newDescription": { - "topologyType": "Single", - "servers": [ - { - "address": "a:27017", - "arbiters": [], - "hosts": [], - "passives": [], - "type": "Standalone" - } - ] - } - } - } - ] - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/compatible.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/compatible.json deleted file mode 100644 index 444b13e9d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/compatible.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "description": "Replica set member with large maxWireVersion", - "uri": "mongodb://a,b/?replicaSet=rs", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "setName": "rs", - "hosts": [ - "a:27017", - "b:27017" - ], - "minWireVersion": 0, - "maxWireVersion": 6 - } - ], - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": false, - "secondary": true, - "setName": "rs", - "hosts": [ - "a:27017", - "b:27017" - ], - "minWireVersion": 0, - "maxWireVersion": 1000 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs" - }, - "b:27017": { - "type": "RSSecondary", - "setName": "rs" - } - }, - "topologyType": "ReplicaSetWithPrimary", - "setName": "rs", - "logicalSessionTimeoutMinutes": null, - "compatible": true - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/null_election_id-pre-6.0.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/null_election_id-pre-6.0.json deleted file mode 100644 index dedf900ec..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/null_election_id-pre-6.0.json +++ /dev/null @@ -1,204 +0,0 @@ -{ - "description": "Pre 6.0 Primaries with and without electionIds", - "uri": "mongodb://a/?replicaSet=rs", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017", - "c:27017" - ], - "setVersion": 1, - "setName": "rs", - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": null - }, - "b:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "c:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 1 - } - }, - { - "responses": [ - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017", - "c:27017" - ], - "setName": "rs", - "setVersion": 1, - "electionId": { - "$oid": "000000000000000000000002" - }, - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "b:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": { - "$oid": "000000000000000000000002" - } - }, - "c:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 1, - "maxElectionId": { - "$oid": "000000000000000000000002" - } - } - }, - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017", - "c:27017" - ], - "setVersion": 1, - "setName": "rs", - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": null - }, - "b:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "c:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 1, - "maxElectionId": { - "$oid": "000000000000000000000002" - } - } - }, - { - "responses": [ - [ - "c:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017", - "c:27017" - ], - "setName": "rs", - "setVersion": 1, - "electionId": { - "$oid": "000000000000000000000001" - }, - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": null - }, - "b:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "c:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 1, - "maxElectionId": { - "$oid": "000000000000000000000002" - } - } - } - ] - } - \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/secondary_ignore_ok_0-pre-6.0.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/secondary_ignore_ok_0-pre-6.0.json deleted file mode 100644 index 7db59aa3b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/secondary_ignore_ok_0-pre-6.0.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "description": "Pre 6.0 New primary", - "uri": "mongodb://a,b/?replicaSet=rs", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "setName": "rs", - "hosts": [ - "a:27017", - "b:27017" - ], - "minWireVersion": 0, - "maxWireVersion": 6 - } - ], - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": false, - "secondary": true, - "setName": "rs", - "hosts": [ - "a:27017", - "b:27017" - ], - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs" - }, - "b:27017": { - "type": "RSSecondary", - "setName": "rs" - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs" - } - }, - { - "responses": [ - [ - "b:27017", - { - "ok": 0, - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs" - }, - "b:27017": { - "type": "Unknown", - "setName": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs" - } - } - ] - } - \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/set_version_can_rollback.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/set_version_can_rollback.json deleted file mode 100644 index add5d3c14..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/set_version_can_rollback.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "description": "Set version rolls back after new primary with higher election Id", - "uri": "mongodb://a/?replicaSet=rs", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 2, - "electionId": { - "$oid": "000000000000000000000001" - }, - "minWireVersion": 0, - "maxWireVersion": 17 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 2, - "electionId": { - "$oid": "000000000000000000000001" - } - }, - "b:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 2, - "maxElectionId": { - "$oid": "000000000000000000000001" - } - } - }, - { - "responses": [ - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 1, - "electionId": { - "$oid": "000000000000000000000002" - }, - "minWireVersion": 0, - "maxWireVersion": 17 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "b:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": { - "$oid": "000000000000000000000002" - } - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 1, - "maxElectionId": { - "$oid": "000000000000000000000002" - } - } - }, - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 2, - "electionId": { - "$oid": "000000000000000000000001" - }, - "minWireVersion": 0, - "maxWireVersion": 17 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "b:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": { - "$oid": "000000000000000000000002" - } - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 1, - "maxElectionId": { - "$oid": "000000000000000000000002" - } - } - } - ] - } - \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/setversion_equal_max_without_electionid.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/setversion_equal_max_without_electionid.json deleted file mode 100644 index ebbf654b7..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/setversion_equal_max_without_electionid.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "description": "setVersion version that is equal is treated the same as greater than if there is no electionId", - "uri": "mongodb://a/?replicaSet=rs", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 1, - "minWireVersion": 0, - "maxWireVersion": 17 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": null - }, - "b:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 1 - } - }, - { - "responses": [ - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 1, - "minWireVersion": 0, - "maxWireVersion": 17 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "b:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 1 - } - } - ] - } - \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/setversion_greaterthan_max_without_electionid.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/setversion_greaterthan_max_without_electionid.json deleted file mode 100644 index 3b15af71f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/setversion_greaterthan_max_without_electionid.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "description": "setVersion that is greater than maxSetVersion is used if there is no electionId", - "uri": "mongodb://a/?replicaSet=rs", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 1, - "minWireVersion": 0, - "maxWireVersion": 17 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": null - }, - "b:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 1 - } - }, - { - "responses": [ - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 2, - "minWireVersion": 0, - "maxWireVersion": 17 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "b:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 2, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 2 - } - } - ] - } - \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/setversion_without_electionid-pre-6.0.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/setversion_without_electionid-pre-6.0.json deleted file mode 100644 index bc0e86fad..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/setversion_without_electionid-pre-6.0.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "description": "Pre 6.0 setVersion is ignored if there is no electionId", - "uri": "mongodb://a/?replicaSet=rs", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 2, - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 2, - "electionId": null - }, - "b:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 2 - } - }, - { - "responses": [ - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 1, - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "b:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 2 - } - } - ] - } - \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/too_new.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/too_new.json deleted file mode 100644 index 0433d27a3..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/too_new.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "description": "Replica set member with large minWireVersion", - "uri": "mongodb://a,b/?replicaSet=rs", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "setName": "rs", - "hosts": [ - "a:27017", - "b:27017" - ], - "minWireVersion": 0, - "maxWireVersion": 6 - } - ], - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": false, - "secondary": true, - "setName": "rs", - "hosts": [ - "a:27017", - "b:27017" - ], - "minWireVersion": 999, - "maxWireVersion": 1000 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs" - }, - "b:27017": { - "type": "RSSecondary", - "setName": "rs" - } - }, - "topologyType": "ReplicaSetWithPrimary", - "setName": "rs", - "logicalSessionTimeoutMinutes": null, - "compatible": false - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/too_old.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/too_old.json deleted file mode 100644 index 461d00acc..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/too_old.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "description": "Replica set member with default maxWireVersion of 0", - "uri": "mongodb://a,b/?replicaSet=rs", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "setName": "rs", - "hosts": [ - "a:27017", - "b:27017" - ], - "minWireVersion": 0, - "maxWireVersion": 6 - } - ], - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": false, - "secondary": true, - "setName": "rs", - "hosts": [ - "a:27017", - "b:27017" - ] - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs" - }, - "b:27017": { - "type": "RSSecondary", - "setName": "rs" - } - }, - "topologyType": "ReplicaSetWithPrimary", - "setName": "rs", - "logicalSessionTimeoutMinutes": null, - "compatible": false - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/use_setversion_without_electionid-pre-6.0.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/use_setversion_without_electionid-pre-6.0.json deleted file mode 100644 index d8e6186fb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/rs/use_setversion_without_electionid-pre-6.0.json +++ /dev/null @@ -1,138 +0,0 @@ -{ - "description": "Pre 6.0 Record max setVersion, even from primary without electionId", - "uri": "mongodb://a/?replicaSet=rs", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 1, - "electionId": { - "$oid": "000000000000000000000001" - }, - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 1, - "electionId": { - "$oid": "000000000000000000000001" - } - }, - "b:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 1, - "maxElectionId": { - "$oid": "000000000000000000000001" - } - } - }, - { - "responses": [ - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 2, - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "b:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 2 - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 2, - "maxElectionId": { - "$oid": "000000000000000000000001" - } - } - }, - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "hosts": [ - "a:27017", - "b:27017" - ], - "setName": "rs", - "setVersion": 1, - "electionId": { - "$oid": "000000000000000000000002" - }, - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Unknown", - "setName": null, - "electionId": null - }, - "b:27017": { - "type": "RSPrimary", - "setName": "rs", - "setVersion": 2 - } - }, - "topologyType": "ReplicaSetWithPrimary", - "logicalSessionTimeoutMinutes": null, - "setName": "rs", - "maxSetVersion": 2, - "maxElectionId": { - "$oid": "000000000000000000000001" - } - } - } - ] - } diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/sharded/compatible.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/sharded/compatible.json deleted file mode 100644 index e531db97f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/sharded/compatible.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "description": "Multiple mongoses with large maxWireVersion", - "uri": "mongodb://a,b", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "msg": "isdbgrid", - "minWireVersion": 0, - "maxWireVersion": 1000 - } - ], - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "msg": "isdbgrid", - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Mongos", - "setName": null - }, - "b:27017": { - "type": "Mongos", - "setName": null - } - }, - "topologyType": "Sharded", - "logicalSessionTimeoutMinutes": null, - "setName": null, - "compatible": true - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/sharded/too_new.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/sharded/too_new.json deleted file mode 100644 index 4b997d216..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/sharded/too_new.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "description": "Multiple mongoses with large minWireVersion", - "uri": "mongodb://a,b", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "msg": "isdbgrid", - "minWireVersion": 999, - "maxWireVersion": 1000 - } - ], - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "msg": "isdbgrid" - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Mongos", - "setName": null - }, - "b:27017": { - "type": "Mongos", - "setName": null - } - }, - "topologyType": "Sharded", - "logicalSessionTimeoutMinutes": null, - "setName": null, - "compatible": false - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/sharded/too_old.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/sharded/too_old.json deleted file mode 100644 index 688e1db0f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/sharded/too_old.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "description": "Multiple mongoses with default maxWireVersion of 0", - "uri": "mongodb://a,b", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "msg": "isdbgrid", - "minWireVersion": 2, - "maxWireVersion": 6 - } - ], - [ - "b:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "msg": "isdbgrid" - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Mongos", - "setName": null - }, - "b:27017": { - "type": "Mongos", - "setName": null - } - }, - "topologyType": "Sharded", - "logicalSessionTimeoutMinutes": null, - "setName": null, - "compatible": false - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/single/compatible.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/single/compatible.json deleted file mode 100644 index 302927598..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/server_discovery_and_monitoring/single/compatible.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "description": "Standalone with large maxWireVersion", - "uri": "mongodb://a", - "phases": [ - { - "responses": [ - [ - "a:27017", - { - "ok": 1, - "helloOk": true, - "isWritablePrimary": true, - "minWireVersion": 0, - "maxWireVersion": 6 - } - ] - ], - "outcome": { - "servers": { - "a:27017": { - "type": "Standalone", - "setName": null - } - }, - "topologyType": "Single", - "logicalSessionTimeoutMinutes": null, - "setName": null, - "compatible": true - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/uri-options/connection-pool-options.json b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/uri-options/connection-pool-options.json deleted file mode 100644 index aae16190b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/json/uri-options/connection-pool-options.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "tests": [ - { - "description": "Valid connection pool options are parsed correctly", - "uri": "mongodb://example.com/?maxIdleTimeMS=50000&maxPoolSize=5&minPoolSize=3", - "valid": true, - "warning": false, - "hosts": null, - "auth": null, - "options": { - "maxIdleTimeMS": 50000, - "maxPoolSize": 5, - "minPoolSize": 3 - } - }, - { - "description": "Non-numeric maxIdleTimeMS causes a warning", - "uri": "mongodb://example.com/?maxIdleTimeMS=invalid", - "valid": true, - "warning": true, - "hosts": null, - "auth": null, - "options": {} - }, - { - "description": "Too low maxIdleTimeMS causes a warning", - "uri": "mongodb://example.com/?maxIdleTimeMS=-2", - "valid": true, - "warning": true, - "hosts": null, - "auth": null, - "options": {} - }, - { - "description": "maxPoolSize=0 does not error", - "uri": "mongodb://example.com/?maxPoolSize=0", - "valid": true, - "warning": false, - "hosts": null, - "auth": null, - "options": { - "maxPoolSize": 0 - } - }, - { - "description": "minPoolSize=0 does not error", - "uri": "mongodb://example.com/?minPoolSize=0", - "valid": true, - "warning": false, - "hosts": null, - "auth": null, - "options": { - "minPoolSize": 0 - } - } - ] -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/mock_server/mock-server.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/mock_server/mock-server.h deleted file mode 100644 index d6c593829..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/mock_server/mock-server.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MOCK_SERVER_H -#define MOCK_SERVER_H - -#include - -#include "mongoc/mongoc-flags-private.h" -#include "mongoc/mongoc-uri.h" - -#ifdef MONGOC_ENABLE_SSL -#include "mongoc/mongoc-ssl.h" -#endif - -#include "request.h" - -typedef struct _mock_server_t mock_server_t; -typedef struct _autoresponder_handle_t autoresponder_handle_t; -typedef struct _hello_callback_t hello_callback_t; - -typedef struct _mock_server_bind_opts_t { - struct sockaddr_in *bind_addr; - size_t bind_addr_len; - int family; - int ipv6_only; -} mock_server_bind_opts_t; - -typedef bool (*autoresponder_t) (request_t *request, void *data); - -typedef bool (*hello_callback_func_t) (request_t *request, - void *data, - bson_t *hello_response); - -typedef void (*destructor_t) (void *data); - -mock_server_t * -mock_server_new (void); - -mock_server_t * -mock_server_with_auto_hello (int32_t max_wire_version); - -mock_server_t * -mock_mongos_new (int32_t max_wire_version); - -mock_server_t * -mock_server_down (void); - -int -mock_server_autoresponds (mock_server_t *server, - autoresponder_t responder, - void *data, - destructor_t destructor); - -void -mock_server_remove_autoresponder (mock_server_t *server, int id); - -int -mock_server_auto_hello_callback (mock_server_t *server, - hello_callback_func_t callback_func, - void *data, - destructor_t destructor); - -int -mock_server_auto_hello (mock_server_t *server, const char *response_json, ...); - -int -mock_server_auto_endsessions (mock_server_t *server); - -#ifdef MONGOC_ENABLE_SSL - -void -mock_server_set_ssl_opts (mock_server_t *server, mongoc_ssl_opt_t *opts); - -#endif - -void -mock_server_set_bind_opts (mock_server_t *server, - mock_server_bind_opts_t *opts); - -uint16_t -mock_server_run (mock_server_t *server); - -const mongoc_uri_t * -mock_server_get_uri (mock_server_t *server); - -const char * -mock_server_get_host_and_port (mock_server_t *server); - -uint16_t -mock_server_get_port (mock_server_t *server); - -void -mock_server_set_request_timeout_msec (mock_server_t *server, - int64_t request_timeout_msec); - -bool -mock_server_get_rand_delay (mock_server_t *server); - -void -mock_server_set_rand_delay (mock_server_t *server, bool rand_delay); - -request_t * -mock_server_receives_request (mock_server_t *server); - -request_t * -mock_server_receives_command (mock_server_t *server, - const char *database_name, - mongoc_query_flags_t flags, - const char *command_json, - ...); - -request_t * -mock_server_receives_any_hello (mock_server_t *server); - -request_t * -mock_server_receives_legacy_hello (mock_server_t *server, - const char *match_json); - -request_t * -mock_server_receives_hello (mock_server_t *server); - -request_t * -mock_server_receives_hello_op_msg (mock_server_t *server); - -request_t * -mock_server_receives_any_hello_with_match (mock_server_t *server, - const char *match_json_op_msg, - const char *match_json_op_query); - -request_t * -mock_server_receives_query (mock_server_t *server, - const char *ns, - mongoc_query_flags_t flags, - uint32_t skip, - int32_t n_return, - const char *query_json, - const char *fields_json); - -request_t * -mock_server_receives_kill_cursors (mock_server_t *server, int64_t cursor_id); - -request_t * -_mock_server_receives_msg (mock_server_t *server, uint32_t flags, ...); -#define mock_server_receives_msg(_server, _flags, ...) \ - _mock_server_receives_msg (_server, _flags, __VA_ARGS__, NULL) - -request_t * -mock_server_receives_bulk_msg (mock_server_t *server, - uint32_t flags, - const bson_t *msg_json, - const bson_t *doc_json, - size_t n_docs); - -void -reply_to_request_with_hang_up (request_t *request); - -void -reply_to_request_with_reset (request_t *request); - -void -reply_to_request (request_t *request, - mongoc_reply_flags_t flags, - int64_t cursor_id, - int32_t starting_from, - int32_t number_returned, - const char *docs_json); - -void -reply_to_request_simple (request_t *request, const char *docs_json); - -void -reply_to_request_with_ok_and_destroy (request_t *request); - -void -reply_to_find_request (request_t *request, - mongoc_query_flags_t flags, - int64_t cursor_id, - int32_t number_returned, - const char *ns, - const char *reply_json, - bool is_command); - -void -reply_to_op_msg_request (request_t *request, - mongoc_op_msg_flags_t flags, - const bson_t *doc); - -void -reply_to_request_with_multiple_docs (request_t *request, - mongoc_reply_flags_t flags, - const bson_t *docs, - int n_docs, - int64_t cursor_id); - -void -mock_server_destroy (mock_server_t *server); - -void -rs_response_to_hello (mock_server_t *server, - int max_wire_version, - bool primary, - int has_tags, - ...); - -#define RS_RESPONSE_TO_HELLO(server, max_wire_version, primary, has_tags, ...) \ - rs_response_to_hello ( \ - server, max_wire_version, primary, has_tags, __VA_ARGS__, NULL) - -#endif /* MOCK_SERVER_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/mock_server/request.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/mock_server/request.c deleted file mode 100644 index 2a9ab43a7..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/mock_server/request.c +++ /dev/null @@ -1,738 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include "mongoc/mongoc.h" - -#include "mock-server.h" -#include "../test-conveniences.h" -#include "../TestSuite.h" - -static bool -is_command_ns (const char *ns); - -static void -request_from_query (request_t *request); - -static void -request_from_killcursors (request_t *request); - -static void -request_from_getmore (request_t *request); - -static void -request_from_op_msg (request_t *request); - -static char * -query_flags_str (int32_t flags); - -request_t * -request_new (const mongoc_buffer_t *buffer, - int32_t msg_len, - mock_server_t *server, - mongoc_stream_t *client, - uint16_t client_port, - sync_queue_t *replies) -{ - BSON_ASSERT_PARAM (buffer); - BSON_ASSERT_PARAM (server); - BSON_ASSERT_PARAM (client); - BSON_ASSERT_PARAM (replies); - - BSON_ASSERT (bson_in_range_signed (size_t, msg_len)); - - request_t *const request = (request_t *) bson_malloc0 (sizeof *request); - - request->data = bson_malloc ((size_t) msg_len); - request->data_len = (size_t) msg_len; - request->replies = replies; - - memcpy (request->data, buffer->data, request->data_len); - - const void *data_end = NULL; - request->rpc = - mcd_rpc_message_from_data (request->data, request->data_len, &data_end); - - if (!request->rpc) { - test_error ("failed to parse incoming message due to byte %zu of %zu", - (size_t) ((const uint8_t *) data_end - request->data), - request->data_len); - } - - request->opcode = mcd_rpc_header_get_op_code (request->rpc); - request->server = server; - request->client = client; - request->client_port = client_port; - _mongoc_array_init (&request->docs, sizeof (bson_t *)); - - switch (request->opcode) { - case MONGOC_OP_CODE_COMPRESSED: - // Nothing to do. - break; - - case MONGOC_OP_CODE_QUERY: - request_from_query (request); - break; - - case MONGOC_OP_CODE_KILL_CURSORS: - // Still being used for legacy OP_KILL_CURSORS tests. - request_from_killcursors (request); - break; - - case MONGOC_OP_CODE_GET_MORE: - // Still being used for exhaust cursor tests. - request_from_getmore (request); - break; - - case MONGOC_OP_CODE_MSG: - request_from_op_msg (request); - break; - - case MONGOC_OP_CODE_DELETE: - case MONGOC_OP_CODE_INSERT: - case MONGOC_OP_CODE_REPLY: - case MONGOC_OP_CODE_UPDATE: - default: - test_error ("Mock server does not support opcode %d", request->opcode); - } - - return request; -} - -const bson_t * -request_get_doc (const request_t *request, size_t n) -{ - BSON_ASSERT (request); - return _mongoc_array_index (&request->docs, const bson_t *, n); -} - -void -assert_request_matches_flags (const request_t *request, uint32_t flags) -{ - BSON_ASSERT (request); - - const int32_t request_flags = mcd_rpc_op_query_get_flags (request->rpc); - if (bson_cmp_not_equal_su (request_flags, flags)) { - test_error ("request's query flags are %s, expected %s", - query_flags_str (request_flags), - query_flags_str ((int32_t) flags)); - } -} - -/* TODO: take file, line, function params from caller, wrap in macro */ -bool -request_matches_query (const request_t *request, - const char *ns, - uint32_t flags, - uint32_t skip, - int32_t n_return, - const char *query_json, - const char *fields_json, - bool is_command) -{ - const bson_t *doc; - const bson_t *doc2; - char *doc_as_json; - bool ret = false; - - BSON_ASSERT (request); - BSON_ASSERT (request->docs.len <= 2); - - if (request->docs.len) { - doc = request_get_doc (request, 0); - doc_as_json = bson_as_json (doc, NULL); - } else { - doc = NULL; - doc_as_json = NULL; - } - - if (!match_json ( - doc, is_command, __FILE__, __LINE__, BSON_FUNC, query_json)) { - /* match_json has logged the err */ - goto done; - } - - if (request->docs.len > 1) { - doc2 = request_get_doc (request, 1); - } else { - doc2 = NULL; - } - - if (!match_json (doc2, false, __FILE__, __LINE__, BSON_FUNC, fields_json)) { - /* match_json has logged the err */ - goto done; - } - - if (request->is_command && !is_command) { - test_error ("expected query, got command: %s", doc_as_json); - goto done; - } - - if (!request->is_command && is_command) { - test_error ("expected command, got query: %s", doc_as_json); - goto done; - } - - if (request->opcode != MONGOC_OPCODE_QUERY) { - test_error ("request's opcode does not match QUERY: %s", doc_as_json); - goto done; - } - - const char *const request_ns = - mcd_rpc_op_query_get_full_collection_name (request->rpc); - if (0 != strcmp (request_ns, ns)) { - test_error ("request's namespace is '%s', expected '%s': %s", - request_ns, - ns, - doc_as_json); - goto done; - } - - assert_request_matches_flags (request, flags); - - const int32_t request_skip = - mcd_rpc_op_query_get_number_to_skip (request->rpc); - if (bson_cmp_not_equal_su (request_skip, skip)) { - test_error ("requests's skip = %" PRId32 ", expected %" PRIu32 ": %s", - request_skip, - skip, - doc_as_json); - goto done; - } - - - const int32_t request_n_return = - mcd_rpc_op_query_get_number_to_return (request->rpc); - bool n_return_equal = (request_n_return == n_return); - - if (!n_return_equal && abs (request_n_return) == 1) { - /* quirk: commands from mongoc_client_command_simple have n_return 1, - * from mongoc_topology_scanner_t have n_return -1 - */ - n_return_equal = abs (request_n_return) == n_return; - } - - if (!n_return_equal) { - test_error ("requests's n_return = %" PRId32 ", expected %" PRId32 ": %s", - request_n_return, - n_return, - doc_as_json); - goto done; - } - - ret = true; - -done: - bson_free (doc_as_json); - return ret; -} - - -/* TODO: take file, line, function params from caller, wrap in macro */ -bool -request_matches_kill_cursors (const request_t *request, int64_t cursor_id) -{ - BSON_ASSERT (request); - - if (request->opcode != MONGOC_OPCODE_KILL_CURSORS) { - test_error ("request's opcode does not match KILL_CURSORS, got: %d", - request->opcode); - return false; - } - - const int32_t request_n_cursors = - mcd_rpc_op_kill_cursors_get_number_of_cursor_ids (request->rpc); - if (request_n_cursors != 1) { - test_error ("request's n_cursors is %" PRId32 ", expected 1", - request_n_cursors); - return false; - } - - const int64_t request_cursor_id = - mcd_rpc_op_kill_cursors_get_cursor_ids (request->rpc)[0]; - if (request_cursor_id != cursor_id) { - test_error ("request's cursor_id %" PRId64 ", expected %" PRId64, - request_cursor_id, - cursor_id); - return false; - } - - return true; -} - -/*-------------------------------------------------------------------------- - * - * request_matches_msg -- - * - * Test that a client OP_MSG matches a pattern. The OP_MSG consists - * of at least one document (the command body) and optional sequence - * of additional documents (e.g., documents in a bulk insert). The - * documents in the actual client message are compared pairwise to - * the patterns in @docs. - * - * Returns: - * True if the body and document sequence of the request match - * the given pattern. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -request_matches_msg (const request_t *request, - uint32_t flags, - const bson_t **docs, - size_t n_docs) -{ - const bson_t *doc; - const bson_t *pattern; - bson_error_t bson_error; - bool is_command_doc; - - BSON_ASSERT (request); - if (request->opcode != MONGOC_OPCODE_MSG) { - test_error ("%s", "request's opcode does not match OP_MSG"); - } - - BSON_ASSERT (request->docs.len >= 1); - - for (size_t i = 0u; i < n_docs; i++) { - pattern = docs[i]; - - /* make sure the pattern is reasonable, e.g. that we didn't pass a string - * instead of a bson_t* by mistake */ - ASSERT_WITH_MSG (bson_validate_with_error (pattern, - BSON_VALIDATE_EMPTY_KEYS | - BSON_VALIDATE_UTF8, - &bson_error), - "invalid argument at position %zu (note: must be " - "bson_t*, not char*):\ndomain: %" PRIu32 - ", code: %" PRIu32 ", message: %s\n", - i, - bson_error.domain, - bson_error.code, - bson_error.message); - - if (i > request->docs.len) { - fprintf (stderr, - "Expected at least %zu documents in request, got %zu\n", - i, - request->docs.len); - return false; - } - - doc = request_get_doc (request, i); - /* pass is_command=true for first doc, including "find" command */ - is_command_doc = (i == 0u); - assert_match_bson (doc, pattern, is_command_doc); - } - - if (n_docs < request->docs.len) { - fprintf (stderr, - "Expected %zu documents in request, got %zu\n", - n_docs, - request->docs.len); - return false; - } - - const uint32_t request_flags = mcd_rpc_op_msg_get_flag_bits (request->rpc); - if (request_flags != flags) { - fprintf (stderr, - "Expected OP_MSG flags %" PRIu32 ", got %" PRIu32 "\n", - flags, - request_flags); - return false; - } - - return true; -} - - -/*-------------------------------------------------------------------------- - * - * request_matches_msgv -- - * - * Variable-args version of request_matches_msg. - * - * Returns: - * True if the body and document sequence of the request match - * the given pattern. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -bool -request_matches_msgv (const request_t *request, uint32_t flags, va_list *args) -{ - bson_t **docs; - size_t n_docs, allocated; - bool r; - - n_docs = 0; - allocated = 1; - docs = bson_malloc (allocated * sizeof (bson_t *)); - while ((docs[n_docs] = va_arg (*args, bson_t *))) { - n_docs++; - if (n_docs == allocated) { - allocated = bson_next_power_of_two (allocated + 1); - docs = bson_realloc (docs, allocated * sizeof (bson_t *)); - } - } - - r = request_matches_msg (request, flags, (const bson_t **) docs, n_docs); - - bson_free (docs); - - return r; -} - -/*-------------------------------------------------------------------------- - * - * request_get_server_port -- - * - * Get the port of the server this request was sent to. - * - * Returns: - * A port number. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -uint16_t -request_get_server_port (request_t *request) -{ - return mock_server_get_port (request->server); -} - - -/*-------------------------------------------------------------------------- - * - * request_get_client_port -- - * - * Get the client port this request was sent from. - * - * Returns: - * A port number. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -uint16_t -request_get_client_port (request_t *request) -{ - return request->client_port; -} - - -/*-------------------------------------------------------------------------- - * - * request_destroy -- - * - * Free a request_t. - * - * Returns: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -void -request_destroy (request_t *request) -{ - size_t i; - bson_t *doc; - - for (i = 0; i < request->docs.len; i++) { - doc = _mongoc_array_index (&request->docs, bson_t *, i); - bson_destroy (doc); - } - - _mongoc_array_destroy (&request->docs); - bson_free (request->command_name); - bson_free (request->as_str); - mcd_rpc_message_destroy (request->rpc); - bson_free (request->data); - bson_free (request); -} - - -static bool -is_command_ns (const char *ns) -{ - size_t len = strlen (ns); - const char *cmd = ".$cmd"; - size_t cmd_len = strlen (cmd); - - return len > cmd_len && !strncmp (ns + len - cmd_len, cmd, cmd_len); -} - - -static char * -query_flags_str (int32_t flags) -{ - int flag = 1; - bson_string_t *str = bson_string_new (""); - bool begun = false; - - if (flags == MONGOC_OP_QUERY_FLAG_NONE) { - bson_string_append (str, "0"); - } else { - while (flag <= MONGOC_OP_QUERY_FLAG_PARTIAL) { - flag <<= 1; - - if (flags & flag) { - if (begun) { - bson_string_append (str, "|"); - } - - begun = true; - - switch (flag) { - case MONGOC_OP_QUERY_FLAG_TAILABLE_CURSOR: - bson_string_append (str, "TAILABLE"); - break; - case MONGOC_OP_QUERY_FLAG_SECONDARY_OK: - bson_string_append (str, "SECONDARY_OK"); - break; - case MONGOC_OP_QUERY_FLAG_OPLOG_REPLAY: - bson_string_append (str, "OPLOG_REPLAY"); - break; - case MONGOC_OP_QUERY_FLAG_NO_CURSOR_TIMEOUT: - bson_string_append (str, "NO_TIMEOUT"); - break; - case MONGOC_OP_QUERY_FLAG_AWAIT_DATA: - bson_string_append (str, "AWAIT_DATA"); - break; - case MONGOC_OP_QUERY_FLAG_EXHAUST: - bson_string_append (str, "EXHAUST"); - break; - case MONGOC_OP_QUERY_FLAG_PARTIAL: - bson_string_append (str, "PARTIAL"); - break; - case MONGOC_OP_QUERY_FLAG_NONE: - default: - BSON_ASSERT (false); - } - } - } - } - - return bson_string_free (str, false); /* detach buffer */ -} - - -static int32_t -length_prefix (const uint8_t *data) -{ - uint32_t storage; - memcpy (&storage, data, sizeof (storage)); - storage = BSON_UINT32_FROM_LE (storage); - int32_t res; - memcpy (&res, &storage, sizeof (storage)); - return res; -} - - -static void -request_from_query (request_t *request) -{ - bson_iter_t iter; - bson_string_t *query_as_str = bson_string_new ("OP_QUERY "); - char *str; - - const int32_t request_flags = mcd_rpc_op_query_get_flags (request->rpc); - const char *const request_coll = - mcd_rpc_op_query_get_full_collection_name (request->rpc); - const int32_t request_skip = - mcd_rpc_op_query_get_number_to_skip (request->rpc); - const int32_t request_return = - mcd_rpc_op_query_get_number_to_return (request->rpc); - const void *const request_query = mcd_rpc_op_query_get_query (request->rpc); - const void *const request_fields = - mcd_rpc_op_query_get_return_fields_selector (request->rpc); - - { - const int32_t len = length_prefix (request_query); - bson_t *const query = bson_new_from_data (request_query, (size_t) len); - BSON_ASSERT (query); - _mongoc_array_append_val (&request->docs, query); - - bson_string_append_printf (query_as_str, "%s ", request_coll); - - if (is_command_ns (request_coll)) { - request->is_command = true; - - if (bson_iter_init (&iter, query) && bson_iter_next (&iter)) { - request->command_name = bson_strdup (bson_iter_key (&iter)); - } else { - fprintf (stderr, "WARNING: no command name for %s\n", request_coll); - } - } - - str = bson_as_json (query, NULL); - bson_string_append (query_as_str, str); - bson_free (str); - } - - if (request_fields) { - const int32_t len = length_prefix (request_fields); - bson_t *const fields = bson_new_from_data (request_fields, (size_t) len); - BSON_ASSERT (fields); - _mongoc_array_append_val (&request->docs, fields); - - str = bson_as_json (fields, NULL); - bson_string_append (query_as_str, " fields="); - bson_string_append (query_as_str, str); - bson_free (str); - } - - bson_string_append (query_as_str, " flags="); - - str = query_flags_str (request_flags); - bson_string_append (query_as_str, str); - bson_free (str); - - if (request_skip) { - bson_string_append_printf (query_as_str, " skip=%" PRId32, request_skip); - } - - if (request_return) { - bson_string_append_printf ( - query_as_str, " n_return=%" PRId32, request_return); - } - - request->as_str = bson_string_free (query_as_str, false); -} - - -static void -request_from_killcursors (request_t *request) -{ - /* protocol allows multiple cursor ids but we only implement one */ - BSON_ASSERT ( - mcd_rpc_op_kill_cursors_get_number_of_cursor_ids (request->rpc) == 1); - request->as_str = bson_strdup_printf ( - "OP_KILLCURSORS %" PRId64, - mcd_rpc_op_kill_cursors_get_cursor_ids (request->rpc)[0]); -} - - -static void -request_from_getmore (request_t *request) -{ - request->as_str = bson_strdup_printf ( - "OP_GETMORE %s %" PRId64 " n_return=%d", - mcd_rpc_op_get_more_get_full_collection_name (request->rpc), - mcd_rpc_op_get_more_get_cursor_id (request->rpc), - mcd_rpc_op_get_more_get_number_to_return (request->rpc)); -} - - -static void -parse_op_msg_doc (request_t *request, - const uint8_t *data, - size_t data_len, - bson_string_t *msg_as_str) -{ - const uint8_t *pos = data; - while (pos < data + data_len) { - if (pos > data) { - bson_string_append (msg_as_str, ", "); - } - - const int32_t doc_len = length_prefix (pos); - const bson_t *const doc = bson_new_from_data (pos, (size_t) doc_len); - BSON_ASSERT (doc); - _mongoc_array_append_val (&request->docs, doc); - - char *const str = bson_as_json (doc, NULL); - bson_string_append (msg_as_str, str); - bson_free (str); - - pos += doc_len; - } -} - - -static void -request_from_op_msg (request_t *request) -{ - bson_string_t *msg_as_str = bson_string_new ("OP_MSG"); - - const size_t sections_count = - mcd_rpc_op_msg_get_sections_count (request->rpc); - - BSON_ASSERT (sections_count <= 2u); - for (size_t index = 0; index < sections_count; ++index) { - bson_string_append (msg_as_str, (index > 0 ? ", " : " ")); - const uint8_t kind = - mcd_rpc_op_msg_section_get_kind (request->rpc, index); - switch (kind) { - case 0: { /* a single BSON document */ - const void *const body = - mcd_rpc_op_msg_section_get_body (request->rpc, index); - parse_op_msg_doc ( - request, body, (size_t) length_prefix (body), msg_as_str); - break; - } - - case 1: { /* a sequence of BSON documents */ - bson_string_append ( - msg_as_str, - mcd_rpc_op_msg_section_get_identifier (request->rpc, index)); - bson_string_append (msg_as_str, ": ["); - parse_op_msg_doc ( - request, - mcd_rpc_op_msg_section_get_document_sequence (request->rpc, index), - mcd_rpc_op_msg_section_get_document_sequence_length (request->rpc, - index), - msg_as_str); - - bson_string_append (msg_as_str, "]"); - break; - } - - default: - test_error ("Unimplemented payload type %d\n", kind); - } - } - - request->as_str = bson_string_free (msg_as_str, false); - request->is_command = true; /* true for all OP_MSG requests */ - - if (request->docs.len) { - const bson_t *doc = request_get_doc (request, 0); - bson_iter_t iter; - if (bson_iter_init (&iter, doc) && bson_iter_next (&iter)) { - request->command_name = bson_strdup (bson_iter_key (&iter)); - } - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-atlas-executor.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-atlas-executor.c deleted file mode 100644 index d57c93156..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-atlas-executor.c +++ /dev/null @@ -1,95 +0,0 @@ -#include "TestSuite.h" - -#include "unified/operation.h" -#include "unified/runner.h" - -#include "json-test.h" -#include "test-libmongoc.h" - -#include - -#include -#include -#include - -static void -TestSuite_Init_Atlas (TestSuite *suite, int argc, char **argv) -{ - ASSERT_WITH_MSG (argc > 1, "test-atlas-executor requires a workload spec!"); - - *suite = (TestSuite){ - .ctest_run = NULL, - .failing_flaky_skips = {0}, - .flags = TEST_NOFORK, - .match_patterns = {0}, - .mock_server_log = NULL, - .mock_server_log_buf = NULL, - .name = bson_strdup ("/atlas"), - .outfile = NULL, - .prgname = bson_strdup (argv[0]), - .silent = false, - .tests = NULL, - }; -} - -// Used to ensure that repeated SIGINT are not ignored. -void (*original_sigint_handler) (int) = NULL; - -static void -sigint_handler (int sigint) -{ - assert (sigint == SIGINT); - operation_loop_terminated = true; - signal (SIGINT, original_sigint_handler); -} - -static void -TestSuite_Run_Atlas (TestSuite *suite) -{ - BSON_ASSERT_PARAM (suite); - - Test *const test = suite->tests; - - ASSERT_WITH_MSG (test, "missing expected test in test suite"); - ASSERT_WITH_MSG (!test->next, "expected exactly one test in test suite"); - - original_sigint_handler = signal (SIGINT, sigint_handler); - - srand (test->seed); - - test_conveniences_init (); - test->func (test->ctx); - test_conveniences_cleanup (); - - capture_logs (false); -} - -int -main (int argc, char **argv) -{ - ASSERT_WITH_MSG (argc > 1, "test-atlas-executor requires a workload spec!"); - - TestSuite suite = {0}; - TestSuite_Init_Atlas (&suite, argc, argv); - - bson_error_t error; - bson_t *const bson = - bson_new_from_json ((const uint8_t *) argv[1], -1, &error); - ASSERT_OR_PRINT (bson, error); - - TestSuite_AddFull (&suite, - "test", - (TestFuncWC) &run_one_test_file, - (TestFuncDtor) &bson_destroy, - bson, - TestSuite_CheckLive, - NULL); - - mongoc_init (); - TestSuite_Run_Atlas (&suite); - mongoc_cleanup (); - - TestSuite_Destroy (&suite); - - return 0; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-azurekms.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-azurekms.c deleted file mode 100644 index 52c1121b4..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-azurekms.c +++ /dev/null @@ -1,81 +0,0 @@ -#include - -int -main (void) -{ - char *mongodb_uri = getenv ("MONGODB_URI"); - char *expect_error = getenv ("EXPECT_ERROR"); - char *keyName = getenv ("KEY_NAME"); - char *keyVaultEndpoint = getenv ("KEY_VAULT_ENDPOINT"); - - if (!mongodb_uri || !keyName || !keyVaultEndpoint) { - MONGOC_ERROR ("Error: expecting environment variables to be set: " - "MONGODB_URI, KEY_NAME, KEY_VAULT_ENDPOINT"); - return EXIT_FAILURE; - } - - mongoc_init (); - - mongoc_client_t *keyvault_client = mongoc_client_new (mongodb_uri); - MONGOC_DEBUG ("libmongoc version: %s", mongoc_get_version ()); - - mongoc_client_encryption_opts_t *ceopts = - mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_keyvault_client (ceopts, keyvault_client); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ceopts, "keyvault", "datakeys"); - - bson_t *kms_providers = BCON_NEW ("azure", "{", "}"); - - mongoc_client_encryption_opts_set_kms_providers (ceopts, kms_providers); - - bson_error_t error; - mongoc_client_encryption_t *ce = - mongoc_client_encryption_new (ceopts, &error); - if (!ce) { - MONGOC_ERROR ("Error in mongoc_client_encryption_new: %s", error.message); - return EXIT_FAILURE; - } - - mongoc_client_encryption_datakey_opts_t *dkopts; - dkopts = mongoc_client_encryption_datakey_opts_new (); - bson_t *masterkey = BCON_NEW ("keyVaultEndpoint", - BCON_UTF8 (keyVaultEndpoint), - "keyName", - BCON_UTF8 (keyName)); - mongoc_client_encryption_datakey_opts_set_masterkey (dkopts, masterkey); - - bson_value_t keyid; - bool got = mongoc_client_encryption_create_datakey ( - ce, "azure", dkopts, &keyid, &error); - - if (NULL != expect_error) { - if (got) { - MONGOC_ERROR ("Expected error to contain %s, but got success", - expect_error); - return EXIT_FAILURE; - } - if (NULL == strstr (error.message, expect_error)) { - MONGOC_ERROR ("Expected error to contain %s, but got: %s", - expect_error, - error.message); - return EXIT_FAILURE; - } - } else { - if (!got) { - MONGOC_ERROR ("Expected to create data key, but got error: %s", - error.message); - return EXIT_FAILURE; - } - MONGOC_DEBUG ("Created key\n"); - } - bson_value_destroy (&keyid); - bson_destroy (masterkey); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - mongoc_client_encryption_destroy (ce); - bson_destroy (kms_providers); - mongoc_client_encryption_opts_destroy (ceopts); - mongoc_client_destroy (keyvault_client); - - mongoc_cleanup (); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-conveniences.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-conveniences.h deleted file mode 100644 index 242289296..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-conveniences.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_CONVENIENCES_H -#define TEST_CONVENIENCES_H - -#include - -#include "mongoc/mongoc.h" -#include "mongoc/mongoc-read-prefs-private.h" -#include "mongoc/mongoc-client-private.h" - -/* TODO: split this header up. - * Move bson_lookup_* functions under bsonutil. - * Move temporary helpers into a separate header. - */ - -/* Initialize global test convenience structures. - * Safe to call repeatedly, or after calling test_conveniences_cleanup(). - */ -void -test_conveniences_init (void); - -/* Tear down global test conveniences. - * Safe to call repeatedly. - * Called automatically at process exit. - */ -void -test_conveniences_cleanup (void); - -/* Return a bson_t representation from a single-quoted JSON string, with - * possible printf format directives. - * bson_t is freed automatically at test cleanup. - * E.g. tmp_bson ("{'key': %d}", 123); */ -bson_t * -tmp_bson (const char *json, ...); - -/* Return a string, with possible printf format directives. String is - * automatically freed at test cleanup. */ -const char * -tmp_str (const char *fmt, ...); - -/* Return a JSON string representation of BSON. String is freed automatically at - * test cleanup. */ -const char * -tmp_json (const bson_t *bson); - -void -bson_iter_bson (const bson_iter_t *iter, bson_t *bson); - -/* create a bson_t containing all types of values, and an empty key. The - * returned bson_t does not need to be freed. This corresponds to the same - * document in json_with_all_types. */ -bson_t * -bson_with_all_types (void); - -/* returns a json string with all types of values, and an empty key. This - * corresponds to the same document in bson_with_all_types. */ -const char * -json_with_all_types (void); - - -#ifndef PATH_MAX -#define PATH_MAX 1024 -#endif - -#ifdef _WIN32 -#define realpath(path, expanded) \ - GetFullPathName (path, PATH_MAX, expanded, NULL) -#endif - -const char * -bson_lookup_utf8 (const bson_t *b, const char *key); - -void -value_init_from_doc (bson_value_t *value, const bson_t *doc); - -void -bson_lookup_value (const bson_t *b, const char *key, bson_value_t *value); - -bson_t * -bson_lookup_bson (const bson_t *b, const char *key); - -void -bson_lookup_doc (const bson_t *b, const char *key, bson_t *doc); - -void -bson_lookup_doc_null_ok (const bson_t *b, const char *key, bson_t *doc); - -bool -bson_lookup_bool (const bson_t *b, const char *key); - -int32_t -bson_lookup_int32 (const bson_t *b, const char *key); - -int64_t -bson_lookup_int64 (const bson_t *b, const char *key); - -mongoc_read_concern_t * -bson_lookup_read_concern (const bson_t *b, const char *key); - -mongoc_write_concern_t * -bson_lookup_write_concern (const bson_t *b, const char *key); - -mongoc_read_prefs_t * -bson_lookup_read_prefs (const bson_t *b, const char *key); - -void -bson_lookup_database_opts (const bson_t *b, - const char *key, - mongoc_database_t *database); - -void -bson_lookup_collection_opts (const bson_t *b, - const char *key, - mongoc_collection_t *collection); - -mongoc_transaction_opt_t * -bson_lookup_txn_opts (const bson_t *b, const char *key); - -mongoc_session_opt_t * -bson_lookup_session_opts (const bson_t *b, const char *key); - -mongoc_client_session_t * -bson_lookup_session (const bson_t *b, const char *key, mongoc_client_t *client); - -bool -bson_init_from_value (bson_t *b, const bson_value_t *v); - -char * -single_quotes_to_double (const char *str); - -/* match_action_t determines if default check for a field is overridden. */ -typedef enum { - MATCH_ACTION_SKIP, /* do not use the default check. */ - MATCH_ACTION_ABORT, /* an error occurred, stop checking. */ - MATCH_ACTION_CONTINUE /* use the default check. */ -} match_action_t; - -struct _match_ctx_t; -/* doc_iter may be null if the pattern field is not found. */ -typedef match_action_t (*match_visitor_fn) (struct _match_ctx_t *ctx, - bson_iter_t *pattern_iter, - bson_iter_t *doc_iter); - -typedef struct _match_ctx_t { - char errmsg[1000]; - bool strict_numeric_types; - /* if retain_dots_in_keys is true, then don't consider a path with dots to - * indicate recursing into a sub document. */ - bool retain_dots_in_keys; - /* if allow_placeholders is true, treats 42 and "42" as placeholders. I.e. - * comparing 42 to anything is ok. */ - bool allow_placeholders; - /* path is the dot separated breadcrumb trail of keys. */ - char path[1000]; - /* if visitor_fn is not NULL, this is called on for every key in the pattern. - * The returned match_action_t can override the default match behavior. */ - match_visitor_fn visitor_fn; - void *visitor_ctx; - /* if is_command is true, then compare the first key case insensitively. */ - bool is_command; -} match_ctx_t; - -#define assert_match_bson(doc, pattern, _is_command) \ - if (1) { \ - match_ctx_t _ctx = {.strict_numeric_types = true, \ - .is_command = _is_command}; \ - \ - if (!match_bson_with_ctx (doc, pattern, &_ctx)) { \ - test_error ("Expected: %s\n, Got: %s\n, %s\n", \ - bson_as_canonical_extended_json (pattern, NULL), \ - bson_as_canonical_extended_json (doc, NULL), \ - _ctx.errmsg); \ - } \ - } else \ - (void) 0 - -bool -match_bson (const bson_t *doc, const bson_t *pattern, bool is_command); - -int64_t -bson_value_as_int64 (const bson_value_t *value); - -bool -match_bson_value (const bson_value_t *doc, - const bson_value_t *pattern, - match_ctx_t *ctx); - -bool -match_bson_with_ctx (const bson_t *doc, - const bson_t *pattern, - match_ctx_t *ctx); - -bool -match_json (const bson_t *doc, - bool is_command, - const char *filename, - int lineno, - const char *funcname, - const char *json_pattern, - ...); - -#define ASSERT_MATCH(doc, ...) \ - do { \ - BSON_ASSERT ( \ - match_json (doc, false, __FILE__, __LINE__, BSON_FUNC, __VA_ARGS__)); \ - } while (0) - -bool -mongoc_write_concern_append_bad (mongoc_write_concern_t *write_concern, - bson_t *command); - -#define FOUR_MB 1024 * 1024 * 4 - -const char * -huge_string (mongoc_client_t *client); - -size_t -huge_string_length (mongoc_client_t *client); - -const char * -four_mb_string (void); - -void -assert_no_duplicate_keys (const bson_t *doc); - -void -match_in_array (const bson_t *doc, const bson_t *array, match_ctx_t *ctx); - -void -match_err (match_ctx_t *ctx, const char *fmt, ...); - -void -assert_wc_oob_error (bson_error_t *error); - -typedef struct { - int major; - int minor; - bool has_minor; - int patch; - bool has_patch; -} semver_t; - -void -semver_parse (const char *str, semver_t *out); - -void -server_semver (mongoc_client_t *client, semver_t *out); - -int -semver_cmp (semver_t *a, semver_t *b); - -int -semver_cmp_str (semver_t *a, const char *str); - -const char * -semver_to_string (semver_t *str); - -/* Iterate over a BSON document or array. - * - * Example of iterating and printing an array of BSON documents: - * - * bson_iter_t iter; - * bson_t *arr = my_func(); - * - * BSON_FOREACH (arr, iter) { - * bson_t el; - * bson_iter_bson (&iter, &el); - * printf ("%d: %s", bson_iter_key (&iter), tmp_json (&el)); - * } - */ -#define BSON_FOREACH(bson, iter_varname) \ - for (bson_iter_init (&(iter_varname), (bson)); \ - bson_iter_next (&(iter_varname));) - -#define TEST_ERROR_DOMAIN 123456 -#define TEST_ERROR_CODE 654321 -#define test_set_error(error, ...) \ - bson_set_error (error, TEST_ERROR_DOMAIN, TEST_ERROR_CODE, __VA_ARGS__) - -#endif /* TEST_CONVENIENCES_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mcd-azure-imds.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mcd-azure-imds.c deleted file mode 100644 index 58bfa607a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mcd-azure-imds.c +++ /dev/null @@ -1,132 +0,0 @@ -#include - -#include - -#include "TestSuite.h" - -#define RAW_STRING(...) #__VA_ARGS__ - -static void -_test_oauth_parse (void) -{ - // Test that we can correctly parse a JSON document from the IMDS sever - bson_error_t error; - mcd_azure_access_token token; - ASSERT (!mcd_azure_access_token_try_init_from_json_str ( - &token, "invalid json", -1, &error)); - ASSERT_CMPUINT32 (error.domain, ==, BSON_ERROR_JSON); - - ASSERT (!mcd_azure_access_token_try_init_from_json_str ( - &token, "{}", -1, &error)); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_AZURE, MONGOC_ERROR_KMS_SERVER_BAD_JSON, ""); - - ASSERT (!mcd_azure_access_token_try_init_from_json_str ( - &token, RAW_STRING ({"access_token" : null}), -1, &error)); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_AZURE, MONGOC_ERROR_KMS_SERVER_BAD_JSON, ""); - - error = (bson_error_t){0}; - ASSERT (mcd_azure_access_token_try_init_from_json_str ( - &token, - RAW_STRING ({ - "access_token" : "meow", - "resource" : "something", - "expires_in" : "1234", - "token_type" : "Bearer" - }), - -1, - &error)); - ASSERT_ERROR_CONTAINS (error, 0, 0, ""); - ASSERT_CMPSTR (token.access_token, "meow"); - - mcd_azure_access_token_destroy (&token); -} - -static void -_test_http_req (void) -{ - // Test generating an HTTP request for the IMDS server - mcd_azure_imds_request req; - mcd_azure_imds_request_init (&req, "example.com", 9879, ""); - bson_string_t *req_str = _mongoc_http_render_request_head (&req.req); - mcd_azure_imds_request_destroy (&req); - // Assert that we composed exactly the request that we expected - ASSERT_CMPSTR (req_str->str, - "GET " - "/metadata/identity/oauth2/" - "token?api-version=2018-02-01&resource=https%3A%2F%2Fvault." - "azure.net HTTP/1.0\r\n" - "Host: example.com:9879\r\n" - "Connection: close\r\n" - "Metadata: true\r\n" - "Accept: application/json\r\n" - "\r\n"); - bson_string_free (req_str, true); -} - -static const char * -_get_test_imds_host (void) -{ - return getenv ("TEST_KMS_PROVIDER_HOST"); -} - -static void -_run_http_test_case (const char *case_, - mongoc_error_domain_t expect_domain, - mongoc_error_code_t expect_code, - const char *expect_error_message) -{ - bson_error_t error = {0}; - struct _mongoc_host_list_t host; - _mongoc_host_list_from_string_with_err ( - &host, _get_test_imds_host (), &error); - ASSERT_ERROR_CONTAINS (error, 0, 0, ""); - - mcd_azure_access_token token = {0}; - char *const header = - bson_strdup_printf ("X-MongoDB-HTTP-TestParams: case=%s\r\n", case_); - mcd_azure_access_token_from_imds ( - &token, host.host, host.port, header, &error); - bson_free (header); - mcd_azure_access_token_destroy (&token); - ASSERT_ERROR_CONTAINS ( - error, expect_domain, expect_code, expect_error_message); -} - -static void -_test_with_mock_server (void *ctx) -{ - BSON_UNUSED (ctx); - - _run_http_test_case ("", 0, 0, ""); // (No error) - _run_http_test_case ( - "404", MONGOC_ERROR_AZURE, MONGOC_ERROR_KMS_SERVER_HTTP, ""); - _run_http_test_case ( - "slow", MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "Timeout"); - _run_http_test_case ( - "empty-json", MONGOC_ERROR_AZURE, MONGOC_ERROR_KMS_SERVER_BAD_JSON, ""); - _run_http_test_case ( - "bad-json", MONGOC_ERROR_CLIENT, MONGOC_ERROR_STREAM_INVALID_TYPE, ""); - _run_http_test_case ( - "giant", MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "too large"); -} - -static int -have_mock_server_env (TestSuite *ctx) -{ - return _get_test_imds_host () != NULL; -} - -void -test_mcd_azure_imds_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/azure/imds/http/parse", _test_oauth_parse); - TestSuite_Add (suite, "/azure/imds/http/request", _test_http_req); - TestSuite_AddFull (suite, - "/azure/imds/http/talk", - _test_with_mock_server, - NULL, - NULL, - have_mock_server_env); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-aggregate.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-aggregate.c deleted file mode 100644 index fc97ace3b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-aggregate.c +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include "mongoc/mongoc-client-private.h" - -#include "TestSuite.h" -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - -static void -_test_query_flag (mongoc_query_flags_t flag, bson_t *opt) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_error_t error; - future_t *future; - request_t *request; - const bson_t *doc; - - server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_aggregate ( - collection, flag, tmp_bson ("{'pipeline': []}"), opt, NULL); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - /* "aggregate" command */ - future = future_cursor_next (cursor, &doc); - request = - mock_server_receives_msg (server, - MONGOC_QUERY_NONE, - tmp_bson ("{'aggregate': 'collection'," - " 'pipeline': [ ]," - " 'tailable': {'$exists': false}}")); - ASSERT (request); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '123'}," - " 'ns': 'db.collection'," - " 'nextBatch': [{}]}}"); - ASSERT (future_get_bool (future)); - request_destroy (request); - future_destroy (future); - - /* "getMore" command */ - future = future_cursor_next (cursor, &doc); - request = - mock_server_receives_msg (server, - MONGOC_QUERY_NONE, - tmp_bson ("{'getMore': {'$numberLong': '123'}," - " 'collection': 'collection'," - " 'tailable': {'$exists': false}}")); - ASSERT (request); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.collection'," - " 'nextBatch': [{}]}}"); - - ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_query_flags (void) -{ - int i; - - typedef struct { - mongoc_query_flags_t flag; - bson_t *opt; - } flag_and_opt_t; - - flag_and_opt_t flags_and_opts[] = { - {MONGOC_QUERY_TAILABLE_CURSOR, tmp_bson ("{'tailable': true}")}, - {MONGOC_QUERY_TAILABLE_CURSOR | MONGOC_QUERY_AWAIT_DATA, - tmp_bson ("{'tailable': true, 'awaitData': true}")}}; - - /* test with both flag and opt */ - for (i = 0; i < (sizeof flags_and_opts) / (sizeof (flag_and_opt_t)); i++) { - _test_query_flag (flags_and_opts[i].flag, NULL); - _test_query_flag (MONGOC_QUERY_NONE, flags_and_opts[i].opt); - } -} - -void -test_aggregate_install (TestSuite *suite) -{ - TestSuite_AddMockServerTest ( - suite, "/Aggregate/query_flags", test_query_flags); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-aws.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-aws.c deleted file mode 100644 index 74a58bff6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-aws.c +++ /dev/null @@ -1,385 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "TestSuite.h" -#include "test-libmongoc.h" -#include "mongoc/mongoc-cluster-aws-private.h" - -void -test_obtain_credentials (void *unused) -{ - mongoc_uri_t *uri; - _mongoc_aws_credentials_t creds; - bool ret; - bson_error_t error; - - BSON_UNUSED (unused); - - /* A username specified with a password is parsed correctly. */ - uri = mongoc_uri_new ("mongodb://" - "access_key_id:secret_access_key@localhost/?" - "authMechanism=MONGODB-AWS"); - ret = _mongoc_aws_credentials_obtain (uri, &creds, &error); - ASSERT_OR_PRINT (ret, error); - ASSERT_CMPSTR (creds.access_key_id, "access_key_id"); - ASSERT_CMPSTR (creds.secret_access_key, "secret_access_key"); - BSON_ASSERT (creds.session_token == NULL); - _mongoc_aws_credentials_cleanup (&creds); - mongoc_uri_destroy (uri); - - /* A username specified with no password is an error. */ - uri = mongoc_uri_new ( - "mongodb://access_key_id:@localhost/?authMechanism=MONGODB-AWS"); - ret = _mongoc_aws_credentials_obtain (uri, &creds, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "ACCESS_KEY_ID is set, but SECRET_ACCESS_KEY is missing"); - _mongoc_aws_credentials_cleanup (&creds); - mongoc_uri_destroy (uri); - - /* Password not set at all (not empty string) */ - uri = mongoc_uri_new ( - "mongodb://access_key_id@localhost/?authMechanism=MONGODB-AWS"); - ret = _mongoc_aws_credentials_obtain (uri, &creds, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "ACCESS_KEY_ID is set, but SECRET_ACCESS_KEY is missing"); - _mongoc_aws_credentials_cleanup (&creds); - mongoc_uri_destroy (uri); - - /* A session token may be set through the AWS_SESSION_TOKEN auth mechanism - * property */ - uri = mongoc_uri_new ("mongodb://" - "access_key_id:secret_access_key@localhost/?" - "authMechanism=MONGODB-AWS&authMechanismProperties=" - "AWS_SESSION_TOKEN:token"); - ret = _mongoc_aws_credentials_obtain (uri, &creds, &error); - ASSERT_OR_PRINT (ret, error); - ASSERT_CMPSTR (creds.access_key_id, "access_key_id"); - ASSERT_CMPSTR (creds.secret_access_key, "secret_access_key"); - ASSERT_CMPSTR (creds.session_token, "token"); - _mongoc_aws_credentials_cleanup (&creds); - mongoc_uri_destroy (uri); - - /* A session token in the URI with no username/password is an error. */ - uri = mongoc_uri_new ("mongodb://localhost/" - "?authMechanism=MONGODB-AWS&authMechanismProperties=" - "AWS_SESSION_TOKEN:token"); - ret = _mongoc_aws_credentials_obtain (uri, &creds, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "AWS_SESSION_TOKEN is set, but ACCESS_KEY_ID and " - "SECRET_ACCESS_KEY are missing"); - _mongoc_aws_credentials_cleanup (&creds); - mongoc_uri_destroy (uri); -} - -void -test_obtain_credentials_from_env (void *unused) -{ - mongoc_uri_t *uri; - _mongoc_aws_credentials_t creds; - bool ret; - bson_error_t error; - - BSON_UNUSED (unused); - - /* "clear" environment variables by setting them to the empty string. */ - _mongoc_setenv ("AWS_ACCESS_KEY_ID", ""); - _mongoc_setenv ("AWS_SECRET_ACCESS_KEY", ""); - _mongoc_setenv ("AWS_SESSION_TOKEN", ""); - - /* Environment variables are used if username/password is not set. */ - _mongoc_setenv ("AWS_ACCESS_KEY_ID", "access_key_id"); - _mongoc_setenv ("AWS_SECRET_ACCESS_KEY", "secret_access_key"); - uri = mongoc_uri_new ("mongodb://localhost/?authMechanism=MONGODB-AWS"); - ret = _mongoc_aws_credentials_obtain (uri, &creds, &error); - ASSERT_OR_PRINT (ret, error); - ASSERT_CMPSTR (creds.access_key_id, "access_key_id"); - ASSERT_CMPSTR (creds.secret_access_key, "secret_access_key"); - BSON_ASSERT (creds.session_token == NULL); - _mongoc_aws_credentials_cleanup (&creds); - mongoc_uri_destroy (uri); - - /* Omitting one of the required environment variables is an error. */ - _mongoc_setenv ("AWS_ACCESS_KEY_ID", "access_key_id"); - _mongoc_setenv ("AWS_SECRET_ACCESS_KEY", ""); - uri = mongoc_uri_new ("mongodb://localhost/?authMechanism=MONGODB-AWS"); - ret = _mongoc_aws_credentials_obtain (uri, &creds, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "ACCESS_KEY_ID is set, but SECRET_ACCESS_KEY is missing"); - _mongoc_aws_credentials_cleanup (&creds); - mongoc_uri_destroy (uri); - - /* Omitting one of the required environment variables is an error. */ - _mongoc_setenv ("AWS_ACCESS_KEY_ID", ""); - _mongoc_setenv ("AWS_SECRET_ACCESS_KEY", "secret_access_key"); - uri = mongoc_uri_new ("mongodb://localhost/?authMechanism=MONGODB-AWS"); - ret = _mongoc_aws_credentials_obtain (uri, &creds, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "SECRET_ACCESS_KEY is set, but ACCESS_KEY_ID is missing"); - _mongoc_aws_credentials_cleanup (&creds); - mongoc_uri_destroy (uri); - - /* Only specifying the token is an error. */ - _mongoc_setenv ("AWS_ACCESS_KEY_ID", ""); - _mongoc_setenv ("AWS_SECRET_ACCESS_KEY", ""); - _mongoc_setenv ("AWS_SESSION_TOKEN", "token"); - uri = mongoc_uri_new ("mongodb://localhost/?authMechanism=MONGODB-AWS"); - ret = _mongoc_aws_credentials_obtain (uri, &creds, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "AWS_SESSION_TOKEN is set, but ACCESS_KEY_ID and " - "SECRET_ACCESS_KEY are missing"); - _mongoc_aws_credentials_cleanup (&creds); - mongoc_uri_destroy (uri); - - /* But a session token in the environment is picked up. */ - _mongoc_setenv ("AWS_ACCESS_KEY_ID", "access_key_id"); - _mongoc_setenv ("AWS_SECRET_ACCESS_KEY", "secret_access_key"); - _mongoc_setenv ("AWS_SESSION_TOKEN", "token"); - uri = mongoc_uri_new ("mongodb://localhost/?authMechanism=MONGODB-AWS"); - ret = _mongoc_aws_credentials_obtain (uri, &creds, &error); - ASSERT_OR_PRINT (ret, error); - ASSERT_CMPSTR (creds.access_key_id, "access_key_id"); - ASSERT_CMPSTR (creds.secret_access_key, "secret_access_key"); - ASSERT_CMPSTR (creds.session_token, "token"); - _mongoc_aws_credentials_cleanup (&creds); - mongoc_uri_destroy (uri); - - /* "clear" environment variables by setting them to the empty string. */ - _mongoc_setenv ("AWS_ACCESS_KEY_ID", ""); - _mongoc_setenv ("AWS_SECRET_ACCESS_KEY", ""); - _mongoc_setenv ("AWS_SESSION_TOKEN", ""); -} - -static void -test_derive_region (void *unused) -{ - bson_error_t error; - char *region; - bool ret; - char *large; - - BSON_UNUSED (unused); - -#define WITH_LEN(s) s, strlen (s) - - ret = _mongoc_validate_and_derive_region ( - WITH_LEN ("abc..def"), ®ion, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Invalid STS host: empty part"); - bson_free (region); - - ret = _mongoc_validate_and_derive_region (WITH_LEN ("."), ®ion, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Invalid STS host: empty part"); - bson_free (region); - - ret = _mongoc_validate_and_derive_region (WITH_LEN ("..."), ®ion, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Invalid STS host: empty part"); - bson_free (region); - - ret = - _mongoc_validate_and_derive_region (WITH_LEN ("first."), ®ion, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Invalid STS host: empty part"); - bson_free (region); - - ret = _mongoc_validate_and_derive_region ( - WITH_LEN ("sts.amazonaws.com"), ®ion, &error); - BSON_ASSERT (ret); - ASSERT_CMPSTR ("us-east-1", region); - bson_free (region); - - ret = _mongoc_validate_and_derive_region ( - WITH_LEN ("first.second"), ®ion, &error); - BSON_ASSERT (ret); - ASSERT_CMPSTR ("second", region); - bson_free (region); - - ret = - _mongoc_validate_and_derive_region (WITH_LEN ("first"), ®ion, &error); - BSON_ASSERT (ret); - ASSERT_CMPSTR ("us-east-1", region); - bson_free (region); - - ret = _mongoc_validate_and_derive_region (WITH_LEN (""), ®ion, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Invalid STS host: empty"); - bson_free (region); - - large = bson_malloc0 (257); - memset (large, 'a', 256); - - ret = _mongoc_validate_and_derive_region ( - large, strlen (large), ®ion, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Invalid STS host: too large"); - bson_free (region); - bson_free (large); - -#undef WITH_LEN -} - -// test_aws_cache unit tests the _mongoc_aws_credentials_cache_t. It does not -// require libmongoc to be built with MONGOC_ENABLE_MONGODB_AWS_AUTH. -static void -test_aws_cache (void *unused) -{ - BSON_UNUSED (unused); - _mongoc_aws_credentials_t valid_creds = MONGOC_AWS_CREDENTIALS_INIT; - valid_creds.access_key_id = bson_strdup ("access_key_id"); - valid_creds.secret_access_key = bson_strdup ("secret_access_key"); - valid_creds.session_token = bson_strdup ("session_token"); - // Set expiration to one minute from now. - valid_creds.expiration.set = true; - valid_creds.expiration.value = - mcd_timer_expire_after (mcd_milliseconds (60 * 1000)); - - _mongoc_aws_credentials_t expired_creds = MONGOC_AWS_CREDENTIALS_INIT; - expired_creds.access_key_id = bson_strdup ("access_key_id"); - expired_creds.secret_access_key = bson_strdup ("secret_access_key"); - expired_creds.session_token = bson_strdup ("session_token"); - // Set expiration to one minute before. - expired_creds.expiration.set = true; - expired_creds.expiration.value = - mcd_timer_expire_after (mcd_milliseconds (-60 * 1000)); - - _mongoc_aws_credentials_cache_t *cache = &mongoc_aws_credentials_cache; - _mongoc_aws_credentials_cache_clear (); - - // Expect `get` to return nothing initially. - { - _mongoc_aws_credentials_t got = MONGOC_AWS_CREDENTIALS_INIT; - bool found = _mongoc_aws_credentials_cache_get (&got); - ASSERT (!found); - } - - // Expect `get` to return after valid credentials are added with `put`. - { - _mongoc_aws_credentials_t got = MONGOC_AWS_CREDENTIALS_INIT; - _mongoc_aws_credentials_cache_put (&valid_creds); - bool found = _mongoc_aws_credentials_cache_get (&got); - ASSERT (found); - ASSERT_CMPSTR (got.access_key_id, valid_creds.access_key_id); - ASSERT_CMPSTR (got.secret_access_key, valid_creds.secret_access_key); - ASSERT_CMPSTR (got.session_token, valid_creds.session_token); - _mongoc_aws_credentials_cleanup (&got); - } - - // Expect `clear` to clear cached credentials. - { - _mongoc_aws_credentials_t got = MONGOC_AWS_CREDENTIALS_INIT; - _mongoc_aws_credentials_cache_put (&valid_creds); - _mongoc_aws_credentials_cache_clear (); - bool found = _mongoc_aws_credentials_cache_get (&got); - ASSERT (!found); - } - - // Expect expired credentials are not added to cache. - { - _mongoc_aws_credentials_t got = MONGOC_AWS_CREDENTIALS_INIT; - _mongoc_aws_credentials_cache_put (&expired_creds); - bool found = _mongoc_aws_credentials_cache_get (&got); - ASSERT (!found); - } - - // Expect credentials that expire are not returned from cache. - { - _mongoc_aws_credentials_t got = MONGOC_AWS_CREDENTIALS_INIT; - _mongoc_aws_credentials_cache_put (&valid_creds); - bool found = _mongoc_aws_credentials_cache_get (&got); - ASSERT (found); - - // Manually expire the credentials. - cache->cached.value.expiration.value = expired_creds.expiration.value; - found = _mongoc_aws_credentials_cache_get (&got); - ASSERT (!found); - _mongoc_aws_credentials_cleanup (&got); - } - - _mongoc_aws_credentials_cache_clear (); - _mongoc_aws_credentials_cleanup (&expired_creds); - _mongoc_aws_credentials_cleanup (&valid_creds); -} - -void -test_aws_install (TestSuite *suite) -{ - TestSuite_AddFull (suite, - "/aws/obtain_credentials", - test_obtain_credentials, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_aws); - TestSuite_AddFull (suite, - "/aws/obtain_credentials_from_env", - test_obtain_credentials_from_env, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_aws, - test_framework_skip_if_no_setenv); - TestSuite_AddFull (suite, - "/aws/derive_region", - test_derive_region, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_aws); - TestSuite_AddFull (suite, - "/aws/cache", - test_aws_cache, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_aws); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-change-stream.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-change-stream.c deleted file mode 100644 index 6bf91e135..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-change-stream.c +++ /dev/null @@ -1,2789 +0,0 @@ -/* - * Copyright 2017-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "mongoc/mongoc-client-private.h" -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mongoc/mongoc-change-stream-private.h" -#include "mongoc/mongoc-cursor-private.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "TestSuite.h" -#include "json-test.h" -#include "json-test-operations.h" - -#define DESTROY_CHANGE_STREAM(cursor_id) \ - do { \ - future_t *_future = future_change_stream_destroy (stream); \ - request_t *_request = mock_server_receives_msg ( \ - server, \ - MONGOC_MSG_NONE, \ - tmp_bson ("{'$db': 'db'," \ - " 'killCursors': 'coll'," \ - " 'cursors': [{'$numberLong': '" #cursor_id "'}]}")); \ - reply_to_request_simple (_request, \ - "{ 'cursorsKilled': [ " #cursor_id " ] }"); \ - future_wait (_future); \ - future_destroy (_future); \ - request_destroy (_request); \ - } while (0); - - -typedef struct _data_change_stream_t { - mongoc_cursor_response_t response; - bson_t post_batch_resume_token; -} _data_change_stream_t; - -static void -_setup_for_resume (mongoc_change_stream_t *stream) -{ - bool ret; - bson_error_t error; - mongoc_client_t *client; - const char *cmd; - - client = stream->cursor->client; - if (stream->max_wire_version >= WIRE_VERSION_4_4) { - cmd = "{'configureFailPoint': 'failGetMoreAfterCursorCheckout', 'mode': " - "{ 'times': 1 }, 'data': { 'errorCode': 6 }}"; - } else { - cmd = "{'configureFailPoint': 'failCommand', 'mode': { 'times': 1 }, " - "'data': { 'failCommands': ['getMore'], 'errorCode': 6 }}"; - } - ret = mongoc_client_command_simple_with_server_id (client, - "admin", - tmp_bson (cmd), - NULL /* read prefs */, - stream->cursor->server_id, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); -} - - -static int -test_framework_skip_if_not_single_version_5 (void) -{ - if (!TestSuite_CheckLive ()) { - return 0; - } - return (!test_framework_is_replset () && !test_framework_is_mongos ()) ? 1 - : 0; -} - -static mongoc_collection_t * -drop_and_get_coll (mongoc_client_t *client, - const char *db_name, - const char *coll_name) -{ - ASSERT (client); - - mongoc_collection_t *coll = - mongoc_client_get_collection (client, db_name, coll_name); - mongoc_collection_drop (coll, NULL); - return coll; -} - -/* From Change Streams Spec tests: - * "$changeStream must be the first stage in a change stream pipeline sent - * to the server" */ -static void -test_change_stream_pipeline (void) -{ - mock_server_t *server; - request_t *request; - future_t *future; - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *next_doc = NULL; - bson_t *nonempty_pipeline = - tmp_bson ("{ 'pipeline' : [ { '$project' : { 'ns': false } } ] }"); - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - ASSERT (client); - - coll = mongoc_client_get_collection (client, "db", "coll"); - ASSERT (coll); - - future = future_collection_watch (coll, tmp_bson ("{}"), NULL); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'coll'," - " 'pipeline': [{'$changeStream': {}}]," - " 'cursor': {}}")); - - reply_to_request_simple ( - request, - "{'cursor' : {'id': 123, 'ns': 'db.coll', 'firstBatch': []}, 'ok': 1 }"); - - stream = future_get_mongoc_change_stream_ptr (future); - ASSERT (stream); - - future_destroy (future); - request_destroy (request); - - future = future_change_stream_next (stream, &next_doc); - - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '123'}," - " 'collection': 'coll'}")); - reply_to_request_simple (request, - "{'cursor' : { 'nextBatch' : [] }, 'ok': 1}"); - ASSERT (!future_get_bool (future)); - ASSERT (!mongoc_change_stream_error_document (stream, NULL, NULL)); - ASSERT (next_doc == NULL); - future_destroy (future); - request_destroy (request); - - /* Another call to next should produce another getMore */ - future = future_change_stream_next (stream, &next_doc); - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '123'}," - " 'collection': 'coll'}")); - reply_to_request_simple (request, - "{ 'cursor': { 'nextBatch': [] }, 'ok': 1 }"); - ASSERT (!future_get_bool (future)); - ASSERT (!mongoc_change_stream_error_document (stream, NULL, NULL)); - ASSERT (next_doc == NULL); - future_destroy (future); - request_destroy (request); - - DESTROY_CHANGE_STREAM (123); - - /* Test non-empty pipeline */ - future = future_collection_watch (coll, nonempty_pipeline, NULL); - - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'coll'," - " 'pipeline': [" - " {'$changeStream': {}}," - " {'$project': {'ns': false}}]," - " 'cursor': {}}")); - reply_to_request_simple ( - request, - "{'cursor': {'id': 123, 'ns': 'db.coll','firstBatch': []},'ok': 1}"); - - stream = future_get_mongoc_change_stream_ptr (future); - ASSERT (stream); - - future_destroy (future); - request_destroy (request); - - - future = future_change_stream_next (stream, &next_doc); - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '123'}," - " 'collection': 'coll'}")); - reply_to_request_simple (request, - "{ 'cursor': { 'nextBatch': [] }, 'ok': 1 }"); - ASSERT (!future_get_bool (future)); - ASSERT (!mongoc_change_stream_error_document (stream, NULL, NULL)); - ASSERT (next_doc == NULL); - future_destroy (future); - request_destroy (request); - - DESTROY_CHANGE_STREAM (123); - - mongoc_client_destroy (client); - mongoc_collection_destroy (coll); - mock_server_destroy (server); -} - -/* From Change Streams Spec tests: - * "The watch helper must not throw a custom exception when executed against a - * single server topology, but instead depend on a server error" - */ -static void -test_change_stream_live_single_server (void *test_ctx) -{ - /* Temporarily skip on arm64 until mongod tested against is updated */ - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll; - bson_error_t error; - mongoc_change_stream_t *stream; - const bson_t *next_doc = NULL; - const bson_t *reported_err_doc = NULL; - const char *not_replset_doc = "{'errmsg': 'The $changeStream stage is " - "only supported on replica sets', 'code': " - "40573, 'ok': 0}"; - - /* Don't use the errmsg field since it contains quotes. */ - const char *not_supported_doc = "{'code' : 40324, 'ok' : 0 }"; - - BSON_UNUSED (test_ctx); - - ASSERT (client); - - coll = mongoc_client_get_collection (client, "db", "coll"); - ASSERT (coll); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), NULL, NULL, &error), - error); - - stream = mongoc_collection_watch (coll, tmp_bson ("{}"), NULL); - ASSERT (stream); - - ASSERT ( - mongoc_change_stream_error_document (stream, NULL, &reported_err_doc)); - ASSERT (next_doc == NULL); - - if (test_framework_max_wire_version_at_least (6)) { - ASSERT_MATCH (reported_err_doc, not_replset_doc); - } else { - ASSERT_MATCH (reported_err_doc, not_supported_doc); - ASSERT_CONTAINS (bson_lookup_utf8 (reported_err_doc, "errmsg"), - "Unrecognized pipeline stage"); - } - - mongoc_change_stream_destroy (stream); - mongoc_client_destroy (client); - mongoc_collection_destroy (coll); -} - - -typedef struct _test_resume_token_ctx_t { - bool expecting_resume_token; - const bson_t *expected_resume_token_bson; -} test_resume_token_ctx_t; - -static void -test_resume_token_command_start (const mongoc_apm_command_started_t *event) -{ - const bson_t *cmd = mongoc_apm_command_started_get_command (event); - const char *cmd_name = mongoc_apm_command_started_get_command_name (event); - - test_resume_token_ctx_t *ctx = - (test_resume_token_ctx_t *) mongoc_apm_command_started_get_context ( - event); - - if (strcmp (cmd_name, "aggregate") == 0) { - if (ctx->expecting_resume_token) { - char *rt_pattern = bson_as_canonical_extended_json ( - ctx->expected_resume_token_bson, NULL); - char *pattern = - bson_strdup_printf ("{'aggregate': 'coll_resume', 'pipeline': " - "[{'$changeStream': { 'resumeAfter': %s }}]}", - rt_pattern); - ASSERT_MATCH (cmd, pattern); - bson_free (pattern); - bson_free (rt_pattern); - } else { - ASSERT_MATCH (cmd, - "{'aggregate': 'coll_resume', 'pipeline': [{ " - "'$changeStream': { 'resumeAfter': { '$exists': " - "false } }}]}"); - } - } -} - -/* From Change Streams Spec tests: - * "ChangeStream must continuously track the last seen resumeToken" - * Note: we should not inspect the resume token, since the format may change. - */ -static void -test_change_stream_live_track_resume_token (void *test_ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - bson_error_t error; - test_resume_token_ctx_t ctx = {0}; - const bson_t *next_doc = NULL; - mongoc_apm_callbacks_t *callbacks; - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - bson_t opts = BSON_INITIALIZER; - bson_t doc0_rt, doc1_rt, doc2_rt; - const bson_t *resume_token; - - BSON_UNUSED (test_ctx); - - client = test_framework_new_default_client (); - ASSERT (client); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, - test_resume_token_command_start); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - - coll = drop_and_get_coll (client, "db", "coll_resume"); - ASSERT (coll); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), NULL, NULL, &error), - error); - - /* Set the batch size to 1 so we only get one document per call to next. */ - stream = mongoc_collection_watch ( - coll, tmp_bson ("{}"), tmp_bson ("{'batchSize': 1}")); - ASSERT (stream); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), - error); - - /* Insert a few docs to listen for. Use write concern majority, so subsequent - * call to watch will be guaranteed to retrieve them. */ - mongoc_write_concern_set_wmajority (wc, 30000); - mongoc_write_concern_append (wc, &opts); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 0}"), &opts, NULL, &error), - error); - - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 1}"), &opts, NULL, &error), - error); - - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 2}"), &opts, NULL, &error), - error); - - /* The resume token should be updated to the most recently iterated doc */ - ASSERT (mongoc_change_stream_next (stream, &next_doc)); - ASSERT (next_doc); - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (!bson_empty0 (resume_token)); - bson_copy_to (resume_token, &doc0_rt); - - ASSERT (mongoc_change_stream_next (stream, &next_doc)); - ASSERT (next_doc); - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (!bson_empty0 (resume_token)); - ASSERT (bson_compare (resume_token, &doc0_rt) != 0); - bson_copy_to (resume_token, &doc1_rt); - - _setup_for_resume (stream); - /* A resume will occur, forcing a resumeAfter token in the aggregate cmd. */ - - ctx.expecting_resume_token = true; - ctx.expected_resume_token_bson = &doc1_rt; - ASSERT (mongoc_change_stream_next (stream, &next_doc)); - - ASSERT (next_doc); - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (!bson_empty0 (resume_token)); - ASSERT (bson_compare (resume_token, &doc0_rt) != 0); - ASSERT (bson_compare (resume_token, &doc1_rt) != 0); - bson_copy_to (resume_token, &doc2_rt); - - /* There are no docs left. But the next call should still keep the same - * resume token */ - ASSERT (!mongoc_change_stream_next (stream, &next_doc)); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), - error); - ASSERT (!next_doc); - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (!bson_empty0 (resume_token)); - ASSERT (bson_compare (resume_token, &doc2_rt) == 0); - - bson_destroy (&doc0_rt); - bson_destroy (&doc1_rt); - bson_destroy (&doc2_rt); - bson_destroy (&opts); - mongoc_write_concern_destroy (wc); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_change_stream_destroy (stream); - mongoc_client_destroy (client); - mongoc_collection_destroy (coll); -} - -typedef struct _test_batch_size_ctx { - uint32_t num_get_mores; - uint32_t expected_getmore_batch_size; - uint32_t expected_agg_batch_size; -} test_batch_size_ctx_t; - -static void -test_batch_size_command_succeeded (const mongoc_apm_command_succeeded_t *event) -{ - const bson_t *reply = mongoc_apm_command_succeeded_get_reply (event); - const char *cmd_name = mongoc_apm_command_succeeded_get_command_name (event); - - test_batch_size_ctx_t *ctx = - (test_batch_size_ctx_t *) mongoc_apm_command_succeeded_get_context ( - event); - - if (strcmp (cmd_name, "getMore") == 0) { - bson_t next_batch; - ++ctx->num_get_mores; - bson_lookup_doc (reply, "cursor.nextBatch", &next_batch); - ASSERT (bson_count_keys (&next_batch) == - ctx->expected_getmore_batch_size); - } else if (strcmp (cmd_name, "aggregate") == 0) { - bson_t first_batch; - bson_lookup_doc (reply, "cursor.firstBatch", &first_batch); - ASSERT (bson_count_keys (&first_batch) == ctx->expected_agg_batch_size); - } -} -/* Test that the batch size option applies to both the initial aggregate and - * subsequent getMore commands. - */ -static void -test_change_stream_live_batch_size (void *test_ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - test_batch_size_ctx_t ctx = {0}; - const bson_t *next_doc = NULL; - mongoc_apm_callbacks_t *callbacks; - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - bson_t opts = BSON_INITIALIZER; - bson_error_t err; - uint32_t i; - - BSON_UNUSED (test_ctx); - - client = test_framework_new_default_client (); - ASSERT (client); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_succeeded_cb (callbacks, - test_batch_size_command_succeeded); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - - coll = drop_and_get_coll (client, "db", "coll_batch"); - ASSERT (coll); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), NULL, NULL, &err), - err); - - stream = mongoc_collection_watch ( - coll, tmp_bson ("{}"), tmp_bson ("{'batchSize': 1}")); - ASSERT (stream); - - ctx.expected_agg_batch_size = 0; - ctx.expected_getmore_batch_size = 0; - - ASSERT (!mongoc_change_stream_next (stream, &next_doc)); - ASSERT (!mongoc_change_stream_error_document (stream, NULL, NULL)); - ASSERT (next_doc == NULL); - - ctx.expected_getmore_batch_size = 1; - - mongoc_write_concern_set_wmajority (wc, 30000); - mongoc_write_concern_append (wc, &opts); - for (i = 0; i < 10; i++) { - bson_t *doc = BCON_NEW ("_id", BCON_INT32 (i)); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, doc, &opts, NULL, &err), err); - bson_destroy (doc); - } - - ctx.expected_getmore_batch_size = 1; - for (i = 0; i < 10; i++) { - mongoc_change_stream_next (stream, &next_doc); - } - - ctx.expected_getmore_batch_size = 0; - ASSERT (!mongoc_change_stream_next (stream, &next_doc)); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &err, NULL), - err); - ASSERT (next_doc == NULL); - - /* 10 getMores for results, 1 for initial next, 1 for last empty next */ - ASSERT (ctx.num_get_mores == 12); - - bson_destroy (&opts); - mongoc_write_concern_destroy (wc); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_change_stream_destroy (stream); - mongoc_client_destroy (client); - mongoc_collection_destroy (coll); -} - - -/* From Change Streams Spec tests: - * "ChangeStream will throw an exception if the server response is missing the - * resume token." In the C driver case, return an error. - */ -static void -_test_resume_token_error (const char *id_projection) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - const bson_t *next_doc = NULL; - mongoc_change_stream_t *stream; - bson_error_t err; - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - bson_t opts = BSON_INITIALIZER; - - client = test_framework_new_default_client (); - ASSERT (client); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - - coll = drop_and_get_coll (client, "db", "coll_missing_resume"); - ASSERT (coll); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), NULL, NULL, &err), - err); - - stream = mongoc_collection_watch ( - coll, - tmp_bson ("{'pipeline': [{'$project': {'_id': %s }}]}", id_projection), - NULL); - - ASSERT (stream); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &err, NULL), - err); - - mongoc_write_concern_set_wmajority (wc, 30000); - mongoc_write_concern_append (wc, &opts); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 2}"), &opts, NULL, &err), - err); - - ASSERT (!mongoc_change_stream_next (stream, &next_doc)); - ASSERT (mongoc_change_stream_error_document (stream, &err, NULL)); - - /* Newer server versions emit different errors. */ - if (!test_framework_max_wire_version_at_least (8)) { - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CHANGE_STREAM_NO_RESUME_TOKEN, - "Cannot provide resume functionality"); - } else { - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_SERVER, - 280, - "Only transformations that retain the unmodified " - "_id field are allowed."); - } - - bson_destroy (&opts); - mongoc_write_concern_destroy (wc); - mongoc_change_stream_destroy (stream); - mongoc_client_destroy (client); - mongoc_collection_destroy (coll); -} - -static void -test_change_stream_live_missing_resume_token (void *test_ctx) -{ - BSON_UNUSED (test_ctx); - - _test_resume_token_error ("0"); -} - -static void -test_change_stream_live_invalid_resume_token (void *test_ctx) -{ - BSON_UNUSED (test_ctx); - - /* test a few non-document BSON types */ - _test_resume_token_error ("{'$literal': 1}"); - _test_resume_token_error ("{'$literal': true}"); - _test_resume_token_error ("{'$literal': 'foo'}"); - _test_resume_token_error ("{'$literal': []}"); -} - -static void -_test_getmore_error (const char *server_reply, - bool should_resume, - bool resume_kills_cursor) -{ - mock_server_t *server; - request_t *request; - future_t *future; - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *next_doc = NULL; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - coll = mongoc_client_get_collection (client, "db", "coll"); - future = future_collection_watch (coll, tmp_bson ("{}"), NULL); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'aggregate': 'coll'}")); - reply_to_request_simple ( - request, - "{'cursor': {'id': 123, 'ns': 'db.coll','firstBatch': []},'ok': 1 }"); - stream = future_get_mongoc_change_stream_ptr (future); - BSON_ASSERT (stream); - future_destroy (future); - request_destroy (request); - - /* the first getMore receives an error. */ - future = future_change_stream_next (stream, &next_doc); - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '123'}," - " 'collection': 'coll'}")); - reply_to_request_simple (request, server_reply); - request_destroy (request); - if (should_resume) { - /* client should retry the aggregate. */ - if (resume_kills_cursor) { - /* errors that are considered "not primary" or "node is recovering" - * errors by SDAM will mark the connected server as UNKNOWN, and no - * killCursors will be executed. */ - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'killCursors': 'coll'}")); - reply_to_request_simple (request, "{'cursorsKilled': [123]}"); - request_destroy (request); - } - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'aggregate': 'coll'}")); - reply_to_request_simple (request, - "{'cursor':" - " {'id': 124," - " 'ns': 'db.coll'," - " 'firstBatch':" - " [{'_id': {'resume': 'doc'}}]}," - "'ok': 1}"); - request_destroy (request); - BSON_ASSERT (future_get_bool (future)); - BSON_ASSERT (!mongoc_change_stream_error_document (stream, NULL, NULL)); - DESTROY_CHANGE_STREAM (124); - } else { - BSON_ASSERT (!future_get_bool (future)); - BSON_ASSERT (mongoc_change_stream_error_document (stream, NULL, NULL)); - DESTROY_CHANGE_STREAM (123); - } - future_destroy (future); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -/* Test a variety of resumable and non-resumable errors that may be returned - * from a getMore. */ -static void -test_getmore_errors (void) -{ - _test_getmore_error ("{'ok': 0, 'code': 1, 'errmsg': 'internal error'}", - false /* should_resume */, - false /* ignored */); - _test_getmore_error ("{'ok': 0, 'code': 6, 'errmsg': 'host unreachable'}", - true /* should_resume */, - true /* resume_kills_cursor */); - _test_getmore_error ("{'ok': 0, 'code': 12345, 'errmsg': 'random error'}", - false /* should_resume */, - false /* ignored */); - /* most error codes are resumable, excluding a few deny listed ones. */ - _test_getmore_error ("{'ok': 0, 'code': 11601, 'errmsg': 'interrupted'}", - false /* should_resume */, - false /* ignored */); - _test_getmore_error ( - "{'ok': 0, 'code': 136, 'errmsg': 'capped position lost'}", - false /* should_resume */, - false /* ignored */); - _test_getmore_error ("{'ok': 0, 'code': 237, 'errmsg': 'cursor killed'}", - false /* should_resume */, - false /* ignored */); - _test_getmore_error ("{'ok': 0, 'errmsg': 'random error'}", - false /* should_resume */, - false /* ignored */); - /* Even an error with a 'NonResumableChangeStreamError' label will resume if - * it is on the allow list. */ - _test_getmore_error ( - "{'ok': 0, 'code': 6, 'errorLabels': " - "['NonResumableChangeStreamError'], 'errmsg': 'host unreachable'}", - true /* should_resume */, - true /* resume_kills_cursor */); - _test_getmore_error ( - "{'ok': 0, 'code': 6, 'errorLabels': " - "['NonRetryableChangeStreamError'], 'errmsg': 'host unreachable'}", - true /* should_resume */, - true /* resume_kills_cursor */); -} -/* From Change Streams Spec tests: - * "ChangeStream will automatically resume one time on a resumable error - * (including not primary) with the initial pipeline and options, except for the - * addition/update of a resumeToken" - * "The killCursors command sent during the “Resume Process†must not be - * allowed to throw an exception." - */ -static void -test_change_stream_resumable_error (void) -{ - mock_server_t *server; - request_t *request; - future_t *future; - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - mongoc_uri_t *uri; - bson_error_t err; - const bson_t *err_doc = NULL; - const bson_t *next_doc = NULL; - const char *not_primary_err = - "{ 'code': 10107, 'errmsg': 'not primary', 'ok': 0 }"; - const char *interrupted_err = - "{ 'code': 11601, 'errmsg': 'interrupted', 'ok': 0 }"; - const bson_t *watch_cmd = tmp_bson ("{'$db': 'db'," - " 'aggregate': 'coll'," - " 'pipeline': [{'$changeStream': {}}]," - " 'cursor': {}}"); - const char *expected_msg = - "{'$db': 'db', 'getMore': {'$numberLong': '%d'}, 'collection': 'coll' }"; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "socketTimeoutMS", 100); - client = test_framework_client_new_from_uri (uri, NULL); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - coll = mongoc_client_get_collection (client, "db", "coll"); - - future = future_collection_watch (coll, tmp_bson ("{}"), NULL); - - request = mock_server_receives_msg (server, MONGOC_MSG_NONE, watch_cmd); - - reply_to_request_simple (request, - "{'cursor': {'id': 123, 'ns': " - "'db.coll','firstBatch': []},'ok': 1 " - "}"); - - stream = future_get_mongoc_change_stream_ptr (future); - ASSERT (stream); - - future_destroy (future); - request_destroy (request); - - /* Test that a network hangup results in a resumable error */ - future = future_change_stream_next (stream, &next_doc); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson (expected_msg, 123)); - BSON_ASSERT (request); - reply_to_request_with_hang_up (request); - request_destroy (request); - - /* Retry command */ - request = mock_server_receives_msg (server, MONGOC_MSG_NONE, watch_cmd); - BSON_ASSERT (request); - reply_to_request_simple ( - request, - "{'cursor': {'id': 124,'ns': 'db.coll','firstBatch': []},'ok': 1 }"); - request_destroy (request); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson (expected_msg, 124)); - reply_to_request_simple (request, - "{ 'cursor': { 'nextBatch': [] }, 'ok': 1 }"); - request_destroy (request); - ASSERT (!future_get_bool (future)); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &err, NULL), - err); - ASSERT (next_doc == NULL); - future_destroy (future); - - /* Test the "not_primary" resumable error occurring twice in a row */ - future = future_change_stream_next (stream, &next_doc); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson (expected_msg, 124)); - reply_to_request_simple (request, not_primary_err); - request_destroy (request); - - /* Retry command */ - request = mock_server_receives_msg (server, MONGOC_MSG_NONE, watch_cmd); - reply_to_request_simple ( - request, - "{'cursor': {'id': 125, 'ns': 'db.coll','firstBatch': []},'ok': 1}"); - request_destroy (request); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson (expected_msg, 125)); - reply_to_request_simple (request, not_primary_err); - request_destroy (request); - - /* Retry command */ - request = mock_server_receives_msg (server, MONGOC_MSG_NONE, watch_cmd); - reply_to_request_simple (request, - "{'cursor': {'id': 126, 'ns': " - "'db.coll','firstBatch': []},'ok': 1 " - "}"); - request_destroy (request); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson (expected_msg, 126)); - reply_to_request_simple (request, interrupted_err); - request_destroy (request); - - /* Check that error is returned */ - ASSERT (!future_get_bool (future)); - ASSERT (mongoc_change_stream_error_document (stream, &err, &err_doc)); - ASSERT (next_doc == NULL); - ASSERT_ERROR_CONTAINS (err, MONGOC_ERROR_SERVER, 11601, "interrupted"); - ASSERT_MATCH (err_doc, interrupted_err); - future_destroy (future); - DESTROY_CHANGE_STREAM (126); - - /* Test an error on the initial aggregate when resuming. */ - future = future_collection_watch (coll, tmp_bson ("{}"), NULL); - request = mock_server_receives_msg (server, MONGOC_MSG_NONE, watch_cmd); - reply_to_request_simple (request, - "{'cursor': {'id': 123, 'ns': " - "'db.coll','firstBatch': []},'ok': 1 " - "}"); - stream = future_get_mongoc_change_stream_ptr (future); - ASSERT (stream); - request_destroy (request); - future_destroy (future); - - future = future_change_stream_next (stream, &next_doc); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson (expected_msg, 123)); - reply_to_request_simple ( - request, "{ 'code': 10107, 'errmsg': 'not primary', 'ok': 0 }"); - request_destroy (request); - - /* Retry command */ - request = mock_server_receives_msg (server, MONGOC_MSG_NONE, watch_cmd); - reply_to_request_simple (request, - "{'code': 123, 'errmsg': 'bad cmd', 'ok': 0}"); - request_destroy (request); - - /* Check that error is returned */ - ASSERT (!future_get_bool (future)); - ASSERT (mongoc_change_stream_error_document (stream, &err, &err_doc)); - ASSERT (next_doc == NULL); - ASSERT_ERROR_CONTAINS (err, MONGOC_ERROR_SERVER, 123, "bad cmd"); - ASSERT_MATCH (err_doc, "{'code': 123, 'errmsg': 'bad cmd', 'ok': 0}"); - future_destroy (future); - - mongoc_change_stream_destroy (stream); - mongoc_uri_destroy (uri); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -/* Test that options are sent correctly. - */ -static void -test_change_stream_options (void) -{ - mock_server_t *server; - request_t *request; - future_t *future; - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *next_doc = NULL; - bson_error_t err; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - ASSERT (client); - - coll = mongoc_client_get_collection (client, "db", "coll"); - ASSERT (coll); - - - /* - * fullDocument: 'default'|'updateLookup', passed to $changeStream stage - * resumeAfter: optional, passed to $changeStream stage - * startAfter: optional, passed to $changeStream stage - * startAtOperationTime: optional, passed to $changeStream stage - * maxAwaitTimeMS: Optional, passed to cursor - * batchSize: Optional, passed as agg option, {cursor: { batchSize: }} - * collation: Optional, passed as agg option - */ - - /* fullDocument */ - future = future_collection_watch ( - coll, - tmp_bson ("{}"), - tmp_bson ("{ 'fullDocument': 'updateLookup', " - "'resumeAfter': {'resume': 'after'}, " - "'startAfter': {'start': 'after'}, " - "'startAtOperationTime': { '$timestamp': { 't': 1, 'i': 1 }}, " - "'maxAwaitTimeMS': 5000, 'batchSize': " - "5, 'collation': { 'locale': 'en' }}")); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ( - "{'$db': 'db'," - " 'aggregate': 'coll'," - " 'pipeline': [" - " {'$changeStream': {" - " 'fullDocument': 'updateLookup'," - " 'resumeAfter': {'resume': 'after'}," - " 'startAfter': {'start': 'after'}," - " 'startAtOperationTime': {'$timestamp': { 't': 1, 'i': 1 }}}}]," - " 'cursor': {'batchSize': 5}," - " 'collation': {'locale': 'en'}}")); - - reply_to_request_simple ( - request, - "{'cursor': {'id': 123,'ns': 'db.coll','firstBatch': []},'ok': 1 }"); - - stream = future_get_mongoc_change_stream_ptr (future); - ASSERT (stream); - future_destroy (future); - request_destroy (request); - - future = future_change_stream_next (stream, &next_doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '123'}," - " 'collection': 'coll'," - " 'maxTimeMS': {'$numberLong': '5000'}," - " 'batchSize': {'$numberLong': '5'}}")); - reply_to_request_simple (request, - "{ 'cursor': { 'nextBatch': [] }, 'ok': 1 }"); - request_destroy (request); - ASSERT (!future_get_bool (future)); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &err, NULL), - err); - ASSERT (next_doc == NULL); - future_destroy (future); - - DESTROY_CHANGE_STREAM (123); - - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -/* Test basic watch functionality and validate the server documents */ -static void -test_change_stream_live_watch (void *test_ctx) -{ - mongoc_client_t *client = test_framework_new_default_client (); - bson_t *inserted_doc = tmp_bson ("{ 'x': 'y'}"); - const bson_t *next_doc = NULL; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - bson_t opts = BSON_INITIALIZER; - bson_error_t err; - - BSON_UNUSED (test_ctx); - - mongoc_write_concern_set_wmajority (wc, 30000); - - coll = drop_and_get_coll (client, "db", "coll_watch"); - ASSERT (coll); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), NULL, NULL, &err), - err); - - stream = mongoc_collection_watch (coll, tmp_bson ("{}"), NULL); - ASSERT (stream); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &err, NULL), - err); - - /* Test that inserting a doc produces the expected change stream doc */ - mongoc_write_concern_append (wc, &opts); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, inserted_doc, &opts, NULL, &err), - err); - - ASSERT (mongoc_change_stream_next (stream, &next_doc)); - - /* Validation rules as follows: - * { _id: , operationType: "insert", ns: , documentKey: - * , - * updateDescription: , fullDocument: } - */ - ASSERT_HAS_FIELD (next_doc, "_id"); - ASSERT (!strcmp (bson_lookup_utf8 (next_doc, "operationType"), "insert")); - - ASSERT_MATCH ( - next_doc, - "{ '_id': { '$exists': true },'operationType': 'insert', 'ns': " - "{ 'db': 'db', 'coll': 'coll_watch' },'documentKey': { " - "'$exists': true }, 'updateDescription': { '$exists': false }, " - "'fullDocument': { '_id': { '$exists': true }, 'x': 'y' }}"); - - /* Test updating a doc */ - ASSERT_OR_PRINT ( - mongoc_collection_update_one (coll, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'x': 'z'} }"), - &opts, - NULL, - &err), - err); - - ASSERT (mongoc_change_stream_next (stream, &next_doc)); - - ASSERT_MATCH ( - next_doc, - "{ '_id': { '$exists': true },'operationType': 'update', 'ns': { 'db': " - "'db', 'coll': 'coll_watch' },'documentKey': { '$exists': " - "true }, 'updateDescription': { 'updatedFields': { 'x': 'z' } " - "}, 'fullDocument': { '$exists': false }}"); - - bson_destroy (&opts); - mongoc_write_concern_destroy (wc); - mongoc_change_stream_destroy (stream); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -/* From Change Streams Spec tests: - * "ChangeStream will resume after a killCursors command is issued for its child - * cursor." - * "ChangeStream will perform server selection before attempting to resume, - * using initial readPreference" - */ -static void -test_change_stream_live_read_prefs (void *test_ctx) -{ - /* - - connect with secondary read preference - - verify we are connected to a secondary - - issue a killCursors to trigger a resume - - after resume, check that the cursor connected to a secondary - */ - - mongoc_read_prefs_t *prefs; - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - mongoc_cursor_t *raw_cursor; - const bson_t *next_doc = NULL; - bson_error_t err; - uint64_t first_cursor_id; - - BSON_UNUSED (test_ctx); - - coll = drop_and_get_coll (client, "db", "coll_read_prefs"); - ASSERT (coll); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, - tmp_bson (NULL), - tmp_bson ("{'writeConcern': {'w': %d}}", - test_framework_data_nodes_count ()), - NULL, - &err), - err); - - prefs = mongoc_read_prefs_copy (mongoc_collection_get_read_prefs (coll)); - mongoc_read_prefs_set_mode (prefs, MONGOC_READ_SECONDARY); - mongoc_collection_set_read_prefs (coll, prefs); - - stream = mongoc_collection_watch (coll, tmp_bson ("{}"), NULL); - ASSERT (stream); - mongoc_change_stream_next (stream, &next_doc); - - raw_cursor = stream->cursor; - ASSERT (raw_cursor); - - ASSERT (test_framework_server_is_secondary (client, raw_cursor->server_id)); - first_cursor_id = mongoc_cursor_get_id (raw_cursor); - - /* Call next to create the cursor, should return no documents. */ - ASSERT (!mongoc_change_stream_next (stream, &next_doc)); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &err, NULL), - err); - - _setup_for_resume (stream); - - /* Change stream client will resume with another cursor. */ - /* depending on the server version, this may or may not receive another - * document on resume */ - (void) mongoc_change_stream_next (stream, &next_doc); - ASSERT_OR_PRINT ( - !mongoc_change_stream_error_document (stream, &err, &next_doc), err); - - raw_cursor = stream->cursor; - ASSERT (first_cursor_id != mongoc_cursor_get_id (raw_cursor)); - ASSERT (test_framework_server_is_secondary (client, raw_cursor->server_id)); - - mongoc_read_prefs_destroy (prefs); - mongoc_change_stream_destroy (stream); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -/* Test that a failed server selection returns an error. This verifies a bug - * is fixed, which would trigger an assert in this case. */ -static void -test_change_stream_server_selection_fails (void) -{ - const bson_t *bson; - bson_error_t err; - mongoc_client_t *client = - test_framework_client_new ("mongodb://localhost:12345/", NULL); - mongoc_collection_t *coll = - mongoc_client_get_collection (client, "test", "test"); - mongoc_change_stream_t *cs = - mongoc_collection_watch (coll, tmp_bson ("{}"), NULL); - - mongoc_change_stream_next (cs, &bson); - BSON_ASSERT (mongoc_change_stream_error_document (cs, &err, &bson)); - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "No servers yet eligible for rescan"); - mongoc_change_stream_destroy (cs); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -/* Test calling next on a change stream which errors after construction. This - * verifies a bug is fixed, which would try to access a NULL cursor. */ -static void -test_change_stream_next_after_error (void *test_ctx) -{ - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *bson; - bson_error_t err; - - BSON_UNUSED (test_ctx); - - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - coll = mongoc_client_get_collection (client, "db", "coll"); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), NULL, NULL, &err), - err); - stream = mongoc_collection_watch ( - coll, tmp_bson ("{'pipeline': ['invalid_stage']}"), NULL); - BSON_ASSERT (!mongoc_change_stream_next (stream, &bson)); - BSON_ASSERT (mongoc_change_stream_error_document (stream, &err, &bson)); - BSON_ASSERT (err.domain == MONGOC_ERROR_SERVER); - mongoc_change_stream_destroy (stream); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -typedef struct { - char *pattern; - int agg_count; -} array_started_ctx_t; - -static void -_accepts_array_started (const mongoc_apm_command_started_t *event) -{ - const bson_t *cmd = mongoc_apm_command_started_get_command (event); - const char *cmd_name = mongoc_apm_command_started_get_command_name (event); - array_started_ctx_t *ctx = - (array_started_ctx_t *) mongoc_apm_command_started_get_context (event); - if (strcmp (cmd_name, "aggregate") != 0) { - return; - } - ctx->agg_count++; - ASSERT_MATCH (cmd, ctx->pattern); -} - -/* Test that watch accepts an array document {0: {}, 1: {}} as the pipeline, - * similar to mongoc_collection_aggregate */ -static void -test_change_stream_accepts_array (void *test_ctx) -{ - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_apm_callbacks_t *callbacks = mongoc_apm_callbacks_new (); - array_started_ctx_t ctx = {0}; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *bson; - bson_error_t err; - bson_t *opts = - tmp_bson ("{'maxAwaitTimeMS': 1}"); /* to speed up the test. */ - - BSON_UNUSED (test_ctx); - - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - /* set up apm callbacks to listen for the agg commands. */ - ctx.pattern = - bson_strdup ("{'aggregate': 'coll', 'pipeline': [ {'$changeStream': {}}, " - "{'$match': {'x': 1}}, {'$project': {'x': 1}}]}"); - mongoc_apm_set_command_started_cb (callbacks, _accepts_array_started); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - coll = mongoc_client_get_collection (client, "db", "coll"); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), NULL, NULL, &err), - err); - /* try starting a change stream with a { "pipeline": [...] } argument */ - stream = mongoc_collection_watch ( - coll, - tmp_bson ("{'pipeline': [{'$match': {'x': 1}}, {'$project': {'x': 1}}]}"), - opts); - (void) mongoc_change_stream_next (stream, &bson); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &err, &bson), - err); - ASSERT_CMPINT32 (ctx.agg_count, ==, 1); - mongoc_change_stream_destroy (stream); - /* try with an array like document. */ - stream = mongoc_collection_watch ( - coll, - tmp_bson ("{'0': {'$match': {'x': 1}}, '1': {'$project': {'x': 1}}}"), - opts); - (void) mongoc_change_stream_next (stream, &bson); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &err, &bson), - err); - ASSERT_CMPINT32 (ctx.agg_count, ==, 2); - mongoc_change_stream_destroy (stream); - /* try with malformed { "pipeline": [...] } argument. */ - bson_free (ctx.pattern); - ctx.pattern = bson_strdup ( - "{'aggregate': 'coll', 'pipeline': [ {'$changeStream': {}}, 42 ]}"); - stream = - mongoc_collection_watch (coll, tmp_bson ("{'pipeline': [42] }"), NULL); - (void) mongoc_change_stream_next (stream, &bson); - BSON_ASSERT (mongoc_change_stream_error_document (stream, &err, &bson)); - ASSERT_ERROR_CONTAINS ( - err, - MONGOC_ERROR_SERVER, - 14, - "Each element of the 'pipeline' array must be an object"); - ASSERT_CMPINT32 (ctx.agg_count, ==, 3); - mongoc_change_stream_destroy (stream); - /* try with malformed array doc argument. */ - stream = mongoc_collection_watch (coll, tmp_bson ("{'0': 42 }"), NULL); - (void) mongoc_change_stream_next (stream, &bson); - BSON_ASSERT (mongoc_change_stream_error_document (stream, &err, &bson)); - ASSERT_ERROR_CONTAINS ( - err, - MONGOC_ERROR_SERVER, - 14, - "Each element of the 'pipeline' array must be an object"); - ASSERT_CMPINT32 (ctx.agg_count, ==, 4); - mongoc_change_stream_destroy (stream); - bson_free (ctx.pattern); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -/* A simple test that passing 'startAtOperationTime' does not error. */ -void -test_change_stream_start_at_operation_time (void *test_ctx) -{ - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *doc; - bson_t opts; - mongoc_client_session_t *session; - bson_error_t error; - - BSON_UNUSED (test_ctx); - - session = mongoc_client_start_session (client, NULL, &error); - coll = mongoc_client_get_collection (client, "db", "coll"); - bson_init (&opts); - ASSERT_OR_PRINT (mongoc_client_session_append (session, &opts, &error), - error); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), &opts, NULL, &error), - error); - BSON_APPEND_TIMESTAMP (&opts, - "startAtOperationTime", - session->operation_timestamp, - session->operation_increment); - stream = - mongoc_collection_watch (coll, tmp_bson ("{'pipeline': []}"), &opts); - - (void) mongoc_change_stream_next (stream, &doc); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), - error); - - bson_destroy (&opts); - mongoc_change_stream_destroy (stream); - mongoc_client_session_destroy (session); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -typedef struct { - bool has_initiated; - bool has_resumed; - bson_t agg_reply; -} resume_ctx_t; - -#define RESUME_INITIALIZER \ - { \ - false, false, BSON_INITIALIZER \ - } - -static void -_resume_at_optime_started (const mongoc_apm_command_started_t *event) -{ - resume_ctx_t *ctx; - - ctx = (resume_ctx_t *) mongoc_apm_command_started_get_context (event); - if (0 != strcmp (mongoc_apm_command_started_get_command_name (event), - "aggregate")) { - return; - } - - if (!ctx->has_initiated) { - ctx->has_initiated = true; - return; - } - - ctx->has_resumed = true; - - /* postBatchResumeToken (MongoDB 4.0.7+) supersedes operationTime. Since - * test_change_stream_resume_at_optime runs for wire version 7+, decide - * whether to skip operationTime assertion based on the command reply. */ - if (!bson_has_field (&ctx->agg_reply, "cursor.postBatchResumeToken")) { - bson_value_t replied_optime, sent_optime; - match_ctx_t match_ctx = {{0}}; - - /* it should re-use the same optime on resume. */ - bson_lookup_value (&ctx->agg_reply, "operationTime", &replied_optime); - bson_lookup_value (mongoc_apm_command_started_get_command (event), - "pipeline.0.$changeStream.startAtOperationTime", - &sent_optime); - BSON_ASSERT (replied_optime.value_type == BSON_TYPE_TIMESTAMP); - BSON_ASSERT ( - match_bson_value (&sent_optime, &replied_optime, &match_ctx)); - bson_value_destroy (&sent_optime); - bson_value_destroy (&replied_optime); - } -} - -static void -_resume_at_optime_succeeded (const mongoc_apm_command_succeeded_t *event) -{ - resume_ctx_t *ctx; - - ctx = (resume_ctx_t *) mongoc_apm_command_succeeded_get_context (event); - if (!strcmp (mongoc_apm_command_succeeded_get_command_name (event), - "aggregate")) { - bson_destroy (&ctx->agg_reply); - bson_copy_to (mongoc_apm_command_succeeded_get_reply (event), - &ctx->agg_reply); - } -} - -/* Test that "operationTime" in aggregate reply is used on resume */ -static void -test_change_stream_resume_at_optime (void *test_ctx) -{ - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *doc; - bson_error_t error; - mongoc_apm_callbacks_t *callbacks; - resume_ctx_t ctx = RESUME_INITIALIZER; - - BSON_UNUSED (test_ctx); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, _resume_at_optime_started); - mongoc_apm_set_command_succeeded_cb (callbacks, _resume_at_optime_succeeded); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - coll = mongoc_client_get_collection (client, "db", "coll"); - stream = mongoc_collection_watch (coll, tmp_bson ("{'pipeline': []}"), NULL); - - _setup_for_resume (stream); - (void) mongoc_change_stream_next (stream, &doc); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), - error); - BSON_ASSERT (ctx.has_initiated); - BSON_ASSERT (ctx.has_resumed); - - bson_destroy (&ctx.agg_reply); - mongoc_change_stream_destroy (stream); - mongoc_collection_destroy (coll); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_client_destroy (client); -} - -static void -_resume_with_post_batch_resume_token_started ( - const mongoc_apm_command_started_t *event) -{ - resume_ctx_t *ctx; - - ctx = (resume_ctx_t *) mongoc_apm_command_started_get_context (event); - if (0 != strcmp (mongoc_apm_command_started_get_command_name (event), - "aggregate")) { - return; - } - - if (!ctx->has_initiated) { - ctx->has_initiated = true; - return; - } - - ctx->has_resumed = true; - - /* postBatchResumeToken is available since MongoDB 4.0.7, but the test runs - * for wire version 7+. Decide whether to skip postBatchResumeToken assertion - * based on the command reply. */ - if (bson_has_field (&ctx->agg_reply, "cursor.postBatchResumeToken")) { - bson_value_t replied_pbrt, sent_pbrt; - match_ctx_t match_ctx = {{0}}; - - /* it should re-use the same postBatchResumeToken on resume. */ - bson_lookup_value ( - &ctx->agg_reply, "cursor.postBatchResumeToken", &replied_pbrt); - bson_lookup_value (mongoc_apm_command_started_get_command (event), - "pipeline.0.$changeStream.resumeAfter", - &sent_pbrt); - BSON_ASSERT (replied_pbrt.value_type == BSON_TYPE_DOCUMENT); - BSON_ASSERT (match_bson_value (&sent_pbrt, &replied_pbrt, &match_ctx)); - bson_value_destroy (&sent_pbrt); - bson_value_destroy (&replied_pbrt); - } -} - -static void -_resume_with_post_batch_resume_token_succeeded ( - const mongoc_apm_command_succeeded_t *event) -{ - resume_ctx_t *ctx; - - ctx = (resume_ctx_t *) mongoc_apm_command_succeeded_get_context (event); - if (!strcmp (mongoc_apm_command_succeeded_get_command_name (event), - "aggregate")) { - bson_destroy (&ctx->agg_reply); - bson_copy_to (mongoc_apm_command_succeeded_get_reply (event), - &ctx->agg_reply); - } -} - -/* Test that "postBatchResumeToken" in aggregate reply is used on resume */ -static void -test_change_stream_resume_with_post_batch_resume_token (void *test_ctx) -{ - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *doc; - bson_error_t error; - mongoc_apm_callbacks_t *callbacks; - resume_ctx_t ctx = RESUME_INITIALIZER; - - BSON_UNUSED (test_ctx); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb ( - callbacks, _resume_with_post_batch_resume_token_started); - mongoc_apm_set_command_succeeded_cb ( - callbacks, _resume_with_post_batch_resume_token_succeeded); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - coll = mongoc_client_get_collection (client, "db", "coll"); - stream = mongoc_collection_watch (coll, tmp_bson ("{'pipeline': []}"), NULL); - - _setup_for_resume (stream); - (void) mongoc_change_stream_next (stream, &doc); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), - error); - BSON_ASSERT (ctx.has_initiated); - BSON_ASSERT (ctx.has_resumed); - - bson_destroy (&ctx.agg_reply); - mongoc_change_stream_destroy (stream); - mongoc_collection_destroy (coll); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_client_destroy (client); -} - -/* A simple test of database watch. */ -void -test_change_stream_database_watch (void *test_ctx) -{ - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_database_t *db; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *doc; - bson_t opts; - bson_error_t error; - - BSON_UNUSED (test_ctx); - - db = mongoc_client_get_database (client, "db"); - bson_init (&opts); - - stream = mongoc_database_watch (db, tmp_bson ("{}"), NULL); - - coll = mongoc_database_get_collection (db, "coll"); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), &opts, NULL, &error), - error); - - (void) mongoc_change_stream_next (stream, &doc); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), - error); - - bson_destroy (&opts); - mongoc_change_stream_destroy (stream); - mongoc_database_destroy (db); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -/* A simple test of client watch. */ -void -test_change_stream_client_watch (void *test_ctx) -{ - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *doc; - bson_t opts; - bson_error_t error; - - BSON_UNUSED (test_ctx); - - bson_init (&opts); - - stream = mongoc_client_watch (client, tmp_bson ("{}"), NULL); - - coll = mongoc_client_get_collection (client, "db", "coll"); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), &opts, NULL, &error), - error); - - (void) mongoc_change_stream_next (stream, &doc); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), - error); - - bson_destroy (&opts); - mongoc_change_stream_destroy (stream); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - - -static int -_skip_if_rs_version_less_than (const char *version) -{ - if (!TestSuite_CheckLive ()) { - return 0; - } - if (!test_framework_skip_if_not_replset ()) { - return 0; - } - if (test_framework_get_server_version () >= - test_framework_str_to_version (version)) { - return 1; - } - return 0; -} - -static int -_skip_if_no_client_watch (void) -{ - return _skip_if_rs_version_less_than ("3.8.0"); -} - -static int -_skip_if_no_db_watch (void) -{ - return _skip_if_rs_version_less_than ("3.8.0"); -} - -static int -_skip_if_no_start_at_optime (void) -{ - return _skip_if_rs_version_less_than ("3.8.0"); -} - -typedef struct { - mongoc_change_stream_t *change_stream; -} change_stream_spec_ctx_t; - -static bool -change_stream_spec_operation_cb (json_test_ctx_t *ctx, - const bson_t *test, - const bson_t *operation) -{ - bson_t reply; - bool res; - - mongoc_collection_t *coll = - mongoc_client_get_collection (ctx->client, - bson_lookup_utf8 (operation, "database"), - bson_lookup_utf8 (operation, "collection")); - res = json_test_operation (ctx, test, operation, coll, NULL, &reply); - mongoc_collection_destroy (coll); - bson_destroy (&reply); - - return res; -} - -static void -change_stream_spec_before_test_cb (json_test_ctx_t *test_ctx, - const bson_t *test) -{ - change_stream_spec_ctx_t *ctx = - (change_stream_spec_ctx_t *) test_ctx->config->ctx; - bson_t opts; - bson_t pipeline; - bson_t tmp; - const char *target = bson_lookup_utf8 (test, "target"); - - set_apm_callbacks (test_ctx, test_ctx->client); - - bson_lookup_doc (test, "changeStreamOptions", &tmp); - bson_copy_to (&tmp, &opts); - if (!bson_has_field (&tmp, "maxAwaitTimeMS")) { - BSON_APPEND_INT64 (&opts, "maxAwaitTimeMS", 1000); - } - bson_lookup_doc (test, "changeStreamPipeline", &pipeline); - if (!strcmp (target, "collection")) { - ctx->change_stream = - mongoc_collection_watch (test_ctx->collection, &pipeline, &opts); - } else if (!strcmp (target, "database")) { - ctx->change_stream = - mongoc_database_watch (test_ctx->db, &pipeline, &opts); - } else if (!strcmp (target, "client")) { - ctx->change_stream = - mongoc_client_watch (test_ctx->client, &pipeline, &opts); - } else { - ASSERT_WITH_MSG (false, - "target unknown: \"%s\" in test: %s", - target, - bson_as_json (test, NULL)); - } - bson_destroy (&opts); -} - -/* The iteration of change streams for most drivers blocks until either - * an event is available or an error has occurred. libmongoc differs. - * It does not block indefinitely if there are no events. It is more like a - * "try_next" iteration. This behaves the way other drivers iterate. - * - * Returns true on success (i.e. no error), false on error. - */ -static bool -_iterate_until_error_or_event (mongoc_change_stream_t *stream, - const bson_t **event, - bson_error_t *error, - const bson_t **error_reply) -{ - uint32_t max_retry = 100; - bool has_error; - bool has_document; - - do { - has_document = mongoc_change_stream_next (stream, event); - has_error = - mongoc_change_stream_error_document (stream, error, error_reply); - /* in case the test was set-up incorrectly, and there really are no events - * coming, exit early. */ - max_retry--; - } while (!has_error && !has_document && max_retry > 0); - return !has_error; -} - -static void -change_stream_spec_after_test_cb (json_test_ctx_t *test_ctx, const bson_t *test) -{ - change_stream_spec_ctx_t *ctx = - (change_stream_spec_ctx_t *) test_ctx->config->ctx; - bson_error_t error; - const bson_t *reply; - const bson_t *doc; - bool ret; - - if (bson_has_field (test, "result.error")) { - int32_t expected_err_code; - - /* iterate change stream once. */ - ret = _iterate_until_error_or_event ( - ctx->change_stream, &doc, &error, &reply); - if (ret) { - test_error ( - "Expected error, but change stream did not return an error"); - } - - expected_err_code = bson_lookup_int32 (test, "result.error.code"); - ASSERT_CMPINT64 (expected_err_code, ==, (int32_t) error.code); - - /* Check expected error labels. */ - if (bson_has_field (test, "result.error.errorLabels")) { - bson_iter_t iter; - - if (!reply) { - test_error ("test expects error labels but no reply set"); - } - bson_iter_init (&iter, test); - bson_iter_find_descendant (&iter, "result.error.errorLabels", &iter); - while (bson_iter_next (&iter)) { - const char *label; - - BSON_ASSERT (BSON_ITER_HOLDS_UTF8 (&iter)); - label = bson_iter_utf8 (&iter, NULL); - BSON_ASSERT (mongoc_error_has_label (reply, label)); - } - } - - } else if (bson_has_field (test, "result.success")) { - bson_t expected_docs; - bson_iter_t expected_iter; - bson_t all_changes = BSON_INITIALIZER; - int i; - int num_iterations = 0; - - bson_lookup_doc (test, "result.success", &expected_docs); - BSON_ASSERT (bson_iter_init (&expected_iter, &expected_docs)); - - /* If there was no error and result.success is non-empty, iterate - * changeStream until it returns as many changes as there are elements in - * the result.success array. */ - BSON_ASSERT (bson_iter_init (&expected_iter, &expected_docs)); - while (bson_iter_next (&expected_iter)) { - num_iterations++; - } - - /* iterate over the change stream, and verify that the document exists. - */ - for (i = 0; i < num_iterations; i++) { - char *key = bson_strdup_printf ("%d", i); - ret = _iterate_until_error_or_event ( - ctx->change_stream, &doc, &error, &reply); - if (!ret) { - test_error ("unexpected error at iteration %d/%d: %s\n", - i + 1, - num_iterations, - error.message); - } - bson_append_document (&all_changes, key, -1, doc); - bson_free (key); - } - - /* check that everything in the "result.success" array is contained in - * our captured changes. */ - while (bson_iter_next (&expected_iter)) { - bson_t expected_doc; - match_ctx_t match_ctx = {{0}}; - - match_ctx.allow_placeholders = true; - match_ctx.retain_dots_in_keys = true; - match_ctx.strict_numeric_types = false; - bson_iter_bson (&expected_iter, &expected_doc); - match_in_array (&expected_doc, &all_changes, &match_ctx); - } - bson_destroy (&all_changes); - - if (mongoc_change_stream_error_document ( - ctx->change_stream, &error, NULL)) { - test_error ("Expected success, but error occurred: %s", error.message); - } - } else { - test_error ("Test format unrecognized, expected 'result.success' or " - "'result.error'"); - } - - mongoc_change_stream_destroy (ctx->change_stream); -} - -static void -test_change_stream_spec_cb (bson_t *scenario) -{ - json_test_config_t config = JSON_TEST_CONFIG_INIT; - change_stream_spec_ctx_t ctx = {0}; - config.ctx = &ctx; - config.command_started_events_only = true; - config.command_monitoring_allow_subset = true; - config.before_test_cb = change_stream_spec_before_test_cb; - config.after_test_cb = change_stream_spec_after_test_cb; - config.run_operation_cb = change_stream_spec_operation_cb; - config.scenario = scenario; - run_json_general_test (&config); -} - - -static void -_test_resume (const char *opts, - const char *expected_change_stream_opts, - const char *first_doc, - const char *expected_resume_change_stream_opts, - const char *cursor_pbr) -{ - mock_server_t *server; - request_t *request; - future_t *future; - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - bson_error_t err; - char *msg; - const bson_t *doc = NULL; - - server = mock_server_with_auto_hello (WIRE_VERSION_4_0); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - coll = mongoc_client_get_collection (client, "db", "coll"); - future = future_collection_watch (coll, tmp_bson ("{}"), tmp_bson (opts)); - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'aggregate': 'coll', 'pipeline' : [ { '$changeStream': { %s " - " 'fullDocument': null } } ], 'cursor': { } }", - expected_change_stream_opts)); - msg = bson_strdup_printf ("{'cursor': {'id': 123, 'ns': 'db.coll'," - "'firstBatch': [%s]%s }, 'operationTime': " - "{ '$timestamp': {'t': 1, 'i': 2} }, 'ok': 1 }", - first_doc, - cursor_pbr); - reply_to_request_simple (request, msg); - bson_free (msg); - stream = future_get_mongoc_change_stream_ptr (future); - BSON_ASSERT (stream); - future_destroy (future); - request_destroy (request); - /* if a first document was returned, the first call to next returns it. */ - if (*first_doc) { - mongoc_change_stream_next (stream, &doc); - ASSERT_MATCH (doc, first_doc); - } - future = future_change_stream_next (stream, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'getMore': {'$numberLong': '123'}, 'collection': 'coll' }")); - reply_to_request_with_hang_up (request); - request_destroy (request); - /* since the server closed the connection, a resume is attempted. */ - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'aggregate': 'coll', 'pipeline' : [ { '$changeStream': { %s " - " 'fullDocument': null }} ], 'cursor': { } }", - expected_resume_change_stream_opts)); - reply_to_request_simple ( - request, - "{'cursor': {'id': 0,'ns': 'db.coll','firstBatch': []},'ok': 1 }"); - request_destroy (request); - - BSON_ASSERT (!future_get_bool (future)); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &err, NULL), - err); - BSON_ASSERT (doc == NULL); - future_destroy (future); - - mongoc_change_stream_destroy (stream); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -/* test resume behavior before and after the first document is received. */ -static void -test_resume_cases (void) -{ -#define NO_OPT_RA "'resumeAfter': {'$exists': false}" -#define NO_OPT_SA "'startAfter': {'$exists': false}" -#define NO_OPT_OP "'startAtOperationTime': {'$exists': false}" -#define AGG_OP "'startAtOperationTime': {'$timestamp': {'t': 1, 'i': 2}}" -#define DOC "{'_id': {'resume': 'doc'}}" -#define OPT_OP "'startAtOperationTime': {'$timestamp': {'t': 111, 'i': 222}}" -#define DOC_RA "'resumeAfter': {'resume': 'doc'}" -#define OPT_RA "'resumeAfter': {'resume': 'opt'}" -#define OPT_SA "'startAfter': {'resume': 'opt'}" - - /* test features: - * - whether the change stream returns a document before resuming. - * - whether 'startAtOperationTime' is specified - * - whether 'resumeAfter' is specified - * - whether 'startAfterAfter' is specified */ - - /* no options specified. */ - /* - if no doc recv'ed, use the operationTime returned by aggregate. */ - _test_resume ("{}", - NO_OPT_OP "," NO_OPT_RA "," NO_OPT_SA ",", - "", - AGG_OP "," NO_OPT_RA "," NO_OPT_SA ",", - ""); - /* - if doc recv'ed and iterated, use the doc's resume token. */ - _test_resume ("{}", - NO_OPT_OP "," NO_OPT_RA "," NO_OPT_SA ",", - DOC, - DOC_RA "," NO_OPT_OP "," NO_OPT_SA ",", - ""); - - /* only 'startAtOperationTime' specified. */ - /* - if no doc recv'ed, use the startAtOperationTime option. */ - _test_resume ("{" OPT_OP "}", - OPT_OP "," NO_OPT_RA "," NO_OPT_SA ",", - "", - OPT_OP "," NO_OPT_RA "," NO_OPT_SA ",", - ""); - /* - if doc recv'ed and iterated, use the doc's resume token. */ - _test_resume ("{" OPT_OP "}", - OPT_OP "," NO_OPT_RA "," NO_OPT_SA ",", - DOC, - DOC_RA "," NO_OPT_OP "," NO_OPT_SA ",", - ""); - - /* only 'resumeAfter' specified. */ - /* - if no doc recv'ed, use the resumeAfter option. */ - _test_resume ("{" OPT_RA "}", - OPT_RA "," NO_OPT_OP "," NO_OPT_SA ",", - "", - OPT_RA "," NO_OPT_OP "," NO_OPT_SA ",", - ""); - /* - if doc recv'ed and iterated, use the doc's resume token. */ - _test_resume ("{" OPT_RA "}", - OPT_RA "," NO_OPT_OP "," NO_OPT_SA ",", - DOC, - DOC_RA "," NO_OPT_OP "," NO_OPT_SA ",", - ""); - - /* only 'startAfter' specified. */ - /* - if no doc recv'ed, use the startAfter option for the original aggregate - * whether or not we are resuming. */ - _test_resume ("{" OPT_SA "}", - OPT_SA "," NO_OPT_OP "," NO_OPT_RA ",", - "", - OPT_SA "," NO_OPT_OP "," NO_OPT_RA ",", - ""); - /* - if doc recv'ed and iterated, use the doc's resume token. */ - _test_resume ("{" OPT_SA "}", - OPT_SA "," NO_OPT_OP "," NO_OPT_RA ",", - DOC, - DOC_RA "," NO_OPT_OP "," NO_OPT_SA ",", - ""); - - /* 'resumeAfter', 'startAfter', and 'startAtOperationTime' are all specified. - * All should be passed (although the server currently returns an error). */ - /* - if no doc recv'ed, use startAfter. */ - _test_resume ("{" OPT_RA "," OPT_SA "," OPT_OP "}", - OPT_RA "," OPT_SA "," OPT_OP ",", - "", - OPT_SA "," NO_OPT_OP "," NO_OPT_RA ",", - ""); - /* - if one doc recv'ed and iterated, use resumeAfter with doc's resume - * token. */ - _test_resume ("{" OPT_RA "," OPT_SA "," OPT_OP "}", - OPT_RA "," OPT_SA "," OPT_OP ",", - DOC, - DOC_RA "," NO_OPT_OP "," NO_OPT_SA ",", - ""); -} - - -/* test resume behavior before and after the first document is received when a - postBatchResumeToken is available. */ -static void -test_resume_cases_with_post_batch_resume_token (void) -{ -#define CURSOR_PBR "'postBatchResumeToken': {'resume': 'pbr'}" -#define PBR_RA "'resumeAfter': {'resume': 'pbr'}" -#define PBR_SA "'startAfter': {'resume': 'pbr'}" - - /* test features: - * - whether the change stream returns a document before resuming. - * - whether 'postBatchResumeToken' is available - * - whether 'startAtOperationTime' is specified - * - whether 'resumeAfter' is specified - * - whether 'startAfterAfter' is specified */ - - /* postBatchResumeToken always takes priority over specified options or - * operation time. It will also take priority over the resume token of the - * last document in the batch (if _test_resume() iterates to that point). */ - - /* no options specified. */ - /* - if no doc recv'ed, use resumeAfter with postBatchResumeToken. */ - _test_resume ("{}", - NO_OPT_OP "," NO_OPT_RA "," NO_OPT_SA ",", - "", - PBR_RA "," NO_OPT_OP "," NO_OPT_SA ",", - "," CURSOR_PBR); - /* - if one doc recv'ed and iterated, use resumeAfter with - * postBatchResumeToken. */ - _test_resume ("{}", - NO_OPT_OP "," NO_OPT_RA "," NO_OPT_SA ",", - DOC, - PBR_RA "," NO_OPT_OP "," NO_OPT_SA ",", - "," CURSOR_PBR); - - /* only 'startAtOperationTime' specified. */ - /* - if no doc recv'ed, use resumeAfter with postBatchResumeToken. */ - _test_resume ("{" OPT_OP "}", - OPT_OP "," NO_OPT_RA "," NO_OPT_SA ",", - "", - PBR_RA "," NO_OPT_OP "," NO_OPT_SA ",", - "," CURSOR_PBR); - /* - if one doc recv'ed and iterated, use resumeAfter with - * postBatchResumeToken. */ - _test_resume ("{" OPT_OP "}", - OPT_OP "," NO_OPT_RA "," NO_OPT_SA ",", - DOC, - PBR_RA "," NO_OPT_OP "," NO_OPT_SA ",", - "," CURSOR_PBR); - - /* only 'resumeAfter' specified. */ - /* - if no doc recv'ed, use resumeAfter with postBatchResumeToken. */ - _test_resume ("{" OPT_RA "}", - OPT_RA "," NO_OPT_OP "," NO_OPT_SA ",", - "", - PBR_RA "," NO_OPT_OP "," NO_OPT_SA ",", - "," CURSOR_PBR); - /* - if one doc recv'ed and iterated, use resumeAfter with - * postBatchResumeToken. */ - _test_resume ("{" OPT_RA "}", - OPT_RA "," NO_OPT_OP "," NO_OPT_SA ",", - DOC, - PBR_RA "," NO_OPT_OP "," NO_OPT_SA ",", - "," CURSOR_PBR); - - /* only 'startAfter' specified. */ - /* - if no doc recv'ed, use startAfter with postBatchResumeToken. */ - _test_resume ("{" OPT_SA "}", - OPT_SA "," NO_OPT_OP "," NO_OPT_RA ",", - "", - PBR_SA "," NO_OPT_OP "," NO_OPT_RA ",", - "," CURSOR_PBR); - /* - if one doc recv'ed and iterated, use resumeAfter with - * postBatchResumeToken. */ - _test_resume ("{" OPT_SA "}", - OPT_SA "," NO_OPT_OP "," NO_OPT_RA ",", - DOC, - PBR_RA "," NO_OPT_OP "," NO_OPT_SA ",", - "," CURSOR_PBR); - - /* 'resumeAfter', 'startAfter', and 'startAtOperationTime' are all specified. - * All should be passed (although the server currently returns an error). */ - /* - if no doc recv'ed, use startAfter with postBatchResumeToken. */ - _test_resume ("{" OPT_RA "," OPT_SA "," OPT_OP "}", - OPT_RA "," OPT_SA "," OPT_OP ",", - "", - PBR_SA "," NO_OPT_OP "," NO_OPT_RA ",", - "," CURSOR_PBR); - /* - if one doc recv'ed and iterated, use resumeAfter with - * postBatchResumeToken. */ - _test_resume ("{" OPT_RA "," OPT_SA "," OPT_OP "}", - OPT_RA "," OPT_SA "," OPT_OP ",", - DOC, - PBR_RA "," NO_OPT_OP "," NO_OPT_SA ",", - "," CURSOR_PBR); -} - - -void -test_error_null_doc (void *ctx) -{ - mongoc_client_t *client; - mongoc_change_stream_t *stream; - bson_error_t err; - const bson_t *error_doc = - tmp_bson ("{}"); /* assign to a non-zero address. */ - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - stream = mongoc_client_watch (client, tmp_bson ("{}"), NULL); - /* error_doc starts as non-NULL. */ - BSON_ASSERT (error_doc); - BSON_ASSERT ( - !mongoc_change_stream_error_document (stream, &err, &error_doc)); - /* error_doc is set to NULL no error occurred. */ - BSON_ASSERT (!error_doc); - mongoc_change_stream_destroy (stream); - mongoc_client_destroy (client); -} - - -void -_check_doc_resume_token (const bson_t *doc, const bson_t *resume_token) -{ - bson_t document_resume_token; - - bson_lookup_doc (doc, "_id", &document_resume_token); - ASSERT (bson_equal (resume_token, &document_resume_token)); - - bson_destroy (&document_resume_token); -} - - -void -prose_test_11 (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - bson_error_t error; - const bson_t *next_doc = NULL; - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - bson_t opts = BSON_INITIALIZER; - const bson_t *resume_token; - _data_change_stream_t *post_batch_expected; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - ASSERT (client); - - coll = drop_and_get_coll (client, "db", "coll_resume"); - ASSERT (coll); - - /* Set the batch size to 1 so we only get one document per call to next. */ - stream = mongoc_collection_watch ( - coll, tmp_bson ("{}"), tmp_bson ("{'batchSize': 1}")); - ASSERT (stream); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), - error); - - /* The resume token should be updated to the post batch resume token */ - ASSERT (!mongoc_change_stream_next (stream, &next_doc)); - ASSERT (!next_doc); - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (!bson_empty0 (resume_token)); - - /* Look into the struct and get the actual post batch resume token, assert it - * is equal to our resume token */ - post_batch_expected = (_data_change_stream_t *) stream->cursor->impl.data; - ASSERT (bson_compare (resume_token, - &post_batch_expected->post_batch_resume_token) == 0); - - mongoc_write_concern_set_wmajority (wc, 30000); - mongoc_write_concern_append (wc, &opts); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 0}"), &opts, NULL, &error), - error); - - /* Checking that a resume token is returned */ - ASSERT (mongoc_change_stream_next (stream, &next_doc)); - ASSERT (next_doc); - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (!bson_empty0 (resume_token)); - ASSERT (bson_compare (resume_token, - &post_batch_expected->post_batch_resume_token) == 0); - - bson_destroy (&opts); - mongoc_write_concern_destroy (wc); - mongoc_change_stream_destroy (stream); - mongoc_client_destroy (client); - mongoc_collection_destroy (coll); -} - - -void -prose_test_12 (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - bson_error_t error; - const bson_t *next_doc = NULL; - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - bson_t opts = BSON_INITIALIZER; - const bson_t *resume_token; - bson_iter_t iter, child; - bson_t expected_token; - bson_t expected_doc; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - ASSERT (client); - - coll = drop_and_get_coll (client, "db", "coll_resume"); - ASSERT (coll); - - /* Set the batch size to 1 so we only get one document per call to next. */ - stream = mongoc_collection_watch ( - coll, tmp_bson ("{}"), tmp_bson ("{'batchSize': 1}")); - ASSERT (stream); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), - error); - - mongoc_write_concern_set_wmajority (wc, 30000); - mongoc_write_concern_append (wc, &opts); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 0}"), &opts, NULL, &error), - error); - - /* Checking that a resume token is returned */ - ASSERT (mongoc_change_stream_next (stream, &next_doc)); - ASSERT (next_doc); - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (!bson_empty0 (resume_token)); - - /* Need to now check that we are getting back the _id of the last inserted - * document when we iterate to the last document */ - bson_copy_to (next_doc, &expected_doc); - _check_doc_resume_token (&expected_doc, resume_token); - - ASSERT (bson_iter_init_find (&iter, next_doc, "documentKey")); - ASSERT (bson_iter_recurse (&iter, &child)); - ASSERT (bson_iter_find (&child, "_id") && bson_iter_int32 (&child) == 0); - - /* Must check that getResumeToken returns resumeAfter correctly when - * specified. */ - bson_copy_to (resume_token, &expected_token); - mongoc_change_stream_destroy (stream); - bson_destroy (&opts); - bson_init (&opts); - BSON_APPEND_DOCUMENT (&opts, "resumeAfter", &expected_token); - - stream = mongoc_collection_watch (coll, tmp_bson ("{}"), &opts); - ASSERT (stream); - - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (bson_equal (resume_token, &expected_token)); - - bson_destroy (&expected_doc); - bson_destroy (&expected_token); - bson_destroy (&opts); - mongoc_write_concern_destroy (wc); - mongoc_change_stream_destroy (stream); - mongoc_client_destroy (client); - mongoc_collection_destroy (coll); -} - - -void -prose_test_13 (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - bson_error_t error; - const bson_t *next_doc = NULL; - mongoc_apm_callbacks_t *callbacks; - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - bson_t opts = BSON_INITIALIZER; - const bson_t *resume_token; - bson_iter_t iter, child; - - client = test_framework_new_default_client (); - ASSERT (client); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, - test_resume_token_command_start); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - - coll = drop_and_get_coll (client, "db", "coll_resume"); - ASSERT (coll); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson (NULL), NULL, NULL, &error), - error); - - /* Set the batch size to 1 so we only get one document per call to next. */ - stream = mongoc_collection_watch ( - coll, tmp_bson ("{}"), tmp_bson ("{'batchSize': 1}")); - ASSERT (stream); - ASSERT_OR_PRINT (!mongoc_change_stream_error_document (stream, &error, NULL), - error); - - /* Insert a few docs to listen for. Use write concern majority, so subsequent - * call to watch will be guaranteed to retrieve them. */ - mongoc_write_concern_set_wmajority (wc, 30000); - mongoc_write_concern_append (wc, &opts); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 0}"), &opts, NULL, &error), - error); - - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 1}"), &opts, NULL, &error), - error); - - /* The resume token should be updated to the most recently iterated doc */ - ASSERT (mongoc_change_stream_next (stream, &next_doc)); - ASSERT (next_doc); - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (!bson_empty0 (resume_token)); - _check_doc_resume_token (next_doc, resume_token); - - ASSERT (mongoc_change_stream_next (stream, &next_doc)); - ASSERT (next_doc); - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (!bson_empty0 (resume_token)); - _check_doc_resume_token (next_doc, resume_token); - - ASSERT (bson_iter_init_find (&iter, next_doc, "documentKey")); - ASSERT (bson_iter_recurse (&iter, &child)); - ASSERT (bson_iter_find (&child, "_id") && bson_iter_int32 (&child) == 1); - - bson_destroy (&opts); - mongoc_write_concern_destroy (wc); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_change_stream_destroy (stream); - mongoc_client_destroy (client); - mongoc_collection_destroy (coll); -} - -static void -_save_operation_time_from_agg (const mongoc_apm_command_succeeded_t *event) -{ - if (0 == strcmp ("aggregate", - mongoc_apm_command_succeeded_get_command_name (event))) { - mongoc_timestamp_t *timestamp; - bson_iter_t iter; - const bson_t *cmd; - - cmd = mongoc_apm_command_succeeded_get_reply (event); - timestamp = mongoc_apm_command_succeeded_get_context (event); - /* Capture the operationTime from the first aggregate reply. */ - if (timestamp->timestamp == 0) { - BSON_ASSERT (bson_iter_init_find (&iter, cmd, "operationTime")); - _mongoc_timestamp_set_from_bson (timestamp, &iter); - } - } -} - -void -prose_test_14 (void *test_ctx) -{ - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - bson_t opts; - bson_error_t error; - const bson_t *resume_token; - bson_t expected_token; - const bson_t *doc = NULL; - mongoc_timestamp_t optime = {0}; - mongoc_apm_callbacks_t *callbacks; - - BSON_UNUSED (test_ctx); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_succeeded_cb (callbacks, - _save_operation_time_from_agg); - mongoc_client_set_apm_callbacks (client, callbacks, &optime); - mongoc_apm_callbacks_destroy (callbacks); - - coll = drop_and_get_coll (client, "db", "coll"); - bson_init (&opts); - stream = mongoc_collection_watch (coll, tmp_bson ("{}"), &opts); - /* The _save_operation_time_from_agg listener must have stored the operation - * time. */ - BSON_ASSERT (optime.timestamp != 0); - - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 0}"), &opts, NULL, &error), - error); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 1}"), &opts, NULL, &error), - error); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 2}"), &opts, NULL, &error), - error); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 3}"), &opts, NULL, &error), - error); - - ASSERT (mongoc_change_stream_next (stream, &doc)); - resume_token = mongoc_change_stream_get_resume_token (stream); - - bson_copy_to (resume_token, &expected_token); - BSON_APPEND_DOCUMENT (&opts, "startAfter", &expected_token); - - mongoc_change_stream_destroy (stream); - - /* Start a new change stream using "startAfter" set to a previously obtained - resume token to guarantee a non-empty initial batch */ - stream = mongoc_collection_watch (coll, tmp_bson ("{}"), &opts); - - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (bson_equal (resume_token, &expected_token)); - - /* Doing the same using "resumeAfter" instead */ - mongoc_change_stream_destroy (stream); - bson_destroy (&opts); - bson_init (&opts); - BSON_APPEND_DOCUMENT (&opts, "resumeAfter", &expected_token); - - stream = mongoc_collection_watch (coll, tmp_bson ("{}"), &opts); - - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (bson_equal (resume_token, &expected_token)); - mongoc_change_stream_destroy (stream); - - /* Finally, with neither. */ - bson_destroy (&opts); - bson_init (&opts); - BSON_APPEND_TIMESTAMP ( - &opts, "startAtOperationTime", optime.timestamp, optime.increment); - stream = mongoc_collection_watch (coll, tmp_bson ("{}"), &opts); - - resume_token = mongoc_change_stream_get_resume_token (stream); - ASSERT (resume_token == NULL); - - bson_destroy (&expected_token); - bson_destroy (&opts); - mongoc_change_stream_destroy (stream); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - - -void -prose_test_17 (void) -{ - mock_server_t *server; - request_t *request; - future_t *future; - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *next_doc = NULL; - - server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - coll = mongoc_client_get_collection (client, "db", "coll"); - /* Pass an arbitrary document as the resume token, like {'x': 1} */ - future = future_collection_watch ( - coll, tmp_bson ("{}"), tmp_bson ("{'startAfter': {'x': 1}}")); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'aggregate': 'coll', 'pipeline' : [ { '$changeStream': { " - "'startAfter': {'x': 1} , 'resumeAfter': { '$exists': false }, " - "'startAtOperationTime': { '$exists': false } } } ]}")); - - reply_to_request_simple ( - request, - "{'cursor': {'id': 123, 'ns': 'db.coll', 'firstBatch': []}, 'ok': 1 }"); - - request_destroy (request); - - stream = future_get_mongoc_change_stream_ptr (future); - ASSERT (stream); - future_destroy (future); - - future = future_change_stream_next (stream, &next_doc); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'getMore': {'$numberLong': '123'}, 'collection': 'coll' }")); - - reply_to_request_simple ( - request, - "{ 'code': 10107, 'errmsg': 'not primary', 'errorLabels': " - "['ResumableChangeStreamError'], 'ok': 0 }"); - - request_destroy (request); - - /* Resume occurs. */ - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ( - "{ 'killCursors': 'coll', 'cursors': [{ '$numberLong': '123'}]}")); - reply_to_request_with_ok_and_destroy (request); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'aggregate': 'coll', 'pipeline': [ { " - "'$changeStream': { 'startAfter': {'x': 1}, 'resumeAfter': { " - "'$exists': false }, 'startAtOperationTime': { '$exists': " - "false } } " - "}]}")); - - /* Reply with a 0 cursor ID to prevent a killCursors command. */ - reply_to_request_simple ( - request, - "{'cursor': {'id': 0, 'ns': 'db.coll', 'firstBatch': []}, 'ok': 1 }"); - request_destroy (request); - BSON_ASSERT (!future_get_bool (future)); - future_destroy (future); - mongoc_change_stream_destroy (stream); - - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -void -prose_test_18 (void) -{ - mock_server_t *server; - request_t *request; - future_t *future; - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_change_stream_t *stream; - const bson_t *next_doc = NULL; - - server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - coll = mongoc_client_get_collection (client, "db", "coll"); - /* Pass an arbitrary document as the resume token, like {'x': 1} */ - future = future_collection_watch ( - coll, tmp_bson ("{}"), tmp_bson ("{'startAfter': {'x': 1}}")); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'aggregate': 'coll', 'pipeline' : [ { '$changeStream': { " - "'startAfter': {'x': 1}, 'resumeAfter': { '$exists': false }, " - "'startAtOperationTime': { '$exists': false } } } ]}")); - - reply_to_request_simple (request, - "{'cursor': {'id': 123, 'ns': " - "'db.coll', 'firstBatch': [{'_id': " - "{'y': 1}}]}, 'ok': 1 }"); - - request_destroy (request); - stream = future_get_mongoc_change_stream_ptr (future); - ASSERT (stream); - future_destroy (future); - - /* The first call to mongoc_change_stream_next returns the batched document. - */ - mongoc_change_stream_next (stream, &next_doc); - - future = future_change_stream_next (stream, &next_doc); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'getMore': {'$numberLong': '123'}, 'collection': 'coll' }")); - - reply_to_request_simple ( - request, - "{ 'code': 10107, 'errmsg': 'not primary', 'errorLabels': " - "['ResumableChangeStreamError'], 'ok': 0 }"); - - request_destroy (request); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ( - "{ 'killCursors': 'coll', 'cursors': [{ '$numberLong': '123'}]}")); - reply_to_request_with_ok_and_destroy (request); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'aggregate': 'coll', 'pipeline': [ { " - "'$changeStream': { 'resumeAfter': {'y': 1}, 'startAfter': { " - "'$exists': false }, 'startAtOperationTime': { '$exists': " - "false } } " - "}]}")); - /* Reply with a 0 cursor ID to prevent a killCursors command. */ - reply_to_request_simple ( - request, - "{'cursor': {'id': 0, 'ns': 'db.coll', 'firstBatch': []}, 'ok': 1 }"); - request_destroy (request); - BSON_ASSERT (!future_get_bool (future)); - future_destroy (future); - mongoc_change_stream_destroy (stream); - - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -void -test_change_stream_install (TestSuite *suite) -{ - TestSuite_AddMockServerTest ( - suite, "/change_stream/pipeline", test_change_stream_pipeline); - - TestSuite_AddFull (suite, - "/change_stream/live/single_server", - test_change_stream_live_single_server, - NULL, - NULL, - test_framework_skip_if_not_single_version_5); - - TestSuite_AddFull (suite, - "/change_stream/live/track_resume_token", - test_change_stream_live_track_resume_token, - NULL, - NULL, - test_framework_skip_if_not_replset, - test_framework_skip_if_no_failpoint); - - TestSuite_AddFull (suite, - "/change_stream/live/batch_size", - test_change_stream_live_batch_size, - NULL, - NULL, - test_framework_skip_if_not_replset); - - TestSuite_AddFull (suite, - "/change_stream/live/missing_resume_token", - test_change_stream_live_missing_resume_token, - NULL, - NULL, - test_framework_skip_if_not_replset); - - TestSuite_AddFull (suite, - "/change_stream/live/invalid_resume_token", - test_change_stream_live_invalid_resume_token, - NULL, - NULL, - test_framework_skip_if_not_replset); - - TestSuite_AddMockServerTest (suite, - "/change_stream/resumable_error", - test_change_stream_resumable_error); - - TestSuite_AddMockServerTest ( - suite, "/change_stream/options", test_change_stream_options); - - TestSuite_AddFull (suite, - "/change_stream/live/watch", - test_change_stream_live_watch, - NULL, - NULL, - test_framework_skip_if_not_replset); - - TestSuite_AddFull (suite, - "/change_stream/live/read_prefs", - test_change_stream_live_read_prefs, - NULL, - NULL, - _skip_if_no_start_at_optime, - test_framework_skip_if_no_failpoint); - - TestSuite_Add (suite, - "/change_stream/server_selection_fails", - test_change_stream_server_selection_fails); - - TestSuite_AddFull (suite, - "/change_stream/next_after_error", - test_change_stream_next_after_error, - NULL, - NULL, - test_framework_skip_if_not_replset); - - TestSuite_AddFull (suite, - "/change_stream/accepts_array", - test_change_stream_accepts_array, - NULL, - NULL, - test_framework_skip_if_not_replset); - TestSuite_AddMockServerTest ( - suite, "/change_stream/getmore_errors", test_getmore_errors); - TestSuite_AddFull (suite, - "/change_stream/start_at_operation_time", - test_change_stream_start_at_operation_time, - NULL, - NULL, - test_framework_skip_if_not_rs_version_7, - test_framework_skip_if_no_crypto, - _skip_if_no_start_at_optime); - TestSuite_AddFull (suite, - "/change_stream/resume_at_optime", - test_change_stream_resume_at_optime, - NULL, - NULL, - test_framework_skip_if_not_rs_version_7, - test_framework_skip_if_no_crypto, - _skip_if_no_start_at_optime, - test_framework_skip_if_no_failpoint); - TestSuite_AddFull (suite, - "/change_stream/resume_with_post_batch_resume_token", - test_change_stream_resume_with_post_batch_resume_token, - NULL, - NULL, - test_framework_skip_if_not_rs_version_7, - test_framework_skip_if_no_crypto, - _skip_if_no_start_at_optime, - test_framework_skip_if_no_failpoint); - TestSuite_AddFull (suite, - "/change_stream/database", - test_change_stream_database_watch, - NULL, - NULL, - _skip_if_no_db_watch); - TestSuite_AddFull (suite, - "/change_stream/client", - test_change_stream_client_watch, - NULL, - NULL, - _skip_if_no_client_watch); - TestSuite_AddMockServerTest ( - suite, "/change_stream/resume_with_first_doc", test_resume_cases); - TestSuite_AddMockServerTest ( - suite, - "/change_stream/resume_with_first_doc/post_batch_resume_token", - test_resume_cases_with_post_batch_resume_token); - TestSuite_AddFull (suite, - "/change_stream/error_null_doc", - test_error_null_doc, - NULL, - NULL, - _skip_if_no_client_watch); - TestSuite_AddFull (suite, - "/change_stream/live/prose_test_11", - prose_test_11, - NULL, - NULL, - test_framework_skip_if_not_replset, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/change_stream/live/prose_test_12", - prose_test_12, - NULL, - NULL, - test_framework_skip_if_not_replset, - test_framework_skip_if_max_wire_version_more_than_7); - TestSuite_AddFull (suite, - "/change_stream/live/prose_test_13", - prose_test_13, - NULL, - NULL, - test_framework_skip_if_not_replset, - _skip_if_no_start_at_optime); - TestSuite_AddFull (suite, - "/change_stream/live/prose_test_14", - prose_test_14, - NULL, - NULL, - test_framework_skip_if_mongos, - test_framework_skip_if_not_rs_version_7); - TestSuite_AddMockServerTest ( - suite, "/change_streams/prose_test_17", prose_test_17); - TestSuite_AddMockServerTest ( - suite, "/change_streams/prose_test_18", prose_test_18); - - install_json_test_suite ( - suite, JSON_DIR, "/change_streams/legacy", &test_change_stream_spec_cb); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client-pool.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client-pool.c deleted file mode 100644 index 56995ab5d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client-pool.c +++ /dev/null @@ -1,511 +0,0 @@ -#include -#include "mongoc/mongoc-client-pool-private.h" -#include "mongoc/mongoc-util-private.h" - - -#include "TestSuite.h" -#include "test-libmongoc.h" - - -static void -test_mongoc_client_pool_basic (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_uri_t *uri; - - uri = mongoc_uri_new ("mongodb://127.0.0.1/?maxpoolsize=1"); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - BSON_ASSERT (client); - mongoc_client_pool_push (pool, client); - mongoc_uri_destroy (uri); - mongoc_client_pool_destroy (pool); -} - - -static void -test_mongoc_client_pool_try_pop (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_uri_t *uri; - - uri = mongoc_uri_new ("mongodb://127.0.0.1/?maxpoolsize=1"); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - BSON_ASSERT (client); - BSON_ASSERT (!mongoc_client_pool_try_pop (pool)); - mongoc_client_pool_push (pool, client); - mongoc_uri_destroy (uri); - mongoc_client_pool_destroy (pool); -} - -static void -test_mongoc_client_pool_pop_timeout (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_uri_t *uri; - int64_t start; - int64_t duration_usec; - - uri = mongoc_uri_new ( - "mongodb://127.0.0.1/?maxpoolsize=1&waitqueuetimeoutms=2000"); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - BSON_ASSERT (client); - start = bson_get_monotonic_time (); - BSON_ASSERT (!mongoc_client_pool_pop (pool)); - duration_usec = bson_get_monotonic_time () - start; - /* There is a possibility that the wait is a few milliseconds short. The - * assertion is structured like this since the timeout is a rough lower bound - * and some test environments might slow things down. */ - BSON_ASSERT (duration_usec / 1000 >= 1990); - mongoc_client_pool_push (pool, client); - mongoc_uri_destroy (uri); - mongoc_client_pool_destroy (pool); -} - -static void -test_mongoc_client_pool_min_size_zero (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client1; - mongoc_client_t *client2; - mongoc_client_t *client3; - mongoc_client_t *client4; - mongoc_uri_t *uri; - - uri = mongoc_uri_new (NULL); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - - client1 = mongoc_client_pool_pop (pool); - client2 = mongoc_client_pool_pop (pool); - mongoc_client_pool_push (pool, client2); - mongoc_client_pool_push (pool, client1); - - BSON_ASSERT (mongoc_client_pool_get_size (pool) == 2); - client3 = mongoc_client_pool_pop (pool); - - /* min pool size zero means "no min", so clients weren't destroyed */ - BSON_ASSERT (client3 == client1); - client4 = mongoc_client_pool_pop (pool); - BSON_ASSERT (client4 == client2); - - mongoc_client_pool_push (pool, client4); - mongoc_client_pool_push (pool, client3); - mongoc_client_pool_destroy (pool); - mongoc_uri_destroy (uri); -} - -static void -test_mongoc_client_pool_min_size_dispose (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_uri_t *uri; - mongoc_client_t *c0, *c1, *c2, *c3; - - capture_logs (true); - uri = mongoc_uri_new ("mongodb://127.0.0.1/?minpoolsize=2"); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - - c0 = mongoc_client_pool_pop (pool); - BSON_ASSERT (c0); - ASSERT_CMPSIZE_T (mongoc_client_pool_get_size (pool), ==, (size_t) 1); - - c1 = mongoc_client_pool_pop (pool); - BSON_ASSERT (c1); - ASSERT_CMPSIZE_T (mongoc_client_pool_get_size (pool), ==, (size_t) 2); - - c2 = mongoc_client_pool_pop (pool); - BSON_ASSERT (c2); - ASSERT_CMPSIZE_T (mongoc_client_pool_get_size (pool), ==, (size_t) 3); - - c3 = mongoc_client_pool_pop (pool); - BSON_ASSERT (c3); - ASSERT_CMPSIZE_T (mongoc_client_pool_get_size (pool), ==, (size_t) 4); - - mongoc_client_pool_push (pool, c0); /* queue is [c0] */ - ASSERT_CMPSIZE_T (mongoc_client_pool_num_pushed (pool), ==, (size_t) 1); - ASSERT_CMPSIZE_T (mongoc_client_pool_get_size (pool), ==, (size_t) 4); - - mongoc_client_pool_push (pool, c1); /* queue is [c1, c0] */ - ASSERT_CMPSIZE_T (mongoc_client_pool_num_pushed (pool), ==, (size_t) 2); - ASSERT_CMPSIZE_T (mongoc_client_pool_get_size (pool), ==, (size_t) 4); - - mongoc_client_pool_push (pool, c2); /* queue is [c2, c1] */ - ASSERT_CMPSIZE_T (mongoc_client_pool_num_pushed (pool), ==, (size_t) 2); - ASSERT_CMPSIZE_T (mongoc_client_pool_get_size (pool), ==, (size_t) 3); - - mongoc_client_pool_push (pool, c3); /* queue is [c3, c2] */ - ASSERT_CMPSIZE_T (mongoc_client_pool_num_pushed (pool), ==, (size_t) 2); - ASSERT_CMPSIZE_T (mongoc_client_pool_get_size (pool), ==, (size_t) 2); - - /* BSON_ASSERT oldest client was destroyed, newest were stored */ - client = mongoc_client_pool_pop (pool); - BSON_ASSERT (client); - BSON_ASSERT (client == c3); - - client = mongoc_client_pool_pop (pool); - BSON_ASSERT (client); - BSON_ASSERT (client == c2); - - ASSERT_CMPSIZE_T (mongoc_client_pool_get_size (pool), ==, (size_t) 2); - - /* clean up */ - mongoc_client_pool_push (pool, c2); - mongoc_client_pool_push (pool, c3); - mongoc_client_pool_destroy (pool); - mongoc_uri_destroy (uri); -} - -static void -test_mongoc_client_pool_set_max_size (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_uri_t *uri; - mongoc_array_t conns; - int i; - - _mongoc_array_init (&conns, sizeof client); - - uri = mongoc_uri_new ("mongodb://127.0.0.1/?maxpoolsize=10"); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - - for (i = 0; i < 5; i++) { - client = mongoc_client_pool_pop (pool); - BSON_ASSERT (client); - _mongoc_array_append_val (&conns, client); - BSON_ASSERT (mongoc_client_pool_get_size (pool) == i + 1); - } - - mongoc_client_pool_max_size (pool, 3); - - BSON_ASSERT (mongoc_client_pool_try_pop (pool) == NULL); - - for (i = 0; i < 5; i++) { - client = _mongoc_array_index (&conns, mongoc_client_t *, i); - BSON_ASSERT (client); - mongoc_client_pool_push (pool, client); - } - - _mongoc_array_clear (&conns); - _mongoc_array_destroy (&conns); - mongoc_uri_destroy (uri); - mongoc_client_pool_destroy (pool); -} - -static void -test_mongoc_client_pool_set_min_size (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_uri_t *uri; - mongoc_array_t conns; - int i; - - _mongoc_array_init (&conns, sizeof client); - - uri = mongoc_uri_new ("mongodb://127.0.0.1/?maxpoolsize=10&minpoolsize=3"); - capture_logs (true); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - ASSERT_CAPTURED_LOG ( - "minpoolsize URI option", MONGOC_LOG_LEVEL_WARNING, "is deprecated"); - - for (i = 0; i < 10; i++) { - client = mongoc_client_pool_pop (pool); - BSON_ASSERT (client); - _mongoc_array_append_val (&conns, client); - BSON_ASSERT (mongoc_client_pool_get_size (pool) == i + 1); - } - - capture_logs (true); - BEGIN_IGNORE_DEPRECATIONS - mongoc_client_pool_min_size (pool, 7); - END_IGNORE_DEPRECATIONS - ASSERT_CAPTURED_LOG ("mongoc_client_pool_min_size", - MONGOC_LOG_LEVEL_WARNING, - "mongoc_client_pool_min_size is deprecated"); - - for (i = 0; i < 10; i++) { - client = _mongoc_array_index (&conns, mongoc_client_t *, i); - BSON_ASSERT (client); - mongoc_client_pool_push (pool, client); - } - - BSON_ASSERT (mongoc_client_pool_get_size (pool) == 7); - - _mongoc_array_clear (&conns); - _mongoc_array_destroy (&conns); - mongoc_uri_destroy (uri); - mongoc_client_pool_destroy (pool); -} - -#ifndef MONGOC_ENABLE_SSL -static void -test_mongoc_client_pool_ssl_disabled (void) -{ - mongoc_uri_t *uri = mongoc_uri_new ("mongodb://host/?ssl=true"); - - ASSERT (uri); - capture_logs (true); - ASSERT (NULL == test_framework_client_pool_new_from_uri (uri, NULL)); - ASSERT_CAPTURED_LOG ("mongoc_client_pool_new", - MONGOC_LOG_LEVEL_ERROR, - "SSL not enabled in this build."); - - mongoc_uri_destroy (uri); -} -#endif - -static void -test_mongoc_client_pool_handshake (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_uri_t *uri; - - uri = mongoc_uri_new ("mongodb://127.0.0.1/?maxpoolsize=1"); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - - - ASSERT (mongoc_client_pool_set_appname (pool, "some application")); - /* Be sure we can't set it twice */ - capture_logs (true); - ASSERT (!mongoc_client_pool_set_appname (pool, "a")); - ASSERT_CAPTURED_LOG ("_mongoc_topology_scanner_set_appname", - MONGOC_LOG_LEVEL_ERROR, - "Cannot set appname more than once"); - capture_logs (false); - - mongoc_client_pool_destroy (pool); - - /* Make sure that after we pop a client we can't set handshake anymore */ - pool = test_framework_client_pool_new_from_uri (uri, NULL); - - client = mongoc_client_pool_pop (pool); - - /* Be sure a client can't set it now that we've popped them */ - capture_logs (true); - ASSERT (!mongoc_client_set_appname (client, "a")); - ASSERT_CAPTURED_LOG ("_mongoc_topology_scanner_set_appname", - MONGOC_LOG_LEVEL_ERROR, - "Cannot call set_appname on a client from a pool"); - capture_logs (false); - - mongoc_client_pool_push (pool, client); - - /* even now that we pushed the client back we shouldn't be able to set - * the handshake */ - capture_logs (true); - ASSERT (!mongoc_client_pool_set_appname (pool, "a")); - ASSERT_CAPTURED_LOG ("_mongoc_topology_scanner_set_appname", - MONGOC_LOG_LEVEL_ERROR, - "Cannot set appname after handshake initiated"); - capture_logs (false); - - mongoc_uri_destroy (uri); - mongoc_client_pool_destroy (pool); -} - -/* Test that destroying a pool without pushing all clients is ok. */ -static void -test_client_pool_destroy_without_pushing (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client_in_pool; - mongoc_client_t *client1; - mongoc_client_t *client2; - bson_error_t error; - bson_t *cmd; - bool ret; - - cmd = BCON_NEW ("ping", BCON_INT32 (1)); - pool = test_framework_new_default_client_pool (); - client1 = mongoc_client_pool_pop (pool); - client2 = mongoc_client_pool_pop (pool); - - /* Push a client back onto the pool so endSessions succeeds to avoid a - * warning. */ - client_in_pool = mongoc_client_pool_pop (pool); - ret = mongoc_client_command_simple (client_in_pool, - "admin", - cmd, - NULL /* read prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - mongoc_client_pool_push (pool, client_in_pool); - - - ret = mongoc_client_command_simple ( - client1, "admin", cmd, NULL /* read prefs */, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - ret = mongoc_client_command_simple ( - client2, "admin", cmd, NULL /* read prefs */, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - - /* Since clients are checked out of pool, it is technically ok to - * mongoc_client_destroy them instead of pushing. */ - mongoc_client_destroy (client1); - - /* An operation on client2 should still be ok. */ - ret = mongoc_client_command_simple ( - client2, "admin", cmd, NULL /* read prefs */, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - mongoc_client_destroy (client2); - - /* Destroy the pool, which destroys the shared topology object. */ - mongoc_client_pool_destroy (pool); - - bson_destroy (cmd); -} - -static void -command_started_cb (const mongoc_apm_command_started_t *event) -{ - if (strcmp (mongoc_apm_command_started_get_command_name (event), - "endSessions") != 0) { - return; - } - - int *const count = (int *) mongoc_apm_command_started_get_context (event); - (*count)++; -} - -/* tests that creating and destroying an unused session - * in pooled mode does not result in an error log */ -static void -test_client_pool_create_unused_session (void *context) -{ - mongoc_client_t *client; - mongoc_client_pool_t *pool; - mongoc_client_session_t *session; - mongoc_apm_callbacks_t *callbacks; - bson_error_t error; - int count = 0; - - BSON_UNUSED (context); - - capture_logs (true); - - callbacks = mongoc_apm_callbacks_new (); - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - session = mongoc_client_start_session (client, NULL, &error); - - mongoc_apm_set_command_started_cb (callbacks, command_started_cb); - mongoc_client_pool_set_apm_callbacks (pool, callbacks, &count); - - mongoc_client_session_destroy (session); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - mongoc_apm_callbacks_destroy (callbacks); - ASSERT_CMPINT (count, ==, 0); - ASSERT_NO_CAPTURED_LOGS ("mongoc_client_pool_destroy"); -} - - -/* Tests case where thread is blocked waiting for a client to be pushed back - * into the client pool. Specifically this tests that the program terminates. - * Addresses CDRIVER-3757 */ -typedef struct pool_timeout { - mongoc_client_pool_t *pool; - bson_mutex_t mutex; - mongoc_cond_t cond; - int nleft; -} pool_timeout_args_t; - -static BSON_THREAD_FUN (worker, arg) -{ - pool_timeout_args_t *args = arg; - mongoc_client_t *client = mongoc_client_pool_pop (args->pool); - BSON_ASSERT (client); - _mongoc_usleep (10); - mongoc_client_pool_push (args->pool, client); - bson_mutex_lock (&args->mutex); - /* notify main thread that current thread has terminated */ - args->nleft--; - mongoc_cond_signal (&args->cond); - bson_mutex_unlock (&args->mutex); - BSON_THREAD_RETURN; -} - -static void -test_client_pool_max_pool_size_exceeded (void) -{ - mongoc_client_pool_t *pool; - mongoc_uri_t *uri; - bson_thread_t thread1, thread2; - pool_timeout_args_t *args = bson_malloc0 (sizeof (pool_timeout_args_t)); - int wait_time = 4000; /* 4000 msec = 4 sec */ - int ret; - - uri = mongoc_uri_new ("mongodb://127.0.0.1/?maxpoolsize=1"); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - args->pool = pool; - args->nleft = 2; - bson_mutex_init (&args->mutex); - mongoc_cond_init (&args->cond); - - ASSERT_CMPINT (0, ==, mcommon_thread_create (&thread1, worker, args)); - ASSERT_CMPINT (0, ==, mcommon_thread_create (&thread2, worker, args)); - - bson_mutex_lock (&args->mutex); - while (args->nleft > 0) { - ret = mongoc_cond_timedwait (&args->cond, &args->mutex, wait_time); - /* ret non-zero indicates an error (a timeout) */ - BSON_ASSERT (!ret); - } - bson_mutex_unlock (&args->mutex); - - mcommon_thread_join (thread1); - mcommon_thread_join (thread2); - - mongoc_uri_destroy (uri); - mongoc_client_pool_destroy (pool); - bson_free (args); -} - -void -test_client_pool_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/ClientPool/basic", test_mongoc_client_pool_basic); - TestSuite_Add ( - suite, "/ClientPool/try_pop", test_mongoc_client_pool_try_pop); - TestSuite_Add ( - suite, "/ClientPool/pop_timeout", test_mongoc_client_pool_pop_timeout); - TestSuite_Add (suite, - "/ClientPool/min_size_zero", - test_mongoc_client_pool_min_size_zero); - TestSuite_Add (suite, - "/ClientPool/min_size_dispose", - test_mongoc_client_pool_min_size_dispose); - TestSuite_Add ( - suite, "/ClientPool/set_max_size", test_mongoc_client_pool_set_max_size); - TestSuite_Add ( - suite, "/ClientPool/set_min_size", test_mongoc_client_pool_set_min_size); - - TestSuite_Add ( - suite, "/ClientPool/handshake", test_mongoc_client_pool_handshake); - - TestSuite_AddFull (suite, - "/ClientPool/create_client_pool_unused_session", - test_client_pool_create_unused_session, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_sessions); -#ifndef MONGOC_ENABLE_SSL - TestSuite_Add ( - suite, "/ClientPool/ssl_disabled", test_mongoc_client_pool_ssl_disabled); -#endif - TestSuite_AddLive (suite, - "/ClientPool/destroy_without_push", - test_client_pool_destroy_without_pushing); - TestSuite_AddLive (suite, - "/ClientPool/max_pool_size_exceeded", - test_client_pool_max_pool_size_exceeded); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client-session.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client-session.c deleted file mode 100644 index 68ab962a7..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client-session.c +++ /dev/null @@ -1,3200 +0,0 @@ -#include -#include "mongoc/mongoc.h" -#include "mongoc/mongoc-util-private.h" -#include "mongoc/mongoc-change-stream-private.h" -#include "mongoc/mongoc-collection-private.h" -#include "mongoc/utlist.h" -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "mock_server/mock-server.h" -#include "mock_server/future-functions.h" -#include "json-test.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "session-test" - -static void -test_session_opts_clone (void) -{ - mongoc_session_opt_t *opts; - mongoc_session_opt_t *clone; - - opts = mongoc_session_opts_new (); - clone = mongoc_session_opts_clone (opts); - /* causalConsistency is enabled by default if snapshot is not enabled */ - BSON_ASSERT (mongoc_session_opts_get_causal_consistency (clone)); - mongoc_session_opts_destroy (clone); - - mongoc_session_opts_set_causal_consistency (opts, false); - clone = mongoc_session_opts_clone (opts); - BSON_ASSERT (!mongoc_session_opts_get_causal_consistency (clone)); - - mongoc_session_opts_destroy (clone); - mongoc_session_opts_destroy (opts); -} - - -static void -test_session_opts_causal_consistency_and_snapshot (void) -{ - mongoc_session_opt_t *opts; - - opts = mongoc_session_opts_new (); - /* causalConsistency is enabled by default if snapshot is not enabled */ - BSON_ASSERT (mongoc_session_opts_get_causal_consistency (opts)); - BSON_ASSERT (!mongoc_session_opts_get_snapshot (opts)); - - /* causalConsistency is disabled by default if snapshot is enabled */ - mongoc_session_opts_set_snapshot (opts, true); - BSON_ASSERT (!mongoc_session_opts_get_causal_consistency (opts)); - BSON_ASSERT (mongoc_session_opts_get_snapshot (opts)); - - /* causalConsistency and snapshot can both be enabled, although this will - * result in an error when starting the session. */ - mongoc_session_opts_set_causal_consistency (opts, true); - BSON_ASSERT (mongoc_session_opts_get_causal_consistency (opts)); - BSON_ASSERT (mongoc_session_opts_get_snapshot (opts)); - - mongoc_session_opts_destroy (opts); -} - - -static void -test_session_no_crypto (void *ctx) -{ - mongoc_client_t *client; - bson_error_t error; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - BSON_ASSERT (!mongoc_client_start_session (client, NULL, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_SESSION_FAILURE, - "need a cryptography library"); - - mongoc_client_destroy (client); -} - - -#define ASSERT_SESSIONS_MATCH(_lsid_a, _lsid_b) \ - do { \ - assert_match_bson ((_lsid_a), (_lsid_b), false); \ - } while (0) - - -#define ASSERT_SESSIONS_DIFFER(_lsid_a, _lsid_b) \ - do { \ - BSON_ASSERT (!match_bson ((_lsid_a), (_lsid_b), false)); \ - } while (0) - - -/* "Pool is LIFO" test from Driver Sessions Spec */ -static void -_test_session_pool_lifo (bool pooled) -{ - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_client_session_t *a, *b, *c, *d; - bson_t lsid_a, lsid_b; - bson_error_t error; - - if (pooled) { - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - } - - a = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (a, error); - a->server_session->last_used_usec = bson_get_monotonic_time (); - bson_copy_to (mongoc_client_session_get_lsid (a), &lsid_a); - - b = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (b, error); - b->server_session->last_used_usec = bson_get_monotonic_time (); - bson_copy_to (mongoc_client_session_get_lsid (b), &lsid_b); - - /* return server sessions to pool: first "a", then "b" */ - mongoc_client_session_destroy (a); - mongoc_client_session_destroy (b); - - /* first pop returns last push */ - c = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (c, error); - ASSERT_SESSIONS_MATCH (&lsid_b, mongoc_client_session_get_lsid (c)); - - /* second pop returns previous push */ - d = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (d, error); - ASSERT_SESSIONS_MATCH (&lsid_a, mongoc_client_session_get_lsid (d)); - - mongoc_client_session_destroy (c); - mongoc_client_session_destroy (d); - - if (pooled) { - /* the pooled client never needed to connect, so it warns that - * it isn't connecting in order to send endSessions */ - capture_logs (true); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - bson_destroy (&lsid_a); - bson_destroy (&lsid_b); -} - - -static void -test_session_pool_lifo_single (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_session_pool_lifo (false); -} - - -static void -test_session_pool_lifo_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_session_pool_lifo (true); -} - - -/* test that a session that is timed out is not added to the pool, - * and a session that times out while it's in the pool is destroyed - */ -static void -_test_session_pool_timeout (bool pooled) -{ - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - uint32_t server_id; - mongoc_client_session_t *s; - bson_error_t error; - bson_t lsid; - int64_t almost_timeout_usec; - - almost_timeout_usec = - (test_framework_session_timeout_minutes () - 1) * 60 * 1000 * 1000; - - if (pooled) { - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - } - - /* - * trigger discovery - */ - server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_READ, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (server_id, error); - - /* - * get a session, set last_used_date more than 29 minutes ago and return to - * the pool. it's timed out & freed. - */ - BSON_ASSERT ( - mongoc_server_session_pool_is_empty (client->topology->session_pool)); - s = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (s, error); - bson_copy_to (mongoc_client_session_get_lsid (s), &lsid); - - s->server_session->last_used_usec = - (bson_get_monotonic_time () - almost_timeout_usec - 100); - - mongoc_client_session_destroy (s); - BSON_ASSERT ( - mongoc_server_session_pool_is_empty (client->topology->session_pool)); - - /* - * get a new session, set last_used_date so it has one second left to live, - * return to the pool, wait 1.5 seconds. it's timed out & freed. - */ - s = mongoc_client_start_session (client, NULL, &error); - ASSERT_SESSIONS_DIFFER (&lsid, mongoc_client_session_get_lsid (s)); - - bson_destroy (&lsid); - bson_copy_to (mongoc_client_session_get_lsid (s), &lsid); - - s->server_session->last_used_usec = - (bson_get_monotonic_time () + 1000 * 1000 - almost_timeout_usec); - - mongoc_client_session_destroy (s); - BSON_ASSERT ( - !mongoc_server_session_pool_is_empty (client->topology->session_pool)); - - _mongoc_usleep (1500 * 1000); - - /* getting a new client session must start a new server session */ - s = mongoc_client_start_session (client, NULL, &error); - ASSERT_SESSIONS_DIFFER (&lsid, mongoc_client_session_get_lsid (s)); - BSON_ASSERT ( - mongoc_server_session_pool_is_empty (client->topology->session_pool)); - mongoc_client_session_destroy (s); - - if (pooled) { - /* the pooled client never needed to connect, so it warns that - * it isn't connecting in order to send endSessions */ - capture_logs (true); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - bson_destroy (&lsid); -} - - -static void -test_session_pool_timeout_single (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_session_pool_timeout (false); -} - - -static void -test_session_pool_timeout_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_session_pool_timeout (true); -} - - -/* test that a session that times out while it's in the pool is reaped when - * another session is added - */ -static void -_test_session_pool_reap (bool pooled) -{ - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_client_session_t *a, *b; - bool r; - bson_error_t error; - bson_t lsid_a, lsid_b; - int64_t almost_timeout_usec; - mongoc_server_session_t *ss; - - almost_timeout_usec = - (test_framework_session_timeout_minutes () - 1) * 60 * 1000 * 1000; - - if (pooled) { - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - } - - /* - * trigger discovery - */ - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - - /* - * get a new session, set last_used_date so it has one second left to live, - * return to the pool, wait 1.5 seconds. - */ - a = mongoc_client_start_session (client, NULL, &error); - b = mongoc_client_start_session (client, NULL, &error); - bson_copy_to (mongoc_client_session_get_lsid (a), &lsid_a); - bson_copy_to (mongoc_client_session_get_lsid (b), &lsid_b); - - a->server_session->last_used_usec = - (bson_get_monotonic_time () + 1000 * 1000 - almost_timeout_usec); - - mongoc_client_session_destroy (a); - BSON_ASSERT (!mongoc_server_session_pool_is_empty ( - client->topology->session_pool)); /* session is pooled */ - - _mongoc_usleep (1500 * 1000); - - /* - * returning session B causes session A to be reaped - */ - b->server_session->last_used_usec = bson_get_monotonic_time (); - mongoc_client_session_destroy (b); - BSON_ASSERT ( - !mongoc_server_session_pool_is_empty (client->topology->session_pool)); - ss = - mongoc_server_session_pool_get_existing (client->topology->session_pool); - BSON_ASSERT (ss); - ASSERT_SESSIONS_MATCH (&ss->lsid, &lsid_b); - mongoc_server_session_pool_return (client->topology->session_pool, ss); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - bson_destroy (&lsid_a); - bson_destroy (&lsid_b); -} - - -static void -test_session_pool_reap_single (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_session_pool_reap (false); -} - - -static void -test_session_pool_reap_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_session_pool_reap (true); -} - - -static void -test_session_id_bad (void *ctx) -{ - const char *bad_opts[] = { - "{'sessionId': null}", - "{'sessionId': 'foo'}", - "{'sessionId': {'$numberInt': '1'}}", - "{'sessionId': {'$numberDouble': '1'}}", - /* doesn't fit in uint32 */ - "{'sessionId': {'$numberLong': '5000000000'}}", - /* doesn't match existing mongoc_client_session_t */ - "{'sessionId': {'$numberLong': '123'}}", - NULL, - }; - - const char **bad_opt; - mongoc_client_t *client; - bson_error_t error; - bool r; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - for (bad_opt = bad_opts; *bad_opt; bad_opt++) { - r = mongoc_client_read_command_with_opts (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL, - tmp_bson (*bad_opt), - NULL, - &error); - - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid sessionId"); - - memset (&error, 0, sizeof (bson_error_t)); - } - - mongoc_client_destroy (client); -} - -static void -_test_session_supported (bool pooled) -{ - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bson_error_t error; - mongoc_client_session_t *session; - - if (pooled) { - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - } - - if (test_framework_session_timeout_minutes () == -1) { - BSON_ASSERT (!mongoc_client_start_session (client, NULL, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_SESSION_FAILURE, - "Server does not support sessions"); - } else { - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - mongoc_client_session_destroy (session); - } - - if (pooled) { - /* the pooled client never needed to connect, so it warns that - * it isn't connecting in order to send endSessions */ - capture_logs (true); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } -} - -static void -test_session_supported_single (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_session_supported (false); -} - -static void -test_session_supported_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_session_supported (true); -} - -static void -_test_mock_end_sessions (bool pooled) -{ - mock_server_t *server; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bson_error_t error; - mongoc_client_session_t *session; - bson_t lsid; - bson_t opts = BSON_INITIALIZER; - bson_t *expected_cmd; - future_t *future; - request_t *request; - bool r; - - server = mock_mongos_new (WIRE_VERSION_MAX); - mock_server_run (server); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri ( - mock_server_get_uri (server), NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (mock_server_get_uri (server), - NULL); - } - - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - bson_copy_to (mongoc_client_session_get_lsid (session), &lsid); - r = mongoc_client_session_append (session, &opts, &error); - ASSERT_OR_PRINT (r, error); - - future = future_client_command_with_opts ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, &opts, NULL, &error); - - request = mock_server_receives_msg ( - server, 0, tmp_bson ("{'ping': 1, 'lsid': {'$exists': true}}")); - reply_to_request_with_ok_and_destroy (request); - - BSON_ASSERT (future_get_bool (future)); - future_destroy (future); - - /* before destroying the session, construct the expected endSessions cmd */ - expected_cmd = - BCON_NEW ("endSessions", - "[", - BCON_DOCUMENT (mongoc_client_session_get_lsid (session)), - "]"); - - mongoc_client_session_destroy (session); - - if (pooled) { - mongoc_client_pool_push (pool, client); - future = future_client_pool_destroy (pool); - } else { - future = future_client_destroy (client); - } - - /* check that we got the expected endSessions cmd */ - request = mock_server_receives_msg (server, 0, expected_cmd); - reply_to_request_with_ok_and_destroy (request); - future_wait (future); - future_destroy (future); - - mock_server_destroy (server); - bson_destroy (expected_cmd); - bson_destroy (&lsid); - bson_destroy (&opts); -} - -static void -test_mock_end_sessions_single (void) -{ - _test_mock_end_sessions (false); -} - -static void -test_mock_end_sessions_pooled (void) -{ - _test_mock_end_sessions (true); -} - -/* Test for CDRIVER-3587 - Do not reuse server stream that becomes invalid on - * failure to end session */ -static void -test_mock_end_sessions_server_disconnect (void) -{ - mock_server_t *server; - mongoc_client_t *client; - bson_error_t error; - mongoc_client_session_t *session[12000]; - future_t *future; - uint16_t i; - - server = mock_mongos_new (WIRE_VERSION_MAX); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - for (i = 0; i < 12000; i++) { - session[i] = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session[i], error); - } - - /* Simulate server failure or network failure. Destroy the mock server here - * rather than at the end of the test so that the 'endSessions' commands fail - * to reach the mock server. */ - mock_server_destroy (server); - - /* The below calls to mongoc_client_session_destroy () will produce a warning - * regarding the inability to send the 'endSessions' command. */ - capture_logs (true); - - for (i = 0; i < 12000; i++) { - mongoc_client_session_destroy (session[i]); - } - - /* The above loop will add each session back to the session pool. If - * CDRIVER-3587 has not been fixed, the mongoc_client_destroy () call below - * will create 'endSessions' commands which will be sent but fail to reach - * the server; the associated server stream will not be correctly - * invalidated. Subsequent reuse of the stream, as in the attempt to send - * the second batch of 10,000 during the attempt to destroy the client, will - * trigger a segfault. */ - - future = future_client_destroy (client); - - future_wait (future); - future_destroy (future); -} - -typedef struct { - int started_calls; - int succeeded_calls; - mongoc_array_t cmds; - mongoc_client_pool_t *pool; - mongoc_client_t *client; -} endsessions_test_t; - -static void -endsessions_started_cb (const mongoc_apm_command_started_t *event) -{ - endsessions_test_t *test; - bson_t *cmd; - - if (strcmp (mongoc_apm_command_started_get_command_name (event), - "endSessions") != 0) { - return; - } - - test = (endsessions_test_t *) mongoc_apm_command_started_get_context (event); - test->started_calls++; - cmd = bson_copy (mongoc_apm_command_started_get_command (event)); - _mongoc_array_append_vals (&test->cmds, &cmd, 1); -} - -static void -endsessions_succeeded_cb (const mongoc_apm_command_succeeded_t *event) -{ - endsessions_test_t *test; - - if (strcmp (mongoc_apm_command_succeeded_get_command_name (event), - "endSessions") != 0) { - return; - } - - test = - (endsessions_test_t *) mongoc_apm_command_succeeded_get_context (event); - test->succeeded_calls++; -} - -static void -endsessions_test_init (endsessions_test_t *test, bool pooled) -{ - mongoc_apm_callbacks_t *callbacks; - - test->started_calls = test->succeeded_calls = 0; - _mongoc_array_init (&test->cmds, sizeof (bson_t *)); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, endsessions_started_cb); - mongoc_apm_set_command_succeeded_cb (callbacks, endsessions_succeeded_cb); - - if (pooled) { - test->pool = test_framework_new_default_client_pool (); - ASSERT ( - mongoc_client_pool_set_apm_callbacks (test->pool, callbacks, test)); - test->client = mongoc_client_pool_pop (test->pool); - } else { - test->pool = NULL; - test->client = test_framework_new_default_client (); - ASSERT (mongoc_client_set_apm_callbacks (test->client, callbacks, test)); - } - - mongoc_apm_callbacks_destroy (callbacks); -} - -static void -endsessions_test_destroy_client (endsessions_test_t *test) -{ - if (test->pool) { - mongoc_client_pool_push (test->pool, test->client); - mongoc_client_pool_destroy (test->pool); - } else { - mongoc_client_destroy (test->client); - } -} - -static void -endsessions_test_get_ended_lsids (endsessions_test_t *test, - size_t index, - bson_t *ended_lsids) -{ - bson_iter_t iter; - - ASSERT_CMPINT (test->started_calls, >, (int) index); - - BSON_ASSERT ( - bson_iter_init_find (&iter, - _mongoc_array_index (&test->cmds, bson_t *, index), - "endSessions")); - - BSON_ASSERT (BSON_ITER_HOLDS_ARRAY (&iter)); - bson_iter_bson (&iter, ended_lsids); -} - -static void -endsessions_test_cleanup (endsessions_test_t *test) -{ - size_t i; - - for (i = 0; i < test->cmds.len; i++) { - bson_destroy (_mongoc_array_index (&test->cmds, bson_t *, i)); - } - - _mongoc_array_destroy (&test->cmds); -} - -static void -_test_end_sessions (bool pooled) -{ - endsessions_test_t test; - mongoc_client_t *client; - bson_error_t error; - mongoc_client_session_t *cs1; - mongoc_client_session_t *cs2; - bson_t lsid1; - bson_t lsid2; - bson_t opts1 = BSON_INITIALIZER; - bson_t opts2 = BSON_INITIALIZER; - bool lsid1_ended = false; - bool lsid2_ended = false; - bson_t ended_lsids; - bson_iter_t iter; - bson_t ended_lsid; - match_ctx_t ctx = {{0}}; - bool r; - - endsessions_test_init (&test, pooled); - client = test.client; - - /* - * create and use sessions 1 and 2 - */ - cs1 = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (cs1, error); - bson_copy_to (mongoc_client_session_get_lsid (cs1), &lsid1); - r = mongoc_client_session_append (cs1, &opts1, &error); - ASSERT_OR_PRINT (r, error); - r = mongoc_client_command_with_opts ( - client, "admin", tmp_bson ("{'count': 'c'}"), NULL, &opts1, NULL, &error); - ASSERT_OR_PRINT (r, error); - - cs2 = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (cs2, error); - bson_copy_to (mongoc_client_session_get_lsid (cs2), &lsid2); - r = mongoc_client_session_append (cs2, &opts2, &error); - ASSERT_OR_PRINT (r, error); - r = mongoc_client_command_with_opts ( - client, "admin", tmp_bson ("{'count': 'c'}"), NULL, &opts2, NULL, &error); - ASSERT_OR_PRINT (r, error); - - /* - * return server sessions to the pool - */ - mongoc_client_session_destroy (cs1); - mongoc_client_session_destroy (cs2); - endsessions_test_destroy_client (&test); - - /* - * sessions were ended on server - */ - ASSERT_CMPINT (test.started_calls, ==, 1); - ASSERT_CMPINT (test.succeeded_calls, ==, 1); - - endsessions_test_get_ended_lsids (&test, 0, &ended_lsids); - - BSON_ASSERT (bson_iter_init (&iter, &ended_lsids)); - while (bson_iter_next (&iter)) { - BSON_ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - bson_iter_bson (&iter, &ended_lsid); - if (match_bson_with_ctx (&ended_lsid, &lsid1, &ctx)) { - lsid1_ended = true; - } else if (match_bson_with_ctx (&ended_lsid, &lsid2, &ctx)) { - lsid2_ended = true; - } - } - - BSON_ASSERT (lsid1_ended); - BSON_ASSERT (lsid2_ended); - - bson_destroy (&lsid1); - bson_destroy (&opts1); - bson_destroy (&lsid2); - bson_destroy (&opts2); - endsessions_test_cleanup (&test); -} - -static void -test_end_sessions_single (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_end_sessions (false); -} - -static void -test_end_sessions_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_end_sessions (true); -} - -/* Sends ping to server via client_session. useful for marking - * server_sessions as used so that they are pushed back to the session pool */ -static void -send_ping (mongoc_client_t *client, mongoc_client_session_t *client_session) -{ - ASSERT (client); - - bson_t ping_cmd = BSON_INITIALIZER; - bson_t opts = BSON_INITIALIZER; - bson_error_t error; - bool ret; - - BCON_APPEND (&ping_cmd, "ping", BCON_INT32 (1)); - - ret = mongoc_client_session_append (client_session, &opts, &error); - ASSERT_OR_PRINT (ret, error); - - ret = mongoc_client_command_with_opts ( - client, "admin", &ping_cmd, NULL, &opts, NULL, &error); - ASSERT_OR_PRINT (ret, error); - bson_destroy (&opts); - bson_destroy (&ping_cmd); -} - -static void -_test_end_sessions_many (bool pooled) -{ - endsessions_test_t test; - mongoc_client_t *client; - int i; - mongoc_client_session_t *sessions[10001]; - bson_error_t error; - bson_t ended_lsids; - - endsessions_test_init (&test, pooled); - client = test.client; - /* connect */ - ASSERT_OR_PRINT ( - mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error), - error); - - /* - * create and destroy 10,001 sessions - */ - for (i = 0; i < sizeof sessions / sizeof (mongoc_client_session_t *); i++) { - sessions[i] = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (sessions[i], error); - send_ping (client, sessions[i]); - } - - for (i = 0; i < sizeof sessions / sizeof (mongoc_client_session_t *); i++) { - mongoc_client_session_destroy (sessions[i]); - } - - endsessions_test_destroy_client (&test); - - /* - * sessions were ended on the server, ten thousand at a time - */ - ASSERT_CMPINT (test.started_calls, ==, 2); - ASSERT_CMPINT (test.succeeded_calls, ==, 2); - - endsessions_test_get_ended_lsids (&test, 0, &ended_lsids); - ASSERT_CMPINT (bson_count_keys (&ended_lsids), ==, 10000); - endsessions_test_get_ended_lsids (&test, 1, &ended_lsids); - ASSERT_CMPINT (bson_count_keys (&ended_lsids), ==, 1); - - endsessions_test_cleanup (&test); -} - -static void -test_end_sessions_many_single (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_end_sessions_many (false); -} - -static void -test_end_sessions_many_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_end_sessions_many (true); -} - -static void -_test_advance_cluster_time (mongoc_client_session_t *cs, - int new_timestamp, - int new_increment, - bool should_advance) -{ - bson_t *old_cluster_time; - bson_t *new_cluster_time; - - old_cluster_time = bson_copy (mongoc_client_session_get_cluster_time (cs)); - new_cluster_time = - tmp_bson ("{'clusterTime': {'$timestamp': {'t': %d, 'i': %d}}}", - new_timestamp, - new_increment); - - mongoc_client_session_advance_cluster_time (cs, new_cluster_time); - - if (should_advance) { - assert_match_bson ( - mongoc_client_session_get_cluster_time (cs), new_cluster_time, false); - } else { - assert_match_bson ( - mongoc_client_session_get_cluster_time (cs), old_cluster_time, false); - } - - bson_destroy (old_cluster_time); -} - -static void -test_session_advance_cluster_time (void *ctx) -{ - mongoc_client_t *client; - bson_error_t error; - mongoc_client_session_t *cs; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - cs = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (cs, error); - BSON_ASSERT (!mongoc_client_session_get_cluster_time (cs)); - - capture_logs (true); - mongoc_client_session_advance_cluster_time (cs, tmp_bson ("{'foo': 1}")); - ASSERT_CAPTURED_LOG ("mongoc_client_session_advance_cluster_time", - MONGOC_LOG_LEVEL_ERROR, - "Cannot parse cluster time"); - - capture_logs (true); - mongoc_client_session_advance_cluster_time (cs, - tmp_bson ("{'clusterTime': 1}")); - ASSERT_CAPTURED_LOG ("mongoc_client_session_advance_cluster_time", - MONGOC_LOG_LEVEL_ERROR, - "Cannot parse cluster time"); - - mongoc_client_session_advance_cluster_time ( - cs, tmp_bson ("{'clusterTime': {'$timestamp': {'t': 1, 'i': 1}}}")); - - _test_advance_cluster_time (cs, 1, 0, false); - _test_advance_cluster_time (cs, 2, 2, true); - _test_advance_cluster_time (cs, 2, 1, false); - _test_advance_cluster_time (cs, 3, 1, true); - - mongoc_client_session_destroy (cs); - mongoc_client_destroy (client); -} - - -static void -_test_advance_operation_time (mongoc_client_session_t *cs, - uint32_t t, - uint32_t i, - bool should_advance) -{ - uint32_t old_t, old_i; - uint32_t new_t, new_i; - - mongoc_client_session_get_operation_time (cs, &old_t, &old_i); - mongoc_client_session_advance_operation_time (cs, t, i); - mongoc_client_session_get_operation_time (cs, &new_t, &new_i); - - if (should_advance) { - ASSERT_CMPUINT32 (new_t, ==, t); - ASSERT_CMPUINT32 (new_i, ==, i); - } else if (new_t == t && new_i == i) { - test_error ("Shouldn't have advanced from operationTime %" PRIu32 - ", %" PRIu32 " to %" PRIu32 ", %" PRIu32, - old_t, - old_i, - t, - i); - } -} - - -static void -test_session_advance_operation_time (void *ctx) -{ - mongoc_client_t *client; - bson_error_t error; - mongoc_client_session_t *cs; - uint32_t t, i; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - cs = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (cs, error); - mongoc_client_session_get_operation_time (cs, &t, &i); - - ASSERT_CMPUINT32 (t, ==, 0); - ASSERT_CMPUINT32 (t, ==, 0); - - mongoc_client_session_advance_operation_time (cs, 1, 1); - - _test_advance_operation_time (cs, 1, 0, false); - _test_advance_operation_time (cs, 2, 2, true); - _test_advance_operation_time (cs, 2, 1, false); - _test_advance_operation_time (cs, 3, 1, true); - - mongoc_client_session_destroy (cs); - mongoc_client_destroy (client); -} - - -typedef enum { - CORRECT_CLIENT, - INCORRECT_CLIENT, -} session_test_correct_t; - - -typedef enum { - CAUSAL, - NOT_CAUSAL, -} session_test_causal_t; - -typedef struct { - bool verbose; - mongoc_client_t *session_client, *client; - mongoc_database_t *session_db, *db; - mongoc_collection_t *session_collection, *collection; - mongoc_client_session_t *cs; - mongoc_client_session_t *wrong_cs; - bson_t opts; - bson_error_t error; - int n_started; - int n_succeeded; - bool expect_explicit_lsid; - bool acknowledged; - bool succeeded; - mongoc_array_t cmds; - mongoc_array_t replies; - bson_t sent_lsid; - bson_t sent_cluster_time; - bson_t received_cluster_time; -} session_test_t; - - -static void -started (const mongoc_apm_command_started_t *event) -{ - match_ctx_t ctx = {{0}}; - bson_iter_t iter; - bool has_cluster_time; - bson_t cluster_time; - bson_t lsid; - const bson_t *client_session_lsid; - bson_t *cmd = bson_copy (mongoc_apm_command_started_get_command (event)); - const char *cmd_name = mongoc_apm_command_started_get_command_name (event); - session_test_t *test = - (session_test_t *) mongoc_apm_command_started_get_context (event); - - ctx.strict_numeric_types = false; - - if (test->verbose) { - char *s = bson_as_json (cmd, NULL); - printf ("%s\n", s); - bson_free (s); - } - - if (!strcmp (cmd_name, "endSessions")) { - BSON_ASSERT (!bson_has_field (cmd, "lsid")); - bson_destroy (cmd); - return; - } - - if (test->acknowledged) { - if (!bson_iter_init_find (&iter, cmd, "lsid")) { - test_error ("no lsid sent with command %s", cmd_name); - } - - bson_iter_bson (&iter, &lsid); - client_session_lsid = &test->cs->server_session->lsid; - - if (test->expect_explicit_lsid) { - if (!match_bson_with_ctx (&lsid, client_session_lsid, &ctx)) { - test_error ("command %s should have used client session's lsid", - cmd_name); - } - } else { - if (match_bson_with_ctx (&lsid, client_session_lsid, &ctx)) { - test_error ("command %s should not have used client session's lsid", - cmd_name); - } - } - - if (bson_empty (&test->sent_lsid)) { - bson_destroy (&test->sent_lsid); - bson_copy_to (&lsid, &test->sent_lsid); - } else { - if (!match_bson_with_ctx (&lsid, &test->sent_lsid, &ctx)) { - test_error ("command %s used different lsid than previous command", - cmd_name); - } - } - } else { - /* unacknowledged commands should never include lsid */ - BSON_ASSERT (!bson_has_field (cmd, "lsid")); - } - - has_cluster_time = bson_iter_init_find (&iter, cmd, "$clusterTime"); - if (test->acknowledged && !has_cluster_time) { - test_error ("no $clusterTime sent with command %s", cmd_name); - } - - if (has_cluster_time) { - /* like $clusterTime: {clusterTime: } */ - bson_iter_bson (&iter, &cluster_time); - bson_destroy (&test->sent_cluster_time); - bson_copy_to (&cluster_time, &test->sent_cluster_time); - } - - _mongoc_array_append_vals (&test->cmds, &cmd, 1); - - test->n_started++; -} - - -static void -succeeded (const mongoc_apm_command_succeeded_t *event) -{ - bson_iter_t iter; - bool has_cluster_time; - bson_t cluster_time; - bson_t *reply = bson_copy (mongoc_apm_command_succeeded_get_reply (event)); - const char *cmd_name = mongoc_apm_command_succeeded_get_command_name (event); - session_test_t *test = - (session_test_t *) mongoc_apm_command_succeeded_get_context (event); - - if (test->verbose) { - char *s = bson_as_json (reply, NULL); - printf ("<-- %s\n", s); - bson_free (s); - } - - has_cluster_time = bson_iter_init_find (&iter, reply, "$clusterTime"); - if (test->acknowledged && !has_cluster_time) { - test_error ("no $clusterTime in reply to command %s", cmd_name); - } - - if (strcmp (cmd_name, "endSessions") == 0) { - bson_destroy (reply); - return; - } - - if (has_cluster_time) { - /* like $clusterTime: {clusterTime: } */ - bson_iter_bson (&iter, &cluster_time); - bson_destroy (&test->received_cluster_time); - bson_copy_to (&cluster_time, &test->received_cluster_time); - } - - _mongoc_array_append_vals (&test->replies, &reply, 1); - - test->n_succeeded++; -} - - -static void -failed (const mongoc_apm_command_failed_t *event) -{ - const char *cmd_name; - bson_error_t error; - - session_test_t *test = - (session_test_t *) mongoc_apm_command_failed_get_context (event); - - if (!test->verbose) { - return; - } - - cmd_name = mongoc_apm_command_failed_get_command_name (event); - mongoc_apm_command_failed_get_error (event, &error); - printf ("<-- %s: %s\n", cmd_name, error.message); -} - - -static void -set_session_test_callbacks (session_test_t *test) -{ - mongoc_apm_callbacks_t *callbacks; - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, started); - mongoc_apm_set_command_succeeded_cb (callbacks, succeeded); - mongoc_apm_set_command_failed_cb (callbacks, failed); - mongoc_client_set_apm_callbacks (test->client, callbacks, test); - - mongoc_apm_callbacks_destroy (callbacks); -} - - -static session_test_t * -session_test_new (session_test_correct_t correct_client, - session_test_causal_t causal) -{ - session_test_t *test; - mongoc_session_opt_t *cs_opts; - bson_error_t error; - - test = bson_malloc0 (sizeof (session_test_t)); - - test->verbose = test_framework_getenv_bool ("MONGOC_TEST_SESSION_VERBOSE"); - - test->n_started = 0; - test->expect_explicit_lsid = true; - test->acknowledged = true; - test->succeeded = false; - _mongoc_array_init (&test->cmds, sizeof (bson_t *)); - _mongoc_array_init (&test->replies, sizeof (bson_t *)); - bson_init (&test->sent_cluster_time); - bson_init (&test->received_cluster_time); - bson_init (&test->sent_lsid); - - test->session_client = test_framework_new_default_client (); - mongoc_client_set_error_api (test->session_client, 2); - test->session_db = mongoc_client_get_database (test->session_client, "db"); - test->session_collection = - mongoc_database_get_collection (test->session_db, "collection"); - - bson_init (&test->opts); - - if (correct_client == CORRECT_CLIENT) { - test->client = test->session_client; - test->db = test->session_db; - test->collection = test->session_collection; - } else { - /* test each function with a session from the correct client and a session - * from the wrong client */ - test->client = test_framework_new_default_client (); - mongoc_client_set_error_api (test->client, 2); - test->wrong_cs = mongoc_client_start_session (test->client, NULL, &error); - ASSERT_OR_PRINT (test->wrong_cs, error); - test->db = mongoc_client_get_database (test->client, "db"); - test->collection = - mongoc_database_get_collection (test->db, "collection"); - } - - set_session_test_callbacks (test); - - cs_opts = mongoc_session_opts_new (); - mongoc_session_opts_set_causal_consistency (cs_opts, causal == CAUSAL); - test->cs = - mongoc_client_start_session (test->session_client, cs_opts, &error); - ASSERT_OR_PRINT (test->cs, error); - - mongoc_session_opts_destroy (cs_opts); - - return test; -} - -struct check_session_returned_t { - const bson_t *expect_lsid; - bool found; -}; - -static int -check_session_returned_visit (mongoc_server_session_t *ss, - mongoc_topology_t *unused, - void *check_state_) -{ - match_ctx_t ctx = {{0}}; - struct check_session_returned_t *check_state = check_state_; - - BSON_UNUSED (unused); - - ctx.strict_numeric_types = false; - if (!check_state->found) { - check_state->found = - match_bson_with_ctx (&ss->lsid, check_state->expect_lsid, &ctx); - } - /* No session will ever be returned to the pool if it has never been used */ - ASSERT_CMPINT64 (ss->last_used_usec, !=, SESSION_NEVER_USED); - return 0; -} - - -static void -check_session_returned (session_test_t *test, const bson_t *lsid) -{ - struct check_session_returned_t check_state; - - check_state.expect_lsid = lsid; - check_state.found = false; - - mongoc_server_session_pool_visit_each ( - test->session_client->topology->session_pool, - &check_state, - check_session_returned_visit); - - /* Server session will only be returned to the pool if it has - * been used. It is expected behavior for found to be false if - * ss->last_used_usec == SESSION_NEVER_USED */ - if (!check_state.found) { - test_error ("server session %s not returned to pool", - bson_as_json (lsid, NULL)); - } -} - - -static const bson_t * -first_cmd (session_test_t *test) -{ - ASSERT_CMPSIZE_T (test->cmds.len, >, (size_t) 0); - return _mongoc_array_index (&test->cmds, bson_t *, 0); -} - - -static const bson_t * -last_non_getmore_cmd (session_test_t *test) -{ - ssize_t i; - const bson_t *cmd; - - ASSERT_CMPSIZE_T (test->cmds.len, >, (size_t) 0); - - for (i = test->replies.len - 1; i >= 0; i--) { - cmd = _mongoc_array_index (&test->cmds, bson_t *, i); - if (strcmp (_mongoc_get_command_name (cmd), "getMore") != 0) { - return cmd; - } - } - - test_error ("No commands besides getMore were recorded"); -} - - -static const bson_t * -last_reply (session_test_t *test) -{ - ASSERT_CMPSIZE_T (test->replies.len, >, (size_t) 0); - return _mongoc_array_index (&test->replies, bson_t *, test->replies.len - 1); -} - - -static void -clear_history (session_test_t *test) -{ - size_t i; - - for (i = 0; i < test->cmds.len; i++) { - bson_destroy (_mongoc_array_index (&test->cmds, bson_t *, i)); - } - - for (i = 0; i < test->replies.len; i++) { - bson_destroy (_mongoc_array_index (&test->replies, bson_t *, i)); - } - - test->cmds.len = 0; - test->replies.len = 0; -} - - -static void -session_test_destroy (session_test_t *test) -{ - bson_t session_lsid; - size_t i; - bool ss_was_used = - test->cs->server_session->last_used_usec != SESSION_NEVER_USED; - - bson_copy_to (mongoc_client_session_get_lsid (test->cs), &session_lsid); - - mongoc_client_session_destroy (test->cs); - - if (ss_was_used) { - /* If the session was used, assert that it was returned to the pool: */ - check_session_returned (test, &session_lsid); - } - bson_destroy (&session_lsid); - - if (!bson_empty (&test->sent_lsid)) { - /* for implicit sessions, ensure the implicit session was returned */ - check_session_returned (test, &test->sent_lsid); - } - - if (test->client != test->session_client) { - mongoc_client_session_destroy (test->wrong_cs); - mongoc_collection_destroy (test->collection); - mongoc_database_destroy (test->db); - mongoc_client_destroy (test->client); - } - - mongoc_collection_destroy (test->session_collection); - mongoc_database_destroy (test->session_db); - mongoc_client_destroy (test->session_client); - bson_destroy (&test->opts); - bson_destroy (&test->sent_cluster_time); - bson_destroy (&test->received_cluster_time); - bson_destroy (&test->sent_lsid); - - for (i = 0; i < test->cmds.len; i++) { - bson_destroy (_mongoc_array_index (&test->cmds, bson_t *, i)); - } - - _mongoc_array_destroy (&test->cmds); - - for (i = 0; i < test->replies.len; i++) { - bson_destroy (_mongoc_array_index (&test->replies, bson_t *, i)); - } - - _mongoc_array_destroy (&test->replies); - - bson_free (test); -} - - -static void -check_sessions_from_same_client_enforced (session_test_t *test) -{ - if (test->session_client != test->client) { - BSON_ASSERT (!test->succeeded); - ASSERT_ERROR_CONTAINS (test->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid sessionId"); - } -} - - -static void -check_sessions_with_w0_prohibited (session_test_t *test) -{ - if (test->expect_explicit_lsid && !test->acknowledged) { - BSON_ASSERT (!test->succeeded); - ASSERT_ERROR_CONTAINS (test->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "session with unacknowledged"); - } -} - - -static void -check_success (session_test_t *test) -{ - check_sessions_from_same_client_enforced (test); - check_sessions_with_w0_prohibited (test); - - if (test->session_client == test->client && - test->expect_explicit_lsid == test->acknowledged) { - ASSERT_OR_PRINT (test->succeeded, test->error); - } - - if (test->succeeded) { - ASSERT_CMPINT (test->n_started, >, 0); - ASSERT_CMPINT (test->n_succeeded, >, 0); - } -} - - -static void -check_cluster_time (session_test_t *test) -{ - const bson_t *session_time; - - session_time = mongoc_client_session_get_cluster_time (test->cs); - BSON_ASSERT (session_time); /* should be set during handshake */ - - /* fail if cluster_time_greater logs an error */ - capture_logs (true); - if (_mongoc_cluster_time_greater (&test->received_cluster_time, - session_time)) { - test_error ("client session's cluster time is outdated"); - } - - ASSERT_NO_CAPTURED_LOGS ("_mongoc_cluster_time_greater"); - capture_logs (false); -} - - -typedef void (*session_test_fn_t) (session_test_t *); - - -/* - * the following tests check session logic for a variety of operations. most of - * the asserts are in the APM started/succeeded/failed callbacks above - */ - -/* use the same client for the session and the operation, expect success */ -static void -_test_explicit_session_lsid (session_test_fn_t test_fn) -{ - session_test_t *test; - bson_error_t error; - int64_t start; - - test = session_test_new (CORRECT_CLIENT, NOT_CAUSAL); - ASSERT_CMPINT64 (test->cs->server_session->last_used_usec, ==, (int64_t) -1); - ASSERT_OR_PRINT ( - mongoc_client_session_append (test->cs, &test->opts, &error), error); - - start = bson_get_monotonic_time (); - test_fn (test); - check_success (test); - ASSERT_CMPINT (test->n_started, >, 0); - ASSERT_CMPINT (test->n_succeeded, >, 0); - check_cluster_time (test); - ASSERT_CMPINT64 (test->cs->server_session->last_used_usec, >=, start); - session_test_destroy (test); -} - - -/* use a session from the wrong client, expect failure. this is the - * "session argument is for right client" test from Driver Sessions Spec */ -static void -_test_session_from_wrong_client (session_test_fn_t test_fn) -{ - session_test_t *test; - bson_error_t error; - - test = session_test_new (INCORRECT_CLIENT, NOT_CAUSAL); - ASSERT_OR_PRINT ( - mongoc_client_session_append (test->cs, &test->opts, &error), error); - - test_fn (test); - check_success (test); - mongoc_collection_drop_with_opts (test->session_collection, NULL, NULL); - session_test_destroy (test); -} - - -/* implicit session - all commands should use an internally-acquired lsid */ -static void -_test_implicit_session_lsid (session_test_fn_t test_fn) -{ - session_test_t *test; - int64_t start; - mongoc_server_session_t *ss; - - test = session_test_new (CORRECT_CLIENT, NOT_CAUSAL); - test->expect_explicit_lsid = false; - start = bson_get_monotonic_time (); - test_fn (test); - check_success (test); - mongoc_collection_drop_with_opts (test->session_collection, NULL, NULL); - ss = mongoc_server_session_pool_get_existing ( - test->client->topology->session_pool); - BSON_ASSERT (ss); - ASSERT_CMPINT64 (ss->last_used_usec, >=, start); - mongoc_server_session_pool_return (test->client->topology->session_pool, ss); - session_test_destroy (test); -} - - -typedef struct { - uint32_t t; - uint32_t i; -} op_time_t; - - -static void -parse_read_concern_time (const bson_t *cmd, op_time_t *op_time) -{ - bson_iter_t iter; - bson_iter_t rc; - - BSON_ASSERT (bson_iter_init_find (&iter, cmd, "readConcern")); - BSON_ASSERT (bson_iter_recurse (&iter, &rc)); - BSON_ASSERT (bson_iter_find (&rc, "afterClusterTime")); - BSON_ASSERT (BSON_ITER_HOLDS_TIMESTAMP (&rc)); - bson_iter_timestamp (&rc, &op_time->t, &op_time->i); -} - - -static void -parse_reply_time (const bson_t *reply, op_time_t *op_time) -{ - bson_iter_t iter; - - BSON_ASSERT (bson_iter_init_find (&iter, reply, "operationTime")); - BSON_ASSERT (BSON_ITER_HOLDS_TIMESTAMP (&iter)); - bson_iter_timestamp (&iter, &op_time->t, &op_time->i); -} - - -#define ASSERT_OP_TIMES_EQUAL(_a, _b) \ - if ((_a).t != (_b).t || (_a).i != (_b).i) { \ - test_error (#_a " (%d, %d) does not match " #_b " (%d, %d)", \ - (_a).t, \ - (_a).i, \ - (_b).t, \ - (_b).i); \ - } else \ - ((void) 0) - - -static void -_test_causal_consistency (session_test_fn_t test_fn, bool allow_read_concern) -{ - session_test_t *test; - op_time_t session_time, read_concern_time, reply_time; - bson_error_t error; - const bson_t *cmd; - size_t i; - - /* - * first causal exchange: don't send readConcern, receive opTime - */ - test = session_test_new (CORRECT_CLIENT, CAUSAL); - ASSERT_OR_PRINT ( - mongoc_client_session_append (test->cs, &test->opts, &error), error); - - test_fn (test); - check_success (test); - BSON_ASSERT (!bson_has_field (first_cmd (test), "readConcern")); - mongoc_client_session_get_operation_time ( - test->cs, &session_time.t, &session_time.i); - BSON_ASSERT (session_time.t != 0); - parse_reply_time (last_reply (test), &reply_time); - ASSERT_OP_TIMES_EQUAL (session_time, reply_time); - - /* - * second exchange: send previous opTime and receive an opTime. - * send readConcern if this function supports readConcern, like - * mongoc_collection_find_with_opts or mongoc_client_read_command_with_opts. - * don't send readConcern for generic command helpers like - * mongoc_client_command_with_opts or mongoc_client_command. - */ - clear_history (test); - test_fn (test); - check_success (test); - - if (allow_read_concern) { - parse_read_concern_time (first_cmd (test), &read_concern_time); - ASSERT_OP_TIMES_EQUAL (reply_time, read_concern_time); - mongoc_client_session_get_operation_time ( - test->cs, &session_time.t, &session_time.i); - BSON_ASSERT (session_time.t != 0); - parse_reply_time (last_reply (test), &reply_time); - ASSERT_OP_TIMES_EQUAL (session_time, reply_time); - } else { - /* readConcern prohibited */ - for (i = 0; i < test->cmds.len; i++) { - cmd = _mongoc_array_index (&test->cmds, bson_t *, i); - if (bson_has_field (cmd, "readConcern")) { - test_error ("Command should not have included readConcern: %s", - bson_as_json (cmd, NULL)); - } - } - } - - session_test_destroy (test); -} - - -static void -_run_session_test (session_test_fn_t test_fn, bool allow_read_concern) -{ - _test_explicit_session_lsid (test_fn); - _test_session_from_wrong_client (test_fn); - _test_implicit_session_lsid (test_fn); - _test_causal_consistency (test_fn, allow_read_concern); -} - - -static void -run_session_test (void *ctx) -{ - _run_session_test ((session_test_fn_t) ((TestFnCtx *) ctx)->test_fn, true); -} - - -/* test a command that doesn't allow readConcern, and therefore isn't causal */ -static void -run_session_test_no_rc (void *ctx) -{ - _run_session_test ((session_test_fn_t) ((TestFnCtx *) ctx)->test_fn, false); -} - - -/* skip _test_session_from_wrong_client, which would abort with bulk op */ -static void -run_session_test_bulk_operation (void *ctx) -{ - session_test_fn_t test_fn = (session_test_fn_t) ((TestFnCtx *) ctx)->test_fn; - _test_explicit_session_lsid (test_fn); - _test_implicit_session_lsid (test_fn); - _test_causal_consistency (test_fn, false /* read concern */); -} - - -static void -run_count_test (void *ctx) -{ - /* CDRIVER-3612: mongoc_collection_estimated_document_count does not support - * explicit sessions */ - _test_implicit_session_lsid ( - (session_test_fn_t) ((TestFnCtx *) ctx)->test_fn); -} - - -static void -insert_10_docs (session_test_t *test) -{ - mongoc_bulk_operation_t *bulk; - bson_error_t error; - int i; - bool r; - - /* disable callbacks, we're not testing insert's lsid */ - mongoc_client_set_apm_callbacks (test->session_client, NULL, NULL); - bulk = mongoc_collection_create_bulk_operation_with_opts ( - test->session_collection, NULL); - - for (i = 0; i < 10; i++) { - mongoc_bulk_operation_insert (bulk, tmp_bson ("{}")); - } - - r = (bool) mongoc_bulk_operation_execute (bulk, NULL, &error); - ASSERT_OR_PRINT (r, error); - - mongoc_bulk_operation_destroy (bulk); - - set_session_test_callbacks (test); -} - - -static void -test_cmd (session_test_t *test) -{ - test->succeeded = - mongoc_client_command_with_opts (test->client, - "db", - tmp_bson ("{'listCollections': 1}"), - NULL, - &test->opts, - NULL, - &test->error); -} - - -static void -test_read_cmd (session_test_t *test) -{ - test->succeeded = - mongoc_client_read_command_with_opts (test->client, - "db", - tmp_bson ("{'listCollections': 1}"), - NULL, - &test->opts, - NULL, - &test->error); -} - - -static void -test_write_cmd (session_test_t *test) -{ - bson_t *cmd = - tmp_bson ("{'delete': 'collection', 'deletes': [{'q': {}, 'limit': 1}]}"); - - test->succeeded = mongoc_client_write_command_with_opts ( - test->client, "db", cmd, &test->opts, NULL, &test->error); -} - - -static void -test_read_write_cmd (session_test_t *test) -{ - bson_t *cmd = tmp_bson ("{" - " 'aggregate': 'collection'," - " 'cursor': {}," - " 'pipeline': [{'$out': 'collection2'}]" - "}"); - - test->succeeded = mongoc_client_read_write_command_with_opts ( - test->client, "db", cmd, NULL, &test->opts, NULL, &test->error); -} - - -static void -test_db_cmd (session_test_t *test) -{ - test->succeeded = - mongoc_database_command_with_opts (test->db, - tmp_bson ("{'listCollections': 1}"), - NULL, - &test->opts, - NULL, - &test->error); -} - - -static void -test_count (session_test_t *test) -{ - test->succeeded = - (-1 != mongoc_collection_count_with_opts (test->collection, - MONGOC_QUERY_NONE, - NULL, - 0, - 0, - &test->opts, - NULL, - &test->error)); -} - - -static void -test_cursor (session_test_t *test) -{ - mongoc_cursor_t *cursor; - const bson_t *doc; - - /* ensure multiple batches */ - insert_10_docs (test); - - cursor = mongoc_collection_find_with_opts ( - test->collection, tmp_bson ("{}"), &test->opts, NULL); - - mongoc_cursor_set_batch_size (cursor, 2); - while (mongoc_cursor_next (cursor, &doc)) { - } - - test->succeeded = !mongoc_cursor_error (cursor, &test->error); - - mongoc_cursor_destroy (cursor); -} - - -static void -test_drop (session_test_t *test) -{ - /* create the collection so that "drop" can succeed */ - insert_10_docs (test); - - test->succeeded = mongoc_collection_drop_with_opts ( - test->collection, &test->opts, &test->error); -} - - -static void -test_drop_index (session_test_t *test) -{ - bson_error_t error; - bool r; - - mongoc_index_model_t *im = mongoc_index_model_new ( - tmp_bson ("{'a': 1}"), tmp_bson ("{'name': 'foo'}")); - r = mongoc_collection_create_indexes_with_opts ( - test->session_collection, &im, 1, &test->opts, NULL /* reply */, &error); - mongoc_index_model_destroy (im); - ASSERT_OR_PRINT (r, error); - - test->succeeded = mongoc_collection_drop_index_with_opts ( - test->collection, "foo", &test->opts, &test->error); -} - -static void -test_create_index (session_test_t *test) -{ - BEGIN_IGNORE_DEPRECATIONS - test->succeeded = - mongoc_collection_create_index_with_opts (test->collection, - tmp_bson ("{'a': 1}"), - NULL, - &test->opts, - NULL, - &test->error); - END_IGNORE_DEPRECATIONS -} - -static void -test_replace_one (session_test_t *test) -{ - test->succeeded = mongoc_collection_replace_one (test->collection, - tmp_bson ("{}"), - tmp_bson ("{}"), - &test->opts, - NULL, - &test->error); -} - -static void -test_update_one (session_test_t *test) -{ - test->succeeded = - mongoc_collection_update_one (test->collection, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'x': 1}}"), - &test->opts, - NULL, - &test->error); -} - -static void -test_update_many (session_test_t *test) -{ - test->succeeded = - mongoc_collection_update_many (test->collection, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'x': 1}}"), - &test->opts, - NULL, - &test->error); -} - -static void -test_insert_one (session_test_t *test) -{ - test->succeeded = mongoc_collection_insert_one ( - test->collection, tmp_bson ("{}"), &test->opts, NULL, &test->error); -} - -static void -test_insert_many (session_test_t *test) -{ - bson_t *docs[2] = {tmp_bson ("{}"), tmp_bson ("{}")}; - test->succeeded = mongoc_collection_insert_many (test->collection, - (const bson_t **) docs, - 2, - &test->opts, - NULL, - &test->error); -} - -static void -test_delete_one (session_test_t *test) -{ - test->succeeded = mongoc_collection_delete_one ( - test->collection, tmp_bson ("{}"), &test->opts, NULL, &test->error); -} - -static void -test_delete_many (session_test_t *test) -{ - test->succeeded = mongoc_collection_delete_many ( - test->collection, tmp_bson ("{}"), &test->opts, NULL, &test->error); -} - -static void -test_rename (session_test_t *test) -{ - mongoc_collection_t *collection; - - /* ensure "rename" can succeed */ - insert_10_docs (test); - - /* mongoc_collection_rename_with_opts mutates the struct! */ - collection = mongoc_collection_copy (test->collection); - test->succeeded = mongoc_collection_rename_with_opts ( - collection, "db", "newname", true, &test->opts, &test->error); - - mongoc_collection_destroy (collection); -} - -static void -test_fam (session_test_t *test) -{ - mongoc_find_and_modify_opts_t *fam_opts; - - fam_opts = mongoc_find_and_modify_opts_new (); - mongoc_find_and_modify_opts_set_update (fam_opts, - tmp_bson ("{'$set': {'x': 1}}")); - BSON_ASSERT (mongoc_find_and_modify_opts_append (fam_opts, &test->opts)); - test->succeeded = mongoc_collection_find_and_modify_with_opts ( - test->collection, tmp_bson ("{}"), fam_opts, NULL, &test->error); - - mongoc_find_and_modify_opts_destroy (fam_opts); -} - -static void -test_db_drop (session_test_t *test) -{ - test->succeeded = - mongoc_database_drop_with_opts (test->db, &test->opts, &test->error); -} - -static void -test_gridfs_find (session_test_t *test) -{ - mongoc_gridfs_t *gfs; - bson_error_t error; - mongoc_gridfs_file_list_t *list; - mongoc_gridfs_file_t *f; - - /* work around lack of mongoc_client_get_gridfs_with_opts for now, can't yet - * include lsid with the GridFS createIndexes command */ - mongoc_client_set_apm_callbacks (test->client, NULL, NULL); - gfs = mongoc_client_get_gridfs (test->client, "test", NULL, &error); - ASSERT_OR_PRINT (gfs, error); - set_session_test_callbacks (test); - list = mongoc_gridfs_find_with_opts (gfs, tmp_bson ("{}"), &test->opts); - f = mongoc_gridfs_file_list_next (list); - test->succeeded = !mongoc_gridfs_file_list_error (list, &test->error); - - if (f) { - mongoc_gridfs_file_destroy (f); - } - - mongoc_gridfs_file_list_destroy (list); - mongoc_gridfs_destroy (gfs); -} - -static void -test_gridfs_find_one (session_test_t *test) -{ - mongoc_gridfs_t *gfs; - bson_error_t error; - mongoc_gridfs_file_t *f; - - /* work around lack of mongoc_client_get_gridfs_with_opts for now, can't yet - * include lsid with the GridFS createIndexes command */ - mongoc_client_set_apm_callbacks (test->client, NULL, NULL); - gfs = mongoc_client_get_gridfs (test->client, "test", NULL, &error); - ASSERT_OR_PRINT (gfs, error); - set_session_test_callbacks (test); - f = mongoc_gridfs_find_one_with_opts ( - gfs, tmp_bson ("{}"), &test->opts, &test->error); - - test->succeeded = test->error.domain == 0; - - if (f) { - mongoc_gridfs_file_destroy (f); - } - - mongoc_gridfs_destroy (gfs); -} - - -static void -test_watch (session_test_t *test) -{ - mongoc_change_stream_t *change_stream; - - insert_10_docs (test); - change_stream = - mongoc_collection_watch (test->collection, tmp_bson ("{}"), &test->opts); - - test->succeeded = - !mongoc_change_stream_error_document (change_stream, &test->error, NULL); - mongoc_change_stream_destroy (change_stream); -} - - -static void -test_aggregate (session_test_t *test) -{ - bson_t opts; - mongoc_cursor_t *cursor; - const bson_t *doc; - - /* ensure multiple batches */ - insert_10_docs (test); - - bson_copy_to (&test->opts, &opts); - BSON_APPEND_INT32 (&opts, "batchSize", 2); - - cursor = mongoc_collection_aggregate ( - test->collection, MONGOC_QUERY_NONE, tmp_bson ("{}"), &opts, NULL); - - while (mongoc_cursor_next (cursor, &doc)) { - } - - test->succeeded = !mongoc_cursor_error (cursor, &test->error); - - mongoc_cursor_destroy (cursor); - bson_destroy (&opts); -} - - -static void -test_create (session_test_t *test) -{ - mongoc_collection_t *collection; - - /* ensure "create" can succeed */ - mongoc_database_write_command_with_opts (test->session_db, - tmp_bson ("{'drop': 'newname'}"), - &test->opts, - NULL, - NULL); - - collection = mongoc_database_create_collection ( - test->db, "newname", &test->opts, &test->error); - - test->succeeded = (collection != NULL); - - if (collection) { - mongoc_collection_destroy (collection); - } -} - - -static void -test_database_names (session_test_t *test) -{ - char **names; - - names = mongoc_client_get_database_names_with_opts ( - test->client, &test->opts, &test->error); - - test->succeeded = (names != NULL); - - if (names) { - bson_strfreev (names); - } -} - - -static void -test_find_databases (session_test_t *test) -{ - mongoc_cursor_t *cursor; - const bson_t *doc; - - cursor = mongoc_client_find_databases_with_opts (test->client, &test->opts); - - while (mongoc_cursor_next (cursor, &doc)) { - } - - test->succeeded = !mongoc_cursor_error (cursor, &test->error); - mongoc_cursor_destroy (cursor); -} - - -static void -test_find_collections (session_test_t *test) -{ - mongoc_cursor_t *cursor; - const bson_t *doc; - - cursor = mongoc_database_find_collections_with_opts (test->db, &test->opts); - - while (mongoc_cursor_next (cursor, &doc)) { - } - - test->succeeded = !mongoc_cursor_error (cursor, &test->error); - mongoc_cursor_destroy (cursor); -} - - -static void -test_collection_names (session_test_t *test) -{ - char **strv; - - strv = mongoc_database_get_collection_names_with_opts ( - test->db, &test->opts, &test->error); - test->succeeded = (strv != NULL); - bson_strfreev (strv); -} - - -static void -test_find_indexes (session_test_t *test) -{ - mongoc_cursor_t *cursor; - const bson_t *doc; - - /* ensure the collection exists so the listIndexes command succeeds */ - insert_10_docs (test); - - cursor = - mongoc_collection_find_indexes_with_opts (test->collection, &test->opts); - - while (mongoc_cursor_next (cursor, &doc)) { - } - - test->succeeded = !mongoc_cursor_error (cursor, &test->error); - mongoc_cursor_destroy (cursor); -} - - -static void -_test_bulk (session_test_t *test, mongoc_bulk_operation_t *bulk) -{ - uint32_t i; - - test->succeeded = mongoc_bulk_operation_insert_with_opts ( - bulk, tmp_bson ("{}"), NULL, &test->error); - - check_sessions_from_same_client_enforced (test); - - test->succeeded = mongoc_bulk_operation_update_one_with_opts ( - bulk, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'x': 1}}"), - NULL, - &test->error); - check_sessions_from_same_client_enforced (test); - - test->succeeded = mongoc_bulk_operation_remove_one_with_opts ( - bulk, tmp_bson ("{}"), NULL, &test->error); - check_sessions_from_same_client_enforced (test); - - i = mongoc_bulk_operation_execute (bulk, NULL, &test->error); - test->succeeded = (i != 0); - check_sessions_with_w0_prohibited (test); - - mongoc_bulk_operation_destroy (bulk); -} - - -/* test the standard mongoc_collection_create_bulk_operation_with_opts */ -static void -test_bulk (session_test_t *test) -{ - mongoc_bulk_operation_t *bulk; - - bulk = mongoc_collection_create_bulk_operation_with_opts (test->collection, - &test->opts); - - _test_bulk (test, bulk); -} - - -/* instead of the standard mongoc_collection_create_bulk_operation_with_opts, - * test a quirky way of setting the client session on an existing bulk */ -static void -test_bulk_set_session (session_test_t *test) -{ - mongoc_bulk_operation_t *bulk; - bson_iter_t iter; - mongoc_client_session_t *cs; - bson_error_t error; - bool r; - - bulk = mongoc_bulk_operation_new (true /* ordered */); - mongoc_bulk_operation_set_client (bulk, test->client); - mongoc_bulk_operation_set_database (bulk, - mongoc_database_get_name (test->db)); - - mongoc_bulk_operation_set_collection ( - bulk, mongoc_collection_get_name (test->collection)); - - if (bson_iter_init_find (&iter, &test->opts, "sessionId")) { - r = _mongoc_client_session_from_iter ( - test->session_client, &iter, &cs, &error); - - ASSERT_OR_PRINT (r, error); - mongoc_bulk_operation_set_client_session (bulk, cs); - } - - _test_bulk (test, bulk); -} - - -/* like test_bulk_set_session, but set session first, then client */ -static void -test_bulk_set_client (session_test_t *test) -{ - mongoc_bulk_operation_t *bulk; - bson_iter_t iter; - mongoc_client_session_t *cs; - bson_error_t error; - bool r; - - bulk = mongoc_bulk_operation_new (true /* ordered */); - - if (bson_iter_init_find (&iter, &test->opts, "sessionId")) { - r = _mongoc_client_session_from_iter ( - test->session_client, &iter, &cs, &error); - - ASSERT_OR_PRINT (r, error); - mongoc_bulk_operation_set_client_session (bulk, cs); - } - - mongoc_bulk_operation_set_client (bulk, test->client); - mongoc_bulk_operation_set_database (bulk, - mongoc_database_get_name (test->db)); - - mongoc_bulk_operation_set_collection ( - bulk, mongoc_collection_get_name (test->collection)); - - _test_bulk (test, bulk); -} - - -static void -test_cursor_implicit_session (void *ctx) -{ - session_test_t *test; - mongoc_topology_t *topology; - mongoc_cursor_t *cursor; - const bson_t *doc; - mongoc_client_session_t *cs; - bson_t find_lsid; - bson_error_t error; - mongoc_server_session_t *ss; - - BSON_UNUSED (ctx); - - test = session_test_new (CORRECT_CLIENT, NOT_CAUSAL); - test->expect_explicit_lsid = false; - topology = test->client->topology; - cs = mongoc_client_start_session (test->client, NULL, &error); - ASSERT_OR_PRINT (cs, error); - - mongoc_collection_drop_with_opts (test->session_collection, NULL, NULL); - insert_10_docs (test); - cursor = mongoc_collection_find_with_opts ( - test->collection, tmp_bson ("{}"), &test->opts, NULL); - - BSON_ASSERT (!cursor->client_session); - mongoc_cursor_set_batch_size (cursor, 2); - - /* start the cursor. it makes an implicit session & sends it with "find" */ - BSON_ASSERT (mongoc_cursor_next (cursor, &doc)); - BSON_ASSERT (cursor->client_session); - BSON_ASSERT (!cursor->explicit_session); - bson_copy_to (&cursor->client_session->server_session->lsid, &find_lsid); - ASSERT_CMPSIZE_T ( - mongoc_server_session_pool_size (topology->session_pool), ==, 0); - ASSERT_SESSIONS_MATCH (&test->sent_lsid, &find_lsid); - - /* push a new server session into the pool. server session is only pushed - * if it is used. therefore mark session as used prior to - * destroying session by sending a ping */ - bson_reinit (&test->sent_lsid); - send_ping (test->client, cs); - mongoc_client_session_destroy (cs); - BSON_ASSERT (mongoc_server_session_pool_size (topology->session_pool) == 1); - ss = mongoc_server_session_pool_get_existing (topology->session_pool); - BSON_ASSERT (ss); - ASSERT_SESSIONS_DIFFER (&find_lsid, &ss->lsid); - mongoc_server_session_pool_return (topology->session_pool, ss); - - /* "getMore" uses the same lsid as "find" did */ - bson_reinit (&test->sent_lsid); - ASSERT_CURSOR_COUNT (9, cursor); - ASSERT_SESSIONS_MATCH (&test->sent_lsid, &find_lsid); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - /* lsid returned after last batch, doesn't wait for mongoc_cursor_destroy */ - check_session_returned (test, &find_lsid); - ASSERT_CMPSIZE_T ( - mongoc_server_session_pool_size (topology->session_pool), ==, 2); - - bson_destroy (&find_lsid); - mongoc_cursor_destroy (cursor); - session_test_destroy (test); -} - - -static void -test_change_stream_implicit_session (void *ctx) -{ - session_test_t *test; - mongoc_topology_t *topology; - mongoc_client_session_t *cs; - bson_error_t error; - mongoc_change_stream_t *change_stream; - bson_t pipeline = BSON_INITIALIZER; - const bson_t *doc; - bson_t aggregate_lsid; - mongoc_server_session_t *ss; - - BSON_UNUSED (ctx); - - test = session_test_new (CORRECT_CLIENT, NOT_CAUSAL); - test->expect_explicit_lsid = false; - topology = test->client->topology; - cs = mongoc_client_start_session (test->client, NULL, &error); - ASSERT_OR_PRINT (cs, error); - change_stream = - mongoc_collection_watch (test->session_collection, &pipeline, NULL); - bson_destroy (&pipeline); - bson_copy_to (&test->sent_lsid, &aggregate_lsid); - ASSERT_CMPSIZE_T ( - mongoc_server_session_pool_size (topology->session_pool), ==, 0); - BSON_ASSERT (change_stream->implicit_session); - - - /* push a new server session into the pool. server session is only pushed - * if it is used. therefore mark session as used prior to - * destroying session by sending a ping */ - bson_reinit (&test->sent_lsid); - send_ping (test->client, cs); - mongoc_client_session_destroy (cs); - ASSERT_CMPSIZE_T ( - mongoc_server_session_pool_size (topology->session_pool), ==, 1); - ss = mongoc_server_session_pool_get_existing (topology->session_pool); - BSON_ASSERT (ss); - ASSERT_SESSIONS_DIFFER (&aggregate_lsid, &ss->lsid); - mongoc_server_session_pool_return (topology->session_pool, ss); - - /* "getMore" uses the same lsid as "aggregate" did */ - bson_reinit (&test->sent_lsid); - mongoc_change_stream_next (change_stream, &doc); - ASSERT_SESSIONS_MATCH ( - &test->sent_lsid, &change_stream->implicit_session->server_session->lsid); - ASSERT_SESSIONS_MATCH ( - &test->sent_lsid, - &change_stream->cursor->client_session->server_session->lsid); - ASSERT_SESSIONS_MATCH (&test->sent_lsid, &aggregate_lsid); - ASSERT_OR_PRINT ( - !mongoc_change_stream_error_document (change_stream, &error, NULL), - error); - bson_destroy (&aggregate_lsid); - mongoc_change_stream_destroy (change_stream); - session_test_destroy (test); -} - - -static void -test_cmd_error (void *ctx) -{ - session_test_t *test; - bson_error_t error; - - BSON_UNUSED (ctx); - - test = session_test_new (CORRECT_CLIENT, CAUSAL); - - /* - * explicit session. command error still updates operation time - */ - test->expect_explicit_lsid = true; - ASSERT_OR_PRINT ( - mongoc_client_session_append (test->cs, &test->opts, &error), error); - - BSON_ASSERT (test->cs->operation_timestamp == 0); - BSON_ASSERT (!mongoc_client_command_with_opts (test->session_client, - "db", - tmp_bson ("{'bad': 1}"), - NULL, - &test->opts, - NULL, - NULL)); - - BSON_ASSERT (test->cs->operation_timestamp != 0); - - session_test_destroy (test); -} - - -static void -test_read_concern (void *ctx) -{ - session_test_t *test; - mongoc_read_concern_t *rc; - mongoc_session_opt_t *cs_opts; - bson_error_t error; - - BSON_UNUSED (ctx); - - test = session_test_new (CORRECT_CLIENT, CAUSAL); - test->expect_explicit_lsid = true; - ASSERT_OR_PRINT ( - mongoc_client_session_append (test->cs, &test->opts, &error), error); - - /* first exchange sets session's operationTime */ - test_read_cmd (test); - check_success (test); - BSON_ASSERT (!bson_has_field (last_non_getmore_cmd (test), "readConcern")); - - /* - * default: no explicit read concern, driver sends afterClusterTime - */ - test_read_cmd (test); - check_success (test); - ASSERT_MATCH (last_non_getmore_cmd (test), - "{" - " 'readConcern': {" - " 'level': {'$exists': false}," - " 'afterClusterTime': {'$exists': true}" - " }" - "}"); - - /* - * explicit read concern - */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_LOCAL); - BSON_ASSERT (mongoc_read_concern_append (rc, &test->opts)); - test_read_cmd (test); - check_success (test); - ASSERT_MATCH (last_non_getmore_cmd (test), - "{" - " 'readConcern': {" - " 'level': 'local'," - " 'afterClusterTime': {'$exists': true}" - " }" - "}"); - - /* - * explicit read concern, not causal - */ - cs_opts = mongoc_session_opts_new (); - mongoc_session_opts_set_causal_consistency (cs_opts, false); - mongoc_client_session_destroy (test->cs); - test->cs = mongoc_client_start_session (test->client, cs_opts, &error); - ASSERT_OR_PRINT (test->cs, error); - bson_reinit (&test->opts); - ASSERT_OR_PRINT ( - mongoc_client_session_append (test->cs, &test->opts, &error), error); - BSON_ASSERT (mongoc_read_concern_append (rc, &test->opts)); - /* set new session's operationTime */ - test_read_cmd (test); - check_success (test); - ASSERT_CMPUINT32 (test->cs->operation_timestamp, >, (uint32_t) 0); - /* afterClusterTime is not sent */ - test_read_cmd (test); - check_success (test); - ASSERT_MATCH (last_non_getmore_cmd (test), - "{" - " 'readConcern': {" - " 'level': 'local'," - " 'afterClusterTime': {'$exists': false}" - " }" - "}"); - - /* - * no read concern, not causal - */ - bson_reinit (&test->opts); - ASSERT_OR_PRINT ( - mongoc_client_session_append (test->cs, &test->opts, &error), error); - /* afterClusterTime is not sent */ - test_read_cmd (test); - check_success (test); - ASSERT_MATCH (last_non_getmore_cmd (test), - "{'readConcern': {'$exists': false}}"); - - mongoc_session_opts_destroy (cs_opts); - mongoc_read_concern_destroy (rc); - session_test_destroy (test); -} - - -static void -_test_unacknowledged (session_test_fn_t test_fn, - bool explicit_cs, - bool inherit_wc) -{ - session_test_t *test; - mongoc_write_concern_t *wc; - bson_error_t error; - - /* The following tests assert that unacknowledged command does not set the - * operationTime. Additionally, the "started" APM callback asserts that the - * command does not include an lsid. */ - test = session_test_new (CORRECT_CLIENT, CAUSAL); - test->expect_explicit_lsid = explicit_cs; - test->acknowledged = false; - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - - if (explicit_cs) { - ASSERT_OR_PRINT ( - mongoc_client_session_append (test->cs, &test->opts, &error), error); - } - - if (inherit_wc) { - mongoc_client_set_write_concern (test->client, wc); - mongoc_database_set_write_concern (test->db, wc); - mongoc_collection_set_write_concern (test->collection, wc); - } else { - BSON_ASSERT (mongoc_write_concern_append_bad (wc, &test->opts)); - } - - test_fn (test); - check_success (test); - - if (test->succeeded) { - ASSERT_MATCH (last_non_getmore_cmd (test), "{'writeConcern': {'w': 0}}"); - ASSERT_CMPUINT32 (test->cs->operation_timestamp, ==, (uint32_t) 0); - } - - mongoc_write_concern_destroy (wc); - session_test_destroy (test); -} - - -static void -test_unacknowledged_explicit_cs_inherit_wc (void *ctx) -{ - _test_unacknowledged ( - (session_test_fn_t) ((TestFnCtx *) ctx)->test_fn, true, true); -} - - -static void -test_unacknowledged_implicit_cs_explicit_wc (void *ctx) -{ - _test_unacknowledged ( - (session_test_fn_t) ((TestFnCtx *) ctx)->test_fn, true, false); -} - - -static void -test_unacknowledged_implicit_cs_inherit_wc (void *ctx) -{ - _test_unacknowledged ( - (session_test_fn_t) ((TestFnCtx *) ctx)->test_fn, false, true); -} - - -static void -test_unacknowledged_explicit_cs_explicit_wc (void *ctx) -{ - _test_unacknowledged ( - (session_test_fn_t) ((TestFnCtx *) ctx)->test_fn, false, false); -} - - -#define add_session_test(_suite, _name, _test_fn, _allow_read_concern) \ - TestSuite_AddFullWithTestFn ( \ - _suite, \ - _name, \ - (_allow_read_concern) ? run_session_test : run_session_test_no_rc, \ - NULL, \ - _test_fn, \ - test_framework_skip_if_no_cluster_time, \ - test_framework_skip_if_no_crypto) - -#define add_session_test_wc(_suite, _name, _test_fn, _allow_read_concern, ...) \ - TestSuite_AddFullWithTestFn ( \ - _suite, \ - _name, \ - (_allow_read_concern) ? run_session_test : run_session_test_no_rc, \ - NULL, \ - _test_fn, \ - test_framework_skip_if_no_cluster_time, \ - test_framework_skip_if_no_crypto, \ - __VA_ARGS__) - -#define add_unacknowledged_test( \ - _suite, _name, _test_fn, _explicit_cs, _inherit_wc) \ - TestSuite_AddFullWithTestFn ( \ - _suite, \ - _name, \ - (_explicit_cs) \ - ? (_inherit_wc ? test_unacknowledged_explicit_cs_inherit_wc \ - : test_unacknowledged_implicit_cs_explicit_wc) \ - : (_inherit_wc ? test_unacknowledged_implicit_cs_inherit_wc \ - : test_unacknowledged_explicit_cs_explicit_wc), \ - NULL, \ - _test_fn, \ - test_framework_skip_if_no_cluster_time, \ - test_framework_skip_if_no_crypto) - - -static bool -_test_run_operation (json_test_ctx_t *ctx, - const bson_t *test, - const bson_t *operation) -{ - bson_t reply; - mongoc_client_session_t *session = NULL; - /* Look up the session to use by name. Really, json_test_operation should - * probably handle this. Let's wait until unified test runner is spec'ed. */ - - if (bson_has_field (operation, "arguments.session")) { - session = session_from_name ( - ctx, bson_lookup_utf8 (operation, "arguments.session")); - } - - json_test_operation (ctx, test, operation, ctx->collection, session, &reply); - bson_destroy (&reply); - return true; -} - -static void -test_sessions_spec_cb (bson_t *scenario) -{ - json_test_config_t config = JSON_TEST_CONFIG_INIT; - config.run_operation_cb = _test_run_operation; - config.scenario = scenario; - config.command_started_events_only = true; - run_json_general_test (&config); -} - -/* Test that a session is made dirty after a network error, and that it is not - * added back to the session pool. */ -static void -_test_session_dirty_helper (bool retry_succeeds) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_client_session_t *session; - bson_t opts; - bool ret; - bson_error_t error; - bson_t *failpoint_cmd; - int fail_count; - mongoc_uri_t *uri; - - uri = test_framework_get_uri (); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYWRITES, true); - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - session = mongoc_client_start_session (client, NULL /* opts */, &error); - ASSERT_OR_PRINT (session, error); - coll = mongoc_client_get_collection (client, "test", "test"); - bson_init (&opts); - ret = mongoc_client_session_append (session, &opts, &error); - ASSERT_OR_PRINT (ret, error); - - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{}"), &opts, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - BSON_ASSERT (!session->server_session->dirty); - - if (retry_succeeds) { - /* Only fail once, so retried insert succeeds. */ - fail_count = 1; - } else { - /* Fail twice, so retried insert fails as well. */ - fail_count = 2; - } - - /* Enable failpoint. */ - failpoint_cmd = BCON_NEW ("configureFailPoint", - "failCommand", - "mode", - "{", - "times", - BCON_INT32 (fail_count), - "}", - "data", - "{", - "failCommands", - "[", - "insert", - "]", - "closeConnection", - BCON_BOOL (true), - "}"); - ret = mongoc_client_command_simple (client, - "admin", - failpoint_cmd, - NULL /* read prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{}"), &opts, NULL /* reply */, &error); - if (retry_succeeds) { - ASSERT_OR_PRINT (ret, error); - } else { - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "socket error"); - } - /* Regardless of whether the retry succeeded, the session should be marked - * dirty */ - BSON_ASSERT (session->server_session->dirty); - - const size_t pooled_session_count_pre = - mongoc_server_session_pool_size (client->topology->session_pool); - mongoc_client_session_destroy (session); - const size_t pooled_session_count_post = - mongoc_server_session_pool_size (client->topology->session_pool); - - /* Check that destroying in the session did not add it back to the pool. */ - ASSERT_CMPSIZE_T (pooled_session_count_pre, ==, pooled_session_count_post); - - mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'configureFailPoint': 'failCommand', 'mode': 'off'}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - - bson_destroy (&opts); - bson_destroy (failpoint_cmd); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); -} - -static void -test_session_dirty (void *unused) -{ - BSON_UNUSED (unused); - - _test_session_dirty_helper (true /* retry succceeds */); - _test_session_dirty_helper (false /* retry succceeds */); -} - -void -test_sessions_snapshot_prose_test_1 (void *ctx) -{ - mongoc_client_t *client = NULL; - mongoc_session_opt_t *session_opts = NULL; - bson_error_t error; - bool r; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - session_opts = mongoc_session_opts_new (); - mongoc_session_opts_set_causal_consistency (session_opts, true); - mongoc_session_opts_set_snapshot (session_opts, true); - - /* assert that starting session with causal consistency and snapshot enabled - * results in an error. */ - r = mongoc_client_start_session (client, session_opts, &error); - ASSERT (!r); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_SESSION_FAILURE, - "Only one of causal consistency and snapshot can be enabled."); - - mongoc_session_opts_destroy (session_opts); - mongoc_client_destroy (client); -} - -void -test_session_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/Session/opts/clone", test_session_opts_clone); - TestSuite_Add (suite, - "/Session/opts/causal_consistency_and_snapshot", - test_session_opts_causal_consistency_and_snapshot); - TestSuite_AddFull (suite, - "/Session/no_crypto", - test_session_no_crypto, - NULL, - NULL, - TestSuite_CheckLive, - test_framework_skip_if_no_sessions, - test_framework_skip_if_crypto); - TestSuite_AddFull (suite, - "/Session/lifo/single", - test_session_pool_lifo_single, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/Session/lifo/pooled", - test_session_pool_lifo_pooled, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/Session/timeout/single", - test_session_pool_timeout_single, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/Session/timeout/pooled", - test_session_pool_timeout_pooled, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/Session/reap/single", - test_session_pool_reap_single, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/Session/reap/pooled", - test_session_pool_reap_pooled, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/Session/id_bad", - test_session_id_bad, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/Session/supported/single", - test_session_supported_single, - NULL, - NULL, - TestSuite_CheckLive, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/Session/supported/pooled", - test_session_supported_pooled, - NULL, - NULL, - TestSuite_CheckLive, - test_framework_skip_if_no_crypto); - TestSuite_AddMockServerTest (suite, - "/Session/end/mock/single", - test_mock_end_sessions_single, - test_framework_skip_if_no_crypto); - TestSuite_AddMockServerTest (suite, - "/Session/end/mock/pooled", - test_mock_end_sessions_pooled, - test_framework_skip_if_no_crypto); - TestSuite_AddMockServerTest (suite, - "/Session/end/mock/disconnected", - test_mock_end_sessions_server_disconnect, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/Session/end/single", - test_end_sessions_single, - NULL, - NULL, - test_framework_skip_if_no_crypto, - TestSuite_CheckLive); - TestSuite_AddFull (suite, - "/Session/end/pooled", - test_end_sessions_pooled, - NULL, - NULL, - test_framework_skip_if_no_crypto, - TestSuite_CheckLive); - TestSuite_AddFull (suite, - "/Session/end/many/single", - test_end_sessions_many_single, - NULL, - NULL, - test_framework_skip_if_no_crypto, - TestSuite_CheckLive, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/Session/end/many/pooled", - test_end_sessions_many_pooled, - NULL, - NULL, - test_framework_skip_if_no_crypto, - TestSuite_CheckLive, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/Session/advance_cluster_time", - test_session_advance_cluster_time, - NULL, - NULL, - test_framework_skip_if_no_crypto, - test_framework_skip_if_no_sessions); - TestSuite_AddFull (suite, - "/Session/advance_operation_time", - test_session_advance_operation_time, - NULL, - NULL, - test_framework_skip_if_no_crypto, - test_framework_skip_if_no_sessions); - - /* "true" is for tests that expect readConcern: afterClusterTime for causally - * consistent sessions, "false" is for tests that prohibit readConcern */ - add_session_test (suite, "/Session/cmd", test_cmd, false); - add_session_test (suite, "/Session/read_cmd", test_read_cmd, true); - add_session_test (suite, "/Session/write_cmd", test_write_cmd, false); - add_session_test ( - suite, "/Session/read_write_cmd", test_read_write_cmd, true); - add_session_test (suite, "/Session/db_cmd", test_db_cmd, false); - TestSuite_AddFullWithTestFn (suite, - "/Session/count", - (TestFuncWC) run_count_test, - NULL, - test_count, - test_framework_skip_if_no_cluster_time, - test_framework_skip_if_no_crypto); - add_session_test (suite, "/Session/cursor", test_cursor, true); - add_session_test (suite, "/Session/drop", test_drop, false); - add_session_test (suite, "/Session/drop_index", test_drop_index, false); - add_session_test (suite, "/Session/create_index", test_create_index, false); - add_session_test (suite, "/Session/replace_one", test_replace_one, false); - add_session_test (suite, "/Session/update_one", test_update_one, false); - add_session_test (suite, "/Session/update_many", test_update_many, false); - add_session_test (suite, "/Session/insert_one", test_insert_one, false); - add_session_test (suite, "/Session/insert_many", test_insert_many, false); - add_session_test (suite, "/Session/delete_one", test_delete_one, false); - add_session_test (suite, "/Session/delete_many", test_delete_many, false); - add_session_test (suite, "/Session/rename", test_rename, false); - add_session_test (suite, "/Session/fam", test_fam, true); - add_session_test (suite, "/Session/db_drop", test_db_drop, false); - add_session_test (suite, "/Session/gridfs_find", test_gridfs_find, true); - add_session_test ( - suite, "/Session/gridfs_find_one", test_gridfs_find_one, true); - add_session_test_wc (suite, - "/Session/watch", - test_watch, - true, - test_framework_skip_if_not_replset); - add_session_test (suite, "/Session/aggregate", test_aggregate, true); - add_session_test (suite, "/Session/create", test_create, false); - add_session_test ( - suite, "/Session/database_names", test_database_names, true); - add_session_test ( - suite, "/Session/find_databases", test_find_databases, true); - add_session_test ( - suite, "/Session/find_collections", test_find_collections, true); - add_session_test ( - suite, "/Session/collection_names", test_collection_names, true); - add_session_test (suite, "/Session/bulk", test_bulk, false); - add_session_test (suite, "/Session/find_indexes", test_find_indexes, true); - TestSuite_AddFullWithTestFn (suite, - "/Session/bulk_set_session", - run_session_test_bulk_operation, - NULL, - test_bulk_set_session, - test_framework_skip_if_no_cluster_time, - test_framework_skip_if_no_crypto); - TestSuite_AddFullWithTestFn (suite, - "/Session/bulk_set_client", - run_session_test_bulk_operation, - NULL, - test_bulk_set_client, - test_framework_skip_if_no_cluster_time, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/Session/cursor_implicit_session", - test_cursor_implicit_session, - NULL, - NULL, - test_framework_skip_if_no_cluster_time, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/Session/change_stream_implicit_session", - test_change_stream_implicit_session, - NULL, - NULL, - test_framework_skip_if_no_cluster_time, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/Session/cmd_error", - test_cmd_error, - NULL, - NULL, - test_framework_skip_if_no_cluster_time, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/Session/read_concern", - test_read_concern, - NULL, - NULL, - test_framework_skip_if_no_cluster_time, - test_framework_skip_if_no_crypto); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/insert_one/explicit_cs/inherit_wc", - test_insert_one, - true, - true); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/insert_one/explicit_cs/explicit_wc", - test_insert_one, - true, - false); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/insert_one/implicit_cs/inherit_wc", - test_insert_one, - false, - true); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/insert_one/implicit_cs/explicit_wc", - test_insert_one, - false, - false); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/bulk/explicit_cs/inherit_wc", - test_bulk, - true, - true); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/bulk/explicit_cs/explicit_wc", - test_bulk, - true, - false); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/bulk/implicit_cs/inherit_wc", - test_bulk, - false, - true); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/bulk/implicit_cs/explicit_wc", - test_bulk, - false, - false); - /* find_and_modify_with_opts only inherits acknowledged write concerns, so - * skip tests that inherit a write concern. Technically, an explicit - * unacknowledged write concern doesn't make much sense with findAndModify, - * but this is testing the common code path for command execution. */ - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/find_and_modify/explicit_cs/explicit_wc", - test_fam, - true, - false); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/find_and_modify/implicit_cs/explicit_wc", - test_fam, - false, - false); - /* command_with_opts also does not inherit write concerns, but we still want - * to test the common code path for command execution. */ - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/db_cmd/explicit_cs/explicit_wc", - test_db_cmd, - true, - false); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/db_cmd/implicit_cs/explicit_wc", - test_db_cmd, - false, - false); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/read_write_cmd/explicit_cs/inherit_wc", - test_read_write_cmd, - true, - true); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/read_write_cmd/explicit_cs/explicit_wc", - test_read_write_cmd, - true, - false); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/read_write_cmd/implicit_cs/inherit_wc", - test_read_write_cmd, - false, - true); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/read_write_cmd/implicit_cs/explicit_wc", - test_read_write_cmd, - false, - false); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/write_cmd/explicit_cs/inherit_wc", - test_write_cmd, - true, - true); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/write_cmd/explicit_cs/explicit_wc", - test_write_cmd, - true, - false); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/write_cmd/implicit_cs/inherit_wc", - test_write_cmd, - false, - true); - add_unacknowledged_test ( - suite, - "/Session/unacknowledged/write_cmd/implicit_cs/explicit_wc", - test_write_cmd, - false, - false); - - install_json_test_suite_with_check (suite, - JSON_DIR, - "sessions/legacy", - test_sessions_spec_cb, - test_framework_skip_if_no_sessions); - - TestSuite_AddFull ( - suite, - "/Session/dirty", - test_session_dirty, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_failpoint, - /* Tests with retryable writes, requires non-standalone. */ - test_framework_skip_if_single); - - TestSuite_AddFull (suite, - "/Session/snapshot/prose_test_1", - test_sessions_snapshot_prose_test_1, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client-side-encryption.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client-side-encryption.c deleted file mode 100644 index aafee1a36..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client-side-encryption.c +++ /dev/null @@ -1,7547 +0,0 @@ -/* - * Copyright 2019-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "json-test.h" -#include "test-libmongoc.h" - -#include "bson-dsl.h" - -#include "common-b64-private.h" - -/* _mongoc_host_list_from_string_with_err */ -#include "mongoc/mongoc-host-list-private.h" -#include "mongoc/mongoc-cluster-aws-private.h" - -/* MONGOC_SERVER_ERR_NS_NOT_FOUND */ -#include "mongoc/mongoc-error-private.h" - -#include "mongoc/mongoc-client-side-encryption-private.h" - -#include "mongoc/mongoc-uri.h" - -static void -_before_test (json_test_ctx_t *ctx, const bson_t *test) -{ - mongoc_client_t *client; - mongoc_collection_t *keyvault_coll; - bson_iter_t iter; - bson_error_t error; - bool ret; - mongoc_write_concern_t *wc; - bson_t insert_opts; - - BSON_UNUSED (test); - - /* Insert data into the key vault. */ - client = test_framework_new_default_client (); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_wmajority (wc, 1000); - bson_init (&insert_opts); - mongoc_write_concern_append (wc, &insert_opts); - - if (bson_iter_init_find (&iter, ctx->config->scenario, "key_vault_data")) { - keyvault_coll = - mongoc_client_get_collection (client, "keyvault", "datakeys"); - - /* Drop and recreate, inserting data. */ - ret = mongoc_collection_drop (keyvault_coll, &error); - if (!ret) { - /* Ignore "namespace does not exist" error. */ - ASSERT_OR_PRINT (error.code == 26, error); - } - - bson_iter_recurse (&iter, &iter); - while (bson_iter_next (&iter)) { - bson_t doc; - - bson_iter_bson (&iter, &doc); - ret = mongoc_collection_insert_one ( - keyvault_coll, &doc, &insert_opts, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - } - mongoc_collection_destroy (keyvault_coll); - } - - bson_destroy (&insert_opts); - mongoc_write_concern_destroy (wc); - mongoc_client_destroy (client); -} - -static bool -_run_operation (json_test_ctx_t *ctx, - const bson_t *test, - const bson_t *operation) -{ - bson_t reply; - bool res; - - res = - json_test_operation (ctx, test, operation, ctx->collection, NULL, &reply); - - bson_destroy (&reply); - - return res; -} - -static void -test_client_side_encryption_cb (bson_t *scenario) -{ - json_test_config_t config = JSON_TEST_CONFIG_INIT; - config.before_test_cb = _before_test; - config.run_operation_cb = _run_operation; - config.scenario = scenario; - config.command_started_events_only = true; - config.command_monitoring_allow_subset = false; - run_json_general_test (&config); -} - -/* This is the hex form of the base64 encoded value: - * Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk - * From the client side encryption spec. - */ -#define LOCAL_MASTERKEY \ - "\x32\x78\x34\x34\x2b\x78\x64\x75\x54\x61\x42\x42\x6b\x59\x31\x36\x45\x72" \ - "\x35\x44\x75\x41\x44\x61\x67\x68\x76\x53\x34\x76\x77\x64\x6b\x67\x38\x74" \ - "\x70\x50\x70\x33\x74\x7a\x36\x67\x56\x30\x31\x41\x31\x43\x77\x62\x44\x39" \ - "\x69\x74\x51\x32\x48\x46\x44\x67\x50\x57\x4f\x70\x38\x65\x4d\x61\x43\x31" \ - "\x4f\x69\x37\x36\x36\x4a\x7a\x58\x5a\x42\x64\x42\x64\x62\x64\x4d\x75\x72" \ - "\x64\x6f\x6e\x4a\x31\x64" - -static void -_set_extra_bypass (bson_t *extra) -{ - if (test_framework_getenv_bool ("MONGOC_TEST_MONGOCRYPTD_BYPASS_SPAWN")) { - BSON_APPEND_BOOL (extra, "mongocryptdBypassSpawn", true); - } -} - -static void -_set_extra_crypt_shared (bson_t *extra) -{ - char *const path = - test_framework_getenv ("MONGOC_TEST_CRYPT_SHARED_LIB_PATH"); - if (path) { - BSON_APPEND_UTF8 (extra, "cryptSharedLibPath", path); - bson_free (path); - } -} - -/* Convenience helper to check if spawning mongocryptd should be bypassed */ -static void -_check_bypass (mongoc_auto_encryption_opts_t *opts) -{ - bson_t extra = BSON_INITIALIZER; - _set_extra_bypass (&extra); - mongoc_auto_encryption_opts_set_extra (opts, &extra); - bson_destroy (&extra); -} - -static bson_t * -_make_aws_kms_provider (bson_t *kms_providers) -{ - char *aws_secret_access_key; - char *aws_access_key_id; - - aws_secret_access_key = - test_framework_getenv_required ("MONGOC_TEST_AWS_SECRET_ACCESS_KEY"); - aws_access_key_id = - test_framework_getenv_required ("MONGOC_TEST_AWS_ACCESS_KEY_ID"); - - if (!kms_providers) { - kms_providers = bson_new (); - } - - bson_concat ( - kms_providers, - tmp_bson ("{ 'aws': { 'secretAccessKey': '%s', 'accessKeyId': '%s' }}", - aws_secret_access_key, - aws_access_key_id)); - - bson_free (aws_secret_access_key); - bson_free (aws_access_key_id); - - return kms_providers; -} - -static bson_t * -_make_azure_kms_provider (bson_t *kms_providers) -{ - char *azure_tenant_id; - char *azure_client_id; - char *azure_client_secret; - - azure_tenant_id = - test_framework_getenv_required ("MONGOC_TEST_AZURE_TENANT_ID"); - azure_client_id = - test_framework_getenv_required ("MONGOC_TEST_AZURE_CLIENT_ID"); - azure_client_secret = - test_framework_getenv_required ("MONGOC_TEST_AZURE_CLIENT_SECRET"); - - if (!kms_providers) { - kms_providers = bson_new (); - } - - bson_concat (kms_providers, - tmp_bson ("{ 'azure': { 'tenantId': '%s', 'clientId': '%s', " - "'clientSecret': '%s' }}", - azure_tenant_id, - azure_client_id, - azure_client_secret)); - - bson_free (azure_tenant_id); - bson_free (azure_client_id); - bson_free (azure_client_secret); - - return kms_providers; -} - -static bson_t * -_make_gcp_kms_provider (bson_t *kms_providers) -{ - char *gcp_email; - char *gcp_privatekey; - - - gcp_email = test_framework_getenv_required ("MONGOC_TEST_GCP_EMAIL"); - gcp_privatekey = - test_framework_getenv_required ("MONGOC_TEST_GCP_PRIVATEKEY"); - - if (!gcp_email || !gcp_privatekey) { - test_error ("Set MONGOC_TEST_GCP_EMAIL and MONGOC_TEST_GCP_PRIVATEKEY to " - "enable CSFLE tests."); - } - - if (!kms_providers) { - kms_providers = bson_new (); - } - - bson_concat (kms_providers, - tmp_bson ("{ 'gcp': { 'email': '%s', 'privateKey': '%s' }}", - gcp_email, - gcp_privatekey)); - - bson_free (gcp_email); - bson_free (gcp_privatekey); - - return kms_providers; -} - -static bson_t * -_make_local_kms_provider (bson_t *kms_providers) -{ - bson_t *local = BCON_NEW ( - "local", "{", "key", BCON_BIN (0, (uint8_t *) LOCAL_MASTERKEY, 96), "}"); - - if (!kms_providers) { - kms_providers = bson_new (); - } - - bson_concat (kms_providers, local); - bson_destroy (local); - - return kms_providers; -} - -static bson_t * -_make_kmip_kms_provider (bson_t *kms_providers) -{ - if (!kms_providers) { - kms_providers = bson_new (); - } - - bson_concat (kms_providers, - tmp_bson ("{ 'kmip': { 'endpoint': 'localhost:5698' } }")); - - - return kms_providers; -} - -/* Convenience helper for creating KMS providers doc */ -static bson_t * -_make_kms_providers (bool with_aws, bool with_local) -{ - bson_t *kms_providers = bson_new (); - - if (with_aws) { - _make_aws_kms_provider (kms_providers); - _make_azure_kms_provider (kms_providers); - _make_gcp_kms_provider (kms_providers); - _make_kmip_kms_provider (kms_providers); - } - - if (with_local) { - _make_local_kms_provider (kms_providers); - } - - return kms_providers; -} - -static bson_t * -_make_tls_opts (void) -{ - bson_t *tls_opts = bson_new (); - char *kmip_tls_ca_file; - char *kmip_tls_certificate_key_file; - - kmip_tls_ca_file = - test_framework_getenv_required ("MONGOC_TEST_CSFLE_TLS_CA_FILE"); - kmip_tls_certificate_key_file = test_framework_getenv_required ( - "MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE"); - - bson_concat ( - tls_opts, - tmp_bson ( - "{ 'kmip': { 'tlsCAFile': '%s', 'tlsCertificateKeyFile': '%s' } }", - kmip_tls_ca_file, - kmip_tls_certificate_key_file)); - - bson_free (kmip_tls_ca_file); - bson_free (kmip_tls_certificate_key_file); - return tls_opts; -} - -static bson_t * -_make_kms_masterkey (char const *provider) -{ - if (strcmp (provider, "aws") == 0) { - return BCON_NEW ("region", - "us-east-1", - "key", - "arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0"); - } - - if (strcmp (provider, "azure") == 0) { - return BCON_NEW ("keyVaultEndpoint", - "key-vault-csfle.vault.azure.net", - "keyName", - "key-name-csfle"); - } - - if (strcmp (provider, "gcp") == 0) { - return BCON_NEW ("projectId", - "devprod-drivers", - "location", - "global", - "keyRing", - "key-ring-csfle", - "keyName", - "key-name-csfle"); - } - - if (strcmp (provider, "kmip") == 0) { - return bson_new (); - } - - if (strcmp (provider, "local") == 0) { - return bson_new (); - } - - return NULL; -} - -typedef struct { - int num_inserts; -} limits_apm_ctx_t; - -static void -_command_started (const mongoc_apm_command_started_t *event) -{ - limits_apm_ctx_t *ctx; - - ctx = (limits_apm_ctx_t *) mongoc_apm_command_started_get_context (event); - if (0 == - strcmp ("insert", mongoc_apm_command_started_get_command_name (event))) { - ctx->num_inserts++; - } -} - -/* Prose Test 4: BSON Size Limits and Batch Splitting */ -static void -test_bson_size_limits_and_batch_splitting (void *unused) -{ - /* Expect an insert of two documents over 2MiB to split into two inserts but - * still succeed. */ - mongoc_client_t *client; - mongoc_auto_encryption_opts_t *opts; - mongoc_uri_t *uri; - mongoc_collection_t *coll; - bson_error_t error; - bson_t *corpus_schema; - bson_t *datakey; - bson_t *cmd; - bson_t *kms_providers; - bson_t *docs[2]; - char *as; - limits_apm_ctx_t ctx = {0}; - mongoc_apm_callbacks_t *callbacks; - /* Values from the spec to test boundaries. */ - const int size_16mib = 16777216; - const int size_2mib = 2097152; - const int exceeds_2mib_after_encryption = size_2mib - 2000; - const int exceeds_16mib_after_encryption = size_16mib - 2000; - - BSON_UNUSED (unused); - - /* Do the test setup. */ - - /* Drop and create db.coll configured with limits-schema.json */ - uri = test_framework_get_uri (); - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - coll = mongoc_client_get_collection (client, "db", "coll"); - (void) mongoc_collection_drop (coll, NULL); - corpus_schema = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/limits-schema.json"); - cmd = BCON_NEW ("create", - "coll", - "validator", - "{", - "$jsonSchema", - BCON_DOCUMENT (corpus_schema), - "}"); - ASSERT_OR_PRINT ( - mongoc_client_command_simple ( - client, "db", cmd, NULL /* read prefs */, NULL /* reply */, &error), - error); - - mongoc_collection_destroy (coll); - /* Drop and create the key vault collection, keyvault.datakeys. */ - { - mongoc_write_concern_t *wc; - - coll = mongoc_client_get_collection (client, "keyvault", "datakeys"); - (void) mongoc_collection_drop (coll, NULL); - datakey = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/limits-key.json"); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_wmajority (wc, 1000); - mongoc_collection_set_write_concern (coll, wc); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one ( - coll, datakey, NULL /* opts */, NULL /* reply */, &error), - error); - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (coll); - } - - mongoc_client_destroy (client); - - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - - kms_providers = _make_kms_providers (false /* aws */, true /* local */); - opts = mongoc_auto_encryption_opts_new (); - _check_bypass (opts); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - opts, "keyvault", "datakeys"); - mongoc_auto_encryption_opts_set_kms_providers (opts, kms_providers); - - ASSERT_OR_PRINT (mongoc_client_enable_auto_encryption (client, opts, &error), - error); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, _command_started); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - - coll = mongoc_client_get_collection (client, "db", "coll"); - /* End of setup */ - - /* Insert { "_id": "over_2mib_under_16mib", "unencrypted": } */ - docs[0] = BCON_NEW ("_id", "over_2mib_under_16mib"); - as = bson_malloc (size_16mib); - memset (as, 'a', size_16mib); - bson_append_utf8 (docs[0], "unencrypted", -1, as, 2097152); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one ( - coll, docs[0], NULL /* opts */, NULL /* reply */, &error), - error); - bson_destroy (docs[0]); - - /* Insert the document `limits/limits-doc.json <../limits/limits-doc.json>`_ - * concatenated with ``{ "_id": "encryption_exceeds_2mib", "unencrypted": < - * the string "a" repeated (2097152 - 2000) times > }`` */ - docs[0] = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/limits-doc.json"); - bson_append_utf8 (docs[0], "_id", -1, "encryption_exceeds_2mib", -1); - bson_append_utf8 ( - docs[0], "unencrypted", -1, as, exceeds_2mib_after_encryption); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one ( - coll, docs[0], NULL /* opts */, NULL /* reply */, &error), - error); - bson_destroy (docs[0]); - - /* Insert two documents that each exceed 2MiB but no encryption occurs. - * Expect the bulk write to succeed and run as two separate inserts. - */ - docs[0] = BCON_NEW ("_id", "over_2mib_1"); - bson_append_utf8 (docs[0], "unencrypted", -1, as, size_2mib); - docs[1] = BCON_NEW ("_id", "over_2mib_2"); - bson_append_utf8 (docs[1], "unencrypted", -1, as, size_2mib); - ctx.num_inserts = 0; - ASSERT_OR_PRINT (mongoc_collection_insert_many (coll, - (const bson_t **) docs, - 2, - NULL /* opts */, - NULL /* reply */, - &error), - error); - ASSERT_CMPINT (ctx.num_inserts, ==, 2); - bson_destroy (docs[0]); - bson_destroy (docs[1]); - - /* Insert two documents that each exceed 2MiB after encryption occurs. Expect - * the bulk write to succeed and run as two separate inserts. - */ - - docs[0] = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/limits-doc.json"); - bson_append_utf8 (docs[0], "_id", -1, "encryption_exceeds_2mib_1", -1); - bson_append_utf8 ( - docs[0], "unencrypted", -1, as, exceeds_2mib_after_encryption); - docs[1] = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/limits-doc.json"); - bson_append_utf8 (docs[1], "_id", -1, "encryption_exceeds_2mib_2", -1); - bson_append_utf8 ( - docs[1], "unencrypted", -1, as, exceeds_2mib_after_encryption); - ctx.num_inserts = 0; - ASSERT_OR_PRINT (mongoc_collection_insert_many (coll, - (const bson_t **) docs, - 2, - NULL /* opts */, - NULL /* reply */, - &error), - error); - ASSERT_CMPINT (ctx.num_inserts, ==, 2); - bson_destroy (docs[0]); - bson_destroy (docs[1]); - - /* Check that inserting close to, but not exceeding, 16MiB, passes */ - docs[0] = bson_new (); - bson_append_utf8 (docs[0], "_id", -1, "under_16mib", -1); - bson_append_utf8 ( - docs[0], "unencrypted", -1, as, exceeds_16mib_after_encryption); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one ( - coll, docs[0], NULL /* opts */, NULL /* reply */, &error), - error); - bson_destroy (docs[0]); - - /* but.. exceeding 16 MiB fails */ - docs[0] = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/limits-doc.json"); - bson_append_utf8 (docs[0], "_id", -1, "under_16mib", -1); - bson_append_utf8 ( - docs[0], "unencrypted", -1, as, exceeds_16mib_after_encryption); - BSON_ASSERT (!mongoc_collection_insert_one ( - coll, docs[0], NULL /* opts */, NULL /* reply */, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 2, "too large"); - bson_destroy (docs[0]); - - bson_free (as); - bson_destroy (kms_providers); - bson_destroy (corpus_schema); - bson_destroy (cmd); - bson_destroy (datakey); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_auto_encryption_opts_destroy (opts); -} - -typedef struct { - bson_t *last_cmd; -} _datakey_and_double_encryption_ctx_t; - -static void -_datakey_and_double_encryption_command_started ( - const mongoc_apm_command_started_t *event) -{ - _datakey_and_double_encryption_ctx_t *ctx; - - ctx = (_datakey_and_double_encryption_ctx_t *) - mongoc_apm_command_started_get_context (event); - bson_destroy (ctx->last_cmd); - ctx->last_cmd = bson_copy (mongoc_apm_command_started_get_command (event)); -} - -static void -test_datakey_and_double_encryption_creating_and_using ( - mongoc_client_encryption_t *client_encryption, - mongoc_client_t *client, - mongoc_client_t *client_encrypted, - const char *kms_provider, - _datakey_and_double_encryption_ctx_t *test_ctx) -{ - bson_value_t keyid; - bson_error_t error; - bool ret; - mongoc_client_encryption_datakey_opts_t *opts; - mongoc_client_encryption_encrypt_opts_t *encrypt_opts; - char *altname; - mongoc_collection_t *coll; - mongoc_cursor_t *cursor; - bson_t filter; - const bson_t *doc; - bson_value_t to_encrypt; - bson_value_t encrypted; - bson_value_t encrypted_via_altname; - bson_t to_insert = BSON_INITIALIZER; - char *hello; - - opts = mongoc_client_encryption_datakey_opts_new (); - - if (0 == strcmp (kms_provider, "aws")) { - mongoc_client_encryption_datakey_opts_set_masterkey ( - opts, - tmp_bson ("{ 'region': 'us-east-1', 'key': " - "'arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0' }")); - } else if (0 == strcmp (kms_provider, "azure")) { - mongoc_client_encryption_datakey_opts_set_masterkey ( - opts, - tmp_bson ("{'keyVaultEndpoint': 'key-vault-csfle.vault.azure.net', " - "'keyName': 'key-name-csfle'}")); - } else if (0 == strcmp (kms_provider, "gcp")) { - mongoc_client_encryption_datakey_opts_set_masterkey ( - opts, - tmp_bson ("{'projectId': 'devprod-drivers','location': " - "'global','keyRing': 'key-ring-csfle','keyName': " - "'key-name-csfle'}")); - } else if (0 == strcmp (kms_provider, "kmip")) { - mongoc_client_encryption_datakey_opts_set_masterkey (opts, - tmp_bson ("{}")); - } - - altname = bson_strdup_printf ("%s_altname", kms_provider); - mongoc_client_encryption_datakey_opts_set_keyaltnames (opts, &altname, 1); - - ret = mongoc_client_encryption_create_datakey ( - client_encryption, kms_provider, opts, &keyid, &error); - ASSERT_OR_PRINT (ret, error); - - /* Expect a BSON binary with subtype 4 to be returned */ - BSON_ASSERT (keyid.value_type == BSON_TYPE_BINARY); - BSON_ASSERT (keyid.value.v_binary.subtype == BSON_SUBTYPE_UUID); - - /* Check that client captured a command_started event for the insert command - * containing a majority writeConcern. */ - assert_match_bson ( - test_ctx->last_cmd, - tmp_bson ("{'insert': 'datakeys', 'writeConcern': { 'w': 'majority' } }"), - false); - - /* Use client to run a find on keyvault.datakeys */ - coll = mongoc_client_get_collection (client, "keyvault", "datakeys"); - bson_init (&filter); - BSON_APPEND_VALUE (&filter, "_id", &keyid); - cursor = mongoc_collection_find_with_opts ( - coll, &filter, NULL /* opts */, NULL /* read prefs */); - mongoc_collection_destroy (coll); - - /* Expect that exactly one document is returned with the "masterKey.provider" - * equal to */ - BSON_ASSERT (mongoc_cursor_next (cursor, &doc)); - BSON_ASSERT ( - 0 == strcmp (kms_provider, bson_lookup_utf8 (doc, "masterKey.provider"))); - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - - /* Call client_encryption.encrypt() with the value "hello " */ - encrypt_opts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - encrypt_opts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); - mongoc_client_encryption_encrypt_opts_set_keyid (encrypt_opts, &keyid); - - hello = bson_strdup_printf ("hello %s", kms_provider); - - { - to_encrypt.value_type = BSON_TYPE_UTF8; - to_encrypt.value.v_utf8.str = bson_strdup (hello); - - const size_t len = strlen (to_encrypt.value.v_utf8.str); - ASSERT (bson_in_range_unsigned (uint32_t, len)); - to_encrypt.value.v_utf8.len = (uint32_t) len; - } - - ret = mongoc_client_encryption_encrypt ( - client_encryption, &to_encrypt, encrypt_opts, &encrypted, &error); - ASSERT_OR_PRINT (ret, error); - mongoc_client_encryption_encrypt_opts_destroy (encrypt_opts); - - /* Expect the return value to be a BSON binary subtype 6 */ - BSON_ASSERT (encrypted.value_type == BSON_TYPE_BINARY); - BSON_ASSERT (encrypted.value.v_binary.subtype == BSON_SUBTYPE_ENCRYPTED); - - /* Use client_encrypted to insert { _id: "", "value": - * } into db.coll */ - coll = mongoc_client_get_collection (client_encrypted, "db", "coll"); - BSON_APPEND_UTF8 (&to_insert, "_id", kms_provider); - BSON_APPEND_VALUE (&to_insert, "value", &encrypted); - ret = mongoc_collection_insert_one ( - coll, &to_insert, NULL /* opts */, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - - /* Use client_encrypted to run a find querying with _id of and - * expect value to be "hello ". */ - cursor = mongoc_collection_find_with_opts ( - coll, - tmp_bson ("{ '_id': '%s' }", kms_provider), - NULL /* opts */, - NULL /* read prefs */); - BSON_ASSERT (mongoc_cursor_next (cursor, &doc)); - BSON_ASSERT (0 == strcmp (hello, bson_lookup_utf8 (doc, "value"))); - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (coll); - - /* Call client_encryption.encrypt() with the value "hello ", - * the algorithm AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic, and the - * key_alt_name of _altname. */ - encrypt_opts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - encrypt_opts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); - mongoc_client_encryption_encrypt_opts_set_keyaltname (encrypt_opts, altname); - - ret = mongoc_client_encryption_encrypt (client_encryption, - &to_encrypt, - encrypt_opts, - &encrypted_via_altname, - &error); - ASSERT_OR_PRINT (ret, error); - mongoc_client_encryption_encrypt_opts_destroy (encrypt_opts); - - /* Expect the return value to be a BSON binary subtype 6. Expect the value to - * exactly match the value of encrypted. */ - BSON_ASSERT (encrypted_via_altname.value_type == BSON_TYPE_BINARY); - BSON_ASSERT (encrypted_via_altname.value.v_binary.subtype == - BSON_SUBTYPE_ENCRYPTED); - BSON_ASSERT (encrypted_via_altname.value.v_binary.data_len == - encrypted.value.v_binary.data_len); - BSON_ASSERT (0 == memcmp (encrypted_via_altname.value.v_binary.data, - encrypted.value.v_binary.data, - encrypted.value.v_binary.data_len)); - - bson_value_destroy (&encrypted); - bson_value_destroy (&encrypted_via_altname); - bson_free (hello); - bson_destroy (&to_insert); - bson_value_destroy (&to_encrypt); - bson_value_destroy (&keyid); - bson_free (altname); - bson_destroy (&filter); - mongoc_client_encryption_datakey_opts_destroy (opts); -} - -/* Prose Test 1: Custom Key Material Test */ -static void -test_create_datakey_with_custom_key_material (void *unused) -{ - mongoc_client_t *client = NULL; - mongoc_client_encryption_t *client_encryption = NULL; - bson_error_t error; - bson_t datakey = BSON_INITIALIZER; - - BSON_UNUSED (unused); - - /* Create a MongoClient object (referred to as client). */ - client = test_framework_new_default_client (); - - /* Using client, drop the collection keyvault.datakeys. */ - { - mongoc_collection_t *const datakeys = - mongoc_client_get_collection (client, "keyvault", "datakeys"); - (void) mongoc_collection_drop (datakeys, NULL); - mongoc_collection_destroy (datakeys); - } - - /* Create a ClientEncryption object (referred to as client_encryption) with - * client set as the keyVaultClient. */ - { - mongoc_client_encryption_opts_t *const client_encryption_opts = - mongoc_client_encryption_opts_new (); - bson_t *const kms_providers = - _make_kms_providers (true /* aws */, true /* local */); - bson_t *const tls_opts = _make_tls_opts (); - - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_tls_opts (client_encryption_opts, - tls_opts); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - client); - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, &error); - ASSERT_OR_PRINT (client_encryption, error); - - mongoc_client_encryption_opts_destroy (client_encryption_opts); - bson_destroy (kms_providers); - bson_destroy (tls_opts); - } - - /* Using client_encryption, create a data key with a local KMS provider and - * the following custom key material: */ - { - const char key_material[] = - "xPTAjBRG5JiPm+d3fj6XLi2q5DMXUS/" - "f1f+SMAlhhwkhDRL0kr8r9GDLIGTAGlvC+HVjSIgdL+" - "RKwZCvpXSyxTICWSXTUYsWYPyu3IoHbuBZdmw2faM3WhcRIgbMReU5"; - uint8_t data[96]; - mongoc_client_encryption_datakey_opts_t *datakey_opts = - mongoc_client_encryption_datakey_opts_new (); - bson_value_t keyid; - - BSON_ASSERT ( - mcommon_b64_pton (key_material, data, sizeof (key_material)) == 96); - - mongoc_client_encryption_datakey_opts_set_keymaterial ( - datakey_opts, data, sizeof (data)); - - ASSERT_OR_PRINT ( - mongoc_client_encryption_create_datakey ( - client_encryption, "local", datakey_opts, &keyid, &error), - error); - - ASSERT (keyid.value_type == BSON_TYPE_BINARY); - ASSERT (keyid.value.v_binary.subtype == BSON_SUBTYPE_UUID); - ASSERT (keyid.value.v_binary.data_len != 0); - - mongoc_client_encryption_datakey_opts_destroy (datakey_opts); - bson_value_destroy (&keyid); - } - - /* Find the resulting key document in keyvault.datakeys, save a copy of the - * key document, then remove the key document from the collection. */ - { - mongoc_collection_t *const datakeys = - mongoc_client_get_collection (client, "keyvault", "datakeys"); - mongoc_cursor_t *cursor = mongoc_collection_find_with_opts ( - datakeys, tmp_bson ("{}"), NULL /* opts */, NULL /* read prefs */); - const bson_t *bson; - - ASSERT (mongoc_cursor_next (cursor, &bson)); - bson_copy_to (bson, &datakey); - mongoc_cursor_destroy (cursor); - - (void) mongoc_collection_drop (datakeys, &error); - mongoc_collection_destroy (datakeys); - } - - /* Replace the _id field in the copied key document with a UUID with base64 - * value AAAAAAAAAAAAAAAAAAAAAA== (16 bytes all equal to 0x00) and insert the - * modified key document into keyvault.datakeys with majority write concern. - */ - { - mongoc_collection_t *const datakeys = - mongoc_client_get_collection (client, "keyvault", "datakeys"); - bson_t modified_datakey = BSON_INITIALIZER; - uint8_t bytes[16] = {0}; - mongoc_write_concern_t *const wc = mongoc_write_concern_new (); - bson_t opts = BSON_INITIALIZER; - - bson_copy_to_excluding_noinit (&datakey, &modified_datakey, "_id", NULL); - BSON_ASSERT (BSON_APPEND_BINARY ( - &modified_datakey, "_id", BSON_SUBTYPE_UUID, bytes, sizeof (bytes))); - - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY); - mongoc_write_concern_append (wc, &opts); - - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - datakeys, &modified_datakey, &opts, NULL, &error), - error); - - mongoc_collection_destroy (datakeys); - bson_destroy (&modified_datakey); - mongoc_write_concern_destroy (wc); - bson_destroy (&opts); - } - - /* Using client_encryption, encrypt the string "test" with the modified data - * key using the AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic algorithm and - * assert the resulting value is equal to the following (given as base64): */ - { - const char expected[] = - "AQAAAAAAAAAAAAAAAAAAAAACz0ZOLuuhEYi807ZXTdhbqhLaS2/" - "t9wLifJnnNYwiw79d75QYIZ6M/aYC1h9nCzCjZ7pGUpAuNnkUhnIXM3PjrA=="; - mongoc_client_encryption_encrypt_opts_t *const encrypt_opts = - mongoc_client_encryption_encrypt_opts_new (); - bson_value_t keyid = {0}; - bson_value_t to_encrypt = {0}; - bson_value_t ciphertext = {0}; - - keyid.value_type = BSON_TYPE_BINARY; - keyid.value.v_binary.subtype = BSON_SUBTYPE_UUID; - keyid.value.v_binary.data = bson_malloc0 (16); - keyid.value.v_binary.data_len = 16u; - - to_encrypt.value_type = BSON_TYPE_UTF8; - to_encrypt.value.v_utf8.str = bson_strdup ("test"); - to_encrypt.value.v_utf8.len = 4u; - - mongoc_client_encryption_encrypt_opts_set_keyid (encrypt_opts, &keyid); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - encrypt_opts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); - ASSERT_OR_PRINT ( - mongoc_client_encryption_encrypt ( - client_encryption, &to_encrypt, encrypt_opts, &ciphertext, &error), - error); - - { - char actual[256]; - - /* Need room for null terminator. */ - ASSERT (mcommon_b64_ntop (ciphertext.value.v_binary.data, - ciphertext.value.v_binary.data_len, - actual, - sizeof (actual)) < 255); - - ASSERT_CMPSTR (expected, actual); - } - - bson_value_destroy (&keyid); - bson_value_destroy (&ciphertext); - bson_value_destroy (&to_encrypt); - mongoc_client_encryption_encrypt_opts_destroy (encrypt_opts); - } - - mongoc_client_destroy (client); - mongoc_client_encryption_destroy (client_encryption); - bson_destroy (&datakey); -} - -/* Prose Test 2: Data Key and Double Encryption */ -static void -test_datakey_and_double_encryption (void *unused) -{ - mongoc_client_t *client; - mongoc_client_t *client_encrypted; - mongoc_client_encryption_t *client_encryption; - mongoc_apm_callbacks_t *callbacks; - mongoc_collection_t *coll; - bson_error_t error; - bson_t *kms_providers; - bson_t *tls_opts; - mongoc_auto_encryption_opts_t *auto_encryption_opts; - mongoc_client_encryption_opts_t *client_encryption_opts; - bson_t *schema_map; - bool ret; - _datakey_and_double_encryption_ctx_t test_ctx = {0}; - - BSON_UNUSED (unused); - - /* Test setup */ - /* Create a MongoClient without encryption enabled (referred to as client). - * Enable command monitoring to listen for command_started events. */ - client = test_framework_new_default_client (); - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb ( - callbacks, _datakey_and_double_encryption_command_started); - mongoc_client_set_apm_callbacks (client, callbacks, &test_ctx); - - /* Using client, drop the collections keyvault.datakeys and db.coll. */ - coll = mongoc_client_get_collection (client, "keyvault", "datakeys"); - (void) mongoc_collection_drop (coll, NULL); - mongoc_collection_destroy (coll); - coll = mongoc_client_get_collection (client, "db", "coll"); - (void) mongoc_collection_drop (coll, NULL); - mongoc_collection_destroy (coll); - - /* Create a MongoClient configured with auto encryption (referred to as - * client_encrypted) */ - auto_encryption_opts = mongoc_auto_encryption_opts_new (); - kms_providers = _make_kms_providers (true /* aws */, true /* local */); - tls_opts = _make_tls_opts (); - _check_bypass (auto_encryption_opts); - mongoc_auto_encryption_opts_set_kms_providers (auto_encryption_opts, - kms_providers); - mongoc_auto_encryption_opts_set_tls_opts (auto_encryption_opts, tls_opts); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - auto_encryption_opts, "keyvault", "datakeys"); - schema_map = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/" - "datakey-and-double-encryption-schemamap.json"); - mongoc_auto_encryption_opts_set_schema_map (auto_encryption_opts, - schema_map); - - client_encrypted = test_framework_new_default_client (); - ret = mongoc_client_enable_auto_encryption ( - client_encrypted, auto_encryption_opts, &error); - ASSERT_OR_PRINT (ret, error); - - /* Create a ClientEncryption object (referred to as client_encryption) */ - client_encryption_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_tls_opts (client_encryption_opts, - tls_opts); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - client); - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, &error); - ASSERT_OR_PRINT (client_encryption, error); - - test_datakey_and_double_encryption_creating_and_using ( - client_encryption, client, client_encrypted, "local", &test_ctx); - test_datakey_and_double_encryption_creating_and_using ( - client_encryption, client, client_encrypted, "aws", &test_ctx); - test_datakey_and_double_encryption_creating_and_using ( - client_encryption, client, client_encrypted, "azure", &test_ctx); - test_datakey_and_double_encryption_creating_and_using ( - client_encryption, client, client_encrypted, "gcp", &test_ctx); - test_datakey_and_double_encryption_creating_and_using ( - client_encryption, client, client_encrypted, "kmip", &test_ctx); - - bson_destroy (kms_providers); - bson_destroy (tls_opts); - bson_destroy (schema_map); - mongoc_client_encryption_opts_destroy (client_encryption_opts); - mongoc_auto_encryption_opts_destroy (auto_encryption_opts); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_client_destroy (client); - mongoc_client_destroy (client_encrypted); - mongoc_client_encryption_destroy (client_encryption); - bson_destroy (test_ctx.last_cmd); -} - -static void -_test_key_vault (bool with_external_key_vault) -{ - mongoc_client_t *client; - mongoc_client_t *client_encrypted; - mongoc_client_t *client_external; - mongoc_client_encryption_t *client_encryption; - mongoc_uri_t *external_uri; - mongoc_collection_t *coll; - bson_t *datakey; - bson_t *kms_providers; - bson_error_t error; - mongoc_write_concern_t *wc; - bson_t *schema; - bson_t *schema_map; - mongoc_auto_encryption_opts_t *auto_encryption_opts; - mongoc_client_encryption_opts_t *client_encryption_opts; - mongoc_client_encryption_encrypt_opts_t *encrypt_opts; - bool res; - const bson_value_t *keyid; - bson_value_t value; - bson_value_t ciphertext; - bson_iter_t iter; - - external_uri = test_framework_get_uri (); - mongoc_uri_set_username (external_uri, "fake-user"); - mongoc_uri_set_password (external_uri, "fake-pwd"); - client_external = test_framework_client_new_from_uri (external_uri, NULL); - test_framework_set_ssl_opts (client_external); - - /* Using client, drop the collections keyvault.datakeys and db.coll. */ - client = test_framework_new_default_client (); - coll = mongoc_client_get_collection (client, "db", "coll"); - (void) mongoc_collection_drop (coll, NULL); - mongoc_collection_destroy (coll); - coll = mongoc_client_get_collection (client, "keyvault", "datakeys"); - (void) mongoc_collection_drop (coll, NULL); - - /* Insert the document external-key.json into ``keyvault.datakeys``. */ - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_wmajority (wc, 1000); - mongoc_collection_set_write_concern (coll, wc); - datakey = get_bson_from_json_file ("./src/libmongoc/tests/" - "client_side_encryption_prose/external/" - "external-key.json"); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, datakey, NULL, NULL, &error), error); - mongoc_collection_destroy (coll); - - /* Create a MongoClient configured with auto encryption. */ - client_encrypted = test_framework_new_default_client (); - mongoc_client_set_error_api (client_encrypted, MONGOC_ERROR_API_VERSION_2); - auto_encryption_opts = mongoc_auto_encryption_opts_new (); - _check_bypass (auto_encryption_opts); - schema = get_bson_from_json_file ("./src/libmongoc/tests/" - "client_side_encryption_prose/external/" - "external-schema.json"); - schema_map = BCON_NEW ("db.coll", BCON_DOCUMENT (schema)); - kms_providers = _make_kms_providers (false /* aws */, true /* local */); - mongoc_auto_encryption_opts_set_kms_providers (auto_encryption_opts, - kms_providers); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - auto_encryption_opts, "keyvault", "datakeys"); - mongoc_auto_encryption_opts_set_schema_map (auto_encryption_opts, - schema_map); - if (with_external_key_vault) { - mongoc_auto_encryption_opts_set_keyvault_client (auto_encryption_opts, - client_external); - } - ASSERT_OR_PRINT (mongoc_client_enable_auto_encryption ( - client_encrypted, auto_encryption_opts, &error), - error); - - /* Create a ClientEncryption object. */ - client_encryption_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, "keyvault", "datakeys"); - if (with_external_key_vault) { - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - client_external); - } else { - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - client); - } - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, &error); - ASSERT_OR_PRINT (client_encryption, error); - - /* Use client_encrypted to insert the document {"encrypted": "test"} into - * db.coll. */ - coll = mongoc_client_get_collection (client_encrypted, "db", "coll"); - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'encrypted': 'test'}"), NULL, NULL, &error); - if (with_external_key_vault) { - BSON_ASSERT (!res); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Authentication failed"); - } else { - ASSERT_OR_PRINT (res, error); - } - - /* Use client_encryption to explicitly encrypt the string "test" with key ID - * ``LOCALAAAAAAAAAAAAAAAAA==`` and deterministic algorithm. */ - encrypt_opts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - encrypt_opts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); - BSON_ASSERT (bson_iter_init_find (&iter, datakey, "_id")); - keyid = bson_iter_value (&iter); - mongoc_client_encryption_encrypt_opts_set_keyid (encrypt_opts, keyid); - value.value_type = BSON_TYPE_UTF8; - value.value.v_utf8.str = "test"; - value.value.v_utf8.len = 4; - res = mongoc_client_encryption_encrypt ( - client_encryption, &value, encrypt_opts, &ciphertext, &error); - if (with_external_key_vault) { - BSON_ASSERT (!res); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Authentication failed"); - } else { - ASSERT_OR_PRINT (res, error); - } - - bson_destroy (schema); - bson_destroy (schema_map); - bson_destroy (datakey); - bson_value_destroy (&ciphertext); - mongoc_write_concern_destroy (wc); - bson_destroy (kms_providers); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mongoc_client_destroy (client_encrypted); - mongoc_client_destroy (client_external); - mongoc_uri_destroy (external_uri); - mongoc_auto_encryption_opts_destroy (auto_encryption_opts); - mongoc_client_encryption_opts_destroy (client_encryption_opts); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_encrypt_opts_destroy (encrypt_opts); -} - -/* Prose Test 3: External Key Vault Test */ -static void -test_external_key_vault (void *unused) -{ - BSON_UNUSED (unused); - - _test_key_vault (false /* external */); - _test_key_vault (true /* external */); -} - -/* Prose Test 5: Views Are Prohibited */ -static void -test_views_are_prohibited (void *unused) -{ - mongoc_client_t *client; - mongoc_client_t *client_encrypted; - mongoc_collection_t *coll; - bool res; - bson_error_t error; - - mongoc_auto_encryption_opts_t *auto_encryption_opts; - bson_t *kms_providers; - - BSON_UNUSED (unused); - - client = test_framework_new_default_client (); - - /* Using client, drop and create a view named db.view with an empty pipeline. - * E.g. using the command { "create": "view", "viewOn": "coll" }. */ - coll = mongoc_client_get_collection (client, "db", "view"); - (void) mongoc_collection_drop (coll, NULL); - res = mongoc_client_command_simple ( - client, - "db", - tmp_bson ("{'create': 'view', 'viewOn': 'coll'}"), - NULL, - NULL, - &error); - ASSERT_OR_PRINT (res, error); - - client_encrypted = test_framework_new_default_client (); - auto_encryption_opts = mongoc_auto_encryption_opts_new (); - _check_bypass (auto_encryption_opts); - kms_providers = _make_kms_providers (false /* aws */, true /* local */); - mongoc_auto_encryption_opts_set_kms_providers (auto_encryption_opts, - kms_providers); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - auto_encryption_opts, "keyvault", "datakeys"); - ASSERT_OR_PRINT (mongoc_client_enable_auto_encryption ( - client_encrypted, auto_encryption_opts, &error), - error); - - mongoc_collection_destroy (coll); - coll = mongoc_client_get_collection (client_encrypted, "db", "view"); - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'x': 1}"), NULL, NULL, &error); - BSON_ASSERT (!res); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - 1, - "cannot auto encrypt a view"); - - bson_destroy (kms_providers); - mongoc_collection_destroy (coll); - mongoc_auto_encryption_opts_destroy (auto_encryption_opts); - mongoc_client_destroy (client_encrypted); - mongoc_client_destroy (client); -} - -static void -_endpoint_setup (mongoc_client_t *keyvault_client, - mongoc_client_encryption_t **client_encryption, - mongoc_client_encryption_t **client_encryption_invalid) -{ - bson_t *tls_opts; - bson_t *kms_providers; - bson_t *kms_providers_invalid; - mongoc_client_encryption_opts_t *client_encryption_opts; - mongoc_client_encryption_opts_t *client_encryption_opts_invalid; - bson_error_t error; - - ASSERT (keyvault_client); - - char *mongoc_test_aws_access_key_id = - test_framework_getenv_required ("MONGOC_TEST_AWS_ACCESS_KEY_ID"); - char *mongoc_test_aws_secret_access_key = - test_framework_getenv_required ("MONGOC_TEST_AWS_SECRET_ACCESS_KEY"); - char *mongoc_test_azure_tenant_id = - test_framework_getenv_required ("MONGOC_TEST_AZURE_TENANT_ID"); - char *mongoc_test_azure_client_id = - test_framework_getenv_required ("MONGOC_TEST_AZURE_CLIENT_ID"); - char *mongoc_test_azure_client_secret = - test_framework_getenv_required ("MONGOC_TEST_AZURE_CLIENT_SECRET"); - char *mongoc_test_gcp_email = - test_framework_getenv_required ("MONGOC_TEST_GCP_EMAIL"); - char *mongoc_test_gcp_privatekey = - test_framework_getenv_required ("MONGOC_TEST_GCP_PRIVATEKEY"); - char *ca_file = - test_framework_getenv_required ("MONGOC_TEST_CSFLE_TLS_CA_FILE"); - char *certificate_key_file = test_framework_getenv_required ( - "MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE"); - - - kms_providers = - tmp_bson ("{'aws': {'accessKeyId': '%s', 'secretAccessKey': '%s'}}", - mongoc_test_aws_access_key_id, - mongoc_test_aws_secret_access_key); - bson_concat ( - kms_providers, - tmp_bson ( - "{'azure': {'tenantId': '%s', 'clientId': '%s', 'clientSecret': '%s', " - "'identityPlatformEndpoint': 'login.microsoftonline.com:443'}}", - mongoc_test_azure_tenant_id, - mongoc_test_azure_client_id, - mongoc_test_azure_client_secret)); - bson_concat (kms_providers, - tmp_bson ("{'gcp': { 'email': '%s', 'privateKey': '%s', " - "'endpoint': 'oauth2.googleapis.com:443'}}", - mongoc_test_gcp_email, - mongoc_test_gcp_privatekey)); - bson_concat (kms_providers, - tmp_bson ("{'kmip': { 'endpoint': 'localhost:5698' }}")); - tls_opts = tmp_bson ( - "{'kmip': { 'tlsCAFile': '%s', 'tlsCertificateKeyFile': '%s' }}", - ca_file, - certificate_key_file); - - kms_providers_invalid = - tmp_bson ("{'aws': {'accessKeyId': '%s', 'secretAccessKey': '%s'}}", - mongoc_test_aws_access_key_id, - mongoc_test_aws_secret_access_key); - bson_concat ( - kms_providers_invalid, - tmp_bson ( - "{'azure': {'tenantId': '%s', 'clientId': '%s', 'clientSecret': '%s', " - "'identityPlatformEndpoint': 'doesnotexist.invalid:443'}}", - mongoc_test_azure_tenant_id, - mongoc_test_azure_client_id, - mongoc_test_azure_client_secret)); - bson_concat (kms_providers_invalid, - tmp_bson ("{'gcp': { 'email': '%s', 'privateKey': '%s', " - "'endpoint': 'doesnotexist.invalid'}}", - mongoc_test_gcp_email, - mongoc_test_gcp_privatekey)); - bson_concat ( - kms_providers_invalid, - tmp_bson ("{'kmip': { 'endpoint': 'doesnotexist.local:5698' }}")); - - client_encryption_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_tls_opts (client_encryption_opts, - tls_opts); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - keyvault_client); - *client_encryption = - mongoc_client_encryption_new (client_encryption_opts, &error); - ASSERT_OR_PRINT (client_encryption, error); - - client_encryption_opts_invalid = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers ( - client_encryption_opts_invalid, kms_providers_invalid); - mongoc_client_encryption_opts_set_tls_opts (client_encryption_opts_invalid, - tls_opts); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts_invalid, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client ( - client_encryption_opts_invalid, keyvault_client); - *client_encryption_invalid = - mongoc_client_encryption_new (client_encryption_opts_invalid, &error); - ASSERT_OR_PRINT (client_encryption_invalid, error); - - mongoc_client_encryption_opts_destroy (client_encryption_opts); - mongoc_client_encryption_opts_destroy (client_encryption_opts_invalid); - bson_free (mongoc_test_aws_access_key_id); - bson_free (mongoc_test_aws_secret_access_key); - bson_free (mongoc_test_azure_tenant_id); - bson_free (mongoc_test_azure_client_id); - bson_free (mongoc_test_azure_client_secret); - bson_free (mongoc_test_gcp_email); - bson_free (mongoc_test_gcp_privatekey); - bson_free (ca_file); - bson_free (certificate_key_file); -} - -/* Use the returned UUID of the key to explicitly encrypt and decrypt the - * string "test" to validate it works. */ -#define TEST_ENCRYPT_DECRYPT(keyid, client_encryption, res, error) \ - do { \ - bson_value_t ciphertext; \ - bson_value_t plaintext; \ - bson_value_t test; \ - mongoc_client_encryption_encrypt_opts_t *encrypt_opts; \ - \ - test.value_type = BSON_TYPE_UTF8; \ - test.value.v_utf8.str = "test"; \ - test.value.v_utf8.len = 4; \ - \ - encrypt_opts = mongoc_client_encryption_encrypt_opts_new (); \ - mongoc_client_encryption_encrypt_opts_set_algorithm ( \ - encrypt_opts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); \ - mongoc_client_encryption_encrypt_opts_set_keyid (encrypt_opts, keyid); \ - res = mongoc_client_encryption_encrypt ( \ - client_encryption, &test, encrypt_opts, &ciphertext, &error); \ - ASSERT_OR_PRINT (res, error); \ - res = mongoc_client_encryption_decrypt ( \ - client_encryption, &ciphertext, &plaintext, &error); \ - ASSERT_OR_PRINT (res, error); \ - if (plaintext.value_type != BSON_TYPE_UTF8) { \ - test_error ( \ - "expected decrypted result to be value type UTF-8, got %s", \ - _mongoc_bson_type_to_str (plaintext.value_type)); \ - } \ - ASSERT_CMPSTR (plaintext.value.v_utf8.str, test.value.v_utf8.str); \ - bson_value_destroy (&ciphertext); \ - bson_value_destroy (&plaintext); \ - mongoc_client_encryption_encrypt_opts_destroy (encrypt_opts); \ - } while (0) - -/* Prose Test 7: Custom Endpoint Test */ -static void -test_custom_endpoint (void *unused) -{ - mongoc_client_t *keyvault_client; - mongoc_client_encryption_t *client_encryption = NULL; - mongoc_client_encryption_t *client_encryption_invalid = NULL; - mongoc_client_encryption_datakey_opts_t *datakey_opts; - bson_error_t error; - bool res; - bson_t *masterkey; - bson_value_t keyid; - - BSON_UNUSED (unused); - - keyvault_client = test_framework_new_default_client (); - - datakey_opts = mongoc_client_encryption_datakey_opts_new (); - - /* Case 1: No endpoint, expect to succeed. */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("region", - "us-east-1", - "key", - "arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "aws", datakey_opts, &keyid, &error); - ASSERT_OR_PRINT (res, error); - - TEST_ENCRYPT_DECRYPT (&keyid, client_encryption, res, error); - bson_value_destroy (&keyid); - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 2: Custom endpoint, with the same as the default. Expect to succeed - */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("region", - "us-east-1", - "key", - "arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0", - "endpoint", - "kms.us-east-1.amazonaws.com"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "aws", datakey_opts, &keyid, &error); - ASSERT_OR_PRINT (res, error); - - TEST_ENCRYPT_DECRYPT (&keyid, client_encryption, res, error); - bson_value_destroy (&keyid); - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 3: Custom endpoint, with the same as the default but port included. - * Expect to succeed */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("region", - "us-east-1", - "key", - "arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0", - "endpoint", - "kms.us-east-1.amazonaws.com:443"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "aws", datakey_opts, &keyid, &error); - ASSERT_OR_PRINT (res, error); - - TEST_ENCRYPT_DECRYPT (&keyid, client_encryption, res, error); - bson_value_destroy (&keyid); - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 4: Custom endpoint, with the same as the default but wrong port - * included. - * Expect to fail with socket error */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("region", - "us-east-1", - "key", - "arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0", - "endpoint", - "kms.us-east-1.amazonaws.com:12345"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "aws", datakey_opts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "Failed to connect"); - BSON_ASSERT (!res); - bson_value_destroy (&keyid); - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 5: Custom endpoint, but wrong region. */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("region", - "us-east-1", - "key", - "arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0", - "endpoint", - "kms.us-east-2.amazonaws.com"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - memset (&error, 0, sizeof (bson_error_t)); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "aws", datakey_opts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, 1, ""); - BSON_ASSERT (!res); - bson_value_destroy (&keyid); - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 6: Custom endpoint to doesnotexist.invalid. */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("region", - "us-east-1", - "key", - "arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0", - "endpoint", - "doesnotexist.invalid"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - memset (&error, 0, sizeof (bson_error_t)); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "aws", datakey_opts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "Failed to resolve"); - BSON_ASSERT (!res); - bson_value_destroy (&keyid); - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 7: Azure successful case */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("keyVaultEndpoint", - "key-vault-csfle.vault.azure.net", - "keyName", - "key-name-csfle"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "azure", datakey_opts, &keyid, &error); - ASSERT_OR_PRINT (res, error); - - TEST_ENCRYPT_DECRYPT (&keyid, client_encryption, res, error); - bson_value_destroy (&keyid); - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Azure invalid case. */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - res = mongoc_client_encryption_create_datakey ( - client_encryption_invalid, "azure", datakey_opts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "Failed to resolve"); - BSON_ASSERT (!res); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 8: GCP successful case. */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("projectId", - "devprod-drivers", - "location", - "global", - "keyRing", - "key-ring-csfle", - "keyName", - "key-name-csfle", - "endpoint", - "cloudkms.googleapis.com:443"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "gcp", datakey_opts, &keyid, &error); - ASSERT_OR_PRINT (res, error); - - TEST_ENCRYPT_DECRYPT (&keyid, client_encryption, res, error); - bson_value_destroy (&keyid); - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* GCP invalid case. */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - res = mongoc_client_encryption_create_datakey ( - client_encryption_invalid, "gcp", datakey_opts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "Failed to resolve"); - BSON_ASSERT (!res); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 9: GCP invalid key endpoint. */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("projectId", - "devprod-drivers", - "location", - "global", - "keyRing", - "key-ring-csfle", - "keyName", - "key-name-csfle", - "endpoint", - "doesnotexist.invalid:443"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "gcp", datakey_opts, &keyid, &error); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, 1, "Invalid KMS response"); - BSON_ASSERT (!res); - - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 10: KMIP no endpoint. */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("keyId", "1"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "kmip", datakey_opts, &keyid, &error); - ASSERT_OR_PRINT (res, error); - - TEST_ENCRYPT_DECRYPT (&keyid, client_encryption, res, error); - bson_value_destroy (&keyid); - - /* Attempt to use client_encryption_invalid with the same masterKey. Expect - * an error. */ - res = mongoc_client_encryption_create_datakey ( - client_encryption_invalid, "kmip", datakey_opts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "Failed to resolve"); - BSON_ASSERT (!res); - bson_value_destroy (&keyid); - - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 11: KMIP overriding with valid endpoint. */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("keyId", "1", "endpoint", "localhost:5698"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "kmip", datakey_opts, &keyid, &error); - ASSERT_OR_PRINT (res, error); - - TEST_ENCRYPT_DECRYPT (&keyid, client_encryption, res, error); - bson_value_destroy (&keyid); - - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - /* Case 12: KMIP overriding with invalid endpoint. */ - _endpoint_setup ( - keyvault_client, &client_encryption, &client_encryption_invalid); - masterkey = BCON_NEW ("keyId", "1", "endpoint", "doesnotexist.local:5698"); - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - masterkey); - res = mongoc_client_encryption_create_datakey ( - client_encryption, "kmip", datakey_opts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "Failed to resolve"); - BSON_ASSERT (!res); - bson_value_destroy (&keyid); - - bson_destroy (masterkey); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_encryption_destroy (client_encryption_invalid); - - mongoc_client_encryption_datakey_opts_destroy (datakey_opts); - mongoc_client_destroy (keyvault_client); -} - -typedef struct { - const char *kms; - const char *type; - const char *algo; - const char *method; - const char *identifier; - bool allowed; - bson_value_t value; /* a copy */ -} corpus_field_t; - -static corpus_field_t * -_corpus_field_new (bson_iter_t *top_iter) -{ - bson_iter_t iter; - corpus_field_t *field; - - field = bson_malloc0 (sizeof (corpus_field_t)); - memset (field, 0, sizeof (*field)); - BSON_ASSERT (BSON_ITER_HOLDS_DOCUMENT (top_iter)); - bson_iter_recurse (top_iter, &iter); - while (bson_iter_next (&iter)) { - if (0 == strcmp ("kms", bson_iter_key (&iter))) { - field->kms = bson_iter_utf8 (&iter, NULL); - } else if (0 == strcmp ("type", bson_iter_key (&iter))) { - field->type = bson_iter_utf8 (&iter, NULL); - } else if (0 == strcmp ("algo", bson_iter_key (&iter))) { - field->algo = bson_iter_utf8 (&iter, NULL); - } else if (0 == strcmp ("method", bson_iter_key (&iter))) { - field->method = bson_iter_utf8 (&iter, NULL); - } else if (0 == strcmp ("identifier", bson_iter_key (&iter))) { - field->identifier = bson_iter_utf8 (&iter, NULL); - } else if (0 == strcmp ("allowed", bson_iter_key (&iter))) { - field->allowed = bson_iter_bool (&iter); - } else if (0 == strcmp ("value", bson_iter_key (&iter))) { - bson_value_copy (bson_iter_value (&iter), &field->value); - } else { - fprintf (stderr, "unexpected field: %s\n", bson_iter_key (&iter)); - BSON_ASSERT (false); - } - } - return field; -} - -static void -_corpus_field_destroy (corpus_field_t *field) -{ - if (!field) { - return; - } - bson_value_destroy (&field->value); - bson_free (field); -} - -#define LOCAL_UUID \ - "\x2c\xe0\x80\x2c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" -#define AWS_UUID \ - "\x01\x64\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" -#define AZURE_UUID \ - "\x01\x95\x11\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" -#define GCP_UUID \ - "\x18\x23\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" -#define KMIP_UUID \ - "\x28\xc2\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" - -static void -_corpus_copy_field (mongoc_client_encryption_t *client_encryption, - bson_iter_t *iter, - bson_t *corpus_copied) -{ - corpus_field_t *field; - const char *key = bson_iter_key (iter); - mongoc_client_encryption_encrypt_opts_t *encrypt_opts; - bson_value_t ciphertext; - bool res; - bson_error_t error; - - if (0 == strcmp ("_id", key) || 0 == strcmp ("altname_aws", key) || - 0 == strcmp ("altname_local", key) || - 0 == strcmp ("altname_azure", key) || 0 == strcmp ("altname_gcp", key) || - 0 == strcmp ("altname_kmip", key)) { - bson_append_value (corpus_copied, key, -1, bson_iter_value (iter)); - return; - } - field = _corpus_field_new (iter); - - if (0 == strcmp ("auto", field->method)) { - bson_append_value (corpus_copied, key, -1, bson_iter_value (iter)); - _corpus_field_destroy (field); - return; - } - - /* Otherwise, use explicit encryption. */ - encrypt_opts = mongoc_client_encryption_encrypt_opts_new (); - if (0 == strcmp ("rand", field->algo)) { - mongoc_client_encryption_encrypt_opts_set_algorithm ( - encrypt_opts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM); - } else if (0 == strcmp ("det", field->algo)) { - mongoc_client_encryption_encrypt_opts_set_algorithm ( - encrypt_opts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); - } - - if (0 == strcmp ("id", field->identifier)) { - bson_value_t uuid; - uuid.value_type = BSON_TYPE_BINARY; - uuid.value.v_binary.subtype = BSON_SUBTYPE_UUID; - uuid.value.v_binary.data_len = 16; - if (0 == strcmp ("local", field->kms)) { - uuid.value.v_binary.data = (uint8_t *) LOCAL_UUID; - } else if (0 == strcmp ("aws", field->kms)) { - uuid.value.v_binary.data = (uint8_t *) AWS_UUID; - } else if (0 == strcmp ("azure", field->kms)) { - uuid.value.v_binary.data = (uint8_t *) AZURE_UUID; - } else if (0 == strcmp ("gcp", field->kms)) { - uuid.value.v_binary.data = (uint8_t *) GCP_UUID; - } else if (0 == strcmp ("kmip", field->kms)) { - uuid.value.v_binary.data = (uint8_t *) KMIP_UUID; - } - mongoc_client_encryption_encrypt_opts_set_keyid (encrypt_opts, &uuid); - } else if (0 == strcmp ("altname", field->identifier)) { - mongoc_client_encryption_encrypt_opts_set_keyaltname (encrypt_opts, - field->kms); - } - - res = mongoc_client_encryption_encrypt ( - client_encryption, &field->value, encrypt_opts, &ciphertext, &error); - - if (field->allowed) { - bson_t new_field; - ASSERT_OR_PRINT (res, error); - bson_append_document_begin (corpus_copied, key, -1, &new_field); - BSON_APPEND_UTF8 (&new_field, "kms", field->kms); - BSON_APPEND_UTF8 (&new_field, "type", field->type); - BSON_APPEND_UTF8 (&new_field, "algo", field->algo); - BSON_APPEND_UTF8 (&new_field, "method", field->method); - BSON_APPEND_UTF8 (&new_field, "identifier", field->identifier); - BSON_APPEND_BOOL (&new_field, "allowed", field->allowed); - BSON_APPEND_VALUE (&new_field, "value", &ciphertext); - bson_append_document_end (corpus_copied, &new_field); - } else { - BSON_ASSERT (!res); - bson_append_value (corpus_copied, key, -1, bson_iter_value (iter)); - } - - bson_value_destroy (&ciphertext); - mongoc_client_encryption_encrypt_opts_destroy (encrypt_opts); - _corpus_field_destroy (field); -} - -static void -_corpus_check_encrypted (mongoc_client_encryption_t *client_encryption, - bson_iter_t *expected_iter, - bson_iter_t *actual_iter) -{ - corpus_field_t *expected; - corpus_field_t *actual; - const char *key; - bson_error_t error; - match_ctx_t match_ctx; - - memset (&match_ctx, 0, sizeof (match_ctx)); - key = bson_iter_key (expected_iter); - if (0 == strcmp ("_id", key) || 0 == strcmp ("altname_aws", key) || - 0 == strcmp ("altname_local", key) || - 0 == strcmp ("altname_azure", key) || 0 == strcmp ("altname_gcp", key) || - 0 == strcmp ("altname_kmip", key)) { - return; - } - - expected = _corpus_field_new (expected_iter); - actual = _corpus_field_new (actual_iter); - - /* If the algo is det, that the value equals the value of the corresponding - * field - * in corpus_encrypted_actual. - */ - if (0 == strcmp (expected->algo, "det")) { - BSON_ASSERT ( - match_bson_value (&expected->value, &actual->value, &match_ctx)); - } - - /* If the algo is rand and allowed is true, that the value does not equal the - * value of the corresponding field in corpus_encrypted_actual. */ - if (0 == strcmp (expected->algo, "rand") && expected->allowed) { - BSON_ASSERT ( - !match_bson_value (&expected->value, &actual->value, &match_ctx)); - } - - /* If allowed is true, decrypt the value with client_encryption. Decrypt the - * value of the corresponding field of corpus_encrypted and validate that - * they are both equal */ - if (expected->allowed) { - bson_value_t expected_decrypted; - bson_value_t actual_decrypted; - bool res; - - res = mongoc_client_encryption_decrypt ( - client_encryption, &expected->value, &expected_decrypted, &error); - ASSERT_OR_PRINT (res, error); - - res = mongoc_client_encryption_decrypt ( - client_encryption, &actual->value, &actual_decrypted, &error); - ASSERT_OR_PRINT (res, error); - - BSON_ASSERT ( - match_bson_value (&expected_decrypted, &actual_decrypted, &match_ctx)); - bson_value_destroy (&expected_decrypted); - bson_value_destroy (&actual_decrypted); - } - - /* If allowed is false, validate the value exactly equals the value of the - * corresponding field of corpus (neither was encrypted). */ - if (!expected->allowed) { - BSON_ASSERT ( - match_bson_value (&expected->value, &actual->value, &match_ctx)); - } - - _corpus_field_destroy (expected); - _corpus_field_destroy (actual); -} - -static void -_insert_from_file (mongoc_collection_t *coll, char *path) -{ - bson_t *datakey; - bool res; - bson_error_t error; - - datakey = get_bson_from_json_file (path); - res = mongoc_collection_insert_one (coll, datakey, NULL, NULL, &error); - ASSERT_OR_PRINT (res, error); - bson_destroy (datakey); -} - -static void -_test_corpus (bool local_schema) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_t *schema; - bson_t *create_cmd; - bool res; - bson_error_t error; - mongoc_write_concern_t *wc; - mongoc_client_t *client_encrypted; - mongoc_auto_encryption_opts_t *auto_encryption_opts; - bson_t *kms_providers; - mongoc_client_encryption_t *client_encryption; - mongoc_client_encryption_opts_t *client_encryption_opts; - bson_t *corpus; - bson_t corpus_copied; - const bson_t *corpus_decrypted; - bson_t *corpus_encrypted_expected; - const bson_t *corpus_encrypted_actual; - bson_iter_t iter; - mongoc_cursor_t *cursor; - bson_t *schema_map; - bson_t *tls_opts; - - /* Create a MongoClient without encryption enabled */ - client = test_framework_new_default_client (); - coll = mongoc_client_get_collection (client, "db", "coll"); - (void) mongoc_collection_drop (coll, NULL); - schema = get_bson_from_json_file ("./src/libmongoc/tests/" - "client_side_encryption_prose/corpus/" - "corpus-schema.json"); - schema_map = BCON_NEW ("db.coll", BCON_DOCUMENT (schema)); - create_cmd = BCON_NEW ("create", - "coll", - "validator", - "{", - "$jsonSchema", - BCON_DOCUMENT (schema), - "}"); - - if (!local_schema) { - /* Drop and create the collection db.coll configured with the included - * JSON schema corpus-schema.json */ - res = mongoc_client_command_simple ( - client, "db", create_cmd, NULL, NULL, &error); - ASSERT_OR_PRINT (res, error); - } - - /* Drop the collection keyvault.datakeys. Insert the key documents for each - * KMS provider. */ - mongoc_collection_destroy (coll); - coll = mongoc_client_get_collection (client, "keyvault", "datakeys"); - (void) mongoc_collection_drop (coll, NULL); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_wmajority (wc, 1000); - mongoc_collection_set_write_concern (coll, wc); - _insert_from_file (coll, - "./src/libmongoc/tests/client_side_encryption_prose/" - "corpus/corpus-key-aws.json"); - _insert_from_file (coll, - "./src/libmongoc/tests/client_side_encryption_prose/" - "corpus/corpus-key-azure.json"); - _insert_from_file (coll, - "./src/libmongoc/tests/client_side_encryption_prose/" - "corpus/corpus-key-gcp.json"); - _insert_from_file (coll, - "./src/libmongoc/tests/client_side_encryption_prose/" - "corpus/corpus-key-local.json"); - _insert_from_file (coll, - "./src/libmongoc/tests/client_side_encryption_prose/" - "corpus/corpus-key-kmip.json"); - - /* Create a MongoClient configured with auto encryption */ - client_encrypted = test_framework_new_default_client (); - auto_encryption_opts = mongoc_auto_encryption_opts_new (); - mongoc_auto_encryption_opts_set_schema_map (auto_encryption_opts, - schema_map); - _check_bypass (auto_encryption_opts); - kms_providers = _make_kms_providers (true /* aws */, true /* local */); - mongoc_auto_encryption_opts_set_kms_providers (auto_encryption_opts, - kms_providers); - tls_opts = _make_tls_opts (); - mongoc_auto_encryption_opts_set_tls_opts (auto_encryption_opts, tls_opts); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - auto_encryption_opts, "keyvault", "datakeys"); - res = mongoc_client_enable_auto_encryption ( - client_encrypted, auto_encryption_opts, &error); - ASSERT_OR_PRINT (res, error); - - /* Create a ClientEncryption object */ - client_encryption_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_tls_opts (client_encryption_opts, - tls_opts); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - client); - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, &error); - ASSERT_OR_PRINT (client_encryption, error); - - corpus = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/corpus/corpus.json"); - - /* Try each field individually */ - bson_iter_init (&iter, corpus); - bson_init (&corpus_copied); - while (bson_iter_next (&iter)) { - _corpus_copy_field (client_encryption, &iter, &corpus_copied); - } - - /* Insert corpus_copied with auto encryption */ - mongoc_collection_destroy (coll); - coll = mongoc_client_get_collection (client_encrypted, "db", "coll"); - res = - mongoc_collection_insert_one (coll, &corpus_copied, NULL, NULL, &error); - ASSERT_OR_PRINT (res, error); - - /* Get the automatically decrypted corpus */ - cursor = - mongoc_collection_find_with_opts (coll, tmp_bson ("{}"), NULL, NULL); - BSON_ASSERT (mongoc_cursor_next (cursor, &corpus_decrypted)); - - /* It should exactly match corpus. match_bson does a subset match, so match - * in both directions */ - assert_match_bson (corpus, corpus_decrypted, false); - assert_match_bson (corpus_decrypted, corpus, false); - mongoc_cursor_destroy (cursor); - - /* Load corpus-encrypted.json */ - corpus_encrypted_expected = - get_bson_from_json_file ("./src/libmongoc/tests/" - "client_side_encryption_prose/" - "corpus/corpus-encrypted.json"); - /* Get the actual encrypted document from unencrypted client */ - mongoc_collection_destroy (coll); - coll = mongoc_client_get_collection (client, "db", "coll"); - cursor = - mongoc_collection_find_with_opts (coll, tmp_bson ("{}"), NULL, NULL); - BSON_ASSERT (mongoc_cursor_next (cursor, &corpus_encrypted_actual)); - - /* Iterate over corpus_encrypted_expected, and check corpus_encrypted_actual - */ - bson_iter_init (&iter, corpus_encrypted_expected); - while (bson_iter_next (&iter)) { - bson_iter_t actual_iter; - - BSON_ASSERT (bson_iter_init_find ( - &actual_iter, corpus_encrypted_actual, bson_iter_key (&iter))); - _corpus_check_encrypted (client_encryption, &iter, &actual_iter); - } - - mongoc_cursor_destroy (cursor); - bson_destroy (corpus_encrypted_expected); - bson_destroy (corpus); - bson_destroy (&corpus_copied); - mongoc_auto_encryption_opts_destroy (auto_encryption_opts); - mongoc_client_destroy (client_encrypted); - mongoc_client_encryption_opts_destroy (client_encryption_opts); - mongoc_client_encryption_destroy (client_encryption); - bson_destroy (tls_opts); - bson_destroy (kms_providers); - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (coll); - bson_destroy (schema); - bson_destroy (schema_map); - bson_destroy (create_cmd); - mongoc_client_destroy (client); -} - -/* Prose Test 6: Corpus Test */ -static void -test_corpus (void *unused) -{ - BSON_UNUSED (unused); - - _test_corpus (false /* local schema */); - _test_corpus (true /* local schema */); -} - -/* Begin C driver specific, non-spec tests: */ -static void -_reset (mongoc_client_pool_t **pool, - mongoc_client_t **singled_threaded_client, - mongoc_client_t **multi_threaded_client, - mongoc_auto_encryption_opts_t **opts, - bool recreate) -{ - bson_t *kms_providers; - mongoc_uri_t *uri; - bson_t *schema; - bson_t *schema_map; - - ASSERT (pool); - - mongoc_auto_encryption_opts_destroy (*opts); - *opts = mongoc_auto_encryption_opts_new (); - { - bson_t extra = BSON_INITIALIZER; - _set_extra_bypass (&extra); - _set_extra_crypt_shared (&extra); - mongoc_auto_encryption_opts_set_extra (*opts, &extra); - bson_destroy (&extra); - } - mongoc_auto_encryption_opts_set_keyvault_namespace (*opts, "db", "keyvault"); - kms_providers = _make_kms_providers (false /* aws */, true /* local */); - mongoc_auto_encryption_opts_set_kms_providers (*opts, kms_providers); - schema = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/schema.json"); - BSON_ASSERT (schema); - schema_map = BCON_NEW ("db.coll", BCON_DOCUMENT (schema)); - mongoc_auto_encryption_opts_set_schema_map (*opts, schema_map); - - if (*multi_threaded_client) { - mongoc_client_pool_push (*pool, *multi_threaded_client); - } - - mongoc_client_destroy (*singled_threaded_client); - /* Workaround to hide unnecessary logs per CDRIVER-3322 */ - capture_logs (true); - mongoc_client_pool_destroy (*pool); - capture_logs (false); - - if (recreate) { - mongoc_collection_t *coll; - bson_t *datakey; - bson_error_t error; - mongoc_write_concern_t *wc; - - uri = test_framework_get_uri (); - *pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (*pool); - *singled_threaded_client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (*singled_threaded_client); - *multi_threaded_client = mongoc_client_pool_pop (*pool); - mongoc_uri_destroy (uri); - - /* create key */ - coll = mongoc_client_get_collection ( - *singled_threaded_client, "db", "keyvault"); - (void) mongoc_collection_drop (coll, NULL); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_wmajority (wc, 1000); - mongoc_collection_set_write_concern (coll, wc); - datakey = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/limits-key.json"); - BSON_ASSERT (datakey); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one ( - coll, datakey, NULL /* opts */, NULL /* reply */, &error), - error); - - bson_destroy (datakey); - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (coll); - } - bson_destroy (schema); - bson_destroy (schema_map); - bson_destroy (kms_providers); -} - -static void -_perform_op (mongoc_client_t *client_encrypted) -{ - bool ret; - bson_error_t error; - mongoc_collection_t *coll; - - ASSERT (client_encrypted); - - coll = mongoc_client_get_collection (client_encrypted, "db", "coll"); - ret = mongoc_collection_insert_one (coll, - tmp_bson ("{'encrypted_string': 'abc'}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - mongoc_collection_destroy (coll); -} - -static void -_perform_op_pooled (mongoc_client_pool_t *client_pool_encrypted) -{ - mongoc_client_t *client_encrypted; - - ASSERT (client_pool_encrypted); - - client_encrypted = mongoc_client_pool_pop (client_pool_encrypted); - _perform_op (client_encrypted); - mongoc_client_pool_push (client_pool_encrypted, client_encrypted); -} - -static void -test_invalid_single_and_pool_mismatches (void *unused) -{ - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *single_threaded_client = NULL; - mongoc_client_t *multi_threaded_client = NULL; - mongoc_auto_encryption_opts_t *opts = NULL; - bson_error_t error; - bool ret; - - BSON_UNUSED (unused); - - _reset (&pool, &single_threaded_client, &multi_threaded_client, &opts, true); - - /* single threaded client, single threaded setter => ok */ - ret = mongoc_client_enable_auto_encryption ( - single_threaded_client, opts, &error); - ASSERT_OR_PRINT (ret, error); - _perform_op (single_threaded_client); - - /* multi threaded client, single threaded setter => bad */ - ret = mongoc_client_enable_auto_encryption ( - multi_threaded_client, opts, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Cannot enable auto encryption on a pooled client"); - - /* pool - pool setter */ - ret = mongoc_client_pool_enable_auto_encryption (pool, opts, &error); - ASSERT_OR_PRINT (ret, error); - _perform_op_pooled (pool); - - /* single threaded client, single threaded key vault client => ok */ - _reset (&pool, &single_threaded_client, &multi_threaded_client, &opts, true); - mongoc_auto_encryption_opts_set_keyvault_client (opts, - single_threaded_client); - ret = mongoc_client_enable_auto_encryption ( - single_threaded_client, opts, &error); - ASSERT_OR_PRINT (ret, error); - _perform_op (single_threaded_client); - - /* single threaded client, multi threaded key vault client => bad */ - _reset (&pool, &single_threaded_client, &multi_threaded_client, &opts, true); - mongoc_auto_encryption_opts_set_keyvault_client (opts, - multi_threaded_client); - ret = mongoc_client_enable_auto_encryption ( - single_threaded_client, opts, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "The key vault client must be single threaded, not " - "be from a client pool"); - - /* single threaded client, pool key vault client => bad */ - _reset (&pool, &single_threaded_client, &multi_threaded_client, &opts, true); - mongoc_auto_encryption_opts_set_keyvault_client_pool (opts, pool); - ret = mongoc_client_enable_auto_encryption ( - single_threaded_client, opts, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "The key vault client pool only applies to a client " - "pool, not a single threaded client"); - - /* pool, singled threaded key vault client => bad */ - _reset (&pool, &single_threaded_client, &multi_threaded_client, &opts, true); - mongoc_auto_encryption_opts_set_keyvault_client (opts, - single_threaded_client); - ret = mongoc_client_pool_enable_auto_encryption (pool, opts, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "The key vault client only applies to a single " - "threaded client not a client pool. Set a " - "key vault client pool"); - - /* pool, multi threaded key vault client => bad */ - _reset (&pool, &single_threaded_client, &multi_threaded_client, &opts, true); - mongoc_auto_encryption_opts_set_keyvault_client (opts, - multi_threaded_client); - ret = mongoc_client_pool_enable_auto_encryption (pool, opts, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "The key vault client only applies to a single " - "threaded client not a client pool. Set a " - "key vault client pool"); - - /* pool, pool key vault client => ok */ - _reset (&pool, &single_threaded_client, &multi_threaded_client, &opts, true); - mongoc_auto_encryption_opts_set_keyvault_client_pool (opts, pool); - ret = mongoc_client_pool_enable_auto_encryption (pool, opts, &error); - ASSERT_OR_PRINT (ret, error); - _perform_op_pooled (pool); - - /* double enabling */ - _reset (&pool, &single_threaded_client, &multi_threaded_client, &opts, true); - ret = mongoc_client_enable_auto_encryption ( - single_threaded_client, opts, &error); - ASSERT_OR_PRINT (ret, error); - ret = mongoc_client_enable_auto_encryption ( - single_threaded_client, opts, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "Automatic encryption already set"); - ret = mongoc_client_pool_enable_auto_encryption (pool, opts, &error); - ASSERT_OR_PRINT (ret, error); - ret = mongoc_client_pool_enable_auto_encryption (pool, opts, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, - "Automatic encryption already set"); - - /* single threaded, using self as key vault client => redundant, but ok */ - _reset (&pool, &single_threaded_client, &multi_threaded_client, &opts, true); - mongoc_auto_encryption_opts_set_keyvault_client (opts, - single_threaded_client); - ret = mongoc_client_enable_auto_encryption ( - single_threaded_client, opts, &error); - ASSERT_OR_PRINT (ret, error); - _perform_op (single_threaded_client); - - /* pool, using self as key vault client pool => redundant, but ok */ - _reset (&pool, &single_threaded_client, &multi_threaded_client, &opts, true); - mongoc_auto_encryption_opts_set_keyvault_client_pool (opts, pool); - ret = mongoc_client_pool_enable_auto_encryption (pool, opts, &error); - ASSERT_OR_PRINT (ret, error); - _perform_op_pooled (pool); - - _reset ( - &pool, &single_threaded_client, &multi_threaded_client, &opts, false); - mongoc_auto_encryption_opts_destroy (opts); -} - -static BSON_THREAD_FUN (_worker_thread, client_ptr) -{ - mongoc_client_t *client_encrypted; - mongoc_collection_t *coll; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_t filter = BSON_INITIALIZER; - bson_t *to_insert = BCON_NEW ("encrypted_string", "abc"); - int i; - bool ret; - bson_error_t error; - - client_encrypted = client_ptr; - coll = mongoc_client_get_collection (client_encrypted, "db", "coll"); - - for (i = 0; i < 100; i++) { - ret = mongoc_collection_insert_one ( - coll, to_insert, NULL /* opts */, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - cursor = mongoc_collection_find_with_opts ( - coll, &filter, NULL /* opts */, NULL /* read_prefs */); - mongoc_cursor_next (cursor, &doc); - mongoc_cursor_destroy (cursor); - } - mongoc_collection_destroy (coll); - bson_destroy (&filter); - bson_destroy (to_insert); - BSON_THREAD_RETURN; -} - -static void -_test_multi_threaded (bool external_key_vault) -{ - /* Spawn two threads and do repeated encryption/decryption operations. */ - bson_thread_t threads[2]; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_client_t *client1; - mongoc_client_t *client2; - mongoc_auto_encryption_opts_t *opts; - bson_t *datakey; - mongoc_collection_t *coll; - bson_t *schema; - bson_t *schema_map; - bool ret; - bson_error_t error; - bson_t *kms_providers; - int r; - int i; - mongoc_write_concern_t *wc; - - uri = test_framework_get_uri (); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - opts = mongoc_auto_encryption_opts_new (); - - /* Do setup: create a data key and configure pool for auto encryption. */ - coll = mongoc_client_get_collection (client, "db", "keyvault"); - (void) mongoc_collection_drop (coll, NULL); - datakey = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/limits-key.json"); - BSON_ASSERT (datakey); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_wmajority (wc, 1000); - mongoc_collection_set_write_concern (coll, wc); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one ( - coll, datakey, NULL /* opts */, NULL /* reply */, &error), - error); - - /* create pool with auto encryption */ - _check_bypass (opts); - - mongoc_auto_encryption_opts_set_keyvault_namespace (opts, "db", "keyvault"); - kms_providers = _make_kms_providers (false /* aws */, true /* local */); - mongoc_auto_encryption_opts_set_kms_providers (opts, kms_providers); - - if (external_key_vault) { - mongoc_auto_encryption_opts_set_keyvault_client_pool (opts, pool); - } - - schema = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/schema.json"); - BSON_ASSERT (schema); - schema_map = BCON_NEW ("db.coll", BCON_DOCUMENT (schema)); - mongoc_auto_encryption_opts_set_schema_map (opts, schema_map); - ret = mongoc_client_pool_enable_auto_encryption (pool, opts, &error); - ASSERT_OR_PRINT (ret, error); - - client1 = mongoc_client_pool_pop (pool); - client2 = mongoc_client_pool_pop (pool); - - r = mcommon_thread_create (threads, _worker_thread, client1); - BSON_ASSERT (r == 0); - - r = mcommon_thread_create (threads + 1, _worker_thread, client2); - BSON_ASSERT (r == 0); - - for (i = 0; i < 2; i++) { - r = mcommon_thread_join (threads[i]); - BSON_ASSERT (r == 0); - } - - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mongoc_client_pool_push (pool, client1); - mongoc_client_pool_push (pool, client2); - mongoc_client_pool_destroy (pool); - bson_destroy (schema); - bson_destroy (schema_map); - bson_destroy (datakey); - mongoc_auto_encryption_opts_destroy (opts); - mongoc_uri_destroy (uri); - bson_destroy (kms_providers); -} - -static void -test_multi_threaded (void *ctx_unused) -{ - BSON_UNUSED (ctx_unused); - - _test_multi_threaded (true); - _test_multi_threaded (false); -} - -static void -test_malformed_explicit (void *unused) -{ - mongoc_client_t *client; - bson_t *kms_providers; - mongoc_client_encryption_t *client_encryption; - mongoc_client_encryption_opts_t *client_encryption_opts; - bson_value_t value; - bson_value_t ciphertext; - bool ret; - bson_error_t error; - - BSON_UNUSED (unused); - - /* Create a MongoClient without encryption enabled */ - client = test_framework_new_default_client (); - kms_providers = _make_kms_providers (false /* aws */, true /* local */); - - /* Create a ClientEncryption object */ - client_encryption_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - client); - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, &error); - ASSERT_OR_PRINT (client_encryption, error); - - /* Test attempting to decrypt a malformed value */ - ciphertext.value_type = BSON_TYPE_DOUBLE; - ciphertext.value.v_double = 1.23; - ret = mongoc_client_encryption_decrypt ( - client_encryption, &ciphertext, &value, &error); - BSON_ASSERT (!ret); - bson_value_destroy (&value); - - mongoc_client_encryption_opts_destroy (client_encryption_opts); - mongoc_client_encryption_destroy (client_encryption); - bson_destroy (kms_providers); - mongoc_client_destroy (client); -} - -static void -_check_mongocryptd_not_spawned (void) -{ - mongoc_client_t *client; - bson_t *cmd; - bson_error_t error; - bool ret; - - /* Set up client. */ - { - mongoc_uri_t *uri = mongoc_uri_new ("mongodb://localhost:27021"); - ASSERT (mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_SERVERSELECTIONTIMEOUTMS, 1000)); - /* Set SERVERSELECTIONTRYONCE to false so client will wait for the full - * second before giving up on server selection. */ - ASSERT (mongoc_uri_set_option_as_bool ( - uri, MONGOC_URI_SERVERSELECTIONTRYONCE, false)); - - client = mongoc_client_new_from_uri (uri); - /* Bypass the 5 second cooldown so attempts to connect are repeated. - * Single threaded clients wait for 5 second cooldown period after failing - * to connect to a server before connecting again. If mongocryptd just - * spawned, it may take time before connections are accepted. */ - _mongoc_topology_bypass_cooldown (client->topology); - mongoc_uri_destroy (uri); - } - cmd = BCON_NEW (HANDSHAKE_CMD_LEGACY_HELLO, BCON_INT32 (1)); - ret = mongoc_client_command_simple ( - client, "keyvault", cmd, NULL /* read prefs */, NULL /* reply */, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "No suitable servers"); - mongoc_client_destroy (client); - bson_destroy (cmd); -} - -/* Prose Test 8: Bypass Spawning mongocryptd - Via mongocryptdBypassSpawn */ -static void -test_bypass_spawning_via_mongocryptdBypassSpawn (void *unused) -{ - mongoc_client_t *client_encrypted; - mongoc_auto_encryption_opts_t *auto_encryption_opts; - bson_t *kms_providers; - bson_t *doc_to_insert; - bson_t *extra; - bson_t *schema_map; - bson_t *schema; - bool ret; - bson_error_t error; - mongoc_collection_t *coll; - - BSON_UNUSED (unused); - - auto_encryption_opts = mongoc_auto_encryption_opts_new (); - kms_providers = _make_kms_providers (false /* aws */, true /* local */); - mongoc_auto_encryption_opts_set_kms_providers (auto_encryption_opts, - kms_providers); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - auto_encryption_opts, "keyvault", "datakeys"); - schema = get_bson_from_json_file ("./src/libmongoc/tests/" - "client_side_encryption_prose/external/" - "external-schema.json"); - schema_map = BCON_NEW ("db.coll", BCON_DOCUMENT (schema)); - - /* Create a MongoClient with encryption enabled */ - client_encrypted = test_framework_new_default_client (); - extra = - BCON_NEW ("mongocryptdBypassSpawn", - BCON_BOOL (true), - "mongocryptdSpawnArgs", - "[", - "--pidfilepath=bypass-spawning-mongocryptd.pid", - "--port=27021", - "]", - "mongocryptdURI", - "mongodb://localhost:27021/?serverSelectionTimeoutMS=1000"); - mongoc_auto_encryption_opts_set_extra (auto_encryption_opts, extra); - mongoc_auto_encryption_opts_set_schema_map (auto_encryption_opts, - schema_map); - bson_destroy (extra); - ret = mongoc_client_enable_auto_encryption ( - client_encrypted, auto_encryption_opts, &error); - ASSERT_OR_PRINT (ret, error); - - /* Insert { 'encrypt': 'test' }. Should fail with a server selection error. - */ - coll = mongoc_client_get_collection (client_encrypted, "db", "coll"); - doc_to_insert = BCON_NEW ("encrypt", "test"); - ret = mongoc_collection_insert_one ( - coll, doc_to_insert, NULL /* opts */, NULL /* reply */, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "mongocryptd error: No suitable servers found"); - - _check_mongocryptd_not_spawned (); - bson_destroy (schema_map); - bson_destroy (schema); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client_encrypted); - bson_destroy (doc_to_insert); - mongoc_auto_encryption_opts_destroy (auto_encryption_opts); - bson_destroy (kms_providers); -} - -static void -test_bypass_spawning_via_helper (const char *auto_encryption_opt) -{ - mongoc_client_t *client_encrypted; - mongoc_auto_encryption_opts_t *auto_encryption_opts; - bson_t *kms_providers; - bson_t *doc_to_insert; - bson_t *extra = bson_new (); - bool ret; - bson_error_t error; - bool check_crypt_shared = false; - mongoc_collection_t *coll; - - auto_encryption_opts = mongoc_auto_encryption_opts_new (); - kms_providers = _make_kms_providers (false /* aws */, true /* local */); - mongoc_auto_encryption_opts_set_kms_providers (auto_encryption_opts, - kms_providers); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - auto_encryption_opts, "keyvault", "datakeys"); - if (0 == strcmp (auto_encryption_opt, "bypass_auto_encryption")) { - mongoc_auto_encryption_opts_set_bypass_auto_encryption ( - auto_encryption_opts, true); - } else if (0 == strcmp (auto_encryption_opt, "bypass_query_analysis")) { - mongoc_auto_encryption_opts_set_bypass_query_analysis ( - auto_encryption_opts, true); - } else if (0 == strcmp (auto_encryption_opt, "cryptSharedLibRequired")) { - bson_t *schema = - get_bson_from_json_file ("./src/libmongoc/tests/" - "client_side_encryption_prose/external/" - "external-schema.json"); - BSON_ASSERT (schema); - bson_t *schema_map = BCON_NEW ("db.coll", BCON_DOCUMENT (schema)); - mongoc_auto_encryption_opts_set_schema_map (auto_encryption_opts, - schema_map); - check_crypt_shared = true; - char *env_cryptSharedLibPath = - test_framework_getenv ("MONGOC_TEST_CRYPT_SHARED_LIB_PATH"); - BSON_ASSERT (env_cryptSharedLibPath); - BSON_APPEND_UTF8 (extra, "cryptSharedLibPath", env_cryptSharedLibPath); - BSON_APPEND_BOOL (extra, "cryptSharedLibRequired", true); - BSON_APPEND_UTF8 ( - extra, - "mongocryptdURI", - "mongodb://localhost:27021/db?serverSelectionTimeoutMS=1000"); - bson_free (env_cryptSharedLibPath); - bson_destroy (schema); - bson_destroy (schema_map); - } else { - test_error ("Unexpected 'auto_encryption_opt' argument: %s", - auto_encryption_opt); - } - - /* Create a MongoClient with encryption enabled */ - client_encrypted = test_framework_new_default_client (); - BCON_APPEND (extra, - "mongocryptdSpawnArgs", - "[", - "--pidfilepath=bypass-spawning-mongocryptd.pid", - "--port=27021", - "]"); - mongoc_auto_encryption_opts_set_extra (auto_encryption_opts, extra); - bson_destroy (extra); - ret = mongoc_client_enable_auto_encryption ( - client_encrypted, auto_encryption_opts, &error); - ASSERT_OR_PRINT (ret, error); - - if (check_crypt_shared) { - BSON_ASSERT (mongoc_client_get_crypt_shared_version (client_encrypted) != - NULL); - } - - /* Insert { 'unencrypted': 'test' }. Should succeed. */ - coll = mongoc_client_get_collection (client_encrypted, "db", "coll"); - doc_to_insert = BCON_NEW ("unencrypted", "test"); - ret = mongoc_collection_insert_one ( - coll, doc_to_insert, NULL /* opts */, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - - _check_mongocryptd_not_spawned (); - - mongoc_collection_destroy (coll); - mongoc_client_destroy (client_encrypted); - bson_destroy (doc_to_insert); - mongoc_auto_encryption_opts_destroy (auto_encryption_opts); - bson_destroy (kms_providers); -} - -/* Prose Test 8: Bypass Spawning mongocryptd - Via bypassAutoEncryption */ -static void -test_bypass_spawning_via_bypassAutoEncryption (void *unused) -{ - BSON_UNUSED (unused); - - test_bypass_spawning_via_helper ("bypass_auto_encryption"); -} - -/* Prose Test 8: Bypass Spawning mongocryptd - Via bypassQueryAnalysis */ -static void -test_bypass_spawning_via_bypassQueryAnalysis (void *unused) -{ - BSON_UNUSED (unused); - - test_bypass_spawning_via_helper ("bypass_query_analysis"); -} - -/* Prose Test 8: Bypass Spawning mongocryptd - Via loading shared library */ -static void -test_bypass_spawning_via_cryptSharedLibLoaded (void *unused) -{ - BSON_UNUSED (unused); - test_bypass_spawning_via_helper ("cryptSharedLibRequired"); -} - -static int -_skip_if_no_crypt_shared (void) -{ - char *env = test_framework_getenv ("MONGOC_TEST_CRYPT_SHARED_LIB_PATH"); - if (!env) { - return 0; // Skip! - } - bson_free (env); - return 1; // Do not skip -} - -static mongoc_client_encryption_t * -_make_kms_certificate_client_encryption (mongoc_client_t *client, - bson_error_t *error) -{ - mongoc_client_encryption_t *client_encryption; - - ASSERT (client); - - mongoc_client_encryption_opts_t *client_encryption_opts = - mongoc_client_encryption_opts_new (); - - { - bson_t *kms_providers = _make_aws_kms_provider (NULL); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - bson_destroy (kms_providers); - } - - { - char *tls_ca_file = - test_framework_getenv_required ("MONGOC_TEST_CSFLE_TLS_CA_FILE"); - char *tls_cert_key_file = test_framework_getenv_required ( - "MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE"); - bson_t *tls_opts = tmp_bson ("{ 'aws': { '%s': '%s', '%s': '%s' } }", - MONGOC_URI_TLSCAFILE, - tls_ca_file, - MONGOC_URI_TLSCERTIFICATEKEYFILE, - tls_cert_key_file); - - mongoc_client_encryption_opts_set_tls_opts (client_encryption_opts, - tls_opts); - - bson_free (tls_cert_key_file); - bson_free (tls_ca_file); - } - - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - client); - - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, error); - ASSERT_OR_PRINT (client_encryption, (*error)); - - mongoc_client_encryption_opts_destroy (client_encryption_opts); - return client_encryption; -} - - -static void -test_kms_tls_cert_valid (void *unused) -{ - const int32_t connecttimeoutms = MONGOC_DEFAULT_CONNECTTIMEOUTMS; - const int is_client = 1; - - bson_error_t error; - mongoc_host_list_t host; - mongoc_stream_t *base_stream; - mongoc_ssl_opt_t ssl_opts; - mongoc_stream_t *tls_stream; - - char *tls_ca_file = - test_framework_getenv_required ("MONGOC_TEST_CSFLE_TLS_CA_FILE"); - char *tls_cert_key_file = test_framework_getenv_required ( - "MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE"); - - BSON_UNUSED (unused); - -#if defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) - /* Certificate verification fails with Secure Channel given - * "127.0.0.1:8999" with error: "hostname doesn't match certificate". */ - ASSERT_OR_PRINT ( - _mongoc_host_list_from_string_with_err (&host, "localhost:8999", &error), - error); -#else - ASSERT_OR_PRINT ( - _mongoc_host_list_from_string_with_err (&host, "127.0.0.1:8999", &error), - error); -#endif - - base_stream = mongoc_client_connect_tcp (connecttimeoutms, &host, &error); - ASSERT_OR_PRINT (base_stream, error); - - ssl_opts = *test_framework_get_ssl_opts (); - ssl_opts.ca_file = tls_ca_file; - ssl_opts.pem_file = tls_cert_key_file; - - tls_stream = mongoc_stream_tls_new_with_hostname ( - base_stream, host.host, &ssl_opts, is_client); - - ASSERT_OR_PRINT (mongoc_stream_tls_handshake_block ( - tls_stream, host.host, connecttimeoutms, &error), - error); - - mongoc_stream_destroy (tls_stream); /* Also destroys base_stream. */ - - bson_free (tls_cert_key_file); - bson_free (tls_ca_file); -} - -/* Prose Test 10: KMS TLS Tests - Invalid KMS Certificate */ -static void -test_kms_tls_cert_expired (void *unused) -{ - bool ret; - - bson_error_t error; - - bson_value_t keyid; - - mongoc_client_t *client = test_framework_new_default_client (); - - mongoc_client_encryption_t *client_encryption = - _make_kms_certificate_client_encryption (client, &error); - - mongoc_client_encryption_datakey_opts_t *opts = - mongoc_client_encryption_datakey_opts_new (); - - BSON_UNUSED (unused); - - mongoc_client_encryption_datakey_opts_set_masterkey ( - opts, - tmp_bson ("{ 'region': 'us-east-1', 'key': " - "'arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0', " - "'endpoint': '127.0.0.1:9000' }")); - - ret = mongoc_client_encryption_create_datakey ( - client_encryption, "aws", opts, &keyid, &error); - - BSON_ASSERT (!ret); - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) - ASSERT_CONTAINS (error.message, "certificate has expired"); -#elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) - ASSERT_CONTAINS (error.message, "CSSMERR_TP_CERT_EXPIRED"); -#elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) - ASSERT_CONTAINS (error.message, "certificate has expired"); -#elif defined(MONGOC_ENABLE_SSL_LIBRESSL) - ASSERT_CONTAINS (error.message, "certificate has expired"); -#endif - - mongoc_client_encryption_datakey_opts_destroy (opts); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_destroy (client); -} - - -/* Prose Test 10: KMS TLS Tests - Invalid Hostname in KMS Certificate */ -static void -test_kms_tls_cert_wrong_host (void *unused) -{ - bool ret; - - bson_error_t error; - - bson_value_t keyid; - - mongoc_client_t *client = test_framework_new_default_client (); - - mongoc_client_encryption_t *client_encryption = - _make_kms_certificate_client_encryption (client, &error); - - mongoc_client_encryption_datakey_opts_t *opts = - mongoc_client_encryption_datakey_opts_new (); - - BSON_UNUSED (unused); - - mongoc_client_encryption_datakey_opts_set_masterkey ( - opts, - tmp_bson ("{ 'region': 'us-east-1', 'key': " - "'arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0', " - "'endpoint': '127.0.0.1:9001' }")); - - ret = mongoc_client_encryption_create_datakey ( - client_encryption, "aws", opts, &keyid, &error); - - BSON_ASSERT (!ret); - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) - ASSERT_CONTAINS (error.message, "IP address mismatch"); -#elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) - ASSERT_CONTAINS (error.message, "Host name mismatch"); -#elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) - ASSERT_CONTAINS (error.message, "hostname doesn't match certificate"); -#elif defined(MONGOC_ENABLE_SSL_LIBRESSL) - ASSERT_CONTAINS (error.message, "not present in server certificate"); -#endif - - mongoc_client_encryption_datakey_opts_destroy (opts); - mongoc_client_encryption_destroy (client_encryption); - mongoc_client_destroy (client); -} - -typedef enum { - NO_CLIENT_CERT, - WITH_TLS, - INVALID_HOSTNAME, - EXPIRED, - WITH_NAMES -} tls_test_ce_t; - -static mongoc_client_encryption_t * -_tls_test_make_client_encryption (mongoc_client_t *keyvault_client, - tls_test_ce_t test_ce) -{ - bson_t *kms_providers; - mongoc_client_encryption_opts_t *client_encryption_opts; - bson_error_t error = {0}; - mongoc_client_encryption_t *client_encryption; - bson_t *tls_opts = NULL; - - ASSERT (keyvault_client); - - char *mongoc_test_aws_access_key_id = - test_framework_getenv_required ("MONGOC_TEST_AWS_ACCESS_KEY_ID"); - char *mongoc_test_aws_secret_access_key = - test_framework_getenv_required ("MONGOC_TEST_AWS_SECRET_ACCESS_KEY"); - char *mongoc_test_azure_tenant_id = - test_framework_getenv_required ("MONGOC_TEST_AZURE_TENANT_ID"); - char *mongoc_test_azure_client_id = - test_framework_getenv_required ("MONGOC_TEST_AZURE_CLIENT_ID"); - char *mongoc_test_azure_client_secret = - test_framework_getenv_required ("MONGOC_TEST_AZURE_CLIENT_SECRET"); - char *mongoc_test_gcp_email = - test_framework_getenv_required ("MONGOC_TEST_GCP_EMAIL"); - char *mongoc_test_gcp_privatekey = - test_framework_getenv_required ("MONGOC_TEST_GCP_PRIVATEKEY"); - char *ca_file = - test_framework_getenv_required ("MONGOC_TEST_CSFLE_TLS_CA_FILE"); - char *certificate_key_file = test_framework_getenv_required ( - "MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE"); - - if (test_ce == WITH_TLS) { - kms_providers = - tmp_bson ("{'aws': {'accessKeyId': '%s', 'secretAccessKey': '%s' }}", - mongoc_test_aws_access_key_id, - mongoc_test_aws_secret_access_key); - - tls_opts = tmp_bson ( - "{'aws': {'tlsCaFile': '%s', 'tlsCertificateKeyFile': '%s' }}", - ca_file, - certificate_key_file); - bson_concat (kms_providers, - tmp_bson ("{'azure': {'tenantId': '%s', 'clientId': '%s', " - "'clientSecret': '%s', " - "'identityPlatformEndpoint': '127.0.0.1:9002' }}", - mongoc_test_azure_tenant_id, - mongoc_test_azure_client_id, - mongoc_test_azure_client_secret)); - bson_concat ( - tls_opts, - tmp_bson ( - "{'azure': {'tlsCaFile': '%s', 'tlsCertificateKeyFile': '%s' }}", - ca_file, - certificate_key_file)); - - bson_concat (kms_providers, - tmp_bson ("{'gcp': { 'email': '%s', 'privateKey': '%s', " - "'endpoint': '127.0.0.1:9002' }}", - mongoc_test_gcp_email, - mongoc_test_gcp_privatekey)); - bson_concat ( - tls_opts, - tmp_bson ( - "{'gcp': {'tlsCaFile': '%s', 'tlsCertificateKeyFile': '%s' }}", - ca_file, - certificate_key_file)); - - bson_concat (kms_providers, - tmp_bson ("{'kmip': { 'endpoint': '127.0.0.1:5698'}}")); - bson_concat ( - tls_opts, - tmp_bson ( - "{'kmip': {'tlsCaFile': '%s', 'tlsCertificateKeyFile': '%s' }}", - ca_file, - certificate_key_file)); - } else if (test_ce == NO_CLIENT_CERT) { - kms_providers = - tmp_bson ("{'aws': {'accessKeyId': '%s', 'secretAccessKey': '%s' }}", - mongoc_test_aws_access_key_id, - mongoc_test_aws_secret_access_key); - bson_concat (kms_providers, - tmp_bson ("{'azure': {'tenantId': '%s', 'clientId': '%s', " - "'clientSecret': '%s', " - "'identityPlatformEndpoint': '127.0.0.1:9002'}}", - mongoc_test_azure_tenant_id, - mongoc_test_azure_client_id, - mongoc_test_azure_client_secret)); - bson_concat (kms_providers, - tmp_bson ("{'gcp': { 'email': '%s', 'privateKey': '%s', " - "'endpoint': '127.0.0.1:9002'}}", - mongoc_test_gcp_email, - mongoc_test_gcp_privatekey)); - bson_concat (kms_providers, - tmp_bson ("{'kmip': { 'endpoint': '127.0.0.1:5698' }}")); - } else if (test_ce == EXPIRED) { - kms_providers = - tmp_bson ("{'aws': {'accessKeyId': '%s', 'secretAccessKey': '%s' }}", - mongoc_test_aws_access_key_id, - mongoc_test_aws_secret_access_key); - tls_opts = tmp_bson ("{'aws': {'tlsCaFile': '%s'} }", ca_file); - - bson_concat (kms_providers, - tmp_bson ("{'azure': {'tenantId': '%s', 'clientId': '%s', " - "'clientSecret': '%s', " - "'identityPlatformEndpoint': '127.0.0.1:9000'}}", - mongoc_test_azure_tenant_id, - mongoc_test_azure_client_id, - mongoc_test_azure_client_secret)); - bson_concat (tls_opts, - tmp_bson ("{'azure': {'tlsCaFile': '%s'} }", ca_file)); - - bson_concat (kms_providers, - tmp_bson ("{'gcp': { 'email': '%s', 'privateKey': '%s', " - "'endpoint': '127.0.0.1:9000'}}", - mongoc_test_gcp_email, - mongoc_test_gcp_privatekey)); - bson_concat (tls_opts, - tmp_bson ("{'gcp': {'tlsCaFile': '%s'} }", ca_file)); - - bson_concat (kms_providers, - tmp_bson ("{'kmip': { 'endpoint': '127.0.0.1:9000' }}")); - bson_concat (tls_opts, - tmp_bson ("{'kmip': {'tlsCaFile': '%s'} }", ca_file)); - } else if (test_ce == INVALID_HOSTNAME) { - kms_providers = - tmp_bson ("{'aws': {'accessKeyId': '%s', 'secretAccessKey': '%s' } }", - mongoc_test_aws_access_key_id, - mongoc_test_aws_secret_access_key); - tls_opts = tmp_bson ("{'aws': {'tlsCaFile': '%s'} }", ca_file); - - bson_concat (kms_providers, - tmp_bson ("{'azure': {'tenantId': '%s', 'clientId': '%s', " - "'clientSecret': '%s', " - "'identityPlatformEndpoint': '127.0.0.1:9001' }}", - mongoc_test_azure_tenant_id, - mongoc_test_azure_client_id, - mongoc_test_azure_client_secret)); - bson_concat (tls_opts, - tmp_bson ("{'azure': {'tlsCaFile': '%s'} }", ca_file)); - - bson_concat (kms_providers, - tmp_bson ("{'gcp': { 'email': '%s', 'privateKey': '%s', " - "'endpoint': '127.0.0.1:9001' }}", - mongoc_test_gcp_email, - mongoc_test_gcp_privatekey)); - bson_concat (tls_opts, - tmp_bson ("{'gcp': {'tlsCaFile': '%s'} }", ca_file)); - - bson_concat (kms_providers, - tmp_bson ("{'kmip': { 'endpoint': '127.0.0.1:9001' }}")); - bson_concat (tls_opts, - tmp_bson ("{'kmip': {'tlsCaFile': '%s'} }", ca_file)); - } else if (test_ce == WITH_NAMES) { - kms_providers = tmp_bson ("{'aws:no_client_cert': {'accessKeyId': '%s', " - "'secretAccessKey': '%s' }}", - mongoc_test_aws_access_key_id, - mongoc_test_aws_secret_access_key); - tls_opts = - tmp_bson ("{'aws:no_client_cert': {'tlsCaFile': '%s' }}", ca_file); - - bson_concat ( - kms_providers, - tmp_bson ( - "{'aws:with_tls': {'accessKeyId': '%s', 'secretAccessKey': '%s' }}", - mongoc_test_aws_access_key_id, - mongoc_test_aws_secret_access_key)); - bson_concat (tls_opts, - tmp_bson ("{'aws:with_tls': {'tlsCaFile': '%s', " - "'tlsCertificateKeyFile': '%s' }}", - ca_file, - certificate_key_file)); - - bson_concat ( - kms_providers, - tmp_bson ( - "{'azure:no_client_cert': {'tenantId': '%s', 'clientId': '%s'," - "'clientSecret': '%s', " - "'identityPlatformEndpoint': '127.0.0.1:9002'" - "}}", - mongoc_test_azure_tenant_id, - mongoc_test_azure_client_id, - mongoc_test_azure_client_secret)); - bson_concat ( - tls_opts, - tmp_bson ("{'azure:no_client_cert': {'tlsCaFile': '%s' }}", ca_file)); - - bson_concat ( - kms_providers, - tmp_bson ("{'azure:with_tls': {'tenantId': '%s', 'clientId': '%s'," - "'clientSecret': '%s', " - "'identityPlatformEndpoint': '127.0.0.1:9002'" - "}}", - mongoc_test_azure_tenant_id, - mongoc_test_azure_client_id, - mongoc_test_azure_client_secret)); - bson_concat (tls_opts, - tmp_bson ("{'azure:with_tls': {'tlsCaFile': '%s', " - "'tlsCertificateKeyFile': '%s' }}", - ca_file, - certificate_key_file)); - - bson_concat ( - kms_providers, - tmp_bson ( - "{'gcp:no_client_cert': { 'email': '%s', 'privateKey': '%s', " - "'endpoint': '127.0.0.1:9002' }}", - mongoc_test_gcp_email, - mongoc_test_gcp_privatekey)); - bson_concat (tls_opts, - tmp_bson ("{'gcp:no_client_cert': {'tlsCaFile': '%s' }}", - ca_file, - certificate_key_file)); - - bson_concat ( - kms_providers, - tmp_bson ("{'gcp:with_tls': { 'email': '%s', 'privateKey': '%s', " - "'endpoint': '127.0.0.1:9002' }}", - mongoc_test_gcp_email, - mongoc_test_gcp_privatekey)); - bson_concat (tls_opts, - tmp_bson ("{'gcp:with_tls': {'tlsCaFile': '%s', " - "'tlsCertificateKeyFile': '%s' }}", - ca_file, - certificate_key_file)); - - bson_concat ( - kms_providers, - tmp_bson ("{'kmip:no_client_cert': { 'endpoint': '127.0.0.1:5698'}}")); - bson_concat ( - tls_opts, - tmp_bson ("{'kmip:no_client_cert': {'tlsCaFile': '%s' }}", ca_file)); - - bson_concat ( - kms_providers, - tmp_bson ("{'kmip:with_tls': { 'endpoint': '127.0.0.1:5698'}}")); - bson_concat (tls_opts, - tmp_bson ("{'kmip:with_tls': {'tlsCaFile': '%s', " - "'tlsCertificateKeyFile': '%s' }}", - ca_file, - certificate_key_file)); - } else { - BSON_UNREACHABLE ("Invalid value for test_ce"); - } - - client_encryption_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - keyvault_client); - mongoc_client_encryption_opts_set_tls_opts (client_encryption_opts, - tls_opts); - - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, &error); - ASSERT_OR_PRINT (client_encryption, error); - - mongoc_client_encryption_opts_destroy (client_encryption_opts); - bson_free (mongoc_test_aws_access_key_id); - bson_free (mongoc_test_aws_secret_access_key); - bson_free (mongoc_test_azure_tenant_id); - bson_free (mongoc_test_azure_client_id); - bson_free (mongoc_test_azure_client_secret); - bson_free (mongoc_test_gcp_email); - bson_free (mongoc_test_gcp_privatekey); - bson_free (ca_file); - bson_free (certificate_key_file); - - return client_encryption; -} - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) -#define ASSERT_EXPIRED(error) \ - ASSERT_CONTAINS (error.message, "certificate has expired"); -#elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) -#define ASSERT_EXPIRED(error) \ - ASSERT_CONTAINS (error.message, "CSSMERR_TP_CERT_EXPIRED"); -#elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) -#define ASSERT_EXPIRED(error) \ - ASSERT_CONTAINS (error.message, "certificate has expired"); -#elif defined(MONGOC_ENABLE_SSL_LIBRESSL) -#define ASSERT_EXPIRED(error) \ - ASSERT_CONTAINS (error.message, "certificate has expired"); -#else -#define ASSERT_EXPIRED(error) -#endif - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) -#define ASSERT_INVALID_HOSTNAME(error) \ - ASSERT_CONTAINS (error.message, "IP address mismatch"); -#elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) -#define ASSERT_INVALID_HOSTNAME(error) \ - ASSERT_CONTAINS (error.message, "Host name mismatch"); -#elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) -#define ASSERT_INVALID_HOSTNAME(error) \ - ASSERT_CONTAINS (error.message, "hostname doesn't match certificate"); -#elif defined(MONGOC_ENABLE_SSL_LIBRESSL) -#define ASSERT_INVALID_HOSTNAME(error) \ - ASSERT_CONTAINS (error.message, "not present in server certificate"); -#else -#define ASSERT_INVALID_HOSTNAME(error) -#endif - -/* Prose Test 11: KMS TLS Options Tests */ -static void -test_kms_tls_options (void *unused) -{ - mongoc_client_t *keyvault_client; - mongoc_client_encryption_t *client_encryption_no_client_cert = NULL; - mongoc_client_encryption_t *client_encryption_with_tls = NULL; - mongoc_client_encryption_t *client_encryption_expired = NULL; - mongoc_client_encryption_t *client_encryption_invalid_hostname = NULL; - mongoc_client_encryption_t *client_encryption_with_names = NULL; - bson_value_t keyid; - mongoc_client_encryption_datakey_opts_t *dkopts; - bson_error_t error; - bool res; - const int mongocrypt_errno = - 1; /* libmongocrypt returns all errors with code 1. */ - - BSON_UNUSED (unused); - - keyvault_client = test_framework_new_default_client (); - client_encryption_no_client_cert = - _tls_test_make_client_encryption (keyvault_client, NO_CLIENT_CERT); - client_encryption_with_tls = - _tls_test_make_client_encryption (keyvault_client, WITH_TLS); - client_encryption_expired = - _tls_test_make_client_encryption (keyvault_client, EXPIRED); - client_encryption_invalid_hostname = - _tls_test_make_client_encryption (keyvault_client, INVALID_HOSTNAME); - client_encryption_with_names = - _tls_test_make_client_encryption (keyvault_client, WITH_NAMES); - - /* Case 1: AWS - no client cert. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'region': 'us-east-1', 'key': " - "'arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0', 'endpoint': " - "'127.0.0.1:9002' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_no_client_cert, "aws", dkopts, &keyid, &error); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, ""); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* AWS - named with no client cert. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'region': 'us-east-1', 'key': " - "'arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0', 'endpoint': " - "'127.0.0.1:9002' }")); - res = mongoc_client_encryption_create_datakey (client_encryption_with_names, - "aws:no_client_cert", - dkopts, - &keyid, - &error); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, ""); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* AWS - with TLS. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'region': 'us-east-1', 'key': " - "'arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0', 'endpoint': " - "'127.0.0.1:9002' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_with_tls, "aws", dkopts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - mongocrypt_errno, - "parse error"); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* AWS - named with TLS. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'region': 'us-east-1', 'key': " - "'arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0', 'endpoint': " - "'127.0.0.1:9002' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_with_names, "aws:with_tls", dkopts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - mongocrypt_errno, - "parse error"); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* AWS - expired. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'region': 'us-east-1', 'key': " - "'arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0', 'endpoint': " - "'127.0.0.1:9000' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_expired, "aws", dkopts, &keyid, &error); - ASSERT_EXPIRED (error); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* AWS - invalid hostname. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'region': 'us-east-1', 'key': " - "'arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0', 'endpoint': " - "'127.0.0.1:9001' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_invalid_hostname, "aws", dkopts, &keyid, &error); - ASSERT_INVALID_HOSTNAME (error); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* Case 2: Azure - no client cert. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ( - "{ 'keyVaultEndpoint': 'doesnotexist.local', 'keyName': 'foo' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_no_client_cert, "azure", dkopts, &keyid, &error); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, ""); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* Azure - named with no client cert. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ( - "{ 'keyVaultEndpoint': 'doesnotexist.local', 'keyName': 'foo' }")); - res = mongoc_client_encryption_create_datakey (client_encryption_with_names, - "azure:no_client_cert", - dkopts, - &keyid, - &error); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, ""); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* Azure - with TLS. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ( - "{ 'keyVaultEndpoint': 'doesnotexist.local', 'keyName': 'foo' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_with_tls, "azure", dkopts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - mongocrypt_errno, - "HTTP status=404"); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* Azure - named with TLS. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ( - "{ 'keyVaultEndpoint': 'doesnotexist.local', 'keyName': 'foo' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_with_names, "azure:with_tls", dkopts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - mongocrypt_errno, - "HTTP status=404"); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* Azure - expired. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ( - "{ 'keyVaultEndpoint': 'doesnotexist.local', 'keyName': 'foo' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_expired, "azure", dkopts, &keyid, &error); - ASSERT_EXPIRED (error); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* Azure - invalid hostname. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ( - "{ 'keyVaultEndpoint': 'doesnotexist.local', 'keyName': 'foo' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_invalid_hostname, "azure", dkopts, &keyid, &error); - ASSERT_INVALID_HOSTNAME (error); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* Case 3: GCP - no client cert. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'projectId': 'pid', 'location': 'l', 'keyRing': 'kr', " - "'keyName': 'kn' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_no_client_cert, "gcp", dkopts, &keyid, &error); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, ""); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* GCP - named with no client cert. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'projectId': 'pid', 'location': 'l', 'keyRing': 'kr', " - "'keyName': 'kn' }")); - res = mongoc_client_encryption_create_datakey (client_encryption_with_names, - "gcp:no_client_cert", - dkopts, - &keyid, - &error); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, ""); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* GCP - with TLS. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'projectId': 'pid', 'location': 'l', 'keyRing': 'kr', " - "'keyName': 'kn' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_with_tls, "gcp", dkopts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - mongocrypt_errno, - "HTTP status=404"); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* GCP - named with TLS. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'projectId': 'pid', 'location': 'l', 'keyRing': 'kr', " - "'keyName': 'kn' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_with_names, "gcp:with_tls", dkopts, &keyid, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - mongocrypt_errno, - "HTTP status=404"); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* GCP - expired. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'projectId': 'pid', 'location': 'l', 'keyRing': 'kr', " - "'keyName': 'kn' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_expired, "gcp", dkopts, &keyid, &error); - ASSERT_EXPIRED (error); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* GCP - invalid hostname. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dkopts, - tmp_bson ("{ 'projectId': 'pid', 'location': 'l', 'keyRing': 'kr', " - "'keyName': 'kn' }")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_invalid_hostname, "gcp", dkopts, &keyid, &error); - ASSERT_INVALID_HOSTNAME (error); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* Case 4: KMIP - no client cert. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey (dkopts, - tmp_bson ("{}")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_no_client_cert, "kmip", dkopts, &keyid, &error); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, ""); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* KMIP - named with no client cert. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey (dkopts, - tmp_bson ("{}")); - res = mongoc_client_encryption_create_datakey (client_encryption_with_names, - "kmip:no_client_cert", - dkopts, - &keyid, - &error); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, ""); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* KMIP - with TLS. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey (dkopts, - tmp_bson ("{}")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_with_tls, "kmip", dkopts, &keyid, &error); - ASSERT_OR_PRINT (res, error); - bson_value_destroy (&keyid); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* KMIP - named with TLS. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey (dkopts, - tmp_bson ("{}")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_with_names, "kmip:with_tls", dkopts, &keyid, &error); - ASSERT_OR_PRINT (res, error); - bson_value_destroy (&keyid); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* KMIP - expired. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey (dkopts, - tmp_bson ("{}")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_expired, "kmip", dkopts, &keyid, &error); - ASSERT_EXPIRED (error); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - /* KMIP - invalid hostname. */ - memset (&error, 0, sizeof (bson_error_t)); - dkopts = mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey (dkopts, - tmp_bson ("{}")); - res = mongoc_client_encryption_create_datakey ( - client_encryption_invalid_hostname, "kmip", dkopts, &keyid, &error); - ASSERT_INVALID_HOSTNAME (error); - ASSERT (!res); - mongoc_client_encryption_datakey_opts_destroy (dkopts); - - mongoc_client_encryption_destroy (client_encryption_with_names); - mongoc_client_encryption_destroy (client_encryption_invalid_hostname); - mongoc_client_encryption_destroy (client_encryption_expired); - mongoc_client_encryption_destroy (client_encryption_with_tls); - mongoc_client_encryption_destroy (client_encryption_no_client_cert); - mongoc_client_destroy (keyvault_client); -} - -static void -test_kms_tls_options_extra_rejected (void *unused) -{ - mongoc_client_encryption_t *ce; - mongoc_client_encryption_opts_t *ce_opts; - mongoc_client_t *keyvault_client; - bson_error_t error; - bson_t *kms_providers = - tmp_bson ("{'aws': {'accessKeyId': 'foo', 'secretAccessKey': 'bar'}}"); - - BSON_UNUSED (unused); - - keyvault_client = test_framework_new_default_client (); - - /* Test that the "local" KMS provider is rejected. */ - ce_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ce_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (ce_opts, keyvault_client); - mongoc_client_encryption_opts_set_kms_providers (ce_opts, kms_providers); - mongoc_client_encryption_opts_set_tls_opts ( - ce_opts, tmp_bson ("{'local': {'tlsCaFile': 'ca.pem'}}")); - ce = mongoc_client_encryption_new (ce_opts, &error); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Cannot configure TLS options for KMS provider: local"); - ASSERT (NULL == ce); - mongoc_client_encryption_opts_destroy (ce_opts); - - /* Test that insecure TLS options are rejected. */ - memset (&error, 0, sizeof (bson_error_t)); - ce_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ce_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (ce_opts, keyvault_client); - mongoc_client_encryption_opts_set_kms_providers (ce_opts, kms_providers); - mongoc_client_encryption_opts_set_tls_opts ( - ce_opts, tmp_bson ("{'aws': {'tlsInsecure': true}}")); - ce = mongoc_client_encryption_new (ce_opts, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error setting TLS option tlsInsecure for aws. " - "Insecure TLS options prohibited"); - ASSERT (NULL == ce); - mongoc_client_encryption_opts_destroy (ce_opts); - - /* Test that extra TLS options are rejected. */ - memset (&error, 0, sizeof (bson_error_t)); - ce_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ce_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (ce_opts, keyvault_client); - mongoc_client_encryption_opts_set_kms_providers (ce_opts, kms_providers); - mongoc_client_encryption_opts_set_tls_opts ( - ce_opts, tmp_bson ("{'aws': {'extra': true}}")); - ce = mongoc_client_encryption_new (ce_opts, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error setting TLS option extra for aws. Insecure " - "TLS options prohibited"); - ASSERT (NULL == ce); - mongoc_client_encryption_opts_destroy (ce_opts); - - /* Test that TLS options for duplicate providers are rejected. */ - memset (&error, 0, sizeof (bson_error_t)); - ce_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ce_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (ce_opts, keyvault_client); - mongoc_client_encryption_opts_set_kms_providers (ce_opts, kms_providers); - mongoc_client_encryption_opts_set_tls_opts ( - ce_opts, - tmp_bson ( - "{'aws': {'tlsCAFile': 'foo.pem'}, 'aws': {'tlsCAFile': 'foo.pem'}}")); - ce = mongoc_client_encryption_new (ce_opts, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "Error parsing duplicate TLS options for aws"); - ASSERT (NULL == ce); - mongoc_client_encryption_opts_destroy (ce_opts); - - /* Test that tlsDisableOCSPEndpointCheck may be set. */ - memset (&error, 0, sizeof (bson_error_t)); - ce_opts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ce_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (ce_opts, keyvault_client); - mongoc_client_encryption_opts_set_kms_providers (ce_opts, kms_providers); - mongoc_client_encryption_opts_set_tls_opts ( - ce_opts, - tmp_bson ("{'aws': {'%s': true}}", - MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK)); - ce = mongoc_client_encryption_new (ce_opts, &error); - ASSERT_OR_PRINT (ce, error); - mongoc_client_encryption_destroy (ce); - mongoc_client_encryption_opts_destroy (ce_opts); - - mongoc_client_destroy (keyvault_client); -} - -/* ee_fixture is a fixture for the Explicit Encryption prose test. */ -typedef struct { - bson_value_t key1ID; - mongoc_client_t *keyVaultClient; - mongoc_client_encryption_t *clientEncryption; - mongoc_client_t *encryptedClient; - mongoc_collection_t *encryptedColl; -} ee_fixture; - -static ee_fixture * -explicit_encryption_setup (void) -{ - ee_fixture *eef = (ee_fixture *) bson_malloc0 (sizeof (ee_fixture)); - bson_t *encryptedFields = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/explicit_encryption/" - "encryptedFields.json"); - bson_t *key1Document = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/explicit_encryption/" - "key1-document.json"); - mongoc_client_t *setupClient = test_framework_new_default_client (); - - - /* Read the ``"_id"`` field of ``key1Document`` as ``key1ID``. */ - { - bson_iter_t iter; - const bson_value_t *value; - - ASSERT (bson_iter_init_find (&iter, key1Document, "_id")); - value = bson_iter_value (&iter); - bson_value_copy (value, &eef->key1ID); - } - - /* Drop and create the collection ``db.explicit_encryption`` using - * ``encryptedFields`` as an option. */ - { - mongoc_database_t *db = mongoc_client_get_database (setupClient, "db"); - mongoc_collection_t *coll = - mongoc_database_get_collection (db, "explicit_encryption"); - bson_error_t error; - bson_t *opts; - - opts = BCON_NEW ("encryptedFields", BCON_DOCUMENT (encryptedFields)); - - if (!mongoc_collection_drop_with_opts (coll, opts, &error)) { - if (error.code != MONGOC_SERVER_ERR_NS_NOT_FOUND) { - test_error ("unexpected error in drop: %s", error.message); - } - } - mongoc_collection_destroy (coll); - - coll = mongoc_database_create_collection ( - db, "explicit_encryption", opts, &error); - ASSERT_OR_PRINT (coll, error); - - mongoc_collection_destroy (coll); - bson_destroy (opts); - mongoc_database_destroy (db); - } - - /* Drop and create the collection ``keyvault.datakeys``. */ - { - mongoc_database_t *db = - mongoc_client_get_database (setupClient, "keyvault"); - mongoc_collection_t *coll = - mongoc_database_get_collection (db, "datakeys"); - bson_error_t error; - bson_t iopts = BSON_INITIALIZER; - mongoc_write_concern_t *wc; - - if (!mongoc_collection_drop (coll, &error)) { - if (error.code != MONGOC_SERVER_ERR_NS_NOT_FOUND) { - test_error ("unexpected error in drop: %s", error.message); - } - } - mongoc_collection_destroy (coll); - - coll = mongoc_database_create_collection ( - db, "datakeys", NULL /* opts */, &error); - ASSERT_OR_PRINT (coll, error); - - /* Insert keyDocument1 with write concern majority */ - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY); - ASSERT (mongoc_write_concern_append (wc, &iopts)); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, key1Document, &iopts, NULL /* reply */, &error), - error); - - mongoc_write_concern_destroy (wc); - bson_destroy (&iopts); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - } - - eef->keyVaultClient = test_framework_new_default_client (); - - /* Create a ClientEncryption object named ``clientEncryption`` */ - { - mongoc_client_encryption_opts_t *ceOpts = - mongoc_client_encryption_opts_new (); - bson_t *kms_providers = _make_local_kms_provider (NULL); - bson_error_t error; - - mongoc_client_encryption_opts_set_keyvault_client (ceOpts, - eef->keyVaultClient); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ceOpts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_kms_providers (ceOpts, kms_providers); - - eef->clientEncryption = mongoc_client_encryption_new (ceOpts, &error); - ASSERT_OR_PRINT (eef->clientEncryption, error); - - bson_destroy (kms_providers); - mongoc_client_encryption_opts_destroy (ceOpts); - } - - /* Create a MongoClient named ``encryptedClient``. */ - { - mongoc_auto_encryption_opts_t *aeOpts = - mongoc_auto_encryption_opts_new (); - bson_t *kms_providers = _make_local_kms_provider (NULL); - bson_error_t error; - - mongoc_auto_encryption_opts_set_keyvault_namespace ( - aeOpts, "keyvault", "datakeys"); - mongoc_auto_encryption_opts_set_kms_providers (aeOpts, kms_providers); - mongoc_auto_encryption_opts_set_bypass_query_analysis (aeOpts, true); - eef->encryptedClient = test_framework_new_default_client (); - ASSERT_OR_PRINT (mongoc_client_enable_auto_encryption ( - eef->encryptedClient, aeOpts, &error), - error); - - bson_destroy (kms_providers); - mongoc_auto_encryption_opts_destroy (aeOpts); - eef->encryptedColl = mongoc_client_get_collection ( - eef->encryptedClient, "db", "explicit_encryption"); - } - - mongoc_client_destroy (setupClient); - bson_destroy (key1Document); - bson_destroy (encryptedFields); - return eef; -} - -static void -explicit_encryption_destroy (ee_fixture *eef) -{ - if (!eef) { - return; - } - - mongoc_collection_destroy (eef->encryptedColl); - mongoc_client_destroy (eef->encryptedClient); - mongoc_client_encryption_destroy (eef->clientEncryption); - mongoc_client_destroy (eef->keyVaultClient); - bson_value_destroy (&eef->key1ID); - bson_free (eef); -} - -/* ree_fixture is a fixture for the Range Explicit Encryption prose test. */ -typedef struct { - bson_value_t key1ID; - mongoc_client_t *keyVaultClient; - mongoc_client_encryption_t *clientEncryption; - mongoc_client_t *encryptedClient; - mongoc_collection_t *encryptedColl; - // typeStr is DoublePrecision, DoubleNoPrecision, Date, Int, or Long - const char *typeStr; - char *fieldName; - bson_value_t zero; - bson_value_t six; - bson_value_t thirty; - bson_value_t twoHundred; - bson_value_t twoHundredOne; - mongoc_client_encryption_encrypt_range_opts_t *ro; -} ree_fixture; - -static ree_fixture * -range_explicit_encryption_setup (const char *typeStr) -{ - ree_fixture *reef = (ree_fixture *) bson_malloc0 (sizeof (ree_fixture)); - reef->typeStr = typeStr; - reef->fieldName = bson_strdup_printf ("encrypted%s", typeStr); - char *filepath = - bson_strdup_printf ("./src/libmongoc/tests/client_side_encryption_prose/" - "explicit_encryption/range-encryptedFields-%s.json", - typeStr); - bson_t *encryptedFields = get_bson_from_json_file (filepath); - ASSERT (encryptedFields); - bson_free (filepath); - bson_t *key1Document = get_bson_from_json_file ( - "./src/libmongoc/tests/client_side_encryption_prose/explicit_encryption/" - "key1-document.json"); - ASSERT (key1Document); - mongoc_client_t *setupClient = test_framework_new_default_client (); - - - /* Read the ``"_id"`` field of ``key1Document`` as ``key1ID``. */ - { - bson_iter_t iter; - const bson_value_t *value; - - ASSERT (bson_iter_init_find (&iter, key1Document, "_id")); - value = bson_iter_value (&iter); - bson_value_copy (value, &reef->key1ID); - } - - /* Drop and create the collection ``db.explicit_encryption`` using - * ``encryptedFields`` as an option. */ - { - mongoc_database_t *db = mongoc_client_get_database (setupClient, "db"); - mongoc_collection_t *coll = - mongoc_database_get_collection (db, "explicit_encryption"); - bson_error_t error; - bson_t *opts; - - opts = BCON_NEW ("encryptedFields", BCON_DOCUMENT (encryptedFields)); - - if (!mongoc_collection_drop_with_opts (coll, opts, &error)) { - if (error.code != MONGOC_SERVER_ERR_NS_NOT_FOUND) { - test_error ("unexpected error in drop: %s", error.message); - } - } - mongoc_collection_destroy (coll); - - coll = mongoc_database_create_collection ( - db, "explicit_encryption", opts, &error); - ASSERT_OR_PRINT (coll, error); - - mongoc_collection_destroy (coll); - bson_destroy (opts); - mongoc_database_destroy (db); - } - - /* Drop and create the collection ``keyvault.datakeys``. */ - { - mongoc_database_t *db = - mongoc_client_get_database (setupClient, "keyvault"); - mongoc_collection_t *coll = - mongoc_database_get_collection (db, "datakeys"); - bson_error_t error; - bson_t iopts = BSON_INITIALIZER; - mongoc_write_concern_t *wc; - - if (!mongoc_collection_drop (coll, &error)) { - if (error.code != MONGOC_SERVER_ERR_NS_NOT_FOUND) { - test_error ("unexpected error in drop: %s", error.message); - } - } - mongoc_collection_destroy (coll); - - coll = mongoc_database_create_collection ( - db, "datakeys", NULL /* opts */, &error); - ASSERT_OR_PRINT (coll, error); - - /* Insert keyDocument1 with write concern majority */ - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY); - ASSERT (mongoc_write_concern_append (wc, &iopts)); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, key1Document, &iopts, NULL /* reply */, &error), - error); - - mongoc_write_concern_destroy (wc); - bson_destroy (&iopts); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - } - - reef->keyVaultClient = test_framework_new_default_client (); - - /* Create a ClientEncryption object named ``clientEncryption`` */ - { - mongoc_client_encryption_opts_t *ceOpts = - mongoc_client_encryption_opts_new (); - bson_t *kms_providers = _make_local_kms_provider (NULL); - bson_error_t error; - - mongoc_client_encryption_opts_set_keyvault_client (ceOpts, - reef->keyVaultClient); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ceOpts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_kms_providers (ceOpts, kms_providers); - - reef->clientEncryption = mongoc_client_encryption_new (ceOpts, &error); - ASSERT_OR_PRINT (reef->clientEncryption, error); - - bson_destroy (kms_providers); - mongoc_client_encryption_opts_destroy (ceOpts); - } - - /* Create a MongoClient named ``encryptedClient``. */ - { - mongoc_auto_encryption_opts_t *aeOpts = - mongoc_auto_encryption_opts_new (); - bson_t *kms_providers = _make_local_kms_provider (NULL); - bson_error_t error; - - mongoc_auto_encryption_opts_set_keyvault_namespace ( - aeOpts, "keyvault", "datakeys"); - mongoc_auto_encryption_opts_set_kms_providers (aeOpts, kms_providers); - mongoc_auto_encryption_opts_set_bypass_query_analysis (aeOpts, true); - reef->encryptedClient = test_framework_new_default_client (); - ASSERT_OR_PRINT (mongoc_client_enable_auto_encryption ( - reef->encryptedClient, aeOpts, &error), - error); - - bson_destroy (kms_providers); - mongoc_auto_encryption_opts_destroy (aeOpts); - reef->encryptedColl = mongoc_client_get_collection ( - reef->encryptedClient, "db", "explicit_encryption"); - } - - /* Create the values 0, 6, 30, 200, and 201 as BSON values. */ - { - if (0 == strcmp ("DecimalNoPrecision", typeStr) || - 0 == strcmp ("DecimalPrecision", typeStr)) { - reef->zero.value_type = BSON_TYPE_DECIMAL128; - ASSERT ( - bson_decimal128_from_string ("0", &reef->zero.value.v_decimal128)); - reef->six.value_type = BSON_TYPE_DECIMAL128; - ASSERT ( - bson_decimal128_from_string ("6", &reef->six.value.v_decimal128)); - reef->thirty.value_type = BSON_TYPE_DECIMAL128; - ASSERT (bson_decimal128_from_string ( - "30", &reef->thirty.value.v_decimal128)); - reef->twoHundred.value_type = BSON_TYPE_DECIMAL128; - ASSERT (bson_decimal128_from_string ( - "200", &reef->twoHundred.value.v_decimal128)); - reef->twoHundredOne.value_type = BSON_TYPE_DECIMAL128; - ASSERT (bson_decimal128_from_string ( - "201", &reef->twoHundredOne.value.v_decimal128)); - } else if (0 == strcmp ("DoubleNoPrecision", typeStr) || - 0 == strcmp ("DoublePrecision", typeStr)) { - reef->zero.value_type = BSON_TYPE_DOUBLE; - reef->zero.value.v_double = 0; - reef->six.value_type = BSON_TYPE_DOUBLE; - reef->six.value.v_double = 6; - reef->thirty.value_type = BSON_TYPE_DOUBLE; - reef->thirty.value.v_double = 30; - reef->twoHundred.value_type = BSON_TYPE_DOUBLE; - reef->twoHundred.value.v_double = 200; - reef->twoHundredOne.value_type = BSON_TYPE_DOUBLE; - reef->twoHundredOne.value.v_double = 201; - } else if (0 == strcmp ("Date", typeStr)) { - reef->zero.value_type = BSON_TYPE_DATE_TIME; - reef->zero.value.v_datetime = 0; - reef->six.value_type = BSON_TYPE_DATE_TIME; - reef->six.value.v_datetime = 6; - reef->thirty.value_type = BSON_TYPE_DATE_TIME; - reef->thirty.value.v_datetime = 30; - reef->twoHundred.value_type = BSON_TYPE_DATE_TIME; - reef->twoHundred.value.v_datetime = 200; - reef->twoHundredOne.value_type = BSON_TYPE_DATE_TIME; - reef->twoHundredOne.value.v_datetime = 201; - } else if (0 == strcmp ("Int", typeStr)) { - reef->zero.value_type = BSON_TYPE_INT32; - reef->zero.value.v_int32 = 0; - reef->six.value_type = BSON_TYPE_INT32; - reef->six.value.v_int32 = 6; - reef->thirty.value_type = BSON_TYPE_INT32; - reef->thirty.value.v_int32 = 30; - reef->twoHundred.value_type = BSON_TYPE_INT32; - reef->twoHundred.value.v_int32 = 200; - reef->twoHundredOne.value_type = BSON_TYPE_INT32; - reef->twoHundredOne.value.v_int32 = 201; - } else if (0 == strcmp ("Long", typeStr)) { - reef->zero.value_type = BSON_TYPE_INT64; - reef->zero.value.v_int64 = 0; - reef->six.value_type = BSON_TYPE_INT64; - reef->six.value.v_int64 = 6; - reef->thirty.value_type = BSON_TYPE_INT64; - reef->thirty.value.v_int64 = 30; - reef->twoHundred.value_type = BSON_TYPE_INT64; - reef->twoHundred.value.v_int64 = 200; - reef->twoHundredOne.value_type = BSON_TYPE_INT64; - reef->twoHundredOne.value.v_int64 = 201; - } else { - test_error ("Unexpected type string: %s\n", typeStr); - } - } - - /* Create the RangeOpts depending on the type. */ - { - reef->ro = mongoc_client_encryption_encrypt_range_opts_new (); - mongoc_client_encryption_encrypt_range_opts_set_sparsity (reef->ro, 1); - if (0 == strcmp ("DoubleNoPrecision", typeStr) || - 0 == strcmp ("DecimalNoPrecision", typeStr)) { - // DoubleNoPrecision does not need more range options. - } else if (0 == strcmp ("DoublePrecision", typeStr) || - 0 == strcmp ("DecimalPrecision", typeStr)) { - mongoc_client_encryption_encrypt_range_opts_set_min (reef->ro, - &reef->zero); - mongoc_client_encryption_encrypt_range_opts_set_max ( - reef->ro, &reef->twoHundred); - mongoc_client_encryption_encrypt_range_opts_set_precision (reef->ro, - 2); - } else if (0 == strcmp ("Date", typeStr) || - 0 == strcmp ("Int", typeStr) || - 0 == strcmp ("Long", typeStr)) { - mongoc_client_encryption_encrypt_range_opts_set_min (reef->ro, - &reef->zero); - mongoc_client_encryption_encrypt_range_opts_set_max ( - reef->ro, &reef->twoHundred); - } else { - test_error ("Unexpected type string: %s\n", typeStr); - } - } - - /* Encrypt and insert 0, 6, 30, and 200. */ - { - mongoc_client_encryption_encrypt_opts_t *eo; - bool ok; - bson_error_t error; - - eo = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eo, &reef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eo, MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eo, 0); - mongoc_client_encryption_encrypt_opts_set_range_opts (eo, reef->ro); - - bson_value_t *values[4]; - values[0] = &reef->zero; - values[1] = &reef->six; - values[2] = &reef->thirty; - values[3] = &reef->twoHundred; - - for (size_t i = 0; i < sizeof values / sizeof values[0]; i++) { - bson_value_t *value = values[i]; - bson_value_t ciphertext; - ok = mongoc_client_encryption_encrypt ( - reef->clientEncryption, value, eo, &ciphertext, &error); - ASSERT_OR_PRINT (ok, error); - bson_t *doc = bson_new (); - BSON_APPEND_INT32 (doc, "_id", (int32_t) i); - BSON_APPEND_VALUE (doc, reef->fieldName, &ciphertext); - ok = mongoc_collection_insert_one (reef->encryptedColl, - doc, - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - bson_destroy (doc); - bson_value_destroy (&ciphertext); - } - - mongoc_client_encryption_encrypt_opts_destroy (eo); - } - - mongoc_client_destroy (setupClient); - bson_destroy (key1Document); - bson_destroy (encryptedFields); - return reef; -} - -static void -range_explicit_encryption_destroy (ree_fixture *reef) -{ - if (!reef) { - return; - } - - bson_free (reef->fieldName); - mongoc_client_encryption_encrypt_range_opts_destroy (reef->ro); - mongoc_collection_destroy (reef->encryptedColl); - mongoc_client_destroy (reef->encryptedClient); - mongoc_client_encryption_destroy (reef->clientEncryption); - mongoc_client_destroy (reef->keyVaultClient); - bson_value_destroy (&reef->key1ID); - bson_free (reef); -} - -// range_explicit_encryption_assert_cursor_results asserts that the encrypted -// field in documents returned by the cursor have match a list of values. The -// variadic args are a list of const bson_value_t *. The variadic args must be -// NULL terminated. -static void -range_explicit_encryption_assert_cursor_results (ree_fixture *reef, - mongoc_cursor_t *cursor, - ...) -{ - const bson_t *got; - va_list args; - bson_error_t error; - - va_start (args, cursor); - while (true) { - const bson_value_t *expect = va_arg (args, const bson_value_t *); - if (!expect) { - break; - } - if (!mongoc_cursor_next (cursor, &got)) { - if (mongoc_cursor_error (cursor, &error)) { - test_error ("Got unexpected error in mongoc_cursor_next: %s", - error.message); - } - test_error ("Expected document with value: %s but got end of cursor", - bson_value_to_str (expect)); - } - bson_iter_t goti; - const bson_value_t *gotv; - if (!bson_iter_init_find (&goti, got, reef->fieldName)) { - test_error ("Expected to find field %s, but got %s", - reef->fieldName, - bson_as_canonical_extended_json (got, NULL)); - } - gotv = bson_iter_value (&goti); - ASSERT_BSONVALUE_EQ (expect, gotv); - } - va_end (args); - if (mongoc_cursor_next (cursor, &got)) { - test_error ("Expected end of cursor, but got extra document: %s", - bson_as_canonical_extended_json (got, NULL)); - } -} - -static void -test_range_explicit_encryption_case1 (void *ctx) -{ - // Case 1: can decrypt a payload - const char *typeStr = (const char *) ctx; - mongoc_client_encryption_encrypt_opts_t *eo; - ree_fixture *reef = range_explicit_encryption_setup (typeStr); - bool ok; - bson_error_t error; - bson_value_t insertPayload; - bson_value_t decrypted; - - eo = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eo, &reef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eo, MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eo, 0); - mongoc_client_encryption_encrypt_opts_set_range_opts (eo, reef->ro); - - /* Use clientEncryption.encrypt() to encrypt the value 6. */ - ok = mongoc_client_encryption_encrypt ( - reef->clientEncryption, &reef->six, eo, &insertPayload, &error); - ASSERT_OR_PRINT (ok, error); - - /* Use clientEncryption to decrypt insertPayload. Assert the returned - value equals 6. */ - ok = mongoc_client_encryption_decrypt ( - reef->clientEncryption, &insertPayload, &decrypted, &error); - ASSERT_OR_PRINT (ok, error); - ASSERT_BSONVALUE_EQ (&decrypted, &reef->six); - - bson_value_destroy (&insertPayload); - mongoc_client_encryption_encrypt_opts_destroy (eo); - range_explicit_encryption_destroy (reef); -} - -static void -test_range_explicit_encryption_case2 (void *ctx) -{ - // Case 2: can find encrypted range and return the maximum - const char *typeStr = (const char *) ctx; - ree_fixture *reef = range_explicit_encryption_setup (typeStr); - bool ok; - bson_error_t error; - - // Encrypt. - bson_t findPayload; - { - mongoc_client_encryption_encrypt_opts_t *eo = - mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eo, &reef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eo, MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_query_type ( - eo, MONGOC_ENCRYPT_QUERY_TYPE_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eo, 0); - mongoc_client_encryption_encrypt_opts_set_range_opts (eo, reef->ro); - - bsonBuildDecl ( - expr, - kv ("$and", - array ( // - doc (kv (reef->fieldName, // - doc (kv ("$gte", value (reef->six))))), // - doc (kv (reef->fieldName, - doc (kv ("$lte", value (reef->twoHundred)))))))); - - ok = mongoc_client_encryption_encrypt_expression ( - reef->clientEncryption, &expr, eo, &findPayload, &error); - ASSERT_OR_PRINT (ok, error); - bson_destroy (&expr); - mongoc_client_encryption_encrypt_opts_destroy (eo); - } - - // Query and check results. - { - bson_t *opts = tmp_bson ("{'sort': { '_id': 1 }}"); - mongoc_cursor_t *cursor = mongoc_collection_find_with_opts ( - reef->encryptedColl, &findPayload, opts, NULL /* read_prefs */); - range_explicit_encryption_assert_cursor_results ( - reef, cursor, &reef->six, &reef->thirty, &reef->twoHundred, NULL); - mongoc_cursor_destroy (cursor); - } - - bson_destroy (&findPayload); - range_explicit_encryption_destroy (reef); -} - -static void -test_range_explicit_encryption_case3 (void *ctx) -{ - // Case 3: can find encrypted range and return the minimum - const char *typeStr = (const char *) ctx; - ree_fixture *reef = range_explicit_encryption_setup (typeStr); - bool ok; - bson_error_t error; - - // Encrypt. - bson_t findPayload; - { - mongoc_client_encryption_encrypt_opts_t *eo = - mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eo, &reef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eo, MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_query_type ( - eo, MONGOC_ENCRYPT_QUERY_TYPE_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eo, 0); - mongoc_client_encryption_encrypt_opts_set_range_opts (eo, reef->ro); - - bsonBuildDecl (expr, - kv ("$and", - array ( // - doc (kv (reef->fieldName, // - doc (kv ("$gte", value (reef->zero))))), // - doc (kv (reef->fieldName, - doc (kv ("$lte", value (reef->six)))))))); - - ok = mongoc_client_encryption_encrypt_expression ( - reef->clientEncryption, &expr, eo, &findPayload, &error); - ASSERT_OR_PRINT (ok, error); - bson_destroy (&expr); - mongoc_client_encryption_encrypt_opts_destroy (eo); - } - - // Query and check results. - { - bson_t *opts = tmp_bson ("{'sort': { '_id': 1 }}"); - mongoc_cursor_t *cursor = mongoc_collection_find_with_opts ( - reef->encryptedColl, &findPayload, opts, NULL /* read_prefs */); - range_explicit_encryption_assert_cursor_results ( - reef, cursor, &reef->zero, &reef->six, NULL); - mongoc_cursor_destroy (cursor); - } - - bson_destroy (&findPayload); - range_explicit_encryption_destroy (reef); -} - -static void -test_range_explicit_encryption_case4 (void *ctx) -{ - // Case 4: can find encrypted range with an open range query - const char *typeStr = (const char *) ctx; - ree_fixture *reef = range_explicit_encryption_setup (typeStr); - bool ok; - bson_error_t error; - - // Encrypt. - bson_t findPayload; - { - mongoc_client_encryption_encrypt_opts_t *eo = - mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eo, &reef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eo, MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_query_type ( - eo, MONGOC_ENCRYPT_QUERY_TYPE_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eo, 0); - mongoc_client_encryption_encrypt_opts_set_range_opts (eo, reef->ro); - - bsonBuildDecl (expr, - kv ("$and", - array ( // - doc (kv (reef->fieldName, // - doc (kv ("$gt", value (reef->thirty))))) // - ))); - - ok = mongoc_client_encryption_encrypt_expression ( - reef->clientEncryption, &expr, eo, &findPayload, &error); - ASSERT_OR_PRINT (ok, error); - bson_destroy (&expr); - mongoc_client_encryption_encrypt_opts_destroy (eo); - } - - // Query and check results. - { - bson_t *opts = tmp_bson ("{'sort': { '_id': 1 }}"); - mongoc_cursor_t *cursor = mongoc_collection_find_with_opts ( - reef->encryptedColl, &findPayload, opts, NULL /* read_prefs */); - range_explicit_encryption_assert_cursor_results ( - reef, cursor, &reef->twoHundred, NULL); - mongoc_cursor_destroy (cursor); - } - - bson_destroy (&findPayload); - range_explicit_encryption_destroy (reef); -} - -static void -test_range_explicit_encryption_case5 (void *ctx) -{ - // Case 5: can run an aggregation expression inside $expr - const char *typeStr = (const char *) ctx; - ree_fixture *reef = range_explicit_encryption_setup (typeStr); - bool ok; - bson_error_t error; - - // Encrypt. - bson_t findPayload; - { - mongoc_client_encryption_encrypt_opts_t *eo = - mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eo, &reef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eo, MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_query_type ( - eo, MONGOC_ENCRYPT_QUERY_TYPE_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eo, 0); - mongoc_client_encryption_encrypt_opts_set_range_opts (eo, reef->ro); - char *fieldPath = bson_strdup_printf ("$%s", reef->fieldName); - - // Encrypt this: - // {'$and': [ { '$lt': [ '$encrypted', 30 ] } ] } } - bsonBuildDecl ( - expr, - kv ("$and", - array ( // - doc (kv ("$lt", // - array (cstr (fieldPath), value (reef->thirty))))))); - - ok = mongoc_client_encryption_encrypt_expression ( - reef->clientEncryption, &expr, eo, &findPayload, &error); - ASSERT_OR_PRINT (ok, error); - bson_free (fieldPath); - bson_destroy (&expr); - mongoc_client_encryption_encrypt_opts_destroy (eo); - } - - // Query and check results. - { - bson_t *opts = tmp_bson ("{'sort': { '_id': 1 }}"); - bsonBuildDecl (filter, kv ("$expr", bson (findPayload))); - mongoc_cursor_t *cursor = mongoc_collection_find_with_opts ( - reef->encryptedColl, &filter, opts, NULL /* read_prefs */); - range_explicit_encryption_assert_cursor_results ( - reef, cursor, &reef->zero, &reef->six, NULL); - bson_destroy (&filter); - mongoc_cursor_destroy (cursor); - } - - bson_destroy (&findPayload); - range_explicit_encryption_destroy (reef); -} - -static void -test_range_explicit_encryption_case6 (void *ctx) -{ - // Case 6: encrypting a document greater than the maximum errors - const char *typeStr = (const char *) ctx; - - // This test case should be skipped if the encrypted field is - // encryptedDoubleNoPrecision or encryptedDecimalNoPrecision. - if (0 == strcmp (typeStr, "DoubleNoPrecision") || - 0 == strcmp (typeStr, "DecimalNoPrecision")) { - MONGOC_DEBUG ("skipping test"); - return; - } - - ree_fixture *reef = range_explicit_encryption_setup (typeStr); - bool ok; - bson_error_t error; - - // Encrypt. - bson_value_t insertPayload; - { - mongoc_client_encryption_encrypt_opts_t *eo = - mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eo, &reef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eo, MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eo, 0); - mongoc_client_encryption_encrypt_opts_set_range_opts (eo, reef->ro); - - ok = mongoc_client_encryption_encrypt (reef->clientEncryption, - &reef->twoHundredOne, - eo, - &insertPayload, - &error); - ASSERT (!ok); - mongoc_client_encryption_encrypt_opts_destroy (eo); - } - - bson_value_destroy (&insertPayload); - range_explicit_encryption_destroy (reef); -} - -static void -test_range_explicit_encryption_case7 (void *ctx) -{ - // Case 7: encrypting a document of a different type errors - const char *typeStr = (const char *) ctx; - - // This test case should be skipped if the encrypted field is - // encryptedDoubleNoPrecision or encryptedDecimalNoPrecision. - if (0 == strcmp (typeStr, "DoubleNoPrecision") || - 0 == strcmp (typeStr, "DecimalNoPrecision")) { - MONGOC_DEBUG ("skipping test"); - return; - } - - ree_fixture *reef = range_explicit_encryption_setup (typeStr); - bool ok; - bson_error_t error; - - // Encrypt. - bson_value_t insertPayload; - { - mongoc_client_encryption_encrypt_opts_t *eo = - mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eo, &reef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eo, MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eo, 0); - mongoc_client_encryption_encrypt_opts_set_range_opts (eo, reef->ro); - - bson_value_t wrongType; - if (0 == strcmp ("encryptedInt", reef->fieldName)) { - wrongType.value_type = BSON_TYPE_DOUBLE; - wrongType.value.v_double = 6; - } else { - wrongType.value_type = BSON_TYPE_INT32; - wrongType.value.v_int32 = 6; - } - - ok = mongoc_client_encryption_encrypt ( - reef->clientEncryption, &wrongType, eo, &insertPayload, &error); - ASSERT (!ok); - mongoc_client_encryption_encrypt_opts_destroy (eo); - } - - bson_value_destroy (&insertPayload); - range_explicit_encryption_destroy (reef); -} - -static void -test_range_explicit_encryption_case8 (void *ctx) -{ - // Case 8: setting precision errors if the type is not a double - const char *typeStr = (const char *) ctx; - - // This test case should be skipped if the encrypted field is - // encryptedDoublePrecision or encryptedDoubleNoPrecision or - // encryptedDecimalPrecision or encryptedDecimalNoPrecision. - if (0 == strcmp (typeStr, "DoubleNoPrecision") || - 0 == strcmp (typeStr, "DoublePrecision") || - 0 == strcmp (typeStr, "DecimalPrecision") || - 0 == strcmp (typeStr, "DecimalNoPrecision")) { - MONGOC_DEBUG ("skipping test"); - return; - } - - ree_fixture *reef = range_explicit_encryption_setup (typeStr); - bool ok; - bson_error_t error; - - // Encrypt. - bson_value_t insertPayload; - { - mongoc_client_encryption_encrypt_opts_t *eo = - mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eo, &reef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eo, MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eo, 0); - mongoc_client_encryption_encrypt_range_opts_set_precision (reef->ro, 2); - mongoc_client_encryption_encrypt_opts_set_range_opts (eo, reef->ro); - - ok = mongoc_client_encryption_encrypt ( - reef->clientEncryption, &reef->six, eo, &insertPayload, &error); - ASSERT (!ok); - mongoc_client_encryption_encrypt_opts_destroy (eo); - } - - bson_value_destroy (&insertPayload); - range_explicit_encryption_destroy (reef); -} - -static void -test_explicit_encryption_case1 (void *unused) -{ - /* Case 1: can insert encrypted indexed and find */ - bson_error_t error; - bool ok; - mongoc_client_encryption_encrypt_opts_t *eopts; - bson_value_t plaintext = {0}; - ee_fixture *eef = explicit_encryption_setup (); - - BSON_UNUSED (unused); - - plaintext.value_type = BSON_TYPE_UTF8; - plaintext.value.v_utf8.str = "encrypted indexed value"; - plaintext.value.v_utf8.len = (uint32_t) strlen (plaintext.value.v_utf8.str); - - /* Use ``encryptedClient`` to insert the document ``{ "encryptedIndexed": - * }``. */ - { - bson_value_t insertPayload; - bson_t to_insert = BSON_INITIALIZER; - - eopts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eopts, &eef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eopts, MONGOC_ENCRYPT_ALGORITHM_INDEXED); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eopts, 0); - - ok = mongoc_client_encryption_encrypt ( - eef->clientEncryption, &plaintext, eopts, &insertPayload, &error); - ASSERT_OR_PRINT (ok, error); - - ASSERT ( - BSON_APPEND_VALUE (&to_insert, "encryptedIndexed", &insertPayload)); - - ok = mongoc_collection_insert_one (eef->encryptedColl, - &to_insert, - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - - bson_value_destroy (&insertPayload); - bson_destroy (&to_insert); - mongoc_client_encryption_encrypt_opts_destroy (eopts); - } - - /* Use ``encryptedClient`` to run a "find" operation on the - * ``db.explicit_encryption`` collection with the filter ``{ - * "encryptedIndexed": }``. */ - { - bson_value_t findPayload; - mongoc_cursor_t *cursor; - bson_t filter = BSON_INITIALIZER; - const bson_t *got; - - eopts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eopts, &eef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eopts, MONGOC_ENCRYPT_ALGORITHM_INDEXED); - mongoc_client_encryption_encrypt_opts_set_query_type ( - eopts, MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eopts, 0); - - ok = mongoc_client_encryption_encrypt ( - eef->clientEncryption, &plaintext, eopts, &findPayload, &error); - ASSERT_OR_PRINT (ok, error); - - ASSERT (BSON_APPEND_VALUE (&filter, "encryptedIndexed", &findPayload)); - - cursor = mongoc_collection_find_with_opts ( - eef->encryptedColl, &filter, NULL /* opts */, NULL /* read_prefs */); - ASSERT (mongoc_cursor_next (cursor, &got)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT_MATCH (got, "{ 'encryptedIndexed': 'encrypted indexed value' }"); - ASSERT (!mongoc_cursor_next (cursor, &got) && - "expected one document to be returned, got more than one"); - - bson_value_destroy (&findPayload); - mongoc_cursor_destroy (cursor); - mongoc_client_encryption_encrypt_opts_destroy (eopts); - bson_destroy (&filter); - } - - explicit_encryption_destroy (eef); -} - -static void -test_explicit_encryption_case2 (void *unused) -{ - /* Case 2: can insert encrypted indexed and find with non-zero contention */ - bson_error_t error; - bool ok; - mongoc_client_encryption_encrypt_opts_t *eopts; - bson_value_t plaintext = {0}; - int i = 0; - ee_fixture *eef = explicit_encryption_setup (); - - BSON_UNUSED (unused); - - plaintext.value_type = BSON_TYPE_UTF8; - plaintext.value.v_utf8.str = "encrypted indexed value"; - plaintext.value.v_utf8.len = (uint32_t) strlen (plaintext.value.v_utf8.str); - - /* Insert 10 documents ``{ "encryptedIndexed": }`` with - * contention factor 10. */ - for (i = 0; i < 10; i++) { - bson_value_t insertPayload; - bson_t to_insert = BSON_INITIALIZER; - - eopts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eopts, &eef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eopts, MONGOC_ENCRYPT_ALGORITHM_INDEXED); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eopts, 10); - - ok = mongoc_client_encryption_encrypt ( - eef->clientEncryption, &plaintext, eopts, &insertPayload, &error); - ASSERT_OR_PRINT (ok, error); - - ASSERT ( - BSON_APPEND_VALUE (&to_insert, "encryptedIndexed", &insertPayload)); - - ok = mongoc_collection_insert_one (eef->encryptedColl, - &to_insert, - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - - bson_value_destroy (&insertPayload); - bson_destroy (&to_insert); - mongoc_client_encryption_encrypt_opts_destroy (eopts); - } - - /* Find with contention factor of 0. Expect < 10 documents returned. - */ - { - bson_value_t findPayload; - mongoc_cursor_t *cursor; - bson_t filter = BSON_INITIALIZER; - const bson_t *got; - int got_count = 0; - - eopts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eopts, &eef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eopts, MONGOC_ENCRYPT_ALGORITHM_INDEXED); - mongoc_client_encryption_encrypt_opts_set_query_type ( - eopts, MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eopts, 0); - - ok = mongoc_client_encryption_encrypt ( - eef->clientEncryption, &plaintext, eopts, &findPayload, &error); - ASSERT_OR_PRINT (ok, error); - - ASSERT (BSON_APPEND_VALUE (&filter, "encryptedIndexed", &findPayload)); - - cursor = mongoc_collection_find_with_opts ( - eef->encryptedColl, &filter, NULL /* opts */, NULL /* read_prefs */); - - while (mongoc_cursor_next (cursor, &got)) { - got_count++; - ASSERT_MATCH (got, - "{ 'encryptedIndexed': 'encrypted indexed value' }"); - } - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT_CMPINT (got_count, <, 10); - - bson_value_destroy (&findPayload); - mongoc_cursor_destroy (cursor); - mongoc_client_encryption_encrypt_opts_destroy (eopts); - bson_destroy (&filter); - } - - /* Find with contention factor of 10. Expect all 10 documents returned. */ - { - bson_value_t findPayload; - mongoc_cursor_t *cursor; - bson_t filter = BSON_INITIALIZER; - const bson_t *got; - int got_count = 0; - - eopts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eopts, &eef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eopts, MONGOC_ENCRYPT_ALGORITHM_INDEXED); - mongoc_client_encryption_encrypt_opts_set_query_type ( - eopts, MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eopts, 10); - - ok = mongoc_client_encryption_encrypt ( - eef->clientEncryption, &plaintext, eopts, &findPayload, &error); - ASSERT_OR_PRINT (ok, error); - - ASSERT (BSON_APPEND_VALUE (&filter, "encryptedIndexed", &findPayload)); - - cursor = mongoc_collection_find_with_opts ( - eef->encryptedColl, &filter, NULL /* opts */, NULL /* read_prefs */); - - while (mongoc_cursor_next (cursor, &got)) { - got_count++; - ASSERT_MATCH (got, - "{ 'encryptedIndexed': 'encrypted indexed value' }"); - } - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT_CMPINT (got_count, ==, 10); - - bson_value_destroy (&findPayload); - mongoc_cursor_destroy (cursor); - mongoc_client_encryption_encrypt_opts_destroy (eopts); - bson_destroy (&filter); - } - - explicit_encryption_destroy (eef); -} - -static void -test_explicit_encryption_case3 (void *unused) -{ - /* Case 3: can insert encrypted unindexed */ - bson_error_t error; - bool ok; - mongoc_client_encryption_encrypt_opts_t *eopts; - bson_value_t plaintext = {0}; - ee_fixture *eef = explicit_encryption_setup (); - - BSON_UNUSED (unused); - - plaintext.value_type = BSON_TYPE_UTF8; - plaintext.value.v_utf8.str = "encrypted unindexed value"; - plaintext.value.v_utf8.len = (uint32_t) strlen (plaintext.value.v_utf8.str); - - /* Use ``encryptedClient`` to insert the document ``{ "_id": 1, - * "encryptedUnindexed": }``. */ - { - bson_value_t insertPayload; - bson_t to_insert = BSON_INITIALIZER; - - eopts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eopts, &eef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eopts, MONGOC_ENCRYPT_ALGORITHM_UNINDEXED); - - ok = mongoc_client_encryption_encrypt ( - eef->clientEncryption, &plaintext, eopts, &insertPayload, &error); - ASSERT_OR_PRINT (ok, error); - - ASSERT (BSON_APPEND_INT32 (&to_insert, "_id", 1)); - ASSERT ( - BSON_APPEND_VALUE (&to_insert, "encryptedUnindexed", &insertPayload)); - - ok = mongoc_collection_insert_one (eef->encryptedColl, - &to_insert, - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - - bson_value_destroy (&insertPayload); - bson_destroy (&to_insert); - mongoc_client_encryption_encrypt_opts_destroy (eopts); - } - - /* Use ``encryptedClient`` to run a "find" operation on the - * ``db.explicit_encryption`` collection with the filter ``{ "_id": 1 }``. */ - { - mongoc_cursor_t *cursor; - bson_t filter = BSON_INITIALIZER; - const bson_t *got; - - ASSERT (BSON_APPEND_INT32 (&filter, "_id", 1)); - - cursor = mongoc_collection_find_with_opts ( - eef->encryptedColl, &filter, NULL /* opts */, NULL /* read_prefs */); - ASSERT (mongoc_cursor_next (cursor, &got)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT_MATCH (got, - "{ 'encryptedUnindexed': 'encrypted unindexed value' }"); - ASSERT (!mongoc_cursor_next (cursor, &got) && - "expected one document to be returned, got more than one"); - - mongoc_cursor_destroy (cursor); - bson_destroy (&filter); - } - - explicit_encryption_destroy (eef); -} - -static void -test_explicit_encryption_case4 (void *unused) -{ - /* Case 4: can roundtrip encrypted indexed */ - bson_error_t error; - bool ok; - mongoc_client_encryption_encrypt_opts_t *eopts; - bson_value_t plaintext = {0}; - bson_value_t payload; - ee_fixture *eef = explicit_encryption_setup (); - - BSON_UNUSED (unused); - - plaintext.value_type = BSON_TYPE_UTF8; - plaintext.value.v_utf8.str = "encrypted indexed value"; - plaintext.value.v_utf8.len = (uint32_t) strlen (plaintext.value.v_utf8.str); - - /* Use ``clientEncryption`` to encrypt the value "encrypted indexed value". - */ - { - eopts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eopts, &eef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eopts, MONGOC_ENCRYPT_ALGORITHM_INDEXED); - mongoc_client_encryption_encrypt_opts_set_contention_factor (eopts, 0); - - ok = mongoc_client_encryption_encrypt ( - eef->clientEncryption, &plaintext, eopts, &payload, &error); - ASSERT_OR_PRINT (ok, error); - - mongoc_client_encryption_encrypt_opts_destroy (eopts); - } - - /* Use ``clientEncryption`` to decrypt ``payload`` */ - { - bson_value_t got; - - ok = mongoc_client_encryption_decrypt ( - eef->clientEncryption, &payload, &got, &error); - ASSERT_OR_PRINT (ok, error); - ASSERT (got.value_type == BSON_TYPE_UTF8); - ASSERT_CMPSTR (got.value.v_utf8.str, "encrypted indexed value"); - bson_value_destroy (&got); - } - - bson_value_destroy (&payload); - explicit_encryption_destroy (eef); -} - -static void -test_explicit_encryption_case5 (void *unused) -{ - /* Case 5: can roundtrip encrypted unindexed */ - bson_error_t error; - bool ok; - mongoc_client_encryption_encrypt_opts_t *eopts; - bson_value_t plaintext = {0}; - bson_value_t payload; - ee_fixture *eef = explicit_encryption_setup (); - - BSON_UNUSED (unused); - - plaintext.value_type = BSON_TYPE_UTF8; - plaintext.value.v_utf8.str = "encrypted unindexed value"; - plaintext.value.v_utf8.len = (uint32_t) strlen (plaintext.value.v_utf8.str); - - /* Use ``clientEncryption`` to encrypt the value "encrypted unindexed value". - */ - { - eopts = mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eopts, &eef->key1ID); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eopts, MONGOC_ENCRYPT_ALGORITHM_UNINDEXED); - - ok = mongoc_client_encryption_encrypt ( - eef->clientEncryption, &plaintext, eopts, &payload, &error); - ASSERT_OR_PRINT (ok, error); - - mongoc_client_encryption_encrypt_opts_destroy (eopts); - } - - /* Use ``clientEncryption`` to decrypt ``payload`` */ - { - bson_value_t got; - - ok = mongoc_client_encryption_decrypt ( - eef->clientEncryption, &payload, &got, &error); - ASSERT_OR_PRINT (ok, error); - ASSERT (got.value_type == BSON_TYPE_UTF8); - ASSERT_CMPSTR (got.value.v_utf8.str, "encrypted unindexed value"); - bson_value_destroy (&got); - } - - bson_value_destroy (&payload); - explicit_encryption_destroy (eef); -} - -static void -_test_unique_index_on_keyaltnames_setup ( - void (*test_case) (mongoc_client_encryption_t *, const bson_value_t *keyid)) -{ - mongoc_client_t *client = NULL; - mongoc_database_t *keyvault = NULL; - mongoc_client_encryption_t *client_encryption = NULL; - bson_value_t existing_key; - bson_error_t error; - - /* Create a MongoClient object (referred to as client). */ - client = test_framework_new_default_client (); - keyvault = mongoc_client_get_database (client, "keyvault"); - - /* Using client, drop the collection keyvault.datakeys. */ - { - mongoc_collection_t *const datakeys = - mongoc_database_get_collection (keyvault, "datakeys"); - mongoc_collection_drop (datakeys, &error); - mongoc_collection_destroy (datakeys); - } - - /* Using client, create a unique index on keyAltNames with a partial index - * filter for only documents where keyAltNames exists. */ - { - mongoc_collection_t *const datakeys = - mongoc_database_get_collection (keyvault, "datakeys"); - - mongoc_index_model_t *im = mongoc_index_model_new ( - tmp_bson ("{'keyAltNames': 1}"), tmp_bson (BSON_STR ({ - "name" : "keyAltNames_1", - "unique" : true, - "partialFilterExpression" : {"keyAltNames" : {"$exists" : true}} - }))); - - bson_t *const command_opts = - tmp_bson ("{'writeConcern': { 'w': 'majority' }}"); - - ASSERT_OR_PRINT ( - mongoc_collection_create_indexes_with_opts ( - datakeys, &im, 1, command_opts, NULL /* reply */, &error), - error); - mongoc_index_model_destroy (im); - mongoc_collection_destroy (datakeys); - } - - /* Create a ClientEncryption object (referred to as client_encryption) with - * client set as the keyVaultClient. */ - { - mongoc_client_encryption_opts_t *const client_encryption_opts = - mongoc_client_encryption_opts_new (); - bson_t *const kms_providers = - _make_kms_providers (true /* aws */, true /* local */); - bson_t *const tls_opts = _make_tls_opts (); - - mongoc_client_encryption_opts_set_kms_providers (client_encryption_opts, - kms_providers); - mongoc_client_encryption_opts_set_tls_opts (client_encryption_opts, - tls_opts); - mongoc_client_encryption_opts_set_keyvault_namespace ( - client_encryption_opts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (client_encryption_opts, - client); - client_encryption = - mongoc_client_encryption_new (client_encryption_opts, &error); - ASSERT_OR_PRINT (client_encryption, error); - - mongoc_client_encryption_opts_destroy (client_encryption_opts); - bson_destroy (kms_providers); - bson_destroy (tls_opts); - } - - /* Using client_encryption, create a data key with a local KMS provider - * and the keyAltName "def" (referred to as "the existing key"). */ - { - mongoc_client_encryption_datakey_opts_t *const opts = - mongoc_client_encryption_datakey_opts_new (); - const char *const keyaltname[] = {"def"}; - - mongoc_client_encryption_datakey_opts_set_keyaltnames ( - opts, (char **) keyaltname, 1u); - - ASSERT_OR_PRINT ( - mongoc_client_encryption_create_datakey ( - client_encryption, "local", opts, &existing_key, &error), - error); - - mongoc_client_encryption_datakey_opts_destroy (opts); - } - - test_case (client_encryption, &existing_key); - - mongoc_client_destroy (client); - mongoc_database_destroy (keyvault); - mongoc_client_encryption_destroy (client_encryption); - bson_value_destroy (&existing_key); -} - -static void -_test_unique_index_on_keyaltnames_case_1 ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *existing_key) -{ - bson_error_t error; - - BSON_UNUSED (existing_key); - - /* Step 1: Use client_encryption to create a new local data key with a - * keyAltName "abc" and assert the operation does not fail. */ - { - mongoc_client_encryption_datakey_opts_t *const opts = - mongoc_client_encryption_datakey_opts_new (); - const char *const keyaltname[] = {"abc"}; - bson_value_t keyid; - - mongoc_client_encryption_datakey_opts_set_keyaltnames ( - opts, (char **) keyaltname, 1u); - - ASSERT_OR_PRINT (mongoc_client_encryption_create_datakey ( - client_encryption, "local", opts, &keyid, &error), - error); - - mongoc_client_encryption_datakey_opts_destroy (opts); - bson_value_destroy (&keyid); - } - - /* Step 2: Repeat Step 1 and assert the operation fails due to a duplicate - * key server error (error code 11000). */ - { - mongoc_client_encryption_datakey_opts_t *const opts = - mongoc_client_encryption_datakey_opts_new (); - const char *const keyaltname[] = {"abc"}; - bson_value_t keyid; - - mongoc_client_encryption_datakey_opts_set_keyaltnames ( - opts, (char **) keyaltname, 1u); - - ASSERT (!mongoc_client_encryption_create_datakey ( - client_encryption, "local", opts, &keyid, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COLLECTION, - MONGOC_ERROR_DUPLICATE_KEY, - "keyAltNames: \"abc\""); - - mongoc_client_encryption_datakey_opts_destroy (opts); - bson_value_destroy (&keyid); - } - - /* Step 3: Use client_encryption to create a new local data key with a - * keyAltName "def" and assert the operation fails due to a duplicate key - * server error (error code 11000). */ - { - mongoc_client_encryption_datakey_opts_t *const opts = - mongoc_client_encryption_datakey_opts_new (); - const char *const keyaltname[] = {"def"}; - bson_value_t keyid; - - mongoc_client_encryption_datakey_opts_set_keyaltnames ( - opts, (char **) keyaltname, 1u); - - ASSERT (!mongoc_client_encryption_create_datakey ( - client_encryption, "local", opts, &keyid, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COLLECTION, - MONGOC_ERROR_DUPLICATE_KEY, - "keyAltNames: \"def\""); - - mongoc_client_encryption_datakey_opts_destroy (opts); - bson_value_destroy (&keyid); - } -} - -static void -_test_unique_index_on_keyaltnames_case_2 ( - mongoc_client_encryption_t *client_encryption, - const bson_value_t *existing_key) -{ - bson_value_t new_key; - bson_error_t error; - mongoc_client_encryption_datakey_opts_t *const opts = - mongoc_client_encryption_datakey_opts_new (); - - /* Step 1: Use client_encryption to create a new local data key and assert - * the operation does not fail. */ - ASSERT_OR_PRINT (mongoc_client_encryption_create_datakey ( - client_encryption, "local", opts, &new_key, &error), - error); - - /* Step 2: Use client_encryption to add a keyAltName "abc" to the key created - * in Step 1 and assert the operation does not fail. */ - { - bson_t key_doc; - ASSERT_OR_PRINT (mongoc_client_encryption_add_key_alt_name ( - client_encryption, &new_key, "abc", &key_doc, &error), - error); - bson_destroy (&key_doc); - } - - /* Step 3: Repeat Step 2, assert the operation does not fail, and assert the - * returned key document contains the keyAltName "abc" added in Step 2. */ - { - bson_t key_doc; - ASSERT_OR_PRINT (mongoc_client_encryption_add_key_alt_name ( - client_encryption, &new_key, "abc", &key_doc, &error), - error); - ASSERT ( - match_bson (&key_doc, tmp_bson ("{'keyAltNames': ['abc']}"), false)); - bson_destroy (&key_doc); - } - - /* Step 4: Use client_encryption to add a keyAltName "def" to the key created - * in Step 1 and assert the operation fails due to a duplicate key server - * error (error code 11000). */ - { - bson_t key_doc; - ASSERT (!mongoc_client_encryption_add_key_alt_name ( - client_encryption, &new_key, "def", &key_doc, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_QUERY, - MONGOC_ERROR_DUPLICATE_KEY, - "keyAltNames: \"def\""); - bson_destroy (&key_doc); - } - - /* Step 5: Use client_encryption to add a keyAltName "def" to the existing - * key, assert the operation does not fail, and assert the returned key - * document contains the keyAltName "def" added during Setup. */ - { - bson_t key_doc; - ASSERT_OR_PRINT ( - mongoc_client_encryption_add_key_alt_name ( - client_encryption, existing_key, "def", &key_doc, &error), - error); - ASSERT ( - match_bson (&key_doc, tmp_bson ("{'keyAltNames': ['def']}"), false)); - bson_destroy (&key_doc); - } - - bson_value_destroy (&new_key); - mongoc_client_encryption_datakey_opts_destroy (opts); -} - -/* Prose Test 13: Unique Index on keyAltNames */ -static void -test_unique_index_on_keyaltnames (void *unused) -{ - BSON_UNUSED (unused); - - _test_unique_index_on_keyaltnames_setup ( - _test_unique_index_on_keyaltnames_case_1); - - _test_unique_index_on_keyaltnames_setup ( - _test_unique_index_on_keyaltnames_case_2); -} - -typedef struct { - mongoc_client_t *setupClient; - mongoc_client_t *encryptedClient; - mongoc_collection_t *encryptedColl; - bson_value_t ciphertext; - bson_value_t malformedCiphertext; - /* aggEvent is the CommandSucceeded or CommandFailed event observed for the - * 'aggregate' command run in the test. */ - struct { - const char *gotType; /* "none", "succeeded", or "failed" */ - bson_error_t gotFailedError; - bson_t *gotSucceededReply; - } aggEvent; -} decryption_events_fixture; - -static void -decryption_events_succeeded_cb (const mongoc_apm_command_succeeded_t *event) -{ - decryption_events_fixture *def = - (decryption_events_fixture *) mongoc_apm_command_succeeded_get_context ( - event); - /* Only match the 'aggregate' command. */ - if (0 != strcmp (mongoc_apm_command_succeeded_get_command_name (event), - "aggregate")) { - return; - } - ASSERT_CMPSTR (def->aggEvent.gotType, "none"); - def->aggEvent.gotType = "succeeded"; - def->aggEvent.gotSucceededReply = - bson_copy (mongoc_apm_command_succeeded_get_reply (event)); -} - -static void -decryption_events_failed_cb (const mongoc_apm_command_failed_t *event) -{ - decryption_events_fixture *def = - (decryption_events_fixture *) mongoc_apm_command_failed_get_context ( - event); - - /* Only match the 'aggregate' command. */ - if (0 != strcmp (mongoc_apm_command_failed_get_command_name (event), - "aggregate")) { - return; - } - ASSERT_CMPSTR (def->aggEvent.gotType, "none"); - def->aggEvent.gotType = "failed"; - mongoc_apm_command_failed_get_error (event, &def->aggEvent.gotFailedError); -} - -decryption_events_fixture * -decryption_events_setup (void) -{ - decryption_events_fixture *def = (decryption_events_fixture *) bson_malloc0 ( - sizeof (decryption_events_fixture)); - mongoc_client_encryption_t *clientEncryption; - bson_value_t keyID; - - def->setupClient = test_framework_new_default_client (); - def->aggEvent.gotType = "none"; - - /* Drop and create the collection ``db.decryption_events`` */ - { - mongoc_collection_t *coll = mongoc_client_get_collection ( - def->setupClient, "db", "decryption_events"); - bson_error_t error; - - if (!mongoc_collection_drop (coll, &error)) { - if (error.code != MONGOC_SERVER_ERR_NS_NOT_FOUND) { - test_error ("unexpected error in drop: %s", error.message); - } - } - mongoc_collection_destroy (coll); - } - - /* Create a ClientEncryption object */ - { - mongoc_client_encryption_opts_t *ceOpts = - mongoc_client_encryption_opts_new (); - bson_t *kms_providers = _make_local_kms_provider (NULL); - bson_error_t error; - - mongoc_client_encryption_opts_set_keyvault_client (ceOpts, - def->setupClient); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ceOpts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_kms_providers (ceOpts, kms_providers); - - clientEncryption = mongoc_client_encryption_new (ceOpts, &error); - ASSERT_OR_PRINT (clientEncryption, error); - - bson_destroy (kms_providers); - mongoc_client_encryption_opts_destroy (ceOpts); - } - - /* Create a data key. */ - { - mongoc_client_encryption_datakey_opts_t *dkOpts; - bson_error_t error; - bool res; - - dkOpts = mongoc_client_encryption_datakey_opts_new (); - - res = mongoc_client_encryption_create_datakey ( - clientEncryption, "local", dkOpts, &keyID, &error); - ASSERT_OR_PRINT (res, error); - - mongoc_client_encryption_datakey_opts_destroy (dkOpts); - } - - /* Create a valid ciphertext. */ - { - mongoc_client_encryption_encrypt_opts_t *eOpts; - bson_error_t error; - bson_value_t plaintext; - eOpts = mongoc_client_encryption_encrypt_opts_new (); - plaintext.value_type = BSON_TYPE_UTF8; - plaintext.value.v_utf8.str = "hello"; - - const size_t len = strlen (plaintext.value.v_utf8.str); - ASSERT (bson_in_range_unsigned (uint32_t, len)); - - plaintext.value.v_utf8.len = (uint32_t) len; - - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eOpts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); - mongoc_client_encryption_encrypt_opts_set_keyid (eOpts, &keyID); - - ASSERT_OR_PRINT ( - mongoc_client_encryption_encrypt ( - clientEncryption, &plaintext, eOpts, &def->ciphertext, &error), - error); - - mongoc_client_encryption_encrypt_opts_destroy (eOpts); - } - - /* Create a malformed ciphertext. */ - { - bson_value_copy (&def->ciphertext, &def->malformedCiphertext); - ASSERT (def->ciphertext.value_type == BSON_TYPE_BINARY); - /* Change the last data byte to make malformed. The last data byte is - * part of the HMAC tag. */ - def->malformedCiphertext.value.v_binary - .data[def->malformedCiphertext.value.v_binary.data_len - 1]++; - } - - /* Create a MongoClient with automatic decryption. */ - { - mongoc_auto_encryption_opts_t *aeOpts = - mongoc_auto_encryption_opts_new (); - bson_t *kms_providers = _make_local_kms_provider (NULL); - bson_error_t error; - mongoc_uri_t *uri; - - mongoc_auto_encryption_opts_set_keyvault_namespace ( - aeOpts, "keyvault", "datakeys"); - mongoc_auto_encryption_opts_set_kms_providers (aeOpts, kms_providers); - uri = test_framework_get_uri (); - /* disable retryable reads so only one event is emitted on failure. */ - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYREADS, false); - def->encryptedClient = - test_framework_client_new_from_uri (uri, NULL /* api */); - test_framework_set_ssl_opts (def->encryptedClient); - - ASSERT (mongoc_client_set_error_api (def->encryptedClient, - MONGOC_ERROR_API_VERSION_2)); - ASSERT_OR_PRINT (mongoc_client_enable_auto_encryption ( - def->encryptedClient, aeOpts, &error), - error); - - def->encryptedColl = mongoc_client_get_collection ( - def->encryptedClient, "db", "decryption_events"); - - bson_destroy (kms_providers); - mongoc_auto_encryption_opts_destroy (aeOpts); - mongoc_uri_destroy (uri); - } - - /* Monitor for CommandSucceeded and CommandFailed events. */ - { - mongoc_apm_callbacks_t *cbs = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_succeeded_cb (cbs, decryption_events_succeeded_cb); - mongoc_apm_set_command_failed_cb (cbs, decryption_events_failed_cb); - mongoc_client_set_apm_callbacks (def->encryptedClient, cbs, def); - mongoc_apm_callbacks_destroy (cbs); - } - - mongoc_client_encryption_destroy (clientEncryption); - bson_value_destroy (&keyID); - return def; -} - -static void -decryption_events_fixture_destroy (decryption_events_fixture *def) -{ - mongoc_client_destroy (def->setupClient); - mongoc_client_destroy (def->encryptedClient); - mongoc_collection_destroy (def->encryptedColl); - bson_value_destroy (&def->ciphertext); - bson_value_destroy (&def->malformedCiphertext); - bson_destroy (def->aggEvent.gotSucceededReply); - bson_free (def); -} - -/* Prose test 14: Case 1: Command Error */ -/* test_decryption_events_command_error is a regression test for CDRIVER-4401. - * Send a command on an encrypted client resulting in a { 'ok': 0 } reply. - * Expect an error returned and a CommandFailed event to be emitted. */ -static void -test_decryption_events_case1 (void *unused) -{ - bool got; - bson_error_t error; - decryption_events_fixture *def = decryption_events_setup (); - const bson_t *found; - mongoc_cursor_t *cursor; - - BSON_UNUSED (unused); - - got = mongoc_client_command_simple ( - def->setupClient, - "admin", - tmp_bson ("{'configureFailPoint': 'failCommand', 'mode': {'times': 1}, " - "'data': {'errorCode': 123, 'failCommands': ['aggregate']}}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (got, error); - - cursor = mongoc_collection_aggregate (def->encryptedColl, - MONGOC_QUERY_NONE, - tmp_bson ("{}"), - NULL /* opts */, - NULL /* read prefs */); - - got = mongoc_cursor_next (cursor, &found); - ASSERT_WITH_MSG (!got, - "Expected error in mongoc_cursor_next, but got success"); - - ASSERT (mongoc_cursor_error (cursor, &error)); - - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 123, "failpoint"); - - ASSERT_CMPSTR (def->aggEvent.gotType, "failed"); - ASSERT_ERROR_CONTAINS ( - def->aggEvent.gotFailedError, MONGOC_ERROR_SERVER, 123, "failpoint"); - ASSERT (!got); - mongoc_cursor_destroy (cursor); - decryption_events_fixture_destroy (def); -} - -/* Prose test 14: Case 2: Network Error */ -/* test_decryption_events_network_error is a regression test for CDRIVER-4401. - * Send a command on an encrypted client resulting in a network error. - * Expect an error returned and a CommandFailed event to be emitted. */ -static void -test_decryption_events_case2 (void *unused) - -{ - bool got; - bson_error_t error; - decryption_events_fixture *def = decryption_events_setup (); - const bson_t *found; - mongoc_cursor_t *cursor; - - BSON_UNUSED (unused); - - got = mongoc_client_command_simple ( - def->setupClient, - "admin", - tmp_bson ("{'configureFailPoint': 'failCommand', 'mode': {'times': 1}, " - "'data': {'errorCode': 123, 'closeConnection': true, " - "'failCommands': ['aggregate']}}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (got, error); - - cursor = mongoc_collection_aggregate (def->encryptedColl, - MONGOC_QUERY_NONE, - tmp_bson ("{}"), - NULL /* opts */, - NULL /* read prefs */); - got = mongoc_cursor_next (cursor, &found); - ASSERT_WITH_MSG (!got, - "Expected error in mongoc_cursor_next, but got success"); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "socket error"); - - ASSERT_CMPSTR (def->aggEvent.gotType, "failed"); - ASSERT_ERROR_CONTAINS (def->aggEvent.gotFailedError, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "socket error"); - ASSERT (!got); - mongoc_cursor_destroy (cursor); - decryption_events_fixture_destroy (def); -} - -/* Prose test 14: Case 3: Decrypt Error. */ -/* test_decryption_events_decrypt_error is a regression test for CDRIVER-4401. - * Decrypt a reply with a malformed ciphertext. - * Expect an error returned and a CommandSucceeded event to be emitted with - * ciphertext. */ -static void -test_decryption_events_case3 (void *unused) -{ - bool got; - bson_error_t error; - decryption_events_fixture *def = decryption_events_setup (); - bson_t to_insert = BSON_INITIALIZER; - const bson_t *found; - mongoc_cursor_t *cursor; - - BSON_UNUSED (unused); - - BSON_APPEND_VALUE (&to_insert, "encrypted", &def->malformedCiphertext); - - got = mongoc_collection_insert_one (def->encryptedColl, - &to_insert, - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (got, error); - - cursor = mongoc_collection_aggregate (def->encryptedColl, - MONGOC_QUERY_NONE, - tmp_bson ("{}"), - NULL /* opts */, - NULL /* read prefs */); - got = mongoc_cursor_next (cursor, &found); - ASSERT_WITH_MSG (!got, - "Expected error in mongoc_cursor_next, but got success"); - - ASSERT (mongoc_cursor_error (cursor, &error)); - - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, 1, "HMAC validation failure"); - - ASSERT_CMPSTR (def->aggEvent.gotType, "succeeded"); - ASSERT_MATCH (def->aggEvent.gotSucceededReply, - "{ 'cursor' : { 'firstBatch' : [ { 'encrypted': { " - "'$$type': 'binData' }} ] } }"); - - mongoc_cursor_destroy (cursor); - bson_destroy (&to_insert); - decryption_events_fixture_destroy (def); -} - -/* Prose test 14: Case 4: Decrypt Success. */ -/* test_decryption_events_decrypt_success is a regression test for CDRIVER-4401. - * Decrypt a reply with a valid ciphertext. - * Expect a successful return and a CommandSucceeded event to be emitted with - * ciphertext. */ -static void -test_decryption_events_case4 (void *unused) -{ - bool got; - bson_error_t error; - decryption_events_fixture *def = decryption_events_setup (); - bson_t to_insert = BSON_INITIALIZER; - const bson_t *found; - mongoc_cursor_t *cursor; - - BSON_UNUSED (unused); - - BSON_APPEND_VALUE (&to_insert, "encrypted", &def->ciphertext); - - got = mongoc_collection_insert_one (def->encryptedColl, - &to_insert, - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (got, error); - - cursor = mongoc_collection_aggregate (def->encryptedColl, - MONGOC_QUERY_NONE, - tmp_bson ("{}"), - NULL /* opts */, - NULL /* read prefs */); - got = mongoc_cursor_next (cursor, &found); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT (got); - - ASSERT_CMPSTR (def->aggEvent.gotType, "succeeded"); - - ASSERT_MATCH (def->aggEvent.gotSucceededReply, - "{ 'cursor' : { 'firstBatch' : [ { 'encrypted': { " - "'$$type': 'binData' }} ] } }"); - - mongoc_cursor_destroy (cursor); - bson_destroy (&to_insert); - decryption_events_fixture_destroy (def); -} - -static void -_test_rewrap_with_separate_client_encryption (const char *src_provider, - const char *dst_provider) -{ - mongoc_uri_t *const uri = test_framework_get_uri (); - mongoc_client_encryption_opts_t *const ce_opts = - mongoc_client_encryption_opts_new (); - mongoc_client_t *const src_client = - test_framework_client_new_from_uri (uri, NULL); - mongoc_client_t *const dst_client = - test_framework_client_new_from_uri (uri, NULL); - - bson_error_t error = {0}; - bson_value_t keyid = {0}; - - BSON_ASSERT (uri); - BSON_ASSERT (ce_opts); - BSON_ASSERT (src_client); - BSON_ASSERT (dst_client); - - test_framework_set_ssl_opts (src_client); - test_framework_set_ssl_opts (dst_client); - - { - mongoc_client_encryption_opts_set_keyvault_client (ce_opts, src_client); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ce_opts, "keyvault", "datakeys"); - - { - bson_t *const kms_providers = _make_kms_providers (true, true); - BSON_ASSERT (kms_providers); - mongoc_client_encryption_opts_set_kms_providers (ce_opts, - kms_providers); - bson_destroy (kms_providers); - } - - { - bson_t *const tls_opts = _make_tls_opts (); - BSON_ASSERT (tls_opts); - mongoc_client_encryption_opts_set_tls_opts (ce_opts, tls_opts); - bson_destroy (tls_opts); - } - } - - - // 1. Drop the collection keyvault.datakeys. - { - mongoc_collection_t *datakeys = - mongoc_client_get_collection (src_client, "keyvault", "datakeys"); - ASSERT (datakeys); - (void) mongoc_collection_drop (datakeys, NULL); - mongoc_collection_destroy (datakeys); - } - - // 2. Create a ClientEncryption object named clientEncryption1 with these - // options: (see ce_opts). - mongoc_client_encryption_t *clientEncryption1 = - mongoc_client_encryption_new (ce_opts, &error); - ASSERT_OR_PRINT (clientEncryption1, error); - - // 3. Call clientEncryption1.createDataKey with srcProvider and these - // options: (see below). - { - mongoc_client_encryption_datakey_opts_t *dk_opts = - mongoc_client_encryption_datakey_opts_new (); - - { - bson_t *const src_masterkey = _make_kms_masterkey (src_provider); - BSON_ASSERT (src_masterkey); - mongoc_client_encryption_datakey_opts_set_masterkey (dk_opts, - src_masterkey); - bson_destroy (src_masterkey); - } - - ASSERT_OR_PRINT ( - mongoc_client_encryption_create_datakey ( - clientEncryption1, src_provider, dk_opts, &keyid, &error), - error); - - mongoc_client_encryption_datakey_opts_destroy (dk_opts); - } - - bson_value_t ciphertext = {0}; - - // 4. Call clientEncryption1.encrypt with the value "test" and these options: - // (see below). - { - char message[] = "test"; - - bson_value_t bson_value; - - bson_value.value_type = BSON_TYPE_UTF8; - bson_value.value.v_utf8.str = message; - bson_value.value.v_utf8.len = - (uint32_t) strlen (bson_value.value.v_utf8.str); - - mongoc_client_encryption_encrypt_opts_t *const e_opts = - mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (e_opts, &keyid); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - e_opts, MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC); - ASSERT_OR_PRINT ( - mongoc_client_encryption_encrypt ( - clientEncryption1, &bson_value, e_opts, &ciphertext, &error), - error); - mongoc_client_encryption_encrypt_opts_destroy (e_opts); - } - - // 5. Create a ClientEncryption object named clientEncryption2 with these - // options: (see ce_opts). - mongoc_client_encryption_t *clientEncryption2 = - mongoc_client_encryption_new (ce_opts, &error); - ASSERT_OR_PRINT (clientEncryption2, error); - - mongoc_client_encryption_rewrap_many_datakey_result_t *const result = - mongoc_client_encryption_rewrap_many_datakey_result_new (); - BSON_ASSERT (result); - - // 6. Call clientEncryption2.rewrapManyDataKey with an empty filter and these - // options: (see below). - { - { - bson_t *const dst_masterkey = _make_kms_masterkey (dst_provider); - BSON_ASSERT (dst_masterkey); - ASSERT_OR_PRINT ( - mongoc_client_encryption_rewrap_many_datakey (clientEncryption2, - NULL, - dst_provider, - dst_masterkey, - result, - &error), - error); - bson_destroy (dst_masterkey); - } - - // Assert that the returned - // RewrapManyDataKeyResult.bulkWriteResult.modifiedCount is 1. - const bson_t *const bulk_write_result = - mongoc_client_encryption_rewrap_many_datakey_result_get_bulk_write_result ( - result); - ASSERT (bulk_write_result); - ASSERT_WITH_MSG ( - match_bson (bulk_write_result, tmp_bson ("{'nModified': 1}"), false), - "'%s' does not match expected value", - tmp_json (bulk_write_result)); - } - - // 7. Call clientEncryption1.decrypt with the ciphertext. Assert the return - // value is "test". - { - bson_value_t decrypted = {0}; - - ASSERT (mongoc_client_encryption_decrypt ( - clientEncryption1, &ciphertext, &decrypted, &error)); - - ASSERT (decrypted.value_type == BSON_TYPE_UTF8); - ASSERT (decrypted.value.v_utf8.len != 0u); - ASSERT_CMPSTR (decrypted.value.v_utf8.str, "test"); - - bson_value_destroy (&decrypted); - } - - // 8. Call clientEncryption2.decrypt with the ciphertext. Assert the return - // value is "test". - { - bson_value_t decrypted = {0}; - - ASSERT (mongoc_client_encryption_decrypt ( - clientEncryption2, &ciphertext, &decrypted, &error)); - - ASSERT (decrypted.value_type == BSON_TYPE_UTF8); - ASSERT (decrypted.value.v_utf8.len != 0u); - ASSERT_CMPSTR (decrypted.value.v_utf8.str, "test"); - - bson_value_destroy (&decrypted); - } - - mongoc_client_encryption_rewrap_many_datakey_result_destroy (result); - mongoc_client_encryption_destroy (clientEncryption2); - bson_value_destroy (&ciphertext); - bson_value_destroy (&keyid); - mongoc_client_encryption_destroy (clientEncryption1); - mongoc_client_encryption_opts_destroy (ce_opts); - mongoc_uri_destroy (uri); - mongoc_client_destroy (dst_client); - mongoc_client_destroy (src_client); -} - -/* Prose Test 16: Case 1: Rewrap with separate ClientEncryption */ -static void -test_rewrap_with_separate_client_encryption (void *unused) -{ - BSON_UNUSED (unused); - - const char *const providers[] = {"aws", "azure", "gcp", "kmip", "local"}; - const size_t providers_len = sizeof (providers) / sizeof (*providers); - - for (size_t src_idx = 0u; src_idx < providers_len; ++src_idx) { - for (size_t dst_idx = 0u; dst_idx < providers_len; ++dst_idx) { - const char *const src = providers[src_idx]; - const char *const dst = providers[dst_idx]; - - if (test_suite_debug_output ()) { - printf (" - %s -> %s\n", src, dst); - fflush (stdout); - } - - _test_rewrap_with_separate_client_encryption (src, dst); - } - } -} - -/* Prose Test 16: Case 2: RewrapManyDataKeyOpts.provider is not optional. */ -static void -test_rewrap_without_provider (void *unused) -{ - BSON_UNUSED (unused); - - mongoc_uri_t *const uri = test_framework_get_uri (); - mongoc_client_encryption_opts_t *const ce_opts = - mongoc_client_encryption_opts_new (); - mongoc_client_t *const key_vault_client = - test_framework_client_new_from_uri (uri, NULL); - - bson_error_t error = {0}; - - BSON_ASSERT (uri); - BSON_ASSERT (ce_opts); - BSON_ASSERT (key_vault_client); - - test_framework_set_ssl_opts (key_vault_client); - - { - mongoc_client_encryption_opts_set_keyvault_client (ce_opts, - key_vault_client); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ce_opts, "keyvault", "datakeys"); - - { - bson_t *const kms_providers = _make_kms_providers (true, true); - BSON_ASSERT (kms_providers); - mongoc_client_encryption_opts_set_kms_providers (ce_opts, - kms_providers); - bson_destroy (kms_providers); - } - - { - bson_t *const tls_opts = _make_tls_opts (); - BSON_ASSERT (tls_opts); - mongoc_client_encryption_opts_set_tls_opts (ce_opts, tls_opts); - bson_destroy (tls_opts); - } - } - - // 1. Create a ClientEncryption object named clientEncryption with these - // options: (see ce_opts). - mongoc_client_encryption_t *clientEncryption = - mongoc_client_encryption_new (ce_opts, &error); - ASSERT_OR_PRINT (clientEncryption, error); - - // 2. Call ``clientEncryption.rewrapManyDataKey`` with an empty ``filter`` - // and these options: (see below). - { - bool ok = - mongoc_client_encryption_rewrap_many_datakey (clientEncryption, - NULL /* filter */, - NULL /* kms_provider */, - tmp_bson ("{}"), - NULL /* result */, - &error); - // Assert an error is returned from the driver suggesting that the - // ``provider`` option is required. - ASSERT_WITH_MSG (!ok, "expected error, but got success"); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, - "expected 'provider' to be set to identify type of 'master_key'"); - } - - mongoc_client_encryption_destroy (clientEncryption); - mongoc_client_encryption_opts_destroy (ce_opts); - mongoc_uri_destroy (uri); - mongoc_client_destroy (key_vault_client); -} - -/* test_qe_docs_example tests the documentation example requested in - * CDRIVER-4379. */ -static void -test_qe_docs_example (void *unused) -{ - bson_error_t error; - mongoc_client_t *const client = test_framework_new_default_client (); - bson_t *const kmsProviders = - _make_kms_providers (false /* with aws */, true /* with local */); - bson_value_t key1ID; - bson_value_t key2ID; - bson_t *encryptedFieldsMap; - mongoc_client_t *encryptedClient; - mongoc_collection_t *encryptedColl; - - BSON_UNUSED (unused); - - /* Drop data from prior test runs. */ - { - mongoc_database_t *db; - mongoc_collection_t *coll; - - coll = mongoc_client_get_collection (client, "keyvault", "datakeys"); - if (!mongoc_collection_drop (coll, &error)) { - bool ignored_error = NULL != strstr (error.message, "ns not found"); - ASSERT_OR_PRINT (ignored_error, error); - } - mongoc_collection_destroy (coll); - - db = mongoc_client_get_database (client, "docsExamples"); - ASSERT_OR_PRINT (mongoc_database_drop (db, &error), error); - mongoc_database_destroy (db); - } - - /* Create two data keys. */ - { - mongoc_client_encryption_opts_t *ceOpts; - mongoc_client_encryption_t *ce; - mongoc_client_encryption_datakey_opts_t *dkOpts; - - ceOpts = mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (ceOpts, kmsProviders); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ceOpts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (ceOpts, client); - ce = mongoc_client_encryption_new (ceOpts, &error); - ASSERT_OR_PRINT (ce, error); - - dkOpts = mongoc_client_encryption_datakey_opts_new (); - ASSERT_OR_PRINT (mongoc_client_encryption_create_datakey ( - ce, "local", dkOpts, &key1ID, &error), - error); - ASSERT_OR_PRINT (mongoc_client_encryption_create_datakey ( - ce, "local", dkOpts, &key2ID, &error), - error); - - mongoc_client_encryption_datakey_opts_destroy (dkOpts); - mongoc_client_encryption_destroy (ce); - mongoc_client_encryption_opts_destroy (ceOpts); - } - - /* Create an encryptedFieldsMap. */ - /* clang-format off */ - encryptedFieldsMap = BCON_NEW ( - "docsExamples.encrypted", "{", - "fields", "[", - "{", - "path", "encryptedIndexed", - "bsonType", "string", - "keyId", BCON_BIN (key1ID.value.v_binary.subtype, - key1ID.value.v_binary.data, - key1ID.value.v_binary.data_len), - "queries", "[", "{", "queryType", "equality", "}", "]", - "}", - "{", - "path", "encryptedUnindexed", - "bsonType", "string", - "keyId", BCON_BIN (key2ID.value.v_binary.subtype, - key2ID.value.v_binary.data, - key2ID.value.v_binary.data_len), - "}", - "]", - "}" - ); - /* clang-format on */ - - /* Create an Queryable Encryption collection. */ - { - mongoc_auto_encryption_opts_t *aeOpts; - mongoc_database_t *db; - - encryptedClient = test_framework_new_default_client (); - aeOpts = mongoc_auto_encryption_opts_new (); - mongoc_auto_encryption_opts_set_kms_providers (aeOpts, kmsProviders); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - aeOpts, "keyvault", "datakeys"); - mongoc_auto_encryption_opts_set_encrypted_fields_map (aeOpts, - encryptedFieldsMap); - ASSERT_OR_PRINT ( - mongoc_client_enable_auto_encryption (encryptedClient, aeOpts, &error), - error); - /* Create the Queryable Encryption collection docsExample.encrypted. */ - db = mongoc_client_get_database (encryptedClient, "docsExamples"); - /* Because docsExample.encrypted is in encryptedFieldsMap, it is created - * with Queryable Encryption support. */ - encryptedColl = mongoc_database_create_collection ( - db, "encrypted", NULL /* opts */, &error); - ASSERT_OR_PRINT (encryptedColl, error); - - mongoc_database_destroy (db); - mongoc_auto_encryption_opts_destroy (aeOpts); - } - - /* Auto encrypt an insert and find. */ - { - /* Encrypt an insert. */ - bson_t *to_insert; - bson_t *filter; - const bson_t *got; - mongoc_cursor_t *cursor; - bool found; - bson_iter_t iter; - - to_insert = BCON_NEW ("_id", - BCON_INT32 (1), - "encryptedIndexed", - "indexedValue", - "encryptedUnindexed", - "unindexedValue"); - - ASSERT_OR_PRINT (mongoc_collection_insert_one (encryptedColl, - to_insert, - NULL /* opts */, - NULL /* reply */, - &error), - error); - - filter = BCON_NEW ("encryptedIndexed", "indexedValue"); - cursor = mongoc_collection_find_with_opts ( - encryptedColl, filter, NULL /* opts */, NULL /* read prefs */); - found = mongoc_cursor_next (cursor, &got); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT (found); - ASSERT (bson_iter_init_find (&iter, got, "encryptedIndexed")); - ASSERT (BSON_ITER_HOLDS_UTF8 (&iter)); - ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL /* length */), "indexedValue"); - ASSERT (bson_iter_init_find (&iter, got, "encryptedUnindexed")); - ASSERT (BSON_ITER_HOLDS_UTF8 (&iter)); - ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL /* length */), - "unindexedValue"); - - mongoc_cursor_destroy (cursor); - bson_destroy (filter); - bson_destroy (to_insert); - } - - /* Find documents without decryption. */ - { - mongoc_collection_t *unencryptedColl; - bson_t *filter; - const bson_t *got; - mongoc_cursor_t *cursor; - bool found; - bson_iter_t iter; - - unencryptedColl = - mongoc_client_get_collection (client, "docsExamples", "encrypted"); - filter = BCON_NEW ("_id", BCON_INT32 (1)); - cursor = mongoc_collection_find_with_opts ( - unencryptedColl, filter, NULL /* opts */, NULL /* read prefs */); - found = mongoc_cursor_next (cursor, &got); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT (found); - ASSERT (bson_iter_init_find (&iter, got, "encryptedIndexed")); - ASSERT (BSON_ITER_HOLDS_BINARY (&iter)); - ASSERT (bson_iter_init_find (&iter, got, "encryptedUnindexed")); - ASSERT (BSON_ITER_HOLDS_BINARY (&iter)); - - mongoc_cursor_destroy (cursor); - bson_destroy (filter); - mongoc_collection_destroy (unencryptedColl); - } - - mongoc_collection_destroy (encryptedColl); - mongoc_client_destroy (encryptedClient); - bson_destroy (encryptedFieldsMap); - bson_value_destroy (&key2ID); - bson_value_destroy (&key1ID); - bson_destroy (kmsProviders); - mongoc_client_destroy (client); -} - -struct kms_callback_data { - int value; - const char *set_error; - bool provide_creds; -}; - -static bool -_kms_callback (void *userdata, - const bson_t *params, - bson_t *out, - bson_error_t *error) -{ - struct kms_callback_data *ctx = userdata; - - BSON_UNUSED (params); - - ctx->value = 42; - if (ctx->set_error) { - bson_set_error (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - 1729, - "%s", - ctx->set_error); - return false; - } - if (ctx->provide_creds) { - uint8_t keydata[96] = {0}; - BCON_APPEND (out, - "local", - "{", - "key", - BCON_BIN (BSON_SUBTYPE_BINARY, keydata, sizeof keydata), - "}"); - } - return true; -} - -static void -test_kms_callback (void *unused) -{ - // No interesting datakey options - mongoc_client_encryption_datakey_opts_t *dk_opts = - mongoc_client_encryption_datakey_opts_new (); - - // Create a client encryption object - mongoc_client_encryption_opts_t *opts = mongoc_client_encryption_opts_new (); - mongoc_client_t *cl = test_framework_new_default_client (); - mongoc_client_encryption_opts_set_keyvault_client (opts, cl); - - BSON_UNUSED (unused); - - // Given it an on-demand 'local' provider - bson_t *empty_local = tmp_bson ("{'local': {}}"); - mongoc_client_encryption_opts_set_kms_providers (opts, empty_local); - mongoc_client_encryption_opts_set_keyvault_namespace ( - opts, "testing", "testing"); - - { - // Attempting to create a key from 'local' will fail immediately - // Create a client encryption object for it. - bson_error_t error; - mongoc_client_encryption_t *enc = - mongoc_client_encryption_new (opts, &error); - ASSERT_OR_PRINT (enc, error); - - bson_value_t keyid; - mongoc_client_encryption_create_datakey ( - enc, "local", dk_opts, &keyid, &error); - mongoc_client_encryption_destroy (enc); - - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, 1, "no kms provider set"); - } - - - { - // Now attach a callback - struct kms_callback_data callback_data = {0}; - mongoc_client_encryption_opts_set_kms_credential_provider_callback ( - opts, _kms_callback, &callback_data); - BSON_ASSERT (callback_data.value == 0); - - bson_error_t error; - mongoc_client_encryption_t *enc = - mongoc_client_encryption_new (opts, &error); - ASSERT_OR_PRINT (enc, error); - - bson_value_t keyid; - - { - mongoc_client_encryption_create_datakey ( - enc, "local", dk_opts, &keyid, &error); - - // The callback will have set a value when it was called - BSON_ASSERT (callback_data.value == 42); - - // But we still get an error, because we didn't fill in 'local' - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - 1, - "no kms provider set"); - } - - { - // Now actually provide a key - callback_data.provide_creds = true; - ASSERT_OR_PRINT (mongoc_client_encryption_create_datakey ( - enc, "local", dk_opts, &keyid, &error), - error); - - // The callback will have set a value when it was called - BSON_ASSERT (callback_data.value == 42); - bson_value_destroy (&keyid); - } - - // Clear the value and tell the callback to set its own error - callback_data.value = 0; - callback_data.set_error = - "This is the error that should appear from the callback"; - - { - mongoc_client_encryption_create_datakey ( - enc, "local", dk_opts, &keyid, &error); - // It was called again: - BSON_ASSERT (callback_data.value == 42); - - // This time the callback provided an error - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, - 1729, - "This is the error that should appear from the callback"); - } - - mongoc_client_encryption_destroy (enc); - } - - mongoc_client_encryption_datakey_opts_destroy (dk_opts); - mongoc_client_encryption_opts_destroy (opts); - mongoc_client_destroy (cl); -} - -static void -_test_auto_aws (bool should_succeed) -{ - // Datakey options for AWS - mongoc_client_encryption_datakey_opts_t *dk_opts = - mongoc_client_encryption_datakey_opts_new (); - mongoc_client_encryption_datakey_opts_set_masterkey ( - dk_opts, - tmp_bson ("{ 'region': 'us-east-1', 'key': " - "'arn:aws:kms:us-east-1:579766882180:key/" - "89fcc2c4-08b0-4bd9-9f25-e30687b580d0' }")); - - // Create a client encryption object - mongoc_client_encryption_opts_t *opts = mongoc_client_encryption_opts_new (); - mongoc_client_t *cl = test_framework_new_default_client (); - mongoc_client_encryption_opts_set_keyvault_client (opts, cl); - - // Given it an on-demand 'aws' provider - bson_t *empty_aws = tmp_bson ("{'aws': {}}"); - mongoc_client_encryption_opts_set_kms_providers (opts, empty_aws); - mongoc_client_encryption_opts_set_keyvault_namespace ( - opts, "testing", "testing"); - - { - // Attempting to create a key from 'aws' will require credentials in the - // environment immediately. Create a client encryption object for it. - bson_error_t error; - mongoc_client_encryption_t *enc = - mongoc_client_encryption_new (opts, &error); - ASSERT_OR_PRINT (enc, error); - - bson_value_t keyid; - mongoc_client_encryption_create_datakey ( - enc, "aws", dk_opts, &keyid, &error); - mongoc_client_encryption_destroy (enc); - - if (should_succeed) { - bson_value_destroy (&keyid); - ASSERT_OR_PRINT (error.code == 0, error); - } else { - // We should encounter an error while attempting to connect to the EC2 - // metadata server. - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_CLIENT, MONGOC_ERROR_CLIENT_AUTHENTICATE, ""); - } - } - - mongoc_client_encryption_datakey_opts_destroy (dk_opts); - mongoc_client_encryption_opts_destroy (opts); - mongoc_client_destroy (cl); -} - -static void -test_auto_aws_fail (void *unused) -{ - BSON_UNUSED (unused); - _test_auto_aws (false); -} - -static void -test_auto_aws_succeed (void *unused) -{ - BSON_UNUSED (unused); - _test_auto_aws (true); -} - -static int -_have_aws_creds_env (void *unused) -{ - BSON_UNUSED (unused); - - // State variable: - // Zero: Haven't checked yet - // One: We have AWS creds - // Two = We do not have AWS creds - static int creds_check_state = 0; - if (creds_check_state == 0) { - // We need to do a check - _mongoc_aws_credentials_t creds = {0}; - bson_error_t error; - bool got_creds = _mongoc_aws_credentials_obtain (NULL, &creds, &error); - _mongoc_aws_credentials_cleanup (&creds); - if (got_creds) { - creds_check_state = 1; - } else { - creds_check_state = 2; - } - } - return creds_check_state == 1; -} - -static int -_not_have_aws_creds_env (void *unused) -{ - return !_have_aws_creds_env (unused); -} - -// Test calling mongoc_collection_drop with a NULL bson_error_t when the state -// collections do not exist. This is a regression test for CDRIVER-4457. -static void -test_drop_qe_null_error (void *unused) -{ - bson_error_t error; - mongoc_client_t *const client = test_framework_new_default_client (); - bson_t *const kmsProviders = - _make_kms_providers (false /* with aws */, true /* with local */); - bson_t *encryptedFieldsMap; - mongoc_client_t *encryptedClient; - mongoc_auto_encryption_opts_t *aeOpts; - mongoc_collection_t *coll; - - BSON_UNUSED (unused); - - /* Create an encryptedFieldsMap. */ - encryptedFieldsMap = BCON_NEW ("db.encrypted", "{", "fields", "[", "]", "}"); - encryptedClient = test_framework_new_default_client (); - aeOpts = mongoc_auto_encryption_opts_new (); - mongoc_auto_encryption_opts_set_kms_providers (aeOpts, kmsProviders); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - aeOpts, "keyvault", "datakeys"); - mongoc_auto_encryption_opts_set_encrypted_fields_map (aeOpts, - encryptedFieldsMap); - ASSERT_OR_PRINT ( - mongoc_client_enable_auto_encryption (encryptedClient, aeOpts, &error), - error); - coll = mongoc_client_get_collection (encryptedClient, "db", "encrypted"); - ASSERT (mongoc_collection_drop (coll, NULL)); - - mongoc_collection_destroy (coll); - mongoc_auto_encryption_opts_destroy (aeOpts); - mongoc_client_destroy (encryptedClient); - bson_destroy (encryptedFieldsMap); - bson_destroy (kmsProviders); - mongoc_client_destroy (client); -} - -static bool -_auto_datakeys (struct auto_datakey_context *ctx) -{ - ctx->out_keyid->value.v_int32 = 42; - ctx->out_keyid->value_type = BSON_TYPE_INT32; - return true; -} - -static bool -_auto_datakeys_error (struct auto_datakey_context *ctx) -{ - bson_set_error (ctx->out_error, 42, 1729, "I am an error"); - return false; -} - -static bool -_auto_datakeys_error_noset (struct auto_datakey_context *ctx) -{ - // Do not set an error code, but indicate error anyway - BSON_UNUSED (ctx); - return false; -} - -static void -test_auto_datakeys (void *unused) -{ - BSON_UNUSED (unused); - - bson_error_t error = {0}; - bson_t in_fields = BSON_INITIALIZER; - bsonBuildArray ( // - in_fields, - doc (kv ("keyId", cstr ("keepme"))), // - doc (kv ("keyId", null))); - bson_t out_fields = BSON_INITIALIZER; - bool okay = _mongoc_encryptedFields_fill_auto_datakeys ( - &out_fields, &in_fields, _auto_datakeys, NULL, &error); - ASSERT_ERROR_CONTAINS (error, 0, 0, ""); - ASSERT (okay); - bsonParse ( // - out_fields, - require ( - keyWithType ("0", doc), // - parse (require (allOf (key ("keyId"), strEqual ("keepme")), nop))), - require ( - keyWithType ("1", doc), - parse (require (allOf (keyWithType ("keyId", int32)), - do (ASSERT_CMPINT32 (bsonAs (int32), ==, 42)))))); - ASSERT (bsonParseError == NULL); - bson_destroy (&out_fields); - - // Do it again, but we will generate an error - okay = _mongoc_encryptedFields_fill_auto_datakeys ( - &out_fields, &in_fields, _auto_datakeys_error, NULL, &error); - ASSERT (!okay); - ASSERT_ERROR_CONTAINS (error, 42, 1729, "I am an error"); - bson_destroy (&out_fields); - - // Do it again, but we will generate an error without the factory setting the - // error - okay = _mongoc_encryptedFields_fill_auto_datakeys ( - &out_fields, &in_fields, _auto_datakeys_error_noset, NULL, &error); - ASSERT (!okay); - // Generic error, since the factory didn't provide one: - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_BSON, MONGOC_ERROR_BSON_INVALID, "indicated failure"); - bson_destroy (&out_fields); - bson_destroy (&in_fields); -} - -static void -_do_cec_test (void (*test) (const char *kmsProvider)) -{ - test ("local"); - test ("aws"); -} - -// Declare a createEncryptedCollection test case (See usage below) -#define CEC_TEST(name, ...) \ - static void name##_impl (__VA_ARGS__); \ - static void name (void *unused) \ - { \ - BSON_UNUSED (unused); \ - _do_cec_test (name##_impl); \ - } \ - static void name##_impl (__VA_ARGS__) - -CEC_TEST (test_create_encrypted_collection_simple, const char *kmsProvider) -{ - bson_error_t error = {0}; - mongoc_client_t *const client = test_framework_new_default_client (); - bson_t *const kmsProviders = _make_kms_providers (true, true); - bson_t *const tlsOptions = _make_tls_opts (); - - const char *const dbName = "cec-test-db"; - - // Drop prior data - { - mongoc_collection_t *const coll = - mongoc_client_get_collection (client, "keyvault", "datakeys"); - if (coll) { - mongoc_collection_drop (coll, &error); - bool okay = - error.code == 0 || strstr (error.message, "ns not found") != NULL; - ASSERT_OR_PRINT (okay, error); - } - mongoc_collection_destroy (coll); - - mongoc_database_t *const db = mongoc_client_get_database (client, dbName); - ASSERT_OR_PRINT (mongoc_database_drop (db, &error), error); - mongoc_database_destroy (db); - } - - // Create a CE - mongoc_client_encryption_opts_t *const ceOpts = - mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (ceOpts, kmsProviders); - mongoc_client_encryption_opts_set_tls_opts (ceOpts, tlsOptions); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ceOpts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (ceOpts, client); - mongoc_client_encryption_t *const ce = - mongoc_client_encryption_new (ceOpts, &error); - mongoc_client_encryption_opts_destroy (ceOpts); - ASSERT_OR_PRINT (ce, error); - - // Create the encrypted collection - bsonBuildDecl (ccOpts, - kv ("encryptedFields", - doc (kv ("fields", - array (doc (kv ("path", cstr ("ssn")), - kv ("bsonType", cstr ("string")), - kv ("keyId", null))))))); - mongoc_database_t *const db = mongoc_client_get_database (client, dbName); - bson_t *const mkey = _make_kms_masterkey (kmsProvider); - mongoc_collection_t *const coll = - mongoc_client_encryption_create_encrypted_collection ( - ce, db, "test-coll", &ccOpts, NULL, kmsProvider, mkey, &error); - ASSERT_OR_PRINT (coll, error); - bson_destroy (&ccOpts); - bson_destroy (mkey); - - bsonBuildDecl (doc, kv ("ssn", cstr ("123-45-6789"))); - const bool okay = - mongoc_collection_insert_one (coll, &doc, NULL, NULL, &error); - // Expect a failure: We didn't encrypt the field, and we don't have - // auto-encryption enabled, but the server expects this to be encrypted. - ASSERT (!okay); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_COLLECTION, 121, "failed validation"); - bson_destroy (&doc); - - bson_destroy (kmsProviders); - bson_destroy (tlsOptions); - mongoc_collection_destroy (coll); - mongoc_database_drop (db, &error); - mongoc_database_destroy (db); - mongoc_client_encryption_destroy (ce); - mongoc_client_destroy (client); -} - -static void -test_create_encrypted_collection_no_encryptedFields_helper ( - mongoc_client_t *client, - const char *dbName, - const char *collName, - const char *kmsProvider) -{ - bson_error_t error = {0}; - bson_t *const kmsProviders = _make_kms_providers (true, true); - bson_t *const tlsOptions = _make_tls_opts (); - - ASSERT (client); - - // Drop prior data - { - mongoc_collection_t *const coll = - mongoc_client_get_collection (client, "keyvault", "datakeys"); - if (coll) { - mongoc_collection_drop (coll, &error); - bool okay = - error.code == 0 || strstr (error.message, "ns not found") != NULL; - ASSERT_OR_PRINT (okay, error); - } - mongoc_collection_destroy (coll); - - mongoc_database_t *const db = mongoc_client_get_database (client, dbName); - ASSERT_OR_PRINT (mongoc_database_drop (db, &error), error); - mongoc_database_destroy (db); - } - - // Create a CE - mongoc_client_encryption_opts_t *const ceOpts = - mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (ceOpts, kmsProviders); - mongoc_client_encryption_opts_set_tls_opts (ceOpts, tlsOptions); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ceOpts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (ceOpts, client); - mongoc_client_encryption_t *const ce = - mongoc_client_encryption_new (ceOpts, &error); - mongoc_client_encryption_opts_destroy (ceOpts); - ASSERT_OR_PRINT (ce, error); - - // Create the encrypted collection - bsonBuildDecl (ccOpts, do ()); - mongoc_database_t *const db = mongoc_client_get_database (client, dbName); - bson_t *const mkey = _make_kms_masterkey (kmsProvider); - mongoc_collection_t *const coll = - mongoc_client_encryption_create_encrypted_collection ( - ce, db, collName, &ccOpts, NULL, kmsProvider, mkey, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "No 'encryptedFields' are defined"); - bson_destroy (&ccOpts); - bson_destroy (mkey); - - bson_destroy (kmsProviders); - bson_destroy (tlsOptions); - mongoc_collection_destroy (coll); - mongoc_database_drop (db, &error); - mongoc_database_destroy (db); - mongoc_client_encryption_destroy (ce); -} - -CEC_TEST (test_create_encrypted_collection_no_encryptedFields, - const char *kmsProvider) -{ - const char *dbName = "cec-test-db"; - const char *collName = "test-coll"; - - // Test with a default client. - { - mongoc_client_t *const client = test_framework_new_default_client (); - test_create_encrypted_collection_no_encryptedFields_helper ( - client, dbName, collName, kmsProvider); - mongoc_client_destroy (client); - } - - // Test with a client configured with an encryptedFieldsMap. - // This is not a required test. But a prior implementation checked if the - // target collection was configured in encryptedFieldsMap. - { - mongoc_client_t *const client = test_framework_new_default_client (); - mongoc_auto_encryption_opts_t *aeOpts = - mongoc_auto_encryption_opts_new (); - bson_t *const kmsProviders = - _make_kms_providers (true /* with aws */, true /* with local */); - char *namespace = bson_strdup_printf ("%s.%s", dbName, collName); - bson_t *encryptedFieldsMap = - tmp_bson ("{'%s': {'fields': []}}", namespace); - bson_error_t error; - - mongoc_auto_encryption_opts_set_kms_providers (aeOpts, kmsProviders); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - aeOpts, "keyvault", "datakeys"); - mongoc_auto_encryption_opts_set_encrypted_fields_map (aeOpts, - encryptedFieldsMap); - ASSERT_OR_PRINT ( - mongoc_client_enable_auto_encryption (client, aeOpts, &error), error); - - test_create_encrypted_collection_no_encryptedFields_helper ( - client, dbName, collName, kmsProvider); - - bson_free (namespace); - bson_destroy (kmsProviders); - mongoc_auto_encryption_opts_destroy (aeOpts); - mongoc_client_destroy (client); - } -} - -CEC_TEST (test_create_encrypted_collection_bad_keyId, - const char *const kmsProvider) -{ - bson_error_t error = {0}; - mongoc_client_t *const client = test_framework_new_default_client (); - bson_t *const kmsProviders = _make_kms_providers (true, true); - bson_t *const tlsOptions = _make_tls_opts (); - - const char *const dbName = "cec-test-db"; - - // Drop prior data - { - mongoc_collection_t *const coll = - mongoc_client_get_collection (client, "keyvault", "datakeys"); - if (coll) { - mongoc_collection_drop (coll, &error); - bool okay = - error.code == 0 || strstr (error.message, "ns not found") != NULL; - ASSERT_OR_PRINT (okay, error); - } - mongoc_collection_destroy (coll); - - mongoc_database_t *const db = mongoc_client_get_database (client, dbName); - ASSERT_OR_PRINT (mongoc_database_drop (db, &error), error); - mongoc_database_destroy (db); - } - - // Create a CE - mongoc_client_encryption_opts_t *const ceOpts = - mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (ceOpts, kmsProviders); - mongoc_client_encryption_opts_set_tls_opts (ceOpts, tlsOptions); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ceOpts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (ceOpts, client); - mongoc_client_encryption_t *const ce = - mongoc_client_encryption_new (ceOpts, &error); - mongoc_client_encryption_opts_destroy (ceOpts); - ASSERT_OR_PRINT (ce, error); - - // Create the encrypted collection - bsonBuildDecl (ccOpts, - kv ("encryptedFields", - doc (kv ("fields", - array (doc (kv ("path", cstr ("ssn")), - kv ("bsonType", cstr ("string")), - kv ("keyId", bool (true)))))))); - mongoc_database_t *const db = mongoc_client_get_database (client, dbName); - bson_t *const mkey = _make_kms_masterkey (kmsProvider); - mongoc_collection_t *const coll = - mongoc_client_encryption_create_encrypted_collection ( - ce, db, "test-coll", &ccOpts, NULL, kmsProvider, mkey, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_QUERY, - MONGOC_ERROR_PROTOCOL_INVALID_REPLY, - "create.encryptedFields.fields.keyId"); - bson_destroy (&ccOpts); - bson_destroy (mkey); - - bson_destroy (kmsProviders); - bson_destroy (tlsOptions); - mongoc_collection_destroy (coll); - mongoc_database_drop (db, &error); - mongoc_database_destroy (db); - mongoc_client_encryption_destroy (ce); - mongoc_client_destroy (client); -} - -// Implements Prose Test 21. Case: 4. -CEC_TEST (test_create_encrypted_collection_insert, - const char *const kmsProvider) -{ - bson_error_t error = {0}; - mongoc_client_t *const client = test_framework_new_default_client (); - bson_t *const kmsProviders = _make_kms_providers (true, true); - bson_t *const tlsOptions = _make_tls_opts (); - - const char *const dbName = "cec-test-db"; - - // Drop prior data - { - mongoc_collection_t *const coll = - mongoc_client_get_collection (client, "keyvault", "datakeys"); - if (coll) { - mongoc_collection_drop (coll, &error); - bool okay = - error.code == 0 || strstr (error.message, "ns not found") != NULL; - ASSERT_OR_PRINT (okay, error); - } - mongoc_collection_destroy (coll); - - mongoc_database_t *const db = mongoc_client_get_database (client, dbName); - ASSERT_OR_PRINT (mongoc_database_drop (db, &error), error); - mongoc_database_destroy (db); - } - - // Create a CE - mongoc_client_encryption_opts_t *const ceOpts = - mongoc_client_encryption_opts_new (); - mongoc_client_encryption_opts_set_kms_providers (ceOpts, kmsProviders); - mongoc_client_encryption_opts_set_tls_opts (ceOpts, tlsOptions); - mongoc_client_encryption_opts_set_keyvault_namespace ( - ceOpts, "keyvault", "datakeys"); - mongoc_client_encryption_opts_set_keyvault_client (ceOpts, client); - mongoc_client_encryption_t *const ce = - mongoc_client_encryption_new (ceOpts, &error); - mongoc_client_encryption_opts_destroy (ceOpts); - ASSERT_OR_PRINT (ce, error); - - // Create the encrypted collection - bsonBuildDecl (ccOpts, - kv ("encryptedFields", - doc (kv ("fields", - array (doc (kv ("path", cstr ("ssn")), - kv ("bsonType", cstr ("string")), - kv ("keyId", null))))))); - mongoc_database_t *const db = mongoc_client_get_database (client, dbName); - bson_t new_opts; - bson_t *const mkey = _make_kms_masterkey (kmsProvider); - mongoc_collection_t *const coll = - mongoc_client_encryption_create_encrypted_collection ( - ce, db, "testing1", &ccOpts, &new_opts, kmsProvider, mkey, &error); - ASSERT_OR_PRINT (coll, error); - bson_destroy (&ccOpts); - bson_destroy (mkey); - - // Extract the encryption key ID that was generated by - // CreateEncryptedCollection: - bson_value_t new_keyid; - bsonParse ( - new_opts, - require ( - keyWithType ("encryptedFields", doc), - parse (require ( - keyWithType ("fields", array), - visitEach (require (type (doc)), - parse (require (key ("keyId"), - require (type (binary)), - do ({ - bson_value_copy ( - bson_iter_value ( - (bson_iter_t *) &bsonVisitIter), - &new_keyid); - }), - halt))))))); - ASSERT_CMPSTR (bsonParseError, NULL); - - // Generate some plaintext: - bson_value_t plain; - plain.value_type = BSON_TYPE_UTF8; - plain.value.v_utf8.str = "123-45-6789"; - plain.value.v_utf8.len = (uint32_t) strlen (plain.value.v_utf8.str); - - // Encrypt the value using the new encryption key: - mongoc_client_encryption_encrypt_opts_t *eo = - mongoc_client_encryption_encrypt_opts_new (); - mongoc_client_encryption_encrypt_opts_set_keyid (eo, &new_keyid); - mongoc_client_encryption_encrypt_opts_set_algorithm ( - eo, MONGOC_ENCRYPT_ALGORITHM_UNINDEXED); - bson_value_t ciphertext; - bool okay = - mongoc_client_encryption_encrypt (ce, &plain, eo, &ciphertext, &error); - ASSERT_OR_PRINT (okay, error); - mongoc_client_encryption_encrypt_opts_destroy (eo); - bson_value_destroy (&new_keyid); - - // Insert the ciphertext: - bsonBuildDecl (doc, kv ("ssn", value (ciphertext))); - okay = mongoc_collection_insert_one (coll, &doc, NULL, NULL, &error); - ASSERT_OR_PRINT (okay, error); - // Success! - - bson_destroy (&doc); - bson_value_destroy (&ciphertext); - bson_destroy (kmsProviders); - bson_destroy (tlsOptions); - mongoc_collection_destroy (coll); - mongoc_database_drop (db, &error); - mongoc_database_destroy (db); - mongoc_client_encryption_destroy (ce); - mongoc_client_destroy (client); - bson_destroy (&new_opts); -} - - -typedef struct listen_socket { - mongoc_socket_t *socket; - mongoc_cond_t cond; - bson_mutex_t mutex; - bool failed; - char ip[16]; - unsigned short port; - bool complete; -} listen_socket_args_t; - -static BSON_THREAD_FUN (listen_socket, arg) -{ - listen_socket_args_t *args = arg; - mongoc_socket_t *socket; - struct sockaddr_in server_addr = {0}; - args->failed = false; - - // create a TcpListener on 127.0.0.1 endpoint - socket = mongoc_socket_new (AF_INET, SOCK_STREAM, 0); - BSON_ASSERT (socket); - - server_addr.sin_family = AF_INET; - server_addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - server_addr.sin_port = htons (0); - mongoc_socklen_t addr_len = (mongoc_socklen_t) sizeof server_addr; - - int r = - mongoc_socket_bind (socket, (struct sockaddr *) &server_addr, addr_len); - BSON_ASSERT (r == 0); - - // forward the port and ip for mongocryptdURI - r = mongoc_socket_getsockname ( - socket, (struct sockaddr *) &server_addr, &addr_len); - BSON_ASSERT (r == 0); - - bson_mutex_lock (&args->mutex); - args->port = ntohs (server_addr.sin_port); - inet_ntop (AF_INET, &server_addr.sin_addr, args->ip, sizeof (args->ip)); - mongoc_cond_signal (&args->cond); - bson_mutex_unlock (&args->mutex); - - // listen on socket - r = mongoc_socket_listen (socket, 100); - BSON_ASSERT (r == 0); - _mongoc_usleep (1000); // wait to see if received connection - mongoc_socket_t *ret = - mongoc_socket_accept (socket, bson_get_monotonic_time () + 100); - if (ret) { - // not null received a connection and test should fail - args->failed = true; - } - // signal that test is complete. - bson_mutex_lock (&args->mutex); - args->complete = true; - mongoc_cond_signal (&args->cond); - bson_mutex_unlock (&args->mutex); - - mongoc_socket_destroy (socket); - BSON_THREAD_RETURN; -} - -/* Prose Test 20: Bypass creating mongocryptd client when shared library is - * loaded */ -static void -test_bypass_mongocryptd_shared_library (void *unused) -{ - BSON_UNUSED (unused); - mongoc_client_t *client_encrypted; - mongoc_auto_encryption_opts_t *auto_encryption_opts; - bson_t *kms_providers; - mongoc_database_t *db; - mongoc_collection_t *coll; - bson_error_t error; - bson_thread_t socket_thread; - - // start the socket on a thread - listen_socket_args_t *args = bson_malloc0 (sizeof (listen_socket_args_t)); - bson_mutex_init (&args->mutex); - mongoc_cond_init (&args->cond); - ASSERT_CMPINT ( - 0, ==, mcommon_thread_create (&socket_thread, listen_socket, args)); - - // configure mongoclient with auto encryption - char *env_cryptSharedLibPath = - test_framework_getenv ("MONGOC_TEST_CRYPT_SHARED_LIB_PATH"); - BSON_ASSERT (env_cryptSharedLibPath); - auto_encryption_opts = mongoc_auto_encryption_opts_new (); - kms_providers = BCON_NEW ( - "local", "{", "key", BCON_BIN (0, (uint8_t *) LOCAL_MASTERKEY, 96), "}"); - mongoc_auto_encryption_opts_set_kms_providers (auto_encryption_opts, - kms_providers); - mongoc_auto_encryption_opts_set_keyvault_namespace ( - auto_encryption_opts, "keyvault", "datakeys"); - - // wait for port and ip to be set on the other thread - bson_mutex_lock (&args->mutex); - while (!args->port) { - int cond_ret = mongoc_cond_timedwait (&args->cond, &args->mutex, 5000); - /* ret non-zero indicates an error (a timeout) */ - BSON_ASSERT (!cond_ret); - } - bson_mutex_unlock (&args->mutex); - BSON_ASSERT (strlen (args->ip) > 0); - - // configure extra options - bson_t *extra = tmp_bson ("{'mongocryptdURI': 'mongodb://%s:%d', " - "'cryptSharedLibPath': '%s'}", - args->ip, - args->port, - env_cryptSharedLibPath); - mongoc_auto_encryption_opts_set_extra (auto_encryption_opts, extra); - bson_free (env_cryptSharedLibPath); - // get the client - client_encrypted = test_framework_new_default_client (); - bool ret = mongoc_client_enable_auto_encryption ( - client_encrypted, auto_encryption_opts, &error); - ASSERT_OR_PRINT (ret, error); - - // insert a document - db = mongoc_client_get_database (client_encrypted, "db"); - coll = mongoc_database_get_collection (db, "coll"); - ret = mongoc_collection_insert_one (coll, - tmp_bson ("{'unencrypted': 'test'}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - // Wait for listener thread to complete. - bson_mutex_lock (&args->mutex); - while (!args->complete) { - int cond_ret = mongoc_cond_timedwait (&args->cond, &args->mutex, 5000); - /* ret non-zero indicates an error (a timeout) */ - BSON_ASSERT (!cond_ret); - } - bson_mutex_unlock (&args->mutex); - // failed should be false if the signal did not receive a connection - BSON_ASSERT (!args->failed); - mcommon_thread_join (socket_thread); - - bson_mutex_destroy (&args->mutex); - mongoc_cond_destroy (&args->cond); - bson_destroy (kms_providers); - mongoc_auto_encryption_opts_destroy (auto_encryption_opts); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - mongoc_client_destroy (client_encrypted); - bson_free (args); -} - -void -test_client_side_encryption_install (TestSuite *suite) -{ - install_json_test_suite_with_check ( - suite, - JSON_DIR, - "client_side_encryption/legacy", - test_client_side_encryption_cb, - test_framework_skip_if_no_client_side_encryption); - /* Prose tests from the spec. */ - TestSuite_AddFull ( - suite, - "/client_side_encryption/create_datakey_with_custom_key_material", - test_create_datakey_with_custom_key_material, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_offline /* requires AWS */); - TestSuite_AddFull (suite, - "/client_side_encryption/datakey_and_double_encryption", - test_datakey_and_double_encryption, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_offline /* requires AWS */); - TestSuite_AddFull ( - suite, - "/client_side_encryption/external_key_vault", - test_external_key_vault, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_no_auth /* requires auth for error check */); - TestSuite_AddFull ( - suite, - "/client_side_encryption/bson_size_limits_and_batch_splitting", - test_bson_size_limits_and_batch_splitting, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/views_are_prohibited", - test_views_are_prohibited, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/corpus", - test_corpus, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_offline /* requires AWS */); - TestSuite_AddFull ( - suite, - "/client_side_encryption/custom_endpoint", - test_custom_endpoint, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_offline /* requires AWS, Azure, and GCP */); - TestSuite_AddFull (suite, - "/client_side_encryption/bypass_spawning_mongocryptd/" - "mongocryptdBypassSpawn", - test_bypass_spawning_via_mongocryptdBypassSpawn, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/bypass_spawning_mongocryptd/" - "bypassAutoEncryption", - test_bypass_spawning_via_bypassAutoEncryption, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/bypass_spawning_mongocryptd/" - "bypassQueryAnalysis", - test_bypass_spawning_via_bypassQueryAnalysis, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/bypass_spawning_mongocryptd/" - "cryptSharedLibLoaded", - test_bypass_spawning_via_cryptSharedLibLoaded, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8, - _skip_if_no_crypt_shared); - TestSuite_AddFull (suite, - "/client_side_encryption/kms_tls/valid", - test_kms_tls_cert_valid, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/kms_tls/expired", - test_kms_tls_cert_expired, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/kms_tls/wrong_host", - test_kms_tls_cert_wrong_host, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/unique_index_on_keyaltnames", - test_unique_index_on_keyaltnames, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/prose_test_16/case1", - test_rewrap_with_separate_client_encryption, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/client_side_encryption/prose_test_16/case2", - test_rewrap_without_provider, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - - /* Other, C driver specific, tests. */ - TestSuite_AddFull (suite, - "/client_side_encryption/single_and_pool_mismatches", - test_invalid_single_and_pool_mismatches, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/multi_threaded", - test_multi_threaded, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/client_side_encryption/malformed_explicit", - test_malformed_explicit, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull ( - suite, - "/client_side_encryption/kms_tls_options", - test_kms_tls_options, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_offline /* requires AWS, Azure, and GCP */, - /* Do not run on Windows due to CDRIVER-4181. Tests use a literal IP with - a TLS connection. */ - test_framework_skip_if_windows); - - TestSuite_AddFull (suite, - "/client_side_encryption/kms_tls_options/extra_rejected", - test_kms_tls_options_extra_rejected, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption); - - TestSuite_AddFull ( - suite, - "/client_side_encryption/explicit_encryption/case1", - test_explicit_encryption_case1, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_single); - - TestSuite_AddFull (suite, - "/client_side_encryption/explicit_encryption/case2", - test_explicit_encryption_case2, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - // Remove skip_if_serverless once DRIVERS-2589 is resolved - test_framework_skip_if_serverless, - test_framework_skip_if_single); - - TestSuite_AddFull ( - suite, - "/client_side_encryption/explicit_encryption/case3", - test_explicit_encryption_case3, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_single); - - TestSuite_AddFull ( - suite, - "/client_side_encryption/explicit_encryption/case4", - test_explicit_encryption_case4, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_single); - - TestSuite_AddFull ( - suite, - "/client_side_encryption/explicit_encryption/case5", - test_explicit_encryption_case5, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_single); - - TestSuite_AddFull (suite, - "/client_side_encryption/decryption_events/case1", - test_decryption_events_case1, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - - TestSuite_AddFull (suite, - "/client_side_encryption/decryption_events/case2", - test_decryption_events_case2, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - - TestSuite_AddFull (suite, - "/client_side_encryption/decryption_events/case3", - test_decryption_events_case3, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - - - TestSuite_AddFull (suite, - "/client_side_encryption/decryption_events/case4", - test_decryption_events_case4, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - - TestSuite_AddFull ( - suite, - "/client_side_encryption/qe_docs_example", - test_qe_docs_example, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_single); - - TestSuite_AddFull (suite, - "/client_side_encryption/kms/callback", - test_kms_callback, - NULL, // dtor - NULL, // ctx - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - - TestSuite_AddFull (suite, - "/client_side_encryption/kms/auto-aws/fail", - test_auto_aws_fail, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8, - _not_have_aws_creds_env); - - TestSuite_AddFull (suite, - "/client_side_encryption/kms/auto-aws/succeed", - test_auto_aws_succeed, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8, - _have_aws_creds_env); - - TestSuite_AddFull (suite, - "/client_side_encryption/drop_qe_null_error", - test_drop_qe_null_error, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_8); - - TestSuite_AddFull (suite, - "/client_side_encryption/auto_datakeys", - test_auto_datakeys, - NULL, - NULL, - NULL); - - TestSuite_AddFull ( - suite, - "/client_side_encryption/createEncryptedCollection/simple", - test_create_encrypted_collection_simple, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_single); - - TestSuite_AddFull ( - suite, - "/client_side_encryption/createEncryptedCollection/" - "missing-encryptedFields", - test_create_encrypted_collection_no_encryptedFields, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_single); - TestSuite_AddFull ( - suite, - "/client_side_encryption/createEncryptedCollection/" - "bad-keyId", - test_create_encrypted_collection_bad_keyId, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_single); - TestSuite_AddFull ( - suite, - "/client_side_encryption/createEncryptedCollection/insert", - test_create_encrypted_collection_insert, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_single); - TestSuite_AddFull ( - suite, - "/client_side_encryption/bypass_mongocryptd_shared_library", - test_bypass_mongocryptd_shared_library, - NULL, - NULL, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_17, - _skip_if_no_crypt_shared); - - // Add test cases for prose test: 22. Range Explicit Encryption. - { - const char *rangeTypes[] = { - "DecimalNoPrecision", - "DecimalPrecision", - "DoubleNoPrecision", - "DoublePrecision", - "Date", - "Int", - "Long", - }; - - typedef struct { - const char *name; - TestFuncWC fn; - } rangeCase; - - rangeCase rangeCases[] = { - {"case1", test_range_explicit_encryption_case1}, - {"case2", test_range_explicit_encryption_case2}, - {"case3", test_range_explicit_encryption_case3}, - {"case4", test_range_explicit_encryption_case4}, - {"case5", test_range_explicit_encryption_case5}, - {"case6", test_range_explicit_encryption_case6}, - {"case7", test_range_explicit_encryption_case7}, - {"case8", test_range_explicit_encryption_case8}, - }; - - for (size_t i = 0; i < sizeof rangeTypes / sizeof rangeTypes[0]; i++) { - for (size_t j = 0; j < sizeof rangeCases / sizeof rangeCases[0]; j++) { - const char *rangeType = rangeTypes[i]; - rangeCase rc = rangeCases[j]; - - char *test_name = bson_strdup_printf ( - "/client_side_encryption/range_explicit_encryption/%s/%s", - rc.name, - rangeType); - - // Skip DecimalNoPrecision if not a replica set. - if (0 == strcmp (rangeType, "DecimalNoPrecision")) { - TestSuite_AddFull (suite, - test_name, - rc.fn, - NULL /* dtor */, - (void *) rangeTypes[i] /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - test_framework_skip_if_max_wire_version_more_than_24 /* skip on MongoDB 8.0+ */, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_not_replset); - } else { - TestSuite_AddFull (suite, - test_name, - rc.fn, - NULL /* dtor */, - (void *) rangeTypes[i] /* ctx */, - test_framework_skip_if_no_client_side_encryption, - test_framework_skip_if_max_wire_version_less_than_21, - test_framework_skip_if_max_wire_version_more_than_24 /* skip on MongoDB 8.0+ */, - // Remove skip_if_serverless once DRIVERS-2589 is resolved. - test_framework_skip_if_serverless, - test_framework_skip_if_single); - } - - bson_free (test_name); - } - } - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client.c deleted file mode 100644 index 0197e71f6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-client.c +++ /dev/null @@ -1,4571 +0,0 @@ -#include -#include - -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-cursor-private.h" -#include "mongoc/mongoc-cluster-private.h" -#include "mongoc/mongoc-database-private.h" -#include "mongoc/mongoc-handshake-private.h" -#include "mongoc/mongoc-host-list-private.h" -#include "mongoc/mongoc-read-concern-private.h" -#include "mongoc/mongoc-set-private.h" -#ifdef MONGOC_ENABLE_SSL -#include "mongoc/mongoc-ssl.h" -#include "mongoc/mongoc-ssl-private.h" -#endif -#include "mongoc/mongoc-util-private.h" -#include "mongoc/mongoc-write-concern-private.h" - -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" -#include "mock_server/mock-rs.h" - - -#ifdef BSON_HAVE_STRINGS_H -#include -#endif - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "client-test" - - -static void -test_client_cmd_w_server_id (void) -{ - mock_rs_t *rs; - mongoc_client_t *client; - bson_error_t error; - bson_t *opts; - bson_t reply; - future_t *future; - request_t *request; - - rs = mock_rs_with_auto_hello (WIRE_VERSION_MIN, - true /* has primary */, - 1 /* secondary */, - 0 /* arbiters */); - - mock_rs_run (rs); - client = test_framework_client_new_from_uri (mock_rs_get_uri (rs), NULL); - - /* use serverId instead of prefs to select the secondary */ - opts = tmp_bson ("{'serverId': 2, 'readConcern': {'level': 'local'}}"); - future = future_client_read_command_with_opts (client, - "db", - tmp_bson ("{'ping': 1}"), - NULL /* prefs */, - opts, - &reply, - &error); - - /* recognized that wire version is recent enough for readConcern */ - request = - mock_rs_receives_msg (rs, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'ping': 1," - " 'readConcern': {'level': 'local'}," - " 'serverId': {'$exists': false}}")); - - ASSERT (mock_rs_request_is_to_secondary (rs, request)); - reply_to_request_simple (request, "{'ok': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - - bson_destroy (&reply); - future_destroy (future); - request_destroy (request); - mongoc_client_destroy (client); - mock_rs_destroy (rs); -} - - -static void -test_client_cmd_w_server_id_sharded (void) -{ - mock_server_t *server; - mongoc_client_t *client; - bson_error_t error; - bson_t *opts; - bson_t reply; - future_t *future; - request_t *request; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - opts = tmp_bson ("{'serverId': 1}"); - future = future_client_read_command_with_opts (client, - "db", - tmp_bson ("{'ping': 1}"), - NULL /* prefs */, - opts, - &reply, - &error); - - /* does NOT set secondaryOk, since this is a sharded topology */ - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'ping': 1, 'serverId': {'$exists': false}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - - bson_destroy (&reply); - future_destroy (future); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_server_id_option (void *ctx) -{ - mongoc_client_t *client; - bson_error_t error; - bson_t *cmd; - bool r; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - cmd = tmp_bson ("{'ping': 1}"); - r = mongoc_client_read_command_with_opts (client, - "test", - cmd, - NULL /* prefs */, - tmp_bson ("{'serverId': 'foo'}"), - NULL, - &error); - - ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "must be an integer"); - - r = mongoc_client_read_command_with_opts (client, - "test", - cmd, - NULL /* prefs */, - tmp_bson ("{'serverId': 0}"), - NULL, - &error); - - ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "must be >= 1"); - - r = mongoc_client_read_command_with_opts (client, - "test", - cmd, - NULL /* prefs */, - tmp_bson ("{'serverId': 1}"), - NULL, - &error); - - ASSERT_OR_PRINT (r, error); - - mongoc_client_destroy (client); -} - - -static void -test_client_cmd_w_write_concern (void *ctx) -{ - mongoc_write_concern_t *good_wc; - mongoc_write_concern_t *bad_wc; - mongoc_client_t *client; - bson_t *command = tmp_bson ("{'insert' : 'test', " - "'documents' : [{'hello' : 'world'}]}"); - bson_t reply; - bson_t *opts = NULL; - bson_error_t error; - - BSON_UNUSED (ctx); - - opts = bson_new (); - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - - good_wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (good_wc, 1); - - bad_wc = mongoc_write_concern_new (); - /* writeConcern that will not pass mongoc_write_concern_is_valid */ - bad_wc->wtimeout = -10; - - mongoc_write_concern_append (good_wc, opts); - ASSERT_OR_PRINT (mongoc_client_write_command_with_opts ( - client, "test", command, opts, &reply, &error), - error); - - bson_reinit (opts); - bson_destroy (&reply); - - mongoc_write_concern_append_bad (bad_wc, opts); - ASSERT (!mongoc_client_write_command_with_opts ( - client, "test", command, opts, &reply, &error)); - - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid writeConcern"); - bad_wc->wtimeout = 0; - bson_destroy (&reply); - error.code = 0; - error.domain = 0; - - if (!test_framework_is_mongos ()) { - mongoc_write_concern_set_w (bad_wc, 99); - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - - /* bad write concern in opts */ - ASSERT (!mongoc_client_write_command_with_opts ( - client, "test", command, opts, &reply, &error)); - assert_wc_oob_error (&error); - bson_destroy (&reply); - } - - mongoc_write_concern_destroy (good_wc); - mongoc_write_concern_destroy (bad_wc); - bson_destroy (opts); - mongoc_client_destroy (client); -} - - -/* - * test_client_cmd_write_concern: - * - * This test ensures that there is a lack of special - * handling for write concerns and write concern - * errors in generic functions that support commands - * that write. - * - */ - -static void -test_client_cmd_write_concern (void) -{ - mongoc_client_t *client; - bson_t reply; - bson_error_t error; - future_t *future; - request_t *request; - mock_server_t *server; - bson_t *cmd; - - /* set up client and wire protocol version */ - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - /* command with invalid writeConcern */ - cmd = tmp_bson ("{'$db': 'test', 'foo' : 1, 'writeConcern' : {'w' : 99 }}"); - future = - future_client_command_simple (client, "test", cmd, NULL, &reply, &error); - request = mock_server_receives_msg (server, MONGOC_MSG_NONE, cmd); - BSON_ASSERT (request); - - reply_to_request_with_ok_and_destroy (request); - BSON_ASSERT (future_get_bool (future)); - - future_destroy (future); - bson_destroy (&reply); - - /* standalone response */ - future = - future_client_command_simple (client, "test", cmd, NULL, &reply, &error); - request = mock_server_receives_msg (server, MONGOC_MSG_NONE, cmd); - BSON_ASSERT (request); - - reply_to_request_simple (request, - "{ 'ok' : 0, 'errmsg' : 'cannot use w > 1 when a " - "host is not replicated', 'code' : 2 }"); - - BSON_ASSERT (!future_get_bool (future)); - future_destroy (future); - request_destroy (request); - bson_destroy (&reply); - - /* replicaset response */ - future = - future_client_command_simple (client, "test", cmd, NULL, &reply, &error); - request = mock_server_receives_msg (server, MONGOC_MSG_NONE, cmd); - reply_to_request_simple ( - request, - "{ 'ok' : 1, 'n': 1, " - "'writeConcernError': {'code': 17, 'errmsg': 'foo'}}"); - BSON_ASSERT (future_get_bool (future)); - - bson_destroy (&reply); - future_destroy (future); - mock_server_destroy (server); - mongoc_client_destroy (client); - request_destroy (request); -} - - -static void -test_client_cmd_write_concern_fam (void) -{ - mongoc_client_t *client; - mongoc_write_concern_t *wc; - bson_t *fam; - bson_t reply; - bson_error_t error; - future_t *future; - request_t *request; - mock_server_t *server; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 2); - mongoc_client_set_write_concern (client, wc); - fam = tmp_bson ("{'findAndModify': 'collection'}"); - - future = future_client_read_write_command_with_opts ( - client, "test", fam, NULL, NULL, &reply, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test', 'findAndModify': 'collection', " - "'writeConcern': {'w': 2}}")); - - reply_to_request_with_ok_and_destroy (request); - BSON_ASSERT (future_get_bool (future)); - - bson_destroy (&reply); - future_destroy (future); - mock_server_destroy (server); - mongoc_write_concern_destroy (wc); - mongoc_client_destroy (client); -} - - -static char * -gen_test_user (void) -{ - return bson_strdup_printf ( - "testuser_%u_%u", (unsigned) time (NULL), (unsigned) gettestpid ()); -} - - -static char * -gen_good_uri (const char *username, const char *dbname) -{ - char *host = test_framework_get_host (); - uint16_t port = test_framework_get_port (); - char *uri = bson_strdup_printf ( - "mongodb://%s:testpass@%s:%hu/%s", username, host, port, dbname); - - bson_free (host); - return uri; -} - - -static void -test_mongoc_client_authenticate (void *context) -{ - mongoc_client_t *admin_client; - char *username; - char *uri; - bson_t roles; - mongoc_database_t *database; - char *uri_str_no_auth; - char *uri_str_auth; - mongoc_collection_t *collection; - mongoc_client_t *auth_client; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_error_t error; - bool r; - bson_t q; - - BSON_UNUSED (context); - - /* - * Log in as admin. - */ - admin_client = test_framework_new_default_client (); - - /* - * Add a user to the test database. - */ - username = gen_test_user (); - uri = gen_good_uri (username, "test"); - - database = mongoc_client_get_database (admin_client, "test"); - (void) mongoc_database_remove_user (database, username, &error); - bson_init (&roles); - BCON_APPEND (&roles, "0", "{", "role", "read", "db", "test", "}"); - - r = mongoc_database_add_user (database, - username, - "testpass", - tmp_bson ("[{'role': 'read', 'db': 'test'}]"), - NULL, - &error); - - ASSERT_OR_PRINT (r, error); - mongoc_database_destroy (database); - - /* - * Try authenticating with that user. - */ - bson_init (&q); - uri_str_no_auth = test_framework_get_uri_str_no_auth ("test"); - uri_str_auth = - test_framework_add_user_password (uri_str_no_auth, username, "testpass"); - auth_client = test_framework_client_new (uri_str_auth, NULL); - test_framework_set_ssl_opts (auth_client); - collection = mongoc_client_get_collection (auth_client, "test", "test"); - cursor = mongoc_collection_find_with_opts (collection, &q, NULL, NULL); - r = mongoc_cursor_next (cursor, &doc); - if (!r) { - r = mongoc_cursor_error (cursor, &error); - if (r) { - fprintf (stderr, "Authentication failure: \"%s\"", error.message); - } - BSON_ASSERT (!r); - } - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (auth_client); - - /* - * Remove all test users. - */ - database = mongoc_client_get_database (admin_client, "test"); - r = mongoc_database_remove_all_users (database, &error); - BSON_ASSERT (r); - - bson_destroy (&q); - bson_free (uri_str_no_auth); - bson_free (uri_str_auth); - bson_destroy (&roles); - bson_free (uri); - bson_free (username); - mongoc_database_destroy (database); - mongoc_client_destroy (admin_client); -} - - -static void -test_mongoc_client_speculative_auth_failure (bool pooled) -{ - mongoc_client_t *admin_client; - char *username; - bson_t roles; - mongoc_database_t *database; - char *uri_str_no_auth; - char *uri_str_auth; - mongoc_collection_t *collection; - mongoc_client_t *auth_client; - mongoc_client_pool_t *pool = NULL; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_error_t error; - bool r; - bson_t q; - - /* - * Log in as admin. - */ - admin_client = test_framework_new_default_client (); - - /* - * Add a user to the test database. - */ - username = gen_test_user (); - database = mongoc_client_get_database (admin_client, "test"); - (void) mongoc_database_remove_user (database, username, &error); - bson_init (&roles); - BCON_APPEND (&roles, "0", "{", "role", "read", "db", "test", "}"); - - r = mongoc_database_add_user (database, - username, - "testpass", - tmp_bson ("[{'role': 'read', 'db': 'test'}]"), - NULL, - &error); - - ASSERT_OR_PRINT (r, error); - mongoc_database_destroy (database); - - bson_init (&q); - uri_str_no_auth = test_framework_get_uri_str_no_auth ("test"); - uri_str_auth = - test_framework_add_user_password (uri_str_no_auth, username, "testpass"); - - { - mongoc_uri_t *const uri = mongoc_uri_new (uri_str_auth); - - ASSERT ( - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYREADS, false)); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - auth_client = mongoc_client_pool_pop (pool); - } else { - auth_client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (auth_client); - } - mongoc_uri_destroy (uri); - } - - collection = mongoc_client_get_collection (auth_client, "test", "test"); - - database = mongoc_client_get_database (admin_client, "admin"); - - /* Enable failpoint to break saslContinue */ - r = mongoc_database_command_simple ( - database, - tmp_bson ("{'configureFailPoint': 'failCommand', " - "'mode': {'times': 1}, " - "'data': {'failCommands': ['saslContinue'], 'closeConnection': " - "true, 'errorCode': 10107}}"), - NULL, - NULL, - &error); - ASSERT_OR_PRINT (r, error); - mongoc_database_destroy (database); - - /* Try authenticating by running a find operation */ - capture_logs (true); - cursor = mongoc_collection_find_with_opts (collection, &q, NULL, NULL); - r = mongoc_cursor_next (cursor, &doc); - if (!r) { - r = mongoc_cursor_error (cursor, &error); - BSON_ASSERT (r); - /* A client pool on servers supporting speculative auth (4.4+) will get an - * error on saslContinue and subsequently attempt to start auth from the - * beginning. The failpoint closes the stream causing an error from - * saslStart. */ - if (pooled && - test_framework_max_wire_version_at_least (WIRE_VERSION_4_4)) { - ASSERT_CAPTURED_LOG ("cluster", - MONGOC_LOG_LEVEL_WARNING, - "Failed to send \"saslStart\" command") - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Failed to send \"saslStart\" command"); - } else { - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Failed to send \"saslContinue\" command"); - } - } - capture_logs (false); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - - if (pooled) { - mongoc_client_pool_push (pool, auth_client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (auth_client); - } - - /* - * Remove all test users. - */ - database = mongoc_client_get_database (admin_client, "test"); - r = mongoc_database_remove_all_users (database, &error); - BSON_ASSERT (r); - - bson_destroy (&q); - bson_free (uri_str_no_auth); - bson_free (uri_str_auth); - bson_destroy (&roles); - bson_free (username); - mongoc_database_destroy (database); - mongoc_client_destroy (admin_client); -} - -static void -test_mongoc_client_single_speculative_auth_failure (void *context) -{ - BSON_UNUSED (context); - - test_mongoc_client_speculative_auth_failure (false); -} - -static void -test_mongoc_client_pooled_speculative_auth_failure (void *context) -{ - BSON_UNUSED (context); - - test_mongoc_client_speculative_auth_failure (true); -} - - -static void -test_mongoc_client_authenticate_cached (bool pooled) -{ - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_t insert = BSON_INITIALIZER; - const bson_t *doc; - bson_error_t error; - bool r; - int i = 0; - uint32_t server_id; - - { - mongoc_uri_t *const uri = test_framework_get_uri (); - - // Avoid retryable handshakes from interfering with screwed-up cache. - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYREADS, false); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - } - - mongoc_uri_destroy (uri); - } - - collection = mongoc_client_get_collection (client, "test", "test"); - mongoc_collection_insert_one (collection, &insert, NULL, NULL, &error); - for (i = 0; i < 10; i++) { - mongoc_topology_scanner_node_t *scanner_node; - - cursor = - mongoc_collection_find_with_opts (collection, &insert, NULL, NULL); - r = mongoc_cursor_next (cursor, &doc); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT (r); - server_id = mongoc_cursor_get_hint (cursor); - mongoc_cursor_destroy (cursor); - - if (pooled) { - mongoc_cluster_disconnect_node (&client->cluster, server_id); - } else { - scanner_node = mongoc_topology_scanner_get_node ( - client->topology->scanner, server_id); - mongoc_stream_destroy (scanner_node->stream); - scanner_node->stream = NULL; - } - } - - mongoc_collection_destroy (collection); - if (pooled) { - capture_logs (true); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - bson_destroy (&insert); -} - - -static void -test_mongoc_client_authenticate_cached_pooled (void *context) -{ - BSON_UNUSED (context); - - test_mongoc_client_authenticate_cached (true); -} - - -static void -test_mongoc_client_authenticate_cached_single (void *context) -{ - BSON_UNUSED (context); - - test_mongoc_client_authenticate_cached (false); -} - - -static void -test_mongoc_client_authenticate_failure (void *context) -{ - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - mongoc_client_t *client; - const bson_t *doc; - bson_error_t error; - bool r; - bson_t q; - bson_t empty = BSON_INITIALIZER; - char *host = test_framework_get_host (); - char *uri_str_no_auth = test_framework_get_uri_str_no_auth (NULL); - char *bad_uri_str = - test_framework_add_user_password (uri_str_no_auth, "baduser", "badpass"); - - BSON_UNUSED (context); - - /* - * Try authenticating with bad user. - */ - bson_init (&q); - client = test_framework_client_new (bad_uri_str, NULL); - test_framework_set_ssl_opts (client); - - collection = mongoc_client_get_collection (client, "test", "test"); - cursor = mongoc_collection_find_with_opts (collection, &q, NULL, NULL); - r = mongoc_cursor_next (cursor, &doc); - BSON_ASSERT (!r); - r = mongoc_cursor_error (cursor, &error); - BSON_ASSERT (r); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_CLIENT); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_CLIENT_AUTHENTICATE); - mongoc_cursor_destroy (cursor); - - /* - * Try various commands while in the failed state to ensure we get the - * same sort of errors. - */ - r = mongoc_collection_insert_one (collection, &empty, NULL, NULL, &error); - BSON_ASSERT (!r); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_CLIENT); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_CLIENT_AUTHENTICATE); - - /* - * Try various commands while in the failed state to ensure we get the - * same sort of errors. - */ - r = - mongoc_collection_update_one (collection, &q, &empty, NULL, NULL, &error); - BSON_ASSERT (!r); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_CLIENT); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_CLIENT_AUTHENTICATE); - - bson_destroy (&q); - bson_destroy (&empty); - bson_free (host); - bson_free (uri_str_no_auth); - bson_free (bad_uri_str); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_mongoc_client_authenticate_timeout (void *context) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_t *client; - bson_t reply; - bson_error_t error; - future_t *future; - request_t *request; - - BSON_UNUSED (context); - - if (!TestSuite_CheckMockServerAllowed ()) { - return; - } - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_username (uri, "user"); - mongoc_uri_set_password (uri, "password"); - mongoc_uri_set_option_as_int32 (uri, "socketTimeoutMS", 10); - client = test_framework_client_new_from_uri (uri, NULL); - - future = future_client_command_simple ( - client, "test", tmp_bson ("{'ping': 1}"), NULL, &reply, &error); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin'}")); - - ASSERT (request); - ASSERT_CMPSTR (request->command_name, "saslStart"); - - /* don't reply */ - BSON_ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_AUTHENTICATE, - "Failed to send \"saslStart\" command with database \"admin\""); - - bson_destroy (&reply); - future_destroy (future); - request_destroy (request); - mongoc_uri_destroy (uri); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -/* Update: this test was changed after CDRIVER-3653 was fixed. - * Originally, the test used cursor operations, assuming changes in the - * min/maxWireVersion from the mock server would be re-evaluated on each cursor - * operation. - * After CDRIVER-3653 was fixed, this is no longer true. The cursor will examine - * the server description associated with the connection handshake. If the - * connection has not been closed, changes from monitoring will not affect the - * connection's server description. - * This test now uses mongoc_client_select_server to validate wire version - * checks. */ -static void -test_wire_version (void) -{ - mongoc_uri_t *uri; - mongoc_client_t *client; - mock_server_t *server; - bson_error_t error; - bson_t q = BSON_INITIALIZER; - mongoc_server_description_t *sd; - - if (!test_framework_skip_if_slow ()) { - bson_destroy (&q); - return; - } - - server = mock_server_new (); - - /* too new */ - mock_server_auto_hello (server, - "{'ok': 1.0," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MAX + 1, - WIRE_VERSION_MAX + 1); - - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "heartbeatFrequencyMS", 500); - client = test_framework_client_new_from_uri (uri, NULL); - sd = mongoc_client_select_server (client, true, NULL, &error); - BSON_ASSERT (!sd); - BSON_ASSERT (error.domain == MONGOC_ERROR_PROTOCOL); - BSON_ASSERT (error.code == MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION); - - /* too old */ - mock_server_auto_hello (server, - "{'ok': 1.0," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN - 1, - WIRE_VERSION_MIN - 1); - - /* wait until it's time for next heartbeat */ - _mongoc_usleep (600 * 1000); - sd = mongoc_client_select_server (client, true, NULL, &error); - BSON_ASSERT (!sd); - BSON_ASSERT (error.domain == MONGOC_ERROR_PROTOCOL); - BSON_ASSERT (error.code == MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION); - - /* compatible again */ - mock_server_auto_hello (server, - "{'ok': 1.0," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - - /* wait until it's time for next heartbeat */ - _mongoc_usleep (600 * 1000); - sd = mongoc_client_select_server (client, true, NULL, &error); - ASSERT_OR_PRINT (sd, error); - mongoc_server_description_destroy (sd); - - bson_destroy (&q); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - - -static void -test_mongoc_client_command (void) -{ - mongoc_client_t *client; - mongoc_cursor_t *cursor; - const bson_t *doc; - bool r; - bson_t cmd = BSON_INITIALIZER; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - bson_append_int32 (&cmd, "ping", 4, 1); - - cursor = mongoc_client_command ( - client, "admin", MONGOC_QUERY_NONE, 0, 1, 0, &cmd, NULL, NULL); - - r = mongoc_cursor_next (cursor, &doc); - BSON_ASSERT (r); - BSON_ASSERT (doc); - - r = mongoc_cursor_next (cursor, &doc); - BSON_ASSERT (!r); - BSON_ASSERT (!doc); - - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); - bson_destroy (&cmd); -} - - -static void -test_mongoc_client_command_defaults (void) -{ - mongoc_client_t *client; - mongoc_read_prefs_t *read_prefs; - mongoc_read_concern_t *read_concern; - mongoc_cursor_t *cursor; - - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - - read_concern = mongoc_read_concern_new (); - mongoc_read_concern_set_level (read_concern, "majority"); - - client = test_framework_new_default_client (); - mongoc_client_set_read_prefs (client, read_prefs); - mongoc_client_set_read_concern (client, read_concern); - - cursor = mongoc_client_command (client, - "admin", - MONGOC_QUERY_NONE, - 0, - 0, - 0, - tmp_bson ("{'ping': 1}"), - NULL, - NULL); - - /* Read and Write Concern spec: "If your driver offers a generic RunCommand - * method on your database object, ReadConcern MUST NOT be applied - * automatically to any command. A user wishing to use a ReadConcern in a - * generic command must supply it manually." Server Selection Spec: "The - * generic command method MUST ignore any default read preference from - * client, database or collection configuration. The generic command method - * SHOULD allow an optional read preference argument." - */ - ASSERT (cursor->read_concern->level == NULL); - ASSERT (cursor->read_prefs->mode == MONGOC_READ_PRIMARY); - - mongoc_cursor_destroy (cursor); - mongoc_read_concern_destroy (read_concern); - mongoc_read_prefs_destroy (read_prefs); - mongoc_client_destroy (client); -} - - -static void -test_mongoc_client_command_secondary (void) -{ - mongoc_client_t *client; - mongoc_cursor_t *cursor; - mongoc_read_prefs_t *read_prefs; - bson_t cmd = BSON_INITIALIZER; - const bson_t *reply; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - BSON_APPEND_INT32 (&cmd, "invalid_command_here", 1); - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - - cursor = mongoc_client_command ( - client, "admin", MONGOC_QUERY_NONE, 0, 1, 0, &cmd, NULL, read_prefs); - mongoc_cursor_next (cursor, &reply); - - if (test_framework_is_replset ()) { - BSON_ASSERT (test_framework_server_is_secondary ( - client, mongoc_cursor_get_hint (cursor))); - } - - mongoc_read_prefs_destroy (read_prefs); - - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); - bson_destroy (&cmd); -} - - -static void -_test_command_read_prefs (bool simple, bool pooled) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_read_prefs_t *secondary_pref; - bson_t *cmd; - future_t *future; - bson_error_t error; - request_t *request; - mongoc_cursor_t *cursor; - const bson_t *reply; - - /* mock mongos: easiest way to test that read preference is configured */ - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - secondary_pref = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_uri_set_read_prefs_t (uri, secondary_pref); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - } - - ASSERT_CMPINT ( - MONGOC_READ_SECONDARY, - ==, - mongoc_read_prefs_get_mode (mongoc_client_get_read_prefs (client))); - - cmd = tmp_bson ("{'foo': 1}"); - - if (simple) { - /* simple, without read preference */ - future = - future_client_command_simple (client, "db", cmd, NULL, NULL, &error); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'foo': 1}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* with read preference */ - future = future_client_command_simple ( - client, "db", cmd, secondary_pref, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'foo': 1," - " '$readPreference': {'mode': 'secondary'}}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - } else { - /* not simple, no read preference */ - cursor = mongoc_client_command ( - client, "db", MONGOC_QUERY_NONE, 0, 0, 0, cmd, NULL, NULL); - future = future_cursor_next (cursor, &reply); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'foo': 1}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT (future_get_bool (future)); - future_destroy (future); - mongoc_cursor_destroy (cursor); - - /* with read preference */ - cursor = mongoc_client_command ( - client, "db", MONGOC_QUERY_NONE, 0, 0, 0, cmd, NULL, secondary_pref); - future = future_cursor_next (cursor, &reply); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'foo': 1," - " '$readPreference': {'mode': 'secondary'}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT (future_get_bool (future)); - future_destroy (future); - mongoc_cursor_destroy (cursor); - } - - mongoc_uri_destroy (uri); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_read_prefs_destroy (secondary_pref); - mock_server_destroy (server); -} - - -static void -test_command_simple_read_prefs_single (void) -{ - _test_command_read_prefs (true, false); -} - - -static void -test_command_simple_read_prefs_pooled (void) -{ - _test_command_read_prefs (true, true); -} - - -static void -test_command_read_prefs_single (void) -{ - _test_command_read_prefs (false, false); -} - - -static void -test_command_read_prefs_pooled (void) -{ - _test_command_read_prefs (false, true); -} - - -static void -test_command_not_found (void) -{ - mongoc_client_t *client; - const bson_t *doc; - bson_error_t error; - mongoc_cursor_t *cursor; - - client = test_framework_new_default_client (); - cursor = mongoc_client_command (client, - "test", - MONGOC_QUERY_NONE, - 0, - 0, - 0, - tmp_bson ("{'foo': 1}"), - NULL, - NULL); - - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_QUERY); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND); - - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); -} - - -static void -test_command_not_found_simple (void) -{ - mongoc_client_t *client; - bson_t reply; - bson_error_t error; - - client = test_framework_new_default_client (); - ASSERT (!mongoc_client_command_simple ( - client, "test", tmp_bson ("{'foo': 1}"), NULL, &reply, &error)); - - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_QUERY); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND); - - bson_destroy (&reply); - mongoc_client_destroy (client); -} - - -static void -test_command_with_opts_read_prefs (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_read_prefs_t *read_prefs; - bson_t *cmd; - bson_t *opts; - bson_error_t error; - future_t *future; - request_t *request; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_client_set_read_prefs (client, read_prefs); - - /* read prefs omitted for command that writes */ - cmd = tmp_bson ("{'create': 'db'}"); - future = future_client_write_command_with_opts ( - client, "admin", cmd, NULL /* opts */, NULL, &error); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'create': 'db'}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* read prefs are included for read command */ - cmd = tmp_bson ("{'count': 'collection'}"); - future = future_client_read_command_with_opts ( - client, "admin", cmd, NULL, NULL /* opts */, NULL, &error); - - /* Server Selection Spec: For all read preference modes that are not - * 'primary', drivers MUST set '$readPreference'. */ - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin'," - " 'count': 'collection'," - " '$readPreference': {'mode': 'secondary'}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* read prefs not included for read/write command, but read concern is */ - cmd = tmp_bson ("{'whatever': 1}"); - opts = tmp_bson ("{'readConcern': {'level': 'majority'}}"); - future = future_client_read_write_command_with_opts ( - client, "admin", cmd, NULL, opts, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin'," - " 'whatever': 1," - " 'readConcern': {'level': 'majority'}," - " '$readPreference': {'$exists': false}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - mongoc_read_prefs_destroy (read_prefs); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_read_write_cmd_with_opts (void) -{ - mock_rs_t *rs; - mongoc_client_t *client; - mongoc_read_prefs_t *secondary; - bson_error_t error; - bson_t reply; - future_t *future; - request_t *request; - - rs = mock_rs_with_auto_hello (WIRE_VERSION_MIN, - true /* has primary */, - 1 /* secondary */, - 0 /* arbiters */); - - mock_rs_run (rs); - client = test_framework_client_new_from_uri (mock_rs_get_uri (rs), NULL); - secondary = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - - /* mongoc_client_read_write_command_with_opts must ignore read prefs - * CDRIVER-2224 - */ - future = future_client_read_write_command_with_opts ( - client, "db", tmp_bson ("{'ping': 1}"), secondary, NULL, &reply, &error); - - request = mock_rs_receives_msg ( - rs, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'ping': 1}")); - - ASSERT (mock_rs_request_is_to_primary (rs, request)); - reply_to_request_simple (request, "{'ok': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - - bson_destroy (&reply); - future_destroy (future); - request_destroy (request); - mongoc_read_prefs_destroy (secondary); - mongoc_client_destroy (client); - mock_rs_destroy (rs); -} - - -static void -test_read_command_with_opts (void) -{ - mock_server_t *server; - mongoc_client_t *client; - bson_t *cmd; - bson_t *opts; - mongoc_write_concern_t *wc; - mongoc_read_concern_t *read_concern; - bson_error_t error; - future_t *future; - request_t *request; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - /* collation allowed */ - cmd = tmp_bson ("{'create': 'db'}"); - opts = tmp_bson ("{'collation': {'locale': 'en_US'}}"); - future = future_client_write_command_with_opts ( - client, "admin", cmd, opts, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ( - "{'$db': 'admin', 'create': 'db', 'collation': {'locale': 'en_US'}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* writeConcern included */ - cmd = tmp_bson ("{'create': 'db'}"); - opts = tmp_bson ("{'writeConcern': {'w': 1}}"); - future = future_client_write_command_with_opts ( - client, "admin", cmd, opts, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin', 'create': 'db', 'writeConcern': {'w': 1}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* apply client's write concern by default */ - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 1); - mongoc_client_set_write_concern (client, wc); - future = future_client_write_command_with_opts ( - client, "admin", cmd, NULL /* opts */, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin', 'create': 'db', 'writeConcern': {'w': 1}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* apply write concern from opts, not client */ - opts = tmp_bson ("{'writeConcern': {'w': 2}}"); - mongoc_write_concern_destroy (wc); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 4); - mongoc_client_set_write_concern (client, wc); - future = future_client_write_command_with_opts ( - client, "admin", cmd, opts, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin', 'create': 'db', 'writeConcern': {'w': 2}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* readConcern allowed */ - cmd = tmp_bson ("{'count': 'collection'}"); - read_concern = mongoc_read_concern_new (); - mongoc_read_concern_set_level (read_concern, "local"); - opts = tmp_bson (NULL); - mongoc_read_concern_append (read_concern, opts); - future = future_client_read_command_with_opts ( - client, "admin", cmd, NULL, opts, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin'," - " 'count': 'collection'," - " 'readConcern': {'level': 'local'}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* apply client's readConcern by default */ - mongoc_client_set_read_concern (client, read_concern); - future = future_client_read_command_with_opts ( - client, "admin", cmd, NULL, NULL /* opts */, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin'," - " 'count': 'collection'," - " 'readConcern': {'level': 'local'}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - mongoc_read_concern_destroy (read_concern); - mongoc_write_concern_destroy (wc); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_command_with_opts (void) -{ - mock_server_t *server; - mongoc_client_t *client; - bson_t *cmd; - mongoc_write_concern_t *wc; - mongoc_read_concern_t *read_concern; - mongoc_read_prefs_t *prefs; - bson_error_t error; - future_t *future; - request_t *request; - bson_t opts = BSON_INITIALIZER; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - /* client's write concern, read concern, read prefs are ignored */ - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 2); - mongoc_client_set_write_concern (client, wc); - - read_concern = mongoc_read_concern_new (); - mongoc_read_concern_set_level (read_concern, "majority"); - mongoc_client_set_read_concern (client, read_concern); - - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_client_set_read_prefs (client, prefs); - - cmd = tmp_bson ("{'create': 'db'}"); - future = future_client_command_with_opts ( - client, "admin", cmd, NULL, NULL, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin'," - " 'create': 'db'," - " 'readConcern': {'$exists': false}," - " 'writeConcern': {'$exists': false}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* write concern, read concern, and read preference passed in explicitly */ - mongoc_write_concern_append (wc, &opts); - mongoc_read_concern_append (read_concern, &opts); - future = future_client_command_with_opts ( - client, "admin", cmd, prefs, &opts, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin'," - " 'create':'db'," - " 'writeConcern': {'w': 2}," - " 'readConcern': {'level':'majority'}," - " '$readPreference': {'mode':'secondary'}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - bson_destroy (&opts); - mongoc_read_prefs_destroy (prefs); - mongoc_read_concern_destroy (read_concern); - mongoc_write_concern_destroy (wc); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_command_with_opts_op_msg (void) -{ - mock_server_t *server; - mongoc_client_t *client; - bson_t *cmd; - mongoc_write_concern_t *wc; - mongoc_read_concern_t *read_concern; - mongoc_read_prefs_t *prefs; - bson_error_t error; - future_t *future; - request_t *request; - bson_t opts = BSON_INITIALIZER; - - server = mock_mongos_new (WIRE_VERSION_MAX); - - mock_server_auto_endsessions (server); - - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - /* client's write concern, read concern, read prefs are ignored */ - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 2); - mongoc_client_set_write_concern (client, wc); - - read_concern = mongoc_read_concern_new (); - mongoc_read_concern_set_level (read_concern, "majority"); - mongoc_client_set_read_concern (client, read_concern); - - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_client_set_read_prefs (client, prefs); - - cmd = tmp_bson ("{'create': 'db'}"); - future = future_client_command_with_opts ( - client, "admin", cmd, NULL, NULL, NULL, &error); - - request = mock_server_receives_msg ( - server, - 0, - tmp_bson ("{" - " 'create': 'db'," - " 'readConcern': {'$exists': false}," - " 'writeConcern': {'$exists': false}" - "}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* write concern, read concern, and read preference passed in explicitly */ - mongoc_write_concern_append (wc, &opts); - mongoc_read_concern_append (read_concern, &opts); - future = future_client_command_with_opts ( - client, "admin", cmd, prefs, &opts, NULL, &error); - - request = mock_server_receives_msg ( - server, - 0, - tmp_bson ("{" - " 'create':'db'," - " 'writeConcern': {'w': 2}," - " 'readConcern': {'level':'majority'}," - " '$readPreference': {" - " 'mode':'secondary'" - " }" - "}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - bson_destroy (&opts); - mongoc_read_prefs_destroy (prefs); - mongoc_read_concern_destroy (read_concern); - mongoc_write_concern_destroy (wc); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_command_empty (void) -{ - mongoc_client_t *client; - mongoc_write_concern_t *wc; - bson_error_t error; - bool r; - - client = test_framework_new_default_client (); - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{}"), NULL, NULL, &error); - - ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Empty command document"); - - r = mongoc_client_command_with_opts ( - client, "admin", tmp_bson ("{}"), NULL, tmp_bson ("{}"), NULL, &error); - - ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Empty command document"); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 1); - mongoc_client_set_write_concern (client, wc); - - r = mongoc_client_write_command_with_opts ( - client, "admin", tmp_bson ("{}"), NULL, NULL, &error); - - ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Empty command document"); - - mongoc_write_concern_destroy (wc); - mongoc_client_destroy (client); -} - - -static void -test_command_no_errmsg (void) -{ - mock_server_t *server; - mongoc_client_t *client; - bson_t *cmd; - bson_error_t error; - future_t *future; - request_t *request; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - mongoc_client_set_error_api (client, 2); - - cmd = tmp_bson ("{'command': 1}"); - future = - future_client_command_simple (client, "admin", cmd, NULL, NULL, &error); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin'}")); - - /* auth errors have $err, not errmsg. we'd raised "Unknown command error", - * see CDRIVER-1928 */ - reply_to_request_simple (request, "{'ok': 0, 'code': 7, '$err': 'bad!'}"); - ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 7, "bad!"); - - future_destroy (future); - request_destroy (request); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_unavailable_seeds (void) -{ - mock_server_t *servers[2]; - char **uri_strs; - char **uri_str; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_t query = BSON_INITIALIZER; - const bson_t *doc; - bson_error_t error; - - int i; - - for (i = 0; i < 2; i++) { - servers[i] = mock_server_down (); /* hangs up on all requests */ - mock_server_run (servers[i]); - } - - uri_str = uri_strs = bson_malloc0 (7 * sizeof (char *)); - *(uri_str++) = bson_strdup_printf ( - "mongodb://%s", mock_server_get_host_and_port (servers[0])); - - *(uri_str++) = - bson_strdup_printf ("mongodb://%s,%s", - mock_server_get_host_and_port (servers[0]), - mock_server_get_host_and_port (servers[1])); - - *(uri_str++) = - bson_strdup_printf ("mongodb://%s,%s/?replicaSet=rs", - mock_server_get_host_and_port (servers[0]), - mock_server_get_host_and_port (servers[1])); - - *(uri_str++) = bson_strdup_printf ( - "mongodb://u:p@%s", mock_server_get_host_and_port (servers[0])); - - *(uri_str++) = - bson_strdup_printf ("mongodb://u:p@%s,%s", - mock_server_get_host_and_port (servers[0]), - mock_server_get_host_and_port (servers[1])); - - *(uri_str++) = - bson_strdup_printf ("mongodb://u:p@%s,%s/?replicaSet=rs", - mock_server_get_host_and_port (servers[0]), - mock_server_get_host_and_port (servers[1])); - - for (i = 0; i < (sizeof (uri_strs) / sizeof (const char *)); i++) { - client = test_framework_client_new (uri_strs[i], NULL); - BSON_ASSERT (client); - - collection = mongoc_client_get_collection (client, "test", "test"); - cursor = - mongoc_collection_find_with_opts (collection, &query, NULL, NULL); - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - BSON_ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_SERVER_SELECTION); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_SERVER_SELECTION_FAILURE); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - } - - for (i = 0; i < 2; i++) { - mock_server_destroy (servers[i]); - } - - bson_strfreev (uri_strs); - bson_destroy (&query); -} - - -typedef enum { NO_CONNECT, CONNECT, RECONNECT } connection_option_t; - - -static bool -responder (request_t *request, void *data) -{ - BSON_UNUSED (data); - - if (!strcmp (request->command_name, "foo")) { - reply_to_request_with_ok_and_destroy (request); - return true; - } - - return false; -} - - -/* mongoc_set_for_each callback */ -static bool -host_equals (const void *item, void *ctx) -{ - const mongoc_server_description_t *sd = item; - const char *host_and_port = ctx; - - return !strcasecmp (sd->host.host_and_port, host_and_port); -} - - -/* CDRIVER-721 catch errors in _mongoc_cluster_destroy */ -static void -test_seed_list (bool rs, connection_option_t connection_option, bool pooled) -{ - mock_server_t *server; - mock_server_t *down_servers[3]; - int i; - char *uri_str; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_topology_t *topology; - mongoc_read_prefs_t *primary_pref; - uint32_t discovered_nodes_len; - bson_t reply; - bson_error_t error; - uint32_t id; - mc_shared_tpld td = MC_SHARED_TPLD_NULL; - - server = mock_server_new (); - mock_server_run (server); - - for (i = 0; i < 3; i++) { - down_servers[i] = mock_server_down (); - mock_server_run (down_servers[i]); - } - - uri_str = - bson_strdup_printf ("mongodb://%s,%s,%s,%s", - mock_server_get_host_and_port (server), - mock_server_get_host_and_port (down_servers[0]), - mock_server_get_host_and_port (down_servers[1]), - mock_server_get_host_and_port (down_servers[2])); - - uri = mongoc_uri_new (uri_str); - BSON_ASSERT (uri); - - if (pooled) { - /* must be >= minHeartbeatFrequencyMS=500 or the "reconnect" - * case won't have time to succeed */ - mongoc_uri_set_option_as_int32 (uri, "serverSelectionTimeoutMS", 1000); - } - - if (rs) { - mock_server_auto_hello (server, - "{'ok': 1," - " 'isWritablePrimary': true," - " 'setName': 'rs'," - " 'hosts': ['%s']}", - mock_server_get_host_and_port (server)); - - mongoc_uri_set_option_as_utf8 (uri, "replicaSet", "rs"); - } else { - mock_server_auto_hello (server, - "{'ok': 1," - " 'isWritablePrimary': true," - " 'msg': 'isdbgrid'}"); - } - - /* auto-respond to "foo" command */ - mock_server_autoresponds (server, responder, NULL, NULL); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - } - - topology = client->topology; - - /* a mongos load-balanced connection never removes down nodes */ - discovered_nodes_len = rs ? 1 : 4; - - primary_pref = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - if (connection_option == CONNECT || connection_option == RECONNECT) { - /* only localhost:port responds to initial discovery. the other seeds are - * discarded from replica set topology, but remain for sharded. */ - ASSERT_OR_PRINT (mongoc_client_command_simple (client, - "test", - tmp_bson ("{'foo': 1}"), - primary_pref, - &reply, - &error), - error); - - bson_destroy (&reply); - - /* td may be invalidated by client_command_simple */ - mc_tpld_renew_ref (&td, topology); - ASSERT_CMPINT (discovered_nodes_len, - ==, - (int) mc_tpld_servers_const (td.ptr)->items_len); - - if (rs) { - ASSERT_CMPINT (td.ptr->type, ==, MONGOC_TOPOLOGY_RS_WITH_PRIMARY); - } else { - ASSERT_CMPINT (td.ptr->type, ==, MONGOC_TOPOLOGY_SHARDED); - } - - if (pooled) { - /* nodes created on demand when we use servers for actual operations */ - ASSERT_CMPINT ((int) client->cluster.nodes->items_len, ==, 1); - } - } - - if (connection_option == RECONNECT) { - id = mongoc_set_find_id (mc_tpld_servers_const (td.ptr), - host_equals, - (void *) mock_server_get_host_and_port (server)); - ASSERT_CMPINT (id, !=, 0); - _mongoc_topology_invalidate_server (topology, id); - mc_tpld_renew_ref (&td, topology); - if (rs) { - ASSERT_CMPINT (td.ptr->type, ==, MONGOC_TOPOLOGY_RS_NO_PRIMARY); - } else { - ASSERT_CMPINT (td.ptr->type, ==, MONGOC_TOPOLOGY_SHARDED); - } - - ASSERT_OR_PRINT (mongoc_client_command_simple (client, - "test", - tmp_bson ("{'foo': 1}"), - primary_pref, - &reply, - &error), - error); - - bson_destroy (&reply); - - /* td may be invalidated by client_command_simple */ - mc_tpld_renew_ref (&td, topology); - ASSERT_CMPINT (discovered_nodes_len, - ==, - (int) mc_tpld_servers_const (td.ptr)->items_len); - - if (pooled) { - ASSERT_CMPINT ((int) client->cluster.nodes->items_len, ==, 1); - } - } - - /* testing for crashes like CDRIVER-721 */ - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_read_prefs_destroy (primary_pref); - mongoc_uri_destroy (uri); - bson_free (uri_str); - - for (i = 0; i < 3; i++) { - mock_server_destroy (down_servers[i]); - } - - mock_server_destroy (server); - mc_tpld_drop_ref (&td); -} - - -static void -test_rs_seeds_no_connect_single (void) -{ - test_seed_list (true, NO_CONNECT, false); -} - - -static void -test_rs_seeds_no_connect_pooled (void) -{ - test_seed_list (true, NO_CONNECT, true); -} - - -static void -test_rs_seeds_connect_single (void) -{ - test_seed_list (true, CONNECT, false); -} - -static void -test_rs_seeds_connect_pooled (void) -{ - test_seed_list (true, CONNECT, true); -} - - -static void -test_rs_seeds_reconnect_single (void) -{ - test_seed_list (true, RECONNECT, false); -} - - -static void -test_rs_seeds_reconnect_pooled (void) -{ - test_seed_list (true, RECONNECT, true); -} - - -static void -test_mongos_seeds_no_connect_single (void) -{ - test_seed_list (false, NO_CONNECT, false); -} - - -static void -test_mongos_seeds_no_connect_pooled (void) -{ - test_seed_list (false, NO_CONNECT, true); -} - - -static void -test_mongos_seeds_connect_single (void) -{ - test_seed_list (false, CONNECT, false); -} - - -static void -test_mongos_seeds_connect_pooled (void) -{ - test_seed_list (false, CONNECT, true); -} - - -static void -test_mongos_seeds_reconnect_single (void) -{ - test_seed_list (false, RECONNECT, false); -} - - -static void -test_mongos_seeds_reconnect_pooled (void) -{ - test_seed_list (false, RECONNECT, true); -} - - -static void -test_recovering (void *ctx) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_read_mode_t read_mode; - mongoc_read_prefs_t *prefs; - bson_error_t error; - - BSON_UNUSED (ctx); - - if (!TestSuite_CheckMockServerAllowed ()) { - return; - } - - server = mock_server_new (); - mock_server_run (server); - - /* server is "recovering": not primary, not secondary */ - mock_server_auto_hello (server, - "{'ok': 1," - " 'isWritablePrimary': false," - " 'secondary': false," - " 'setName': 'rs'," - " 'hosts': ['%s']}", - mock_server_get_host_and_port (server)); - - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_utf8 (uri, "replicaSet", "rs"); - client = test_framework_client_new_from_uri (uri, NULL); - prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - /* recovering member matches no read mode */ - for (read_mode = MONGOC_READ_PRIMARY; read_mode <= MONGOC_READ_NEAREST; - read_mode++) { - mongoc_read_prefs_set_mode (prefs, read_mode); - BSON_ASSERT (!mongoc_topology_select ( - client->topology, MONGOC_SS_READ, prefs, NULL, &error)); - } - - mongoc_read_prefs_destroy (prefs); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - - -static void -test_server_status (void) -{ - mongoc_client_t *client; - bson_error_t error; - bson_iter_t iter; - bson_t reply; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - BEGIN_IGNORE_DEPRECATIONS - ASSERT_OR_PRINT ( - mongoc_client_get_server_status (client, NULL, &reply, &error), error); - END_IGNORE_DEPRECATIONS - - BSON_ASSERT (bson_iter_init_find (&iter, &reply, "host")); - BSON_ASSERT (bson_iter_init_find (&iter, &reply, "version")); - BSON_ASSERT (bson_iter_init_find (&iter, &reply, "ok")); - - bson_destroy (&reply); - - mongoc_client_destroy (client); -} - - -static void -test_get_database_names (void) -{ - mock_server_t *server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mongoc_client_t *client; - bson_error_t error; - future_t *future; - request_t *request; - char **names; - - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - future = future_client_get_database_names_with_opts (client, NULL, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin', 'listDatabases': 1, 'nameOnly': true}")); - reply_to_request ( - request, - 0, - 0, - 0, - 1, - "{'ok': 1.0, 'databases': [{'name': 'a'}, {'name': 'local'}]}"); - names = future_get_char_ptr_ptr (future); - BSON_ASSERT (!strcmp (names[0], "a")); - BSON_ASSERT (!strcmp (names[1], "local")); - BSON_ASSERT (NULL == names[2]); - - bson_strfreev (names); - request_destroy (request); - future_destroy (future); - - future = future_client_get_database_names_with_opts (client, NULL, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin', 'listDatabases': 1, 'nameOnly': true}")); - reply_to_request ( - request, 0, 0, 0, 1, "{'ok': 0.0, 'code': 17, 'errmsg': 'err'}"); - - names = future_get_char_ptr_ptr (future); - BSON_ASSERT (!names); - ASSERT_CMPINT (MONGOC_ERROR_QUERY, ==, error.domain); - ASSERT_CMPSTR ("err", error.message); - - request_destroy (request); - future_destroy (future); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -_test_mongoc_client_ipv6 (bool pooled) -{ - char *uri_str; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; -#if (defined(__APPLE__) || defined(_WIN32)) && defined(MONGOC_ENABLE_SSL) - mongoc_ssl_opt_t ssl_opts; -#endif - bson_error_t error; - - uri_str = test_framework_add_user_password_from_env ("mongodb://[::1]/"); - uri = mongoc_uri_new (uri_str); - BSON_ASSERT (uri); - -#if (defined(__APPLE__) || defined(_WIN32)) && defined(MONGOC_ENABLE_SSL) - /* This is necessary because macOS & Windows seem to treat [::1] as not - * matching the hostname "0:0:0:0:0:0:0:1", which results in a certificate - * trust failure. This behavior has been captured in CDRIVER-3765 (macOS) - * and CDRIVER-3766 (Windows). When those are fixed, the code in this - * function should be restored to its previous state without the use of - * ssl_opts.allow_invalid_hostname. */ - ssl_opts = *test_framework_get_ssl_opts (); - ssl_opts.allow_invalid_hostname = true; -#endif - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); -#if (defined(__APPLE__) || defined(_WIN32)) && defined(MONGOC_ENABLE_SSL) - mongoc_client_pool_set_ssl_opts (pool, &ssl_opts); -#else - test_framework_set_pool_ssl_opts (pool); -#endif - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); -#if (defined(__APPLE__) || defined(_WIN32)) && defined(MONGOC_ENABLE_SSL) - mongoc_client_set_ssl_opts (client, &ssl_opts); -#else - test_framework_set_ssl_opts (client); -#endif - } - -#if (defined(__APPLE__) || defined(_WIN32)) && defined(MONGOC_ENABLE_SSL) - BSON_ASSERT (client->ssl_opts.allow_invalid_hostname); -#endif - - ASSERT_OR_PRINT ( - mongoc_client_read_command_with_opts ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL, &error), - error); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); - bson_free (uri_str); -} - - -static void -test_mongoc_client_ipv6_single (void) -{ - _test_mongoc_client_ipv6 (false); -} - - -static void -test_mongoc_client_ipv6_pooled (void) -{ - _test_mongoc_client_ipv6 (true); -} - - -static void -test_mongoc_client_unix_domain_socket (void *context) -{ - mongoc_client_t *client; - bson_error_t error; - char *uri_str; - - BSON_UNUSED (context); - - uri_str = test_framework_get_unix_domain_socket_uri_str (); - client = test_framework_client_new (uri_str, NULL); - test_framework_set_ssl_opts (client); - - BSON_ASSERT (client); - - ASSERT_OR_PRINT ( - mongoc_client_read_command_with_opts ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL, &error), - error); - - mongoc_client_destroy (client); - bson_free (uri_str); -} - - -static void -test_mongoc_client_mismatched_me (void) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_read_prefs_t *prefs; - bson_error_t error; - future_t *future; - request_t *request; - char *reply; - - server = mock_server_new (); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_utf8 (uri, "replicaSet", "rs"); - client = test_framework_client_new_from_uri (uri, NULL); - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - - /* any operation should fail with server selection error */ - future = future_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), prefs, NULL, &error); - - request = mock_server_receives_any_hello (server); - - reply = bson_strdup_printf ("{'ok': 1," - " 'setName': 'rs'," - " 'isWritablePrimary': false," - " 'secondary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'me': 'foo.com'," /* mismatched "me" field */ - " 'hosts': ['%s']}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX, - mock_server_get_host_and_port (server)); - - capture_logs (true); - reply_to_request_simple (request, reply); - - BSON_ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "No suitable servers"); - ASSERT_CAPTURED_LOG ( - "client", MONGOC_LOG_LEVEL_WARNING, "Last server removed from topology"); - capture_logs (false); - - bson_free (reply); - request_destroy (request); - future_destroy (future); - mongoc_read_prefs_destroy (prefs); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - - -#ifdef MONGOC_ENABLE_SSL -static void -_test_mongoc_client_ssl_opts (bool pooled) -{ - char *host_and_port; - char *uri_str; - char *uri_str_auth; - char *uri_str_auth_ssl; - mongoc_uri_t *uri; - const mongoc_ssl_opt_t *ssl_opts; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bool ret; - bson_error_t error; - int add_ssl_to_uri; - - host_and_port = test_framework_get_host_and_port (); - uri_str = bson_strdup_printf ( - "mongodb://%s/?serverSelectionTimeoutMS=1000&connectTimeoutMS=1000", - host_and_port); - - uri_str_auth = test_framework_add_user_password_from_env (uri_str); - uri_str_auth_ssl = bson_strdup_printf ("%s&ssl=true", uri_str_auth); - - ssl_opts = test_framework_get_ssl_opts (); - - /* client uses SSL once SSL options are set, regardless of "ssl=true" */ - for (add_ssl_to_uri = 0; add_ssl_to_uri < 2; add_ssl_to_uri++) { - if (add_ssl_to_uri) { - uri = mongoc_uri_new (uri_str_auth_ssl); - } else { - uri = mongoc_uri_new (uri_str_auth); - } - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - mongoc_client_pool_set_ssl_opts (pool, ssl_opts); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - mongoc_client_set_ssl_opts (client, ssl_opts); - } - - /* any operation */ - ret = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - - if (test_framework_get_ssl ()) { - ASSERT_OR_PRINT (ret, error); - } else { - /* TODO: CDRIVER-936 check the err msg has "SSL handshake failed" */ - ASSERT (!ret); - ASSERT_CMPINT (MONGOC_ERROR_SERVER_SELECTION, ==, error.domain); - } - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); - } - - bson_free (uri_str_auth_ssl); - bson_free (uri_str_auth); - bson_free (uri_str); - bson_free (host_and_port); -} - - -static void -test_ssl_single (void) -{ - _test_mongoc_client_ssl_opts (false); -} - - -static void -test_ssl_pooled (void) -{ - _test_mongoc_client_ssl_opts (true); -} - -static void -test_client_buildinfo_hang (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_database_t *database; - bson_error_t error; - bson_t command; - bson_t reply; - - pool = test_framework_new_default_client_pool (); - BSON_ASSERT (pool); - client = mongoc_client_pool_pop (pool); - - database = mongoc_client_get_database (client, "admin"); - bson_init (&command); - bson_append_int32 (&command, "buildInfo", -1, 1); - - /* Prior to a bug fix this command caused a hang - see CDRIVER-3318 */ - ASSERT_OR_PRINT ( - mongoc_database_command_simple (database, &command, NULL, &reply, &error), - error); - - bson_destroy (&command); - bson_destroy (&reply); - mongoc_database_destroy (database); - - capture_logs (true); - mongoc_client_destroy (client); - mongoc_client_pool_destroy (pool); - capture_logs (false); -} - -#else -/* MONGOC_ENABLE_SSL is not defined */ -static void -test_mongoc_client_ssl_disabled (void) -{ - capture_logs (true); - ASSERT (NULL == - test_framework_client_new ("mongodb://host/?ssl=true", NULL)); - ASSERT_CAPTURED_LOG ("mongoc_client_new", - MONGOC_LOG_LEVEL_ERROR, - "SSL not enabled in this build."); - capture_logs (false); -} -#endif - - -static void -_test_mongoc_client_get_description (bool pooled) -{ - mongoc_client_t *client; - mongoc_client_pool_t *pool = NULL; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - const bson_t *doc; - uint32_t server_id; - mongoc_server_description_t *sd; - mongoc_host_list_t host; - - if (pooled) { - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - } - - /* bad server_id handled correctly */ - ASSERT (NULL == mongoc_client_get_server_description (client, 1234)); - - collection = get_test_collection (client, "test_mongoc_client_description"); - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{}"), NULL, NULL); - ASSERT (!mongoc_cursor_next (cursor, &doc)); - server_id = mongoc_cursor_get_hint (cursor); - ASSERT (0 != server_id); - sd = mongoc_client_get_server_description (client, server_id); - ASSERT (sd); - mongoc_cursor_get_host (cursor, &host); - ASSERT (_mongoc_host_list_compare_one (&host, - mongoc_server_description_host (sd))); - - mongoc_server_description_destroy (sd); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } -} - - -static void -test_mongoc_client_get_description_single (void) -{ - _test_mongoc_client_get_description (false); -} - - -static void -test_mongoc_client_get_description_pooled (void) -{ - _test_mongoc_client_get_description (true); -} - -static void -test_mongoc_client_descriptions_single (void) -{ - mongoc_client_t *client; - mongoc_server_description_t **sds; - size_t n, expected_n; - bson_error_t error; - bool r; - bson_t *ping = tmp_bson ("{'ping': 1}"); - - expected_n = test_framework_server_count (); - n = 0; - - /* - * single-threaded - */ - client = test_framework_new_default_client (); - - /* before connecting */ - sds = mongoc_client_get_server_descriptions (client, &n); - ASSERT_CMPSIZE_T (n, ==, (size_t) 0); - bson_free (sds); - - /* connect */ - r = mongoc_client_command_simple (client, "db", ping, NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - sds = mongoc_client_get_server_descriptions (client, &n); - ASSERT_CMPSIZE_T (n, ==, expected_n); - - mongoc_server_descriptions_destroy_all (sds, n); - mongoc_client_destroy (client); -} - -static void -test_mongoc_client_descriptions_pooled (void *unused) -{ - mongoc_client_t *client; - mongoc_client_pool_t *pool; - mongoc_server_description_t **sds; - size_t n, expected_n; - int64_t start; - - BSON_UNUSED (unused); - - expected_n = test_framework_server_count (); - n = 0; - - /* - * pooled - */ - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - - /* wait for background thread to discover all members */ - start = bson_get_monotonic_time (); - do { - _mongoc_usleep (1000); - /* Windows IPv4 tasks may take longer to connect since connection to the - * first address returned by getaddrinfo may be IPv6, and failure to - * connect may take a couple seconds. See CDRIVER-3639. */ - if (bson_get_monotonic_time () - start > 3 * 1000 * 1000) { - test_error ("still have %d descriptions, not expected %d, after 1 sec", - (int) n, - (int) expected_n); - } - - sds = mongoc_client_get_server_descriptions (client, &n); - mongoc_server_descriptions_destroy_all (sds, n); - } while (n != expected_n); - - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); -} - - -static bool -is_standalone_or_rs_primary_or_mongos (const char *server_type) -{ - BSON_ASSERT_PARAM (server_type); - // Avoid -Woverlength-strings in ASSERT macros. - return strcmp (server_type, "Standalone") == 0 || - strcmp (server_type, "RSPrimary") == 0 || - strcmp (server_type, "Mongos") == 0; -} - -static bool -is_standalone_or_rs_secondary_or_mongos (const char *server_type) -{ - BSON_ASSERT_PARAM (server_type); - // Avoid -Woverlength-strings in ASSERT macros. - return strcmp (server_type, "Standalone") == 0 || - strcmp (server_type, "RSSecondary") == 0 || - strcmp (server_type, "Mongos") == 0; -} - -static bool -is_standalone_or_mongos (const char *server_type) -{ - BSON_ASSERT_PARAM (server_type); - // Avoid -Woverlength-strings in ASSERT macros. - return strcmp (server_type, "Standalone") == 0 || - strcmp (server_type, "Mongos") == 0; -} - - -static void -_test_mongoc_client_select_server (bool pooled) -{ - mongoc_client_t *client; - mongoc_client_pool_t *pool = NULL; - mongoc_server_description_t *sd; - const char *server_type; - bson_error_t error; - mongoc_read_prefs_t *prefs; - - if (pooled) { - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - } - - sd = mongoc_client_select_server (client, - true, /* for writes */ - NULL, - &error); - - ASSERT (sd); - server_type = mongoc_server_description_type (sd); - ASSERT (is_standalone_or_rs_primary_or_mongos (server_type)); - - /* Do not inherit read prefs from the client. */ - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_client_set_read_prefs (client, prefs); - - mongoc_server_description_destroy (sd); - sd = mongoc_client_select_server (client, - true, /* for writes */ - NULL, - &error); - - ASSERT (sd); - server_type = mongoc_server_description_type (sd); - ASSERT (is_standalone_or_rs_primary_or_mongos (server_type)); - - mongoc_server_description_destroy (sd); - sd = mongoc_client_select_server (client, - false, /* for reads */ - NULL, - &error); - - ASSERT (sd); - server_type = mongoc_server_description_type (sd); - ASSERT (is_standalone_or_rs_primary_or_mongos (server_type)); - - mongoc_server_description_destroy (sd); - sd = mongoc_client_select_server (client, - false, /* for reads */ - prefs, - &error); - - ASSERT (sd); - server_type = mongoc_server_description_type (sd); - ASSERT (is_standalone_or_rs_secondary_or_mongos (server_type)); - - mongoc_server_description_destroy (sd); - mongoc_read_prefs_destroy (prefs); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } -} - - -static void -test_mongoc_client_select_server_single (void) -{ - _test_mongoc_client_select_server (false); -} - - -static void -test_mongoc_client_select_server_pooled (void) -{ - _test_mongoc_client_select_server (true); -} - - -static void -_test_mongoc_client_select_server_error (bool pooled) -{ - mongoc_uri_t *uri = NULL; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_server_description_t *sd; - bson_error_t error; - mongoc_read_prefs_t *prefs; - mongoc_topology_description_type_t tdtype; - const char *server_type; - - if (pooled) { - uri = test_framework_get_uri (); - mongoc_uri_set_option_as_int32 (uri, "serverSelectionTimeoutMS", 3000); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - test_framework_set_ssl_opts (client); - } - - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_read_prefs_set_tags (prefs, tmp_bson ("[{'does-not-exist': 'x'}]")); - sd = mongoc_client_select_server (client, - true, /* for writes */ - prefs, - &error); - - ASSERT (!sd); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "Cannot use read preference"); - - sd = mongoc_client_select_server (client, - false, /* for reads */ - prefs, - &error); - - /* Server Selection Spec: "With topology type Single, the single server is - * always suitable for reads if it is available." */ - tdtype = _mongoc_topology_get_type (client->topology); - if (tdtype == MONGOC_TOPOLOGY_SINGLE || tdtype == MONGOC_TOPOLOGY_SHARDED) { - ASSERT (sd); - server_type = mongoc_server_description_type (sd); - ASSERT (is_standalone_or_mongos (server_type)); - mongoc_server_description_destroy (sd); - } else { - ASSERT (!sd); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_SERVER_SELECTION); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_SERVER_SELECTION_FAILURE); - } - - mongoc_read_prefs_destroy (prefs); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - mongoc_uri_destroy (uri); - } else { - mongoc_client_destroy (client); - } -} - - -static void -test_mongoc_client_select_server_error_single (void) -{ - _test_mongoc_client_select_server_error (false); -} - - -static void -test_mongoc_client_select_server_error_pooled (void) -{ - _test_mongoc_client_select_server_error (true); -} - - -/* CDRIVER-2172: in single mode, if the selected server has a socket that's been - * idle for socketCheckIntervalMS, check it with ping. If it fails, retry once. - */ -static void -_test_mongoc_client_select_server_retry (bool retry_succeeds) -{ - char *hello; - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_t *client; - bson_error_t error; - request_t *request; - future_t *future; - mongoc_server_description_t *sd; - - server = mock_server_new (); - mock_server_run (server); - hello = bson_strdup_printf ("{'ok': 1," - " 'isWritablePrimary': true," - " 'secondary': false," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'setName': 'rs'," - " 'hosts': ['%s']}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX, - mock_server_get_host_and_port (server)); - - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_utf8 (uri, "replicaSet", "rs"); - mongoc_uri_set_option_as_int32 (uri, "socketCheckIntervalMS", 50); - client = test_framework_client_new_from_uri (uri, NULL); - - /* first selection succeeds */ - future = future_client_select_server (client, true, NULL, &error); - request = mock_server_receives_any_hello (server); - reply_to_request_simple (request, hello); - request_destroy (request); - sd = future_get_mongoc_server_description_ptr (future); - ASSERT_OR_PRINT (sd, error); - - future_destroy (future); - mongoc_server_description_destroy (sd); - - /* let socketCheckIntervalMS pass */ - _mongoc_usleep (100 * 1000); - - /* second selection requires ping, which fails */ - future = future_client_select_server (client, true, NULL, &error); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'ping': 1}")); - - reply_to_request_with_hang_up (request); - request_destroy (request); - - /* mongoc_client_select_server retries once */ - request = mock_server_receives_any_hello (server); - if (retry_succeeds) { - reply_to_request_simple (request, hello); - sd = future_get_mongoc_server_description_ptr (future); - ASSERT_OR_PRINT (sd, error); - mongoc_server_description_destroy (sd); - } else { - reply_to_request_with_hang_up (request); - sd = future_get_mongoc_server_description_ptr (future); - BSON_ASSERT (sd == NULL); - } - - future_destroy (future); - request_destroy (request); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - bson_free (hello); - mock_server_destroy (server); -} - - -static void -test_mongoc_client_select_server_retry_succeed (void) -{ - _test_mongoc_client_select_server_retry (true); -} - -static void -test_mongoc_client_select_server_retry_fail (void) -{ - _test_mongoc_client_select_server_retry (false); -} - - -/* CDRIVER-2172: in single mode, if the selected server has a socket that's been - * idle for socketCheckIntervalMS, check it with ping. If it fails, retry once. - */ -static void -_test_mongoc_client_fetch_stream_retry (bool retry_succeeds) -{ - char *hello; - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_t *client; - bson_error_t error; - request_t *request; - future_t *future; - - server = mock_server_new (); - mock_server_run (server); - hello = bson_strdup_printf ("{'ok': 1," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "socketCheckIntervalMS", 50); - client = test_framework_client_new_from_uri (uri, NULL); - - /* first time succeeds */ - future = future_client_command_simple ( - client, "db", tmp_bson ("{'cmd': 1}"), NULL, NULL, &error); - request = mock_server_receives_any_hello (server); - reply_to_request_simple (request, hello); - request_destroy (request); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'cmd': 1}")); - reply_to_request_with_ok_and_destroy (request); - - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* let socketCheckIntervalMS pass */ - _mongoc_usleep (100 * 1000); - - /* second selection requires ping, which fails */ - future = future_client_command_simple ( - client, "db", tmp_bson ("{'cmd': 1}"), NULL, NULL, &error); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'ping': 1}")); - - reply_to_request_with_hang_up (request); - request_destroy (request); - - /* mongoc_client_select_server retries once */ - request = mock_server_receives_any_hello (server); - if (retry_succeeds) { - reply_to_request_simple (request, hello); - request_destroy (request); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'cmd': 1}")); - - reply_to_request_simple (request, "{'ok': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - } else { - reply_to_request_with_hang_up (request); - BSON_ASSERT (!future_get_bool (future)); - } - - future_destroy (future); - request_destroy (request); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - bson_free (hello); - mock_server_destroy (server); -} - - -static void -test_mongoc_client_fetch_stream_retry_succeed (void) -{ - _test_mongoc_client_fetch_stream_retry (true); -} - -static void -test_mongoc_client_fetch_stream_retry_fail (void) -{ - _test_mongoc_client_fetch_stream_retry (false); -} - - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) || \ - defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) -static bool -_cmd (mock_server_t *server, - mongoc_client_t *client, - bool server_replies, - bson_error_t *error) -{ - future_t *future; - request_t *request; - bool r; - - ASSERT (client); - - future = future_client_command_simple ( - client, "db", tmp_bson ("{'cmd': 1}"), NULL, NULL, error); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'cmd': 1}")); - ASSERT (request); - - if (server_replies) { - reply_to_request_simple (request, "{'ok': 1}"); - } - - r = future_get_bool (future); - - future_destroy (future); - request_destroy (request); - - return r; -} - -static void -test_client_set_ssl_copies_args (bool pooled) -{ - mock_server_t *server; - mongoc_ssl_opt_t client_opts = {0}; - mongoc_ssl_opt_t server_opts = {0}; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bson_error_t error; - char *mutable_client_ca = NULL; - const size_t ca_bufsize = strlen (CERT_CA) + 1; - - mutable_client_ca = bson_malloc (ca_bufsize); - bson_strncpy (mutable_client_ca, CERT_CA, ca_bufsize); - - client_opts.ca_file = mutable_client_ca; - - server_opts.weak_cert_validation = true; - server_opts.ca_file = CERT_CA; - server_opts.pem_file = CERT_SERVER; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_set_ssl_opts (server, &server_opts); - mock_server_run (server); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri ( - mock_server_get_uri (server), NULL); - mongoc_client_pool_set_ssl_opts (pool, &client_opts); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (mock_server_get_uri (server), - NULL); - mongoc_client_set_ssl_opts (client, &client_opts); - } - - /* Now change the client ca string to be something else */ - bson_strncpy (mutable_client_ca, "garbage", ca_bufsize); - - ASSERT_OR_PRINT (_cmd (server, client, true /* server replies */, &error), - error); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - bson_free (mutable_client_ca); - mock_server_destroy (server); -} - -static void -test_ssl_client_single_copies_args (void) -{ - test_client_set_ssl_copies_args (false); -} - - -static void -test_ssl_client_pooled_copies_args (void) -{ - test_client_set_ssl_copies_args (true); -} - - -static void -_test_ssl_reconnect (bool pooled) -{ - mongoc_uri_t *uri; - mock_server_t *server; - mongoc_ssl_opt_t client_opts = {0}; - mongoc_ssl_opt_t server_opts = {0}; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bson_error_t error; - future_t *future; - - client_opts.ca_file = CERT_CA; - - server_opts.weak_cert_validation = true; - server_opts.ca_file = CERT_CA; - server_opts.pem_file = CERT_SERVER; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_set_ssl_opts (server, &server_opts); - mock_server_run (server); - - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "socketTimeoutMS", 1000); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - mongoc_client_pool_set_ssl_opts (pool, &client_opts); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - mongoc_client_set_ssl_opts (client, &client_opts); - } - - ASSERT_OR_PRINT (_cmd (server, client, true /* server replies */, &error), - error); - - /* man-in-the-middle: certificate changed, for example expired */ - server_opts.pem_file = CERT_EXPIRED; - mock_server_set_ssl_opts (server, &server_opts); - - /* network timeout */ - capture_logs (true); - ASSERT (!_cmd (server, client, false /* server hangs up */, &error)); - if (pooled) { - ASSERT_CAPTURED_LOG ( - "failed to write data because server closed the connection", - MONGOC_LOG_LEVEL_WARNING, - "Failed to buffer 4 bytes"); - } - capture_logs (false); - - /* next operation comes on a new connection, server verification fails */ - capture_logs (true); - future = future_client_command_simple ( - client, "db", tmp_bson ("{'cmd': 1}"), NULL, NULL, &error); - ASSERT (!future_get_bool (future)); - ASSERT_CONTAINS (error.message, "TLS handshake failed"); - if (pooled) { - ASSERT_CAPTURED_LOG ( - "cluster", MONGOC_LOG_LEVEL_WARNING, "TLS handshake failed"); - } - capture_logs (false); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - future_destroy (future); - mock_server_destroy (server); - mongoc_uri_destroy (uri); -} - - -static void -test_ssl_reconnect_single (void) -{ - _test_ssl_reconnect (false); -} - - -static void -test_ssl_reconnect_pooled (void) -{ - _test_ssl_reconnect (true); -} -#endif /* OpenSSL or Secure Transport */ - - -static void -test_mongoc_client_application_handshake (void) -{ - enum { BUFFER_SIZE = HANDSHAKE_MAX_SIZE }; - char big_string[BUFFER_SIZE]; - const char *short_string = "hallo thar"; - mongoc_client_t *client; - - client = test_framework_client_new ("mongodb://example", NULL); - - memset (big_string, 'a', BUFFER_SIZE - 1); - big_string[BUFFER_SIZE - 1] = '\0'; - - /* Check that setting too long a name causes failure */ - capture_logs (true); - ASSERT (!mongoc_client_set_appname (client, big_string)); - ASSERT_CAPTURED_LOG ("_mongoc_topology_scanner_set_appname", - MONGOC_LOG_LEVEL_ERROR, - "is invalid"); - clear_captured_logs (); - - /* Success case */ - ASSERT (mongoc_client_set_appname (client, short_string)); - - /* Make sure we can't set it twice */ - ASSERT (!mongoc_client_set_appname (client, "a")); - ASSERT_CAPTURED_LOG ("_mongoc_topology_scanner_set_appname", - MONGOC_LOG_LEVEL_ERROR, - "Cannot set appname more than once"); - capture_logs (false); - - mongoc_client_destroy (client); -} - -static void -_assert_hello_valid (request_t *request, bool needs_meta) -{ - const bson_t *request_doc; - - ASSERT (request); - request_doc = request_get_doc (request, 0); - ASSERT (request_doc); - ASSERT (bson_has_field (request_doc, HANDSHAKE_FIELD) == needs_meta); -} - -/* For single threaded clients, to cause a hello to be sent, we must wait - * until we're overdue for a heartbeat, and then execute some command */ -static future_t * -_force_hello_with_ping (mongoc_client_t *client, int heartbeat_ms) -{ - future_t *future; - - BSON_ASSERT_PARAM (client); - - /* Wait until we're overdue to send a hello */ - _mongoc_usleep (heartbeat_ms * 2 * 1000); - - /* Send a ping */ - future = future_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL); - ASSERT (future); - return future; -} - -/* Call after we've dealt with the hello sent by - * _force_hello_with_ping */ -static void -_respond_to_ping (future_t *future, mock_server_t *server) -{ - request_t *request; - - ASSERT (future); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'ping': 1}")); - - reply_to_request_with_ok_and_destroy (request); - - ASSERT (future_get_bool (future)); - future_destroy (future); -} - -static void -test_mongoc_handshake_pool (void) -{ - mock_server_t *server; - request_t *request1; - request_t *request2; - mongoc_uri_t *uri; - mongoc_client_t *client1; - mongoc_client_t *client2; - mongoc_client_pool_t *pool; - const char *const server_reply = - tmp_str ("{'ok': 1," - " '" HANDSHAKE_RESPONSE_LEGACY_HELLO "': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - future_t *future; - - server = mock_server_new (); - mock_server_run (server); - - uri = mongoc_uri_copy (mock_server_get_uri (server)); - ASSERT (mongoc_uri_set_appname (uri, BSON_FUNC)); - - pool = mongoc_client_pool_new (uri); - - client1 = mongoc_client_pool_pop (pool); - request1 = mock_server_receives_legacy_hello (server, NULL); - _assert_hello_valid (request1, true); - reply_to_request_simple (request1, server_reply); - request_destroy (request1); - - client2 = mongoc_client_pool_pop (pool); - future = future_client_command_simple ( - client2, "test", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL); - - request2 = mock_server_receives_legacy_hello (server, NULL); - _assert_hello_valid (request2, true); - reply_to_request_simple (request2, server_reply); - request_destroy (request2); - - request2 = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'test'}")); - reply_to_request_with_ok_and_destroy (request2); - ASSERT (future_get_bool (future)); - future_destroy (future); - - mongoc_client_pool_push (pool, client1); - mongoc_client_pool_push (pool, client2); - - mongoc_client_pool_destroy (pool); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - -static void -_test_client_sends_handshake (bool pooled) -{ - mock_server_t *server; - request_t *request; - mongoc_uri_t *uri; - future_t *future; - mongoc_client_t *client; - mongoc_client_pool_t *pool; - const char *const server_reply = tmp_str ("{'ok': 1," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - const int heartbeat_ms = 500; - - if (!TestSuite_CheckMockServerAllowed ()) { - return; - } - - server = mock_server_new (); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "heartbeatFrequencyMS", heartbeat_ms); - mongoc_uri_set_option_as_int32 (uri, "connectTimeoutMS", 100); - - if (pooled) { - pool = mongoc_client_pool_new (uri); - - /* Pop a client to trigger the topology scanner */ - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - future = _force_hello_with_ping (client, heartbeat_ms); - } - - request = mock_server_receives_any_hello (server); - - /* Make sure the hello request has a "client" field: */ - _assert_hello_valid (request, true); - reply_to_request_simple (request, server_reply); - request_destroy (request); - - if (!pooled) { - _respond_to_ping (future, server); - - /* Wait until another hello is sent */ - future = _force_hello_with_ping (client, heartbeat_ms); - } - - request = mock_server_receives_any_hello (server); - _assert_hello_valid (request, false); - - reply_to_request_simple (request, server_reply); - request_destroy (request); - - if (!pooled) { - _respond_to_ping (future, server); - future = _force_hello_with_ping (client, heartbeat_ms); - } - - /* Now wait for the client to send another hello command, but this - * time the server hangs up */ - request = mock_server_receives_any_hello (server); - _assert_hello_valid (request, false); - reply_to_request_with_hang_up (request); - request_destroy (request); - - /* Client retries once (CDRIVER-2075) */ - request = mock_server_receives_any_hello (server); - _assert_hello_valid (request, true); - reply_to_request_with_hang_up (request); - request_destroy (request); - - if (!pooled) { - /* The ping wasn't sent since we hung up with hello */ - ASSERT (!future_get_bool (future)); - future_destroy (future); - - /* We're in cooldown for the next few seconds, so we're not - * allowed to send hellos. Wait for the cooldown to end. */ - _mongoc_usleep ((MONGOC_TOPOLOGY_COOLDOWN_MS + 1000) * 1000); - future = _force_hello_with_ping (client, heartbeat_ms); - } - - /* Now the client should try to reconnect. They think the server's down - * so now they SHOULD send hello */ - request = mock_server_receives_any_hello (server); - _assert_hello_valid (request, true); - - reply_to_request_simple (request, server_reply); - request_destroy (request); - - if (!pooled) { - _respond_to_ping (future, server); - } - - /* cleanup */ - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - -static void -test_client_sends_handshake_single (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_client_sends_handshake (false); -} - -static void -test_client_sends_handshake_pooled (void) -{ - _test_client_sends_handshake (true); -} - -static void -test_client_appname (bool pooled, bool use_uri) -{ - mock_server_t *server; - request_t *request; - mongoc_uri_t *uri; - future_t *future; - mongoc_client_t *client; - mongoc_client_pool_t *pool; - const char *const server_reply = tmp_str ("{'ok': 1," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - const int heartbeat_ms = 500; - - server = mock_server_new (); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "heartbeatFrequencyMS", heartbeat_ms); - mongoc_uri_set_option_as_int32 (uri, "connectTimeoutMS", 120 * 1000); - - if (use_uri) { - mongoc_uri_set_option_as_utf8 (uri, "appname", "testapp"); - } - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - if (!use_uri) { - ASSERT (mongoc_client_pool_set_appname (pool, "testapp")); - } - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - if (!use_uri) { - ASSERT (mongoc_client_set_appname (client, "testapp")); - } - future = _force_hello_with_ping (client, heartbeat_ms); - } - - request = - mock_server_receives_any_hello_with_match (server, - "{'client': {" - " 'application': {" - " 'name': 'testapp'}}}", - "{'client': {" - " 'application': {" - " 'name': 'testapp'}}}"); - - reply_to_request_simple (request, server_reply); - if (!pooled) { - _respond_to_ping (future, server); - } - - request_destroy (request); - - /* cleanup */ - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - -static void -test_client_appname_single_uri (void) -{ - test_client_appname (false, true); -} - -static void -test_client_appname_single_no_uri (void) -{ - test_client_appname (false, false); -} - -static void -test_client_appname_pooled_uri (void) -{ - test_client_appname (true, true); -} - -static void -test_client_appname_pooled_no_uri (void) -{ - test_client_appname (true, false); -} - -/* test a disconnect with a NULL bson_error_t * passed to command_simple() */ -static void -_test_null_error_pointer (bool pooled) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - future_t *future; - request_t *request; - - if (!TestSuite_CheckMockServerAllowed ()) { - return; - } - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "serverSelectionTimeoutMS", 1000); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - } - - /* connect */ - future = future_client_command_simple ( - client, "test", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'test', 'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT (future_get_bool (future)); - future_destroy (future); - - /* disconnect */ - mock_server_destroy (server); - if (pooled) { - mongoc_cluster_disconnect_node (&client->cluster, 1); - } else { - mongoc_topology_scanner_node_t *scanner_node; - - scanner_node = - mongoc_topology_scanner_get_node (client->topology->scanner, 1); - mongoc_stream_destroy (scanner_node->stream); - scanner_node->stream = NULL; - } - - /* doesn't abort with assertion failure */ - capture_logs (true); - future = future_client_command_simple ( - client, "test", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL /* error */); - ASSERT (!future_get_bool (future)); - future_destroy (future); - if (pooled) { - ASSERT_CAPTURED_LOG ("cluster", - MONGOC_LOG_LEVEL_WARNING, - "Failed to connect to target host") - } - capture_logs (false); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); -} - -static void -test_null_error_pointer_single (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_null_error_pointer (false); -} - -static void -test_null_error_pointer_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_null_error_pointer (true); -} - -#ifdef MONGOC_ENABLE_SSL -static void -test_set_ssl_opts (void) -{ - const mongoc_ssl_opt_t *opts = mongoc_ssl_opt_get_default (); - - ASSERT (opts->pem_file == NULL); - ASSERT (opts->pem_pwd == NULL); - ASSERT (opts->ca_file == NULL); - ASSERT (opts->ca_dir == NULL); - ASSERT (opts->crl_file == NULL); - ASSERT (!opts->weak_cert_validation); - ASSERT (!opts->allow_invalid_hostname); -} -#endif - -static void -test_client_reset_sessions (void) -{ - bson_error_t error; - mock_server_t *server; - mongoc_client_t *client; - mongoc_client_session_t *session; - mongoc_client_session_t *session_lookup; - future_t *future; - request_t *request; - bson_t opts = BSON_INITIALIZER; - uint32_t csid; - bson_t lsid; - bool res; - - server = mock_mongos_new (WIRE_VERSION_MAX); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - ASSERT (client->generation == 0); - - /* Ensure that resetting client removes existing sessions from its set */ - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - ASSERT (session->client_generation == client->generation); - csid = session->client_session_id; - - mongoc_client_reset (client); - ASSERT (client->generation == 1); - - ASSERT ( - !_mongoc_client_lookup_session (client, csid, &session_lookup, &error)); - - /* Ensure that resetting did not send endSessions. To do this, we wait for - a ping, so if we receive endSessions instead we will fail. */ - future = future_client_command_with_opts ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL, &error); - - request = mock_server_receives_msg ( - server, 0, tmp_bson ("{'ping': 1, 'lsid': {'$exists': true}}")); - reply_to_request_with_ok_and_destroy (request); - - ASSERT (future_get_bool (future)); - - future_destroy (future); - - /* Ensure that a session left over from before the reset call cannot - be used for any operations. */ - bson_copy_to (mongoc_client_session_get_lsid (session), &lsid); - res = (mongoc_client_session_append (session, &opts, &error)); - ASSERT_OR_PRINT (res, error); - future = future_client_command_with_opts ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, &opts, NULL, &error); - - ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid sessionId"); - - /* Add an autoresponder for endSessions to unblock the test. */ - mock_server_auto_endsessions (server); - - bson_destroy (&opts); - bson_destroy (&lsid); - future_destroy (future); - mongoc_client_session_destroy (session); - mongoc_client_session_destroy (session_lookup); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_client_reset_cursors (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - mongoc_database_t *database; - mongoc_collection_t *coll; - future_t *future; - request_t *request; - bson_error_t error; - const bson_t *doc; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - /* Ensure that cursors with an old client generation don't send killCursors. - This test should timeout and fail if the client does send killCursors. */ - - coll = mongoc_client_get_collection (client, "test", "test"); - cursor = mongoc_collection_find ( - coll, MONGOC_QUERY_NONE, 0, 0, 0, tmp_bson (NULL), NULL, NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'test', 'find': 'test'}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 4," - " 'ns': 'test.test'," - " 'firstBatch': [{}]}}"); - - BSON_ASSERT (future_get_bool (future)); - ASSERT (cursor->cursor_id); - - mongoc_client_reset (client); - - /* Attempt to call next() on the cursor after a reset--should fail without - sending any requests to the server. */ - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot advance cursor after client reset"); - - mongoc_cursor_destroy (cursor); - - request_destroy (request); - future_destroy (future); - - /* Expect a ping here, and send one after destroying cursor. If a killCursors - command intervened, this test will fail. */ - database = mongoc_client_get_database (client, "admin"); - future = future_database_command_simple ( - database, tmp_bson ("{'ping': 1}"), NULL, NULL, NULL); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - - ASSERT (future_get_bool (future)); - - future_destroy (future); - mongoc_client_destroy (client); - mongoc_collection_destroy (coll); - mongoc_database_destroy (database); - mock_server_destroy (server); -} - -static bool -mongoc_topology_scanner_is_connected (mongoc_topology_scanner_t *scanner) -{ - mongoc_topology_scanner_node_t *node; - - BSON_ASSERT (scanner); - node = scanner->nodes; - - if (!node) { - return false; - } - - while (node) { - if (!node->stream) { - return false; - } - - node = node->next; - } - - return true; -} - -static void -test_client_reset_connections (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_database_t *database; - mongoc_uri_t *uri; - future_t *future; - request_t *request; - int autoresponder_id; - - server = mock_server_new (); - autoresponder_id = - mock_server_auto_hello (server, "{ 'isWritablePrimary': true }"); - mock_server_run (server); - - /* After calling reset, check that connections are left as-is. Set - heartbeat frequency high, so a background scan won't interfere. */ - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "heartbeatFrequencyMS", 99999); - client = test_framework_client_new_from_uri (uri, NULL); - - database = mongoc_client_get_database (client, "admin"); - future = future_database_command_simple ( - database, tmp_bson ("{'ping': 1}"), NULL, NULL, NULL); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'ping': 1}")); - BSON_ASSERT (request); - reply_to_request_with_ok_and_destroy (request); - - ASSERT (future_get_bool (future)); - - mock_server_remove_autoresponder (server, autoresponder_id); - - ASSERT (mongoc_topology_scanner_is_connected (client->topology->scanner)); - - mongoc_client_reset (client); - - ASSERT (mongoc_topology_scanner_is_connected (client->topology->scanner)); - - future_destroy (future); - mongoc_uri_destroy (uri); - mongoc_database_destroy (database); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_get_database (void) -{ - mongoc_client_t *client; - mongoc_database_t *database; - mongoc_write_concern_t *wc; - mongoc_read_concern_t *rc; - mongoc_read_prefs_t *read_prefs; - - client = test_framework_client_new (NULL, NULL); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 2); - mongoc_client_set_write_concern (client, wc); - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, "majority"); - mongoc_client_set_read_concern (client, rc); - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_client_set_read_prefs (client, read_prefs); - - database = mongoc_client_get_database (client, "test"); - - ASSERT_CMPINT32 (database->write_concern->w, ==, 2); - ASSERT_CMPSTR (database->read_concern->level, "majority"); - ASSERT_CMPINT (database->read_prefs->mode, ==, MONGOC_READ_SECONDARY); - - mongoc_database_destroy (database); - mongoc_read_prefs_destroy (read_prefs); - mongoc_read_concern_destroy (rc); - mongoc_write_concern_destroy (wc); - mongoc_client_destroy (client); -} - - -static void -test_invalid_server_id (void) -{ - mongoc_client_t *client; - bson_error_t error; - bool ret; - - client = test_framework_client_new ("mongodb://localhost", NULL); - ret = mongoc_client_command_simple_with_server_id (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - 123, - NULL /* reply */, - &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Could not find server with id: 123"); - mongoc_client_destroy (client); -} - -#ifdef MONGOC_ENABLE_SSL -static void -test_ssl_opts_override (void) -{ - /* Test that mongoc_client_set_ssl_opts does not override the internal TLS - * options that can only be set through the URI. */ - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_ssl_opt_t ssl_opts = {0}; - - uri = mongoc_uri_new ( - "mongodb://localhost:27017/?tls=true&tlsDisableOCSPEndpointCheck=true"); - client = test_framework_client_new_from_uri (uri, NULL); - ssl_opts.allow_invalid_hostname = true; - mongoc_client_set_ssl_opts (client, &ssl_opts); - BSON_ASSERT (client->ssl_opts.allow_invalid_hostname); - BSON_ASSERT (((_mongoc_internal_tls_opts_t *) client->ssl_opts.internal) - ->tls_disable_ocsp_endpoint_check); - mongoc_uri_destroy (uri); - mongoc_client_destroy (client); -} - -static void -test_ssl_opts_padding_not_null (void) -{ - mongoc_client_t *client; - mongoc_ssl_opt_t ssl_opt = {0}; - - ssl_opt.allow_invalid_hostname = true; - ssl_opt.internal = (void *) 123; - client = test_framework_client_new ("mongodb://localhost:27017", NULL); - mongoc_client_set_ssl_opts (client, &ssl_opt); - BSON_ASSERT (client->ssl_opts.internal == NULL); - mongoc_client_destroy (client); -} -#endif - -static void -test_mongoc_client_recv_network_error (void) -{ - mock_server_t *server; - mongoc_client_t *client; - future_t *future; - request_t *request; - bson_error_t error; - mongoc_server_description_t const *sd; - int generation; - mcd_rpc_message *rpc = NULL; - mongoc_buffer_t buffer; - mongoc_server_stream_t *stream; - mc_shared_tpld td; - - server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - future = future_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - request = mock_server_receives_request (server); - reply_to_request_with_ok_and_destroy (request); - future_wait (future); - future_destroy (future); - - /* The server should be a standalone. */ - sd = mongoc_topology_description_server_by_id_const ( - mc_tpld_unsafe_get_const (client->topology), 1, &error); - ASSERT_OR_PRINT (sd, error); - generation = mc_tpl_sd_get_generation (sd, &kZeroServiceId); - BSON_ASSERT (sd->type == MONGOC_SERVER_STANDALONE); - mock_server_destroy (server); - - /* A network error when calling _mongoc_client_recv should mark the server - * unknown and increment the generation. */ - _mongoc_buffer_init (&buffer, - NULL /* initial buffer */, - 0 /* initial length */, - NULL /* realloc fn */, - NULL /* realloc ctx */); - rpc = mcd_rpc_message_new (); - stream = mongoc_cluster_stream_for_server ( - &client->cluster, 1, false, NULL, NULL, &error); - ASSERT_OR_PRINT (stream, error); - BSON_ASSERT (!_mongoc_client_recv (client, rpc, &buffer, stream, &error)); - - td = mc_tpld_take_ref (client->topology); - sd = mongoc_topology_description_server_by_id_const (td.ptr, 1, &error); - ASSERT_OR_PRINT (sd, error); - ASSERT_CMPINT ( - mc_tpl_sd_get_generation (sd, &kZeroServiceId), ==, generation + 1); - BSON_ASSERT (sd->type == MONGOC_SERVER_UNKNOWN); - - mongoc_client_destroy (client); - _mongoc_buffer_destroy (&buffer); - mcd_rpc_message_destroy (rpc); - mongoc_server_stream_cleanup (stream); - mc_tpld_drop_ref (&td); -} - -void -test_mongoc_client_get_handshake_hello_response_single (void) -{ - mongoc_client_t *client; - mongoc_server_description_t *monitor_sd; - mongoc_server_description_t *invalidated_sd; - mongoc_server_description_t *handshake_sd; - bson_error_t error = {0}; - - client = test_framework_new_default_client (); - /* Perform server selection to establish a connection. */ - monitor_sd = mongoc_client_select_server ( - client, false /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (monitor_sd, error); - BSON_ASSERT ( - 0 != strcmp ("Unknown", mongoc_server_description_type (monitor_sd))); - - /* Invalidate the server. */ - _mongoc_topology_invalidate_server (client->topology, monitor_sd->id); - - /* Get the new invalidated server description from monitoring. */ - invalidated_sd = - mongoc_client_get_server_description (client, monitor_sd->id); - BSON_ASSERT (NULL != invalidated_sd); - ASSERT_CMPSTR ("Unknown", mongoc_server_description_type (invalidated_sd)); - - /* The previously established connection should have a valid server - * description. */ - handshake_sd = mongoc_client_get_handshake_description ( - client, monitor_sd->id, NULL /* opts */, &error); - ASSERT_OR_PRINT (handshake_sd, error); - BSON_ASSERT ( - 0 != strcmp ("Unknown", mongoc_server_description_type (handshake_sd))); - - mongoc_server_description_destroy (handshake_sd); - mongoc_server_description_destroy (invalidated_sd); - mongoc_server_description_destroy (monitor_sd); - mongoc_client_destroy (client); -} - -void -test_mongoc_client_get_handshake_hello_response_pooled (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_server_description_t *monitor_sd; - mongoc_server_description_t *invalidated_sd; - mongoc_server_description_t *handshake_sd; - bson_error_t error = {0}; - bool ret; - - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - monitor_sd = mongoc_client_select_server ( - client, false /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (monitor_sd, error); - BSON_ASSERT ( - 0 != strcmp ("Unknown", mongoc_server_description_type (monitor_sd))); - - /* Send a ping to establish a connection. */ - ret = mongoc_client_command_simple_with_server_id (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL, - monitor_sd->id, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - /* Invalidate the server. */ - _mongoc_topology_invalidate_server (client->topology, monitor_sd->id); - - /* Get the new invalidated server description from monitoring. */ - invalidated_sd = - mongoc_client_get_server_description (client, monitor_sd->id); - BSON_ASSERT (NULL != invalidated_sd); - - // Check the resulting server description. - // Invalidating sets the type to Unknown. - // A background monitor may have set the type to PossiblePrimary. - const char *got_description_type = - mongoc_server_description_type (invalidated_sd); - if (0 != strcmp ("Unknown", got_description_type) && - 0 != strcmp ("PossiblePrimary", got_description_type)) { - test_error ("Expected server to have type 'Unknown' or " - "'PossiblePrimary', got: '%s'", - got_description_type); - } - - /* The previously established connection should have a valid server - * description. */ - handshake_sd = mongoc_client_get_handshake_description ( - client, monitor_sd->id, NULL /* opts */, &error); - ASSERT_OR_PRINT (handshake_sd, error); - BSON_ASSERT ( - 0 != strcmp ("Unknown", mongoc_server_description_type (handshake_sd))); - - mongoc_server_description_destroy (handshake_sd); - mongoc_server_description_destroy (invalidated_sd); - mongoc_server_description_destroy (monitor_sd); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); -} - -/* Test that calling mongoc_client_get_handshake_description establishes a - * connection if a connection has not already been established. */ -void -test_mongoc_client_get_handshake_establishes_connection_single (void) -{ - mongoc_client_t *client; - mongoc_server_description_t *handshake_sd; - bson_error_t error = {0}; - uint32_t server_id = 1; - - client = test_framework_new_default_client (); - - handshake_sd = mongoc_client_get_handshake_description ( - client, server_id, NULL /* opts */, &error); - ASSERT_OR_PRINT (handshake_sd, error); - BSON_ASSERT ( - 0 != strcmp ("Unknown", mongoc_server_description_type (handshake_sd))); - - mongoc_server_description_destroy (handshake_sd); - mongoc_client_destroy (client); -} - -void -test_mongoc_client_get_handshake_establishes_connection_pooled (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_server_description_t *handshake_sd; - bson_error_t error = {0}; - uint32_t server_id = 1; - - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - - /* The previously established connection should have a valid server - * description. */ - handshake_sd = mongoc_client_get_handshake_description ( - client, server_id, NULL /* opts */, &error); - ASSERT_OR_PRINT (handshake_sd, error); - BSON_ASSERT ( - 0 != strcmp ("Unknown", mongoc_server_description_type (handshake_sd))); - - mongoc_server_description_destroy (handshake_sd); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); -} - -/* Regression test for CDRIVER-4207. */ -void -test_mongoc_client_resends_handshake_on_network_error (void) -{ - mongoc_client_t *client; - mock_server_t *server; - future_t *future; - request_t *request; - bson_error_t error; - bson_t *ping = tmp_bson ("{'ping': 1}"); - - server = mock_server_new (); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - mongoc_client_set_appname (client, "foo"); - - /* Send a "ping" command. */ - future = future_client_command_simple ( - client, "db", ping, NULL /* read_prefs */, NULL /* reply */, &error); - /* The first command on the new connection is handshake. It uses the legacy - * hello and includes the client.application.name. */ - request = mock_server_receives_any_hello_with_match ( - server, - "{'" HANDSHAKE_CMD_HELLO - "': 1, 'client': {'application': {'name': 'foo'}}}", - "{'" HANDSHAKE_CMD_LEGACY_HELLO - "': 1, 'client': {'application': {'name': 'foo'}}}"); - reply_to_request_simple ( - request, - tmp_str ("{'ok': 1, 'minWireVersion': %d, 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_5_1)); - request_destroy (request); - request = mock_server_receives_msg ( - server, MONGOC_QUERY_NONE, tmp_bson ("{'ping': 1}")); - reply_to_request_with_hang_up (request); - future_wait (future); - future_destroy (future); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "socket error or timeout"); - request_destroy (request); - - /* Send another "ping" command. */ - future = future_client_command_simple ( - client, "db", ping, NULL /* read_prefs */, NULL /* reply */, &error); - /* Expect the new connection to send the full handshake. */ - request = mock_server_receives_any_hello_with_match ( - server, - "{'" HANDSHAKE_CMD_HELLO - "': 1, 'client': {'application': {'name': 'foo'}}}", - "{'" HANDSHAKE_CMD_LEGACY_HELLO - "': 1, 'client': {'application': {'name': 'foo'}}}"); - reply_to_request_simple ( - request, - tmp_str ("{'ok': 1, 'minWireVersion': %d, 'maxWireVersion': %d }", - WIRE_VERSION_MIN, - WIRE_VERSION_5_1)); - request_destroy (request); - - request = mock_server_receives_msg ( - server, MONGOC_QUERY_NONE, tmp_bson ("{'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT (future_get_bool (future)); - future_destroy (future); - - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -// test_failure_to_auth is a regression test for the leak reported in -// CDRIVER-4699. -static void -test_failure_to_auth (void) -{ - mongoc_uri_t *uri = mongoc_uri_new_for_host_port ("localhost", 12345); - mongoc_uri_set_username (uri, "foo"); - mongoc_uri_set_password (uri, "bar"); - mongoc_uri_set_option_as_bool ( - uri, MONGOC_URI_SERVERSELECTIONTRYONCE, false); - // Set a shorter serverSelectionTimeoutMS for a faster test. - // serverSelectionTimeoutMS must be long enough to require a second attempt - // of authentication. Experimentally: 100ms appears long enough to reproduce - // leak reported in CDRIVER-4699. - mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_SERVERSELECTIONTIMEOUTMS, 100); - mongoc_client_t *client = mongoc_client_new_from_uri (uri); - - // Override minHeartbeatFrequencyMS to reduce the time between server checks. - client->topology->min_heartbeat_frequency_msec = 1; - - // Disable the cooldown period to reduce the time between server checks. - // Single threaded clients wait for a default 5 second cooldown period after - // failing to connect to a server before making another attempt. - _mongoc_topology_bypass_cooldown (client->topology); - - bool ok = mongoc_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - NULL /* error */); - ASSERT_WITH_MSG (!ok, "expected command to fail, got success"); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); -} -void -test_client_install (TestSuite *suite) -{ - if (test_framework_getenv_bool ("MONGOC_CHECK_IPV6")) { - /* try to validate ipv6 too */ - TestSuite_AddLive ( - suite, "/Client/ipv6/single", test_mongoc_client_ipv6_single); - - /* try to validate ipv6 too */ - TestSuite_AddLive ( - suite, "/Client/ipv6/single", test_mongoc_client_ipv6_pooled); - } - - TestSuite_AddFull (suite, - "/Client/authenticate", - test_mongoc_client_authenticate, - NULL, - NULL, - test_framework_skip_if_no_auth); - TestSuite_AddFull (suite, - "/Client/speculative_auth_failure/single", - test_mongoc_client_single_speculative_auth_failure, - NULL, - NULL, - test_framework_skip_if_no_auth, - test_framework_skip_if_no_failpoint); - TestSuite_AddFull (suite, - "/Client/speculative_auth_failure/pooled", - test_mongoc_client_pooled_speculative_auth_failure, - NULL, - NULL, - test_framework_skip_if_no_auth, - test_framework_skip_if_no_failpoint); - TestSuite_AddFull (suite, - "/Client/authenticate_cached/pool", - test_mongoc_client_authenticate_cached_pooled, - NULL, - NULL, - test_framework_skip_if_no_auth); - TestSuite_AddFull (suite, - "/Client/authenticate_cached/client", - test_mongoc_client_authenticate_cached_single, - NULL, - NULL, - test_framework_skip_if_no_auth, - // speculativeAuthentication in single-threaded clients - // does not use the scram cache. speculativeAuthentication - // was introduced in server 4.4 (maxWireVersion=9) - test_framework_skip_if_max_wire_version_more_than_8); - TestSuite_AddFull (suite, - "/Client/authenticate_failure", - test_mongoc_client_authenticate_failure, - NULL, - NULL, - test_framework_skip_if_no_auth); - TestSuite_AddFull (suite, - "/Client/authenticate_timeout", - test_mongoc_client_authenticate_timeout, - NULL, - NULL, - test_framework_skip_if_no_auth); - TestSuite_AddLive (suite, "/Client/command", test_mongoc_client_command); - TestSuite_AddLive ( - suite, "/Client/command_defaults", test_mongoc_client_command_defaults); - TestSuite_AddLive ( - suite, "/Client/command_secondary", test_mongoc_client_command_secondary); - TestSuite_AddMockServerTest ( - suite, "/Client/command_w_server_id", test_client_cmd_w_server_id); - TestSuite_AddMockServerTest (suite, - "/Client/command_w_server_id/sharded", - test_client_cmd_w_server_id_sharded); - TestSuite_AddFull (suite, - "/Client/command_w_server_id/option", - test_server_id_option, - NULL, - NULL, - test_framework_skip_if_auth); - TestSuite_AddFull (suite, - "/Client/command_w_write_concern", - test_client_cmd_w_write_concern, - NULL, - NULL, - TestSuite_CheckLive); - TestSuite_AddMockServerTest ( - suite, "/Client/command/write_concern", test_client_cmd_write_concern); - TestSuite_AddMockServerTest (suite, - "/Client/command/write_concern_fam", - test_client_cmd_write_concern_fam); - TestSuite_AddMockServerTest (suite, - "/Client/command/read_prefs/simple/single", - test_command_simple_read_prefs_single); - TestSuite_AddMockServerTest (suite, - "/Client/command/read_prefs/simple/pooled", - test_command_simple_read_prefs_pooled); - TestSuite_AddMockServerTest (suite, - "/Client/command/read_prefs/single", - test_command_read_prefs_single); - TestSuite_AddMockServerTest (suite, - "/Client/command/read_prefs/pooled", - test_command_read_prefs_pooled); - TestSuite_AddLive ( - suite, "/Client/command_not_found/cursor", test_command_not_found); - TestSuite_AddLive ( - suite, "/Client/command_not_found/simple", test_command_not_found_simple); - TestSuite_AddMockServerTest (suite, - "/Client/command_with_opts/read_prefs", - test_command_with_opts_read_prefs); - TestSuite_AddMockServerTest (suite, - "/Client/command_with_opts/read_write", - test_read_write_cmd_with_opts); - TestSuite_AddMockServerTest ( - suite, "/Client/command_with_opts", test_command_with_opts); - TestSuite_AddMockServerTest ( - suite, "/Client/command_with_opts/op_msg", test_command_with_opts_op_msg); - TestSuite_AddMockServerTest ( - suite, "/Client/command_with_opts/read", test_read_command_with_opts); - TestSuite_AddLive (suite, "/Client/command/empty", test_command_empty); - TestSuite_AddMockServerTest ( - suite, "/Client/command/no_errmsg", test_command_no_errmsg); - TestSuite_AddMockServerTest ( - suite, "/Client/unavailable_seeds", test_unavailable_seeds); - TestSuite_AddMockServerTest (suite, - "/Client/rs_seeds_no_connect/single", - test_rs_seeds_no_connect_single); - TestSuite_AddMockServerTest (suite, - "/Client/rs_seeds_no_connect/pooled", - test_rs_seeds_no_connect_pooled); - TestSuite_AddMockServerTest ( - suite, "/Client/rs_seeds_connect/single", test_rs_seeds_connect_single); - TestSuite_AddMockServerTest ( - suite, "/Client/rs_seeds_connect/pooled", test_rs_seeds_connect_pooled); - TestSuite_AddMockServerTest (suite, - "/Client/rs_seeds_reconnect/single", - test_rs_seeds_reconnect_single); - TestSuite_AddMockServerTest (suite, - "/Client/rs_seeds_reconnect/pooled", - test_rs_seeds_reconnect_pooled); - TestSuite_AddMockServerTest (suite, - "/Client/mongos_seeds_no_connect/single", - test_mongos_seeds_no_connect_single); - TestSuite_AddMockServerTest (suite, - "/Client/mongos_seeds_no_connect/pooled", - test_mongos_seeds_no_connect_pooled); - TestSuite_AddMockServerTest (suite, - "/Client/mongos_seeds_connect/single", - test_mongos_seeds_connect_single); - TestSuite_AddMockServerTest (suite, - "/Client/mongos_seeds_connect/pooled", - test_mongos_seeds_connect_pooled); - TestSuite_AddMockServerTest (suite, - "/Client/mongos_seeds_reconnect/single", - test_mongos_seeds_reconnect_single); - TestSuite_AddMockServerTest (suite, - "/Client/mongos_seeds_reconnect/pooled", - test_mongos_seeds_reconnect_pooled); - TestSuite_AddFull (suite, - "/Client/recovering", - test_recovering, - NULL, - NULL, - test_framework_skip_if_slow); - TestSuite_AddLive (suite, "/Client/server_status", test_server_status); - TestSuite_AddMockServerTest ( - suite, "/Client/database_names", test_get_database_names); - TestSuite_AddFull (suite, - "/Client/connect/uds", - test_mongoc_client_unix_domain_socket, - NULL, - NULL, - test_framework_skip_if_no_uds); - TestSuite_AddMockServerTest ( - suite, "/Client/mismatched_me", test_mongoc_client_mismatched_me); - - TestSuite_AddMockServerTest ( - suite, "/Client/handshake/pool", test_mongoc_handshake_pool); - TestSuite_Add (suite, - "/Client/application_handshake", - test_mongoc_client_application_handshake); - TestSuite_AddFull (suite, - "/Client/sends_handshake_single", - test_client_sends_handshake_single, - NULL, - NULL, - test_framework_skip_if_slow); - TestSuite_Add (suite, - "/Client/sends_handshake_pooled", - test_client_sends_handshake_pooled); - TestSuite_AddMockServerTest ( - suite, "/Client/appname_single_uri", test_client_appname_single_uri); - TestSuite_AddMockServerTest (suite, - "/Client/appname_single_no_uri", - test_client_appname_single_no_uri); - TestSuite_AddMockServerTest ( - suite, "/Client/appname_pooled_uri", test_client_appname_pooled_uri); - TestSuite_AddMockServerTest (suite, - "/Client/appname_pooled_no_uri", - test_client_appname_pooled_no_uri); - TestSuite_AddMockServerTest ( - suite, "/Client/wire_version", test_wire_version); -#ifdef MONGOC_ENABLE_SSL - TestSuite_AddLive (suite, "/Client/ssl_opts/single", test_ssl_single); - TestSuite_AddLive (suite, "/Client/ssl_opts/pooled", test_ssl_pooled); - TestSuite_Add (suite, "/Client/set_ssl_opts", test_set_ssl_opts); - TestSuite_Add (suite, "/Client/ssl_opts_override", test_ssl_opts_override); - TestSuite_Add (suite, - "/Client/ssl_opts_padding_not_null/single", - test_ssl_opts_padding_not_null); - TestSuite_AddLive (suite, "/Client/ssl_hang", test_client_buildinfo_hang); - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) || \ - defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) - TestSuite_AddMockServerTest (suite, - "/Client/ssl_opts/copies_single", - test_ssl_client_single_copies_args); - TestSuite_AddMockServerTest (suite, - "/Client/ssl_opts/copies_pooled", - test_ssl_client_pooled_copies_args); - TestSuite_AddMockServerTest ( - suite, "/Client/ssl/reconnect/single", test_ssl_reconnect_single); - TestSuite_AddMockServerTest ( - suite, "/Client/ssl/reconnect/pooled", test_ssl_reconnect_pooled); - -#endif -#else - /* No SSL support at all */ - TestSuite_Add ( - suite, "/Client/ssl_disabled", test_mongoc_client_ssl_disabled); -#endif - - TestSuite_AddMockServerTest (suite, - "/Client/client_reset/sessions", - test_client_reset_sessions, - test_framework_skip_if_no_crypto); - - TestSuite_AddMockServerTest ( - suite, "/Client/client_reset/cursors", test_client_reset_cursors); - TestSuite_AddMockServerTest ( - suite, "/Client/client_reset/connections", test_client_reset_connections); - - TestSuite_AddLive (suite, - "/Client/get_description/single", - test_mongoc_client_get_description_single); - TestSuite_AddLive (suite, - "/Client/get_description/pooled", - test_mongoc_client_get_description_pooled); - TestSuite_AddLive (suite, - "/Client/descriptions/single", - test_mongoc_client_descriptions_single); - TestSuite_AddFull (suite, - "/Client/descriptions/pooled", - test_mongoc_client_descriptions_pooled, - NULL, - NULL, - TestSuite_CheckLive); - TestSuite_AddLive (suite, - "/Client/select_server/single", - test_mongoc_client_select_server_single); - TestSuite_AddLive (suite, - "/Client/select_server/pooled", - test_mongoc_client_select_server_pooled); - TestSuite_AddLive (suite, - "/Client/select_server/err/single", - test_mongoc_client_select_server_error_single); - TestSuite_AddLive (suite, - "/Client/select_server/err/pooled", - test_mongoc_client_select_server_error_pooled); - TestSuite_AddMockServerTest (suite, - "/Client/select_server/retry/succeed", - test_mongoc_client_select_server_retry_succeed); - TestSuite_AddMockServerTest (suite, - "/Client/select_server/retry/fail", - test_mongoc_client_select_server_retry_fail); - TestSuite_AddMockServerTest (suite, - "/Client/fetch_stream/retry/succeed", - test_mongoc_client_fetch_stream_retry_succeed); - TestSuite_AddMockServerTest (suite, - "/Client/fetch_stream/retry/fail", - test_mongoc_client_fetch_stream_retry_fail); - TestSuite_AddFull (suite, - "/Client/null_error_pointer/single", - test_null_error_pointer_single, - NULL, - NULL, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/Client/null_error_pointer/pooled", - test_null_error_pointer_pooled, - NULL, - NULL, - test_framework_skip_if_slow); - TestSuite_Add (suite, "/Client/get_database", test_get_database); - TestSuite_Add (suite, "/Client/invalid_server_id", test_invalid_server_id); - TestSuite_AddMockServerTest (suite, - "/Client/recv_network_error", - test_mongoc_client_recv_network_error); - TestSuite_AddLive (suite, - "/Client/get_handshake_hello_response/single", - test_mongoc_client_get_handshake_hello_response_single); - TestSuite_AddLive (suite, - "/Client/get_handshake_hello_response/pooled", - test_mongoc_client_get_handshake_hello_response_pooled); - TestSuite_AddLive ( - suite, - "/Client/get_handshake_establishes_connection/single", - test_mongoc_client_get_handshake_establishes_connection_single); - TestSuite_AddLive ( - suite, - "/Client/get_handshake_establishes_connection/pooled", - test_mongoc_client_get_handshake_establishes_connection_pooled); - TestSuite_AddMockServerTest ( - suite, - "/Client/resends_handshake_on_network_error", - test_mongoc_client_resends_handshake_on_network_error); - TestSuite_Add (suite, "/Client/failure_to_auth", test_failure_to_auth); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cluster.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cluster.c deleted file mode 100644 index c0f7f8297..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cluster.c +++ /dev/null @@ -1,2026 +0,0 @@ -#include -#include - -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-client-pool-private.h" -#include "mongoc/mongoc-topology-background-monitoring-private.h" -#include "mongoc/mongoc-uri-private.h" - -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "TestSuite.h" -#include "test-libmongoc.h" -#include "test-conveniences.h" - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "cluster-test" - - -static uint32_t -server_id_for_reads (mongoc_cluster_t *cluster) -{ - bson_error_t error; - mongoc_server_stream_t *server_stream; - uint32_t id; - - server_stream = - mongoc_cluster_stream_for_reads (cluster, NULL, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (server_stream, error); - id = server_stream->sd->id; - - mongoc_server_stream_cleanup (server_stream); - - return id; -} - - -static void -test_get_max_bson_obj_size (void) -{ - mongoc_server_description_t *sd; - mongoc_cluster_node_t *node; - mongoc_client_pool_t *pool; - mongoc_client_t *client; - int32_t max_bson_obj_size = 16; - uint32_t id; - mc_tpld_modification tdmod; - - /* single-threaded */ - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - id = server_id_for_reads (&client->cluster); - tdmod = mc_tpld_modify_begin (client->topology); - sd = mongoc_set_get (mc_tpld_servers (tdmod.new_td), id); - sd->max_bson_obj_size = max_bson_obj_size; - mc_tpld_modify_commit (tdmod); - BSON_ASSERT (max_bson_obj_size == - mongoc_cluster_get_max_bson_obj_size (&client->cluster)); - - mongoc_client_destroy (client); - - /* multi-threaded */ - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - - id = server_id_for_reads (&client->cluster); - node = (mongoc_cluster_node_t *) mongoc_set_get (client->cluster.nodes, id); - node->handshake_sd->max_bson_obj_size = max_bson_obj_size; - BSON_ASSERT (max_bson_obj_size == - mongoc_cluster_get_max_bson_obj_size (&client->cluster)); - - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); -} - -static void -test_get_max_msg_size (void) -{ - mongoc_server_description_t *sd; - mongoc_cluster_node_t *node; - mongoc_client_pool_t *pool; - mongoc_client_t *client; - int32_t max_msg_size = 32; - uint32_t id; - mc_tpld_modification tdmod; - - /* single-threaded */ - client = test_framework_new_default_client (); - id = server_id_for_reads (&client->cluster); - - tdmod = mc_tpld_modify_begin (client->topology); - sd = mongoc_set_get (mc_tpld_servers (tdmod.new_td), id); - sd->max_msg_size = max_msg_size; - mc_tpld_modify_commit (tdmod); - BSON_ASSERT (max_msg_size == - mongoc_cluster_get_max_msg_size (&client->cluster)); - - mongoc_client_destroy (client); - - /* multi-threaded */ - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - - id = server_id_for_reads (&client->cluster); - node = (mongoc_cluster_node_t *) mongoc_set_get (client->cluster.nodes, id); - node->handshake_sd->max_msg_size = max_msg_size; - BSON_ASSERT (max_msg_size == - mongoc_cluster_get_max_msg_size (&client->cluster)); - - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); -} - - -#define ASSERT_CURSOR_ERR() \ - do { \ - BSON_ASSERT (!future_get_bool (future)); \ - BSON_ASSERT (mongoc_cursor_error (cursor, &error)); \ - ASSERT_ERROR_CONTAINS ( \ - error, \ - MONGOC_ERROR_STREAM, \ - MONGOC_ERROR_STREAM_SOCKET, \ - "Failed to read 4 bytes: socket error or timeout"); \ - } while (0) - - -#define START_QUERY(client_port_variable) \ - do { \ - cursor = mongoc_collection_find_with_opts ( \ - collection, tmp_bson ("{}"), NULL, NULL); \ - future = future_cursor_next (cursor, &doc); \ - request = mock_server_receives_msg ( \ - server, \ - MONGOC_MSG_NONE, \ - tmp_bson ("{'$db': 'test', 'find': 'test', 'filter': {}}")); \ - BSON_ASSERT (request); \ - client_port_variable = request_get_client_port (request); \ - } while (0) - - -#define CLEANUP_QUERY() \ - do { \ - request_destroy (request); \ - future_destroy (future); \ - mongoc_cursor_destroy (cursor); \ - } while (0) - - -/* test that we reconnect a cluster node after disconnect */ -static void -_test_cluster_node_disconnect (bool pooled) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_collection_t *collection; - const bson_t *doc; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - uint16_t client_port_0, client_port_1; - bson_error_t error; - - if (!TestSuite_CheckMockServerAllowed ()) { - return; - } - - capture_logs (true); - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - uri = mongoc_uri_copy (mock_server_get_uri (server)); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - } - - collection = mongoc_client_get_collection (client, "test", "test"); - - /* query 0 fails. set client_port_0 to the port used by the query. */ - START_QUERY (client_port_0); - - reply_to_request_with_reset (request); - ASSERT_CURSOR_ERR (); - CLEANUP_QUERY (); - - /* query 1 opens a new socket. set client_port_1 to the new port. */ - START_QUERY (client_port_1); - ASSERT_CMPINT (client_port_1, !=, client_port_0); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': [{'a': 1}]}}"); - - /* success! */ - BSON_ASSERT (future_get_bool (future)); - - CLEANUP_QUERY (); - mongoc_collection_destroy (collection); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - - -static void -test_cluster_node_disconnect_single (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_cluster_node_disconnect (false); -} - - -static void -test_cluster_node_disconnect_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_cluster_node_disconnect (true); -} - - -static void -_test_cluster_command_timeout (bool pooled) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bson_error_t error; - future_t *future; - request_t *request; - uint16_t client_port; - mongoc_server_description_t const *sd; - bson_t reply; - - capture_logs (true); - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "socketTimeoutMS", 200); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - } - - /* server doesn't respond in time */ - future = future_client_command_simple ( - client, "db", tmp_bson ("{'foo': 1}"), NULL, NULL, &error); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'foo': 1}")); - client_port = request_get_client_port (request); - - ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to send \"foo\" command with database \"db\""); - - /* a network timeout does NOT invalidate the server description */ - sd = mongoc_topology_description_server_by_id_const ( - mc_tpld_unsafe_get_const (client->topology), 1, NULL); - BSON_ASSERT (sd->type != MONGOC_SERVER_UNKNOWN); - - /* late response */ - reply_to_request_simple (request, "{'ok': 1, 'bar': 1}"); - request_destroy (request); - future_destroy (future); - - future = future_client_command_simple ( - client, "db", tmp_bson ("{'baz': 1}"), NULL, &reply, &error); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'baz': 1}")); - ASSERT (request); - /* new socket */ - ASSERT_CMPUINT16 (client_port, !=, request_get_client_port (request)); - reply_to_request_simple (request, "{'ok': 1, 'quux': 1}"); - ASSERT (future_get_bool (future)); - - /* got the proper response */ - ASSERT_HAS_FIELD (&reply, "quux"); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - bson_destroy (&reply); - request_destroy (request); - future_destroy (future); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - - -static void -test_cluster_command_timeout_single (void) -{ - _test_cluster_command_timeout (false); -} - - -static void -test_cluster_command_timeout_pooled (void) -{ - _test_cluster_command_timeout (true); -} - - -static void -_test_write_disconnect (void) -{ - mock_server_t *server; - char *hello; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - future_t *future; - request_t *request; - mongoc_topology_scanner_node_t *scanner_node; - mongoc_server_description_t const *sd; - - if (!TestSuite_CheckMockServerAllowed ()) { - return; - } - - server = mock_server_new (); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - /* - * establish connection with an "hello" and "ping" - */ - future = future_client_command_simple ( - client, "db", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - request = mock_server_receives_any_hello (server); - hello = bson_strdup_printf ("{'ok': 1.0," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - - reply_to_request_simple (request, hello); - request_destroy (request); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'ping': 1}")); - reply_to_request_simple (request, "{'ok': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - - /* - * close the socket - */ - reply_to_request_with_hang_up (request); - - /* - * next operation detects the hangup - */ - collection = mongoc_client_get_collection (client, "db", "collection"); - future_destroy (future); - future = future_collection_insert_one ( - collection, tmp_bson ("{'_id': 1}"), NULL, NULL, &error); - - ASSERT (!future_get_bool (future)); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_STREAM); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_STREAM_SOCKET); - - scanner_node = mongoc_topology_scanner_get_node (client->topology->scanner, - 1 /* server_id */); - ASSERT (scanner_node && !scanner_node->stream); - - /* a hangup DOES invalidate the server description */ - sd = mongoc_topology_description_server_by_id_const ( - mc_tpld_unsafe_get_const (client->topology), 1, NULL); - BSON_ASSERT (sd->type == MONGOC_SERVER_UNKNOWN); - - mongoc_collection_destroy (collection); - request_destroy (request); - future_destroy (future); - bson_free (hello); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_write_command_disconnect (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_write_disconnect (); -} - - -typedef struct { - int calls; - bson_t *cluster_time; - bson_t *command; -} cluster_time_test_t; - - -static void -test_cluster_time_cmd_started_cb (const mongoc_apm_command_started_t *event) -{ - const bson_t *cmd; - cluster_time_test_t *test; - bson_iter_t iter; - bson_t client_cluster_time; - - cmd = mongoc_apm_command_started_get_command (event); - if (!strcmp (_mongoc_get_command_name (cmd), "killCursors")) { - /* ignore killCursors */ - return; - } - - test = - (cluster_time_test_t *) mongoc_apm_command_started_get_context (event); - - test->calls++; - bson_destroy (test->command); - test->command = bson_copy (cmd); - - /* Only a MongoDB 3.6+ server reports $clusterTime. If we've received a - * $clusterTime, we send it to any server. In this case, we got a - * $clusterTime during the initial handshake. */ - if (test_framework_clustertime_supported ()) { - BSON_ASSERT (bson_iter_init_find (&iter, cmd, "$clusterTime")); - BSON_ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - - if (test->calls == 2) { - /* previous call to cmd_succeeded_cb saved server's clusterTime */ - BSON_ASSERT (!bson_empty0 (test->cluster_time)); - bson_iter_bson (&iter, &client_cluster_time); - if (!bson_equal (test->cluster_time, &client_cluster_time)) { - test_error ("Unequal clusterTimes.\nServer sent %s\nClient sent %s", - bson_as_json (test->cluster_time, NULL), - bson_as_json (&client_cluster_time, NULL)); - } - - bson_destroy (&client_cluster_time); - } - } else { - BSON_ASSERT (!bson_has_field (event->command, "$clusterTime")); - } -} - - -static void -test_cluster_time_cmd_succeeded_cb (const mongoc_apm_command_succeeded_t *event) -{ - const bson_t *reply; - cluster_time_test_t *test; - bson_iter_t iter; - uint32_t len; - const uint8_t *data; - - reply = mongoc_apm_command_succeeded_get_reply (event); - test = - (cluster_time_test_t *) mongoc_apm_command_succeeded_get_context (event); - - /* Only a MongoDB 3.6+ server reports $clusterTime. Save it in "test". */ - if (test_framework_clustertime_supported ()) { - BSON_ASSERT (bson_iter_init_find (&iter, reply, "$clusterTime")); - BSON_ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - bson_iter_document (&iter, &len, &data); - bson_destroy (test->cluster_time); - test->cluster_time = bson_new_from_data (data, len); - } -} - - -typedef bool (*command_fn_t) (mongoc_client_t *, bson_error_t *); - - -/* test $clusterTime handling according to the test instructions in the - * Driver Sessions Spec */ -static void -_test_cluster_time (bool pooled, command_fn_t command) -{ - mongoc_apm_callbacks_t *callbacks; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bool r; - bson_error_t error; - cluster_time_test_t cluster_time_test; - - cluster_time_test.calls = 0; - cluster_time_test.command = NULL; - cluster_time_test.cluster_time = NULL; - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, - test_cluster_time_cmd_started_cb); - mongoc_apm_set_command_succeeded_cb (callbacks, - test_cluster_time_cmd_succeeded_cb); - - if (pooled) { - pool = test_framework_new_default_client_pool (); - mongoc_client_pool_set_apm_callbacks ( - pool, callbacks, &cluster_time_test); - client = mongoc_client_pool_pop (pool); - /* CDRIVER-3596 - prevent client discovery of the pool interfering with - * the test operations. */ - _mongoc_usleep (5000 * 1000); /* 5 s */ - } else { - client = test_framework_new_default_client (); - mongoc_client_set_apm_callbacks (client, callbacks, &cluster_time_test); - } - - r = command (client, &error); - ASSERT_OR_PRINT (r, error); - ASSERT_CMPINT (cluster_time_test.calls, ==, 1); - - /* repeat */ - r = command (client, &error); - ASSERT_OR_PRINT (r, error); - ASSERT_CMPINT (cluster_time_test.calls, ==, 2); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_apm_callbacks_destroy (callbacks); - bson_destroy (cluster_time_test.command); - bson_destroy (cluster_time_test.cluster_time); -} - - -static bool -command_simple (mongoc_client_t *client, bson_error_t *error) -{ - return mongoc_client_command_simple ( - client, "test", tmp_bson ("{'ping': 1}"), NULL, NULL, error); -} - - -static void -test_cluster_time_command_simple_single (void) -{ - _test_cluster_time (false, command_simple); -} - - -static void -test_cluster_time_command_simple_pooled (void) -{ - _test_cluster_time (true, command_simple); -} - - -/* test the deprecated mongoc_client_command function with $clusterTime */ -static bool -client_command (mongoc_client_t *client, bson_error_t *error) -{ - mongoc_cursor_t *cursor; - const bson_t *doc; - bool r; - - ASSERT (client); - - cursor = mongoc_client_command (client, - "test", - MONGOC_QUERY_NONE, - 0, - 0, - 0, - tmp_bson ("{'ping': 1}"), - NULL, - NULL); - - mongoc_cursor_next (cursor, &doc); - r = !mongoc_cursor_error (cursor, error); - mongoc_cursor_destroy (cursor); - return r; -} - - -static void -test_cluster_time_command_single (void) -{ - _test_cluster_time (false, client_command); -} - - -static void -test_cluster_time_command_pooled (void) -{ - _test_cluster_time (true, client_command); -} - - -/* test modern mongoc_client_read_command_with_opts with $clusterTime */ -static bool -client_command_with_opts (mongoc_client_t *client, bson_error_t *error) -{ - /* any of the with_opts command functions should work */ - return mongoc_client_read_command_with_opts ( - client, "test", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL, error); -} - - -static void -test_cluster_time_command_with_opts_single (void) -{ - _test_cluster_time (false, client_command_with_opts); -} - - -static void -test_cluster_time_command_with_opts_pooled (void) -{ - _test_cluster_time (true, client_command_with_opts); -} - - -/* test aggregate with $clusterTime */ -static bool -aggregate (mongoc_client_t *client, bson_error_t *error) -{ - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - const bson_t *doc; - bool r; - - ASSERT (client); - - collection = mongoc_client_get_collection (client, "test", "collection"); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson ("{}"), NULL, NULL); - - mongoc_cursor_next (cursor, &doc); - r = !mongoc_cursor_error (cursor, error); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - - return r; -} - - -static void -test_cluster_time_aggregate_single (void) -{ - _test_cluster_time (false, aggregate); -} - - -static void -test_cluster_time_aggregate_pooled (void) -{ - _test_cluster_time (true, aggregate); -} - - -/* test queries with $clusterTime */ -static bool -cursor_next (mongoc_client_t *client, bson_error_t *error) -{ - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - const bson_t *doc; - bool r; - - ASSERT (client); - collection = get_test_collection (client, "test_cluster_time_cursor"); - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{'ping': 1}"), NULL, NULL); - - mongoc_cursor_next (cursor, &doc); - r = !mongoc_cursor_error (cursor, error); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - - return r; -} - - -static void -test_cluster_time_cursor_single (void) -{ - _test_cluster_time (false, cursor_next); -} - - -static void -test_cluster_time_cursor_pooled (void) -{ - _test_cluster_time (true, cursor_next); -} - - -/* test inserts with $clusterTime */ -static bool -insert (mongoc_client_t *client, bson_error_t *error) -{ - mongoc_collection_t *collection; - bool r; - - ASSERT (client); - - collection = get_test_collection (client, "test_cluster_time_cursor"); - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{}"), NULL, NULL, error); - - mongoc_collection_destroy (collection); - - return r; -} - - -static void -test_cluster_time_insert_single (void) -{ - _test_cluster_time (false, insert); -} - - -static void -test_cluster_time_insert_pooled (void) -{ - _test_cluster_time (true, insert); -} - - -static void -test_cluster_command_timeout_negative (void) -{ - bson_error_t error; - - mongoc_uri_t *const uri = test_framework_get_uri (); - - // CDRIVER-4781: libmongoc historically supports negative values as - // fallback to a "default" value for timeouts. - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_SOCKETTIMEOUTMS, -1); - - mongoc_client_t *const client = - test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - - // There should not be an error when validating sockettimeoutms. - ASSERT_OR_PRINT ( - mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error), - error); - - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); -} - - -static void -replies_with_cluster_time (request_t *request, - int t, - int i, - const char *docs_json) -{ - char *quotes_replaced; - bson_t doc; - bson_error_t error; - bool r; - - BSON_ASSERT (request); - - if (docs_json) { - quotes_replaced = single_quotes_to_double (docs_json); - r = bson_init_from_json (&doc, quotes_replaced, -1, &error); - bson_free (quotes_replaced); - } else { - r = bson_init_from_json (&doc, "{}", -1, &error); - } - - if (!r) { - MONGOC_WARNING ("%s", error.message); - return; - } - - BSON_APPEND_DOCUMENT ( - &doc, - "$clusterTime", - tmp_bson ("{'clusterTime': {'$timestamp': {'t': %d, 'i': %d}}, 'x': 'y'}", - t, - i)); - - reply_to_request_with_multiple_docs ( - request, MONGOC_REPLY_NONE, &doc, 1, 0 /* cursor id */); - - bson_destroy (&doc); - request_destroy (request); -} - - -static request_t * -receives_with_cluster_time (mock_server_t *server, - uint32_t timestamp, - uint32_t increment, - bson_t *command) -{ - request_t *request; - const bson_t *doc; - bson_iter_t cluster_time; - uint32_t t; - uint32_t i; - - request = mock_server_receives_msg (server, 0, command); - BSON_ASSERT (request); - doc = request_get_doc (request, 0); - - BSON_ASSERT (bson_iter_init_find (&cluster_time, doc, "$clusterTime")); - BSON_ASSERT (BSON_ITER_HOLDS_DOCUMENT (&cluster_time)); - BSON_ASSERT (bson_iter_recurse (&cluster_time, &cluster_time)); - BSON_ASSERT (bson_iter_find (&cluster_time, "clusterTime")); - BSON_ASSERT (BSON_ITER_HOLDS_TIMESTAMP (&cluster_time)); - bson_iter_timestamp (&cluster_time, &t, &i); - if (t != timestamp || i != increment) { - test_error ("Expected Timestamp(%d, %d), got Timestamp(%d, %d)", - timestamp, - increment, - t, - i); - } - - return request; -} - - -static void -assert_ok (future_t *future, const bson_error_t *error) -{ - bool r = future_get_bool (future); - ASSERT_OR_PRINT (r, (*error)); - future_destroy (future); -} - - -static future_t * -future_ping (mongoc_client_t *client, bson_error_t *error) -{ - return future_client_command_simple ( - client, "test", tmp_bson ("{'ping': 1}"), NULL, NULL, error); -} - - -static void -_test_cluster_time_comparison (bool pooled) -{ - const char *hello = tmp_str ("{'ok': 1.0," - " 'isWritablePrimary': true," - " 'msg': 'isdbgrid'," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bson_error_t error; - future_t *future; - request_t *request; - bson_t *ping = tmp_bson ("{'ping': 1}"); - - server = mock_server_new (); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "heartbeatFrequencyMS", 500); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - } - - future = future_ping (client, &error); - - /* timestamp is 1 */ - request = mock_server_receives_any_hello (server); - replies_with_cluster_time (request, 1, 1, hello); - - if (pooled) { - /* a pooled client handshakes its own connection */ - request = mock_server_receives_any_hello (server); - replies_with_cluster_time (request, 1, 1, hello); - } - - request = receives_with_cluster_time (server, 1, 1, ping); - - /* timestamp is 2, increment is 2 */ - replies_with_cluster_time (request, 2, 2, "{'ok': 1.0}"); - assert_ok (future, &error); - - future = future_ping (client, &error); - request = receives_with_cluster_time (server, 2, 2, ping); - - /* timestamp is 2, increment is only 1 */ - replies_with_cluster_time (request, 2, 1, "{'ok': 1.0}"); - assert_ok (future, &error); - - future = future_ping (client, &error); - - /* client doesn't update cluster time, since new value is less than old */ - request = receives_with_cluster_time (server, 2, 2, ping); - reply_to_request_with_ok_and_destroy (request); - assert_ok (future, &error); - - if (pooled) { - /* wait for next heartbeat, it should contain newest cluster time */ - request = mock_server_receives_any_hello_with_match ( - server, - "{'$clusterTime': " - "{'clusterTime': {'$timestamp': " - "{'t': 2, 'i': 2}}}}", - - "{'$clusterTime': " - "{'clusterTime': {'$timestamp': " - "{'t': 2, 'i': 2}}}}"); - - replies_with_cluster_time (request, 2, 1, hello); - - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - /* trigger next heartbeat, it should contain newest cluster time */ - _mongoc_usleep (750 * 1000); /* 750 ms */ - future = future_ping (client, &error); - request = mock_server_receives_any_hello_with_match ( - server, - "{'$clusterTime': " - "{'clusterTime': {'$timestamp': " - "{'t': 2, 'i': 2}}}}", - - "{'$clusterTime': " - "{'clusterTime': {'$timestamp': " - "{'t': 2, 'i': 2}}}}"); - - replies_with_cluster_time (request, 2, 1, hello); - request = receives_with_cluster_time (server, 2, 2, ping); - reply_to_request_with_ok_and_destroy (request); - assert_ok (future, &error); - - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - - -static void -test_cluster_time_comparison_single (void) -{ - _test_cluster_time_comparison (false); -} - - -static void -test_cluster_time_comparison_pooled (void) -{ - _test_cluster_time_comparison (true); -} - - -typedef future_t *(*run_command_fn_t) (mongoc_client_t *); -typedef void (*cleanup_fn_t) (future_t *); - - -typedef struct { - const char *errmsg; - bool is_not_primary_err; -} test_error_msg_t; - - -test_error_msg_t errors[] = { - {"not master", true}, - {"not master or secondary", true}, - {"node is recovering", true}, - {"not master and secondaryOk=false", true}, - {"replicatedToNum called but not master anymore", true}, - {"??? node is recovering ???", true}, - {"??? not master ???", true}, - {"foo", false}, - {0}}; - -/* a "not primary" or "node is recovering" error marks server Unknown. - "not primary" and "node is recovering" need only be substrings of the error - message. */ -static void -_test_not_primary (bool pooled, - run_command_fn_t run_command, - cleanup_fn_t cleanup_fn) -{ - test_error_msg_t *test_error_msg; - mock_server_t *server; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - const char *cmd = "{'cmd': 1}"; - bson_error_t error; - future_t *future; - request_t *request; - mongoc_topology_description_t const *td; - const mongoc_server_description_t *sd; - char *reply; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri ( - mock_server_get_uri (server), NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (mock_server_get_uri (server), - NULL); - } - - for (test_error_msg = errors; test_error_msg->errmsg; test_error_msg++) { - /* - * successful command results in known server type - */ - future = future_client_command_simple ( - client, "test", tmp_bson (cmd), NULL, NULL, &error); - - request = mock_server_receives_request (server); - reply_to_request_with_ok_and_destroy (request); - BSON_ASSERT (future_get_bool (future)); - future_destroy (future); - - /* Topology may be invalidated by client_command_simple */ - td = mc_tpld_unsafe_get_const (client->topology); - sd = mongoc_set_get_const (mc_tpld_servers_const (td), 1); - - BSON_ASSERT (sd->type == MONGOC_SERVER_STANDALONE); - - /* - * command error marks server Unknown if it's a "not primary" error - */ - future = run_command (client); - request = mock_server_receives_request (server); - - reply = bson_strdup_printf ("{'ok': 0, 'errmsg': '%s'}", - test_error_msg->errmsg); - reply_to_request_simple (request, reply); - BSON_ASSERT (!future_get_bool (future)); - - /* Topology should be invalidated by run_command */ - td = mc_tpld_unsafe_get_const (client->topology); - sd = mongoc_set_get_const (mc_tpld_servers_const (td), 1); - - if (test_error_msg->is_not_primary_err) { - BSON_ASSERT (sd->type == MONGOC_SERVER_UNKNOWN); - } else { - BSON_ASSERT (sd->type == MONGOC_SERVER_STANDALONE); - } - - bson_free (reply); - request_destroy (request); - cleanup_fn (future); - } - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mock_server_destroy (server); -} - - -static future_t * -future_command_simple (mongoc_client_t *client) -{ - return future_client_command_simple ( - client, "test", tmp_bson ("{'cmd': 1}"), NULL, NULL, NULL); -} - - -static void -function_command_simple_cleanup (future_t *future) -{ - future_destroy (future); -} - - -static void -test_not_primary_single (void) -{ - _test_not_primary ( - false, future_command_simple, function_command_simple_cleanup); -} - - -static void -test_not_primary_pooled (void) -{ - _test_not_primary ( - true, future_command_simple, function_command_simple_cleanup); -} - - -/* parts must remain valid after future_command_private exits */ -mongoc_cmd_parts_t parts; - -static future_t * -future_command_private (mongoc_client_t *client) -{ - bson_error_t error; - mongoc_server_stream_t *server_stream; - - ASSERT (client); - - server_stream = mongoc_cluster_stream_for_writes ( - &client->cluster, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (server_stream, error); - - mongoc_cmd_parts_init ( - &parts, client, "test", MONGOC_QUERY_NONE, tmp_bson ("{'cmd': 1}")); - - /* mongoc_cluster_run_command_parts will call mongoc_cmd_parts_cleanup */ - return future_cluster_run_command_parts ( - &client->cluster, server_stream, &parts, NULL, NULL); -} - - -static void -future_command_private_cleanup (future_t *future) -{ - mongoc_server_stream_t *server_stream = - future_value_get_mongoc_server_stream_ptr (future_get_param (future, 1)); - mongoc_server_stream_cleanup (server_stream); - future_destroy (future); -} - - -static void -test_not_primary_auth_single (void) -{ - _test_not_primary ( - false, future_command_private, future_command_private_cleanup); -} - - -static void -test_not_primary_auth_pooled (void) -{ - _test_not_primary ( - true, future_command_private, future_command_private_cleanup); -} - - -typedef struct { - const char *name; - const char *q; - const char *e; - bool secondary; - bool cluster_time; -} dollar_query_test_t; - - -static bool -auto_hello_callback (request_t *request, void *data, bson_t *hello_response) -{ - dollar_query_test_t *test; - bson_t cluster_time; - - BSON_UNUSED (request); - - test = (dollar_query_test_t *) data; - - bson_init (hello_response); - BSON_APPEND_INT32 (hello_response, "ok", 1); - BSON_APPEND_BOOL (hello_response, "isWritablePrimary", !test->secondary); - BSON_APPEND_BOOL (hello_response, "secondary", test->secondary); - BSON_APPEND_INT32 (hello_response, "minWireVersion", WIRE_VERSION_MIN); - BSON_APPEND_INT32 (hello_response, "maxWireVersion", WIRE_VERSION_MAX); - BSON_APPEND_UTF8 (hello_response, "setName", "rs"); - - if (test->cluster_time) { - BSON_APPEND_DOCUMENT_BEGIN ( - hello_response, "$clusterTime", &cluster_time); - BSON_APPEND_TIMESTAMP (&cluster_time, "clusterTime", 1, 1); - bson_append_document_end (hello_response, &cluster_time); - } - - return true; -} - - -static void -_test_dollar_query (void *ctx) -{ - dollar_query_test_t *test; - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_read_prefs_t *read_prefs; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - const bson_t *doc; - bson_error_t error; - - test = (dollar_query_test_t *) ctx; - - server = mock_server_new (); - mock_server_auto_hello_callback (server, auto_hello_callback, test, NULL); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - if (test->secondary) { - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - } else { - read_prefs = NULL; - } - - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_NONE, - 0, - 0, - 0, - tmp_bson (test->q), - NULL, - read_prefs); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg (server, 0, tmp_bson (test->e)); - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.collection'," - " 'firstBatch': []}}")); - - BSON_ASSERT (!future_get_bool (future)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - future_destroy (future); - request_destroy (request); - mongoc_read_prefs_destroy (read_prefs); - mongoc_cursor_destroy (cursor); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -dollar_query_test_t tests[] = { - {"/Cluster/cluster_time/query/", - "{'a': 1}", - "{" - " 'find': 'collection', 'filter': {'a': 1}," - " '$clusterTime': {'$exists': false}" - "}", - false, - false}, - {"/Cluster/cluster_time/query/cluster_time", - "{'a': 1}", - "{" - " 'find': 'collection', 'filter': {'a': 1}," - " '$clusterTime': {'$exists': true}" - "}", - false, - true}, - {"/Cluster/cluster_time/query/secondary", - "{'a': 1}", - "{" - " 'find': 'collection', 'filter': {'a': 1}, " - " '$clusterTime': {'$exists': false}," - " '$readPreference': {'mode': 'secondary'}" - "}", - true, - false}, - {"/Cluster/cluster_time/query/cluster_time_secondary", - "{'a': 1}", - "{" - " 'find': 'collection', 'filter': {'a': 1}, " - " '$clusterTime': {'$exists': true}," - " '$readPreference': {'mode': 'secondary'}" - "}", - true, - true}, - {"/Cluster/cluster_time/dollar_query/from_user", - "{'$query': {'a': 1}}", - "{" - " 'find': 'collection', 'filter': {'a': 1}," - " '$clusterTime': {'$exists': false}" - "}", - false, - false}, - {"/Cluster/cluster_time/dollar_query/from_user/cluster_time", - "{'$query': {'a': 1}}", - "{" - " 'find': 'collection', 'filter': {'a': 1}," - " '$clusterTime': {'$exists': true}" - "}", - false, - true}, - {"/Cluster/cluster_time/dollar_query/from_user/secondary", - "{'$query': {'a': 1}}", - "{" - " 'find': 'collection', 'filter': {'a': 1}," - " '$clusterTime': {'$exists': false}," - " '$readPreference': {'mode': 'secondary'}" - "}", - true, - false}, - {"/Cluster/cluster_time/dollar_query/from_user/cluster_time_secondary", - "{'$query': {'a': 1}}", - "{" - " 'find': 'collection', 'filter': {'a': 1}," - " '$clusterTime': {'$exists': true}," - " '$readPreference': {'mode': 'secondary'}" - "}", - true, - true}, - {"/Cluster/cluster_time/dollar_orderby", - "{'$query': {'a': 1}, '$orderby': {'a': 1}}", - "{" - " 'find': 'collection', 'filter': {'a': 1}," - " 'sort': {'a': 1}" - "}", - false, - false}, - {"/Cluster/cluster_time/dollar_orderby/secondary", - "{'$query': {'a': 1}, '$orderby': {'a': 1}}", - "{" - " 'find': 'collection', 'filter': {'a': 1}," - " 'sort': {'a': 1}," - " '$clusterTime': {'$exists': false}," - " '$readPreference': {'mode': 'secondary'}" - "}", - true, - false}, - {"/Cluster/cluster_time/dollar_orderby/cluster_time", - "{'$query': {'a': 1}, '$orderby': {'a': 1}}", - "{" - " 'find': 'collection', 'filter': {'a': 1}," - " 'sort': {'a': 1}," - " '$clusterTime': {'$exists': true}" - "}", - false, - true}, - {"/Cluster/cluster_time/dollar_orderby/cluster_time_secondary", - "{'$query': {'a': 1}, '$orderby': {'a': 1}}", - "{" - " 'find': 'collection', 'filter': {'a': 1}," - " 'sort': {'a': 1}," - " '$clusterTime': {'$exists': true}," - " '$readPreference': {'mode': 'secondary'}" - "}", - true, - true}, - {NULL}}; - -static void -_test_cluster_hello_fails (bool hangup) -{ - mock_server_t *mock_server; - mongoc_uri_t *uri; - mongoc_server_description_t *sd; - mongoc_client_pool_t *pool; - mongoc_client_t *client; - request_t *request; - future_t *future; - bson_error_t error; - int autoresponder_id; - - mock_server = mock_server_new (); - autoresponder_id = - mock_server_auto_hello (mock_server, "{ 'isWritablePrimary': true }"); - mock_server_run (mock_server); - uri = mongoc_uri_copy (mock_server_get_uri (mock_server)); - /* increase heartbeatFrequencyMS to prevent background server selection. */ - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 99999); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - mongoc_client_pool_set_error_api (pool, 2); - mongoc_uri_destroy (uri); - client = mongoc_client_pool_pop (pool); - /* do server selection to add this server to the topology. this does not add - * a cluster node for this server. */ - sd = mongoc_client_select_server (client, false, NULL, NULL); - BSON_ASSERT (sd); - mongoc_server_description_destroy (sd); - mock_server_remove_autoresponder (mock_server, autoresponder_id); - /* now create a cluster node by running a command. */ - future = future_client_command_simple ( - client, "test", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - /* the client adds a cluster node, creating a stream to the server, and then - * sends a hello request. */ - request = mock_server_receives_any_hello (mock_server); - /* CDRIVER-2576: the server replies with an error, so - * _mongoc_stream_run_hello returns NULL, which - * _mongoc_cluster_run_hello must check. */ - - if (hangup) { - capture_logs (true); /* suppress "failed to buffer" warning */ - reply_to_request_with_hang_up (request); - BSON_ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "socket err"); - } else { - reply_to_request_simple (request, "{'ok': 0, 'code': 123}"); - BSON_ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_SERVER, 123, "Unknown command error"); - } - - request_destroy (request); - future_destroy (future); - mock_server_destroy (mock_server); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); -} - -static void -test_cluster_hello_fails (void) -{ - _test_cluster_hello_fails (false); -} - - -static void -test_cluster_hello_hangup (void) -{ - _test_cluster_hello_fails (true); -} - -static void -test_cluster_command_error (void) -{ - mock_server_t *server; - mongoc_client_t *client; - bson_error_t err; - request_t *request; - future_t *future; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - future = future_client_command_simple (client, - "db", - tmp_bson ("{'ping': 1}"), - NULL /* opts */, - NULL /* read prefs */, - &err); - request = mock_server_receives_msg ( - server, MONGOC_QUERY_NONE, tmp_bson ("{'$db': 'db', 'ping': 1}")); - reply_to_request_with_hang_up (request); - BSON_ASSERT (!future_get_bool (future)); - future_destroy (future); - request_destroy (request); - /* _mongoc_buffer_append_from_stream, used by opmsg gives more detail. */ - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to send \"ping\" command with database " - "\"db\": Failed to read 4 bytes: socket error or " - "timeout"); - mock_server_destroy (server); - mongoc_client_destroy (client); -} - -static void -test_advanced_cluster_time_not_sent_to_standalone (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_client_session_t *cs; - bson_t opts = BSON_INITIALIZER; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - const bson_t *doc; - bson_error_t error; - - server = mock_server_new (); - mock_server_auto_endsessions (server); - mock_server_auto_hello (server, - "{'ok': 1.0," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'logicalSessionTimeoutMinutes': 30}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - cs = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (cs, error); - - mongoc_client_session_advance_cluster_time ( - cs, tmp_bson ("{'clusterTime': {'$timestamp': {'t': 1, 'i': 1}}}")); - - ASSERT_OR_PRINT (mongoc_client_session_append (cs, &opts, &error), error); - - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{}"), &opts, NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - 0, - tmp_bson ("{" - " 'find': 'collection', 'filter': {}," - " '$clusterTime': {'$exists': false}" - "}")); - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.collection'," - " 'firstBatch': []}}")); - - BSON_ASSERT (!future_get_bool (future)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - bson_destroy (&opts); - mongoc_collection_destroy (collection); - mongoc_client_session_destroy (cs); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -/* Responds properly to hello, hangs up on serverStatus, and replies {ok:1} - * to everything else. */ -static bool -_responder (request_t *req, void *data) -{ - char *hello; - - hello = (char *) data; - if (0 == strcasecmp (req->command_name, HANDSHAKE_CMD_LEGACY_HELLO) || - 0 == strcasecmp (req->command_name, "hello")) { - reply_to_request_simple (req, hello); - request_destroy (req); - return true; - } else if (0 == strcmp (req->command_name, "serverStatus")) { - reply_to_request_with_hang_up (req); - request_destroy (req); - return true; - } - - /* Otherwise, reply {ok:1} */ - reply_to_request_with_ok_and_destroy (req); - return true; -} - -static mongoc_stream_t * -_initiator_fn (const mongoc_uri_t *uri, - const mongoc_host_list_t *host, - void *user_data, - bson_error_t *error) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - bool ret; - bson_t *cmd; - bson_error_t ss_error; - mongoc_stream_t *stream; - - cmd = BCON_NEW ("serverStatus", BCON_INT32 (1)); - pool = (mongoc_client_pool_t *) user_data; - client = mongoc_client_pool_pop (pool); - - /* Hide warnings that get logged from network errors. */ - capture_logs (true); - ret = - mongoc_client_command_simple (client, "db", cmd, NULL, NULL, &ss_error); - capture_logs (false); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (ss_error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "socket error or timeout"); - stream = mongoc_client_default_stream_initiator (uri, host, client, error); - ASSERT_OR_PRINT (stream != NULL, (*error)); - mongoc_client_pool_push (pool, client); - bson_destroy (cmd); - return stream; -} - -void -test_hello_on_unknown (void) -{ - mock_server_t *mock_server; - mongoc_client_pool_t *pool; - mongoc_client_t *client; - bson_error_t error; - bool ret; - mongoc_uri_t *uri; - - mock_server = mock_server_new (); - mock_server_run (mock_server); - mock_server_autoresponds (mock_server, - _responder, - (void *) tmp_str ("{ 'ok': 1.0," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'msg': 'isdbgrid'}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX), - NULL); - - uri = mongoc_uri_copy (mock_server_get_uri (mock_server)); - - /* Add a placeholder additional host, so the topology type can be SHARDED. - * The host will get removed on the first failed hello. */ - ret = mongoc_uri_upsert_host (uri, "localhost", 12345, &error); - ASSERT_OR_PRINT (ret, error); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - - client = mongoc_client_pool_pop (pool); - - mongoc_client_set_stream_initiator (client, _initiator_fn, pool); - - /* The other client marked the server as unknown after this client selected - * the server and created a stream, but *before* constructing the initial - * hello. This reproduces the crash reported in CDRIVER-3404. */ - ret = mongoc_client_command_simple ( - client, "db", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (ret, error); - - - mongoc_uri_destroy (uri); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - mock_server_destroy (mock_server); -} - - -/* Test what happens when running a command directly on a server (by passing an - * explicit server id) that is marked as "unknown" in the topology description. - * Prior to the bug fix of CDRIVER-3404, a pooled client would erroneously - * attempt to send the command. - * - * Update: After applying the fix to CDRIVER-3653 this test was updated. - * Connections will track their own server description from the handshake - * response. - * Marking the server unknown in the shared topology description no longer - * affects established connections. - */ -void -_test_cmd_on_unknown_serverid (bool pooled) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - bson_error_t error; - bool ret; - mongoc_uri_t *uri; - - uri = test_framework_get_uri (); - /* Set a lower heartbeatFrequencyMS. - * Servers supporting streamable hello will only respond to an awaitable - * hello until heartbeatFrequencyMS has passed or the server had changed - * state. This test marks the server Unknown in the client's topology - * description. During cleanup, _mongoc_client_end_sessions will attempt to - * do server selection again and wait for a server to become discovered. */ - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 5000); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - client = mongoc_client_pool_pop (pool); - } else { - pool = NULL; - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - } - - /* Do the initial topology scan and selection. */ - ret = mongoc_client_command_simple (client, - "admin", - tmp_bson ("{ 'ping': 1 }"), - NULL /* read prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - - ret = mongoc_client_command_simple_with_server_id (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - 1, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - /* Invalidate the server, giving it the server type MONGOC_SERVER_UNKNOWN */ - _mongoc_topology_invalidate_server (client->topology, 1); - - /* The next command is attempted directly on the unknown server and should - * result in an error. */ - ret = mongoc_client_command_simple_with_server_id (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - 1, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - mongoc_uri_destroy (uri); -} - -void -test_cmd_on_unknown_serverid_pooled (void) -{ - _test_cmd_on_unknown_serverid (true /* pooled */); -} - -void -test_cmd_on_unknown_serverid_single (void) -{ - _test_cmd_on_unknown_serverid (false /* pooled */); -} - - -/* Test that server streams are invalidated as expected. */ -static void -test_cluster_stream_invalidation_single (void) -{ - mongoc_client_t *client; - mongoc_server_description_t *sd; - bson_error_t error; - mongoc_server_stream_t *stream; - mc_tpld_modification tdmod; - - client = test_framework_new_default_client (); - /* Select a server to start monitoring. */ - sd = mongoc_client_select_server ( - client, true /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (sd, error); - - /* Test "clearing the pool". This should invalidate existing server streams. - */ - stream = mongoc_cluster_stream_for_writes (&client->cluster, - NULL /* session */, - NULL /* deprioritized servers */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (stream, error); - BSON_ASSERT (mongoc_cluster_stream_valid (&client->cluster, stream)); - tdmod = mc_tpld_modify_begin (client->topology); - _mongoc_topology_description_clear_connection_pool ( - tdmod.new_td, mongoc_server_description_id (sd), &kZeroServiceId); - mc_tpld_modify_commit (tdmod); - BSON_ASSERT (!mongoc_cluster_stream_valid (&client->cluster, stream)); - mongoc_server_stream_cleanup (stream); - - /* Test closing the connection. This should invalidate existing server - * streams. */ - stream = mongoc_cluster_stream_for_writes (&client->cluster, - NULL /* session */, - NULL /* deprioritized servers */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (stream, error); - BSON_ASSERT (mongoc_cluster_stream_valid (&client->cluster, stream)); - mongoc_cluster_disconnect_node (&client->cluster, sd->id); - BSON_ASSERT (!mongoc_cluster_stream_valid (&client->cluster, stream)); - mongoc_server_stream_cleanup (stream); - - /* Test that a new stream is considered valid. */ - stream = mongoc_cluster_stream_for_writes (&client->cluster, - NULL /* session */, - NULL /* deprioritized servers */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (stream, error); - BSON_ASSERT (mongoc_cluster_stream_valid (&client->cluster, stream)); - mongoc_server_stream_cleanup (stream); - - mongoc_server_description_destroy (sd); - mongoc_client_destroy (client); -} - -/* Test that server streams are invalidated as expected. */ -static void -test_cluster_stream_invalidation_pooled (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - mongoc_server_description_t *sd; - bson_error_t error; - mongoc_server_stream_t *stream; - mc_tpld_modification tdmod; - - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - /* Select a server. */ - sd = mongoc_client_select_server ( - client, true /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (sd, error); - - /* Test "clearing the pool". This should invalidate existing server streams. - */ - stream = mongoc_cluster_stream_for_writes (&client->cluster, - NULL /* session */, - NULL /* deprioritized servers */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (stream, error); - BSON_ASSERT (mongoc_cluster_stream_valid (&client->cluster, stream)); - tdmod = mc_tpld_modify_begin (client->topology); - _mongoc_topology_description_clear_connection_pool ( - tdmod.new_td, mongoc_server_description_id (sd), &kZeroServiceId); - mc_tpld_modify_commit (tdmod); - BSON_ASSERT (!mongoc_cluster_stream_valid (&client->cluster, stream)); - mongoc_server_stream_cleanup (stream); - - /* Test closing the connection. This should invalidate existing server - * streams. */ - stream = mongoc_cluster_stream_for_writes (&client->cluster, - NULL /* session */, - NULL /* deprioritized servers */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (stream, error); - BSON_ASSERT (mongoc_cluster_stream_valid (&client->cluster, stream)); - mongoc_cluster_disconnect_node (&client->cluster, sd->id); - BSON_ASSERT (!mongoc_cluster_stream_valid (&client->cluster, stream)); - mongoc_server_stream_cleanup (stream); - - /* Test that a new stream is considered valid. */ - stream = mongoc_cluster_stream_for_writes (&client->cluster, - NULL /* session */, - NULL /* deprioritized servers */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (stream, error); - BSON_ASSERT (mongoc_cluster_stream_valid (&client->cluster, stream)); - mongoc_server_stream_cleanup (stream); - - mongoc_server_description_destroy (sd); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); -} - -void -test_cluster_install (TestSuite *suite) -{ - dollar_query_test_t *p = tests; - - while (p->name) { - TestSuite_AddFull (suite, - p->name, - _test_dollar_query, - NULL, - p, - TestSuite_CheckMockServerAllowed); - - p++; - } - - TestSuite_AddLive ( - suite, "/Cluster/test_get_max_bson_obj_size", test_get_max_bson_obj_size); - TestSuite_AddLive ( - suite, "/Cluster/test_get_max_msg_size", test_get_max_msg_size); - TestSuite_AddFull (suite, - "/Cluster/disconnect/single", - test_cluster_node_disconnect_single, - NULL, - NULL, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/Cluster/disconnect/pooled", - test_cluster_node_disconnect_pooled, - NULL, - NULL, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest (suite, - "/Cluster/command/timeout/single", - test_cluster_command_timeout_single); - TestSuite_AddMockServerTest (suite, - "/Cluster/command/timeout/pooled", - test_cluster_command_timeout_pooled); - TestSuite_AddFull (suite, - "/Cluster/write_command/disconnect", - test_write_command_disconnect, - NULL, - NULL, - test_framework_skip_if_slow); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/command_simple/single", - test_cluster_time_command_simple_single); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/command_simple/pooled", - test_cluster_time_command_simple_pooled); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/command/single", - test_cluster_time_command_single); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/command/pooled", - test_cluster_time_command_pooled); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/command_with_opts/single", - test_cluster_time_command_with_opts_single); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/command_with_opts/pooled", - test_cluster_time_command_with_opts_pooled); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/aggregate/single", - test_cluster_time_aggregate_single); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/aggregate/pooled", - test_cluster_time_aggregate_pooled); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/cursor/single", - test_cluster_time_cursor_single); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/cursor/pooled", - test_cluster_time_cursor_pooled); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/insert/single", - test_cluster_time_insert_single); - TestSuite_AddLive (suite, - "/Cluster/cluster_time/insert/pooled", - test_cluster_time_insert_pooled); - TestSuite_AddLive (suite, - "/Cluster/command/timeout/negative", - test_cluster_command_timeout_negative); - TestSuite_AddMockServerTest (suite, - "/Cluster/cluster_time/comparison/single", - test_cluster_time_comparison_single, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest (suite, - "/Cluster/cluster_time/comparison/pooled", - test_cluster_time_comparison_pooled, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest ( - suite, - "/Cluster/cluster_time/advanced_not_sent_to_standalone", - test_advanced_cluster_time_not_sent_to_standalone, - test_framework_skip_if_no_crypto); - TestSuite_AddMockServerTest (suite, - "/Cluster/not_primary/single", - test_not_primary_single, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest (suite, - "/Cluster/not_primary/pooled", - test_not_primary_pooled, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest (suite, - "/Cluster/not_primary_auth/single", - test_not_primary_auth_single, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest (suite, - "/Cluster/not_primary_auth/pooled", - test_not_primary_auth_pooled, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest ( - suite, "/Cluster/hello_fails", test_cluster_hello_fails); - TestSuite_AddMockServerTest ( - suite, "/Cluster/hello_hangup", test_cluster_hello_hangup); - TestSuite_AddMockServerTest ( - suite, "/Cluster/command_error/op_msg", test_cluster_command_error); - TestSuite_AddMockServerTest ( - suite, "/Cluster/hello_on_unknown/mock", test_hello_on_unknown); - /* These tests exhibit some mysterious behavior after the new feature - changes-- see: "https://jira.mongodb.org/browse/CDRIVER-4293". - TestSuite_AddLive (suite, - "/Cluster/cmd_on_unknown_serverid/pooled", - test_cmd_on_unknown_serverid_pooled); - TestSuite_AddLive (suite, - "/Cluster/cmd_on_unknown_serverid/single", - test_cmd_on_unknown_serverid_single); - */ - TestSuite_AddLive (suite, - "/Cluster/stream_invalidation/single", - test_cluster_stream_invalidation_single); - TestSuite_AddLive (suite, - "/Cluster/stream_invalidation/pooled", - test_cluster_stream_invalidation_pooled); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cmd.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cmd.c deleted file mode 100644 index 2e8da5e73..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cmd.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2020 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "mongoc/mongoc-client-private.h" - -#include "TestSuite.h" -#include "test-conveniences.h" -#include "mock_server/mock-server.h" -#include "mock_server/future-functions.h" -#include "test-libmongoc.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "cmd-test-options" - - -/* CDRIVER-3303 - mongoc_cmd_parts_assemble sometimes fails to set options; - * the fix was to refactor the code and this test guards against regressions - */ -static void -test_client_cmd_options (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_read_concern_t *rc; - bson_t opts; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_MAJORITY); - bson_init (&opts); - mongoc_read_concern_append (rc, &opts); - - future = - future_client_command_with_opts (client, - "db", - tmp_bson ("{'ping': 1, '$db': 'db'}"), - NULL, - &opts, - NULL, - &error); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{'readConcern': { '$exists': true }}")); - - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - - request_destroy (request); - future_destroy (future); - - bson_destroy (&opts); - mongoc_read_concern_destroy (rc); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -void -test_client_cmd_install (TestSuite *suite) -{ - TestSuite_AddMockServerTest ( - suite, "/Client/cmd/options", test_client_cmd_options); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c deleted file mode 100644 index 6e68afef8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c +++ /dev/null @@ -1,1006 +0,0 @@ -#include -#include "mongoc/mongoc-cursor-private.h" -#include "mongoc/mongoc-client-private.h" - -#include "TestSuite.h" -#include "test-conveniences.h" -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "test-libmongoc.h" -#include "mock_server/mock-rs.h" - - -typedef struct { - const char *filter; - bson_t *filter_bson; - const char *opts; - bson_t *opts_bson; - mongoc_read_prefs_t *read_prefs; - const char *expected_find_command; - int32_t expected_n_return; - mongoc_query_flags_t expected_flags; - uint32_t expected_skip; -} test_collection_find_with_opts_t; - - -/*-------------------------------------------------------------------------- - * - * _test_collection_find_command -- - * - * Start a mock server with @max_wire_version, connect a client, and - * execute a query with @test_data->filter and @test_data->opts. Use - * the @check_request_fn callback to verify the client formatted the - * query correctly, and @reply_json to respond to the client. - * - *-------------------------------------------------------------------------- - */ - -static void -_test_collection_find_command (test_collection_find_with_opts_t *test_data) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_error_t error; - future_t *future; - request_t *request; - const bson_t *doc; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_find_with_opts (collection, - test_data->filter_bson, - test_data->opts_bson, - test_data->read_prefs); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson (test_data->expected_find_command)); - ASSERT (request); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -_test_collection_find_with_opts (test_collection_find_with_opts_t *test_data) -{ - BSON_ASSERT (test_data->expected_find_command); - - test_data->filter_bson = tmp_bson (test_data->filter); - test_data->opts_bson = tmp_bson (test_data->opts); - - _test_collection_find_command (test_data); -} - - -static void -test_dollar_or (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.filter = "{'$or': [{'_id': 1}]}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {'$or': [{'_id': 1}]}}"; - - _test_collection_find_with_opts (&test_data); -} - - -/* test '$or': [{'_id': 1}], 'snapshot': true - * we just use snapshot to prove that an option can be passed - * alongside '$or' - */ -static void -test_snapshot_dollar_or (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.filter = "{'$or': [{'_id': 1}]}"; - test_data.opts = "{'snapshot': true}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {'$or': [{'_id': 1}]}," - " 'snapshot': true}"; - - _test_collection_find_with_opts (&test_data); -} - - -/* test that we can query for a document by a key named "filter" */ -static void -test_key_named_filter (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.filter = "{'filter': 2}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {'filter': 2}}"; - _test_collection_find_with_opts (&test_data); -} - - -/* test 'filter': {'filter': {'i': 2}} */ -static void -test_op_query_subdoc_named_filter (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.filter = "{'filter': {'i': 2}}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {'filter': {'i': 2}}}"; - _test_collection_find_with_opts (&test_data); -} - - -/* test 'filter': {'filter': {'i': 2}}, 'snapshot': true - * we just use snapshot to prove that an option can be passed - * alongside 'filter' - */ -static void -test_find_cmd_subdoc_named_filter_with_option (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.filter = "{'filter': {'i': 2}}"; - test_data.opts = "{'snapshot': true}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {'filter': {'i': 2}}, " - " 'snapshot': true}"; - - _test_collection_find_with_opts (&test_data); -} - - -static void -test_newoption (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.filter = "{'_id': 1}"; - test_data.opts = "{'newOption': true}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {'_id': 1}, 'newOption': true}"; - - _test_collection_find_with_opts (&test_data); -} - - -static void -test_sort (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'sort': {'_id': -1}}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'sort': {'_id': -1}}"; - _test_collection_find_with_opts (&test_data); -} - - -static void -test_fields (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'projection': {'_id': 0, 'b': 1}}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'projection': {'_id': 0, 'b': 1}}"; - _test_collection_find_with_opts (&test_data); -} - - -static void -test_slice (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'projection': {'array': {'$slice': 10}}}"; - test_data.expected_find_command = - "{'find': 'collection', " - " 'filter': {}," - " 'projection': {'array': {'$slice': 10}}}"; - _test_collection_find_with_opts (&test_data); -} - - -static void -test_int_modifiers (void) -{ - const char *modifiers[] = { - "maxScan", - "maxTimeMS", - }; - - const char *mod; - size_t i; - char *opts; - char *find_command; - test_collection_find_with_opts_t test_data = {0}; - - for (i = 0; i < sizeof (modifiers) / sizeof (const char *); i++) { - mod = modifiers[i]; - opts = bson_strdup_printf ("{'%s': {'$numberLong': '9999'}}", mod); - - /* find command has same modifier, without the $-prefix */ - find_command = bson_strdup_printf ("{'find': 'collection', 'filter': {}," - " '%s': {'$numberLong': '9999'}}", - mod); - - test_data.opts = opts; - test_data.expected_find_command = find_command; - _test_collection_find_with_opts (&test_data); - - bson_free (opts); - bson_free (find_command); - } -} - - -static void -test_index_spec_modifiers (void) -{ - const char *modifiers[] = { - "hint", - "min", - "max", - }; - - const char *mod; - size_t i; - char *opts; - char *find_command; - test_collection_find_with_opts_t test_data = {0}; - - for (i = 0; i < sizeof (modifiers) / sizeof (const char *); i++) { - mod = modifiers[i]; - opts = bson_strdup_printf ("{'%s': {'_id': 1}}", mod); - - /* find command options have no $-prefix: hint, min, max */ - find_command = bson_strdup_printf ( - "{'find': 'collection', 'filter': {}, '%s': {'_id': 1}}", mod); - - test_data.opts = opts; - test_data.expected_find_command = find_command; - _test_collection_find_with_opts (&test_data); - - bson_free (opts); - bson_free (find_command); - } -} - - -static void -test_comment (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'comment': 'COMMENT'}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'comment': 'COMMENT'}"; - _test_collection_find_with_opts (&test_data); -} - - -static void -test_snapshot (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'snapshot': true}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'snapshot': true}"; - _test_collection_find_with_opts (&test_data); -} - - -/* showRecordId becomes $showDiskLoc */ -static void -test_diskloc (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'showRecordId': true}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'showRecordId': true}"; - _test_collection_find_with_opts (&test_data); -} - - -static void -test_returnkey (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'returnKey': true}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'returnKey': true}"; - _test_collection_find_with_opts (&test_data); -} - - -static void -test_skip (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.expected_skip = 1; - test_data.opts = "{'skip': {'$numberLong': '1'}}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'skip': {'$numberLong': '1'}}"; - _test_collection_find_with_opts (&test_data); -} - - -static void -test_batch_size (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'batchSize': {'$numberLong': '2'}}"; - test_data.expected_n_return = 2; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'batchSize': {'$numberLong': '2'}}"; - _test_collection_find_with_opts (&test_data); -} - - -static void -test_limit (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'limit': {'$numberLong': '2'}}"; - test_data.expected_n_return = 2; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'limit': {'$numberLong': '2'}}"; - _test_collection_find_with_opts (&test_data); -} - - -static void -test_singlebatch (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'limit': {'$numberLong': '2'}, 'singleBatch': true}"; - test_data.expected_n_return = -2; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, " - " 'singleBatch': true, 'limit': {'$numberLong': '2'}}"; - - _test_collection_find_with_opts (&test_data); -} - -static void -test_singlebatch_no_limit (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'singleBatch': true}"; - /* singleBatch doesn't affect OP_QUERY with limit 0, nToReturn is still 0 */ - test_data.expected_n_return = 0; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'singleBatch': true}"; - - _test_collection_find_with_opts (&test_data); -} - - -static void -test_unrecognized_dollar_option (void) -{ - test_collection_find_with_opts_t test_data = {0}; - - test_data.opts = "{'dumb': 1}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'dumb': 1}"; - - _test_collection_find_with_opts (&test_data); -} - - -static void -test_query_flags (void) -{ - int i; - char *opts; - char *find_cmd; - test_collection_find_with_opts_t test_data = {0}; - - typedef struct { - mongoc_query_flags_t flag; - const char *json_fragment; - } flag_and_name_t; - - /* secondaryOk is not supported as an option, exhaust is tested separately */ - flag_and_name_t flags_and_frags[] = { - {MONGOC_QUERY_TAILABLE_CURSOR, "'tailable': true"}, - {MONGOC_QUERY_OPLOG_REPLAY, "'oplogReplay': true"}, - {MONGOC_QUERY_NO_CURSOR_TIMEOUT, "'noCursorTimeout': true"}, - {MONGOC_QUERY_PARTIAL, "'allowPartialResults': true"}, - {MONGOC_QUERY_TAILABLE_CURSOR | MONGOC_QUERY_AWAIT_DATA, - "'tailable': true, 'awaitData': true"}, - }; - - for (i = 0; i < (sizeof flags_and_frags) / (sizeof (flag_and_name_t)); i++) { - opts = bson_strdup_printf ("{%s}", flags_and_frags[i].json_fragment); - find_cmd = bson_strdup_printf ("{'find': 'collection', 'filter': {}, %s}", - flags_and_frags[i].json_fragment); - - test_data.opts = opts; - test_data.expected_flags = flags_and_frags[i].flag; - test_data.expected_find_command = find_cmd; - - _test_collection_find_with_opts (&test_data); - - bson_free (find_cmd); - bson_free (opts); - } -} - - -static void -test_exhaust (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - request_t *request; - future_t *future; - const bson_t *doc; - bson_error_t error; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson (NULL), tmp_bson ("{'exhaust': true}"), NULL); - - future = future_cursor_next (cursor, &doc); - - /* Find, getMore and killCursors commands spec: "The find command does not - * support the exhaust flag from OP_QUERY. Drivers that support exhaust MUST - * fallback to existing OP_QUERY wire protocol messages." - */ - request = mock_server_receives_request (server); - reply_to_find_request (request, - MONGOC_QUERY_SECONDARY_OK | MONGOC_QUERY_EXHAUST, - 0, - 0, - "db.collection", - "{}", - false /* is_command */); - - ASSERT (future_get_bool (future)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_getmore_cmd_await (void) -{ - bson_t *opts; - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - const bson_t *doc; - - opts = tmp_bson ("{'tailable': true," - " 'awaitData': true," - " 'maxAwaitTimeMS': {'$numberLong': '9999'}}"); - - /* - * "find" command - */ - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson (NULL), opts, NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'find': 'collection'," - " 'filter': {}," - " 'maxTimeMS': {'$exists': false}," - " 'maxAwaitTimeMS': {'$exists': false}}")); - - ASSERT (request); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '123'}," - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - - ASSERT (future_get_bool (future)); - request_destroy (request); - future_destroy (future); - - /* - * "getMore" command - */ - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '123'}," - " 'collection': 'collection'," - " 'maxAwaitTimeMS': {'$exists': false}," - " 'maxTimeMS': {'$numberLong': '9999'}}")); - - ASSERT (request); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.collection'," - " 'nextBatch': [{}]}}"); - - ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_find_w_server_id (void) -{ - mock_rs_t *rs; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *opts; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - - rs = mock_rs_with_auto_hello (WIRE_VERSION_MIN /* wire version */, - true /* has primary */, - 1 /* secondary */, - 0 /* arbiters */); - - mock_rs_run (rs); - client = test_framework_client_new_from_uri (mock_rs_get_uri (rs), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - /* use serverId instead of prefs to select the secondary */ - opts = tmp_bson ("{'serverId': 2}"); - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson (NULL), opts, NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_rs_receives_msg ( - rs, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'find': 'collection'," - " 'filter': {}," - " '$readPreference': {'mode': 'primaryPreferred'}}")); - - ASSERT (mock_rs_request_is_to_secondary (rs, request)); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - ASSERT_OR_PRINT (future_get_bool (future), cursor->error); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_rs_destroy (rs); -} - - -static void -test_find_cmd_w_server_id (void) -{ - mock_rs_t *rs; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *opts; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - bson_error_t error; - - rs = mock_rs_with_auto_hello (WIRE_VERSION_MIN, - true /* has primary */, - 1 /* secondary */, - 0 /* arbiters */); - - mock_rs_run (rs); - client = test_framework_client_new_from_uri (mock_rs_get_uri (rs), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - /* use serverId instead of prefs to select the secondary */ - opts = tmp_bson ("{'serverId': 2, 'readConcern': {'level': 'local'}}"); - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson (NULL), opts, NULL); - - future = future_cursor_next (cursor, &doc); - - /* recognized that wire version is recent enough for readConcern */ - request = - mock_rs_receives_msg (rs, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'find': 'collection', " - " 'filter': {}," - " 'readConcern': {'level': 'local'}," - " 'serverId': {'$exists': false}}")); - - ASSERT (mock_rs_request_is_to_secondary (rs, request)); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - - ASSERT_OR_PRINT (future_get_bool (future), error); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_rs_destroy (rs); -} - - -static void -test_find_w_server_id_sharded (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *opts; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - opts = tmp_bson ("{'serverId': 1}"); - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson (NULL), opts, NULL); - - future = future_cursor_next (cursor, &doc); - - /* Does NOT set '$readPreference', since this is a sharded topology. */ - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'find': 'collection'," - " 'filter': {}," - " '$readPreference': {'$exists': false}}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_find_cmd_w_server_id_sharded (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *opts; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - opts = tmp_bson ("{'serverId': 1, 'readConcern': {'level': 'local'}}"); - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson (NULL), opts, NULL); - - future = future_cursor_next (cursor, &doc); - - /* recognized that wire version is recent enough for readConcern */ - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'find': 'collection', " - " 'filter': {}," - " 'readConcern': {'level': 'local'}," - " 'serverId': {'$exists': false}}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - - ASSERT_OR_PRINT (future_get_bool (future), error); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_server_id_option (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *q; - bson_error_t error; - mongoc_cursor_t *cursor; - - client = test_framework_new_default_client (); - collection = mongoc_client_get_collection (client, "db", "collection"); - q = tmp_bson (NULL); - cursor = mongoc_collection_find_with_opts ( - collection, q, tmp_bson ("{'serverId': 'foo'}"), NULL); - - ASSERT_ERROR_CONTAINS (cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "must be an integer"); - - mongoc_cursor_destroy (cursor); - cursor = mongoc_collection_find_with_opts ( - collection, q, tmp_bson ("{'serverId': 0}"), NULL); - - ASSERT_ERROR_CONTAINS (cursor->error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "must be >= 1"); - - mongoc_cursor_destroy (cursor); - cursor = mongoc_collection_find_with_opts ( - collection, q, tmp_bson ("{'serverId': 1}"), NULL); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -static void -test_find_batchSize (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - mongoc_cursor_t *cursor; - - client = test_framework_new_default_client (); - collection = mongoc_client_get_collection (client, "db", "collection"); - - // Test a cursor with an int32 batchSize. - { - cursor = mongoc_collection_find_with_opts ( - collection, - tmp_bson ("{}"), - tmp_bson ("{'batchSize': { '$numberInt': '1' }}"), - NULL); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - // Exhaust the cursor. - { - // Note: Cursors are lazy. The `find` command is sent on the first call - // to `mongoc_cursor_next`. - const bson_t *got; - while (mongoc_cursor_next (cursor, &got)) - ; - } - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - } - - // Test a cursor with an int64 batchSize. - { - cursor = mongoc_collection_find_with_opts ( - collection, - tmp_bson ("{}"), - tmp_bson ("{'batchSize': { '$numberLong': '1' }}"), - NULL); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - // Exhaust the cursor. - { - // Note: Cursors are lazy. The `find` command is sent on the first call - // to `mongoc_cursor_next`. - const bson_t *got; - while (mongoc_cursor_next (cursor, &got)) - ; - } - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - } - - // Test a cursor with a string batchSize. - { - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{}"), tmp_bson ("{'batchSize': 'foo'}"), NULL); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - // Attempt to exhaust the cursor. - { - // Note: Cursors are lazy. The `find` command is sent on the first call - // to `mongoc_cursor_next`. - const bson_t *got; - while (mongoc_cursor_next (cursor, &got)) - ; - } - - // Expect an error from the server. - ASSERT (mongoc_cursor_error (cursor, &error)); - mongoc_cursor_destroy (cursor); - } - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -void -test_collection_find_with_opts_install (TestSuite *suite) -{ - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/dollar_or", test_dollar_or); - TestSuite_AddMockServerTest (suite, - "/Collection/find_with_opts/snapshot_dollar_or", - test_snapshot_dollar_or); - TestSuite_AddMockServerTest (suite, - "/Collection/find_with_opts/key_named_filter", - test_key_named_filter); - TestSuite_AddMockServerTest ( - suite, - "/Collection/find_with_opts/query/subdoc_named_filter", - test_op_query_subdoc_named_filter); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/newoption", test_newoption); - TestSuite_AddMockServerTest ( - suite, - "/Collection/find_with_opts/cmd/subdoc_named_filter", - test_find_cmd_subdoc_named_filter_with_option); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/orderby", test_sort); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/fields", test_fields); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/slice", test_slice); - TestSuite_AddMockServerTest (suite, - "/Collection/find_with_opts/modifiers/integer", - test_int_modifiers); - TestSuite_AddMockServerTest ( - suite, - "/Collection/find_with_opts/modifiers/index_spec", - test_index_spec_modifiers); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/comment", test_comment); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/modifiers/bool", test_snapshot); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/showdiskloc", test_diskloc); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/returnkey", test_returnkey); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/skip", test_skip); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/batch_size", test_batch_size); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/limit", test_limit); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/singlebatch", test_singlebatch); - TestSuite_AddMockServerTest ( - suite, - "/Collection/find_with_opts/singlebatch/no_limit", - test_singlebatch_no_limit); - TestSuite_AddMockServerTest ( - suite, - "/Collection/find_with_opts/unrecognized_dollar", - test_unrecognized_dollar_option); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/flags", test_query_flags); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/exhaust", test_exhaust); - TestSuite_AddMockServerTest (suite, - "/Collection/find_with_opts/await/getmore_cmd", - test_getmore_cmd_await); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/server_id", test_find_w_server_id); - TestSuite_AddMockServerTest (suite, - "/Collection/find_cmd_with_opts/server_id", - test_find_cmd_w_server_id); - TestSuite_AddMockServerTest (suite, - "/Collection/find_with_opts/server_id/sharded", - test_find_w_server_id_sharded); - TestSuite_AddMockServerTest ( - suite, - "/Collection/find_cmd_with_opts/server_id/sharded", - test_find_cmd_w_server_id_sharded); - TestSuite_AddLive (suite, - "/Collection/find_with_opts/server_id/option", - test_server_id_option); - TestSuite_AddLive (suite, "/Collection/find/batchSize", test_find_batchSize); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-collection-find.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-collection-find.c deleted file mode 100644 index 14b39512b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-collection-find.c +++ /dev/null @@ -1,1150 +0,0 @@ -#include -#include -#include - -#include "TestSuite.h" -#include "test-libmongoc.h" -#include "test-conveniences.h" -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" - - -typedef struct { - /* if do_live is true (the default), actually query the server using the - * appropriate wire protocol: either OP_QUERY or a "find" command */ - bool do_live; - int32_t max_wire_version; - const char *docs; - bson_t *docs_bson; - const char *query_input; - bson_t *query_bson; - const char *fields; - bson_t *fields_bson; - const char *expected_find_command; - int32_t n_return; - const char *expected_result; - bson_t *expected_result_bson; - uint32_t skip; - int32_t limit; - uint32_t batch_size; - mongoc_query_flags_t flags; - mongoc_read_prefs_t *read_prefs; - const char *filename; - int lineno; - const char *funcname; - uint32_t n_results; -} test_collection_find_t; - - -#define TEST_COLLECTION_FIND_INIT \ - { \ - true, INT32_MAX \ - } - - -static void -_insert_test_docs (mongoc_collection_t *collection, const bson_t *docs) -{ - bson_iter_t iter; - uint32_t len; - const uint8_t *data; - bson_t doc; - bool r; - bson_error_t error; - - bson_iter_init (&iter, docs); - while (bson_iter_next (&iter)) { - bson_iter_document (&iter, &len, &data); - BSON_ASSERT (bson_init_static (&doc, data, len)); - r = mongoc_collection_insert_one (collection, &doc, NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - } -} - - -static void -_check_cursor (mongoc_cursor_t *cursor, test_collection_find_t *test_data) -{ - const bson_t *doc; - bson_t actual_result = BSON_INITIALIZER; - char str[16]; - const char *key; - uint32_t i = 0; - bson_error_t error; - - while (mongoc_cursor_next (cursor, &doc)) { - bson_uint32_to_string (i, &key, str, sizeof str); - bson_append_document (&actual_result, key, -1, doc); - i++; - } - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - if (i != test_data->n_results) { - test_error ("expect %d results, got %d", test_data->n_results, i); - } - - ASSERT (match_json (&actual_result, - false /* is_command */, - test_data->filename, - test_data->lineno, - test_data->funcname, - test_data->expected_result)); - - bson_destroy (&actual_result); -} - - -static void -_test_collection_find_live (test_collection_find_t *test_data) - -{ - mongoc_client_t *client; - mongoc_database_t *database; - char *collection_name; - mongoc_collection_t *collection; - char *drop_cmd; - bool r; - bson_error_t error; - mongoc_cursor_t *cursor; - - client = test_framework_new_default_client (); - database = mongoc_client_get_database (client, "test"); - collection_name = gen_collection_name ("test"); - collection = mongoc_database_create_collection ( - database, - collection_name, - tmp_bson ("{'capped': true, 'size': 10000}"), - &error); - - ASSERT_OR_PRINT (collection, error); - - _insert_test_docs (collection, test_data->docs_bson); - - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_NONE, - test_data->skip, - test_data->limit, - test_data->batch_size, - test_data->query_bson, - test_data->fields_bson, - test_data->read_prefs); - - _check_cursor (cursor, test_data); - - drop_cmd = bson_strdup_printf ("{'drop': '%s'}", collection_name); - r = mongoc_client_command_simple ( - client, "test", tmp_bson (drop_cmd), NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - - bson_free (drop_cmd); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - bson_free (collection_name); - mongoc_client_destroy (client); -} - - -static request_t * -_check_find_command (mock_server_t *server, test_collection_find_t *test_data) -{ - return mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson (test_data->expected_find_command)); -} - - -static void -_reply_to_find_command (request_t *request, test_collection_find_t *test_data) -{ - const char *result_json; - char *reply_json; - - result_json = test_data->expected_result ? test_data->expected_result : "[]"; - - reply_json = bson_strdup_printf ("{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': %s}}", - result_json); - - reply_to_request_simple (request, reply_json); - - bson_free (reply_json); -} - - -/*-------------------------------------------------------------------------- - * - * _test_collection_find_command -- - * - * Start a mock server with @max_wire_version, connect a client, and - * execute @test_data->query. Check that the client cursor's results - * match @test_data->expected_result. - * - *-------------------------------------------------------------------------- - */ - -static void -_test_collection_find_command (test_collection_find_t *test_data) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_error_t error; - future_t *future; - request_t *request; - const bson_t *doc; - bool cursor_next_result; - bson_t actual_result = BSON_INITIALIZER; - char str[16]; - const char *key; - uint32_t i = 0; - - if (!TestSuite_CheckMockServerAllowed ()) { - bson_destroy (&actual_result); - return; - } - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_find (collection, - test_data->flags, - test_data->skip, - test_data->limit, - test_data->batch_size, - test_data->query_bson, - test_data->fields_bson, - test_data->read_prefs); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - future = future_cursor_next (cursor, &doc); - request = _check_find_command (server, test_data); - ASSERT (request); - _reply_to_find_command (request, test_data); - - cursor_next_result = future_get_bool (future); - /* did we expect at least one result? */ - ASSERT (cursor_next_result == (test_data->n_results > 0)); - BSON_ASSERT (!mongoc_cursor_error (cursor, NULL)); - - if (cursor_next_result) { - bson_append_document (&actual_result, "0", -1, doc); - i++; - - /* check remaining results */ - while (mongoc_cursor_next (cursor, &doc)) { - bson_uint32_to_string (i, &key, str, sizeof str); - bson_append_document (&actual_result, key, -1, doc); - i++; - } - - BSON_ASSERT (!mongoc_cursor_error (cursor, NULL)); - } - - if (i != test_data->n_results) { - test_error ("Expected %d results, got %d\n", test_data->n_results, i); - } - - ASSERT (match_json (&actual_result, - false /* is_command */, - test_data->filename, - test_data->lineno, - test_data->funcname, - test_data->expected_result)); - - bson_destroy (&actual_result); - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -_test_collection_find (test_collection_find_t *test_data) -{ - BSON_ASSERT (test_data->expected_find_command); - - test_data->docs_bson = tmp_bson (test_data->docs); - test_data->query_bson = tmp_bson (test_data->query_input); - test_data->fields_bson = - test_data->fields ? tmp_bson (test_data->fields) : NULL; - test_data->expected_result_bson = tmp_bson (test_data->expected_result); - test_data->n_results = bson_count_keys (test_data->expected_result_bson); - - if (test_data->do_live) { - int64_t max_version; - - test_framework_get_max_wire_version (&max_version); - if (test_data->max_wire_version >= max_version) { - _test_collection_find_live (test_data); - } - } - - _test_collection_find_command (test_data); -} - - -static void -test_dollar_query (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}, {'_id': 2}]"; - test_data.query_input = "{'$query': {'_id': 1}}"; - test_data.expected_find_command = - "{'$db': 'db', 'find': 'collection', 'filter': {'_id': 1}}"; - test_data.expected_result = "[{'_id': 1}]"; - _test_collection_find (&test_data); -} - - -static void -test_dollar_or (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - - test_data.docs = "[{'_id': 1}, {'_id': 2}, {'_id': 3}]"; - test_data.query_input = "{'$or': [{'_id': 1}, {'_id': 3}]}"; - test_data.expected_find_command = - "{'$db': 'db'," - " 'find': 'collection'," - " 'filter': {'$or': [{'_id': 1}, {'_id': 3}]}}"; - - test_data.expected_result = "[{'_id': 1}, {'_id': 3}]"; - _test_collection_find (&test_data); -} - - -static void -test_mixed_dollar_nondollar (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - - test_data.docs = "[{'a': 1}, {'a': 1, 'b': 2}, {'a': 2}]"; - test_data.query_input = "{'a': 1, '$or': [{'b': 1}, {'b': 2}]}"; - test_data.expected_find_command = - "{'$db': 'db'," - " 'find': 'collection'," - " 'filter': {'a': 1, '$or': [{'b': 1}, {'b': 2}]}}"; - - test_data.expected_result = "[{'a': 1, 'b': 2}]"; - _test_collection_find (&test_data); -} - - -/* test that we can query for a document by a key named "filter" */ -static void -test_key_named_filter (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1, 'filter': 1}, {'_id': 2, 'filter': 2}]"; - test_data.query_input = "{'filter': 2}"; - test_data.expected_find_command = - "{'$db': 'db', 'find': 'collection', 'filter': {'filter': 2}}"; - test_data.expected_result = "[{'_id': 2, 'filter': 2}]"; - _test_collection_find (&test_data); -} - - -/* test that we can query for a document by a key named "filter" using $query */ -static void -test_key_named_filter_with_dollar_query (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1, 'filter': 1}, {'_id': 2, 'filter': 2}]"; - test_data.query_input = "{'$query': {'filter': 2}}"; - test_data.expected_find_command = - "{'$db': 'db', 'find': 'collection', 'filter': {'filter': 2}}"; - test_data.expected_result = "[{'_id': 2, 'filter': 2}]"; - _test_collection_find (&test_data); -} - - -/* test 'filter': {'i': 2} */ -static void -test_subdoc_named_filter (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = - "[{'_id': 1, 'filter': {'i': 1}}, {'_id': 2, 'filter': {'i': 2}}]"; - test_data.query_input = "{'filter': {'i': 2}}"; - test_data.expected_find_command = - "{'$db': 'db', 'find': 'collection', 'filter': {'filter': {'i': 2}}}"; - test_data.expected_result = "[{'_id': 2, 'filter': {'i': 2}}]"; - - _test_collection_find (&test_data); -} - - -/* test '$query': {'filter': {'i': 2}} */ -static void -test_subdoc_named_filter_with_dollar_query (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = - "[{'_id': 1, 'filter': {'i': 1}}, {'_id': 2, 'filter': {'i': 2}}]"; - test_data.query_input = "{'$query': {'filter': {'i': 2}}}"; - test_data.expected_find_command = - "{'$db': 'db', 'find': 'collection', 'filter': {'filter': {'i': 2}}}"; - test_data.expected_result = "[{'_id': 2, 'filter': {'i': 2}}]"; - _test_collection_find (&test_data); -} - - -/* test future-compatibility with a new server's find command options */ -static void -test_newoption (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.query_input = "{'$query': {'_id': 1}, '$newOption': true}"; - test_data.expected_find_command = "{'$db': 'db'," - " 'find': 'collection'," - " 'filter': {'_id': 1}," - " 'newOption': true}"; - - /* won't work today */ - test_data.do_live = false; - - _test_collection_find (&test_data); -} - - -static void -test_orderby (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}, {'_id': 2}]"; - test_data.query_input = "{'$query': {}, '$orderby': {'_id': -1}}"; - test_data.expected_find_command = - "{'$db': 'db', 'find': 'collection', 'filter': {}, 'sort': {'_id': -1}}"; - test_data.expected_result = "[{'_id': 2}, {'_id': 1}]"; - _test_collection_find (&test_data); -} - - -static void -test_fields (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1, 'a': 1, 'b': 2}]"; - test_data.fields = "{'_id': 0, 'b': 1}"; - test_data.expected_find_command = "{'$db': 'db'," - " 'find': 'collection'," - " 'filter': {}," - " 'projection': {'_id': 0, 'b': 1}}"; - test_data.expected_result = "[{'b': 2}]"; - _test_collection_find (&test_data); -} - - -static void -_test_int_modifier (const char *mod) -{ - char *query; - char *find_command; - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - - test_data.expected_result = test_data.docs = "[{'_id': 1}]"; - - query = bson_strdup_printf ("{'$query': {}, '$%s': 9999}", mod); - - /* find command has same modifier, without the $-prefix */ - find_command = bson_strdup_printf ( - "{'find': 'collection', 'filter': {}, '%s': 9999}", mod); - - test_data.query_input = query; - test_data.expected_find_command = find_command; - _test_collection_find (&test_data); - bson_free (query); - bson_free (find_command); -} - - -static void -test_maxtimems (void) -{ - _test_int_modifier ("maxTimeMS"); -} - - -static void -test_comment (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}]"; - test_data.query_input = "{'$query': {}, '$comment': 'hi'}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'comment': 'hi'}"; - test_data.expected_result = "[{'_id': 1}]"; - _test_collection_find (&test_data); -} - - -static void -test_hint (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}]"; - test_data.query_input = "{'$query': {}, '$hint': { '_id': 1 }}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'hint': { '_id': 1 }}"; - test_data.expected_result = "[{'_id': 1}]"; - _test_collection_find (&test_data); -} - - -static void -test_max (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}]"; - /* MongoDB 4.2 requires that max/min also use hint */ - test_data.query_input = - "{'$query': {}, '$max': {'_id': 100}, '$hint': { '_id': 1 }}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, " - "'max': {'_id': 100}, 'hint': { '_id': 1 }}"; - test_data.expected_result = "[{'_id': 1}]"; - _test_collection_find (&test_data); -} - - -static void -test_min (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}]"; - /* MongoDB 4.2 requires that max/min also use hint */ - test_data.query_input = - "{'$query': {}, '$min': {'_id': 1}, '$hint': { '_id': 1 }}"; - test_data.expected_find_command = "{'find': 'collection', 'filter': {}, " - "'min': {'_id': 1}, 'hint': { '_id': 1 }}"; - test_data.expected_result = "[{'_id': 1}]"; - _test_collection_find (&test_data); -} - - -static void -test_snapshot (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - /* "snapshot" dropped in MongoDB 4.0, wire version 7 */ - test_data.max_wire_version = 6; - test_data.docs = "[{'_id': 1}]"; - test_data.query_input = "{'$query': {}, '$snapshot': true}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'snapshot': true}"; - test_data.expected_result = "[{'_id': 1}]"; - _test_collection_find (&test_data); -} - - -/* $showDiskLoc becomes showRecordId */ -static void -test_diskloc (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}]"; - test_data.query_input = "{'$query': {}, '$showDiskLoc': true}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'showRecordId': true}"; - test_data.expected_result = "[{'_id': 1}]"; - _test_collection_find (&test_data); -} - - -static void -test_returnkey (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}]"; - test_data.query_input = "{'$query': {}, '$returnKey': true}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'returnKey': true}"; - test_data.expected_result = "[{}]"; - _test_collection_find (&test_data); -} - - -static void -test_skip (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}, {'_id': 2}]"; - test_data.skip = 1; - test_data.query_input = "{'$query': {}, '$orderby': {'_id': 1}}"; - test_data.expected_find_command = "{'find': 'collection', 'filter': {}, " - "'sort': {'_id': 1}, 'skip': " - "{'$numberLong': '1'}}"; - test_data.expected_result = "[{'_id': 2}]"; - _test_collection_find (&test_data); -} - - -static void -test_batch_size (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}]"; - test_data.batch_size = 2; - test_data.n_return = 2; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {}, 'batchSize': {'$numberLong': '2'}}"; - test_data.expected_result = "[{'_id': 1}]"; - _test_collection_find (&test_data); -} - - -static void -test_limit (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}, {'_id': 2}, {'_id': 3}]"; - test_data.limit = 2; - test_data.query_input = "{'$query': {}, '$orderby': {'_id': 1}}"; - test_data.n_return = 2; - test_data.expected_find_command = "{'find': 'collection', 'filter': {}, " - "'sort': {'_id': 1}, 'limit': " - "{'$numberLong': '2'}}"; - test_data.expected_result = "[{'_id': 1}, {'_id': 2}]"; - _test_collection_find (&test_data); -} - - -static void -test_negative_limit (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - test_data.docs = "[{'_id': 1}, {'_id': 2}, {'_id': 3}]"; - test_data.limit = -2; - test_data.query_input = "{'$query': {}, '$orderby': {'_id': 1}}"; - test_data.n_return = -2; - test_data.expected_find_command = "{'find': 'collection', 'filter': {}, " - "'sort': {'_id': 1}, 'singleBatch': true, " - "'limit': {'$numberLong': '2'}}"; - test_data.expected_result = "[{'_id': 1}, {'_id': 2}]"; - _test_collection_find (&test_data); -} - - -static void -test_unrecognized_dollar_option (void) -{ - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - - test_data.query_input = "{'$query': {'a': 1}, '$dumb': 1}"; - test_data.expected_find_command = - "{'find': 'collection', 'filter': {'a': 1}, 'dumb': 1}"; - - test_data.do_live = false; - _test_collection_find (&test_data); -} - - -static void -test_query_flags (void) -{ - int i; - char *find_cmd; - test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT; - - typedef struct { - mongoc_query_flags_t flag; - const char *json_fragment; - } flag_and_name_t; - - /* secondaryOk is not supported as an option, exhaust is tested separately */ - flag_and_name_t flags_and_frags[] = { - {MONGOC_QUERY_TAILABLE_CURSOR, "'tailable': true"}, - {MONGOC_QUERY_OPLOG_REPLAY, "'oplogReplay': true"}, - {MONGOC_QUERY_NO_CURSOR_TIMEOUT, "'noCursorTimeout': true"}, - {MONGOC_QUERY_PARTIAL, "'allowPartialResults': true"}, - {MONGOC_QUERY_TAILABLE_CURSOR | MONGOC_QUERY_AWAIT_DATA, - "'tailable': true, 'awaitData': true"}, - }; - - test_data.expected_result = test_data.docs = "[{'_id': 1}]"; - - for (i = 0; i < (sizeof flags_and_frags) / (sizeof (flag_and_name_t)); i++) { - find_cmd = bson_strdup_printf ("{'find': 'collection', 'filter': {}, %s}", - flags_and_frags[i].json_fragment); - - test_data.flags = flags_and_frags[i].flag; - test_data.expected_find_command = find_cmd; - - _test_collection_find (&test_data); - - bson_free (find_cmd); - } -} - - -static void -test_exhaust (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - request_t *request; - future_t *future; - const bson_t *doc; - bson_error_t error; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_EXHAUST, 0, 0, 0, tmp_bson (NULL), NULL, NULL); - - future = future_cursor_next (cursor, &doc); - - /* Find, getMore and killCursors commands spec: "The find command does not - * support the exhaust flag from OP_QUERY. Drivers that support exhaust MUST - * fallback to existing OP_QUERY wire protocol messages." - */ - request = mock_server_receives_request (server); - reply_to_find_request (request, - MONGOC_QUERY_SECONDARY_OK | MONGOC_QUERY_EXHAUST, - 0, - 0, - "db.collection", - "{}", - false /* is_command */); - - ASSERT (future_get_bool (future)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_getmore_batch_size (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - const bson_t *doc; - uint32_t batch_sizes[] = {0, 1, 2}; - size_t i; - char *batch_size_json; - bson_error_t error; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - for (i = 0; i < sizeof (batch_sizes) / sizeof (uint32_t); i++) { - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_NONE, - 0, - 0, - batch_sizes[i], - tmp_bson ("{}"), - NULL, - NULL); - - future = future_cursor_next (cursor, &doc); - - if (batch_sizes[i]) { - batch_size_json = - bson_strdup_printf ("{'$numberLong': '%u'}", batch_sizes[i]); - } else { - batch_size_json = bson_strdup ("{'$exists': false}"); - } - - request = mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'find': 'collection'," - " 'filter': {}," - " 'batchSize': %s}", - batch_size_json)); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': []}}"); - - /* no result */ - ASSERT (!future_get_bool (future)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - future_destroy (future); - request_destroy (request); - bson_free (batch_size_json); - mongoc_cursor_destroy (cursor); - } - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_getmore_invalid_reply (void *ctx) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - const bson_t *doc; - bson_error_t error; - - BSON_UNUSED (ctx); - - if (!TestSuite_CheckMockServerAllowed ()) { - return; - } - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, tmp_bson ("{}"), NULL, NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'find': 'collection', 'filter': {}}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '123'}," - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - - ASSERT (future_get_bool (future)); - - future_destroy (future); - request_destroy (request); - - future = future_cursor_next (cursor, &doc); - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '123'}," - " 'collection': 'collection'}")); - - /* missing "cursor" */ - reply_to_request_with_ok_and_destroy (request); - - ASSERT (!future_get_bool (future)); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_PROTOCOL); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_PROTOCOL_INVALID_REPLY); - ASSERT_CONTAINS (error.message, "getMore"); - - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_getmore_await (void) -{ - typedef struct { - mongoc_query_flags_t flags; - bool expect_await; - } await_test_t; - - await_test_t await_tests[] = { - {MONGOC_QUERY_NONE, false}, - {MONGOC_QUERY_TAILABLE_CURSOR, false}, - {MONGOC_QUERY_AWAIT_DATA, false}, - {MONGOC_QUERY_TAILABLE_CURSOR | MONGOC_QUERY_AWAIT_DATA, true}, - }; - - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - const bson_t *doc; - size_t i; - char *max_time_json; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - for (i = 3; i < sizeof (await_tests) / sizeof (await_test_t); i++) { - cursor = mongoc_collection_find (collection, - await_tests[i].flags, - 0, - 0, - 0, - tmp_bson ("{}"), - NULL, - NULL); - - ASSERT (mongoc_cursor_more (cursor)); - - ASSERT_CMPINT (0, ==, mongoc_cursor_get_max_await_time_ms (cursor)); - mongoc_cursor_set_max_await_time_ms (cursor, 123); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'find': 'collection'," - " 'maxTimeMS': {'$exists': false}," - " 'maxAwaitTimeMS': {'$exists': false}}")); - - /* reply with cursor id 1 */ - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 1," - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - - /* no result or error */ - ASSERT (future_get_bool (future)); - ASSERT (mongoc_cursor_more (cursor)); - - future_destroy (future); - request_destroy (request); - - future = future_cursor_next (cursor, &doc); - - if (await_tests[i].expect_await) { - max_time_json = "123"; - } else { - max_time_json = "{'$exists': false}"; - } - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '1'}," - " 'collection': 'collection'," - " 'maxAwaitTimeMS': {'$exists': false}," - " 'maxTimeMS': {'$numberLong': '%s'}}", - max_time_json)); - - BSON_ASSERT (request); - /* reply with cursor id 0 */ - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'nextBatch': []}}"); - - /* no result or error */ - ASSERT (!future_get_bool (future)); - ASSERT (!mongoc_cursor_error (cursor, NULL)); - ASSERT (!mongoc_cursor_more (cursor)); - ASSERT (!doc); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - } - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -_test_tailable_timeout (bool pooled) -{ - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_database_t *database; - char *collection_name; - mongoc_collection_t *collection; - bool r; - bson_error_t error; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_t reply; - - capture_logs (true); - - if (pooled) { - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - } - - database = mongoc_client_get_database (client, "test"); - collection_name = gen_collection_name ("test"); - - collection = mongoc_database_get_collection (database, collection_name); - mongoc_collection_drop (collection, NULL); - mongoc_collection_destroy (collection); - - collection = mongoc_database_create_collection ( - database, - collection_name, - tmp_bson ("{'capped': true, 'size': 10000}"), - &error); - - ASSERT_OR_PRINT (collection, error); - - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{}"), NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - - client->cluster.sockettimeoutms = 100; - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_TAILABLE_CURSOR | - MONGOC_QUERY_AWAIT_DATA, - 0, - 0, - 0, - tmp_bson ("{'a': 1}"), - NULL, - NULL); - - ASSERT (!mongoc_cursor_next (cursor, &doc)); - - client->cluster.sockettimeoutms = 30 * 1000 * 1000; - r = mongoc_client_command_simple ( - client, "test", tmp_bson ("{'buildinfo': 1}"), NULL, &reply, &error); - - ASSERT_OR_PRINT (r, error); - ASSERT_HAS_FIELD (&reply, "version"); - - bson_destroy (&reply); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - bson_free (collection_name); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } -} - - -static void -test_tailable_timeout_single (void) -{ - _test_tailable_timeout (false); -} - - -#ifndef MONGOC_ENABLE_SSL_SECURE_TRANSPORT -#ifndef MONGOC_ENABLE_SSL_SECURE_CHANNEL -static void -test_tailable_timeout_pooled (void) -{ - _test_tailable_timeout (true); -} -#endif -#endif - - -void -test_collection_find_install (TestSuite *suite) -{ - TestSuite_AddLive ( - suite, "/Collection/find/dollar_query", test_dollar_query); - TestSuite_AddLive (suite, "/Collection/find/dollar_or", test_dollar_or); - TestSuite_AddLive (suite, - "/Collection/find/mixed_dollar_nondollar", - test_mixed_dollar_nondollar); - TestSuite_AddLive ( - suite, "/Collection/find/key_named_filter", test_key_named_filter); - TestSuite_AddLive (suite, - "/Collection/find/key_named_filter/$query", - test_key_named_filter_with_dollar_query); - TestSuite_AddLive ( - suite, "/Collection/find/subdoc_named_filter", test_subdoc_named_filter); - TestSuite_AddLive (suite, - "/Collection/find/subdoc_named_filter/$query", - test_subdoc_named_filter_with_dollar_query); - TestSuite_AddLive (suite, "/Collection/find/newoption", test_newoption); - TestSuite_AddLive (suite, "/Collection/find/orderby", test_orderby); - TestSuite_AddLive (suite, "/Collection/find/fields", test_fields); - TestSuite_AddLive ( - suite, "/Collection/find/modifiers/maxtimems", test_maxtimems); - TestSuite_AddLive (suite, "/Collection/find/comment", test_comment); - TestSuite_AddLive (suite, "/Collection/find/hint", test_hint); - TestSuite_AddLive (suite, "/Collection/find/max", test_max); - TestSuite_AddLive (suite, "/Collection/find/min", test_min); - TestSuite_AddLive (suite, "/Collection/find/modifiers/bool", test_snapshot); - TestSuite_AddLive (suite, "/Collection/find/showdiskloc", test_diskloc); - TestSuite_AddLive (suite, "/Collection/find/returnkey", test_returnkey); - TestSuite_AddLive (suite, "/Collection/find/skip", test_skip); - TestSuite_AddLive (suite, "/Collection/find/batch_size", test_batch_size); - TestSuite_AddLive (suite, "/Collection/find/limit", test_limit); - TestSuite_AddLive ( - suite, "/Collection/find/negative_limit", test_negative_limit); - TestSuite_Add ( - suite, "/Collection/find/unrecognized", test_unrecognized_dollar_option); - TestSuite_AddLive (suite, "/Collection/find/flags", test_query_flags); - TestSuite_AddMockServerTest ( - suite, "/Collection/find/exhaust", test_exhaust); - TestSuite_AddMockServerTest ( - suite, "/Collection/getmore/batch_size", test_getmore_batch_size); - TestSuite_AddFull (suite, - "/Collection/getmore/invalid_reply", - test_getmore_invalid_reply, - NULL, - NULL, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest ( - suite, "/Collection/getmore/await", test_getmore_await); - TestSuite_AddLive (suite, - "/Collection/tailable/timeout/single", - test_tailable_timeout_single); -#ifndef MONGOC_ENABLE_SSL_SECURE_TRANSPORT -#ifndef MONGOC_ENABLE_SSL_SECURE_CHANNEL - TestSuite_AddLive (suite, - "/Collection/tailable/timeout/pooled", - test_tailable_timeout_pooled); -#endif -#endif -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-collection.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-collection.c deleted file mode 100644 index df186cc00..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-collection.c +++ /dev/null @@ -1,6687 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "TestSuite.h" - -#include "test-libmongoc.h" -#include "test-conveniences.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" -#include "mock_server/mock-rs.h" - - -BEGIN_IGNORE_DEPRECATIONS - - -static void -test_aggregate_w_write_concern (void *ctx) -{ - mongoc_cursor_t *cursor; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_write_concern_t *good_wc; - mongoc_write_concern_t *bad_wc; - bson_t *pipeline; - bson_t *opts = NULL; - char *json; - const bson_t *doc; - bson_error_t error; - - BSON_UNUSED (ctx); - - /* set up */ - good_wc = mongoc_write_concern_new (); - bad_wc = mongoc_write_concern_new (); - opts = bson_new (); - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - ASSERT (mongoc_client_set_error_api (client, 2)); - - collection = mongoc_client_get_collection (client, "test", "test"); - - /* pipeline that writes to collection */ - json = bson_strdup_printf ("[{'$out': '%s'}]", collection->collection); - pipeline = tmp_bson (json); - - /* collection aggregate with valid writeConcern: no error */ - mongoc_write_concern_set_w (good_wc, 1); - bson_reinit (opts); - mongoc_write_concern_append (good_wc, opts); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, pipeline, opts, NULL); - ASSERT (cursor); - mongoc_cursor_next (cursor, &doc); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - - /* writeConcern that will not pass mongoc_write_concern_is_valid */ - bad_wc->wtimeout = -10; - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, pipeline, opts, NULL); - ASSERT (cursor); - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT_ERROR_CONTAINS (cursor->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid writeConcern"); - bad_wc->wtimeout = 0; - - mongoc_write_concern_destroy (good_wc); - mongoc_write_concern_destroy (bad_wc); - mongoc_collection_destroy (collection); - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); - bson_destroy (opts); - bson_free (json); -} - -static void -test_aggregate_inherit_collection (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - mongoc_collection_t *collection; - const bson_t *doc; - request_t *request; - future_t *future; - bson_t *pipeline; - bson_t opts = BSON_INITIALIZER; - mongoc_read_concern_t *rc2; - mongoc_read_concern_t *rc; - mongoc_write_concern_t *wc2; - mongoc_write_concern_t *wc; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - - pipeline = BCON_NEW ( - "pipeline", "[", "{", "$out", BCON_UTF8 ("collection2"), "}", "]"); - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_MAJORITY); - mongoc_read_concern_append (rc, &opts); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 2); - mongoc_write_concern_append (wc, &opts); - - /* Uses the opts */ - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_SECONDARY_OK, pipeline, &opts, NULL); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'collection'," - " 'pipeline': [{'$out': 'collection2'}]," - " 'cursor': {}," - " 'readConcern': {'level': 'majority'}," - " 'writeConcern': {'w': 2}}")); - - reply_to_request_with_ok_and_destroy (request); - - ASSERT (!future_get_bool (future)); - - /* Set collection level defaults */ - wc2 = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc2, 3); - mongoc_collection_set_write_concern (collection, wc2); - rc2 = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc2, MONGOC_READ_CONCERN_LEVEL_LOCAL); - mongoc_collection_set_read_concern (collection, rc2); - - future_destroy (future); - mongoc_cursor_destroy (cursor); - - /* Inherits from collection */ - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_SECONDARY_OK, pipeline, NULL, NULL); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson (" {'$db': 'db'," - " 'aggregate': 'collection'," - " 'pipeline': [{'$out': 'collection2'}]," - " 'cursor': {}," - " 'readConcern': {'level': 'local'}," - " 'writeConcern': {'w': 3}}")); - - reply_to_request_with_ok_and_destroy (request); - - ASSERT (!future_get_bool (future)); - - future_destroy (future); - mongoc_cursor_destroy (cursor); - - /* Uses the opts, not default collection level */ - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_SECONDARY_OK, pipeline, &opts, NULL); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'collection'," - " 'pipeline': [{'$out': 'collection2'}]," - " 'cursor': {}," - " 'readConcern': {'level': 'majority'}," - " 'writeConcern': {'w': 2}}")); - - reply_to_request_with_ok_and_destroy (request); - - ASSERT (!future_get_bool (future)); - - future_destroy (future); - mongoc_cursor_destroy (cursor); - - /* Doesn't inherit write concern when not using $out */ - bson_destroy (pipeline); - pipeline = BCON_NEW ( - "pipeline", "[", "{", "$in", BCON_UTF8 ("collection2"), "}", "]"); - - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_SECONDARY_OK, pipeline, NULL, NULL); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson (" {'$db': 'db'," - " 'aggregate': 'collection'," - " 'pipeline': [{'$in': 'collection2'}]," - " 'cursor': {}," - " 'readConcern': {'level': 'local'}," - " 'writeConcern': {'$exists': false}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT (!future_get_bool (future)); - - future_destroy (future); - mongoc_cursor_destroy (cursor); - - bson_destroy (&opts); - bson_destroy (pipeline); - mongoc_read_concern_destroy (rc); - mongoc_read_concern_destroy (rc2); - mongoc_write_concern_destroy (wc); - mongoc_write_concern_destroy (wc2); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -_batch_size_test (bson_t *pipeline, - bson_t *batch_size, - bool use_batch_size, - int size) -{ - mock_server_t *mock_server; - mongoc_client_t *client; - mongoc_collection_t *coll; - future_t *future; - request_t *request; - mongoc_cursor_t *cursor; - const bson_t *doc; - - mock_server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_run (mock_server); - - client = test_framework_client_new_from_uri ( - mock_server_get_uri (mock_server), NULL); - coll = mongoc_client_get_collection (client, "db", "coll"); - - cursor = mongoc_collection_aggregate ( - coll, MONGOC_QUERY_NONE, pipeline, batch_size, NULL); - future = future_cursor_next (cursor, &doc); - - if (use_batch_size) { - request = mock_server_receives_msg ( - mock_server, - 0, - tmp_bson ("{ 'cursor' : { 'batchSize' : %d } }", size)); - } else { - request = mock_server_receives_msg ( - mock_server, - 0, - tmp_bson ("{ 'cursor' : { 'batchSize' : { '$exists': false } } }")); - } - - reply_to_request_simple (request, "{'ok': 1}"); - - request_destroy (request); - future_wait (future); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mock_server_destroy (mock_server); -} - -static void -test_aggregate_with_batch_size (void) -{ - bson_t *pipeline_dollar_out; - bson_t *pipeline_dollar_merge; - bson_t *pipeline_no_terminal_key; - bson_t *batch_size_zero; - bson_t *batch_size_one; - - pipeline_dollar_out = tmp_bson ("{ 'pipeline': [ { '$out' : 'coll2' } ] }"); - pipeline_dollar_merge = - tmp_bson ("{ 'pipeline': [ { '$merge' : 'coll2' } ] }"); - pipeline_no_terminal_key = tmp_bson ("{ 'pipeline': [ ] }"); - - batch_size_one = tmp_bson (" { 'batchSize': 1 } "); - batch_size_zero = tmp_bson (" { 'batchSize': 0 } "); - - /* Case 1: - Test that with a terminal key and batchSize > 0, - we use the batchSize */ - _batch_size_test (pipeline_dollar_out, batch_size_one, true, 1); - _batch_size_test (pipeline_dollar_merge, batch_size_one, true, 1); - - /* Case 2: - Test that with terminal key and batchSize == 0, - we don't use the batchSize */ - _batch_size_test (pipeline_dollar_out, batch_size_zero, false, 0); - _batch_size_test (pipeline_dollar_merge, batch_size_zero, false, 0); - - /* Case 3: - Test that without a terminal key and batchSize > 0, - we use the batchSize */ - _batch_size_test (pipeline_no_terminal_key, batch_size_one, true, 1); - - /* Case 4: - Test that without $out and batchSize == 0, - we use the batchSize */ - _batch_size_test (pipeline_no_terminal_key, batch_size_zero, true, 0); -} - -static void -test_read_prefs_is_valid (void *ctx) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error; - bson_t *pipeline; - mongoc_read_prefs_t *read_prefs; - bson_t reply; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_aggregate"); - ASSERT (collection); - - pipeline = BCON_NEW ("pipeline", - "[", - "{", - "$match", - "{", - "hello", - BCON_UTF8 ("world"), - "}", - "}", - "]"); - - /* if read prefs is not valid */ - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - ASSERT (read_prefs); - mongoc_read_prefs_set_tags (read_prefs, - tmp_bson ("[{'does-not-exist': 'x'}]")); - - /* mongoc_collection_aggregate */ - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, pipeline, NULL, read_prefs); - ASSERT (cursor); - ASSERT (mongoc_cursor_error (cursor, &error)); - mongoc_cursor_destroy (cursor); - - /* mongoc_collection_command */ - cursor = mongoc_collection_command (collection, - MONGOC_QUERY_NONE, - 0, - 0, - 0, - tmp_bson ("{}"), - NULL, - read_prefs); - ASSERT (cursor); - ASSERT (mongoc_cursor_error (cursor, &error)); - mongoc_cursor_destroy (cursor); - - /* mongoc_collection_command_simple */ - ASSERT (!mongoc_collection_command_simple ( - collection, tmp_bson ("{'ping': 1}"), read_prefs, &reply, &error)); - bson_destroy (&reply); - - /* mongoc_collection_count_with_opts */ - ASSERT (mongoc_collection_count_with_opts (collection, - MONGOC_QUERY_NONE, - tmp_bson ("{}"), - 0, - 0, - NULL, - read_prefs, - &error) == -1); - - /* mongoc_collection_find */ - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_NONE, - 0, - 0, - 0, - tmp_bson ("{}"), - NULL, - read_prefs); - - ASSERT (cursor); - ASSERT (mongoc_cursor_error (cursor, &error)); - mongoc_cursor_destroy (cursor); - - /* mongoc_collection_find_with_opts */ - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{}"), NULL, read_prefs); - - ASSERT (cursor); - ASSERT (mongoc_cursor_error (cursor, &error)); - mongoc_cursor_destroy (cursor); - - /* if read prefs is valid */ - mongoc_read_prefs_destroy (read_prefs); - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - ASSERT (read_prefs); - - /* mongoc_collection_aggregate */ - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, pipeline, NULL, read_prefs); - ASSERT (cursor); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - - /* mongoc_collection_command */ - cursor = mongoc_collection_command (collection, - MONGOC_QUERY_NONE, - 0, - 0, - 0, - tmp_bson ("{}"), - NULL, - read_prefs); - ASSERT (cursor); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - - /* mongoc_collection_command_simple */ - ASSERT_OR_PRINT ( - mongoc_collection_command_simple ( - collection, tmp_bson ("{'ping': 1}"), read_prefs, &reply, &error), - error); - bson_destroy (&reply); - /* mongoc_collection_count_with_opts */ - ASSERT_OR_PRINT (mongoc_collection_count_with_opts (collection, - MONGOC_QUERY_NONE, - tmp_bson ("{}"), - 0, - 0, - NULL, - read_prefs, - &error) != -1, - error); - - /* mongoc_collection_find */ - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_NONE, - 0, - 0, - 0, - tmp_bson ("{}"), - NULL, - read_prefs); - - ASSERT (cursor); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - - /* mongoc_collection_find_with_opts */ - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{}"), NULL, read_prefs); - - ASSERT (cursor); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - - mongoc_read_prefs_destroy (read_prefs); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); - bson_destroy (pipeline); -} - -static void -test_copy (void) -{ - mongoc_database_t *database; - mongoc_collection_t *collection; - mongoc_collection_t *copy; - mongoc_client_t *client; - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_insert"); - ASSERT (collection); - - copy = mongoc_collection_copy (collection); - ASSERT (copy); - ASSERT (copy->client == collection->client); - ASSERT (strcmp (copy->ns, collection->ns) == 0); - - mongoc_collection_destroy (copy); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - - -static void -test_insert (void) -{ - mongoc_database_t *database; - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_context_t *context; - bson_error_t error; - bool r; - bson_oid_t oid; - unsigned i; - bson_t b; - - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_insert"); - ASSERT (collection); - - /* don't care if ns not found. */ - (void) mongoc_collection_drop (collection, &error); - - context = bson_context_new (BSON_CONTEXT_NONE); - ASSERT (context); - - for (i = 0; i < 10; i++) { - bson_init (&b); - bson_oid_init (&oid, context); - bson_append_oid (&b, "_id", 3, &oid); - bson_append_utf8 (&b, "hello", 5, "/world", 6); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, &b, NULL, NULL, &error), - error); - - bson_destroy (&b); - } - - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{'': 1}"), NULL, NULL, &error); - ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "invalid document"); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - bson_context_destroy (context); - mongoc_client_destroy (client); -} - - -static void -test_insert_null (void) -{ - mongoc_collection_t *collection; - mongoc_bulk_operation_t *bulk; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error; - bson_t reply; - const bson_t *out; - bool ret; - bson_t doc; - bson_t filter = BSON_INITIALIZER; - bson_iter_t iter; - uint32_t len; - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = - mongoc_client_get_collection (client, "test", "test_null_insert"); - ASSERT (collection); - - (void) mongoc_collection_drop (collection, &error); - - bson_init (&doc); - bson_append_utf8 (&doc, "hello", 5, "wor\0ld", 6); - ret = mongoc_collection_insert_one (collection, &doc, NULL, NULL, &error); - ASSERT_OR_PRINT (ret, error); - - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - mongoc_bulk_operation_insert (bulk, &doc); - ret = mongoc_bulk_operation_execute (bulk, &reply, &error); - ASSERT_OR_PRINT (ret, error); - ASSERT_MATCH (&reply, - "{'nInserted': 1," - " 'nMatched': 0," - " 'nModified': 0," - " 'nRemoved': 0," - " 'nUpserted': 0," - " 'writeErrors': []}"); - bson_destroy (&doc); - bson_destroy (&reply); - - cursor = mongoc_collection_find_with_opts (collection, &filter, NULL, NULL); - ASSERT (mongoc_cursor_next (cursor, &out)); - ASSERT (bson_iter_init_find (&iter, out, "hello")); - ASSERT (!memcmp (bson_iter_utf8 (&iter, &len), "wor\0ld", 6)); - ASSERT_CMPINT (len, ==, 6); - - ASSERT (mongoc_cursor_next (cursor, &out)); - ASSERT (bson_iter_init_find (&iter, out, "hello")); - ASSERT (!memcmp (bson_iter_utf8 (&iter, &len), "wor\0ld", 6)); - ASSERT_CMPINT (len, ==, 6); - - mongoc_cursor_destroy (cursor); - mongoc_bulk_operation_destroy (bulk); - - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - mongoc_bulk_operation_remove_one (bulk, &doc); - ret = mongoc_bulk_operation_update_one_with_opts ( - bulk, &doc, tmp_bson ("{'$set': {'x': 1}}"), NULL, &error); - ASSERT_OR_PRINT (ret, error); - ret = mongoc_bulk_operation_execute (bulk, &reply, &error); - ASSERT_OR_PRINT (ret, error); - - ASSERT_MATCH (&reply, - "{'nInserted': 0," - " 'nMatched': 1," - " 'nModified': 1," - " 'nRemoved': 1," - " 'nUpserted': 0," - " 'writeErrors': []}"); - - bson_destroy (&filter); - bson_destroy (&reply); - mongoc_bulk_operation_destroy (bulk); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_insert_oversize (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t doc = BSON_INITIALIZER; - bool r; - bson_error_t error; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_insert_oversize"); - - /* two huge strings make the doc too large */ - BSON_ASSERT (bson_append_utf8 ( - &doc, "x", 1, huge_string (client), (int) huge_string_length (client))); - - BSON_ASSERT (bson_append_utf8 ( - &doc, "y", 1, huge_string (client), (int) huge_string_length (client))); - - - r = mongoc_collection_insert_one (collection, &doc, NULL, NULL, &error); - ASSERT (!r); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_BSON, MONGOC_ERROR_BSON_INVALID, "too large"); - - bson_destroy (&doc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_insert_many (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - bson_context_t *context; - bson_error_t error; - bool r; - bson_oid_t oid; - unsigned i; - bson_t q; - bson_t b[10]; - bson_t *bptr[10]; - bson_t reply; - int64_t count; - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_insert_many"); - ASSERT (collection); - - (void) mongoc_collection_drop (collection, &error); - - context = bson_context_new (BSON_CONTEXT_NONE); - ASSERT (context); - - bson_init (&q); - bson_append_int32 (&q, "n", -1, 0); - - for (i = 0; i < 10; i++) { - bson_init (&b[i]); - bson_oid_init (&oid, context); - bson_append_oid (&b[i], "_id", -1, &oid); - bson_append_int32 (&b[i], "n", -1, i % 2); - bptr[i] = &b[i]; - } - - ASSERT_OR_PRINT ( - mongoc_collection_insert_many ( - collection, (const bson_t **) bptr, 10, NULL, &reply, &error), - error); - - ASSERT_CMPINT32 (bson_lookup_int32 (&reply, "insertedCount"), ==, 10); - bson_destroy (&reply); - count = mongoc_collection_count_documents ( - collection, &q, NULL, NULL, NULL, &error); - ASSERT (count == 5); - - for (i = 8; i < 10; i++) { - bson_destroy (&b[i]); - bson_init (&b[i]); - bson_oid_init (&oid, context); - bson_append_oid (&b[i], "_id", -1, &oid); - bson_append_int32 (&b[i], "n", -1, i % 2); - bptr[i] = &b[i]; - } - - r = mongoc_collection_insert_many ( - collection, (const bson_t **) bptr, 10, NULL, &reply, &error); - - ASSERT (!r); - ASSERT (error.code == 11000); - ASSERT_CMPINT32 (bson_lookup_int32 (&reply, "insertedCount"), ==, 0); - bson_destroy (&reply); - - count = mongoc_collection_count_documents ( - collection, &q, NULL, NULL, NULL, &error); - ASSERT (count == 5); - - r = mongoc_collection_insert_many (collection, - (const bson_t **) bptr, - 10, - tmp_bson ("{'ordered': false}"), - &reply, - &error); - ASSERT (!r); - ASSERT (error.code == 11000); - ASSERT_CMPINT32 (bson_lookup_int32 (&reply, "insertedCount"), ==, 2); - bson_destroy (&reply); - - count = mongoc_collection_count_documents ( - collection, &q, NULL, NULL, NULL, &error); - ASSERT (count == 6); - - /* test validate */ - for (i = 0; i < 10; i++) { - bson_destroy (&b[i]); - bson_init (&b[i]); - BSON_APPEND_INT32 (&b[i], "" /* empty key */, i); - bptr[i] = &b[i]; - } - r = mongoc_collection_insert_many (collection, - (const bson_t **) bptr, - 10, - tmp_bson ("{'ordered': false}"), - NULL, - &error); - ASSERT (!r); - ASSERT (error.domain == MONGOC_ERROR_COMMAND); - ASSERT (error.code == MONGOC_ERROR_COMMAND_INVALID_ARG); - - for (i = 0; i < 10; i++) { - bson_destroy (&b[i]); - bson_init (&b[i]); - BSON_APPEND_INT32 (&b[i], "" /* empty key */, i); - bptr[i] = &b[i]; - } - - r = mongoc_collection_insert_many ( - collection, (const bson_t **) bptr, 10, NULL, NULL, &error); - ASSERT (!r); - ASSERT (error.domain == MONGOC_ERROR_COMMAND); - ASSERT (error.code == MONGOC_ERROR_COMMAND_INVALID_ARG); - - bson_destroy (&q); - for (i = 0; i < 10; i++) { - bson_destroy (&b[i]); - } - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - bson_context_destroy (context); - mongoc_client_destroy (client); -} - - -static void -test_insert_bulk_empty (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - bson_error_t error; - bson_t *bptr = NULL; - - client = test_framework_new_default_client (); - database = get_test_database (client); - collection = get_test_collection (client, "test_insert_bulk_empty"); - - BEGIN_IGNORE_DEPRECATIONS; - ASSERT (!mongoc_collection_insert_bulk (collection, - MONGOC_INSERT_NONE, - (const bson_t **) &bptr, - 0, - NULL, - &error)); - END_IGNORE_DEPRECATIONS; - - ASSERT_CMPINT (MONGOC_ERROR_COLLECTION, ==, error.domain); - ASSERT_CMPINT (MONGOC_ERROR_COLLECTION_INSERT_FAILED, ==, error.code); - ASSERT_CONTAINS (error.message, "empty insert"); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - - -char * -make_string (size_t len) -{ - char *s = (char *) bson_malloc (len); - - BSON_ASSERT (len > 0); - memset (s, 'a', len - 1); - s[len - 1] = '\0'; - - return s; -} - - -bson_t * -make_document (size_t bytes) -{ - bson_t *bson; - bson_oid_t oid; - char *s; - size_t string_len; - - bson_oid_init (&oid, NULL); - bson = bson_new (); - BSON_APPEND_OID (bson, "_id", &oid); - - /* make the document exactly n bytes by appending a string. a string has - * 7 bytes overhead (1 for type code, 2 for key, 4 for length prefix), so - * make the string (n_bytes - current_length - 7) bytes long. */ - ASSERT_CMPUINT ((unsigned int) bytes, >=, bson->len + 7); - string_len = bytes - bson->len - 7; - s = make_string (string_len); - BSON_APPEND_UTF8 (bson, "s", s); - bson_free (s); - ASSERT_CMPUINT ((unsigned int) bytes, ==, bson->len); - - return bson; -} - - -void -make_bulk_insert (bson_t **bsons, int n, size_t bytes) -{ - int i; - - for (i = 0; i < n; i++) { - bsons[i] = make_document (bytes); - } -} - - -static void -destroy_all (bson_t **ptr, int n) -{ - int i; - - for (i = 0; i < n; i++) { - bson_destroy (ptr[i]); - } -} - - -/* CDRIVER-845: "insert" command must have array keys "0", "1", "2", ... */ -static void -test_insert_command_keys (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_bulk_operation_t *bulk; - uint32_t i; - bson_t *doc; - bson_t reply; - bson_error_t error; - future_t *future; - request_t *request; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - - for (i = 0; i < 3; i++) { - doc = BCON_NEW ("_id", BCON_INT32 (i)); - mongoc_bulk_operation_insert (bulk, doc); - bson_destroy (doc); - } - - future = future_bulk_operation_execute (bulk, &reply, &error); - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test', 'insert': 'test'}"), - tmp_bson ("{'_id': 0}"), - tmp_bson ("{'_id': 1}"), - tmp_bson ("{'_id': 2}")); - - reply_to_request_with_ok_and_destroy (request); - - ASSERT_OR_PRINT (future_get_uint32_t (future), error); - - bson_destroy (&reply); - future_destroy (future); - mongoc_bulk_operation_destroy (bulk); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_save (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - bson_context_t *context; - bson_error_t error; - bson_oid_t oid; - unsigned i; - bson_t b; - bool r; - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_save"); - ASSERT (collection); - - /* don't care if ns not found. */ - (void) mongoc_collection_drop (collection, &error); - - context = bson_context_new (BSON_CONTEXT_NONE); - ASSERT (context); - - BEGIN_IGNORE_DEPRECATIONS; - - for (i = 0; i < 10; i++) { - bson_init (&b); - bson_oid_init (&oid, context); - bson_append_oid (&b, "_id", 3, &oid); - bson_append_utf8 (&b, "hello", 5, "/world", 5); - ASSERT_OR_PRINT (mongoc_collection_save (collection, &b, NULL, &error), - error); - bson_destroy (&b); - } - - r = mongoc_collection_save (collection, tmp_bson ("{'': 1}"), NULL, &error); - - END_IGNORE_DEPRECATIONS; - - ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "invalid document"); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - bson_context_destroy (context); - mongoc_client_destroy (client); -} - - -static void -test_regex (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_write_concern_t *wr; - bson_t opts = BSON_INITIALIZER; - mongoc_client_t *client; - bson_error_t error; - int64_t count; - bson_t q = BSON_INITIALIZER; - bson_t *doc; - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_regex"); - ASSERT (collection); - - wr = mongoc_write_concern_new (); - mongoc_write_concern_set_journal (wr, true); - mongoc_write_concern_append (wr, &opts); - - doc = BCON_NEW ("hello", "/world"); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, doc, &opts, NULL, &error), - error); - - BSON_APPEND_REGEX (&q, "hello", "^/wo", "i"); - - count = mongoc_collection_count_documents ( - collection, &q, NULL, NULL, NULL, &error); - - ASSERT (count > 0); - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - bson_destroy (&opts); - mongoc_write_concern_destroy (wr); - bson_destroy (&q); - bson_destroy (doc); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - - -static void -test_decimal128 (void *ctx) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_write_concern_t *wr; - bson_t opts = BSON_INITIALIZER; - mongoc_client_t *client; - bson_error_t error = {0}; - int64_t count; - bson_t query = BSON_INITIALIZER; - bson_t *doc; - const bson_t *dec; - bson_iter_t dec_iter; - mongoc_cursor_t *cursor; - bool r; - bson_decimal128_t decimal128; - bson_decimal128_t read_decimal; - - BSON_UNUSED (ctx); - - bson_decimal128_from_string ("-123456789.101112E-120", &decimal128); - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_decimal128"); - ASSERT (collection); - - wr = mongoc_write_concern_new (); - mongoc_write_concern_set_journal (wr, true); - mongoc_write_concern_append (wr, &opts); - - doc = BCON_NEW ("the_decimal", BCON_DECIMAL128 (&decimal128)); - r = mongoc_collection_insert_one (collection, doc, &opts, NULL, &error); - if (!r) { - MONGOC_WARNING ("test_decimal128: %s\n", error.message); - } - ASSERT (r); - - count = mongoc_collection_count_documents ( - collection, &query, NULL, NULL, NULL, &error); - ASSERT (count > 0); - - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, &query, NULL, NULL); - ASSERT (mongoc_cursor_next (cursor, &dec)); - - ASSERT (bson_iter_init (&dec_iter, dec)); - - ASSERT (bson_iter_find (&dec_iter, "the_decimal")); - ASSERT (BSON_ITER_HOLDS_DECIMAL128 (&dec_iter)); - bson_iter_decimal128 (&dec_iter, &read_decimal); - - ASSERT (read_decimal.high == decimal128.high && - read_decimal.low == decimal128.low); - - bson_destroy (doc); - bson_destroy (&query); - bson_destroy (&opts); - mongoc_write_concern_destroy (wr); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - - -static void -test_update (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - bson_context_t *context; - bson_error_t error; - bool r; - bson_oid_t oid; - unsigned i; - bson_t b; - bson_t q; - bson_t u; - bson_t set; - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_update"); - ASSERT (collection); - - context = bson_context_new (BSON_CONTEXT_NONE); - ASSERT (context); - - for (i = 0; i < 10; i++) { - bson_init (&b); - bson_oid_init (&oid, context); - bson_append_oid (&b, "_id", 3, &oid); - bson_append_utf8 (&b, "utf8", 4, "utf8 string", 11); - bson_append_int32 (&b, "int32", 5, 1234); - bson_append_int64 (&b, "int64", 5, 12345678); - bson_append_bool (&b, "bool", 4, 1); - - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, &b, NULL, NULL, &error), - error); - - bson_init (&q); - bson_append_oid (&q, "_id", 3, &oid); - - bson_init (&u); - bson_append_document_begin (&u, "$set", 4, &set); - bson_append_utf8 (&set, "utf8", 4, "updated", 7); - bson_append_document_end (&u, &set); - - ASSERT_OR_PRINT (mongoc_collection_update ( - collection, MONGOC_UPDATE_NONE, &q, &u, NULL, &error), - error); - - bson_destroy (&b); - bson_destroy (&q); - bson_destroy (&u); - } - - bson_init (&q); - bson_init (&u); - BSON_APPEND_INT32 (&u, "abcd", 1); - BSON_APPEND_INT32 (&u, "$hi", 1); - r = mongoc_collection_update ( - collection, MONGOC_UPDATE_NONE, &q, &u, NULL, &error); - ASSERT (!r); - ASSERT (error.domain == MONGOC_ERROR_COMMAND); - ASSERT (error.code == MONGOC_ERROR_COMMAND_INVALID_ARG); - bson_destroy (&q); - bson_destroy (&u); - - bson_init (&q); - bson_init (&u); - BSON_APPEND_INT32 (&u, "" /* empty key */, 1); - r = mongoc_collection_update ( - collection, MONGOC_UPDATE_NONE, &q, &u, NULL, &error); - ASSERT (!r); - ASSERT (error.domain == MONGOC_ERROR_COMMAND); - ASSERT (error.code == MONGOC_ERROR_COMMAND_INVALID_ARG); - bson_destroy (&q); - bson_destroy (&u); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - bson_context_destroy (context); - mongoc_client_destroy (client); -} - -static void -test_update_pipeline (void *ctx) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - bson_error_t error; - bson_t *b; - bson_t *pipeline; - bson_t *replacement; - bool res; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_update_pipeline"); - ASSERT (collection); - - b = tmp_bson ("{'nums': {'x': 1, 'y': 2}}"); - res = mongoc_collection_insert_one (collection, b, NULL, NULL, &error); - ASSERT_OR_PRINT (res, error); - - /* format: array document with incrementing keys - (i.e. {"0": value, "1": value, "2": value}) */ - pipeline = tmp_bson ("{'0': {'$replaceRoot': {'newRoot': '$nums'}}," - " '1': {'$addFields': {'z': 3}}}"); - res = mongoc_collection_update_one ( - collection, b, pipeline, NULL, NULL, &error); - ASSERT_OR_PRINT (res, error); - - res = mongoc_collection_insert_one (collection, b, NULL, NULL, &error); - ASSERT_OR_PRINT (res, error); - - /* ensure that arrays sent to mongoc_collection_replace_one are not - treated as pipelines */ - replacement = tmp_bson ("{'0': 0, '1': 1}"); - res = mongoc_collection_replace_one ( - collection, b, replacement, NULL, NULL, &error); - ASSERT_OR_PRINT (res, error); - - /* ensure that a pipeline with an empty document is considered invalid */ - pipeline = tmp_bson ("{ '0': {} }"); - res = mongoc_collection_update_one ( - collection, b, pipeline, NULL, NULL, &error); - ASSERT (!res); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid key"); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_update_oversize (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - size_t huger_sz = 20 * 1024 * 1024; - char *huger; - bson_t huge = BSON_INITIALIZER; - bson_t empty = BSON_INITIALIZER; - bson_t huge_update = BSON_INITIALIZER; - bson_t child; - bool r; - bson_error_t error; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_update_oversize"); - - /* first test oversized selector. two huge strings make the doc too large */ - BSON_ASSERT (bson_append_utf8 ( - &huge, "x", 1, huge_string (client), (int) huge_string_length (client))); - - BSON_ASSERT (bson_append_utf8 ( - &huge, "y", 1, huge_string (client), (int) huge_string_length (client))); - - r = mongoc_collection_update ( - collection, MONGOC_UPDATE_NONE, &huge, &empty, NULL, &error); - ASSERT (!r); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_BSON, MONGOC_ERROR_BSON_INVALID, "too large"); - - /* test oversized update operator */ - huger = bson_malloc (huger_sz + 1); - memset (huger, 'a', huger_sz); - huger[huger_sz] = '\0'; - BSON_ASSERT (BSON_APPEND_DOCUMENT_BEGIN (&huge_update, "$set", &child)); - BSON_ASSERT (bson_append_utf8 (&child, "x", 1, huger, (int) huger_sz)); - BSON_ASSERT (bson_append_document_end (&huge_update, &child)); - - r = mongoc_collection_update ( - collection, MONGOC_UPDATE_NONE, &empty, &huge_update, NULL, &error); - ASSERT (!r); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_BSON, MONGOC_ERROR_BSON_INVALID, "too large"); - - bson_free (huger); - bson_destroy (&huge); - bson_destroy (&empty); - bson_destroy (&huge_update); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_remove (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - bson_context_t *context; - bson_error_t error; - bool r; - bson_oid_t oid; - bson_t b; - int i; - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_remove"); - ASSERT (collection); - - context = bson_context_new (BSON_CONTEXT_NONE); - ASSERT (context); - - for (i = 0; i < 100; i++) { - bson_init (&b); - bson_oid_init (&oid, context); - bson_append_oid (&b, "_id", 3, &oid); - bson_append_utf8 (&b, "hello", 5, "world", 5); - r = mongoc_collection_insert_one (collection, &b, NULL, NULL, &error); - if (!r) { - MONGOC_WARNING ("%s\n", error.message); - } - ASSERT (r); - bson_destroy (&b); - - bson_init (&b); - bson_append_oid (&b, "_id", 3, &oid); - r = mongoc_collection_delete_many (collection, &b, NULL, NULL, &error); - if (!r) { - MONGOC_WARNING ("%s\n", error.message); - } - ASSERT (r); - bson_destroy (&b); - } - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - bson_context_destroy (context); - mongoc_client_destroy (client); -} - - -static void -test_remove_oversize (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t doc = BSON_INITIALIZER; - bool r; - bson_error_t error; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_remove_oversize"); - - /* two huge strings make the doc too large */ - BSON_ASSERT (bson_append_utf8 ( - &doc, "x", 1, huge_string (client), (int) huge_string_length (client))); - - BSON_ASSERT (bson_append_utf8 ( - &doc, "y", 1, huge_string (client), (int) huge_string_length (client))); - - r = mongoc_collection_delete_many (collection, &doc, NULL, NULL, &error); - ASSERT (!r); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_BSON, MONGOC_ERROR_BSON_INVALID, "too large"); - - bson_destroy (&doc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_insert_w0 (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_write_concern_t *wc; - bson_t opts = BSON_INITIALIZER; - bson_error_t error; - bool r; - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_insert_w0"); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - mongoc_write_concern_append (wc, &opts); - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{}"), &opts, NULL, &error); - ASSERT_OR_PRINT (r, error); - ASSERT (mongoc_collection_get_last_error (collection) == NULL); - - bson_destroy (&opts); - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_update_w0 (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_write_concern_t *wc; - bson_error_t error; - - bool r; - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_update_w0"); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - r = mongoc_collection_update (collection, - MONGOC_UPDATE_NONE, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'x': 1}}"), - wc, - &error); - ASSERT_OR_PRINT (r, error); - ASSERT (bson_empty (mongoc_collection_get_last_error (collection))); - - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_remove_w0 (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_write_concern_t *wc; - bson_t opts = BSON_INITIALIZER; - bson_t reply; - bson_error_t error; - bool r; - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_remove_w0"); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - mongoc_write_concern_append (wc, &opts); - r = mongoc_collection_delete_many ( - collection, tmp_bson ("{}"), &opts, &reply, &error); - ASSERT_OR_PRINT (r, error); - ASSERT (bson_empty (&reply)); - - bson_destroy (&reply); - bson_destroy (&opts); - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_insert_twice_w0 (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_write_concern_t *wc; - bson_t opts = BSON_INITIALIZER; - bson_error_t error; - bool r; - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_insert_twice_w0"); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - mongoc_write_concern_append (wc, &opts); - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{'_id': 1}"), &opts, NULL, &error); - ASSERT_OR_PRINT (r, error); - ASSERT (mongoc_collection_get_last_error (collection) == NULL); - - /* Insert same document for the second time, but we should not get - * an error since we don't wait for a server response */ - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{'_id': 1}"), &opts, NULL, &error); - ASSERT_OR_PRINT (r, error); - ASSERT (mongoc_collection_get_last_error (collection) == NULL); - - bson_destroy (&opts); - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_index (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - mongoc_index_opt_t opt; - bson_error_t error; - bson_t keys; - bson_t *opts = NULL; - mongoc_write_concern_t *bad_wc; - mongoc_write_concern_t *good_wc; - bool r; - - mongoc_index_opt_init (&opt); - opts = bson_new (); - - client = test_framework_new_default_client (); - ASSERT (client); - mongoc_client_set_error_api (client, 2); - - bad_wc = mongoc_write_concern_new (); - good_wc = mongoc_write_concern_new (); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_index"); - ASSERT (collection); - - bson_init (&keys); - bson_append_int32 (&keys, "hello", -1, 1); - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &keys, &opt, &error), error); - - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &keys, &opt, &error), error); - - ASSERT_OR_PRINT ( - mongoc_collection_drop_index (collection, "hello_1", &error), error); - - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &keys, &opt, &error), error); - - /* invalid writeConcern */ - bad_wc->wtimeout = -10; - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - ASSERT (!mongoc_collection_drop_index_with_opts ( - collection, "hello_1", opts, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid writeConcern"); - bad_wc->wtimeout = 0; - error.code = 0; - error.domain = 0; - - /* valid writeConcern on all configs*/ - mongoc_write_concern_set_w (good_wc, 1); - bson_reinit (opts); - mongoc_write_concern_append (good_wc, opts); - ASSERT_OR_PRINT (mongoc_collection_drop_index_with_opts ( - collection, "hello_1", opts, &error), - error); - ASSERT (!error.code); - ASSERT (!error.domain); - - /* writeConcern that results in writeConcernError */ - mongoc_write_concern_set_w (bad_wc, 99); - - if (!test_framework_is_mongos ()) { /* skip if sharded */ - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &keys, &opt, &error), - error); - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - r = mongoc_collection_drop_index_with_opts ( - collection, "hello_1", opts, &error); - ASSERT (!r); - assert_wc_oob_error (&error); - } - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - bson_destroy (&keys); - bson_destroy (opts); - mongoc_write_concern_destroy (bad_wc); - mongoc_write_concern_destroy (good_wc); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_index_w_write_concern (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - mongoc_index_opt_t opt; - mongoc_write_concern_t *good_wc; - mongoc_write_concern_t *bad_wc; - bson_error_t error; - bson_t keys; - bson_t reply; - bson_t *opts = NULL; - bool result; - bool is_mongos = test_framework_is_mongos (); - - mongoc_index_opt_init (&opt); - opts = bson_new (); - - client = test_framework_new_default_client (); - ASSERT (client); - - good_wc = mongoc_write_concern_new (); - bad_wc = mongoc_write_concern_new (); - - mongoc_client_set_error_api (client, 2); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_index"); - ASSERT (collection); - - bson_init (&keys); - bson_append_int32 (&keys, "hello", -1, 1); - - /* writeConcern that will not pass validation */ - bad_wc->wtimeout = -10; - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - ASSERT (!mongoc_collection_create_index_with_opts ( - collection, &keys, &opt, opts, &reply, &error)); - bson_destroy (&reply); - - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid writeConcern"); - bad_wc->wtimeout = 0; - error.code = 0; - error.domain = 0; - - /* valid writeConcern on all server configs */ - mongoc_write_concern_set_w (good_wc, 1); - bson_reinit (opts); - mongoc_write_concern_append (good_wc, opts); - result = mongoc_collection_create_index_with_opts ( - collection, &keys, &opt, opts, &reply, &error); - ASSERT_OR_PRINT (result, error); - ASSERT (!error.code); - - /* Be sure the reply is valid */ - ASSERT (bson_validate (&reply, 0, NULL)); - result = mongoc_collection_drop_index (collection, "hello_1", &error); - ASSERT_OR_PRINT (result, error); - ASSERT (!bson_empty (&reply)); - bson_destroy (&reply); - - /* writeConcern that will result in writeConcernError */ - mongoc_write_concern_set_w (bad_wc, 99); - - ASSERT (!error.code); - - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - /* skip this part of the test if sharded cluster */ - if (!is_mongos) { - ASSERT (!mongoc_collection_create_index_with_opts ( - collection, &keys, &opt, opts, &reply, &error)); - assert_wc_oob_error (&error); - - ASSERT (!bson_empty (&reply)); - bson_destroy (&reply); - } - - /* Make sure it doesn't crash with a NULL reply or writeConcern */ - result = mongoc_collection_create_index_with_opts ( - collection, &keys, &opt, NULL, NULL, &error); - ASSERT_OR_PRINT (result, error); - - ASSERT_OR_PRINT ( - mongoc_collection_drop_index (collection, "hello_1", &error), error); - - /* Now attempt to create an invalid index which the server will reject */ - bson_reinit (&keys); - - /* Try to create an index like {abc: "hallo thar"} (won't work, - should really be something like {abc: 1}) - - This fails both on legacy and modern versions of the server - */ - BSON_APPEND_UTF8 (&keys, "abc", "hallo thar"); - result = mongoc_collection_create_index_with_opts ( - collection, &keys, &opt, NULL, &reply, &error); - bson_destroy (&reply); - - ASSERT (!result); - ASSERT (strlen (error.message) > 0); - memset (&error, 0, sizeof (error)); - - /* Try again but with reply NULL. Shouldn't crash */ - result = mongoc_collection_create_index_with_opts ( - collection, &keys, &opt, NULL, NULL, &error); - ASSERT (!result); - ASSERT (strlen (error.message) > 0); - - bson_destroy (&keys); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); - mongoc_write_concern_destroy (bad_wc); - mongoc_write_concern_destroy (good_wc); - bson_destroy (opts); -} - -static void -test_index_compound (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - mongoc_index_opt_t opt; - bson_error_t error; - bson_t keys; - - mongoc_index_opt_init (&opt); - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_index_compound"); - ASSERT (collection); - - bson_init (&keys); - bson_append_int32 (&keys, "hello", -1, 1); - bson_append_int32 (&keys, "world", -1, -1); - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &keys, &opt, &error), error); - - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &keys, &opt, &error), error); - - ASSERT_OR_PRINT ( - mongoc_collection_drop_index (collection, "hello_1_world_-1", &error), - error); - - bson_destroy (&keys); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_index_geo (void *unused) -{ - mongoc_server_description_t const *description; - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - mongoc_index_opt_t opt; - mongoc_index_opt_geo_t geo_opt; - bson_error_t error; - bool r; - bson_t keys; - uint32_t id; - - BSON_UNUSED (unused); - - mongoc_index_opt_init (&opt); - mongoc_index_opt_geo_init (&geo_opt); - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_geo_index"); - ASSERT (collection); - - /* Create a basic 2d index */ - bson_init (&keys); - BSON_APPEND_UTF8 (&keys, "location", "2d"); - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &keys, &opt, &error), error); - - ASSERT_OR_PRINT ( - mongoc_collection_drop_index (collection, "location_2d", &error), error); - - /* Create a 2d index with bells and whistles */ - bson_destroy (&keys); - bson_init (&keys); - BSON_APPEND_UTF8 (&keys, "location", "2d"); - - geo_opt.twod_location_min = -123; - geo_opt.twod_location_max = +123; - geo_opt.twod_bits_precision = 30; - opt.geo_options = &geo_opt; - - /* TODO this hack is needed for single-threaded tests */ - id = mc_tpld_servers_const (mc_tpld_unsafe_get_const (client->topology)) - ->items[0] - .id; - description = mongoc_topology_description_server_by_id_const ( - mc_tpld_unsafe_get_const (client->topology), id, &error); - ASSERT_OR_PRINT (description, error); - - if (description->max_wire_version > 0) { - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &keys, &opt, &error), - error); - - ASSERT_OR_PRINT ( - mongoc_collection_drop_index (collection, "location_2d", &error), - error); - } - - /* Create a Haystack index */ - bson_destroy (&keys); - bson_init (&keys); - BSON_APPEND_UTF8 (&keys, "location", "geoHaystack"); - BSON_APPEND_INT32 (&keys, "category", 1); - - mongoc_index_opt_geo_init (&geo_opt); - geo_opt.haystack_bucket_size = 5; - - opt.geo_options = &geo_opt; - - description = mongoc_topology_description_server_by_id_const ( - mc_tpld_unsafe_get_const (client->topology), id, &error); - ASSERT_OR_PRINT (description, error); - if (description->max_wire_version > 0) { - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &keys, &opt, &error), - error); - - r = mongoc_collection_drop_index ( - collection, "location_geoHaystack_category_1", &error); - ASSERT_OR_PRINT (r, error); - } - - bson_destroy (&keys); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static char * -storage_engine (mongoc_client_t *client) -{ - bson_iter_t iter; - bson_error_t error; - bson_t cmd = BSON_INITIALIZER; - bson_t reply; - - ASSERT (client); - - /* NOTE: this default will change eventually */ - char *engine = bson_strdup ("mmapv1"); - - BSON_APPEND_INT32 (&cmd, "getCmdLineOpts", 1); - ASSERT_OR_PRINT (mongoc_client_command_simple ( - client, "admin", &cmd, NULL, &reply, &error), - error); - - if (bson_iter_init_find (&iter, &reply, "parsed.storage.engine")) { - engine = bson_strdup (bson_iter_utf8 (&iter, NULL)); - } - - bson_destroy (&reply); - bson_destroy (&cmd); - - return engine; -} - -static void -test_index_storage (void) -{ - mongoc_collection_t *collection = NULL; - mongoc_database_t *database = NULL; - mongoc_client_t *client = NULL; - mongoc_index_opt_t opt; - mongoc_index_opt_wt_t wt_opt; - bson_error_t error; - bson_t keys; - char *engine = NULL; - - client = test_framework_new_default_client (); - ASSERT (client); - - /* Skip unless we are on WT */ - engine = storage_engine (client); - if (strcmp ("wiredTiger", engine) != 0) { - goto cleanup; - } - - mongoc_index_opt_init (&opt); - mongoc_index_opt_wt_init (&wt_opt); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_storage_index"); - ASSERT (collection); - - /* Create a simple index */ - bson_init (&keys); - bson_append_int32 (&keys, "hello", -1, 1); - - /* Add storage option to the index */ - wt_opt.base.type = MONGOC_INDEX_STORAGE_OPT_WIREDTIGER; - wt_opt.config_str = "block_compressor=zlib"; - - opt.storage_options = (mongoc_index_opt_storage_t *) &wt_opt; - - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &keys, &opt, &error), error); - -cleanup: - if (engine) - bson_free (engine); - if (collection) - mongoc_collection_destroy (collection); - if (database) - mongoc_database_destroy (database); - if (client) - mongoc_client_destroy (client); -} - -static void -test_count (void) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_error_t error; - int64_t count; - bson_t b; - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = mongoc_client_get_collection (client, "test", "test"); - ASSERT (collection); - - bson_init (&b); - count = mongoc_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - - if (count == -1) { - MONGOC_WARNING ("%s\n", error.message); - } - ASSERT (count != -1); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_count_read_pref (void) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_read_prefs_t *prefs; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - - mongoc_collection_set_read_prefs (collection, prefs); - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, NULL, 0, 0, NULL, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'count': 'collection'," - " '$readPreference': {'mode': 'secondary'}}")); - - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (1 == future_get_int64_t (future), error); - - request_destroy (request); - future_destroy (future); - mongoc_read_prefs_destroy (prefs); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_count_read_concern (void) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_read_concern_t *rc; - mock_server_t *server; - request_t *request; - bson_error_t error; - future_t *future; - int64_t count; - bson_t b; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - ASSERT (client); - - collection = mongoc_client_get_collection (client, "test", "test"); - ASSERT (collection); - - bson_init (&b); - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test', 'count': 'test', 'query': {}}")); - - reply_to_request_simple (request, "{ 'n' : 42, 'ok' : 1 } "); - count = future_get_int64_t (future); - ASSERT_OR_PRINT (count == 42, error); - request_destroy (request); - future_destroy (future); - - /* readConcern: { level: majority } */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_MAJORITY); - mongoc_collection_set_read_concern (collection, rc); - - bson_init (&b); - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'count': 'test'," - " 'query': {}," - " 'readConcern': {'level': 'majority'}}")); - - reply_to_request_simple (request, "{ 'n' : 43, 'ok' : 1 } "); - count = future_get_int64_t (future); - ASSERT_OR_PRINT (count == 43, error); - mongoc_read_concern_destroy (rc); - request_destroy (request); - future_destroy (future); - - /* readConcern: { level: local } */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_LOCAL); - mongoc_collection_set_read_concern (collection, rc); - - bson_init (&b); - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'count': 'test'," - " 'query': {}," - " 'readConcern': {'level': 'local'}}")); - - reply_to_request_simple (request, "{ 'n' : 44, 'ok' : 1 } "); - count = future_get_int64_t (future); - ASSERT_OR_PRINT (count == 44, error); - mongoc_read_concern_destroy (rc); - request_destroy (request); - future_destroy (future); - - /* readConcern: { level: futureCompatible } */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, "futureCompatible"); - mongoc_collection_set_read_concern (collection, rc); - - bson_init (&b); - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'count': 'test'," - " 'query': {}," - " 'readConcern': {'level': 'futureCompatible'}}")); - - reply_to_request_simple (request, "{ 'n' : 45, 'ok' : 1 } "); - count = future_get_int64_t (future); - ASSERT_OR_PRINT (count == 45, error); - mongoc_read_concern_destroy (rc); - request_destroy (request); - future_destroy (future); - - /* Setting readConcern to NULL should not send readConcern */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, NULL); - mongoc_collection_set_read_concern (collection, rc); - - bson_init (&b); - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'count': 'test'," - " 'query': {}," - " 'readConcern': { '$exists': false }}")); - - reply_to_request_simple (request, "{ 'n' : 46, 'ok' : 1 } "); - count = future_get_int64_t (future); - ASSERT_OR_PRINT (count == 46, error); - mongoc_read_concern_destroy (rc); - request_destroy (request); - future_destroy (future); - - /* Fresh read_concern should not send readConcern */ - rc = mongoc_read_concern_new (); - mongoc_collection_set_read_concern (collection, rc); - - bson_init (&b); - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'count': 'test'," - " 'query': {}," - " 'readConcern': { '$exists': false }}")); - - reply_to_request_simple (request, "{ 'n' : 47, 'ok' : 1 } "); - count = future_get_int64_t (future); - ASSERT_OR_PRINT (count == 47, error); - - mongoc_read_concern_destroy (rc); - request_destroy (request); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_count_read_concern_live (void *unused) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_read_concern_t *rc; - bson_error_t error; - int64_t count; - bson_t b; - - BSON_UNUSED (unused); - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = mongoc_client_get_collection (client, "test", "test"); - ASSERT (collection); - - // Drop collection. - // Use writeConcern=majority so later readConcern=majority observes dropped - // collection. - { - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY); - bson_t drop_opts = BSON_INITIALIZER; - mongoc_write_concern_append (wc, &drop_opts); - if (!mongoc_collection_drop_with_opts (collection, &drop_opts, &error)) { - // Ignore an "ns not found" error. - if (NULL == strstr (error.message, "ns not found")) { - ASSERT_OR_PRINT (false, error); - } - } - - bson_destroy (&drop_opts); - mongoc_write_concern_destroy (wc); - } - - bson_init (&b); - count = mongoc_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - ASSERT_OR_PRINT (count != -1, error); - ASSERT_CMPINT64 (count, ==, 0); - - /* Setting readConcern to NULL should not send readConcern */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, NULL); - mongoc_collection_set_read_concern (collection, rc); - - bson_init (&b); - count = mongoc_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - ASSERT_OR_PRINT (count != -1, error); - ASSERT_CMPINT64 (count, ==, 0); - mongoc_read_concern_destroy (rc); - - /* readConcern: { level: local } should raise error pre 3.2 */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_LOCAL); - mongoc_collection_set_read_concern (collection, rc); - - bson_init (&b); - count = mongoc_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - ASSERT_OR_PRINT (count != -1, error); - ASSERT_CMPINT64 (count, ==, 0); - mongoc_read_concern_destroy (rc); - - /* readConcern: { level: majority } should raise error pre 3.2 */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_MAJORITY); - mongoc_collection_set_read_concern (collection, rc); - - bson_init (&b); - count = mongoc_collection_count ( - collection, MONGOC_QUERY_NONE, &b, 0, 0, NULL, &error); - bson_destroy (&b); - ASSERT_OR_PRINT (count != -1, error); - ASSERT_CMPINT64 (count, ==, 0); - mongoc_read_concern_destroy (rc); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -int -skip_unless_server_has_decimal128 (void) -{ - if (!TestSuite_CheckLive ()) { - return 0; - } - if (test_framework_get_server_version () >= - test_framework_str_to_version ("3.3.5")) { - return 1; - } - return 0; -} - -int -mongod_supports_majority_read_concern (void) -{ - if (!TestSuite_CheckLive ()) { - return 0; - } - return test_framework_getenv_bool ("MONGOC_ENABLE_MAJORITY_READ_CONCERN"); -} - - -static void -test_count_with_opts (void) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - future_t *future; - request_t *request; - bson_error_t error; - - /* use a mongos since we don't send SECONDARY_OK to mongos by default */ - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - future = future_collection_count_with_opts (collection, - MONGOC_QUERY_SECONDARY_OK, - NULL, - 0, - 0, - tmp_bson ("{'opt': 1}"), - NULL, - &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'count': 'collection', 'opt': 1}")); - - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (1 == future_get_int64_t (future), error); - - request_destroy (request); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_count_with_collation (void) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - future = future_collection_count_with_opts ( - collection, - MONGOC_QUERY_SECONDARY_OK, - NULL, - 0, - 0, - tmp_bson ("{'collation': {'locale': 'en'}}"), - NULL, - &error); - - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'count': 'collection'," - " 'collation': {'locale': 'en'}}")); - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (1 == future_get_int64_t (future), error); - request_destroy (request); - - - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_count_documents (void) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - future_t *future; - request_t *request; - bson_error_t error; - bson_t reply; - const char *server_reply = "{'cursor': {'firstBatch': [{'n': 123}], '_id': " - "0, 'ns': 'db.coll'}, 'ok': 1}"; - - server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "coll"); - - future = - future_collection_count_documents (collection, - tmp_bson ("{'x': 1}"), - tmp_bson ("{'limit': 2, 'skip': 1}"), - NULL, - &reply, - &error); - - request = mock_server_receives_msg ( - server, - 0, - tmp_bson ("{'aggregate': 'coll', 'pipeline': [{'$match': " - "{'x': 1}}, {'$skip': 1}, {'$limit': 2}, {'$group': " - "{'n': {'$sum': 1}}}]}")); - reply_to_request_simple (request, server_reply); - ASSERT_OR_PRINT (123 == future_get_int64_t (future), error); - ASSERT_MATCH (&reply, server_reply); - - bson_destroy (&reply); - request_destroy (request); - future_destroy (future); - - future = - future_collection_count_documents (collection, - tmp_bson ("{}"), - tmp_bson ("{'limit': 2, 'skip': 1}"), - NULL, - &reply, - &error); - - /* even with an empty filter, we still prepend $match */ - request = mock_server_receives_msg ( - server, - 0, - tmp_bson ("{'aggregate': 'coll', 'pipeline': [{'$match': {}}, {'$skip': " - "1}, {'$limit': 2}, {'$group': " - "{'n': {'$sum': 1}}}]}")); - reply_to_request_simple (request, server_reply); - ASSERT_OR_PRINT (123 == future_get_int64_t (future), error); - ASSERT_MATCH (&reply, server_reply); - bson_destroy (&reply); - request_destroy (request); - future_destroy (future); - - // Test appending maxTimeMS. - future = future_collection_count_documents (collection, - tmp_bson ("{}"), - tmp_bson ("{'maxTimeMS': 123}"), - NULL, - &reply, - &error); - - request = mock_server_receives_msg ( - server, - 0, - tmp_bson ("{'aggregate': 'coll', 'pipeline': [{'$match': {}}, {'$group': " - "{'n': {'$sum': 1}}}], 'maxTimeMS': 123}")); - reply_to_request_simple (request, server_reply); - ASSERT_OR_PRINT (123 == future_get_int64_t (future), error); - ASSERT_MATCH (&reply, server_reply); - bson_destroy (&reply); - request_destroy (request); - future_destroy (future); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_count_documents_live (void) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_error_t error; - int64_t count; - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = mongoc_client_get_collection (client, "test", "test"); - ASSERT (collection); - - count = mongoc_collection_count_documents ( - collection, tmp_bson ("{}"), NULL, NULL, NULL, &error); - - ASSERT_OR_PRINT (count != -1, error); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_estimated_document_count (void) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - future_t *future; - request_t *request; - bson_error_t error; - bson_t reply; - const char *server_reply = "{'n': 123, 'ok': 1}"; - - server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "coll"); - - future = future_collection_estimated_document_count ( - collection, tmp_bson ("{'limit': 2, 'skip': 1}"), NULL, &reply, &error); - - request = mock_server_receives_msg ( - server, 0, tmp_bson ("{'count': 'coll', 'limit': 2, 'skip': 1}")); - reply_to_request_simple (request, server_reply); - ASSERT_OR_PRINT (123 == future_get_int64_t (future), error); - ASSERT_MATCH (&reply, server_reply); - - future_destroy (future); - - /* CDRIVER-3612: ensure that an explicit session triggers a client error */ - future = future_collection_estimated_document_count ( - collection, tmp_bson ("{'sessionId': 123}"), NULL, &reply, &error); - - ASSERT (-1 == future_get_int64_t (future)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Collection count must not specify explicit session"); - - bson_destroy (&reply); - request_destroy (request); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_estimated_document_count_live (void) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_error_t error; - int64_t count; - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = mongoc_client_get_collection (client, "test", "test"); - ASSERT (collection); - - count = mongoc_collection_estimated_document_count ( - collection, NULL, NULL, NULL, &error); - - ASSERT (count != -1); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_drop (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - mongoc_write_concern_t *good_wc; - mongoc_write_concern_t *bad_wc; - bool r; - bson_error_t error; - bson_t *doc; - bson_t *opts = NULL; - - opts = bson_new (); - client = test_framework_new_default_client (); - ASSERT (client); - mongoc_client_set_error_api (client, 2); - - bad_wc = mongoc_write_concern_new (); - good_wc = mongoc_write_concern_new (); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_drop"); - ASSERT (collection); - - doc = BCON_NEW ("hello", "world"); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, doc, NULL, NULL, &error), - error); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - /* invalid writeConcern */ - bad_wc->wtimeout = -10; - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, doc, NULL, NULL, &error), - error); - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - ASSERT (!mongoc_collection_drop_with_opts (collection, opts, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid writeConcern"); - bad_wc->wtimeout = 0; - error.code = 0; - error.domain = 0; - - /* valid writeConcern */ - mongoc_write_concern_set_w (good_wc, 1); - bson_reinit (opts); - mongoc_write_concern_append (good_wc, opts); - ASSERT_OR_PRINT (mongoc_collection_drop_with_opts (collection, opts, &error), - error); - ASSERT (!error.code); - ASSERT (!error.domain); - - /* writeConcern that results in writeConcernError */ - mongoc_write_concern_set_w (bad_wc, 99); - - if (!test_framework_is_mongos ()) { /* skip if sharded */ - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, doc, NULL, NULL, &error), - error); - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - r = mongoc_collection_drop_with_opts (collection, opts, &error); - ASSERT (!r); - assert_wc_oob_error (&error); - } - - bson_destroy (doc); - bson_destroy (opts); - mongoc_write_concern_destroy (good_wc); - mongoc_write_concern_destroy (bad_wc); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - - -static void -test_aggregate_bypass (void *context) -{ - mongoc_collection_t *data_collection; - mongoc_collection_t *out_collection; - mongoc_bulk_operation_t *bulk; - mongoc_database_t *database; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *doc; - bson_t *pipeline; - bson_t *options; - char *collname; - char *dbname; - bson_t reply; - bool r; - int i; - char *json; - - BSON_UNUSED (context); - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - dbname = gen_collection_name ("dbtest"); - collname = gen_collection_name ("data"); - database = mongoc_client_get_database (client, dbname); - data_collection = mongoc_database_get_collection (database, collname); - bson_free (collname); - - collname = gen_collection_name ("bypass"); - options = tmp_bson ( - "{'validator': {'number': {'$gte': 5}}, 'validationAction': 'error'}"); - out_collection = - mongoc_database_create_collection (database, collname, options, &error); - ASSERT_OR_PRINT (out_collection, error); - - bson_free (dbname); - bson_free (collname); - - /* Generate some example data */ - bulk = - mongoc_collection_create_bulk_operation_with_opts (data_collection, NULL); - - for (i = 0; i < 3; i++) { - bson_t *document; - json = bson_strdup_printf ("{'number': 3, 'high': %d }", i); - document = tmp_bson (json); - - mongoc_bulk_operation_insert (bulk, document); - - bson_free (json); - } - - r = (bool) mongoc_bulk_operation_execute (bulk, &reply, &error); - ASSERT_OR_PRINT (r, error); - mongoc_bulk_operation_destroy (bulk); - - json = bson_strdup_printf ("[{'$out': '%s'}]", out_collection->collection); - pipeline = tmp_bson (json); - - cursor = mongoc_collection_aggregate ( - data_collection, MONGOC_QUERY_NONE, pipeline, NULL, NULL); - ASSERT (cursor); - r = mongoc_cursor_next (cursor, &doc); - ASSERT (!r); - ASSERT (mongoc_cursor_error (cursor, &error)); - mongoc_cursor_destroy (cursor); - - options = tmp_bson ("{'bypassDocumentValidation': true}"); - cursor = mongoc_collection_aggregate ( - data_collection, MONGOC_QUERY_NONE, pipeline, options, NULL); - ASSERT (cursor); - ASSERT (!mongoc_cursor_error (cursor, &error)); - - ASSERT_OR_PRINT (mongoc_collection_drop (data_collection, &error), error); - ASSERT_OR_PRINT (mongoc_collection_drop (out_collection, &error), error); - - bson_destroy (&reply); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (data_collection); - mongoc_collection_destroy (out_collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); - bson_free (json); -} - - -static void -test_aggregate (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_error_t error; - bool did_alternate = false; - bool r; - bson_t opts; - bson_t *pipeline; - bson_t *broken_pipeline; - bson_t *b; - bson_iter_t iter; - int i, j; - - client = test_framework_new_default_client (); - ASSERT (client); - - database = get_test_database (client); - ASSERT (database); - - collection = get_test_collection (client, "test_aggregate"); - ASSERT (collection); - - pipeline = BCON_NEW ("pipeline", - "[", - "{", - "$match", - "{", - "hello", - BCON_UTF8 ("world"), - "}", - "}", - "]"); - broken_pipeline = BCON_NEW ("pipeline", - "[", - "{", - "$asdf", - "{", - "foo", - BCON_UTF8 ("bar"), - "}", - "}", - "]"); - b = BCON_NEW ("hello", BCON_UTF8 ("world")); - - /* empty collection */ - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, pipeline, NULL, NULL); - ASSERT (cursor); - - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - - /* empty collection */ - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, pipeline, NULL, NULL); - ASSERT (cursor); - - r = mongoc_cursor_next (cursor, &doc); - ASSERT (!r); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - - for (i = 0; i < 2; i++) { - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, b, NULL, NULL, &error), - error); - } - -again: - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, broken_pipeline, NULL, NULL); - ASSERT (cursor); - - r = mongoc_cursor_next (cursor, &doc); - ASSERT (!r); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT (error.code); - mongoc_cursor_destroy (cursor); - - for (i = 0; i < 2; i++) { - if (i % 2 == 0) { - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, pipeline, NULL, NULL); - ASSERT (cursor); - } else { - bson_init (&opts); - - BSON_APPEND_BOOL (&opts, "allowDiskUse", true); - - BSON_APPEND_INT32 (&opts, "batchSize", 10); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, pipeline, &opts, NULL); - ASSERT (cursor); - - bson_destroy (&opts); - } - - for (j = 0; j < 2; j++) { - r = mongoc_cursor_next (cursor, &doc); - if (mongoc_cursor_error (cursor, &error)) { - test_error ("[%d.%d] %s", error.domain, error.code, error.message); - } - - ASSERT (r); - ASSERT (doc); - - ASSERT (bson_iter_init_find (&iter, doc, "hello") && - BSON_ITER_HOLDS_UTF8 (&iter)); - } - - r = mongoc_cursor_next (cursor, &doc); - if (mongoc_cursor_error (cursor, &error)) { - test_error ("%s", error.message); - } - - ASSERT (!r); - ASSERT (!doc); - - mongoc_cursor_destroy (cursor); - } - - if (!did_alternate) { - did_alternate = true; - bson_destroy (pipeline); - pipeline = BCON_NEW ( - "0", "{", "$match", "{", "hello", BCON_UTF8 ("world"), "}", "}"); - goto again; - } - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); - bson_destroy (b); - bson_destroy (pipeline); - bson_destroy (broken_pipeline); -} - - -static void -test_aggregate_large (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_bulk_operation_t *bulk; - bson_iter_t iter; - int32_t i; - uint32_t server_id; - mongoc_cursor_t *cursor; - bson_t *inserted_doc; - bson_error_t error; - bson_t *pipeline; - const bson_t *doc; - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = get_test_collection (client, "test_aggregate_large"); - ASSERT (collection); - - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - - /* ensure a few batches */ - inserted_doc = tmp_bson ("{'_id': 0}"); - - for (i = 0; i < 2000; i++) { - bson_iter_init_find (&iter, inserted_doc, "_id"); - bson_iter_overwrite_int32 (&iter, i); - mongoc_bulk_operation_insert (bulk, inserted_doc); - } - - server_id = mongoc_bulk_operation_execute (bulk, NULL, &error); - ASSERT_OR_PRINT (server_id > 0, error); - - pipeline = tmp_bson ("[{'$sort': {'_id': 1}}]"); - - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, pipeline, NULL, NULL); - ASSERT (cursor); - - i = 0; - while (mongoc_cursor_next (cursor, &doc)) { - ASSERT (bson_iter_init_find (&iter, doc, "_id")); - ASSERT_CMPINT (i, ==, bson_iter_int32 (&iter)); - i++; - } - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT_CMPINT (i, ==, 2000); - - mongoc_bulk_operation_destroy (bulk); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -typedef struct { - bool with_batch_size; - bool with_options; -} test_aggregate_context_t; - - -static const char * -options_json (test_aggregate_context_t *c) -{ - if (c->with_batch_size && c->with_options) { - return "{'foo': 1, 'batchSize': 11}"; - } else if (c->with_batch_size) { - return "{'batchSize': 11}"; - } else if (c->with_options) { - return "{'foo': 1}"; - } else { - return "{}"; - } -} - - -static void -test_aggregate_modern (void *data) -{ - test_aggregate_context_t *context = (test_aggregate_context_t *) data; - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - future_t *future; - request_t *request; - mongoc_cursor_t *cursor; - const bson_t *doc; - - if (!TestSuite_CheckMockServerAllowed ()) { - return; - } - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - cursor = mongoc_collection_aggregate (collection, - MONGOC_QUERY_NONE, - tmp_bson ("[{'a': 1}]"), - tmp_bson (options_json (context)), - NULL); - - ASSERT (cursor); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'collection'," - " 'pipeline': [{'a': 1}]," - " 'cursor': %s %s}", - context->with_batch_size ? "{'batchSize': 11}" - : "{'$empty': true}", - context->with_options ? ", 'foo': 1" : "")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 42," - " 'ns': 'db.collection'," - " 'firstBatch': [{'_id': 123}]" - "}}"); - - ASSERT (future_get_bool (future)); - ASSERT_MATCH (doc, "{'_id': 123}"); - - request_destroy (request); - future_destroy (future); - - /* create a second batch to see if batch size is still 11 */ - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '42'}," - "'collection': 'collection'," - "'batchSize': %s}", - context->with_batch_size ? "{'$numberLong': '11'}" - : "{'$exists': false}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'nextBatch': [{'_id': 123}]}}"); - - ASSERT (future_get_bool (future)); - ASSERT_MATCH (doc, "{'_id': 123}"); - - /* cursor is completed */ - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - - mongoc_cursor_destroy (cursor); - request_destroy (request); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_aggregate_w_server_id (void) -{ - mock_rs_t *rs; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *opts; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - - rs = mock_rs_with_auto_hello (WIRE_VERSION_MIN, - true /* has primary */, - 1 /* secondary */, - 0 /* arbiters */); - - mock_rs_run (rs); - client = test_framework_client_new_from_uri (mock_rs_get_uri (rs), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - /* use serverId instead of prefs to select the secondary */ - opts = tmp_bson ("{'serverId': 2}"); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson (NULL), opts, NULL); - - future = future_cursor_next (cursor, &doc); - request = - mock_rs_receives_msg (rs, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'collection'," - " 'cursor': {}," - " 'serverId': {'$exists': false}}")); - - ASSERT (mock_rs_request_is_to_secondary (rs, request)); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - ASSERT_OR_PRINT (future_get_bool (future), cursor->error); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_rs_destroy (rs); -} - - -static void -test_aggregate_w_server_id_sharded (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_t *opts; - const bson_t *doc; - future_t *future; - request_t *request; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - opts = tmp_bson ("{'serverId': 1}"); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson (NULL), opts, NULL); - - future = future_cursor_next (cursor, &doc); - - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'collection'," - " 'serverId': {'$exists': false}}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - - ASSERT_OR_PRINT (future_get_bool (future), cursor->error); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_aggregate_server_id_option (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *q; - bson_error_t error; - mongoc_cursor_t *cursor; - const bson_t *doc; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - collection = mongoc_client_get_collection (client, "db", "collection"); - q = tmp_bson (NULL); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, q, tmp_bson ("{'serverId': 'foo'}"), NULL); - - ASSERT_ERROR_CONTAINS (cursor->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "must be an integer"); - - mongoc_cursor_destroy (cursor); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, q, tmp_bson ("{'serverId': 0}"), NULL); - - ASSERT_ERROR_CONTAINS (cursor->error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "must be >= 1"); - - mongoc_cursor_destroy (cursor); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, q, tmp_bson ("{'serverId': 1}"), NULL); - - mongoc_cursor_next (cursor, &doc); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_validate (void *ctx) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_iter_t iter; - bson_error_t error; - bson_t doc = BSON_INITIALIZER; - bson_t opts = BSON_INITIALIZER; - bson_t reply; - bool r; - const uint32_t expected_err_domain = MONGOC_ERROR_BSON; - const uint32_t expected_err_code = MONGOC_ERROR_BSON_INVALID; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = get_test_collection (client, "test_validate"); - ASSERT (collection); - - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, &doc, NULL, NULL, &error), - error); - - BSON_APPEND_BOOL (&opts, "full", true); - - ASSERT_OR_PRINT ( - mongoc_collection_validate (collection, &opts, &reply, &error), error); - - BSON_ASSERT (bson_iter_init_find (&iter, &reply, "valid")); - - bson_destroy (&reply); - - /* Make sure we don't segfault when reply is NULL */ - ASSERT_OR_PRINT ( - mongoc_collection_validate (collection, &opts, NULL, &error), error); - - bson_reinit (&opts); - BSON_APPEND_UTF8 (&opts, "full", "bad_value"); - - /* invalidate reply */ - reply.len = 0; - BSON_ASSERT (!bson_validate (&reply, BSON_VALIDATE_NONE, NULL)); - - r = mongoc_collection_validate (collection, &opts, &reply, &error); - BSON_ASSERT (!r); - BSON_ASSERT (error.domain == expected_err_domain); - BSON_ASSERT (error.code == expected_err_code); - - /* check that reply has been initialized */ - BSON_ASSERT (bson_validate (&reply, 0, NULL)); - - /* Make sure we don't segfault when reply is NULL */ - memset (&error, 0, sizeof (error)); - r = mongoc_collection_validate (collection, &opts, NULL, &error); - BSON_ASSERT (!r); - BSON_ASSERT (error.domain == expected_err_domain); - BSON_ASSERT (error.code == expected_err_code); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - bson_destroy (&reply); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_destroy (&doc); - bson_destroy (&opts); -} - - -static void -test_rename (void) -{ - mongoc_client_t *client; - mongoc_database_t *database; - mongoc_collection_t *collection; - mongoc_write_concern_t *bad_wc; - mongoc_write_concern_t *good_wc; - bool r; - bson_error_t error; - char *dbname; - bson_t doc = BSON_INITIALIZER; - bson_t *opts = NULL; - char **name; - char **names; - bool found; - - client = test_framework_new_default_client (); - ASSERT (client); - mongoc_client_set_error_api (client, 2); - opts = bson_new (); - - bad_wc = mongoc_write_concern_new (); - good_wc = mongoc_write_concern_new (); - - dbname = gen_collection_name ("dbtest"); - database = mongoc_client_get_database (client, dbname); - collection = mongoc_database_get_collection (database, "test_rename"); - - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, &doc, NULL, NULL, &error), - error); - - ASSERT_OR_PRINT (mongoc_collection_rename ( - collection, dbname, "test_rename.2", false, &error), - error); - - names = - mongoc_database_get_collection_names_with_opts (database, NULL, &error); - ASSERT_OR_PRINT (names, error); - found = false; - for (name = names; *name; ++name) { - if (!strcmp (*name, "test_rename.2")) { - found = true; - } - - bson_free (*name); - } - - ASSERT (found); - ASSERT_CMPSTR (mongoc_collection_get_name (collection), "test_rename.2"); - - /* invalid writeConcern */ - bad_wc->wtimeout = -10; - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - ASSERT (!mongoc_collection_rename_with_opts ( - collection, dbname, "test_rename.3", false, opts, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid writeConcern"); - ASSERT_CMPSTR (mongoc_collection_get_name (collection), "test_rename.2"); - - bad_wc->wtimeout = 0; - error.code = 0; - error.domain = 0; - - /* valid writeConcern on all configs */ - mongoc_write_concern_set_w (good_wc, 1); - bson_reinit (opts); - mongoc_write_concern_append (good_wc, opts); - r = mongoc_collection_rename_with_opts ( - collection, dbname, "test_rename.3", false, opts, &error); - ASSERT_OR_PRINT (r, error); - ASSERT_CMPSTR (mongoc_collection_get_name (collection), "test_rename.3"); - - ASSERT (!error.code); - ASSERT (!error.domain); - - /* writeConcern that results in writeConcernError */ - mongoc_write_concern_set_w (bad_wc, 99); - - if (!test_framework_is_mongos ()) { - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - r = mongoc_collection_rename_with_opts ( - collection, dbname, "test_rename.4", false, opts, &error); - ASSERT (!r); - - /* check that collection name has not changed */ - ASSERT_CMPSTR (mongoc_collection_get_name (collection), "test_rename.3"); - assert_wc_oob_error (&error); - } - - ASSERT_OR_PRINT (mongoc_database_drop (database, &error), error); - - bson_free (names); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_write_concern_destroy (good_wc); - mongoc_write_concern_destroy (bad_wc); - mongoc_client_destroy (client); - bson_free (dbname); - bson_destroy (&doc); - bson_destroy (opts); -} - - -static void -test_stats (void *unused) -{ - BSON_UNUSED (unused); - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_error_t error; - bson_iter_t iter; - bson_t stats; - bson_t doc = BSON_INITIALIZER; - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = get_test_collection (client, "test_stats"); - ASSERT (collection); - - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, &doc, NULL, NULL, &error), - error); - - BEGIN_IGNORE_DEPRECATIONS - ASSERT_OR_PRINT (mongoc_collection_stats (collection, NULL, &stats, &error), - error); - END_IGNORE_DEPRECATIONS - - BSON_ASSERT (bson_iter_init_find (&iter, &stats, "ns")); - - BSON_ASSERT (bson_iter_init_find (&iter, &stats, "count")); - BSON_ASSERT (bson_iter_as_int64 (&iter) >= 1); - - bson_destroy (&stats); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_destroy (&doc); -} - - -static void -test_stats_read_pref (void) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_read_prefs_t *prefs; - future_t *future; - request_t *request; - bson_error_t error; - bson_t stats; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_collection_set_read_prefs (collection, prefs); - future = future_collection_stats (collection, NULL, &stats, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'collStats': 'collection'," - " '$readPreference': {'mode': 'secondary'}}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - - future_destroy (future); - bson_destroy (&stats); - mongoc_read_prefs_destroy (prefs); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_find_and_modify_write_concern (void) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - mock_server_t *server; - request_t *request; - future_t *future; - bson_error_t error; - bson_t *update; - bson_t doc = BSON_INITIALIZER; - bson_t reply; - mongoc_write_concern_t *write_concern; - - server = mock_server_new (); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - ASSERT (client); - - collection = - mongoc_client_get_collection (client, "test", "test_find_and_modify"); - - mock_server_auto_hello (server, - "{'isWritablePrimary': true, " - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'maxBsonObjectSize': %d," - " 'maxMessageSizeBytes': %d," - " 'maxWriteBatchSize': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX, - 16777216, - 48000000, - 1000); - - BSON_APPEND_INT32 (&doc, "superduper", 77889); - - update = BCON_NEW ("$set", "{", "superduper", BCON_INT32 (1234), "}"); - - write_concern = mongoc_write_concern_new (); - mongoc_write_concern_set_w (write_concern, 42); - mongoc_collection_set_write_concern (collection, write_concern); - future = future_collection_find_and_modify ( - collection, &doc, NULL, update, NULL, false, false, true, &reply, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'findAndModify': 'test_find_and_modify'," - " 'query': {'superduper': 77889}," - " 'update': {'$set': {'superduper': 1234}}," - " 'new' : true," - " 'writeConcern': {'w': 42}}")); - - reply_to_request_simple (request, "{ 'value' : null, 'ok' : 1 }"); - ASSERT_OR_PRINT (future_get_bool (future), error); - - future_destroy (future); - - bson_destroy (&reply); - bson_destroy (update); - - request_destroy (request); - mongoc_write_concern_destroy (write_concern); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); - bson_destroy (&doc); -} - -static void -test_find_and_modify (void) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_error_t error; - bson_iter_t iter; - bson_iter_t citer; - bson_t *update; - bson_t doc = BSON_INITIALIZER; - bson_t reply; - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = get_test_collection (client, "test_find_and_modify"); - ASSERT (collection); - - BSON_APPEND_INT32 (&doc, "superduper", 77889); - - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, &doc, NULL, NULL, &error), - error); - - update = BCON_NEW ("$set", "{", "superduper", BCON_INT32 (1234), "}"); - - ASSERT_OR_PRINT (mongoc_collection_find_and_modify (collection, - &doc, - NULL, - update, - NULL, - false, - false, - true, - &reply, - &error), - error); - - BSON_ASSERT (bson_iter_init_find (&iter, &reply, "value")); - BSON_ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - BSON_ASSERT (bson_iter_recurse (&iter, &citer)); - BSON_ASSERT (bson_iter_find (&citer, "superduper")); - BSON_ASSERT (BSON_ITER_HOLDS_INT32 (&citer)); - BSON_ASSERT (bson_iter_int32 (&citer) == 1234); - - BSON_ASSERT (bson_iter_init_find (&iter, &reply, "lastErrorObject")); - BSON_ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - BSON_ASSERT (bson_iter_recurse (&iter, &citer)); - BSON_ASSERT (bson_iter_find (&citer, "updatedExisting")); - BSON_ASSERT (BSON_ITER_HOLDS_BOOL (&citer)); - BSON_ASSERT (bson_iter_bool (&citer)); - - bson_destroy (&reply); - bson_destroy (update); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_destroy (&doc); -} - - -static void -test_large_return (void *ctx) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *doc = NULL; - bson_oid_t oid; - bson_t insert_doc = BSON_INITIALIZER; - bson_t query = BSON_INITIALIZER; - size_t len; - char *str; - bool r; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = get_test_collection (client, "test_large_return"); - ASSERT (collection); - - len = 1024 * 1024 * 4; - str = (char *) bson_malloc (len); - memset (str, (int) ' ', len); - str[len - 1] = '\0'; - - bson_oid_init (&oid, NULL); - BSON_APPEND_OID (&insert_doc, "_id", &oid); - BSON_APPEND_UTF8 (&insert_doc, "big", str); - - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - collection, &insert_doc, NULL, NULL, &error), - error); - - bson_destroy (&insert_doc); - - BSON_APPEND_OID (&query, "_id", &oid); - - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, &query, NULL, NULL); - BSON_ASSERT (cursor); - bson_destroy (&query); - - ASSERT_CURSOR_NEXT (cursor, &doc); - BSON_ASSERT (doc); - - r = mongoc_cursor_next (cursor, &doc); - BSON_ASSERT (!r); - - mongoc_cursor_destroy (cursor); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_free (str); -} - - -static void -test_many_return (void) -{ - enum { N_BSONS = 5000 }; - - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *doc = NULL; - bson_oid_t oid; - bson_t query = BSON_INITIALIZER; - bson_t *docs[N_BSONS]; - bool r; - int i; - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = get_test_collection (client, "test_many_return"); - ASSERT (collection); - - for (i = 0; i < N_BSONS; i++) { - docs[i] = bson_new (); - bson_oid_init (&oid, NULL); - BSON_APPEND_OID (docs[i], "_id", &oid); - } - - ASSERT_OR_PRINT (mongoc_collection_insert_many (collection, - (const bson_t **) docs, - (uint32_t) N_BSONS, - NULL, - NULL, - &error), - error); - - cursor = mongoc_collection_find_with_opts (collection, &query, NULL, NULL); - BSON_ASSERT (cursor); - BSON_ASSERT (mongoc_cursor_more (cursor)); - bson_destroy (&query); - - i = 0; - - while (mongoc_cursor_next (cursor, &doc)) { - BSON_ASSERT (doc); - i++; - BSON_ASSERT (mongoc_cursor_more (cursor)); - } - - BSON_ASSERT (i == N_BSONS); - - BSON_ASSERT (!mongoc_cursor_error (cursor, &error)); - r = mongoc_cursor_next (cursor, &doc); - BSON_ASSERT (!r); - BSON_ASSERT (!mongoc_cursor_more (cursor)); - /* mongoc_cursor_next after done is considered an error */ - BSON_ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot advance a completed or failed cursor") - - mongoc_cursor_destroy (cursor); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - destroy_all (docs, N_BSONS); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static bool -insert_one (mongoc_collection_t *collection, - const bson_t *doc, - const bson_t *opts, - bson_error_t *error) -{ - return mongoc_collection_insert_one (collection, doc, opts, NULL, error); -} - - -static bool -insert_many (mongoc_collection_t *collection, - const bson_t *doc, - const bson_t *opts, - bson_error_t *error) -{ - return mongoc_collection_insert_many ( - collection, &doc, 1, opts, NULL, error); -} - - -typedef bool (*insert_fn_t) (mongoc_collection_t *, - const bson_t *, - const bson_t *, - bson_error_t *); - - -static void -_test_insert_validate (insert_fn_t insert_fn) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - collection = get_test_collection (client, "test_insert_validate"); - - BSON_ASSERT (!insert_fn (collection, tmp_bson ("{'': 1}"), NULL, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "empty key"); - - BSON_ASSERT (!insert_fn (collection, - tmp_bson ("{'_id': {'$a': 1}}"), - tmp_bson ("{'validate': false}"), - &error)); - ASSERT_CMPUINT32 (error.domain, ==, (uint32_t) MONGOC_ERROR_SERVER); - - BSON_ASSERT (!insert_fn (collection, - tmp_bson ("{'$': 1}"), - tmp_bson ("{'validate': 'foo'}"), - &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid type for option \"validate\": \"UTF8\""); - - BSON_ASSERT (insert_fn ( - collection, tmp_bson ("{'a': 1}"), tmp_bson ("{'validate': 0}"), &error)); - - /* BSON_VALIDATE_DOT_KEYS */ - BSON_ASSERT (!insert_fn (collection, - tmp_bson ("{'a.a': 1}"), - tmp_bson ("{'validate': 4}"), - &error)); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "invalid document for insert: keys cannot contain \".\": \"a.a\""); - - /* {validate: true} is still prohibited */ - BSON_ASSERT (!insert_fn (collection, - tmp_bson ("{'a': 1}"), - tmp_bson ("{'validate': true}"), - &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid option \"validate\": true"); - - - BSON_ASSERT (insert_fn (collection, - tmp_bson ("{'a.a': 1}"), - tmp_bson ("{'validate': 0}"), - &error)); - - BSON_ASSERT (insert_fn (collection, - tmp_bson ("{'a': 1}"), - tmp_bson ("{'validate': 31}"), - &error)); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -static void -test_insert_bulk_validate (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - const bson_t *docs_client_invalid[] = {tmp_bson ("{'a': 1}"), - tmp_bson ("{'': 2}")}; - const bson_t *docs_server_invalid[] = {tmp_bson ("{'a': 1}"), - tmp_bson ("{'_id': {'$a': 2}}")}; - - BEGIN_IGNORE_DEPRECATIONS - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - collection = get_test_collection (client, "test_insert_validate"); - - /* Invalid documents, validation. */ - BSON_ASSERT (!mongoc_collection_insert_bulk (collection, - MONGOC_INSERT_NONE, - docs_client_invalid, - 2, - NULL /* write concern */, - &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "invalid document"); - - /* Invalid documents, no validation. */ - BSON_ASSERT (!mongoc_collection_insert_bulk ( - collection, - (mongoc_insert_flags_t) MONGOC_INSERT_NO_VALIDATE, - docs_server_invalid, - 2, - NULL /* write concern */, - &error)); - ASSERT_CMPUINT32 (error.domain, ==, (uint32_t) MONGOC_ERROR_SERVER); - - /* Valid document, validation. */ - ASSERT_OR_PRINT ( - mongoc_collection_insert_bulk (collection, - MONGOC_INSERT_NONE, - docs_client_invalid, - 1 /* don't include invalid second doc. */, - NULL /* write concern */, - &error), - error); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - END_IGNORE_DEPRECATIONS -} - - -static void -test_insert_one_validate (void) -{ - _test_insert_validate (insert_one); -} - - -static void -test_insert_many_validate (void) -{ - _test_insert_validate (insert_many); -} - - -/* use a mock server to test the "limit" parameter */ -static void -test_find_limit (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - const bson_t *doc; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - - /* test mongoc_collection_find and mongoc_collection_find_with_opts */ - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_NONE, - 0 /* skip */, - 2 /* limit */, - 0 /* batch_size */, - tmp_bson ("{}"), - NULL, - NULL); - - future = future_cursor_next (cursor, &doc); - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'find': 'test'," - " 'filter': {}," - " 'limit': {'$numberLong': '2'}}")); - - reply_to_request_simple ( - request, - "{'ok': 1, 'cursor': {'id': 0, 'ns': 'test.test', 'firstBatch': [{}]}}"); - BSON_ASSERT (future_get_bool (future)); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - - cursor = mongoc_collection_find_with_opts ( - collection, - tmp_bson ("{}"), - tmp_bson ("{'limit': {'$numberLong': '2'}}"), - NULL); - - future = future_cursor_next (cursor, &doc); - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'find': 'test'," - " 'filter': {}," - " 'limit': {'$numberLong': '2'}}")); - - reply_to_request_simple ( - request, - "{'ok': 1, 'cursor': {'id': 0, 'ns': 'test.test', 'firstBatch': [{}]}}"); - BSON_ASSERT (future_get_bool (future)); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -/* use a mock server to test the "batch_size" parameter */ -static void -test_find_batch_size (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - const bson_t *doc; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - - /* test mongoc_collection_find and mongoc_collection_find_with_opts */ - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_NONE, - 0 /* skip */, - 0 /* limit */, - 2 /* batch_size */, - tmp_bson ("{}"), - NULL, - NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'find': 'test'," - " 'filter': {}," - " 'batchSize': {'$numberLong': '2'}}")); - - reply_to_request_simple ( - request, - "{'ok': 1, 'cursor': {'id': 0, 'ns': 'test.test', 'firstBatch': [{}]}}"); - BSON_ASSERT (future_get_bool (future)); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - - cursor = mongoc_collection_find_with_opts ( - collection, - tmp_bson ("{}"), - tmp_bson ("{'batchSize': {'$numberLong': '2'}}"), - NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'find': 'test'," - " 'filter': {}," - " 'batchSize': {'$numberLong': '2'}}")); - - reply_to_request_simple ( - request, - "{'ok': 1, 'cursor': {'id': 0, 'ns': 'test.test', 'firstBatch': [{}]}}"); - BSON_ASSERT (future_get_bool (future)); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_command_fq (void *context) -{ - mongoc_client_t *client; - mongoc_cursor_t *cursor; - const bson_t *doc = NULL; - bson_iter_t iter; - bson_t *cmd; - bool r; - - BSON_UNUSED (context); - - client = test_framework_new_default_client (); - ASSERT (client); - - cmd = tmp_bson ("{ 'dbstats': 1}"); - - cursor = mongoc_client_command (client, - "sometest.$cmd", - MONGOC_QUERY_SECONDARY_OK, - 0, - -1, - 0, - cmd, - NULL, - NULL); - r = mongoc_cursor_next (cursor, &doc); - BSON_ASSERT (r); - - if (bson_iter_init_find (&iter, doc, "db") && BSON_ITER_HOLDS_UTF8 (&iter)) { - ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), "sometest"); - } else { - test_error ("dbstats didn't return 'db' key?"); - } - - - r = mongoc_cursor_next (cursor, &doc); - BSON_ASSERT (!r); - - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); -} - -static void -test_get_index_info (void) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_index_opt_t opt1; - mongoc_index_opt_t opt2; - bson_error_t error = {0}; - mongoc_cursor_t *cursor; - const bson_t *indexinfo; - bson_t indexkey1; - bson_t indexkey2; - bson_t indexkey3; - bson_t indexkey4; - bson_t indexkey5; - bson_t dummy = BSON_INITIALIZER; - bson_iter_t idx_spec_iter; - bson_iter_t idx_spec_iter_copy; - bool r; - const char *cur_idx_name; - char *idx1_name = NULL; - char *idx2_name = NULL; - char *idx3_name = NULL; - char *idx4_name = NULL; - char *idx5_name = NULL; - const char *id_idx_name = "_id_"; - int num_idxs = 0; - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = get_test_collection (client, "test_get_index_info"); - ASSERT (collection); - - /* - * Try it on a collection that doesn't exist. - */ - cursor = mongoc_collection_find_indexes_with_opts (collection, NULL); - - ASSERT (!mongoc_cursor_next (cursor, &indexinfo)); - ASSERT (!mongoc_cursor_error (cursor, &error)); - - mongoc_cursor_destroy (cursor); - - /* insert a dummy document so that the collection actually exists */ - r = mongoc_collection_insert_one (collection, &dummy, NULL, NULL, &error); - ASSERT (r); - - /* Try it on a collection with no secondary indexes. - * We should just get back the index on _id. - */ - cursor = mongoc_collection_find_indexes_with_opts (collection, NULL); - ASSERT (!mongoc_cursor_error (cursor, &error)); - - while (mongoc_cursor_next (cursor, &indexinfo)) { - if (bson_iter_init (&idx_spec_iter, indexinfo) && - bson_iter_find (&idx_spec_iter, "name") && - BSON_ITER_HOLDS_UTF8 (&idx_spec_iter) && - (cur_idx_name = bson_iter_utf8 (&idx_spec_iter, NULL))) { - BSON_ASSERT (0 == strcmp (cur_idx_name, id_idx_name)); - ++num_idxs; - } else { - BSON_ASSERT (false); - } - } - - BSON_ASSERT (1 == num_idxs); - - mongoc_cursor_destroy (cursor); - - num_idxs = 0; - indexinfo = NULL; - - bson_init (&indexkey1); - BSON_APPEND_INT32 (&indexkey1, "raspberry", 1); - idx1_name = mongoc_collection_keys_to_index_string (&indexkey1); - ASSERT (strcmp (idx1_name, "raspberry_1") == 0); - mongoc_index_opt_init (&opt1); - opt1.background = true; - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &indexkey1, &opt1, &error), - error); - bson_destroy (&indexkey1); - - bson_init (&indexkey2); - BSON_APPEND_INT32 (&indexkey2, "snozzberry", 1); - idx2_name = mongoc_collection_keys_to_index_string (&indexkey2); - ASSERT (strcmp (idx2_name, "snozzberry_1") == 0); - mongoc_index_opt_init (&opt2); - opt2.unique = true; - ASSERT_OR_PRINT ( - mongoc_collection_create_index (collection, &indexkey2, &opt2, &error), - error); - bson_destroy (&indexkey2); - - /* - * Now we try again after creating two indexes. - */ - cursor = mongoc_collection_find_indexes_with_opts (collection, NULL); - ASSERT (!mongoc_cursor_error (cursor, &error)); - - while (mongoc_cursor_next (cursor, &indexinfo)) { - if (bson_iter_init (&idx_spec_iter, indexinfo) && - bson_iter_find (&idx_spec_iter, "name") && - BSON_ITER_HOLDS_UTF8 (&idx_spec_iter) && - (cur_idx_name = bson_iter_utf8 (&idx_spec_iter, NULL))) { - if (0 == strcmp (cur_idx_name, idx1_name)) { - /* need to use the copy of the iter since idx_spec_iter may have - * gone - * past the key we want */ - ASSERT (bson_iter_init_find ( - &idx_spec_iter_copy, indexinfo, "background")); - ASSERT (BSON_ITER_HOLDS_BOOL (&idx_spec_iter_copy)); - ASSERT (bson_iter_bool (&idx_spec_iter_copy)); - } else if (0 == strcmp (cur_idx_name, idx2_name)) { - ASSERT ( - bson_iter_init_find (&idx_spec_iter_copy, indexinfo, "unique")); - ASSERT (BSON_ITER_HOLDS_BOOL (&idx_spec_iter_copy)); - ASSERT (bson_iter_bool (&idx_spec_iter_copy)); - } else { - ASSERT ((0 == strcmp (cur_idx_name, id_idx_name))); - } - - ++num_idxs; - } else { - BSON_ASSERT (false); - } - } - - BSON_ASSERT (3 == num_idxs); - - mongoc_cursor_destroy (cursor); - - /* - * Test that index strings are formed correctly when using an INT64 - * for direction. - */ - bson_init (&indexkey3); - BSON_APPEND_INT64 (&indexkey3, "blackberry", 1); - idx3_name = mongoc_collection_keys_to_index_string (&indexkey3); - ASSERT ((0 == strcmp (idx3_name, "blackberry_1"))); - bson_destroy (&indexkey3); - - bson_init (&indexkey4); - BSON_APPEND_INT64 (&indexkey4, "blueberry", -1); - idx4_name = mongoc_collection_keys_to_index_string (&indexkey4); - ASSERT ((0 == strcmp (idx4_name, "blueberry_-1"))); - bson_destroy (&indexkey4); - - /* - * Test that index string is NULL when an incorrect BSON type is - * used for direction. - */ - bson_init (&indexkey5); - BSON_APPEND_DOUBLE (&indexkey5, "strawberry", 1.0f); - idx5_name = mongoc_collection_keys_to_index_string (&indexkey5); - ASSERT ((idx5_name == NULL)); - bson_destroy (&indexkey5); - - bson_free (idx1_name); - bson_free (idx2_name); - bson_free (idx3_name); - bson_free (idx4_name); - bson_free (idx5_name); - - bson_destroy (&dummy); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_find_indexes_err (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - future_t *future; - request_t *request; - mongoc_cursor_t *cursor; - bson_error_t error; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - mongoc_client_set_error_api (client, 2); - collection = mongoc_client_get_collection (client, "db", "collection"); - - future = future_collection_find_indexes_with_opts (collection, NULL); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'listIndexes': 'collection'}")); - - reply_to_request_simple (request, - "{'ok': 0, 'code': 1234567, 'errmsg': 'foo'}"); - cursor = future_get_mongoc_cursor_ptr (future); - BSON_ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 1234567, "foo"); - - mongoc_cursor_destroy (cursor); - request_destroy (request); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_aggregate_install (TestSuite *suite) -{ - static test_aggregate_context_t test_aggregate_contexts[2][2]; - - int with_batch_size, with_options; - char *name; - test_aggregate_context_t *context; - - for (with_batch_size = 0; with_batch_size < 2; with_batch_size++) { - for (with_options = 0; with_options < 2; with_options++) { - context = &test_aggregate_contexts[with_batch_size][with_options]; - - context->with_batch_size = (bool) with_batch_size; - context->with_options = (bool) with_options; - - name = bson_strdup_printf ( - "/Collection/aggregate/%s/%s", - context->with_batch_size ? "batch_size" : "no_batch_size", - context->with_options ? "with_options" : "no_options"); - - TestSuite_AddWC ( - suite, name, test_aggregate_modern, NULL, (void *) context); - bson_free (name); - } - } -} - - -static void -test_find_read_concern (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_read_concern_t *rc; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - const bson_t *doc; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - - /* No read_concern set - test find and find_with_opts */ - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_SECONDARY_OK, - 0 /* skip */, - 0 /* limit */, - 0 /* batch_size */, - tmp_bson ("{}"), - NULL, - NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test', 'find': 'test', 'filter': {}}")); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'test.test'," - " 'firstBatch': [{'_id': 123}]}}"); - ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - - /* readConcernLevel = local */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_LOCAL); - mongoc_collection_set_read_concern (collection, rc); - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_SECONDARY_OK, - 0 /* skip */, - 0 /* limit */, - 0 /* batch_size */, - tmp_bson ("{}"), - NULL, - NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'find': 'test'," - " 'filter': {}," - " 'readConcern': {'level': 'local'}}")); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'test.test'," - " 'firstBatch': [{'_id': 123}]}}"); - ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_read_concern_destroy (rc); - - /* readConcernLevel = random */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, "random"); - mongoc_collection_set_read_concern (collection, rc); - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_SECONDARY_OK, - 0 /* skip */, - 0 /* limit */, - 0 /* batch_size */, - tmp_bson ("{}"), - NULL, - NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'find': 'test'," - " 'filter': {}," - " 'readConcern': {'level': 'random'}}")); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'test.test'," - " 'firstBatch': [{'_id': 123}]}}"); - ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_read_concern_destroy (rc); - - /* empty readConcernLevel doesn't send anything */ - rc = mongoc_read_concern_new (); - mongoc_collection_set_read_concern (collection, rc); - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_SECONDARY_OK, - 0 /* skip */, - 0 /* limit */, - 0 /* batch_size */, - tmp_bson ("{}"), - NULL, - NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'find': 'test'," - " 'filter': {}," - " 'readConcern': {'$exists': false}}")); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'test.test'," - " 'firstBatch': [{'_id': 123}]}}"); - ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_read_concern_destroy (rc); - - /* readConcernLevel = NULL doesn't send anything */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, NULL); - mongoc_collection_set_read_concern (collection, rc); - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_SECONDARY_OK, - 0 /* skip */, - 0 /* limit */, - 0 /* batch_size */, - tmp_bson ("{}"), - NULL, - NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'find': 'test'," - " 'filter': {}," - " 'readConcern': {'$exists': false}}")); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'test.test'," - " 'firstBatch': [{'_id': 123}]}}"); - ASSERT (future_get_bool (future)); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_read_concern_destroy (rc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_getmore_read_concern_live (void *ctx) -{ - mongoc_client_t *client; - mongoc_read_concern_t *rc; - mongoc_collection_t *collection; - mongoc_bulk_operation_t *bulk; - bson_t *insert_doc; - mongoc_cursor_t *cursor; - mongoc_write_concern_t *wc; - const bson_t *doc; - bson_error_t error; - int i = 0; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_read_concern"); - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_LOCAL); - mongoc_collection_set_read_concern (collection, rc); - - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY); - mongoc_collection_set_write_concern (collection, wc); - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - insert_doc = tmp_bson ("{'a': 1}"); - - for (i = 5000; i > 0; i--) { - mongoc_bulk_operation_insert_with_opts (bulk, insert_doc, NULL, NULL); - } - - ASSERT_OR_PRINT (mongoc_bulk_operation_execute (bulk, NULL, &error), error); - mongoc_bulk_operation_destroy (bulk); - - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{}"), NULL, NULL); - - while (mongoc_cursor_next (cursor, &doc)) { - i++; - } - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - ASSERT_CMPINT (i, ==, 5000); - mongoc_cursor_destroy (cursor); - - mongoc_read_concern_destroy (rc); - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -static void -test_aggregate_secondary (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_read_prefs_t *pref; - bson_error_t error; - mongoc_cursor_t *cursor; - const bson_t *doc; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "aggregate_secondary"); - pref = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson ("[]"), NULL, pref); - - ASSERT (cursor); - mongoc_cursor_next (cursor, &doc); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - if (test_framework_is_replset ()) { - ASSERT (test_framework_server_is_secondary ( - client, mongoc_cursor_get_hint (cursor))); - } - - mongoc_read_prefs_destroy (pref); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_aggregate_secondary_sharded (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_read_prefs_t *pref; - bson_error_t error; - mongoc_cursor_t *cursor; - future_t *future; - request_t *request; - const bson_t *doc; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - pref = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson ("[]"), NULL, pref); - - ASSERT (cursor); - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'collection'," - " 'pipeline': []," - " '$readPreference': {'mode': 'secondary'}}")); - - reply_to_request_simple (request, - "{ 'ok':1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': []}}"); - - ASSERT (!future_get_bool (future)); /* cursor_next returns false */ - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_read_prefs_destroy (pref); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_aggregate_read_concern (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_read_concern_t *rc; - future_t *future; - request_t *request; - mongoc_cursor_t *cursor; - const bson_t *doc; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - /* No readConcern */ - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson ("[{'a': 1}]"), NULL, NULL); - - ASSERT (cursor); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'collection'," - " 'pipeline': [{'a': 1}]," - " 'cursor': {}," - " 'readConcern': {'$exists': false}}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': [{'_id': 123}]" - "}}"); - - ASSERT (future_get_bool (future)); - ASSERT_MATCH (doc, "{'_id': 123}"); - - /* cursor is completed */ - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - mongoc_cursor_destroy (cursor); - request_destroy (request); - future_destroy (future); - - /* readConcern: majority */ - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_MAJORITY); - mongoc_collection_set_read_concern (collection, rc); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson ("[{'a': 1}]"), NULL, NULL); - - ASSERT (cursor); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'collection'," - " 'pipeline': [{'a': 1}]," - " 'cursor': {}," - " 'readConcern': {'level': 'majority'}}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': [{'_id': 123}]" - "}}"); - - ASSERT (future_get_bool (future)); - ASSERT_MATCH (doc, "{'_id': 123}"); - - /* cursor is completed */ - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - mongoc_cursor_destroy (cursor); - request_destroy (request); - future_destroy (future); - - mongoc_read_concern_destroy (rc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_aggregate_with_collation (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - future_t *future; - request_t *request; - mongoc_cursor_t *cursor; - const bson_t *doc; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - cursor = - mongoc_collection_aggregate (collection, - MONGOC_QUERY_NONE, - tmp_bson ("[{'a': 1}]"), - tmp_bson ("{'collation': {'locale': 'en'}}"), - NULL); - - future = future_cursor_next (cursor, &doc); - - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'aggregate': 'collection'," - " 'pipeline': [{'a': 1}]," - " 'collation': {'locale': 'en'}}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': [{'_id': 123}]" - "}}"); - ASSERT (future_get_bool (future)); - ASSERT_MATCH (doc, "{'_id': 123}"); - /* cursor is completed */ - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - request_destroy (request); - - mongoc_cursor_destroy (cursor); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_index_with_collation (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - request_t *request; - bson_error_t error; - bson_t *collation; - bson_t keys; - mongoc_index_opt_t opt; - bson_t reply; - future_t *future; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - bson_init (&keys); - bson_append_int32 (&keys, "hello", -1, 1); - mongoc_index_opt_init (&opt); - collation = - BCON_NEW ("locale", BCON_UTF8 ("en"), "strength", BCON_INT32 (2)); - opt.collation = collation; - - future = future_collection_create_index_with_opts ( - collection, &keys, &opt, NULL, &reply, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'createIndexes': 'collection'," - " 'indexes': [{" - " 'key': {'hello' : 1}," - " 'name': 'hello_1'," - " 'collation': {'locale': 'en', 'strength': 2}}]}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT (future_get_bool (future)); - - bson_destroy (&reply); - bson_destroy (collation); - bson_destroy (&keys); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_insert_duplicate_key (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_insert_duplicate_key"); - mongoc_collection_insert_one ( - collection, tmp_bson ("{'_id': 1}"), NULL, NULL, NULL); - - ASSERT (!mongoc_collection_insert_one ( - collection, tmp_bson ("{'_id': 1}"), NULL, NULL, &error)); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_COLLECTION); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_DUPLICATE_KEY); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -static void -test_create_index_fail (void *context) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bool r; - bson_t reply; - bson_error_t error; - - BSON_UNUSED (context); - - client = test_framework_client_new ( - "mongodb://example.doesntexist/?connectTimeoutMS=10", NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - r = mongoc_collection_create_index_with_opts ( - collection, tmp_bson ("{'a': 1}"), NULL, NULL, &reply, &error); - - ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "No suitable servers"); - - /* reply was initialized */ - ASSERT (bson_empty (&reply)); - - bson_destroy (&reply); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -/* Tests that documents in `coll` found with `selector` all match `match` */ -static void -_test_docs_in_coll_matches (mongoc_collection_t *coll, - bson_t *selector, - const char *match, - uint32_t expected_count) -{ - const bson_t *next_doc; - mongoc_cursor_t *cursor = - mongoc_collection_find_with_opts (coll, selector, NULL, NULL); - while (expected_count > 0) { - ASSERT (mongoc_cursor_next (cursor, &next_doc)); - if (match) { - ASSERT_MATCH (next_doc, match); - } - --expected_count; - } - ASSERT_CMPINT (expected_count, ==, 0); - mongoc_cursor_destroy (cursor); -} - -static void -_test_no_docs_match (mongoc_collection_t *coll, const char *selector) -{ - bson_error_t error; - int64_t ret; - - ret = mongoc_collection_count_documents ( - coll, tmp_bson (selector), NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (ret != -1, error); - ASSERT_CMPINT64 (ret, ==, (int64_t) 0); -} - -typedef struct { - const char *command_under_test; - int commands_tested; - const char *expected_command; -} test_crud_ctx_t; - -/* Tests that commands match the `expected_command` in the update ctx */ -void -_test_crud_command_start (const mongoc_apm_command_started_t *event) -{ - const bson_t *cmd = mongoc_apm_command_started_get_command (event); - const char *cmd_name = mongoc_apm_command_started_get_command_name (event); - - test_crud_ctx_t *ctx = - (test_crud_ctx_t *) mongoc_apm_command_started_get_context (event); - - if (!strcmp (cmd_name, ctx->command_under_test)) { - ctx->commands_tested++; - ASSERT_MATCH (cmd, ctx->expected_command); - assert_no_duplicate_keys (cmd); - } -} - -static void -test_insert_one (void) -{ - bson_error_t err = {0}; - bson_t reply; - bson_t opts_with_wc = BSON_INITIALIZER; - bool ret; - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_database_t *db = get_test_database (client); - mongoc_collection_t *coll = mongoc_database_get_collection (db, "coll"); - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - mongoc_write_concern_t *wc2 = mongoc_write_concern_new (); - test_crud_ctx_t ctx; - mongoc_apm_callbacks_t *callbacks = mongoc_apm_callbacks_new (); - - ctx.command_under_test = "insert"; - ctx.commands_tested = 0; - - /* Give wc and wc2 different j values so we can distinguish them but make - * sure they have w:1 so the writes are committed when we check results */ - mongoc_write_concern_set_w (wc, 1); - mongoc_write_concern_set_journal (wc, false); - mongoc_write_concern_set_w (wc2, 1); - mongoc_write_concern_set_journal (wc2, true); - - mongoc_collection_set_write_concern (coll, wc); - mongoc_apm_set_command_started_cb (callbacks, _test_crud_command_start); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - mongoc_collection_drop (coll, NULL); - - /* Test a simple insert with bypassDocumentValidation */ - ctx.expected_command = "{'insert': 'coll', 'bypassDocumentValidation': " - "true, 'writeConcern': {'w': 1, 'j': false}}"; - ret = mongoc_collection_insert_one ( - coll, - tmp_bson ("{'_id': 1}"), - tmp_bson ("{'bypassDocumentValidation': true}"), - &reply, - &err); - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, "{'insertedCount': 1}"); - bson_destroy (&reply); - _test_docs_in_coll_matches (coll, tmp_bson ("{'_id': 1}"), NULL, 1); - - /* Test maxTimeMS */ - ctx.expected_command = "{'insert': 'coll', 'maxTimeMS': 9999, " - " 'writeConcern': {'w': 1, 'j': false}}"; - ret = mongoc_collection_insert_one (coll, - tmp_bson ("{'_id': 2}"), - tmp_bson ("{'maxTimeMS': 9999}"), - &reply, - &err); - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, "{'insertedCount': 1}"); - bson_destroy (&reply); - _test_docs_in_coll_matches (coll, tmp_bson ("{'_id': 2}"), NULL, 1); - - /* Test passing write concern through the options */ - mongoc_write_concern_append (wc2, &opts_with_wc); - ctx.expected_command = - "{'insert': 'coll', 'writeConcern': {'w': 1, 'j': true}}"; - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 3}"), &opts_with_wc, &reply, &err); - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, "{'insertedCount': 1}"); - bson_destroy (&reply); - _test_docs_in_coll_matches (coll, tmp_bson ("{'_id':3}"), NULL, 1); - - /* Test passing NULL for opts, reply, and error */ - ctx.expected_command = - "{'insert': 'coll', 'writeConcern': {'w': 1, 'j': false}}"; - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 4}"), NULL, NULL, NULL); - ASSERT (ret); - _test_docs_in_coll_matches (coll, tmp_bson ("{'_id': 4}"), NULL, 1); - - /* Duplicate key error */ - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 4}"), NULL, &reply, &err); - ASSERT (!ret); - ASSERT_CMPUINT32 (err.domain, ==, (uint32_t) MONGOC_ERROR_COLLECTION); - ASSERT_MATCH (&reply, - "{'insertedCount': 0," - " 'writeErrors': [" - " {'index': 0, 'code': 11000, 'errmsg': {'$exists': true}}" - "]}"); - bson_destroy (&reply); - ASSERT_CMPINT (ctx.commands_tested, ==, 5); - - if (test_framework_is_replset ()) { - /* Write concern error */ - ctx.expected_command = "{'insert': 'coll'," - " 'writeConcern': {'w': 99, 'wtimeout': 100}}"; - ret = mongoc_collection_insert_one ( - coll, - tmp_bson ("{}"), - tmp_bson ("{'writeConcern': {'w': 99, 'wtimeout': 100}}"), - &reply, - &err); - ASSERT (!ret); - if (test_framework_get_server_version () >= - test_framework_str_to_version ("4.3.3")) { - /* Error reporting changed in SERVER-45584 */ - ASSERT_CMPUINT32 (err.domain, ==, (uint32_t) MONGOC_ERROR_QUERY); - ASSERT_MATCH (&reply, - "{'insertedCount': 0," - " 'writeErrors': {'$exists': false}," - " 'writeConcernErrors': {'$exists': false}" - "}"); - } else { - ASSERT_CMPUINT32 ( - err.domain, ==, (uint32_t) MONGOC_ERROR_WRITE_CONCERN); - ASSERT_MATCH (&reply, - "{'insertedCount': 1," - " 'writeErrors': {'$exists': false}," - " 'writeConcernErrors': {'$exists': true}" - "}"); - } - bson_destroy (&reply); - } - - bson_destroy (&opts_with_wc); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_write_concern_destroy (wc); - mongoc_write_concern_destroy (wc2); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -typedef bool (*update_fn_t) (mongoc_collection_t *, - const bson_t *, - const bson_t *, - const bson_t *, - bson_t *, - bson_error_t *); - -/* Tests `update_one`, `update_many`, and `replace_one` */ -static void -_test_update_and_replace (bool is_replace, bool is_multi) -{ - update_fn_t fn = NULL; - bson_t *update = NULL; - bson_error_t err = {0}; - bson_t reply; - bson_t opts_with_wc = BSON_INITIALIZER; - bson_t opts_with_wc2 = BSON_INITIALIZER; - bool ret = false; - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_database_t *db = get_test_database (client); - mongoc_collection_t *coll = mongoc_database_get_collection (db, "coll"); - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - mongoc_write_concern_t *wc2 = mongoc_write_concern_new (); - test_crud_ctx_t ctx; - mongoc_apm_callbacks_t *callbacks = mongoc_apm_callbacks_new (); - - ctx.command_under_test = "update"; - ctx.commands_tested = 0; - - /* Give wc and wc2 different j values so we can distinguish them but make - * sure they have w:1 so the writes are committed when we check results */ - mongoc_write_concern_set_w (wc, 1); - mongoc_write_concern_set_journal (wc, false); - mongoc_write_concern_append (wc, &opts_with_wc); - mongoc_collection_set_write_concern (coll, wc); - - mongoc_write_concern_set_w (wc2, 1); - mongoc_write_concern_set_journal (wc2, true); - mongoc_write_concern_append (wc2, &opts_with_wc2); - - mongoc_apm_set_command_started_cb (callbacks, _test_crud_command_start); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - mongoc_collection_drop (coll, NULL); - - /* Test `replace_one`, `update_one` or `update_many` based on args */ - if (is_replace) { - ASSERT (!is_multi); - fn = mongoc_collection_replace_one; - } else { - fn = is_multi ? mongoc_collection_update_many - : mongoc_collection_update_one; - } - - /* Test a simple update with bypassDocumentValidation */ - ctx.expected_command = "{'update': 'coll', 'bypassDocumentValidation': " - "true, 'writeConcern': {'w': 1, 'j': false}}"; - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 1}"), &opts_with_wc, NULL, &err); - ASSERT_OR_PRINT (ret, err); - update = - is_replace ? tmp_bson ("{'a': 1}") : tmp_bson ("{'$set': {'a': 1}}"); - ret = fn (coll, - tmp_bson ("{}"), - update, - tmp_bson ("{'bypassDocumentValidation': true}"), - &reply, - &err); - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, - "{'modifiedCount': 1, 'matchedCount': 1, " - "'upsertedId': {'$exists': false}}"); - bson_destroy (&reply); - _test_docs_in_coll_matches (coll, tmp_bson ("{'_id':1}"), "{'a': 1}", 1); - - /* Test passing an upsert */ - ctx.expected_command = - "{'update': 'coll', 'writeConcern': {'w': 1, 'j': false}}"; - update = is_replace ? tmp_bson ("{'b': 'TEST'}") - : tmp_bson ("{'$set': {'b': 'TEST'}}"); - ret = fn (coll, - tmp_bson ("{'_id': 2}"), - update, - tmp_bson ("{'upsert': true}"), - &reply, - &err); - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, - "{'modifiedCount': 0, 'matchedCount': 0, " - "'upsertedId': {'$exists': true}}"); - bson_destroy (&reply); - _test_docs_in_coll_matches ( - coll, tmp_bson ("{'_id':2}"), "{'b': 'TEST'}", 1); - - /* Test collation */ - update = is_replace ? tmp_bson ("{'b': 'test'}") - : tmp_bson ("{'$set': {'b': 'test'}}"); - ret = fn (coll, - tmp_bson ("{'b': 'TEST'}"), - update, - tmp_bson ("{'collation': {'locale': 'en', 'strength': 2}}"), - &reply, - &err); - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, - "{'modifiedCount': 1, 'matchedCount': 1, " - "'upsertedId': {'$exists': false}}"); - bson_destroy (&reply); - _test_docs_in_coll_matches ( - coll, tmp_bson ("{'_id':2}"), "{'b': 'test'}", 1); - - /* Test passing write concern through the options */ - ctx.expected_command = - "{'update': 'coll', 'writeConcern': {'w': 1, 'j': true}}"; - update = - is_replace ? tmp_bson ("{'b': 0}") : tmp_bson ("{'$set': {'b': 0}}"); - ret = - fn (coll, tmp_bson ("{'_id': 2}"), update, &opts_with_wc2, &reply, &err); - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, - "{'modifiedCount': 1, 'matchedCount': 1, " - "'upsertedId': {'$exists': false}}"); - bson_destroy (&reply); - _test_docs_in_coll_matches (coll, tmp_bson ("{'_id':2}"), "{'b': 0}", 1); - - /* Test passing NULL for opts, reply, and error */ - ctx.expected_command = - "{'update': 'coll', 'writeConcern': {'w': 1, 'j': false}}"; - update = - is_replace ? tmp_bson ("{'b': 1}") : tmp_bson ("{'$set': {'b': 1}}"); - ret = fn (coll, tmp_bson ("{'_id': 2}"), update, NULL, NULL, NULL); - ASSERT (ret); - _test_docs_in_coll_matches (coll, tmp_bson ("{'_id' :2}"), "{'b': 1}", 1); - - /* Test multiple matching documents */ - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 3, 'a': 1}"), &opts_with_wc, NULL, &err); - ASSERT_OR_PRINT (ret, err); - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 4, 'a': 1}"), &opts_with_wc, NULL, &err); - ASSERT_OR_PRINT (ret, err); - update = - is_replace ? tmp_bson ("{'a': 2}") : tmp_bson ("{'$set': {'a': 2}}"); - ret = fn ( - coll, tmp_bson ("{'_id': {'$in': [3,4]}}"), update, NULL, &reply, &err); - ASSERT_OR_PRINT (ret, err); - if (is_multi) { - ASSERT_MATCH (&reply, - "{'modifiedCount': 2, 'matchedCount': 2, " - "'upsertedId': {'$exists': false}}"); - _test_docs_in_coll_matches ( - coll, tmp_bson ("{'_id': {'$in': [3,4]}}"), "{'a': 2}", 2); - } else { - ASSERT_MATCH (&reply, - "{'modifiedCount': 1, 'matchedCount': 1, " - "'upsertedId': {'$exists': false}}"); - /* omit testing collection since not sure which was updated */ - } - bson_destroy (&reply); - - ctx.expected_command = "{'update': 'coll'}"; - ret = fn (coll, tmp_bson ("{'$badOp': 1}"), update, NULL, &reply, &err); - ASSERT (!ret); - ASSERT_CMPUINT32 (err.domain, ==, (uint32_t) MONGOC_ERROR_COLLECTION); - ASSERT_MATCH (&reply, - "{'modifiedCount': 0," - " 'matchedCount': 0," - " 'writeErrors': [" - " {'index': 0, 'code': 2, 'errmsg': {'$exists': true}}" - "]}"); - bson_destroy (&reply); - - if (test_framework_is_replset ()) { - ret = fn (coll, - tmp_bson ("{'_id': 3}"), - is_replace ? tmp_bson ("{'a': 3}") - : tmp_bson ("{'$set': {'a': 3}}"), - tmp_bson ("{'writeConcern': {'w': 99, 'wtimeout': 100}}"), - &reply, - &err); - ASSERT (!ret); - - if (test_framework_get_server_version () >= - test_framework_str_to_version ("4.3.3")) { - /* Error reporting changed in SERVER-45584 */ - ASSERT_CMPUINT32 (err.domain, ==, (uint32_t) MONGOC_ERROR_QUERY); - ASSERT_MATCH (&reply, - "{'modifiedCount': 0," - " 'matchedCount': 0," - " 'writeErrors': {'$exists': false}," - " 'writeConcernErrors': {'$exists': false}" - "}"); - } else { - ASSERT_CMPUINT32 ( - err.domain, ==, (uint32_t) MONGOC_ERROR_WRITE_CONCERN); - ASSERT_MATCH (&reply, - "{'modifiedCount': 1," - " 'matchedCount': 1," - " 'writeErrors': {'$exists': false}," - " 'writeConcernErrors': {'$exists': true}" - "}"); - } - bson_destroy (&reply); - } - - /* Test function specific behavior */ - if (is_replace) { - /* Test that replace really does replace */ - ret = - mongoc_collection_insert_one (coll, - tmp_bson ("{'_id': 5, 'a': 1, 'b': 2}"), - &opts_with_wc, - NULL, - &err); - ASSERT_OR_PRINT (ret, err); - ret = fn (coll, - tmp_bson ("{'_id': 5}"), - tmp_bson ("{'a': 2}"), - NULL, - &reply, - &err); - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, - "{'modifiedCount': 1, 'matchedCount': 1, " - "'upsertedId': {'$exists': false}}"); - _test_docs_in_coll_matches ( - coll, tmp_bson ("{'_id': 5}"), "{'a': 2, 'b': {'$exists': false}}", 1); - bson_destroy (&reply); - - /* Test that a non-replace update fails. */ - ret = fn (coll, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'a': 1}}"), - NULL, - NULL, - &err); - ASSERT (!ret); - ASSERT_ERROR_CONTAINS ( - err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid key '$set': replace prohibits $ operators"); - } else { - /* Test update_one and update_many with arrayFilters */ - ret = mongoc_collection_insert_one ( - coll, - tmp_bson ("{'_id': 6, 'a': [{'x':1},{'x':2}]}"), - &opts_with_wc, - NULL, - &err); - - ASSERT_OR_PRINT (ret, err); - - update = tmp_bson ("{'$set': {'a.$[i].x': 3}}"); - ret = fn (coll, - tmp_bson ("{'_id': 6}"), - update, - tmp_bson ("{'arrayFilters': [{'i.x': {'$gt': 1}}]}"), - &reply, - &err); - - if (test_framework_max_wire_version_at_least (6)) { - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, - "{'modifiedCount': 1, 'matchedCount': 1, " - "'upsertedId': {'$exists': false}}"); - _test_docs_in_coll_matches ( - coll, tmp_bson ("{'_id':6}"), "{'a': [{'x':1},{'x':3}]}", 1); - } else { - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS ( - err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "The selected server does not support array filters"); - } - - bson_destroy (&reply); - - /* Test update that fails */ - ctx.expected_command = "{'update': 'coll'}"; - ret = - fn (coll, tmp_bson ("{}"), tmp_bson ("{'a': 1}"), NULL, &reply, &err); - ASSERT (!ret); - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid key"); - ASSERT (bson_empty (&reply)); - bson_destroy (&reply); - } - - ASSERT_CMPINT (ctx.commands_tested, >, 0); - - mongoc_apm_callbacks_destroy (callbacks); - bson_destroy (&opts_with_wc); - bson_destroy (&opts_with_wc2); - mongoc_write_concern_destroy (wc); - mongoc_write_concern_destroy (wc2); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -static void -test_update_and_replace (void) -{ - _test_update_and_replace (false /* is_replace */, false /* is_multi */); - _test_update_and_replace (true /* is_replace */, false /* is_multi */); - _test_update_and_replace (false /* is_replace */, true /* is_multi */); - /* Note, there is no multi replace */ -} - - -static void -test_array_filters_validate (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - bool r; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - collection = get_test_collection (client, "test_array_filters_validation"); - r = mongoc_collection_update_one (collection, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'x': 1}}"), - tmp_bson ("{'arrayFilters': 1}"), - NULL, - &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid field \"arrayFilters\" in opts, should contain array," - " not INT32"); - - r = mongoc_collection_update_one (collection, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'x': 1}}"), - tmp_bson ("{'arrayFilters': {}}"), - NULL, - &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid field \"arrayFilters\" in opts, should contain array," - " not DOCUMENT"); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -_test_update_validate (update_fn_t update_fn) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *selector; - bson_t *invalid_update, *valid_update; - const char *msg; - bson_error_t error; - bool r; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - collection = get_test_collection (client, "test_update_validate"); - selector = tmp_bson ("{}"); - - if (update_fn == mongoc_collection_replace_one) { - /* prohibited for replace */ - invalid_update = tmp_bson ("{'$set': {'x': 1}}"); - /* permitted for replace */ - valid_update = tmp_bson ("{'x': 1}"); - msg = "Invalid key '$set': replace prohibits $ operators"; - } else { - /* prohibited for update */ - invalid_update = tmp_bson ("{'x': 1}"); - /* permitted for update */ - valid_update = tmp_bson ("{'$set': {'x': 1}}"); - msg = "Invalid key 'x': update only works with $ operators and pipelines"; - } - - BSON_ASSERT ( - !update_fn (collection, selector, invalid_update, NULL, NULL, &error)); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, msg); - - r = update_fn (collection, - selector, - invalid_update, - tmp_bson ("{'validate': false}"), - NULL, - &error); - - /* server may or may not error */ - if (!r) { - ASSERT_CMPUINT32 (error.domain, ==, (uint32_t) MONGOC_ERROR_SERVER); - } - - BSON_ASSERT (!update_fn (collection, - selector, - invalid_update, - tmp_bson ("{'validate': 'foo'}"), - NULL, - &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid type for option \"validate\": \"UTF8\""); - - /* Set all validation flags */ - BSON_ASSERT (!update_fn (collection, - selector, - invalid_update, - tmp_bson ("{'validate': 31}"), - NULL, - &error)); - - /* bson_validate_with_error will yield a different error message than the - * standard key check in _mongoc_validate_replace */ - if (update_fn == mongoc_collection_replace_one) { - msg = - "invalid argument for replace: keys cannot begin with \"$\": \"$set\""; - } - - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, msg); - - /* Check that validation passes for a valid update. */ - ASSERT_OR_PRINT ( - update_fn (collection, - selector, - valid_update, - tmp_bson ("{'validate': %d}", BSON_VALIDATE_UTF8), - NULL, - &error), - error); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_replace_one_validate (void) -{ - _test_update_validate (mongoc_collection_replace_one); -} - - -static void -test_update_one_validate (void) -{ - _test_update_validate (mongoc_collection_update_one); -} - - -static void -test_update_many_validate (void) -{ - _test_update_validate (mongoc_collection_update_many); -} - - -typedef bool (*delete_fn_t) (mongoc_collection_t *, - const bson_t *, - const bson_t *, - bson_t *, - bson_error_t *); - -static void -_test_delete_one_or_many (bool is_multi) -{ - delete_fn_t fn = - is_multi ? mongoc_collection_delete_many : mongoc_collection_delete_one; - bson_error_t err = {0}; - bson_t reply; - bson_t opts_with_wc = BSON_INITIALIZER; - bool ret; - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_database_t *db = get_test_database (client); - mongoc_collection_t *coll = mongoc_database_get_collection (db, "coll"); - mongoc_write_concern_t *wc = mongoc_write_concern_new (); - mongoc_write_concern_t *wc2 = mongoc_write_concern_new (); - test_crud_ctx_t ctx; - mongoc_apm_callbacks_t *callbacks = mongoc_apm_callbacks_new (); - int i; - - ctx.command_under_test = "delete"; - ctx.commands_tested = 0; - - /* Give wc and wc2 different j values so we can distinguish them but make - * sure they have w:1 so the writes are committed when we check results */ - mongoc_write_concern_set_w (wc, 1); - mongoc_write_concern_set_journal (wc, false); - mongoc_write_concern_set_w (wc2, 1); - mongoc_write_concern_set_journal (wc2, true); - - mongoc_collection_set_write_concern (coll, wc); - mongoc_apm_set_command_started_cb (callbacks, _test_crud_command_start); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - mongoc_collection_drop (coll, NULL); - - for (i = 0; i < 3; i++) { - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': %d}", i), NULL, NULL, &err); - ASSERT_OR_PRINT (ret, err); - } - - /* Test maxTimeMS */ - ctx.expected_command = "{'delete': 'coll', 'maxTimeMS': 9999, " - " 'writeConcern': {'w': 1, 'j': false}}"; - ret = fn (coll, - tmp_bson ("{'_id': 1}"), - tmp_bson ("{'maxTimeMS': 9999}"), - &reply, - &err); - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, "{'deletedCount': 1}"); - bson_destroy (&reply); - _test_no_docs_match (coll, "{'_id': 1}"); - - /* Test passing write concern through the options */ - mongoc_write_concern_append (wc2, &opts_with_wc); - ctx.expected_command = - "{'delete': 'coll', 'writeConcern': {'w': 1, 'j': true}}"; - ret = fn (coll, tmp_bson ("{'_id': 2}"), &opts_with_wc, &reply, &err); - ASSERT_OR_PRINT (ret, err); - ASSERT_MATCH (&reply, "{'deletedCount': 1}"); - bson_destroy (&reply); - _test_no_docs_match (coll, "{'_id': 2}"); - - /* Test passing NULL for opts, reply, and error */ - ctx.expected_command = - "{'delete': 'coll', 'writeConcern': {'w': 1, 'j': false}}"; - ret = fn (coll, tmp_bson ("{'_id': 3}"), NULL, NULL, NULL); - ASSERT (ret); - _test_no_docs_match (coll, "{'_id': 3}"); - - /* Server error */ - ret = fn (coll, tmp_bson ("{'_id': {'$foo': 1}}"), NULL, &reply, &err); - ASSERT (!ret); - ASSERT_CMPUINT32 (err.domain, ==, (uint32_t) MONGOC_ERROR_COLLECTION); - ASSERT_MATCH (&reply, - "{'deletedCount': 0," - " 'writeErrors': [" - " {'index': 0," - " 'code': {'$exists': true}," - " 'errmsg': {'$exists': true}}" - "]}"); - bson_destroy (&reply); - ASSERT_CMPINT (ctx.commands_tested, ==, 4); - - if (test_framework_is_replset ()) { - /* Write concern error */ - ctx.expected_command = "{'delete': 'coll'," - " 'writeConcern': {'w': 99, 'wtimeout': 100}}"; - ret = fn (coll, - tmp_bson ("{}"), - tmp_bson ("{'writeConcern': {'w': 99, 'wtimeout': 100}}"), - &reply, - &err); - ASSERT (!ret); - if (test_framework_get_server_version () >= - test_framework_str_to_version ("4.3.3")) { - /* Error reporting changed in SERVER-45584 */ - ASSERT_CMPUINT32 (err.domain, ==, (uint32_t) MONGOC_ERROR_QUERY); - ASSERT_MATCH (&reply, - "{'deletedCount': 0," - " 'writeErrors': {'$exists': false}," - " 'writeConcernErrors': {'$exists': false}" - "}"); - } else { - ASSERT_CMPUINT32 ( - err.domain, ==, (uint32_t) MONGOC_ERROR_WRITE_CONCERN); - ASSERT_MATCH (&reply, - "{'deletedCount': 1," - " 'writeErrors': {'$exists': false}," - " 'writeConcernErrors': {'$exists': true}" - "}"); - } - bson_destroy (&reply); - ASSERT_CMPINT (ctx.commands_tested, ==, 5); - } - - /* Test deleting with collation. */ - ctx.expected_command = "{'delete': 'coll'}"; - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 1, 'x': 11}"), NULL, NULL, &err); - ASSERT_OR_PRINT (ret, err); - - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 2, 'x': 'ping'}"), NULL, NULL, &err); - ASSERT_OR_PRINT (ret, err); - - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'_id': 3, 'x': 'pINg'}"), NULL, NULL, &err); - ASSERT_OR_PRINT (ret, err); - - ret = fn (coll, - tmp_bson ("{'x': 'PING'}"), - tmp_bson ("{'collation': {'locale': 'en_US', 'strength': 2 }}"), - &reply, - &err); - - ASSERT_OR_PRINT (ret, err); - if (is_multi) { - ASSERT_MATCH (&reply, "{'deletedCount': 2}"); - } else { - ASSERT_MATCH (&reply, "{'deletedCount': 1}"); - } - bson_destroy (&reply); - - _test_no_docs_match (coll, "{'_id': 2}"); - - bson_destroy (&opts_with_wc); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_write_concern_destroy (wc); - mongoc_write_concern_destroy (wc2); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -typedef future_t *(*future_delete_fn_t) (mongoc_collection_t *, - const bson_t *, - const bson_t *, - bson_t *, - bson_error_t *); - -static void -_test_delete_collation (bool is_multi) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - future_t *future; - request_t *request; - bson_error_t error; - future_delete_fn_t fn = - is_multi ? future_collection_delete_many : future_collection_delete_one; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - future = fn (collection, - tmp_bson ("{}"), - tmp_bson ("{'collation': {'locale': 'en'}}"), - NULL, - &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'delete': 'collection'}"), - tmp_bson ("{'q': {}, 'limit': %d, 'collation': {'locale': 'en'}}", - is_multi ? 0 : 1)); - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - request_destroy (request); - - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_delete_one_or_many (void) -{ - _test_delete_one_or_many (true); - _test_delete_one_or_many (false); -} - -static void -test_delete_collation (void) -{ - _test_delete_collation (true); - _test_delete_collation (false); -} - -typedef future_t *(*future_update_fn_t) (mongoc_collection_t *, - const bson_t *, - const bson_t *, - const bson_t *, - bson_t *, - bson_error_t *); -static void -_test_update_or_replace_with_collation (bool is_replace, bool is_multi) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - future_t *future; - request_t *request; - bson_error_t error; - future_update_fn_t fn; - - if (is_replace) { - BSON_ASSERT (!is_multi); - fn = future_collection_replace_one; - } else { - fn = is_multi ? future_collection_update_many - : future_collection_update_one; - } - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - future = fn (collection, - tmp_bson ("{}"), - tmp_bson ("{}"), - tmp_bson ("{'collation': {'locale': 'en'}}"), - NULL, - &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'update': 'collection'}"), - tmp_bson ("{'q': {}, 'u': {}, 'collation': {'locale': 'en'}%s}", - is_multi ? ", 'multi': true" : "")); - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - request_destroy (request); - - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_update_collation (void) -{ - _test_update_or_replace_with_collation (false, false); - _test_update_or_replace_with_collation (false, true); - _test_update_or_replace_with_collation (true, false); -} - - -static void -_test_update_hint (bool is_replace, bool is_multi, const char *hint) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - future_t *future; - request_t *request; - bson_error_t error; - future_update_fn_t fn; - - if (is_replace) { - BSON_ASSERT (!is_multi); - fn = future_collection_replace_one; - } else { - fn = is_multi ? future_collection_update_many - : future_collection_update_one; - } - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - future = fn (collection, - tmp_bson ("{}"), - tmp_bson ("{}"), - tmp_bson ("{'hint': %s}", hint), - NULL, - &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'update': 'collection'}"), - tmp_bson ("{'q': {}, 'u': {}, 'hint': %s %s }", - hint, - is_multi ? ", 'multi': true" : "")); - - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - request_destroy (request); - - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_update_hint (void) -{ - _test_update_hint (false, false, "'_id_'"); - _test_update_hint (false, true, "'_id_'"); - _test_update_hint (true, false, "'_id_'"); - - _test_update_hint (false, false, "{'_id': 1}"); - _test_update_hint (false, true, "{'_id': 1}"); - _test_update_hint (true, false, "{'_id': 1}"); -} - -static void -test_update_hint_validate (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - bool r; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - collection = get_test_collection (client, "test_update_hint_validation"); - r = mongoc_collection_update_one (collection, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'x': 1}}"), - tmp_bson ("{'hint': 1}"), - NULL, - &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The hint option must be a string or document"); - - r = mongoc_collection_update_many (collection, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'x': 1}}"), - tmp_bson ("{'hint': 3.14}"), - NULL, - &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The hint option must be a string or document"); - - r = mongoc_collection_replace_one (collection, - tmp_bson ("{}"), - tmp_bson ("{'x': 1}"), - tmp_bson ("{'hint': []}"), - NULL, - &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The hint option must be a string or document"); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_update_multi (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - unsigned i; - bson_t *bptr[10]; - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_update_multi"); - - (void) mongoc_collection_drop (collection, &error); - - for (i = 0; i < 10; i++) { - bptr[i] = tmp_bson ("{'_id': %d, 'x': 1234}", i); - } - - ASSERT_OR_PRINT ( - mongoc_collection_insert_many ( - collection, (const bson_t **) bptr, 10, NULL, NULL, &error), - error); - - ASSERT_OR_PRINT (mongoc_collection_update (collection, - MONGOC_UPDATE_MULTI_UPDATE, - tmp_bson ("{'_id': {'$gte': 5}}"), - tmp_bson ("{'$inc': {'x': 1}}"), - NULL, - &error), - error); - - _test_docs_in_coll_matches ( - collection, tmp_bson ("{'_id': {'$lt': 5}, 'x': 1234}"), NULL, 5); - _test_docs_in_coll_matches ( - collection, tmp_bson ("{'_id': {'$gte': 5}, 'x': 1235}"), NULL, 5); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_update_upsert (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_update_upsert"); - - (void) mongoc_collection_drop (collection, &error); - - ASSERT_OR_PRINT ( - mongoc_collection_update (collection, - MONGOC_UPDATE_UPSERT, - tmp_bson ("{'_id': 1}"), - tmp_bson ("{'$set': {'x': 1234}}"), - NULL, - &error), - error); - - _test_docs_in_coll_matches ( - collection, tmp_bson ("{'_id': 1, 'x': 1234}"), NULL, 1); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_remove_multi (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - unsigned i; - bson_t *bptr[10]; - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_remove_multi"); - - (void) mongoc_collection_drop (collection, &error); - - for (i = 0; i < 10; i++) { - bptr[i] = tmp_bson ("{'_id': %d, 'x': 1234}", i); - } - - ASSERT_OR_PRINT ( - mongoc_collection_insert_many ( - collection, (const bson_t **) bptr, 10, NULL, NULL, &error), - error); - - ASSERT_OR_PRINT (mongoc_collection_remove (collection, - MONGOC_REMOVE_NONE, - tmp_bson ("{'_id': {'$gte': 8}}"), - NULL, - &error), - error); - - /* mongoc_collection_delete is an alias of mongoc_collection_remove, although - * its flag type differs slightly */ - ASSERT_OR_PRINT (mongoc_collection_delete (collection, - MONGOC_DELETE_NONE, - tmp_bson ("{'_id': {'$lt': 2}}"), - NULL, - &error), - error); - - _test_docs_in_coll_matches (collection, tmp_bson ("{'x': 1234}"), NULL, 6); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -static void -test_fam_no_error_on_retry (void *unused) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_error_t error = {0}; - bool ret; - bson_t reply; - mongoc_find_and_modify_opts_t *opts; - - BSON_UNUSED (unused); - - client = test_framework_new_default_client (); - ret = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'configureFailPoint': 'failCommand', 'mode': {'times': 1}, " - "'data': {'failCommands': ['findAndModify'], 'errorLabels': " - "['RetryableWriteError']}}"), - NULL, - &reply, - &error); - - if (!ret) { - test_error ("configureFailPoint error: %s reply: %s", - error.message, - tmp_json (&reply)); - } - - coll = get_test_collection (client, BSON_FUNC); - opts = mongoc_find_and_modify_opts_new (); - mongoc_find_and_modify_opts_set_update (opts, - tmp_bson ("{'$set': {'x': 2}}")); - bson_destroy (&reply); - ret = mongoc_collection_find_and_modify_with_opts ( - coll, tmp_bson ("{'x': 1}"), opts, &reply, &error); - if (!ret) { - test_error ( - "findAndModify error: %s reply: %s", error.message, tmp_json (&reply)); - } - - if (error.code != 0 || error.domain != 0 || - 0 != strcmp (error.message, "")) { - test_error ("error set, but findAndModify succeeded: code=%" PRIu32 - " domain=%" PRIu32 " message=%s", - error.code, - error.domain, - error.message); - } - - bson_destroy (&reply); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mongoc_find_and_modify_opts_destroy (opts); -} - -static void -test_hint_is_validated_aggregate (void) -{ - bson_error_t error; - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - mongoc_collection_t *collection = - get_test_collection (client, "test_hint_is_validated_aggregate"); - mongoc_cursor_t *cursor = - mongoc_collection_aggregate (collection, - MONGOC_QUERY_NONE, - tmp_bson ("{}"), - tmp_bson ("{'hint': 1}"), - NULL /* read prefs */); - bool has_error = mongoc_cursor_error (cursor, &error); - ASSERT (has_error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The hint option must be a string or document"); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -static void -test_hint_is_validated_countDocuments (void) -{ - bson_error_t error; - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - mongoc_collection_t *collection = - get_test_collection (client, "test_hint_is_validated_countDocuments"); - int64_t got = mongoc_collection_count_documents (collection, - tmp_bson ("{}"), - tmp_bson ("{'hint': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - ASSERT_CMPINT64 (got, ==, -1); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "The hint option must be a string or document"); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -#define ASSERT_INDEX_EXISTS(keys, expect_name) \ - if (1) { \ - bool found = false; \ - mongoc_cursor_t *cursor = \ - mongoc_collection_find_indexes_with_opts (coll, NULL /* opts */); \ - const bson_t *got; \ - while (mongoc_cursor_next (cursor, &got)) { \ - bson_t got_key; \ - const char *got_name = NULL; \ - /* Results have the form: `{ v: 2, key: { x: 1 }, name: 'x_1' }` */ \ - bsonParse ( \ - *got, \ - require (keyWithType ("key", doc), storeDocRef (got_key)), \ - require (keyWithType ("name", utf8), storeStrRef (got_name))); \ - ASSERT_WITH_MSG ( \ - !bsonParseError, "got parse error: %s", bsonParseError); \ - if (bson_equal (&got_key, keys)) { \ - found = true; \ - ASSERT_CMPSTR (got_name, expect_name); \ - } \ - } \ - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); \ - ASSERT_WITH_MSG (found, \ - "could not find expected index for keys: '%s'", \ - tmp_json (keys)); \ - mongoc_cursor_destroy (cursor); \ - } else \ - (void) 0 - -static void -test_create_indexes_with_opts (void) -{ - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll = - get_test_collection (client, "test_create_indexes_with_opts"); - bson_error_t error; - - // Test creating an index. - { - const bson_t *keys = tmp_bson ("{'x': 1}"); - mongoc_index_model_t *im = mongoc_index_model_new (keys, NULL); - bool ok = mongoc_collection_create_indexes_with_opts ( - coll, &im, 1, NULL /* opts */, NULL /* reply */, &error); - ASSERT_OR_PRINT (ok, error); - mongoc_index_model_destroy (im); - ASSERT_INDEX_EXISTS (keys, "x_1"); - } - - // Drop collection to remove previously created index. - ASSERT_OR_PRINT (mongoc_collection_drop (coll, &error), error); - - // Test creating an index uses specified `name`. - { - const bson_t *keys = tmp_bson ("{'x': 1}"); - mongoc_index_model_t *im = - mongoc_index_model_new (keys, tmp_bson ("{'name': 'foobar'}")); - bool ok = mongoc_collection_create_indexes_with_opts ( - coll, &im, 1, NULL /* opts */, NULL /* reply */, &error); - ASSERT_OR_PRINT (ok, error); - mongoc_index_model_destroy (im); - ASSERT_INDEX_EXISTS (keys, "foobar"); - } - - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -static void -test_create_indexes_with_opts_no_retry (void *unused) -{ - BSON_UNUSED (unused); - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll = - get_test_collection (client, "test_create_indexes_with_opts"); - bson_error_t error; - - // Configure failpoint to cause a network error. - { - const char *cmd_str = BSON_STR ({ - "configureFailPoint" : "failCommand", - "mode" : {"times" : 1}, - "data" : {"failCommands" : ["createIndexes"], "closeConnection" : true} - }); - bson_t *failpoint_cmd = - bson_new_from_json ((const uint8_t *) cmd_str, -1, &error); - ASSERT_OR_PRINT (failpoint_cmd, error); - bool ok = mongoc_client_command_simple (client, - "admin", - failpoint_cmd, - NULL /* read_prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - bson_destroy (failpoint_cmd); - } - - // Test creating an index does not retry on network error. - { - const bson_t *keys = tmp_bson ("{'x': 1}"); - mongoc_index_model_t *im = mongoc_index_model_new (keys, NULL); - bool ok = mongoc_collection_create_indexes_with_opts ( - coll, &im, 1, NULL /* opts */, NULL /* reply */, &error); - ASSERT (!ok); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "Failed to send"); - mongoc_index_model_destroy (im); - } - - - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -// Test creating an index with the 'commitQuorum' option results in a driver -// error on Server Version <4.4. -static void -test_create_indexes_with_opts_commitQuorum_pre44 (void *unused) -{ - BSON_UNUSED (unused); - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll = - get_test_collection (client, "test_create_indexes_with_opts"); - bson_error_t error; - - // Create index. - { - const bson_t *keys = tmp_bson ("{'x': 1}"); - mongoc_index_model_t *im = mongoc_index_model_new (keys, NULL); - bool ok = mongoc_collection_create_indexes_with_opts ( - coll, - &im, - 1, - tmp_bson ("{'commitQuorum': 'majority'}"), - NULL /* reply */, - &error); - ASSERT (!ok); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "The selected server does not support the commitQuorum option"); - mongoc_index_model_destroy (im); - } - - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -// Test creating an index with the 'commitQuorum' option succeeds on Server -// Version >=4.4. -static void -test_create_indexes_with_opts_commitQuorum_post44 (void *unused) -{ - BSON_UNUSED (unused); - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll = - get_test_collection (client, "test_create_indexes_with_opts"); - bson_error_t error; - - // Create index. - { - const bson_t *keys = tmp_bson ("{'x': 1}"); - mongoc_index_model_t *im = mongoc_index_model_new (keys, NULL); - bool ok = mongoc_collection_create_indexes_with_opts ( - coll, - &im, - 1, - tmp_bson ("{'commitQuorum': 'majority'}"), - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - mongoc_index_model_destroy (im); - ASSERT_INDEX_EXISTS (keys, "x_1"); - } - - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -#undef ASSERT_INDEX_EXISTS - -void -test_collection_install (TestSuite *suite) -{ - test_aggregate_install (suite); - - TestSuite_AddFull (suite, - "/Collection/aggregate/write_concern", - test_aggregate_w_write_concern, - NULL, - NULL, - TestSuite_CheckLive); - TestSuite_AddFull (suite, - "/Collection/read_prefs_is_valid", - test_read_prefs_is_valid, - NULL, - NULL, - test_framework_skip_if_mongos); - TestSuite_AddLive (suite, "/Collection/insert_many", test_insert_many); - TestSuite_AddLive ( - suite, "/Collection/insert_bulk_empty", test_insert_bulk_empty); - TestSuite_AddLive (suite, "/Collection/copy", test_copy); - TestSuite_AddLive (suite, "/Collection/insert", test_insert); - TestSuite_AddLive ( - suite, "/Collection/insert/null_string", test_insert_null); - TestSuite_AddFull (suite, - "/Collection/insert/oversize", - test_insert_oversize, - NULL, - NULL, - test_framework_skip_if_slow_or_live); - TestSuite_AddMockServerTest ( - suite, "/Collection/insert/keys", test_insert_command_keys); - TestSuite_AddLive (suite, "/Collection/save", test_save); - TestSuite_AddLive (suite, "/Collection/insert/w0", test_insert_w0); - TestSuite_AddLive (suite, "/Collection/update/w0", test_update_w0); - TestSuite_AddLive (suite, "/Collection/remove/w0", test_remove_w0); - TestSuite_AddLive ( - suite, "/Collection/insert_twice/w0", test_insert_twice_w0); - TestSuite_AddLive (suite, "/Collection/index", test_index); - TestSuite_AddLive ( - suite, "/Collection/index_w_write_concern", test_index_w_write_concern); - TestSuite_AddMockServerTest ( - suite, "/Collection/index/collation", test_index_with_collation); - TestSuite_AddLive (suite, "/Collection/index_compound", test_index_compound); - TestSuite_AddFull (suite, - "/Collection/index_geo", - test_index_geo, - NULL, - NULL, - test_framework_skip_if_max_wire_version_more_than_9); - TestSuite_AddLive (suite, "/Collection/index_storage", test_index_storage); - TestSuite_AddLive (suite, "/Collection/regex", test_regex); - TestSuite_AddFull (suite, - "/Collection/decimal128", - test_decimal128, - NULL, - NULL, - skip_unless_server_has_decimal128); - TestSuite_AddLive (suite, "/Collection/update", test_update); - TestSuite_AddFull (suite, - "/Collection/update_pipeline", - test_update_pipeline, - NULL, - NULL, - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddLive (suite, "/Collection/update/multi", test_update_multi); - TestSuite_AddLive (suite, "/Collection/update/upsert", test_update_upsert); - TestSuite_AddFull (suite, - "/Collection/update/oversize", - test_update_oversize, - NULL, - NULL, - test_framework_skip_if_slow_or_live); - TestSuite_AddLive (suite, "/Collection/remove", test_remove); - TestSuite_AddLive (suite, "/Collection/remove/multi", test_remove_multi); - TestSuite_AddFull (suite, - "/Collection/remove/oversize", - test_remove_oversize, - NULL, - NULL, - test_framework_skip_if_slow_or_live); - TestSuite_AddLive (suite, "/Collection/count", test_count); - TestSuite_AddMockServerTest ( - suite, "/Collection/count_with_opts", test_count_with_opts); - TestSuite_AddMockServerTest ( - suite, "/Collection/count/read_pref", test_count_read_pref); - TestSuite_AddMockServerTest ( - suite, "/Collection/count/read_concern", test_count_read_concern); - TestSuite_AddMockServerTest ( - suite, "/Collection/count/collation", test_count_with_collation); - TestSuite_AddFull (suite, - "/Collection/count/read_concern_live", - test_count_read_concern_live, - NULL, - NULL, - mongod_supports_majority_read_concern); - TestSuite_AddLive (suite, "/Collection/drop", test_drop); - TestSuite_AddLive (suite, "/Collection/aggregate", test_aggregate); - TestSuite_AddMockServerTest (suite, - "/Collection/aggregate/inherit/collection", - test_aggregate_inherit_collection); - TestSuite_AddLive ( - suite, "/Collection/aggregate/large", test_aggregate_large); - TestSuite_AddFull (suite, - "/Collection/aggregate/secondary", - test_aggregate_secondary, - NULL, - NULL, - test_framework_skip_if_mongos); - TestSuite_AddMockServerTest (suite, - "/Collection/aggregate/secondary/sharded", - test_aggregate_secondary_sharded); - TestSuite_AddMockServerTest ( - suite, "/Collection/aggregate/read_concern", test_aggregate_read_concern); - TestSuite_AddFull (suite, - "/Collection/aggregate/bypass_document_validation", - test_aggregate_bypass, - NULL, - NULL, - TestSuite_CheckLive); - TestSuite_AddMockServerTest ( - suite, "/Collection/aggregate/collation", test_aggregate_with_collation); - TestSuite_AddMockServerTest ( - suite, "/Collection/aggregate_w_server_id", test_aggregate_w_server_id); - TestSuite_AddMockServerTest (suite, - "/Collection/aggregate_w_server_id/sharded", - test_aggregate_w_server_id_sharded); - TestSuite_AddFull (suite, - "/Collection/aggregate_w_server_id/option", - test_aggregate_server_id_option, - NULL, - NULL, - test_framework_skip_if_auth); - TestSuite_AddFull (suite, - "/Collection/validate", - test_validate, - NULL, - NULL, - test_framework_skip_if_slow_or_live); - TestSuite_AddLive (suite, "/Collection/rename", test_rename); - // The collStats command is deprecated in MongoDB 6.0 (maxWireVersion=17) and - // may be removed in a future major release. - TestSuite_AddFull (suite, - "/Collection/stats", - test_stats, - NULL, - NULL, - test_framework_skip_if_max_wire_version_more_than_17); - TestSuite_AddMockServerTest ( - suite, "/Collection/stats/read_pref", test_stats_read_pref); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_read_concern", test_find_read_concern); - TestSuite_AddFull (suite, - "/Collection/getmore_read_concern_live", - test_getmore_read_concern_live, - NULL, - NULL, - TestSuite_CheckLive); - TestSuite_AddLive ( - suite, "/Collection/find_and_modify", test_find_and_modify); - TestSuite_AddMockServerTest (suite, - "/Collection/find_and_modify/write_concern", - test_find_and_modify_write_concern); - TestSuite_AddFull (suite, - "/Collection/large_return", - test_large_return, - NULL, - NULL, - test_framework_skip_if_slow_or_live); - TestSuite_AddLive (suite, "/Collection/many_return", test_many_return); - TestSuite_AddLive ( - suite, "/Collection/insert_one_validate", test_insert_one_validate); - TestSuite_AddLive ( - suite, "/Collection/insert_many_validate", test_insert_many_validate); - TestSuite_AddMockServerTest (suite, "/Collection/limit", test_find_limit); - TestSuite_AddMockServerTest ( - suite, "/Collection/batch_size", test_find_batch_size); - TestSuite_AddFull (suite, - "/Collection/command_fully_qualified", - test_command_fq, - NULL, - NULL, - test_framework_skip_if_mongos); - TestSuite_AddLive (suite, "/Collection/get_index_info", test_get_index_info); - TestSuite_AddMockServerTest ( - suite, "/Collection/find_indexes/error", test_find_indexes_err); - TestSuite_AddLive ( - suite, "/Collection/insert/duplicate_key", test_insert_duplicate_key); - TestSuite_AddFull (suite, - "/Collection/create_index/fail", - test_create_index_fail, - NULL, - NULL, - test_framework_skip_if_offline); - TestSuite_AddLive (suite, "/Collection/insert_one", test_insert_one); - TestSuite_AddLive ( - suite, "/Collection/update_and_replace", test_update_and_replace); - TestSuite_AddLive ( - suite, "/Collection/array_filters_validate", test_array_filters_validate); - TestSuite_AddLive ( - suite, "/Collection/replace_one_validate", test_replace_one_validate); - TestSuite_AddLive ( - suite, "/Collection/update_one_validate", test_update_one_validate); - TestSuite_AddLive ( - suite, "/Collection/update_many_validate", test_update_many_validate); - TestSuite_AddLive ( - suite, "/Collection/delete_one_or_many", test_delete_one_or_many); - TestSuite_AddMockServerTest ( - suite, "/Collection/delete/collation", test_delete_collation); - TestSuite_AddMockServerTest ( - suite, "/Collection/update/collation", test_update_collation); - TestSuite_AddMockServerTest ( - suite, "/Collection/update/hint", test_update_hint); - TestSuite_AddLive ( - suite, "/Collection/update/hint/validate", test_update_hint_validate); - TestSuite_AddMockServerTest ( - suite, "/Collection/count_documents", test_count_documents); - TestSuite_AddLive ( - suite, "/Collection/count_documents_live", test_count_documents_live); - TestSuite_AddMockServerTest (suite, - "/Collection/estimated_document_count", - test_estimated_document_count); - TestSuite_AddLive (suite, - "/Collection/estimated_document_count_live", - test_estimated_document_count_live); - TestSuite_AddLive ( - suite, "/Collection/insert_bulk_validate", test_insert_bulk_validate); - TestSuite_AddMockServerTest (suite, - "/Collection/aggregate_with_batch_size", - test_aggregate_with_batch_size); - TestSuite_AddFull (suite, - "/Collection/fam/no_error_on_retry", - test_fam_no_error_on_retry, - NULL, - NULL, - test_framework_skip_if_no_failpoint, - test_framework_skip_if_max_wire_version_more_than_9); - TestSuite_AddLive (suite, - "/Collection/hint_is_validated/aggregate", - test_hint_is_validated_aggregate); - TestSuite_AddLive (suite, - "/Collection/hint_is_validated/countDocuments", - test_hint_is_validated_countDocuments); - TestSuite_AddLive (suite, - "/Collection/create_indexes_with_opts", - test_create_indexes_with_opts); - TestSuite_AddFull ( - suite, - "/Collection/create_indexes_with_opts/commitQuorum/pre44", - test_create_indexes_with_opts_commitQuorum_pre44, - NULL /* _dtor */, - NULL /* _ctx */, - // commitQuorum option is not available on standalone servers. - test_framework_skip_if_not_replset, - // Server Version 4.4 has Wire Version 9. - test_framework_skip_if_max_wire_version_more_than_8); - TestSuite_AddFull ( - suite, - "/Collection/create_indexes_with_opts/commitQuorum/post44", - test_create_indexes_with_opts_commitQuorum_post44, - NULL /* _dtor */, - NULL /* _ctx */, - // commitQuorum option is not available on standalone servers. - test_framework_skip_if_not_replset, - // Server Version 4.4 has Wire Version 9. - test_framework_skip_if_max_wire_version_less_than_9); - TestSuite_AddFull (suite, - "/Collection/create_indexes_with_opts/no_retry", - test_create_indexes_with_opts_no_retry, - NULL /* _dtor */, - NULL /* _ctx */, - // requires failpoint - test_framework_skip_if_no_failpoint); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-command-monitoring.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-command-monitoring.c deleted file mode 100644 index 4326263d5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-command-monitoring.c +++ /dev/null @@ -1,1426 +0,0 @@ -#include -#include -#include - -#include "json-test.h" -#include "test-libmongoc.h" -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "json-test-operations.h" -#include "unified/runner.h" - - -const char * -first_key (const bson_t *bson) -{ - bson_iter_t iter; - - BSON_ASSERT (bson_iter_init (&iter, bson)); - if (!bson_iter_next (&iter)) { - return NULL; - } - - return bson_iter_key (&iter); -} - - -void -check_operation_ids (const bson_t *events) -{ - bson_iter_t iter; - int64_t first_operation_id = -1; - int64_t operation_id; - bson_t event; - - /* check op ids of events like {command_started_event: {operation_id: N}} */ - BSON_ASSERT (bson_iter_init (&iter, events)); - while (bson_iter_next (&iter)) { - bson_iter_bson (&iter, &event); - if (!strcmp (first_key (&event), "command_started_event")) { - operation_id = - bson_lookup_int64 (&event, "command_started_event.operation_id"); - - if (first_operation_id == -1) { - first_operation_id = operation_id; - } else if (operation_id != first_operation_id) { - test_error ( - "%s sent wrong operation_id", - bson_lookup_utf8 (&event, "command_started_event.command_name")); - } - } - } -} - - -static bool -command_monitoring_test_run_operation (json_test_ctx_t *ctx, - const bson_t *test, - const bson_t *operation) -{ - bson_t reply; - bool res; - - /* Command Monitoring tests don't use explicit session */ - res = - json_test_operation (ctx, test, operation, ctx->collection, NULL, &reply); - - bson_destroy (&reply); - - return res; -} - - -/* - *----------------------------------------------------------------------- - * - * test_command_monitoring_cb -- - * - * Runs the JSON tests included with the Command Monitoring spec. - * - *----------------------------------------------------------------------- - */ - -static void -test_command_monitoring_cb (bson_t *scenario) -{ - json_test_config_t config = JSON_TEST_CONFIG_INIT; - config.run_operation_cb = command_monitoring_test_run_operation; - config.scenario = scenario; - config.events_check_cb = check_operation_ids; - run_json_general_test (&config); - json_test_config_cleanup (&config); -} - - -/* - *----------------------------------------------------------------------- - * - * Runner for the JSON tests for command monitoring. - * - *----------------------------------------------------------------------- - */ -static void -test_all_spec_tests (TestSuite *suite) -{ - run_unified_tests (suite, JSON_DIR, "command_monitoring/unified"); - install_json_test_suite (suite, - JSON_DIR, - "command_monitoring/legacy", - &test_command_monitoring_cb); -} - - -static void -test_get_error_failed_cb (const mongoc_apm_command_failed_t *event) -{ - bson_error_t *error; - - error = (bson_error_t *) mongoc_apm_command_failed_get_context (event); - mongoc_apm_command_failed_get_error (event, error); -} - - -static void -test_get_error (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_apm_callbacks_t *callbacks; - future_t *future; - request_t *request; - bson_error_t error = {0}; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_failed_cb (callbacks, test_get_error_failed_cb); - mongoc_client_set_apm_callbacks (client, callbacks, (void *) &error); - future = future_client_command_simple ( - client, "db", tmp_bson ("{'foo': 1}"), NULL, NULL, NULL); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'foo': 1}")); - reply_to_request_simple (request, "{'ok': 0, 'errmsg': 'foo', 'code': 42}"); - ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_QUERY, 42, "foo"); - - future_destroy (future); - request_destroy (request); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -insert_200_docs (mongoc_collection_t *collection) -{ - int i; - bson_t *doc; - bool r; - bson_error_t error; - - /* insert 200 docs so we have a couple batches */ - doc = tmp_bson (NULL); - for (i = 0; i < 200; i++) { - r = mongoc_collection_insert_one (collection, doc, NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - } -} - - -static void -increment (const mongoc_apm_command_started_t *event) -{ - int *i = (int *) mongoc_apm_command_started_get_context (event); - - ++(*i); -} - - -static mongoc_apm_callbacks_t * -increment_callbacks (void) -{ - mongoc_apm_callbacks_t *callbacks; - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, increment); - - return callbacks; -} - - -static void -decrement (const mongoc_apm_command_started_t *event) -{ - int *i = (int *) mongoc_apm_command_started_get_context (event); - - --(*i); -} - - -static mongoc_apm_callbacks_t * -decrement_callbacks (void) -{ - mongoc_apm_callbacks_t *callbacks; - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, decrement); - - return callbacks; -} - - -static void -test_change_callbacks (void) -{ - mongoc_apm_callbacks_t *inc_callbacks; - mongoc_apm_callbacks_t *dec_callbacks; - int incremented = 0; - int decremented = 0; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - mongoc_cursor_t *cursor; - const bson_t *b; - - inc_callbacks = increment_callbacks (); - dec_callbacks = decrement_callbacks (); - - client = test_framework_new_default_client (); - mongoc_client_set_apm_callbacks (client, inc_callbacks, &incremented); - - collection = get_test_collection (client, "test_change_callbacks"); - - insert_200_docs (collection); - ASSERT_CMPINT (incremented, ==, 200); - - mongoc_client_set_apm_callbacks (client, dec_callbacks, &decremented); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson (NULL), NULL, NULL); - - ASSERT (mongoc_cursor_next (cursor, &b)); - ASSERT_CMPINT (decremented, ==, -1); - - mongoc_client_set_apm_callbacks (client, inc_callbacks, &incremented); - while (mongoc_cursor_next (cursor, &b)) { - } - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT_CMPINT (incremented, ==, 201); - - mongoc_collection_drop (collection, NULL); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mongoc_apm_callbacks_destroy (inc_callbacks); - mongoc_apm_callbacks_destroy (dec_callbacks); -} - - -static void -test_reset_callbacks (void) -{ - mongoc_apm_callbacks_t *inc_callbacks; - mongoc_apm_callbacks_t *dec_callbacks; - int incremented = 0; - int decremented = 0; - mongoc_client_t *client; - mongoc_collection_t *collection; - bool r; - bson_t *cmd; - bson_t cmd_reply; - bson_error_t error; - mongoc_server_description_t *sd; - mongoc_cursor_t *cursor; - const bson_t *b; - - inc_callbacks = increment_callbacks (); - dec_callbacks = decrement_callbacks (); - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_reset_apm_callbacks"); - - /* insert 200 docs so we have a couple batches */ - insert_200_docs (collection); - - mongoc_client_set_apm_callbacks (client, inc_callbacks, &incremented); - cmd = tmp_bson ("{'aggregate': '%s', 'pipeline': [], 'cursor': {}}", - collection->collection); - - sd = - mongoc_client_select_server (client, true /* for writes */, NULL, &error); - ASSERT_OR_PRINT (sd, error); - - r = mongoc_client_read_command_with_opts ( - client, - "test", - cmd, - NULL, - tmp_bson ("{'serverId': %d}", sd->id), - &cmd_reply, - &error); - - ASSERT_OR_PRINT (r, error); - ASSERT_CMPINT (incremented, ==, 1); - - /* reset callbacks */ - mongoc_client_set_apm_callbacks (client, NULL, NULL); - /* destroys cmd_reply */ - cursor = mongoc_cursor_new_from_command_reply (client, &cmd_reply, sd->id); - ASSERT (mongoc_cursor_next (cursor, &b)); - ASSERT_CMPINT (incremented, ==, 1); /* same value as before */ - - mongoc_client_set_apm_callbacks (client, dec_callbacks, &decremented); - while (mongoc_cursor_next (cursor, &b)) { - } - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT_CMPINT (decremented, ==, -1); - - mongoc_collection_drop (collection, NULL); - - mongoc_cursor_destroy (cursor); - mongoc_server_description_destroy (sd); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mongoc_apm_callbacks_destroy (inc_callbacks); - mongoc_apm_callbacks_destroy (dec_callbacks); -} - - -static void -test_set_callbacks_cb (const mongoc_apm_command_started_t *event) -{ - int *n_calls = (int *) mongoc_apm_command_started_get_context (event); - - (*n_calls)++; -} - - -static void -_test_set_callbacks (bool pooled, bool try_pop) -{ - mongoc_client_t *client; - mongoc_client_pool_t *pool = NULL; - mongoc_apm_callbacks_t *callbacks; - int n_calls = 0; - bson_error_t error; - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, test_set_callbacks_cb); - - if (pooled) { - pool = test_framework_new_default_client_pool (); - ASSERT (mongoc_client_pool_set_apm_callbacks ( - pool, callbacks, (void *) &n_calls)); - if (try_pop) { - client = mongoc_client_pool_try_pop (pool); - } else { - client = mongoc_client_pool_pop (pool); - } - } else { - client = test_framework_new_default_client (); - ASSERT (mongoc_client_set_apm_callbacks ( - client, callbacks, (void *) &n_calls)); - } - - ASSERT_OR_PRINT ( - mongoc_client_read_command_with_opts ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL, &error), - error); - ASSERT_CMPINT (1, ==, n_calls); - - capture_logs (true); - - if (pooled) { - ASSERT ( - !mongoc_client_pool_set_apm_callbacks (pool, NULL, (void *) &n_calls)); - ASSERT_CAPTURED_LOG ("mongoc_client_pool_set_apm_callbacks", - MONGOC_LOG_LEVEL_ERROR, - "Can only set callbacks once"); - - clear_captured_logs (); - ASSERT ( - !mongoc_client_set_apm_callbacks (client, NULL, (void *) &n_calls)); - ASSERT_CAPTURED_LOG ("mongoc_client_pool_set_apm_callbacks", - MONGOC_LOG_LEVEL_ERROR, - "Cannot set callbacks on a pooled client"); - } else { - /* repeated calls ok, null is ok */ - ASSERT (mongoc_client_set_apm_callbacks (client, NULL, NULL)); - } - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_apm_callbacks_destroy (callbacks); -} - - -static void -test_set_callbacks_single (void) -{ - _test_set_callbacks (false, false); -} - - -static void -test_set_callbacks_pooled (void) -{ - _test_set_callbacks (true, false); -} - -static void -test_set_callbacks_pooled_try_pop (void) -{ - _test_set_callbacks (true, true); -} - - -typedef struct { - int64_t request_id; - int64_t op_id; -} ids_t; - - -typedef struct { - mongoc_array_t started_ids; - mongoc_array_t succeeded_ids; - mongoc_array_t failed_ids; - int started_calls; - int succeeded_calls; - int failed_calls; -} op_id_test_t; - - -static void -op_id_test_init (op_id_test_t *test) -{ - _mongoc_array_init (&test->started_ids, sizeof (ids_t)); - _mongoc_array_init (&test->succeeded_ids, sizeof (ids_t)); - _mongoc_array_init (&test->failed_ids, sizeof (ids_t)); - - test->started_calls = 0; - test->succeeded_calls = 0; - test->failed_calls = 0; -} - - -static void -op_id_test_cleanup (op_id_test_t *test) -{ - _mongoc_array_destroy (&test->started_ids); - _mongoc_array_destroy (&test->succeeded_ids); - _mongoc_array_destroy (&test->failed_ids); -} - - -static void -test_op_id_started_cb (const mongoc_apm_command_started_t *event) -{ - op_id_test_t *test; - ids_t ids; - - test = (op_id_test_t *) mongoc_apm_command_started_get_context (event); - ids.request_id = mongoc_apm_command_started_get_request_id (event); - ids.op_id = mongoc_apm_command_started_get_operation_id (event); - - _mongoc_array_append_val (&test->started_ids, ids); - - test->started_calls++; -} - - -static void -test_op_id_succeeded_cb (const mongoc_apm_command_succeeded_t *event) -{ - op_id_test_t *test; - ids_t ids; - - test = (op_id_test_t *) mongoc_apm_command_succeeded_get_context (event); - ids.request_id = mongoc_apm_command_succeeded_get_request_id (event); - ids.op_id = mongoc_apm_command_succeeded_get_operation_id (event); - - _mongoc_array_append_val (&test->succeeded_ids, ids); - - test->succeeded_calls++; -} - - -static void -test_op_id_failed_cb (const mongoc_apm_command_failed_t *event) -{ - op_id_test_t *test; - ids_t ids; - - test = (op_id_test_t *) mongoc_apm_command_failed_get_context (event); - ids.request_id = mongoc_apm_command_failed_get_request_id (event); - ids.op_id = mongoc_apm_command_failed_get_operation_id (event); - - _mongoc_array_append_val (&test->failed_ids, ids); - - test->failed_calls++; -} - - -#define REQUEST_ID(_event_type, _index) \ - _mongoc_array_index (&test._event_type##_ids, ids_t, _index).request_id - -#define OP_ID(_event_type, _index) \ - _mongoc_array_index (&test._event_type##_ids, ids_t, _index).op_id - -static void -_test_bulk_operation_id (bool pooled, bool use_bulk_operation_new) -{ - mongoc_client_t *client; - mongoc_client_pool_t *pool = NULL; - mongoc_apm_callbacks_t *callbacks; - mongoc_collection_t *collection; - bson_t opts = BSON_INITIALIZER; - mongoc_bulk_operation_t *bulk; - bson_error_t error; - op_id_test_t test; - int64_t op_id; - - op_id_test_init (&test); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, test_op_id_started_cb); - mongoc_apm_set_command_succeeded_cb (callbacks, test_op_id_succeeded_cb); - mongoc_apm_set_command_failed_cb (callbacks, test_op_id_failed_cb); - - if (pooled) { - pool = test_framework_new_default_client_pool (); - ASSERT (mongoc_client_pool_set_apm_callbacks ( - pool, callbacks, (void *) &test)); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - ASSERT ( - mongoc_client_set_apm_callbacks (client, callbacks, (void *) &test)); - } - - collection = get_test_collection (client, "test_bulk_operation_id"); - if (use_bulk_operation_new) { - bulk = mongoc_bulk_operation_new (false); - mongoc_bulk_operation_set_client (bulk, client); - mongoc_bulk_operation_set_database (bulk, collection->db); - mongoc_bulk_operation_set_collection (bulk, collection->collection); - } else { - bson_append_bool (&opts, "ordered", 7, false); - bulk = - mongoc_collection_create_bulk_operation_with_opts (collection, &opts); - } - - mongoc_bulk_operation_insert (bulk, tmp_bson ("{'_id': 1}")); - mongoc_bulk_operation_update_one ( - bulk, tmp_bson ("{'_id': 1}"), tmp_bson ("{'$set': {'x': 1}}"), false); - mongoc_bulk_operation_remove (bulk, tmp_bson ("{}")); - - /* ensure we monitor with bulk->operation_id, not cluster->operation_id */ - client->cluster.operation_id = 42; - - /* write errors don't trigger failed events, so we only test success */ - ASSERT_OR_PRINT (mongoc_bulk_operation_execute (bulk, NULL, &error), error); - ASSERT_CMPINT (test.started_calls, ==, 3); - ASSERT_CMPINT (test.succeeded_calls, ==, 3); - - ASSERT_CMPINT64 (REQUEST_ID (started, 0), ==, REQUEST_ID (succeeded, 0)); - ASSERT_CMPINT64 (REQUEST_ID (started, 1), ==, REQUEST_ID (succeeded, 1)); - ASSERT_CMPINT64 (REQUEST_ID (started, 2), ==, REQUEST_ID (succeeded, 2)); - - /* 3 unique request ids */ - ASSERT_CMPINT64 (REQUEST_ID (started, 0), !=, REQUEST_ID (started, 1)); - ASSERT_CMPINT64 (REQUEST_ID (started, 0), !=, REQUEST_ID (started, 2)); - ASSERT_CMPINT64 (REQUEST_ID (started, 1), !=, REQUEST_ID (started, 2)); - ASSERT_CMPINT64 (REQUEST_ID (succeeded, 0), !=, REQUEST_ID (succeeded, 1)); - ASSERT_CMPINT64 (REQUEST_ID (succeeded, 0), !=, REQUEST_ID (succeeded, 2)); - ASSERT_CMPINT64 (REQUEST_ID (succeeded, 1), !=, REQUEST_ID (succeeded, 2)); - - /* events' operation ids all equal bulk->operation_id */ - op_id = bulk->operation_id; - ASSERT_CMPINT64 (op_id, !=, (int64_t) 0); - ASSERT_CMPINT64 (op_id, ==, OP_ID (started, 0)); - ASSERT_CMPINT64 (op_id, ==, OP_ID (started, 1)); - ASSERT_CMPINT64 (op_id, ==, OP_ID (started, 2)); - ASSERT_CMPINT64 (op_id, ==, OP_ID (succeeded, 0)); - ASSERT_CMPINT64 (op_id, ==, OP_ID (succeeded, 1)); - ASSERT_CMPINT64 (op_id, ==, OP_ID (succeeded, 2)); - - mongoc_bulk_operation_destroy (bulk); - mongoc_collection_destroy (collection); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - bson_destroy (&opts); - op_id_test_cleanup (&test); - mongoc_apm_callbacks_destroy (callbacks); -} - - -static void -test_collection_bulk_op_single (void) -{ - _test_bulk_operation_id (false, false); -} - - -static void -test_collection_bulk_op_pooled (void) -{ - _test_bulk_operation_id (true, false); -} - - -static void -test_bulk_op_single (void) -{ - _test_bulk_operation_id (false, true); -} - - -static void -test_bulk_op_pooled (void) -{ - _test_bulk_operation_id (true, true); -} - - -static void -_test_query_operation_id (bool pooled) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_client_pool_t *pool = NULL; - mongoc_apm_callbacks_t *callbacks; - mongoc_collection_t *collection; - op_id_test_t test; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - int64_t op_id; - - op_id_test_init (&test); - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, test_op_id_started_cb); - mongoc_apm_set_command_succeeded_cb (callbacks, test_op_id_succeeded_cb); - mongoc_apm_set_command_failed_cb (callbacks, test_op_id_failed_cb); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri ( - mock_server_get_uri (server), NULL); - ASSERT (mongoc_client_pool_set_apm_callbacks ( - pool, callbacks, (void *) &test)); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (mock_server_get_uri (server), - NULL); - ASSERT ( - mongoc_client_set_apm_callbacks (client, callbacks, (void *) &test)); - } - - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 1, tmp_bson ("{}"), NULL, NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_request (server); - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '123'}," - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}")); - - ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - - ASSERT_CMPINT (test.started_calls, ==, 1); - ASSERT_CMPINT (test.succeeded_calls, ==, 1); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_request (server); - reply_to_request_simple (request, "{'ok': 0, 'code': 42, 'errmsg': 'bad!'}"); - - ASSERT (!future_get_bool (future)); - future_destroy (future); - request_destroy (request); - - ASSERT_CMPINT (test.started_calls, ==, 2); - ASSERT_CMPINT (test.succeeded_calls, ==, 1); - ASSERT_CMPINT (test.failed_calls, ==, 1); - - ASSERT_CMPINT64 (REQUEST_ID (started, 0), ==, REQUEST_ID (succeeded, 0)); - ASSERT_CMPINT64 (REQUEST_ID (started, 1), ==, REQUEST_ID (failed, 0)); - - /* unique request ids */ - ASSERT_CMPINT64 (REQUEST_ID (started, 0), !=, REQUEST_ID (started, 1)); - - /* operation ids all the same */ - op_id = OP_ID (started, 0); - ASSERT_CMPINT64 (op_id, !=, (int64_t) 0); - ASSERT_CMPINT64 (op_id, ==, OP_ID (started, 1)); - ASSERT_CMPINT64 (op_id, ==, OP_ID (failed, 0)); - - mock_server_destroy (server); - - /* client logs warning because it can't send killCursors or endSessions */ - capture_logs (true); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - op_id_test_cleanup (&test); - mongoc_apm_callbacks_destroy (callbacks); -} - - -static void -test_query_operation_id_single_cmd (void) -{ - _test_query_operation_id (false); -} - - -static void -test_query_operation_id_pooled_cmd (void) -{ - _test_query_operation_id (true); -} - -typedef struct { - int started_calls; - int succeeded_calls; - int failed_calls; - char db[100]; - char cmd_name[100]; - bson_t cmd; -} cmd_test_t; - - -static void -cmd_test_init (cmd_test_t *test) -{ - memset (test, 0, sizeof *test); - bson_init (&test->cmd); -} - - -static void -cmd_test_cleanup (cmd_test_t *test) -{ - bson_destroy (&test->cmd); -} - - -static void -cmd_started_cb (const mongoc_apm_command_started_t *event) -{ - cmd_test_t *test; - - if (!strcmp (mongoc_apm_command_started_get_command_name (event), - "endSessions")) { - /* the test is ending */ - return; - } - - test = (cmd_test_t *) mongoc_apm_command_started_get_context (event); - test->started_calls++; - bson_destroy (&test->cmd); - bson_strncpy (test->db, - mongoc_apm_command_started_get_database_name (event), - sizeof (test->db)); - bson_copy_to (mongoc_apm_command_started_get_command (event), &test->cmd); - bson_strncpy (test->cmd_name, - mongoc_apm_command_started_get_command_name (event), - sizeof (test->cmd_name)); -} - - -static void -cmd_succeeded_cb (const mongoc_apm_command_succeeded_t *event) -{ - cmd_test_t *test; - int64_t duration; - - if (!strcmp (mongoc_apm_command_succeeded_get_command_name (event), - "endSessions")) { - return; - } - - test = (cmd_test_t *) mongoc_apm_command_succeeded_get_context (event); - test->succeeded_calls++; - ASSERT_CMPSTR (test->cmd_name, - mongoc_apm_command_succeeded_get_command_name (event)); - - duration = mongoc_apm_command_succeeded_get_duration (event); - ASSERT_CMPINT64 (duration, >=, (int64_t) 0); - ASSERT_CMPINT64 (duration, <=, (int64_t) 10000000); /* ten seconds */ -} - - -static void -cmd_failed_cb (const mongoc_apm_command_failed_t *event) -{ - cmd_test_t *test; - int64_t duration; - - test = (cmd_test_t *) mongoc_apm_command_failed_get_context (event); - test->failed_calls++; - ASSERT_CMPSTR (test->cmd_name, - mongoc_apm_command_failed_get_command_name (event)); - - duration = mongoc_apm_command_failed_get_duration (event); - ASSERT_CMPINT64 (duration, >=, (int64_t) 0); - ASSERT_CMPINT64 (duration, <=, (int64_t) 10000000); /* ten seconds */ -} - - -static void -set_cmd_test_callbacks (mongoc_client_t *client, void *context) -{ - mongoc_apm_callbacks_t *callbacks; - - ASSERT (client); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, cmd_started_cb); - mongoc_apm_set_command_succeeded_cb (callbacks, cmd_succeeded_cb); - mongoc_apm_set_command_failed_cb (callbacks, cmd_failed_cb); - ASSERT (mongoc_client_set_apm_callbacks (client, callbacks, context)); - mongoc_apm_callbacks_destroy (callbacks); -} - - -static void -test_client_cmd (void) -{ - cmd_test_t test; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - const bson_t *reply; - - cmd_test_init (&test); - client = test_framework_new_default_client (); - set_cmd_test_callbacks (client, (void *) &test); - cursor = mongoc_client_command (client, - "admin", - MONGOC_QUERY_SECONDARY_OK, - 0, - 0, - 0, - tmp_bson ("{'ping': 1}"), - NULL, - NULL); - - ASSERT (mongoc_cursor_next (cursor, &reply)); - ASSERT_CMPSTR (test.cmd_name, "ping"); - ASSERT_MATCH (&test.cmd, "{'ping': 1}"); - ASSERT_CMPSTR (test.db, "admin"); - ASSERT_CMPINT (1, ==, test.started_calls); - ASSERT_CMPINT (1, ==, test.succeeded_calls); - ASSERT_CMPINT (0, ==, test.failed_calls); - - cmd_test_cleanup (&test); - mongoc_cursor_destroy (cursor); - - cmd_test_init (&test); - cursor = mongoc_client_command (client, - "admin", - MONGOC_QUERY_SECONDARY_OK, - 0, - 0, - 0, - tmp_bson ("{'foo': 1}"), - NULL, - NULL); - - ASSERT (!mongoc_cursor_next (cursor, &reply)); - ASSERT_CMPSTR (test.cmd_name, "foo"); - ASSERT_MATCH (&test.cmd, "{'foo': 1}"); - ASSERT_CMPSTR (test.db, "admin"); - ASSERT_CMPINT (1, ==, test.started_calls); - ASSERT_CMPINT (0, ==, test.succeeded_calls); - ASSERT_CMPINT (1, ==, test.failed_calls); - - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); - cmd_test_cleanup (&test); -} - - -static void -test_client_cmd_simple (void) -{ - cmd_test_t test; - mongoc_client_t *client; - bool r; - bson_error_t error; - - cmd_test_init (&test); - client = test_framework_new_default_client (); - set_cmd_test_callbacks (client, (void *) &test); - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - ASSERT_CMPSTR (test.cmd_name, "ping"); - ASSERT_MATCH (&test.cmd, "{'ping': 1}"); - ASSERT_CMPSTR (test.db, "admin"); - ASSERT_CMPINT (1, ==, test.started_calls); - ASSERT_CMPINT (1, ==, test.succeeded_calls); - ASSERT_CMPINT (0, ==, test.failed_calls); - - cmd_test_cleanup (&test); - cmd_test_init (&test); - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'foo': 1}"), NULL, NULL, &error); - - ASSERT (!r); - ASSERT_CMPSTR (test.cmd_name, "foo"); - ASSERT_MATCH (&test.cmd, "{'foo': 1}"); - ASSERT_CMPSTR (test.db, "admin"); - ASSERT_CMPINT (1, ==, test.started_calls); - ASSERT_CMPINT (0, ==, test.succeeded_calls); - ASSERT_CMPINT (1, ==, test.failed_calls); - - mongoc_client_destroy (client); - cmd_test_cleanup (&test); -} - - -static void -test_client_cmd_op_ids (void) -{ - op_id_test_t test; - mongoc_client_t *client; - mongoc_apm_callbacks_t *callbacks; - bool r; - bson_error_t error; - int64_t op_id; - - op_id_test_init (&test); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, test_op_id_started_cb); - mongoc_apm_set_command_succeeded_cb (callbacks, test_op_id_succeeded_cb); - mongoc_apm_set_command_failed_cb (callbacks, test_op_id_failed_cb); - - client = test_framework_new_default_client (); - mongoc_client_set_apm_callbacks (client, callbacks, (void *) &test); - - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - ASSERT_CMPINT (1, ==, test.started_calls); - ASSERT_CMPINT (1, ==, test.succeeded_calls); - ASSERT_CMPINT (0, ==, test.failed_calls); - ASSERT_CMPINT64 (REQUEST_ID (started, 0), ==, REQUEST_ID (succeeded, 0)); - ASSERT_CMPINT64 (OP_ID (started, 0), ==, OP_ID (succeeded, 0)); - op_id = OP_ID (started, 0); - ASSERT_CMPINT64 (op_id, !=, (int64_t) 0); - - op_id_test_cleanup (&test); - op_id_test_init (&test); - - /* again. test that we use a new op_id. */ - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - ASSERT_CMPINT (1, ==, test.started_calls); - ASSERT_CMPINT (1, ==, test.succeeded_calls); - ASSERT_CMPINT (0, ==, test.failed_calls); - ASSERT_CMPINT64 (REQUEST_ID (started, 0), ==, REQUEST_ID (succeeded, 0)); - ASSERT_CMPINT64 (OP_ID (started, 0), ==, OP_ID (succeeded, 0)); - ASSERT_CMPINT64 (OP_ID (started, 0), !=, (int64_t) 0); - - /* new op_id */ - ASSERT_CMPINT64 (OP_ID (started, 0), !=, op_id); - - mongoc_client_destroy (client); - op_id_test_cleanup (&test); - mongoc_apm_callbacks_destroy (callbacks); -} - - -static void -test_killcursors_deprecated (void *unused) -{ - cmd_test_t test; - mongoc_client_t *client; - bool r; - bson_error_t error; - - BSON_UNUSED (unused); - - cmd_test_init (&test); - client = test_framework_new_default_client (); - - /* connect */ - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - set_cmd_test_callbacks (client, (void *) &test); - - /* deprecated function without "db" or "collection", skips APM. This sends - * OP_KILL_CURSORS. */ - mongoc_client_kill_cursor (client, 123); - - ASSERT_CMPINT (0, ==, test.started_calls); - ASSERT_CMPINT (0, ==, test.succeeded_calls); - ASSERT_CMPINT (0, ==, test.failed_calls); - - mongoc_client_destroy (client); - cmd_test_cleanup (&test); -} - - -typedef struct { - int failed_calls; - bson_t reply; -} cmd_failed_reply_test_t; - - -static void -cmd_failed_reply_test_init (cmd_failed_reply_test_t *test) -{ - memset (test, 0, sizeof *test); - bson_init (&test->reply); -} - - -static void -cmd_failed_reply_test_cleanup (cmd_failed_reply_test_t *test) -{ - bson_destroy (&test->reply); -} - - -static void -command_failed_reply_command_failed_cb ( - const mongoc_apm_command_failed_t *event) -{ - cmd_failed_reply_test_t *test; - - test = - (cmd_failed_reply_test_t *) mongoc_apm_command_failed_get_context (event); - test->failed_calls++; - bson_destroy (&test->reply); - - bson_copy_to (mongoc_apm_command_failed_get_reply (event), &test->reply); -} - - -static void -test_command_failed_reply_mock (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_apm_callbacks_t *callbacks; - mongoc_collection_t *collection; - cmd_failed_reply_test_t test; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - - /* test that the command_failed_event's reply is the same as a mocked reply - */ - cmd_failed_reply_test_init (&test); - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_failed_cb (callbacks, - command_failed_reply_command_failed_cb); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - ASSERT (mongoc_client_set_apm_callbacks (client, callbacks, (void *) &test)); - - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 1, tmp_bson ("{}"), NULL, NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_request (server); - reply_to_request_simple (request, "{'ok': 0, 'code': 42, 'errmsg': 'bad!'}"); - - ASSERT (!future_get_bool (future)); - future_destroy (future); - request_destroy (request); - - ASSERT_MATCH (&test.reply, "{'ok': 0, 'code': 42, 'errmsg': 'bad!'}"); - ASSERT_CMPINT (test.failed_calls, ==, 1); - - mock_server_destroy (server); - - /* client logs warning because it can't send killCursors or endSessions */ - capture_logs (true); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - - mongoc_client_destroy (client); - - cmd_failed_reply_test_cleanup (&test); - mongoc_apm_callbacks_destroy (callbacks); -} - - -static void -test_command_failed_reply_hangup (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_apm_callbacks_t *callbacks; - mongoc_collection_t *collection; - cmd_failed_reply_test_t test; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - - /* test that the command_failed_event's reply is empty if there is a network - * error (i.e. the server hangs up) */ - cmd_failed_reply_test_init (&test); - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_failed_cb (callbacks, - command_failed_reply_command_failed_cb); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - ASSERT (mongoc_client_set_apm_callbacks (client, callbacks, (void *) &test)); - - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 1, tmp_bson ("{}"), NULL, NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_request (server); - reply_to_request_simple (request, "{'ok': 0, 'code': 42, 'errmsg': 'bad!'}"); - - ASSERT (!future_get_bool (future)); - future_destroy (future); - reply_to_request_with_hang_up (request); - request_destroy (request); - - ASSERT_MATCH (&test.reply, "{}"); - ASSERT_CMPINT (test.failed_calls, ==, 1); - - mock_server_destroy (server); - - /* client logs warning because it can't send killCursors or endSessions */ - capture_logs (true); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - - mongoc_client_destroy (client); - - cmd_failed_reply_test_cleanup (&test); - mongoc_apm_callbacks_destroy (callbacks); -} - - -typedef struct { - int started_calls; - int succeeded_calls; - int failed_calls; - bool has_service_id; - bson_oid_t expected_service_id; -} service_id_test_t; - - -static void -assert_service_id (service_id_test_t *test, const bson_oid_t *actual_service_id) -{ - if (test->has_service_id) { - BSON_ASSERT (actual_service_id); - ASSERT_CMPOID (actual_service_id, &test->expected_service_id); - } else { - BSON_ASSERT (!actual_service_id); - } -} - - -static void -service_id_cmd_started_cb (const mongoc_apm_command_started_t *event) -{ - service_id_test_t *test = mongoc_apm_command_started_get_context (event); - - test->started_calls++; - assert_service_id (test, mongoc_apm_command_started_get_service_id (event)); -} - - -static void -service_id_cmd_succeeded_cb (const mongoc_apm_command_succeeded_t *event) -{ - service_id_test_t *test = mongoc_apm_command_succeeded_get_context (event); - - test->succeeded_calls++; - assert_service_id (test, - mongoc_apm_command_succeeded_get_service_id (event)); -} - - -static void -service_id_cmd_failed_cb (const mongoc_apm_command_failed_t *event) -{ - service_id_test_t *test = mongoc_apm_command_failed_get_context (event); - - test->failed_calls++; - assert_service_id (test, mongoc_apm_command_failed_get_service_id (event)); -} - - -static void -_test_service_id (bool is_loadbalanced) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_uri_t *uri; - request_t *request; - future_t *future; - bson_error_t error; - service_id_test_t context = {0}; - mongoc_apm_callbacks_t *callbacks; - - server = mock_server_new (); - mock_server_run (server); - mock_server_auto_endsessions (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_bool ( - uri, MONGOC_URI_LOADBALANCED, is_loadbalanced); - client = test_framework_client_new_from_uri (uri, NULL); - - if (is_loadbalanced) { - context.has_service_id = true; - bson_oid_init_from_string (&context.expected_service_id, - "AAAAAAAAAAAAAAAAAAAAAAAA"); - } - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, service_id_cmd_started_cb); - mongoc_apm_set_command_succeeded_cb (callbacks, service_id_cmd_succeeded_cb); - mongoc_apm_set_command_failed_cb (callbacks, service_id_cmd_failed_cb); - ASSERT (mongoc_client_set_apm_callbacks (client, callbacks, &context)); - mongoc_apm_callbacks_destroy (callbacks); - - future = future_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - - if (is_loadbalanced) { - request = mock_server_receives_any_hello_with_match ( - server, "{'loadBalanced': true}", "{'loadBalanced': true}"); - reply_to_request_simple ( - request, - tmp_str ("{'ismaster': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'msg': 'isdbgrid'," - " 'serviceId': {'$oid': 'AAAAAAAAAAAAAAAAAAAAAAAA'}}", - WIRE_VERSION_MIN, - WIRE_VERSION_5_0)); - } else { - request = mock_server_receives_any_hello_with_match ( - server, - "{'loadBalanced': { '$exists': false }}", - "{'loadBalanced': { '$exists': false }}"); - reply_to_request_simple (request, - tmp_str ("{'ismaster': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'msg': 'isdbgrid'}", - WIRE_VERSION_MIN, - WIRE_VERSION_5_0)); - } - request_destroy (request); - - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - future = future_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - reply_to_request_simple (request, - "{'ok': 0, 'code': 8, 'errmsg': 'UnknownError'}"); - request_destroy (request); - - ASSERT (!future_get_bool (future)); - future_destroy (future); - - ASSERT_CMPINT (2, ==, context.started_calls); - ASSERT_CMPINT (1, ==, context.succeeded_calls); - ASSERT_CMPINT (1, ==, context.failed_calls); - - mongoc_uri_destroy (uri); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -void -test_service_id_loadbalanced (void) -{ - _test_service_id (true); -} - - -void -test_service_id_not_loadbalanced (void) -{ - _test_service_id (false); -} - - -void -test_command_monitoring_install (TestSuite *suite) -{ - test_all_spec_tests (suite); - TestSuite_AddMockServerTest ( - suite, "/command_monitoring/get_error", test_get_error); - TestSuite_AddLive (suite, - "/command_monitoring/set_callbacks/single", - test_set_callbacks_single); - TestSuite_AddLive (suite, - "/command_monitoring/set_callbacks/pooled", - test_set_callbacks_pooled); - TestSuite_AddLive (suite, - "/command_monitoring/set_callbacks/pooled_try_pop", - test_set_callbacks_pooled_try_pop); - /* require aggregation cursor */ - TestSuite_AddLive ( - suite, "/command_monitoring/set_callbacks/change", test_change_callbacks); - TestSuite_AddLive ( - suite, "/command_monitoring/set_callbacks/reset", test_reset_callbacks); - TestSuite_AddLive (suite, - "/command_monitoring/operation_id/bulk/collection/single", - test_collection_bulk_op_single); - TestSuite_AddLive (suite, - "/command_monitoring/operation_id/bulk/collection/pooled", - test_collection_bulk_op_pooled); - TestSuite_AddLive (suite, - "/command_monitoring/operation_id/bulk/new/single", - test_bulk_op_single); - TestSuite_AddLive (suite, - "/command_monitoring/operation_id/bulk/new/pooled", - test_bulk_op_pooled); - TestSuite_AddMockServerTest ( - suite, - "/command_monitoring/operation_id/query/single/cmd", - test_query_operation_id_single_cmd); - TestSuite_AddMockServerTest ( - suite, - "/command_monitoring/operation_id/query/pooled/cmd", - test_query_operation_id_pooled_cmd); - TestSuite_AddLive (suite, "/command_monitoring/client_cmd", test_client_cmd); - TestSuite_AddLive ( - suite, "/command_monitoring/client_cmd_simple", test_client_cmd_simple); - TestSuite_AddLive ( - suite, "/command_monitoring/client_cmd/op_ids", test_client_cmd_op_ids); - TestSuite_AddFull (suite, - "/command_monitoring/killcursors_deprecated", - test_killcursors_deprecated, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_legacy_opcodes); - TestSuite_AddMockServerTest (suite, - "/command_monitoring/failed_reply_mock", - test_command_failed_reply_mock); - TestSuite_AddMockServerTest (suite, - "/command_monitoring/failed_reply_hangup", - test_command_failed_reply_hangup); - TestSuite_AddMockServerTest (suite, - "/command_monitoring/service_id/loadbalanced", - test_service_id_loadbalanced); - TestSuite_AddMockServerTest ( - suite, - "/command_monitoring/service_id/not_loadbalanced", - test_service_id_not_loadbalanced); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-connection-uri.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-connection-uri.c deleted file mode 100644 index b8ce775ca..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-connection-uri.c +++ /dev/null @@ -1,372 +0,0 @@ -#include -#include - -#include "json-test.h" -#include "test-libmongoc.h" -#include "mongoc/mongoc-read-concern-private.h" - - -/* - * Asserts every key-value pair in 'needle' is in 'haystack', including those in - * embedded documents. - */ -static void -bson_contains_iter (const bson_t *haystack, bson_iter_t *needle) -{ - bson_iter_t iter; - uint32_t bson_type; - - if (!bson_iter_next (needle)) { - return; - } - - ASSERT (bson_iter_init_find_case (&iter, haystack, bson_iter_key (needle))); - - bson_type = bson_iter_type (needle); - switch (bson_type) { - case BSON_TYPE_ARRAY: - case BSON_TYPE_DOCUMENT: { - bson_t sub_bson; - bson_iter_t sub_iter; - - ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - bson_iter_bson (&iter, &sub_bson); - - bson_iter_recurse (needle, &sub_iter); - bson_contains_iter (&sub_bson, &sub_iter); - - bson_destroy (&sub_bson); - return; - } - case BSON_TYPE_BOOL: - ASSERT (bson_iter_as_bool (needle) == bson_iter_as_bool (&iter)); - bson_contains_iter (haystack, needle); - return; - case BSON_TYPE_UTF8: - ASSERT (0 == - strcmp (bson_iter_utf8 (needle, 0), bson_iter_utf8 (&iter, 0))); - bson_contains_iter (haystack, needle); - return; - case BSON_TYPE_DOUBLE: - ASSERT (bson_iter_double (needle) == bson_iter_double (&iter)); - bson_contains_iter (haystack, needle); - return; - case BSON_TYPE_INT64: - case BSON_TYPE_INT32: - ASSERT (bson_iter_as_int64 (needle) == bson_iter_as_int64 (&iter)); - bson_contains_iter (haystack, needle); - return; - default: - ASSERT (false); - return; - } -} - -static void -run_uri_test (const char *uri_string, - bool valid, - const bson_t *hosts, - const bson_t *auth, - const bson_t *options) -{ - mongoc_uri_t *uri; - bson_iter_t auth_iter; - const char *db; - bson_error_t error; - - uri = mongoc_uri_new_with_error (uri_string, &error); - - /* BEGIN Exceptions to test suite */ - - /* some spec tests assume we allow DB names like "auth.foo" */ - if ((bson_iter_init_find (&auth_iter, auth, "db") || - bson_iter_init_find (&auth_iter, auth, "source")) && - BSON_ITER_HOLDS_UTF8 (&auth_iter)) { - db = bson_iter_utf8 (&auth_iter, NULL); - if (strchr (db, '.')) { - BSON_ASSERT (!uri); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid database name in URI"); - clear_captured_logs (); - return; - } - } - - if (valid && !uri && error.domain) { - /* Eager failures which the spec expects to be warnings. */ - /* CDRIVER-3167 */ - if (strstr (uri_string, "=invalid") || - strstr (uri_string, "heartbeatFrequencyMS=-2") || - strstr (uri_string, "w=-2") || strstr (uri_string, "wTimeoutMS=-2") || - strstr (uri_string, "zlibCompressionLevel=-2") || - strstr (uri_string, "zlibCompressionLevel=10") || - (!strstr (uri_string, "mongodb+srv") && - strstr (uri_string, "srvServiceName=customname")) || - strstr (uri_string, "srvMaxHosts=-1") || - strstr (uri_string, "srvMaxHosts=foo")) { - MONGOC_WARNING ("Error parsing URI: '%s'", error.message); - return; - } - } - - if (uri) { - /* mongoc does not warn on negative timeouts when it should. */ - /* CDRIVER-3167 */ - if ((mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_CONNECTTIMEOUTMS, 0) < 0) || - (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_LOCALTHRESHOLDMS, 0) < 0) || - (mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_MAXIDLETIMEMS, 0) < - 0) || - (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_SERVERSELECTIONTIMEOUTMS, 0) < 0) || - (mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_SOCKETTIMEOUTMS, 0) < - 0)) { - MONGOC_WARNING ("Invalid negative timeout"); - } - - /* mongoc does not store lists the way the spec test expects. */ - if (strstr (uri_string, "compressors=") || - strstr (uri_string, "readPreferenceTags=")) { - options = NULL; - } - - /* mongoc eagerly warns about unsupported compressors. */ -#ifndef MONGOC_ENABLE_COMPRESSION_SNAPPY - if (strstr (uri_string, "compressors=snappy")) { - clear_captured_logs (); - } -#endif - -#ifndef MONGOC_ENABLE_COMPRESSION_ZLIB - if (strstr (uri_string, "compressors=zlib") || - strstr (uri_string, "compressors=snappy,zlib")) { - clear_captured_logs (); - } -#endif - } - - /* END Exceptions to test suite */ - - if (valid) { - ASSERT_OR_PRINT (uri, error); - } else { - BSON_ASSERT (!uri); - return; - } - - if (!bson_empty0 (hosts)) { - const mongoc_host_list_t *hl; - bson_iter_t iter; - bson_iter_t host_iter; - - for (bson_iter_init (&iter, hosts); - bson_iter_next (&iter) && bson_iter_recurse (&iter, &host_iter);) { - const char *host = "localhost"; - int64_t port = 27017; - bool ok = false; - - if (bson_iter_find (&host_iter, "host") && - BSON_ITER_HOLDS_UTF8 (&host_iter)) { - host = bson_iter_utf8 (&host_iter, NULL); - } - if (bson_iter_find (&host_iter, "port") && - BSON_ITER_HOLDS_INT (&host_iter)) { - port = bson_iter_as_int64 (&host_iter); - } - - for (hl = mongoc_uri_get_hosts (uri); hl; hl = hl->next) { - if (!strcmp (host, hl->host) && port == hl->port) { - ok = true; - break; - } - } - - if (!ok) { - fprintf (stderr, - "Could not find '%s':%" PRId64 " in uri '%s'\n", - host, - port, - mongoc_uri_get_string (uri)); - BSON_ASSERT (0); - } - } - } - - if (!bson_empty0 (auth)) { - const char *auth_source = mongoc_uri_get_auth_source (uri); - const char *username = mongoc_uri_get_username (uri); - const char *password = mongoc_uri_get_password (uri); - bson_iter_t iter; - - if (bson_iter_init_find (&iter, auth, "username") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - ASSERT_CMPSTR (username, bson_iter_utf8 (&iter, NULL)); - } - - if (bson_iter_init_find (&iter, auth, "password") && - BSON_ITER_HOLDS_UTF8 (&iter)) { - ASSERT_CMPSTR (password, bson_iter_utf8 (&iter, NULL)); - } - - if ((bson_iter_init_find (&iter, auth, "db") || - bson_iter_init_find (&iter, auth, "source")) && - BSON_ITER_HOLDS_UTF8 (&iter)) { - ASSERT_CMPSTR (auth_source, bson_iter_utf8 (&iter, NULL)); - } - } - - if (options) { - const mongoc_read_concern_t *rc; - bson_t uri_options = BSON_INITIALIZER; - bson_t test_options = BSON_INITIALIZER; - bson_iter_t iter; - - bson_concat (&uri_options, mongoc_uri_get_options (uri)); - bson_concat (&uri_options, mongoc_uri_get_credentials (uri)); - - rc = mongoc_uri_get_read_concern (uri); - if (!mongoc_read_concern_is_default (rc)) { - BSON_APPEND_UTF8 (&uri_options, - "readconcernlevel", - mongoc_read_concern_get_level (rc)); - } - - bson_copy_to_excluding_noinit ( - options, - &test_options, - "username", /* these 'auth' params may be included in 'options' */ - "password", - "source", - "mechanism", /* renamed to 'authmechanism' for consistency */ - "mechanism_properties", /* renamed to 'authmechanismproperties' for - * consistency */ - NULL); - - if ((bson_iter_init_find (&iter, options, "mechanism") || - bson_iter_init_find (&iter, options, "authmechanism")) && - BSON_ITER_HOLDS_UTF8 (&iter)) { - BSON_APPEND_UTF8 ( - &test_options, "authmechanism", bson_iter_utf8 (&iter, NULL)); - } - - if ((bson_iter_init_find (&iter, options, "mechanism_properties") || - bson_iter_init_find (&iter, options, "authmechanismproperties")) && - BSON_ITER_HOLDS_DOCUMENT (&iter)) { - ASSERT (bson_append_iter ( - &test_options, "authmechanismproperties", -1, &iter)); - } - - bson_iter_init (&iter, &test_options); - bson_contains_iter (&uri_options, &iter); - - bson_destroy (&test_options); - bson_destroy (&uri_options); - } - - if (uri) { - mongoc_uri_destroy (uri); - } -} - -static void -test_connection_uri_cb (bson_t *scenario) -{ - bson_iter_t iter; - bson_iter_t descendent; - bson_iter_t tests_iter; - bson_iter_t warning_iter; - const char *uri_string = NULL; - bson_t hosts; - bson_t auth; - bson_t options; - bool valid; - - BSON_ASSERT (scenario); - - - BSON_ASSERT (bson_iter_init_find (&iter, scenario, "tests")); - BSON_ASSERT (BSON_ITER_HOLDS_ARRAY (&iter)); - ASSERT (bson_iter_recurse (&iter, &tests_iter)); - - while (bson_iter_next (&tests_iter)) { - bson_t test_case; - - bson_iter_bson (&tests_iter, &test_case); - - if (test_suite_debug_output ()) { - bson_iter_t test_case_iter; - - ASSERT (bson_iter_recurse (&tests_iter, &test_case_iter)); - if (bson_iter_find (&test_case_iter, "description")) { - const char *description = bson_iter_utf8 (&test_case_iter, NULL); - ASSERT (bson_iter_find_case (&test_case_iter, "uri")); - - printf (" - %s: '%s'\n", - description, - bson_iter_utf8 (&test_case_iter, 0)); - fflush (stdout); - } else { - fprintf (stderr, "Couldn't find `description` field in testcase\n"); - BSON_ASSERT (0); - } - } - - uri_string = bson_lookup_utf8 (&test_case, "uri"); - /* newer spec test replaces both "auth" and "options" with "credential" - */ - if (bson_has_field (&test_case, "credential")) { - bson_lookup_doc_null_ok (&test_case, "credential", &auth); - bson_lookup_doc_null_ok (&test_case, "credential", &options); - bson_init (&hosts); - } else if (bson_has_field (&test_case, "auth")) { - bson_lookup_doc_null_ok (&test_case, "auth", &auth); - bson_lookup_doc_null_ok (&test_case, "options", &options); - bson_lookup_doc_null_ok (&test_case, "hosts", &hosts); - } else { - /* These are expected to be initialized */ - bson_init (&hosts); - bson_init (&auth); - bson_init (&options); - } - - valid = _mongoc_lookup_bool (&test_case, "valid", true); - capture_logs (true); - run_uri_test (uri_string, valid, &hosts, &auth, &options); - - bson_iter_init (&warning_iter, &test_case); - - if (bson_iter_find_descendant (&warning_iter, "warning", &descendent) && - BSON_ITER_HOLDS_BOOL (&descendent)) { - if (bson_iter_as_bool (&descendent)) { - ASSERT_CAPTURED_LOG ("mongoc_uri", MONGOC_LOG_LEVEL_WARNING, ""); - } else { - ASSERT_NO_CAPTURED_LOGS ("mongoc_uri"); - } - } - - bson_destroy (&hosts); - bson_destroy (&auth); - bson_destroy (&options); - } -} - - -static void -test_all_spec_tests (TestSuite *suite) -{ - install_json_test_suite ( - suite, JSON_DIR, "uri-options", &test_connection_uri_cb); - install_json_test_suite ( - suite, JSON_DIR, "connection_uri", &test_connection_uri_cb); - install_json_test_suite (suite, JSON_DIR, "auth", &test_connection_uri_cb); -} - - -void -test_connection_uri_install (TestSuite *suite) -{ - test_all_spec_tests (suite); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-crud.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-crud.c deleted file mode 100644 index e785feb49..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-crud.c +++ /dev/null @@ -1,188 +0,0 @@ -#include - -#include "json-test.h" -#include "json-test-operations.h" -#include "test-libmongoc.h" - -static bool -crud_test_operation_cb (json_test_ctx_t *ctx, - const bson_t *test, - const bson_t *operation) -{ - bson_t reply; - bool res; - - res = - json_test_operation (ctx, test, operation, ctx->collection, NULL, &reply); - - bson_destroy (&reply); - - return res; -} - -static void -test_crud_cb (bson_t *scenario) -{ - json_test_config_t config = JSON_TEST_CONFIG_INIT; - config.run_operation_cb = crud_test_operation_cb; - config.command_started_events_only = true; - config.scenario = scenario; - run_json_general_test (&config); -} - -static void -test_all_spec_tests (TestSuite *suite) -{ - install_json_test_suite_with_check (suite, - JSON_DIR, - "crud/legacy", - &test_crud_cb, - test_framework_skip_if_no_crypto, - TestSuite_CheckLive); - - /* Read/write concern spec tests use the same format. */ - install_json_test_suite_with_check (suite, - JSON_DIR, - "read_write_concern/operation", - &test_crud_cb, - TestSuite_CheckLive); -} - -static void -prose_test_1 (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bool ret; - bson_t reply; - bson_error_t error; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - coll = get_test_collection (client, "coll"); - - ret = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'configureFailPoint': 'failCommand', 'mode': {'times': 1}, " - " 'data': {'failCommands': ['insert'], 'writeConcernError': {" - " 'code': 100, 'codeName': 'UnsatisfiableWriteConcern', " - " 'errmsg': 'Not enough data-bearing nodes', " - " 'errInfo': {'writeConcern': {'w': 2, 'wtimeout': 0, " - " 'provenance': 'clientSupplied'}}}}}"), - NULL, - NULL, - &error); - ASSERT_OR_PRINT (ret, error); - - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'x':1}"), NULL /* opts */, &reply, &error); - ASSERT (!ret); - - /* libmongoc does not model WriteConcernError, so we only assert that the - * "errInfo" field set in configureFailPoint matches that in the result */ - ASSERT_MATCH (&reply, - "{'writeConcernErrors': [{'errInfo': {'writeConcern': {" - "'w': 2, 'wtimeout': 0, 'provenance': 'clientSupplied'}}}]}"); - - bson_destroy (&reply); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -typedef struct { - bool has_reply; - bson_t reply; -} prose_test_2_apm_ctx_t; - -static void -prose_test_2_command_succeeded (const mongoc_apm_command_succeeded_t *event) -{ - if (!strcmp (mongoc_apm_command_succeeded_get_command_name (event), - "insert")) { - prose_test_2_apm_ctx_t *ctx = - mongoc_apm_command_succeeded_get_context (event); - ASSERT (!ctx->has_reply); - ctx->has_reply = true; - bson_copy_to (mongoc_apm_command_succeeded_get_reply (event), - &ctx->reply); - } -} - -static void -prose_test_2 (void *ctx) -{ - mongoc_client_t *client; - mongoc_database_t *db; - mongoc_collection_t *coll, *coll_created; - mongoc_apm_callbacks_t *callbacks; - prose_test_2_apm_ctx_t apm_ctx = {0}; - bool ret; - bson_t reply, reply_errInfo, observed_errInfo; - bson_error_t error = {0}; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - db = get_test_database (client); - coll = get_test_collection (client, "coll"); - - /* don't care if ns not found. */ - (void) mongoc_collection_drop (coll, NULL); - - coll_created = mongoc_database_create_collection ( - db, - mongoc_collection_get_name (coll), - tmp_bson ("{'validator': {'x': {'$type': 'string'}}}"), - &error); - ASSERT_OR_PRINT (coll_created, error); - mongoc_collection_destroy (coll_created); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_succeeded_cb (callbacks, - prose_test_2_command_succeeded); - mongoc_client_set_apm_callbacks (client, callbacks, (void *) &apm_ctx); - mongoc_apm_callbacks_destroy (callbacks); - - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'x':1}"), NULL /* opts */, &reply, &error); - ASSERT (!ret); - - /* Assert that the WriteError's code is DocumentValidationFailure */ - ASSERT_MATCH (&reply, "{'writeErrors': [{'code': 121}]}"); - - /* libmongoc does not model WriteError, so we only assert that the observed - * "errInfo" field matches that in the result */ - ASSERT (apm_ctx.has_reply); - bson_lookup_doc (&apm_ctx.reply, "writeErrors.0.errInfo", &observed_errInfo); - bson_lookup_doc (&reply, "writeErrors.0.errInfo", &reply_errInfo); - ASSERT (bson_compare (&reply_errInfo, &observed_errInfo) == 0); - - bson_destroy (&apm_ctx.reply); - bson_destroy (&reply); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -void -test_crud_install (TestSuite *suite) -{ - test_all_spec_tests (suite); - - TestSuite_AddFull (suite, - "/crud/prose_test_1", - prose_test_1, - NULL, /* dtor */ - NULL, /* ctx */ - test_framework_skip_if_no_failpoint, - test_framework_skip_if_max_wire_version_less_than_7); - - TestSuite_AddFull (suite, - "/crud/prose_test_2", - prose_test_2, - NULL, /* dtor */ - NULL, /* ctx */ - test_framework_skip_if_max_wire_version_less_than_13); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cursor.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cursor.c deleted file mode 100644 index 490df9426..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cursor.c +++ /dev/null @@ -1,2860 +0,0 @@ -#include -#include - -#include "TestSuite.h" -#include "test-libmongoc.h" -#include "mock_server/mock-rs.h" -#include "mock_server/future-functions.h" -#include "mongoc/mongoc-cursor-private.h" -#include "mongoc/mongoc-collection-private.h" -#include "mongoc/mongoc-error-private.h" -#include "mongoc/mongoc-read-concern-private.h" -#include "mongoc/mongoc-write-concern-private.h" -#include "test-conveniences.h" - -#define CURSOR_COMMON_SETUP \ - do { \ - bson_error_t _err; \ - bool _ret; \ - client = test_framework_new_default_client (); \ - coll = mongoc_client_get_collection (client, "test", "test"); \ - /* populate to ensure db and coll exist. */ \ - _ret = mongoc_collection_insert_one ( \ - coll, tmp_bson ("{}"), NULL, NULL, &_err); \ - ASSERT_OR_PRINT (_ret, _err); \ - ctor = (make_cursor_fn) ((TestFnCtx *) ctx)->test_fn; \ - } while (0) - -#define CURSOR_COMMON_TEARDOWN \ - do { \ - mongoc_collection_destroy (coll); \ - mongoc_client_destroy (client); \ - } while (0) - -typedef mongoc_cursor_t *(*make_cursor_fn) (mongoc_collection_t *); - -static mongoc_cursor_t * -_make_cmd_deprecated_cursor (mongoc_collection_t *coll); - -static mongoc_cursor_t * -_make_array_cursor (mongoc_collection_t *coll); - -/* test that the host a cursor returns belongs to a server it connected to. */ -static void -_test_common_get_host (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - make_cursor_fn ctor; - mongoc_cursor_t *cursor; - const mongoc_host_list_t *hosts; - mongoc_host_list_t cursor_host; - mongoc_uri_t *uri; - const bson_t *doc; - bson_error_t err; - bool ret; - - CURSOR_COMMON_SETUP; - cursor = ctor (coll); - uri = test_framework_get_uri (); - hosts = mongoc_uri_get_hosts (uri); - ret = mongoc_cursor_next (cursor, &doc); - if (!ret && mongoc_cursor_error (cursor, &err)) { - test_error ("%s", err.message); - } - mongoc_cursor_get_host (cursor, &cursor_host); - /* In a production deployment the driver can discover servers not in the seed - * list, but for this test assume the cursor uses one of the seeds. */ - while (hosts) { - if (strcmp (cursor_host.host_and_port, hosts->host_and_port) == 0) { - /* the cursor is using this server */ - ASSERT_CMPSTR (cursor_host.host, hosts->host); - ASSERT_CMPINT (cursor_host.port, ==, hosts->port); - ASSERT_CMPINT (cursor_host.family, ==, hosts->family); - break; - } - hosts = hosts->next; - } - mongoc_uri_destroy (uri); - mongoc_cursor_destroy (cursor); - CURSOR_COMMON_TEARDOWN; -} - - -/* test cloning cursors returns the same results. */ -static void -_test_common_clone (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - make_cursor_fn ctor; - mongoc_cursor_t *cursor; - mongoc_cursor_t *cloned; - const bson_t *doc; - bson_error_t err; - - CURSOR_COMMON_SETUP; - cursor = ctor (coll); - cloned = mongoc_cursor_clone (cursor); - /* check that both cursors return the same number of documents. don't check - * that they return the same exact documents. A cursor on the listDatabases - * returns the database size, which may change in the background. */ - while (mongoc_cursor_next (cursor, &doc)) { - BSON_ASSERT (mongoc_cursor_next (cloned, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cloned, &err), err); - } - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &err), err); - BSON_ASSERT (!mongoc_cursor_next (cloned, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cloned, &err), err); - mongoc_cursor_destroy (cursor); - mongoc_cursor_destroy (cloned); - CURSOR_COMMON_TEARDOWN; -} - - -/* test cloning cursors with read and write concerns set. */ -static void -_test_common_clone_w_concerns (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - make_cursor_fn ctor; - mongoc_cursor_t *cursor; - mongoc_cursor_t *cloned; - mongoc_read_concern_t *read_concern; - mongoc_write_concern_t *write_concern; - const bson_t *bson; - bson_iter_t iter; - - CURSOR_COMMON_SETUP; - cursor = ctor (coll); - read_concern = mongoc_read_concern_new (); - ASSERT (read_concern); - mongoc_read_concern_set_level (read_concern, - MONGOC_READ_CONCERN_LEVEL_LOCAL); - write_concern = mongoc_write_concern_new (); - ASSERT (write_concern); - mongoc_write_concern_set_fsync (write_concern, true); - mongoc_write_concern_set_journal (write_concern, true); - mongoc_write_concern_set_wmajority (write_concern, 1000); - cursor->write_concern = write_concern; - mongoc_read_concern_destroy (cursor->read_concern); - cursor->read_concern = read_concern; - /* don't call mongoc_cursor_next (), since the test may run against a version - * of MongoDB that doesn't support read/write concerns, and we are only - * interested in testing if the clone process works. */ - cloned = mongoc_cursor_clone (cursor); - /* test cloned read_concern. */ - ASSERT (!mongoc_read_concern_is_default (cloned->read_concern)); - ASSERT_CMPSTR (mongoc_read_concern_get_level (cloned->read_concern), - MONGOC_READ_CONCERN_LEVEL_LOCAL); - /* test cloned write_concern. */ - ASSERT (mongoc_write_concern_get_wmajority (cloned->write_concern)); - ASSERT (mongoc_write_concern_get_wtimeout_int64 (cloned->write_concern) == - 1000); - ASSERT (mongoc_write_concern_get_w (cloned->write_concern) == - MONGOC_WRITE_CONCERN_W_MAJORITY); - /* check generated bson in cloned cursor. */ - ASSERT_MATCH (_mongoc_read_concern_get_bson (cloned->read_concern), - "{'level': 'local'}"); - bson = _mongoc_write_concern_get_bson (cloned->write_concern); - ASSERT (bson); - ASSERT (bson_iter_init_find (&iter, bson, "fsync") && - BSON_ITER_HOLDS_BOOL (&iter) && bson_iter_bool (&iter)); - ASSERT (bson_iter_init_find (&iter, bson, "j") && - BSON_ITER_HOLDS_BOOL (&iter) && bson_iter_bool (&iter)); - ASSERT (bson_iter_init_find (&iter, bson, "w") && - BSON_ITER_HOLDS_UTF8 (&iter)); - ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), "majority"); - mongoc_cursor_destroy (cursor); - mongoc_cursor_destroy (cloned); - CURSOR_COMMON_TEARDOWN; -} - - -/* test calling mongoc_cursor_next again after it returns false. */ -static void -_test_common_advancing_past_end (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - make_cursor_fn ctor; - mongoc_cursor_t *cursor; - const bson_t *doc; - const bson_t *current; - const bson_t *err_doc; - bson_error_t err; - - CURSOR_COMMON_SETUP; - cursor = ctor (coll); - while (mongoc_cursor_next (cursor, &doc)) { - current = mongoc_cursor_current (cursor); - /* should be same address. */ - BSON_ASSERT (doc == current); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &err), err); - /* cursor will report more until certain there are no documents left. */ - ASSERT (mongoc_cursor_more (cursor)); - } - /* advance one past the end. */ - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - BSON_ASSERT (mongoc_cursor_error (cursor, &err)); - BSON_ASSERT (mongoc_cursor_error_document (cursor, &err, &err_doc)); - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot advance a completed or failed cursor."); - /* this is not a server error, the error document should be NULL. */ - BSON_ASSERT (bson_empty (err_doc)); - mongoc_cursor_destroy (cursor); - CURSOR_COMMON_TEARDOWN; -} - - -typedef struct { - char *expected_host_and_port; - bool called; -} test_common_server_hint_ctx_t; - - -static void -_test_common_server_hint_command_started ( - const mongoc_apm_command_started_t *event) -{ - const mongoc_host_list_t *host = mongoc_apm_command_started_get_host (event); - const char *cmd = mongoc_apm_command_started_get_command_name (event); - test_common_server_hint_ctx_t *ctx; - /* only check command associated with cursor priming. */ - if (strcmp (cmd, "find") == 0 || - strcasecmp (cmd, HANDSHAKE_CMD_LEGACY_HELLO) == 0 || - strcmp (cmd, "hello") == 0 || strcmp (cmd, "listDatabases") == 0) { - ctx = (test_common_server_hint_ctx_t *) - mongoc_apm_command_started_get_context (event); - ASSERT_CMPSTR (host->host_and_port, ctx->expected_host_and_port); - BSON_ASSERT (!ctx->called); - ctx->called = true; - } -} - - -/* test setting the server id (hint) on cursors that support it. */ -static void -_test_common_server_hint (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - make_cursor_fn ctor; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_error_t err; - mongoc_server_description_t *sd; - mongoc_read_prefs_t *read_prefs; - test_common_server_hint_ctx_t test_ctx = {0}; - mongoc_apm_callbacks_t *callbacks; - - CURSOR_COMMON_SETUP; - /* set APM callbacks, and then set server hint. Make sure we target the same - * host that we select. */ - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, - _test_common_server_hint_command_started); - cursor = ctor (coll); - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - sd = mongoc_client_select_server (client, false, read_prefs, &err); - ASSERT_OR_PRINT (sd, err); - test_ctx.expected_host_and_port = bson_strdup (sd->host.host_and_port); - mongoc_read_prefs_destroy (read_prefs); - mongoc_client_set_apm_callbacks (client, callbacks, &test_ctx); - mongoc_apm_callbacks_destroy (callbacks); - BSON_ASSERT (mongoc_cursor_set_hint (cursor, sd->id)); - ASSERT_CMPUINT32 (mongoc_cursor_get_hint (cursor), ==, sd->id); - mongoc_server_description_destroy (sd); - - BSON_ASSERT (mongoc_cursor_next (cursor, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &err), err); - mongoc_cursor_destroy (cursor); - bson_free (test_ctx.expected_host_and_port); - BSON_ASSERT (test_ctx.called); - CURSOR_COMMON_TEARDOWN; -} - - -/* test setting options on unprimed, non-aggregate cursors. */ -static void -_test_common_opts (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - make_cursor_fn ctor; - mongoc_cursor_t *cursor; - const bson_t *doc; - mongoc_server_description_t *sd; - bson_error_t err; - - CURSOR_COMMON_SETUP; - sd = mongoc_client_select_server (client, true, NULL, &err); - ASSERT_OR_PRINT (sd, err); - cursor = ctor (coll); - /* check that we get what we set. */ - BSON_ASSERT (mongoc_cursor_set_hint (cursor, sd->id)); - ASSERT_CMPINT (mongoc_cursor_get_hint (cursor), ==, sd->id); - - /* listDatabases and hello prohibits limit and batchSize */ - if (ctor != _make_array_cursor && ctor != _make_cmd_deprecated_cursor) { - mongoc_cursor_set_batch_size (cursor, 1); - ASSERT_CMPINT (mongoc_cursor_get_batch_size (cursor), ==, 1); - BSON_ASSERT (mongoc_cursor_set_limit (cursor, 2)); - ASSERT_CMPINT ((int) mongoc_cursor_get_limit (cursor), ==, 2); - } - - mongoc_cursor_set_max_await_time_ms (cursor, 3); - ASSERT_CMPINT (mongoc_cursor_get_max_await_time_ms (cursor), ==, 3); - /* prime the cursor. */ - ASSERT_OR_PRINT (mongoc_cursor_next (cursor, &doc), cursor->error); - /* options should be unchanged. */ - ASSERT_CMPINT (mongoc_cursor_get_hint (cursor), ==, sd->id); - if (ctor != _make_array_cursor && ctor != _make_cmd_deprecated_cursor) { - ASSERT_CMPINT (mongoc_cursor_get_batch_size (cursor), ==, 1); - ASSERT_CMPINT ((int) mongoc_cursor_get_limit (cursor), ==, 2); - /* limit cannot be set again. */ - BSON_ASSERT (!mongoc_cursor_set_limit (cursor, 5)); - ASSERT_CMPINT ((int) mongoc_cursor_get_limit (cursor), ==, 2); - } - - ASSERT_CMPINT (mongoc_cursor_get_max_await_time_ms (cursor), ==, 3); - /* trying to set hint again logs an error. */ - capture_logs (true); - BSON_ASSERT (!mongoc_cursor_set_hint (cursor, 123)); - capture_logs (false); - ASSERT_CMPINT (mongoc_cursor_get_hint (cursor), ==, sd->id); - /* batch size can be set again without issue. */ - mongoc_cursor_set_batch_size (cursor, 4); - ASSERT_CMPINT (mongoc_cursor_get_batch_size (cursor), ==, 4); - /* max await time ms cannot be set (but fails quietly). */ - mongoc_cursor_set_max_await_time_ms (cursor, 6); - ASSERT_CMPINT (mongoc_cursor_get_max_await_time_ms (cursor), ==, 3); - mongoc_cursor_destroy (cursor); - mongoc_server_description_destroy (sd); - CURSOR_COMMON_TEARDOWN; -} - - -/* test setting options on cursors that are primed on construction. */ -static void -_test_common_opts_after_prime (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - make_cursor_fn ctor; - mongoc_cursor_t *cursor; - - CURSOR_COMMON_SETUP; - cursor = ctor (coll); - /* trying to set hint logs an error. */ - capture_logs (true); - BSON_ASSERT (!mongoc_cursor_set_hint (cursor, 123)); - capture_logs (false); - ASSERT_CMPINT (mongoc_cursor_get_hint (cursor), !=, 0); - /* batch size can be set again without issue. */ - mongoc_cursor_set_batch_size (cursor, 4); - ASSERT_CMPINT (mongoc_cursor_get_batch_size (cursor), ==, 4); - /* limit cannot be set. */ - BSON_ASSERT (!mongoc_cursor_set_limit (cursor, 5)); - ASSERT_CMPINT ((int) mongoc_cursor_get_limit (cursor), ==, 0); - /* max await time ms cannot be set (but fails quietly). */ - mongoc_cursor_set_max_await_time_ms (cursor, 6); - ASSERT_CMPINT (mongoc_cursor_get_max_await_time_ms (cursor), ==, 0); - mongoc_cursor_destroy (cursor); - CURSOR_COMMON_TEARDOWN; -} - - -/* test setting options on a cursor constructed from an aggregation. */ -static void -_test_common_opts_agg (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - make_cursor_fn ctor; - mongoc_cursor_t *cursor; - - CURSOR_COMMON_SETUP; - cursor = ctor (coll); - /* trying to set hint logs an error. */ - capture_logs (true); - BSON_ASSERT (!mongoc_cursor_set_hint (cursor, 123)); - capture_logs (false); - ASSERT_CMPINT (mongoc_cursor_get_hint (cursor), !=, 0); - /* batch size can be set again without issue. */ - mongoc_cursor_set_batch_size (cursor, 4); - ASSERT_CMPINT (mongoc_cursor_get_batch_size (cursor), ==, 4); - /* limit can be set. */ - BSON_ASSERT (mongoc_cursor_set_limit (cursor, 5)); - ASSERT_CMPINT ((int) mongoc_cursor_get_limit (cursor), ==, 5); - /* max await time ms can be set. */ - mongoc_cursor_set_max_await_time_ms (cursor, 6); - ASSERT_CMPINT (mongoc_cursor_get_max_await_time_ms (cursor), ==, 6); - mongoc_cursor_destroy (cursor); - CURSOR_COMMON_TEARDOWN; -} - - -static mongoc_cursor_t * -_make_find_cursor (mongoc_collection_t *coll) -{ - return mongoc_collection_find_with_opts (coll, tmp_bson ("{}"), NULL, NULL); -} - - -static mongoc_cursor_t * -_make_cmd_cursor (mongoc_collection_t *coll) -{ - return mongoc_collection_find_indexes_with_opts (coll, NULL); -} - - -static mongoc_cursor_t * -_make_cmd_cursor_from_agg (mongoc_collection_t *coll) -{ - return mongoc_collection_aggregate ( - coll, MONGOC_QUERY_SECONDARY_OK, tmp_bson ("{}"), NULL, NULL); -} - - -static mongoc_cursor_t * -_make_cmd_deprecated_cursor (mongoc_collection_t *coll) -{ - return mongoc_collection_command ( - coll, - MONGOC_QUERY_SECONDARY_OK, - 0, - 0, - 0, - tmp_bson ("{'" HANDSHAKE_CMD_LEGACY_HELLO "': 1}"), - NULL, - NULL); -} - - -static mongoc_cursor_t * -_make_array_cursor (mongoc_collection_t *coll) -{ - return mongoc_client_find_databases_with_opts (coll->client, NULL); -} - -#define TEST_CURSOR_FIND(prefix, fn) \ - TestSuite_AddFullWithTestFn (suite, \ - prefix "/find", \ - fn, \ - NULL, \ - _make_find_cursor, \ - TestSuite_CheckLive); - -#define TEST_CURSOR_CMD(prefix, fn) \ - TestSuite_AddFullWithTestFn ( \ - suite, prefix "/cmd", fn, NULL, _make_cmd_cursor, TestSuite_CheckLive); - -#define TEST_CURSOR_CMD_DEPRECATED(prefix, fn) \ - TestSuite_AddFullWithTestFn (suite, \ - prefix "/cmd_deprecated", \ - fn, \ - NULL, \ - _make_cmd_deprecated_cursor, \ - TestSuite_CheckLive); - -#define TEST_CURSOR_ARRAY(prefix, fn) \ - TestSuite_AddFullWithTestFn (suite, \ - prefix "/array", \ - fn, \ - NULL, \ - _make_array_cursor, \ - TestSuite_CheckLive); - -#define TEST_CURSOR_AGG(prefix, fn) \ - TestSuite_AddFullWithTestFn (suite, \ - prefix "/agg", \ - fn, \ - NULL, \ - _make_cmd_cursor_from_agg, \ - TestSuite_CheckLive); - - -#define TEST_FOREACH_CURSOR(prefix, fn) \ - TEST_CURSOR_FIND (prefix, fn); \ - TEST_CURSOR_CMD (prefix, fn); \ - TEST_CURSOR_CMD_DEPRECATED (prefix, fn); \ - TEST_CURSOR_ARRAY (prefix, fn); \ - TEST_CURSOR_AGG (prefix, fn); - - -static void -test_common_cursor_functions_install (TestSuite *suite) -{ - /* test functionality common to all cursor implementations. */ - TEST_FOREACH_CURSOR ("/Cursor/common/get_host", _test_common_get_host); - TEST_FOREACH_CURSOR ("/Cursor/common/clone", _test_common_clone); - TEST_FOREACH_CURSOR ("/Cursor/common/clone_w_concerns", - _test_common_clone_w_concerns); - TEST_FOREACH_CURSOR ("/Cursor/common/advancing_past_end", - _test_common_advancing_past_end); - /* an agg/cmd cursors do not support setting server id. test others. */ - TEST_CURSOR_FIND ("/Cursor/common/hint", _test_common_server_hint); - TEST_CURSOR_CMD_DEPRECATED ("/Cursor/common/hint", _test_common_server_hint); - TEST_CURSOR_ARRAY ("/Cursor/common/hint", _test_common_server_hint); - /* find, cmd_depr, and array cursors can have all options set. */ - TEST_CURSOR_FIND ("/Cursor/common/opts", _test_common_opts); - TEST_CURSOR_CMD_DEPRECATED ("/Cursor/common/opts", _test_common_opts); - TEST_CURSOR_ARRAY ("/Cursor/common/opts", _test_common_opts); - /* a command cursor created from find_indexes_with_opts is already primed. */ - TEST_CURSOR_CMD ("/Cursor/common/opts", _test_common_opts_after_prime); - /* a command cursor created from an agg has the server id set, but is not - * primed. */ - TEST_CURSOR_AGG ("/Cursor/common/opts", _test_common_opts_agg); -} - - -static void -test_limit (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_bulk_operation_t *bulk; - bson_t *b; - bson_t *opts; - int i, n_docs; - mongoc_cursor_t *cursor; - bson_error_t error; - int64_t limits[] = {5, -5}; - const bson_t *doc = NULL; - bool r; - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_limit"); - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - b = tmp_bson ("{}"); - for (i = 0; i < 10; ++i) { - mongoc_bulk_operation_insert (bulk, b); - } - - r = (0 != mongoc_bulk_operation_execute (bulk, NULL, &error)); - ASSERT_OR_PRINT (r, error); - - /* test positive and negative limit */ - for (i = 0; i < 2; i++) { - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, tmp_bson ("{}"), NULL, NULL); - ASSERT_CMPINT64 ((int64_t) 0, ==, mongoc_cursor_get_limit (cursor)); - ASSERT (mongoc_cursor_set_limit (cursor, limits[i])); - ASSERT_CMPINT64 (limits[i], ==, mongoc_cursor_get_limit (cursor)); - n_docs = 0; - while (mongoc_cursor_next (cursor, &doc)) { - ++n_docs; - } - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT (!mongoc_cursor_more (cursor)); - ASSERT_CMPINT (n_docs, ==, 5); - ASSERT (!mongoc_cursor_set_limit (cursor, 123)); /* no effect */ - ASSERT_CMPINT64 (limits[i], ==, mongoc_cursor_get_limit (cursor)); - - mongoc_cursor_destroy (cursor); - - if (limits[i] > 0) { - opts = - tmp_bson ("{'limit': {'$numberLong': '%" PRId64 "'}}", limits[i]); - } else { - opts = tmp_bson ( - "{'singleBatch': true, 'limit': {'$numberLong': '%" PRId64 "'}}", - -limits[i]); - } - - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson (NULL), opts, NULL); - - ASSERT_CMPINT64 (limits[i], ==, mongoc_cursor_get_limit (cursor)); - n_docs = 0; - while (mongoc_cursor_next (cursor, &doc)) { - ++n_docs; - } - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT_CMPINT (n_docs, ==, 5); - - mongoc_cursor_destroy (cursor); - } - - mongoc_bulk_operation_destroy (bulk); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -typedef struct { - int succeeded_count; - int64_t cursor_id; -} killcursors_test_t; - - -static void -killcursors_succeeded (const mongoc_apm_command_succeeded_t *event) -{ - killcursors_test_t *ctx; - const bson_t *reply; - bson_iter_t iter; - bson_iter_t array; - - if (bson_strcasecmp (mongoc_apm_command_succeeded_get_command_name (event), - "killcursors") != 0) { - return; - } - - ctx = - (killcursors_test_t *) mongoc_apm_command_succeeded_get_context (event); - ctx->succeeded_count++; - - reply = mongoc_apm_command_succeeded_get_reply (event); - -#define ASSERT_EMPTY(_fieldname) \ - BSON_ASSERT (bson_iter_init_find (&iter, reply, (_fieldname))); \ - BSON_ASSERT (bson_iter_recurse (&iter, &array)); \ - BSON_ASSERT (!bson_iter_next (&array)); - - ASSERT_EMPTY ("cursorsNotFound"); - ASSERT_EMPTY ("cursorsAlive"); - ASSERT_EMPTY ("cursorsUnknown"); - - BSON_ASSERT (bson_iter_init_find (&iter, reply, "cursorsKilled")); - BSON_ASSERT (bson_iter_recurse (&iter, &array)); - BSON_ASSERT (bson_iter_next (&array)); - ASSERT_CMPINT64 (ctx->cursor_id, ==, bson_iter_int64 (&array)); -} - -extern void -_mongoc_cursor_impl_find_opquery_init (mongoc_cursor_t *cursor, bson_t *filter); - -/* Tests killing a cursor with mongo_cursor_destroy and a real server. - * Asserts that the cursor ID is no longer valid by attempting to get another - * batch of results with the previously killed cursor ID. Uses OP_GET_MORE (on - * servers older than 3.2) or a getMore command (servers 3.2+) to iterate the - * cursor ID. - */ -static void -test_kill_cursor_live (void) -{ - mongoc_apm_callbacks_t *callbacks; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *b; - mongoc_bulk_operation_t *bulk; - int i; - bson_error_t error; - uint32_t server_id; - bool r; - mongoc_cursor_t *cursor; - const bson_t *doc; - killcursors_test_t ctx; - - ctx.succeeded_count = 0; - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_succeeded_cb (callbacks, killcursors_succeeded); - client = test_framework_new_default_client (); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - collection = get_test_collection (client, "test"); - b = tmp_bson ("{}"); - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - for (i = 0; i < 200; i++) { - mongoc_bulk_operation_insert (bulk, b); - } - - server_id = mongoc_bulk_operation_execute (bulk, NULL, &error); - ASSERT_OR_PRINT (server_id > 0, error); - - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_NONE, - 0, - 0, - 2, /* batch size 2 */ - b, - NULL, - NULL); - - r = mongoc_cursor_next (cursor, &doc); - ASSERT (r); - ctx.cursor_id = mongoc_cursor_get_id (cursor); - ASSERT (ctx.cursor_id); - - /* sends OP_KILLCURSORS or killCursors command to server */ - mongoc_cursor_destroy (cursor); - - ASSERT_CMPINT (ctx.succeeded_count, ==, 1); - - if (test_framework_supports_legacy_opcodes ()) { - b = bson_new (); - cursor = _mongoc_cursor_find_new ( - client, collection->ns, b, NULL, NULL, NULL, NULL); - /* override the typical priming, and immediately transition to an OPQUERY - * find cursor. */ - cursor->impl.destroy (&cursor->impl); - _mongoc_cursor_impl_find_opquery_init (cursor, b); - - cursor->cursor_id = ctx.cursor_id; - cursor->state = - END_OF_BATCH; /* meaning, "finished reading first batch" */ - r = mongoc_cursor_next (cursor, &doc); - ASSERT (!r); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_CURSOR, 16, "cursor is invalid"); - - mongoc_cursor_destroy (cursor); - } else { - bson_t *cmd; - - cmd = BCON_NEW ("getMore", - BCON_INT64 (ctx.cursor_id), - "collection", - mongoc_collection_get_name (collection)); - r = mongoc_client_command_simple ( - client, "test", cmd, NULL /* read prefs */, NULL /* reply */, &error); - ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_QUERY, - MONGOC_SERVER_ERR_CURSOR_NOT_FOUND, - "not found"); - bson_destroy (cmd); - } - - mongoc_bulk_operation_destroy (bulk); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mongoc_apm_callbacks_destroy (callbacks); -} - - -/* test the killCursors command with mock servers */ -static void -_test_kill_cursors (bool pooled) -{ - mock_rs_t *rs; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *q = BCON_NEW ("a", BCON_INT32 (1)); - mongoc_read_prefs_t *prefs; - mongoc_cursor_t *cursor; - const bson_t *doc = NULL; - future_t *future; - request_t *request; - bson_error_t error; - request_t *kill_cursors; - const char *ns_out; - int64_t cursor_id_out; - - rs = mock_rs_with_auto_hello (WIRE_VERSION_MIN, /* wire version */ - true, /* has primary */ - 5, /* number of secondaries */ - 0); /* number of arbiters */ - - mock_rs_run (rs); - - if (pooled) { - pool = - test_framework_client_pool_new_from_uri (mock_rs_get_uri (rs), NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (mock_rs_get_uri (rs), NULL); - } - - collection = mongoc_client_get_collection (client, "db", "collection"); - - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, q, NULL, prefs); - - future = future_cursor_next (cursor, &doc); - request = mock_rs_receives_request (rs); - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '123'}," - " 'ns': 'db.collection'," - " 'firstBatch': [{'b': 1}]}}")); - - if (!future_get_bool (future)) { - mongoc_cursor_error (cursor, &error); - test_error ("%s", error.message); - }; - - ASSERT_MATCH (doc, "{'b': 1}"); - ASSERT_CMPINT (123, ==, (int) mongoc_cursor_get_id (cursor)); - - future_destroy (future); - future = future_cursor_destroy (cursor); - - kill_cursors = - mock_rs_receives_msg (rs, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'killCursors': 'collection'," - " 'cursors': [{'$numberLong': '123'}]}")); - - /* mock server framework can't test "cursors" array, CDRIVER-994 */ - ASSERT (BCON_EXTRACT ((bson_t *) request_get_doc (kill_cursors, 0), - "killCursors", - BCONE_UTF8 (ns_out), - "cursors", - "[", - BCONE_INT64 (cursor_id_out), - "]")); - - ASSERT_CMPSTR ("collection", ns_out); - ASSERT_CMPINT64 ((int64_t) 123, ==, cursor_id_out); - - reply_to_request_simple (request, "{'ok': 1}"); - - /* OP_KILLCURSORS was sent to the right secondary */ - ASSERT_CMPINT (request_get_server_port (kill_cursors), - ==, - request_get_server_port (request)); - - BSON_ASSERT (future_wait (future)); - - request_destroy (kill_cursors); - request_destroy (request); - future_destroy (future); - mongoc_read_prefs_destroy (prefs); - mongoc_collection_destroy (collection); - bson_destroy (q); - - if (pooled) { - capture_logs (true); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - capture_logs (false); - } else { - mongoc_client_destroy (client); - } - - mock_rs_destroy (rs); -} - - -static void -test_kill_cursors_single (void) -{ - _test_kill_cursors (false); -} - - -static void -test_kill_cursors_pooled (void) -{ - _test_kill_cursors (true); -} - - -/* Test explicit mongoc_client_kill_cursor. */ -static void -_test_client_kill_cursor (bool has_primary) -{ - mock_rs_t *rs; - mongoc_client_t *client; - mongoc_read_prefs_t *read_prefs; - bson_error_t error; - future_t *future; - request_t *request; - - rs = mock_rs_with_auto_hello (WIRE_VERSION_MIN, - has_primary, /* maybe a primary*/ - 1, /* definitely a secondary */ - 0); /* no arbiter */ - mock_rs_run (rs); - client = test_framework_client_new_from_uri (mock_rs_get_uri (rs), NULL); - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - - /* make client open a connection - it won't open one to kill a cursor */ - future = future_client_command_simple ( - client, "admin", tmp_bson ("{'foo': 1}"), read_prefs, NULL, &error); - - request = mock_rs_receives_msg ( - rs, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'admin'," - " '$readPreference': {'mode': 'secondary'}," - " 'foo': 1}")); - - reply_to_request_simple (request, "{'ok': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - request_destroy (request); - future_destroy (future); - - future = future_client_kill_cursor (client, 123); - mock_rs_set_request_timeout_msec (rs, 100); - - /* we don't pass namespace so client always sends legacy OP_KILLCURSORS */ - request = mock_rs_receives_kill_cursors (rs, 123); - - if (has_primary) { - BSON_ASSERT (request); - - /* weird but true. see mongoc_client_kill_cursor's documentation */ - BSON_ASSERT (mock_rs_request_is_to_primary (rs, request)); - - request_destroy (request); /* server has no reply to OP_KILLCURSORS */ - } else { - /* TODO: catch and check warning */ - BSON_ASSERT (!request); - } - - future_wait (future); /* no return value */ - future_destroy (future); - mongoc_read_prefs_destroy (read_prefs); - mongoc_client_destroy (client); - mock_rs_destroy (rs); -} - -static void -test_client_kill_cursor_with_primary (void) -{ - _test_client_kill_cursor (true); -} - - -static void -test_client_kill_cursor_without_primary (void) -{ - _test_client_kill_cursor (false); -} - - -static int -count_docs (mongoc_cursor_t *cursor) -{ - int n = 0; - const bson_t *doc; - bson_error_t error; - - while (mongoc_cursor_next (cursor, &doc)) { - ++n; - } - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - return n; -} - - -static void -_test_cursor_new_from_command (const char *cmd_json, - const char *collection_name) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_bulk_operation_t *bulk; - bool r; - bson_error_t error; - mongoc_server_description_t *sd; - uint32_t server_id; - bson_t reply; - mongoc_cursor_t *cmd_cursor; - - client = test_framework_new_default_client (); - collection = mongoc_client_get_collection (client, "test", collection_name); - mongoc_collection_delete_many ( - collection, tmp_bson ("{}"), NULL, NULL, NULL); - - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - mongoc_bulk_operation_insert (bulk, tmp_bson ("{'_id': 'a'}")); - mongoc_bulk_operation_insert (bulk, tmp_bson ("{'_id': 'b'}")); - r = (0 != mongoc_bulk_operation_execute (bulk, NULL, &error)); - ASSERT_OR_PRINT (r, error); - - sd = mongoc_topology_select ( - client->topology, MONGOC_SS_READ, NULL, NULL, &error); - - ASSERT_OR_PRINT (sd, error); - server_id = sd->id; - mongoc_client_command_simple_with_server_id ( - client, "test", tmp_bson (cmd_json), NULL, server_id, &reply, &error); - cmd_cursor = mongoc_cursor_new_from_command_reply_with_opts ( - client, &reply, tmp_bson ("{'serverId': %d}", server_id)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cmd_cursor, &error), error); - ASSERT_CMPUINT32 (server_id, ==, mongoc_cursor_get_hint (cmd_cursor)); - ASSERT_CMPINT (count_docs (cmd_cursor), ==, 2); - - mongoc_cursor_destroy (cmd_cursor); - mongoc_server_description_destroy (sd); - mongoc_bulk_operation_destroy (bulk); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -static void -test_cursor_empty_collection (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - const bson_t *doc; - mongoc_cursor_t *cursor; - - client = test_framework_new_default_client (); - collection = mongoc_client_get_collection ( - client, "test", "test_cursor_empty_collection"); - mongoc_collection_delete_many ( - collection, tmp_bson ("{}"), NULL, NULL, NULL); - - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{}"), NULL, NULL); - - ASSERT (cursor); - ASSERT (!mongoc_cursor_error (cursor, &error)); - ASSERT (mongoc_cursor_more (cursor)); - - mongoc_cursor_next (cursor, &doc); - - ASSERT (!mongoc_cursor_error (cursor, &error)); - ASSERT (!mongoc_cursor_more (cursor)); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_cursor_new_from_aggregate (void) -{ - _test_cursor_new_from_command ( - "{'aggregate': 'test_cursor_new_from_aggregate'," - " 'pipeline': [], 'cursor': {}}", - "test_cursor_new_from_aggregate"); -} - - -static void -test_cursor_new_from_aggregate_no_initial (void) -{ - _test_cursor_new_from_command ( - "{'aggregate': 'test_cursor_new_from_aggregate_no_initial'," - " 'pipeline': [], 'cursor': {'batchSize': 0}}", - "test_cursor_new_from_aggregate_no_initial"); -} - - -static void -test_cursor_new_from_find (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_cursor_new_from_command ("{'find': 'test_cursor_new_from_find'}", - "test_cursor_new_from_find"); -} - - -static void -test_cursor_new_from_find_batches (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_cursor_new_from_command ( - "{'find': 'test_cursor_new_from_find_batches', 'batchSize': 1}", - "test_cursor_new_from_find_batches"); -} - - -static void -test_cursor_new_invalid (void) -{ - mongoc_client_t *client; - bson_error_t error; - mongoc_cursor_t *cursor; - bson_t b = BSON_INITIALIZER; - const bson_t *error_doc; - - client = test_framework_new_default_client (); - cursor = mongoc_cursor_new_from_command_reply_with_opts (client, &b, NULL); - ASSERT (cursor); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Couldn't parse cursor document"); - - ASSERT (mongoc_cursor_error_document (cursor, &error, &error_doc)); - ASSERT (bson_empty (error_doc)); - - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); -} - - -static void -test_cursor_new_tailable_await (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *doc; - future_t *future; - request_t *request; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - // Select a server to get the server_id. - // mongoc_cursor_new_from_command_reply_with_opts expects to receive a - // serverId when creating an open cursor (non-zero cursor.id) - uint32_t server_id; - { - mongoc_server_description_t *sd = mongoc_client_select_server ( - client, false /* for_writes */, NULL /* prefs */, &error); - ASSERT_OR_PRINT (sd, error); - server_id = mongoc_server_description_id (sd); - mongoc_server_description_destroy (sd); - } - - cursor = mongoc_cursor_new_from_command_reply_with_opts ( - client, - bson_copy (tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '123'}," - " 'ns': 'db.collection'," - " 'firstBatch': []" - " }," - " 'tailable': true," - " 'awaitData': true," - " 'maxAwaitTimeMS': 100" - "}")), - tmp_bson ("{'tailable': true," - " 'awaitData': true," - " 'maxAwaitTimeMS': 100," - " 'serverId': %" PRIu32 "}", - server_id)); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '123'}," - " 'collection': 'collection'," - " 'maxTimeMS': {'$numberLong': '100'}}")); - - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.collection'," - " 'firstBatch': [{'_id': 1}]}}")); - - BSON_ASSERT (future_get_bool (future)); - ASSERT_MATCH (doc, "{'_id': 1}"); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_cursor_int64_t_maxtimems (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *doc; - future_t *future; - request_t *request; - bson_t *max_await_time_ms; - uint64_t ms_int64 = UINT32_MAX + (uint64_t) 1; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - // Select a server to get the server_id. - // mongoc_cursor_new_from_command_reply_with_opts expects to receive a - // serverId when creating an open cursor (non-zero cursor.id) - uint32_t server_id; - { - mongoc_server_description_t *sd = mongoc_client_select_server ( - client, false /* for_writes */, NULL /* prefs */, &error); - ASSERT_OR_PRINT (sd, error); - server_id = mongoc_server_description_id (sd); - mongoc_server_description_destroy (sd); - } - - max_await_time_ms = tmp_bson (NULL); - bson_append_bool (max_await_time_ms, "tailable", 8, true); - bson_append_bool (max_await_time_ms, "awaitData", 9, true); - bson_append_int64 (max_await_time_ms, - MONGOC_CURSOR_MAX_AWAIT_TIME_MS, - MONGOC_CURSOR_MAX_AWAIT_TIME_MS_LEN, - ms_int64); - ASSERT (bson_in_range_int32_t_unsigned (server_id)); - BSON_APPEND_INT32 (max_await_time_ms, "serverId", (uint32_t) server_id); - - cursor = mongoc_cursor_new_from_command_reply_with_opts ( - client, - bson_copy (tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '123'}," - " 'ns': 'db.collection'," - " 'firstBatch': []" - " }" - "}")), - max_await_time_ms); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '123'}," - " 'collection': 'collection'," - " 'maxTimeMS': {'$numberLong': '%" PRIu64 "'}}", - ms_int64)); - - - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.collection'," - " 'firstBatch': [{'_id': 1}]}}")); - - BSON_ASSERT (future_get_bool (future)); - ASSERT_MATCH (doc, "{'_id': 1}"); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_cursor_new_ignores_fields (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_error_t error; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - cursor = mongoc_cursor_new_from_command_reply_with_opts ( - client, - bson_copy (tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'test.foo'," - " 'firstBatch': []" - " }," - " 'operationTime' : {}," - " '$clusterTime': {}," - " '$gleStats': {}" - "}")), - tmp_bson ("{'batchSize': 10}")); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT_MATCH (&cursor->opts, "{'batchSize': 10}"); - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_cursor_new_invalid_filter (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *error_doc; - - client = test_framework_new_default_client (); - collection = mongoc_client_get_collection (client, "test", "test"); - - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{'': 1}"), NULL, NULL); - - ASSERT (cursor); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Invalid filter: empty key"); - - ASSERT (mongoc_cursor_error_document (cursor, &error, &error_doc)); - ASSERT (bson_empty (error_doc)); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_cursor_new_invalid_opts (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *error_doc; - - client = test_framework_new_default_client (); - collection = mongoc_client_get_collection (client, "test", "test"); - - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson (NULL), tmp_bson ("{'projection': {'': 1}}"), NULL); - - ASSERT (cursor); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Invalid opts: empty key"); - - ASSERT (mongoc_cursor_error_document (cursor, &error, &error_doc)); - ASSERT (bson_empty (error_doc)); - mongoc_cursor_destroy (cursor); - - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson (NULL), tmp_bson ("{'$invalid': 1}"), NULL); - - ASSERT (cursor); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot use $-modifiers in opts: \"$invalid\""); - - ASSERT (mongoc_cursor_error_document (cursor, &error, &error_doc)); - ASSERT (bson_empty (error_doc)); - - mongoc_cursor_destroy (cursor); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_cursor_new_static (void) -{ - mongoc_client_t *client; - bson_error_t error; - mongoc_cursor_t *cursor; - bson_t *bson_alloced; - bson_t bson_static; - bson_t *bson_copied; - - bson_alloced = tmp_bson ("{ 'ok':1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'test.foo'," - " 'firstBatch': [{'x': 1}, {'x': 2}]}}"); - - ASSERT (bson_init_static ( - &bson_static, bson_get_data (bson_alloced), bson_alloced->len)); - - /* test heap-allocated bson */ - client = test_framework_new_default_client (); - bson_copied = bson_copy (bson_alloced); - cursor = mongoc_cursor_new_from_command_reply_with_opts ( - client, bson_copied, NULL); - - ASSERT (cursor); - ASSERT (!mongoc_cursor_error (cursor, &error)); - mongoc_cursor_destroy (cursor); - - /* test static bson */ - cursor = mongoc_cursor_new_from_command_reply_with_opts ( - client, &bson_static, NULL); - ASSERT (cursor); - ASSERT (!mongoc_cursor_error (cursor, &error)); - - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); -} - - -static void -test_cursor_hint_errors (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - - client = test_framework_new_default_client (); - collection = mongoc_client_get_collection (client, "db", "collection"); - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, tmp_bson ("{}"), NULL, NULL); - - capture_logs (true); - ASSERT (!mongoc_cursor_set_hint (cursor, 0)); - ASSERT_CAPTURED_LOG ("mongoc_cursor_set_hint", - MONGOC_LOG_LEVEL_ERROR, - "cannot set server_id to 0"); - - capture_logs (true); /* clear logs */ - ASSERT (mongoc_cursor_set_hint (cursor, 123)); - ASSERT_CMPUINT32 ((uint32_t) 123, ==, mongoc_cursor_get_hint (cursor)); - ASSERT_NO_CAPTURED_LOGS ("mongoc_cursor_set_hint"); - ASSERT (!mongoc_cursor_set_hint (cursor, 42)); - ASSERT_CAPTURED_LOG ("mongoc_cursor_set_hint", - MONGOC_LOG_LEVEL_ERROR, - "server_id already set"); - - /* last set_hint had no effect */ - ASSERT_CMPUINT32 ((uint32_t) 123, ==, mongoc_cursor_get_hint (cursor)); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static uint32_t -server_id_for_read_mode (mongoc_client_t *client, mongoc_read_mode_t read_mode) -{ - ASSERT (client); - - mongoc_read_prefs_t *prefs; - mongoc_server_description_t *sd; - bson_error_t error; - uint32_t server_id; - - prefs = mongoc_read_prefs_new (read_mode); - sd = mongoc_topology_select ( - client->topology, MONGOC_SS_READ, prefs, NULL, &error); - - ASSERT_OR_PRINT (sd, error); - server_id = sd->id; - - mongoc_server_description_destroy (sd); - mongoc_read_prefs_destroy (prefs); - - return server_id; -} - - -static void -_test_cursor_hint (bool pooled, bool use_primary) -{ - mock_rs_t *rs; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *q = BCON_NEW ("a", BCON_INT32 (1)); - mongoc_cursor_t *cursor; - uint32_t server_id; - const bson_t *doc = NULL; - future_t *future; - request_t *request; - - /* wire version WIRE_VERSION_MIN, primary, two secondaries, no arbiters */ - rs = mock_rs_with_auto_hello (WIRE_VERSION_MIN, true, 2, 0); - mock_rs_run (rs); - - if (pooled) { - pool = - test_framework_client_pool_new_from_uri (mock_rs_get_uri (rs), NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (mock_rs_get_uri (rs), NULL); - } - - collection = mongoc_client_get_collection (client, "test", "test"); - - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, q, NULL, NULL); - ASSERT_CMPUINT32 ((uint32_t) 0, ==, mongoc_cursor_get_hint (cursor)); - - if (use_primary) { - server_id = server_id_for_read_mode (client, MONGOC_READ_PRIMARY); - } else { - server_id = server_id_for_read_mode (client, MONGOC_READ_SECONDARY); - } - - ASSERT (mongoc_cursor_set_hint (cursor, server_id)); - ASSERT_CMPUINT32 (server_id, ==, mongoc_cursor_get_hint (cursor)); - - future = future_cursor_next (cursor, &doc); - request = mock_rs_receives_msg ( - rs, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test', 'find': 'test', 'filter': {'a': 1}}")); - - if (use_primary) { - BSON_ASSERT (mock_rs_request_is_to_primary (rs, request)); - } else { - BSON_ASSERT (mock_rs_request_is_to_secondary (rs, request)); - } - - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'test.test'," - " 'firstBatch': [{'b': 1}]}}")); - BSON_ASSERT (future_get_bool (future)); - ASSERT_MATCH (doc, "{'b': 1}"); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - - if (pooled) { - capture_logs (true); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - capture_logs (false); - } else { - mongoc_client_destroy (client); - } - - mock_rs_destroy (rs); - bson_destroy (q); -} - -static void -test_hint_single_secondary (void) -{ - _test_cursor_hint (false, false); -} - -static void -test_hint_single_primary (void) -{ - _test_cursor_hint (false, true); -} - -static void -test_hint_pooled_secondary (void) -{ - _test_cursor_hint (true, false); -} - -static void -test_hint_pooled_primary (void) -{ - _test_cursor_hint (true, true); -} - -mongoc_read_mode_t modes[] = { - MONGOC_READ_PRIMARY, - MONGOC_READ_PRIMARY_PREFERRED, - MONGOC_READ_SECONDARY, - MONGOC_READ_SECONDARY_PREFERRED, - MONGOC_READ_NEAREST, -}; - -mongoc_query_flags_t expected_flag[] = { - MONGOC_QUERY_NONE, - MONGOC_QUERY_SECONDARY_OK, - MONGOC_QUERY_SECONDARY_OK, - MONGOC_QUERY_SECONDARY_OK, - MONGOC_QUERY_SECONDARY_OK, -}; - -/* test that mongoc_cursor_set_hint sets secondaryOk for mongos only if read - * pref is secondaryPreferred. */ -static void -test_cursor_hint_mongos (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - size_t i; - mongoc_read_prefs_t *prefs; - mongoc_cursor_t *cursor; - const bson_t *doc = NULL; - future_t *future; - request_t *request; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - - for (i = 0; i < sizeof (modes) / sizeof (mongoc_read_mode_t); i++) { - prefs = mongoc_read_prefs_new (modes[i]); - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, tmp_bson (NULL), NULL, prefs); - - ASSERT_CMPUINT32 ((uint32_t) 0, ==, mongoc_cursor_get_hint (cursor)); - ASSERT (mongoc_cursor_set_hint (cursor, 1)); - ASSERT_CMPUINT32 ((uint32_t) 1, ==, mongoc_cursor_get_hint (cursor)); - - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test', 'find': 'test', 'filter': {}}")); - - reply_to_request_simple (request, - "{'ok':1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'test.test'," - " 'firstBatch': [{}]}}"); - BSON_ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_read_prefs_destroy (prefs); - } - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_cursor_hint_mongos_cmd (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - size_t i; - mongoc_read_prefs_t *prefs; - const bson_t *doc = NULL; - future_t *future; - request_t *request; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - - for (i = 0; i < sizeof (modes) / sizeof (mongoc_read_mode_t); i++) { - prefs = mongoc_read_prefs_new (modes[i]); - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, tmp_bson (NULL), NULL, prefs); - - ASSERT_CMPUINT32 ((uint32_t) 0, ==, mongoc_cursor_get_hint (cursor)); - ASSERT (mongoc_cursor_set_hint (cursor, 1)); - ASSERT_CMPUINT32 ((uint32_t) 1, ==, mongoc_cursor_get_hint (cursor)); - - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'test', 'find': 'test'}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'test.test'," - " 'firstBatch': [{}]}}"); - - BSON_ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_read_prefs_destroy (prefs); - } - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -/* Tests CDRIVER-562: after calling hello to handshake a new connection we - * must update topology description with the server response. If not, this test - * fails under auth with "auth failed" because we use the wrong auth protocol. - */ -static void -_test_cursor_hint_no_warmup (bool pooled) -{ - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t *q = tmp_bson (NULL); - mongoc_cursor_t *cursor; - const bson_t *doc = NULL; - bson_error_t error; - - if (pooled) { - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - } - - collection = get_test_collection (client, "test_cursor_hint_no_warmup"); - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, q, NULL, NULL); - - /* no chance for topology scan, no server selection */ - ASSERT (mongoc_cursor_set_hint (cursor, 1)); - ASSERT_CMPUINT32 (1, ==, mongoc_cursor_get_hint (cursor)); - - mongoc_cursor_next (cursor, &doc); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } -} - -static void -test_hint_no_warmup_single (void) -{ - _test_cursor_hint_no_warmup (false); -} - -static void -test_hint_no_warmup_pooled (void) -{ - _test_cursor_hint_no_warmup (true); -} - - -static void -test_tailable_alive (void) -{ - mongoc_client_t *client; - mongoc_database_t *database; - char *collection_name; - mongoc_collection_t *collection; - bool r; - bson_error_t error; - mongoc_cursor_t *cursor; - const bson_t *doc; - - client = test_framework_new_default_client (); - database = mongoc_client_get_database (client, "test"); - collection_name = gen_collection_name ("test"); - - collection = mongoc_database_get_collection (database, collection_name); - mongoc_collection_drop (collection, NULL); - mongoc_collection_destroy (collection); - - collection = mongoc_database_create_collection ( - database, - collection_name, - tmp_bson ("{'capped': true, 'size': 10000}"), - &error); - - ASSERT_OR_PRINT (collection, error); - - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{}"), NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - - /* test mongoc_collection_find and mongoc_collection_find_with_opts */ - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_TAILABLE_CURSOR | - MONGOC_QUERY_AWAIT_DATA, - 0, - 0, - 0, - tmp_bson (NULL), - NULL, - NULL); - - ASSERT (mongoc_cursor_more (cursor)); - ASSERT (mongoc_cursor_next (cursor, &doc)); - - /* still alive */ - ASSERT (mongoc_cursor_more (cursor)); - - /* no next document, but still alive and could return more in the future - * see CDRIVER-1530 */ - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_more (cursor)); - - mongoc_cursor_destroy (cursor); - - cursor = mongoc_collection_find_with_opts ( - collection, - tmp_bson (NULL), - tmp_bson ("{'tailable': true, 'awaitData': true}"), - NULL); - - ASSERT (mongoc_cursor_more (cursor)); - ASSERT (mongoc_cursor_next (cursor, &doc)); - - /* still alive */ - ASSERT (mongoc_cursor_more (cursor)); - - mongoc_cursor_destroy (cursor); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - bson_free (collection_name); - mongoc_client_destroy (client); -} - - -typedef struct { - int64_t skip; - int64_t limit; - int64_t batch_size; - int64_t expected_n_return[3]; - int64_t reply_length[3]; -} cursor_n_return_test; - - -static void -_make_reply_batch (bson_string_t *reply, - uint32_t n_docs, - bool first_batch, - bool finished) -{ - uint32_t j; - - bson_string_append_printf (reply, - "{'ok': 1, 'cursor': {" - " 'id': %d," - " 'ns': 'db.coll',", - finished ? 0 : 123); - - if (first_batch) { - bson_string_append (reply, "'firstBatch': [{}"); - } else { - bson_string_append (reply, "'nextBatch': [{}"); - } - - for (j = 1; j < n_docs; j++) { - bson_string_append (reply, ", {}"); - } - - bson_string_append (reply, "]}}"); -} - - -static void -_test_cursor_n_return_find_cmd (mongoc_cursor_t *cursor, - mock_server_t *server, - cursor_n_return_test *test) -{ - bson_t find_cmd = BSON_INITIALIZER; - bson_t getmore_cmd = BSON_INITIALIZER; - const bson_t *doc; - request_t *request; - future_t *future; - int j; - int reply_no; - bson_string_t *reply; - bool cursor_finished; - - BSON_APPEND_UTF8 (&find_cmd, "find", "coll"); - if (test->skip) { - BSON_APPEND_INT64 (&find_cmd, "skip", test->skip); - } - if (test->limit > 0) { - BSON_APPEND_INT64 (&find_cmd, "limit", test->limit); - } else if (test->limit < 0) { - BSON_APPEND_INT64 (&find_cmd, "limit", -test->limit); - BSON_APPEND_BOOL (&find_cmd, "singleBatch", true); - } - - if (test->batch_size) { - BSON_APPEND_INT64 (&find_cmd, "batchSize", BSON_ABS (test->batch_size)); - } - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db'}")); - - assert_match_bson (request_get_doc (request, 0), &find_cmd, true); - - reply = bson_string_new (NULL); - _make_reply_batch (reply, (uint32_t) test->reply_length[0], true, false); - reply_to_request_simple (request, reply->str); - bson_string_free (reply, true); - - ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - - /* advance to the end of the batch */ - for (j = 1; j < test->reply_length[0]; j++) { - ASSERT (mongoc_cursor_next (cursor, &doc)); - } - - for (reply_no = 1; reply_no < 3; reply_no++) { - /* expect getMore command, send reply_length[reply_no] docs to client */ - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db'}")); - - bson_reinit (&getmore_cmd); - BSON_APPEND_INT64 (&getmore_cmd, "getMore", 123); - if (test->expected_n_return[reply_no] && test->batch_size) { - BSON_APPEND_INT64 (&getmore_cmd, - "batchSize", - BSON_ABS (test->expected_n_return[reply_no])); - } else { - BSON_APPEND_DOCUMENT ( - &getmore_cmd, "batchSize", tmp_bson ("{'$exists': false}")); - } - - assert_match_bson (request_get_doc (request, 0), &getmore_cmd, true); - - reply = bson_string_new (NULL); - cursor_finished = (reply_no == 2); - _make_reply_batch (reply, - (uint32_t) test->reply_length[reply_no], - false, - cursor_finished); - - reply_to_request_simple (request, reply->str); - bson_string_free (reply, true); - - ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - - /* advance to the end of the batch */ - for (j = 1; j < test->reply_length[reply_no]; j++) { - ASSERT (mongoc_cursor_next (cursor, &doc)); - } - } - - bson_destroy (&find_cmd); - bson_destroy (&getmore_cmd); -} - - -static void -_test_cursor_n_return (bool find_with_opts) -{ - cursor_n_return_test tests[] = {{ - 0, /* skip */ - 0, /* limit */ - 0, /* batch_size */ - {0, 0, 0}, /* expected_n_return */ - {1, 1, 1} /* reply_length */ - }, - { - 7, /* skip */ - 0, /* limit */ - 0, /* batch_size */ - {0, 0, 0}, /* expected_n_return */ - {1, 1, 1} /* reply_length */ - }, - { - 0, /* skip */ - 3, /* limit */ - 0, /* batch_size */ - {3, 2, 1}, /* expected_n_return */ - {1, 1, 1} /* reply_length */ - }, - { - 0, /* skip */ - 5, /* limit */ - 2, /* batch_size */ - {2, 2, 1}, /* expected_n_return */ - {2, 2, 1} /* reply_length */ - }, - { - 0, /* skip */ - 4, /* limit */ - 7, /* batch_size */ - {4, 2, 1}, /* expected_n_return */ - {2, 1, 1} /* reply_length */ - }, - { - 0, /* skip */ - -3, /* limit */ - 1, /* batch_size */ - {-3, -3, -3}, /* expected_n_return */ - {1, 1, 1} /* reply_length */ - }}; - - cursor_n_return_test *test; - size_t i; - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t opts = BSON_INITIALIZER; - mongoc_cursor_t *cursor; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "coll"); - - for (i = 0; i < sizeof (tests) / sizeof (cursor_n_return_test); i++) { - test = &tests[i]; - - if (find_with_opts) { - bson_reinit (&opts); - - if (test->skip) { - BSON_APPEND_INT64 (&opts, "skip", test->skip); - } - - if (test->limit > 0) { - BSON_APPEND_INT64 (&opts, "limit", test->limit); - } else if (test->limit < 0) { - BSON_APPEND_INT64 (&opts, "limit", -test->limit); - BSON_APPEND_BOOL (&opts, "singleBatch", true); - } - - if (test->batch_size) { - BSON_APPEND_INT64 (&opts, "batchSize", test->batch_size); - } - - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson (NULL), &opts, NULL); - } else { - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_NONE, - (uint32_t) test->skip, - (uint32_t) test->limit, - (uint32_t) test->batch_size, - tmp_bson (NULL), - NULL, - NULL); - } - - _test_cursor_n_return_find_cmd (cursor, server, test); - - mongoc_cursor_destroy (cursor); - } - - bson_destroy (&opts); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_n_return_find_cmd (void) -{ - _test_cursor_n_return (false); -} - - -static void -test_n_return_find_cmd_with_opts (void) -{ - _test_cursor_n_return (true); -} - - -/* mongos can return empty final batch with limit and batchSize, which had - * caused an abort in the cursor */ -static void -test_empty_final_batch_live (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *doc; - int i; - bool r; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - collection = get_test_collection (client, "test_empty_final_batch_live"); - - mongoc_collection_delete_many ( - collection, tmp_bson ("{}"), NULL, NULL, NULL); - for (i = 0; i < 3; i++) { - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{}"), NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - } - - cursor = mongoc_collection_find_with_opts ( - collection, - tmp_bson ("{}"), - tmp_bson ("{'limit': 3, 'batchSize': 3}"), - NULL); - - for (i = 0; i < 3; i++) { - ASSERT (mongoc_cursor_next (cursor, &doc)); - } - - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_empty_final_batch (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "coll"); - cursor = mongoc_collection_find_with_opts ( - collection, - tmp_bson ("{}"), - tmp_bson ("{'limit': 1, 'batchSize': 1}"), - NULL); - - /* - * one document in first batch - */ - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db'}")); - - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '1234'}," - " 'ns': 'db.coll'," - " 'firstBatch': [{}]}}")); - - ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - - /* - * empty batch with nonzero cursor id - */ - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db'}")); - - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '1234'}," - " 'ns': 'db.coll'," - " 'firstBatch': []}}")); - - ASSERT (!future_get_bool (future)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - future_destroy (future); - request_destroy (request); - - /* - * final batch, empty with zero cursor id - */ - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db'}")); - - ASSERT_CMPINT64 ( - bson_lookup_int64 (request_get_doc (request, 0), "batchSize"), - ==, - (int64_t) 1); - - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.coll'," - " 'firstBatch': []}}")); - - ASSERT (!future_get_bool (future)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_error_document_query (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *doc; - const bson_t *error_doc; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - collection = get_test_collection (client, "test_error_document_query"); - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{'x': {'$badOperator': 1}}"), NULL, NULL); - - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_error_document (cursor, &error, &error_doc)); - ASSERT_CMPUINT32 (error.domain, ==, MONGOC_ERROR_SERVER); - ASSERT_CONTAINS (error.message, "$badOperator"); - ASSERT_CMPINT32 ( - bson_lookup_int32 (error_doc, "code"), ==, (int32_t) error.code); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_error_document_command (void) -{ - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *doc; - const bson_t *error_doc; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - cursor = mongoc_client_command (client, - "test", - MONGOC_QUERY_NONE, - 0, - 0, - 0, - tmp_bson ("{'foo': 1}"), /* no such cmd */ - NULL, - NULL); - - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_error_document (cursor, &error, &error_doc)); - ASSERT_CMPUINT32 (error.domain, ==, MONGOC_ERROR_SERVER); - ASSERT_CONTAINS (error.message, "no such"); - - ASSERT_CMPINT32 ( - bson_lookup_int32 (error_doc, "code"), ==, (int32_t) error.code); - - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); -} - - -static void -test_error_document_getmore (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - int i; - bool r; - bson_error_t error; - mongoc_cursor_t *cursor; - const bson_t *doc; - const bson_t *error_doc; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - collection = get_test_collection (client, "test_error_document_getmore"); - mongoc_collection_drop (collection, NULL); - - for (i = 0; i < 10; i++) { - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{'i': %d}", i), NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - } - - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{}"), tmp_bson ("{'batchSize': 2}"), NULL); - - ASSERT (mongoc_cursor_next (cursor, &doc)); - - mongoc_collection_drop (collection, NULL); - - ASSERT (mongoc_cursor_next (cursor, &doc)); - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_error_document (cursor, &error, &error_doc)); - - /* results vary by server version */ - if (error.domain == MONGOC_ERROR_CURSOR) { - /* MongoDB 3.0 and older */ - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "cursor is invalid"); - } else { - /* MongoDB 3.2+ */ - ASSERT_CMPUINT32 (error.domain, ==, MONGOC_ERROR_SERVER); - ASSERT_CMPINT32 ( - bson_lookup_int32 (error_doc, "code"), ==, (int32_t) error.code); - } - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -/* test that an error during constructing a find cursor causes the cursor to - * be marked as failed, so mongoc_cursor_is_alive and mongoc_cursor_more return - * false */ -static void -test_find_error_is_alive (void) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_cursor_t *cursor; - bson_error_t err; - const bson_t *bson; - client = test_framework_new_default_client (); - coll = mongoc_client_get_collection (client, "test", "test"); - cursor = - mongoc_collection_find (coll, - MONGOC_QUERY_NONE, - 0, - 0, - 0, - tmp_bson ("{'$query': {}, 'non_dollar': {}}"), - NULL, - NULL); - BSON_ASSERT (mongoc_cursor_error (cursor, &err)); - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot mix $query with non-dollar field"); - BSON_ASSERT (!mongoc_cursor_is_alive (cursor)); - BSON_ASSERT (!mongoc_cursor_more (cursor)); - BSON_ASSERT (!mongoc_cursor_next (cursor, &bson)); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -typedef struct _started_event_t { - char *command_name; - bson_t *command; -} started_event_t; - -static void -command_started (const mongoc_apm_command_started_t *event) -{ - mongoc_array_t *events = - (mongoc_array_t *) mongoc_apm_command_started_get_context (event); - started_event_t *started_event = bson_malloc0 (sizeof (started_event_t)); - - started_event->command = - bson_copy (mongoc_apm_command_started_get_command (event)); - started_event->command_name = - bson_strdup (mongoc_apm_command_started_get_command_name (event)); - _mongoc_array_append_val (events, started_event); -} - -static void -clear_started_events (mongoc_array_t *events) -{ - for (size_t i = 0; i < events->len; i++) { - started_event_t *started_event = - _mongoc_array_index (events, started_event_t *, i); - bson_destroy (started_event->command); - bson_free (started_event->command_name); - bson_free (started_event); - } - _mongoc_array_clear (events); -} - -void -numeric_iter_eq (bson_iter_t *iter, int64_t val) -{ - ASSERT_CMPINT64 (bson_iter_as_int64 (iter), ==, val); -} - -void -decimal128_iter_eq (bson_iter_t *iter, int64_t val) -{ - bson_decimal128_t d; - bson_iter_decimal128 (iter, &d); - ASSERT_CMPUINT64 (d.high, ==, 0x3040000000000000); - ASSERT_CMPINT64 (d.low, ==, val); -} - -void -test_cursor_batchsize_override (bson_t *findopts, - void (*assert_eq) (bson_iter_t *, int64_t)) -{ - mongoc_client_t *client; - mongoc_apm_callbacks_t *cbs; - mongoc_collection_t *coll; - bson_error_t error; - mongoc_array_t started_events; - - client = test_framework_new_default_client (); - cbs = mongoc_apm_callbacks_new (); - _mongoc_array_init (&started_events, sizeof (started_event_t *)); - mongoc_apm_set_command_started_cb (cbs, command_started); - coll = mongoc_client_get_collection (client, "db", "coll"); - - /* Drop and insert two documents into the collection */ - { - bson_t *to_insert = BCON_NEW ("x", "y"); - - // Ignore "ns not found" error on drop. - mongoc_collection_drop (coll, NULL); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one ( - coll, to_insert, NULL /* opts */, NULL /* reply */, &error), - error); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one ( - coll, to_insert, NULL /* opts */, NULL /* reply */, &error), - error); - bson_destroy (to_insert); - } - - mongoc_client_set_apm_callbacks (client, cbs, &started_events); - - /* Create a cursor and iterate once. */ - { - const bson_t *got; - bson_t *filter = bson_new (); - mongoc_cursor_t *cursor = mongoc_collection_find_with_opts ( - coll, filter, findopts, NULL /* read_prefs */); - /* Attempt to overwrite the 'batchSize' with 2. */ - mongoc_cursor_set_batch_size (cursor, 2); - /* Assert no command started events. The cursor does not send 'find' until - * the first call to mongoc_cursor_next. */ - ASSERT_CMPSIZE_T (started_events.len, ==, 0); - /* Iterate once. */ - ASSERT (mongoc_cursor_next (cursor, &got)); - - mongoc_cursor_destroy (cursor); - bson_destroy (findopts); - bson_destroy (filter); - } - - /* Check events. */ - { - started_event_t *started_event; - bson_iter_t iter; - /* Expect first event is find. */ - started_event = - _mongoc_array_index (&started_events, started_event_t *, 0); - ASSERT_CMPSTR (started_event->command_name, "find"); - /* Expect the batchSize sent to be 2. */ - ASSERT (bson_iter_init_find (&iter, started_event->command, "batchSize")); - assert_eq (&iter, 2); - } - - mongoc_collection_destroy (coll); - mongoc_apm_callbacks_destroy (cbs); - mongoc_client_destroy (client); - - clear_started_events (&started_events); - _mongoc_array_destroy (&started_events); -} - -/* Test that mongoc_cursor_set_batch_size overrides a previously set int32 - * batchSize. */ -void -test_cursor_batchsize_override_int32 (void) -{ - bson_t *findopts = BCON_NEW ("batchSize", BCON_INT32 (1)); - test_cursor_batchsize_override (findopts, numeric_iter_eq); -} - -/* Test that mongoc_cursor_set_batch_size overrides a previously set int64 - * batchSize. */ -void -test_cursor_batchsize_override_int64 (void) -{ - bson_t *findopts = BCON_NEW ("batchSize", BCON_INT64 (1)); - test_cursor_batchsize_override (findopts, numeric_iter_eq); -} - -/* Test that mongoc_cursor_set_batch_size overrides a previously set double - * batchSize. */ -void -test_cursor_batchsize_override_double (void) -{ - bson_t *findopts = BCON_NEW ("batchSize", BCON_DOUBLE (1.0)); - test_cursor_batchsize_override (findopts, numeric_iter_eq); -} - -/* Test that mongoc_cursor_set_batch_size overrides a previously set decimal128 - * batchSize. */ -void -test_cursor_batchsize_override_decimal128 (void) -{ - bson_decimal128_t start_val; - bson_decimal128_from_string ("1", &start_val); - bson_t *findopts = BCON_NEW ("batchSize", BCON_DECIMAL128 (&start_val)); - test_cursor_batchsize_override (findopts, decimal128_iter_eq); -} - -/* Test that attempting to overwrite an int32 batchSize with an out-of-range - * value raises a warning */ -void -test_cursor_batchsize_override_range_warning (void) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_t *findopts = BCON_NEW ("batchSize", BCON_INT32 (1)); - - client = test_framework_new_default_client (); - coll = mongoc_client_get_collection (client, "db", "coll"); - - /* Create a cursor and attempt to override outside int32 range. */ - { - bson_t *filter = bson_new (); - mongoc_cursor_t *cursor = mongoc_collection_find_with_opts ( - coll, filter, findopts, NULL /* read_prefs */); - - capture_logs (true); - /* Attempt to overwrite the 'batchSize' with uint32_max. */ - mongoc_cursor_set_batch_size (cursor, UINT32_MAX); - ASSERT_CAPTURED_LOG ( - "mongoc_cursor_set_batch_size", - MONGOC_LOG_LEVEL_WARNING, - "unable to overwrite stored int32 batchSize with out-of-range value"); - - mongoc_cursor_destroy (cursor); - bson_destroy (findopts); - bson_destroy (filter); - } - - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -// Test using an open cursor created by -// `mongoc_cursor_new_from_command_reply_with_opts`. -// This is a regression test for CDRIVER-3969. -static void -test_open_cursor_from_reply (void) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_error_t error; - bool ok; - - client = test_framework_new_default_client (); - coll = get_test_collection (client, "test_open_cursor_from_reply"); - - // Drop collection to remove data from prior runs. - // Ignore errors. Dropping a non-existing collection may return an "ns not - // found" error. - mongoc_collection_drop (coll, &error); - - // Insert two documents. - { - ok = mongoc_collection_insert_one (coll, - tmp_bson ("{'_id': 0}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - ok = mongoc_collection_insert_one (coll, - tmp_bson ("{'_id': 1}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - } - - // Test creating an open cursor created without a serverId. Expect error. - { - mongoc_cursor_t *cursor; - bson_t reply; - // Use a smaller batchSize than the number of documents. The smaller - // batchSize will result in the cursor being left open on the server. - bson_t *cmd = tmp_bson ("{'find': '%s', 'batchSize': 1}", - mongoc_collection_get_name (coll)); - ok = mongoc_collection_command_simple ( - coll, cmd, NULL /* read_prefs */, &reply, &error); - ASSERT_OR_PRINT (ok, error); - - // Assert that the cursor has a non-zero cursorId. A non-zero cursorId - // means the cursor is open on the server. - { - bson_iter_t iter; - ASSERT (bson_iter_init (&iter, &reply)); - ASSERT (bson_iter_find_descendant (&iter, "cursor.id", &iter)); - ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - ASSERT_CMPINT64 (bson_iter_int64 (&iter), >, 0); - } - - // `reply` is destroyed by - // `mongoc_cursor_new_from_command_reply_with_opts`. - cursor = mongoc_cursor_new_from_command_reply_with_opts ( - client, &reply, NULL /* opts */); - - // Expect an error to be returned. - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Expected `serverId` option"); - - mongoc_cursor_destroy (cursor); - } - - // Test iterating an open cursor created with a serverId. Expect no error. - { - // Get a serverID. - uint32_t server_id; - { - mongoc_server_description_t *sd = mongoc_client_select_server ( - client, true /* for_writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (sd, error); - server_id = mongoc_server_description_id (sd); - mongoc_server_description_destroy (sd); - } - mongoc_cursor_t *cursor; - bson_t reply; - // Use a smaller batchSize than the number of documents. The smaller - // batchSize will result in the cursor being left open on the server. - bson_t *cmd = - tmp_bson ("{'find': '%s', 'batchSize': 1, 'sort': {'_id': 1}}", - mongoc_collection_get_name (coll)); - ok = mongoc_collection_command_with_opts ( - coll, - cmd, - NULL /* read_prefs */, - tmp_bson ("{'serverId': %" PRIu32 "}", server_id), - &reply, - &error); - ASSERT_OR_PRINT (ok, error); - - // Assert that the cursor has a non-zero cursorId. A non-zero cursorId - // means the cursor is open on the server. - { - bson_iter_t iter; - ASSERT (bson_iter_init (&iter, &reply)); - ASSERT (bson_iter_find_descendant (&iter, "cursor.id", &iter)); - ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - ASSERT_CMPINT64 (bson_iter_int64 (&iter), >, 0); - } - - // `reply` is destroyed by - // `mongoc_cursor_new_from_command_reply_with_opts`. - cursor = mongoc_cursor_new_from_command_reply_with_opts ( - client, &reply, tmp_bson ("{'serverId': %" PRIu32 "}", server_id)); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - const bson_t *got; - bool found = mongoc_cursor_next (cursor, &got); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT (found); - ASSERT_MATCH (got, "{'_id': 0}"); - found = mongoc_cursor_next (cursor, &got); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT (found); - ASSERT_MATCH (got, "{'_id': 1}"); - found = mongoc_cursor_next (cursor, &got); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT (!found); - - mongoc_cursor_destroy (cursor); - } - - // Test destroying an open cursor created with a serverId. Expect no error. - { - // Get a serverID. - uint32_t server_id; - { - mongoc_server_description_t *sd = mongoc_client_select_server ( - client, true /* for_writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (sd, error); - server_id = mongoc_server_description_id (sd); - mongoc_server_description_destroy (sd); - } - mongoc_cursor_t *cursor; - bson_t reply; - // Use a smaller batchSize than the number of documents. The smaller - // batchSize will result in the cursor being left open on the server. - bson_t *cmd = tmp_bson ("{'find': '%s', 'batchSize': 1}", - mongoc_collection_get_name (coll)); - ok = mongoc_collection_command_with_opts ( - coll, - cmd, - NULL /* read_prefs */, - tmp_bson ("{'serverId': %" PRIu32 "}", server_id), - &reply, - &error); - ASSERT_OR_PRINT (ok, error); - - // Assert that the cursor has a non-zero cursorId. A non-zero cursorId - // means the cursor is open on the server. - { - bson_iter_t iter; - ASSERT (bson_iter_init (&iter, &reply)); - ASSERT (bson_iter_find_descendant (&iter, "cursor.id", &iter)); - ASSERT (BSON_ITER_HOLDS_INT64 (&iter)); - ASSERT_CMPINT64 (bson_iter_int64 (&iter), >, 0); - } - - // `reply` is destroyed by - // `mongoc_cursor_new_from_command_reply_with_opts`. - cursor = mongoc_cursor_new_from_command_reply_with_opts ( - client, &reply, tmp_bson ("{'serverId': %" PRIu32 "}", server_id)); - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - } - - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -void -test_cursor_install (TestSuite *suite) -{ - test_common_cursor_functions_install (suite); - TestSuite_AddLive (suite, "/Cursor/limit", test_limit); - TestSuite_AddLive (suite, - "" - "/Cursor/kill/live", - test_kill_cursor_live); - TestSuite_AddMockServerTest ( - suite, "/Cursor/kill/single", test_kill_cursors_single); - TestSuite_AddMockServerTest ( - suite, "/Cursor/kill/pooled", test_kill_cursors_pooled); - TestSuite_AddMockServerTest (suite, - "/Cursor/client_kill_cursor/with_primary", - test_client_kill_cursor_with_primary); - TestSuite_AddMockServerTest (suite, - "/Cursor/client_kill_cursor/without_primary", - test_client_kill_cursor_without_primary); - TestSuite_AddLive ( - suite, "/Cursor/empty_collection", test_cursor_empty_collection); - TestSuite_AddLive ( - suite, "/Cursor/new_from_agg", test_cursor_new_from_aggregate); - TestSuite_AddLive (suite, - "/Cursor/new_from_agg_no_initial", - test_cursor_new_from_aggregate_no_initial); - TestSuite_AddFull (suite, - "/Cursor/new_from_find", - test_cursor_new_from_find, - NULL, - NULL, - TestSuite_CheckLive); - TestSuite_AddFull (suite, - "/Cursor/new_from_find_batches", - test_cursor_new_from_find_batches, - NULL, - NULL, - TestSuite_CheckLive); - TestSuite_AddLive (suite, "/Cursor/new_invalid", test_cursor_new_invalid); - TestSuite_AddMockServerTest ( - suite, "/Cursor/new_tailable_await", test_cursor_new_tailable_await); - TestSuite_AddMockServerTest ( - suite, "/Cursor/int64_t_maxtimems", test_cursor_int64_t_maxtimems); - TestSuite_AddMockServerTest ( - suite, "/Cursor/new_ignores_fields", test_cursor_new_ignores_fields); - TestSuite_AddLive ( - suite, "/Cursor/new_invalid_filter", test_cursor_new_invalid_filter); - TestSuite_AddLive ( - suite, "/Cursor/new_invalid_opts", test_cursor_new_invalid_opts); - TestSuite_AddLive (suite, "/Cursor/new_static", test_cursor_new_static); - TestSuite_AddLive (suite, "/Cursor/hint/errors", test_cursor_hint_errors); - TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/single/secondary", test_hint_single_secondary); - TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/single/primary", test_hint_single_primary); - TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/pooled/secondary", test_hint_pooled_secondary); - TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/pooled/primary", test_hint_pooled_primary); - TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/mongos", test_cursor_hint_mongos); - TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/mongos/cmd", test_cursor_hint_mongos_cmd); - TestSuite_AddLive ( - suite, "/Cursor/hint/no_warmup/single", test_hint_no_warmup_single); - TestSuite_AddLive ( - suite, "/Cursor/hint/no_warmup/pooled", test_hint_no_warmup_pooled); - TestSuite_AddLive (suite, "/Cursor/tailable/alive", test_tailable_alive); - TestSuite_AddMockServerTest ( - suite, "/Cursor/n_return/find_cmd", test_n_return_find_cmd); - TestSuite_AddMockServerTest (suite, - "/Cursor/n_return/find_cmd/with_opts", - test_n_return_find_cmd_with_opts); - TestSuite_AddLive ( - suite, "/Cursor/empty_final_batch_live", test_empty_final_batch_live); - TestSuite_AddMockServerTest ( - suite, "/Cursor/empty_final_batch", test_empty_final_batch); - TestSuite_AddLive ( - suite, "/Cursor/error_document/query", test_error_document_query); - TestSuite_AddLive ( - suite, "/Cursor/error_document/getmore", test_error_document_getmore); - TestSuite_AddLive ( - suite, "/Cursor/error_document/command", test_error_document_command); - TestSuite_AddLive ( - suite, "/Cursor/find_error/is_alive", test_find_error_is_alive); - TestSuite_AddLive (suite, - "/Cursor/batchsize_override_int32", - test_cursor_batchsize_override_int32); - TestSuite_AddLive (suite, - "/Cursor/batchsize_override_int64", - test_cursor_batchsize_override_int64); - TestSuite_AddLive (suite, - "/Cursor/batchsize_override_double", - test_cursor_batchsize_override_double); - TestSuite_AddLive (suite, - "/Cursor/batchsize_override_decimal128", - test_cursor_batchsize_override_decimal128); - TestSuite_AddLive (suite, - "/Cursor/batchsize_override_range_warning", - test_cursor_batchsize_override_range_warning); - TestSuite_AddLive ( - suite, "/Cursor/open_cursor_from_reply", test_open_cursor_from_reply); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cyrus.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cyrus.c deleted file mode 100644 index 3d5c67aeb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-cyrus.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "TestSuite.h" -#include "test-libmongoc.h" - - -static void -test_sasl_properties (void) -{ - mongoc_uri_t *uri; - mongoc_cyrus_t sasl; - - uri = mongoc_uri_new ( - "mongodb://user@host/?authMechanism=GSSAPI&" - "authMechanismProperties=SERVICE_NAME:sn,CANONICALIZE_HOST_NAME:TrUe"); - - BSON_ASSERT (uri); - memset (&sasl, 0, sizeof sasl); - _mongoc_sasl_set_properties ((mongoc_sasl_t *) &sasl, uri); - - ASSERT (sasl.credentials.canonicalize_host_name); - ASSERT_CMPSTR (sasl.credentials.service_name, "sn"); - - mongoc_uri_destroy (uri); - - capture_logs (true); - /* authMechanismProperties take precedence */ - uri = mongoc_uri_new ( - "mongodb://user@host/?authMechanism=GSSAPI&" - "canonicalizeHostname=true&gssapiServiceName=blah&" - "authMechanismProperties=SERVICE_NAME:sn,CANONICALIZE_HOST_NAME:False"); - - ASSERT_CAPTURED_LOG ( - "authMechanismProperties should overwrite gssapiServiceName", - MONGOC_LOG_LEVEL_WARNING, - "Overwriting previously provided value for 'authmechanismproperties'"); - - _mongoc_cyrus_destroy (&sasl); - memset (&sasl, 0, sizeof sasl); - _mongoc_sasl_set_properties ((mongoc_sasl_t *) &sasl, uri); - - ASSERT (!sasl.credentials.canonicalize_host_name); - ASSERT_CMPSTR (sasl.credentials.service_name, "sn"); - - _mongoc_cyrus_destroy (&sasl); - mongoc_uri_destroy (uri); -} - - -static void -test_sasl_canonicalize_hostname (void *ctx) -{ - mongoc_client_t *client; - mongoc_server_stream_t *ss; - char real_name[BSON_HOST_NAME_MAX + 1] = {'\0'}; - bson_error_t error; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - ss = mongoc_cluster_stream_for_reads ( - &client->cluster, NULL, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (ss, error); - - BSON_ASSERT (_mongoc_sasl_get_canonicalized_name ( - ss->stream, real_name, sizeof real_name)); - - ASSERT_CMPSIZE_T (strlen (real_name), >, (size_t) 0); - - mongoc_server_stream_cleanup (ss); - mongoc_client_destroy (client); -} - - -void -test_cyrus_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/SASL/properties", test_sasl_properties); - TestSuite_AddFull (suite, - "/SASL/canonicalize", - test_sasl_canonicalize_hostname, - NULL, - NULL, - TestSuite_CheckLive, - test_framework_skip_if_offline); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-database.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-database.c deleted file mode 100644 index 51797a11c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-database.c +++ /dev/null @@ -1,1187 +0,0 @@ -#include -#include -#include -#include -#include - -#include "TestSuite.h" -#include "test-libmongoc.h" -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-cursor-private.h" -#include "mongoc/mongoc-database-private.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" -#include "test-conveniences.h" - - -static void -test_aggregate_inherit_database (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - mongoc_database_t *database; - const bson_t *doc; - request_t *request; - future_t *future; - bson_t *pipeline; - bson_t opts = BSON_INITIALIZER; - mongoc_read_concern_t *rc2; - mongoc_read_concern_t *rc; - mongoc_write_concern_t *wc2; - mongoc_write_concern_t *wc; - - server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - database = mongoc_client_get_database (client, "admin"); - - pipeline = BCON_NEW ("pipeline", - "[", - "{", - "$currentOp", - "{", - "}", - "}", - "{", - "$out", - BCON_UTF8 ("ops"), - "}", - "]"); - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_MAJORITY); - mongoc_read_concern_append (rc, &opts); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 2); - mongoc_write_concern_append (wc, &opts); - - /* Uses the opts */ - cursor = mongoc_database_aggregate (database, pipeline, &opts, NULL); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'aggregate' : 1," - " 'pipeline' : [ { '$currentOp': { } }, { '$out' : 'ops' } ]," - " 'cursor' : { }," - " '$db' : 'admin'," - " '$readPreference' : { '$exists': false }," - " 'readConcern' : { 'level' : 'majority' }," - " 'writeConcern' : { 'w' : 2 } }")); - - reply_to_request_simple (request, "{'ok': 1}"); - - ASSERT (!future_get_bool (future)); - - /* Set database level defaults */ - wc2 = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc2, 3); - mongoc_database_set_write_concern (database, wc2); - rc2 = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc2, MONGOC_READ_CONCERN_LEVEL_LOCAL); - mongoc_database_set_read_concern (database, rc2); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - - /* Inherits from database */ - cursor = mongoc_database_aggregate (database, pipeline, NULL, NULL); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'aggregate' : 1," - " 'pipeline' : [ { '$currentOp': { } }, { '$out' : 'ops' } ]," - " 'cursor' : { }," - " '$db' : 'admin'," - " '$readPreference' : { '$exists': false }," - " 'readConcern' : { 'level' : 'local' }," - " 'writeConcern' : { 'w' : 3 } }")); - - reply_to_request_simple (request, "{'ok': 1}"); - - ASSERT (!future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - - /* Uses the opts, not default database level */ - cursor = mongoc_database_aggregate (database, pipeline, &opts, NULL); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'aggregate' : 1," - " 'pipeline' : [ { '$currentOp': { } }, { '$out' : 'ops' } ]," - " 'cursor' : { }," - " '$db' : 'admin'," - " '$readPreference' : { '$exists': false }," - " 'readConcern' : { 'level' : 'majority' }," - " 'writeConcern' : { 'w' : 2 } }")); - - reply_to_request_simple (request, "{'ok': 1}"); - - ASSERT (!future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - - /* Doesn't inherit write concern when not using $out */ - bson_destroy (pipeline); - pipeline = BCON_NEW ("pipeline", "[", "{", "$currentOp", "{", "}", "}", "]"); - - cursor = mongoc_database_aggregate (database, pipeline, NULL, NULL); - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, - MONGOC_QUERY_NONE, - tmp_bson ("{ 'aggregate' : 1," - " 'pipeline' : [ { '$currentOp': { } } ]," - " 'cursor' : { }," - " '$db' : 'admin'," - " '$readPreference' : { '$exists': false }," - " 'readConcern' : { 'level' : 'local' }," - " 'writeConcern' : { '$exists' : false } }")); - - reply_to_request_simple (request, "{'ok': 1}"); - ASSERT (!future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - - bson_destroy (&opts); - bson_destroy (pipeline); - mongoc_read_concern_destroy (rc); - mongoc_read_concern_destroy (rc2); - mongoc_write_concern_destroy (wc); - mongoc_write_concern_destroy (wc2); - mongoc_database_destroy (database); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_create_with_write_concern (void *ctx) -{ - mongoc_database_t *database; - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_error_t error = {0}; - mongoc_write_concern_t *bad_wc; - mongoc_write_concern_t *good_wc; - bson_t *opts = NULL; - char *dbname; - char *name; - - BSON_UNUSED (ctx); - - capture_logs (true); - opts = bson_new (); - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - mongoc_client_set_error_api (client, 2); - - bad_wc = mongoc_write_concern_new (); - good_wc = mongoc_write_concern_new (); - - dbname = gen_collection_name ("dbtest"); - database = mongoc_client_get_database (client, dbname); - BSON_ASSERT (database); - - name = gen_collection_name ("create_collection"); - - /* writeConcern that will not pass mongoc_write_concern_is_valid */ - bad_wc->wtimeout = -10; - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - collection = - mongoc_database_create_collection (database, name, opts, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid writeConcern"); - ASSERT (!collection); - bad_wc->wtimeout = 0; - error.code = 0; - error.domain = 0; - - /* valid writeConcern on all configs */ - mongoc_write_concern_set_w (good_wc, 1); - bson_reinit (opts); - mongoc_write_concern_append (good_wc, opts); - collection = - mongoc_database_create_collection (database, name, opts, &error); - ASSERT_OR_PRINT (collection, error); - ASSERT (!error.code); - ASSERT (!error.domain); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - mongoc_collection_destroy (collection); - - /* writeConcern that results in writeConcernError */ - bad_wc->wtimeout = 0; - mongoc_write_concern_set_w (bad_wc, 99); - if (!test_framework_is_mongos ()) { /* skip if sharded */ - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - collection = - mongoc_database_create_collection (database, name, opts, &error); - - ASSERT (!collection); - assert_wc_oob_error (&error); - } - - mongoc_database_destroy (database); - bson_free (name); - bson_free (dbname); - bson_destroy (opts); - mongoc_write_concern_destroy (good_wc); - mongoc_write_concern_destroy (bad_wc); - mongoc_client_destroy (client); -} - - -static void -test_copy (void) -{ - mongoc_database_t *database; - mongoc_database_t *copy; - mongoc_client_t *client; - - client = test_framework_new_default_client (); - ASSERT (client); - - database = mongoc_client_get_database (client, "test"); - ASSERT (database); - - copy = mongoc_database_copy (database); - ASSERT (copy); - ASSERT (copy->client == database->client); - ASSERT (strcmp (copy->name, database->name) == 0); - - mongoc_database_destroy (copy); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_has_collection (void) -{ - mongoc_collection_t *collection; - mongoc_database_t *database; - mongoc_client_t *client; - bson_error_t error; - char *name; - bool r; - bson_oid_t oid; - bson_t b; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - name = gen_collection_name ("has_collection"); - collection = mongoc_client_get_collection (client, "test", name); - BSON_ASSERT (collection); - - database = mongoc_client_get_database (client, "test"); - BSON_ASSERT (database); - - bson_init (&b); - bson_oid_init (&oid, NULL); - bson_append_oid (&b, "_id", 3, &oid); - bson_append_utf8 (&b, "hello", 5, "world", 5); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, &b, NULL, NULL, &error), error); - bson_destroy (&b); - - r = mongoc_database_has_collection (database, name, &error); - BSON_ASSERT (!error.domain); - BSON_ASSERT (r); - - bson_free (name); - mongoc_database_destroy (database); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_command (void) -{ - mongoc_database_t *database; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error; - const bson_t *doc; - bool r; - bson_t cmd = BSON_INITIALIZER; - bson_t reply; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - database = mongoc_client_get_database (client, "admin"); - - /* - * Test a known working command, "ping". - */ - bson_append_int32 (&cmd, "ping", 4, 1); - - cursor = mongoc_database_command ( - database, MONGOC_QUERY_NONE, 0, 1, 0, &cmd, NULL, NULL); - BSON_ASSERT (cursor); - - r = mongoc_cursor_next (cursor, &doc); - BSON_ASSERT (r); - BSON_ASSERT (doc); - - r = mongoc_cursor_next (cursor, &doc); - BSON_ASSERT (!r); - BSON_ASSERT (!doc); - - mongoc_cursor_destroy (cursor); - - - /* - * Test a non-existing command to ensure we get the failure. - */ - bson_reinit (&cmd); - bson_append_int32 (&cmd, "a_non_existing_command", -1, 1); - - r = mongoc_database_command_simple (database, &cmd, NULL, &reply, &error); - BSON_ASSERT (!r); - BSON_ASSERT (error.domain == MONGOC_ERROR_QUERY); - BSON_ASSERT (error.code == MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND); - BSON_ASSERT (strstr (error.message, "a_non_existing_command")); - - bson_destroy (&reply); - mongoc_database_destroy (database); - mongoc_client_destroy (client); - bson_destroy (&cmd); -} - - -static void -_test_db_command_read_prefs (bool simple, bool pooled) -{ - mock_server_t *server; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_database_t *db; - mongoc_read_prefs_t *secondary_pref; - bson_t *cmd; - future_t *future; - bson_error_t error; - request_t *request; - mongoc_cursor_t *cursor; - const bson_t *reply; - - /* mock mongos: easiest way to test that read preference is configured */ - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri ( - mock_server_get_uri (server), NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (mock_server_get_uri (server), - NULL); - } - - db = mongoc_client_get_database (client, "db"); - secondary_pref = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_database_set_read_prefs (db, secondary_pref); - cmd = tmp_bson ("{'foo': 1}"); - - if (simple) { - /* simple, without read preference */ - future = future_database_command_simple (db, cmd, NULL, NULL, &error); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'foo': 1}")); - - reply_to_request_simple (request, "{'ok': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - request_destroy (request); - - /* with read preference */ - future = - future_database_command_simple (db, cmd, secondary_pref, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'foo': 1," - " '$readPreference': {'mode': 'secondary'}}")); - reply_to_request_simple (request, "{'ok': 1}"); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - request_destroy (request); - } else { - /* not simple, no read preference */ - cursor = mongoc_database_command ( - db, MONGOC_QUERY_NONE, 0, 0, 0, cmd, NULL, NULL); - future = future_cursor_next (cursor, &reply); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'foo': 1}")); - - reply_to_request_simple (request, "{'ok': 1}"); - ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - - /* with read preference */ - cursor = mongoc_database_command ( - db, MONGOC_QUERY_NONE, 0, 0, 0, cmd, NULL, secondary_pref); - future = future_cursor_next (cursor, &reply); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'foo': 1," - " '$readPreference': {'mode': 'secondary'}}")); - - reply_to_request_simple (request, "{'ok': 1}"); - ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - } - - mongoc_database_destroy (db); - mongoc_read_prefs_destroy (secondary_pref); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mock_server_destroy (server); -} - - -static void -test_db_command_simple_read_prefs_single (void) -{ - _test_db_command_read_prefs (true, false); -} - - -static void -test_db_command_simple_read_prefs_pooled (void) -{ - _test_db_command_read_prefs (true, true); -} - - -static void -test_db_command_read_prefs_single (void) -{ - _test_db_command_read_prefs (false, false); -} - - -static void -test_db_command_read_prefs_pooled (void) -{ - _test_db_command_read_prefs (false, true); -} - - -static void -test_drop (void) -{ - mongoc_client_t *client; - mongoc_database_t *database; - mongoc_collection_t *collection; - bson_error_t error = {0}; - bson_t *opts = NULL; - char *dbname; - mongoc_write_concern_t *good_wc; - mongoc_write_concern_t *bad_wc; - bool r; - - opts = bson_new (); - client = test_framework_new_default_client (); - BSON_ASSERT (client); - mongoc_client_set_error_api (client, 2); - - bad_wc = mongoc_write_concern_new (); - good_wc = mongoc_write_concern_new (); - - dbname = gen_collection_name ("db_drop_test"); - database = mongoc_client_get_database (client, dbname); - - /* MongoDB 3.2+ must create at least one replicated database before - * dropDatabase will check writeConcern, see SERVER-25601 */ - collection = mongoc_database_get_collection (database, "collection"); - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{}"), NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - - ASSERT_OR_PRINT (mongoc_database_drop (database, &error), error); - BSON_ASSERT (!error.domain); - BSON_ASSERT (!error.code); - - mongoc_database_destroy (database); - - /* invalid writeConcern */ - bad_wc->wtimeout = -10; - database = mongoc_client_get_database (client, dbname); - - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - ASSERT (!mongoc_database_drop_with_opts (database, opts, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid writeConcern"); - bad_wc->wtimeout = 0; - error.code = 0; - error.domain = 0; - - /* valid writeConcern */ - mongoc_write_concern_set_w (good_wc, 1); - - bson_reinit (opts); - mongoc_write_concern_append (good_wc, opts); - ASSERT_OR_PRINT (mongoc_database_drop_with_opts (database, opts, &error), - error); - BSON_ASSERT (!error.code); - BSON_ASSERT (!error.domain); - - /* invalid writeConcern */ - mongoc_write_concern_set_w (bad_wc, 99); - mongoc_database_destroy (database); - - if (!test_framework_is_mongos ()) { /* skip if sharded */ - database = mongoc_client_get_database (client, dbname); - bson_reinit (opts); - mongoc_write_concern_append_bad (bad_wc, opts); - r = mongoc_database_drop_with_opts (database, opts, &error); - ASSERT (!r); - assert_wc_oob_error (&error); - mongoc_database_destroy (database); - } - - bson_free (dbname); - bson_destroy (opts); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mongoc_write_concern_destroy (good_wc); - mongoc_write_concern_destroy (bad_wc); -} - - -static void -test_create_collection (void) -{ - mongoc_database_t *database; - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_error_t error = {0}; - bson_t options; - bson_t storage_opts; - bson_t wt_opts; - - char *dbname; - char *name; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - dbname = gen_collection_name ("dbtest"); - database = mongoc_client_get_database (client, dbname); - BSON_ASSERT (database); - bson_free (dbname); - - bson_init (&options); - BSON_APPEND_INT32 (&options, "size", 1234); - BSON_APPEND_INT32 (&options, "max", 4567); - BSON_APPEND_BOOL (&options, "capped", true); - - BSON_APPEND_DOCUMENT_BEGIN (&options, "storageEngine", &storage_opts); - BSON_APPEND_DOCUMENT_BEGIN (&storage_opts, "wiredTiger", &wt_opts); - BSON_APPEND_UTF8 (&wt_opts, "configString", "block_compressor=zlib"); - bson_append_document_end (&storage_opts, &wt_opts); - bson_append_document_end (&options, &storage_opts); - - - name = gen_collection_name ("create_collection"); - ASSERT_OR_PRINT (collection = mongoc_database_create_collection ( - database, name, &options, &error), - error); - - bson_destroy (&options); - bson_free (name); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - ASSERT_OR_PRINT (mongoc_database_drop (database, &error), error); - - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_get_collection_info (void) -{ - mongoc_database_t *database; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error = {0}; - bson_iter_t col_iter; - bson_t capped_options = BSON_INITIALIZER; - bson_t noopts_options = BSON_INITIALIZER; - bson_t name_filter = BSON_INITIALIZER; - const bson_t *doc; - int num_infos = 0; - - const char *name; - char *dbname; - char *capped_name; - char *noopts_name; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - dbname = gen_collection_name ("dbtest"); - database = mongoc_client_get_database (client, dbname); - - BSON_ASSERT (database); - bson_free (dbname); - - capped_name = gen_collection_name ("capped"); - BSON_APPEND_BOOL (&capped_options, "capped", true); - BSON_APPEND_INT32 (&capped_options, "size", 10000000); - BSON_APPEND_INT32 (&capped_options, "max", 1024); - - noopts_name = gen_collection_name ("noopts"); - - collection = mongoc_database_create_collection ( - database, capped_name, &capped_options, &error); - ASSERT_OR_PRINT (collection, error); - mongoc_collection_destroy (collection); - - collection = mongoc_database_create_collection ( - database, noopts_name, &noopts_options, &error); - ASSERT_OR_PRINT (collection, error); - mongoc_collection_destroy (collection); - - /* first we filter on collection name. */ - BSON_APPEND_UTF8 (&name_filter, "name", noopts_name); - - /* We only test with filters since get_collection_names will - * test w/o filters for us. */ - - /* Filter on an exact match of name */ - BEGIN_IGNORE_DEPRECATIONS - cursor = mongoc_database_find_collections (database, &name_filter, &error); - END_IGNORE_DEPRECATIONS - BSON_ASSERT (cursor); - BSON_ASSERT (!error.domain); - BSON_ASSERT (!error.code); - - while (mongoc_cursor_next (cursor, &doc)) { - if (bson_iter_init (&col_iter, doc) && - bson_iter_find (&col_iter, "name") && - BSON_ITER_HOLDS_UTF8 (&col_iter) && - (name = bson_iter_utf8 (&col_iter, NULL))) { - ++num_infos; - BSON_ASSERT (0 == strcmp (name, noopts_name)); - } else { - BSON_ASSERT (false); - } - } - - BSON_ASSERT (1 == num_infos); - - mongoc_cursor_destroy (cursor); - - ASSERT_OR_PRINT (mongoc_database_drop (database, &error), error); - BSON_ASSERT (!error.domain); - BSON_ASSERT (!error.code); - - bson_free (capped_name); - bson_free (noopts_name); - - bson_destroy (&capped_options); - bson_destroy (&noopts_options); - bson_destroy (&name_filter); - - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_get_collection_info_regex (void) -{ - mongoc_database_t *database; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error = {0}; - bson_iter_t col_iter; - bson_t name_filter = BSON_INITIALIZER; - const bson_t *doc; - char *dbname; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - dbname = gen_collection_name ("test_get_collection_info_regex"); - database = mongoc_client_get_database (client, dbname); - mongoc_database_drop_with_opts (database, NULL, NULL); - - collection = - mongoc_database_create_collection (database, "abbbc", NULL, &error); - ASSERT_OR_PRINT (collection, error); - mongoc_collection_destroy (collection); - - collection = - mongoc_database_create_collection (database, "foo", NULL, &error); - ASSERT_OR_PRINT (collection, error); - - BSON_APPEND_REGEX (&name_filter, "name", "ab+c", NULL); - - BEGIN_IGNORE_DEPRECATIONS - cursor = mongoc_database_find_collections (database, &name_filter, &error); - END_IGNORE_DEPRECATIONS - - BSON_ASSERT (cursor); - BSON_ASSERT (!error.domain); - BSON_ASSERT (!error.code); - - BSON_ASSERT (mongoc_cursor_next (cursor, &doc)); - BSON_ASSERT (bson_iter_init_find (&col_iter, doc, "name")); - BSON_ASSERT (0 == strcmp (bson_iter_utf8 (&col_iter, NULL), "abbbc")); - - /* only one match */ - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - mongoc_cursor_destroy (cursor); - - bson_destroy (&name_filter); - mongoc_collection_destroy (collection); - bson_free (dbname); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_get_collection_info_with_opts_regex (void) -{ - mongoc_database_t *database; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error = {0}; - bson_iter_t col_iter; - bson_t opts = BSON_INITIALIZER; - bson_t name_filter; - const bson_t *doc; - char *dbname; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - dbname = gen_collection_name ("test_get_collection_info_regex"); - database = mongoc_client_get_database (client, dbname); - mongoc_database_drop_with_opts (database, NULL, NULL); - - collection = - mongoc_database_create_collection (database, "abbbc", NULL, &error); - ASSERT_OR_PRINT (collection, error); - mongoc_collection_destroy (collection); - - collection = - mongoc_database_create_collection (database, "foo", NULL, &error); - ASSERT_OR_PRINT (collection, error); - - BSON_APPEND_DOCUMENT_BEGIN (&opts, "filter", &name_filter); - BSON_APPEND_REGEX (&name_filter, "name", "ab+c", NULL); - bson_append_document_end (&opts, &name_filter); - - cursor = mongoc_database_find_collections_with_opts (database, &opts); - BSON_ASSERT (cursor); - - BSON_ASSERT (!error.domain); - BSON_ASSERT (!error.code); - - BSON_ASSERT (mongoc_cursor_next (cursor, &doc)); - BSON_ASSERT (bson_iter_init_find (&col_iter, doc, "name")); - BSON_ASSERT (0 == strcmp (bson_iter_utf8 (&col_iter, NULL), "abbbc")); - - /* only one match */ - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - mongoc_cursor_destroy (cursor); - bson_destroy (&opts); - mongoc_collection_destroy (collection); - bson_free (dbname); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -_test_get_collection_info_getmore (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_database_t *database; - future_t *future; - request_t *request; - char **names; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - database = mongoc_client_get_database (client, "db"); - future = - future_database_get_collection_names_with_opts (database, NULL, NULL); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'listCollections': 1, 'nameOnly': true}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '123'}," - " 'ns': 'db.$cmd.listCollections'," - " 'firstBatch': [{'name': 'a'}]}}"); - request_destroy (request); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'getMore': {'$numberLong': '123'}," - " 'collection': '$cmd.listCollections'}")); - - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.$cmd.listCollections'," - " 'nextBatch': []}}"); - request_destroy (request); - names = future_get_char_ptr_ptr (future); - BSON_ASSERT (names); - ASSERT_CMPSTR (names[0], "a"); - - bson_strfreev (names); - future_destroy (future); - mongoc_database_destroy (database); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_get_collection_info_getmore_cmd (void) -{ - _test_get_collection_info_getmore (); -} - -static void -test_get_collection (void) -{ - mongoc_client_t *client; - mongoc_database_t *database; - mongoc_write_concern_t *wc; - mongoc_read_concern_t *rc; - mongoc_read_prefs_t *read_prefs; - mongoc_collection_t *collection; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - database = mongoc_client_get_database (client, "test"); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 2); - mongoc_database_set_write_concern (database, wc); - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, "majority"); - mongoc_database_set_read_concern (database, rc); - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_database_set_read_prefs (database, read_prefs); - - collection = mongoc_database_get_collection (database, "test"); - - ASSERT_CMPINT32 (collection->write_concern->w, ==, 2); - ASSERT_CMPSTR (collection->read_concern->level, "majority"); - ASSERT_CMPINT (collection->read_prefs->mode, ==, MONGOC_READ_SECONDARY); - - mongoc_collection_destroy (collection); - mongoc_read_prefs_destroy (read_prefs); - mongoc_read_concern_destroy (rc); - mongoc_write_concern_destroy (wc); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_get_collection_names (void) -{ - mongoc_database_t *database; - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_error_t error = {0}; - bson_t options; - int namecount; - int explicit_nameonly; - - char **names; - char **name; - char *curname; - - char *dbname; - char *name1; - char *name2; - char *name3; - char *name4; - char *name5; - const char *system_prefix = "system."; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - dbname = gen_collection_name ("dbtest"); - database = mongoc_client_get_database (client, dbname); - - BSON_ASSERT (database); - bson_free (dbname); - - bson_init (&options); - - name1 = gen_collection_name ("name1"); - name2 = gen_collection_name ("name2"); - name3 = gen_collection_name ("name3"); - name4 = gen_collection_name ("name4"); - name5 = gen_collection_name ("name5"); - - collection = - mongoc_database_create_collection (database, name1, &options, &error); - BSON_ASSERT (collection); - mongoc_collection_destroy (collection); - - collection = - mongoc_database_create_collection (database, name2, &options, &error); - BSON_ASSERT (collection); - mongoc_collection_destroy (collection); - - collection = - mongoc_database_create_collection (database, name3, &options, &error); - BSON_ASSERT (collection); - mongoc_collection_destroy (collection); - - collection = - mongoc_database_create_collection (database, name4, &options, &error); - BSON_ASSERT (collection); - mongoc_collection_destroy (collection); - - collection = - mongoc_database_create_collection (database, name5, &options, &error); - BSON_ASSERT (collection); - mongoc_collection_destroy (collection); - - for (explicit_nameonly = 0; explicit_nameonly <= 1; explicit_nameonly++) { - namecount = 0; - - /* ensure that if users happen to pass nameOnly in opts we don't - * append it again and cause a "duplicate field" server error */ - if (explicit_nameonly) { - names = mongoc_database_get_collection_names_with_opts ( - database, tmp_bson ("{'nameOnly': true}"), &error); - } else { - names = mongoc_database_get_collection_names_with_opts ( - database, NULL, &error); - } - BSON_ASSERT (!error.domain); - BSON_ASSERT (!error.code); - - for (name = names; *name; ++name) { - /* inefficient, but OK for a unit test. */ - curname = *name; - - if (0 == strcmp (curname, name1) || 0 == strcmp (curname, name2) || - 0 == strcmp (curname, name3) || 0 == strcmp (curname, name4) || - 0 == strcmp (curname, name5)) { - ++namecount; - } else if (0 == - strncmp (curname, system_prefix, strlen (system_prefix))) { - /* Collections prefixed with 'system.' are system collections */ - } else { - BSON_ASSERT (false); - } - - bson_free (curname); - } - - BSON_ASSERT (namecount == 5); - bson_free (names); - } - - bson_free (name1); - bson_free (name2); - bson_free (name3); - bson_free (name4); - bson_free (name5); - - ASSERT_OR_PRINT (mongoc_database_drop (database, &error), error); - BSON_ASSERT (!error.domain); - BSON_ASSERT (!error.code); - - bson_destroy (&options); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_get_collection_names_error (void) -{ - mongoc_database_t *database; - mongoc_uri_t *uri; - mongoc_client_t *client; - mock_server_t *server; - bson_error_t error = {0}; - bson_t b = BSON_INITIALIZER; - future_t *future; - request_t *request; - char **names; - - capture_logs (true); - - server = mock_server_new (); - mock_server_auto_hello (server, - "{'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - client = test_framework_client_new_from_uri (uri, NULL); - - database = mongoc_client_get_database (client, "test"); - future = - future_database_get_collection_names_with_opts (database, NULL, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test', 'listCollections': 1, 'nameOnly': true}")); - reply_to_request_with_hang_up (request); - names = future_get_char_ptr_ptr (future); - BSON_ASSERT (!names); - ASSERT_CMPINT (MONGOC_ERROR_STREAM, ==, error.domain); - ASSERT_CMPINT (MONGOC_ERROR_STREAM_SOCKET, ==, error.code); - - request_destroy (request); - future_destroy (future); - mongoc_database_destroy (database); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_server_destroy (server); - bson_destroy (&b); -} - -static void -test_get_default_database (void) -{ - /* default database is "db_name" */ - mongoc_client_t *client = - test_framework_client_new ("mongodb://host/db_name", NULL); - mongoc_database_t *db = mongoc_client_get_default_database (client); - - BSON_ASSERT (!strcmp ("db_name", mongoc_database_get_name (db))); - - mongoc_database_destroy (db); - mongoc_client_destroy (client); - - /* no default database */ - client = test_framework_client_new ("mongodb://host/", NULL); - db = mongoc_client_get_default_database (client); - - BSON_ASSERT (!db); - - mongoc_client_destroy (client); -} - -void -test_database_install (TestSuite *suite) -{ - TestSuite_AddMockServerTest (suite, - "/Database/aggregate/inherit/database", - test_aggregate_inherit_database); - TestSuite_AddFull (suite, - "/Database/create_with_write_concern", - test_create_with_write_concern, - NULL, - NULL, - TestSuite_CheckLive); - TestSuite_AddLive (suite, "/Database/copy", test_copy); - TestSuite_AddLive (suite, "/Database/has_collection", test_has_collection); - TestSuite_AddLive (suite, "/Database/command", test_command); - TestSuite_AddMockServerTest (suite, - "/Database/command/read_prefs/simple/single", - test_db_command_simple_read_prefs_single); - TestSuite_AddMockServerTest (suite, - "/Database/command/read_prefs/simple/pooled", - test_db_command_simple_read_prefs_pooled); - TestSuite_AddMockServerTest (suite, - "/Database/command/read_prefs/single", - test_db_command_read_prefs_single); - TestSuite_AddMockServerTest (suite, - "/Database/command/read_prefs/pooled", - test_db_command_read_prefs_pooled); - TestSuite_AddLive (suite, "/Database/drop", test_drop); - TestSuite_AddLive ( - suite, "/Database/create_collection", test_create_collection); - TestSuite_AddLive ( - suite, "/Database/get_collection_info", test_get_collection_info); - TestSuite_AddLive (suite, - "/Database/get_collection_info_regex", - test_get_collection_info_regex); - TestSuite_AddLive (suite, - "/Database/get_collection_info_with_opts_regex", - test_get_collection_info_with_opts_regex); - TestSuite_AddMockServerTest (suite, - "/Database/get_collection/getmore_cmd", - test_get_collection_info_getmore_cmd); - TestSuite_AddLive (suite, "/Database/get_collection", test_get_collection); - TestSuite_AddLive ( - suite, "/Database/get_collection_names", test_get_collection_names); - TestSuite_AddMockServerTest (suite, - "/Database/get_collection_names_error", - test_get_collection_names_error); - TestSuite_Add ( - suite, "/Database/get_default_database", test_get_default_database); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-dns.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-dns.c deleted file mode 100644 index 7820b8592..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-dns.c +++ /dev/null @@ -1,1336 +0,0 @@ -#include "mongoc/mongoc-util-private.h" -#include "mongoc/mongoc-client-pool-private.h" -#include "mongoc/mongoc.h" -#include "mongoc/mongoc-host-list-private.h" -#include "mongoc/mongoc-thread-private.h" -#include "mongoc/mongoc-uri-private.h" -#include "mongoc/utlist.h" - -#ifdef MONGOC_ENABLE_SSL -#include "mongoc/mongoc-ssl.h" -#include "mongoc/mongoc-ssl-private.h" -#endif - -#include "json-test.h" -#include "test-libmongoc.h" - -static void -_assert_options_match (const bson_t *test, mongoc_uri_t *uri) -{ - match_ctx_t ctx = {{0}}; - bson_iter_t iter; - bson_t opts_from_test; - const bson_t *opts_from_uri; - const bson_t *creds_from_uri; - const bson_t *opts_or_creds; - bson_iter_t test_opts_iter; - bson_iter_t uri_opts_iter; - const char *opt_name, *opt_name_canon; - const bson_value_t *test_value, *uri_value; - - if (!bson_iter_init_find (&iter, test, "options")) { - /* no URI options specified in the test */ - return; - } - - bson_iter_bson (&iter, &opts_from_test); - BSON_ASSERT (bson_iter_init (&test_opts_iter, &opts_from_test)); - - opts_from_uri = mongoc_uri_get_options (uri); - creds_from_uri = mongoc_uri_get_credentials (uri); - - while (bson_iter_next (&test_opts_iter)) { - opt_name = bson_iter_key (&test_opts_iter); - opt_name_canon = mongoc_uri_canonicalize_option (opt_name); - opts_or_creds = !bson_strcasecmp (opt_name, "authSource") ? creds_from_uri - : opts_from_uri; - if (!bson_iter_init_find_case ( - &uri_opts_iter, opts_or_creds, opt_name_canon)) { - test_error ("URI options incorrectly set from TXT record: " - "no option named \"%s\"\n" - "expected: %s\n" - "actual: %s", - opt_name, - bson_as_json (&opts_from_test, NULL), - bson_as_json (opts_or_creds, NULL)); - } - - test_value = bson_iter_value (&test_opts_iter); - uri_value = bson_iter_value (&uri_opts_iter); - if (!match_bson_value (uri_value, test_value, &ctx)) { - test_error ("URI option \"%s\" incorrectly set from TXT record: %s\n" - "expected: %s\n" - "actual: %s", - opt_name, - ctx.errmsg, - bson_as_json (&opts_from_test, NULL), - bson_as_json (opts_from_uri, NULL)); - } - } -} - - -typedef struct { - bson_mutex_t mutex; - mongoc_host_list_t *hosts; -} context_t; - - -static void -topology_changed (const mongoc_apm_topology_changed_t *event) -{ - context_t *ctx; - const mongoc_topology_description_t *td; - size_t i; - size_t n; - mongoc_server_description_t **sds; - - ctx = (context_t *) mongoc_apm_topology_changed_get_context (event); - - td = mongoc_apm_topology_changed_get_new_description (event); - sds = mongoc_topology_description_get_servers (td, &n); - - bson_mutex_lock (&ctx->mutex); - _mongoc_host_list_destroy_all (ctx->hosts); - ctx->hosts = NULL; - for (i = 0; i < n; i++) { - ctx->hosts = _mongoc_host_list_push ( - sds[i]->host.host, sds[i]->host.port, AF_UNSPEC, ctx->hosts); - } - bson_mutex_unlock (&ctx->mutex); - - mongoc_server_descriptions_destroy_all (sds, n); -} - - -static bool -host_list_contains (const mongoc_host_list_t *hl, const char *host_and_port) -{ - while (hl) { - if (!strcmp (hl->host_and_port, host_and_port)) { - return true; - } - - hl = hl->next; - } - - return false; -} - - -static int64_t -hosts_count (const bson_t *test) -{ - bson_iter_t iter; - bson_iter_t hosts; - int64_t c = 0; - - if (bson_iter_init_find (&iter, test, "hosts")) { - BSON_ASSERT (bson_iter_recurse (&iter, &hosts)); - while (bson_iter_next (&hosts)) { - c++; - } - } - - else if (bson_iter_init_find (&iter, test, "numHosts")) { - c = bson_iter_as_int64 (&iter); - } - - return c; -} - - -static bool -_host_list_matches (const bson_t *test, context_t *ctx) -{ - bson_iter_t iter; - bson_iter_t hosts; - const char *host_and_port; - bool ret = true; - - if (bson_iter_init_find (&iter, test, "hosts")) { - BSON_ASSERT (bson_iter_recurse (&iter, &hosts)); - - bson_mutex_lock (&ctx->mutex); - BSON_ASSERT (bson_iter_recurse (&iter, &hosts)); - while (bson_iter_next (&hosts)) { - host_and_port = bson_iter_utf8 (&hosts, NULL); - if (!host_list_contains (ctx->hosts, host_and_port)) { - ret = false; - break; - } - } - - _mongoc_host_list_destroy_all (ctx->hosts); - ctx->hosts = NULL; - bson_mutex_unlock (&ctx->mutex); - } - - else if (bson_iter_init_find (&iter, test, "numHosts")) { - const int64_t expected = bson_iter_as_int64 (&iter); - - bson_mutex_lock (&ctx->mutex); - const size_t actual = _mongoc_host_list_length (ctx->hosts); - _mongoc_host_list_destroy_all (ctx->hosts); - ctx->hosts = NULL; - bson_mutex_unlock (&ctx->mutex); - - ret = bson_cmp_equal_su (expected, actual); - } - - return ret; -} - -typedef struct { - const char *uri_str; - const char *reason; -} skipped_dns_test_t; - -skipped_dns_test_t SKIPPED_DNS_TESTS[] = { - {"mongodb+srv://test5.test.build.10gen.cc/?authSource=otherDB", - "C driver requires username present if any auth fields are present"}, - {0}}; - -static bool -is_test_skipped (const char *uri_str) -{ - skipped_dns_test_t *skip; - - for (skip = SKIPPED_DNS_TESTS; skip->uri_str != NULL; skip++) { - if (!strcmp (skip->uri_str, uri_str)) { - MONGOC_DEBUG ( - "Skipping test of URI: %s Reason: %s", skip->uri_str, skip->reason); - return true; - } - } - - return false; -} - -static void -_test_dns_maybe_pooled (bson_t *test, bool pooled) -{ - context_t ctx; - bool expect_ssl; - bool expect_error; - mongoc_uri_t *uri; - mongoc_apm_callbacks_t *callbacks; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; -#ifdef MONGOC_ENABLE_SSL - mongoc_ssl_opt_t ssl_opts; -#endif - bson_error_t error; - bool r; - const char *uri_str; - - if (!test_framework_get_ssl ()) { - test_error ( - "Must configure an SSL replica set and set MONGOC_TEST_SSL=on " - "and other ssl options to test DNS"); - } - - uri_str = bson_lookup_utf8 (test, "uri"); - if (is_test_skipped (uri_str)) { - return; - } - - bson_mutex_init (&ctx.mutex); - ctx.hosts = NULL; - expect_ssl = strstr (uri_str, "ssl=false") == NULL; - expect_error = _mongoc_lookup_bool (test, "error", false /* default */); - - uri = mongoc_uri_new_with_error (uri_str, &error); - if (!expect_error) { - ASSERT_OR_PRINT (uri, error); - } - - if (!uri) { - /* expected failure, e.g. we're testing an invalid URI */ - return; - } - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_topology_changed_cb (callbacks, topology_changed); - - /* suppress "cannot override URI option" messages */ - capture_logs (true); - -#ifdef MONGOC_ENABLE_SSL - ssl_opts = *test_framework_get_ssl_opts (); - ssl_opts.allow_invalid_hostname = true; -#endif - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - - if (!expect_error) { - BSON_ASSERT (pool); - } - - if (!pool) { - /* expected failure, e.g. SRV lookup or URI finalization failed */ - goto cleanup; - } - - /* before we set SSL on so that we can connect to the test replica set, - * assert that the URI has SSL on by default, and SSL off if "ssl=false" - * is in the URI string */ - BSON_ASSERT ( - mongoc_uri_get_tls (_mongoc_client_pool_get_topology (pool)->uri) == - expect_ssl); -#ifdef MONGOC_ENABLE_SSL - mongoc_client_pool_set_ssl_opts (pool, &ssl_opts); -#else - test_framework_set_pool_ssl_opts (pool); -#endif - mongoc_client_pool_set_apm_callbacks (pool, callbacks, &ctx); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - - if (!expect_error) { - BSON_ASSERT (client); - } - - if (!client) { - /* expected failure, e.g. SRV lookup or URI finalization failed */ - goto cleanup; - } - - BSON_ASSERT (mongoc_uri_get_tls (client->uri) == expect_ssl); -#ifdef MONGOC_ENABLE_SSL - mongoc_client_set_ssl_opts (client, &ssl_opts); -#else - test_framework_set_ssl_opts (client); -#endif - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - } - -#ifdef MONGOC_ENABLE_SSL - BSON_ASSERT (client->ssl_opts.allow_invalid_hostname); -#endif - - const int64_t n_hosts = hosts_count (test); - - if (pooled) { - if (n_hosts > 0 && !expect_error) { - WAIT_UNTIL (_host_list_matches (test, &ctx)); - } else { - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - ""); - } - } else if (NULL == mongoc_uri_get_username (uri)) { - /* Skip single-threaded tests containing auth credentials. Monitoring - * connections need to authenticate, and the credentials in the tests do - * not correspond to the test users. TODO (CDRIVER-4046): unskip these - * tests. */ - if (n_hosts > 0 && !expect_error) { - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - WAIT_UNTIL (_host_list_matches (test, &ctx)); - } else { - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - ""); - } - } - - /* the client's URI is updated after initial seedlist discovery (though for - * background SRV polling, only the topology's URI is updated). Check that - * both the topology and client URI have the expected options. */ - _assert_options_match (test, client->uri); - _assert_options_match (test, client->topology->uri); - - /* the client has a copy of the topology's URI, assert they're the same */ - ASSERT (bson_equal (mongoc_uri_get_options (client->uri), - mongoc_uri_get_options (client->topology->uri))); - ASSERT (bson_equal (mongoc_uri_get_credentials (client->uri), - mongoc_uri_get_credentials (client->topology->uri))); - if (!mongoc_uri_get_hosts (client->uri)) { - ASSERT (!mongoc_uri_get_hosts (client->topology->uri)); - } else { - _mongoc_host_list_compare_one ( - mongoc_uri_get_hosts (client->uri), - mongoc_uri_get_hosts (client->topology->uri)); - } - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - -cleanup: - mongoc_apm_callbacks_destroy (callbacks); - mongoc_uri_destroy (uri); -} - - -static void -test_dns (bson_t *test) -{ - _test_dns_maybe_pooled (test, false); - _test_dns_maybe_pooled (test, true); -} - - -static int -test_dns_check_replset (void) -{ - return test_framework_getenv_bool ("MONGOC_TEST_DNS") ? 1 : 0; -} - -static int -test_dns_check_loadbalanced (void) -{ - return test_framework_getenv_bool ("MONGOC_TEST_DNS_LOADBALANCED") ? 1 : 0; -} - -static int -test_dns_check_srv_polling (void) -{ - return test_framework_getenv_bool ("MONGOC_TEST_DNS_SRV_POLLING") ? 1 : 0; -} - - -/* - *----------------------------------------------------------------------- - * - * Runner for the JSON tests for mongodb+srv URIs. - * - *----------------------------------------------------------------------- - */ -static void -test_all_spec_tests (TestSuite *suite) -{ - install_json_test_suite_with_check ( - suite, - JSON_DIR, - "initial_dns_seedlist_discovery/replica-set", - test_dns, - test_dns_check_replset, - test_framework_skip_if_no_crypto); - - install_json_test_suite_with_check ( - suite, - JSON_DIR, - "initial_dns_seedlist_discovery/load-balanced", - test_dns, - test_dns_check_loadbalanced, - test_framework_skip_if_no_crypto); - - install_json_test_suite_with_check ( - suite, - JSON_DIR, - "initial_dns_seedlist_discovery/sharded", - test_dns, - /* Topology of load-balancer tests satisfy topology requirements of - * sharded tests, even though a load balancer is not required. */ - test_dns_check_loadbalanced, - test_framework_skip_if_no_crypto); -} - -extern bool -mongoc_topology_apply_scanned_srv_hosts (mongoc_uri_t *uri, - mongoc_topology_description_t *td, - mongoc_host_list_t *hosts, - bson_error_t *error); - -static mongoc_host_list_t * -make_hosts (char *first_host, ...) -{ - va_list va; - mongoc_host_list_t *hosts = NULL; - mongoc_host_list_t host; - char *host_str; - - _mongoc_host_list_from_string (&host, first_host); - _mongoc_host_list_upsert (&hosts, &host); - - va_start (va, first_host); - while ((host_str = va_arg (va, char *))) { - _mongoc_host_list_from_string (&host, host_str); - _mongoc_host_list_upsert (&hosts, &host); - } - va_end (va); - return hosts; -} - -#define MAKE_HOSTS(...) make_hosts (__VA_ARGS__, NULL) - -static void -dump_hosts (mongoc_host_list_t *hosts) -{ - mongoc_host_list_t *host; - - MONGOC_DEBUG ("hosts:"); - - LL_FOREACH (hosts, host) - { - MONGOC_DEBUG ("- %s", host->host_and_port); - } -} - -static void -dump_topology_description (const mongoc_topology_description_t *td) -{ - const mongoc_server_description_t *sd; - const mongoc_set_t *servers = mc_tpld_servers_const (td); - - MONGOC_DEBUG ("topology hosts:"); - for (size_t i = 0u; i < servers->items_len; ++i) { - sd = mongoc_set_get_item_const (servers, i); - MONGOC_DEBUG ("- %s", sd->host.host_and_port); - } -} - -static void -check_topology_description (mongoc_topology_description_t *td, - mongoc_host_list_t *hosts) -{ - size_t nhosts = 0u; - mongoc_host_list_t *host; - const mongoc_set_t *servers = mc_tpld_servers_const (td); - - for (host = hosts; host; host = host->next) { - ++nhosts; - - /* Check that "host" is already in the topology description by upserting - * it, and ensuring that the number of servers remains constant. */ - const size_t server_count = servers->items_len; - BSON_ASSERT (mongoc_topology_description_add_server ( - td, host->host_and_port, NULL)); - - if (server_count != servers->items_len) { - dump_topology_description (td); - dump_hosts (hosts); - test_error ("topology description did not have host: %s", - host->host_and_port); - } - } - - if (nhosts != servers->items_len) { - dump_topology_description (td); - dump_hosts (hosts); - test_error ("topology description had extra hosts"); - } -} - -static void -test_srv_polling_mocked (void *unused) -{ - mongoc_uri_t *uri; - mongoc_topology_description_t td; - bson_error_t error; - mongoc_host_list_t *hosts; - mongoc_host_list_t *expected; - bool ret; - - BSON_UNUSED (unused); - - mongoc_topology_description_init (&td, 0); - uri = mongoc_uri_new ("mongodb+srv://server.test.com/?tls=true"); - capture_logs (true); - - hosts = MAKE_HOSTS ("a.test.com", "b.test.com"); - expected = MAKE_HOSTS ("a.test.com", "b.test.com"); - ret = mongoc_topology_apply_scanned_srv_hosts (uri, &td, hosts, &error); - ASSERT_OR_PRINT (ret, error); - check_topology_description (&td, expected); - _mongoc_host_list_destroy_all (expected); - _mongoc_host_list_destroy_all (hosts); - ASSERT_NO_CAPTURED_LOGS ("topology"); - - /* Add an extra host. */ - hosts = MAKE_HOSTS ("x.test.com", "a.test.com", "y.test.com", "b.test.com"); - expected = - MAKE_HOSTS ("x.test.com", "a.test.com", "y.test.com", "b.test.com"); - ret = mongoc_topology_apply_scanned_srv_hosts (uri, &td, hosts, &error); - ASSERT_OR_PRINT (ret, error); - check_topology_description (&td, expected); - _mongoc_host_list_destroy_all (expected); - _mongoc_host_list_destroy_all (hosts); - ASSERT_NO_CAPTURED_LOGS ("topology"); - - /* Remove all but one host. */ - hosts = MAKE_HOSTS ("x.test.com"); - expected = MAKE_HOSTS ("x.test.com"); - ret = mongoc_topology_apply_scanned_srv_hosts (uri, &td, hosts, &error); - ASSERT_OR_PRINT (ret, error); - check_topology_description (&td, expected); - _mongoc_host_list_destroy_all (expected); - _mongoc_host_list_destroy_all (hosts); - ASSERT_NO_CAPTURED_LOGS ("topology"); - - /* Add one valid and one invalid. Invalid should skip, warning should be - * logged. */ - hosts = MAKE_HOSTS ("x.test.com", "y.test.com", "bad.wrongdomain.com"); - expected = MAKE_HOSTS ("x.test.com", "y.test.com"); - ret = mongoc_topology_apply_scanned_srv_hosts (uri, &td, hosts, &error); - ASSERT_OR_PRINT (ret, error); - check_topology_description (&td, expected); - _mongoc_host_list_destroy_all (expected); - _mongoc_host_list_destroy_all (hosts); - ASSERT_CAPTURED_LOG ("topology", MONGOC_LOG_LEVEL_ERROR, "Invalid host"); - - /* An empty host list returns false but does NOT change topology description - */ - expected = MAKE_HOSTS ("x.test.com", "y.test.com"); - ret = mongoc_topology_apply_scanned_srv_hosts (uri, &td, NULL, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "SRV response did not contain any valid hosts"); - check_topology_description (&td, expected); - _mongoc_host_list_destroy_all (expected); - ASSERT_CAPTURED_LOG ("topology", MONGOC_LOG_LEVEL_ERROR, "Invalid host"); - - /* All invalid hosts returns false but does NOT change topology description - */ - hosts = MAKE_HOSTS ("bad1.wrongdomain.com", "bad2.wrongdomain.com"); - expected = MAKE_HOSTS ("x.test.com", "y.test.com"); - ret = mongoc_topology_apply_scanned_srv_hosts (uri, &td, NULL, &error); - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "SRV response did not contain any valid hosts"); - check_topology_description (&td, expected); - _mongoc_host_list_destroy_all (expected); - _mongoc_host_list_destroy_all (hosts); - ASSERT_CAPTURED_LOG ("topology", MONGOC_LOG_LEVEL_ERROR, "Invalid host"); - - mongoc_topology_description_cleanup (&td); - mongoc_uri_destroy (uri); -} - -static void -test_small_initial_buffer (void *unused) -{ - mongoc_rr_type_t rr_type = MONGOC_RR_SRV; - mongoc_rr_data_t rr_data; - bson_error_t error; - /* Size needs to be large enough to fit DNS answer header to not error, but - * smaller than SRV response to test. The SRV response is 155 bytes. This can - * be determined with: dig -t SRV _mongodb._tcp.test1.test.build.10gen.cc */ - size_t small_buffer_size = 30; - - BSON_UNUSED (unused); - - memset (&rr_data, 0, sizeof (rr_data)); - ASSERT_OR_PRINT ( - _mongoc_client_get_rr ("_mongodb._tcp.test1.test.build.10gen.cc", - rr_type, - &rr_data, - small_buffer_size, - &error), - error); - ASSERT_CMPINT (rr_data.count, ==, 2); - bson_free (rr_data.txt_record_opts); - _mongoc_host_list_destroy_all (rr_data.hosts); -} - -bool -_mock_rr_resolver_prose_test_9 (const char *service, - mongoc_rr_type_t rr_type, - mongoc_rr_data_t *rr_data, - size_t initial_buffer_size, - bson_error_t *error) -{ - BSON_UNUSED (service); - BSON_UNUSED (rr_type); - BSON_UNUSED (rr_data); - BSON_UNUSED (initial_buffer_size); - BSON_UNUSED (error); - - test_error ("Expected mock resolver to not be called"); - return true; -} - -static void -_prose_test_ping (mongoc_client_t *client) -{ - bson_error_t error; - bson_t *cmd = BCON_NEW ("ping", BCON_INT32 (1)); - - ASSERT (client); - - if (!mongoc_client_command_simple ( - client, "admin", cmd, NULL, NULL, &error)) { - test_error ("ping failed: %s", error.message); - } - - bson_destroy (cmd); -} - -/* SRV Polling Tests Spec: rescanSRVIntervalMS */ -#define RESCAN_INTERVAL_MS 500 - -static void * -_prose_test_init_resource_single (const mongoc_uri_t *uri, - _mongoc_rr_resolver_fn fn) -{ - mongoc_client_t *client; - mongoc_topology_t *topology; - - BSON_ASSERT_PARAM (uri); - BSON_ASSERT_PARAM (fn); - - client = mongoc_client_new_from_uri (uri); - topology = client->topology; - - _mongoc_topology_set_rr_resolver (topology, fn); - _mongoc_topology_set_srv_polling_rescan_interval_ms (topology, - RESCAN_INTERVAL_MS); - -#if defined(MONGOC_ENABLE_SSL) - { - mongoc_ssl_opt_t ssl_opts = *test_framework_get_ssl_opts (); - ssl_opts.allow_invalid_hostname = true; - mongoc_client_set_ssl_opts (client, &ssl_opts); - } -#endif /* defined(MONGOC_ENABLE_SSL) */ - - return client; -} - -static void * -_prose_test_init_resource_pooled (const mongoc_uri_t *uri, - _mongoc_rr_resolver_fn fn) -{ - mongoc_client_pool_t *pool; - mongoc_topology_t *topology; - - BSON_ASSERT_PARAM (uri); - BSON_ASSERT_PARAM (fn); - - pool = mongoc_client_pool_new (uri); - topology = _mongoc_client_pool_get_topology (pool); - - _mongoc_topology_set_rr_resolver (topology, fn); - _mongoc_topology_set_srv_polling_rescan_interval_ms (topology, - RESCAN_INTERVAL_MS); - -#if defined(MONGOC_ENABLE_SSL) - { - mongoc_ssl_opt_t ssl_opts = *test_framework_get_ssl_opts (); - ssl_opts.allow_invalid_hostname = true; - mongoc_client_pool_set_ssl_opts (pool, &ssl_opts); - } -#endif /* defined(MONGOC_ENABLE_SSL) */ - - return pool; -} - -static void -_prose_test_free_resource_single (void *resource) -{ - mongoc_client_destroy ((mongoc_client_t *) resource); -} - -static void -_prose_test_free_resource_pooled (void *resource) -{ - mongoc_client_pool_destroy ((mongoc_client_pool_t *) resource); -} - -static mongoc_client_t * -_prose_test_get_client_single (void *resource) -{ - BSON_ASSERT_PARAM (resource); - return (mongoc_client_t *) resource; -} - -static mongoc_client_t * -_prose_test_get_client_pooled (void *resource) -{ - BSON_ASSERT_PARAM (resource); - return mongoc_client_pool_pop (((mongoc_client_pool_t *) resource)); -} - -static void -_prose_test_release_client_single (void *resource, mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (resource); - BSON_ASSERT_PARAM (client); - /* Nothing to do. */ -} - -static void -_prose_test_release_client_pooled (void *resource, mongoc_client_t *client) -{ - BSON_ASSERT_PARAM (resource); - BSON_ASSERT_PARAM (client); - mongoc_client_pool_push ((mongoc_client_pool_t *) resource, client); -} - -static void -_prose_test_update_srv_single (void *resource) -{ - mongoc_client_t *client; - - BSON_ASSERT_PARAM (resource); - - client = resource; - - _mongoc_usleep (2000 * RESCAN_INTERVAL_MS); - - /* Avoid ping given `loadBalanced=true`; see prose test 9. */ - if (!mongoc_uri_get_option_as_bool ( - client->uri, MONGOC_URI_LOADBALANCED, false)) { - _prose_test_ping (client); - } -} - -static void -_prose_test_update_srv_pooled (void *resource) -{ - BSON_ASSERT_PARAM (resource); - - _mongoc_usleep (2000 * RESCAN_INTERVAL_MS); -} - -typedef struct { - void *(*init_resource) (const mongoc_uri_t *uri, _mongoc_rr_resolver_fn fn); - void (*free_resource) (void *); - mongoc_client_t *(*get_client) (void *resource); - void (*release_client) (void *resource, mongoc_client_t *client); - void (*update_srv) (void *); -} _prose_test_fns_t; - -static const _prose_test_fns_t _prose_test_single_fns = { - _prose_test_init_resource_single, - _prose_test_free_resource_single, - _prose_test_get_client_single, - _prose_test_release_client_single, - _prose_test_update_srv_single}; - -static const _prose_test_fns_t _prose_test_pooled_fns = { - _prose_test_init_resource_pooled, - _prose_test_free_resource_pooled, - _prose_test_get_client_pooled, - _prose_test_release_client_pooled, - _prose_test_update_srv_pooled}; - -static void -_prose_test_9 (const _prose_test_fns_t *fns) -{ - void *resource; - - BSON_ASSERT_PARAM (fns); - - { - mongoc_uri_t *const uri = - mongoc_uri_new ("mongodb+srv://test3.test.build.10gen.cc"); - - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_LOADBALANCED, true); - mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, RESCAN_INTERVAL_MS); - - resource = fns->init_resource (uri, _mock_rr_resolver_prose_test_9); - - mongoc_uri_destroy (uri); - } - - { - mongoc_host_list_t *const expected = - MAKE_HOSTS ("localhost.test.build.10gen.cc:27017"); - mongoc_client_t *const client = fns->get_client (resource); - - { - mc_tpld_modification tdmod = mc_tpld_modify_begin (client->topology); - check_topology_description (tdmod.new_td, expected); - mc_tpld_modify_drop (tdmod); - } - - fns->release_client (resource, client); - _mongoc_host_list_destroy_all (expected); - } - - fns->update_srv (resource); - - { - mongoc_host_list_t *const expected = - MAKE_HOSTS ("localhost.test.build.10gen.cc:27017"); - mongoc_client_t *const client = fns->get_client (resource); - - { - mc_tpld_modification tdmod = mc_tpld_modify_begin (client->topology); - check_topology_description (tdmod.new_td, expected); - mc_tpld_modify_drop (tdmod); - } - - fns->release_client (resource, client); - _mongoc_host_list_destroy_all (expected); - } - - fns->free_resource (resource); -} - -static void -prose_test_9_single (void *unused) -{ - BSON_UNUSED (unused); - - _prose_test_9 (&_prose_test_single_fns); -} - -static void -prose_test_9_pooled (void *unused) -{ - BSON_UNUSED (unused); - - _prose_test_9 (&_prose_test_pooled_fns); -} - -static bool -_mock_rr_resolver_prose_test_10 (const char *service, - mongoc_rr_type_t rr_type, - mongoc_rr_data_t *rr_data, - size_t initial_buffer_size, - bson_error_t *error) -{ - BSON_UNUSED (initial_buffer_size); - - BSON_ASSERT_PARAM (service); - BSON_ASSERT_PARAM (rr_data); - BSON_ASSERT_PARAM (error); - - if (rr_type == MONGOC_RR_SRV) { - const size_t count = _mongoc_host_list_length (rr_data->hosts); - BSON_ASSERT (bson_in_range_unsigned (uint32_t, count)); - - rr_data->hosts = MAKE_HOSTS ("localhost.test.build.10gen.cc:27017", - "localhost.test.build.10gen.cc:27019", - "localhost.test.build.10gen.cc:27020"); - rr_data->count = (uint32_t) count; - rr_data->min_ttl = 0u; - rr_data->txt_record_opts = NULL; - } - - error->code = 0u; - - return true; -} - -static void -_prose_test_10 (const _prose_test_fns_t *fns) -{ - void *resource; - - BSON_ASSERT_PARAM (fns); - - { - mongoc_uri_t *const uri = - mongoc_uri_new ("mongodb+srv://test1.test.build.10gen.cc"); - - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_SRVMAXHOSTS, 0); - mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, RESCAN_INTERVAL_MS); - - resource = fns->init_resource (uri, _mock_rr_resolver_prose_test_10); - - mongoc_uri_destroy (uri); - } - - { - mongoc_host_list_t *const expected = - MAKE_HOSTS ("localhost.test.build.10gen.cc:27017", - "localhost.test.build.10gen.cc:27018"); - mongoc_client_t *const client = fns->get_client (resource); - - { - mc_tpld_modification tdmod = mc_tpld_modify_begin (client->topology); - check_topology_description (tdmod.new_td, expected); - mc_tpld_modify_drop (tdmod); - } - - fns->release_client (resource, client); - _mongoc_host_list_destroy_all (expected); - } - - fns->update_srv (resource); - - { - mongoc_host_list_t *const expected = - MAKE_HOSTS ("localhost.test.build.10gen.cc:27017", - "localhost.test.build.10gen.cc:27019", - "localhost.test.build.10gen.cc:27020"); - mongoc_client_t *const client = fns->get_client (resource); - - { - mc_tpld_modification tdmod = mc_tpld_modify_begin (client->topology); - check_topology_description (tdmod.new_td, expected); - mc_tpld_modify_drop (tdmod); - } - - fns->release_client (resource, client); - _mongoc_host_list_destroy_all (expected); - } - - fns->free_resource (resource); -} - -static void -prose_test_10_single (void *unused) -{ - BSON_UNUSED (unused); - - _prose_test_10 (&_prose_test_single_fns); -} - -static void -prose_test_10_pooled (void *unused) -{ - BSON_UNUSED (unused); - - _prose_test_10 (&_prose_test_pooled_fns); -} - -static bool -_mock_rr_resolver_prose_test_11 (const char *service, - mongoc_rr_type_t rr_type, - mongoc_rr_data_t *rr_data, - size_t initial_buffer_size, - bson_error_t *error) -{ - BSON_UNUSED (initial_buffer_size); - - BSON_ASSERT_PARAM (service); - BSON_ASSERT_PARAM (rr_data); - BSON_ASSERT_PARAM (error); - - if (rr_type == MONGOC_RR_SRV) { - const size_t count = _mongoc_host_list_length (rr_data->hosts); - BSON_ASSERT (bson_in_range_unsigned (uint32_t, count)); - - rr_data->hosts = MAKE_HOSTS ("localhost.test.build.10gen.cc:27019", - "localhost.test.build.10gen.cc:27020"); - rr_data->count = (uint32_t) count; - rr_data->min_ttl = 0u; - rr_data->txt_record_opts = NULL; - } - - error->code = 0u; - - return true; -} - -static void -_prose_test_11 (const _prose_test_fns_t *fns) -{ - void *resource; - - BSON_ASSERT_PARAM (fns); - - { - mongoc_uri_t *const uri = - mongoc_uri_new ("mongodb+srv://test1.test.build.10gen.cc"); - - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_SRVMAXHOSTS, 2); - mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, RESCAN_INTERVAL_MS); - - resource = fns->init_resource (uri, _mock_rr_resolver_prose_test_11); - - mongoc_uri_destroy (uri); - } - - { - mongoc_host_list_t *const expected = - MAKE_HOSTS ("localhost.test.build.10gen.cc:27017", - "localhost.test.build.10gen.cc:27018"); - mongoc_client_t *const client = fns->get_client (resource); - - { - mc_tpld_modification tdmod = mc_tpld_modify_begin (client->topology); - check_topology_description (tdmod.new_td, expected); - mc_tpld_modify_drop (tdmod); - } - - fns->release_client (resource, client); - _mongoc_host_list_destroy_all (expected); - } - - fns->update_srv (resource); - - { - mongoc_host_list_t *const expected = - MAKE_HOSTS ("localhost.test.build.10gen.cc:27019", - "localhost.test.build.10gen.cc:27020"); - mongoc_client_t *const client = fns->get_client (resource); - - { - mc_tpld_modification tdmod = mc_tpld_modify_begin (client->topology); - check_topology_description (tdmod.new_td, expected); - mc_tpld_modify_drop (tdmod); - } - - fns->release_client (resource, client); - _mongoc_host_list_destroy_all (expected); - } - - fns->free_resource (resource); -} - -static void -prose_test_11_single (void *unused) -{ - BSON_UNUSED (unused); - - _prose_test_11 (&_prose_test_single_fns); -} - -static void -prose_test_11_pooled (void *unused) -{ - BSON_UNUSED (unused); - - _prose_test_11 (&_prose_test_pooled_fns); -} - -static bool -_mock_rr_resolver_prose_test_12 (const char *service, - mongoc_rr_type_t rr_type, - mongoc_rr_data_t *rr_data, - size_t initial_buffer_size, - bson_error_t *error) -{ - BSON_UNUSED (initial_buffer_size); - - BSON_ASSERT_PARAM (service); - BSON_ASSERT_PARAM (rr_data); - BSON_ASSERT_PARAM (error); - - if (rr_type == MONGOC_RR_SRV) { - const size_t count = _mongoc_host_list_length (rr_data->hosts); - BSON_ASSERT (bson_in_range_unsigned (uint32_t, count)); - - rr_data->hosts = MAKE_HOSTS ("localhost.test.build.10gen.cc:27017", - "localhost.test.build.10gen.cc:27019", - "localhost.test.build.10gen.cc:27020"); - rr_data->count = (uint32_t) count; - rr_data->min_ttl = 0u; - rr_data->txt_record_opts = NULL; - } - - error->code = 0u; - - return true; -} - -typedef struct { - size_t num_existing; - size_t num_new_valid; -} _prose_test_12_ctx_t; - -static bool -_prose_test_12_cb (const void *sd_void, void *ctx_void) -{ - const mongoc_server_description_t *sd; - _prose_test_12_ctx_t *ctx; - const mongoc_host_list_t *host; - - BSON_ASSERT_PARAM (sd_void); - BSON_ASSERT_PARAM (ctx_void); - - sd = sd_void; - ctx = ctx_void; - host = &sd->host; - - ASSERT_CMPSTR (host->host, "localhost.test.build.10gen.cc"); - - if (host->port == 27017u) { - ++ctx->num_existing; - } - - else { - ASSERT (host->port == 27019 || host->port == 27020); - ++ctx->num_new_valid; - } - - return true; -} - -static void -_prose_test_12 (const _prose_test_fns_t *fns) -{ - void *resource; - - BSON_ASSERT_PARAM (fns); - - { - mongoc_uri_t *const uri = - mongoc_uri_new ("mongodb+srv://test1.test.build.10gen.cc"); - - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_SRVMAXHOSTS, 2); - mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, RESCAN_INTERVAL_MS); - - resource = fns->init_resource (uri, _mock_rr_resolver_prose_test_12); - - mongoc_uri_destroy (uri); - } - - { - mongoc_host_list_t *const expected = - MAKE_HOSTS ("localhost.test.build.10gen.cc:27017", - "localhost.test.build.10gen.cc:27018"); - mongoc_client_t *const client = fns->get_client (resource); - - { - mc_tpld_modification tdmod = mc_tpld_modify_begin (client->topology); - check_topology_description (tdmod.new_td, expected); - mc_tpld_modify_drop (tdmod); - } - - fns->release_client (resource, client); - _mongoc_host_list_destroy_all (expected); - } - - fns->update_srv (resource); - - { - mongoc_client_t *const client = fns->get_client (resource); - _prose_test_12_ctx_t ctx; - - ctx.num_existing = 0u; - ctx.num_new_valid = 0u; - - { - mc_tpld_modification tdmod = mc_tpld_modify_begin (client->topology); - const mongoc_set_t *servers = mc_tpld_servers_const (tdmod.new_td); - mongoc_set_for_each_const (servers, _prose_test_12_cb, &ctx); - mc_tpld_modify_drop (tdmod); - } - - ASSERT_WITH_MSG ( - ctx.num_existing > 0u, - "hosts that have not changed must be left alone and unchanged"); - ASSERT_WITH_MSG (ctx.num_existing == 1u, - "only a single host should have remained, but found %zu", - ctx.num_existing); - - ASSERT_WITH_MSG (ctx.num_new_valid == 1u, - "exactly one valid new hosts should have been added"); - - fns->release_client (resource, client); - } - - fns->free_resource (resource); -} - -static void -prose_test_12_single (void *unused) -{ - BSON_UNUSED (unused); - - _prose_test_12 (&_prose_test_single_fns); -} - -static void -prose_test_12_pooled (void *unused) -{ - BSON_UNUSED (unused); - - _prose_test_12 (&_prose_test_pooled_fns); -} - -void -test_dns_install (TestSuite *suite) -{ - test_all_spec_tests (suite); - TestSuite_AddFull (suite, - "/initial_dns_seedlist_discovery/srv_polling/mocked", - test_srv_polling_mocked, - NULL, - NULL, - NULL); - TestSuite_AddFull (suite, - "/initial_dns_seedlist_discovery/small_initial_buffer", - test_small_initial_buffer, - NULL, - NULL, - test_dns_check_replset); - - /* TODO (CDRIVER-4045): remove /initial_dns_seedlist_discovery from the path - * of the SRV polling tests, since they are defined in the "Polling SRV - * Records for mongos Discovery" spec, not the "Initial DNS Seedlist - * Discovery" spec. */ - TestSuite_AddFull ( - suite, - "/initial_dns_seedlist_discovery/srv_polling/prose_test_9/single", - prose_test_9_single, - NULL, - NULL, - test_dns_check_srv_polling); - - TestSuite_AddFull ( - suite, - "/initial_dns_seedlist_discovery/srv_polling/prose_test_9/pooled", - prose_test_9_pooled, - NULL, - NULL, - test_dns_check_srv_polling); - - TestSuite_AddFull ( - suite, - "/initial_dns_seedlist_discovery/srv_polling/prose_test_10/single", - prose_test_10_single, - NULL, - NULL, - test_dns_check_srv_polling); - - TestSuite_AddFull ( - suite, - "/initial_dns_seedlist_discovery/srv_polling/prose_test_10/pooled", - prose_test_10_pooled, - NULL, - NULL, - test_dns_check_srv_polling); - - TestSuite_AddFull ( - suite, - "/initial_dns_seedlist_discovery/srv_polling/prose_test_11/single", - prose_test_11_single, - NULL, - NULL, - test_dns_check_srv_polling); - - TestSuite_AddFull ( - suite, - "/initial_dns_seedlist_discovery/srv_polling/prose_test_11/pooled", - prose_test_11_pooled, - NULL, - NULL, - test_dns_check_srv_polling); - - TestSuite_AddFull ( - suite, - "/initial_dns_seedlist_discovery/srv_polling/prose_test_12/single", - prose_test_12_single, - NULL, - NULL, - test_dns_check_srv_polling); - - TestSuite_AddFull ( - suite, - "/initial_dns_seedlist_discovery/srv_polling/prose_test_12/pooled", - prose_test_12_pooled, - NULL, - NULL, - test_dns_check_srv_polling); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-error.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-error.c deleted file mode 100644 index 032b7e413..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-error.c +++ /dev/null @@ -1,254 +0,0 @@ -#include - -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" -#include "mongoc/mongoc-error-private.h" - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "error-test" - - -static void -test_set_error_api_single (void) -{ - mongoc_client_t *client; - int32_t unsupported_versions[] = {-1, 0, 3}; - int i; - - capture_logs (true); - client = test_framework_new_default_client (); - - for (i = 0; i < sizeof (unsupported_versions) / sizeof (int32_t); i++) { - ASSERT (!mongoc_client_set_error_api (client, unsupported_versions[i])); - ASSERT_CAPTURED_LOG ("mongoc_client_set_error_api", - MONGOC_LOG_LEVEL_ERROR, - "Unsupported Error API Version"); - } - - mongoc_client_destroy (client); -} - - -static void -test_set_error_api_pooled (void) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - int32_t unsupported_versions[] = {-1, 0, 3}; - int i; - - capture_logs (true); - pool = test_framework_new_default_client_pool (); - - for (i = 0; i < sizeof (unsupported_versions) / sizeof (int32_t); i++) { - ASSERT ( - !mongoc_client_pool_set_error_api (pool, unsupported_versions[i])); - ASSERT_CAPTURED_LOG ("mongoc_client_pool_set_error_api", - MONGOC_LOG_LEVEL_ERROR, - "Unsupported Error API Version"); - } - - client = mongoc_client_pool_pop (pool); - ASSERT (!mongoc_client_set_error_api (client, 1)); - ASSERT_CAPTURED_LOG ("mongoc_client_set_error_api", - MONGOC_LOG_LEVEL_ERROR, - "Cannot set Error API Version on a pooled client"); - - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); -} - - -static void -_test_command_error (int32_t error_api_version) -{ - mock_server_t *server; - mongoc_client_t *client; - bson_t reply; - bson_error_t error; - future_t *future; - request_t *request; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - if (error_api_version != 0) { - BSON_ASSERT (mongoc_client_set_error_api (client, error_api_version)); - } - - future = future_client_command_simple ( - client, "db", tmp_bson ("{'foo': 1}"), NULL, &reply, &error); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'db', 'foo': 1}")); - reply_to_request_simple (request, "{'ok': 0, 'code': 42, 'errmsg': 'foo'}"); - ASSERT (!future_get_bool (future)); - - if (error_api_version >= 2) { - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 42, "foo"); - } else { - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_QUERY, 42, "foo"); - } - - future_destroy (future); - request_destroy (request); - bson_destroy (&reply); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_command_error_default (void) -{ - _test_command_error (0); -} - - -static void -test_command_error_v1 (void) -{ - _test_command_error (1); -} - - -static void -test_command_error_v2 (void) -{ - _test_command_error (2); -} - -static void -test_has_label (void) -{ - bson_t *reply = tmp_bson ("{'errorLabels': ['foo', 'bar']}"); - BSON_ASSERT (mongoc_error_has_label (reply, "foo")); - BSON_ASSERT (mongoc_error_has_label (reply, "bar")); - BSON_ASSERT (!mongoc_error_has_label (reply, "baz")); - BSON_ASSERT (!mongoc_error_has_label (tmp_bson ("{}"), "foo")); -} - -static void -test_state_change_helper (uint32_t domain, bool expect_error) -{ - bson_error_t error; - mongoc_server_err_t not_primary_codes[] = { - MONGOC_SERVER_ERR_NOTPRIMARY, - MONGOC_SERVER_ERR_NOTPRIMARYNOSECONDARYOK, - MONGOC_SERVER_ERR_LEGACYNOTPRIMARY}; - mongoc_server_err_t node_is_recovering_codes[] = { - MONGOC_SERVER_ERR_INTERRUPTEDATSHUTDOWN, - MONGOC_SERVER_ERR_INTERRUPTEDDUETOREPLSTATECHANGE, - MONGOC_SERVER_ERR_NOTPRIMARYORSECONDARY, - MONGOC_SERVER_ERR_PRIMARYSTEPPEDDOWN, - MONGOC_SERVER_ERR_SHUTDOWNINPROGRESS}; - mongoc_server_err_t shutdown_codes[] = { - MONGOC_SERVER_ERR_INTERRUPTEDATSHUTDOWN, - MONGOC_SERVER_ERR_SHUTDOWNINPROGRESS}; - int i; - - MONGOC_DEBUG ("Checking domain = %d", domain); - - memset (&error, 0, sizeof (bson_error_t)); - error.domain = domain; - - for (i = 0; i < sizeof (not_primary_codes) / sizeof (mongoc_server_err_t); - i++) { - error.code = not_primary_codes[i]; - BSON_ASSERT (expect_error == _mongoc_error_is_not_primary (&error)); - BSON_ASSERT (!_mongoc_error_is_recovering (&error)); - BSON_ASSERT (!_mongoc_error_is_shutdown (&error)); - BSON_ASSERT (expect_error == _mongoc_error_is_state_change (&error)); - } - for (i = 0; - i < sizeof (node_is_recovering_codes) / sizeof (mongoc_server_err_t); - i++) { - error.code = node_is_recovering_codes[i]; - BSON_ASSERT (!_mongoc_error_is_not_primary (&error)); - BSON_ASSERT (expect_error == _mongoc_error_is_recovering (&error)); - BSON_ASSERT (expect_error == _mongoc_error_is_state_change (&error)); - } - for (i = 0; i < sizeof (shutdown_codes) / sizeof (mongoc_server_err_t); - i++) { - error.code = shutdown_codes[i]; - BSON_ASSERT (!_mongoc_error_is_not_primary (&error)); - /* Shutdown errors are a subset of recovering errors. */ - BSON_ASSERT (expect_error == _mongoc_error_is_recovering (&error)); - BSON_ASSERT (expect_error == _mongoc_error_is_shutdown (&error)); - BSON_ASSERT (expect_error == _mongoc_error_is_state_change (&error)); - } - - /* Fallback code that's used when no code was returned */ - error.code = MONGOC_ERROR_QUERY_FAILURE; - bson_strncpy (error.message, "... not master ...", sizeof (error.message)); - BSON_ASSERT (expect_error == _mongoc_error_is_not_primary (&error)); - BSON_ASSERT (!_mongoc_error_is_recovering (&error)); - BSON_ASSERT (!_mongoc_error_is_shutdown (&error)); - BSON_ASSERT (expect_error == _mongoc_error_is_state_change (&error)); - - bson_strncpy ( - error.message, "... node is recovering ...", sizeof (error.message)); - BSON_ASSERT (!_mongoc_error_is_not_primary (&error)); - BSON_ASSERT (expect_error == _mongoc_error_is_recovering (&error)); - BSON_ASSERT (!_mongoc_error_is_shutdown (&error)); - BSON_ASSERT (expect_error == _mongoc_error_is_state_change (&error)); - - bson_strncpy ( - error.message, "... not master or secondary ...", sizeof (error.message)); - BSON_ASSERT (!_mongoc_error_is_not_primary (&error)); - BSON_ASSERT (expect_error == _mongoc_error_is_recovering (&error)); - BSON_ASSERT (!_mongoc_error_is_shutdown (&error)); - BSON_ASSERT (expect_error == _mongoc_error_is_state_change (&error)); - - error.code = 123; - bson_strncpy (error.message, "... not master ...", sizeof (error.message)); - BSON_ASSERT (!_mongoc_error_is_not_primary (&error)); - BSON_ASSERT (!_mongoc_error_is_recovering (&error)); - BSON_ASSERT (!_mongoc_error_is_shutdown (&error)); - BSON_ASSERT (!_mongoc_error_is_state_change (&error)); - - bson_strncpy ( - error.message, "... node is recovering ...", sizeof (error.message)); - BSON_ASSERT (!_mongoc_error_is_not_primary (&error)); - BSON_ASSERT (!_mongoc_error_is_recovering (&error)); - BSON_ASSERT (!_mongoc_error_is_shutdown (&error)); - BSON_ASSERT (!_mongoc_error_is_state_change (&error)); - - bson_strncpy ( - error.message, "... not master or secondary ...", sizeof (error.message)); - BSON_ASSERT (!_mongoc_error_is_not_primary (&error)); - BSON_ASSERT (!_mongoc_error_is_recovering (&error)); - BSON_ASSERT (!_mongoc_error_is_shutdown (&error)); - BSON_ASSERT (!_mongoc_error_is_state_change (&error)); -} - -static void -test_state_change (void) -{ - test_state_change_helper (MONGOC_ERROR_SERVER, true); - test_state_change_helper (MONGOC_ERROR_WRITE_CONCERN, true); - test_state_change_helper (MONGOC_ERROR_QUERY, false); -} - -void -test_error_install (TestSuite *suite) -{ - TestSuite_AddLive ( - suite, "/Error/set_api/single", test_set_error_api_single); - TestSuite_AddLive ( - suite, "/Error/set_api/pooled", test_set_error_api_pooled); - TestSuite_AddMockServerTest ( - suite, "/Error/command/default", test_command_error_default); - TestSuite_AddMockServerTest ( - suite, "/Error/command/v1", test_command_error_v1); - TestSuite_AddMockServerTest ( - suite, "/Error/command/v2", test_command_error_v2); - TestSuite_Add (suite, "/Error/has_label", test_has_label); - TestSuite_Add (suite, "/Error/state_change", test_state_change); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-exhaust.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-exhaust.c deleted file mode 100644 index 829aab8c2..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-exhaust.c +++ /dev/null @@ -1,906 +0,0 @@ -#include -#include - -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-cursor-private.h" -#include "mongoc/mongoc-uri-private.h" -#include "mongoc/mongoc-util-private.h" - -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" - - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "exhaust-test" - -/* Server support for exhaust cursors depends on server topology and version: - * Server Version Server Behavior - * ------------------ ----------------------------------- - * mongod <4.2 only supports with OP_QUERY. - * mongod >=4.2,<5.1 supports with OP_MSG and OP_QUERY. - * mongod >=5.1 only supports with OP_MSG. - - * mongos <7.1 does not support. - * mongos >=7.1 only supports with OP_MSG. - - - * When attempting to create an exhaust cursor, libmongoc behaves as follows: - - * Server Version libmongoc behavior - * ------------------ ----------------------------------- - * mongod <4.2 uses OP_QUERY. - * mongod >=4.2,<5.1 uses OP_MSG. - * mongod >=5.1 uses OP_MSG. - - * mongos <7.1 returns error - * mongos >=7.1 uses OP_MSG. - */ - -static int -skip_if_no_exhaust (void) -{ - if (!TestSuite_CheckLive ()) { - return 0; - } - - int64_t max_wire_version; - test_framework_get_max_wire_version (&max_wire_version); - - // mongos only supports exhaust cursors on server version 7.1+. - if (test_framework_is_mongos ()) { - if (max_wire_version >= WIRE_VERSION_MONGOS_EXHAUST) { - return 1; - } - return 0; - } - - // mongod supports exhaust cursors over OP_MSG or OP_QUERY for all versions - // supported by libmongoc. - - return 1; -} - - -static uint32_t -get_generation (mongoc_client_t *client, mongoc_cursor_t *cursor) -{ - uint32_t server_id; - uint32_t generation; - mongoc_server_description_t const *sd; - bson_error_t error; - ASSERT (client); - - mc_shared_tpld td = mc_tpld_take_ref (client->topology); - - server_id = mongoc_cursor_get_hint (cursor); - - sd = mongoc_topology_description_server_by_id_const ( - td.ptr, server_id, &error); - ASSERT_OR_PRINT (sd, error); - generation = mc_tpl_sd_get_generation (sd, &kZeroServiceId); - mc_tpld_drop_ref (&td); - - return generation; -} - -static uint32_t -get_connection_count (mongoc_client_t *client) -{ - bson_error_t error; - bson_t cmd = BSON_INITIALIZER; - bson_t reply; - bool res; - int conns; - - ASSERT (client); - - BSON_APPEND_INT32 (&cmd, "serverStatus", 1); - res = mongoc_client_command_simple ( - client, "admin", &cmd, NULL, &reply, &error); - ASSERT_OR_PRINT (res, error); - - conns = bson_lookup_int32 (&reply, "connections.totalCreated"); - bson_destroy (&cmd); - bson_destroy (&reply); - return conns; -} - -static void -test_exhaust_cursor (bool pooled) -{ - mongoc_stream_t *stream; - mongoc_write_concern_t *wr; - mongoc_client_t *client; - mongoc_client_pool_t *pool = NULL; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - mongoc_cursor_t *cursor2; - const bson_t *doc; - bson_t q; - bson_t b[10]; - bson_t *bptr[10]; - int i; - bool r; - uint32_t server_id; - bson_error_t error; - bson_oid_t oid; - int64_t generation1; - uint32_t connection_count1; - mongoc_client_t *audit_client; - - if (pooled) { - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - } - BSON_ASSERT (client); - - /* Use a separate client to count connections. */ - audit_client = test_framework_new_default_client (); - - collection = get_test_collection (client, "test_exhaust_cursor"); - BSON_ASSERT (collection); - - /* don't care if ns not found. */ - (void) mongoc_collection_drop (collection, &error); - - wr = mongoc_write_concern_new (); - mongoc_write_concern_set_journal (wr, true); - - /* bulk insert some records to work on */ - { - bson_init (&q); - - for (i = 0; i < 10; i++) { - bson_init (&b[i]); - bson_oid_init (&oid, NULL); - bson_append_oid (&b[i], "_id", -1, &oid); - bson_append_int32 (&b[i], "n", -1, i % 2); - bptr[i] = &b[i]; - } - - BEGIN_IGNORE_DEPRECATIONS; - ASSERT_OR_PRINT (mongoc_collection_insert_bulk (collection, - MONGOC_INSERT_NONE, - (const bson_t **) bptr, - 10, - wr, - &error), - error); - END_IGNORE_DEPRECATIONS; - } - - /* create a couple of cursors */ - { - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_EXHAUST, 0, 0, 5, &q, NULL, NULL); - - cursor2 = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, &q, NULL, NULL); - } - - /* Read from the exhaust cursor, ensure that we're in exhaust where we - * should be and ensure that an early destroy properly causes a disconnect - * */ - { - r = mongoc_cursor_next (cursor, &doc); - if (!r) { - mongoc_cursor_error (cursor, &error); - fprintf (stderr, "cursor error: %s\n", error.message); - } - BSON_ASSERT (r); - BSON_ASSERT (doc); - - // With OP_MSG, a cursor only becomes exhaust after the first getMore - while (!cursor->in_exhaust && mongoc_cursor_next (cursor, &doc)) - ; - BSON_ASSERT (client->in_exhaust); - - /* destroy the cursor, make sure the connection pool was not cleared */ - generation1 = get_generation (client, cursor); - /* Getting the connection count requires a new enough server. */ - connection_count1 = get_connection_count (audit_client); - mongoc_cursor_destroy (cursor); - BSON_ASSERT (!client->in_exhaust); - } - - /* Grab a new exhaust cursor, then verify that reading from that cursor - * (putting the client into exhaust), breaks a mid-stream read from a - * regular cursor */ - { - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_EXHAUST, 0, 0, 5, &q, NULL, NULL); - - r = mongoc_cursor_next (cursor2, &doc); - if (!r) { - mongoc_cursor_error (cursor2, &error); - fprintf (stderr, "cursor error: %s\n", error.message); - } - BSON_ASSERT (r); - BSON_ASSERT (doc); - /* The pool was not cleared. */ - ASSERT_CMPINT64 (generation1, ==, get_generation (client, cursor2)); - /* But a new connection was made. */ - ASSERT_CMPINT32 ( - connection_count1 + 1, ==, get_connection_count (audit_client)); - - for (i = 0; i < 5; i++) { - r = mongoc_cursor_next (cursor2, &doc); - if (!r) { - mongoc_cursor_error (cursor2, &error); - fprintf (stderr, "cursor error: %s\n", error.message); - } - BSON_ASSERT (r); - BSON_ASSERT (doc); - } - - while (!cursor->in_exhaust && (r = mongoc_cursor_next (cursor, &doc), r)) - ; - BSON_ASSERT (client->in_exhaust); - BSON_ASSERT (r); - BSON_ASSERT (doc); - - doc = NULL; - r = mongoc_cursor_next (cursor2, &doc); - BSON_ASSERT (!r); - BSON_ASSERT (!doc); - - mongoc_cursor_error (cursor2, &error); - ASSERT_CMPUINT32 (error.domain, ==, MONGOC_ERROR_CLIENT); - ASSERT_CMPUINT32 (error.code, ==, MONGOC_ERROR_CLIENT_IN_EXHAUST); - - mongoc_cursor_destroy (cursor2); - } - - /* make sure writes fail as well */ - { - BEGIN_IGNORE_DEPRECATIONS; - r = mongoc_collection_insert_bulk (collection, - MONGOC_INSERT_NONE, - (const bson_t **) bptr, - 10, - wr, - &error); - END_IGNORE_DEPRECATIONS; - - BSON_ASSERT (!r); - ASSERT_CMPUINT32 (error.domain, ==, MONGOC_ERROR_CLIENT); - ASSERT_CMPUINT32 (error.code, ==, MONGOC_ERROR_CLIENT_IN_EXHAUST); - } - - /* we're still in exhaust. - * - * 1. check that we can create a new cursor, as long as we don't read from it - * 2. fully exhaust the exhaust cursor - * 3. make sure that we don't disconnect at destroy - * 4. make sure we can read the cursor we made during the exhaust - */ - { - cursor2 = mongoc_collection_find ( - collection, MONGOC_QUERY_NONE, 0, 0, 0, &q, NULL, NULL); - - server_id = cursor->server_id; - stream = - (mongoc_stream_t *) mongoc_set_get (client->cluster.nodes, server_id); - - while (cursor->in_exhaust && (r = mongoc_cursor_next (cursor, &doc), r)) - ; - BSON_ASSERT (!r); - BSON_ASSERT (!doc); - - mongoc_cursor_destroy (cursor); - - BSON_ASSERT (stream == (mongoc_stream_t *) mongoc_set_get ( - client->cluster.nodes, server_id)); - - r = mongoc_cursor_next (cursor2, &doc); - BSON_ASSERT (r); - BSON_ASSERT (doc); - } - - bson_destroy (&q); - for (i = 0; i < 10; i++) { - bson_destroy (&b[i]); - } - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_write_concern_destroy (wr); - mongoc_cursor_destroy (cursor2); - mongoc_collection_destroy (collection); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - mongoc_client_destroy (audit_client); -} - -static void -test_exhaust_cursor_works (void *context) -{ - BSON_UNUSED (context); - bson_error_t error; - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll = - mongoc_client_get_collection (client, "db", "coll"); - - // Drop collection to remove prior test data. - mongoc_collection_drop (coll, NULL /* ignore error */); - - // Insert enough documents to require more than one batch. - // With OP_MSG, a cursor only becomes exhaust after the first getMore. - for (int i = 0; i < 5; i++) { - bool ok = mongoc_collection_insert_one (coll, - tmp_bson ("{'i': %d}", i), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - } - - mongoc_cursor_t *cursor = mongoc_collection_find_with_opts ( - coll, - tmp_bson ("{}"), - tmp_bson ("{'exhaust': true, 'batchSize': 2}"), - NULL /* read_prefs */); - const bson_t *result; - while (mongoc_cursor_next (cursor, &result)) - ; - // Expect an error if exhaust cursors are not supported. - const bool sharded = _mongoc_topology_get_type (cursor->client->topology) == - MONGOC_TOPOLOGY_SHARDED; - int64_t wire_version; - test_framework_get_max_wire_version (&wire_version); - if (sharded && wire_version < WIRE_VERSION_MONGOS_EXHAUST) { - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "exhaust cursors require"); - } else { - // Expect no error. - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - } - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -// `test_exhaust_cursor_no_match` is a regression test for CDRIVER-5515 -static void -test_exhaust_cursor_no_match (void *context) -{ - BSON_UNUSED (context); - bson_error_t error; - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll = mongoc_client_get_collection (client, "db", "coll"); - - // Drop collection to remove prior test data. - mongoc_collection_drop (coll, NULL /* ignore error */); - - mongoc_cursor_t *cursor = - mongoc_collection_find_with_opts (coll, tmp_bson ("{}"), tmp_bson ("{'exhaust': true }"), NULL /* read_prefs */); - const bson_t *result; - size_t count = 0; - while (mongoc_cursor_next (cursor, &result)) { - count++; - } - // Expect an error if exhaust cursors are not supported. - const bool sharded = _mongoc_topology_get_type (cursor->client->topology) == MONGOC_TOPOLOGY_SHARDED; - int64_t wire_version; - test_framework_get_max_wire_version (&wire_version); - if (sharded && wire_version < WIRE_VERSION_MONGOS_EXHAUST) { - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_CURSOR, MONGOC_ERROR_CURSOR_INVALID_CURSOR, "exhaust cursors require"); - } else { - // Expect no error. - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - // Expect no results. - ASSERT_CMPSIZE_T (count, ==, 0); - } - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - - -static void -test_exhaust_cursor_single (void *context) -{ - BSON_UNUSED (context); - - test_exhaust_cursor (false); -} - -static void -test_exhaust_cursor_pool (void *context) -{ - BSON_UNUSED (context); - - test_exhaust_cursor (true); -} - -static void -test_exhaust_cursor_multi_batch (void *context) -{ - mongoc_client_t *client; - bson_error_t error; - mongoc_collection_t *collection; - bson_t doc = BSON_INITIALIZER; - mongoc_bulk_operation_t *bulk; - int i; - uint32_t server_id; - mongoc_cursor_t *cursor; - const bson_t *cursor_doc; - - BSON_UNUSED (context); - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_exhaust_cursor_multi_batch"); - - ASSERT_OR_PRINT (collection, error); - - BSON_APPEND_UTF8 (&doc, "key", "value"); - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - - /* enough to require more than initial batch */ - for (i = 0; i < 1000; i++) { - mongoc_bulk_operation_insert (bulk, &doc); - } - - server_id = mongoc_bulk_operation_execute (bulk, NULL, &error); - ASSERT_OR_PRINT (server_id, error); - - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_EXHAUST, 0, 0, 10, tmp_bson ("{}"), NULL, NULL); - - i = 0; - while (mongoc_cursor_next (cursor, &cursor_doc)) { - i++; - ASSERT (mongoc_cursor_more (cursor)); - } - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - ASSERT (!mongoc_cursor_more (cursor)); - ASSERT_CMPINT (i, ==, 1000); - - mongoc_cursor_destroy (cursor); - mongoc_bulk_operation_destroy (bulk); - mongoc_collection_destroy (collection); - bson_destroy (&doc); - mongoc_client_destroy (client); -} - -static void -test_cursor_server_hint_with_exhaust (void *unused) -{ - BSON_UNUSED (unused); - bson_error_t error; - mongoc_client_t *client = test_framework_new_default_client (); - mongoc_collection_t *coll = - get_test_collection (client, "cursor_server_hint_with_exhaust"); - mongoc_cursor_t *cursor = mongoc_collection_find_with_opts ( - coll, - tmp_bson ("{}"), - tmp_bson ("{'exhaust': true}"), /* opts */ - NULL /* read_prefs */); - - // Set a bogus server ID. - mongoc_cursor_set_hint (cursor, 123); - - // Iterate the cursor. - const bson_t *result; - while (mongoc_cursor_next (cursor, &result)) - ; - // Expect an error due to the bogus server ID. - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Could not find server with id: 123"); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -static void -test_cursor_set_max_await_time_ms (void) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - const bson_t *bson; - - client = test_framework_new_default_client (); - collection = - get_test_collection (client, "test_cursor_set_max_await_time_ms"); - - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_TAILABLE_CURSOR | - MONGOC_QUERY_AWAIT_DATA, - 0, - 0, - 0, - tmp_bson ("{}"), - NULL, - NULL); - - ASSERT_CMPINT (0, ==, mongoc_cursor_get_max_await_time_ms (cursor)); - mongoc_cursor_set_max_await_time_ms (cursor, 123); - ASSERT_CMPINT (123, ==, mongoc_cursor_get_max_await_time_ms (cursor)); - mongoc_cursor_next (cursor, &bson); - - /* once started, cursor ignores set_max_await_time_ms () */ - mongoc_cursor_set_max_await_time_ms (cursor, 42); - ASSERT_CMPINT (123, ==, mongoc_cursor_get_max_await_time_ms (cursor)); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -typedef enum { - FIRST_BATCH, - SECOND_BATCH, -} exhaust_error_when_t; - -typedef enum { - NETWORK_ERROR, - SERVER_ERROR, -} exhaust_error_type_t; - -static void -_request_error (request_t *request, exhaust_error_type_t error_type) -{ - if (error_type == NETWORK_ERROR) { - reply_to_request_with_reset (request); - } else { - reply_to_request (request, - MONGOC_REPLY_QUERY_FAILURE, - 123, - 0, - 0, - "{'$err': 'uh oh', 'code': 4321}"); - } -} - -static void -_check_error (mongoc_client_t *client, - mongoc_cursor_t *cursor, - exhaust_error_type_t error_type) -{ - uint32_t server_id; - bson_error_t error; - - ASSERT (client); - - server_id = mongoc_cursor_get_hint (cursor); - ASSERT (server_id); - ASSERT (mongoc_cursor_error (cursor, &error)); - - if (error_type == NETWORK_ERROR) { - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "socket error or timeout"); - - /* socket was discarded */ - ASSERT (!mongoc_cluster_stream_for_server (&client->cluster, - server_id, - false /* don't reconnect */, - NULL, - NULL, - &error)); - - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "socket error or timeout"); - } else { - /* query failure */ - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_QUERY, - 4321 /* error from mock server */, - "uh oh" /* message from mock server */); - } -} - -static void -_mock_test_exhaust (bool pooled, - exhaust_error_when_t error_when, - exhaust_error_type_t error_type) -{ - mock_server_t *server; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - - capture_logs (true); - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri ( - mock_server_get_uri (server), NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (mock_server_get_uri (server), - NULL); - } - - collection = mongoc_client_get_collection (client, "db", "test"); - cursor = mongoc_collection_find ( - collection, MONGOC_QUERY_EXHAUST, 0, 0, 0, tmp_bson ("{}"), NULL, NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_query (server, - "db.test", - MONGOC_QUERY_SECONDARY_OK | - MONGOC_QUERY_EXHAUST, - 0, - 0, - "{}", - NULL); - - if (error_when == SECOND_BATCH) { - /* initial query succeeds, gets a doc and cursor id of 123 */ - reply_to_request (request, MONGOC_REPLY_NONE, 123, 1, 1, "{'a': 1}"); - ASSERT (future_get_bool (future)); - assert_match_bson (doc, tmp_bson ("{'a': 1}"), false); - ASSERT_CMPINT64 ((int64_t) 123, ==, mongoc_cursor_get_id (cursor)); - - future_destroy (future); - - /* error after initial batch */ - future = future_cursor_next (cursor, &doc); - } - - _request_error (request, error_type); - ASSERT (!future_get_bool (future)); - _check_error (client, cursor, error_type); - - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mock_server_destroy (server); -} - -static void -test_exhaust_network_err_1st_batch_single (void) -{ - _mock_test_exhaust (false, FIRST_BATCH, NETWORK_ERROR); -} - -static void -test_exhaust_network_err_1st_batch_pooled (void) -{ - _mock_test_exhaust (true, FIRST_BATCH, NETWORK_ERROR); -} - -static void -test_exhaust_server_err_1st_batch_single (void) -{ - _mock_test_exhaust (false, FIRST_BATCH, SERVER_ERROR); -} - -static void -test_exhaust_server_err_1st_batch_pooled (void) -{ - _mock_test_exhaust (true, FIRST_BATCH, SERVER_ERROR); -} - -static void -test_exhaust_network_err_2nd_batch_single (void) -{ - _mock_test_exhaust (false, SECOND_BATCH, NETWORK_ERROR); -} - -static void -test_exhaust_network_err_2nd_batch_pooled (void) -{ - _mock_test_exhaust (true, SECOND_BATCH, NETWORK_ERROR); -} - -static void -test_exhaust_server_err_2nd_batch_single (void) -{ - _mock_test_exhaust (false, SECOND_BATCH, SERVER_ERROR); -} - -static void -test_exhaust_server_err_2nd_batch_pooled (void) -{ - _mock_test_exhaust (true, SECOND_BATCH, SERVER_ERROR); -} - -#ifndef _WIN32 -#include -/* Test that calling mongoc_client_reset on a client that has an exhaust cursor - * closes the socket open to that server, and marks the client as no longer in - * exhaust. */ -static void -test_exhaust_in_child (void) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bool ret; - mongoc_cursor_t *cursor; - bson_t *to_insert; - int i; - bson_error_t error; - const bson_t *doc; - mongoc_bulk_operation_t *bulk; - pid_t pid; - uint32_t server_id; - int child_exit_status; - - client = test_framework_new_default_client (); - coll = get_test_collection (client, "exhaust_in_child"); - - /* insert some documents, more than one reply's worth. */ - to_insert = BCON_NEW ("x", BCON_INT32 (1)); - bulk = mongoc_collection_create_bulk_operation (coll, false, NULL /* wc */); - for (i = 0; i < 1001; i++) { - ret = mongoc_bulk_operation_insert_with_opts ( - bulk, to_insert, NULL /* opts */, &error); - ASSERT_OR_PRINT (ret, error); - } - ret = mongoc_bulk_operation_execute (bulk, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - mongoc_bulk_operation_destroy (bulk); - - /* create an exhaust cursor. */ - cursor = mongoc_collection_find_with_opts (coll, - tmp_bson ("{}"), - tmp_bson ("{'exhaust': true }"), - NULL /* read prefs */); - BSON_ASSERT (mongoc_cursor_next (cursor, &doc)); - BSON_ASSERT (client->in_exhaust); - server_id = mongoc_cursor_get_hint (cursor); - - pid = fork (); - if (pid == 0) { - bson_t *ping; - - /* In child process, reset the client and destroy the cursor. */ - mongoc_client_reset (client); - mongoc_cursor_destroy (cursor); - /* The client should no longer be in exhaust */ - BSON_ASSERT (!client->in_exhaust); - /* A command directly on that server should still work (it should open a - * new socket). */ - ping = BCON_NEW ("ping", BCON_INT32 (1)); - ret = mongoc_client_command_simple_with_server_id (client, - "admin", - ping, - NULL /* read prefs */, - server_id, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - /* Clean up and exit, so child does not continue running test-libmongoc. - */ - mongoc_cleanup (); - exit (0); - } - - BSON_ASSERT (-1 != waitpid (pid, &child_exit_status, 0 /* opts */)); - BSON_ASSERT (0 == child_exit_status); - while (mongoc_cursor_next (cursor, &doc)) - ; - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - bson_destroy (to_insert); - mongoc_cursor_destroy (cursor); - mongoc_collection_drop (coll, &error); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} -#endif /* _WIN32 */ - -void -test_exhaust_install (TestSuite *suite) -{ - TestSuite_AddFull (suite, - "/Client/exhaust_cursor/works", - test_exhaust_cursor_works, - NULL, - NULL, - skip_if_no_exhaust); - TestSuite_AddFull ( - suite, "/Client/exhaust_cursor/no_match", test_exhaust_cursor_no_match, NULL, NULL, skip_if_no_exhaust); - TestSuite_AddFull (suite, - "/Client/exhaust_cursor/single", - test_exhaust_cursor_single, - NULL, - NULL, - skip_if_no_exhaust); - TestSuite_AddFull (suite, - "/Client/exhaust_cursor/pool", - test_exhaust_cursor_pool, - NULL, - NULL, - skip_if_no_exhaust); - TestSuite_AddFull (suite, - "/Client/exhaust_cursor/batches", - test_exhaust_cursor_multi_batch, - NULL, - NULL, - skip_if_no_exhaust); - TestSuite_AddLive (suite, - "/Client/set_max_await_time_ms", - test_cursor_set_max_await_time_ms); - TestSuite_AddFull (suite, - "/Client/exhaust_cursor/server_hint", - test_cursor_server_hint_with_exhaust, - NULL, - NULL, - skip_if_no_exhaust); - TestSuite_AddMockServerTest ( - suite, - "/Client/exhaust_cursor/err/network/1st_batch/single", - test_exhaust_network_err_1st_batch_single); - TestSuite_AddMockServerTest ( - suite, - "/Client/exhaust_cursor/err/network/1st_batch/pooled", - test_exhaust_network_err_1st_batch_pooled); - TestSuite_AddMockServerTest ( - suite, - "/Client/exhaust_cursor/err/server/1st_batch/single", - test_exhaust_server_err_1st_batch_single); - TestSuite_AddMockServerTest ( - suite, - "/Client/exhaust_cursor/err/server/1st_batch/pooled", - test_exhaust_server_err_1st_batch_pooled); - TestSuite_AddMockServerTest ( - suite, - "/Client/exhaust_cursor/err/network/2nd_batch/single", - test_exhaust_network_err_2nd_batch_single); - TestSuite_AddMockServerTest ( - suite, - "/Client/exhaust_cursor/err/network/2nd_batch/pooled", - test_exhaust_network_err_2nd_batch_pooled); - TestSuite_AddMockServerTest ( - suite, - "/Client/exhaust_cursor/err/server/2nd_batch/single", - test_exhaust_server_err_2nd_batch_single); - TestSuite_AddMockServerTest ( - suite, - "/Client/exhaust_cursor/err/server/2nd_batch/pooled", - test_exhaust_server_err_2nd_batch_pooled); -#ifndef _WIN32 - /* Skip on Windows, since "fork" is not available and this test is not - * particularly platform dependent. */ - if (!TestSuite_NoFork (suite)) { - TestSuite_AddLive ( - suite, "/Client/exhaust_cursor/after_reset", test_exhaust_in_child); - } -#endif /* _WIN32 */ -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-find-and-modify.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-find-and-modify.c deleted file mode 100644 index 6486473e4..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-find-and-modify.c +++ /dev/null @@ -1,580 +0,0 @@ -#include -#include -#include -#include -#include - -#include "TestSuite.h" - -#include "test-libmongoc.h" -#include "test-conveniences.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" - -static void -auto_hello (mock_server_t *server, - int32_t max_wire_version, - int32_t max_message_size, - int32_t max_bson_size, - int32_t max_batch_size) -{ - char *response = bson_strdup_printf ("{'isWritablePrimary': true, " - " 'maxWireVersion': %d," - " 'maxBsonObjectSize': %d," - " 'maxMessageSizeBytes': %d," - " 'maxWriteBatchSize': %d }", - max_wire_version, - max_bson_size, - max_message_size, - max_batch_size); - - BSON_ASSERT (max_wire_version > 0); - mock_server_auto_hello (server, response); - - bson_free (response); -} - - -static void -test_find_and_modify_bypass (bool bypass) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - mock_server_t *server; - request_t *request; - future_t *future; - bson_error_t error; - bson_t *update; - bson_t doc = BSON_INITIALIZER; - bson_t reply; - mongoc_find_and_modify_opts_t *opts; - - server = mock_server_new (); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - ASSERT (client); - - collection = - mongoc_client_get_collection (client, "test", "test_find_and_modify"); - - auto_hello (server, - WIRE_VERSION_MIN, /* max_wire_version */ - 48000000, /* max_message_size */ - 16777216, /* max_bson_size */ - 1000); /* max_write_batch_size */ - - BSON_APPEND_INT32 (&doc, "superduper", 77889); - - update = BCON_NEW ("$set", "{", "superduper", BCON_INT32 (1234), "}"); - - opts = mongoc_find_and_modify_opts_new (); - mongoc_find_and_modify_opts_set_bypass_document_validation (opts, bypass); - BSON_ASSERT ( - bypass == - mongoc_find_and_modify_opts_get_bypass_document_validation (opts)); - mongoc_find_and_modify_opts_set_update (opts, update); - mongoc_find_and_modify_opts_set_flags (opts, - MONGOC_FIND_AND_MODIFY_RETURN_NEW); - - future = future_collection_find_and_modify_with_opts ( - collection, &doc, opts, &reply, &error); - - if (bypass) { - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'findAndModify': 'test_find_and_modify'," - " 'query': {'superduper': 77889}," - " 'update': {'$set': {'superduper': 1234}}," - " 'new': true," - " 'bypassDocumentValidation': true}")); - } else { - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'findAndModify': 'test_find_and_modify', " - "'query': {'superduper': 77889}," - "'update': {'$set': {'superduper': 1234}}," - "'new': true }")); - } - - reply_to_request_simple (request, "{ 'value' : null, 'ok' : 1 }"); - ASSERT_OR_PRINT (future_get_bool (future), error); - - future_destroy (future); - request_destroy (request); - - mongoc_find_and_modify_opts_destroy (opts); - bson_destroy (&reply); - bson_destroy (update); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); - bson_destroy (&doc); -} - -static void -test_find_and_modify_bypass_true (void) -{ - test_find_and_modify_bypass (true); -} - -static void -test_find_and_modify_bypass_false (void) -{ - test_find_and_modify_bypass (false); -} - -static void -test_find_and_modify_write_concern (void) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - mock_server_t *server; - request_t *request; - future_t *future; - bson_error_t error; - bson_t *update; - bson_t doc = BSON_INITIALIZER; - bson_t reply; - mongoc_find_and_modify_opts_t *opts; - mongoc_write_concern_t *write_concern; - - server = mock_server_new (); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - ASSERT (client); - - collection = - mongoc_client_get_collection (client, "test", "test_find_and_modify"); - - auto_hello (server, - WIRE_VERSION_MIN, /* max_wire_version */ - 48000000, /* max_message_size */ - 16777216, /* max_bson_size */ - 1000); /* max_write_batch_size */ - - BSON_APPEND_INT32 (&doc, "superduper", 77889); - - update = BCON_NEW ("$set", "{", "superduper", BCON_INT32 (1234), "}"); - - write_concern = mongoc_write_concern_new (); - mongoc_write_concern_set_w (write_concern, 42); - opts = mongoc_find_and_modify_opts_new (); - mongoc_collection_set_write_concern (collection, write_concern); - mongoc_find_and_modify_opts_set_update (opts, update); - mongoc_find_and_modify_opts_set_flags (opts, - MONGOC_FIND_AND_MODIFY_RETURN_NEW); - - future = future_collection_find_and_modify_with_opts ( - collection, &doc, opts, &reply, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'findAndModify': 'test_find_and_modify', " - " 'query': {'superduper': 77889 }," - " 'update': {'$set': {'superduper': 1234}}," - " 'new': true," - " 'writeConcern': {'w': 42}}")); - - reply_to_request_simple (request, "{ 'value' : null, 'ok' : 1 }"); - ASSERT_OR_PRINT (future_get_bool (future), error); - - future_destroy (future); - request_destroy (request); - - mongoc_find_and_modify_opts_destroy (opts); - bson_destroy (&reply); - bson_destroy (update); - - mongoc_write_concern_destroy (write_concern); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_destroy (&doc); - mock_server_destroy (server); -} - -static void -test_find_and_modify_write_concern_failure (void *context) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_error_t error; - mongoc_find_and_modify_opts_t *opts; - bson_t reply; - bson_t query = BSON_INITIALIZER; - bson_t *update; - bool success; - mongoc_write_concern_t *wc; - - BSON_UNUSED (context); - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "writeFailure"); - wc = mongoc_write_concern_new (); - - mongoc_write_concern_set_w (wc, 42); - mongoc_collection_set_write_concern (collection, wc); - - /* Find Zlatan Ibrahimovic, the striker */ - BSON_APPEND_UTF8 (&query, "firstname", "Zlatan"); - BSON_APPEND_UTF8 (&query, "lastname", "Ibrahimovic"); - BSON_APPEND_UTF8 (&query, "profession", "Football player"); - BSON_APPEND_INT32 (&query, "age", 34); - BSON_APPEND_INT32 ( - &query, "goals", (16 + 35 + 23 + 57 + 16 + 14 + 28 + 84) + (1 + 6 + 62)); - - /* Add his football position */ - update = BCON_NEW ("$set", "{", "position", BCON_UTF8 ("striker"), "}"); - - opts = mongoc_find_and_modify_opts_new (); - - mongoc_find_and_modify_opts_set_update (opts, update); - - /* Create the document if it didn't exist, and return the updated document */ - mongoc_find_and_modify_opts_set_flags ( - opts, MONGOC_FIND_AND_MODIFY_UPSERT | MONGOC_FIND_AND_MODIFY_RETURN_NEW); - - success = mongoc_collection_find_and_modify_with_opts ( - collection, &query, opts, &reply, &error); - - ASSERT (!success); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_WRITE_CONCERN, 100, "Write Concern error:"); - - bson_destroy (&reply); - bson_destroy (update); - bson_destroy (&query); - mongoc_find_and_modify_opts_destroy (opts); - mongoc_collection_drop (collection, NULL); - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -static void -test_find_and_modify (void) -{ - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_error_t error; - bson_iter_t iter; - bson_iter_t citer; - bson_t *update; - bson_t doc = BSON_INITIALIZER; - bson_t tmp; - bson_t reply; - mongoc_find_and_modify_opts_t *opts; - - client = test_framework_new_default_client (); - ASSERT (client); - - collection = get_test_collection (client, "test_find_and_modify"); - ASSERT (collection); - - BSON_APPEND_INT32 (&doc, "superduper", 77889); - - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (collection, &doc, NULL, NULL, &error), - error); - - update = BCON_NEW ("$set", "{", "superduper", BCON_INT32 (1234), "}"); - - opts = mongoc_find_and_modify_opts_new (); - mongoc_find_and_modify_opts_set_update (opts, update); - mongoc_find_and_modify_opts_get_update (opts, &tmp); - assert_match_bson (&tmp, update, false); - bson_destroy (&tmp); - mongoc_find_and_modify_opts_set_fields (opts, - tmp_bson ("{'superduper': 1}")); - mongoc_find_and_modify_opts_get_fields (opts, &tmp); - assert_match_bson (&tmp, tmp_bson ("{'superduper': 1}"), false); - bson_destroy (&tmp); - mongoc_find_and_modify_opts_set_sort (opts, tmp_bson ("{'superduper': 1}")); - mongoc_find_and_modify_opts_get_sort (opts, &tmp); - assert_match_bson (&tmp, tmp_bson ("{'superduper': 1}"), false); - bson_destroy (&tmp); - mongoc_find_and_modify_opts_set_flags (opts, - MONGOC_FIND_AND_MODIFY_RETURN_NEW); - BSON_ASSERT (MONGOC_FIND_AND_MODIFY_RETURN_NEW == - mongoc_find_and_modify_opts_get_flags (opts)); - - ASSERT_OR_PRINT (mongoc_collection_find_and_modify_with_opts ( - collection, &doc, opts, &reply, &error), - error); - - BSON_ASSERT (bson_iter_init_find (&iter, &reply, "value")); - BSON_ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - BSON_ASSERT (bson_iter_recurse (&iter, &citer)); - BSON_ASSERT (bson_iter_find (&citer, "superduper")); - BSON_ASSERT (BSON_ITER_HOLDS_INT32 (&citer)); - BSON_ASSERT (bson_iter_int32 (&citer) == 1234); - - BSON_ASSERT (bson_iter_init_find (&iter, &reply, "lastErrorObject")); - BSON_ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - BSON_ASSERT (bson_iter_recurse (&iter, &citer)); - BSON_ASSERT (bson_iter_find (&citer, "updatedExisting")); - BSON_ASSERT (BSON_ITER_HOLDS_BOOL (&citer)); - BSON_ASSERT (bson_iter_bool (&citer)); - - bson_destroy (&reply); - bson_destroy (update); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - mongoc_find_and_modify_opts_destroy (opts); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_destroy (&doc); -} - - -static void -test_find_and_modify_opts (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - mongoc_find_and_modify_opts_t *opts; - bson_t extra; - future_t *future; - request_t *request; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - opts = mongoc_find_and_modify_opts_new (); - BSON_ASSERT (mongoc_find_and_modify_opts_set_max_time_ms (opts, 42)); - ASSERT_CMPUINT32 ( - 42, ==, mongoc_find_and_modify_opts_get_max_time_ms (opts)); - BSON_ASSERT ( - mongoc_find_and_modify_opts_append (opts, tmp_bson ("{'foo': 1}"))); - mongoc_find_and_modify_opts_get_extra (opts, &extra); - assert_match_bson (&extra, tmp_bson ("{'foo': 1}"), false); - bson_destroy (&extra); - - future = future_collection_find_and_modify_with_opts ( - collection, tmp_bson ("{}"), opts, NULL, &error); - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'findAndModify': 'collection'," - " 'maxTimeMS': 42," - " 'foo': 1}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - - future_destroy (future); - mongoc_find_and_modify_opts_destroy (opts); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_find_and_modify_opts_write_concern (void) -{ - mongoc_write_concern_t *w2; - mongoc_write_concern_t *w3; - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - mongoc_find_and_modify_opts_t *opts; - bson_t extra = BSON_INITIALIZER; - future_t *future; - request_t *request; - - w2 = mongoc_write_concern_new (); - mongoc_write_concern_set_w (w2, 2); - w3 = mongoc_write_concern_new (); - mongoc_write_concern_set_w (w3, 3); - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - opts = mongoc_find_and_modify_opts_new (); - mongoc_write_concern_append (w2, &extra); - BSON_ASSERT (mongoc_find_and_modify_opts_append (opts, &extra)); - bson_destroy (&extra); - - future = future_collection_find_and_modify_with_opts ( - collection, tmp_bson ("{}"), opts, NULL, &error); - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'findAndModify': 'collection'," - " 'writeConcern': {'w': 2}}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* opts overrides collection */ - mongoc_collection_set_write_concern (collection, w3); - future = future_collection_find_and_modify_with_opts ( - collection, tmp_bson ("{}"), opts, NULL, &error); - - /* still w: 2 */ - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'findAndModify': 'collection'," - " 'writeConcern': {'w': 2}}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - mongoc_find_and_modify_opts_destroy (opts); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); - mongoc_write_concern_destroy (w2); - mongoc_write_concern_destroy (w3); -} - - -static void -test_find_and_modify_collation (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - mongoc_find_and_modify_opts_t *opts; - future_t *future; - request_t *request; - bson_t *collation; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - - collation = BCON_NEW ("collation", - "{", - "locale", - BCON_UTF8 ("en_US"), - "caseFirst", - BCON_UTF8 ("lower"), - "}"); - opts = mongoc_find_and_modify_opts_new (); - BSON_ASSERT (mongoc_find_and_modify_opts_append (opts, collation)); - - future = future_collection_find_and_modify_with_opts ( - collection, tmp_bson ("{}"), opts, NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'findAndModify': 'collection'," - " 'collation': {'locale': 'en_US', 'caseFirst': 'lower'}}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - bson_destroy (collation); - mongoc_find_and_modify_opts_destroy (opts); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - - mock_server_destroy (server); -} - - -static void -test_find_and_modify_hint (void) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_find_and_modify_opts_t *opts; - bson_error_t error; - bool ret; - - /* Test setting a hint as a string. Should fail on server < 4.2. */ - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - coll = get_test_collection (client, "fam_hint"); - opts = mongoc_find_and_modify_opts_new (); - mongoc_find_and_modify_opts_append (opts, tmp_bson ("{'hint': 'abc'}")); - mongoc_find_and_modify_opts_set_update (opts, tmp_bson ("{}")); - ret = mongoc_collection_find_and_modify_with_opts ( - coll, tmp_bson ("{}"), opts, NULL /* reply */, &error); - if (test_framework_max_wire_version_at_least ( - WIRE_VERSION_FIND_AND_MODIFY_HINT)) { - ASSERT_OR_PRINT (ret, error); - } else if (test_framework_max_wire_version_at_least ( - WIRE_VERSION_FIND_AND_MODIFY_HINT_SERVER_SIDE_ERROR)) { - BSON_ASSERT (!ret); - BSON_ASSERT (error.domain == MONGOC_ERROR_SERVER); - /* server error. */ - } else { - BSON_ASSERT (!ret); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "The selected server does not support hint for findAndModify"); - } - - mongoc_find_and_modify_opts_destroy (opts); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -void -test_find_and_modify_install (TestSuite *suite) -{ - TestSuite_AddLive ( - suite, "/find_and_modify/find_and_modify", test_find_and_modify); - TestSuite_AddMockServerTest (suite, - "/find_and_modify/find_and_modify/bypass/true", - test_find_and_modify_bypass_true); - TestSuite_AddMockServerTest (suite, - "/find_and_modify/find_and_modify/bypass/false", - test_find_and_modify_bypass_false); - TestSuite_AddMockServerTest ( - suite, - "/find_and_modify/find_and_modify/write_concern", - test_find_and_modify_write_concern); - TestSuite_AddFull (suite, - "/find_and_modify/find_and_modify/write_concern_failure", - test_find_and_modify_write_concern_failure, - NULL, - NULL, - test_framework_skip_if_not_replset); - TestSuite_AddMockServerTest ( - suite, "/find_and_modify/opts", test_find_and_modify_opts); - TestSuite_AddMockServerTest (suite, - "/find_and_modify/opts/write_concern", - test_find_and_modify_opts_write_concern); - TestSuite_AddMockServerTest ( - suite, "/find_and_modify/collation", test_find_and_modify_collation); - TestSuite_AddLive ( - suite, "/find_and_modify/hint", test_find_and_modify_hint); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-gridfs-bucket.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-gridfs-bucket.c deleted file mode 100644 index 1ee5a3246..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-gridfs-bucket.c +++ /dev/null @@ -1,1188 +0,0 @@ -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mongoc/mongoc.h" -#include "mongoc/mongoc-gridfs-bucket-private.h" -#include "json-test.h" -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - -void -test_create_bucket (void) -{ - /* Tests creating a bucket with all opts set */ - mongoc_gridfs_bucket_t *gridfs; - mongoc_read_prefs_t *read_prefs; - mongoc_write_concern_t *write_concern; - mongoc_read_concern_t *read_concern; - mongoc_database_t *db; - mongoc_client_t *client; - bson_t *opts; - char *dbname; - - client = test_framework_new_default_client (); - ASSERT (client); - - dbname = gen_collection_name ("test"); - - db = mongoc_client_get_database (client, dbname); - - bson_free (dbname); - - ASSERT (db); - - opts = bson_new (); - - /* write concern */ - write_concern = mongoc_write_concern_new (); - mongoc_write_concern_set_w (write_concern, 1); - mongoc_write_concern_append (write_concern, opts); - - /* read concern */ - read_concern = mongoc_read_concern_new (); - mongoc_read_concern_set_level (read_concern, - MONGOC_READ_CONCERN_LEVEL_LOCAL); - mongoc_read_concern_append (read_concern, opts); - - /* other opts */ - BSON_APPEND_UTF8 (opts, "bucketName", "test-gridfs"); - BSON_APPEND_INT32 (opts, "chunkSizeBytes", 10); - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - gridfs = mongoc_gridfs_bucket_new (db, opts, read_prefs, NULL); - - ASSERT (gridfs); - - mongoc_gridfs_bucket_destroy (gridfs); - bson_destroy (opts); - mongoc_write_concern_destroy (write_concern); - mongoc_read_concern_destroy (read_concern); - mongoc_read_prefs_destroy (read_prefs); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -static int -_get_index_count (mongoc_collection_t *collection) -{ - mongoc_cursor_t *cursor; - bson_error_t error = {0}; - int n; - const bson_t *info; - - cursor = mongoc_collection_find_indexes (collection, &error); - ASSERT_OR_PRINT (0 == error.code, error); - - n = 0; - - while (mongoc_cursor_next (cursor, &info)) { - n++; - } - - mongoc_cursor_destroy (cursor); - - return n; -} - -/* Util that downloads a file content into the given buffer. Returns num bytes - * read. */ -static size_t -_download_file_into_buf (mongoc_gridfs_bucket_t *bucket, - const bson_value_t *file_id, - char *buf, - size_t len) -{ - bson_error_t error; - size_t nread; - mongoc_stream_t *down = - mongoc_gridfs_bucket_open_download_stream (bucket, file_id, &error); - ASSERT_OR_PRINT (down, error); - nread = - mongoc_stream_read (down, buf, len, 1 /* min read */, 0 /* No timeout */); - mongoc_stream_destroy (down); - ASSERT (nread > 0); - return nread; -} - -/* Util for uploading a file with the given string as content */ -static void -_upload_file_from_str (mongoc_gridfs_bucket_t *bucket, - const char *filename, - const char *content, - const bson_t *opts, - bson_value_t *file_id) -{ - bson_error_t error; - mongoc_stream_t *const up = mongoc_gridfs_bucket_open_upload_stream ( - bucket, filename, opts, file_id, &error); - ASSERT_OR_PRINT (up, error); - const size_t nwritten = - mongoc_stream_write (up, (void *) content, strlen (content), 0); - ASSERT_CMPSIZE_T (nwritten, ==, strlen (content)); - mongoc_stream_destroy (up); -} - -void -_test_upload_and_download (bson_t *create_index_cmd) -{ - mongoc_gridfs_bucket_t *gridfs; - bson_value_t file_id; - mongoc_database_t *db; - mongoc_client_t *client; - bson_t *opts; - /* big enough to hold all of str */ - char buf[100] = {0}; - char *str; - char *dbname; - - str = "This is a test sentence with multiple chunks."; - - client = test_framework_new_default_client (); - - ASSERT (client); - - dbname = gen_collection_name ("test"); - - db = mongoc_client_get_database (client, dbname); - - bson_free (dbname); - - ASSERT (db); - - if (create_index_cmd) { - bson_error_t error; - - ASSERT_OR_PRINT (mongoc_database_write_command_with_opts ( - db, create_index_cmd, NULL, NULL, &error), - error); - } - - opts = bson_new (); - BSON_APPEND_INT32 (opts, "chunkSizeBytes", 10); - - gridfs = mongoc_gridfs_bucket_new (db, opts, NULL, NULL); - - _upload_file_from_str (gridfs, "my-file", str, opts, &file_id); - - /* download str into the buffer from gridfs. */ - _download_file_into_buf (gridfs, &file_id, buf, sizeof buf); - - /* compare. */ - ASSERT (strcmp (buf, str) == 0); - - ASSERT_CMPINT (_get_index_count (gridfs->files), ==, 2); - ASSERT_CMPINT (_get_index_count (gridfs->chunks), ==, 2); - - bson_destroy (opts); - mongoc_gridfs_bucket_destroy (gridfs); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -void -test_upload_and_download (void) -{ - _test_upload_and_download (NULL); - - /* Test files index with float and same options */ - _test_upload_and_download ( - tmp_bson ("{'createIndexes': '%s'," - " 'indexes': [{'key': {'filename': 1.0, 'uploadDate': 1}, " - "'name': 'filename_1_uploadDate_1'}]}", - "fs.files")); - - /* Files index with float and different options */ - _test_upload_and_download ( - tmp_bson ("{'createIndexes': '%s'," - " 'indexes': [{'key': {'filename': 1.0, 'uploadDate': 1}, " - "'name': 'different_name'}]}", - "fs.files")); - - /* Chunks index with float and same options */ - _test_upload_and_download ( - tmp_bson ("{'createIndexes': '%s'," - " 'indexes': [{'key': {'files_id': 1.0, 'n': 1}, 'name': " - "'files_id_1_n_1', 'unique': true}]}", - "fs.chunks")); - - /* Chunks index with float and different options */ - _test_upload_and_download ( - tmp_bson ("{'createIndexes': '%s'," - " 'indexes': [{'key': {'files_id': 1.0, 'n': 1}, 'name': " - "'different_name', 'unique': true}]}", - "fs.chunks")); -} - -bool -hex_to_bytes (const char *hex_str, - size_t *size /* OUT */, - uint8_t **bytes /* OUT */) -{ - size_t len; - uint8_t *result; - size_t i; - - len = strlen (hex_str); - - ASSERT (bytes); - ASSERT (len % 2 == 0); - - if (len == 0) { - return false; - } - - result = (uint8_t *) bson_malloc0 (len / 2); - - for (i = 0; i < len; i += 2) { - sscanf (hex_str + i, "%2hhx", &result[i / 2]); - } - - *bytes = result; - - if (size) { - *size = (len / 2); - } - - return true; -} - -bson_t * -convert_hex_to_binary (bson_t *doc) -{ - /* PLAN: Recurse to all sub documents and call this function, otherwise, just - * append */ - bson_iter_t iter; - bson_iter_t inner; - bson_t *result; - const char *key; - bson_t *sub_doc; - bson_t *sub_doc_result; - const bson_value_t *value; - - bson_t *hex_doc; - uint8_t *hex_bytes; - size_t hex_len; - const char *str; - bool r; - - result = bson_new (); - - bson_iter_init (&iter, doc); - - while (bson_iter_next (&iter)) { - key = bson_iter_key (&iter); - value = bson_iter_value (&iter); - - if (strcmp (key, "data") == 0) { - hex_doc = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - ASSERT (bson_iter_init_find (&inner, hex_doc, "$hex")); - - str = bson_iter_utf8 (&inner, NULL); - r = hex_to_bytes (str, &hex_len, &hex_bytes); - - if (r) { - BSON_APPEND_BINARY ( - result, key, BSON_SUBTYPE_BINARY, hex_bytes, (uint32_t) hex_len); - bson_free (hex_bytes); - } else { - BSON_APPEND_BINARY ( - result, key, BSON_SUBTYPE_BINARY, (const uint8_t *) str, 0); - } - - bson_destroy (hex_doc); - - } else if (value->value_type == BSON_TYPE_DOCUMENT || - value->value_type == BSON_TYPE_ARRAY) { - sub_doc = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - sub_doc_result = convert_hex_to_binary (sub_doc); - bson_destroy (sub_doc); - if (value->value_type == BSON_TYPE_DOCUMENT) { - BSON_APPEND_DOCUMENT (result, key, sub_doc_result); - } else { - BSON_APPEND_ARRAY (result, key, sub_doc_result); - } - bson_destroy (sub_doc_result); - } else { - BSON_APPEND_VALUE (result, key, value); - } - } - - return result; -} - -/* - * Initializes the proper GridFS collections with the provided data - */ -void -setup_gridfs_collections (mongoc_database_t *db, bson_t *data) -{ - mongoc_collection_t *files; - mongoc_collection_t *chunks; - mongoc_collection_t *expected_files; - mongoc_collection_t *expected_chunks; - bson_iter_t iter; - bson_iter_t inner; - bson_t *selector; - bool r; - - files = mongoc_database_get_collection (db, "fs.files"); - chunks = mongoc_database_get_collection (db, "fs.chunks"); - expected_files = mongoc_database_get_collection (db, "expected.files"); - expected_chunks = mongoc_database_get_collection (db, "expected.chunks"); - - selector = bson_new (); - - mongoc_collection_delete_many (files, selector, NULL, NULL, NULL); - mongoc_collection_delete_many (chunks, selector, NULL, NULL, NULL); - mongoc_collection_delete_many (expected_files, selector, NULL, NULL, NULL); - mongoc_collection_delete_many (expected_chunks, selector, NULL, NULL, NULL); - - bson_destroy (selector); - - if (bson_iter_init_find (&iter, data, "files")) { - bson_t *docs = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - bson_iter_init (&inner, docs); - while (bson_iter_next (&inner)) { - bson_t *doc = - bson_new_from_data (bson_iter_value (&inner)->value.v_doc.data, - bson_iter_value (&inner)->value.v_doc.data_len); - r = mongoc_collection_insert_one (files, doc, NULL, NULL, NULL); - ASSERT (r); - r = mongoc_collection_insert_one ( - expected_files, doc, NULL, NULL, NULL); - ASSERT (r); - bson_destroy (doc); - } - - bson_destroy (docs); - } - - if (bson_iter_init_find (&iter, data, "chunks")) { - bson_t *docs = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - bson_iter_init (&inner, docs); - while (bson_iter_next (&inner)) { - bson_t *doc = - bson_new_from_data (bson_iter_value (&inner)->value.v_doc.data, - bson_iter_value (&inner)->value.v_doc.data_len); - bson_t *chunk = convert_hex_to_binary (doc); - r = mongoc_collection_insert_one (chunks, chunk, NULL, NULL, NULL); - ASSERT (r); - r = mongoc_collection_insert_one ( - expected_chunks, chunk, NULL, NULL, NULL); - ASSERT (r); - bson_destroy (doc); - bson_destroy (chunk); - } - - bson_destroy (docs); - } - - mongoc_collection_destroy (files); - mongoc_collection_destroy (chunks); - mongoc_collection_destroy (expected_files); - mongoc_collection_destroy (expected_chunks); -} - -void -gridfs_spec_run_commands (mongoc_database_t *db, bson_t *commands) -{ - bson_iter_t iter; - bson_t *data; - bson_t *command; - bson_t *hex_command; - bool r; - - ASSERT (bson_iter_init_find (&iter, commands, "data")); - data = bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - bson_iter_init (&iter, data); - - while (bson_iter_next (&iter)) { - command = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - hex_command = convert_hex_to_binary (command); - - r = mongoc_database_command_simple (db, hex_command, NULL, NULL, NULL); - ASSERT (r); - bson_destroy (command); - bson_destroy (hex_command); - } - bson_destroy (data); -} - -bson_t * -gridfs_replace_result (bson_t *doc, bson_value_t *replacement) -{ - bson_iter_t iter; - bson_t *result; - const char *key; - bson_t *sub_doc; - bson_t *sub_doc_result; - const bson_value_t *value; - - const char *str; - - result = bson_new (); - - bson_iter_init (&iter, doc); - - while (bson_iter_next (&iter)) { - key = bson_iter_key (&iter); - value = bson_iter_value (&iter); - - if (value->value_type == BSON_TYPE_UTF8) { - str = bson_iter_utf8 (&iter, NULL); - - if (strcmp (str, "*result") == 0) { - BSON_APPEND_VALUE (result, key, replacement); - } else if (strcmp (str, "*actual") == 0) { - /* Skip adding this */ - } else { - BSON_APPEND_VALUE (result, key, value); - } - - } else if (value->value_type == BSON_TYPE_DOCUMENT || - value->value_type == BSON_TYPE_ARRAY) { - sub_doc = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - sub_doc_result = gridfs_replace_result (sub_doc, replacement); - bson_destroy (sub_doc); - if (value->value_type == BSON_TYPE_DOCUMENT) { - BSON_APPEND_DOCUMENT (result, key, sub_doc_result); - } else { - BSON_APPEND_ARRAY (result, key, sub_doc_result); - } - bson_destroy (sub_doc_result); - } else { - BSON_APPEND_VALUE (result, key, value); - } - } - - return result; -} - -void -gridfs_compare_collections (mongoc_database_t *db) -{ - mongoc_collection_t *files; - mongoc_collection_t *chunks; - mongoc_collection_t *expected_files; - mongoc_collection_t *expected_chunks; - mongoc_cursor_t *expected_cursor; - mongoc_cursor_t *actual_cursor; - const bson_t *expected_doc; - const bson_t *actual_doc; - bson_iter_t expected_iter; - bson_iter_t actual_iter; - const uint8_t *expected_binary; - const uint8_t *actual_binary; - uint32_t expected_len; - uint32_t actual_len; - bson_t filter; - - files = mongoc_database_get_collection (db, "fs.files"); - chunks = mongoc_database_get_collection (db, "fs.chunks"); - expected_files = mongoc_database_get_collection (db, "expected.files"); - expected_chunks = mongoc_database_get_collection (db, "expected.chunks"); - - bson_init (&filter); - - /* Compare files collections */ - actual_cursor = - mongoc_collection_find_with_opts (files, &filter, NULL, NULL); - expected_cursor = - mongoc_collection_find_with_opts (expected_files, &filter, NULL, NULL); - - while (mongoc_cursor_next (expected_cursor, &expected_doc)) { - ASSERT (mongoc_cursor_next (actual_cursor, &actual_doc)); - - ASSERT (bson_iter_init_find (&actual_iter, actual_doc, "_id")); - ASSERT (bson_iter_init_find (&expected_iter, expected_doc, "_id")); - ASSERT (bson_oid_compare (bson_iter_oid (&actual_iter), - bson_iter_oid (&expected_iter)) == 0); - - ASSERT (bson_iter_init_find (&actual_iter, actual_doc, "length")); - ASSERT (bson_iter_init_find (&expected_iter, expected_doc, "length")); - ASSERT (bson_iter_as_int64 (&actual_iter) == - bson_iter_as_int64 (&expected_iter)); - - ASSERT (bson_iter_init_find (&actual_iter, actual_doc, "chunkSize")); - ASSERT (bson_iter_init_find (&expected_iter, expected_doc, "chunkSize")); - ASSERT (bson_iter_int32 (&actual_iter) == - bson_iter_int32 (&expected_iter)); - - ASSERT (bson_iter_init_find (&actual_iter, actual_doc, "filename")); - ASSERT (bson_iter_init_find (&expected_iter, expected_doc, "filename")); - ASSERT (strcmp (bson_iter_utf8 (&actual_iter, NULL), - bson_iter_utf8 (&expected_iter, NULL)) == 0); - } - - /* Make sure the actual doesn't have extra docs */ - ASSERT (!mongoc_cursor_next (actual_cursor, &actual_doc)); - - mongoc_cursor_destroy (actual_cursor); - mongoc_cursor_destroy (expected_cursor); - - - /* Compare chunks collections */ - actual_cursor = - mongoc_collection_find_with_opts (chunks, &filter, NULL, NULL); - expected_cursor = - mongoc_collection_find_with_opts (expected_chunks, &filter, NULL, NULL); - - - while (mongoc_cursor_next (expected_cursor, &expected_doc)) { - ASSERT (mongoc_cursor_next (actual_cursor, &actual_doc)); - - ASSERT (bson_iter_init_find (&actual_iter, actual_doc, "files_id")); - ASSERT (bson_iter_init_find (&expected_iter, expected_doc, "files_id")); - ASSERT (bson_oid_compare (bson_iter_oid (&actual_iter), - bson_iter_oid (&expected_iter)) == 0); - - ASSERT (bson_iter_init_find (&actual_iter, actual_doc, "n")); - ASSERT (bson_iter_init_find (&expected_iter, expected_doc, "n")); - ASSERT (bson_iter_int32 (&actual_iter) == - bson_iter_int32 (&expected_iter)); - - ASSERT (bson_iter_init_find (&actual_iter, actual_doc, "data")); - ASSERT (bson_iter_init_find (&expected_iter, expected_doc, "data")); - bson_iter_binary (&actual_iter, NULL, &actual_len, &actual_binary); - bson_iter_binary (&expected_iter, NULL, &expected_len, &expected_binary); - ASSERT (actual_len == expected_len); - ASSERT (memcmp (actual_binary, expected_binary, actual_len) == 0); - } - - /* Make sure the actual doesn't have extra docs */ - ASSERT (!mongoc_cursor_next (actual_cursor, &actual_doc)); - - bson_destroy (&filter); - mongoc_cursor_destroy (actual_cursor); - mongoc_cursor_destroy (expected_cursor); - - mongoc_collection_destroy (files); - mongoc_collection_destroy (chunks); - mongoc_collection_destroy (expected_files); - mongoc_collection_destroy (expected_chunks); -} - -void -gridfs_spec_delete_operation (mongoc_database_t *db, - mongoc_gridfs_bucket_t *bucket, - bson_t *act, - bson_t *assert) -{ - bson_iter_t iter; - bson_t *arguments; - const bson_value_t *value; - bool r; - - ASSERT (bson_iter_init_find (&iter, act, "arguments")); - arguments = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - ASSERT (bson_iter_init_find (&iter, arguments, "id")); - value = bson_iter_value (&iter); - - r = mongoc_gridfs_bucket_delete_by_id (bucket, value, NULL); - ASSERT (r != bson_iter_init_find (&iter, assert, "error")); - - if (bson_iter_init_find (&iter, assert, "data")) { - gridfs_spec_run_commands (db, assert); - } - - /* compare collections! */ - gridfs_compare_collections (db); - - bson_destroy (arguments); -} - -void -gridfs_spec_download_operation (mongoc_database_t *db, - mongoc_gridfs_bucket_t *bucket, - bson_t *act, - bson_t *assert) -{ - bson_iter_t iter; - bson_t *arguments; - bson_t *hex_doc; - const bson_value_t *value; - mongoc_stream_t *stream; - char buf[100] = {0}; - uint8_t *hex_bytes; - size_t hex_len; - ssize_t ret; - const char *str; - const char *expected_error; - bson_error_t error; - bool r; - - BSON_UNUSED (db); - - ASSERT (bson_iter_init_find (&iter, act, "arguments")); - arguments = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - if (bson_iter_init_find (&iter, assert, "error")) { - expected_error = bson_iter_utf8 (&iter, NULL); - } else { - expected_error = ""; - } - - ASSERT (bson_iter_init_find (&iter, arguments, "id")); - value = bson_iter_value (&iter); - - stream = mongoc_gridfs_bucket_open_download_stream (bucket, value, &error); - - if (strcmp (expected_error, "FileNotFound") == 0) { - ASSERT (!stream); - ASSERT (error.code); - bson_destroy (arguments); - return; - } - - ret = mongoc_stream_read (stream, buf, 100, 0, 0); - - if (strcmp (expected_error, "ChunkIsMissing") == 0 || - strcmp (expected_error, "ChunkIsWrongSize") == 0) { - ASSERT (ret < 0); - r = mongoc_gridfs_bucket_stream_error (stream, &error); - ASSERT (r); - ASSERT (error.code); - bson_destroy (arguments); - mongoc_stream_destroy (stream); - return; - } - - mongoc_stream_close (stream); - - ASSERT (bson_iter_init_find (&iter, assert, "result")); - hex_doc = bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - ASSERT (bson_iter_init_find (&iter, hex_doc, "$hex")); - str = bson_iter_utf8 (&iter, NULL); - - r = hex_to_bytes (str, &hex_len, &hex_bytes); - if (r) { - ASSERT (ret == hex_len); - ASSERT (memcmp (buf, hex_bytes, hex_len) == 0); - bson_free (hex_bytes); - } else { - ASSERT (ret == 0); - } - - /* Make sure we don't need to run any commands */ - ASSERT (!bson_iter_init_find (&iter, assert, "data")); - - bson_destroy (hex_doc); - bson_destroy (arguments); - mongoc_stream_destroy (stream); -} - -void -gridfs_spec_download_by_name_operation (mongoc_database_t *db, - mongoc_gridfs_bucket_t *bucket, - bson_t *act, - bson_t *assert) -{ - BSON_UNUSED (db); - BSON_UNUSED (bucket); - BSON_UNUSED (act); - BSON_UNUSED (assert); - - /* The download_by_name functionality is part of the Advanced API for GridFS - * and the C Driver hasn't implemented the Advanced API yet. This is a - * placeholder to be used when the download_by_name is implemented. */ -} - -void -gridfs_spec_upload_operation (mongoc_database_t *db, - mongoc_gridfs_bucket_t *bucket, - bson_t *act, - bson_t *assert) -{ - bson_iter_t iter; - bson_t *arguments; - const char *filename; - mongoc_stream_t *stream; - uint8_t *hex_bytes; - bson_t *hex_doc; - bson_t *options; - ssize_t bytes_written; - const char *str; - bson_value_t file_id; - bson_t *assert_modified; - size_t hex_len; - bool r; - - ASSERT (bson_iter_init_find (&iter, act, "arguments")); - arguments = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - ASSERT (bson_iter_init_find (&iter, arguments, "filename")); - filename = bson_iter_utf8 (&iter, NULL); - - ASSERT (bson_iter_init_find (&iter, arguments, "source")); - hex_doc = bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - ASSERT (bson_iter_init_find (&iter, hex_doc, "$hex")); - str = bson_iter_utf8 (&iter, NULL); - - r = hex_to_bytes (str, &hex_len, &hex_bytes); - if (!r) { - hex_len = 0; - hex_bytes = bson_malloc0 (1); - } - - ASSERT (bson_iter_init_find (&iter, arguments, "options")); - options = bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - stream = mongoc_gridfs_bucket_open_upload_stream ( - bucket, filename, options, &file_id, NULL); - - ASSERT (stream); - - bytes_written = mongoc_stream_write (stream, hex_bytes, hex_len, 0); - ASSERT (bytes_written == hex_len); - bson_free (hex_bytes); - - mongoc_stream_close (stream); - mongoc_stream_destroy (stream); - - assert_modified = gridfs_replace_result (assert, &file_id); - gridfs_spec_run_commands (db, assert_modified); - gridfs_compare_collections (db); - - bson_destroy (assert_modified); - bson_destroy (options); - bson_destroy (hex_doc); - bson_destroy (arguments); -} -void -run_gridfs_spec_test (mongoc_database_t *db, - mongoc_gridfs_bucket_t *bucket, - bson_t *test) -{ - bson_iter_t iter; - bson_iter_t inner; - bson_t *act; - bson_t *assert; - bson_t *arrange; - const char *operation; - - ASSERT (bson_iter_init_find (&iter, test, "act")); - act = bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - ASSERT (bson_iter_init_find (&iter, test, "assert")); - assert = bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - if (bson_iter_init_find (&iter, test, "arrange")) { - arrange = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - gridfs_spec_run_commands (db, arrange); - bson_destroy (arrange); - } - - ASSERT (bson_iter_init_find (&inner, act, "operation")); - operation = bson_iter_utf8 (&inner, NULL); - - if (strcmp (operation, "delete") == 0) { - gridfs_spec_delete_operation (db, bucket, act, assert); - } else if (strcmp (operation, "download") == 0) { - gridfs_spec_download_operation (db, bucket, act, assert); - } else if (strcmp (operation, "download_by_name") == 0) { - gridfs_spec_download_by_name_operation (db, bucket, act, assert); - } else if (strcmp (operation, "upload") == 0) { - gridfs_spec_upload_operation (db, bucket, act, assert); - } else { - /* Shouldn't happen. */ - ASSERT (false); - } - - bson_destroy (act); - bson_destroy (assert); -} - -static void -test_gridfs_cb (bson_t *scenario) -{ - mongoc_gridfs_bucket_t *gridfs; - mongoc_database_t *db; - mongoc_client_t *client; - bson_iter_t iter; - bson_iter_t inner; - char *dbname; - bson_t *data; - bson_t *tests; - bson_t *test; - - /* Make a gridfs on generated db */ - dbname = gen_collection_name ("test"); - client = test_framework_new_default_client (); - db = mongoc_client_get_database (client, dbname); - gridfs = mongoc_gridfs_bucket_new (db, NULL, NULL, NULL); - - /* Insert the data */ - if (bson_iter_init_find (&iter, scenario, "data")) { - data = bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - setup_gridfs_collections (db, data); - bson_destroy (data); - } - - /* Run the tests */ - if (bson_iter_init_find (&iter, scenario, "tests")) { - tests = - bson_new_from_data (bson_iter_value (&iter)->value.v_doc.data, - bson_iter_value (&iter)->value.v_doc.data_len); - - bson_iter_init (&inner, tests); - while (bson_iter_next (&inner)) { - test = - bson_new_from_data (bson_iter_value (&inner)->value.v_doc.data, - bson_iter_value (&inner)->value.v_doc.data_len); - run_gridfs_spec_test (db, gridfs, test); - bson_destroy (test); - } - - bson_destroy (tests); - } - - bson_free (dbname); - mongoc_gridfs_bucket_destroy (gridfs); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -static void -test_all_spec_tests (TestSuite *suite) -{ - install_json_test_suite (suite, JSON_DIR, "gridfs", &test_gridfs_cb); -} - -static void -test_upload_error (void *ctx) -{ - mongoc_client_t *client; - mongoc_uri_t *uri; - mongoc_database_t *db; - mongoc_gridfs_bucket_t *gridfs; - mongoc_stream_t *source; - bson_error_t error = {0}; - char *const dbname = gen_collection_name ("test_upload_error"); - bool r; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - db = mongoc_client_get_database (client, dbname); - gridfs = mongoc_gridfs_bucket_new (db, NULL, NULL, NULL); - source = mongoc_stream_file_new_for_path ( - BSON_BINARY_DIR "/test1.bson", O_RDONLY, 0); - BSON_ASSERT (source); - r = mongoc_gridfs_bucket_upload_from_stream ( - gridfs, "test1", source, NULL /* opts */, NULL /* file id */, &error); - ASSERT_OR_PRINT (r, error); - - /* create a read-only user */ - (void) mongoc_database_remove_user (db, "fake_user", NULL); - r = mongoc_database_add_user ( - db, "fake_user", "password", tmp_bson ("{'0': 'read'}"), NULL, &error); - ASSERT_OR_PRINT (r, error); - - mongoc_stream_close (source); - mongoc_stream_destroy (source); - mongoc_gridfs_bucket_destroy (gridfs); - mongoc_database_destroy (db); - mongoc_client_destroy (client); - - /* initialize gridfs with a root user. */ - uri = test_framework_get_uri (); - mongoc_uri_set_username (uri, "fake_user"); - mongoc_uri_set_password (uri, "password"); - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - mongoc_uri_destroy (uri); - - source = mongoc_stream_file_new_for_path ( - BSON_BINARY_DIR "/test1.bson", O_RDONLY, 0); - BSON_ASSERT (source); - db = mongoc_client_get_database (client, dbname); - gridfs = mongoc_gridfs_bucket_new (db, NULL, NULL, NULL); - mongoc_gridfs_bucket_upload_from_stream ( - gridfs, "test1", source, NULL /* opts */, NULL /* file id */, &error); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_CLIENT, MONGOC_ERROR_CLIENT_AUTHENTICATE, ""); - - mongoc_stream_close (source); - mongoc_stream_destroy (source); - mongoc_gridfs_bucket_destroy (gridfs); - bson_free (dbname); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -static void -test_find_w_session (void *ctx) -{ - mongoc_client_t *client; - mongoc_database_t *db; - mongoc_gridfs_bucket_t *gridfs; - mongoc_cursor_t *cursor; - bson_error_t error = {0}; - bson_t opts; - mongoc_client_session_t *session; - char *dbname = gen_collection_name ("test_find_w_session"); - bool r; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - db = mongoc_client_get_database (client, dbname); - gridfs = mongoc_gridfs_bucket_new (db, NULL, NULL, NULL); - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - bson_init (&opts); - r = mongoc_client_session_append (session, &opts, &error); - ASSERT_OR_PRINT (r, error); - cursor = mongoc_gridfs_bucket_find (gridfs, tmp_bson ("{}"), &opts); - BSON_ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CURSOR, - MONGOC_ERROR_CURSOR_INVALID_CURSOR, - "Cannot pass sessionId as an option"); - bson_destroy (&opts); - mongoc_cursor_destroy (cursor); - mongoc_gridfs_bucket_destroy (gridfs); - mongoc_client_session_destroy (session); - mongoc_database_destroy (db); - bson_free (dbname); - mongoc_client_destroy (client); -} - -static void -test_find (void *ctx) -{ - mongoc_client_t *const client = test_framework_new_default_client (); - char *const dbname = gen_collection_name ("test_find"); - mongoc_database_t *const db = mongoc_client_get_database (client, dbname); - mongoc_gridfs_bucket_t *const gridfs = - mongoc_gridfs_bucket_new (db, NULL, NULL, NULL); - mongoc_cursor_t *cursor; - bson_error_t error = {0}; - bson_t const *found; - bson_iter_t iter; - char buffer[256] = {0}; - bool ok; - bson_value_t const *found_id; - const bson_t *const find_opts = - tmp_bson ("{'limit': 1, 'skip': 2, 'sort': {'metadata.testOrder': -1}}"); - - BSON_UNUSED (ctx); - - _upload_file_from_str (gridfs, - "file1", - "First file", - tmp_bson ("{'metadata': {'testOrder': 1}}"), - NULL); - _upload_file_from_str (gridfs, - "file2", - "Second file", - tmp_bson ("{'metadata': {'testOrder': 2}}"), - NULL); - _upload_file_from_str (gridfs, - "file3", - "Third file", - tmp_bson ("{'metadata': {'testOrder': 3}}"), - NULL); - _upload_file_from_str (gridfs, - "file4", - "Fourth file", - tmp_bson ("{'metadata': {'testOrder': 4}}"), - NULL); - - cursor = mongoc_gridfs_bucket_find (gridfs, tmp_bson ("{}"), find_opts); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - ok = mongoc_cursor_next (cursor, &found); - ASSERT (ok && "No files returned"); - ok = bson_iter_init_find (&iter, found, "_id"); - ASSERT (ok && "Document has no '_id' ??"); - found_id = bson_iter_value (&iter); - - _download_file_into_buf (gridfs, found_id, buffer, sizeof buffer); - ASSERT_CMPSTR (buffer, "Second file"); - - ok = mongoc_cursor_next (cursor, &found); - ASSERT (!(ok && "More than one file returned")); - - mongoc_cursor_destroy (cursor); - mongoc_gridfs_bucket_destroy (gridfs); - bson_free (dbname); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -void -test_gridfs_bucket_opts (void) -{ - mongoc_client_t *client; - mongoc_database_t *db; - mongoc_gridfs_bucket_t *gridfs; - bson_error_t error; - mongoc_read_concern_t *rc; - mongoc_write_concern_t *wc; - bson_t *opts; - char *bucket_name; - - client = test_framework_new_default_client (); - db = mongoc_client_get_database (client, "test"); - - /* check defaults. */ - gridfs = mongoc_gridfs_bucket_new (db, NULL, NULL, &error); - ASSERT_OR_PRINT (gridfs, error); - ASSERT_CMPSTR (gridfs->bucket_name, "fs"); - ASSERT_CMPINT32 (gridfs->chunk_size, ==, 255 * 1024); - BSON_ASSERT (!mongoc_read_concern_get_level ( - mongoc_collection_get_read_concern (gridfs->chunks))); - BSON_ASSERT (!mongoc_read_concern_get_level ( - mongoc_collection_get_read_concern (gridfs->files))); - ASSERT_CMPINT (mongoc_write_concern_get_w ( - mongoc_collection_get_write_concern (gridfs->chunks)), - ==, - MONGOC_WRITE_CONCERN_W_DEFAULT); - ASSERT_CMPINT (mongoc_write_concern_get_w ( - mongoc_collection_get_write_concern (gridfs->files)), - ==, - MONGOC_WRITE_CONCERN_W_DEFAULT); - mongoc_gridfs_bucket_destroy (gridfs); - - /* check out-of-range chunk sizes */ - gridfs = mongoc_gridfs_bucket_new ( - db, tmp_bson ("{'chunkSizeBytes': -1}"), NULL, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "should be greater than 0"); - mongoc_gridfs_bucket_destroy (gridfs); - - gridfs = mongoc_gridfs_bucket_new ( - db, tmp_bson ("{'chunkSizeBytes': 2147483648}"), NULL, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "out of range"); - mongoc_gridfs_bucket_destroy (gridfs); - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_AVAILABLE); - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED); - - opts = BCON_NEW ("bucketName", "abc", "chunkSizeBytes", BCON_INT32 (123)); - BSON_ASSERT (mongoc_read_concern_append (rc, opts)); - BSON_ASSERT (mongoc_write_concern_append (wc, opts)); - gridfs = mongoc_gridfs_bucket_new (db, opts, NULL, &error); - ASSERT_OR_PRINT (gridfs, error); - ASSERT_CMPSTR (gridfs->bucket_name, "abc"); - ASSERT_CMPINT32 (gridfs->chunk_size, ==, 123); - ASSERT_CMPSTR (mongoc_read_concern_get_level ( - mongoc_collection_get_read_concern (gridfs->chunks)), - MONGOC_READ_CONCERN_LEVEL_AVAILABLE); - ASSERT_CMPSTR (mongoc_read_concern_get_level ( - mongoc_collection_get_read_concern (gridfs->files)), - MONGOC_READ_CONCERN_LEVEL_AVAILABLE); - ASSERT_CMPINT (mongoc_write_concern_get_w ( - mongoc_collection_get_write_concern (gridfs->chunks)), - ==, - MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED); - ASSERT_CMPINT (mongoc_write_concern_get_w ( - mongoc_collection_get_write_concern (gridfs->files)), - ==, - MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED); - mongoc_read_concern_destroy (rc); - mongoc_write_concern_destroy (wc); - bson_destroy (opts); - mongoc_gridfs_bucket_destroy (gridfs); - - /* check validation of long bucket names */ - bucket_name = bson_malloc0 (128); - memset (bucket_name, 'a', 128 - strlen ("chunks")); - opts = BCON_NEW ("bucketName", bucket_name); - gridfs = mongoc_gridfs_bucket_new (db, opts, NULL, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "must have fewer"); - bson_destroy (opts); - mongoc_gridfs_bucket_destroy (gridfs); - - /* one character shorter should be okay though. */ - *(bucket_name + ((int) (128 - strlen ("chunks") - 1))) = '\0'; - opts = BCON_NEW ("bucketName", bucket_name); - gridfs = mongoc_gridfs_bucket_new (db, opts, NULL, &error); - ASSERT_OR_PRINT (gridfs, error); - bson_destroy (opts); - mongoc_gridfs_bucket_destroy (gridfs); - - bson_free (bucket_name); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -void -test_gridfs_bucket_install (TestSuite *suite) -{ - test_all_spec_tests (suite); - TestSuite_AddLive (suite, "/gridfs/create_bucket", test_create_bucket); - TestSuite_AddLive ( - suite, "/gridfs/upload_and_download", test_upload_and_download); - TestSuite_AddFull (suite, - "/gridfs/upload_error", - test_upload_error, - NULL, - NULL, - test_framework_skip_if_no_auth); - TestSuite_AddFull (suite, - "/gridfs/find_w_session", - test_find_w_session, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/gridfs/find", - test_find, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto); - TestSuite_AddLive (suite, "/gridfs/options", test_gridfs_bucket_opts); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-gridfs.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-gridfs.c deleted file mode 100644 index f1e66f3cb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-gridfs.c +++ /dev/null @@ -1,1784 +0,0 @@ -#include -#define MONGOC_INSIDE -#include -#include -#include - -#undef MONGOC_INSIDE - -#include "test-libmongoc.h" -#include "TestSuite.h" -#include "test-conveniences.h" -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" - - -static mongoc_gridfs_t * -get_test_gridfs (mongoc_client_t *client, const char *name, bson_error_t *error) -{ - char *gen; - char n[48]; - mongoc_database_t *db; - - gen = gen_collection_name ("fs"); - bson_snprintf (n, sizeof n, "%s_%s", gen, name); - bson_free (gen); - - db = mongoc_client_get_database (client, "test"); - mongoc_database_drop (db, NULL); - mongoc_database_destroy (db); - - return mongoc_client_get_gridfs (client, "test", NULL, error); -} - - -bool -drop_collections (mongoc_gridfs_t *gridfs, bson_error_t *error) -{ - return (mongoc_collection_drop (mongoc_gridfs_get_files (gridfs), error) && - mongoc_collection_drop (mongoc_gridfs_get_chunks (gridfs), error)); -} - - -static void -_check_index (mongoc_collection_t *collection, const char *index_json) -{ - mongoc_cursor_t *cursor; - bson_error_t error = {0}; - const bson_t *info; - const char *index_name; - bson_t index_key; - int n; - - cursor = mongoc_collection_find_indexes (collection, &error); - ASSERT_OR_PRINT (0 == error.code, error); - - n = 0; - - while (mongoc_cursor_next (cursor, &info)) { - index_name = bson_lookup_utf8 (info, "name"); - - /* if this is NOT the "_id" index */ - if (strcmp (index_name, "_id_")) { - bson_lookup_doc (info, "key", &index_key); - ASSERT_MATCH (&index_key, index_json); - } - - n++; - } - - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - /* _id index plus the expected index */ - ASSERT_CMPINT (n, ==, 2); - - mongoc_cursor_destroy (cursor); -} - - -static mongoc_gridfs_t * -_get_gridfs (mock_server_t *server, - mongoc_client_t *client, - mongoc_query_flags_t flags) -{ - future_t *future; - bson_error_t error; - request_t *request; - mongoc_gridfs_t *gridfs; - - BSON_UNUSED (flags); - - /* gridfs ensures two indexes */ - future = future_client_get_gridfs (client, "db", NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'listIndexes': 'fs.chunks'}")); - reply_to_request_simple ( - request, - "{ 'ok' : 0, 'errmsg' : 'ns does not exist: db.fs.chunks', 'code' : 26, " - "'codeName' : 'NamespaceNotFound' }"); - request_destroy (request); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'createIndexes': 'fs.chunks'}")); - - reply_to_request_with_ok_and_destroy (request); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'listIndexes': 'fs.files'}")); - reply_to_request_simple ( - request, - "{ 'ok' : 0, 'errmsg' : 'ns does not exist: db.fs.files', 'code' : 26, " - "'codeName' : 'NamespaceNotFound' }"); - request_destroy (request); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'createIndexes': 'fs.files'}")); - - reply_to_request_with_ok_and_destroy (request); - - gridfs = future_get_mongoc_gridfs_ptr (future); - ASSERT (gridfs); - - future_destroy (future); - - return gridfs; -} - - -static void -_test_create (bson_t *create_index_cmd) -{ - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_client_t *client; - bson_error_t error; - mongoc_collection_t *files; - mongoc_collection_t *chunks; - - client = test_framework_new_default_client (); - ASSERT (client); - - files = mongoc_client_get_collection (client, "test", "foo.files"); - chunks = mongoc_client_get_collection (client, "test", "foo.chunks"); - mongoc_collection_drop (files, NULL); - mongoc_collection_drop (chunks, NULL); - - if (create_index_cmd) { - bool r; - mongoc_database_t *db; - - db = mongoc_client_get_database (client, "test"); - - r = mongoc_database_write_command_with_opts ( - db, create_index_cmd, NULL, NULL, &error); - - ASSERT_OR_PRINT (r, error); - - mongoc_database_destroy (db); - } - - ASSERT_OR_PRINT ( - (gridfs = mongoc_client_get_gridfs (client, "test", "foo", &error)), - error); - - file = mongoc_gridfs_create_file (gridfs, NULL); - - _check_index (files, "{'filename': 1, 'uploadDate': 1}"); - _check_index (chunks, "{'files_id': 1, 'n': 1}"); - - ASSERT (file); - ASSERT (mongoc_gridfs_file_save (file)); - - mongoc_gridfs_file_destroy (file); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - - mongoc_collection_destroy (chunks); - mongoc_collection_destroy (files); - mongoc_client_destroy (client); -} - - -static void -test_create (void) -{ - _test_create (NULL); - - /* Test files index with float and same options */ - _test_create ( - tmp_bson ("{'createIndexes': '%s'," - " 'indexes': [{'key': {'filename': 1.0, 'uploadDate': 1}, " - "'name': 'filename_1_uploadDate_1'}]}", - "foo.files")); - - /* Files index with float and different options */ - _test_create (tmp_bson ("{'createIndexes': '%s'," - " 'indexes': [{'key': {'filename': 1.0, " - "'uploadDate': 1}, 'name': 'different_name'}]}", - "foo.files")); - - /* Chunks index with float and same options */ - _test_create (tmp_bson ("{'createIndexes': '%s'," - " 'indexes': [{'key': {'files_id': 1.0, 'n': 1}, " - "'name': 'files_id_1_n_1', 'unique': true}]}", - "foo.chunks")); - - /* Chunks index with float and different options */ - _test_create (tmp_bson ("{'createIndexes': '%s'," - " 'indexes': [{'key': {'files_id': 1.0, 'n': 1}, " - "'name': 'different_name', 'unique': true}]}", - "foo.chunks")); -} - - -static void -test_remove (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_gridfs_file_opt_t opts = {0}; - mongoc_client_t *client; - bson_error_t error; - char name[32]; - - client = test_framework_new_default_client (); - ASSERT (client); - - ASSERT_OR_PRINT ( - gridfs = mongoc_client_get_gridfs (client, "test", "foo", &error), error); - - mongoc_gridfs_drop (gridfs, &error); - - bson_snprintf (name, sizeof name, "test-remove.%u", rand ()); - opts.filename = name; - - file = mongoc_gridfs_create_file (gridfs, &opts); - ASSERT (file); - ASSERT (mongoc_gridfs_file_save (file)); - - ASSERT_OR_PRINT (mongoc_gridfs_file_remove (file, &error), error); - - mongoc_gridfs_file_destroy (file); - - file = mongoc_gridfs_find_one_by_filename (gridfs, name, &error); - ASSERT (!file); - - /* ensure "error" is cleared if we successfully find no file */ - ASSERT_CMPINT (error.domain, ==, 0); - ASSERT_CMPINT (error.code, ==, 0); - ASSERT_CMPSTR (error.message, ""); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - - mongoc_client_destroy (client); -} - - -static void -prep_files (mongoc_gridfs_t *gridfs) -{ - mongoc_gridfs_file_t *file; - mongoc_gridfs_file_opt_t opt = {0}; - char buf[100]; - int i = 0; - - for (i = 0; i < 3; i++) { - bson_snprintf (buf, sizeof buf, "file.%d", i); - opt.filename = buf; - file = mongoc_gridfs_create_file (gridfs, &opt); - ASSERT (file); - ASSERT (mongoc_gridfs_file_save (file)); - mongoc_gridfs_file_destroy (file); - } -} - - -static void -test_list (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_client_t *client; - bson_error_t error; - mongoc_gridfs_file_list_t *list; - bson_t query, child; - char buf[100]; - int i = 0; - - client = test_framework_new_default_client (); - ASSERT (client); - - ASSERT_OR_PRINT (gridfs = get_test_gridfs (client, "list", &error), error); - - prep_files (gridfs); - - bson_init (&query); - bson_append_document_begin (&query, "$orderby", -1, &child); - bson_append_int32 (&child, "filename", -1, 1); - bson_append_document_end (&query, &child); - bson_append_document_begin (&query, "$query", -1, &child); - bson_append_document_end (&query, &child); - - list = mongoc_gridfs_find (gridfs, &query); - - bson_destroy (&query); - - i = 0; - while ((file = mongoc_gridfs_file_list_next (list))) { - bson_snprintf (buf, sizeof buf, "file.%d", i++); - - ASSERT_CMPINT ( - strcmp (mongoc_gridfs_file_get_filename (file), buf), ==, 0); - - mongoc_gridfs_file_destroy (file); - } - ASSERT_CMPINT (i, ==, 3); - mongoc_gridfs_file_list_destroy (list); - - bson_init (&query); - bson_append_utf8 (&query, "filename", -1, "file.1", -1); - ASSERT_OR_PRINT (file = mongoc_gridfs_find_one (gridfs, &query, &error), - error); - bson_destroy (&query); - - ASSERT_CMPINT ( - strcmp (mongoc_gridfs_file_get_filename (file), "file.1"), ==, 0); - mongoc_gridfs_file_destroy (file); - - ASSERT_OR_PRINT ( - file = mongoc_gridfs_find_one_by_filename (gridfs, "file.1", &error), - error); - - ASSERT_CMPINT ( - strcmp (mongoc_gridfs_file_get_filename (file), "file.1"), ==, 0); - mongoc_gridfs_file_destroy (file); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - - mongoc_client_destroy (client); -} - -static void -test_find_with_opts (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_client_t *client; - bson_error_t error; - mongoc_gridfs_file_list_t *list; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - gridfs = get_test_gridfs (client, "test_find_with_opts", &error); - ASSERT_OR_PRINT (gridfs, error); - - prep_files (gridfs); - - list = mongoc_gridfs_find_with_opts ( - gridfs, - tmp_bson ("{'filename': {'$ne': 'file.1'}}"), - tmp_bson ("{'sort': {'filename': -1}}")); - - file = mongoc_gridfs_file_list_next (list); - ASSERT (file); - ASSERT_CMPSTR ("file.2", mongoc_gridfs_file_get_filename (file)); - mongoc_gridfs_file_destroy (file); - - file = mongoc_gridfs_file_list_next (list); - ASSERT (file); - ASSERT_CMPSTR ("file.0", mongoc_gridfs_file_get_filename (file)); - mongoc_gridfs_file_destroy (file); - - file = mongoc_gridfs_file_list_next (list); - ASSERT (!file); /* done */ - ASSERT (!mongoc_gridfs_file_list_error (list, &error)); - mongoc_gridfs_file_list_destroy (list); - - file = mongoc_gridfs_find_one_with_opts ( - gridfs, tmp_bson (NULL), tmp_bson ("{'sort': {'filename': -1}}"), &error); - - ASSERT_OR_PRINT (file, error); - /* file.2 is first, according to sort order */ - ASSERT_CMPSTR ("file.2", mongoc_gridfs_file_get_filename (file)); - mongoc_gridfs_file_destroy (file); - - file = mongoc_gridfs_find_one_with_opts ( - gridfs, tmp_bson ("{'x': {'$bad_operator': 1}}"), NULL, &error); - - ASSERT (!file); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_SERVER); - - /* ensure "error" is cleared if we successfully find no file */ - file = mongoc_gridfs_find_one_with_opts ( - gridfs, tmp_bson ("{'x': 'doesntexist'}"), NULL, &error); - - ASSERT (!file); - ASSERT_CMPINT (error.domain, ==, 0); - ASSERT_CMPINT (error.code, ==, 0); - ASSERT_CMPSTR (error.message, ""); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - - -/* mongoc_gridfs_find_one_with_opts uses limit 1, no matter what's in "opts" */ -static void -test_find_one_with_opts_limit (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - bson_error_t error; - future_t *future; - request_t *request; - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - mongoc_client_set_error_api (client, 2); - - gridfs = _get_gridfs (server, client, MONGOC_QUERY_SECONDARY_OK); - - future = - future_gridfs_find_one_with_opts (gridfs, tmp_bson ("{}"), NULL, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'find': 'fs.files', 'filter': {}, 'limit': 1}")); - - reply_to_op_msg_request ( - request, - MONGOC_MSG_NONE, - tmp_bson ( - "{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.fs.files'," - " 'firstBatch': [{'_id': 1, 'length': 1, 'chunkSize': 1}]}}")); - - file = future_get_mongoc_gridfs_file_ptr (future); - ASSERT (file); - - mongoc_gridfs_file_destroy (file); - future_destroy (future); - request_destroy (request); - - future = future_gridfs_find_one_with_opts ( - gridfs, tmp_bson ("{}"), tmp_bson ("{'limit': 2}"), &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'find': 'fs.files', 'filter': {}, 'limit': 1}")); - - reply_to_op_msg_request ( - request, - MONGOC_MSG_NONE, - tmp_bson ( - "{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.fs.files'," - " 'firstBatch': [{'_id': 1, 'length': 1, 'chunkSize': 1}]}}")); - - file = future_get_mongoc_gridfs_file_ptr (future); - ASSERT (file); - - mongoc_gridfs_file_destroy (file); - future_destroy (future); - request_destroy (request); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_properties (void) -{ - mongoc_client_t *client; - mongoc_gridfs_t *gridfs; - bson_error_t error; - bson_t *doc_in; - mongoc_gridfs_file_t *file; - mongoc_gridfs_file_list_t *list; - bson_t query = BSON_INITIALIZER; - const bson_value_t *file_id; - const char *alias0, *alias1; - - client = test_framework_new_default_client (); - - ASSERT_OR_PRINT (gridfs = get_test_gridfs (client, "list", &error), error); - - mongoc_gridfs_drop (gridfs, &error); - - /* the C Driver sets _id to an ObjectId, but other drivers can do anything */ - doc_in = BCON_NEW ("_id", - BCON_INT32 (1), - "md5", - BCON_UTF8 ("md5"), - "filename", - BCON_UTF8 ("filename"), - "contentType", - BCON_UTF8 ("content_type"), - "aliases", - "[", - BCON_UTF8 ("alias0"), - BCON_UTF8 ("alias1"), - "]", - "metadata", - "{", - "key", - BCON_UTF8 ("value"), - "}", - "chunkSize", - BCON_INT32 (100)); - - ASSERT (mongoc_collection_insert_one ( - mongoc_gridfs_get_files (gridfs), doc_in, NULL, NULL, NULL)); - - list = mongoc_gridfs_find (gridfs, &query); - file = mongoc_gridfs_file_list_next (list); - file_id = mongoc_gridfs_file_get_id (file); - ASSERT (file_id); - ASSERT_CMPINT (BSON_TYPE_INT32, ==, file_id->value_type); - ASSERT_CMPINT (1, ==, file_id->value.v_int32); - ASSERT_CMPSTR ("md5", mongoc_gridfs_file_get_md5 (file)); - ASSERT_CMPSTR ("filename", mongoc_gridfs_file_get_filename (file)); - ASSERT_CMPSTR ("content_type", mongoc_gridfs_file_get_content_type (file)); - ASSERT (BCON_EXTRACT ((bson_t *) mongoc_gridfs_file_get_aliases (file), - "0", - BCONE_UTF8 (alias0), - "1", - BCONE_UTF8 (alias1))); - - ASSERT_CMPSTR ("alias0", alias0); - ASSERT_CMPSTR ("alias1", alias1); - - drop_collections (gridfs, &error); - mongoc_gridfs_file_destroy (file); - mongoc_gridfs_file_list_destroy (list); - bson_destroy (doc_in); - bson_destroy (&query); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - - -static void -test_create_from_stream (void) -{ - int64_t start; - int64_t now; - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - bson_t *filter; - mongoc_gridfs_file_t *file2; - mongoc_stream_t *stream; - mongoc_client_t *client; - bson_error_t error; - - client = test_framework_new_default_client (); - ASSERT (client); - - ASSERT_OR_PRINT ((gridfs = get_test_gridfs (client, "from_stream", &error)), - error); - - mongoc_gridfs_drop (gridfs, &error); - - start = _mongoc_get_real_time_ms (); - stream = - mongoc_stream_file_new_for_path (BINARY_DIR "/gridfs.dat", O_RDONLY, 0); - ASSERT_OR_PRINT_ERRNO (stream, errno); - ASSERT (stream); - - file = mongoc_gridfs_create_file_from_stream (gridfs, stream, NULL); - ASSERT (file); - ASSERT (mongoc_gridfs_file_save (file)); - - now = _mongoc_get_real_time_ms (); - - filter = tmp_bson (NULL); - BSON_APPEND_VALUE (filter, "_id", mongoc_gridfs_file_get_id (file)); - file2 = mongoc_gridfs_find_one_with_opts (gridfs, filter, NULL, &error); - ASSERT_OR_PRINT (file2, error); - ASSERT_CMPINT64 (start, <=, mongoc_gridfs_file_get_upload_date (file2)); - ASSERT_CMPINT64 (now, >=, mongoc_gridfs_file_get_upload_date (file2)); - - mongoc_gridfs_file_destroy (file2); - mongoc_gridfs_file_destroy (file); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - - -static void -test_seek (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_stream_t *stream; - mongoc_client_t *client; - bson_error_t error; - - client = test_framework_new_default_client (); - - ASSERT_OR_PRINT (gridfs = get_test_gridfs (client, "seek", &error), error); - - mongoc_gridfs_drop (gridfs, &error); - - stream = mongoc_stream_file_new_for_path ( - BINARY_DIR "/gridfs-large.dat", O_RDONLY, 0); - - file = mongoc_gridfs_create_file_from_stream (gridfs, stream, NULL); - ASSERT (file); - ASSERT (mongoc_gridfs_file_save (file)); - - ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 0, SEEK_SET), ==, 0); - ASSERT_CMPUINT64 (mongoc_gridfs_file_tell (file), ==, (uint64_t) 0); - - ASSERT_CMPINT ( - mongoc_gridfs_file_seek (file, file->chunk_size + 1, SEEK_CUR), ==, 0); - ASSERT_CMPINT64 ( - mongoc_gridfs_file_tell (file), ==, (uint64_t) (file->chunk_size + 1)); - - ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 0, SEEK_END), ==, 0); - ASSERT_CMPINT64 ( - mongoc_gridfs_file_tell (file), ==, mongoc_gridfs_file_get_length (file)); - - mongoc_gridfs_file_destroy (file); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - - mongoc_client_destroy (client); -} - - -static void -test_read (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_stream_t *stream; - mongoc_client_t *client; - bson_error_t error; - ssize_t r; - char buf[10], buf2[10]; - mongoc_iovec_t iov[2]; - int previous_errno; - ssize_t twenty = 20L; - - iov[0].iov_base = buf; - iov[0].iov_len = 10; - - iov[1].iov_base = buf2; - iov[1].iov_len = 10; - - client = test_framework_new_default_client (); - ASSERT (client); - - ASSERT_OR_PRINT (gridfs = get_test_gridfs (client, "read", &error), error); - - mongoc_gridfs_drop (gridfs, &error); - - stream = mongoc_stream_file_new_for_path ( - BINARY_DIR "/gridfs-large.dat", O_RDONLY, 0); - - file = mongoc_gridfs_create_file_from_stream (gridfs, stream, NULL); - ASSERT (file); - ASSERT (mongoc_gridfs_file_save (file)); - - r = mongoc_gridfs_file_readv (file, iov, 2, 20, 0); - ASSERT_CMPSSIZE_T (r, ==, twenty); - ASSERT_MEMCMP (iov[0].iov_base, "Bacon ipsu", 10); - ASSERT_MEMCMP (iov[1].iov_base, "m dolor si", 10); - - ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 1, SEEK_SET), ==, 0); - r = mongoc_gridfs_file_readv (file, iov, 2, 20, 0); - - ASSERT_CMPSSIZE_T (r, ==, twenty); - ASSERT_MEMCMP (iov[0].iov_base, "acon ipsum", 10); - ASSERT_MEMCMP (iov[1].iov_base, " dolor sit", 10); - - ASSERT_CMPINT ( - mongoc_gridfs_file_seek (file, file->chunk_size - 1, SEEK_SET), ==, 0); - r = mongoc_gridfs_file_readv (file, iov, 2, 20, 0); - - ASSERT_CMPSSIZE_T (r, ==, twenty); - ASSERT_CMPINT64 ( - mongoc_gridfs_file_tell (file), ==, (uint64_t) (file->chunk_size + 19)); - ASSERT_MEMCMP (iov[0].iov_base, "turducken ", 10); - ASSERT_MEMCMP (iov[1].iov_base, "spare ribs", 10); - - BSON_ASSERT (mongoc_gridfs_file_seek (file, 20, SEEK_END) == 0); - previous_errno = errno; - r = mongoc_gridfs_file_readv (file, iov, 2, 20, 0); - - BSON_ASSERT (errno == previous_errno); - BSON_ASSERT (r == 0); - BSON_ASSERT (mongoc_gridfs_file_tell (file) == file->length + 20); - - mongoc_gridfs_file_destroy (file); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - - mongoc_client_destroy (client); -} - - -static void -_check_chunk_count (mongoc_gridfs_t *gridfs, int64_t len, int64_t chunk_size) -{ - int64_t expected_chunks; - int64_t cnt; - bson_error_t error; - - /* division, rounding up */ - expected_chunks = (len + chunk_size - 1) / chunk_size; - cnt = mongoc_collection_count_documents (mongoc_gridfs_get_chunks (gridfs), - tmp_bson (NULL), - NULL, - NULL, - NULL, - &error); - - ASSERT_CMPINT64 (expected_chunks, ==, cnt); -} - -static void -_test_write (bool at_boundary) -{ - ssize_t seek_len = at_boundary ? 5 : 6; - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_client_t *client; - bson_error_t error; - ssize_t r; - char buf[] = "foo bar"; - char buf2[] = " baz"; - char buf3[1000]; - char expected[1000] = {0}; - mongoc_gridfs_file_opt_t opt = {0}; - mongoc_iovec_t iov[2]; - mongoc_iovec_t riov; - ssize_t len = sizeof buf + sizeof buf2 - 2; - - iov[0].iov_base = buf; - iov[0].iov_len = sizeof (buf) - 1; - iov[1].iov_base = buf2; - iov[1].iov_len = sizeof (buf2) - 1; - - riov.iov_base = buf3; - riov.iov_len = sizeof (buf3); - - opt.chunk_size = 2; - - client = test_framework_new_default_client (); - ASSERT (client); - - gridfs = get_test_gridfs (client, "write", &error); - ASSERT_OR_PRINT (gridfs, error); - - mongoc_gridfs_drop (gridfs, &error); - - file = mongoc_gridfs_create_file (gridfs, &opt); - ASSERT (file); - - /* Test a write across many pages */ - r = mongoc_gridfs_file_writev (file, iov, 2, 0); - ASSERT_CMPSSIZE_T (r, ==, len); - - ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 0, SEEK_SET), ==, 0); - ASSERT_CMPUINT64 (mongoc_gridfs_file_tell (file), ==, (uint64_t) 0); - - r = mongoc_gridfs_file_readv (file, &riov, 1, len, 0); - ASSERT_CMPSSIZE_T (r, ==, len); - ASSERT_CMPINT (memcmp (buf3, "foo bar baz", len), ==, 0); - - ASSERT_CMPINT ( - mongoc_gridfs_file_seek (file, file->chunk_size, SEEK_SET), ==, 0); - ASSERT_CMPUINT64 ( - mongoc_gridfs_file_tell (file), ==, (uint64_t) (file->chunk_size)); - - r = mongoc_gridfs_file_writev (file, iov + 1, 1, 0); - ASSERT_CMPSSIZE_T (r, ==, iov[1].iov_len); - - ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 0, SEEK_SET), ==, 0); - ASSERT_CMPUINT64 (mongoc_gridfs_file_tell (file), ==, (uint64_t) 0); - - r = mongoc_gridfs_file_readv (file, &riov, 1, len, 0); - ASSERT_CMPSSIZE_T (r, ==, len); - ASSERT_CMPINT (memcmp (buf3, "fo bazr baz", len), ==, 0); - _check_chunk_count (gridfs, len, file->chunk_size); - - /* Test writing beyond the end of the file */ - BSON_ASSERT (mongoc_gridfs_file_seek (file, seek_len, SEEK_END) == 0); - BSON_ASSERT (mongoc_gridfs_file_tell (file) == file->length + seek_len); - - r = mongoc_gridfs_file_writev (file, iov, 2, 0); - BSON_ASSERT (r == len); - BSON_ASSERT (mongoc_gridfs_file_tell (file) == 2 * len + seek_len); - BSON_ASSERT (file->length == 2 * len + seek_len); - BSON_ASSERT (mongoc_gridfs_file_save (file)); - _check_chunk_count (gridfs, 2 * len + seek_len, file->chunk_size); - - BSON_ASSERT (mongoc_gridfs_file_seek (file, 0, SEEK_SET) == 0); - BSON_ASSERT (mongoc_gridfs_file_tell (file) == 0); - - r = mongoc_gridfs_file_readv (file, &riov, 1, 2 * len + seek_len, 0); - BSON_ASSERT (r == 2 * len + seek_len); - - /* expect file to be like "fo bazr baz\0\0\0\0\0\0foo bar baz" */ - bson_snprintf (expected, strlen ("fo bazr baz") + 1, "fo bazr baz"); - bson_snprintf (expected + strlen ("fo bazr baz") + seek_len, - strlen ("foo bar baz") + 1, - "foo bar baz"); - - BSON_ASSERT (memcmp (buf3, expected, (size_t) (2 * len + seek_len)) == 0); - BSON_ASSERT (mongoc_gridfs_file_save (file)); - - mongoc_gridfs_file_destroy (file); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - - mongoc_client_destroy (client); -} - - -static void -test_write (void) -{ - _test_write (false /* at_boundary */); -} - - -/* Test a write starting and ending exactly on chunk boundaries */ -static void -test_write_at_boundary (void) -{ - _test_write (true /* at_boundary */); -} - - -static void -test_write_past_end (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_client_t *client; - bson_error_t error; - ssize_t r; - char buf[] = "foo"; - char read_buf[2000]; - mongoc_gridfs_file_opt_t opt = {0}; - mongoc_iovec_t iov[1]; - mongoc_iovec_t riov; - const size_t len = sizeof (buf) - 1u; - const uint64_t delta = 35u; - const uint32_t chunk_sz = 10u; - /* division, rounding up */ - const uint64_t expected_chunks = - ((delta + len) + (chunk_sz - 1u)) / chunk_sz; - int64_t cnt; - - iov[0].iov_base = buf; - iov[0].iov_len = sizeof (buf) - 1; - - riov.iov_base = read_buf; - riov.iov_len = sizeof (read_buf); - - opt.chunk_size = chunk_sz; - opt.filename = "foo"; - - client = test_framework_new_default_client (); - ASSERT (client); - - gridfs = get_test_gridfs (client, "write_past_end", &error); - ASSERT_OR_PRINT (gridfs, error); - - file = mongoc_gridfs_create_file (gridfs, &opt); - ASSERT (file); - - r = mongoc_gridfs_file_writev (file, iov, 1, 0); - ASSERT (bson_in_range_signed (size_t, r)); - ASSERT_CMPSIZE_T ((size_t) r, ==, len); - - ASSERT_CMPINT ( - mongoc_gridfs_file_seek (file, (int64_t) delta, SEEK_SET), ==, 0); - ASSERT_CMPUINT64 (mongoc_gridfs_file_tell (file), ==, delta); - - r = mongoc_gridfs_file_writev (file, iov, 1, 0); - ASSERT (bson_in_range_signed (size_t, r)); - ASSERT_CMPSIZE_T ((size_t) r, ==, len); - mongoc_gridfs_file_save (file); - - cnt = mongoc_collection_count_documents (mongoc_gridfs_get_chunks (gridfs), - tmp_bson (NULL), - NULL, - NULL, - NULL, - &error); - - ASSERT_OR_PRINT (cnt != -1, error); - ASSERT (bson_cmp_equal_us (expected_chunks, cnt)); - - mongoc_gridfs_file_destroy (file); - file = mongoc_gridfs_find_one (gridfs, tmp_bson (NULL), &error); - ASSERT_OR_PRINT (file, error); - - BSON_ASSERT (bson_in_range_unsigned (size_t, delta + len)); - const size_t total_bytes = (size_t) (delta + len); - - r = mongoc_gridfs_file_readv (file, &riov, 1, total_bytes, 0); - ASSERT (bson_in_range_signed (size_t, r)); - ASSERT_CMPSIZE_T ((size_t) r, ==, total_bytes); - - mongoc_gridfs_file_destroy (file); - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - - -static void -test_empty (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_stream_t *stream; - mongoc_client_t *client; - bson_error_t error; - ssize_t r; - char buf[2] = {'h', 'i'}; - mongoc_iovec_t iov[1]; - ssize_t two = 2L; - - iov[0].iov_base = buf; - iov[0].iov_len = 2; - - client = test_framework_new_default_client (); - - ASSERT_OR_PRINT (gridfs = get_test_gridfs (client, "empty", &error), error); - - stream = - mongoc_stream_file_new_for_path (BINARY_DIR "/empty.dat", O_RDONLY, 0); - ASSERT_OR_PRINT_ERRNO (stream, errno); - - file = mongoc_gridfs_create_file_from_stream (gridfs, stream, NULL); - ASSERT (file); - - ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 0, SEEK_SET), ==, 0); - ASSERT_CMPUINT64 (mongoc_gridfs_file_tell (file), ==, (uint64_t) 0); - - ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 0, SEEK_CUR), ==, 0); - ASSERT_CMPUINT64 (mongoc_gridfs_file_tell (file), ==, (uint64_t) 0); - - ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 0, SEEK_END), ==, 0); - ASSERT_CMPUINT64 (mongoc_gridfs_file_tell (file), ==, (uint64_t) 0); - - r = mongoc_gridfs_file_writev (file, iov, 1, 0); - - ASSERT_CMPSSIZE_T (r, ==, two); - ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 0, SEEK_SET), ==, 0); - ASSERT_CMPUINT64 (mongoc_gridfs_file_tell (file), ==, (uint64_t) 0); - - r = mongoc_gridfs_file_readv (file, iov, 1, 2, 0); - - ASSERT_CMPSSIZE_T (r, ==, two); - ASSERT_CMPINT (strncmp (buf, "hi", 2), ==, 0); - - mongoc_gridfs_file_destroy (file); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - - mongoc_client_destroy (client); -} - - -static void -test_stream (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_client_t *client; - mongoc_stream_t *stream; - mongoc_stream_t *in_stream; - bson_error_t error; - char buf[4096]; - mongoc_iovec_t iov; - - iov.iov_base = buf; - iov.iov_len = sizeof buf; - - client = test_framework_new_default_client (); - ASSERT (client); - - ASSERT_OR_PRINT (gridfs = get_test_gridfs (client, "fs", &error), error); - - mongoc_gridfs_drop (gridfs, &error); - - in_stream = - mongoc_stream_file_new_for_path (BINARY_DIR "/gridfs.dat", O_RDONLY, 0); - ASSERT_OR_PRINT_ERRNO (in_stream, errno); - - file = mongoc_gridfs_create_file_from_stream (gridfs, in_stream, NULL); - ASSERT (file); - ASSERT (mongoc_gridfs_file_save (file)); - - stream = mongoc_stream_gridfs_new (file); - - ASSERT (bson_in_range_signed (size_t, file->length)); - const ssize_t r = - mongoc_stream_readv (stream, &iov, 1, (size_t) file->length, 0); - ASSERT_CMPINT64 ((int64_t) r, ==, file->length); - - /* cleanup */ - mongoc_stream_destroy (stream); - - mongoc_gridfs_file_destroy (file); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - - -#define ASSERT_TELL(file_, position_) \ - ASSERT_CMPUINT64 (mongoc_gridfs_file_tell (file_), ==, position_) - - -static void -test_long_seek (void *ctx) -{ - const uint64_t four_mb = 4 * 1024 * 1024; - - mongoc_client_t *client; - bson_error_t error; - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - ssize_t r; - mongoc_gridfs_file_opt_t opt = {0, "filename"}; - mongoc_iovec_t iov; - char buf[16 * 1024]; /* nothing special about 16k, just a buffer */ - const ssize_t buflen = sizeof (buf); - ssize_t written; - int64_t cursor_id; - int i; - - BSON_UNUSED (ctx); - - iov.iov_base = buf; - iov.iov_len = sizeof (buf); - memset (iov.iov_base, 0, iov.iov_len); - - client = test_framework_new_default_client (); - gridfs = get_test_gridfs (client, "long_seek", &error); - ASSERT_OR_PRINT (gridfs, error); - file = mongoc_gridfs_create_file (gridfs, &opt); - ASSERT (file); - - /* Write 20MB, enough to ensure we need many batches, below */ - written = 0; - while (written < 20 * 1024 * 1024) { - r = mongoc_gridfs_file_writev (file, &iov, 1, 0); - ASSERT_CMPSSIZE_T (r, ==, buflen); - written += r; - } - - /* new file handle */ - mongoc_gridfs_file_save (file); - mongoc_gridfs_file_destroy (file); - file = mongoc_gridfs_find_one ( - gridfs, tmp_bson ("{'filename': 'filename'}"), &error); - - ASSERT_OR_PRINT (file, error); - - /* read the start of the file */ - r = mongoc_gridfs_file_readv (file, &iov, 1, sizeof (buf), 0); - ASSERT_CMPSSIZE_T (r, ==, buflen); - ASSERT_TELL (file, (uint64_t) buflen); - cursor_id = mongoc_cursor_get_id (file->cursor); - ASSERT_CMPINT64 ((int64_t) 0, !=, cursor_id); - - /* seek forward into next batch and read, gridfs advances cursor */ - i = mongoc_gridfs_file_seek (file, four_mb, SEEK_CUR); - ASSERT_CMPINT (i, ==, 0); - r = mongoc_gridfs_file_readv (file, &iov, 1, sizeof (buf), 0); - ASSERT_CMPSSIZE_T (r, ==, buflen); - ASSERT_TELL (file, four_mb + 2 * buflen); - - /* same as the cursor we started with */ - ASSERT_CMPINT64 ((int64_t) 0, !=, mongoc_cursor_get_id (file->cursor)); - ASSERT_CMPINT64 (cursor_id, ==, mongoc_cursor_get_id (file->cursor)); - - /* seek more than a batch forward, gridfs discards cursor */ - i = mongoc_gridfs_file_seek (file, 3 * four_mb, SEEK_CUR); - ASSERT_CMPINT (i, ==, 0); - ASSERT_TELL (file, 4 * four_mb + 2 * buflen); - r = mongoc_gridfs_file_readv (file, &iov, 1, sizeof (buf), 0); - ASSERT_CMPSSIZE_T (r, ==, buflen); - ASSERT_TELL (file, 4 * four_mb + 3 * buflen); - - /* new cursor, not the one we started with */ - ASSERT_CMPINT64 (cursor_id, !=, mongoc_cursor_get_id (file->cursor)); - - mongoc_gridfs_file_destroy (file); - ASSERT_OR_PRINT (drop_collections (gridfs, &error), error); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - - -static void -test_remove_by_filename (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_gridfs_file_opt_t opt = {0}; - mongoc_client_t *client; - bson_error_t error; - - client = test_framework_new_default_client (); - ASSERT (client); - - ASSERT_OR_PRINT ( - gridfs = get_test_gridfs (client, "fs_remove_by_filename", &error), - error); - - mongoc_gridfs_drop (gridfs, &error); - - opt.filename = "foo_file_1.txt"; - file = mongoc_gridfs_create_file (gridfs, &opt); - ASSERT (file); - ASSERT (mongoc_gridfs_file_save (file)); - mongoc_gridfs_file_destroy (file); - - opt.filename = "foo_file_2.txt"; - file = mongoc_gridfs_create_file (gridfs, &opt); - ASSERT (file); - ASSERT (mongoc_gridfs_file_save (file)); - - ASSERT_OR_PRINT ( - mongoc_gridfs_remove_by_filename (gridfs, "foo_file_1.txt", &error), - error); - mongoc_gridfs_file_destroy (file); - - file = mongoc_gridfs_find_one_by_filename (gridfs, "foo_file_1.txt", &error); - ASSERT (!file); - - file = mongoc_gridfs_find_one_by_filename (gridfs, "foo_file_2.txt", &error); - ASSERT (file); - mongoc_gridfs_file_destroy (file); - - drop_collections (gridfs, &error); - mongoc_gridfs_destroy (gridfs); - - mongoc_client_destroy (client); -} - -static void -test_missing_chunk (void *ctx) -{ - mongoc_client_t *client; - bson_error_t error; - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - mongoc_collection_t *chunks; - ssize_t r; - mongoc_gridfs_file_opt_t opt = {0, "filename"}; - mongoc_iovec_t iov; - char buf[16 * 1024]; /* nothing special about 16k, just a buffer */ - const ssize_t buflen = sizeof (buf); - ssize_t written; - bool ret; - - BSON_UNUSED (ctx); - - iov.iov_base = buf; - iov.iov_len = sizeof (buf); - memset (iov.iov_base, 0, iov.iov_len); - - client = test_framework_new_default_client (); - gridfs = get_test_gridfs (client, "long_seek", &error); - ASSERT_OR_PRINT (gridfs, error); - mongoc_gridfs_drop (gridfs, NULL); - file = mongoc_gridfs_create_file (gridfs, &opt); - ASSERT (file); - - /* 700k, enough to need three 255k chunks */ - written = 0; - while (written < 700 * 1024) { - r = mongoc_gridfs_file_writev (file, &iov, 1, 0); - ASSERT_CMPSSIZE_T (r, ==, buflen); - written += r; - } - - /* new file handle */ - mongoc_gridfs_file_save (file); - mongoc_gridfs_file_destroy (file); - file = mongoc_gridfs_find_one_by_filename (gridfs, "filename", &error); - ASSERT_OR_PRINT (file, error); - - /* chunks have n=0, 1, 2; remove the middle one */ - chunks = mongoc_gridfs_get_chunks (gridfs); - ret = mongoc_collection_delete_many ( - chunks, tmp_bson ("{'n': 1}"), NULL, NULL, &error); - - ASSERT_OR_PRINT (ret, error); - - /* read the file */ - for (;;) { - r = mongoc_gridfs_file_readv (file, &iov, 1, sizeof (buf), 0); - if (r > 0) { - ASSERT_CMPSSIZE_T (r, ==, buflen); - } else { - ASSERT (mongoc_gridfs_file_error (file, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_CHUNK_MISSING, - "missing chunk number 1"); - - break; - } - } - - mongoc_gridfs_file_destroy (file); - ASSERT_OR_PRINT (drop_collections (gridfs, &error), error); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - - -static void -test_oversize (void) -{ - mongoc_client_t *client; - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - ssize_t r; - mongoc_iovec_t iov; - char buf[2]; - bson_error_t error; - bool ret; - - client = test_framework_new_default_client (); - - gridfs = get_test_gridfs (client, "test_oversize", &error); - ASSERT_OR_PRINT (gridfs, error); - - /* 2-byte chunk, 'aa', but chunkSize and file size are 1 byte */ - ret = mongoc_collection_insert_one ( - gridfs->chunks, - tmp_bson ("{'files_id': 1, 'n': 0," - " 'data': {'$binary': {'subType': '0', 'base64': 'YWE='}}}"), - NULL, - NULL, - &error); - - ASSERT_OR_PRINT (ret, error); - ret = mongoc_collection_insert_one ( - gridfs->files, - tmp_bson ("{'_id': 1, 'length': 1, 'chunkSize': 1," - " 'filename': 'filename'}"), - NULL, - NULL, - &error); - - ASSERT_OR_PRINT (ret, error); - file = mongoc_gridfs_find_one_by_filename (gridfs, "filename", &error); - ASSERT_OR_PRINT (file, error); - - /* read the file */ - iov.iov_base = (void *) &buf; - iov.iov_len = 1; - r = mongoc_gridfs_file_readv (file, &iov, 1, sizeof (buf), 0); - ASSERT_CMPSSIZE_T (r, ==, (ssize_t) -1); - BSON_ASSERT (mongoc_gridfs_file_error (file, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_CORRUPT, - "corrupt chunk number 0: greater than chunk size"); - - mongoc_gridfs_file_destroy (file); - ASSERT_OR_PRINT (mongoc_gridfs_drop (gridfs, &error), error); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - -static void -test_missing_file (void) -{ - mongoc_client_t *client; - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - bson_error_t error; - char buf[] = "contents contents"; - mongoc_iovec_t iov; - - iov.iov_base = buf; - iov.iov_len = sizeof buf; - - client = test_framework_new_default_client (); - gridfs = - mongoc_client_get_gridfs (client, "test_missing_file", NULL, &error); - ASSERT_OR_PRINT (gridfs, error); - - file = mongoc_gridfs_create_file (gridfs, NULL); - ASSERT_CMPSSIZE_T ( - mongoc_gridfs_file_writev (file, &iov, 1, 0), ==, (ssize_t) sizeof buf); - ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 0, SEEK_SET), ==, 0); - BSON_ASSERT (mongoc_gridfs_file_save (file)); - - /* remove the file */ - BSON_ASSERT (mongoc_gridfs_file_remove (file, &error)); - - /* readv fails */ - ASSERT_CMPSSIZE_T (mongoc_gridfs_file_readv (file, &iov, 1, sizeof buf, 0), - ==, - (ssize_t) -1); - BSON_ASSERT (mongoc_gridfs_file_error (file, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_CHUNK_MISSING, - "missing chunk number 0"); - - memset (&error, 0, sizeof error); - - /* writev fails */ - ASSERT_CMPSSIZE_T ( - mongoc_gridfs_file_writev (file, &iov, 1, 0), ==, (ssize_t) -1); - BSON_ASSERT (mongoc_gridfs_file_error (file, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_CHUNK_MISSING, - "missing chunk number 0"); - - mongoc_gridfs_file_destroy (file); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - - -/* check that user can specify _id of any type for file */ -static void -test_set_id (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_client_t *client; - bson_error_t error; - bson_value_t id; - bson_t *query; - char *dbname; - mongoc_gridfs_file_t *file; - mongoc_gridfs_file_t *result; - mongoc_gridfs_file_opt_t opt = {0}; - - /* create new client and grab gridfs handle */ - client = test_framework_new_default_client (); - ASSERT (client); - dbname = gen_collection_name ("test_set_id"); - gridfs = mongoc_client_get_gridfs (client, dbname, "fs", &error); - bson_free (dbname); - ASSERT_OR_PRINT (gridfs, error); - - /* create bson */ - id.value_type = BSON_TYPE_INT32; - id.value.v_int32 = 1; - - /* query for finding file */ - query = tmp_bson ("{'_id': 1}"); - - /* create new file */ - opt.filename = "test"; - file = mongoc_gridfs_create_file (gridfs, &opt); - ASSERT (file); - - /* if we find a file with new id, then file_set_id worked */ - ASSERT_OR_PRINT (mongoc_gridfs_file_set_id (file, &id, &error), error); - ASSERT (mongoc_gridfs_file_save (file)); - result = mongoc_gridfs_find_one (gridfs, query, &error); - ASSERT_OR_PRINT (result, error); - - mongoc_gridfs_file_destroy (result); - mongoc_gridfs_file_destroy (file); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - -/* check gridfs inherits read / write concern, read prefs from the client */ -static void -test_inherit_client_config (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_write_concern_t *write_concern; - mongoc_read_concern_t *read_concern; - mongoc_read_prefs_t *secondary_pref; - future_t *future; - bson_error_t error; - request_t *request; - mongoc_gridfs_t *gridfs; - mongoc_gridfs_file_t *file; - - /* mock mongos: easiest way to test that read preference is configured */ - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - - /* configure read / write concern and read prefs on client */ - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - - write_concern = mongoc_write_concern_new (); - mongoc_write_concern_set_w (write_concern, 2); - mongoc_client_set_write_concern (client, write_concern); - - read_concern = mongoc_read_concern_new (); - mongoc_read_concern_set_level (read_concern, - MONGOC_READ_CONCERN_LEVEL_MAJORITY); - mongoc_client_set_read_concern (client, read_concern); - - secondary_pref = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_client_set_read_prefs (client, secondary_pref); - - gridfs = _get_gridfs (server, client, MONGOC_QUERY_NONE); - - /* test read prefs and read concern */ - future = future_gridfs_find_one (gridfs, tmp_bson ("{}"), &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " 'find': 'fs.files'," - " 'readConcern': {'level': 'majority'}," - " '$readPreference': {'mode': 'secondary'}}")); - - reply_to_request_simple ( - request, - "{'ok': 1, 'cursor': {'ns': 'fs.files', 'firstBatch': [{'_id': 1}]}}"); - - file = future_get_mongoc_gridfs_file_ptr (future); - ASSERT (file); - - request_destroy (request); - future_destroy (future); - - /* test write concern */ - future = future_gridfs_file_remove (file, &error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ( - "{'$db': 'db', 'delete': 'fs.files', 'writeConcern': {'w': 2}}"), - tmp_bson ("{'q': {'_id': 1}, 'limit': 1}")); - - reply_to_request_with_ok_and_destroy (request); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ( - "{'$db': 'db', 'delete': 'fs.chunks', 'writeConcern': {'w': 2}}"), - tmp_bson ("{'q': {'files_id': 1}, 'limit': 0}")); - - reply_to_request_with_ok_and_destroy (request); - ASSERT (future_get_bool (future)); - future_destroy (future); - - mongoc_gridfs_file_destroy (file); - mongoc_gridfs_destroy (gridfs); - mongoc_write_concern_destroy (write_concern); - mongoc_read_concern_destroy (read_concern); - mongoc_read_prefs_destroy (secondary_pref); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -test_find_one_empty (void) -{ - mongoc_gridfs_t *gridfs; - mongoc_client_t *client; - bson_error_t error = {1, 2, "hello"}; - - client = test_framework_new_default_client (); - gridfs = get_test_gridfs (client, "list", &error); - ASSERT_OR_PRINT (gridfs, error); - ASSERT (!mongoc_gridfs_find_one ( - gridfs, tmp_bson ("{'x': 'doesntexist'}"), &error)); - - /* ensure "error" is cleared if we successfully find no file */ - ASSERT_CMPINT (error.domain, ==, 0); - ASSERT_CMPINT (error.code, ==, 0); - ASSERT_CMPSTR (error.message, ""); - - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); -} - - -static bool -responder (request_t *request, void *data) -{ - BSON_UNUSED (data); - - if (!strcasecmp (request->command_name, "createIndexes")) { - reply_to_request_with_ok_and_destroy (request); - return true; - } - - if (!strcasecmp (request->command_name, "listIndexes")) { - reply_to_request_simple (request, - "{ 'ok' : 0, 'errmsg' : 'ns does not exist: " - "db.fs.chunks', 'code' : 26, " - "'codeName' : 'NamespaceNotFound' }"); - request_destroy (request); - return true; - } - - return false; -} - - -static void -test_write_failure (void) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_gridfs_t *gridfs; - mongoc_stream_t *stream; - mongoc_gridfs_file_opt_t opt = {0}; - mongoc_gridfs_file_t *file; - bson_error_t error; - - server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_autoresponds (server, responder, NULL, NULL); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "socketTimeoutMS", 100); - client = test_framework_client_new_from_uri (uri, NULL); - gridfs = mongoc_client_get_gridfs (client, "db", "fs", &error); - ASSERT_OR_PRINT (gridfs, error); - stream = - mongoc_stream_file_new_for_path (BINARY_DIR "/gridfs.dat", O_RDONLY, 0); - - /* times out writing first chunk */ - opt.chunk_size = 1; - capture_logs (true); - file = mongoc_gridfs_create_file_from_stream (gridfs, stream, &opt); - BSON_ASSERT (!file); - ASSERT_CAPTURED_LOG ("mongoc_gridfs_create_file_from_stream", - MONGOC_LOG_LEVEL_ERROR, - "Failed to send \"update\" command"); - - mongoc_stream_destroy (stream); - mongoc_gridfs_destroy (gridfs); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - -static void -test_reading_multiple_chunks (void) -{ - mongoc_client_t *client = test_framework_new_default_client (); - bson_error_t error; - - // Test reading a file spanning two chunks. - { - mongoc_gridfs_t *gridfs = mongoc_client_get_gridfs ( - client, "test_reading_multiple_chunks", NULL, &error); - - ASSERT_OR_PRINT (gridfs, error); - // Drop prior test data. - ASSERT_OR_PRINT (mongoc_gridfs_drop (gridfs, &error), error); - - // Write a file spanning two chunks. - { - mongoc_gridfs_file_opt_t opts = {.chunk_size = 4, - .filename = "test_file"}; - mongoc_iovec_t iov = {.iov_base = (void *) "foobar", .iov_len = 7}; - mongoc_gridfs_file_t *file = mongoc_gridfs_create_file (gridfs, &opts); - // First chunk is 4 bytes: "foob", second chunk is 3 bytes: "ar\0" - ASSERT_CMPSSIZE_T ( - mongoc_gridfs_file_writev (file, &iov, 1, 0), ==, 7); - BSON_ASSERT (mongoc_gridfs_file_save (file)); - mongoc_gridfs_file_destroy (file); - } - - // Read the entire file. - { - bson_string_t *str = bson_string_new (""); - uint8_t buf[7] = {0}; - mongoc_iovec_t iov = {.iov_base = (void *) buf, - .iov_len = sizeof (buf)}; - mongoc_gridfs_file_t *file = - mongoc_gridfs_find_one_by_filename (gridfs, "test_file", &error); - ASSERT_OR_PRINT (file, error); - - // First read gets first chunk. - { - ssize_t got = mongoc_gridfs_file_readv (file, - &iov, - 1 /* iovcnt */, - 1 /* min_bytes */, - 0 /* timeout_msec */); - ASSERT_CMPSSIZE_T (got, >=, 0); - ASSERT (bson_in_range_int_signed (got)); - bson_string_append_printf (str, "%.*s", (int) got, (char *) buf); - ASSERT_CMPSSIZE_T (got, ==, 4); - } - - // Second read gets second chunk. - { - ssize_t got = mongoc_gridfs_file_readv (file, - &iov, - 1 /* iovcnt */, - 1 /* min_bytes */, - 0 /* timeout_msec */); - ASSERT_CMPSSIZE_T (got, >=, 0); - ASSERT (bson_in_range_int_signed (got)); - bson_string_append_printf (str, "%.*s", (int) got, (char *) buf); - ASSERT_CMPSSIZE_T (got, ==, 3); - } - - ASSERT_CMPSTR (str->str, "foobar"); - bson_string_free (str, true); - mongoc_gridfs_file_destroy (file); - } - - mongoc_gridfs_destroy (gridfs); - } - - // Test an error occurs if reading an incomplete chunk. This is a regression - // test for CDRIVER-5506. - { - mongoc_gridfs_t *gridfs = mongoc_client_get_gridfs ( - client, "test_reading_multiple_chunks", NULL, &error); - - ASSERT_OR_PRINT (gridfs, error); - // Drop prior test data. - ASSERT_OR_PRINT (mongoc_gridfs_drop (gridfs, &error), error); - - // Write a file spanning two chunks. - { - mongoc_gridfs_file_opt_t opts = {.chunk_size = 4, - .filename = "test_file"}; - mongoc_iovec_t iov = {.iov_base = (void *) "foobar", .iov_len = 7}; - mongoc_gridfs_file_t *file = mongoc_gridfs_create_file (gridfs, &opts); - // First chunk is 4 bytes: "foob", second chunk is 3 bytes: "ar\0" - ASSERT_CMPSSIZE_T ( - mongoc_gridfs_file_writev (file, &iov, 1, 0), ==, 7); - BSON_ASSERT (mongoc_gridfs_file_save (file)); - mongoc_gridfs_file_destroy (file); - } - - // Manually remove data from the first chunk. - { - mongoc_collection_t *coll = mongoc_client_get_collection ( - client, "test_reading_multiple_chunks", "fs.chunks"); - bson_t reply; - // Change the data of the first chunk from "foob" to "foo". - bool ok = mongoc_collection_update_one ( - coll, - tmp_bson (BSON_STR ({"n" : 0})), - tmp_bson (BSON_STR ({ - "$set" : - {"data" : {"$binary" : {"base64" : "Zm9v", "subType" : "0"}}} - })), - NULL /* opts */, - &reply, - &error); - ASSERT_OR_PRINT (ok, error); - ASSERT_MATCH (&reply, BSON_STR ({"modifiedCount" : 1})); - mongoc_collection_destroy (coll); - } - - // Attempt to read the entire file. - { - uint8_t buf[7] = {0}; - mongoc_iovec_t iov = {.iov_base = (void *) buf, - .iov_len = sizeof (buf)}; - mongoc_gridfs_file_t *file = - mongoc_gridfs_find_one_by_filename (gridfs, "test_file", &error); - ASSERT_OR_PRINT (file, error); - - // First read gets an error. - { - ssize_t got = mongoc_gridfs_file_readv (file, - &iov, - 1 /* iovcnt */, - 1 /* min_bytes */, - 0 /* timeout_msec */); - ASSERT_CMPSSIZE_T (got, ==, -1); - ASSERT (mongoc_gridfs_file_error (file, &error)); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_GRIDFS, - MONGOC_ERROR_GRIDFS_CORRUPT, - "corrupt chunk number 0: not equal to chunk size: 4"); - } - - mongoc_gridfs_file_destroy (file); - } - - mongoc_gridfs_destroy (gridfs); - } - - mongoc_client_destroy (client); -} - - -void -test_gridfs_install (TestSuite *suite) -{ - TestSuite_AddLive (suite, "/gridfs_old/create", test_create); - TestSuite_AddLive ( - suite, "/gridfs_old/create_from_stream", test_create_from_stream); - TestSuite_AddLive (suite, "/gridfs_old/list", test_list); - TestSuite_AddLive (suite, "/gridfs_old/find_one_empty", test_find_one_empty); - TestSuite_AddLive (suite, "/gridfs_old/find_with_opts", test_find_with_opts); - TestSuite_AddMockServerTest (suite, - "/gridfs_old/find_one_with_opts/limit", - test_find_one_with_opts_limit); - TestSuite_AddLive (suite, "/gridfs_old/properties", test_properties); - TestSuite_AddLive (suite, "/gridfs_old/empty", test_empty); - TestSuite_AddLive (suite, "/gridfs_old/read", test_read); - TestSuite_AddLive (suite, "/gridfs_old/seek", test_seek); - TestSuite_AddLive (suite, "/gridfs_old/stream", test_stream); - TestSuite_AddLive (suite, "/gridfs_old/remove", test_remove); - TestSuite_AddLive (suite, "/gridfs_old/write", test_write); - TestSuite_AddLive ( - suite, "/gridfs_old/write_at_boundary", test_write_at_boundary); - TestSuite_AddLive (suite, "/gridfs_old/write_past_end", test_write_past_end); - TestSuite_AddFull (suite, - "/gridfs_old/test_long_seek", - test_long_seek, - NULL, - NULL, - test_framework_skip_if_slow_or_live); - TestSuite_AddLive ( - suite, "/gridfs_old/remove_by_filename", test_remove_by_filename); - TestSuite_AddFull (suite, - "/gridfs_old/missing_chunk", - test_missing_chunk, - NULL, - NULL, - test_framework_skip_if_slow_or_live); - TestSuite_AddLive (suite, "/gridfs_old/oversize_chunk", test_oversize); - TestSuite_AddLive (suite, "/gridfs_old/missing_file", test_missing_file); - TestSuite_AddLive (suite, "/gridfs_old/file_set_id", test_set_id); - TestSuite_AddMockServerTest ( - suite, "/gridfs_old/inherit_client_config", test_inherit_client_config); - TestSuite_AddMockServerTest ( - suite, "/gridfs_old/write_failure", test_write_failure); - TestSuite_AddLive (suite, - "/gridfs_old/reading_multiple_chunks", - test_reading_multiple_chunks); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-hedged-reads.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-hedged-reads.c deleted file mode 100644 index 6625c0e25..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-hedged-reads.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2020 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "mongoc/mongoc-client-private.h" - -#include "TestSuite.h" -#include "mock_server/mock-server.h" -#include "mock_server/future-functions.h" -#include "test-libmongoc.h" -#include "test-conveniences.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "client-test-hedged-reads" - - -static void -test_mongos_hedged_reads_read_pref (void) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_t hedge_doc = BSON_INITIALIZER; - mongoc_read_prefs_t *prefs; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY_PREFERRED); - - /* For all read preference modes that are not 'primary', drivers MUST set - * readPreference. */ - mongoc_collection_set_read_prefs (collection, prefs); - - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, NULL, 0, 0, NULL, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " '$readPreference': {'mode': 'secondaryPreferred'}}")); - - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (1 == future_get_int64_t (future), error); - - request_destroy (request); - future_destroy (future); - - /* CDRIVER-3583: - * with readPreference mode secondaryPreferred and hedge set, readPreference - * MUST be sent. */ - bson_append_bool (&hedge_doc, "enabled", 7, true); - mongoc_read_prefs_set_hedge (prefs, &hedge_doc); - mongoc_collection_set_read_prefs (collection, prefs); - - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, NULL, 0, 0, NULL, &error); - request = - mock_server_receives_msg (server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " '$readPreference': {" - " 'mode': 'secondaryPreferred'," - " 'hedge': {'enabled': true}}}")); - - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (1 == future_get_int64_t (future), error); - - request_destroy (request); - future_destroy (future); - - mongoc_read_prefs_destroy (prefs); - bson_destroy (&hedge_doc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -void -test_client_hedged_reads_install (TestSuite *suite) -{ - TestSuite_AddMockServerTest ( - suite, "/Client/hedged_reads/mongos", test_mongos_hedged_reads_read_pref); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-linux-distro-scanner.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-linux-distro-scanner.c deleted file mode 100644 index b3c725a47..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-linux-distro-scanner.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright 2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-linux-distro-scanner-private.h" -#include "mongoc/mongoc-handshake-os-private.h" - -#include "TestSuite.h" -#include "test-libmongoc.h" -#include "test-conveniences.h" - -#ifdef MONGOC_OS_IS_LINUX -static void -test_read_generic_release_file (void) -{ - char *name; - char *version; - const char *paths[] = { - OS_RELEASE_FILE_DIR "/lol-im-not-here.txt", - OS_RELEASE_FILE_DIR "/also-not-here.txt", - OS_RELEASE_FILE_DIR "/example-etc-fedora-release.txt", - NULL, - }; - - const char *paths2[] = { - OS_RELEASE_FILE_DIR "/example-etc-xyz-release-no-delimiter.txt", NULL, - }; - - const char *paths3[] = { - OS_RELEASE_FILE_DIR "/empty-file.txt", NULL, - }; - - _mongoc_linux_distro_scanner_read_generic_release_file ( - paths, &name, &version); - ASSERT (name); - ASSERT (version); - ASSERT_CMPSTR ("Fedora", name); - ASSERT_CMPSTR ("8 (Werewolf)", version); - bson_free (name); - bson_free (version); - - _mongoc_linux_distro_scanner_read_generic_release_file ( - paths2, &name, &version); - ASSERT (name); - ASSERT_CMPSTR ("This one just has name, not that R word", name); - ASSERT (version == NULL); - bson_free (name); - - _mongoc_linux_distro_scanner_read_generic_release_file ( - paths3, &name, &version); - ASSERT (name == NULL); - ASSERT (version == NULL); - - _mongoc_linux_distro_scanner_split_line_by_release ( - " release ", -1, &name, &version); - ASSERT (name == NULL); - ASSERT (version == NULL); - - _mongoc_linux_distro_scanner_split_line_by_release ( - "ends with release ", -1, &name, &version); - ASSERT_CMPSTR ("ends with", name); - ASSERT (version == NULL); - bson_free (name); - - _mongoc_linux_distro_scanner_split_line_by_release ("", -1, &name, &version); - ASSERT_CMPSTR (name, ""); - ASSERT (version == NULL); - bson_free (name); -} - - -static void -test_read_key_value_file (void) -{ - char *name = NULL; - char *version = NULL; - - _mongoc_linux_distro_scanner_read_key_value_file (OS_RELEASE_FILE_DIR - "/example-lsb-file.txt", - "DISTRIB_ID", - -1, - &name, - "DISTRIB_RELEASE", - -1, - &version); - - ASSERT (name); - ASSERT_CMPSTR (name, "Ubuntu"); - ASSERT (version); - ASSERT_CMPSTR (version, "12.04"); - - bson_free (name); - bson_free (version); - - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-lsb-file-with-super-long-line.txt", - "DISTRIB_ID", - -1, - &name, - "DISTRIB_RELEASE", - -1, - &version); - ASSERT (!name); - ASSERT (version); - ASSERT_CMPSTR (version, "12.04"); - bson_free (version); - - - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-etc-os-release.txt", - "NAME", - -1, - &name, - "VERSION_ID", - -1, - &version); - - ASSERT_CMPSTR (name, "Fedora"); - ASSERT_CMPSTR (version, "17"); - - bson_free (name); - bson_free (version); - - /* Now try some weird inputs */ - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-etc-os-release.txt", - "ID=", - -1, - &name, - "VERSION_ID=", - -1, - &version); - - ASSERT (name == NULL); - ASSERT (version == NULL); - - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-etc-os-release.txt", - "", - -1, - &name, - "", - -1, - &version); - - ASSERT (name == NULL); - ASSERT (version == NULL); - - /* Test case where we get one but not the other */ - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-etc-os-release.txt", - "NAME", - -1, - &name, - "VERSION_", - -1, - &version); - - ASSERT_CMPSTR (name, "Fedora"); - ASSERT (version == NULL); - bson_free (name); - - /* Case where we say the key is the whole line */ - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-etc-os-release.txt", - "NAME", - -1, - &name, - "VERSION_ID=17", - -1, - &version); - ASSERT_CMPSTR (name, "Fedora"); - ASSERT (version == NULL); - bson_free (name); - - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-etc-os-release-ubuntu1604.txt", - "NAME", - -1, - &name, - "VERSION_ID", - -1, - &version); - ASSERT_CMPSTR ("Ubuntu", name); - ASSERT_CMPSTR ("16.04", version); - bson_free (name); - bson_free (version); - - - /* Case where the key is duplicated, make sure we keep first version */ - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-key-value-file.txt", - "key", - -1, - &name, - "normalkey", - -1, - &version); - ASSERT_CMPSTR (name, "first value"); - ASSERT_CMPSTR (version, "normalval"); - bson_free (name); - bson_free (version); - - /* Case where the key is duplicated, make sure we keep first version */ - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-key-value-file.txt", - "a-key-without-a-value", - -1, - &name, - "normalkey", - -1, - &version); - ASSERT_CMPSTR (name, ""); - ASSERT_CMPSTR (version, "normalval"); - bson_free (name); - bson_free (version); - - /* Try to get value from a line like: - * just-a-key - * (No equals, no value) */ - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-key-value-file.txt", - "just-a-key", - -1, - &name, - "normalkey", - -1, - &version); - ASSERT (name == NULL); - ASSERT_CMPSTR (version, "normalval"); - bson_free (name); - bson_free (version); - - /* Try to get a key which is on line 101 of the file - * (we stop reading at line 100) */ - _mongoc_linux_distro_scanner_read_key_value_file ( - OS_RELEASE_FILE_DIR "/example-key-value-file.txt", - "lastkey", - -1, - &name, - "normalkey", - -1, - &version); - ASSERT (name == NULL); - ASSERT_CMPSTR (version, "normalval"); - bson_free (version); -} - -/* We only expect this function to actually read anything on linux platforms */ -static void -test_distro_scanner_reads (void) -{ - char *name; - char *version; - - _mongoc_linux_distro_scanner_get_distro (&name, &version); - -#ifdef __linux__ - ASSERT (name); - ASSERT (strlen (name) > 0); - - /* Some linux distros don't have a version (like arch) but we should always - * return a version (at the very least, we'll return the kernel version) */ - ASSERT (version); - ASSERT (strlen (version)); -#endif - bson_free (name); - bson_free (version); -} -#endif - -void -test_linux_distro_scanner_install (TestSuite *suite) -{ -#ifdef MONGOC_OS_IS_LINUX - TestSuite_Add (suite, - "/LinuxDistroScanner/test_read_generic_release_file", - test_read_generic_release_file); - TestSuite_Add (suite, - "/LinuxDistroScanner/test_read_key_value_file", - test_read_key_value_file); - TestSuite_Add (suite, - "/LinuxDistroScanner/test_distro_scanner_reads", - test_distro_scanner_reads); -#endif -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-loadbalanced.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-loadbalanced.c deleted file mode 100644 index 8e2ef81d8..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-loadbalanced.c +++ /dev/null @@ -1,995 +0,0 @@ -/* - * Copyright 2021-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc/mongoc.h" -#include "mongoc/mongoc-client-session-private.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "TestSuite.h" - -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" -#include "mock_server/request.h" - -typedef struct { - int server_changed_events; - int server_opening_events; - int server_closed_events; - int topology_changed_events; - int topology_opening_events; - int topology_closed_events; -} stats_t; - -static void -server_changed (const mongoc_apm_server_changed_t *event) -{ - stats_t *context; - - context = (stats_t *) mongoc_apm_server_changed_get_context (event); - context->server_changed_events++; -} - - -static void -server_opening (const mongoc_apm_server_opening_t *event) -{ - stats_t *context; - - context = (stats_t *) mongoc_apm_server_opening_get_context (event); - context->server_opening_events++; -} - - -static void -server_closed (const mongoc_apm_server_closed_t *event) -{ - stats_t *context; - - context = (stats_t *) mongoc_apm_server_closed_get_context (event); - context->server_closed_events++; -} - - -static void -topology_changed (const mongoc_apm_topology_changed_t *event) -{ - stats_t *context; - - context = (stats_t *) mongoc_apm_topology_changed_get_context (event); - context->topology_changed_events++; -} - - -static void -topology_opening (const mongoc_apm_topology_opening_t *event) -{ - stats_t *context; - - context = (stats_t *) mongoc_apm_topology_opening_get_context (event); - context->topology_opening_events++; -} - - -static void -topology_closed (const mongoc_apm_topology_closed_t *event) -{ - stats_t *context; - - context = (stats_t *) mongoc_apm_topology_closed_get_context (event); - context->topology_closed_events++; -} - -static mongoc_apm_callbacks_t * -make_callbacks (void) -{ - mongoc_apm_callbacks_t *cbs; - - cbs = mongoc_apm_callbacks_new (); - mongoc_apm_set_server_changed_cb (cbs, server_changed); - mongoc_apm_set_server_opening_cb (cbs, server_opening); - mongoc_apm_set_server_closed_cb (cbs, server_closed); - mongoc_apm_set_topology_changed_cb (cbs, topology_changed); - mongoc_apm_set_topology_opening_cb (cbs, topology_opening); - mongoc_apm_set_topology_closed_cb (cbs, topology_closed); - return cbs; -} - -static stats_t * -set_client_callbacks (mongoc_client_t *client) -{ - mongoc_apm_callbacks_t *cbs; - stats_t *stats; - - ASSERT (client); - - stats = bson_malloc0 (sizeof (stats_t)); - cbs = make_callbacks (); - mongoc_client_set_apm_callbacks (client, cbs, stats); - mongoc_apm_callbacks_destroy (cbs); - return stats; -} - -static stats_t * -set_client_pool_callbacks (mongoc_client_pool_t *pool) -{ - mongoc_apm_callbacks_t *cbs; - stats_t *stats; - - ASSERT (pool); - - stats = bson_malloc0 (sizeof (stats_t)); - cbs = make_callbacks (); - mongoc_client_pool_set_apm_callbacks (pool, cbs, stats); - mongoc_apm_callbacks_destroy (cbs); - return stats; -} - -static void -free_and_assert_stats (stats_t *stats) -{ - ASSERT_CMPINT (stats->topology_opening_events, ==, 1); - ASSERT_CMPINT (stats->topology_changed_events, ==, 2); - ASSERT_CMPINT (stats->server_opening_events, ==, 1); - ASSERT_CMPINT (stats->server_changed_events, ==, 1); - ASSERT_CMPINT (stats->server_closed_events, ==, 1); - ASSERT_CMPINT (stats->topology_closed_events, ==, 1); - bson_free (stats); -} - -static void -test_loadbalanced_sessions_supported (void *unused) -{ - mongoc_client_t *client; - mongoc_client_session_t *session; - bson_error_t error; - - BSON_UNUSED (unused); - - client = test_framework_new_default_client (); - session = mongoc_client_start_session (client, NULL /* opts */, &error); - ASSERT_OR_PRINT (session, error); - - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); -} - -static void -test_loadbalanced_sessions_do_not_expire (void *unused) -{ - mongoc_client_t *client; - mongoc_client_session_t *session1; - mongoc_client_session_t *session2; - bson_error_t error; - bson_t *session1_lsid; - bson_t *session2_lsid; - mc_tpld_modification tdmod; - - BSON_UNUSED (unused); - - client = test_framework_new_default_client (); - /* Mock a timeout so session expiration applies. */ - tdmod = mc_tpld_modify_begin (client->topology); - tdmod.new_td->session_timeout_minutes = 1; - mc_tpld_modify_commit (tdmod); - - /* Start two sessions, to ensure that pooled sessions remain in the pool when - * the pool is accessed. */ - session1 = mongoc_client_start_session (client, NULL /* opts */, &error); - ASSERT_OR_PRINT (session1, error); - session2 = mongoc_client_start_session (client, NULL /* opts */, &error); - ASSERT_OR_PRINT (session2, error); - - session1_lsid = bson_copy (mongoc_client_session_get_lsid (session1)); - session2_lsid = bson_copy (mongoc_client_session_get_lsid (session2)); - - /* Expire both sessions. */ - session1->server_session->last_used_usec = 1; - session2->server_session->last_used_usec = 1; - mongoc_client_session_destroy (session1); - mongoc_client_session_destroy (session2); - - /* Get a new session, it should reuse the most recently pushed session2. */ - session2 = mongoc_client_start_session (client, NULL /* opts */, &error); - ASSERT_OR_PRINT (session2, error); - if (!bson_equal (mongoc_client_session_get_lsid (session2), session2_lsid)) { - test_error ("Session not reused: %s != %s", - tmp_json (mongoc_client_session_get_lsid (session2)), - tmp_json (session2_lsid)); - } - - session1 = mongoc_client_start_session (client, NULL /* opts */, &error); - ASSERT_OR_PRINT (session1, error); - if (!bson_equal (mongoc_client_session_get_lsid (session1), session1_lsid)) { - test_error ("Session not reused: %s != %s", - tmp_json (mongoc_client_session_get_lsid (session1)), - tmp_json (session1_lsid)); - } - - bson_destroy (session1_lsid); - bson_destroy (session2_lsid); - mongoc_client_session_destroy (session1); - mongoc_client_session_destroy (session2); - mongoc_client_destroy (client); -} - -/* Test that invalid loadBalanced URI configurations are validated during client - * construction. */ -static void -test_loadbalanced_client_uri_validation (void *unused) -{ - mongoc_client_t *client; - mongoc_uri_t *uri; - bson_error_t error; - - BSON_UNUSED (unused); - - uri = mongoc_uri_new ("mongodb://localhost:27017"); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_LOADBALANCED, true); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_DIRECTCONNECTION, true); - client = mongoc_client_new_from_uri_with_error (uri, &error); - - BSON_ASSERT (!client); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "URI with \"loadBalanced\" enabled must not contain " - "option \"directConnection\" enabled"); - - mongoc_uri_destroy (uri); -} - -/* Test basic connectivity to a load balanced cluster. */ -static void -test_loadbalanced_connect_single (void *unused) -{ - mongoc_client_t *client; - bson_error_t error; - bool ok; - mongoc_server_description_t *monitor_sd; - stats_t *stats; - - BSON_UNUSED (unused); - - client = test_framework_new_default_client (); - stats = set_client_callbacks (client); - ok = mongoc_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - - /* Ensure the server description is unchanged and remains as type - * LoadBalancer. */ - monitor_sd = mongoc_client_select_server ( - client, true /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (monitor_sd, error); - ASSERT_CMPSTR ("LoadBalancer", mongoc_server_description_type (monitor_sd)); - - mongoc_server_description_destroy (monitor_sd); - mongoc_client_destroy (client); - free_and_assert_stats (stats); -} - -static void -test_loadbalanced_connect_pooled (void *unused) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client; - bson_error_t error; - bool ok; - mongoc_server_description_t *monitor_sd; - stats_t *stats; - - BSON_UNUSED (unused); - - pool = test_framework_new_default_client_pool (); - stats = set_client_pool_callbacks (pool); - client = mongoc_client_pool_pop (pool); - - ok = mongoc_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - - /* Ensure the server description is unchanged and remains as type - * LoadBalancer. */ - monitor_sd = mongoc_client_select_server ( - client, true /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (monitor_sd, error); - ASSERT_CMPSTR ("LoadBalancer", mongoc_server_description_type (monitor_sd)); - - mongoc_server_description_destroy (monitor_sd); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - free_and_assert_stats (stats); -} - -/* Ensure that server selection on single threaded clients establishes a - * connection against load balanced clusters. */ -static void -test_loadbalanced_server_selection_establishes_connection_single (void *unused) -{ - mongoc_client_t *client; - bson_error_t error; - mongoc_server_description_t *monitor_sd; - mongoc_server_description_t *handshake_sd; - stats_t *stats; - - BSON_UNUSED (unused); - - client = test_framework_new_default_client (); - stats = set_client_callbacks (client); - monitor_sd = mongoc_client_select_server ( - client, true /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (monitor_sd, error); - ASSERT_CMPSTR ("LoadBalancer", mongoc_server_description_type (monitor_sd)); - - /* Ensure that a connection has been established by getting the handshake's - * server description. */ - handshake_sd = mongoc_client_get_handshake_description ( - client, monitor_sd->id, NULL /* opts */, &error); - ASSERT_OR_PRINT (handshake_sd, error); - ASSERT_CMPSTR ("Mongos", mongoc_server_description_type (handshake_sd)); - - mongoc_server_description_destroy (monitor_sd); - mongoc_server_description_destroy (handshake_sd); - mongoc_client_destroy (client); - free_and_assert_stats (stats); -} - -/* Test that the 5 second cooldown does not apply when establishing a new - * connection to the load balancer after a network error. */ -static void -test_loadbalanced_cooldown_is_bypassed_single (void *unused) -{ - mongoc_client_t *client; - bson_error_t error; - bool ok; - stats_t *stats; - mongoc_server_description_t *monitor_sd; - - BSON_UNUSED (unused); - - client = test_framework_new_default_client (); - stats = set_client_callbacks (client); - - ok = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'configureFailPoint': 'failCommand', 'mode': { 'times': 2 }, " - "'data': {'closeConnection': true, 'failCommands': ['ping', " - "'hello']}}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - - ok = mongoc_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - BSON_ASSERT (!ok); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "socket error"); - - /* The next attempted command should attempt to scan, and fail when - * performing the handshake with the hello command. */ - ok = mongoc_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - BSON_ASSERT (!ok); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NOT_ESTABLISHED, - "Could not establish stream"); - - /* Failing to "scan" would normally cause the node to be in cooldown and fail - * to reconnect (until the 5 second period has passed). But in load balancer - * mode cooldown is bypassed, so the subsequent connect attempt should - * succeed. */ - ok = mongoc_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ok, error); - - /* Ensure the server description is unchanged and remains as type - * LoadBalancer. */ - monitor_sd = mongoc_client_select_server ( - client, true /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (monitor_sd, error); - ASSERT_CMPSTR ("LoadBalancer", mongoc_server_description_type (monitor_sd)); - - mongoc_server_description_destroy (monitor_sd); - mongoc_client_destroy (client); - free_and_assert_stats (stats); -} - -/* Tests: - * - loadBalanced: true is added to the handshake - * - serviceId is set in the server description. - */ -#define LB_HELLO \ - tmp_str ("{'ismaster': true," \ - " 'minWireVersion': %d," \ - " 'maxWireVersion': %d," \ - " 'msg': 'isdbgrid'," \ - " 'serviceId': {'$oid': 'AAAAAAAAAAAAAAAAAAAAAAAA'}}", \ - WIRE_VERSION_MIN, \ - WIRE_VERSION_5_0) -static void -test_loadbalanced_handshake_sends_loadbalanced (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_uri_t *uri; - request_t *request; - future_t *future; - bson_error_t error; - mongoc_server_description_t *monitor_sd; - mongoc_server_description_t *handshake_sd; - bson_oid_t expected; - const bson_oid_t *actual; - - server = mock_server_new (); - mock_server_run (server); - mock_server_auto_endsessions (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_LOADBALANCED, true); - client = test_framework_client_new_from_uri (uri, NULL); - - future = future_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - request = mock_server_receives_any_hello_with_match ( - server, "{'loadBalanced': true}", "{'loadBalanced': true}"); - reply_to_request_simple (request, LB_HELLO); - request_destroy (request); - - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - monitor_sd = mongoc_client_select_server ( - client, true /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (monitor_sd, error); - handshake_sd = mongoc_client_get_handshake_description ( - client, 1, NULL /* opts */, &error); - ASSERT_OR_PRINT (handshake_sd, error); - - bson_oid_init_from_string (&expected, "AAAAAAAAAAAAAAAAAAAAAAAA"); - actual = &handshake_sd->service_id; - BSON_ASSERT (actual); - ASSERT_CMPOID (actual, &expected); - - mongoc_server_description_destroy (handshake_sd); - mongoc_server_description_destroy (monitor_sd); - mongoc_uri_destroy (uri); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -/* Tests that a connection is rejected if the handshake reply does not include a - * serviceID field. */ -#define NON_LB_HELLO \ - tmp_str ("{'ismaster': true," \ - " 'minWireVersion': %d," \ - " 'maxWireVersion': %d," \ - " 'msg': 'isdbgrid'}", \ - WIRE_VERSION_MIN, \ - WIRE_VERSION_5_0) -static void -test_loadbalanced_handshake_rejects_non_loadbalanced (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_uri_t *uri; - request_t *request; - future_t *future; - bson_error_t error; - - server = mock_server_new (); - mock_server_run (server); - mock_server_auto_endsessions (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_LOADBALANCED, true); - client = test_framework_client_new_from_uri (uri, NULL); - - future = future_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - request = mock_server_receives_any_hello_with_match ( - server, "{'loadBalanced': true}", "{'loadBalanced': true}"); - reply_to_request_simple (request, NON_LB_HELLO); - request_destroy (request); - BSON_ASSERT (!future_get_bool (future)); - future_destroy (future); - - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_INVALID_LOAD_BALANCER, - "Driver attempted to initialize in load balancing " - "mode, but the server does not support this mode"); - - mongoc_uri_destroy (uri); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -/* Test that an error before the MongoDB handshake completes does NOT go through - * SDAM error handling flow. */ -static void -test_pre_handshake_error_does_not_clear_pool (void) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool; - mongoc_client_t *client_1; - mongoc_client_t *client_2; - future_t *future; - request_t *request; - bson_error_t error; - const bson_t *match_loadBalanced = tmp_bson ("{'loadBalanced': true}"); - - server = mock_server_new (); - mock_server_auto_endsessions (server); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_LOADBALANCED, true); - pool = mongoc_client_pool_new (uri); - client_1 = mongoc_client_pool_pop (pool); - client_2 = mongoc_client_pool_pop (pool); - - /* client_1 opens a new connection to send "ping" */ - future = future_client_command_simple (client_1, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* A new connection is opened. */ - request = mock_server_receives_hello_op_msg (server); - ASSERT ( - request_matches_msg (request, MONGOC_MSG_NONE, &match_loadBalanced, 1)); - - BSON_ASSERT (request); - reply_to_request_simple (request, LB_HELLO); - request_destroy (request); - /* The "ping" command is sent. */ - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - BSON_ASSERT (request); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* client_2 attempts to open a new connection, but receives an error on the - * handshake. */ - future = future_client_command_simple (client_2, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* A new connection is opened. */ - request = mock_server_receives_hello_op_msg (server); - ASSERT ( - request_matches_msg (request, MONGOC_MSG_NONE, &match_loadBalanced, 1)); - BSON_ASSERT (request); - capture_logs (true); /* hide Failed to buffer logs. */ - reply_to_request_with_hang_up (request); - request_destroy (request); - BSON_ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "Failed to send"); - future_destroy (future); - - /* client_1 sends another "ping". */ - future = future_client_command_simple (client_1, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - - /* The connection pool must not have been cleared. It can reuse the previous - * connection. The next command is the "ping". */ - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - BSON_ASSERT (request); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - mongoc_client_pool_push (pool, client_2); - mongoc_client_pool_push (pool, client_1); - mongoc_client_pool_destroy (pool); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - -#define LB_HELLO_A \ - tmp_str ("{'ismaster': true," \ - " 'minWireVersion': %d," \ - " 'maxWireVersion': %d," \ - " 'msg': 'isdbgrid'," \ - " 'serviceId': {'$oid': 'AAAAAAAAAAAAAAAAAAAAAAAA'}}", \ - WIRE_VERSION_MIN, \ - WIRE_VERSION_5_0) - -#define LB_HELLO_B \ - tmp_str ("{'ismaster': true," \ - " 'minWireVersion': %d," \ - " 'maxWireVersion': %d," \ - " 'msg': 'isdbgrid'," \ - " 'serviceId': {'$oid': 'BBBBBBBBBBBBBBBBBBBBBBBB'}}", \ - WIRE_VERSION_MIN, \ - WIRE_VERSION_5_0) - -/* Test that a post handshake error clears the pool ONLY for connections with - * the same serviceID. Test that a post handshake error does not mark the server - * unknown. */ -static void -test_post_handshake_error_clears_pool (void) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool; - mongoc_client_t *client_1_serviceid_a; - mongoc_client_t *client_2_serviceid_a; - mongoc_client_t *client_3_serviceid_b; - future_t *future; - request_t *request; - bson_error_t error; - mongoc_server_description_t *monitor_sd; - const bson_t *match_loadBalanced = tmp_bson ("{'loadBalanced': true}"); - - server = mock_server_new (); - mock_server_auto_endsessions (server); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_LOADBALANCED, true); - pool = mongoc_client_pool_new (uri); - client_1_serviceid_a = mongoc_client_pool_pop (pool); - client_2_serviceid_a = mongoc_client_pool_pop (pool); - client_3_serviceid_b = mongoc_client_pool_pop (pool); - - /* client_1_serviceid_a opens a new connection to send "ping" */ - future = future_client_command_simple (client_1_serviceid_a, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* A new connection is opened. */ - request = mock_server_receives_hello_op_msg (server); - ASSERT ( - request_matches_msg (request, MONGOC_MSG_NONE, &match_loadBalanced, 1)); - BSON_ASSERT (request); - reply_to_request_simple (request, LB_HELLO_A); - request_destroy (request); - /* The "ping" command is sent. */ - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - BSON_ASSERT (request); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* client_2_serviceid_a also opens a new connection and receives the same - * service ID. */ - future = future_client_command_simple (client_2_serviceid_a, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* A new connection is opened. */ - request = mock_server_receives_hello_op_msg (server); - ASSERT ( - request_matches_msg (request, MONGOC_MSG_NONE, &match_loadBalanced, 1)); - BSON_ASSERT (request); - reply_to_request_simple (request, LB_HELLO_A); - request_destroy (request); - /* The "ping" command is sent. */ - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - BSON_ASSERT (request); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* client_3_serviceid_b also opens a new connection, but receives a different - * service ID. */ - future = future_client_command_simple (client_3_serviceid_b, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* A new connection is opened. */ - request = mock_server_receives_hello_op_msg (server); - ASSERT ( - request_matches_msg (request, MONGOC_MSG_NONE, &match_loadBalanced, 1)); - BSON_ASSERT (request); - reply_to_request_simple (request, LB_HELLO_B); - request_destroy (request); - /* The "ping" command is sent. */ - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - BSON_ASSERT (request); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* client_1_serviceid_a receives a network error. */ - future = future_client_command_simple (client_1_serviceid_a, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* The "ping" command is sent. */ - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - BSON_ASSERT (request); - capture_logs (true); /* hide Failed to buffer logs. */ - reply_to_request_with_hang_up (request); - request_destroy (request); - BSON_ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "Failed to send"); - future_destroy (future); - - /* Assert that the server is NOT marked Unknown. */ - monitor_sd = mongoc_client_select_server ( - client_1_serviceid_a, true, NULL /* read prefs */, &error); - ASSERT_CMPSTR ("LoadBalancer", mongoc_server_description_type (monitor_sd)); - - /* This should have invalidated the connection for client_2_serviceid_a. */ - future = future_client_command_simple (client_2_serviceid_a, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* A new connection is opened. */ - request = mock_server_receives_hello_op_msg (server); - ASSERT ( - request_matches_msg (request, MONGOC_MSG_NONE, &match_loadBalanced, 1)); - BSON_ASSERT (request); - reply_to_request_simple (request, LB_HELLO_A); - request_destroy (request); - /* The "ping" command is sent. */ - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - BSON_ASSERT (request); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* But the connection for client_3_serviceid_b should still be OK. */ - future = future_client_command_simple (client_3_serviceid_b, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* The "ping" command is sent. */ - request = mock_server_receives_msg (server, 0, tmp_bson ("{'ping': 1}")); - BSON_ASSERT (request); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - mongoc_server_description_destroy (monitor_sd); - mongoc_client_pool_push (pool, client_3_serviceid_b); - mongoc_client_pool_push (pool, client_2_serviceid_a); - mongoc_client_pool_push (pool, client_1_serviceid_a); - mongoc_client_pool_destroy (pool); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - -static int -skip_if_not_loadbalanced (void) -{ - return test_framework_is_loadbalanced () ? 1 : 0; -} - -static void -store_last_command_started_callback (const mongoc_apm_command_started_t *event) -{ - bson_t **last_command = mongoc_apm_command_started_get_context (event); - const bson_t *cmd = mongoc_apm_command_started_get_command (event); - bson_destroy (*last_command); - *last_command = bson_copy (cmd); -} - -// `test_loadbalanced_sends_recoveryToken` is a regression test for -// CDRIVER-4718. Ensure that a `recoveryToken` is included in the outgoing -// `commitTransaction` and `abortTransaction` commands when connected to a load -// balanced cluster. -static void -test_loadbalanced_sends_recoveryToken (void *unused) -{ - mongoc_client_t *client; - bson_error_t error; - bson_t *last_command = NULL; - - BSON_UNUSED (unused); - - client = test_framework_new_default_client (); - // Set a callback to store the most recent command started. - { - mongoc_apm_callbacks_t *cbs = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (cbs, - store_last_command_started_callback); - mongoc_client_set_apm_callbacks (client, cbs, &last_command); - mongoc_apm_callbacks_destroy (cbs); - } - - mongoc_client_session_t *session = - mongoc_client_start_session (client, NULL /* opts */, &error); - ASSERT_OR_PRINT (session, error); - - mongoc_collection_t *coll = - mongoc_client_get_collection (client, "db", "coll"); - - // Commit a transaction. Expect `commitTransaction` to include - // `recoveryToken`. - { - bool ok = mongoc_client_session_start_transaction ( - session, NULL /* opts */, &error); - ASSERT_OR_PRINT (ok, error); - - bson_t *insert_opts = tmp_bson ("{}"); - ok = mongoc_client_session_append (session, insert_opts, &error); - ASSERT_OR_PRINT (ok, error); - - ok = mongoc_collection_insert_one ( - coll, tmp_bson ("{}"), insert_opts, NULL, &error); - ASSERT_OR_PRINT (ok, error); - - ok = mongoc_client_session_commit_transaction ( - session, NULL /* reply */, &error); - ASSERT_OR_PRINT (ok, error); - - ASSERT_MATCH ( - last_command, - "{'commitTransaction': 1, 'recoveryToken': { '$exists': true } }"); - } - - // Abort a transaction. Expect `abortTransaction` to include - // `recoveryToken`. - { - bool ok = mongoc_client_session_start_transaction ( - session, NULL /* opts */, &error); - ASSERT_OR_PRINT (ok, error); - - bson_t *insert_opts = tmp_bson ("{}"); - ok = mongoc_client_session_append (session, insert_opts, &error); - ASSERT_OR_PRINT (ok, error); - - ok = mongoc_collection_insert_one ( - coll, tmp_bson ("{}"), insert_opts, NULL, &error); - ASSERT_OR_PRINT (ok, error); - - ok = mongoc_client_session_abort_transaction (session, &error); - ASSERT_OR_PRINT (ok, error); - - ASSERT_MATCH ( - last_command, - "{'abortTransaction': 1, 'recoveryToken': { '$exists': true } }"); - } - - mongoc_collection_destroy (coll); - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); - bson_destroy (last_command); -} - -void -test_loadbalanced_install (TestSuite *suite) -{ - TestSuite_AddFull (suite, - "/loadbalanced/sessions/supported", - test_loadbalanced_sessions_supported, - NULL /* ctx */, - NULL /* dtor */, - skip_if_not_loadbalanced); - TestSuite_AddFull (suite, - "/loadbalanced/sessions/do_not_expire", - test_loadbalanced_sessions_do_not_expire, - NULL /* ctx */, - NULL /* dtor */, - skip_if_not_loadbalanced); - TestSuite_AddFull (suite, - "/loadbalanced/client_uri_validation", - test_loadbalanced_client_uri_validation, - NULL /* ctx */, - NULL /* dtor */, - NULL); - - TestSuite_AddFull (suite, - "/loadbalanced/connect/single", - test_loadbalanced_connect_single, - NULL /* ctx */, - NULL /* dtor */, - skip_if_not_loadbalanced); - - TestSuite_AddFull (suite, - "/loadbalanced/connect/pooled", - test_loadbalanced_connect_pooled, - NULL /* ctx */, - NULL /* dtor */, - skip_if_not_loadbalanced); - - TestSuite_AddFull ( - suite, - "/loadbalanced/server_selection_establishes_connection/single", - test_loadbalanced_server_selection_establishes_connection_single, - NULL /* ctx */, - NULL /* dtor */, - skip_if_not_loadbalanced); - - TestSuite_AddFull (suite, - "/loadbalanced/cooldown_is_bypassed/single", - test_loadbalanced_cooldown_is_bypassed_single, - NULL /* dtor */, - NULL /* ctx */, - skip_if_not_loadbalanced, - test_framework_skip_if_no_failpoint); - - TestSuite_AddMockServerTest (suite, - "/loadbalanced/handshake_sends_loadbalanced", - test_loadbalanced_handshake_sends_loadbalanced); - - TestSuite_AddMockServerTest ( - suite, - "/loadbalanced/handshake_rejects_non_loadbalanced", - test_loadbalanced_handshake_rejects_non_loadbalanced); - - TestSuite_AddMockServerTest ( - suite, - "/loadbalanced/pre_handshake_error_does_not_clear_pool", - test_pre_handshake_error_does_not_clear_pool); - - TestSuite_AddMockServerTest ( - suite, - "/loadbalanced/post_handshake_error_clears_pool", - test_post_handshake_error_clears_pool); - - TestSuite_AddFull (suite, - "/loadbalanced/sends_recoveryToken", - test_loadbalanced_sends_recoveryToken, - NULL /* ctx */, - NULL /* dtor */, - skip_if_not_loadbalanced); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-long-namespace.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-long-namespace.c deleted file mode 100644 index 8f9b849cb..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-long-namespace.c +++ /dev/null @@ -1,649 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "mongoc/mongoc.h" -#include "mongoc/mongoc-change-stream-private.h" -#include "mongoc/mongoc-collection-private.h" -#include "mongoc/mongoc-cursor-private.h" -#include "mongoc/mongoc-database-private.h" -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - -typedef struct { - char *ns; - char *ns_coll; - char *ns_db; - mongoc_client_t *client; - mongoc_client_session_t *client_session; - bson_t opts_w_session; - mongoc_database_t *db; - mongoc_collection_t *coll; -} test_fixture_t; - -/* Ensure that the command started callback reports the correct database name. - */ -static void -command_started (const mongoc_apm_command_started_t *event) -{ - test_fixture_t *test_fixture; - - test_fixture = mongoc_apm_command_started_get_context (event); - if (0 == strcmp (mongoc_apm_command_started_get_command_name (event), - "renameCollection")) { - ASSERT_CMPSTR (mongoc_apm_command_started_get_database_name (event), - "admin"); - /* Always runs on admin. */ - } else { - ASSERT_CMPSTR (mongoc_apm_command_started_get_database_name (event), - test_fixture->ns_db); - } -} - -/* Test long namespaces. Prior to SERVER-32959, the total namespace limit was - * 120 characters. */ -static void -test_fixture_init (test_fixture_t *test_fixture, - uint32_t db_len, - uint32_t coll_len) -{ - bool ret; - bson_error_t error; - mongoc_apm_callbacks_t *callbacks; - - test_fixture->ns_db = bson_malloc (db_len + 1); - memset (test_fixture->ns_db, 'd', db_len); - test_fixture->ns_db[db_len] = '\0'; - - test_fixture->ns_coll = bson_malloc (coll_len + 1); - memset (test_fixture->ns_coll, 'c', coll_len); - test_fixture->ns_coll[coll_len] = '\0'; - - test_fixture->ns = - bson_strdup_printf ("%s.%s", test_fixture->ns_db, test_fixture->ns_coll); - - /* Construct client, database, and collection objects. */ - test_fixture->client = test_framework_new_default_client (); - test_framework_set_ssl_opts (test_fixture->client); - mongoc_client_set_error_api (test_fixture->client, - MONGOC_ERROR_API_VERSION_2); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, command_started); - mongoc_client_set_apm_callbacks ( - test_fixture->client, callbacks, test_fixture); - - test_fixture->db = - mongoc_client_get_database (test_fixture->client, test_fixture->ns_db); - ASSERT_CMPSTR (test_fixture->db->name, test_fixture->ns_db); - - test_fixture->coll = - mongoc_database_get_collection (test_fixture->db, test_fixture->ns_coll); - ASSERT_CMPSTR (test_fixture->coll->collection, test_fixture->ns_coll); - ASSERT_CMPSIZE_T ( - test_fixture->coll->collectionlen, ==, strlen (test_fixture->ns_coll)); - ASSERT_CMPSTR (test_fixture->coll->db, test_fixture->ns_db); - ASSERT_CMPSTR (test_fixture->coll->ns, test_fixture->ns); - ASSERT_CMPSIZE_T (test_fixture->coll->nslen, ==, strlen (test_fixture->ns)); - - /* Drop 'coll'. */ - ret = mongoc_collection_drop (test_fixture->coll, &error); - /* ignore a 'ns not found' error */ - if (!ret && NULL == strstr (error.message, "ns not found")) { - /* unexpected error. */ - test_error ("unexpected error: %s\n", error.message); - } - - /* Explicitly create 'coll', so it shows up in listCollections. */ - mongoc_collection_destroy (test_fixture->coll); - test_fixture->coll = mongoc_database_create_collection ( - test_fixture->db, test_fixture->ns_coll, NULL /* opts */, &error); - ASSERT_OR_PRINT (test_fixture->coll, error); - ASSERT_CMPSTR (test_fixture->coll->collection, test_fixture->ns_coll); - ASSERT_CMPSIZE_T ( - test_fixture->coll->collectionlen, ==, strlen (test_fixture->ns_coll)); - ASSERT_CMPSTR (test_fixture->coll->db, test_fixture->ns_db); - ASSERT_CMPSTR (test_fixture->coll->ns, test_fixture->ns); - ASSERT_CMPSIZE_T (test_fixture->coll->nslen, ==, strlen (test_fixture->ns)); - - mongoc_apm_callbacks_destroy (callbacks); -} - -static void -test_fixture_cleanup (test_fixture_t *test_fixture) -{ - /* Clear the APM callbacks, since endSessions runs on the admin database. */ - mongoc_client_set_apm_callbacks (test_fixture->client, NULL, NULL); - mongoc_collection_destroy (test_fixture->coll); - mongoc_database_destroy (test_fixture->db); - mongoc_client_destroy (test_fixture->client); - bson_free (test_fixture->ns_coll); - bson_free (test_fixture->ns_db); - bson_free (test_fixture->ns); -} - -/* Test crud operations. This should test legacy OP_QUERY cursors and legacy - * write ops, which were storing fixed size namespaces using - * MONGOC_NAMESPACE_MAX. */ -static void -crud (test_fixture_t *test_fixture) -{ - bson_error_t error; - bool ret; - mongoc_cursor_t *cursor; - const bson_t *found; - - /* Insert. */ - ret = mongoc_collection_insert_one (test_fixture->coll, - tmp_bson ("{'_id': 'hello'}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - /* Find that document back. */ - cursor = mongoc_collection_find_with_opts (test_fixture->coll, - tmp_bson ("{'_id': 'hello'}"), - NULL /* opts */, - NULL /* read prefs */); - ret = mongoc_cursor_next (cursor, &found); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error) && ret, error); - ASSERT_MATCH (found, "{'_id': 'hello'}"); - ASSERT_CMPSTR (cursor->ns, test_fixture->ns); - ASSERT_CURSOR_DONE (cursor); - mongoc_cursor_destroy (cursor); - - /* Update it. */ - ret = mongoc_collection_update_one (test_fixture->coll, - tmp_bson ("{'_id': 'hello'}"), - tmp_bson ("{'$set': {'x':1}}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - /* Find that document back to ensure the document in the right collection was - * updated. */ - cursor = mongoc_collection_find_with_opts (test_fixture->coll, - tmp_bson ("{'_id': 'hello'}"), - NULL /* opts */, - NULL /* read prefs */); - ret = mongoc_cursor_next (cursor, &found); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error) && ret, error); - ASSERT_MATCH (found, "{'_id': 'hello', 'x': 1}"); - ASSERT_CMPSTR (cursor->ns, test_fixture->ns); - ASSERT_CURSOR_DONE (cursor); - mongoc_cursor_destroy (cursor); - - /* Delete it. */ - ret = mongoc_collection_delete_one (test_fixture->coll, - tmp_bson ("{'_id': 'hello'}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - /* Attempt to find that document back to ensure the document in the right - * collection was deleted. */ - cursor = mongoc_collection_find_with_opts (test_fixture->coll, - tmp_bson ("{'_id': 'hello'}"), - NULL /* opts */, - NULL /* read prefs */); - ASSERT_CURSOR_DONE (cursor); - ASSERT_CMPSTR (cursor->ns, test_fixture->ns); - mongoc_cursor_destroy (cursor); -} - -/* Test cursor getmore, which constructed a namespace with MONGOC_NAMESPACE_MAX. - */ -static void -getmore (test_fixture_t *test_fixture) -{ - bson_error_t error; - bool ret; - mongoc_cursor_t *cursor; - const bson_t *found; - - /* Insert two documents. */ - ret = mongoc_collection_insert_one (test_fixture->coll, - tmp_bson ("{'_id': 'hello'}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - ret = mongoc_collection_insert_one (test_fixture->coll, - tmp_bson ("{'_id': 'world'}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - /* Find each document back in two separate batches. */ - cursor = mongoc_collection_find_with_opts (test_fixture->coll, - tmp_bson ("{}"), - tmp_bson ("{'batchSize': 1}"), - NULL /* read prefs */); - ret = mongoc_cursor_next (cursor, &found); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error) && ret, error); - ASSERT_MATCH (found, "{'_id': 'hello'}"); - ASSERT_CMPSTR (cursor->ns, test_fixture->ns); - /* not DONE, next call will send a getMore */ - BSON_ASSERT (cursor->state != DONE); - ret = mongoc_cursor_next (cursor, &found); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error) && ret, error); - ASSERT_MATCH (found, "{'_id': 'world'}"); - ASSERT_CMPSTR (cursor->ns, test_fixture->ns); - ASSERT_CURSOR_DONE (cursor); - mongoc_cursor_destroy (cursor); -} - -/* Test change streams, which store a namespace in mongoc_change_stream_t */ -static void -change_stream (test_fixture_t *test_fixture) -{ - mongoc_change_stream_t *change_stream; - const bson_t *found; - bool ret; - bson_error_t error; - mongoc_client_session_t *client_session; - bson_t opts_w_session; - - client_session = mongoc_client_start_session ( - test_fixture->client, NULL /* opts */, &error); - ASSERT_OR_PRINT (client_session, error); - bson_init (&opts_w_session); - ret = mongoc_client_session_append (client_session, &opts_w_session, &error); - ASSERT_OR_PRINT (ret, error); - - /* Create a change stream. Do all operations within a session, to guarantee - * change stream sees the subsequent insert operation. */ - change_stream = mongoc_collection_watch ( - test_fixture->coll, tmp_bson ("{}"), &opts_w_session); - ASSERT_CMPSTR (change_stream->db, test_fixture->ns_db); - ASSERT_CMPSTR (change_stream->coll, test_fixture->ns_coll); - - /* Insert. */ - ret = mongoc_collection_insert_one (test_fixture->coll, - tmp_bson ("{'_id': 'hello'}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - /* Get a change stream event. */ - ret = mongoc_change_stream_next (change_stream, &found); - ASSERT_OR_PRINT ( - !mongoc_change_stream_error_document (change_stream, &error, NULL) && ret, - error); - ASSERT_MATCH ( - found, - "{'operationType': 'insert', 'ns': { 'db': '%s', 'coll': '%s' }}", - test_fixture->ns_db, - test_fixture->ns_coll); - - mongoc_change_stream_destroy (change_stream); - mongoc_client_session_destroy (client_session); - bson_destroy (&opts_w_session); -} - - -/* Test mongoc_client_command, which constructed a namespace with - * MONGOC_NAMESPACE_MAX */ -static void -client_command (test_fixture_t *test_fixture) -{ - const bson_t *found; - mongoc_cursor_t *cursor; - bool ret; - bson_error_t error; - - cursor = mongoc_client_command ( - test_fixture->client, - test_fixture->ns_db, - MONGOC_QUERY_NONE, - 0 /* skip */, - 0 /* limit */, - 0 /* batch size */, - tmp_bson ("{'listCollections': 1, 'filter': {'name': '%s'}}", - test_fixture->ns_coll), - NULL /* fields */, - NULL /* read prefs */); - ret = mongoc_cursor_next (cursor, &found); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error) && ret, error); - ASSERT_MATCH (found, - "{'cursor': {'firstBatch': [{'name': '%s'}]}}", - test_fixture->ns_coll); - mongoc_cursor_destroy (cursor); -} - -/* Test mongoc_database_command, which constructed a namespace with - * MONGOC_NAMESPACE_MAX. */ -static void -database_command (test_fixture_t *test_fixture) -{ - const bson_t *found; - mongoc_cursor_t *cursor; - bool ret; - bson_error_t error; - - cursor = mongoc_database_command ( - test_fixture->db, - MONGOC_QUERY_NONE, - 0 /* skip */, - 0 /* limit */, - 0 /* batch size */, - tmp_bson ("{'listCollections': 1, 'filter': {'name': '%s'}}", - test_fixture->ns_coll), - NULL /* fields */, - NULL /* read prefs */); - ret = mongoc_cursor_next (cursor, &found); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error) && ret, error); - ASSERT_MATCH (found, - "{'cursor': {'firstBatch': [{'name': '%s'}]}}", - test_fixture->ns_coll); - mongoc_cursor_destroy (cursor); -} - -/* Test mongoc_collection_command, which constructed a namespace with - * MONGOC_NAMESPACE_MAX. */ -static void -collection_command (test_fixture_t *test_fixture) -{ - const bson_t *found; - mongoc_cursor_t *cursor; - bool ret; - bson_error_t error; - - cursor = mongoc_collection_command ( - test_fixture->coll, - MONGOC_QUERY_NONE, - 0 /* skip */, - 0 /* limit */, - 0 /* batch size */, - tmp_bson ("{'listCollections': 1, 'filter': {'name': '%s'}}", - test_fixture->ns_coll), - NULL /* fields */, - NULL /* read prefs */); - ret = mongoc_cursor_next (cursor, &found); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error) && ret, error); - ASSERT_MATCH (found, - "{'cursor': {'firstBatch': [{'name': '%s'}]}}", - test_fixture->ns_coll); - mongoc_cursor_destroy (cursor); -} - -/* Check whether a collection exists. */ -static void -_check_existence (mongoc_client_t *client, - char *ns_db, - char *ns_coll, - bool should_exist) -{ - mongoc_database_t *db; - char **db_names; - char **coll_names; - bool db_exists = false; - bool coll_exists = false; - char **iter; - bson_error_t error; - - ASSERT (client); - - db = mongoc_client_get_database (client, ns_db); - db_names = mongoc_client_get_database_names_with_opts ( - client, NULL /* opts */, &error); - coll_names = mongoc_database_get_collection_names_with_opts ( - db, NULL /* opts */, &error); - - for (iter = db_names; *iter != NULL; ++iter) { - if (0 == strcmp (ns_db, *iter)) { - db_exists = true; - } - } - - if (!db_exists && should_exist) { - test_error ("Database %s does not exist but should", ns_db); - } - - for (iter = coll_names; *iter != NULL; ++iter) { - if (0 == strcmp (ns_coll, *iter)) { - coll_exists = true; - } - } - - if (coll_exists && !should_exist) { - test_error ("Collection %s exists but shouldn't", ns_coll); - } - if (!coll_exists && should_exist) { - test_error ("Collection %s does not exist but should", ns_coll); - } - - bson_strfreev (db_names); - bson_strfreev (coll_names); - mongoc_database_destroy (db); -} - -/* Test mongoc_collection_rename, which constructed a namespace - * with MONGOC_NAMESPACE_MAX */ -static void -collection_rename (test_fixture_t *test_fixture) -{ - bool ret; - bson_error_t error; - char *new_db; - char *new_coll; - char *new_ns; - mongoc_client_t *client; - - new_db = bson_strdup_printf ("renamed_db"); - new_coll = bson_strdup_printf ("renamed_%s", test_fixture->ns_coll); - new_ns = bson_strdup_printf ("%s.%s", new_db, new_coll); - - /* Insert to create source namespace. */ - ret = mongoc_collection_insert_one (test_fixture->coll, - tmp_bson ("{'_id': 'hello'}"), - NULL /* opts */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (ret, error); - - ret = mongoc_collection_rename ( - test_fixture->coll, new_db, new_coll, true, &error); - ASSERT_OR_PRINT (ret, error); - - /* The fields in the collection struct are updated to the new names. */ - ASSERT_CMPSTR (test_fixture->coll->db, new_db); - ASSERT_CMPSTR (test_fixture->coll->collection, new_coll); - ASSERT_CMPSTR (test_fixture->coll->ns, new_ns); - ASSERT_CMPSIZE_T (test_fixture->coll->nslen, ==, strlen (new_ns)); - ASSERT_CMPSIZE_T (test_fixture->coll->collectionlen, ==, strlen (new_coll)); - - /* Check that source collections do not exist anymore. Use a separate client - * so commands - * don't show up in APM on test fixture's client. */ - client = test_framework_new_default_client (); - _check_existence (client, test_fixture->ns_db, test_fixture->ns_coll, false); - - /* Check that the new collection exists. */ - _check_existence (client, new_db, new_coll, true); - mongoc_client_destroy (client); - bson_free (new_db); - bson_free (new_coll); - bson_free (new_ns); -} - -typedef void (*test_fn) (test_fixture_t *fixture); - -static void -run_test (void *ctx) -{ - test_fn one_test; - test_fixture_t test_fixture; - - one_test = (test_fn) ((TestFnCtx *) ctx)->test_fn; - /* Small names. */ - test_fixture_init (&test_fixture, 32, 32); - one_test (&test_fixture); - test_fixture_cleanup (&test_fixture); - /* Large collection name. */ - test_fixture_init (&test_fixture, 32, 100); - one_test (&test_fixture); - test_fixture_cleanup (&test_fixture); - /* Maximum valid database name is still 64 characters. */ - test_fixture_init (&test_fixture, 63, 32); - one_test (&test_fixture); - test_fixture_cleanup (&test_fixture); - /* Large for both names. */ - test_fixture_init (&test_fixture, 63, 100); - one_test (&test_fixture); - test_fixture_cleanup (&test_fixture); -} - -static void -unsupported_long_coll (void *unused) -{ - bson_error_t error; - bool ret; - char *long_coll; - mongoc_client_t *client; - mongoc_collection_t *coll; - - BSON_UNUSED (unused); - - long_coll = bson_malloc (200); - memset (long_coll, 'd', 199); - long_coll[199] = '\0'; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - coll = mongoc_client_get_collection (client, "test", long_coll); - /* Insert. */ - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'x': 1}"), NULL /* opts */, NULL /* reply */, &error); - BSON_ASSERT (!ret); - /* Error code changed in 4.0 and the message in 4.2. Just validate an error - * happened. */ - BSON_ASSERT (error.code); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - - bson_free (long_coll); -} - -/* 63 characters is still the database length limit. Test this on all server - * versions. */ -static void -unsupported_long_db (void) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_error_t error; - bool ret; - char *long_db; - - long_db = bson_malloc (65); - memset (long_db, 'd', 64); - long_db[64] = '\0'; - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - coll = mongoc_client_get_collection (client, long_db, "test"); - /* Insert. */ - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'x': 1}"), NULL /* opts */, NULL /* reply */, &error); - - BSON_ASSERT (!ret); - /* Error code changed in 3.4. Just validate an error happened. */ - BSON_ASSERT (error.code); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - bson_free (long_db); -} - -void -test_long_namespace_install (TestSuite *suite) -{ - /* MongoDB 4.4 (wire version 9) introduced support for long namespaces in - * SERVER-32959 */ - TestSuite_AddFullWithTestFn ( - suite, - "/long_namespace/client_command", - run_test, - NULL /* dtor */, - client_command, - test_framework_skip_if_max_wire_version_less_than_9); - - TestSuite_AddFullWithTestFn ( - suite, - "/long_namespace/database_command", - run_test, - NULL /* dtor */, - database_command, - test_framework_skip_if_max_wire_version_less_than_9); - - TestSuite_AddFullWithTestFn ( - suite, - "/long_namespace/collection_command", - run_test, - NULL /* dtor */, - collection_command, - test_framework_skip_if_max_wire_version_less_than_9); - - TestSuite_AddFullWithTestFn ( - suite, - "/long_namespace/crud", - run_test, - NULL /* dtor */, - crud, - test_framework_skip_if_max_wire_version_less_than_9); - - TestSuite_AddFullWithTestFn ( - suite, - "/long_namespace/getmore", - run_test, - NULL /* dtor */, - getmore, - test_framework_skip_if_max_wire_version_less_than_9); - - TestSuite_AddFullWithTestFn (suite, - "/long_namespace/change_stream", - run_test, - NULL /* dtor */, - change_stream, - test_framework_skip_if_not_rs_version_9, - test_framework_skip_if_no_sessions); - - TestSuite_AddFullWithTestFn ( - suite, - "/long_namespace/collection_rename", - run_test, - NULL /* dtor */, - collection_rename, - test_framework_skip_if_max_wire_version_less_than_9, - test_framework_skip_if_mongos); - - TestSuite_AddFull (suite, - "/long_namespace/unsupported_long_coll", - unsupported_long_coll, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_max_wire_version_more_than_8); - - TestSuite_AddLive ( - suite, "/long_namespace/unsupported_long_db", unsupported_long_db); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-matcher.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-matcher.c deleted file mode 100644 index aa269b9e1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-matcher.c +++ /dev/null @@ -1,559 +0,0 @@ - -#include -#include -#include -#include - -#include "TestSuite.h" - -BEGIN_IGNORE_DEPRECATIONS - -static void -test_mongoc_matcher_basic (void) -{ - bson_t matcher_query; - bson_t *query; - bson_t *to_match; - bson_t *should_fail; - bson_error_t error; - mongoc_matcher_t *matcher; - - bson_init (&matcher_query); - - query = BCON_NEW ("city", - "New York", - "state", - "New York", - "favorite color", - "blue", - "name", - "{", - "$not", - "invalid", - "}", - /* "zip", "{", "$in", "[", BCON_INT32(11201), */ - /* BCON_INT32(90210), "]", "}", */ - "$or", - "[", - "{", - "age", - "{", - "$lt", - BCON_INT32 (18), - "}", - "}", - "{", - "age", - "{", - "$gt", - BCON_INT32 (45), - "}", - "}", - "]"); - - matcher = mongoc_matcher_new (query, &error); - - BSON_ASSERT (matcher); - - _mongoc_matcher_op_to_bson (matcher->optree, &matcher_query); - -#if 0 - { - char *out = bson_as_canonical_extended_json(&matcher_query, NULL); - fprintf(stderr, "bson: %s\n", out); - bson_free(out); - } -#endif - - to_match = BCON_NEW ("city", - "New York", - "state", - "New York", - "favorite color", - "blue", - "zip", - BCON_INT32 (11201), - "age", - BCON_INT32 (65)); - - BSON_ASSERT (mongoc_matcher_match (matcher, to_match)); - - should_fail = BCON_NEW ("city", - "New York", - "state", - "New York", - "favorite color", - "blue", - "zip", - BCON_INT32 (99999), - "age", - BCON_INT32 (30)); - - BSON_ASSERT (!mongoc_matcher_match (matcher, should_fail)); - - bson_destroy (query); - bson_destroy (to_match); - bson_destroy (should_fail); - bson_destroy (&matcher_query); - - mongoc_matcher_destroy (matcher); -} - -static void -test_mongoc_matcher_array (void) -{ - bson_t *query; - bson_t *to_match; - bson_t *should_fail; - bson_error_t error; - mongoc_matcher_t *matcher; - - query = BCON_NEW ("a", "[", BCON_INT32 (1), BCON_INT32 (2), "]"); - matcher = mongoc_matcher_new (query, &error); - BSON_ASSERT (matcher); - - /* query matches itself */ - BSON_ASSERT (mongoc_matcher_match (matcher, query)); - - to_match = - BCON_NEW ("a", "[", BCON_INT32 (1), BCON_INT32 (2), "]", "b", "whatever"); - BSON_ASSERT (mongoc_matcher_match (matcher, to_match)); - - /* query {a: [1, 2]} doesn't match {a: 1} */ - should_fail = BCON_NEW ("a", BCON_INT32 (1)); - BSON_ASSERT (!mongoc_matcher_match (matcher, should_fail)); - bson_destroy (should_fail); - - /* query {a: [1, 2]} doesn't match {a: [2, 1]} */ - should_fail = BCON_NEW ("a", "[", BCON_INT32 (2), BCON_INT32 (1), "]"); - BSON_ASSERT (!mongoc_matcher_match (matcher, should_fail)); - bson_destroy (should_fail); - - /* query {a: [1, 2]} doesn't match {a: [1, 2, 3]} */ - should_fail = - BCON_NEW ("a", "[", BCON_INT32 (1), BCON_INT32 (2), BCON_INT32 (3), "]"); - BSON_ASSERT (!mongoc_matcher_match (matcher, should_fail)); - bson_destroy (should_fail); - - /* query {a: [1, 2]} doesn't match {a: [1]} */ - should_fail = BCON_NEW ("a", "[", BCON_INT32 (1), "]"); - BSON_ASSERT (!mongoc_matcher_match (matcher, should_fail)); - - bson_destroy (to_match); - mongoc_matcher_destroy (matcher); - bson_destroy (query); - - /* empty array */ - query = BCON_NEW ("a", "[", "]"); - - /* {a: []} matches itself */ - matcher = mongoc_matcher_new (query, &error); - BSON_ASSERT (matcher); - - /* query {a: []} matches {a: [], b: "whatever"} */ - to_match = BCON_NEW ("a", "[", "]", "b", "whatever"); - BSON_ASSERT (mongoc_matcher_match (matcher, query)); - BSON_ASSERT (mongoc_matcher_match (matcher, to_match)); - - /* query {a: []} doesn't match {a: [1]} */ - BSON_ASSERT (!mongoc_matcher_match (matcher, should_fail)); - bson_destroy (should_fail); - - /* query {a: []} doesn't match empty document */ - should_fail = bson_new (); - BSON_ASSERT (!mongoc_matcher_match (matcher, should_fail)); - - bson_destroy (should_fail); - - /* query {a: []} doesn't match {a: null} */ - should_fail = BCON_NEW ("a", BCON_NULL); - BSON_ASSERT (!mongoc_matcher_match (matcher, should_fail)); - - bson_destroy (should_fail); - bson_destroy (query); - bson_destroy (to_match); - mongoc_matcher_destroy (matcher); -} - - -typedef struct compare_check { - const char *op; - int32_t doc; - int32_t query; - bool expected; -} compare_check; - - -static void -test_mongoc_matcher_compare (void) -{ - mongoc_matcher_t *matcher; - compare_check checks[] = {{"$gt", 2, 2, false}, - {"$gte", 2, 2, true}, - {"$lt", 2, 2, false}, - {"$lte", 2, 2, true}, - {"$ne", 2, 2, false}, - {NULL}}; - bson_t *doc; - bson_t *q; - int i; - - for (i = 0; checks[i].op; i++) { - doc = BCON_NEW ("a", BCON_INT32 (checks[i].doc)); - q = BCON_NEW ("a", "{", checks[i].op, BCON_INT32 (checks[i].query), "}"); - matcher = mongoc_matcher_new (q, NULL); - BSON_ASSERT (matcher); - BSON_ASSERT (mongoc_matcher_match (matcher, doc) == checks[i].expected); - bson_destroy (q); - bson_destroy (doc); - mongoc_matcher_destroy (matcher); - } -} - - -typedef struct { - const char *spec; - const char *doc; - bool match; -} logic_op_test_t; - - -static void -test_mongoc_matcher_logic_ops (void) -{ - logic_op_test_t tests[] = { - {"{\"$or\": [{\"a\": 1}, {\"b\": 2}]}", "{\"a\": 1}", true}, - {"{\"$or\": [{\"a\": 1}, {\"b\": 2}]}", "{\"b\": 2}", true}, - {"{\"$or\": [{\"a\": 1}, {\"b\": 2}]}", "{\"a\": 3}", false}, - {"{\"$or\": [{\"a\": {\"$gt\": 1}}, {\"a\": {\"$lt\": -1}}]}", - "{\"a\": 3}", - true}, - {"{\"$or\": [{\"a\": {\"$gt\": 1}}, {\"a\": {\"$lt\": -1}}]}", - "{\"a\": -2}", - true}, - {"{\"$or\": [{\"a\": {\"$gt\": 1}}, {\"a\": {\"$lt\": -1}}]}", - "{\"a\": 0}", - false}, - {"{\"$and\": [{\"a\": 1}, {\"b\": 2}]}", "{\"a\": 1, \"b\": 2}", true}, - {"{\"$and\": [{\"a\": 1}, {\"b\": 2}]}", "{\"a\": 1, \"b\": 1}", false}, - {"{\"$and\": [{\"a\": 1}, {\"b\": 2}]}", "{\"a\": 1}", false}, - {"{\"$and\": [{\"a\": 1}, {\"b\": 2}]}", "{\"b\": 2}", false}, - {"{\"$and\": [{\"a\": {\"$gt\": -1}}, {\"a\": {\"$lt\": 1}}]}", - "{\"a\": 0}", - true}, - {"{\"$and\": [{\"a\": {\"$gt\": -1}}, {\"a\": {\"$lt\": 1}}]}", - "{\"a\": -2}", - false}, - {"{\"$and\": [{\"a\": {\"$gt\": -1}}, {\"a\": {\"$lt\": 1}}]}", - "{\"a\": 1}", - false}, - }; - - int n_tests = sizeof tests / sizeof (logic_op_test_t); - int i; - logic_op_test_t test; - bson_t *spec; - bson_error_t error; - mongoc_matcher_t *matcher; - bson_t *doc; - bool r; - - for (i = 0; i < n_tests; i++) { - test = tests[i]; - spec = bson_new_from_json ((uint8_t *) test.spec, -1, &error); - if (!spec) { - test_error ( - "couldn't parse JSON query:\n\n%s\n\n%s", test.spec, error.message); - } - - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - - doc = bson_new_from_json ((uint8_t *) test.doc, -1, &error); - if (!doc) { - test_error ("couldn't parse JSON document:\n\n%s\n\n%s", - test.doc, - error.message); - } - - r = mongoc_matcher_match (matcher, doc); - if (test.match != r) { - test_error ("query:\n\n%s\n\nshould %shave matched:\n\n%s", - test.match ? "" : "not ", - test.spec, - test.doc); - } - - mongoc_matcher_destroy (matcher); - bson_destroy (doc); - bson_destroy (spec); - } -} - - -static void -test_mongoc_matcher_bad_spec (void) -{ - bson_t *spec; - bson_error_t error; - mongoc_matcher_t *matcher; - - spec = BCON_NEW ("name", "{", "$abc", "invalid", "}"); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (!matcher); - BSON_ASSERT (error.domain == MONGOC_ERROR_MATCHER); - BSON_ASSERT (error.code == MONGOC_ERROR_MATCHER_INVALID); - bson_destroy (spec); - - spec = BCON_NEW ("name", "{", "$or", "", "}"); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (!matcher); - BSON_ASSERT (error.domain == MONGOC_ERROR_MATCHER); - BSON_ASSERT (error.code == MONGOC_ERROR_MATCHER_INVALID); - bson_destroy (spec); -} - - -static void -test_mongoc_matcher_eq_utf8 (void) -{ - bson_t *doc; - bson_t *spec; - bson_error_t error; - mongoc_matcher_t *matcher; - bool r; - - spec = BCON_NEW ("hello", "world"); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - r = mongoc_matcher_match (matcher, spec); - BSON_ASSERT (r); - bson_destroy (spec); - mongoc_matcher_destroy (matcher); - - spec = BCON_NEW ("hello", "world"); - doc = BCON_NEW ("hello", BCON_NULL); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - r = mongoc_matcher_match (matcher, doc); - BSON_ASSERT (!r); - bson_destroy (spec); - bson_destroy (doc); - mongoc_matcher_destroy (matcher); - - spec = BCON_NEW ("hello", "world"); - doc = BCON_NEW ("hello", BCON_UNDEFINED); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - r = mongoc_matcher_match (matcher, doc); - BSON_ASSERT (!r); - bson_destroy (spec); - bson_destroy (doc); - mongoc_matcher_destroy (matcher); -} - - -static void -test_mongoc_matcher_eq_int32 (void) -{ - bson_t *spec; - bson_t *doc; - bson_error_t error; - mongoc_matcher_t *matcher; - bool r; - - spec = BCON_NEW ("hello", BCON_INT32 (1234)); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - r = mongoc_matcher_match (matcher, spec); - BSON_ASSERT (r); - bson_destroy (spec); - mongoc_matcher_destroy (matcher); - - spec = BCON_NEW ("hello", BCON_INT32 (1234)); - doc = BCON_NEW ("hello", BCON_INT64 (1234)); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - r = mongoc_matcher_match (matcher, doc); - BSON_ASSERT (r); - bson_destroy (spec); - bson_destroy (doc); - mongoc_matcher_destroy (matcher); - - spec = BCON_NEW ("hello", BCON_INT32 (1234)); - doc = BCON_NEW ("hello", BCON_INT64 (4321)); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - r = mongoc_matcher_match (matcher, doc); - BSON_ASSERT (!r); - bson_destroy (spec); - bson_destroy (doc); - mongoc_matcher_destroy (matcher); -} - - -static void -test_mongoc_matcher_eq_int64 (void) -{ - bson_t *spec; - bson_t *doc; - bson_error_t error; - mongoc_matcher_t *matcher; - bool r; - - spec = BCON_NEW ("hello", BCON_INT64 (1234)); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - r = mongoc_matcher_match (matcher, spec); - BSON_ASSERT (r); - bson_destroy (spec); - mongoc_matcher_destroy (matcher); - - spec = BCON_NEW ("hello", BCON_INT64 (1234)); - doc = BCON_NEW ("hello", BCON_INT64 (1234)); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - r = mongoc_matcher_match (matcher, doc); - BSON_ASSERT (r); - bson_destroy (spec); - bson_destroy (doc); - mongoc_matcher_destroy (matcher); - - spec = BCON_NEW ("hello", BCON_INT64 (1234)); - doc = BCON_NEW ("hello", BCON_INT32 (4321)); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - r = mongoc_matcher_match (matcher, doc); - BSON_ASSERT (!r); - bson_destroy (spec); - bson_destroy (doc); - mongoc_matcher_destroy (matcher); -} - - -static void -test_mongoc_matcher_eq_doc (void) -{ - bson_t *spec; - bson_t *doc; - bson_error_t error; - mongoc_matcher_t *matcher; - - /* {doc: {a: 1}} matches itself */ - spec = BCON_NEW ("doc", "{", "a", BCON_INT32 (1), "}"); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - BSON_ASSERT (mongoc_matcher_match (matcher, spec)); - - /* {doc: {a: 1}} matches {doc: {a: 1}, foo: "whatever"} */ - doc = BCON_NEW ( - "doc", "{", "a", BCON_INT32 (1), "}", "foo", BCON_UTF8 ("whatever")); - BSON_ASSERT (mongoc_matcher_match (matcher, doc)); - bson_destroy (doc); - - /* {doc: {a: 1}} doesn't match {doc: 1} */ - doc = BCON_NEW ("doc", BCON_INT32 (1)); - BSON_ASSERT (!mongoc_matcher_match (matcher, doc)); - bson_destroy (doc); - - /* {doc: {a: 1}} doesn't match {doc: {}} */ - doc = BCON_NEW ("doc", "{", "}"); - BSON_ASSERT (!mongoc_matcher_match (matcher, doc)); - bson_destroy (doc); - - /* {doc: {a: 1}} doesn't match {doc: {a: 2}} */ - doc = BCON_NEW ("doc", "{", "a", BCON_INT32 (2), "}"); - BSON_ASSERT (!mongoc_matcher_match (matcher, doc)); - bson_destroy (doc); - - /* {doc: {a: 1}} doesn't match {doc: {b: 1}} */ - doc = BCON_NEW ("doc", "{", "b", BCON_INT32 (1), "}"); - BSON_ASSERT (!mongoc_matcher_match (matcher, doc)); - bson_destroy (doc); - - /* {doc: {a: 1}} doesn't match {doc: {a: 1, b: 1}} */ - doc = BCON_NEW ("doc", "{", "a", BCON_INT32 (1), "b", BCON_INT32 (1), "}"); - BSON_ASSERT (!mongoc_matcher_match (matcher, doc)); - bson_destroy (doc); - - /* {doc: {a: 1, b:1}} matches itself */ - bson_destroy (spec); - mongoc_matcher_destroy (matcher); - spec = BCON_NEW ("doc", "{", "a", BCON_INT32 (1), "b", BCON_INT32 (1), "}"); - matcher = mongoc_matcher_new (spec, &error); - BSON_ASSERT (matcher); - BSON_ASSERT (mongoc_matcher_match (matcher, spec)); - - /* {doc: {a: 1, b:1}} doesn't match {doc: {a: 1}} */ - doc = BCON_NEW ("doc", "{", "a", BCON_INT32 (1), "}"); - BSON_ASSERT (!mongoc_matcher_match (matcher, doc)); - bson_destroy (spec); - bson_destroy (doc); - mongoc_matcher_destroy (matcher); -} - - -static void -test_mongoc_matcher_in_basic (void) -{ - mongoc_matcher_t *matcher; - bson_error_t error; - bool r; - bson_t *spec; - bson_t doc = BSON_INITIALIZER; - - spec = BCON_NEW ("key", - "{", - "$in", - "[", - BCON_INT32 (1), - BCON_INT32 (2), - BCON_INT32 (3), - "]", - "}"); - - matcher = mongoc_matcher_new (spec, &error); - r = mongoc_matcher_match (matcher, &doc); - ASSERT (!r); - - bson_reinit (&doc); - bson_append_int32 (&doc, "key", 3, 1); - r = mongoc_matcher_match (matcher, &doc); - ASSERT (r); - - bson_reinit (&doc); - bson_append_int32 (&doc, "key", 3, 2); - r = mongoc_matcher_match (matcher, &doc); - ASSERT (r); - - bson_reinit (&doc); - bson_append_int32 (&doc, "key", 3, 3); - r = mongoc_matcher_match (matcher, &doc); - ASSERT (r); - - bson_reinit (&doc); - bson_append_int32 (&doc, "key", 3, 4); - r = mongoc_matcher_match (matcher, &doc); - ASSERT (!r); - - bson_destroy (&doc); - bson_destroy (spec); - mongoc_matcher_destroy (matcher); -} - -END_IGNORE_DEPRECATIONS - -void -test_matcher_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/Matcher/basic", test_mongoc_matcher_basic); - TestSuite_Add (suite, "/Matcher/array", test_mongoc_matcher_array); - TestSuite_Add (suite, "/Matcher/compare", test_mongoc_matcher_compare); - TestSuite_Add (suite, "/Matcher/logic", test_mongoc_matcher_logic_ops); - TestSuite_Add (suite, "/Matcher/bad_spec", test_mongoc_matcher_bad_spec); - TestSuite_Add (suite, "/Matcher/eq/utf8", test_mongoc_matcher_eq_utf8); - TestSuite_Add (suite, "/Matcher/eq/int32", test_mongoc_matcher_eq_int32); - TestSuite_Add (suite, "/Matcher/eq/int64", test_mongoc_matcher_eq_int64); - TestSuite_Add (suite, "/Matcher/eq/doc", test_mongoc_matcher_eq_doc); - TestSuite_Add (suite, "/Matcher/in/basic", test_mongoc_matcher_in_basic); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-max-staleness.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-max-staleness.c deleted file mode 100644 index 1c8616bed..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-max-staleness.c +++ /dev/null @@ -1,407 +0,0 @@ -#include -#include - -#include "mongoc/mongoc-client-private.h" - -#include "TestSuite.h" -#include "json-test.h" -#include "test-libmongoc.h" -#include "mock_server/mock-server.h" -#include "mock_server/future-functions.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "client-test-max-staleness" - - -static int64_t -get_max_staleness (const mongoc_client_t *client) -{ - const mongoc_read_prefs_t *prefs; - - ASSERT (client); - - prefs = mongoc_client_get_read_prefs (client); - - return mongoc_read_prefs_get_max_staleness_seconds (prefs); -} - - -/* the next few tests are from max-staleness-tests.rst */ -static void -test_mongoc_client_max_staleness (void) -{ - mongoc_client_t *client; - - client = test_framework_client_new (NULL, NULL); - ASSERT_CMPINT64 (get_max_staleness (client), ==, (int64_t) -1); - mongoc_client_destroy (client); - - client = test_framework_client_new ( - "mongodb://a/?" MONGOC_URI_READPREFERENCE "=secondary", NULL); - ASSERT_CMPINT64 (get_max_staleness (client), ==, (int64_t) -1); - mongoc_client_destroy (client); - - /* -1 is the default, means "no max staleness" */ - client = test_framework_client_new ( - "mongodb://a/?" MONGOC_URI_MAXSTALENESSSECONDS "=-1", NULL); - ASSERT_CMPINT64 (get_max_staleness (client), ==, (int64_t) -1); - mongoc_client_destroy (client); - - client = test_framework_client_new ( - "mongodb://a/?" MONGOC_URI_READPREFERENCE - "=primary&" MONGOC_URI_MAXSTALENESSSECONDS "=-1", - NULL); - - ASSERT_CMPINT64 (get_max_staleness (client), ==, (int64_t) -1); - mongoc_client_destroy (client); - - /* no " MONGOC_URI_MAXSTALENESSSECONDS " with primary mode */ - capture_logs (true); - ASSERT (!test_framework_client_new ( - "mongodb://a/?" MONGOC_URI_MAXSTALENESSSECONDS "=120", NULL)); - ASSERT_CAPTURED_LOG (MONGOC_URI_MAXSTALENESSSECONDS "=120", - MONGOC_LOG_LEVEL_WARNING, - "Invalid readPreferences"); - - capture_logs (true); - ASSERT (!test_framework_client_new ( - "mongodb://a/?" MONGOC_URI_READPREFERENCE - "=primary&" MONGOC_URI_MAXSTALENESSSECONDS "=120", - NULL)); - ASSERT_CAPTURED_LOG (MONGOC_URI_MAXSTALENESSSECONDS "=120", - MONGOC_LOG_LEVEL_WARNING, - "Invalid readPreferences"); - capture_logs (false); - - /* zero is prohibited */ - capture_logs (true); - client = test_framework_client_new ( - "mongodb://a/?" MONGOC_URI_READPREFERENCE - "=nearest&" MONGOC_URI_MAXSTALENESSSECONDS "=0", - NULL); - - ASSERT_CAPTURED_LOG ( - MONGOC_URI_MAXSTALENESSSECONDS "=0", - MONGOC_LOG_LEVEL_WARNING, - "Unsupported value for \"" MONGOC_URI_MAXSTALENESSSECONDS "\": \"0\""); - capture_logs (false); - - ASSERT_CMPINT64 (get_max_staleness (client), ==, (int64_t) -1); - mongoc_client_destroy (client); - - client = - test_framework_client_new ("mongodb://a/?" MONGOC_URI_MAXSTALENESSSECONDS - "=120&" MONGOC_URI_READPREFERENCE "=secondary", - NULL); - - ASSERT_CMPINT64 (get_max_staleness (client), ==, (int64_t) 120); - mongoc_client_destroy (client); - - /* float is ignored */ - capture_logs (true); - ASSERT (!test_framework_client_new ( - "mongodb://a/?" MONGOC_URI_READPREFERENCE - "=secondary&" MONGOC_URI_MAXSTALENESSSECONDS "=10.5", - NULL)); - - ASSERT_CAPTURED_LOG (MONGOC_URI_MAXSTALENESSSECONDS "=10.5", - MONGOC_LOG_LEVEL_WARNING, - "Invalid " MONGOC_URI_MAXSTALENESSSECONDS); - capture_logs (false); - - /* 1 is allowed, it'll be rejected once we begin server selection */ - client = test_framework_client_new ( - "mongodb://a/?" MONGOC_URI_READPREFERENCE - "=secondary&" MONGOC_URI_MAXSTALENESSSECONDS "=1", - NULL); - - ASSERT_EQUAL_DOUBLE (get_max_staleness (client), 1); - mongoc_client_destroy (client); -} - - -static void -test_mongos_max_staleness_read_pref (void) -{ - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_read_prefs_t *prefs; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - /* count command with mode "secondary", no MONGOC_URI_MAXSTALENESSSECONDS. */ - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_collection_set_read_prefs (collection, prefs); - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, NULL, 0, 0, NULL, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " '$readPreference': {" - " 'mode': 'secondary'," - " 'maxStalenessSeconds': {'$exists': false}}}")); - - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (1 == future_get_int64_t (future), error); - - request_destroy (request); - future_destroy (future); - - /* count command with mode "secondary". MONGOC_URI_MAXSTALENESSSECONDS=1 is - * allowed by client, although in real life mongos will reject it */ - mongoc_read_prefs_set_max_staleness_seconds (prefs, 1); - mongoc_collection_set_read_prefs (collection, prefs); - - mongoc_collection_set_read_prefs (collection, prefs); - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, NULL, 0, 0, NULL, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " '$readPreference': {" - " 'mode': 'secondary'," - " 'maxStalenessSeconds': {'$numberLong': '1'}}}")); - - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (1 == future_get_int64_t (future), error); - - request_destroy (request); - future_destroy (future); - - /* For all read preference modes that are not 'primary', drivers MUST set - * readPreference. */ - mongoc_read_prefs_set_mode (prefs, MONGOC_READ_SECONDARY_PREFERRED); - mongoc_read_prefs_set_max_staleness_seconds (prefs, MONGOC_NO_MAX_STALENESS); - mongoc_collection_set_read_prefs (collection, prefs); - - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, NULL, 0, 0, NULL, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ( - "{'$db': 'db', '$readPreference': {'mode': 'secondaryPreferred'}}")); - - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (1 == future_get_int64_t (future), error); - - request_destroy (request); - future_destroy (future); - - /* CDRIVER-3633: with readPreference mode secondaryPreferred and - * maxStalenessSeconds set, readPreference MUST be sent. */ - mongoc_read_prefs_set_max_staleness_seconds (prefs, 1); - mongoc_collection_set_read_prefs (collection, prefs); - - future = future_collection_count ( - collection, MONGOC_QUERY_NONE, NULL, 0, 0, NULL, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db'," - " '$readPreference': {" - " 'mode': 'secondaryPreferred'," - " 'maxStalenessSeconds': {'$numberLong': '1'}}}")); - - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - ASSERT_OR_PRINT (1 == future_get_int64_t (future), error); - - request_destroy (request); - future_destroy (future); - - mongoc_read_prefs_destroy (prefs); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -_test_last_write_date (bool pooled) -{ - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - bool r; - mongoc_server_description_t *s0, *s1; - int64_t delta; - - uri = test_framework_get_uri (); - mongoc_uri_set_option_as_int32 (uri, "heartbeatFrequencyMS", 500); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - } - mongoc_uri_destroy (uri); - - collection = get_test_collection (client, "test_last_write_date"); - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{}"), NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - - _mongoc_usleep (1000 * 1000); - s0 = mongoc_topology_select ( - client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); - ASSERT_OR_PRINT (s0, error); - - _mongoc_usleep (1000 * 1000); - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{}"), NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - - _mongoc_usleep (1000 * 1000); - s1 = mongoc_topology_select ( - client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); - ASSERT_OR_PRINT (s1, error); - ASSERT_CMPINT64 (s1->last_write_date_ms, !=, (int64_t) -1); - - /* lastWriteDate increased by roughly one second - be lenient, just check - * it increased by less than 10 seconds */ - delta = s1->last_write_date_ms - s0->last_write_date_ms; - ASSERT_CMPINT64 (delta, >, (int64_t) 0); - ASSERT_CMPINT64 (delta, <, (int64_t) 10 * 1000); - - mongoc_server_description_destroy (s0); - mongoc_server_description_destroy (s1); - mongoc_collection_destroy (collection); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } -} - - -static void -test_last_write_date (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_last_write_date (false); -} - - -static void -test_last_write_date_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_last_write_date (true); -} - - -/* run only if wire version is older than 5 */ -static void -_test_last_write_date_absent (bool pooled) -{ - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bson_error_t error; - mongoc_server_description_t *sd; - - if (pooled) { - pool = test_framework_new_default_client_pool (); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - } - - sd = mongoc_topology_select ( - client->topology, MONGOC_SS_READ, NULL, NULL, &error); - ASSERT_OR_PRINT (sd, error); - - /* lastWriteDate absent */ - ASSERT_CMPINT64 (sd->last_write_date_ms, ==, (int64_t) -1); - - mongoc_server_description_destroy (sd); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } -} - - -static void -test_last_write_date_absent (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_last_write_date_absent (false); -} - - -static void -test_last_write_date_absent_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_last_write_date_absent (true); -} - - -static void -test_all_spec_tests (TestSuite *suite) -{ - install_json_test_suite ( - suite, JSON_DIR, "max_staleness", &test_server_selection_logic_cb); -} - -void -test_client_max_staleness_install (TestSuite *suite) -{ - test_all_spec_tests (suite); - TestSuite_Add ( - suite, "/Client/max_staleness", test_mongoc_client_max_staleness); - TestSuite_AddMockServerTest (suite, - "/Client/max_staleness/mongos", - test_mongos_max_staleness_read_pref); - TestSuite_AddFull (suite, - "/Client/last_write_date", - test_last_write_date, - NULL, - NULL, - test_framework_skip_if_not_replset, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/Client/last_write_date/pooled", - test_last_write_date_pooled, - NULL, - NULL, - test_framework_skip_if_not_replset, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/Client/last_write_date_absent", - test_last_write_date_absent, - NULL, - NULL, - test_framework_skip_if_replset); - TestSuite_AddFull (suite, - "/Client/last_write_date_absent/pooled", - test_last_write_date_absent_pooled, - NULL, - NULL, - test_framework_skip_if_replset); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-mongos-pinning.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-mongos-pinning.c deleted file mode 100644 index 9af3b48d1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-mongos-pinning.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2019-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "mongoc/mongoc-uri-private.h" -#include "mongoc/mongoc-host-list-private.h" - -#include "TestSuite.h" -#include "test-libmongoc.h" -#include "test-conveniences.h" - -static void -add_multiple_mongoses (mongoc_uri_t *uri) -{ - bson_error_t error; - - /* TODO CDRIVER-3285, fix this to be dynamic */ - ASSERT_OR_PRINT ( - mongoc_uri_upsert_host_and_port (uri, "localhost:27017", &error), error); - ASSERT_OR_PRINT ( - mongoc_uri_upsert_host_and_port (uri, "localhost:27018", &error), error); -} - -static void -test_new_transaction_unpins (void *ctx) -{ - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_error_t error; - mongoc_client_session_t *session; - mongoc_host_list_t *servers = NULL; - mongoc_cursor_t *cursor; - bson_t *opts; - int i; - - BSON_UNUSED (ctx); - - uri = test_framework_get_uri (); - add_multiple_mongoses (uri); - - /* Increase localThresholdMS to avoid false positives. Nodes - will be discovered with the first call to server selection. */ - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_LOCALTHRESHOLDMS, 1000); - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - - /* Create a collection. */ - coll = mongoc_client_get_collection (client, "test", "test"); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson ("{}"), NULL, NULL, &error), - error); - - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session != NULL, error); - - opts = bson_new (); - ASSERT_OR_PRINT (mongoc_client_session_append (session, opts, &error), - error); - - /* Under one transaction, insert a document. */ - ASSERT_OR_PRINT ( - mongoc_client_session_start_transaction (session, NULL, &error), error); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson ("{}"), opts, NULL, &error), - error); - ASSERT_OR_PRINT ( - mongoc_client_session_commit_transaction (session, NULL, &error), error); - - /* Then, 50 times, start new transactions. Each time we start a new - transaction, the session should be un-pinned, so by statistics, - we should balance the new transactions across both mongos. */ - for (i = 0; i < 50; i++) { - mongoc_host_list_t cursor_host; - const bson_t *doc; - - ASSERT_OR_PRINT ( - mongoc_client_session_start_transaction (session, NULL, &error), - error); - - cursor = - mongoc_collection_find_with_opts (coll, tmp_bson ("{}"), opts, NULL); - ASSERT (mongoc_cursor_next (cursor, &doc)); - mongoc_cursor_get_host (cursor, &cursor_host); - _mongoc_host_list_upsert (&servers, &cursor_host); - - ASSERT_OR_PRINT ( - mongoc_client_session_commit_transaction (session, NULL, &error), - error); - - mongoc_cursor_destroy (cursor); - } - - ASSERT_CMPSIZE_T (_mongoc_host_list_length (servers), ==, 2u); - - bson_destroy (opts); - _mongoc_host_list_destroy_all (servers); - mongoc_uri_destroy (uri); - mongoc_client_session_destroy (session); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -static void -test_non_transaction_unpins (void *ctx) -{ - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_error_t error; - mongoc_client_session_t *session; - mongoc_host_list_t *servers = NULL; - mongoc_cursor_t *cursor; - bson_t *opts; - int i; - - BSON_UNUSED (ctx); - - uri = test_framework_get_uri (); - add_multiple_mongoses (uri); - - /* Increase localThresholdMS to avoid false positives. Nodes - will be discovered with the first call to server selection. */ - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_LOCALTHRESHOLDMS, 1000); - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - - /* Create a collection. */ - coll = mongoc_client_get_collection (client, "test", "test"); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson ("{}"), NULL, NULL, &error), - error); - - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session != NULL, error); - - opts = bson_new (); - ASSERT_OR_PRINT (mongoc_client_session_append (session, opts, &error), - error); - - /* Under one transaction, insert a document. */ - ASSERT_OR_PRINT ( - mongoc_client_session_start_transaction (session, NULL, &error), error); - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson ("{}"), opts, NULL, &error), - error); - ASSERT_OR_PRINT ( - mongoc_client_session_commit_transaction (session, NULL, &error), error); - - /* After our initial transaction, the session should become un-pinned - if we run further operations on the session. By statistics, - new operations should balance across both mongos. */ - for (i = 0; i < 50; i++) { - mongoc_host_list_t cursor_host; - const bson_t *doc; - - cursor = - mongoc_collection_find_with_opts (coll, tmp_bson ("{}"), opts, NULL); - ASSERT (mongoc_cursor_next (cursor, &doc)); - mongoc_cursor_get_host (cursor, &cursor_host); - _mongoc_host_list_upsert (&servers, &cursor_host); - - mongoc_cursor_destroy (cursor); - } - - ASSERT_CMPSIZE_T (_mongoc_host_list_length (servers), ==, 2u); - - bson_destroy (opts); - _mongoc_host_list_destroy_all (servers); - mongoc_uri_destroy (uri); - mongoc_client_session_destroy (session); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -void -test_mongos_pinning_install (TestSuite *suite) -{ - TestSuite_AddFull (suite, - "/mongos_pinning/new_transaction_unpins", - test_new_transaction_unpins, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_not_mongos); - - TestSuite_AddFull (suite, - "/mongos_pinning/non_transaction_unpins", - test_non_transaction_unpins, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_not_mongos); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-ocsp-cache.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-ocsp-cache.c deleted file mode 100644 index 65737132c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-ocsp-cache.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "TestSuite.h" - -#include "mongoc/mongoc-ocsp-cache-private.h" - -#if defined(MONGOC_ENABLE_OCSP_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x10101000L -#include - -static OCSP_CERTID * -create_cert_id (long serial) -{ - OCSP_CERTID *id; - X509_NAME *issuer_name; - ASN1_BIT_STRING *issuer_key; - ASN1_INTEGER *serial_number; - - issuer_name = X509_NAME_new (); - issuer_key = ASN1_BIT_STRING_new (); - serial_number = ASN1_INTEGER_new (); - ASN1_INTEGER_set (serial_number, serial); - - id = OCSP_cert_id_new (EVP_sha1 (), issuer_name, issuer_key, serial_number); - - ASN1_BIT_STRING_free (issuer_key); - ASN1_INTEGER_free (serial_number); - X509_NAME_free (issuer_name); - return id; -} - -#define CLEAR_CACHE \ - do { \ - _mongoc_ocsp_cache_cleanup (); \ - _mongoc_ocsp_cache_init (); \ - BSON_ASSERT (_mongoc_ocsp_cache_length () == 0); \ - } while (0) - -#define ASSERT_TIME_EQUAL(_a, _b) \ - do { \ - int pday, psec; \ - ASN1_TIME_diff (&pday, &psec, (_a), (_b)); \ - BSON_ASSERT (pday == 0); \ - BSON_ASSERT (psec == 0); \ - } while (0) - -static void -test_mongoc_cache_insert (void) -{ - ASN1_GENERALIZEDTIME *this_update_in, *next_update_in; - ASN1_GENERALIZEDTIME *this_update_out, *next_update_out; - int i, size = 5, status = V_OCSP_CERTSTATUS_GOOD, - reason = OCSP_REVOKED_STATUS_NOSTATUS; - - CLEAR_CACHE; - - next_update_in = ASN1_GENERALIZEDTIME_set (NULL, time (NULL) + 999); - this_update_in = ASN1_GENERALIZEDTIME_set (NULL, time (NULL)); - for (i = 0; i < size; i++) { - int s, r; - OCSP_CERTID *id = create_cert_id (i); - - BSON_ASSERT (!_mongoc_ocsp_cache_get_status ( - id, &s, &r, &this_update_out, &next_update_out)); - _mongoc_ocsp_cache_set_resp ( - id, status, reason, this_update_in, next_update_in); - - OCSP_CERTID_free (id); - } - - BSON_ASSERT (_mongoc_ocsp_cache_length () == size); - - for (i = 0; i < size; i++) { - OCSP_CERTID *id = create_cert_id (i); - int s, r; - - BSON_ASSERT (_mongoc_ocsp_cache_get_status ( - id, &s, &r, &this_update_out, &next_update_out)); - - BSON_ASSERT (status == s); - BSON_ASSERT (reason == r); - ASSERT_TIME_EQUAL (next_update_in, next_update_out); - ASSERT_TIME_EQUAL (this_update_in, this_update_out); - - OCSP_CERTID_free (id); - } - - CLEAR_CACHE; - ASN1_GENERALIZEDTIME_free (this_update_in); - ASN1_GENERALIZEDTIME_free (next_update_in); -} - -static void -test_mongoc_cache_update (void) -{ - OCSP_CERTID *id; - ASN1_GENERALIZEDTIME *next_update_in, *next_update_out, *this_update_out; - int status, reason; - - CLEAR_CACHE; - - next_update_in = ASN1_GENERALIZEDTIME_set (NULL, time (NULL)); - id = create_cert_id (1); - - _mongoc_ocsp_cache_set_resp ( - id, V_OCSP_CERTSTATUS_GOOD, 0, NULL, next_update_in); - BSON_ASSERT (_mongoc_ocsp_cache_length () == 1); - - BSON_ASSERT (_mongoc_ocsp_cache_get_status ( - id, &status, &reason, &this_update_out, &next_update_out)); - BSON_ASSERT (status == V_OCSP_CERTSTATUS_GOOD); - - ASN1_GENERALIZEDTIME_free (next_update_in); - next_update_in = ASN1_GENERALIZEDTIME_set ( - NULL, time (NULL) + 999 /* some time in the future */); - - _mongoc_ocsp_cache_set_resp ( - id, V_OCSP_CERTSTATUS_REVOKED, 0, NULL, next_update_in); - BSON_ASSERT (_mongoc_ocsp_cache_length () == 1); - - BSON_ASSERT (_mongoc_ocsp_cache_get_status ( - id, &status, &reason, &this_update_out, &next_update_out)); - BSON_ASSERT (status == V_OCSP_CERTSTATUS_REVOKED); - - ASN1_GENERALIZEDTIME_free (next_update_in); - next_update_in = ASN1_GENERALIZEDTIME_set ( - NULL, time (NULL) - 999 /* some time in the past */); - - _mongoc_ocsp_cache_set_resp ( - id, V_OCSP_CERTSTATUS_GOOD, 0, NULL, next_update_in); - BSON_ASSERT (_mongoc_ocsp_cache_length () == 1); - - BSON_ASSERT (_mongoc_ocsp_cache_get_status ( - id, &status, &reason, &this_update_out, &next_update_out)); - BSON_ASSERT (status == V_OCSP_CERTSTATUS_REVOKED); - - CLEAR_CACHE; - - ASN1_GENERALIZEDTIME_free (next_update_in); - OCSP_CERTID_free (id); -} - -static void -test_mongoc_cache_remove_expired_cert (void) -{ - ASN1_GENERALIZEDTIME *this_update_in, *next_update_in; - int status = V_OCSP_CERTSTATUS_GOOD, reason = OCSP_REVOKED_STATUS_NOSTATUS; - OCSP_CERTID *id = create_cert_id (1); - - CLEAR_CACHE; - - next_update_in = ASN1_GENERALIZEDTIME_set (NULL, time (NULL) - 1); - this_update_in = ASN1_GENERALIZEDTIME_set (NULL, time (NULL) - 999); - - _mongoc_ocsp_cache_set_resp ( - id, status, reason, this_update_in, next_update_in); - - BSON_ASSERT (_mongoc_ocsp_cache_length () == 1); - BSON_ASSERT (!_mongoc_ocsp_cache_get_status (id, NULL, NULL, NULL, NULL)); - BSON_ASSERT (_mongoc_ocsp_cache_length () == 0); - - OCSP_CERTID_free (id); - ASN1_GENERALIZEDTIME_free (next_update_in); - ASN1_GENERALIZEDTIME_free (this_update_in); - - CLEAR_CACHE; -} - -void -test_ocsp_cache_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/OCSPCache/insert", test_mongoc_cache_insert); - TestSuite_Add (suite, "/OCSPCache/update", test_mongoc_cache_update); - TestSuite_Add (suite, - "/OCSPCache/remove_expired_cert", - test_mongoc_cache_remove_expired_cert); -} -#else -extern int no_mongoc_ocsp; -#endif /* MONGOC_ENABLE_OCSP_OPENSSL */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-opts.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-opts.c deleted file mode 100644 index 76c7599f9..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-opts.c +++ /dev/null @@ -1,1017 +0,0 @@ -#include -#include -#include -#include - -#include "TestSuite.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" -#include "mock_server/mock-rs.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - - -/* - * Test that all "with_opts" functions that accept readConcern, writeConcern, - * and/or readPreference properly implement inheritance. For each of these - * options, test that the function inherits the option from its source object - * (e.g., mongoc_collection_watch inherits readConcern from the collection), - * that the function uses the option from "opts" if present, and that "opts" - * overrides the option from the source object. - * - * listDatabases, listCollections, and listIndexes don't use any of these - * options, so don't test their helpers: - * - * mongoc_client_find_databases_with_opts - * mongoc_client_get_database_names_with_opts - * mongoc_database_find_collections_with_opts - * mongoc_database_get_collection_names_with_opts - * mongoc_collection_find_indexes_with_opts - */ - -/* kinds of options */ -typedef enum { - OPT_READ_CONCERN, - OPT_WRITE_CONCERN, - OPT_READ_PREFS, -} opt_type_t; - - -/* objects on which options can be set */ -typedef enum { - OPT_SOURCE_NONE = 0, - OPT_SOURCE_FUNC = 1 << 0, - OPT_SOURCE_COLL = 1 << 1, - OPT_SOURCE_DB = 1 << 2, - OPT_SOURCE_CLIENT = 1 << 3, -} opt_source_t; - - -/* for mongoc_bulk_operation_t tests */ -typedef bool (*bulk_op_t) (mongoc_bulk_operation_t *bulk, - bson_error_t *error, - bson_t *cmd /* OUT */); - - -struct _opt_inheritance_test_t; - - -typedef struct { - struct _opt_inheritance_test_t *test; - mongoc_client_t *client; - mongoc_database_t *db; - mongoc_collection_t *collection; - const mongoc_read_prefs_t *prefs; - const bson_t *opts; - /* find, aggregate, etc. store the cursor here while running */ - mongoc_cursor_t *cursor; - bson_error_t error; - /* allow func_with_opts_t functions to store data and destroy it later */ - void *data; - void (*destructor) (void *data); -} func_ctx_t; - - -typedef future_t *(func_with_opts_t) (func_ctx_t *ctx, bson_t *cmd); - - -typedef struct _opt_inheritance_test_t { - opt_source_t opt_source; - func_with_opts_t *func_with_opts; - const char *func_name; - opt_type_t opt_type; - int n_sections; - /* for mongoc_bulk_operation_t tests */ - bulk_op_t bulk_op; -} opt_inheritance_test_t; - - -static void -func_ctx_init (func_ctx_t *ctx, - opt_inheritance_test_t *test, - mongoc_client_t *client, - mongoc_database_t *db, - mongoc_collection_t *collection, - const mongoc_read_prefs_t *prefs, - const bson_t *opts) -{ - ASSERT (client); - - ctx->test = test; - ctx->client = client; - ctx->db = db; - ctx->collection = collection; - ctx->prefs = prefs; - ctx->opts = opts; - ctx->cursor = NULL; - memset (&ctx->error, 0, sizeof (ctx->error)); - ctx->data = NULL; - ctx->destructor = NULL; -} - - -static void -func_ctx_cleanup (func_ctx_t *ctx) -{ - mongoc_cursor_destroy (ctx->cursor); - if (ctx->destructor) { - ctx->destructor (ctx->data); - } -} - - -/* if type is e.g. "collection", set readConcern level collection, writeConcern - * w=collection, readPreference tags [{collection: "yes"}] */ -#define SET_OPT_PREAMBLE(_type) \ - mongoc_read_concern_t *rc = mongoc_read_concern_new (); \ - mongoc_write_concern_t *wc = mongoc_write_concern_new (); \ - mongoc_read_prefs_t *prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); \ - \ - mongoc_read_concern_set_level (rc, #_type); \ - mongoc_write_concern_set_wtag (wc, #_type); \ - mongoc_read_prefs_set_tags (prefs, tmp_bson ("[{'%s': 'yes'}]", #_type)) - -#define SET_OPT_CLEANUP \ - mongoc_read_concern_destroy (rc); \ - mongoc_write_concern_destroy (wc); \ - mongoc_read_prefs_destroy (prefs); - -#define SET_OPT(_type) \ - static void set_##_type##_opt (mongoc_##_type##_t *obj, \ - opt_type_t opt_type) \ - { \ - SET_OPT_PREAMBLE (_type); \ - \ - switch (opt_type) { \ - case OPT_READ_CONCERN: \ - mongoc_##_type##_set_read_concern (obj, rc); \ - break; \ - case OPT_WRITE_CONCERN: \ - mongoc_##_type##_set_write_concern (obj, wc); \ - break; \ - case OPT_READ_PREFS: \ - mongoc_##_type##_set_read_prefs (obj, prefs); \ - break; \ - default: \ - test_error ("invalid opt_type: %d", (int) opt_type); \ - } \ - \ - SET_OPT_CLEANUP; \ - } - -SET_OPT (client) -SET_OPT (database) -SET_OPT (collection) - - -static void -set_func_opt (bson_t *opts, - mongoc_read_prefs_t **prefs_ptr, - opt_type_t opt_type) -{ - SET_OPT_PREAMBLE (function); - - switch (opt_type) { - case OPT_READ_CONCERN: - BSON_ASSERT (mongoc_read_concern_append (rc, opts)); - break; - case OPT_WRITE_CONCERN: - BSON_ASSERT (mongoc_write_concern_append (wc, opts)); - break; - case OPT_READ_PREFS: - *prefs_ptr = mongoc_read_prefs_copy (prefs); - break; - default: - test_error ("invalid opt_type: %d", (int) opt_type); - } - - SET_OPT_CLEANUP; -} - - -/* add BSON we expect to be included in a command due to an inherited option. - * e.g., when "count" inherits readConcern from the DB, it should include - * readConcern: {level: 'database'} in the command body. */ -void -add_expected_opt (opt_source_t opt_source, opt_type_t opt_type, bson_t *cmd) -{ - const char *source_name; - bson_t *opt; - - if (opt_source & OPT_SOURCE_FUNC) { - source_name = "function"; - } else if (opt_source & OPT_SOURCE_COLL) { - source_name = "collection"; - } else if (opt_source & OPT_SOURCE_DB) { - source_name = "database"; - } else if (opt_source & OPT_SOURCE_CLIENT) { - source_name = "client"; - } else { - test_error ("opt_json called with OPT_SOURCE_NONE"); - } - - switch (opt_type) { - case OPT_READ_CONCERN: - opt = tmp_bson ("{'readConcern': {'level': '%s'}}", source_name); - break; - case OPT_WRITE_CONCERN: - opt = tmp_bson ("{'writeConcern': {'w': '%s'}}", source_name); - break; - case OPT_READ_PREFS: - opt = tmp_bson ( - "{'$readPreference': {'mode': 'secondary', 'tags': [{'%s': 'yes'}]}}", - source_name); - break; - default: - test_error ("invalid opt_type: %d", (int) opt_type); - } - - bson_concat (cmd, opt); -} - - -static const char * -opt_type_name (opt_type_t opt_type) -{ - switch (opt_type) { - case OPT_READ_CONCERN: - return "readConcern"; - case OPT_WRITE_CONCERN: - return "writeConcern"; - case OPT_READ_PREFS: - return "readPrefs"; - default: - test_error ("invalid opt_type: %d", (int) opt_type); - } -} - - -static void -cleanup_future (future_t *future) -{ - future_value_t v; - - BSON_ASSERT (future_wait (future)); - - v = future->return_value; - if (v.type == future_value_mongoc_change_stream_ptr_type) { - mongoc_change_stream_destroy (v.value.mongoc_change_stream_ptr_value); - } else if (v.type == future_value_char_ptr_ptr_type) { - bson_strfreev (v.value.char_ptr_ptr_value); - } - - future_destroy (future); -} - - -/********************************************************************** - * - * func_with_opts_t implementations for client - * - **********************************************************************/ - -static future_t * -client_read_cmd (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_INT32 (cmd, "foo", 1); - return future_client_read_command_with_opts (ctx->client, - "db", - tmp_bson ("{'foo': 1}"), - ctx->prefs, - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -client_write_cmd (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "foo", "collection"); - return future_client_write_command_with_opts ( - ctx->client, - "db", - tmp_bson ("{'foo': 'collection'}"), - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -client_read_write_cmd (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "foo", "collection"); - return future_client_read_write_command_with_opts ( - ctx->client, - "db", - tmp_bson ("{'foo': 'collection'}"), - ctx->prefs, - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -client_watch (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_INT32 (cmd, "aggregate", 1); - return future_client_watch (ctx->client, tmp_bson ("{}"), ctx->opts); -} - - -/********************************************************************** - * - * func_with_opts_t implementations for database - * - **********************************************************************/ - -static future_t * -db_drop (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_INT32 (cmd, "dropDatabase", 1); - return future_database_drop_with_opts (ctx->db, ctx->opts, &ctx->error); -} - - -static future_t * -db_read_cmd (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "foo", "db"); - return future_database_read_command_with_opts (ctx->db, - tmp_bson ("{'foo': 'db'}"), - ctx->prefs, - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -db_write_cmd (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "foo", "db"); - return future_database_write_command_with_opts ( - ctx->db, tmp_bson ("{'foo': 'db'}"), ctx->opts, NULL, &ctx->error); -} - - -static future_t * -db_read_write_cmd (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "foo", "db"); - return future_database_read_write_command_with_opts ( - ctx->db, - tmp_bson ("{'foo': 'db'}"), - ctx->prefs, - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -db_watch (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_INT32 (cmd, "aggregate", 1); - return future_database_watch (ctx->db, tmp_bson ("{}"), ctx->opts); -} - - -/********************************************************************** - * - * func_with_opts_t implementations for collection - * - **********************************************************************/ - -static future_t * -aggregate (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "aggregate", "collection"); - ctx->cursor = - mongoc_collection_aggregate (ctx->collection, - MONGOC_QUERY_NONE, - tmp_bson ("{'pipeline': [{'$out': 'foo'}]}"), - ctx->opts, - ctx->prefs); - - /* use ctx->data as the bson_t** out-param to mongoc_cursor_next () */ - return future_cursor_next (ctx->cursor, (const bson_t **) &ctx->data); -} - - -static future_t * -aggregate_raw_pipeline (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "aggregate", "collection"); - ctx->cursor = mongoc_collection_aggregate (ctx->collection, - MONGOC_QUERY_NONE, - tmp_bson ("[{'$out': 'foo'}]"), - ctx->opts, - ctx->prefs); - - /* use ctx->data as the bson_t** out-param to mongoc_cursor_next () */ - return future_cursor_next (ctx->cursor, (const bson_t **) &ctx->data); -} - - -static future_t * -collection_drop (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "drop", "collection"); - return future_collection_drop_with_opts ( - ctx->collection, ctx->opts, &ctx->error); -} - - -static future_t * -collection_read_cmd (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "foo", "collection"); - return future_collection_read_command_with_opts ( - ctx->collection, - tmp_bson ("{'foo': 'collection'}"), - ctx->prefs, - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -collection_read_write_cmd (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "foo", "collection"); - return future_collection_read_write_command_with_opts ( - ctx->collection, - tmp_bson ("{'foo': 'collection'}"), - NULL, - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -collection_write_cmd (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "foo", "collection"); - return future_collection_write_command_with_opts ( - ctx->collection, - tmp_bson ("{'foo': 'collection'}"), - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -collection_watch (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "aggregate", "collection"); - return future_collection_watch (ctx->collection, tmp_bson ("{}"), ctx->opts); -} - - -static future_t * -count (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "count", "collection"); - return future_collection_count_with_opts (ctx->collection, - MONGOC_QUERY_NONE, - NULL, - 0, - 0, - ctx->opts, - ctx->prefs, - &ctx->error); -} - - -static future_t * -count_documents (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "aggregate", "collection"); - return future_collection_count_documents (ctx->collection, - tmp_bson ("{}"), - ctx->opts, - ctx->prefs, - NULL, - &ctx->error); -} - - -static future_t * -create_index (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "createIndexes", "collection"); - return future_collection_create_index_with_opts ( - ctx->collection, tmp_bson ("{}"), NULL, ctx->opts, NULL, &ctx->error); -} - - -static future_t * -drop_index (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "dropIndexes", "collection"); - return future_collection_drop_index_with_opts ( - ctx->collection, "index name", ctx->opts, &ctx->error); -} - - -static future_t * -estimated_document_count (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "count", "collection"); - return future_collection_estimated_document_count ( - ctx->collection, ctx->opts, ctx->prefs, NULL, &ctx->error); -} - - -static future_t * -find (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "find", "collection"); - ctx->cursor = mongoc_collection_find_with_opts ( - ctx->collection, tmp_bson ("{}"), ctx->opts, ctx->prefs); - - /* use ctx->data as the bson_t** out-param to mongoc_cursor_next () */ - return future_cursor_next (ctx->cursor, (const bson_t **) &ctx->data); -} - - -static void -find_and_modify_cleanup (void *data) -{ - mongoc_find_and_modify_opts_destroy ((mongoc_find_and_modify_opts_t *) data); -} - - -static future_t * -find_and_modify (func_ctx_t *ctx, bson_t *cmd) -{ - mongoc_find_and_modify_opts_t *fam; - - BSON_APPEND_UTF8 (cmd, "findAndModify", "collection"); - fam = mongoc_find_and_modify_opts_new (); - bson_concat (&fam->extra, ctx->opts); - - /* destroy the mongoc_find_and_modify_opts_t later */ - ctx->data = fam; - ctx->destructor = find_and_modify_cleanup; - - return future_collection_find_and_modify_with_opts ( - ctx->collection, tmp_bson ("{}"), fam, NULL, &ctx->error); -} - - -/********************************************************************** - * - * func_with_opts_t implementations for collection write helpers - * - **********************************************************************/ - -static future_t * -delete_many (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "delete", "collection"); - BSON_ASSERT (!ctx->prefs); - return future_collection_delete_many ( - ctx->collection, tmp_bson ("{}"), ctx->opts, NULL, &ctx->error); -} - - -static future_t * -delete_one (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "delete", "collection"); - BSON_ASSERT (!ctx->prefs); - return future_collection_delete_one ( - ctx->collection, tmp_bson ("{}"), ctx->opts, NULL, &ctx->error); -} - - -static future_t * -insert_many (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "insert", "collection"); - BSON_ASSERT (!ctx->prefs); - /* the "array" of input documents must be a valid pointer, stage it here */ - ctx->data = tmp_bson ("{}"); - return future_collection_insert_many (ctx->collection, - (const bson_t **) &ctx->data, - 1, - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -insert_one (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "insert", "collection"); - BSON_ASSERT (!ctx->prefs); - return future_collection_insert_one ( - ctx->collection, tmp_bson ("{}"), ctx->opts, NULL, &ctx->error); -} - - -static future_t * -replace_one (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "update", "collection"); - BSON_ASSERT (!ctx->prefs); - return future_collection_replace_one (ctx->collection, - tmp_bson ("{}"), - tmp_bson ("{}"), - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -update_many (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "update", "collection"); - BSON_ASSERT (!ctx->prefs); - return future_collection_update_many (ctx->collection, - tmp_bson ("{}"), - tmp_bson ("{}"), - ctx->opts, - NULL, - &ctx->error); -} - - -static future_t * -update_one (func_ctx_t *ctx, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "update", "collection"); - BSON_ASSERT (!ctx->prefs); - return future_collection_update_one (ctx->collection, - tmp_bson ("{}"), - tmp_bson ("{}"), - ctx->opts, - NULL, - &ctx->error); -} - - -/********************************************************************** - * - * mongoc_bulk_operation_t test functions - * - **********************************************************************/ - -static void -bulk_operation_cleanup (void *data) -{ - mongoc_bulk_operation_destroy ((mongoc_bulk_operation_t *) data); -} - - -static future_t * -bulk_exec (func_ctx_t *ctx, bson_t *cmd) -{ - mongoc_bulk_operation_t *bulk; - bson_error_t error; - bool r; - - bulk = mongoc_collection_create_bulk_operation_with_opts (ctx->collection, - ctx->opts); - - ctx->data = bulk; - ctx->destructor = bulk_operation_cleanup; - - r = ctx->test->bulk_op (bulk, &error, cmd); - ASSERT_OR_PRINT (r, error); - - return future_bulk_operation_execute (bulk, NULL /* reply */, &ctx->error); -} - - -static bool -bulk_insert (mongoc_bulk_operation_t *bulk, bson_error_t *error, bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "insert", "collection"); - return mongoc_bulk_operation_insert_with_opts ( - bulk, tmp_bson ("{}"), NULL, error); -} - - -static bool -bulk_remove_many (mongoc_bulk_operation_t *bulk, - bson_error_t *error, - bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "delete", "collection"); - return mongoc_bulk_operation_remove_many_with_opts ( - bulk, tmp_bson ("{}"), NULL, error); -} - - -static bool -bulk_remove_one (mongoc_bulk_operation_t *bulk, - bson_error_t *error, - bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "delete", "collection"); - return mongoc_bulk_operation_remove_one_with_opts ( - bulk, tmp_bson ("{}"), NULL, error); -} - -static bool -bulk_replace_one (mongoc_bulk_operation_t *bulk, - bson_error_t *error, - bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "update", "collection"); - return mongoc_bulk_operation_replace_one_with_opts ( - bulk, tmp_bson ("{}"), tmp_bson ("{}"), NULL, error); -} - - -static bool -bulk_update_many (mongoc_bulk_operation_t *bulk, - bson_error_t *error, - bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "update", "collection"); - return mongoc_bulk_operation_update_many_with_opts ( - bulk, tmp_bson ("{}"), tmp_bson ("{}"), NULL, error); -} - - -static bool -bulk_update_one (mongoc_bulk_operation_t *bulk, - bson_error_t *error, - bson_t *cmd) -{ - BSON_APPEND_UTF8 (cmd, "update", "collection"); - return mongoc_bulk_operation_update_one_with_opts ( - bulk, tmp_bson ("{}"), tmp_bson ("{}"), NULL, error); -} - - -static void -test_func_inherits_opts (void *ctx) -{ - opt_inheritance_test_t *test = (opt_inheritance_test_t *) ctx; - - /* for example, test mongoc_collection_find_with_opts with no read pref, - * with a read pref set on the collection (OPT_SOURCE_COLL), with an explicit - * read pref (OPT_SOURCE_FUNC), or with one read pref on the collection and - * a different one passed explicitly */ - opt_source_t source_matrix[] = {OPT_SOURCE_NONE, - test->opt_source, - OPT_SOURCE_FUNC, - test->opt_source | OPT_SOURCE_FUNC}; - - size_t i; - func_ctx_t func_ctx; - mock_rs_t *rs; - mongoc_client_t *client; - mongoc_database_t *db; - mongoc_collection_t *collection; - bson_t opts = BSON_INITIALIZER; - mongoc_read_prefs_t *func_prefs = NULL; - future_t *future; - request_t *request; - bson_t cmd = BSON_INITIALIZER; - bool expect_secondary; - bson_error_t error; - - /* one primary, one secondary */ - rs = mock_rs_with_auto_hello (WIRE_VERSION_MAX, true, 1, 0); - /* we use read pref tags like "collection": "yes" to verify where the - * pref was inherited from; ensure all secondaries match all tags */ - mock_rs_tag_secondary (rs, - 0, - tmp_bson ("{'client': 'yes'," - " 'database': 'yes'," - " 'collection': 'yes'," - " 'function': 'yes'}")); - - mock_rs_run (rs); - - /* iterate over all combinations of options sources: e.g., an option set on - * collection and not function, on function not collection, both, neither */ - for (i = 0; i < sizeof (source_matrix) / (sizeof (opt_source_t)); i++) { - expect_secondary = false; - func_prefs = NULL; - bson_reinit (&cmd); - bson_reinit (&opts); - - client = test_framework_client_new_from_uri (mock_rs_get_uri (rs), NULL); - if (source_matrix[i] & OPT_SOURCE_CLIENT) { - set_client_opt (client, test->opt_type); - } - - db = mongoc_client_get_database (client, "database"); - if (source_matrix[i] & OPT_SOURCE_DB) { - set_database_opt (db, test->opt_type); - } - - collection = mongoc_database_get_collection (db, "collection"); - if (source_matrix[i] & OPT_SOURCE_COLL) { - set_collection_opt (collection, test->opt_type); - } - - if (source_matrix[i] & OPT_SOURCE_FUNC) { - set_func_opt (&opts, &func_prefs, test->opt_type); - } - - func_ctx_init ( - &func_ctx, test, client, db, collection, func_prefs, &opts); - - /* A warning is thrown if an aggregate command with $out attempts to write - * to a secondary */ - capture_logs (true); - /* func_with_opts creates expected "cmd", like {insert: 'collection'} */ - future = test->func_with_opts (&func_ctx, &cmd); - capture_logs (false); - - if (source_matrix[i] != OPT_SOURCE_NONE) { - add_expected_opt (source_matrix[i], test->opt_type, &cmd); - expect_secondary = test->opt_type == OPT_READ_PREFS; - } - - /* write commands send two OP_MSG sections */ - if (test->n_sections == 2) { - request = mock_rs_receives_msg (rs, 0, &cmd, tmp_bson ("{}")); - } else { - request = mock_rs_receives_msg (rs, 0, &cmd); - } - - if (expect_secondary) { - BSON_ASSERT (mock_rs_request_is_to_secondary (rs, request)); - } else { - BSON_ASSERT (mock_rs_request_is_to_primary (rs, request)); - } - - if (func_ctx.cursor) { - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': []}}"); - - BSON_ASSERT (!future_get_bool (future)); - future_destroy (future); - ASSERT_OR_PRINT (!mongoc_cursor_error (func_ctx.cursor, &error), - error); - } else { - reply_to_request_simple (request, "{'ok': 1}"); - cleanup_future (future); - } - - request_destroy (request); - mongoc_read_prefs_destroy (func_prefs); - func_ctx_cleanup (&func_ctx); - mongoc_collection_destroy (collection); - mongoc_database_destroy (db); - mongoc_client_destroy (client); - } - - bson_destroy (&cmd); - bson_destroy (&opts); - mock_rs_destroy (rs); -} - - -/* commands that send one OP_MSG section */ -#define OPT_TEST(_opt_source, _func, _opt_type) \ - { \ - OPT_SOURCE_##_opt_source, _func, #_func, OPT_##_opt_type, 1 \ - } - - -/* write commands commands that send two OP_MSG sections */ -#define OPT_WRITE_TEST(_func) \ - { \ - OPT_SOURCE_COLL, _func, #_func, OPT_WRITE_CONCERN, 2 \ - } - - -/* mongoc_bulk_operation_t functions */ -#define OPT_BULK_TEST(_bulk_op) \ - { \ - OPT_SOURCE_COLL, bulk_exec, #_bulk_op, OPT_WRITE_CONCERN, 2, _bulk_op \ - } - - -static opt_inheritance_test_t gInheritanceTests[] = { - /* - * client functions - */ - OPT_TEST (CLIENT, client_read_cmd, READ_CONCERN), - OPT_TEST (CLIENT, client_read_cmd, READ_PREFS), - /* read_write_command functions deliberately ignore read prefs */ - OPT_TEST (CLIENT, client_read_write_cmd, READ_CONCERN), - OPT_TEST (CLIENT, client_read_write_cmd, WRITE_CONCERN), - /* watch helpers don't take explicit readPref */ - OPT_TEST (CLIENT, client_watch, READ_CONCERN), - OPT_TEST (CLIENT, client_write_cmd, WRITE_CONCERN), - - /* - * database functions - */ - OPT_TEST (DB, db_drop, WRITE_CONCERN), - OPT_TEST (DB, db_read_cmd, READ_CONCERN), - OPT_TEST (DB, db_read_cmd, READ_PREFS), - OPT_TEST (DB, db_read_write_cmd, READ_CONCERN), - OPT_TEST (DB, db_read_write_cmd, WRITE_CONCERN), - OPT_TEST (DB, db_watch, READ_CONCERN), - OPT_TEST (DB, db_write_cmd, WRITE_CONCERN), - - /* - * collection functions - */ - OPT_TEST (COLL, aggregate, READ_CONCERN), - OPT_TEST (COLL, aggregate, READ_PREFS), - OPT_TEST (COLL, aggregate, WRITE_CONCERN), - OPT_TEST (COLL, aggregate_raw_pipeline, READ_CONCERN), - OPT_TEST (COLL, aggregate_raw_pipeline, READ_PREFS), - OPT_TEST (COLL, aggregate_raw_pipeline, WRITE_CONCERN), - OPT_TEST (COLL, collection_drop, WRITE_CONCERN), - OPT_TEST (COLL, collection_read_cmd, READ_CONCERN), - OPT_TEST (COLL, collection_read_cmd, READ_PREFS), - OPT_TEST (COLL, collection_read_write_cmd, READ_CONCERN), - OPT_TEST (COLL, collection_read_write_cmd, WRITE_CONCERN), - OPT_TEST (COLL, collection_watch, READ_CONCERN), - OPT_TEST (COLL, collection_write_cmd, WRITE_CONCERN), - OPT_TEST (COLL, count, READ_CONCERN), - OPT_TEST (COLL, count, READ_PREFS), - OPT_TEST (COLL, count_documents, READ_CONCERN), - OPT_TEST (COLL, count_documents, READ_PREFS), - OPT_TEST (COLL, create_index, WRITE_CONCERN), - OPT_TEST (COLL, drop_index, WRITE_CONCERN), - OPT_TEST (COLL, estimated_document_count, READ_CONCERN), - OPT_TEST (COLL, estimated_document_count, READ_PREFS), - OPT_TEST (COLL, find, READ_CONCERN), - OPT_TEST (COLL, find, READ_PREFS), - /* find_and_modify deliberately ignores collection read concern */ - OPT_TEST (COLL, find_and_modify, WRITE_CONCERN), - - /* - * collection write functions - */ - OPT_WRITE_TEST (delete_many), - OPT_WRITE_TEST (delete_one), - OPT_WRITE_TEST (insert_many), - OPT_WRITE_TEST (insert_one), - OPT_WRITE_TEST (replace_one), - OPT_WRITE_TEST (update_many), - OPT_WRITE_TEST (update_one), - - /* - * bulk operations - */ - OPT_BULK_TEST (bulk_insert), - OPT_BULK_TEST (bulk_remove_many), - OPT_BULK_TEST (bulk_remove_one), - OPT_BULK_TEST (bulk_replace_one), - OPT_BULK_TEST (bulk_update_many), - OPT_BULK_TEST (bulk_update_one), -}; - - -static void -install_inheritance_tests (TestSuite *suite, - opt_inheritance_test_t *tests, - size_t n) -{ - size_t i; - opt_inheritance_test_t *test; - char *name; - - for (i = 0; i < n; i++) { - test = &tests[i]; - name = bson_strdup_printf ( - "/inheritance/%s/%s", test->func_name, opt_type_name (test->opt_type)); - - TestSuite_AddFull (suite, - name, - test_func_inherits_opts, - NULL, - test, - TestSuite_CheckMockServerAllowed); - - bson_free (name); - } -} - - -void -test_opts_install (TestSuite *suite) -{ - install_inheritance_tests (suite, - gInheritanceTests, - sizeof (gInheritanceTests) / - sizeof (opt_inheritance_test_t)); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-primary-stepdown.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-primary-stepdown.c deleted file mode 100644 index 73674d85c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-primary-stepdown.c +++ /dev/null @@ -1,559 +0,0 @@ -// test-mongoc-primary-stepdown.c contains tests specified in: -// `Connections Survive Primary Step Down Tests`. See: -// https://github.com/mongodb/specifications/tree/db3114e957f7c0976a1af09882dbb46cb4a70049/source/connections-survive-step-down/tests - -#include "mongoc/mongoc.h" -#include "mongoc/mongoc-read-concern-private.h" -#include "mongoc/mongoc-util-private.h" -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-topology-private.h" - -#include "json-test.h" -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - -typedef struct { - // If `use_pooled` is true, a test is run with a `mongoc_client_t` obtained - // from a `mongoc_client_pool_t`. - bool use_pooled; -} test_ctx_t; - -static mongoc_uri_t * -_get_test_uri (void) -{ - mongoc_uri_t *uri; - - /* Use a URI with retryWrites off */ - uri = test_framework_get_uri (); - mongoc_uri_set_option_as_bool (uri, "retryWrites", false); - - return uri; -} - -static void -_setup_test_with_client (mongoc_client_t *client) -{ - mongoc_write_concern_t *wc; - mongoc_database_t *db; - mongoc_collection_t *coll; - bson_error_t error; - bson_t *opts; - - ASSERT (client); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_wmajority (wc, -1); - opts = bson_new (); - ASSERT (mongoc_write_concern_append (wc, opts)); - - /* Drop the "step-down.step-down" collection and re-create it */ - coll = mongoc_client_get_collection (client, "step-down", "step-down"); - if (!mongoc_collection_drop (coll, &error)) { - if (NULL == strstr (error.message, "ns not found")) { - ASSERT_OR_PRINT (false, error); - } - } - - db = mongoc_client_get_database (client, "step-down"); - mongoc_collection_destroy (coll); - coll = mongoc_database_create_collection (db, "step-down", opts, &error); - ASSERT_OR_PRINT (coll, error); - - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - mongoc_write_concern_destroy (wc); - bson_destroy (opts); -} - -static int -_connection_count (mongoc_client_t *client, uint32_t server_id) -{ - bson_error_t error; - bson_iter_t iter; - bson_iter_t child; - bson_t cmd = BSON_INITIALIZER; - bson_t reply; - bool res; - int conns; - - ASSERT (client); - - BSON_APPEND_INT32 (&cmd, "serverStatus", 1); - - res = mongoc_client_command_simple_with_server_id ( - client, "admin", &cmd, NULL, server_id, &reply, &error); - ASSERT_OR_PRINT (res, error); - - ASSERT (bson_iter_init (&iter, &reply)); - ASSERT ( - bson_iter_find_descendant (&iter, "connections.totalCreated", &child)); - conns = bson_iter_int32 (&child); - - bson_destroy (&cmd); - bson_destroy (&reply); - - return conns; -} - -typedef void (*_test_fn_t) (mongoc_client_t *); - -static void -_run_test_single_or_pooled (_test_fn_t test, bool use_pooled) -{ - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_client_pool_t *pool; - - uri = _get_test_uri (); - - if (!use_pooled) { - /* Run in single-threaded mode */ - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - _setup_test_with_client (client); - test (client); - mongoc_client_destroy (client); - } else { - /* Run in pooled mode */ - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - client = mongoc_client_pool_pop (pool); - _setup_test_with_client (client); - /* Wait one second to be assured that the RTT connection has been - * established as well. */ - _mongoc_usleep (1000 * 1000); - test (client); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } - - mongoc_uri_destroy (uri); -} - -static void -test_getmore_iteration (mongoc_client_t *client) -{ - mongoc_write_concern_t *wc; - mongoc_database_t *db; - mongoc_collection_t *coll; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_error_t error; - bson_t *insert; - bson_t *opts; - bool res; - int conn_count; - int i; - uint32_t primary_id; - - ASSERT (client); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_wmajority (wc, -1); - opts = bson_new (); - ASSERT (mongoc_write_concern_append (wc, opts)); - - coll = mongoc_client_get_collection (client, "step-down", "step-down"); - - db = mongoc_client_get_database (client, "admin"); - /* Store the primary ID. After step down, the primary may be a different - * server. We must execute serverStatus against the same server to check - * connection counts. */ - primary_id = - mongoc_topology_select_server_id (client->topology, - MONGOC_SS_WRITE, - NULL /* read prefs */, - NULL /* chosen read mode */, - NULL /* deprioritized servers */, - &error); - ASSERT_OR_PRINT (primary_id, error); - conn_count = _connection_count (client, primary_id); - - /* Insert 5 documents */ - for (i = 0; i < 5; i++) { - insert = bson_new (); - - bson_append_int32 (insert, "a", -1, i); - ASSERT (mongoc_collection_insert_one (coll, insert, opts, NULL, NULL)); - - bson_destroy (insert); - } - - /* Retrieve the first batch of 2 documents */ - cursor = - mongoc_collection_find_with_opts (coll, tmp_bson ("{}"), NULL, NULL); - - ASSERT (cursor); - ASSERT (mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_next (cursor, &doc)); - - /* Send a stepdown to the primary, ensure it succeeds */ - res = mongoc_database_command_simple ( - db, - tmp_bson ("{ 'replSetStepDown': 5, 'force': true}"), - NULL, - NULL, - &error); - ASSERT_OR_PRINT (res, error); - - /* Retrieve the next results from the cursor, - ensure it succeeds */ - ASSERT (mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_next (cursor, &doc)); - - /* Verify that no new connections have been created */ - ASSERT_CMPINT (conn_count, ==, _connection_count (client, primary_id)); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - mongoc_write_concern_destroy (wc); - bson_destroy (opts); -} - -static void -test_getmore_iteration_runner (void *ctx_void) -{ - test_ctx_t *ctx = ctx_void; - - /* Only run on 4.2 or higher */ - if (!test_framework_max_wire_version_at_least (8)) { - return; - } - - _run_test_single_or_pooled (test_getmore_iteration, ctx->use_pooled); -} - -static void -test_not_primary_keep_pool (mongoc_client_t *client) -{ - mongoc_database_t *db; - mongoc_collection_t *coll; - bson_error_t error; - bool res; - int conn_count; - uint32_t primary_id; - - ASSERT (client); - - /* Configure fail points */ - db = mongoc_client_get_database (client, "admin"); - /* Store the primary ID. After step down, the primary may be a different - * server. We must execute serverStatus against the same server to check - * connection counts. */ - primary_id = - mongoc_topology_select_server_id (client->topology, - MONGOC_SS_WRITE, - NULL /* read prefs */, - NULL /* chosen read mode */, - NULL /* deprioritized servers */, - &error); - ASSERT_OR_PRINT (primary_id, error); - conn_count = _connection_count (client, primary_id); - res = mongoc_database_command_simple ( - db, - tmp_bson ("{'configureFailPoint': 'failCommand', " - "'mode': {'times': 1}, " - "'data': {'failCommands': ['insert'], 'errorCode': 10107}}"), - NULL, - NULL, - &error); - ASSERT_OR_PRINT (res, error); - - /* Capture logs to swallow warnings about endSessions */ - capture_logs (true); - - coll = mongoc_client_get_collection (client, "step-down", "step-down"); - - /* Execute an insert, verify that it fails with 10107 */ - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'test': 1}"), NULL, NULL, &error); - ASSERT (!res); - ASSERT_CMPINT (error.code, ==, 10107); - ASSERT_CONTAINS (error.message, "failpoint"); - - /* Execute a second insert, verify that it succeeds */ - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'test': 1}"), NULL, NULL, &error); - ASSERT (res); - - /* Verify that the connection pool has not been cleared */ - ASSERT_CMPINT (conn_count, ==, _connection_count (client, primary_id)); - - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); -} - -static void -test_not_primary_keep_pool_runner (void *ctx_void) -{ - test_ctx_t *ctx = ctx_void; - - /* Only run on 4.2 and higher */ - if (!test_framework_max_wire_version_at_least (8)) { - return; - } - - _run_test_single_or_pooled (test_not_primary_keep_pool, ctx->use_pooled); -} - -static void -test_not_primary_reset_pool (mongoc_client_t *client) -{ - mongoc_database_t *db; - mongoc_collection_t *coll; - mongoc_read_prefs_t *read_prefs; - bson_error_t error; - bool res; - int conn_count; - uint32_t primary_id; - - ASSERT (client); - - /* Configure fail points */ - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - db = mongoc_client_get_database (client, "admin"); - /* Store the primary ID. After step down, the primary may be a different - * server. We must execute serverStatus against the same server to check - * connection counts. */ - primary_id = - mongoc_topology_select_server_id (client->topology, - MONGOC_SS_WRITE, - NULL /* read prefs */, - NULL /* chosen read mode */, - NULL /* deprioritized servers */, - &error); - ASSERT_OR_PRINT (primary_id, error); - conn_count = _connection_count (client, primary_id); - res = mongoc_database_command_simple ( - db, - tmp_bson ("{'configureFailPoint': 'failCommand', " - "'mode': {'times': 1}, " - "'data': {'failCommands': ['insert'], 'errorCode': 10107}}"), - read_prefs, - NULL, - &error); - ASSERT_OR_PRINT (res, error); - - /* Capture logs to swallow warnings about endSessions */ - capture_logs (true); - - coll = mongoc_client_get_collection (client, "step-down", "step-down"); - - /* Execute an insert, verify that it fails with 10107 */ - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'test': 1}"), NULL, NULL, &error); - ASSERT (!res); - ASSERT_CMPINT (error.code, ==, 10107); - ASSERT_CONTAINS (error.message, "failpoint"); - - /* Verify that the pool has been cleared */ - ASSERT_CMPINT ((conn_count + 1), ==, _connection_count (client, primary_id)); - - /* Execute an insert into the test collection and verify it succeeds */ - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'test': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (res, error); - - mongoc_read_prefs_destroy (read_prefs); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); -} - -static void -test_not_primary_reset_pool_runner (void *ctx_void) -{ - int64_t max_wire_version; - - test_ctx_t *ctx = ctx_void; - - /* Only run if version 4.0 */ - test_framework_get_max_wire_version (&max_wire_version); - if (max_wire_version != WIRE_VERSION_4_0) { - return; - } - - _run_test_single_or_pooled (test_not_primary_reset_pool, ctx->use_pooled); -} - -static void -test_shutdown_reset_pool (mongoc_client_t *client) -{ - mongoc_database_t *db; - mongoc_collection_t *coll; - mongoc_read_prefs_t *read_prefs; - bson_error_t error; - bool res; - int conn_count; - uint32_t primary_id; - - ASSERT (client); - - /* Configure fail points */ - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - db = mongoc_client_get_database (client, "admin"); - /* Store the primary ID. After step down, the primary may be a different - * server. We must execute serverStatus against the same server to check - * connection counts. */ - primary_id = - mongoc_topology_select_server_id (client->topology, - MONGOC_SS_WRITE, - NULL /* read prefs */, - NULL /* chosen read mode */, - NULL /* deprioritized servers */, - &error); - ASSERT_OR_PRINT (primary_id, error); - conn_count = _connection_count (client, primary_id); - res = mongoc_database_command_simple ( - db, - tmp_bson ("{'configureFailPoint': 'failCommand', " - "'mode': {'times': 1}, " - "'data': {'failCommands': ['insert'], 'errorCode': 91}}"), - read_prefs, - NULL, - &error); - ASSERT_OR_PRINT (res, error); - - coll = mongoc_client_get_collection (client, "step-down", "step-down"); - - /* Execute an insert, verify that it fails with 91 */ - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'test': 1}"), NULL, NULL, &error); - ASSERT (!res); - ASSERT_CMPINT (error.code, ==, 91); - ASSERT_CONTAINS (error.message, "failpoint"); - - /* Verify that the pool has been cleared */ - ASSERT_CMPINT ((conn_count + 1), ==, _connection_count (client, primary_id)); - - /* Execute an insert into the test collection and verify it succeeds */ - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'test': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (res, error); - - mongoc_read_prefs_destroy (read_prefs); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); -} - -static void -test_shutdown_reset_pool_runner (void *ctx_void) -{ - test_ctx_t *ctx = ctx_void; - - /* Only run if version >= 4.0 */ - if (!test_framework_max_wire_version_at_least (WIRE_VERSION_4_0)) { - return; - } - - _run_test_single_or_pooled (test_shutdown_reset_pool, ctx->use_pooled); -} - -static void -test_interrupted_shutdown_reset_pool (mongoc_client_t *client) -{ - mongoc_database_t *db; - mongoc_collection_t *coll; - mongoc_read_prefs_t *read_prefs; - bson_error_t error; - bool res; - int conn_count; - uint32_t primary_id; - - ASSERT (client); - - /* Configure fail points */ - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - db = mongoc_client_get_database (client, "admin"); - /* Store the primary ID. After step down, the primary may be a different - * server. We must execute serverStatus against the same server to check - * connection counts. */ - primary_id = - mongoc_topology_select_server_id (client->topology, - MONGOC_SS_WRITE, - NULL /* read prefs */, - NULL /* chosen read mode */, - NULL /* deprioritized servers */, - &error); - ASSERT_OR_PRINT (primary_id, error); - conn_count = _connection_count (client, primary_id); - res = mongoc_database_command_simple ( - db, - tmp_bson ("{'configureFailPoint': 'failCommand', " - "'mode': {'times': 1}, " - "'data': {'failCommands': ['insert'], 'errorCode': 11600}}"), - read_prefs, - NULL, - &error); - ASSERT_OR_PRINT (res, error); - - coll = mongoc_client_get_collection (client, "step-down", "step-down"); - - /* Execute an insert, verify that it fails with 11600 */ - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'test': 1}"), NULL, NULL, &error); - ASSERT (!res); - ASSERT_CMPINT (error.code, ==, 11600); - ASSERT_CONTAINS (error.message, "failpoint"); - - /* Verify that the pool has been cleared */ - ASSERT_CMPINT ((conn_count + 1), ==, _connection_count (client, primary_id)); - - /* Execute an insert into the test collection and verify it succeeds */ - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'test': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (res, error); - - mongoc_read_prefs_destroy (read_prefs); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); -} - -static void -test_interrupted_shutdown_reset_pool_runner (void *ctx_void) -{ - test_ctx_t *ctx = ctx_void; - - /* Only run if version >= 4.0 */ - if (!test_framework_max_wire_version_at_least (WIRE_VERSION_4_0)) { - return; - } - - _run_test_single_or_pooled (test_interrupted_shutdown_reset_pool, - ctx->use_pooled); -} - -void -test_primary_stepdown_install (TestSuite *suite) -{ - test_ctx_t single_ctx = {.use_pooled = false}; - test_ctx_t pooled_ctx = {.use_pooled = true}; - -#define TestPooledAndSingle(name, fn) \ - TestSuite_AddFull (suite, \ - name "/single", \ - fn, \ - NULL, \ - &single_ctx, \ - test_framework_skip_if_auth, \ - test_framework_skip_if_not_replset); \ - TestSuite_AddFull (suite, \ - name "/pooled", \ - fn, \ - NULL, \ - &pooled_ctx, \ - test_framework_skip_if_auth, \ - test_framework_skip_if_not_replset); - - TestPooledAndSingle ("/Stepdown/getmore", test_getmore_iteration_runner); - TestPooledAndSingle ("/Stepdown/not_primary_keep", - test_not_primary_keep_pool_runner); - TestPooledAndSingle ("/Stepdown/not_primary_reset", - test_not_primary_reset_pool_runner); - TestPooledAndSingle ("/Stepdown/shutdown_reset_pool", - test_shutdown_reset_pool_runner); - TestPooledAndSingle ("/Stepdown/interrupt_shutdown", - test_interrupted_shutdown_reset_pool_runner); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-read-concern.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-read-concern.c deleted file mode 100644 index 7b7b557df..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-read-concern.c +++ /dev/null @@ -1,240 +0,0 @@ -#include "mongoc/mongoc.h" -#include "mongoc/mongoc-read-concern-private.h" -#include "mongoc/mongoc-util-private.h" - -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "mock_server/future.h" -#include "mock_server/mock-server.h" -#include "mock_server/future-functions.h" - - -static void -test_read_concern_append (void) -{ - mongoc_read_concern_t *rc; - bson_t *cmd; - - cmd = tmp_bson ("{'foo': 1}"); - - /* append default readConcern */ - rc = mongoc_read_concern_new (); - ASSERT (mongoc_read_concern_is_default (rc)); - ASSERT_MATCH (cmd, "{'foo': 1, 'readConcern': {'$exists': false}}"); - - /* append readConcern with level */ - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_LOCAL); - ASSERT (mongoc_read_concern_append (rc, cmd)); - - ASSERT_MATCH (cmd, "{'foo': 1, 'readConcern': {'level': 'local'}}"); - - mongoc_read_concern_destroy (rc); -} - -static void -test_read_concern_basic (void) -{ - mongoc_read_concern_t *read_concern; - - read_concern = mongoc_read_concern_new (); - - BEGIN_IGNORE_DEPRECATIONS; - - /* - * Test defaults. - */ - ASSERT (read_concern); - ASSERT (mongoc_read_concern_is_default (read_concern)); - ASSERT (!mongoc_read_concern_get_level (read_concern)); - - /* - * Test changes to level. - */ - mongoc_read_concern_set_level (read_concern, - MONGOC_READ_CONCERN_LEVEL_LOCAL); - ASSERT (!mongoc_read_concern_is_default (read_concern)); - ASSERT_CMPSTR (mongoc_read_concern_get_level (read_concern), - MONGOC_READ_CONCERN_LEVEL_LOCAL); - - /* - * Check generated bson. - */ - ASSERT_MATCH (_mongoc_read_concern_get_bson (read_concern), - "{'level': 'local'}"); - - mongoc_read_concern_destroy (read_concern); -} - - -static void -test_read_concern_bson_omits_defaults (void) -{ - mongoc_read_concern_t *read_concern; - const bson_t *bson; - bson_iter_t iter; - - read_concern = mongoc_read_concern_new (); - - /* - * Check generated bson. - */ - ASSERT (read_concern); - - bson = _mongoc_read_concern_get_bson (read_concern); - ASSERT (bson); - ASSERT (!bson_iter_init_find (&iter, bson, "level")); - - mongoc_read_concern_destroy (read_concern); -} - - -static void -test_read_concern_always_mutable (void) -{ - mongoc_read_concern_t *read_concern; - - read_concern = mongoc_read_concern_new (); - - ASSERT (read_concern); - - mongoc_read_concern_set_level (read_concern, - MONGOC_READ_CONCERN_LEVEL_LOCAL); - ASSERT_MATCH (_mongoc_read_concern_get_bson (read_concern), - "{'level': 'local'}"); - - mongoc_read_concern_set_level (read_concern, - MONGOC_READ_CONCERN_LEVEL_MAJORITY); - ASSERT_MATCH (_mongoc_read_concern_get_bson (read_concern), - "{'level': 'majority'}"); - - mongoc_read_concern_set_level (read_concern, - MONGOC_READ_CONCERN_LEVEL_LINEARIZABLE); - ASSERT_MATCH (_mongoc_read_concern_get_bson (read_concern), - "{'level': 'linearizable'}"); - - mongoc_read_concern_destroy (read_concern); -} - - -static void -_test_read_concern_wire_version (bool explicit) -{ - mongoc_read_concern_t *rc; - bson_t opts = BSON_INITIALIZER; - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - bson_error_t error; - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, "foo"); - - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - if (explicit) { - mongoc_read_concern_append (rc, &opts); - } else { - mongoc_client_set_read_concern (client, rc); - mongoc_collection_set_read_concern (collection, rc); - } - - /* - * aggregate - */ - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson (NULL), &opts, NULL); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'readConcern': {'level': 'foo'}}")); - reply_to_request_simple (request, - "{'ok': 1, 'cursor': {'id': 0, 'firstBatch': []}}"); - request_destroy (request); - BSON_ASSERT (future_wait (future)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - future_destroy (future); - - /* - * generic mongoc_client_write_command_with_opts - */ - future = future_client_read_command_with_opts ( - client, "db", tmp_bson ("{'foo': 1}"), NULL, &opts, NULL, &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'readConcern': {'level': 'foo'}}")); - reply_to_request_with_ok_and_destroy (request); - BSON_ASSERT (future_get_bool (future)); - - future_destroy (future); - - /* - * count - */ - future = future_collection_count_with_opts (collection, - MONGOC_QUERY_NONE, - tmp_bson ("{}"), - 0, - 0, - &opts, - NULL, - &error); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'readConcern': {'level': 'foo'}}")); - reply_to_request_simple (request, "{'ok': 1, 'n': 1}"); - request_destroy (request); - ASSERT_CMPINT64 (future_get_int64_t (future), ==, (int64_t) 1); - - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); - mongoc_read_concern_destroy (rc); - bson_destroy (&opts); -} - - -static void -test_inherited_read_concern (void) -{ - _test_read_concern_wire_version (false); -} - - -static void -test_explicit_read_concern (void) -{ - _test_read_concern_wire_version (true); -} - - -void -test_read_concern_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/ReadConcern/append", test_read_concern_append); - TestSuite_Add (suite, "/ReadConcern/basic", test_read_concern_basic); - TestSuite_Add (suite, - "/ReadConcern/bson_omits_defaults", - test_read_concern_bson_omits_defaults); - TestSuite_Add ( - suite, "/ReadConcern/always_mutable", test_read_concern_always_mutable); - TestSuite_AddMockServerTest ( - suite, "/ReadConcern/inherited", test_inherited_read_concern); - TestSuite_AddMockServerTest ( - suite, "/ReadConcern/explicit", test_explicit_read_concern); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-read-prefs.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-read-prefs.c deleted file mode 100644 index 5e8c9713a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-read-prefs.c +++ /dev/null @@ -1,924 +0,0 @@ -#include -#include - -#include "TestSuite.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" -#include "mock_server/mock-rs.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - -static bool -_can_be_command (const char *query) -{ - return (!bson_empty (tmp_bson (query))); -} - - -static void -_test_op_msg (const mongoc_uri_t *uri, - mock_server_t *server, - const char *query_or_cmd, - mongoc_read_prefs_t *read_prefs, - const char *expected_find) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_t b = BSON_INITIALIZER; - future_t *future; - request_t *request; - - client = test_framework_client_new_from_uri (uri, NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - - cursor = mongoc_collection_find (collection, - MONGOC_QUERY_NONE, - 0, - 1, - 0, - tmp_bson (query_or_cmd), - NULL, - read_prefs); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg (server, 0, tmp_bson (expected_find)); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': [{'a': 1}]}}"); - - /* mongoc_cursor_next returned true */ - BSON_ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_destroy (&b); -} - - -static void -_test_command (const mongoc_uri_t *uri, - mock_server_t *server, - const char *command, - mongoc_read_prefs_t *read_prefs, - const char *expected_cmd) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_t b = BSON_INITIALIZER; - future_t *future; - request_t *request; - - client = test_framework_client_new_from_uri (uri, NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - mongoc_collection_set_read_prefs (collection, read_prefs); - - cursor = mongoc_collection_command (collection, - MONGOC_QUERY_NONE, - 0, - 1, - 0, - tmp_bson (command), - NULL, - read_prefs); - - future = future_cursor_next (cursor, &doc); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson (expected_cmd)); - - reply_to_request (request, - MONGOC_REPLY_NONE, /* flags */ - 0, /* cursorId */ - 0, /* startingFrom */ - 1, /* numberReturned */ - "{'ok': 1}"); - - /* mongoc_cursor_next returned true */ - BSON_ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_destroy (&b); -} - -static void -_test_command_simple (const mongoc_uri_t *uri, - mock_server_t *server, - const char *command, - mongoc_read_prefs_t *read_prefs, - const char *expected_cmd) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - future_t *future; - request_t *request; - - client = test_framework_client_new_from_uri (uri, NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - mongoc_collection_set_read_prefs (collection, read_prefs); - - future = future_client_command_simple ( - client, "test", tmp_bson (command), read_prefs, NULL, NULL); - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson (expected_cmd)); - - reply_to_request (request, - MONGOC_REPLY_NONE, /* flags */ - 0, /* cursorId */ - 0, /* startingFrom */ - 1, /* numberReturned */ - "{'ok': 1}"); - - /* mongoc_cursor_next returned true */ - BSON_ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -typedef enum { - READ_PREF_TEST_STANDALONE, - READ_PREF_TEST_MONGOS, - READ_PREF_TEST_PRIMARY, - READ_PREF_TEST_SECONDARY, -} read_pref_test_type_t; - - -static mock_server_t * -_run_server (read_pref_test_type_t test_type) -{ - mock_server_t *server; - - server = mock_server_new (); - mock_server_run (server); - - switch (test_type) { - case READ_PREF_TEST_STANDALONE: - mock_server_auto_hello (server, - "{'ok': 1," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'isWritablePrimary': true}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - break; - case READ_PREF_TEST_MONGOS: - mock_server_auto_hello (server, - "{'ok': 1," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'isWritablePrimary': true," - " 'msg': 'isdbgrid'}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - break; - case READ_PREF_TEST_PRIMARY: - mock_server_auto_hello (server, - "{'ok': 1," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'isWritablePrimary': true," - " 'setName': 'rs'," - " 'hosts': ['%s']}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX, - mock_server_get_host_and_port (server)); - break; - case READ_PREF_TEST_SECONDARY: - mock_server_auto_hello (server, - "{'ok': 1," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'isWritablePrimary': false," - " 'secondary': true," - " 'setName': 'rs'," - " 'hosts': ['%s']}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX, - mock_server_get_host_and_port (server)); - break; - default: - test_error ("Invalid test_type: %d", (int) test_type); - } - - return server; -} - - -static mongoc_uri_t * -_get_uri (mock_server_t *server, read_pref_test_type_t test_type) -{ - mongoc_uri_t *uri; - - uri = mongoc_uri_copy (mock_server_get_uri (server)); - - switch (test_type) { - case READ_PREF_TEST_PRIMARY: - case READ_PREF_TEST_SECONDARY: - mongoc_uri_set_option_as_utf8 (uri, "replicaSet", "rs"); - break; - case READ_PREF_TEST_STANDALONE: - case READ_PREF_TEST_MONGOS: - default: - break; - } - - return uri; -} - - -static void -_test_read_prefs_op_msg (read_pref_test_type_t test_type, - mongoc_read_prefs_t *read_prefs, - const char *query_or_cmd, - const char *expected_cmd, - const char *expected_find) -{ - mock_server_t *server; - mongoc_uri_t *uri; - - server = _run_server (test_type); - uri = _get_uri (server, test_type); - - if (_can_be_command (query_or_cmd)) { - _test_command (uri, server, query_or_cmd, read_prefs, expected_cmd); - - _test_command_simple ( - uri, server, query_or_cmd, read_prefs, expected_cmd); - } - - _test_op_msg (uri, server, query_or_cmd, read_prefs, expected_find); - - mock_server_destroy (server); - mongoc_uri_destroy (uri); -} - - -static void -_test_read_prefs (read_pref_test_type_t test_type, - mongoc_read_prefs_t *read_prefs, - const char *query_or_cmd, - const char *expected_cmd, - const char *expected_find) -{ - _test_read_prefs_op_msg ( - test_type, read_prefs, query_or_cmd, expected_cmd, expected_find); -} - - -/* test that a NULL read pref is the same as PRIMARY */ -static void -test_read_prefs_standalone_null (void) -{ - _test_read_prefs_op_msg (READ_PREF_TEST_STANDALONE, - NULL, - "{}", - "{}", - "{ 'find': 'test', 'filter': {}, " - "'$readPreference': { '$exists': false } }"); - - _test_read_prefs_op_msg (READ_PREF_TEST_STANDALONE, - NULL, - "{'a': 1}", - "{'a': 1}", - "{ 'find': 'test', 'filter': {'a': 1}, " - "'$readPreference': { '$exists': false } }"); -} - -static void -test_read_prefs_standalone_primary (void) -{ - mongoc_read_prefs_t *read_prefs; - - /* Server Selection Spec: for topology type single and server types other - * than mongos, "clients MUST always set the secondaryOk wire protocol flag - * on reads to ensure that any server type can handle the request." - * */ - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - _test_read_prefs_op_msg (READ_PREF_TEST_STANDALONE, - read_prefs, - "{}", - "{}", - "{ 'find': 'test', 'filter': {}, " - "'$readPreference': { '$exists': false } }"); - - _test_read_prefs_op_msg (READ_PREF_TEST_STANDALONE, - read_prefs, - "{'a': 1}", - "{'a': 1}", - "{ 'find': 'test', 'filter': {'a': 1}, " - "'$readPreference': { '$exists': false } }"); - - mongoc_read_prefs_destroy (read_prefs); -} - - -static void -test_read_prefs_standalone_secondary (void) -{ - mongoc_read_prefs_t *read_prefs; - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - - _test_read_prefs_op_msg (READ_PREF_TEST_STANDALONE, - read_prefs, - "{}", - "{}", - "{ 'find': 'test', 'filter': {}, " - "'$readPreference': { '$exists': false } }"); - - _test_read_prefs_op_msg (READ_PREF_TEST_STANDALONE, - read_prefs, - "{'a': 1}", - "{'a': 1}", - "{ 'find': 'test', 'filter': {'a': 1}, " - "'$readPreference': { '$exists': false } }"); - - mongoc_read_prefs_destroy (read_prefs); -} - - -static void -test_read_prefs_standalone_tags (void) -{ - bson_t b = BSON_INITIALIZER; - mongoc_read_prefs_t *read_prefs; - - bson_append_utf8 (&b, "dc", 2, "ny", 2); - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY_PREFERRED); - mongoc_read_prefs_add_tag (read_prefs, &b); - mongoc_read_prefs_add_tag (read_prefs, NULL); - - _test_read_prefs_op_msg (READ_PREF_TEST_STANDALONE, - read_prefs, - "{}", - "{}", - "{ 'find': 'test', 'filter': {}, " - "'$readPreference': { '$exists': false } }"); - - _test_read_prefs_op_msg (READ_PREF_TEST_STANDALONE, - read_prefs, - "{'a': 1}", - "{'a': 1}", - "{ 'find': 'test', 'filter': {'a': 1}, " - "'$readPreference': { '$exists': false } }"); - - bson_destroy (&b); - mongoc_read_prefs_destroy (read_prefs); -} - - -static void -test_read_prefs_primary_rsprimary (void) -{ - mongoc_read_prefs_t *read_prefs; - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - _test_read_prefs (READ_PREF_TEST_PRIMARY, - read_prefs, - "{}", - "{}", - "{'find': 'test', 'filter': {}}"); - - _test_read_prefs (READ_PREF_TEST_PRIMARY, - read_prefs, - "{'a': 1}", - "{'a': 1}", - "{'find': 'test', 'filter': {'a': 1}}"); - - mongoc_read_prefs_destroy (read_prefs); -} - - -static void -test_read_prefs_secondary_rssecondary (void) -{ - mongoc_read_prefs_t *read_prefs; - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - - _test_read_prefs (READ_PREF_TEST_SECONDARY, - read_prefs, - "{}", - "{}", - "{'find': 'test', 'filter': {}}"); - - _test_read_prefs (READ_PREF_TEST_SECONDARY, - read_prefs, - "{'a': 1}", - "{'a': 1}", - "{'find': 'test', 'filter': {'a': 1}}"); - - mongoc_read_prefs_destroy (read_prefs); -} - - -/* test that a NULL read pref is the same as PRIMARY */ -static void -test_read_prefs_mongos_null (void) -{ - _test_read_prefs (READ_PREF_TEST_MONGOS, - NULL, - "{}", - "{}", - "{'find': 'test', 'filter': {}}"); - - _test_read_prefs (READ_PREF_TEST_MONGOS, - NULL, - "{'a': 1}", - "{'a': 1}", - "{'find': 'test', 'filter': {}}"); -} - - -static void -test_read_prefs_mongos_primary (void) -{ - mongoc_read_prefs_t *read_prefs; - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - _test_read_prefs (READ_PREF_TEST_MONGOS, - read_prefs, - "{}", - "{}", - "{'find': 'test', 'filter': {}}"); - - _test_read_prefs (READ_PREF_TEST_MONGOS, - read_prefs, - "{'a': 1}", - "{'a': 1}", - "{'find': 'test', 'filter': {'a': 1}}"); - - mongoc_read_prefs_destroy (read_prefs); -} - - -static void -test_read_prefs_mongos_secondary (void) -{ - mongoc_read_prefs_t *read_prefs; - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - - _test_read_prefs_op_msg ( - READ_PREF_TEST_MONGOS, - read_prefs, - "{}", - "{'find': 'test','$readPreference': {'mode': 'secondary'}}", - "{'find': 'test', 'filter': {}," - " '$readPreference': {'mode': 'secondary'}}"); - - _test_read_prefs_op_msg ( - READ_PREF_TEST_MONGOS, - read_prefs, - "{'a': 1}", - "{'a': 1, '$readPreference': {'mode': 'secondary'}}", - "{'find': 'test', 'filter': {'a': 1}," - " '$readPreference': {'mode': 'secondary'}}"); - - _test_read_prefs_op_msg ( - READ_PREF_TEST_MONGOS, - read_prefs, - "{'$query': {'a': 1}}", - "{'$query': {'a': 1}, '$readPreference': {'mode': 'secondary'}}", - "{'find': 'test', 'filter': {'a': 1}," - " '$readPreference': {'mode': 'secondary'}}"); - - mongoc_read_prefs_destroy (read_prefs); -} - - -static void -test_read_prefs_mongos_secondary_preferred (void) -{ - mongoc_read_prefs_t *read_prefs; - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY_PREFERRED); - - /* $readPreference not sent, only secondaryOk */ - _test_read_prefs (READ_PREF_TEST_MONGOS, - read_prefs, - "{}", - "{}", - "{'find': 'test', 'filter': {}}"); - - _test_read_prefs (READ_PREF_TEST_MONGOS, - read_prefs, - "{'a': 1}", - "{'a': 1}", - "{'find': 'test', 'filter': {'a': 1}}"); - - mongoc_read_prefs_destroy (read_prefs); -} - - -static void -test_read_prefs_mongos_tags (void) -{ - bson_t b = BSON_INITIALIZER; - mongoc_read_prefs_t *read_prefs; - - bson_append_utf8 (&b, "dc", 2, "ny", 2); - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY_PREFERRED); - mongoc_read_prefs_add_tag (read_prefs, &b); - mongoc_read_prefs_add_tag (read_prefs, NULL); - - _test_read_prefs_op_msg ( - READ_PREF_TEST_MONGOS, - read_prefs, - "{}", - "{'$query': {}, '$readPreference': {'mode': 'secondaryPreferred'," - " 'tags': [{'dc': 'ny'}, {}]}}", - "{'find': 'test', 'filter': {}," - " '$readPreference': {'mode': 'secondaryPreferred'," - " 'tags': [{'dc': 'ny'}, {}]}}"); - - _test_read_prefs_op_msg ( - READ_PREF_TEST_MONGOS, - read_prefs, - "{'a': 1}", - "{'a': 1," - " '$readPreference': {'mode': 'secondaryPreferred'," - " 'tags': [{'dc': 'ny'}, {}]}}", - "{'find': 'test', 'filter': {}," - " '$readPreference': {'mode': 'secondaryPreferred'," - " 'tags': [{'dc': 'ny'}, {}]}}"); - - mongoc_read_prefs_destroy (read_prefs); - bson_destroy (&b); -} - - -/* CDRIVER-3633 - test read prefs are sent when maxStalenessSeconds is set */ -static void -test_read_prefs_mongos_max_staleness (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_read_prefs_t *prefs; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY_PREFERRED); - mongoc_read_prefs_set_max_staleness_seconds (prefs, 120); - - /* exhaust cursor is required per CDRIVER-3633 so the driver downgrades the - * OP_QUERY find command to an OP_QUERY legacy find */ - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{'a': 1}"), tmp_bson ("{'exhaust': true}"), prefs); - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_query ( - server, - "test.test", - MONGOC_QUERY_EXHAUST | MONGOC_QUERY_SECONDARY_OK, - 0, - 0, - "{'$query': {'a': 1}," - " '$readPreference': {'mode': 'secondaryPreferred'," - " 'maxStalenessSeconds': 120}}", - "{}"); - - reply_to_find_request (request, - MONGOC_QUERY_EXHAUST | MONGOC_QUERY_SECONDARY_OK, - 0, - 1, - "test.test", - "{}", - false); - - /* mongoc_cursor_next returned true */ - BSON_ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_read_prefs_destroy (prefs); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -/* CDRIVER-3583 - support for server hedged reads */ -static void -test_read_prefs_mongos_hedged_reads (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_t hedge_doc = BSON_INITIALIZER; - mongoc_read_prefs_t *prefs; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - - server = mock_mongos_new (WIRE_VERSION_HEDGED_READS); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY_PREFERRED); - bson_append_bool (&hedge_doc, "enabled", 7, true); - - mongoc_read_prefs_set_hedge (prefs, &hedge_doc); - - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{'a': 1}"), tmp_bson ("{'exhaust': true}"), prefs); - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_EXHAUST_ALLOWED, - tmp_bson ("{'find': 'test'," - " 'filter': {'a': {'$numberInt': '1'}}," - " '$readPreference': {'mode': 'secondaryPreferred'," - " 'hedge': {'enabled': true}}}")); - reply_to_request_simple (request, - "{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}"); - mock_server_auto_endsessions (server); - - /* mongoc_cursor_next returned true */ - BSON_ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_read_prefs_destroy (prefs); - bson_destroy (&hedge_doc); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -/* test that we add readConcern only inside $query, not outside it too */ -static void -test_mongos_read_concern (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_read_prefs_t *prefs; - mongoc_cursor_t *cursor; - const bson_t *doc; - future_t *future; - request_t *request; - - server = mock_mongos_new (WIRE_VERSION_MIN); - mock_server_run (server); - mock_server_auto_endsessions (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "test", "test"); - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - cursor = mongoc_collection_find_with_opts ( - collection, - tmp_bson ("{'a': 1}"), - tmp_bson ("{'readConcern': {'level': 'foo'}}"), - prefs); - - future = future_cursor_next (cursor, &doc); - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'test'," - " 'find': 'test'," - " 'filter': {}," - " 'readConcern': {'level': 'foo'}," - " '$readPreference': {'mode': 'secondary'}," - " 'readConcern': {'level': 'foo'}}")); - - reply_to_op_msg_request (request, - MONGOC_MSG_NONE, - tmp_bson ("{'ok': 1," - " 'cursor': {" - " 'id': {'$numberLong': '0'}," - " 'ns': 'db.collection'," - " 'firstBatch': [{}]}}")); - - /* mongoc_cursor_next returned true */ - BSON_ASSERT (future_get_bool (future)); - - request_destroy (request); - future_destroy (future); - mongoc_cursor_destroy (cursor); - mongoc_read_prefs_destroy (prefs); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -typedef mongoc_cursor_t *(*test_op_msg_direct_fn_t) (mongoc_collection_t *, - mongoc_read_prefs_t *); - - -/* direct connection to a secondary requires read pref primaryPreferred to - * avoid "not primary" error from server */ -static void -_test_op_msg_direct_connection (bool is_mongos, - test_op_msg_direct_fn_t fn, - const char *expected_cmd) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_read_prefs_t *prefs = NULL; - mongoc_cursor_t *cursor; - const bson_t *doc; - bson_t *cmd; - future_t *future; - request_t *request; - const char *reply; - int i; - - if (is_mongos) { - server = mock_mongos_new (WIRE_VERSION_MAX); - } else { - char *hello = bson_strdup_printf ("{'ok': 1.0," - " 'isWritablePrimary': true," - " 'setName': 'rs0'," - " 'secondary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - server = mock_server_new (); - mock_server_auto_hello (server, hello); - bson_free (hello); - } - - mock_server_auto_endsessions (server); - - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - for (i = 0; i < 2; i++) { - if (i == 1) { - /* user-supplied read preference primary makes no difference */ - prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - } - - cursor = fn (collection, prefs); - future = future_cursor_next (cursor, &doc); - cmd = tmp_bson (expected_cmd); - request = mock_server_receives_msg (server, 0, cmd); - reply = "{'ok': 1," - " 'cursor': {" - " 'id': 0," - " 'ns': 'db.collection'," - " 'firstBatch': [{'a': 1}]}}"; - - reply_to_request_simple (request, reply); - BSON_ASSERT (future_get_bool (future)); - future_destroy (future); - request_destroy (request); - mongoc_cursor_destroy (cursor); - mongoc_read_prefs_destroy (prefs); /* null ok */ - } - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static mongoc_cursor_t * -find (mongoc_collection_t *collection, mongoc_read_prefs_t *prefs) -{ - return mongoc_collection_find_with_opts ( - collection, tmp_bson ("{}"), NULL /* opts */, prefs); -} - - -static mongoc_cursor_t * -aggregate (mongoc_collection_t *collection, mongoc_read_prefs_t *prefs) -{ - return mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson ("{}"), NULL /* opts */, prefs); -} - - -/* direct connection to a secondary requires read pref primaryPreferred to - * avoid "not primary" error from server */ -static void -test_op_msg_direct_secondary (void) -{ - _test_op_msg_direct_connection ( - false /* is_mongos */, - find, - "{" - " 'find': 'collection'," - " '$readPreference': {'mode': 'primaryPreferred'}" - "}"); - - _test_op_msg_direct_connection ( - false /* is_mongos */, - aggregate, - "{" - " 'aggregate': 'collection'," - " '$readPreference': {'mode': 'primaryPreferred'}" - "}"); -} - - -/* direct connection to mongos must not auto-add read pref primaryPreferred */ -static void -test_op_msg_direct_mongos (void) -{ - _test_op_msg_direct_connection (true /* is_mongos */, - find, - "{" - " 'find': 'collection'," - " '$readPreference': {'$exists': false}" - "}"); - - _test_op_msg_direct_connection (true /* is_mongos */, - aggregate, - "{" - " 'aggregate': 'collection'," - " '$readPreference': {'$exists': false}" - "}"); -} - - -void -test_read_prefs_install (TestSuite *suite) -{ - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/standalone/null", test_read_prefs_standalone_null); - TestSuite_AddMockServerTest (suite, - "/ReadPrefs/standalone/primary", - test_read_prefs_standalone_primary); - TestSuite_AddMockServerTest (suite, - "/ReadPrefs/standalone/secondary", - test_read_prefs_standalone_secondary); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/standalone/tags", test_read_prefs_standalone_tags); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/rsprimary/primary", test_read_prefs_primary_rsprimary); - TestSuite_AddMockServerTest (suite, - "/ReadPrefs/rssecondary/secondary", - test_read_prefs_secondary_rssecondary); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/mongos/null", test_read_prefs_mongos_null); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/mongos/primary", test_read_prefs_mongos_primary); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/mongos/secondary", test_read_prefs_mongos_secondary); - TestSuite_AddMockServerTest (suite, - "/ReadPrefs/mongos/secondaryPreferred", - test_read_prefs_mongos_secondary_preferred); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/mongos/tags", test_read_prefs_mongos_tags); - TestSuite_AddMockServerTest (suite, - "/ReadPrefs/mongos/maxStaleness", - test_read_prefs_mongos_max_staleness); - TestSuite_AddMockServerTest (suite, - "/ReadPrefs/mongos/hedgedReads", - test_read_prefs_mongos_hedged_reads); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/mongos/readConcern", test_mongos_read_concern); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/OP_MSG/secondary", test_op_msg_direct_secondary); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/OP_MSG/mongos", test_op_msg_direct_mongos); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-retryability-helpers.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-retryability-helpers.c deleted file mode 100644 index 12f5b9ac6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-retryability-helpers.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "test-mongoc-retryability-helpers.h" - -#include - -#include "mongoc-array-private.h" - -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "TestSuite.h" - -#include - -mongoc_array_t -_test_get_mongos_clients (const char **ports, size_t num_ports) -{ - bson_error_t error = {0}; - - mongoc_array_t clients; - _mongoc_array_init (&clients, sizeof (mongoc_client_t *)); - - for (size_t i = 0u; i < num_ports; ++i) { - const char *const port = ports[i]; - - char *const host_and_port = - bson_strdup_printf ("mongodb://localhost:%s", port); - char *const uri_str = - test_framework_add_user_password_from_env (host_and_port); - - mongoc_uri_t *const uri = mongoc_uri_new_with_error (uri_str, &error); - ASSERT_OR_PRINT (uri, error); - - mongoc_client_t *const client = - mongoc_client_new_from_uri_with_error (uri, &error); - ASSERT_OR_PRINT (client, error); - test_framework_set_ssl_opts (client); - - { - bson_t reply = BSON_INITIALIZER; - - ASSERT_OR_PRINT ( - mongoc_client_command_simple (client, - "admin", - tmp_bson ("{'hello': 1}"), - NULL, - &reply, - &error), - error); - - ASSERT_WITH_MSG ( - bson_has_field (&reply, "msg") && - strcmp (bson_lookup_utf8 (&reply, "msg"), "isdbgrid") == 0, - "expected a mongos on port %s", - port); - - bson_destroy (&reply); - } - - _mongoc_array_append_val (&clients, client); // Ownership transfer. - - mongoc_uri_destroy (uri); - - bson_free (host_and_port); - bson_free (uri_str); - } - - return clients; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-retryable-reads.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-retryable-reads.c deleted file mode 100644 index 97fb05679..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-retryable-reads.c +++ /dev/null @@ -1,704 +0,0 @@ -#include - -#include "mongoc/mongoc-collection-private.h" - -#include "json-test.h" -#include "test-libmongoc.h" -#include "mock_server/mock-rs.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "json-test-operations.h" -#include "test-mongoc-retryability-helpers.h" - -static bool -retryable_reads_test_run_operation (json_test_ctx_t *ctx, - const bson_t *test, - const bson_t *operation) -{ - bool *explicit_session = (bool *) ctx->config->ctx; - bson_t reply; - bson_iter_t iter; - const char *op_name; - uint32_t op_len; - bool res; - - bson_iter_init_find (&iter, operation, "name"); - op_name = bson_iter_utf8 (&iter, &op_len); - if (strcmp (op_name, "estimatedDocumentCount") == 0 || - strcmp (op_name, "count") == 0) { - /* CDRIVER-3612: mongoc_collection_estimated_document_count does not - * support explicit sessions */ - *explicit_session = false; - } - res = json_test_operation (ctx, - test, - operation, - ctx->collection, - *explicit_session ? ctx->sessions[0] : NULL, - &reply); - - bson_destroy (&reply); - - return res; -} - - -/* Callback for JSON tests from Retryable Reads Spec */ -static void -test_retryable_reads_cb (bson_t *scenario) -{ - bool explicit_session; - json_test_config_t config = JSON_TEST_CONFIG_INIT; - - /* use the context pointer to send "explicit_session" to the callback */ - config.ctx = &explicit_session; - config.run_operation_cb = retryable_reads_test_run_operation; - config.scenario = scenario; - config.command_started_events_only = true; - explicit_session = true; - run_json_general_test (&config); - explicit_session = false; - run_json_general_test (&config); -} - - -static void -_set_failpoint (mongoc_client_t *client) -{ - bson_error_t error; - bson_t *cmd = - tmp_bson ("{'configureFailPoint': 'failCommand'," - " 'mode': {'times': 1}," - " 'data': {'errorCode': 10107, 'failCommands': ['count']}}"); - - ASSERT (client); - - ASSERT_OR_PRINT ( - mongoc_client_command_simple (client, "admin", cmd, NULL, NULL, &error), - error); -} -/* Test code paths for all command helpers */ -static void -test_cmd_helpers (void *ctx) -{ - mongoc_uri_t *uri; - mongoc_client_t *client; - uint32_t server_id; - mongoc_collection_t *collection; - bson_t *cmd; - bson_t reply; - bson_error_t error; - bson_iter_t iter; - mongoc_cursor_t *cursor; - mongoc_database_t *database; - const bson_t *doc; - - BSON_UNUSED (ctx); - - uri = test_framework_get_uri (); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYREADS, true); - - client = test_framework_client_new_from_uri (uri, NULL); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - test_framework_set_ssl_opts (client); - mongoc_uri_destroy (uri); - - /* clean up in case a previous test aborted */ - server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (server_id, error); - deactivate_fail_points (client, server_id); - - collection = get_test_collection (client, "retryable_reads"); - database = mongoc_client_get_database (client, "test"); - - if (!mongoc_collection_drop (collection, &error)) { - if (NULL == strstr (error.message, "ns not found")) { - /* an error besides ns not found */ - ASSERT_OR_PRINT (false, error); - } - } - - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - collection, tmp_bson ("{'_id': 0}"), NULL, NULL, &error), - error); - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - collection, tmp_bson ("{'_id': 1}"), NULL, NULL, &error), - error); - - cmd = tmp_bson ("{'count': '%s'}", collection->collection); - - /* read helpers must retry. */ - _set_failpoint (client); - ASSERT_OR_PRINT (mongoc_client_read_command_with_opts ( - client, "test", cmd, NULL, NULL, &reply, &error), - error); - bson_iter_init_find (&iter, &reply, "n"); - ASSERT (bson_iter_as_int64 (&iter) == 2); - bson_destroy (&reply); - - _set_failpoint (client); - ASSERT_OR_PRINT (mongoc_database_read_command_with_opts ( - database, cmd, NULL, NULL, &reply, &error), - error); - bson_iter_init_find (&iter, &reply, "n"); - ASSERT (bson_iter_as_int64 (&iter) == 2); - bson_destroy (&reply); - - _set_failpoint (client); - ASSERT_OR_PRINT (mongoc_collection_read_command_with_opts ( - collection, cmd, NULL, NULL, &reply, &error), - error); - bson_iter_init_find (&iter, &reply, "n"); - ASSERT (bson_iter_as_int64 (&iter) == 2); - bson_destroy (&reply); - - /* TODO: once CDRIVER-3314 is resolved, test the read+write helpers. */ - - /* read/write agnostic command_simple helpers must not retry. */ - _set_failpoint (client); - ASSERT ( - !mongoc_client_command_simple (client, "test", cmd, NULL, NULL, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 10107, "Failing command"); - - _set_failpoint (client); - ASSERT (!mongoc_database_command_simple (database, cmd, NULL, NULL, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 10107, "Failing command"); - - _set_failpoint (client); - ASSERT ( - !mongoc_collection_command_simple (collection, cmd, NULL, NULL, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 10107, "Failing command"); - - - /* read/write agnostic command_with_opts helpers must not retry. */ - _set_failpoint (client); - ASSERT (!mongoc_client_command_with_opts ( - client, "test", cmd, NULL, NULL, NULL, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 10107, "Failing command"); - - _set_failpoint (client); - ASSERT (!mongoc_database_command_with_opts ( - database, cmd, NULL, NULL, NULL, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 10107, "Failing command"); - - _set_failpoint (client); - ASSERT (!mongoc_collection_command_with_opts ( - collection, cmd, NULL, NULL, NULL, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 10107, "Failing command"); - - /* read/write agnostic command_simple_with_server_id helper must not retry. - */ - server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (server_id, error); - _set_failpoint (client); - ASSERT (!mongoc_client_command_simple_with_server_id ( - client, "test", cmd, NULL, server_id, NULL, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 10107, "Failing command"); - - - /* deprecated command helpers (which goes through cursor logic) function must - * not retry. */ - _set_failpoint (client); - cursor = mongoc_client_command ( - client, "test", MONGOC_QUERY_NONE, 0, 1, 1, cmd, NULL, NULL); - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 10107, "Failing command"); - mongoc_cursor_destroy (cursor); - - _set_failpoint (client); - cursor = mongoc_database_command ( - database, MONGOC_QUERY_NONE, 0, 1, 1, cmd, NULL, NULL); - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 10107, "Failing command"); - mongoc_cursor_destroy (cursor); - - _set_failpoint (client); - cursor = mongoc_collection_command ( - collection, MONGOC_QUERY_NONE, 0, 1, 1, cmd, NULL, NULL); - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 10107, "Failing command"); - mongoc_cursor_destroy (cursor); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - deactivate_fail_points (client, server_id); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_retry_reads_off (void *ctx) -{ - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_collection_t *collection; - uint32_t server_id; - bson_t *cmd; - bson_error_t error; - bool res; - - BSON_UNUSED (ctx); - - uri = test_framework_get_uri (); - mongoc_uri_set_option_as_bool (uri, "retryreads", false); - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - - /* clean up in case a previous test aborted */ - server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (server_id, error); - deactivate_fail_points (client, server_id); - - collection = get_test_collection (client, "retryable_reads"); - - cmd = tmp_bson ("{'configureFailPoint': 'failCommand'," - " 'mode': {'times': 1}," - " 'data': {'errorCode': 10107, 'failCommands': ['count']}}"); - ASSERT_OR_PRINT (mongoc_client_command_simple_with_server_id ( - client, "admin", cmd, NULL, server_id, NULL, &error), - error); - - cmd = tmp_bson ("{'count': 'coll'}", collection->collection); - - res = mongoc_collection_read_command_with_opts ( - collection, cmd, NULL, NULL, NULL, &error); - ASSERT (!res); - ASSERT_CONTAINS (error.message, "failpoint"); - - deactivate_fail_points (client, server_id); - - mongoc_collection_destroy (collection); - mongoc_uri_destroy (uri); - mongoc_client_destroy (client); -} - -typedef struct _test_retry_reads_sharded_on_other_mongos_ctx { - int count; - uint16_t ports[2]; -} test_retry_reads_sharded_on_other_mongos_ctx; - -static void -_test_retry_reads_sharded_on_other_mongos_cb ( - const mongoc_apm_command_failed_t *event) -{ - BSON_ASSERT_PARAM (event); - - test_retry_reads_sharded_on_other_mongos_ctx *const ctx = - (test_retry_reads_sharded_on_other_mongos_ctx *) - mongoc_apm_command_failed_get_context (event); - BSON_ASSERT (ctx); - - ASSERT_WITH_MSG (ctx->count < 2, - "expected at most two failpoints to trigger"); - - const mongoc_host_list_t *const host = - mongoc_apm_command_failed_get_host (event); - BSON_ASSERT (host); - BSON_ASSERT (!host->next); - ctx->ports[ctx->count++] = host->port; -} - -// Retryable Reads Are Retried on a Different mongos if One is Available -static void -test_retry_reads_sharded_on_other_mongos (void *_ctx) -{ - BSON_UNUSED (_ctx); - - bson_error_t error = {0}; - - // Create two clients `s0` and `s1` that each connect to a single mongos from - // the sharded cluster. They must not connect to the same mongos. - const char *ports[] = {"27017", "27018"}; - const size_t num_ports = sizeof (ports) / sizeof (*ports); - mongoc_array_t clients = _test_get_mongos_clients (ports, num_ports); - BSON_ASSERT (clients.len == 2u); - mongoc_client_t *const s0 = - _mongoc_array_index (&clients, mongoc_client_t *, 0u); - mongoc_client_t *const s1 = - _mongoc_array_index (&clients, mongoc_client_t *, 1u); - BSON_ASSERT (s0 && s1); - - // Deprioritization cannot be deterministically asserted by this test due to - // randomized selection from suitable servers. Repeat the test a few times to - // increase the likelihood of detecting incorrect deprioritization behavior. - for (int i = 0; i < 10; ++i) { - // Configure the following fail point for both s0 and s1: - { - bson_t *const command = - tmp_bson ("{" - " 'configureFailPoint': 'failCommand'," - " 'mode': { 'times': 1 }," - " 'data': {" - " 'failCommands': ['find']," - " 'errorCode': 6" - " }" - "}"); - - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s0, "admin", command, NULL, NULL, &error), - error); - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s1, "admin", command, NULL, NULL, &error), - error); - } - - // Create a client client with `retryReads=true` that connects to the - // cluster with both mongoses used by `s0` and `s1` in the initial seed - // list. - mongoc_client_t *client = NULL; - { - const char *const host_and_port = - "mongodb://localhost:27017,localhost:27018/?retryReads=true"; - char *const uri_str = - test_framework_add_user_password_from_env (host_and_port); - mongoc_uri_t *const uri = mongoc_uri_new (uri_str); - - client = mongoc_client_new_from_uri_with_error (uri, &error); - ASSERT_OR_PRINT (client, error); - test_framework_set_ssl_opts (client); - - mongoc_uri_destroy (uri); - bson_free (uri_str); - } - BSON_ASSERT (client); - - { - test_retry_reads_sharded_on_other_mongos_ctx ctx = {0}; - - // Enable failed command event monitoring for client. - { - mongoc_apm_callbacks_t *const callbacks = - mongoc_apm_callbacks_new (); - mongoc_apm_set_command_failed_cb ( - callbacks, _test_retry_reads_sharded_on_other_mongos_cb); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - mongoc_apm_callbacks_destroy (callbacks); - } - - // Execute a `find` command with `client`. Assert that the command - // failed. - { - mongoc_database_t *const db = - mongoc_client_get_database (client, "db"); - mongoc_collection_t *const coll = - mongoc_database_get_collection (db, "test"); - mongoc_cursor_t *const cursor = mongoc_collection_find_with_opts ( - coll, tmp_bson ("{}"), NULL, NULL); - const bson_t *reply = NULL; - ASSERT_WITH_MSG (!mongoc_cursor_next (cursor, &reply), - "expected find command to fail"); - ASSERT_WITH_MSG (mongoc_cursor_error (cursor, &error), - "expected find command to fail"); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - } - - // Assert that two failed command events occurred. - ASSERT_WITH_MSG (ctx.count == 2, - "expected exactly 2 failpoints to trigger, but " - "observed %d with error: %s", - ctx.count, - error.message); - - // Assert that both events occurred on different mongoses. - ASSERT_WITH_MSG ((ctx.ports[0] == 27017 || ctx.ports[0] == 27018) && - (ctx.ports[1] == 27017 || ctx.ports[1] == 27018) && - (ctx.ports[0] != ctx.ports[1]), - "expected failpoints to trigger once on each mongos, " - "but observed failures on %d and %d", - ctx.ports[0], - ctx.ports[1]); - - mongoc_client_destroy (client); - } - - // Disable the fail point on both s0 and s1. - { - bson_t *const command = - tmp_bson ("{" - " 'configureFailPoint': 'failCommand'," - " 'mode': 'off'" - "}"); - - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s0, "admin", command, NULL, NULL, &error), - error); - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s1, "admin", command, NULL, NULL, &error), - error); - } - } - - mongoc_client_destroy (s0); - mongoc_client_destroy (s1); - _mongoc_array_destroy (&clients); -} - -typedef struct _test_retry_reads_sharded_on_same_mongos_ctx { - int failed_count; - int succeeded_count; - uint16_t failed_port; - uint16_t succeeded_port; -} test_retry_reads_sharded_on_same_mongos_ctx; - -static void -_test_retry_reads_sharded_on_same_mongos_cb ( - test_retry_reads_sharded_on_same_mongos_ctx *ctx, - const mongoc_apm_command_failed_t *failed, - const mongoc_apm_command_succeeded_t *succeeded) -{ - BSON_ASSERT_PARAM (ctx); - BSON_ASSERT (failed || true); - BSON_ASSERT (succeeded || true); - - ASSERT_WITH_MSG ( - ctx->failed_count + ctx->succeeded_count < 2, - "expected at most two events, but observed %d failed and %d succeeded", - ctx->failed_count, - ctx->succeeded_count); - - if (failed) { - ctx->failed_count += 1; - - const mongoc_host_list_t *const host = - mongoc_apm_command_failed_get_host (failed); - BSON_ASSERT (host); - BSON_ASSERT (!host->next); - ctx->failed_port = host->port; - } - - if (succeeded) { - ctx->succeeded_count += 1; - - const mongoc_host_list_t *const host = - mongoc_apm_command_succeeded_get_host (succeeded); - BSON_ASSERT (host); - BSON_ASSERT (!host->next); - ctx->succeeded_port = host->port; - } -} - -static void -_test_retry_reads_sharded_on_same_mongos_failed_cb ( - const mongoc_apm_command_failed_t *event) -{ - _test_retry_reads_sharded_on_same_mongos_cb ( - mongoc_apm_command_failed_get_context (event), event, NULL); -} - -static void -_test_retry_reads_sharded_on_same_mongos_succeeded_cb ( - const mongoc_apm_command_succeeded_t *event) -{ - _test_retry_reads_sharded_on_same_mongos_cb ( - mongoc_apm_command_succeeded_get_context (event), NULL, event); -} - -// Retryable Reads Are Retried on the Same mongos if No Others are Available -static void -test_retry_reads_sharded_on_same_mongos (void *_ctx) -{ - BSON_UNUSED (_ctx); - - bson_error_t error = {0}; - - // Create a client `s0` that connects to a single mongos from the cluster. - const char *ports[] = {"27017"}; - const size_t num_ports = sizeof (ports) / sizeof (*ports); - mongoc_array_t clients = _test_get_mongos_clients (ports, num_ports); - BSON_ASSERT (clients.len == 1u); - mongoc_client_t *const s0 = - _mongoc_array_index (&clients, mongoc_client_t *, 0u); - BSON_ASSERT (s0); - - // Configure the following fail point for `s0`: - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s0, - "admin", - tmp_bson ("{" - " 'configureFailPoint': 'failCommand'," - " 'mode': { 'times': 1 }," - " 'data': {" - " 'failCommands': ['find']," - " 'errorCode': 6" - " }" - "}"), - NULL, - NULL, - &error), - error); - - // Create a client client with `directConnection=false` (when not set by - // default) and `retryReads=true` that connects to the cluster using the same - // single mongos as `s0`. - mongoc_client_t *client = NULL; - { - const char *const host_and_port = - "mongodb://localhost:27017/?retryReads=true&directConnection=false"; - char *const uri_str = - test_framework_add_user_password_from_env (host_and_port); - mongoc_uri_t *const uri = mongoc_uri_new (uri_str); - - client = mongoc_client_new_from_uri_with_error (uri, &error); - ASSERT_OR_PRINT (client, error); - test_framework_set_ssl_opts (client); - - mongoc_uri_destroy (uri); - bson_free (uri_str); - } - BSON_ASSERT (client); - - { - test_retry_reads_sharded_on_same_mongos_ctx ctx = { - .failed_count = 0, - .succeeded_count = 0, - }; - - // Enable succeeded and failed command event monitoring for `client`. - { - mongoc_apm_callbacks_t *const callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_failed_cb ( - callbacks, _test_retry_reads_sharded_on_same_mongos_failed_cb); - mongoc_apm_set_command_succeeded_cb ( - callbacks, _test_retry_reads_sharded_on_same_mongos_succeeded_cb); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - mongoc_apm_callbacks_destroy (callbacks); - } - - // Execute a `find` command with `client`. Assert that the command - // succeeded. - { - mongoc_database_t *const db = - mongoc_client_get_database (client, "db"); - mongoc_collection_t *const coll = - mongoc_database_get_collection (db, "test"); - bson_t opts = BSON_INITIALIZER; - { - // Ensure drop from earlier is observed. - mongoc_read_concern_t *const rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, - MONGOC_READ_CONCERN_LEVEL_MAJORITY); - mongoc_read_concern_append (rc, &opts); - mongoc_read_concern_destroy (rc); - } - mongoc_cursor_t *const cursor = - mongoc_collection_find_with_opts (coll, &opts, NULL, NULL); - const bson_t *reply = NULL; - (void) mongoc_cursor_next (cursor, &reply); - ASSERT_WITH_MSG (!mongoc_cursor_error (cursor, &error), - "expecting find to succeed, but observed error: %s", - error.message); - mongoc_cursor_destroy (cursor); - bson_destroy (&opts); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - } - - // Avoid capturing additional events. - mongoc_client_set_apm_callbacks (client, NULL, NULL); - - // Assert that exactly one failed command event and one succeeded command - // event occurred. - ASSERT_WITH_MSG ( - ctx.failed_count == 1 && ctx.succeeded_count == 1, - "expected exactly one failed event and one succeeded " - "event, but observed %d failures and %d successes with error: %s", - ctx.failed_count, - ctx.succeeded_count, - ctx.succeeded_count > 1 ? "none" : error.message); - - // Assert that both events occurred on the same mongos. - ASSERT_WITH_MSG ( - ctx.failed_port == ctx.succeeded_port, - "expected failed and succeeded events on the same mongos, but " - "instead observed port %d (failed) and port %d (succeeded)", - ctx.failed_port, - ctx.succeeded_port); - - mongoc_client_destroy (client); - } - - // Disable the fail point on s0. - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s0, - "admin", - tmp_bson ("{" - " 'configureFailPoint': 'failCommand'," - " 'mode': 'off'" - "}"), - NULL, - NULL, - &error), - error); - - mongoc_client_destroy (s0); - _mongoc_array_destroy (&clients); -} - -/* - *----------------------------------------------------------------------- - * - * Runner for the JSON tests for retryable reads. - * - *----------------------------------------------------------------------- - */ -static void -test_all_spec_tests (TestSuite *suite) -{ - install_json_test_suite_with_check (suite, - JSON_DIR, - "retryable_reads/legacy", - test_retryable_reads_cb, - TestSuite_CheckLive, - test_framework_skip_if_no_failpoint, - test_framework_skip_if_slow); -} - -void -test_retryable_reads_install (TestSuite *suite) -{ - test_all_spec_tests (suite); - /* Since we need failpoints, require wire version 7 */ - TestSuite_AddFull (suite, - "/retryable_reads/cmd_helpers", - test_cmd_helpers, - NULL, - NULL, - test_framework_skip_if_max_wire_version_less_than_7, - test_framework_skip_if_mongos, - test_framework_skip_if_no_failpoint); - TestSuite_AddFull (suite, - "/retryable_reads/retry_off", - test_retry_reads_off, - NULL, - NULL, - test_framework_skip_if_max_wire_version_less_than_7, - test_framework_skip_if_mongos, - test_framework_skip_if_no_failpoint); - TestSuite_AddFull (suite, - "/retryable_reads/sharded/on_other_mongos", - test_retry_reads_sharded_on_other_mongos, - NULL, - NULL, - test_framework_skip_if_not_mongos, - test_framework_skip_if_no_failpoint, - // `retryReads=true` is a 4.2+ feature. - test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddFull (suite, - "/retryable_reads/sharded/on_same_mongos", - test_retry_reads_sharded_on_same_mongos, - NULL, - NULL, - test_framework_skip_if_not_mongos, - test_framework_skip_if_no_failpoint, - // `retryReads=true` is a 4.2+ feature. - test_framework_skip_if_max_wire_version_less_than_8); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-retryable-writes.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-retryable-writes.c deleted file mode 100644 index 4c9805069..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-retryable-writes.c +++ /dev/null @@ -1,1379 +0,0 @@ -#include - -#include "mongoc/mongoc-collection-private.h" - -#include "json-test.h" -#include "test-libmongoc.h" -#include "mock_server/mock-rs.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "json-test-operations.h" -#include "test-mongoc-retryability-helpers.h" - - -static bool -retryable_writes_test_run_operation (json_test_ctx_t *ctx, - const bson_t *test, - const bson_t *operation) -{ - bool *explicit_session = (bool *) ctx->config->ctx; - bson_t reply; - bool res; - - res = json_test_operation (ctx, - test, - operation, - ctx->collection, - *explicit_session ? ctx->sessions[0] : NULL, - &reply); - - bson_destroy (&reply); - - return res; -} - - -static test_skip_t skips[] = { - {"InsertOne fails after multiple retryable writeConcernErrors", - "Waiting on CDRIVER-3790"}, - {0}}; - -/* Callback for JSON tests from Retryable Writes Spec */ -static void -test_retryable_writes_cb (bson_t *scenario) -{ - bool explicit_session; - json_test_config_t config = JSON_TEST_CONFIG_INIT; - - config.skips = skips; - - /* use the context pointer to send "explicit_session" to the callback */ - config.ctx = &explicit_session; - config.run_operation_cb = retryable_writes_test_run_operation; - config.scenario = scenario; - config.command_started_events_only = true; - explicit_session = true; - run_json_general_test (&config); - explicit_session = false; - run_json_general_test (&config); -} - - -/* "Replica Set Failover Test" from Retryable Writes Spec */ -static void -test_rs_failover (void) -{ - mock_rs_t *rs; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_client_session_t *cs; - bson_t opts = BSON_INITIALIZER; - future_t *future; - request_t *request; - bson_error_t error; - bson_t *b = tmp_bson ("{}"); - - rs = mock_rs_with_auto_hello (WIRE_VERSION_MAX, - true /* has primary */, - 2 /* secondaries */, - 0 /* arbiters */); - - mock_rs_run (rs); - uri = mongoc_uri_copy (mock_rs_get_uri (rs)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYWRITES, true); - client = test_framework_client_new_from_uri (uri, NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - cs = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (cs, error); - ASSERT_OR_PRINT (mongoc_client_session_append (cs, &opts, &error), error); - - /* initial insert triggers replica set discovery */ - future = future_collection_insert_one (collection, b, &opts, NULL, &error); - request = - mock_rs_receives_msg (rs, 0, tmp_bson ("{'insert': 'collection'}"), b); - reply_to_request_with_ok_and_destroy (request); - BSON_ASSERT (future_get_bool (future)); - future_destroy (future); - - /* failover */ - mock_rs_stepdown (rs); - mock_rs_elect (rs, 1 /* server id */); - - /* insert receives "not primary" from old primary, reselects and retries */ - future = future_collection_insert_one ( - collection, tmp_bson ("{}"), &opts, NULL, &error); - - request = - mock_rs_receives_msg (rs, 0, tmp_bson ("{'insert': 'collection'}"), b); - BSON_ASSERT (mock_rs_request_is_to_secondary (rs, request)); - reply_to_request_simple (request, - "{" - " 'ok': 0," - " 'code': 10107," - " 'errmsg': 'not primary'," - " 'errorLabels': ['RetryableWriteError']" - "}"); - request_destroy (request); - - request = - mock_rs_receives_msg (rs, 0, tmp_bson ("{'insert': 'collection'}"), b); - BSON_ASSERT (mock_rs_request_is_to_primary (rs, request)); - reply_to_request_with_ok_and_destroy (request); - BSON_ASSERT (future_get_bool (future)); - future_destroy (future); - - bson_destroy (&opts); - mongoc_client_session_destroy (cs); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_rs_destroy (rs); -} - - -/* Test code paths for _mongoc_client_command_with_opts. - * This test requires a 3.6+ replica set to support the - * onPrimaryTransactionalWrite failpoint. */ -static void -test_command_with_opts (void *ctx) -{ - mongoc_uri_t *uri; - mongoc_client_t *client; - uint32_t server_id; - mongoc_collection_t *collection; - bson_t *cmd; - bson_t reply; - bson_t reply_result; - bson_error_t error; - - BSON_UNUSED (ctx); - - uri = test_framework_get_uri (); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYWRITES, true); - - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - mongoc_uri_destroy (uri); - - /* clean up in case a previous test aborted */ - server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (server_id, error); - deactivate_fail_points (client, server_id); - - collection = get_test_collection (client, "retryable_writes"); - - if (!mongoc_collection_drop (collection, &error)) { - if (NULL == strstr (error.message, "ns not found")) { - /* an error besides ns not found */ - ASSERT_OR_PRINT (false, error); - } - } - - ASSERT_OR_PRINT ( - mongoc_collection_insert_one ( - collection, tmp_bson ("{'_id':1, 'x': 1}"), NULL, NULL, &error), - error); - - cmd = tmp_bson ("{'configureFailPoint': 'onPrimaryTransactionalWrite'," - " 'mode': {'times': 1}," - " 'data': {'failBeforeCommitExceptionCode': 1}}"); - - ASSERT_OR_PRINT (mongoc_client_command_simple_with_server_id ( - client, "admin", cmd, NULL, server_id, NULL, &error), - error); - - cmd = tmp_bson ("{'findAndModify': '%s', 'query': {'_id': 1}, 'update': " - "{'$inc': {'x': 1}}, 'new': true}", - collection->collection); - - ASSERT_OR_PRINT (mongoc_collection_read_write_command_with_opts ( - collection, cmd, NULL, NULL, &reply, &error), - error); - - bson_lookup_doc (&reply, "value", &reply_result); - assert_match_bson (&reply_result, tmp_bson ("{'_id': 1, 'x': 2}"), false); - - deactivate_fail_points (client, server_id); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - bson_destroy (&reply_result); - bson_destroy (&reply); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_insert_one_unacknowledged (void) -{ - mongoc_uri_t *uri; - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_write_concern_t *wc; - bson_t opts = BSON_INITIALIZER; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_mongos_new (WIRE_VERSION_MAX); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYWRITES, true); - client = test_framework_client_new_from_uri (uri, NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - mongoc_write_concern_set_journal (wc, false); - mongoc_write_concern_append (wc, &opts); - - future = future_collection_insert_one ( - collection, tmp_bson ("{}"), &opts, NULL, &error); - - request = mock_server_receives_msg ( - server, - 2, /* set moreToCome bit in mongoc_op_msg_flags_t */ - tmp_bson ( - "{'txnNumber': {'$exists': false}, 'lsid': {'$exists': false}}"), - tmp_bson ("{}")); - ASSERT (future_get_bool (future)); - mock_server_auto_endsessions (server); - - mongoc_write_concern_destroy (wc); - mongoc_uri_destroy (uri); - request_destroy (request); - bson_destroy (&opts); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_update_one_unacknowledged (void) -{ - mongoc_uri_t *uri; - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_write_concern_t *wc; - bson_t opts = BSON_INITIALIZER; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_mongos_new (WIRE_VERSION_MAX); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYWRITES, true); - client = test_framework_client_new_from_uri (uri, NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - mongoc_write_concern_set_journal (wc, false); - mongoc_write_concern_append (wc, &opts); - - future = future_collection_update_one (collection, - tmp_bson ("{}"), - tmp_bson ("{'$set': {'x': 1}}"), - &opts, - NULL, - &error); - - request = mock_server_receives_msg ( - server, - 2, /* set moreToCome bit in mongoc_op_msg_flags_t */ - tmp_bson ( - "{'txnNumber': {'$exists': false}, 'lsid': {'$exists': false}}"), - tmp_bson ("{'q': {}, 'u': {'$set': {'x': 1}}}")); - ASSERT (future_get_bool (future)); - - mongoc_write_concern_destroy (wc); - mongoc_uri_destroy (uri); - request_destroy (request); - bson_destroy (&opts); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_delete_one_unacknowledged (void) -{ - mongoc_uri_t *uri; - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_write_concern_t *wc; - bson_t opts = BSON_INITIALIZER; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_mongos_new (WIRE_VERSION_MAX); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYWRITES, true); - client = test_framework_client_new_from_uri (uri, NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - mongoc_write_concern_set_journal (wc, false); - mongoc_write_concern_append (wc, &opts); - - future = future_collection_delete_one ( - collection, tmp_bson ("{}"), &opts, NULL, &error); - - request = mock_server_receives_msg ( - server, - 2, /* set moreToCome bit in mongoc_op_msg_flags_t */ - tmp_bson ( - "{'txnNumber': {'$exists': false}, 'lsid': {'$exists': false}}"), - tmp_bson ("{'q': {}, 'limit': 1}")); - ASSERT (future_get_bool (future)); - - mongoc_write_concern_destroy (wc); - mongoc_uri_destroy (uri); - request_destroy (request); - bson_destroy (&opts); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_bulk_operation_execute_unacknowledged (void) -{ - mongoc_uri_t *uri; - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_write_concern_t *wc; - mongoc_bulk_operation_t *bulk; - bson_t opts = BSON_INITIALIZER; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_mongos_new (WIRE_VERSION_MAX); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYWRITES, true); - client = test_framework_client_new_from_uri (uri, NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - mongoc_write_concern_set_journal (wc, false); - mongoc_write_concern_append (wc, &opts); - - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, &opts); - mongoc_bulk_operation_insert (bulk, tmp_bson ("{'_id': 1}")); - future = future_bulk_operation_execute (bulk, NULL, &error); - - request = mock_server_receives_msg ( - server, - 2, /* set moreToCome bit in mongoc_op_msg_flags_t */ - tmp_bson ( - "{'txnNumber': {'$exists': false}, 'lsid': {'$exists': false}}"), - tmp_bson ("{'_id': 1}")); - ASSERT (future_get_uint32_t (future) == 1); - - mongoc_write_concern_destroy (wc); - mongoc_uri_destroy (uri); - mongoc_bulk_operation_destroy (bulk); - request_destroy (request); - bson_destroy (&opts); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_remove_unacknowledged (void) -{ - mongoc_uri_t *uri; - mock_server_t *server; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_write_concern_t *wc; - bson_t opts = BSON_INITIALIZER; - future_t *future; - request_t *request; - bson_error_t error; - - server = mock_mongos_new (WIRE_VERSION_MAX); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYWRITES, true); - client = test_framework_client_new_from_uri (uri, NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - mongoc_write_concern_set_journal (wc, false); - - future = future_collection_remove ( - collection, MONGOC_REMOVE_NONE, tmp_bson ("{'a': 1}"), wc, &error); - - request = mock_server_receives_msg ( - server, - 2, /* set moreToCome bit in mongoc_op_msg_flags_t */ - tmp_bson ( - "{'txnNumber': {'$exists': false}, 'lsid': {'$exists': false}}"), - tmp_bson ("{'q': {'a': 1}, 'limit': 0}")); - ASSERT (future_get_bool (future)); - - mongoc_write_concern_destroy (wc); - mongoc_uri_destroy (uri); - request_destroy (request); - bson_destroy (&opts); - future_destroy (future); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - - -static void -test_retry_no_crypto (void *ctx) -{ - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_client_pool_t *pool; - - BSON_UNUSED (ctx); - - capture_logs (true); - - /* Test that no warning is logged if retryWrites is disabled. Warning logic - * is implemented in mongoc_topology_new, but test all public APIs that use - * the common code path. */ - client = test_framework_client_new ("mongodb://localhost/?retryWrites=false", - NULL); - BSON_ASSERT (client); - ASSERT_NO_CAPTURED_LOGS ("test_framework_client_new and retryWrites=false"); - mongoc_client_destroy (client); - - uri = mongoc_uri_new ("mongodb://localhost/?retryWrites=false"); - BSON_ASSERT (uri); - - client = test_framework_client_new_from_uri (uri, NULL); - BSON_ASSERT (client); - ASSERT_NO_CAPTURED_LOGS ( - "test_framework_client_new_from_uri and retryWrites=false"); - mongoc_client_destroy (client); - - pool = test_framework_client_pool_new_from_uri (uri, NULL); - BSON_ASSERT (pool); - ASSERT_NO_CAPTURED_LOGS ( - "test_framework_client_pool_new_from_uri and retryWrites=false"); - mongoc_client_pool_destroy (pool); - - mongoc_uri_destroy (uri); - - /* Test that a warning is logged if retryWrites is enabled. */ - client = - test_framework_client_new ("mongodb://localhost/?retryWrites=true", NULL); - BSON_ASSERT (client); - ASSERT_CAPTURED_LOG ( - "test_framework_client_new and retryWrites=true", - MONGOC_LOG_LEVEL_WARNING, - "retryWrites not supported without an SSL crypto library"); - mongoc_client_destroy (client); - - clear_captured_logs (); - - uri = mongoc_uri_new ("mongodb://localhost/?retryWrites=true"); - BSON_ASSERT (uri); - - client = test_framework_client_new_from_uri (uri, NULL); - BSON_ASSERT (client); - ASSERT_CAPTURED_LOG ( - "test_framework_client_new_from_uri and retryWrites=true", - MONGOC_LOG_LEVEL_WARNING, - "retryWrites not supported without an SSL crypto library"); - mongoc_client_destroy (client); - - clear_captured_logs (); - - pool = test_framework_client_pool_new_from_uri (uri, NULL); - BSON_ASSERT (pool); - ASSERT_CAPTURED_LOG ( - "test_framework_client_pool_new_from_uri and retryWrites=true", - MONGOC_LOG_LEVEL_WARNING, - "retryWrites not supported without an SSL crypto library"); - mongoc_client_pool_destroy (pool); - - mongoc_uri_destroy (uri); -} - -static void -test_unsupported_storage_engine_error (void) -{ - mock_rs_t *rs; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_t reply; - bson_error_t error; - future_t *future; - request_t *request; - mongoc_client_session_t *session; - bson_t opts; - const char *expected_msg = "This MongoDB deployment does not support " - "retryable writes. Please add retryWrites=false " - "to your connection string."; - - rs = mock_rs_with_auto_hello (WIRE_VERSION_MAX, true, 0, 0); - mock_rs_run (rs); - uri = mongoc_uri_copy (mock_rs_get_uri (rs)); - mongoc_uri_set_option_as_bool (uri, MONGOC_URI_RETRYWRITES, true); - client = test_framework_client_new_from_uri (uri, NULL); - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - coll = mongoc_client_get_collection (client, "test", "test"); - bson_init (&opts); - ASSERT_OR_PRINT (mongoc_client_session_append (session, &opts, &error), - error); - /* findandmodify is retryable through mongoc_client_write_command_with_opts. - */ - future = future_client_write_command_with_opts ( - client, - "test", - tmp_bson ("{'findandmodify': 'coll' }"), - &opts, - &reply, - &error); - request = mock_rs_receives_request (rs); - reply_to_request_simple ( - request, - "{'ok': 0, 'code': 20, 'errmsg': 'Transaction numbers are great'}"); - request_destroy (request); - - BSON_ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_SERVER, 20, expected_msg); - ASSERT_MATCH (&reply, "{'code': 20, 'errmsg': '%s'}", expected_msg); - - bson_destroy (&opts); - mongoc_client_session_destroy (session); - bson_destroy (&reply); - future_destroy (future); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_rs_destroy (rs); -} - -/* The following 3 tests check that the original reply and error is returned - * after encountering an error with a RetryableWriteError and a - * NoWritesPerformed label. The tests use the same callback function. - * - * Each test checks a different code path for retryable writes: - * mongoc_collection_insert_one, mongoc_client_command_simple, and - * mongoc_collection_find_and_modify_with_opts - * - * These tests require a >=6.0 replica set. - */ -typedef struct { - mongoc_client_t *client; - bool configure_second_fail; - char *failCommand; -} prose_test_3_apm_ctx_t; - -static void -prose_test_3_on_command_success (const mongoc_apm_command_succeeded_t *event) -{ - bson_iter_t iter; - bson_error_t error; - const bson_t *reply = mongoc_apm_command_succeeded_get_reply (event); - prose_test_3_apm_ctx_t *ctx = - mongoc_apm_command_succeeded_get_context (event); - - // wait for a writeConcernError and then set a second failpoint - if (bson_iter_init_find (&iter, reply, "writeConcernError") && - ctx->configure_second_fail) { - ctx->configure_second_fail = false; - ASSERT_OR_PRINT ( - mongoc_client_command_simple ( - ctx->client, - "admin", - tmp_bson ( - "{'configureFailPoint': 'failCommand', 'mode': {'times': 1}," - " 'data': { 'failCommands': ['%s'], 'errorCode': " - "10107, " - "'errorLabels': ['RetryableWriteError', 'NoWritesPerformed']}}", - ctx->failCommand), - NULL, - NULL, - &error), - error); - } -} - -static uint32_t -set_up_original_error_test (mongoc_apm_callbacks_t *callbacks, - prose_test_3_apm_ctx_t *apm_ctx, - char *failCommand, - mongoc_client_t *client) -{ - uint32_t server_id; - bson_error_t error; - - ASSERT (client); - - // clean up in case a previous test aborted - server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (server_id, error); - deactivate_fail_points (client, server_id); - - // set up callbacks for command monitoring - apm_ctx->client = client; - apm_ctx->failCommand = failCommand; - apm_ctx->configure_second_fail = true; - mongoc_apm_set_command_succeeded_cb (callbacks, - prose_test_3_on_command_success); - mongoc_client_set_apm_callbacks (client, callbacks, apm_ctx); - - // configure the first fail point - bool ret = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'configureFailPoint': 'failCommand', 'mode': {'times': 1}, " - "'data': {'failCommands': ['%s'], 'errorLabels': " - "['RetryableWriteError'], 'writeConcernError': {'code': 91 }}}", - failCommand), - NULL, - NULL, - &error); - ASSERT_OR_PRINT (ret, error); - - return server_id; -} - -static void -cleanup_original_error_test (mongoc_client_t *client, - uint32_t server_id, - bson_t *reply, - mongoc_collection_t *coll, - mongoc_apm_callbacks_t *callbacks) -{ - ASSERT (client); - - deactivate_fail_points (client, server_id); // disable the fail point - bson_destroy (reply); - mongoc_collection_destroy (coll); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_client_destroy (client); -} - -static void -retryable_writes_prose_test_3 (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_t reply; - bson_error_t error = {0}; - mongoc_apm_callbacks_t *callbacks = {0}; - prose_test_3_apm_ctx_t apm_ctx = {0}; - - BSON_UNUSED (ctx); - - // setting up the client - client = test_framework_new_default_client (); - coll = get_test_collection (client, "retryable_writes"); - callbacks = mongoc_apm_callbacks_new (); - - // setup test - const uint32_t server_id = - set_up_original_error_test (callbacks, &apm_ctx, "insert", client); - - // attempt an insertOne operation - ASSERT (!mongoc_collection_insert_one ( - coll, tmp_bson ("{'x': 1}"), NULL /* opts */, &reply, &error)); - - // writeConcernErrors are returned in the reply and not as an error - ASSERT_ERROR_CONTAINS (error, 0, 0, ""); - - // the reply holds the original error information - ASSERT_MATCH (&reply, - "{'insertedCount': 1, 'writeConcernErrors': [{ 'code': 91 }], " - "'errorLabels': ['RetryableWriteError']}"); - - cleanup_original_error_test (client, server_id, &reply, coll, callbacks); -} - - -static void -retryable_writes_original_error_find_modify (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_t reply; - bson_error_t error = {0}; - mongoc_apm_callbacks_t *callbacks = {0}; - prose_test_3_apm_ctx_t apm_ctx = {0}; - mongoc_find_and_modify_opts_t *opts; - - BSON_UNUSED (ctx); - - // setting up the client - client = test_framework_new_default_client (); - coll = get_test_collection (client, "retryable_writes"); - callbacks = mongoc_apm_callbacks_new (); - - // setup the test - const uint32_t server_id = - set_up_original_error_test (callbacks, &apm_ctx, "findAndModify", client); - - // setup for findAndModify - bson_t query = BSON_INITIALIZER; - BSON_APPEND_UTF8 (&query, "x", "1"); - bson_t *update = BCON_NEW ("$inc", "{", "x", BCON_INT32 (1), "}"); - opts = mongoc_find_and_modify_opts_new (); - mongoc_find_and_modify_opts_set_update (opts, update); - - // attempt a findAndModify operation - ASSERT (!mongoc_collection_find_and_modify_with_opts ( - coll, &query, opts, &reply, &error)); - - // assert error contains a writeConcernError with original error code - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_WRITE_CONCERN, 91, ""); - - // the reply holds the original error information - ASSERT_MATCH ( - &reply, - "{'lastErrorObject' : { 'n': 0, 'updatedExisting' : false }, 'value' : " - "null, 'writeConcernError' : { 'code': 91 }, 'errorLabels' : [ " - "'RetryableWriteError' ], 'ok' : 1.0}"); - - cleanup_original_error_test (client, server_id, &reply, coll, callbacks); - mongoc_find_and_modify_opts_destroy (opts); - bson_destroy (&query); - bson_destroy (update); -} - -static void -retryable_writes_original_error_general_command (void *ctx) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_t reply; - bson_error_t error = {0}; - mongoc_apm_callbacks_t *callbacks = {0}; - prose_test_3_apm_ctx_t apm_ctx = {0}; - - BSON_UNUSED (ctx); - - // setting up the client - client = test_framework_new_default_client (); - coll = get_test_collection (client, "retryable_writes"); - callbacks = mongoc_apm_callbacks_new (); - - // setup test - const uint32_t server_id = - set_up_original_error_test (callbacks, &apm_ctx, "insert", client); - - bson_t *cmd = BCON_NEW ("insert", - mongoc_collection_get_name (coll), - "documents", - "[", - "{", - "}", - "]"); - - // attempt an insert operation - ASSERT (!mongoc_client_write_command_with_opts ( - client, "test", cmd, NULL, &reply, &error)); - - // assert error contains a writeConcernError with original error code - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_WRITE_CONCERN, 91, ""); - - // the reply holds the original error information - ASSERT_MATCH (&reply, - "{'writeConcernError' : { 'code' : { '$numberInt' : '91' } }, " - "'errorLabels' : [ 'RetryableWriteError' ], 'ok': { " - "'$numberDouble' : '1.0' }}"); - - cleanup_original_error_test (client, server_id, &reply, coll, callbacks); - bson_destroy (cmd); -} - -/* - *----------------------------------------------------------------------- - * - * Runner for the JSON tests for retryable writes. - * - *----------------------------------------------------------------------- - */ -static void -test_all_spec_tests (TestSuite *suite) -{ - install_json_test_suite_with_check (suite, - JSON_DIR, - "retryable_writes/legacy", - test_retryable_writes_cb, - TestSuite_CheckLive, - test_framework_skip_if_no_crypto, - test_framework_skip_if_slow); -} - - -typedef struct { - int num_inserts; - int num_updates; -} _tracks_new_server_counters_t; - -static void -_tracks_new_server_cb (const mongoc_apm_command_started_t *event) -{ - const char *cmd_name; - _tracks_new_server_counters_t *counters; - - cmd_name = mongoc_apm_command_started_get_command_name (event); - counters = - (_tracks_new_server_counters_t *) mongoc_apm_command_started_get_context ( - event); - - if (0 == strcmp (cmd_name, "insert")) { - counters->num_inserts++; - } else if (0 == strcmp (cmd_name, "update")) { - counters->num_updates++; - } -} - -/* Tests that when a command within a bulk write succeeds after a retryable - * error, and selects a new server, it continues to use that server in - * subsequent commands. - * This test requires running against a replica set with at least one - * secondary. - */ -static void -test_bulk_retry_tracks_new_server (void *unused) -{ - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_bulk_operation_t *bulk; - bson_error_t error; - mongoc_read_prefs_t *read_prefs; - bool ret; - mongoc_server_description_t *sd; - mongoc_apm_callbacks_t *callbacks; - _tracks_new_server_counters_t counters = {0}; - - BSON_UNUSED (unused); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, _tracks_new_server_cb); - - client = test_framework_new_default_client (); - mongoc_client_set_apm_callbacks (client, callbacks, &counters); - collection = get_test_collection (client, "tracks_new_server"); - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - - /* The bulk write contains two operations, an insert, followed by an - * update. - */ - ret = mongoc_bulk_operation_insert_with_opts ( - bulk, tmp_bson ("{'x': 1}"), NULL /* opts */, &error); - ASSERT_OR_PRINT (ret, error); - mongoc_bulk_operation_update_one (bulk, - tmp_bson ("{}"), - tmp_bson ("{'$inc': {'x': 1}}"), - false /* upsert */); - - /* Explicitly tell the bulk write to use a secondary. That will result in - * a retryable error, causing the first command to be sent twice. */ - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - sd = mongoc_client_select_server ( - client, false /* for_writes */, read_prefs, &error); - ASSERT_OR_PRINT (sd, error); - mongoc_bulk_operation_set_hint (bulk, mongoc_server_description_id (sd)); - ret = mongoc_bulk_operation_execute (bulk, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - - /* The first insert fails with a retryable write error since it is sent to - * a secondary. The retry selects the primary and succeeds. The second - * command should use the newly selected server, so the update succeeds on - * the first try. */ - ASSERT_CMPINT (counters.num_inserts, ==, 2); - ASSERT_CMPINT (counters.num_updates, ==, 1); - ASSERT_CMPINT (mongoc_bulk_operation_get_hint (bulk), - !=, - mongoc_server_description_id (sd)); - - mongoc_apm_callbacks_destroy (callbacks); - mongoc_server_description_destroy (sd); - mongoc_read_prefs_destroy (read_prefs); - mongoc_bulk_operation_destroy (bulk); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -typedef struct _test_retry_writes_sharded_on_other_mongos_ctx { - int count; - uint16_t ports[2]; -} test_retry_writes_sharded_on_other_mongos_ctx; - -static void -_test_retry_writes_sharded_on_other_mongos_cb ( - const mongoc_apm_command_failed_t *event) -{ - BSON_ASSERT_PARAM (event); - - test_retry_writes_sharded_on_other_mongos_ctx *const ctx = - (test_retry_writes_sharded_on_other_mongos_ctx *) - mongoc_apm_command_failed_get_context (event); - BSON_ASSERT (ctx); - - ASSERT_WITH_MSG (ctx->count < 2, - "expected at most two failpoints to trigger"); - - const mongoc_host_list_t *const host = - mongoc_apm_command_failed_get_host (event); - BSON_ASSERT (host); - BSON_ASSERT (!host->next); - ctx->ports[ctx->count++] = host->port; -} - -// Test that in a sharded cluster writes are retried on a different mongos when -// one is available. -static void -retryable_writes_sharded_on_other_mongos (void *_ctx) -{ - BSON_UNUSED (_ctx); - - bson_error_t error = {0}; - - // Create two clients `s0` and `s1` that each connect to a single mongos from - // the sharded cluster. They must not connect to the same mongos. - const char *ports[] = {"27017", "27018"}; - const size_t num_ports = sizeof (ports) / sizeof (*ports); - mongoc_array_t clients = _test_get_mongos_clients (ports, num_ports); - BSON_ASSERT (clients.len == 2u); - mongoc_client_t *const s0 = - _mongoc_array_index (&clients, mongoc_client_t *, 0u); - mongoc_client_t *const s1 = - _mongoc_array_index (&clients, mongoc_client_t *, 1u); - BSON_ASSERT (s0 && s1); - - // Deprioritization cannot be deterministically asserted by this test due to - // randomized selection from suitable servers. Repeat the test a few times to - // increase the likelihood of detecting incorrect deprioritization behavior. - for (int i = 0; i < 10; ++i) { - // Configure the following fail point for both `s0` and `s1`: - { - bson_t *const command = - tmp_bson ("{" - " 'configureFailPoint': 'failCommand'," - " 'mode': { 'times': 1 }," - " 'data': {" - " 'failCommands': ['insert']," - " 'errorCode': 6," - " 'errorLabels': ['RetryableWriteError']" - " }" - "}"); - - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s0, "admin", command, NULL, NULL, &error), - error); - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s1, "admin", command, NULL, NULL, &error), - error); - } - - // Create a client `client` with `retryWrites=true` that connects to the - // cluster with both mongoses used by `s0` and `s1` in the initial seed - // list. - mongoc_client_t *client = NULL; - { - const char *const host_and_port = - "mongodb://localhost:27017,localhost:27018/?retryWrites=true"; - char *const uri_str = - test_framework_add_user_password_from_env (host_and_port); - mongoc_uri_t *const uri = mongoc_uri_new (uri_str); - - client = mongoc_client_new_from_uri_with_error (uri, &error); - ASSERT_OR_PRINT (client, error); - test_framework_set_ssl_opts (client); - - mongoc_uri_destroy (uri); - bson_free (uri_str); - } - BSON_ASSERT (client); - - { - test_retry_writes_sharded_on_other_mongos_ctx ctx = {0}; - - // Enable failed command event monitoring for `client`. - { - mongoc_apm_callbacks_t *const callbacks = - mongoc_apm_callbacks_new (); - mongoc_apm_set_command_failed_cb ( - callbacks, _test_retry_writes_sharded_on_other_mongos_cb); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - mongoc_apm_callbacks_destroy (callbacks); - } - - // Execute an `insert` command with `client`. Assert that the command - // failed. - { - mongoc_database_t *const db = - mongoc_client_get_database (client, "db"); - mongoc_collection_t *const coll = - mongoc_database_get_collection (db, "test"); - ASSERT_WITH_MSG ( - !mongoc_collection_insert_one ( - coll, tmp_bson ("{'x': 1}"), NULL, NULL, &error), - "expected insert command to fail"); - MONGOC_DEBUG ("insert error: %s", error.message); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - } - - // Assert that two failed command events occurred. - ASSERT_WITH_MSG (ctx.count == 2, - "expected exactly 2 failpoints to trigger, but " - "observed %d with error: %s", - ctx.count, - error.message); - - // Assert that the failed command events occurred on different - // mongoses. - ASSERT_WITH_MSG ((ctx.ports[0] == 27017 || ctx.ports[0] == 27018) && - (ctx.ports[1] == 27017 || ctx.ports[1] == 27018) && - (ctx.ports[0] != ctx.ports[1]), - "expected failpoints to trigger once on each mongos, " - "but observed failures on %d and %d", - ctx.ports[0], - ctx.ports[1]); - - mongoc_client_destroy (client); - } - - // Disable the fail points. - { - bson_t *const command = - tmp_bson ("{" - " 'configureFailPoint': 'failCommand'," - " 'mode': 'off'" - "}"); - - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s0, "admin", command, NULL, NULL, &error), - error); - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s1, "admin", command, NULL, NULL, &error), - error); - } - } - - mongoc_client_destroy (s0); - mongoc_client_destroy (s1); - _mongoc_array_destroy (&clients); -} - -typedef struct _test_retry_writes_sharded_on_same_mongos_ctx { - int failed_count; - int succeeded_count; - uint16_t failed_port; - uint16_t succeeded_port; -} test_retry_writes_sharded_on_same_mongos_ctx; - -static void -_test_retry_writes_sharded_on_same_mongos_cb ( - test_retry_writes_sharded_on_same_mongos_ctx *ctx, - const mongoc_apm_command_failed_t *failed, - const mongoc_apm_command_succeeded_t *succeeded) -{ - BSON_ASSERT_PARAM (ctx); - BSON_ASSERT (failed || true); - BSON_ASSERT (succeeded || true); - - ASSERT_WITH_MSG ( - ctx->failed_count + ctx->succeeded_count < 2, - "expected at most two events, but observed %d failed and %d succeeded", - ctx->failed_count, - ctx->succeeded_count); - - if (failed) { - ctx->failed_count += 1; - - const mongoc_host_list_t *const host = - mongoc_apm_command_failed_get_host (failed); - BSON_ASSERT (host); - BSON_ASSERT (!host->next); - ctx->failed_port = host->port; - } - - if (succeeded) { - ctx->succeeded_count += 1; - - const mongoc_host_list_t *const host = - mongoc_apm_command_succeeded_get_host (succeeded); - BSON_ASSERT (host); - BSON_ASSERT (!host->next); - ctx->succeeded_port = host->port; - } -} - -static void -_test_retry_writes_sharded_on_same_mongos_failed_cb ( - const mongoc_apm_command_failed_t *event) -{ - _test_retry_writes_sharded_on_same_mongos_cb ( - mongoc_apm_command_failed_get_context (event), event, NULL); -} - -static void -_test_retry_writes_sharded_on_same_mongos_succeeded_cb ( - const mongoc_apm_command_succeeded_t *event) -{ - _test_retry_writes_sharded_on_same_mongos_cb ( - mongoc_apm_command_succeeded_get_context (event), NULL, event); -} - -// Test that in a sharded cluster writes are retried on the same mongos when no -// others are available. -static void -retryable_writes_sharded_on_same_mongos (void *_ctx) -{ - BSON_UNUSED (_ctx); - - bson_error_t error = {0}; - - // Create a client `s0` that connects to a single mongos from the cluster. - const char *ports[] = {"27017"}; - const size_t num_ports = sizeof (ports) / sizeof (*ports); - mongoc_array_t clients = _test_get_mongos_clients (ports, num_ports); - BSON_ASSERT (clients.len == 1u); - mongoc_client_t *const s0 = - _mongoc_array_index (&clients, mongoc_client_t *, 0u); - BSON_ASSERT (s0); - - // Configure the following fail point for `s0`: - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s0, - "admin", - tmp_bson ("{" - " 'configureFailPoint': 'failCommand'," - " 'mode': { 'times': 1 }," - " 'data': {" - " 'failCommands': ['insert']," - " 'errorCode': 6," - " 'errorLabels': ['RetryableWriteError']" - " }" - "}"), - NULL, - NULL, - &error), - error); - - // Create a client client with `directConnection=false` (when not set by - // default) and `retryWrites=true` that connects to the cluster using the - // same single mongos as `s0`. - mongoc_client_t *client = NULL; - { - const char *const host_and_port = - "mongodb://localhost:27017/" - "?retryWrites=true&directConnection=false"; - char *const uri_str = - test_framework_add_user_password_from_env (host_and_port); - mongoc_uri_t *const uri = mongoc_uri_new (uri_str); - - client = mongoc_client_new_from_uri_with_error (uri, &error); - ASSERT_OR_PRINT (client, error); - test_framework_set_ssl_opts (client); - - mongoc_uri_destroy (uri); - bson_free (uri_str); - } - BSON_ASSERT (client); - - { - test_retry_writes_sharded_on_same_mongos_ctx ctx = { - .failed_count = 0, - .succeeded_count = 0, - }; - - // Enable succeeded and failed command event monitoring for `client`. - { - mongoc_apm_callbacks_t *const callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_failed_cb ( - callbacks, _test_retry_writes_sharded_on_same_mongos_failed_cb); - mongoc_apm_set_command_succeeded_cb ( - callbacks, _test_retry_writes_sharded_on_same_mongos_succeeded_cb); - mongoc_client_set_apm_callbacks (client, callbacks, &ctx); - mongoc_apm_callbacks_destroy (callbacks); - } - - // Execute an `insert` command with `client`. Assert that the command - // succeeded. - { - mongoc_database_t *const db = - mongoc_client_get_database (client, "db"); - mongoc_collection_t *const coll = - mongoc_database_get_collection (db, "test"); - ASSERT_WITH_MSG (mongoc_collection_insert_one ( - coll, tmp_bson ("{'x': 1}"), NULL, NULL, &error), - "expecting insert to succeed, but observed error: %s", - error.message); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - } - - // Avoid capturing additional events. - mongoc_client_set_apm_callbacks (client, NULL, NULL); - - // Assert that exactly one failed command event and one succeeded - // command event occurred. - ASSERT_WITH_MSG ( - ctx.failed_count == 1 && ctx.succeeded_count == 1, - "expected exactly one failed event and one succeeded " - "event, but observed %d failures and %d successes with error: %s", - ctx.failed_count, - ctx.succeeded_count, - ctx.succeeded_count > 1 ? "none" : error.message); - - // Assert that both events occurred on the same mongos. - ASSERT_WITH_MSG ( - ctx.failed_port == ctx.succeeded_port, - "expected failed and succeeded events on the same mongos, but " - "instead observed port %d (failed) and port %d (succeeded)", - ctx.failed_port, - ctx.succeeded_port); - - mongoc_client_destroy (client); - } - - // Disable the fail point. - ASSERT_OR_PRINT (mongoc_client_command_simple ( - s0, - "admin", - tmp_bson ("{" - " 'configureFailPoint': 'failCommand'," - " 'mode': 'off'" - "}"), - NULL, - NULL, - &error), - error); - - mongoc_client_destroy (s0); - _mongoc_array_destroy (&clients); -} - - -void -test_retryable_writes_install (TestSuite *suite) -{ - test_all_spec_tests (suite); - TestSuite_AddMockServerTest (suite, - "/retryable_writes/failover", - test_rs_failover, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/retryable_writes/command_with_opts", - test_command_with_opts, - NULL, - NULL, - test_framework_skip_if_not_replset); - TestSuite_AddMockServerTest (suite, - "/retryable_writes/insert_one_unacknowledged", - test_insert_one_unacknowledged, - test_framework_skip_if_no_crypto); - TestSuite_AddMockServerTest (suite, - "/retryable_writes/update_one_unacknowledged", - test_update_one_unacknowledged, - test_framework_skip_if_no_crypto); - TestSuite_AddMockServerTest (suite, - "/retryable_writes/delete_one_unacknowledged", - test_delete_one_unacknowledged, - test_framework_skip_if_no_crypto); - TestSuite_AddMockServerTest (suite, - "/retryable_writes/remove_unacknowledged", - test_remove_unacknowledged, - test_framework_skip_if_no_crypto); - TestSuite_AddMockServerTest ( - suite, - "/retryable_writes/bulk_operation_execute_unacknowledged", - test_bulk_operation_execute_unacknowledged, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/retryable_writes/no_crypto", - test_retry_no_crypto, - NULL, - NULL, - test_framework_skip_if_crypto); - TestSuite_AddMockServerTest ( - suite, - "/retryable_writes/unsupported_storage_engine_error", - test_unsupported_storage_engine_error, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/retryable_writes/bulk_tracks_new_server", - test_bulk_retry_tracks_new_server, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_not_replset, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/retryable_writes/prose_test_3", - retryable_writes_prose_test_3, - NULL, - NULL, - test_framework_skip_if_not_replset, - test_framework_skip_if_max_wire_version_less_than_17, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/retryable_writes/prose_test_3/find_modify", - retryable_writes_original_error_find_modify, - NULL, - NULL, - test_framework_skip_if_not_replset, - test_framework_skip_if_max_wire_version_less_than_17, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/retryable_writes/prose_test_3/general_command", - retryable_writes_original_error_general_command, - NULL, - NULL, - test_framework_skip_if_not_replset, - test_framework_skip_if_max_wire_version_less_than_17, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/retryable_writes/prose_test_4", - retryable_writes_sharded_on_other_mongos, - NULL, - NULL, - test_framework_skip_if_not_mongos, - test_framework_skip_if_no_failpoint, - // `errorLabels` is a 4.3.1+ feature. - test_framework_skip_if_max_wire_version_less_than_9, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/retryable_writes/prose_test_5", - retryable_writes_sharded_on_same_mongos, - NULL, - NULL, - test_framework_skip_if_not_mongos, - test_framework_skip_if_no_failpoint, - // `errorLabels` is a 4.3.1+ feature. - test_framework_skip_if_max_wire_version_less_than_9, - test_framework_skip_if_no_crypto); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-scram.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-scram.c deleted file mode 100644 index 99fff7b1c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-scram.c +++ /dev/null @@ -1,813 +0,0 @@ -#include -#include -#include -#include - -#include "mongoc/mongoc-crypto-private.h" -#include "mongoc/mongoc-scram-private.h" - -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - -#ifdef MONGOC_ENABLE_SSL -static void -test_mongoc_scram_step_username_not_set (void) -{ - mongoc_scram_t scram; - bool success; - uint8_t buf[4096] = {0}; - uint32_t buflen = 0; - bson_error_t error; - - _mongoc_scram_init (&scram, MONGOC_CRYPTO_ALGORITHM_SHA_1); - _mongoc_scram_set_pass (&scram, "password"); - - success = _mongoc_scram_step ( - &scram, buf, buflen, buf, sizeof buf, &buflen, &error); - - ASSERT (!success); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: username is not set"); - - _mongoc_scram_destroy (&scram); -} - -typedef struct { - const char *original; - const char *normalized; - bool should_be_required; - bool should_succeed; -} sasl_prep_testcase_t; - - -/* test that an error is reported if the server responds with an iteration - * count that is less than 4096 */ -static void -test_iteration_count (int count, bool should_succeed) -{ - mongoc_scram_t scram; - uint8_t buf[4096] = {0}; - uint32_t buflen = 0; - bson_error_t error; - const char *client_nonce = "YWJjZA=="; - char *server_response; - bool success; - - server_response = bson_strdup_printf ( - "r=YWJjZA==YWJjZA==,s=r6+P1iLmSJvhrRyuFi6Wsg==,i=%d", count); - /* set up the scram state to immediately test step 2. */ - _mongoc_scram_init (&scram, MONGOC_CRYPTO_ALGORITHM_SHA_1); - _mongoc_scram_set_pass (&scram, "password"); - bson_strncpy ( - scram.encoded_nonce, client_nonce, sizeof (scram.encoded_nonce)); - scram.encoded_nonce_len = (int32_t) strlen (client_nonce); - scram.auth_message = bson_malloc0 (4096); - scram.auth_messagemax = 4096; - /* prepare the server's "response" from step 1 as the input for step 2. */ - memcpy (buf, server_response, strlen (server_response) + 1); - buflen = (int32_t) strlen (server_response); - scram.step = 1; - success = _mongoc_scram_step ( - &scram, buf, buflen, buf, sizeof buf, &buflen, &error); - if (should_succeed) { - ASSERT_OR_PRINT (success, error); - } else { - BSON_ASSERT (!success); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SCRAM, - MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, - "SCRAM Failure: iterations must be at least 4096"); - } - bson_free (server_response); - _mongoc_scram_destroy (&scram); -} - -static void -test_mongoc_scram_iteration_count (void) -{ - test_iteration_count (1000, false); - test_iteration_count (4095, false); - test_iteration_count (4096, true); - test_iteration_count (10000, true); -} - -static void -test_mongoc_scram_sasl_prep (void) -{ - int i, ntests; - char *normalized; - bson_error_t err; - /* examples from RFC 4013 section 3. */ - sasl_prep_testcase_t tests[] = { - // normalization - {"\x65\xCC\x81", "\xC3\xA9", true, true}, - {"\xC2\xAA", "a", true, true}, - {"Henry \xE2\x85\xA3", "Henry IV", true, true}, - {"A\xEF\xAC\x83n", "Affin", true, true}, - // mapped to nothing character (Table B.1) - {"I\xC2\xADX", "IX", true, true}, - // mapped to nothing character (Table C.1.2) - {"I\xE2\x80\x80\xC2\xA0X", "I X", true, true}, - // prohibited character - {"banana \x07 apple", "(invalid)", true, false}, - // unassigned codepoint (Table A.1) - {"banana \xe0\xAA\xBA apple", "(invalid)", true, false}, - // bidi: RandALCat but not RandALCat at beginning and end - {"\xD8\xA7\x31", "(invalid)", true, false}, - // bidi: RandALCat and LCat characters - {"\xFB\x1D apple \x09\xA8", "(invalid)", true, false}, - // bidi: RandALCat with RandALCat at beginning and end - {"\xD8\xA1 \xDC\x92", "\xD8\xA1 \xDC\x92", true, true}, - // normalization and mapped to nothing - {"I\xE2\x80\x80\xC2\xA0X \xE2\x85\xA3", "I X IV", true, true}, - {"user", "user", false, true}, - {"USER", "USER", false, true}}; - ntests = sizeof (tests) / sizeof (sasl_prep_testcase_t); - for (i = 0; i < ntests; i++) { - ASSERT_CMPINT (tests[i].should_be_required, - ==, - _mongoc_sasl_prep_required (tests[i].original)); - memset (&err, 0, sizeof (err)); - normalized = _mongoc_sasl_prep (tests[i].original, &err); - if (tests[i].should_succeed) { - ASSERT_CMPSTR (tests[i].normalized, normalized); - ASSERT_CMPINT (err.code, ==, 0); - bson_free (normalized); - } else { - ASSERT_CMPINT (err.code, ==, MONGOC_ERROR_SCRAM_PROTOCOL_ERROR); - ASSERT_CMPINT (err.domain, ==, MONGOC_ERROR_SCRAM); - BSON_ASSERT (normalized == NULL); - } - } -} - -static void -test_mongoc_utf8_char_length (void) -{ - ASSERT_CMPSIZE_T (_mongoc_utf8_char_length (","), ==, 1u); - ASSERT_CMPSIZE_T (_mongoc_utf8_char_length ("ɶ"), ==, 2u); - ASSERT_CMPSIZE_T (_mongoc_utf8_char_length ("ྡྷ"), ==, 3u); - ASSERT_CMPSIZE_T (_mongoc_utf8_char_length ("🌂"), ==, 4u); -} - -static void -test_mongoc_utf8_string_length (void) -{ - ASSERT_CMPSIZE_T (_mongoc_utf8_string_length (",ase"), ==, 4u); - ASSERT_CMPSIZE_T (_mongoc_utf8_string_length ("ɸɴ"), ==, 2u); - ASSERT_CMPSIZE_T (_mongoc_utf8_string_length ("ྡྷ🌂e4🌕"), ==, 5u); - ASSERT_CMPSIZE_T ( - _mongoc_utf8_string_length ("no special characters"), ==, 21u); -} - -static void -test_mongoc_utf8_to_unicode (void) -{ - ASSERT_CMPUINT32 (_mongoc_utf8_get_first_code_point (",", 1), ==, 0x002C); - ASSERT_CMPUINT32 (_mongoc_utf8_get_first_code_point ("ɶ", 2), ==, 0x0276); - ASSERT_CMPUINT32 (_mongoc_utf8_get_first_code_point ("ྡྷ", 3), ==, 0x0FA2); - ASSERT_CMPUINT32 (_mongoc_utf8_get_first_code_point ("🌂", 4), ==, 0x1F302); -} - -#endif - -enum { - // ensure there are more users than slots in cache to test cache invalidation - NUM_CACHE_TEST_USERS = 10 + MONGOC_SCRAM_CACHE_SIZE, - - // ensure that there are several times that the cache needs to be invalidated - NUM_CACHE_TEST_THREADS = 3 * NUM_CACHE_TEST_USERS, -}; - -static char *_scram_cache_invalidation_uri_str = NULL; - -static BSON_THREAD_FUN (_scram_cache_invalidation_thread, username_number_ptr) -{ - bson_error_t error; - - const char *password = "mypass"; - char *username = - bson_strdup_printf ("cachetestuser%dX", *(int *) username_number_ptr); - bson_free (username_number_ptr); - - const char *uri_str = _scram_cache_invalidation_uri_str; - char *cache_test_user_uri = - test_framework_add_user_password (uri_str, username, password); - BSON_ASSERT (cache_test_user_uri); - - mongoc_uri_t *cache_test_uri = mongoc_uri_new (cache_test_user_uri); - BSON_ASSERT (cache_test_uri); - - // Set serverSelectionTryOnce=false so a single failed connection attempt - // does not result in an error. - mongoc_uri_set_option_as_bool ( - cache_test_uri, MONGOC_URI_SERVERSELECTIONTRYONCE, false); - - mongoc_client_t *client = - test_framework_client_new_from_uri (cache_test_uri, NULL /* api */); - BSON_ASSERT (client); - - test_framework_set_ssl_opts (client); - BSON_ASSERT (client); - - mongoc_collection_t *collection = - mongoc_client_get_collection (client, "admin", "testcache"); - BSON_ASSERT (collection); - - bson_t insert = BSON_INITIALIZER; - bool ok = - mongoc_collection_insert_one (collection, &insert, NULL, NULL, &error); - ASSERT_OR_PRINT (ok, error); - - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mongoc_uri_destroy (cache_test_uri); - bson_free (cache_test_user_uri); - bson_free (username); - - BSON_THREAD_RETURN; -} - -static void -test_mongoc_scram_cache_invalidation (void *ctx) -{ - bson_error_t error; - mongoc_uri_t *const uri = test_framework_get_uri (); - BSON_ASSERT (uri); - - mongoc_client_t *client = test_framework_new_default_client (); - BSON_ASSERT (client); - - mongoc_database_t *const db = mongoc_client_get_database (client, "admin"); - BSON_ASSERT (db); - - bson_t *roles = tmp_bson ("[{'role': 'readWrite', 'db': 'admin'}]"); - - _scram_cache_invalidation_uri_str = - test_framework_get_uri_str_no_auth ("admin"); - - /* Remove cache test users if they already exist. - * Create more test users than could exist in cache. */ - for (int i = 0; i < NUM_CACHE_TEST_USERS; i++) { - const char *password = "mypass"; - char *username = bson_strdup_printf ("cachetestuser%dX", i); - - mongoc_database_remove_user (db, username, &error); - bool ok = - mongoc_database_add_user (db, username, password, roles, NULL, &error); - ASSERT_OR_PRINT (ok, error); - bson_free (username); - } - - bson_thread_t threads[NUM_CACHE_TEST_THREADS]; - for (int i = 0; i < NUM_CACHE_TEST_THREADS; i++) { - int *username_number_ptr = bson_malloc (sizeof (*username_number_ptr)); - *username_number_ptr = i % NUM_CACHE_TEST_USERS; - int rc = mcommon_thread_create ( - &threads[i], _scram_cache_invalidation_thread, username_number_ptr); - BSON_ASSERT (rc == 0); - } - - for (int i = 0; i < NUM_CACHE_TEST_THREADS; i++) { - int rc = mcommon_thread_join (threads[i]); - BSON_ASSERT (rc == 0); - } - - bson_free (_scram_cache_invalidation_uri_str); - _scram_cache_invalidation_uri_str = NULL; - mongoc_database_destroy (db); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); -} - -static void -_clear_scram_users (void) -{ - mongoc_client_t *const client = test_framework_new_default_client (); - ASSERT (client); - mongoc_database_t *const db = mongoc_client_get_database (client, "admin"); - ASSERT (db); - (void) mongoc_database_remove_user (db, "sha1", NULL); - (void) mongoc_database_remove_user (db, "sha256", NULL); - (void) mongoc_database_remove_user (db, "both", NULL); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -static void -_create_scram_users (void) -{ - mongoc_client_t *client; - bool res; - bson_error_t error; - client = test_framework_new_default_client (); - res = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'createUser': 'sha1', 'pwd': 'sha1', 'roles': ['root'], " - "'mechanisms': ['SCRAM-SHA-1']}"), - NULL /* read_prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (res, error); - res = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'createUser': 'sha256', 'pwd': 'sha256', 'roles': ['root'], " - "'mechanisms': ['SCRAM-SHA-256']}"), - NULL /* read_prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (res, error); - res = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'createUser': 'both', 'pwd': 'both', 'roles': ['root'], " - "'mechanisms': ['SCRAM-SHA-1', 'SCRAM-SHA-256']}"), - NULL /* read_prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (res, error); - mongoc_client_destroy (client); -} - -static void -_drop_scram_users (void) -{ - mongoc_client_t *client; - mongoc_database_t *db; - bool res; - bson_error_t error; - client = test_framework_new_default_client (); - db = mongoc_client_get_database (client, "admin"); - res = mongoc_database_remove_user (db, "sha1", &error); - ASSERT_OR_PRINT (res, error); - res = mongoc_database_remove_user (db, "sha256", &error); - ASSERT_OR_PRINT (res, error); - res = mongoc_database_remove_user (db, "both", &error); - ASSERT_OR_PRINT (res, error); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -static void -_check_mechanism (bool pooled, - const char *client_mech, - const char *server_mechs, - const char *expected_used_mech) -{ - mock_server_t *server; - mongoc_client_pool_t *client_pool = NULL; - mongoc_client_t *client = NULL; - mongoc_uri_t *uri; - future_t *future; - request_t *request; - const bson_t *sasl_doc; - const char *used_mech; - - server = mock_server_new (); - mock_server_auto_hello (server, - "{'ok': 1," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'isWritablePrimary': true," - " 'saslSupportedMechs': [%s]}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX, - server_mechs ? server_mechs : ""); - - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_username (uri, "user"); - mongoc_uri_set_password (uri, "password"); - if (client_mech) { - mongoc_uri_set_auth_mechanism (uri, client_mech); - } - - if (pooled) { - client_pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (client_pool); - /* suppress the auth failure logs from pooled clients. */ - capture_logs (true); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - } - future = future_client_command_simple (client, - "admin", - tmp_bson ("{'dbstats': 1}"), - NULL /* read_prefs. */, - NULL /* reply. */, - NULL /* error. */); - request = - mock_server_receives_msg (server, MONGOC_QUERY_NONE, tmp_bson ("{}")); - sasl_doc = request_get_doc (request, 0); - used_mech = bson_lookup_utf8 (sasl_doc, "mechanism"); - ASSERT_CMPSTR (used_mech, expected_used_mech); - /* we're not actually going to auth, just hang up. */ - reply_to_request_with_hang_up (request); - future_wait (future); - future_destroy (future); - request_destroy (request); - mongoc_uri_destroy (uri); - if (pooled) { - mongoc_client_pool_push (client_pool, client); - mongoc_client_pool_destroy (client_pool); - capture_logs (false); - } else { - mongoc_client_destroy (client); - } - mock_server_destroy (server); -} - -typedef enum { - MONGOC_TEST_NO_ERROR, - MONGOC_TEST_USER_NOT_FOUND_ERROR, - MONGOC_TEST_AUTH_ERROR -} test_error_t; - -void -_check_error (const bson_error_t *error, test_error_t expected_error) -{ - uint32_t domain = 0; - uint32_t code = 0; - const char *message = ""; - - switch (expected_error) { - case MONGOC_TEST_AUTH_ERROR: { - domain = MONGOC_ERROR_CLIENT; - code = MONGOC_ERROR_CLIENT_AUTHENTICATE; - ASSERT_CMPUINT32 (error->domain, ==, domain); - ASSERT_CMPUINT32 (error->code, ==, code); - const char *const a = "Authentication failed"; - const char *const b = "Unable to use"; - const bool found = - strstr (error->message, a) || strstr (error->message, b); - ASSERT_WITH_MSG ( - found, "[%s] does not contain [%s] or [%s]", error->message, a, b); - break; - } - case MONGOC_TEST_USER_NOT_FOUND_ERROR: - domain = MONGOC_ERROR_CLIENT; - code = MONGOC_ERROR_CLIENT_AUTHENTICATE; - message = "Could not find user"; - break; - case MONGOC_TEST_NO_ERROR: - default: - return; - } - - ASSERT_ERROR_CONTAINS ((*error), domain, code, message); -} - -static void -_try_auth_from_uri (bool pooled, mongoc_uri_t *uri, test_error_t expected_error) -{ - mongoc_client_pool_t *client_pool = NULL; - mongoc_client_t *client = NULL; - mongoc_collection_t *coll; - bson_error_t error; - bson_t reply; - bool res; - - if (pooled) { - client_pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (client_pool); - mongoc_client_pool_set_error_api (client_pool, 2); - client = mongoc_client_pool_pop (client_pool); - /* suppress the auth failure logs from pooled clients. */ - capture_logs (true); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - mongoc_client_set_error_api (client, 2); - test_framework_set_ssl_opts (client); - } - coll = get_test_collection (client, "try_auth"); - res = mongoc_collection_insert_one ( - coll, tmp_bson ("{'x': 1}"), NULL /* opts */, &reply, &error); - - if (expected_error == MONGOC_TEST_NO_ERROR) { - ASSERT_OR_PRINT (res, error); - ASSERT_MATCH (&reply, "{'insertedCount': 1 }"); - } else { - ASSERT (!res); - _check_error (&error, expected_error); - } - bson_destroy (&reply); - mongoc_collection_destroy (coll); - if (pooled) { - mongoc_client_pool_push (client_pool, client); - mongoc_client_pool_destroy (client_pool); - capture_logs (false); - } else { - mongoc_client_destroy (client); - } -} - -/* if auth is expected to succeed, expected_error is zero'd out. */ -static void -_try_auth (bool pooled, - const char *user, - const char *pwd, - const char *mechanism, - test_error_t expected_error) -{ - mongoc_uri_t *uri; - - uri = test_framework_get_uri (); - mongoc_uri_set_username (uri, user); - mongoc_uri_set_password (uri, pwd); - if (mechanism) { - mongoc_uri_set_auth_mechanism (uri, mechanism); - } - _try_auth_from_uri (pooled, uri, expected_error); - mongoc_uri_destroy (uri); -} - - -static void -_test_mongoc_scram_auth (bool pooled) -{ - /* Auth spec: "For each test user, verify that you can connect and run a - command requiring authentication for the following cases: - - Explicitly specifying each mechanism the user supports. - - Specifying no mechanism and relying on mechanism negotiation." */ - _try_auth (pooled, "sha1", "sha1", NULL, MONGOC_TEST_NO_ERROR); - _try_auth (pooled, "sha1", "sha1", "SCRAM-SHA-1", MONGOC_TEST_NO_ERROR); - _try_auth (pooled, "sha256", "sha256", NULL, MONGOC_TEST_NO_ERROR); - _try_auth ( - pooled, "sha256", "sha256", "SCRAM-SHA-256", MONGOC_TEST_NO_ERROR); - _try_auth (pooled, "both", "both", NULL, MONGOC_TEST_NO_ERROR); - _try_auth (pooled, "both", "both", "SCRAM-SHA-1", MONGOC_TEST_NO_ERROR); - _try_auth (pooled, "both", "both", "SCRAM-SHA-256", MONGOC_TEST_NO_ERROR); - - _check_mechanism (pooled, NULL, NULL, "SCRAM-SHA-1"); - _check_mechanism (pooled, NULL, "'SCRAM-SHA-1'", "SCRAM-SHA-1"); - _check_mechanism (pooled, NULL, "'SCRAM-SHA-256'", "SCRAM-SHA-256"); - _check_mechanism ( - pooled, NULL, "'SCRAM-SHA-1','SCRAM-SHA-256'", "SCRAM-SHA-256"); - - _check_mechanism (pooled, "SCRAM-SHA-1", NULL, "SCRAM-SHA-1"); - _check_mechanism (pooled, "SCRAM-SHA-1", "'SCRAM-SHA-1'", "SCRAM-SHA-1"); - _check_mechanism (pooled, "SCRAM-SHA-1", "'SCRAM-SHA-256'", "SCRAM-SHA-1"); - _check_mechanism ( - pooled, "SCRAM-SHA-1", "'SCRAM-SHA-1','SCRAM-SHA-256'", "SCRAM-SHA-1"); - - _check_mechanism (pooled, "SCRAM-SHA-256", NULL, "SCRAM-SHA-256"); - _check_mechanism (pooled, "SCRAM-SHA-256", "'SCRAM-SHA-1'", "SCRAM-SHA-256"); - _check_mechanism ( - pooled, "SCRAM-SHA-256", "'SCRAM-SHA-256'", "SCRAM-SHA-256"); - _check_mechanism (pooled, - "SCRAM-SHA-256", - "'SCRAM-SHA-1','SCRAM-SHA-256'", - "SCRAM-SHA-256"); - - /* Test some failure auths. */ - _try_auth (pooled, "sha1", "bad", NULL, MONGOC_TEST_AUTH_ERROR); - _try_auth (pooled, "sha256", "bad", NULL, MONGOC_TEST_AUTH_ERROR); - _try_auth (pooled, "both", "bad", NULL, MONGOC_TEST_AUTH_ERROR); - _try_auth (pooled, "sha1", "bad", "SCRAM-SHA-256", MONGOC_TEST_AUTH_ERROR); - _try_auth (pooled, "sha256", "bad", "SCRAM-SHA-1", MONGOC_TEST_AUTH_ERROR); - - /* Auth spec: "For a non-existent username, verify that not specifying a - * mechanism when connecting fails with the same error type that would occur - * with a correct username but incorrect password or mechanism." */ - _try_auth (pooled, "unknown_user", "bad", NULL, MONGOC_TEST_AUTH_ERROR); -} - -/* test the auth tests described in the auth spec. */ -static void -test_mongoc_scram_auth (void *ctx) -{ - BSON_UNUSED (ctx); - - _clear_scram_users (); - - /* Auth spec: "Create three test users, one with only SHA-1, one with only - * SHA-256 and one with both" */ - _create_scram_users (); - _test_mongoc_scram_auth (false); - _test_mongoc_scram_auth (true); - _drop_scram_users (); -} - -static int -_skip_if_no_sha256 (void) -{ - mongoc_client_t *client; - bool res; - bson_error_t error; - - client = test_framework_new_default_client (); - - /* Check if SCRAM-SHA-256 is a supported auth mechanism by attempting to - * create a new user with it. */ - res = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'createUser': 'temp', 'pwd': 'sha256', 'roles': ['root'], " - "'mechanisms': ['SCRAM-SHA-256']}"), - NULL /* read_prefs */, - NULL /* reply */, - &error); - - if (res) { - mongoc_database_t *db; - - db = mongoc_client_get_database (client, "admin"); - ASSERT_OR_PRINT (mongoc_database_remove_user (db, "temp", &error), error); - mongoc_database_destroy (db); - } - - mongoc_client_destroy (client); - return res ? 1 : 0; -} - -#define ROMAN_NUMERAL_NINE "\xE2\x85\xA8" -#define ROMAN_NUMERAL_FOUR "\xE2\x85\xA3" - -static void -_clear_saslprep_users (void) -{ - mongoc_client_t *const client = test_framework_new_default_client (); - ASSERT (client); - mongoc_database_t *const db = mongoc_client_get_database (client, "admin"); - ASSERT (db); - (void) mongoc_database_remove_user (db, "IX", NULL); - (void) mongoc_database_remove_user (db, ROMAN_NUMERAL_NINE, NULL); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -static void -_create_saslprep_users (void) -{ - mongoc_client_t *client; - bool res; - bson_error_t error; - client = test_framework_new_default_client (); - res = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'createUser': 'IX', 'pwd': 'IX', 'roles': ['root'], " - "'mechanisms': ['SCRAM-SHA-256']}"), - NULL /* read_prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (res, error); - res = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'createUser': '" ROMAN_NUMERAL_NINE - "', 'pwd': '" ROMAN_NUMERAL_FOUR - "', 'roles': ['root'], 'mechanisms': ['SCRAM-SHA-256']}"), - NULL /* read_prefs */, - NULL /* reply */, - &error); - ASSERT_OR_PRINT (res, error); - mongoc_client_destroy (client); -} - -static void -_drop_saslprep_users (void) -{ - mongoc_client_t *client; - mongoc_database_t *db; - bool res; - bson_error_t error; - client = test_framework_new_default_client (); - db = mongoc_client_get_database (client, "admin"); - res = mongoc_database_remove_user (db, "IX", &error); - ASSERT_OR_PRINT (res, error); - res = mongoc_database_remove_user (db, ROMAN_NUMERAL_NINE, &error); - ASSERT_OR_PRINT (res, error); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - -static void -_make_uri (const char *username, const char *password, mongoc_uri_t **out) -{ - char *uri_str; - char *tmp; - - tmp = test_framework_get_uri_str_no_auth ("admin"); - uri_str = test_framework_add_user_password (tmp, username, password); - mongoc_uri_destroy (*out); - *out = mongoc_uri_new (uri_str); - bson_free (tmp); - bson_free (uri_str); -} - -static void -_test_mongoc_scram_saslprep_auth (bool pooled) -{ - mongoc_uri_t *uri = NULL; - - /* Test URIs of the form in the auth spec test plan for SASLPrep. - - mongodb://IX:IX@mongodb.example.com/admin - - mongodb://IX:I%C2%ADX@mongodb.example.com/admin - - mongodb://%E2%85%A8:IV@mongodb.example.com/admin - - mongodb://%E2%85%A8:I%C2%ADV@mongodb.example.com/admin - - Test in three ways. - 1. By embedding the multi-byte UTF-8 characters directly into the - connection string. - 2. By percent escaping the multi-byte UTF-8 characters. - 3. By using the setters, mongoc_uri_set_username/mongoc_uri_set_password - and embedding the UTF-8 characters (percent unescaping does not occur for - the setters) - */ - - /* Way 1: embedding multi-byte UTF-8 characters directly */ - _make_uri ("IX", "IX", &uri); - _try_auth_from_uri (pooled, uri, MONGOC_TEST_NO_ERROR); - - _make_uri ("IX", ROMAN_NUMERAL_NINE, &uri); - _try_auth_from_uri (pooled, uri, MONGOC_TEST_NO_ERROR); - - _make_uri (ROMAN_NUMERAL_NINE, "IV", &uri); - _try_auth_from_uri (pooled, uri, MONGOC_TEST_NO_ERROR); - - _make_uri (ROMAN_NUMERAL_NINE, ROMAN_NUMERAL_FOUR, &uri); - _try_auth_from_uri (pooled, uri, MONGOC_TEST_NO_ERROR); - - /* Way 2: Percent escaping */ - _make_uri ("IX", "IX", &uri); - _try_auth_from_uri (pooled, uri, MONGOC_TEST_NO_ERROR); - - _make_uri ("IX", "I%C2%ADX", &uri); - _try_auth_from_uri (pooled, uri, MONGOC_TEST_NO_ERROR); - - _make_uri ("%E2%85%A8", "IV", &uri); - _try_auth_from_uri (pooled, uri, MONGOC_TEST_NO_ERROR); - - _make_uri ("%E2%85%A8", "I%C2%ADV", &uri); - _try_auth_from_uri (pooled, uri, MONGOC_TEST_NO_ERROR); - mongoc_uri_destroy (uri); - - /* Way 3: with username/password setters. */ - _try_auth (pooled, "IX", "IX", NULL, MONGOC_TEST_NO_ERROR); - _try_auth (pooled, "IX", ROMAN_NUMERAL_NINE, NULL, MONGOC_TEST_NO_ERROR); - _try_auth (pooled, ROMAN_NUMERAL_NINE, "IV", NULL, MONGOC_TEST_NO_ERROR); - _try_auth (pooled, - ROMAN_NUMERAL_NINE, - ROMAN_NUMERAL_FOUR, - NULL, - MONGOC_TEST_NO_ERROR); -} - - -static void -test_mongoc_saslprep_auth (void *ctx) -{ - BSON_UNUSED (ctx); - - _clear_saslprep_users (); - _create_saslprep_users (); - _test_mongoc_scram_saslprep_auth (false); - _test_mongoc_scram_saslprep_auth (true); - _drop_saslprep_users (); -} - -void -test_scram_install (TestSuite *suite) -{ -#ifdef MONGOC_ENABLE_SSL - TestSuite_Add (suite, - "/scram/username_not_set", - test_mongoc_scram_step_username_not_set); - TestSuite_Add (suite, "/scram/sasl_prep", test_mongoc_scram_sasl_prep); - TestSuite_Add ( - suite, "/scram/iteration_count", test_mongoc_scram_iteration_count); - TestSuite_Add ( - suite, "/scram/utf8_char_length", test_mongoc_utf8_char_length); - TestSuite_Add ( - suite, "/scram/utf8_string_length", test_mongoc_utf8_string_length); - TestSuite_Add (suite, "/scram/utf8_to_unicode", test_mongoc_utf8_to_unicode); -#endif - TestSuite_AddFull (suite, - "/scram/cache_invalidation", - test_mongoc_scram_cache_invalidation, - NULL, - NULL, - test_framework_skip_if_no_auth); - TestSuite_AddFull (suite, - "/scram/auth_tests", - test_mongoc_scram_auth, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_auth, - _skip_if_no_sha256, - TestSuite_CheckLive); - TestSuite_AddFull (suite, - "/scram/saslprep_auth", - test_mongoc_saslprep_auth, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_no_auth, - _skip_if_no_sha256, - TestSuite_CheckLive); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-sdam-monitoring.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-sdam-monitoring.c deleted file mode 100644 index 7622a970a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-sdam-monitoring.c +++ /dev/null @@ -1,1067 +0,0 @@ -#include -#include "json-test.h" - -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-topology-description-apm-private.h" - -#include "test-libmongoc.h" -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "json-test-monitoring.h" - -#ifdef BSON_HAVE_STRINGS_H -#include -#endif - - -typedef struct { - bson_t events; - uint32_t n_events; - mongoc_array_t heartbeat_succeeded_durations; - mongoc_array_t heartbeat_failed_durations; - bson_oid_t topology_id; -} context_t; - -static void -check_json_sdam_events (const bson_t *events, const bson_t *expectations) -{ - uint32_t expected_keys; - uint32_t actual_keys; - match_ctx_t match_ctx = {{0}}; - - expected_keys = bson_count_keys (expectations); - actual_keys = bson_count_keys (events); - - if (expected_keys != actual_keys) { - test_error ("SDAM test failed expectations:\n\n" - "expected\n%s\n\n" - "actual:\n%s\n\n" - "expected %" PRIu32 " events, got %" PRIu32, - bson_as_canonical_extended_json (expectations, NULL), - bson_as_canonical_extended_json (events, NULL), - expected_keys, - actual_keys); - } - - if (!match_bson_with_ctx (events, expectations, &match_ctx)) { - test_error ("SDAM test failed expectations:\n\n" - "expected\n%s\n\n" - "actual:\n%s\n\n%s", - bson_as_canonical_extended_json (expectations, NULL), - bson_as_canonical_extended_json (events, NULL), - match_ctx.errmsg); - } -} - - -static void -context_init (context_t *context) -{ - bson_init (&context->events); - context->n_events = 0; - _mongoc_array_init (&context->heartbeat_succeeded_durations, - sizeof (int64_t)); - _mongoc_array_init (&context->heartbeat_failed_durations, sizeof (int64_t)); - bson_oid_init_from_string (&context->topology_id, - "000000000000000000000000"); -} - -static void -context_append (context_t *context, bson_t *event) -{ - char str[16]; - const char *key; - - bson_uint32_to_string (context->n_events, &key, str, sizeof str); - BSON_APPEND_DOCUMENT (&context->events, key, event); - - context->n_events++; - - bson_destroy (event); -} - -static void -context_destroy (context_t *context) -{ - bson_destroy (&context->events); - _mongoc_array_destroy (&context->heartbeat_succeeded_durations); - _mongoc_array_destroy (&context->heartbeat_failed_durations); -} - -static void -append_array (bson_t *bson, const char *key, const bson_t *array) -{ - if (array->len) { - BSON_APPEND_ARRAY (bson, key, array); - } else { - bson_t tmp = BSON_INITIALIZER; - BSON_APPEND_ARRAY (bson, key, &tmp); - bson_destroy (&tmp); - } -} - -static void -sd_to_bson (const mongoc_server_description_t *sd, bson_t *bson) -{ - const mongoc_host_list_t *host_list; - - host_list = mongoc_server_description_host (sd); - - bson_init (bson); - BSON_APPEND_UTF8 (bson, "address", host_list->host_and_port); - - append_array (bson, "arbiters", &sd->arbiters); - append_array (bson, "hosts", &sd->hosts); - append_array (bson, "passives", &sd->passives); - - if (sd->current_primary) { - BSON_APPEND_UTF8 (bson, "primary", sd->current_primary); - } - - if (sd->set_name) { - BSON_APPEND_UTF8 (bson, "setName", sd->set_name); - } - - BSON_APPEND_UTF8 (bson, "type", mongoc_server_description_type (sd)); -} - -static void -td_to_bson (const mongoc_topology_description_t *td, bson_t *bson) -{ - bson_t servers = BSON_INITIALIZER; - bson_t server; - char str[16]; - const char *key; - mongoc_set_t const *servers_set = mc_tpld_servers_const (td); - - for (size_t i = 0; i < servers_set->items_len; i++) { - BSON_ASSERT (bson_in_range_unsigned (uint32_t, i)); - bson_uint32_to_string ((uint32_t) i, &key, str, sizeof str); - sd_to_bson (mongoc_set_get_item_const (servers_set, i), &server); - BSON_APPEND_DOCUMENT (&servers, key, &server); - bson_destroy (&server); - } - - bson_init (bson); - BSON_APPEND_UTF8 ( - bson, "topologyType", mongoc_topology_description_type (td)); - - if (td->set_name) { - BSON_APPEND_UTF8 (bson, "setName", td->set_name); - } - - BSON_APPEND_ARRAY (bson, "servers", &servers); - - bson_destroy (&servers); -} - -static void -server_changed (const mongoc_apm_server_changed_t *event) -{ - context_t *ctx; - bson_oid_t topology_id; - const char *host_and_port; - bson_t prev_sd; - bson_t new_sd; - - ctx = (context_t *) mongoc_apm_server_changed_get_context (event); - - /* check topology id is consistent */ - mongoc_apm_server_changed_get_topology_id (event, &topology_id); - ASSERT (bson_oid_equal (&topology_id, &ctx->topology_id)); - - host_and_port = mongoc_apm_server_changed_get_host (event)->host_and_port; - sd_to_bson (mongoc_apm_server_changed_get_previous_description (event), - &prev_sd); - sd_to_bson (mongoc_apm_server_changed_get_new_description (event), &new_sd); - - context_append (ctx, - BCON_NEW ("server_description_changed_event", - "{", - "topologyId", - BCON_UTF8 ("42"), - "address", - BCON_UTF8 (host_and_port), - "previousDescription", - BCON_DOCUMENT (&prev_sd), - "newDescription", - BCON_DOCUMENT (&new_sd), - "}")); - - bson_destroy (&prev_sd); - bson_destroy (&new_sd); -} - -static void -server_opening (const mongoc_apm_server_opening_t *event) -{ - context_t *ctx; - bson_oid_t topology_id; - const char *host_and_port; - - ctx = (context_t *) mongoc_apm_server_opening_get_context (event); - - mongoc_apm_server_opening_get_topology_id (event, &topology_id); - ASSERT (bson_oid_equal (&topology_id, &ctx->topology_id)); - - host_and_port = mongoc_apm_server_opening_get_host (event)->host_and_port; - context_append (ctx, - BCON_NEW ("server_opening_event", - "{", - "address", - BCON_UTF8 (host_and_port), - "topologyId", - BCON_UTF8 ("42"), - "}")); -} - -static void -server_closed (const mongoc_apm_server_closed_t *event) -{ - context_t *ctx; - bson_oid_t topology_id; - const char *host_and_port; - - ctx = (context_t *) mongoc_apm_server_closed_get_context (event); - - mongoc_apm_server_closed_get_topology_id (event, &topology_id); - ASSERT (bson_oid_equal (&topology_id, &ctx->topology_id)); - - host_and_port = mongoc_apm_server_closed_get_host (event)->host_and_port; - context_append (ctx, - BCON_NEW ("server_closed_event", - "{", - "address", - BCON_UTF8 (host_and_port), - "topologyId", - BCON_UTF8 ("42"), - "}")); -} - -static void -topology_changed (const mongoc_apm_topology_changed_t *event) -{ - context_t *ctx; - bson_oid_t topology_id; - bson_t prev_td; - bson_t new_td; - - ctx = (context_t *) mongoc_apm_topology_changed_get_context (event); - - mongoc_apm_topology_changed_get_topology_id (event, &topology_id); - ASSERT (bson_oid_equal (&topology_id, &ctx->topology_id)); - - td_to_bson (mongoc_apm_topology_changed_get_previous_description (event), - &prev_td); - td_to_bson (mongoc_apm_topology_changed_get_new_description (event), - &new_td); - - context_append (ctx, - BCON_NEW ("topology_description_changed_event", - "{", - "newDescription", - BCON_DOCUMENT (&new_td), - "previousDescription", - BCON_DOCUMENT (&prev_td), - "topologyId", - BCON_UTF8 ("42"), - "}")); - - bson_destroy (&prev_td); - bson_destroy (&new_td); -} - -static void -topology_opening (const mongoc_apm_topology_opening_t *event) -{ - context_t *ctx; - bson_oid_t zeroes; - - /* new event's topology id is NOT all zeroes */ - bson_oid_init_from_string (&zeroes, "000000000000000000000000"); - ASSERT (!bson_oid_equal (&event->topology_id, &zeroes)); - - ctx = (context_t *) mongoc_apm_topology_opening_get_context (event); - mongoc_apm_topology_opening_get_topology_id (event, &ctx->topology_id); - context_append ( - ctx, - BCON_NEW ( - "topology_opening_event", "{", "topologyId", BCON_UTF8 ("42"), "}")); -} - -static void -topology_closed (const mongoc_apm_topology_closed_t *event) -{ - context_t *ctx; - bson_oid_t topology_id; - - ctx = (context_t *) mongoc_apm_topology_closed_get_context (event); - mongoc_apm_topology_closed_get_topology_id (event, &topology_id); - ASSERT (bson_oid_equal (&topology_id, &ctx->topology_id)); - context_append ( - ctx, - BCON_NEW ( - "topology_closed_event", "{", "topologyId", BCON_UTF8 ("42"), "}")); -} - -/* no standard tests in the specs repo for heartbeat events, so invent some */ -static void -server_heartbeat_started (const mongoc_apm_server_heartbeat_started_t *event) -{ - context_t *ctx; - const mongoc_host_list_t *host; - - ctx = (context_t *) mongoc_apm_server_heartbeat_started_get_context (event); - host = mongoc_apm_server_heartbeat_started_get_host (event); - context_append ( - ctx, - BCON_NEW ( - "heartbeat_started_event", - "{", - "host", - BCON_UTF8 (host->host_and_port), - "awaited", - BCON_BOOL (mongoc_apm_server_heartbeat_started_get_awaited (event)), - "}")); -} - -static void -server_heartbeat_succeeded ( - const mongoc_apm_server_heartbeat_succeeded_t *event) -{ - context_t *ctx; - const mongoc_host_list_t *host; - int64_t duration; - - ctx = - (context_t *) mongoc_apm_server_heartbeat_succeeded_get_context (event); - host = mongoc_apm_server_heartbeat_succeeded_get_host (event); - context_append ( - ctx, - BCON_NEW ( - "heartbeat_succeeded_event", - "{", - "host", - BCON_UTF8 (host->host_and_port), - "awaited", - BCON_BOOL (mongoc_apm_server_heartbeat_succeeded_get_awaited (event)), - "}")); - - duration = mongoc_apm_server_heartbeat_succeeded_get_duration (event); - _mongoc_array_append_val (&ctx->heartbeat_succeeded_durations, duration); -} - -static void -server_heartbeat_failed (const mongoc_apm_server_heartbeat_failed_t *event) -{ - context_t *ctx; - const mongoc_host_list_t *host; - int64_t duration; - - ctx = (context_t *) mongoc_apm_server_heartbeat_failed_get_context (event); - host = mongoc_apm_server_heartbeat_failed_get_host (event); - context_append ( - ctx, - BCON_NEW ( - "heartbeat_failed_event", - "{", - "host", - BCON_UTF8 (host->host_and_port), - "awaited", - BCON_BOOL (mongoc_apm_server_heartbeat_failed_get_awaited (event)), - "}")); - - duration = mongoc_apm_server_heartbeat_failed_get_duration (event); - _mongoc_array_append_val (&ctx->heartbeat_failed_durations, duration); -} - -static mongoc_apm_callbacks_t * -topology_event_callbacks (void) -{ - mongoc_apm_callbacks_t *callbacks; - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_server_changed_cb (callbacks, server_changed); - mongoc_apm_set_server_opening_cb (callbacks, server_opening); - mongoc_apm_set_server_closed_cb (callbacks, server_closed); - mongoc_apm_set_topology_changed_cb (callbacks, topology_changed); - mongoc_apm_set_topology_opening_cb (callbacks, topology_opening); - mongoc_apm_set_topology_closed_cb (callbacks, topology_closed); - - return callbacks; -} - -static void -client_set_topology_event_callbacks (mongoc_client_t *client, - context_t *context) -{ - mongoc_apm_callbacks_t *callbacks; - - ASSERT (client); - - callbacks = topology_event_callbacks (); - mongoc_client_set_apm_callbacks (client, callbacks, (void *) context); - mongoc_apm_callbacks_destroy (callbacks); -} - -static void -pool_set_topology_event_callbacks (mongoc_client_pool_t *pool, - context_t *context) -{ - mongoc_apm_callbacks_t *callbacks; - - ASSERT (pool); - - callbacks = topology_event_callbacks (); - mongoc_client_pool_set_apm_callbacks (pool, callbacks, (void *) context); - mongoc_apm_callbacks_destroy (callbacks); -} - -static mongoc_apm_callbacks_t * -heartbeat_event_callbacks (void) -{ - mongoc_apm_callbacks_t *callbacks; - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_server_heartbeat_started_cb (callbacks, - server_heartbeat_started); - mongoc_apm_set_server_heartbeat_succeeded_cb (callbacks, - server_heartbeat_succeeded); - mongoc_apm_set_server_heartbeat_failed_cb (callbacks, - server_heartbeat_failed); - - return callbacks; -} - -static void -client_set_heartbeat_event_callbacks (mongoc_client_t *client, - context_t *context) -{ - mongoc_apm_callbacks_t *callbacks; - - ASSERT (client); - - callbacks = heartbeat_event_callbacks (); - mongoc_client_set_apm_callbacks (client, callbacks, (void *) context); - mongoc_apm_callbacks_destroy (callbacks); -} - -static void -pool_set_heartbeat_event_callbacks (mongoc_client_pool_t *pool, - context_t *context) -{ - mongoc_apm_callbacks_t *callbacks; - - ASSERT (pool); - - callbacks = heartbeat_event_callbacks (); - mongoc_client_pool_set_apm_callbacks (pool, callbacks, (void *) context); - mongoc_apm_callbacks_destroy (callbacks); -} - -/* - *----------------------------------------------------------------------- - * - * Run the JSON tests from the SDAM Monitoring spec. - * - *----------------------------------------------------------------------- - */ -static void -test_sdam_monitoring_cb (bson_t *test) -{ - mongoc_client_t *client; - mongoc_topology_t *topology; - bson_t phase; - bson_t phases; - bson_t outcome; - bson_iter_t phase_iter; - bson_iter_t phase_field_iter; - bson_iter_t outcome_iter; - bson_iter_t iter; - bson_t events_expected; - context_t context; - bool first_phase; - - /* parse out the uri and use it to create a client */ - BSON_ASSERT (bson_iter_init_find (&iter, test, "uri")); - client = test_framework_client_new (bson_iter_utf8 (&iter, NULL), NULL); - topology = client->topology; - context_init (&context); - client_set_topology_event_callbacks (client, &context); - - /* for each phase, parse and validate */ - BSON_ASSERT (bson_iter_init_find (&iter, test, "phases")); - bson_iter_bson (&iter, &phases); - bson_iter_init (&phase_iter, &phases); - - first_phase = true; - while (bson_iter_next (&phase_iter)) { - bson_iter_bson (&phase_iter, &phase); - - if (first_phase) { - /* Force the topology opening and server opening events. This test - * doesn't exercise this code path naturally, see below in - * _test_topology_events for a non-hacky test of this event */ - mc_tpld_modification tdmod = mc_tpld_modify_begin (topology); - _mongoc_topology_description_monitor_opening (tdmod.new_td); - mc_tpld_modify_commit (tdmod); - first_phase = false; - } else { - /* clear the stored events. */ - bson_reinit (&context.events); - context.n_events = 0; - } - process_sdam_test_hello_responses (&phase, client->topology); - - /* parse out "outcome" and validate */ - BSON_ASSERT (bson_iter_init_find (&phase_field_iter, &phase, "outcome")); - bson_iter_bson (&phase_field_iter, &outcome); - bson_iter_init (&outcome_iter, &outcome); - - while (bson_iter_next (&outcome_iter)) { - if (strcmp ("events", bson_iter_key (&outcome_iter)) == 0) { - bson_iter_bson (&outcome_iter, &events_expected); - check_json_sdam_events (&context.events, &events_expected); - } else { - fprintf (stderr, - "ERROR: unparsed test field %s\n", - bson_iter_key (&outcome_iter)); - BSON_ASSERT (false); - } - } - } - - mongoc_client_destroy (client); - context_destroy (&context); -} - -/* - *----------------------------------------------------------------------- - * - * Runner for the JSON tests for SDAM Monitoring.. - * - *----------------------------------------------------------------------- - */ -static void -test_all_spec_tests (TestSuite *suite) -{ - install_json_test_suite (suite, - JSON_DIR, - "server_discovery_and_monitoring/monitoring", - &test_sdam_monitoring_cb); -} - -static void -_test_topology_events (bool pooled) -{ - mongoc_client_t *client; - mongoc_client_pool_t *pool = NULL; - context_t context; - bool r; - bson_error_t error; - bson_iter_t events_iter; - bson_iter_t event_iter; - uint32_t i; - - context_init (&context); - - if (pooled) { - pool = test_framework_new_default_client_pool (); - pool_set_topology_event_callbacks (pool, &context); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_new_default_client (); - client_set_topology_event_callbacks (client, &context); - } - - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - /* first event is topology opening */ - bson_iter_init (&events_iter, &context.events); - bson_iter_next (&events_iter); - ASSERT (bson_iter_recurse (&events_iter, &event_iter)); - ASSERT (bson_iter_find (&event_iter, "topology_opening_event")); - - /* last event is topology closed */ - for (i = 1; i < context.n_events; i++) { - ASSERT (bson_iter_next (&events_iter)); - } - - ASSERT (bson_iter_recurse (&events_iter, &event_iter)); - ASSERT (bson_iter_find (&event_iter, "topology_closed_event")); - - /* no more events */ - ASSERT (!bson_iter_next (&events_iter)); - - context_destroy (&context); -} - -static void -test_topology_events_single (void) -{ - _test_topology_events (false); -} - -static void -test_topology_events_pooled (void) -{ - _test_topology_events (true); -} - -static void -test_topology_events_disabled (void) -{ - mongoc_client_t *client; - context_t context; - bool r; - bson_error_t error; - bson_iter_t events_iter; - bson_iter_t event_iter; - uint32_t i; - - context_init (&context); - - client = test_framework_new_default_client (); - client_set_topology_event_callbacks (client, &context); - - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - - /* disable callbacks before destroying so we don't see a topology closed - * event */ - mongoc_client_set_apm_callbacks (client, NULL, NULL); - mongoc_client_destroy (client); - - /* first event is topology opening */ - bson_iter_init (&events_iter, &context.events); - bson_iter_next (&events_iter); - ASSERT (bson_iter_recurse (&events_iter, &event_iter)); - ASSERT (bson_iter_find (&event_iter, "topology_opening_event")); - - /* move forward to the last event */ - for (i = 1; i < context.n_events; i++) { - ASSERT (bson_iter_next (&events_iter)); - } - - /* verify we didn't receive a topology closed event */ - ASSERT (bson_iter_recurse (&events_iter, &event_iter)); - ASSERT (!bson_iter_find (&event_iter, "topology_closed_event")); - - /* no more events */ - ASSERT (!bson_iter_next (&events_iter)); - - context_destroy (&context); -} - -static bool -responder (request_t *request, void *data) -{ - BSON_UNUSED (data); - - if (!strcmp (request->command_name, "foo")) { - reply_to_request_simple (request, "{'ok': 1}"); - request_destroy (request); - return true; - } - - return false; -} - -static void -_test_heartbeat_events (bool pooled, bool succeeded) -{ - context_t context; - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_client_pool_t *pool = NULL; - int64_t start; - int64_t duration; - future_t *future; - request_t *request; - char *expected_json; - bson_error_t error; - mongoc_array_t *durations; - size_t i; - - context_init (&context); - - /* auto-respond to "foo" command */ - server = mock_server_new (); - mock_server_run (server); - mock_server_autoresponds (server, responder, NULL, NULL); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, "serverSelectionTimeoutMS", 400); - - /* The start time should be before scanning is started (before the call to - * mongoc_client_pool_pop for pooled) */ - start = bson_get_monotonic_time (); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - pool_set_heartbeat_event_callbacks (pool, &context); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - client_set_heartbeat_event_callbacks (client, &context); - } - - /* trigger "hello" handshake */ - future = future_client_command_simple ( - client, "admin", tmp_bson ("{'foo': 1}"), NULL, NULL, &error); - - /* topology scanner calls hello once */ - request = mock_server_receives_any_hello (server); - - if (succeeded) { - reply_to_request ( - request, - MONGOC_REPLY_NONE, - 0, - 0, - 1, - tmp_str ("{'ok': 1, 'minWireVersion': %d, 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX)); - request_destroy (request); - } else { - reply_to_request_with_hang_up (request); - request_destroy (request); - } - - /* pooled client opens new socket, handshakes it by calling hello again */ - if (pooled && succeeded) { - request = mock_server_receives_any_hello (server); - reply_to_request ( - request, - MONGOC_REPLY_NONE, - 0, - 0, - 1, - tmp_str ("{'ok': 1, 'minWireVersion': %d, 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX)); - request_destroy (request); - } - - if (succeeded) { - /* "foo" command succeeds */ - ASSERT_OR_PRINT (future_get_bool (future), error); - } else { - ASSERT (!future_get_bool (future)); - } - - duration = bson_get_monotonic_time () - start; - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - /* even if pooled, only topology scanner sends events, so we get one pair */ - if (succeeded) { - durations = &context.heartbeat_succeeded_durations; - expected_json = bson_strdup_printf ( - "{'0': {'heartbeat_started_event': {'host': '%s', 'awaited': false}}," - " '1': {'heartbeat_succeeded_event': {'host': '%s', 'awaited': " - "false}}}", - mock_server_get_host_and_port (server), - mock_server_get_host_and_port (server)); - } else { - durations = &context.heartbeat_failed_durations; - expected_json = bson_strdup_printf ( - "{'0': {'heartbeat_started_event': {'host': '%s', 'awaited': false}}," - " '1': {'heartbeat_failed_event': {'host': '%s', 'awaited': false}}}", - mock_server_get_host_and_port (server), - mock_server_get_host_and_port (server)); - } - - ASSERT_CMPSIZE_T (durations->len, >, (size_t) 0); - for (i = 0; i < durations->len; i++) { - int64_t d = _mongoc_array_index (durations, int64_t, i); - ASSERT_CMPINT64 (d, >=, (int64_t) 0); - ASSERT_CMPINT64 (d, <=, duration); - } - - check_json_sdam_events (&context.events, tmp_bson (expected_json)); - - future_destroy (future); - bson_free (expected_json); - mongoc_uri_destroy (uri); - mock_server_destroy (server); - context_destroy (&context); -} - -static void -test_heartbeat_events_single_succeeded (void) -{ - _test_heartbeat_events (false, true); -} - -static void -test_heartbeat_events_pooled_succeeded (void) -{ - _test_heartbeat_events (true, true); -} - -static void -test_heartbeat_events_single_failed (void) -{ - _test_heartbeat_events (false, false); -} - -static void -test_heartbeat_events_pooled_failed (void) -{ - _test_heartbeat_events (true, false); -} - -static void -_test_heartbeat_fails_dns (bool pooled) -{ - context_t context; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_client_pool_t *pool = NULL; - int64_t start; - int64_t duration; - bool r; - bson_error_t error; - mongoc_array_t *durations; - size_t i; - - context_init (&context); - /* Track time before scanning starts (which is triggered by popping the first - * client for a client pool). */ - start = bson_get_monotonic_time (); - uri = mongoc_uri_new ( - "mongodb://doesntexist.invalid/?serverSelectionTimeoutMS=100"); - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - pool_set_heartbeat_event_callbacks (pool, &context); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - client_set_heartbeat_event_callbacks (client, &context); - } - - /* trigger "hello" handshake */ - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'foo': 1}"), NULL, NULL, &error); - - /* Expect a server selection error. */ - ASSERT (!r); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "No suitable servers found"); - - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - duration = bson_get_monotonic_time () - start; - - durations = &context.heartbeat_failed_durations; - - ASSERT_CMPSIZE_T (durations->len, >, (size_t) 0); - for (i = 0; i < durations->len; i++) { - int64_t d = _mongoc_array_index (durations, int64_t, i); - ASSERT_CMPINT64 (d, >=, (int64_t) 0); - ASSERT_CMPINT64 (d, <=, duration); - } - - mongoc_uri_destroy (uri); - context_destroy (&context); -} - -static void -test_heartbeat_fails_dns_single (void) -{ - _test_heartbeat_fails_dns (false); -} - -static void -test_heartbeat_fails_dns_pooled (void) -{ - _test_heartbeat_fails_dns (true); -} - -typedef struct { - uint32_t num_server_description_changed_events; - uint32_t num_topology_description_changed_events; -} duplicates_counter_t; - -void -duplicates_server_changed (const mongoc_apm_server_changed_t *event) -{ - duplicates_counter_t *counters; - - counters = mongoc_apm_server_changed_get_context (event); - counters->num_server_description_changed_events++; -} - -void -duplicates_topology_changed (const mongoc_apm_topology_changed_t *event) -{ - duplicates_counter_t *counters; - - counters = mongoc_apm_topology_changed_get_context (event); - counters->num_topology_description_changed_events++; -} - -/* Test that duplicate hello responses do not trigger two server - * description changed events or topology changed events */ -static void -test_no_duplicates (void) -{ - mock_server_t *server; - mongoc_client_pool_t *pool; - mongoc_client_t *client; - request_t *request; - bson_error_t error; - future_t *future; - mongoc_uri_t *uri; - mongoc_apm_callbacks_t *callbacks; - duplicates_counter_t duplicates_counter = {0}; - mongoc_server_description_t *sd; - - server = mock_server_new (); - mock_server_run (server); - - callbacks = mongoc_apm_callbacks_new (); - /* Set a high heartbeat frequency ms to prevent periodic background scanning - * from interfering. */ - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 99999); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - mongoc_apm_set_server_changed_cb (callbacks, duplicates_server_changed); - mongoc_apm_set_topology_changed_cb (callbacks, duplicates_topology_changed); - mongoc_client_pool_set_apm_callbacks (pool, callbacks, &duplicates_counter); - client = mongoc_client_pool_pop (pool); - - /* Topology scanning thread starts, and sends a hello. */ - request = mock_server_receives_any_hello (server); - reply_to_request_simple (request, - tmp_str ("{'ok': 1.0," - " 'isWritablePrimary': true, " - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_4_4)); - request_destroy (request); - - /* Perform a ping, which creates a new connection, which performs the - * hello handshake before sending the ping command. */ - future = future_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - request = mock_server_receives_any_hello (server); - reply_to_request_simple ( - request, - tmp_str ( - "{'ok': 1.0," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'lastWrite': {" - " 'lastWriteDate': {'$date': {'$numberLong': '123'}}, 'opTime': 2}}", - WIRE_VERSION_MIN, - WIRE_VERSION_4_4)); - request_destroy (request); - request = mock_server_receives_msg ( - server, MONGOC_QUERY_NONE, tmp_bson ("{'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - ASSERT_CMPINT ( - duplicates_counter.num_server_description_changed_events, ==, 1); - /* There should be two topology changed events. One for the initial topology - * (where the server is set to Unknown), and one for the first hello (but - * not the second) */ - ASSERT_CMPINT ( - duplicates_counter.num_topology_description_changed_events, ==, 2); - - /* Even though no topology description changed event was emitted, the newly - * created server description should still overwrite the old one in the - * topology description. It differs in that it has the 'lastWrite' field, - * which does not have an effect in equality comparison. */ - sd = mongoc_client_get_server_description (client, 1); - BSON_ASSERT (bson_has_field (&sd->last_hello_response, "lastWrite")); - mongoc_server_description_destroy (sd); - - mongoc_uri_destroy (uri); - mongoc_apm_callbacks_destroy (callbacks); - mock_server_destroy (server); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); -} - -void -test_sdam_monitoring_install (TestSuite *suite) -{ - test_all_spec_tests (suite); - TestSuite_AddLive ( - suite, - "/server_discovery_and_monitoring/monitoring/topology/single", - test_topology_events_single); - TestSuite_AddLive ( - suite, - "/server_discovery_and_monitoring/monitoring/topology/pooled", - test_topology_events_pooled); - TestSuite_AddLive ( - suite, - "/server_discovery_and_monitoring/monitoring/topology/disabled", - test_topology_events_disabled); - TestSuite_AddMockServerTest ( - suite, - "/server_discovery_and_monitoring/monitoring/heartbeat/single/succeeded", - test_heartbeat_events_single_succeeded); - TestSuite_AddMockServerTest ( - suite, - "/server_discovery_and_monitoring/monitoring/heartbeat/single/failed", - test_heartbeat_events_single_failed); - TestSuite_AddMockServerTest ( - suite, - "/server_discovery_and_monitoring/monitoring/heartbeat/pooled/succeeded", - test_heartbeat_events_pooled_succeeded); - TestSuite_AddMockServerTest ( - suite, - "/server_discovery_and_monitoring/monitoring/heartbeat/pooled/failed", - test_heartbeat_events_pooled_failed); - TestSuite_Add ( - suite, - "/server_discovery_and_monitoring/monitoring/heartbeat/single/dns", - test_heartbeat_fails_dns_single); - TestSuite_Add ( - suite, - "/server_discovery_and_monitoring/monitoring/heartbeat/pooled/dns", - test_heartbeat_fails_dns_pooled); - TestSuite_AddMockServerTest ( - suite, - "/server_discovery_and_monitoring/monitoring/no_duplicates", - test_no_duplicates, - NULL, - NULL); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-sdam.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-sdam.c deleted file mode 100644 index 2d70c08c6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-sdam.c +++ /dev/null @@ -1,954 +0,0 @@ -#include - -#include - -#include "json-test.h" - -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-topology-private.h" -#include "mongoc/mongoc-topology-description-apm-private.h" -#include "test-libmongoc.h" - -#ifdef BSON_HAVE_STRINGS_H -#include -#endif - - -static void -_topology_has_description (const mongoc_topology_description_t *topology, - bson_t *server, - const char *address) -{ - mongoc_server_description_t const *sd; - bson_iter_t server_iter; - const char *server_type; - const char *set_name; - - sd = server_description_by_hostname (topology, address); - BSON_ASSERT (sd); - - bson_iter_init (&server_iter, server); - while (bson_iter_next (&server_iter)) { - if (strcmp ("setName", bson_iter_key (&server_iter)) == 0) { - set_name = bson_iter_utf8 (&server_iter, NULL); - if (set_name) { - BSON_ASSERT (sd->set_name); - ASSERT_CMPSTR (sd->set_name, set_name); - } - /* TODO (CDRIVER-4057) this should assert that a null setName means the - server description also has no setName. Uncomment this when - CDRIVER-4057 is resolved: - - else if (sd->set_name) { - test_error ("server: %s, expected NULL setName, got: %s", address, - sd->set_name); - } - */ - } else if (strcmp ("type", bson_iter_key (&server_iter)) == 0) { - server_type = bson_iter_utf8 (&server_iter, NULL); - if (sd->type != server_type_from_test (server_type)) { - test_error ("expected server type %s not %s", - server_type, - mongoc_server_description_type (sd)); - } - } else if (strcmp ("setVersion", bson_iter_key (&server_iter)) == 0) { - int64_t expected_set_version; - if (BSON_ITER_HOLDS_NULL (&server_iter)) { - expected_set_version = MONGOC_NO_SET_VERSION; - } else { - expected_set_version = bson_iter_as_int64 (&server_iter); - } - BSON_ASSERT (sd->set_version == expected_set_version); - } else if (strcmp ("electionId", bson_iter_key (&server_iter)) == 0) { - bson_oid_t expected_oid; - if (BSON_ITER_HOLDS_NULL (&server_iter)) { - bson_oid_init_from_string (&expected_oid, - "000000000000000000000000"); - } else { - ASSERT (BSON_ITER_HOLDS_OID (&server_iter)); - bson_oid_copy (bson_iter_oid (&server_iter), &expected_oid); - } - - ASSERT_CMPOID (&sd->election_id, &expected_oid); - } else if (strcmp ("topologyVersion", bson_iter_key (&server_iter)) == - 0) { - bson_t expected_topology_version; - - if (BSON_ITER_HOLDS_NULL (&server_iter)) { - bson_init (&expected_topology_version); - } else { - ASSERT (BSON_ITER_HOLDS_DOCUMENT (&server_iter)); - bson_lookup_doc ( - server, "topologyVersion", &expected_topology_version); - } - - assert_match_bson ( - &sd->topology_version, &expected_topology_version, false); - bson_destroy (&expected_topology_version); - } else if (strcmp ("pool", bson_iter_key (&server_iter)) == 0) { - bson_iter_t iter; - uint32_t expected_generation; - - BSON_ASSERT (bson_iter_recurse (&server_iter, &iter)); - BSON_ASSERT (bson_iter_find (&iter, "generation") && - BSON_ITER_HOLDS_INT32 (&iter)); - expected_generation = bson_iter_int32 (&iter); - ASSERT_CMPINT32 (expected_generation, - ==, - mc_tpl_sd_get_generation (sd, &kZeroServiceId)); - } else if (strcmp ("logicalSessionTimeoutMinutes", - bson_iter_key (&server_iter)) == 0) { - if (BSON_ITER_HOLDS_NULL (&server_iter)) { - if (sd->session_timeout_minutes != MONGOC_NO_SESSIONS) { - test_error ("ERROR: expected unset value for " - "logicalSessionTimeoutMinutes but got: %" PRId64, - sd->session_timeout_minutes); - } - } else { - ASSERT_CMPINT64 (bson_iter_as_int64 (&server_iter), - ==, - sd->session_timeout_minutes); - } - } else if (strcmp ("minWireVersion", bson_iter_key (&server_iter)) == 0) { - if (BSON_ITER_HOLDS_NULL (&server_iter)) { - if (sd->min_wire_version != 0) { - test_error ("ERROR: expected unset value for minWireVersion but " - "got: %" PRId32, - sd->min_wire_version); - } - } else { - ASSERT_CMPINT32 ( - bson_iter_int32 (&server_iter), ==, sd->min_wire_version); - } - } else if (strcmp ("maxWireVersion", bson_iter_key (&server_iter)) == 0) { - if (BSON_ITER_HOLDS_NULL (&server_iter)) { - if (sd->max_wire_version != 0) { - test_error ("ERROR: expected unset value for maxWireVersion but " - "got: %" PRId32, - sd->max_wire_version); - } - } else { - ASSERT_CMPINT32 ( - bson_iter_int32 (&server_iter), ==, sd->max_wire_version); - } - } else { - fprintf ( - stderr, "ERROR: unparsed field %s\n", bson_iter_key (&server_iter)); - BSON_ASSERT (0); - } - } -} - -/* - *----------------------------------------------------------------------- - * - * Run the JSON tests from the Server Discovery and Monitoring spec. - * - *----------------------------------------------------------------------- - */ -static void -test_sdam_cb (bson_t *test) -{ - mongoc_client_t *client; - bson_t phase; - bson_t phases; - bson_t servers; - bson_t server; - bson_t outcome; - bson_iter_t phase_iter; - bson_iter_t phase_field_iter; - bson_iter_t servers_iter; - bson_iter_t outcome_iter; - bson_iter_t iter; - mc_tpld_modification tdmod; - mc_shared_tpld td = MC_SHARED_TPLD_NULL; - const char *set_name; - const char *hostname; - - /* parse out the uri and use it to create a client */ - BSON_ASSERT (bson_iter_init_find (&iter, test, "uri")); - client = test_framework_client_new (bson_iter_utf8 (&iter, NULL), NULL); - - /* for each phase, parse and validate */ - BSON_ASSERT (bson_iter_init_find (&iter, test, "phases")); - bson_iter_bson (&iter, &phases); - bson_iter_init (&phase_iter, &phases); - - /* LoadBalanced topologies change the server from Unknown to LoadBalancer - * when SDAM monitoring begins. Force an opening, which would occur on the - * first operation on the client. */ - tdmod = mc_tpld_modify_begin (client->topology); - _mongoc_topology_description_monitor_opening (tdmod.new_td); - mc_tpld_modify_commit (tdmod); - - while (bson_iter_next (&phase_iter)) { - bson_iter_bson (&phase_iter, &phase); - - process_sdam_test_hello_responses (&phase, client->topology); - - /* parse out "outcome" and validate */ - BSON_ASSERT (bson_iter_init_find (&phase_field_iter, &phase, "outcome")); - bson_iter_bson (&phase_field_iter, &outcome); - bson_iter_init (&outcome_iter, &outcome); - - while (bson_iter_next (&outcome_iter)) { - mc_tpld_renew_ref (&td, client->topology); - if (strcmp ("servers", bson_iter_key (&outcome_iter)) == 0) { - bson_iter_bson (&outcome_iter, &servers); - ASSERT_CMPSIZE_T (bson_count_keys (&servers), - ==, - mc_tpld_servers_const (td.ptr)->items_len); - - bson_iter_init (&servers_iter, &servers); - - /* for each server, ensure topology has a matching entry */ - while (bson_iter_next (&servers_iter)) { - hostname = bson_iter_key (&servers_iter); - bson_iter_bson (&servers_iter, &server); - - _topology_has_description (td.ptr, &server, hostname); - } - } else if (strcmp ("setName", bson_iter_key (&outcome_iter)) == 0) { - set_name = bson_iter_utf8 (&outcome_iter, NULL); - if (set_name) { - BSON_ASSERT (td.ptr->set_name); - ASSERT_CMPSTR (td.ptr->set_name, set_name); - } else { - if (td.ptr->set_name) { - test_error ("expected NULL setName, got: %s", - td.ptr->set_name); - } - } - } else if (strcmp ("topologyType", bson_iter_key (&outcome_iter)) == - 0) { - ASSERT_CMPSTR (mongoc_topology_description_type (td.ptr), - bson_iter_utf8 (&outcome_iter, NULL)); - } else if (strcmp ("logicalSessionTimeoutMinutes", - bson_iter_key (&outcome_iter)) == 0) { - if (BSON_ITER_HOLDS_NULL (&outcome_iter)) { - ASSERT_CMPINT64 (td.ptr->session_timeout_minutes, - ==, - (int64_t) MONGOC_NO_SESSIONS); - } else { - ASSERT_CMPINT64 (td.ptr->session_timeout_minutes, - ==, - bson_iter_as_int64 (&outcome_iter)); - } - } else if (strcmp ("compatible", bson_iter_key (&outcome_iter)) == 0) { - if (bson_iter_as_bool (&outcome_iter)) { - ASSERT_CMPINT (0, ==, td.ptr->compatibility_error.domain); - } else { - ASSERT_ERROR_CONTAINS (td.ptr->compatibility_error, - MONGOC_ERROR_PROTOCOL, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - ""); - } - } else if (strcmp ("maxSetVersion", bson_iter_key (&outcome_iter)) == - 0) { - if (BSON_ITER_HOLDS_NULL (&outcome_iter)) { - if (td.ptr->max_set_version != MONGOC_NO_SET_VERSION) { - test_error ("ERROR: expected unset value for maxSetVersion " - "but got: %" PRId64, - td.ptr->max_set_version); - } - } else { - ASSERT_CMPINT64 (bson_iter_as_int64 (&outcome_iter), - ==, - td.ptr->max_set_version); - } - } else if (strcmp ("maxElectionId", bson_iter_key (&outcome_iter)) == - 0) { - const bson_oid_t *expected_oid; - bson_oid_t zeroed = {.bytes = {0}}; - - expected_oid = bson_iter_oid (&outcome_iter); - - if (expected_oid == NULL) { - expected_oid = &zeroed; - } - - if (!bson_oid_equal (expected_oid, &td.ptr->max_election_id)) { - char expected_oid_str[25]; - char actual_oid_str[25]; - - bson_oid_to_string (expected_oid, expected_oid_str); - bson_oid_to_string (&td.ptr->max_election_id, actual_oid_str); - test_error ("ERROR: Expected topology description's " - "maxElectionId to be %s, but was %s", - expected_oid_str, - actual_oid_str); - } - } else if (strcmp ("logicalSessionTimeoutMinutes", - bson_iter_key (&outcome_iter)) == 0) { - if (BSON_ITER_HOLDS_NULL (&outcome_iter)) { - if (td.ptr->session_timeout_minutes != MONGOC_NO_SESSIONS) { - test_error ("ERROR: expected unset value for " - "logicalSessionTimeoutMinutes but got: %" PRId64, - td.ptr->session_timeout_minutes); - } - } else { - ASSERT_CMPINT64 (bson_iter_as_int64 (&outcome_iter), - ==, - td.ptr->session_timeout_minutes); - } - } else { - fprintf (stderr, - "ERROR: unparsed test field %s\n", - bson_iter_key (&outcome_iter)); - BSON_ASSERT (false); - } - } - } - mc_tpld_drop_ref (&td); - mongoc_client_destroy (client); -} - -/* Initialize a test context to run one SDAM integration test file. - * - * Do not use json_test_ctx_init to initialize a context. It sends commands to - * check for sessions support. That interferes with failpoints set on hello. - */ -static void -sdam_json_test_ctx_init (json_test_ctx_t *ctx, - const json_test_config_t *config, - mongoc_client_pool_t *pool) -{ - const char *db_name; - const char *coll_name; - - ASSERT (pool); - - memset (ctx, 0, sizeof (*ctx)); - ctx->config = config; - bson_init (&ctx->events); - ctx->acknowledged = true; - ctx->verbose = test_framework_getenv_bool ("MONGOC_TEST_MONITORING_VERBOSE"); - bson_init (&ctx->lsids[0]); - bson_init (&ctx->lsids[1]); - bson_mutex_init (&ctx->mutex); - - /* Pop a client, which starts topology scanning. */ - ctx->client = mongoc_client_pool_pop (pool); - ctx->test_framework_uri = mongoc_uri_copy (ctx->client->uri); - db_name = bson_lookup_utf8 (ctx->config->scenario, "database_name"); - coll_name = bson_lookup_utf8 (ctx->config->scenario, "collection_name"); - ctx->db = mongoc_client_get_database (ctx->client, db_name); - ctx->collection = mongoc_database_get_collection (ctx->db, coll_name); -} - -static void -sdam_json_test_ctx_cleanup (json_test_ctx_t *ctx) -{ - mongoc_collection_destroy (ctx->collection); - mongoc_database_destroy (ctx->db); - bson_destroy (&ctx->lsids[0]); - bson_destroy (&ctx->lsids[1]); - bson_destroy (&ctx->events); - mongoc_uri_destroy (ctx->test_framework_uri); - bson_destroy (ctx->sent_lsids[0]); - bson_destroy (ctx->sent_lsids[1]); - bson_mutex_destroy (&ctx->mutex); -} - -static bool -sdam_integration_operation_cb (json_test_ctx_t *ctx, - const bson_t *test, - const bson_t *operation) -{ - bson_t reply; - bool res; - - res = - json_test_operation (ctx, test, operation, ctx->collection, NULL, &reply); - - bson_destroy (&reply); - - return res; -} - -/* Try to get a completely clean slate by disabling failpoints on all servers. - */ -static void -deactivate_failpoints_on_all_servers (mongoc_client_t *client) -{ - uint32_t server_id; - const mongoc_set_t *servers; - bson_t cmd; - bson_error_t error; - mc_shared_tpld td; - - ASSERT (client); - - bson_init (&cmd); - BCON_APPEND (&cmd, "configureFailPoint", "failCommand", "mode", "off"); - - td = mc_tpld_take_ref (client->topology); - servers = mc_tpld_servers_const (td.ptr); - - for (size_t i = 0u; i < servers->items_len; i++) { - bool ret; - - server_id = servers->items[i].id; - ret = mongoc_client_command_simple_with_server_id (client, - "admin", - &cmd, - NULL /* read prefs */, - server_id, - NULL /* reply */, - &error); - if (!ret) { - MONGOC_DEBUG ("error disabling failpoint: %s", error.message); - } - } - - mc_tpld_drop_ref (&td); - bson_destroy (&cmd); -} - -static void -run_one_integration_test (json_test_config_t *config, bson_t *test) -{ - json_test_ctx_t ctx; - json_test_ctx_t thread_ctx[2]; - bson_error_t error; - mongoc_client_pool_t *pool; - mongoc_client_t *setup_client; - const char *db_name; - const char *coll_name; - mongoc_uri_t *uri; - - MONGOC_DEBUG ("running test: %s", bson_lookup_utf8 (test, "description")); - - uri = test_framework_get_uri (); - if (bson_has_field (test, "clientOptions")) { - bson_t client_opts; - - bson_lookup_doc (test, "clientOptions", &client_opts); - set_uri_opts_from_bson (uri, &client_opts); - } - - - db_name = bson_lookup_utf8 (config->scenario, "database_name"); - coll_name = bson_lookup_utf8 (config->scenario, "collection_name"); - - /* SDAM integration tests require streamable hello support, which is only - * available for a client pool. */ - pool = test_framework_client_pool_new_from_uri (uri, NULL); - mongoc_client_pool_set_error_api (pool, MONGOC_ERROR_API_VERSION_2); - test_framework_set_pool_ssl_opts (pool); - - setup_client = test_framework_new_default_client (); - /* Disable failpoints that may have been enabled in a previous test run. */ - deactivate_failpoints_on_all_servers (setup_client); - mongoc_client_command_simple (setup_client, - "admin", - tmp_bson ("{'killAllSessions': []}"), - NULL, - NULL, - &error); - - insert_data (db_name, coll_name, config->scenario); - - if (bson_has_field (test, "failPoint")) { - activate_fail_point (setup_client, 0, test, "failPoint"); - } - - /* Listen for events before topology scanning starts. Some tests - * check the result of the first hello command. But popping a client - * starts topology scanning. */ - set_apm_callbacks_pooled (&ctx, pool); - - sdam_json_test_ctx_init (&ctx, config, pool); - - /* Set up test contexts for worker threads, which may be used by tests that - * have "startThread" operations. These get the same APM event callbacks, - * which are protected with a mutex. */ - sdam_json_test_ctx_init (&thread_ctx[0], config, pool); - sdam_json_test_ctx_init (&thread_ctx[1], config, pool); - ctx.worker_threads[0] = worker_thread_new (&thread_ctx[0]); - ctx.worker_threads[1] = worker_thread_new (&thread_ctx[1]); - - json_test_operations (&ctx, test); - - if (bson_has_field (test, "expectations")) { - bson_t expectations; - - bson_lookup_doc (test, "expectations", &expectations); - check_json_apm_events (&ctx, &expectations); - } - - if (bson_has_field (test, "outcome.collection")) { - mongoc_collection_t *outcome_coll; - outcome_coll = mongoc_client_get_collection ( - setup_client, - mongoc_database_get_name (ctx.db), - mongoc_collection_get_name (ctx.collection)); - check_outcome_collection (outcome_coll, test); - mongoc_collection_destroy (outcome_coll); - } - - deactivate_failpoints_on_all_servers (setup_client); - worker_thread_destroy (ctx.worker_threads[0]); - worker_thread_destroy (ctx.worker_threads[1]); - mongoc_client_pool_push (pool, ctx.client); - mongoc_client_pool_push (pool, thread_ctx[0].client); - mongoc_client_pool_push (pool, thread_ctx[1].client); - - /* Capture occasionally emitted "Couldn't end \"endSessions\"" messages. */ - capture_logs (true); - mongoc_client_pool_destroy (pool); - mongoc_client_destroy (setup_client); - capture_logs (false); - - sdam_json_test_ctx_cleanup (&ctx); - sdam_json_test_ctx_cleanup (&thread_ctx[0]); - sdam_json_test_ctx_cleanup (&thread_ctx[1]); - mongoc_uri_destroy (uri); -} - -static void -test_sdam_integration_cb (bson_t *scenario) -{ - json_test_config_t config = JSON_TEST_CONFIG_INIT; - bson_iter_t tests_iter; - - config.run_operation_cb = sdam_integration_operation_cb; - config.scenario = scenario; - config.command_started_events_only = true; - - if (!check_scenario_version (scenario)) { - return; - } - - ASSERT (bson_iter_init_find (&tests_iter, scenario, "tests")); - ASSERT (bson_iter_recurse (&tests_iter, &tests_iter)); - - while (bson_iter_next (&tests_iter)) { - bson_t test; - - ASSERT (BSON_ITER_HOLDS_DOCUMENT (&tests_iter)); - bson_iter_bson (&tests_iter, &test); - run_one_integration_test (&config, &test); - } -} - -/* - *----------------------------------------------------------------------- - * - * Runner for the JSON tests for server discovery and monitoring.. - * - *----------------------------------------------------------------------- - */ -static void -test_all_spec_tests (TestSuite *suite) -{ - /* Single */ - install_json_test_suite ( - suite, JSON_DIR, "server_discovery_and_monitoring/single", &test_sdam_cb); - - /* Replica set */ - install_json_test_suite ( - suite, JSON_DIR, "server_discovery_and_monitoring/rs", &test_sdam_cb); - - /* Sharded */ - install_json_test_suite (suite, - JSON_DIR, - "server_discovery_and_monitoring/sharded", - &test_sdam_cb); - - install_json_test_suite ( - suite, JSON_DIR, "server_discovery_and_monitoring/errors", &test_sdam_cb); - - /* Tests not in official Server Discovery And Monitoring Spec */ - install_json_test_suite (suite, - JSON_DIR, - "server_discovery_and_monitoring/supplemental", - &test_sdam_cb); - - /* Integration tests. */ - /* The integration tests configure retryable writes, which requires crypto. - */ - install_json_test_suite_with_check ( - suite, - JSON_DIR, - "server_discovery_and_monitoring/integration", - &test_sdam_integration_cb, - TestSuite_CheckLive, - test_framework_skip_if_no_crypto, - test_framework_skip_if_slow); - - install_json_test_suite (suite, - JSON_DIR, - "server_discovery_and_monitoring/load-balanced", - &test_sdam_cb); -} - -static void -test_topology_discovery (void *ctx) -{ - char *host_and_port; - char *replset_name; - char *uri_str; - char *uri_str_auth; - mongoc_client_t *client; - mongoc_read_prefs_t *prefs; - mongoc_server_description_t *sd_secondary; - mongoc_host_list_t *hl_secondary; - mongoc_collection_t *collection; - bson_t doc = BSON_INITIALIZER; - bson_t reply; - bson_error_t error; - bool r; - - BSON_UNUSED (ctx); - - host_and_port = test_framework_get_host_and_port (); - replset_name = test_framework_replset_name (); - uri_str = test_framework_get_uri_str (); - - client = test_framework_client_new (uri_str, NULL); - test_framework_set_ssl_opts (client); - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - sd_secondary = mongoc_client_select_server (client, - false, /* for reads */ - prefs, - &error); - ASSERT_OR_PRINT (sd_secondary, error); - hl_secondary = mongoc_server_description_host (sd_secondary); - - /* Scenario: given a replica set deployment with a secondary, where HOST is - * the address of the secondary, create a MongoClient using - * ``mongodb://HOST/?directConnection=false`` as the URI. - * Attempt a write to a collection. - * - * Outcome: Verify that the write succeeded. */ - bson_free (uri_str); - uri_str = bson_strdup_printf ("mongodb://%s/?directConnection=false", - hl_secondary->host_and_port); - uri_str_auth = test_framework_add_user_password_from_env (uri_str); - - mongoc_client_destroy (client); - client = test_framework_client_new (uri_str_auth, NULL); - test_framework_set_ssl_opts (client); - collection = get_test_collection (client, "sdam_dc_test"); - BSON_APPEND_UTF8 (&doc, "hello", "world"); - r = mongoc_collection_insert_one (collection, &doc, NULL, &reply, &error); - ASSERT_OR_PRINT (r, error); - ASSERT_CMPINT32 (bson_lookup_int32 (&reply, "insertedCount"), ==, 1); - - bson_destroy (&reply); - bson_destroy (&doc); - mongoc_server_description_destroy (sd_secondary); - mongoc_read_prefs_destroy (prefs); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_free (uri_str_auth); - bson_free (uri_str); - bson_free (replset_name); - bson_free (host_and_port); -} - -static void -test_direct_connection (void *ctx) -{ - char *host_and_port; - char *replset_name; - char *uri_str; - char *uri_str_auth; - mongoc_client_t *client; - mongoc_read_prefs_t *prefs; - mongoc_server_description_t *sd_secondary; - mongoc_host_list_t *hl_secondary; - mongoc_collection_t *collection; - bson_t doc = BSON_INITIALIZER; - bson_t reply; - bson_error_t error; - bool r; - - BSON_UNUSED (ctx); - - host_and_port = test_framework_get_host_and_port (); - replset_name = test_framework_replset_name (); - uri_str = test_framework_get_uri_str (); - - client = test_framework_client_new (uri_str, NULL); - test_framework_set_ssl_opts (client); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - sd_secondary = mongoc_client_select_server (client, - false, /* for reads */ - prefs, - &error); - ASSERT_OR_PRINT (sd_secondary, error); - hl_secondary = mongoc_server_description_host (sd_secondary); - - /* Scenario: given a replica set deployment with a secondary, where HOST is - * the address of the secondary, create a MongoClient using - * ``mongodb://HOST/?directConnection=true`` as the URI. - * Attempt a write to a collection. - * - * Outcome: Verify that the write failed with a NotPrimary error. */ - bson_free (uri_str); - uri_str = bson_strdup_printf ("mongodb://%s/?directConnection=true", - hl_secondary->host_and_port); - uri_str_auth = test_framework_add_user_password_from_env (uri_str); - - mongoc_client_destroy (client); - client = test_framework_client_new (uri_str_auth, NULL); - test_framework_set_ssl_opts (client); - collection = get_test_collection (client, "sdam_dc_test"); - BSON_APPEND_UTF8 (&doc, "hello", "world"); - r = mongoc_collection_insert_one (collection, &doc, NULL, &reply, &error); - ASSERT_OR_PRINT (!r, error); - ASSERT (strstr (error.message, "not master") || - strstr (error.message, "not primary")); - - bson_destroy (&reply); - bson_destroy (&doc); - mongoc_server_description_destroy (sd_secondary); - mongoc_read_prefs_destroy (prefs); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_free (uri_str_auth); - bson_free (uri_str); - bson_free (replset_name); - bson_free (host_and_port); -} - -static void -test_existing_behavior (void *ctx) -{ - char *host_and_port; - char *replset_name; - char *uri_str; - char *uri_str_auth; - mongoc_client_t *client; - mongoc_read_prefs_t *prefs; - mongoc_server_description_t *sd_secondary; - mongoc_host_list_t *hl_secondary; - mongoc_collection_t *collection; - bson_t doc = BSON_INITIALIZER; - bson_t reply; - bson_error_t error; - bool r; - - BSON_UNUSED (ctx); - - host_and_port = test_framework_get_host_and_port (); - replset_name = test_framework_replset_name (); - uri_str = test_framework_get_uri_str (); - - client = test_framework_client_new (uri_str, NULL); - test_framework_set_ssl_opts (client); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - sd_secondary = mongoc_client_select_server (client, - false, /* for reads */ - prefs, - &error); - ASSERT_OR_PRINT (sd_secondary, error); - hl_secondary = mongoc_server_description_host (sd_secondary); - - /* Scenario: given a replica set deployment with a secondary, where HOST is - * the address of the secondary, create a MongoClient using - * ``mongodb://HOST/`` as the URI. - * Attempt a write to a collection. - * - * Outcome: Verify that the write succeeded or failed depending on existing - * driver behavior with respect to the starting topology. */ - bson_free (uri_str); - uri_str = bson_strdup_printf ("mongodb://%s/", hl_secondary->host_and_port); - uri_str_auth = test_framework_add_user_password_from_env (uri_str); - - mongoc_client_destroy (client); - client = test_framework_client_new (uri_str_auth, NULL); - test_framework_set_ssl_opts (client); - collection = get_test_collection (client, "sdam_dc_test"); - BSON_APPEND_UTF8 (&doc, "hello", "world"); - r = mongoc_collection_insert_one (collection, &doc, NULL, &reply, &error); - ASSERT_OR_PRINT (!r, error); - ASSERT (strstr (error.message, "not master") || - strstr (error.message, "not primary")); - - bson_destroy (&reply); - bson_destroy (&doc); - mongoc_server_description_destroy (sd_secondary); - mongoc_read_prefs_destroy (prefs); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_free (uri_str_auth); - bson_free (uri_str); - bson_free (replset_name); - bson_free (host_and_port); -} - -typedef struct { - uint32_t n_heartbeat_succeeded; -} prose_test_ctx_t; - -static void -heartbeat_succeeded (const mongoc_apm_server_heartbeat_succeeded_t *event) -{ - prose_test_ctx_t *ctx; - - ctx = - (prose_test_ctx_t *) mongoc_apm_server_heartbeat_succeeded_get_context ( - event); - ctx->n_heartbeat_succeeded++; -/* The reported duration may be 0 on Windows due to poor clock resolution. - * bson_get_monotonic_time () uses GetTickCount64. MS docs say: - * "GetTickCount64 function is limited to the resolution of the system timer, - * which is typically in the range of 10 milliseconds to 16 milliseconds" - */ -#ifndef _WIN32 - BSON_ASSERT (mongoc_apm_server_heartbeat_succeeded_get_duration (event) > 0); -#endif -} - -#define RTT_TEST_TIMEOUT_SEC 60 -#define RTT_TEST_INITIAL_SLEEP_SEC 2 -#define RTT_TEST_TICK_MS 10 - -static void -test_prose_rtt (void *unused) -{ - /* Since this tests RTT tracking in the streaming protocol, this test - * requires a client pool. */ - mongoc_client_pool_t *pool; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_error_t error; - const bson_t *doc; - mongoc_cursor_t *cursor; - mongoc_apm_callbacks_t *callbacks; - prose_test_ctx_t ctx; - bson_t cmd; - bool ret; - int64_t start_us; - bool satisfied; - int64_t rtt = 0; - - BSON_UNUSED (unused); - - uri = test_framework_get_uri (); - mongoc_uri_set_option_as_utf8 (uri, MONGOC_URI_APPNAME, "streamingRttTest"); - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 500); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_server_heartbeat_succeeded_cb (callbacks, - heartbeat_succeeded); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - memset (&ctx, 0, sizeof (prose_test_ctx_t)); - mongoc_client_pool_set_apm_callbacks (pool, callbacks, &ctx); - client = mongoc_client_pool_pop (pool); - - /* Run a find command for the server to be discovered. */ - coll = get_test_collection (client, "streamingRttTest"); - cursor = mongoc_collection_find_with_opts ( - coll, tmp_bson ("{}"), NULL /* opts */, NULL /* read prefs */); - mongoc_cursor_next (cursor, &doc); - - /* Sleep for RTT_TEST_INITIAL_SLEEP_SEC seconds to allow multiple heartbeats - * to succeed. */ - _mongoc_usleep (RTT_TEST_INITIAL_SLEEP_SEC * 1000 * 1000); - - /* Set a failpoint to make hello commands take longer. */ - bson_init (&cmd); - BCON_APPEND (&cmd, "configureFailPoint", "failCommand"); - BCON_APPEND (&cmd, "mode", "{", "times", BCON_INT32 (1000), "}"); - BCON_APPEND (&cmd, - "data", - "{", - "failCommands", - "[", - HANDSHAKE_CMD_LEGACY_HELLO, - "hello", - "]", - "blockConnection", - BCON_BOOL (true), - "blockTimeMS", - BCON_INT32 (500), - "appName", - "streamingRttTest", - "}"); - ret = mongoc_client_command_simple ( - client, "admin", &cmd, NULL /* read prefs. */, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - - /* Wait for the server's RTT to exceed 250ms. If this does not happen for - * RTT_TEST_TIMEOUT_SEC seconds, consider it a failure. */ - satisfied = false; - start_us = bson_get_monotonic_time (); - while (!satisfied && bson_get_monotonic_time () < - start_us + RTT_TEST_TIMEOUT_SEC * 1000 * 1000) { - mongoc_server_description_t *sd; - - sd = mongoc_client_select_server ( - client, true, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (sd, error); - rtt = mongoc_server_description_round_trip_time (sd); - if (rtt > 250) { - satisfied = true; - } - mongoc_server_description_destroy (sd); - _mongoc_usleep (RTT_TEST_TICK_MS * 1000); - } - - if (!satisfied) { - test_error ("After %d seconds, the latest observed RTT was only %" PRId64, - RTT_TEST_TIMEOUT_SEC, - rtt); - } - - /* Disable the failpoint. */ - bson_reinit (&cmd); - BCON_APPEND (&cmd, "configureFailPoint", "failCommand"); - BCON_APPEND (&cmd, "mode", "off"); - ret = mongoc_client_command_simple ( - client, "admin", &cmd, NULL /* read prefs. */, NULL /* reply */, &error); - ASSERT_OR_PRINT (ret, error); - - bson_destroy (&cmd); - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (coll); - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - mongoc_uri_destroy (uri); - mongoc_apm_callbacks_destroy (callbacks); - - /* Make this assertion after destroying the pool, to avoid reading while the - * monitor thread is writing. */ - BSON_ASSERT (ctx.n_heartbeat_succeeded > 0); -} - -void -test_sdam_install (TestSuite *suite) -{ - test_all_spec_tests (suite); - TestSuite_AddFull (suite, - "/server_discovery_and_monitoring/topology/discovery", - test_topology_discovery, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_not_replset); - TestSuite_AddFull (suite, - "/server_discovery_and_monitoring/directconnection", - test_direct_connection, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_not_replset); - TestSuite_AddFull (suite, - "/server_discovery_and_monitoring/existing/behavior", - test_existing_behavior, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_not_replset); - TestSuite_AddFull (suite, - "/server_discovery_and_monitoring/prose/rtt", - test_prose_rtt, - NULL /* dtor */, - NULL /* ctx */, - test_framework_skip_if_max_wire_version_less_than_9); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-description.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-description.c deleted file mode 100644 index 4a43d3259..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-description.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mongoc/mongoc.h" -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-server-description-private.h" -#include "TestSuite.h" -#include "test-conveniences.h" - -void -reset_basic_sd (mongoc_server_description_t *sd) -{ - bson_error_t error; - bson_t *hello; - - hello = BCON_NEW ("minWireVersion", - BCON_INT32 (WIRE_VERSION_MIN), - "maxWireVersion", - BCON_INT32 (WIRE_VERSION_MAX)); - - mongoc_server_description_reset (sd); - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_handle_hello (sd, hello, 0 /* rtt */, &error); - bson_destroy (hello); -} - -/* These checks will start failing and need to be updated once CDRIVER-3527 is - * addressed. */ -static void -_test_hostlist (mongoc_server_description_t *sd1, - bson_t *sd1_hostlist, - mongoc_server_description_t *sd2, - bson_t *sd2_hostlist) -{ - bson_reinit (sd1_hostlist); - bson_reinit (sd2_hostlist); - BSON_ASSERT (_mongoc_server_description_equal (sd1, sd2)); - - /* [ "h1" ] vs [] */ - BSON_APPEND_UTF8 (sd1_hostlist, "0", "h1"); - BSON_ASSERT (!_mongoc_server_description_equal (sd1, sd2)); - - /* [ "h1" ] vs [ "h1" ] */ - BSON_APPEND_UTF8 (sd2_hostlist, "0", "h1"); - BSON_ASSERT (_mongoc_server_description_equal (sd1, sd2)); - - /* [ "h1", "h2", "h3" ] vs [ "h1" ] */ - BSON_APPEND_UTF8 (sd1_hostlist, "1", "h2"); - BSON_APPEND_UTF8 (sd1_hostlist, "2", "h3"); - BSON_ASSERT (!_mongoc_server_description_equal (sd1, sd2)); - - /* [ "h1", "h2", "h3" ] vs [ "h1", "h3", "h2" ]. Considered unequal since we - * do not do a set comparison. */ - BSON_APPEND_UTF8 (sd2_hostlist, "1", "h3"); - BSON_APPEND_UTF8 (sd2_hostlist, "2", "h2"); - BSON_ASSERT (!_mongoc_server_description_equal (sd1, sd2)); - - /* [ "h1", "h1" ] vs [ "h1" ]. Considered unequal since we do not do a set - * comparison. */ - bson_reinit (sd1_hostlist); - bson_reinit (sd2_hostlist); - BSON_APPEND_UTF8 (sd1_hostlist, "0", "h1"); - BSON_APPEND_UTF8 (sd1_hostlist, "1", "h1"); - BSON_APPEND_UTF8 (sd2_hostlist, "0", "h1"); - BSON_ASSERT (!_mongoc_server_description_equal (sd1, sd2)); - - /* Arbitrary non-array like equal docs. Considered equal since we don't do - * any parsing. */ - bson_reinit (sd1_hostlist); - bson_reinit (sd2_hostlist); - BSON_APPEND_UTF8 (sd1_hostlist, "test", "h1"); - BSON_APPEND_UTF8 (sd2_hostlist, "test", "h1"); - BSON_ASSERT (_mongoc_server_description_equal (sd1, sd2)); -} - -/* Unit test of server description. */ -/* Check that variations on all (=) fields result in inequal, and variations on - * all non (=) fields do not */ -void -test_server_description_equal (void) -{ - mongoc_server_description_t sd1; - mongoc_server_description_t sd2; - - mongoc_server_description_init (&sd1, "host:1234", 1); - mongoc_server_description_init (&sd2, "host:1234", 2); - - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - BSON_ASSERT (_mongoc_server_description_equal (&sd1, &sd2)); - - /* "address" differs, still considered equal. */ - sd2.connection_address = "host2:5678"; - BSON_ASSERT (_mongoc_server_description_equal (&sd1, &sd2)); - - /* "roundTripTime" differs, still considered equal. */ - sd1.round_trip_time_msec = 1234; - BSON_ASSERT (_mongoc_server_description_equal (&sd1, &sd2)); - - /* "lastWriteDate"/"opTime" are stored in last_hello_response and not parsed - * out. Check that overwriting the stored reply does not factor into the - * equality check. */ - bson_reinit (&sd1.last_hello_response); - BSON_ASSERT (_mongoc_server_description_equal (&sd1, &sd2)); - - /* "error" differs, considered unequal. */ - bson_set_error (&sd1.error, MONGOC_ERROR_SERVER, 123, "some error"); - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "type" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.type = MONGOC_SERVER_RS_GHOST; - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "minWireVersion" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.min_wire_version = 2; - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "maxWireVersion" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.max_wire_version = 7; - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "me" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.me = "test:1234"; - sd2.me = "test:1235"; - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* But if "me" only differs only in case, considered equal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.me = "tesT:1234"; - sd2.me = "test:1234"; - BSON_ASSERT (_mongoc_server_description_equal (&sd1, &sd2)); - - /* Test variations of "hosts", "passives", and "arbiters". */ - _test_hostlist (&sd1, &sd1.hosts, &sd2, &sd2.hosts); - _test_hostlist (&sd1, &sd1.passives, &sd2, &sd2.passives); - _test_hostlist (&sd1, &sd1.arbiters, &sd2, &sd2.arbiters); - - /* "tags" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - bson_reinit (&sd1.tags); - BSON_APPEND_UTF8 (&sd1.tags, "tag", "nyc"); - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "setName" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.set_name = "set"; - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "setName" differs by case only, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.set_name = "set"; - sd2.set_name = "SET"; - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "setVersion" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.set_version = 1; - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "electionId" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - bson_oid_init_from_string (&sd1.election_id, "000000000000000000001234"); - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "primary" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.current_primary = "host"; - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "primary" differs in case only, considered equal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.current_primary = "host"; - sd2.current_primary = "HOST"; - BSON_ASSERT (_mongoc_server_description_equal (&sd1, &sd2)); - - /* "logicalSessionTimeoutMinutes" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - sd1.session_timeout_minutes = 1; - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - /* "compressors" differs, still considered equal since that is only - * applicable for handshake. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - bson_reinit (&sd1.compressors); - BSON_APPEND_UTF8 (&sd1.compressors, "0", "zstd"); - BSON_ASSERT (_mongoc_server_description_equal (&sd1, &sd2)); - - /* "topologyVersion" differs, considered unequal. */ - reset_basic_sd (&sd1); - reset_basic_sd (&sd2); - BCON_APPEND (&sd1.topology_version, "x", BCON_INT32 (1)); - BSON_ASSERT (!_mongoc_server_description_equal (&sd1, &sd2)); - - mongoc_server_description_cleanup (&sd1); - mongoc_server_description_cleanup (&sd2); -} - -/* Test that msg set to anything else besides "isdbgrid" is not considered - * server type mongos */ -void -test_server_description_msg_without_isdbgrid (void) -{ - mongoc_server_description_t sd; - bson_t *hello; - bson_error_t error; - - mongoc_server_description_init (&sd, "host:1234", 1); - hello = BCON_NEW ("minWireVersion", - BCON_INT32 (WIRE_VERSION_MIN), - "maxWireVersion", - BCON_INT32 (WIRE_VERSION_MAX), - "msg", - "isdbgrid"); - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_handle_hello (&sd, hello, 0 /* rtt */, &error); - BSON_ASSERT (sd.type == MONGOC_SERVER_MONGOS); - - mongoc_server_description_reset (&sd); - bson_destroy (hello); - hello = BCON_NEW ("minWireVersion", - BCON_INT32 (WIRE_VERSION_MIN), - "maxWireVersion", - BCON_INT32 (WIRE_VERSION_MAX), - "msg", - "something_else"); - mongoc_server_description_handle_hello (&sd, hello, 0 /* rtt */, &error); - BSON_ASSERT (sd.type == MONGOC_SERVER_STANDALONE); - - bson_destroy (hello); - mongoc_server_description_cleanup (&sd); -} - -static void -test_server_description_ignores_rtt (void) -{ - mongoc_server_description_t sd; - bson_error_t error; - bson_t hello; - - bson_init (&hello); - BCON_APPEND (&hello, "isWritablePrimary", BCON_BOOL (true)); - - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_init (&sd, "host:1234", 1); - /* Initially, the RTT is MONGOC_RTT_UNSET. */ - ASSERT_CMPINT64 (sd.round_trip_time_msec, ==, MONGOC_RTT_UNSET); - BSON_ASSERT (sd.type == MONGOC_SERVER_UNKNOWN); - /* If MONGOC_RTT_UNSET is passed as the RTT, it remains MONGOC_RTT_UNSET. */ - mongoc_server_description_handle_hello ( - &sd, &hello, MONGOC_RTT_UNSET, &error); - ASSERT_CMPINT64 (sd.round_trip_time_msec, ==, MONGOC_RTT_UNSET); - BSON_ASSERT (sd.type == MONGOC_SERVER_STANDALONE); - /* The first real RTT overwrites the stored RTT. */ - mongoc_server_description_handle_hello (&sd, &hello, 10, &error); - ASSERT_CMPINT64 (sd.round_trip_time_msec, ==, 10); - BSON_ASSERT (sd.type == MONGOC_SERVER_STANDALONE); - /* But subsequent MONGOC_RTT_UNSET values do not effect it. */ - mongoc_server_description_handle_hello ( - &sd, &hello, MONGOC_RTT_UNSET, &error); - ASSERT_CMPINT64 (sd.round_trip_time_msec, ==, 10); - BSON_ASSERT (sd.type == MONGOC_SERVER_STANDALONE); - - mongoc_server_description_cleanup (&sd); - bson_destroy (&hello); -} - -static void -test_server_description_hello (void) -{ - mongoc_server_description_t sd; - bson_error_t error; - bson_t hello_response; - - bson_init (&hello_response); - BCON_APPEND (&hello_response, "isWritablePrimary", BCON_BOOL (true)); - - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_init (&sd, "host:1234", 1); - BSON_ASSERT (sd.type == MONGOC_SERVER_UNKNOWN); - mongoc_server_description_handle_hello (&sd, &hello_response, 0, &error); - BSON_ASSERT (sd.type == MONGOC_SERVER_STANDALONE); - - mongoc_server_description_cleanup (&sd); - bson_destroy (&hello_response); -} - -static void -test_server_description_hello_cmd_not_found (void) -{ - mongoc_server_description_t sd; - bson_error_t error; - const char *response = "{" - " 'ok' : 0," - " 'errmsg' : 'no such command: \\'hello\\''," - " 'code' : 59," - " 'codeName' : 'CommandNotFound'" - "}"; - - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_init (&sd, "host:1234", 1); - BSON_ASSERT (sd.type == MONGOC_SERVER_UNKNOWN); - mongoc_server_description_handle_hello (&sd, tmp_bson (response), 0, &error); - BSON_ASSERT (sd.type == MONGOC_SERVER_UNKNOWN); - - mongoc_server_description_cleanup (&sd); -} - -static void -test_server_description_legacy_hello (void) -{ - mongoc_server_description_t sd; - bson_error_t error; - bson_t hello_response; - - bson_init (&hello_response); - BCON_APPEND ( - &hello_response, HANDSHAKE_RESPONSE_LEGACY_HELLO, BCON_BOOL (true)); - - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_init (&sd, "host:1234", 1); - BSON_ASSERT (sd.type == MONGOC_SERVER_UNKNOWN); - mongoc_server_description_handle_hello (&sd, &hello_response, 0, &error); - BSON_ASSERT (sd.type == MONGOC_SERVER_STANDALONE); - BSON_ASSERT (!sd.hello_ok); - - mongoc_server_description_cleanup (&sd); - bson_destroy (&hello_response); -} - -static void -test_server_description_legacy_hello_ok (void) -{ - mongoc_server_description_t sd; - bson_error_t error; - bson_t hello_response; - - bson_init (&hello_response); - BCON_APPEND ( - &hello_response, HANDSHAKE_RESPONSE_LEGACY_HELLO, BCON_BOOL (true)); - BCON_APPEND (&hello_response, "helloOk", BCON_BOOL (true)); - - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_init (&sd, "host:1234", 1); - BSON_ASSERT (sd.type == MONGOC_SERVER_UNKNOWN); - mongoc_server_description_handle_hello (&sd, &hello_response, 0, &error); - BSON_ASSERT (sd.type == MONGOC_SERVER_STANDALONE); - BSON_ASSERT (sd.hello_ok); - - mongoc_server_description_cleanup (&sd); - bson_destroy (&hello_response); -} - -static void -test_server_description_connection_id (void) -{ - mongoc_server_description_t sd; - bson_t *hello; - bson_error_t error; - - // Test an int32. - { - mongoc_server_description_init (&sd, "host:1234", 1); - hello = BCON_NEW ("minWireVersion", - BCON_INT32 (WIRE_VERSION_MIN), - "maxWireVersion", - BCON_INT32 (WIRE_VERSION_MAX), - "connectionId", - BCON_INT32 (1)); - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_handle_hello (&sd, hello, 0 /* rtt */, &error); - BSON_ASSERT (sd.type == MONGOC_SERVER_STANDALONE); - ASSERT_CMPINT64 (sd.server_connection_id, ==, 1); - mongoc_server_description_cleanup (&sd); - bson_destroy (hello); - } - // Test an int64. - { - mongoc_server_description_init (&sd, "host:1234", 1); - hello = BCON_NEW ("minWireVersion", - BCON_INT32 (WIRE_VERSION_MIN), - "maxWireVersion", - BCON_INT32 (WIRE_VERSION_MAX), - "connectionId", - BCON_INT64 (1)); - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_handle_hello (&sd, hello, 0 /* rtt */, &error); - BSON_ASSERT (sd.type == MONGOC_SERVER_STANDALONE); - ASSERT_CMPINT64 (sd.server_connection_id, ==, 1); - bson_destroy (hello); - mongoc_server_description_cleanup (&sd); - } - // Test a double. - { - mongoc_server_description_init (&sd, "host:1234", 1); - hello = BCON_NEW ("minWireVersion", - BCON_INT32 (WIRE_VERSION_MIN), - "maxWireVersion", - BCON_INT32 (WIRE_VERSION_MAX), - "connectionId", - BCON_DOUBLE (1)); - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_handle_hello (&sd, hello, 0 /* rtt */, &error); - BSON_ASSERT (sd.type == MONGOC_SERVER_STANDALONE); - ASSERT_CMPINT64 (sd.server_connection_id, ==, 1); - bson_destroy (hello); - mongoc_server_description_cleanup (&sd); - } -} - -static void -test_server_description_hello_type_error (void) -{ - mongoc_server_description_t sd; - bson_error_t error; - const char *hello = - "{" - " 'ok' : { '$numberInt' : '1' }," - " 'ismaster' : true," - " 'maxBsonObjectSize' : { '$numberInt' : '16777216' }," - " 'maxMessageSizeBytes' : { '$numberInt' : '48000000'}," - " 'maxWriteBatchSize' : { '$numberLong' : '565160423'}," - " 'logicalSessionTimeoutMinutes' : { '$numberInt' : '30'}," - " 'connectionId' : { '$numberLong' : '565160423'}," - " 'minWireVersion' : { '$numberInt' : '0'}," - " 'maxWireVersion' : { '$numberInt' : '15'}," - " 'readOnly' : true" - "}"; - mongoc_server_description_init (&sd, "host:1234", 1); - memset (&error, 0, sizeof (bson_error_t)); - mongoc_server_description_handle_hello (&sd, tmp_bson (hello), 0, &error); - BSON_ASSERT (sd.type == MONGOC_SERVER_UNKNOWN); - BSON_ASSERT (sd.error.code == MONGOC_ERROR_STREAM_INVALID_TYPE); - ASSERT_ERROR_CONTAINS (sd.error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_INVALID_TYPE, - "unexpected type"); - - mongoc_server_description_cleanup (&sd); -} - -void -test_server_description_install (TestSuite *suite) -{ - TestSuite_Add ( - suite, "/server_description/equal", test_server_description_equal); - TestSuite_Add (suite, - "/server_description/msg_without_isdbgrid", - test_server_description_msg_without_isdbgrid); - TestSuite_Add (suite, - "/server_description/ignores_unset_rtt", - test_server_description_ignores_rtt); - TestSuite_Add ( - suite, "/server_description/hello", test_server_description_hello); - TestSuite_Add (suite, - "/server_description/hello_cmd_not_found", - test_server_description_hello_cmd_not_found); - TestSuite_Add (suite, - "/server_description/legacy_hello", - test_server_description_legacy_hello); - TestSuite_Add (suite, - "/server_description/legacy_hello_ok", - test_server_description_legacy_hello_ok); - TestSuite_Add (suite, - "/server_description/connection_id", - test_server_description_connection_id); - TestSuite_Add (suite, - "/server_description/hello_type_error", - test_server_description_hello_type_error); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-selection-errors.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-selection-errors.c deleted file mode 100644 index e0de9960f..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-selection-errors.c +++ /dev/null @@ -1,362 +0,0 @@ -#include - -#include "mongoc/mongoc-client-pool-private.h" - -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - - -static mongoc_stream_t * -cannot_resolve (const mongoc_uri_t *uri, - const mongoc_host_list_t *host, - void *user_data, - bson_error_t *error) -{ - BSON_UNUSED (uri); - BSON_UNUSED (user_data); - - bson_set_error (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_NAME_RESOLUTION, - "Fake error for '%s'", - host->host); - - return NULL; -} - - -static void -server_selection_error_dns (const char *uri_str, - const char *errmsg, - bool expect_success, - bool pooled) -{ - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_collection_t *collection; - bson_error_t error; - bson_t *command; - bson_t reply; - bool success; - - uri = mongoc_uri_new (uri_str); - ASSERT (uri); - - if (pooled && expect_success) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - client = mongoc_client_pool_pop (pool); - } else if (pooled) { - /* we expect selection to fail; let the test finish faster */ - mongoc_uri_set_option_as_int32 (uri, "serverSelectionTimeoutMS", 100); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - _mongoc_client_pool_set_stream_initiator (pool, cannot_resolve, NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - if (!expect_success) { - mongoc_client_set_stream_initiator (client, cannot_resolve, NULL); - } - } - - collection = mongoc_client_get_collection (client, "test", "test"); - - command = tmp_bson ("{'ping': 1}"); - success = mongoc_collection_command_simple ( - collection, command, NULL, &reply, &error); - ASSERT_OR_PRINT (success == expect_success, error); - - if (!success && errmsg) { - ASSERT_CMPSTR (error.message, errmsg); - } - - bson_destroy (&reply); - mongoc_collection_destroy (collection); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); -} - -static void -test_server_selection_error_dns_direct_single (void) -{ - server_selection_error_dns ( - "mongodb://example-localhost.invalid:27017/", - "No suitable servers found (`serverSelectionTryOnce` set): " - "[Fake error for 'example-localhost.invalid']", - false, - false); -} - -static void -test_server_selection_error_dns_direct_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - server_selection_error_dns ( - "mongodb://example-localhost.invalid:27017/", - "No suitable servers found: `serverSelectionTimeoutMS` expired: " - "[Fake error for 'example-localhost.invalid']", - false, - true); -} - -static void -test_server_selection_error_dns_multi_fail_single (void) -{ - server_selection_error_dns ( - "mongodb://" - "example-localhost.invalid:27017,other-example-localhost.invalid:27017/", - "No suitable servers found (`serverSelectionTryOnce` set):" - " [Fake error for 'example-localhost.invalid']" - " [Fake error for 'other-example-localhost.invalid']", - false, - false); -} - -static void -test_server_selection_error_dns_multi_fail_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - server_selection_error_dns ( - "mongodb://" - "example-localhost.invalid:27017,other-example-localhost.invalid:27017/", - "No suitable servers found: `serverSelectionTimeoutMS` expired:" - " [Fake error for 'example-localhost.invalid']" - " [Fake error for 'other-example-localhost.invalid']", - false, - true); -} - -static void -_test_server_selection_error_dns_multi_success (bool pooled) -{ - char *host; - char *uri_str; - - host = test_framework_get_host (); - uri_str = bson_strdup_printf ("mongodb://example-localhost.invalid:27017," - "%s:%d," - "other-example-localhost.invalid:27017/", - host, - test_framework_get_port ()); - - server_selection_error_dns (uri_str, "", true, pooled); - - bson_free (uri_str); - bson_free (host); -} - -static void -test_server_selection_error_dns_multi_success_single (void *context) -{ - BSON_UNUSED (context); - - _test_server_selection_error_dns_multi_success (false); -} - -static void -test_server_selection_error_dns_multi_success_pooled (void *context) -{ - BSON_UNUSED (context); - - _test_server_selection_error_dns_multi_success (true); -} - -static void -_test_server_selection_uds_auth_failure (bool pooled) -{ - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bson_error_t error; - char *path; - char *uri_str; - - path = test_framework_get_unix_domain_socket_path_escaped (); - uri_str = bson_strdup_printf ("mongodb://user:wrongpass@%s", path); - - uri = mongoc_uri_new (uri_str); - ASSERT (uri); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); -#ifdef MONGOC_ENABLE_SSL - test_framework_set_pool_ssl_opts (pool); -#endif - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); -#ifdef MONGOC_ENABLE_SSL - test_framework_set_ssl_opts (client); -#endif - } - - capture_logs (true); - - ASSERT_OR_PRINT ( - !mongoc_client_read_command_with_opts ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL, &error), - error); - - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_CLIENT); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_CLIENT_AUTHENTICATE); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - bson_free (path); - bson_free (uri_str); - mongoc_uri_destroy (uri); -} - -static void -test_server_selection_uds_auth_failure_single (void *context) -{ - BSON_UNUSED (context); - - _test_server_selection_uds_auth_failure (false); -} - -static void -test_server_selection_uds_auth_failure_pooled (void *context) -{ - BSON_UNUSED (context); - - _test_server_selection_uds_auth_failure (true); -} - -static void -_test_server_selection_uds_not_found (bool pooled) -{ - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bson_error_t error; - - uri = mongoc_uri_new ("mongodb://%2Ftmp%2Fmongodb-so-close.sock"); - ASSERT (uri); - mongoc_uri_set_option_as_int32 (uri, "serverSelectionTimeoutMS", 100); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); -#ifdef MONGOC_ENABLE_SSL - test_framework_set_pool_ssl_opts (pool); -#endif - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); -#ifdef MONGOC_ENABLE_SSL - test_framework_set_ssl_opts (client); -#endif - } - -#ifdef MONGOC_ENABLE_SSL - test_framework_set_ssl_opts (client); -#endif - - ASSERT (!mongoc_client_read_command_with_opts ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL, &error)); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_SERVER_SELECTION); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_SERVER_SELECTION_FAILURE); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); -} - -static void -test_server_selection_uds_not_found_single (void *context) -{ - BSON_UNUSED (context); - - _test_server_selection_uds_not_found (false); -} - -static void -test_server_selection_uds_not_found_pooled (void *context) -{ - BSON_UNUSED (context); - - _test_server_selection_uds_not_found (true); -} - - -void -test_server_selection_errors_install (TestSuite *suite) -{ - TestSuite_Add (suite, - "/server_selection/errors/dns/direct/single", - test_server_selection_error_dns_direct_single); - TestSuite_AddFull (suite, - "/server_selection/errors/dns/direct/pooled", - test_server_selection_error_dns_direct_pooled, - NULL, - NULL, - test_framework_skip_if_slow); - TestSuite_Add (suite, - "/server_selection/errors/dns/multi/fail/single", - test_server_selection_error_dns_multi_fail_single); - TestSuite_AddFull (suite, - "/server_selection/errors/dns/multi/fail/pooled", - test_server_selection_error_dns_multi_fail_pooled, - NULL, - NULL, - test_framework_skip_if_slow); - TestSuite_AddFull (suite, - "/server_selection/errors/dns/multi/success/single", - test_server_selection_error_dns_multi_success_single, - NULL, - NULL, - test_framework_skip_if_single); - TestSuite_AddFull (suite, - "/server_selection/errors/dns/multi/success/pooled", - test_server_selection_error_dns_multi_success_pooled, - NULL, - NULL, - test_framework_skip_if_single); - TestSuite_AddFull (suite, - "/server_selection/errors/uds/auth_failure/single", - test_server_selection_uds_auth_failure_single, - NULL, - NULL, - test_framework_skip_if_no_uds); - TestSuite_AddFull (suite, - "/server_selection/errors/uds/auth_failure/pooled", - test_server_selection_uds_auth_failure_pooled, - NULL, - NULL, - test_framework_skip_if_no_uds); - TestSuite_AddFull (suite, - "/server_selection/errors/uds/not_found/single", - test_server_selection_uds_not_found_single, - NULL, - NULL, - test_framework_skip_if_windows); - TestSuite_AddFull (suite, - "/server_selection/errors/uds/not_found/pooled", - test_server_selection_uds_not_found_pooled, - NULL, - NULL, - test_framework_skip_if_windows); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-selection.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-selection.c deleted file mode 100644 index 3ac661c3d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-selection.c +++ /dev/null @@ -1,71 +0,0 @@ -#include - -#include "json-test.h" -#include "test-libmongoc.h" - - -/* - *----------------------------------------------------------------------- - * - * test_rtt_calculation_cb -- - * - * Runs the JSON tests for RTT calculation included with the - * Server Selection spec. - * - *----------------------------------------------------------------------- - */ - -static void -test_rtt_calculation_cb (bson_t *test) -{ - mongoc_server_description_t *description; - bson_iter_t iter; - - BSON_ASSERT (test); - - description = - (mongoc_server_description_t *) bson_malloc0 (sizeof *description); - mongoc_server_description_init (description, "localhost:27017", 1); - - /* parse RTT into server description */ - BSON_ASSERT (bson_iter_init_find (&iter, test, "avg_rtt_ms")); - description->round_trip_time_msec = bson_iter_int64 (&iter); - - /* update server description with new rtt */ - BSON_ASSERT (bson_iter_init_find (&iter, test, "new_rtt_ms")); - mongoc_server_description_update_rtt (description, bson_iter_int64 (&iter)); - - /* ensure new RTT was calculated correctly */ - BSON_ASSERT (bson_iter_init_find (&iter, test, "new_avg_rtt")); - BSON_ASSERT (description->round_trip_time_msec == bson_iter_int64 (&iter)); - - mongoc_server_description_destroy (description); -} - - -/* - *----------------------------------------------------------------------- - * - * Runner for the JSON tests for server selection. - * - *----------------------------------------------------------------------- - */ -static void -test_all_spec_tests (TestSuite *suite) -{ - /* RTT calculation */ - install_json_test_suite ( - suite, JSON_DIR, "server_selection/rtt", &test_rtt_calculation_cb); - - /* SS logic */ - install_json_test_suite (suite, - JSON_DIR, - "server_selection/server_selection", - &test_server_selection_logic_cb); -} - -void -test_server_selection_install (TestSuite *suite) -{ - test_all_spec_tests (suite); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-stream.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-stream.c deleted file mode 100644 index fc2c9967d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-server-stream.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright 2021-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mock_server/mock-server.h" -#include "mock_server/request.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mongoc.h" -#include "mongoc-client-private.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "TestSuite.h" - -#define HELLO_SERVER_ONE \ - tmp_str ("{'ok': 1," \ - " 'isWritablePrimary': true," \ - " 'minWireVersion': %d, " \ - " 'maxWireVersion': %d }", \ - WIRE_VERSION_MIN, \ - WIRE_VERSION_MIN) - -#define HELLO_SERVER_TWO \ - tmp_str ("{'ok': 1," \ - " 'isWritablePrimary': true," \ - " 'minWireVersion': %d," \ - " 'maxWireVersion': %d }", \ - WIRE_VERSION_MIN, \ - WIRE_VERSION_DELETE_HINT) - -/* run_delete_with_hint_and_wc0 runs a delete command with a "hint" option and - * unacknowledged write concern. - * - * If @expect_error is true, expect a client-side error from a maxWireVersion < - * WIRE_VERSION_DELETE_HINT. */ -static void -run_delete_with_hint_and_wc0 (bool expect_error, - mongoc_client_t *client, - mock_server_t *server) -{ - mongoc_collection_t *coll; - mongoc_write_concern_t *wc; - bson_t *delete_selector; - bson_t *delete_opts; - bool r; - bson_error_t error; - future_t *future; - request_t *request; - - ASSERT (client); - - coll = mongoc_client_get_collection (client, "db", "coll"); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED); - - delete_selector = bson_new (); - delete_opts = BCON_NEW ("hint", "{", "}"); - r = mongoc_write_concern_append (wc, delete_opts); - ASSERT_WITH_MSG (r, "mongoc_write_concern_append failed"); - - future = future_collection_delete_one ( - coll, delete_selector, delete_opts, NULL /* reply */, &error); - if (expect_error) { - /* Expect a client side error. The server does not receive anything. */ - r = future_get_bool (future); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, - "The selected server does not support hint for delete"); - ASSERT (!r); - } else { - request = mock_server_receives_msg (server, - MONGOC_MSG_MORE_TO_COME, - tmp_bson ("{ 'delete': 'coll' }"), - tmp_bson ("{'q': {}, 'hint': {}}")); - reply_to_request_with_ok_and_destroy (request); - r = future_get_bool (future); - ASSERT (r); - } - - future_destroy (future); - bson_destroy (delete_opts); - bson_destroy (delete_selector); - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (coll); -} - -/* Test that a connection uses the server description from the handshake when - * checking wire version (instead of the server description from the topology - * description). */ -static void -test_server_stream_ties_server_description_pooled (void *unused) -{ - mongoc_client_pool_t *pool; - mongoc_client_t *client_one; - mongoc_client_t *client_two; - mongoc_uri_t *uri; - mock_server_t *server; - request_t *request; - future_t *future; - bson_error_t error; - mongoc_server_description_t *sd; - - BSON_UNUSED (unused); - - server = mock_server_new (); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client_one = mongoc_client_pool_pop (pool); - client_two = mongoc_client_pool_pop (pool); - - /* Respond to the monitoring hello with server one hello. */ - request = mock_server_receives_any_hello (server); - reply_to_request_simple (request, HELLO_SERVER_ONE); - request_destroy (request); - - /* Create a connection on client_one. */ - future = future_client_command_simple (client_one, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* The first command on a pooled client creates a new connection. */ - request = mock_server_receives_any_hello (server); - reply_to_request_simple (request, HELLO_SERVER_ONE); - request_destroy (request); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* Create a connection on client_two. */ - future = future_client_command_simple (client_two, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* The first command on a pooled client creates a new connection. */ - request = mock_server_receives_any_hello (server); - reply_to_request_simple (request, HELLO_SERVER_TWO); - request_destroy (request); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* Check that selecting the server returns the second server */ - sd = mongoc_client_select_server ( - client_two, true /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (sd, error); - ASSERT_MATCH (mongoc_server_description_hello_response (sd), - tmp_str ("{'maxWireVersion': %d}", WIRE_VERSION_DELETE_HINT)); - mongoc_server_description_destroy (sd); - - /* Expect client_one to continue to use maxWireVersion=WIRE_VERSION_MIN for - * wire version checks. Expect an error when using delete with hint and - * unacknowledged write concern. */ - run_delete_with_hint_and_wc0 (true, client_one, server); - /* Expect client_two to continue to use - * maxWireVersion=WIRE_VERSION_DELETE_HINT for wire version checks. Expect no - * error when using delete with hint and unacknowledged write concern. */ - run_delete_with_hint_and_wc0 (false, client_two, server); - - mock_server_destroy (server); - mongoc_uri_destroy (uri); - mongoc_client_pool_push (pool, client_one); - mongoc_client_pool_push (pool, client_two); - mongoc_client_pool_destroy (pool); -} - -/* Test that a connection uses the server description from the handshake when - * checking wire version (instead of the server description from the topology - * description). */ -static void -test_server_stream_ties_server_description_single (void *unused) -{ - mongoc_client_t *client; - mongoc_uri_t *uri; - mock_server_t *server; - request_t *request; - future_t *future; - bson_error_t error; - mongoc_server_description_t *sd; - mc_tpld_modification tdmod; - - BSON_UNUSED (unused); - - server = mock_server_new (); - mock_server_run (server); - uri = mongoc_uri_copy (mock_server_get_uri (server)); - client = test_framework_client_new_from_uri (uri, NULL); - - /* Create a connection on client. */ - future = future_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - /* The first command on a client creates a new connection. */ - request = mock_server_receives_any_hello (server); - reply_to_request_simple (request, HELLO_SERVER_TWO); - request_destroy (request); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* Muck with the topology description. */ - /* Pass in a zeroed out error. */ - memset (&error, 0, sizeof (bson_error_t)); - tdmod = mc_tpld_modify_begin (client->topology); - mongoc_topology_description_handle_hello ( - tdmod.new_td, 1, tmp_bson (HELLO_SERVER_ONE), 0, &error); - mc_tpld_modify_commit (tdmod); - - future = future_client_command_simple (client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - &error); - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* Check that selecting the server returns the first server */ - sd = mongoc_client_select_server ( - client, true /* for writes */, NULL /* read prefs */, &error); - ASSERT_OR_PRINT (sd, error); - ASSERT_MATCH (mongoc_server_description_hello_response (sd), - tmp_str ("{'maxWireVersion': %d}", WIRE_VERSION_MIN)); - mongoc_server_description_destroy (sd); - - /* Expect client to continue to use maxWireVersion=WIRE_VERSION_DELETE_HINT - * for wire version checks. Expect no error when using delete with hint and - * unacknowledged write concern. */ - run_delete_with_hint_and_wc0 (false, client, server); - - mock_server_destroy (server); - mongoc_uri_destroy (uri); - mongoc_client_destroy (client); -} - - -void -test_server_stream_install (TestSuite *suite) -{ - TestSuite_AddFull (suite, - "/server_stream/ties_server_description/pooled", - test_server_stream_ties_server_description_pooled, - NULL /* dtor */, - NULL /* ctx */, - NULL); - TestSuite_AddFull (suite, - "/server_stream/ties_server_description/single", - test_server_stream_ties_server_description_single, - NULL /* dtor */, - NULL /* ctx */, - NULL); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-speculative-auth.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-speculative-auth.c deleted file mode 100644 index 34dcb5aed..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-speculative-auth.c +++ /dev/null @@ -1,632 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#ifdef _POSIX_VERSION -#include -#endif - -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-handshake.h" -#include "mongoc/mongoc-handshake-private.h" - -#include "TestSuite.h" -#include "test-libmongoc.h" -#include "test-conveniences.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" - -typedef void (*setup_uri_options_t) (mongoc_uri_t *uri); -typedef void (*compare_auth_command_t) (bson_t *auth_command); -typedef void (*post_handshake_commands_t) (mock_server_t *server); - -#ifdef MONGOC_ENABLE_CRYPTO - -/* For single threaded clients, we execute a command to cause a hello to be - * sent */ -static future_t * -_force_hello_with_ping (mongoc_client_t *client) -{ - future_t *future; - - ASSERT (client); - - /* Send a ping */ - future = future_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL); - - ASSERT (future); - return future; -} - -/* Call after we've dealt with the hello sent by - * _force_hello_with_ping */ -static void -_respond_to_ping (future_t *future, mock_server_t *server, bool expect_ping) -{ - request_t *request; - - ASSERT (future); - - if (!expect_ping) { - BSON_ASSERT (!future_get_bool (future)); - future_destroy (future); - - return; - } - - request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin', 'ping': 1}")); - - ASSERT (request); - - reply_to_request_simple (request, "{'ok': 1}"); - - ASSERT (future_get_bool (future)); - request_destroy (request); - future_destroy (future); -} - -static bool -_auto_hello_without_speculative_auth (request_t *request, void *data) -{ - const char *response_json = (const char *) data; - char *quotes_replaced; - - if (!request->is_command) { - return false; - } - - if (strcasecmp (request->command_name, HANDSHAKE_CMD_LEGACY_HELLO) && - strcmp (request->command_name, "hello")) { - return false; - } - - if (bson_has_field (request_get_doc (request, 0), - "speculativeAuthenticate")) { - return false; - } - - quotes_replaced = single_quotes_to_double (response_json); - - if (mock_server_get_rand_delay (request->server)) { - _mongoc_usleep ((int64_t) (rand () % 10) * 1000); - } - - reply_to_request (request, MONGOC_REPLY_NONE, 0, 0, 1, response_json); - - bson_free (quotes_replaced); - request_destroy (request); - return true; -} - -static void -_test_mongoc_speculative_auth (bool pooled, - bool use_ssl, - setup_uri_options_t setup_uri_options, - bool includes_speculative_auth, - compare_auth_command_t compare_auth_command, - bson_t *speculative_auth_response, - post_handshake_commands_t post_hello_commands, - bool expect_successful_ping) -{ - mock_server_t *server; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_client_pool_t *pool = NULL; - future_t *future; - - mongoc_ssl_opt_t client_ssl_opts = {0}; - mongoc_ssl_opt_t server_ssl_opts = {0}; - client_ssl_opts.ca_file = CERT_CA; - client_ssl_opts.pem_file = CERT_CLIENT; - server_ssl_opts.ca_file = CERT_CA; - server_ssl_opts.pem_file = CERT_SERVER; - - server = mock_server_new (); - -#ifdef MONGOC_ENABLE_SSL - if (use_ssl) { - mock_server_set_ssl_opts (server, &server_ssl_opts); - } -#endif - - mock_server_autoresponds (server, - _auto_hello_without_speculative_auth, - (void *) tmp_str ("{'ok': 1," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX), - NULL); - - mock_server_run (server); - - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 15000); - - if (setup_uri_options) { - setup_uri_options (uri); - } - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - -#ifdef MONGOC_ENABLE_SSL - if (use_ssl) { - mongoc_client_pool_set_ssl_opts (pool, &client_ssl_opts); - } -#endif - - /* Force topology scanner to start */ - client = mongoc_client_pool_pop (pool); - /* suppress the auth failure logs from pooled clients. */ - capture_logs (true); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - -#ifdef MONGOC_ENABLE_SSL - if (use_ssl) { - mongoc_client_set_ssl_opts (client, &client_ssl_opts); - } -#endif - } - - future = _force_hello_with_ping (client); - - if (includes_speculative_auth) { - request_t *request; - const bson_t *request_doc; - bson_t *response; - char *str; - - request = mock_server_receives_any_hello (server); - ASSERT (request); - request_doc = request_get_doc (request, 0); - ASSERT (request_doc); - ASSERT (bson_has_field (request_doc, "speculativeAuthenticate")); - - if (compare_auth_command) { - bson_t auth_cmd; - - bson_lookup_doc (request_doc, "speculativeAuthenticate", &auth_cmd); - compare_auth_command (&auth_cmd); - } - - /* Include authentication information in response */ - response = BCON_NEW ("ok", - BCON_INT32 (1), - "isWritablePrimary", - BCON_BOOL (true), - "minWireVersion", - BCON_INT32 (WIRE_VERSION_MIN), - "maxWireVersion", - BCON_INT32 (WIRE_VERSION_MAX)); - - if (speculative_auth_response) { - BSON_APPEND_DOCUMENT ( - response, "speculativeAuthenticate", speculative_auth_response); - } - - str = bson_as_canonical_extended_json (response, NULL); - reply_to_request_simple (request, str); - - bson_free (str); - bson_destroy (response); - request_destroy (request); - } - - if (post_hello_commands) { - post_hello_commands (server); - } - - _respond_to_ping (future, server, expect_successful_ping); - - /* Cleanup */ - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - -static void -_setup_speculative_auth_scram (mongoc_uri_t *uri) -{ - mongoc_uri_set_username (uri, "sasl"); - mongoc_uri_set_password (uri, "sasl"); -} - -static void -_compare_auth_cmd_scram (bson_t *auth_cmd) -{ - bson_iter_t iter; - - ASSERT (bson_has_field (auth_cmd, "saslStart")); - ASSERT (bson_has_field (auth_cmd, "payload")); - ASSERT (bson_iter_init_find (&iter, auth_cmd, "db")); - ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), "admin"); -} - -static void -_post_hello_scram_invalid_auth_response (mock_server_t *srv) -{ - request_t *request; - const bson_t *request_doc; - - request = mock_server_receives_msg ( - srv, MONGOC_MSG_NONE, tmp_bson ("{'$db': 'admin'}")); - ASSERT (request); - request_doc = request_get_doc (request, 0); - ASSERT (request_doc); - - /* Speculative authentication was not successful because the mock server - * can't respond with a valid scram payload. This results in a new - * authentication attempt being started using an explicit saslStart command. - */ - ASSERT_CMPSTR (request->command_name, "saslStart"); - - /* Let authentication fail directly since we won't be able to continue the - * scram conversation. */ - reply_to_request_simple ( - request, "{ 'ok': 1, 'errmsg': 'Cannot mock scram auth conversation' }"); - - request_destroy (request); -} - -static void -test_mongoc_speculative_auth_request_none (void) -{ - _test_mongoc_speculative_auth ( - false, false, NULL, false, NULL, NULL, NULL, true); -} - -static void -test_mongoc_speculative_auth_request_none_pool (void) -{ - _test_mongoc_speculative_auth ( - true, false, NULL, false, NULL, NULL, NULL, true); -} - - -#if defined(MONGOC_ENABLE_SSL_OPENSSL) || \ - defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) -static void -_setup_speculative_auth_x_509 (mongoc_uri_t *uri) -{ - mongoc_uri_set_auth_mechanism (uri, "MONGODB-X509"); - mongoc_uri_set_username ( - uri, - "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry"); -} - -static void -_compare_auth_cmd_x509 (bson_t *auth_cmd) -{ - bson_t *expected_auth_cmd = BCON_NEW ( - "authenticate", - BCON_INT32 (1), - "mechanism", - BCON_UTF8 ("MONGODB-X509"), - "user", - BCON_UTF8 ( - "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry"), - "db", - BCON_UTF8 ("$external")); - - char *auth_cmd_str = bson_as_canonical_extended_json (auth_cmd, NULL); - char *expected_auth_cmd_str = - bson_as_canonical_extended_json (expected_auth_cmd, NULL); - - ASSERT_CMPSTR (auth_cmd_str, expected_auth_cmd_str); - - bson_free (auth_cmd_str); - bson_free (expected_auth_cmd_str); - bson_destroy (expected_auth_cmd); -} - -static void -test_mongoc_speculative_auth_request_x509 (void) -{ - bson_t *response = - BCON_NEW ("dbname", - BCON_UTF8 ("$external"), - "user", - BCON_UTF8 ("CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=" - "myState,C=myCountry")); - - _test_mongoc_speculative_auth (false, - true, - _setup_speculative_auth_x_509, - true, - _compare_auth_cmd_x509, - response, - NULL, - true); - - bson_destroy (response); -} - -static void -test_mongoc_speculative_auth_request_x509_pool (void) -{ - bson_t *response = - BCON_NEW ("dbname", - BCON_UTF8 ("$external"), - "user", - BCON_UTF8 ("CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=" - "myState,C=myCountry")); - - _test_mongoc_speculative_auth (true, - true, - _setup_speculative_auth_x_509, - true, - _compare_auth_cmd_x509, - response, - NULL, - true); - - bson_destroy (response); -} - -// test_mongoc_speculative_auth_request_x509_network_error is a regression test -// for CDRIVER-4635. -static void -test_mongoc_speculative_auth_request_x509_network_error (void) -{ - // Start mock server. - mock_server_t *server; - { - mongoc_ssl_opt_t server_ssl_opts = {0}; - server_ssl_opts.ca_file = CERT_CA; - server_ssl_opts.pem_file = CERT_SERVER; - server = mock_server_new (); - mock_server_set_ssl_opts (server, &server_ssl_opts); - mock_server_run (server); - } - - // Create URI configured for X509 authentication. - mongoc_uri_t *uri; - { - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 15000); - _setup_speculative_auth_x_509 (uri); - } - - // Create single threaded client. - mongoc_client_t *client; - { - mongoc_ssl_opt_t client_ssl_opts = {0}; - client_ssl_opts.ca_file = CERT_CA; - client_ssl_opts.pem_file = CERT_CLIENT; - client = test_framework_client_new_from_uri (uri, NULL); - ASSERT (client); - mongoc_client_set_ssl_opts (client, &client_ssl_opts); - } - - // Send a ping, and receive a network error. - { - bson_error_t error; - - // Send ping. - future_t *future = future_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - - // Expect a hello including speculativeAuthenticate field. - { - request_t *request = mock_server_receives_any_hello (server); - ASSERT (request); - const bson_t *request_doc = request_get_doc (request, 0); - ASSERT (request_doc); - char *request_str = - bson_as_canonical_extended_json (request_doc, NULL); - ASSERT_WITH_MSG ( - bson_has_field (request_doc, "speculativeAuthenticate"), - "expected hello to contain 'speculativeAuthenticate', got: %s", - request_str); - // Respond with a non-empty document "speculativeAuthenticate" field. - // The C driver will interpret this as a successful X509 - // authentication. - bson_t *response = BCON_NEW ("ok", - BCON_INT32 (1), - "isWritablePrimary", - BCON_BOOL (true), - "minWireVersion", - BCON_INT32 (WIRE_VERSION_MIN), - "maxWireVersion", - BCON_INT32 (WIRE_VERSION_MAX), - "speculativeAuthenticate", - "{", - "foo", - "bar", - "}"); - - char *response_str = bson_as_canonical_extended_json (response, NULL); - reply_to_request_simple (request, response_str); - bson_free (response_str); - bson_destroy (response); - bson_free (request_str); - request_destroy (request); - } - - // Expect a ping command. Respond with a network error. - { - request_t *request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'ping': 1}")); - ASSERT (request); - // Cause a network error. - reply_to_request_with_hang_up (request); - request_destroy (request); - } - - // Expect error. - ASSERT (!future_get_bool (future)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_SOCKET, - "socket error"); - future_destroy (future); - } - - // Send another ping, expect another "speculativeAuthenticate" attempt. - { - bson_error_t error; - - // Send ping. - future_t *future = future_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - - // Expect a hello including speculativeAuthenticate field. - { - request_t *request = mock_server_receives_any_hello (server); - ASSERT (request); - const bson_t *request_doc = request_get_doc (request, 0); - ASSERT (request_doc); - char *request_str = - bson_as_canonical_extended_json (request_doc, NULL); - ASSERT_WITH_MSG ( - bson_has_field (request_doc, "speculativeAuthenticate"), - "expected hello to contain 'speculativeAuthenticate', got: %s", - request_str); - // Respond with a non-empty document "speculativeAuthenticate" field. - // The C driver will interpret this as a successful X509 - // authentication. - bson_t *response = BCON_NEW ("ok", - BCON_INT32 (1), - "isWritablePrimary", - BCON_BOOL (true), - "minWireVersion", - BCON_INT32 (WIRE_VERSION_MIN), - "maxWireVersion", - BCON_INT32 (WIRE_VERSION_MAX), - "speculativeAuthenticate", - "{", - "foo", - "bar", - "}"); - - char *response_str = bson_as_canonical_extended_json (response, NULL); - reply_to_request_simple (request, response_str); - bson_free (response_str); - bson_destroy (response); - request_destroy (request); - bson_free (request_str); - } - - // Expect a ping command. Respond with {"ok": 1}. - { - request_t *request = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'ping': 1}")); - ASSERT (request); - reply_to_request_with_ok_and_destroy (request); - } - - // Expect success. - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - } - - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - -#endif // defined(MONGOC_ENABLE_SSL_OPENSSL) || - // defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) - - -static void -test_mongoc_speculative_auth_request_scram (void) -{ - bson_t *response = BCON_NEW ( - "conversationId", - BCON_INT32 (15081984), - "payload", - BCON_BIN (BSON_SUBTYPE_BINARY, (const uint8_t *) "deadbeef", 8)); - - _test_mongoc_speculative_auth (false, - false, - _setup_speculative_auth_scram, - true, - _compare_auth_cmd_scram, - response, - _post_hello_scram_invalid_auth_response, - false); - - bson_destroy (response); -} - -static void -test_mongoc_speculative_auth_request_scram_pool (void) -{ - bson_t *response = BCON_NEW ( - "conversationId", - BCON_INT32 (15081984), - "payload", - BCON_BIN (BSON_SUBTYPE_BINARY, (const uint8_t *) "deadbeef", 8)); - - _test_mongoc_speculative_auth (true, - false, - _setup_speculative_auth_scram, - true, - _compare_auth_cmd_scram, - response, - _post_hello_scram_invalid_auth_response, - false); - - bson_destroy (response); -} -#endif /* MONGOC_ENABLE_CRYPTO */ - -void -test_speculative_auth_install (TestSuite *suite) -{ -#ifdef MONGOC_ENABLE_CRYPTO - TestSuite_AddMockServerTest (suite, - "/speculative_auth/request_none", - test_mongoc_speculative_auth_request_none); - TestSuite_AddMockServerTest (suite, - "/speculative_auth/request_scram", - test_mongoc_speculative_auth_request_scram); - TestSuite_AddMockServerTest (suite, - "/speculative_auth_pool/request_none", - test_mongoc_speculative_auth_request_none_pool); -#if defined(MONGOC_ENABLE_SSL_OPENSSL) || \ - defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) - TestSuite_AddMockServerTest (suite, - "/speculative_auth/request_x509", - test_mongoc_speculative_auth_request_x509); - TestSuite_AddMockServerTest (suite, - "/speculative_auth_pool/request_x509", - test_mongoc_speculative_auth_request_x509_pool); - TestSuite_AddMockServerTest ( - suite, - "/speculative_auth/request_x509/network_error", - test_mongoc_speculative_auth_request_x509_network_error); -#endif /* MONGOC_ENABLE_SSL_* */ - TestSuite_AddMockServerTest ( - suite, - "/speculative_auth_pool/request_scram", - test_mongoc_speculative_auth_request_scram_pool); -#endif /* MONGOC_ENABLE_CRYPTO */ -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-ssl.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-ssl.c deleted file mode 100644 index 9a2e01e7b..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-ssl.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright 2021-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "TestSuite.h" -#include "mongoc-config.h" -#include "test-conveniences.h" - -#ifdef MONGOC_ENABLE_SSL -#include "mongoc-ssl-private.h" - -typedef struct { - const char *description; - const char *bson; - const char *expect_error; - const char *expect_pem_file; - const char *expect_pem_pwd; - const char *expect_ca_file; - bool expect_weak_cert_validation; - bool expect_allow_invalid_hostname; - bool expect_disable_ocsp_endpoint_check; - bool expect_disable_certificate_revocation_check; -} testcase_t; - -/* -The following are the only valid options for _mongoc_ssl_opts_from_bson: - -MONGOC_URI_TLSCERTIFICATEKEYFILE "tlscertificatekeyfile" -MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD "tlscertificatekeyfilepassword" -MONGOC_URI_TLSCAFILE "tlscafile" -MONGOC_URI_TLSALLOWINVALIDCERTIFICATES "tlsallowinvalidcertificates" -MONGOC_URI_TLSALLOWINVALIDHOSTNAMES "tlsallowinvalidhostnames" -MONGOC_URI_TLSINSECURE "tlsinsecure" -MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK -"tlsdisablecertificaterevocationcheck" -MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK "tlsdisableocspendpointcheck" -*/ - -static void -test_mongoc_ssl_opts_from_bson (void) -{ - testcase_t tests[] = { - { - "test all options set", - "{'tlsCertificateKeyFile': 'test_pem_file', " - "'tlsCertificateKeyFilePassword': 'test_pem_pwd', 'tlsCAFile': " - "'test_ca_file', 'tlsAllowInvalidCertificates': true, " - "'tlsAllowInvalidHostnames': true, 'tlsInsecure': true, " - "'tlsDisableCertificateRevocationCheck': true, " - "'tlsDisableOCSPEndpointCheck': true }", - NULL /* expect_error */, - "test_pem_file" /* pem_file */, - "test_pem_pwd" /* pem_pwd */, - "test_ca_file" /* ca_file */, - true /* weak_cert_validation */, - true /* allow_invalid_hostname */, - true /* disable_ocsp_endpoint_check */, - true /* disable_certificate_revocation_check */ - }, - { - "test options are case insentive", - "{'tlscertificatekeyfile': 'test_pem_file', " - "'tlscertificatekeyfilepassword': 'test_pem_pwd', 'tlscafile': " - "'test_ca_file', 'tlsallowinvalidcertificates': true, " - "'tlsallowinvalidhostnames': true, 'tlsinsecure': true, " - "'tlsdisablecertificaterevocationcheck': true, " - "'tlsdisableocspendpointcheck': true }", - NULL /* expect_error */, - "test_pem_file" /* pem_file */, - "test_pem_pwd" /* pem_pwd */, - "test_ca_file" /* ca_file */, - true /* weak_cert_validation */, - true /* allow_invalid_hostname */, - true /* disable_ocsp_endpoint_check */, - true /* disable_certificate_revocation_check */ - }, - { - "test no options set", - "{}", - NULL /* expect_error */, - NULL /* pem_file */, - NULL /* pem_pwd */, - NULL /* ca_file */, - false /* weak_cert_validation */, - false /* allow_invalid_hostname */, - false /* disable_ocsp_endpoint_check */, - false /* disable_certificate_revocation_check */ - }, - { - "test tlsInsecure overrides tlsAllowInvalidHostnames and " - "tlsAllowInvalidCertificates set", - "{'tlsInsecure': true, 'tlsAllowInvalidHostnames': false, " - "'tlsAllowInvalidCertificates': false}", - NULL /* expect_error */, - NULL /* pem_file */, - NULL /* pem_pwd */, - NULL /* ca_file */, - true /* weak_cert_validation */, - true /* allow_invalid_hostname */, - false /* disable_ocsp_endpoint_check */, - false /* disable_certificate_revocation_check */ - }, - { - "test unrecognized option", - "{'foo': true }", - "unexpected BOOL option: foo" /* expect_error */, - NULL /* pem_file */, - NULL /* pem_pwd */, - NULL /* ca_file */, - false /* weak_cert_validation */, - false /* allow_invalid_hostname */, - false /* disable_ocsp_endpoint_check */, - false /* disable_certificate_revocation_check */ - }, - { - "test wrong value type", - "{'tlsCaFile': true }", - "unexpected BOOL option: tlsCaFile" /* expect_error */, - NULL /* pem_file */, - NULL /* pem_pwd */, - NULL /* ca_file */, - false /* weak_cert_validation */, - false /* allow_invalid_hostname */, - false /* disable_ocsp_endpoint_check */, - false /* disable_certificate_revocation_check */ - }, - {0}}; - testcase_t *test; - - for (test = tests; test->bson != NULL; test++) { - mongoc_ssl_opt_t ssl_opt = {0}; - bson_string_t *errmsg = bson_string_new (NULL); - bool ok = - _mongoc_ssl_opts_from_bson (&ssl_opt, tmp_bson (test->bson), errmsg); - - MONGOC_DEBUG ("testcase: %s", test->bson); - if (test->expect_error) { - ASSERT_CONTAINS (errmsg->str, test->expect_error); - ASSERT (!ok); - } else { - if (!ok) { - test_error ("unexpected error parsing: %s", errmsg->str); - } - } - - if (!test->expect_pem_file) { - ASSERT (!ssl_opt.pem_file); - } else { - ASSERT (ssl_opt.pem_file); - ASSERT_CMPSTR (test->expect_pem_file, ssl_opt.pem_file); - } - - if (!test->expect_pem_pwd) { - ASSERT (!ssl_opt.pem_pwd); - } else { - ASSERT (ssl_opt.pem_pwd); - ASSERT_CMPSTR (test->expect_pem_pwd, ssl_opt.pem_pwd); - } - - if (!test->expect_ca_file) { - ASSERT (!ssl_opt.ca_file); - } else { - ASSERT (ssl_opt.ca_file); - ASSERT_CMPSTR (test->expect_ca_file, ssl_opt.ca_file); - } - - ASSERT (test->expect_weak_cert_validation == - ssl_opt.weak_cert_validation); - ASSERT (test->expect_allow_invalid_hostname == - ssl_opt.allow_invalid_hostname); - ASSERT (test->expect_disable_ocsp_endpoint_check == - _mongoc_ssl_opts_disable_ocsp_endpoint_check (&ssl_opt)); - ASSERT (test->expect_disable_certificate_revocation_check == - _mongoc_ssl_opts_disable_certificate_revocation_check (&ssl_opt)); - - /* It is not possible to set ca_dir or crl_file. */ - ASSERT (!ssl_opt.ca_dir); - ASSERT (!ssl_opt.crl_file); - - _mongoc_ssl_opts_cleanup (&ssl_opt, true /* free_internal */); - bson_string_free (errmsg, true /* free_segment */); - } -} - -/* Test that it is safe to call _mongoc_ssl_opts_cleanup on a zero'd struct. */ -static void -test_mongoc_ssl_opts_cleanup_zero (void) -{ - mongoc_ssl_opt_t ssl_opt = {0}; - - _mongoc_ssl_opts_cleanup (&ssl_opt, true /* free_internal */); - _mongoc_ssl_opts_cleanup (&ssl_opt, false /* free_internal */); -} - -#endif /* MONGOC_ENABLE_SSL */ - -void -test_ssl_install (TestSuite *suite) -{ -#ifdef MONGOC_ENABLE_SSL - TestSuite_Add (suite, "/ssl_opt/from_bson", test_mongoc_ssl_opts_from_bson); - TestSuite_Add (suite, "/ssl_opt/cleanup", test_mongoc_ssl_opts_cleanup_zero); -#endif /* MONGOC_ENABLE_SSL */ -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-stream.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-stream.c deleted file mode 100644 index b3a86cf72..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-stream.c +++ /dev/null @@ -1,289 +0,0 @@ - -#include -#include -#include -#include - -#include "TestSuite.h" - - -static void -test_buffered_basic (void) -{ - mongoc_stream_t *stream; - mongoc_stream_t *buffered; - mongoc_iovec_t iov; - ssize_t r; - char buf[16236]; - - stream = - mongoc_stream_file_new_for_path (BINARY_DIR "/reply2.dat", O_RDONLY, 0); - BSON_ASSERT (stream); - - /* buffered assumes ownership of stream */ - buffered = mongoc_stream_buffered_new (stream, 1024); - - /* try to read large chunk larger than buffer. */ - iov.iov_len = sizeof buf; - iov.iov_base = buf; - r = mongoc_stream_readv (buffered, &iov, 1, iov.iov_len, -1); - if (r != iov.iov_len) { - char msg[100]; - - bson_snprintf (msg, - 100, - "Expected %lld got %llu", - (long long) r, - (unsigned long long) iov.iov_len); - ASSERT_CMPSTR (msg, "failed"); - } - - /* cleanup */ - mongoc_stream_destroy (buffered); -} - - -static void -test_buffered_oversized (void) -{ - mongoc_stream_t *stream; - mongoc_stream_t *buffered; - mongoc_iovec_t iov; - ssize_t r; - char buf[16236]; - - stream = - mongoc_stream_file_new_for_path (BINARY_DIR "/reply2.dat", O_RDONLY, 0); - BSON_ASSERT (stream); - - /* buffered assumes ownership of stream */ - buffered = mongoc_stream_buffered_new (stream, 20000); - - /* try to read large chunk larger than buffer. */ - iov.iov_len = sizeof buf; - iov.iov_base = buf; - r = mongoc_stream_readv (buffered, &iov, 1, iov.iov_len, -1); - if (r != iov.iov_len) { - char msg[100]; - - bson_snprintf (msg, - 100, - "Expected %lld got %llu", - (long long) r, - (unsigned long long) iov.iov_len); - ASSERT_CMPSTR (msg, "failed"); - } - - /* cleanup */ - mongoc_stream_destroy (buffered); -} - - -typedef struct { - mongoc_stream_t vtable; - ssize_t rval; -} failing_stream_t; - -static ssize_t -failing_stream_writev (mongoc_stream_t *stream, - mongoc_iovec_t *iov, - size_t iovcnt, - int32_t timeout_msec) -{ - failing_stream_t *fstream = (failing_stream_t *) stream; - - BSON_UNUSED (iov); - BSON_UNUSED (iovcnt); - BSON_UNUSED (timeout_msec); - - return fstream->rval; -} - -void -failing_stream_destroy (mongoc_stream_t *stream) -{ - bson_free (stream); -} - -static mongoc_stream_t * -failing_stream_new (ssize_t rval) -{ - failing_stream_t *stream; - - stream = bson_malloc0 (sizeof *stream); - stream->vtable.type = 999; - stream->vtable.writev = failing_stream_writev; - stream->vtable.destroy = failing_stream_destroy; - stream->rval = rval; - - return (mongoc_stream_t *) stream; -} - - -static void -test_stream_writev_full (void) -{ - mongoc_stream_t *error_stream = failing_stream_new (-1); - mongoc_stream_t *short_stream = failing_stream_new (10); - mongoc_stream_t *success_stream = failing_stream_new (100); - char bufa[20]; - char bufb[80]; - bool r; - mongoc_iovec_t iov[2]; - bson_error_t error = {0}; - const char *error_message = "Failure during socket delivery: "; - const char *short_message = "Failure to send all requested bytes (only " - "sent: 10/100 in 100ms) during socket delivery"; - - iov[0].iov_base = bufa; - iov[0].iov_len = sizeof (bufa); - iov[1].iov_base = bufb; - iov[1].iov_len = sizeof (bufb); - - errno = EINVAL; - r = _mongoc_stream_writev_full (error_stream, iov, 2, 100, &error); - - BSON_ASSERT (!r); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_STREAM); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_STREAM_SOCKET); - ASSERT_STARTSWITH (error.message, error_message); - - errno = 0; - r = _mongoc_stream_writev_full (short_stream, iov, 2, 100, &error); - BSON_ASSERT (!r); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_STREAM); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_STREAM_SOCKET); - ASSERT_CMPSTR (error.message, short_message); - - errno = 0; - r = _mongoc_stream_writev_full (success_stream, iov, 2, 100, &error); - BSON_ASSERT (r); - - mongoc_stream_destroy (error_stream); - mongoc_stream_destroy (short_stream); - mongoc_stream_destroy (success_stream); -} - -typedef struct { - mongoc_stream_t vtable; - int32_t timeout_msec; - bool is_set; -} writev_timeout_stream_t; - -static void -_writev_timeout_stream_destroy (mongoc_stream_t *stream) -{ - bson_free (stream); -} - -static ssize_t -_writev_timeout_stream_writev (mongoc_stream_t *stream_param, - mongoc_iovec_t *iov, - size_t iovcnt, - int32_t timeout_msec) -{ - BSON_UNUSED (iov); - BSON_UNUSED (iovcnt); - - writev_timeout_stream_t *const stream = - (writev_timeout_stream_t *) stream_param; - - stream->is_set = true; - stream->timeout_msec = timeout_msec; - - return 0; -} - -static writev_timeout_stream_t * -_writev_timeout_stream_new (void) -{ - writev_timeout_stream_t *const stream = - bson_malloc (sizeof (writev_timeout_stream_t)); - - *stream = (writev_timeout_stream_t){ - .vtable = - { - .type = 999, // For testing purposes. - .destroy = _writev_timeout_stream_destroy, - .writev = _writev_timeout_stream_writev, - }, - .is_set = false, - .timeout_msec = 0, - }; - - return stream; -} - -static void -test_stream_writev_timeout (void) -{ - bson_error_t error; - - uint8_t data[1] = {0}; - mongoc_iovec_t iov = {.iov_base = (void *) data, .iov_len = 1u}; - - // A positive timeout value should be forwarded as-is to the writev function. - { - writev_timeout_stream_t *const stream = _writev_timeout_stream_new (); - - ssize_t const res = - _mongoc_stream_writev_full ((mongoc_stream_t *) stream, - &iov, - 1u, - MONGOC_DEFAULT_SOCKETTIMEOUTMS, - &error); - ASSERT_CMPSSIZE_T (res, ==, 0); - ASSERT_WITH_MSG ( - stream->is_set, - "expected _writev_timeout_stream_writev() to be invoked"); - ASSERT_CMPINT32 ( - stream->timeout_msec, ==, MONGOC_DEFAULT_SOCKETTIMEOUTMS); - - mongoc_stream_destroy ((mongoc_stream_t *) stream); - } - - // A timeout value of 0 should be forwarded as-is to the writev function. - { - writev_timeout_stream_t *const stream = _writev_timeout_stream_new (); - - ssize_t const res = _mongoc_stream_writev_full ( - (mongoc_stream_t *) stream, &iov, 1u, 0, &error); - ASSERT_CMPSSIZE_T (res, ==, 0); - ASSERT_WITH_MSG ( - stream->is_set, - "expected _writev_timeout_stream_writev() to be invoked"); - ASSERT_CMPINT32 (stream->timeout_msec, ==, 0); - - mongoc_stream_destroy ((mongoc_stream_t *) stream); - } - - // CDRIVER-4781: a negative timeout value will fallback to an unspecified - // default value. The writev function should receive the unspecified default - // timeout value rather than the negative timeout value. - { - // See: MONGOC_DEFAULT_TIMEOUT_MSEC in mongoc-stream.c. - const int32_t default_timeout_msec = 60 * 60 * 1000; - - writev_timeout_stream_t *const stream = _writev_timeout_stream_new (); - - ssize_t const res = _mongoc_stream_writev_full ( - (mongoc_stream_t *) stream, &iov, 1u, -1, &error); - ASSERT_CMPSSIZE_T (res, ==, 0); - ASSERT_WITH_MSG ( - stream->is_set, - "expected _writev_timeout_stream_writev() to be invoked"); - ASSERT_CMPINT32 (stream->timeout_msec, ==, default_timeout_msec); - - mongoc_stream_destroy ((mongoc_stream_t *) stream); - } -} - - -void -test_stream_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/Stream/buffered/basic", test_buffered_basic); - TestSuite_Add (suite, "/Stream/buffered/oversized", test_buffered_oversized); - TestSuite_Add (suite, "/Stream/writev/full", test_stream_writev_full); - TestSuite_Add (suite, "/Stream/writev/timeout", test_stream_writev_timeout); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-streamable-hello.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-streamable-hello.c deleted file mode 100644 index e4f376d32..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-streamable-hello.c +++ /dev/null @@ -1,201 +0,0 @@ -#include - -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-topology-private.h" -#include "mongoc/mongoc-topology-description-private.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "streamable-hello" - -#define TV1 \ - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 1 }" -#define TV2 \ - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 2 }" - -static mongoc_server_description_t * -_force_scan (mongoc_client_t *client, mock_server_t *server, const char *hello) -{ - bson_error_t error; - request_t *request; - future_t *future; - mongoc_server_description_t *sd; - - ASSERT (client); - - /* Mark the topology as "stale" to trigger a scan. */ - client->topology->stale = true; - future = - future_client_select_server (client, true /* for writes */, NULL, &error); - request = mock_server_receives_any_hello (server); - reply_to_request_simple (request, hello); - sd = future_get_mongoc_server_description_ptr (future); - BSON_ASSERT (sd); - - future_destroy (future); - request_destroy (request); - return sd; -} - -static void -test_topology_version_update (void) -{ - mongoc_client_t *client; - mock_server_t *server; - mongoc_server_description_t *sd; - - server = mock_server_new (); - mock_server_run (server); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - /* Override minHeartbeatFrequencyMS so test does not wait for 500ms when a - * scan is needed. */ - client->topology->min_heartbeat_frequency_msec = 1; - - sd = _force_scan (client, - server, - tmp_str ("{'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'topologyVersion': " TV1 "}", - WIRE_VERSION_MIN, - WIRE_VERSION_4_4)); - ASSERT_MATCH (&sd->topology_version, TV1); - mongoc_server_description_destroy (sd); - - /* Returned topology version with higher counter overrides. */ - sd = _force_scan (client, - server, - tmp_str ("{ 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'topologyVersion': " TV2 "}", - WIRE_VERSION_MIN, - WIRE_VERSION_4_4)); - ASSERT_MATCH (&sd->topology_version, TV2); - mongoc_server_description_destroy (sd); - - /* But returned topology version with lower counter does nothing. */ - sd = _force_scan (client, - server, - tmp_str ("{'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'topologyVersion': " TV1 "}", - WIRE_VERSION_MIN, - WIRE_VERSION_4_4)); - ASSERT_MATCH (&sd->topology_version, TV2); - mongoc_server_description_destroy (sd); - - /* Empty topology version overrides. */ - sd = _force_scan (client, - server, - tmp_str ("{'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d}", - WIRE_VERSION_MIN, - WIRE_VERSION_4_4)); - BSON_ASSERT (bson_empty (&sd->topology_version)); - mongoc_server_description_destroy (sd); - - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static char * -_single_to_double (const char *in) -{ - char *in_copy; - char *iter; - - in_copy = bson_strdup (in); - - for (iter = in_copy; *iter; iter++) { - if (*iter == '\'') { - *iter = '"'; - } - } - return in_copy; -} - -static void -_assert_topology_version_compare (const char *tv1, - const char *tv2, - int expected) -{ - int actual; - bson_t *tv1_bson; - bson_t *tv2_bson; - bson_error_t error; - char *tv1_quoted = _single_to_double (tv1); - char *tv2_quoted = _single_to_double (tv2); - - tv1_bson = bson_new_from_json ( - (const uint8_t *) tv1_quoted, strlen (tv1_quoted), &error); - ASSERT_OR_PRINT (tv1_bson, error); - - tv2_bson = bson_new_from_json ( - (const uint8_t *) tv2_quoted, strlen (tv2_quoted), &error); - ASSERT_OR_PRINT (tv2_bson, error); - - actual = mongoc_server_description_topology_version_cmp (tv1_bson, tv2_bson); - ASSERT_CMPINT (actual, ==, expected); - - bson_free (tv1_quoted); - bson_free (tv2_quoted); - bson_destroy (tv1_bson); - bson_destroy (tv2_bson); -} - -static void -test_topology_version_compare (void) -{ - _assert_topology_version_compare ( - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 1 }", - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 2 }", - -1); - _assert_topology_version_compare ( - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 1 }", - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 1 }", - 0); - _assert_topology_version_compare ( - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 2 }", - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 1 }", - 1); - /* Different process IDs always compare less. */ - _assert_topology_version_compare ( - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 1 }", - "{ 'processId': { '$oid': 'CCCCCCCCCCCCCCCCCCCCCCCC' }, 'counter': 1 }", - -1); - /* Missing fields or malformed always compare less. */ - _assert_topology_version_compare ( - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 1 }", - "{ }", - -1); - _assert_topology_version_compare ( - "{ }", - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 1 }", - -1); - _assert_topology_version_compare ( - "{ 'counter': 2 }", - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 1 }", - -1); -} - -void -test_streamable_hello_install (TestSuite *suite) -{ - TestSuite_AddMockServerTest (suite, - "/streamable/topology_version/update", - test_topology_version_update); - TestSuite_Add (suite, - "/streamable/topology_version/compare", - test_topology_version_compare); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-topology-description.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-topology-description.c deleted file mode 100644 index 7159a2361..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-topology-description.c +++ /dev/null @@ -1,373 +0,0 @@ -#include "mongoc/mongoc.h" -#include "mongoc/mongoc-set-private.h" -#include "mongoc/mongoc-client-pool-private.h" -#include "mongoc/mongoc-client-private.h" - -#include "TestSuite.h" -#include "test-libmongoc.h" -#include "test-conveniences.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "topology-test" - -static void -_test_has_readable_writable_server (bool pooled) -{ - mongoc_client_t *client = NULL; - mongoc_client_pool_t *pool = NULL; - mc_shared_tpld td; - mongoc_read_prefs_t *prefs; - bool r; - bson_error_t error; - mongoc_topology_t *topology; - - if (pooled) { - pool = test_framework_new_default_client_pool (); - topology = _mongoc_client_pool_get_topology (pool); - } else { - client = test_framework_new_default_client (); - topology = client->topology; - } - td = mc_tpld_take_ref (topology); - - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_read_prefs_set_tags (prefs, tmp_bson ("[{'tag': 'does-not-exist'}]")); - - /* not yet connected */ - ASSERT (!mongoc_topology_description_has_writable_server (td.ptr)); - ASSERT (!mongoc_topology_description_has_readable_server (td.ptr, NULL)); - ASSERT (!mongoc_topology_description_has_readable_server (td.ptr, prefs)); - - /* get a client if necessary, and trigger connection */ - if (pooled) { - client = mongoc_client_pool_pop (pool); - } - - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - - mc_tpld_renew_ref (&td, topology); - ASSERT (mongoc_topology_description_has_writable_server (td.ptr)); - ASSERT (mongoc_topology_description_has_readable_server (td.ptr, NULL)); - - if (test_framework_is_replset ()) { - /* prefs still don't match any server */ - mc_tpld_renew_ref (&td, topology); - ASSERT (!mongoc_topology_description_has_readable_server (td.ptr, prefs)); - } else { - /* topology type single ignores read preference */ - mc_tpld_renew_ref (&td, topology); - ASSERT (mongoc_topology_description_has_readable_server (td.ptr, prefs)); - } - - mongoc_read_prefs_destroy (prefs); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - mc_tpld_drop_ref (&td); -} - - -static void -test_has_readable_writable_server_single (void) -{ - _test_has_readable_writable_server (false); -} - - -static void -test_has_readable_writable_server_pooled (void) -{ - _test_has_readable_writable_server (true); -} - - -static const mongoc_server_description_t * -_sd_for_host (mongoc_topology_description_t *td, const char *host) -{ - const mongoc_server_description_t *sd; - mongoc_set_t const *servers = mc_tpld_servers_const (td); - - for (size_t i = 0u; i < servers->items_len; i++) { - sd = mongoc_set_get_item_const (servers, i); - - if (!strcmp (sd->host.host, host)) { - return sd; - } - } - - return NULL; -} - - -static void -test_get_servers (void) -{ - mongoc_uri_t *uri; - mongoc_topology_t *topology; - const mongoc_server_description_t *sd_a; - const mongoc_server_description_t *sd_c; - mongoc_server_description_t **sds; - mc_tpld_modification tdmod; - size_t n; - - uri = mongoc_uri_new ("mongodb://a,b,c"); - topology = mongoc_topology_new (uri, true /* single-threaded */); - tdmod = mc_tpld_modify_begin (topology); - - /* servers "a" and "c" are mongos, but "b" remains unknown */ - sd_a = _sd_for_host (tdmod.new_td, "a"); - mongoc_topology_description_handle_hello ( - tdmod.new_td, - sd_a->id, - tmp_bson ("{'ok': 1, 'msg': 'isdbgrid'}"), - 100, - NULL); - - sd_c = _sd_for_host (tdmod.new_td, "c"); - mongoc_topology_description_handle_hello ( - tdmod.new_td, - sd_c->id, - tmp_bson ("{'ok': 1, 'msg': 'isdbgrid'}"), - 100, - NULL); - - sds = mongoc_topology_description_get_servers (tdmod.new_td, &n); - ASSERT_CMPSIZE_T ((size_t) 2, ==, n); - - /* we don't care which order the servers are returned */ - if (sds[0]->id == sd_a->id) { - ASSERT_CMPSTR ("a", sds[0]->host.host); - ASSERT_CMPSTR ("c", sds[1]->host.host); - } else { - ASSERT_CMPSTR ("c", sds[0]->host.host); - ASSERT_CMPSTR ("a", sds[1]->host.host); - } - - mongoc_server_descriptions_destroy_all (sds, n); - mc_tpld_modify_drop (tdmod); - mongoc_topology_destroy (topology); - mongoc_uri_destroy (uri); -} - -#define TV_1 \ - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 1 }" -#define TV_2 \ - "{ 'processId': { '$oid': 'AABBAABBAABBAABBAABBAABB' }, 'counter': 2 }" - -void -_topology_changed (const mongoc_apm_topology_changed_t *event) -{ - int *num_calls; - - num_calls = (int *) mongoc_apm_topology_changed_get_context (event); - (*num_calls)++; -} - -/* Regression test for CDRIVER-3753. */ -static void -test_topology_version_equal (void) -{ - mongoc_uri_t *uri; - mongoc_topology_t *topology; - const mongoc_server_description_t *sd; - mongoc_apm_callbacks_t *callbacks; - int num_calls = 0; - mc_tpld_modification tdmod; - - uri = mongoc_uri_new ("mongodb://host"); - topology = mongoc_topology_new (uri, true /* single-threaded */); - tdmod = mc_tpld_modify_begin (topology); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_topology_changed_cb (callbacks, _topology_changed); - mongoc_topology_set_apm_callbacks ( - topology, tdmod.new_td, callbacks, &num_calls); - - sd = _sd_for_host (tdmod.new_td, "host"); - mongoc_topology_description_handle_hello ( - tdmod.new_td, - sd->id, - tmp_bson ("{'ok': 1, 'topologyVersion': " TV_2 " }"), - 100, - NULL); - - ASSERT_CMPINT (num_calls, ==, 1); - - /* The subsequent hello has a topologyVersion that compares less, so the - * hello skips. */ - mongoc_topology_description_handle_hello ( - tdmod.new_td, - sd->id, - tmp_bson ("{'ok': 1, 'topologyVersion': " TV_1 " }"), - 100, - NULL); - - ASSERT_CMPINT (num_calls, ==, 1); - - mongoc_apm_callbacks_destroy (callbacks); - mc_tpld_modify_drop (tdmod); - mongoc_topology_destroy (topology); - mongoc_uri_destroy (uri); -} - -static void -test_topology_description_new_copy (void) -{ - mongoc_uri_t *uri; - mongoc_topology_t *topology; - mongoc_topology_description_t *td_copy; - const mongoc_server_description_t *sd_a; - const mongoc_server_description_t *sd_c; - mongoc_server_description_t **sds; - mc_tpld_modification tdmod; - size_t n; - - uri = mongoc_uri_new ("mongodb://a,b,c"); - topology = mongoc_topology_new (uri, true /* single-threaded */); - tdmod = mc_tpld_modify_begin (topology); - - td_copy = mongoc_topology_description_new_copy (tdmod.new_td); - - /* servers "a" and "c" are mongos, but "b" remains unknown */ - sd_a = _sd_for_host (tdmod.new_td, "a"); - mongoc_topology_description_handle_hello ( - tdmod.new_td, - sd_a->id, - tmp_bson ("{'ok': 1, 'msg': 'isdbgrid'}"), - 100, - NULL); - - sd_c = _sd_for_host (tdmod.new_td, "c"); - mongoc_topology_description_handle_hello ( - tdmod.new_td, - sd_c->id, - tmp_bson ("{'ok': 1, 'msg': 'isdbgrid'}"), - 100, - NULL); - - /* td was copied before original was updated */ - sds = mongoc_topology_description_get_servers (td_copy, &n); - ASSERT_CMPSIZE_T ((size_t) 0, ==, n); - - mongoc_server_descriptions_destroy_all (sds, n); - mongoc_topology_description_destroy (td_copy); - - td_copy = mongoc_topology_description_new_copy (tdmod.new_td); - - mc_tpld_modify_drop (tdmod); - mongoc_topology_destroy (topology); - mongoc_uri_destroy (uri); - - /* td was copied after original was updated, but before it was destroyed */ - sds = mongoc_topology_description_get_servers (td_copy, &n); - ASSERT_CMPSIZE_T ((size_t) 2, ==, n); - - mongoc_server_descriptions_destroy_all (sds, n); - mongoc_topology_description_destroy (td_copy); -} - -/* Test that _mongoc_topology_description_clear_connection_pool increments the - * generation. - */ -static void -test_topology_pool_clear (void) -{ - mongoc_topology_t *topology; - mc_tpld_modification tdmod; - mongoc_uri_t *uri; - - uri = mongoc_uri_new ("mongodb://localhost:27017,localhost:27018"); - topology = mongoc_topology_new (uri, true); - tdmod = mc_tpld_modify_begin (topology); - - ASSERT_CMPUINT32 (0, - ==, - _mongoc_topology_get_connection_pool_generation ( - tdmod.new_td, 1, &kZeroServiceId)); - ASSERT_CMPUINT32 (0, - ==, - _mongoc_topology_get_connection_pool_generation ( - tdmod.new_td, 2, &kZeroServiceId)); - _mongoc_topology_description_clear_connection_pool ( - tdmod.new_td, 1, &kZeroServiceId); - ASSERT_CMPUINT32 (1, - ==, - _mongoc_topology_get_connection_pool_generation ( - tdmod.new_td, 1, &kZeroServiceId)); - ASSERT_CMPUINT32 (0, - ==, - _mongoc_topology_get_connection_pool_generation ( - tdmod.new_td, 2, &kZeroServiceId)); - - mongoc_uri_destroy (uri); - mc_tpld_modify_drop (tdmod); - mongoc_topology_destroy (topology); -} - -static void -test_topology_pool_clear_by_serviceid (void) -{ - mongoc_topology_t *topology; - mongoc_uri_t *uri; - bson_oid_t oid_a; - bson_oid_t oid_b; - mc_tpld_modification tdmod; - - uri = mongoc_uri_new ("mongodb://localhost:27017"); - topology = mongoc_topology_new (uri, true); - - bson_oid_init_from_string (&oid_a, "AAAAAAAAAAAAAAAAAAAAAAAA"); - bson_oid_init_from_string (&oid_b, "BBBBBBBBBBBBBBBBBBBBBBBB"); - - tdmod = mc_tpld_modify_begin (topology); - ASSERT_CMPUINT32 (0, - ==, - _mongoc_topology_get_connection_pool_generation ( - tdmod.new_td, 1, &oid_a)); - ASSERT_CMPUINT32 (0, - ==, - _mongoc_topology_get_connection_pool_generation ( - tdmod.new_td, 1, &oid_b)); - _mongoc_topology_description_clear_connection_pool (tdmod.new_td, 1, &oid_a); - ASSERT_CMPUINT32 (1, - ==, - _mongoc_topology_get_connection_pool_generation ( - tdmod.new_td, 1, &oid_a)); - ASSERT_CMPUINT32 (0, - ==, - _mongoc_topology_get_connection_pool_generation ( - tdmod.new_td, 1, &oid_b)); - - mongoc_uri_destroy (uri); - mc_tpld_modify_drop (tdmod); - mongoc_topology_destroy (topology); -} - -void -test_topology_description_install (TestSuite *suite) -{ - TestSuite_AddLive (suite, - "/TopologyDescription/readable_writable/single", - test_has_readable_writable_server_single); - TestSuite_AddLive (suite, - "/TopologyDescription/readable_writable/pooled", - test_has_readable_writable_server_pooled); - TestSuite_Add (suite, "/TopologyDescription/get_servers", test_get_servers); - TestSuite_Add (suite, - "/TopologyDescription/topology_version_equal", - test_topology_version_equal); - TestSuite_Add (suite, - "/TopologyDescription/new_copy", - test_topology_description_new_copy); - TestSuite_Add ( - suite, "/TopologyDescription/pool_clear", test_topology_pool_clear); - TestSuite_Add (suite, - "/TopologyDescription/pool_clear_by_serviceid", - test_topology_pool_clear_by_serviceid); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-topology-reconcile.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-topology-reconcile.c deleted file mode 100644 index 3af05c234..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-topology-reconcile.c +++ /dev/null @@ -1,710 +0,0 @@ -#include - -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-client-pool-private.h" -#include "mongoc/mongoc-util-private.h" -#include "mongoc/utlist.h" - -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "mock_server/mock-server.h" -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "topology-reconcile-test" - - -static mongoc_topology_scanner_node_t * -get_node (mongoc_topology_t *topology, const char *host_and_port) -{ - mongoc_topology_scanner_t *ts; - mongoc_topology_scanner_node_t *node; - mongoc_topology_scanner_node_t *sought = NULL; - BSON_ASSERT (topology->single_threaded); - - ts = topology->scanner; - - DL_FOREACH (ts->nodes, node) - { - if (!strcmp (host_and_port, node->host.host_and_port)) { - sought = node; - break; - } - } - - return sought; -} - - -static bool -has_server_description (const mongoc_topology_t *topology, - const char *host_and_port) -{ - mc_shared_tpld td = mc_tpld_take_ref (topology); - const mongoc_set_t *servers = mc_tpld_servers_const (td.ptr); - bool found = false; - const mongoc_server_description_t *sd; - - for (size_t i = 0; i < servers->items_len; i++) { - sd = mongoc_set_get_item_const (servers, i); - if (!strcmp (sd->host.host_and_port, host_and_port)) { - found = true; - break; - } - } - - mc_tpld_drop_ref (&td); - return found; -} - - -bool -selects_server (mongoc_client_t *client, - mongoc_read_prefs_t *read_prefs, - mock_server_t *server) -{ - bson_error_t error; - mongoc_server_description_t *sd; - bool result; - - ASSERT (client); - - sd = mongoc_topology_select ( - client->topology, MONGOC_SS_READ, read_prefs, NULL, &error); - - if (!sd) { - fprintf (stderr, "%s\n", error.message); - return false; - } - - result = (0 == strcmp (mongoc_server_description_host (sd)->host_and_port, - mock_server_get_host_and_port (server))); - - mongoc_server_description_destroy (sd); - - return result; -} - - -static void -_test_topology_reconcile_rs (bool pooled) -{ - mock_server_t *server0; - mock_server_t *server1; - char *uri_str; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - debug_stream_stats_t debug_stream_stats = {0}; - mongoc_read_prefs_t *secondary_read_prefs; - mongoc_read_prefs_t *primary_read_prefs; - mongoc_read_prefs_t *tag_read_prefs; - - server0 = mock_server_new (); - server1 = mock_server_new (); - mock_server_run (server0); - mock_server_run (server1); - - /* secondary, no tags */ - RS_RESPONSE_TO_HELLO ( - server0, WIRE_VERSION_MIN, false, false, server0, server1); - /* primary, no tags */ - RS_RESPONSE_TO_HELLO ( - server1, WIRE_VERSION_MIN, true, false, server0, server1); - - /* provide secondary in seed list */ - uri_str = bson_strdup_printf ("mongodb://%s/?replicaSet=rs", - mock_server_get_host_and_port (server0)); - - uri = mongoc_uri_new (uri_str); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new (uri_str, NULL); - } - - if (!pooled) { - test_framework_set_debug_stream (client, &debug_stream_stats); - } - - secondary_read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - primary_read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - tag_read_prefs = mongoc_read_prefs_new (MONGOC_READ_NEAREST); - mongoc_read_prefs_add_tag (tag_read_prefs, tmp_bson ("{'key': 'value'}")); - - /* - * server0 is selected, server1 is discovered and added to scanner. - */ - BSON_ASSERT (selects_server (client, secondary_read_prefs, server0)); - if (!pooled) { - BSON_ASSERT ( - get_node (client->topology, mock_server_get_host_and_port (server1))); - } - - /* - * select again with mode "primary": server1 is selected. - */ - BSON_ASSERT (selects_server (client, primary_read_prefs, server1)); - - /* - * remove server1 from set. server0 is the primary, with tags. - */ - RS_RESPONSE_TO_HELLO ( - server0, WIRE_VERSION_MIN, true, true, server0); /* server1 absent */ - - BSON_ASSERT (selects_server (client, tag_read_prefs, server0)); - BSON_ASSERT (!client->topology->stale); - - if (!pooled) { - ASSERT_CMPINT (1, ==, debug_stream_stats.n_failed); - } - - /* - * server1 returns as a secondary. its scanner node is un-retired. - */ - RS_RESPONSE_TO_HELLO ( - server0, WIRE_VERSION_MIN, true, true, server0, server1); - RS_RESPONSE_TO_HELLO ( - server1, WIRE_VERSION_MIN, false, false, server0, server1); - - BSON_ASSERT (selects_server (client, secondary_read_prefs, server1)); - - if (!pooled) { - /* no additional failed streams */ - ASSERT_CMPINT (1, ==, debug_stream_stats.n_failed); - } - - mongoc_read_prefs_destroy (primary_read_prefs); - mongoc_read_prefs_destroy (secondary_read_prefs); - mongoc_read_prefs_destroy (tag_read_prefs); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); - bson_free (uri_str); - mock_server_destroy (server1); - mock_server_destroy (server0); -} - - -static void -test_topology_reconcile_rs_single (void) -{ - _test_topology_reconcile_rs (false); -} - - -static void -test_topology_reconcile_rs_pooled (void) -{ - _test_topology_reconcile_rs (true); -} - - -static void -_test_topology_reconcile_sharded (bool pooled) -{ - mock_server_t *mongos; - mock_server_t *secondary; - char *uri_str; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - mongoc_read_prefs_t *primary_read_prefs; - bson_error_t error; - future_t *future; - request_t *request; - char *secondary_response; - mongoc_server_description_t *sd; - - mongos = mock_server_new (); - secondary = mock_server_new (); - mock_server_run (mongos); - mock_server_run (secondary); - - /* provide both servers in seed list */ - uri_str = bson_strdup_printf ("mongodb://%s,%s", - mock_server_get_host_and_port (mongos), - mock_server_get_host_and_port (secondary)); - - uri = mongoc_uri_new (uri_str); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new (uri_str, NULL); - } - - primary_read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - future = future_topology_select ( - client->topology, MONGOC_SS_READ, primary_read_prefs, NULL, &error); - - /* mongos */ - request = mock_server_receives_any_hello (mongos); - reply_to_request_simple (request, - tmp_str ("{'ok': 1," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'msg': 'isdbgrid'}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX)); - - request_destroy (request); - - /* make sure the mongos response is processed first */ - _mongoc_usleep (1000 * 1000); - - /* replica set secondary - topology removes it */ - request = mock_server_receives_any_hello (secondary); - secondary_response = - bson_strdup_printf ("{'ok': 1, " - " 'setName': 'rs'," - " 'isWritablePrimary': false," - " 'secondary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'hosts': ['%s', '%s']}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX, - mock_server_get_host_and_port (mongos), - mock_server_get_host_and_port (secondary)); - - reply_to_request_simple (request, secondary_response); - - request_destroy (request); - - /* - * mongos is selected, secondary is removed. - */ - sd = future_get_mongoc_server_description_ptr (future); - ASSERT_CMPSTR (sd->host.host_and_port, - mock_server_get_host_and_port (mongos)); - - if (!pooled) { - BSON_ASSERT (!get_node (client->topology, - mock_server_get_host_and_port (secondary))); - } - - mongoc_server_description_destroy (sd); - bson_free (secondary_response); - mongoc_read_prefs_destroy (primary_read_prefs); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - future_destroy (future); - mongoc_uri_destroy (uri); - bson_free (uri_str); - mock_server_destroy (secondary); - mock_server_destroy (mongos); -} - - -static void -test_topology_reconcile_sharded_single (void) -{ - _test_topology_reconcile_sharded (false); -} - - -static void -test_topology_reconcile_sharded_pooled (void) -{ - _test_topology_reconcile_sharded (true); -} - - -typedef struct { - bson_mutex_t mutex; - size_t servers; -} reconcile_test_data_t; - - -static void -server_opening (const mongoc_apm_server_opening_t *event) -{ - reconcile_test_data_t *data = (reconcile_test_data_t *) event->context; - - bson_mutex_lock (&data->mutex); - data->servers++; - bson_mutex_unlock (&data->mutex); -} - - -static void -test_topology_reconcile_from_handshake (void *ctx) -{ - reconcile_test_data_t data; - mongoc_apm_callbacks_t *callbacks; - char *host_and_port; - char *replset_name; - char *uri_str; - mongoc_uri_t *uri; - mongoc_client_pool_t *pool; - mongoc_topology_t *topology; - mongoc_client_t *client; - bool r; - bson_error_t error; - int count; - mongoc_topology_scanner_node_t *node; - mc_shared_tpld td = MC_SHARED_TPLD_NULL; - mongoc_async_cmd_t *cmd; - - BSON_UNUSED (ctx); - - bson_mutex_init (&data.mutex); - data.servers = 0; - - callbacks = mongoc_apm_callbacks_new (); - - /* single seed - not the full test_framework_get_uri */ - host_and_port = test_framework_get_host_and_port (); - replset_name = test_framework_replset_name (); - uri_str = bson_strdup_printf ( - "mongodb://%s/?replicaSet=%s", host_and_port, replset_name); - - uri = mongoc_uri_new (uri_str); - pool = test_framework_client_pool_new_from_uri (uri, NULL); - mongoc_apm_set_server_opening_cb (callbacks, server_opening); - mongoc_client_pool_set_apm_callbacks (pool, callbacks, &data); - test_framework_set_pool_ssl_opts (pool); - - /* make the bg thread lose the data race: prevent it starting by pretending - * it already has */ - topology = _mongoc_client_pool_get_topology (pool); - topology->scanner_state = MONGOC_TOPOLOGY_SCANNER_BG_RUNNING; - - /* ordinarily would start bg thread */ - client = mongoc_client_pool_pop (pool); - - /* command in the foreground (hello, just because it doesn't need auth) */ - r = mongoc_client_read_command_with_opts ( - client, - "admin", - tmp_bson ("{'" HANDSHAKE_CMD_LEGACY_HELLO "': 1}"), - NULL, - tmp_bson ("{'serverId': 1}"), - NULL, - &error); - - ASSERT_OR_PRINT (r, error); - - /* added server descriptions */ - mc_tpld_renew_ref (&td, topology); - ASSERT_CMPSIZE_T (mc_tpld_servers_const (td.ptr)->items_len, >, (size_t) 1); - mc_tpld_drop_ref (&td); - - /* didn't add nodes yet, since we're not in the scanner loop */ - DL_COUNT (topology->scanner->nodes, node, count); - ASSERT_CMPINT (count, ==, 1); - - /* if CDRIVER-2073 isn't fixed, then when we discovered the other replicas - * during the handshake, we also created mongoc_async_cmd_t's for them - */ - DL_COUNT (topology->scanner->async->cmds, cmd, count); - ASSERT_CMPINT (count, ==, 0); - - /* allow pool to start scanner thread */ - bson_atomic_int_exchange (&topology->scanner_state, - MONGOC_TOPOLOGY_SCANNER_OFF, - bson_memory_order_seq_cst); - mongoc_client_pool_push (pool, client); - client = mongoc_client_pool_pop (pool); - - /* no serverId, waits for topology scan */ - r = mongoc_client_read_command_with_opts ( - client, - "admin", - tmp_bson ("{'" HANDSHAKE_CMD_LEGACY_HELLO "': 1}"), - NULL, - NULL, - NULL, - &error); - - ASSERT_OR_PRINT (r, error); - bson_mutex_lock (&data.mutex); - ASSERT_CMPSIZE_T (data.servers, ==, test_framework_replset_member_count ()); - bson_mutex_unlock (&data.mutex); - - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_uri_destroy (uri); - bson_free (uri_str); - bson_free (replset_name); - bson_free (host_and_port); -} - - -/* CDRIVER-2552 in mongoc_topology_scanner_node_setup, assert (!node->retired) - * failed after this sequence in pooled mode: - * - * 1. scanner discovers a replica set with primary and at least one secondary - * 2. cluster opens a new stream to the primary - * 3. cluster handshakes the new connection by calling hello on the primary - * 4. the primary, for some reason, suddenly omits the secondary from its host - * list, perhaps because the secondary was removed from the RS configuration - * 5. scanner marks the secondary scanner node "retired" to be destroyed later - * 6. the scanner is disconnected from the secondary for some reason - * 7. on the next scan, mongoc_topology_scanner_node_setup sees that the - * secondary is disconnected, and before creating a new stream it asserts - * !node->retired. - * - * test that between step 5 and 7, mongoc_topology_scanner_reset destroys the - * secondary node, avoiding the assert failure. test both pooled and single - * mode for good measure. - */ -static void -test_topology_reconcile_retire_single (void) -{ - mock_server_t *secondary; - mock_server_t *primary; - char *uri_str; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_topology_t *topology; - mongoc_read_prefs_t *primary_read_prefs; - mongoc_read_prefs_t *secondary_read_prefs; - mongoc_read_prefs_t *tag_read_prefs; - mongoc_topology_scanner_node_t *node; - bson_error_t error; - future_t *future; - request_t *request; - - secondary = mock_server_new (); - primary = mock_server_new (); - mock_server_run (secondary); - mock_server_run (primary); - - RS_RESPONSE_TO_HELLO ( - primary, WIRE_VERSION_MIN, true, false, secondary, primary); - RS_RESPONSE_TO_HELLO ( - secondary, WIRE_VERSION_MIN, false, false, secondary, primary); - - /* selection timeout must be > MONGOC_TOPOLOGY_MIN_HEARTBEAT_FREQUENCY_MS, - * otherwise we skip second scan in pooled mode and don't hit the assert */ - uri_str = bson_strdup_printf ( - "mongodb://%s,%s/?replicaSet=rs" - "&serverSelectionTimeoutMS=600&heartbeatFrequencyMS=999999999", - mock_server_get_host_and_port (primary), - mock_server_get_host_and_port (secondary)); - - uri = mongoc_uri_new (uri_str); - - client = test_framework_client_new (uri_str, NULL); - topology = client->topology; - - - /* step 1: discover both replica set members */ - primary_read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - BSON_ASSERT (selects_server (client, primary_read_prefs, primary)); - secondary_read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - BSON_ASSERT (selects_server (client, secondary_read_prefs, secondary)); - - /* remove secondary from primary's config */ - RS_RESPONSE_TO_HELLO (primary, WIRE_VERSION_MIN, true, false, primary); - - /* step 2: cluster opens new stream to primary - force new stream in single - * mode by disconnecting scanner nodes (also includes step 6) */ - DL_FOREACH (topology->scanner->nodes, node) - { - BSON_ASSERT (node); - BSON_ASSERT (node->stream); - mongoc_stream_destroy (node->stream); - node->stream = NULL; - } - - /* step 3: run "ping" on primary, triggering a connection and handshake, thus - * step 4 & 5: the primary tells the scanner to retire the secondary node */ - future = future_client_read_command_with_opts ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL, &error); - request = mock_server_receives_msg ( - primary, MONGOC_QUERY_NONE, tmp_bson ("{'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - - BSON_ASSERT (!has_server_description ( - topology, mock_server_get_host_and_port (secondary))); - - /* server removed from topology description. in pooled mode, the scanner node - * is untouched, in single mode mongoc_cluster_fetch_stream_single scans and - * updates topology */ - - - BSON_ASSERT ( - !get_node (topology, mock_server_get_host_and_port (secondary))); - - - /* step 7: trigger a scan by selecting with an unsatisfiable read preference. - * should not crash with BSON_ASSERT. */ - tag_read_prefs = mongoc_read_prefs_new (MONGOC_READ_NEAREST); - mongoc_read_prefs_add_tag (tag_read_prefs, tmp_bson ("{'key': 'value'}")); - BSON_ASSERT ( - !mongoc_client_select_server (client, false, tag_read_prefs, NULL)); - - - BSON_ASSERT ( - !get_node (topology, mock_server_get_host_and_port (secondary))); - - mongoc_client_destroy (client); - - - future_destroy (future); - mock_server_destroy (primary); - mock_server_destroy (secondary); - mongoc_read_prefs_destroy (primary_read_prefs); - mongoc_read_prefs_destroy (secondary_read_prefs); - mongoc_read_prefs_destroy (tag_read_prefs); - mongoc_uri_destroy (uri); - bson_free (uri_str); -} - - -/* CDRIVER-2552 in mongoc_topology_scanner_start, assert (!node->cmd) - * failed after this sequence in libmongoc 1.6.0: - * - * 1. scanner discovers a replica set with primary - * 2. cluster opens a new stream to the primary - * 3. cluster handshakes the new connection by calling hello on the primary - * 4. the primary suddenly includes a new secondary in its host list, perhaps - * because the secondary was added - * 5. _mongoc_topology_update_from_handshake adds the secondary to the topology - * and erroneously creates a scanner node with an async_cmd_t for it, - * although it's not in the scanner loop - * 6. on the next mongoc_topology_scanner_start, assert (!node->cmd) fails - * - * test that in step 5 the new node has no new async_cmd_t - */ -static void -test_topology_reconcile_add_single (void) -{ - mock_server_t *secondary; - mock_server_t *primary; - char *uri_str; - mongoc_uri_t *uri; - mongoc_client_t *client; - mongoc_topology_t *topology; - mongoc_read_prefs_t *primary_read_prefs; - mongoc_topology_scanner_node_t *node; - bson_error_t error; - future_t *future; - request_t *request; - - secondary = mock_server_new (); - primary = mock_server_new (); - mock_server_run (secondary); - mock_server_run (primary); - - /* omit secondary from primary's hello, to start with */ - RS_RESPONSE_TO_HELLO (primary, WIRE_VERSION_MIN, true, false, primary); - RS_RESPONSE_TO_HELLO ( - secondary, WIRE_VERSION_MIN, false, false, secondary, primary); - - /* selection timeout must be > MONGOC_TOPOLOGY_MIN_HEARTBEAT_FREQUENCY_MS, - * otherwise we skip second scan in pooled mode and don't hit the assert */ - uri_str = bson_strdup_printf ( - "mongodb://%s,%s/?replicaSet=rs" - "&serverSelectionTimeoutMS=600&heartbeatFrequencyMS=999999999", - mock_server_get_host_and_port (primary), - mock_server_get_host_and_port (secondary)); - - uri = mongoc_uri_new (uri_str); - - client = test_framework_client_new (uri_str, NULL); - topology = client->topology; - - /* step 1: discover primary */ - primary_read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - BSON_ASSERT (selects_server (client, primary_read_prefs, primary)); - - /* add secondary to primary's config */ - RS_RESPONSE_TO_HELLO ( - primary, WIRE_VERSION_MIN, true, false, primary, secondary); - - /* step 2: cluster opens new stream to primary - force new stream in single - * mode by disconnecting primary scanner node */ - node = get_node (topology, mock_server_get_host_and_port (primary)); - BSON_ASSERT (node); - BSON_ASSERT (node->stream); - mongoc_stream_destroy (node->stream); - node->stream = NULL; - - /* step 3: run "ping" on primary, triggering a connection and handshake, thus - * step 4 & 5: we add the secondary to the topology description */ - future = future_client_read_command_with_opts ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, NULL, &error); - request = mock_server_receives_msg ( - primary, MONGOC_QUERY_NONE, tmp_bson ("{'ping': 1}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - - /* added server description */ - BSON_ASSERT (has_server_description ( - topology, mock_server_get_host_and_port (secondary))); - - node = get_node (topology, mock_server_get_host_and_port (secondary)); - - /* in single mode the client completes a scan inline and frees all cmds */ - BSON_ASSERT (!topology->scanner->async->cmds); - BSON_ASSERT (node); - - - mongoc_client_destroy (client); - - - future_destroy (future); - mock_server_destroy (primary); - mock_server_destroy (secondary); - mongoc_read_prefs_destroy (primary_read_prefs); - mongoc_uri_destroy (uri); - bson_free (uri_str); -} - - -void -test_topology_reconcile_install (TestSuite *suite) -{ - TestSuite_AddMockServerTest (suite, - "/TOPOLOGY/reconcile/rs/pooled", - test_topology_reconcile_rs_pooled, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest (suite, - "/TOPOLOGY/reconcile/rs/single", - test_topology_reconcile_rs_single, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest (suite, - "/TOPOLOGY/reconcile/sharded/pooled", - test_topology_reconcile_sharded_pooled); - TestSuite_AddMockServerTest (suite, - "/TOPOLOGY/reconcile/sharded/single", - test_topology_reconcile_sharded_single); - TestSuite_AddFull (suite, - "/TOPOLOGY/reconcile/from_handshake", - test_topology_reconcile_from_handshake, - NULL, - NULL, - test_framework_skip_if_not_replset); - TestSuite_AddMockServerTest (suite, - "/TOPOLOGY/reconcile/retire/single", - test_topology_reconcile_retire_single, - test_framework_skip_if_slow); - TestSuite_AddMockServerTest (suite, - "/TOPOLOGY/reconcile/add/single", - test_topology_reconcile_add_single, - test_framework_skip_if_slow); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-topology-scanner.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-topology-scanner.c deleted file mode 100644 index 4ac03a4c6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-topology-scanner.c +++ /dev/null @@ -1,772 +0,0 @@ -#include -#include -#include -#include -#include - -#include "mongoc/mongoc-util-private.h" -#include "mongoc/mongoc-client-private.h" - -#include "TestSuite.h" -#include "mock_server/mock-server.h" -#include "mock_server/mock-rs.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "topology-scanner-test" - -#define TIMEOUT 20000 /* milliseconds */ -#define NSERVERS 10 - -static void -test_topology_scanner_helper (uint32_t id, - const bson_t *bson, - int64_t rtt_msec, - void *data, - const bson_error_t *error /* IN */) -{ - bson_iter_t iter; - int *finished = (int *) data; - uint32_t max_wire_version; - - BSON_UNUSED (rtt_msec); - - if (error->code) { - test_error ("scanner error: %s", error->message); - } - - /* mock servers are configured to return distinct wire versions */ - BSON_ASSERT (bson); - BSON_ASSERT (bson_iter_init_find (&iter, bson, "maxWireVersion")); - BSON_ASSERT (BSON_ITER_HOLDS_INT32 (&iter)); - max_wire_version = (uint32_t) bson_iter_int32 (&iter); - ASSERT_CMPINT (max_wire_version, ==, id + WIRE_VERSION_MIN); - - (*finished)--; -} - -static void -_test_topology_scanner (bool with_ssl) -{ - mock_server_t *servers[NSERVERS]; - mongoc_topology_scanner_t *topology_scanner; - int i; - bson_t q = BSON_INITIALIZER; - int finished = NSERVERS * 3; - -#ifdef MONGOC_ENABLE_SSL - mongoc_ssl_opt_t sopt = {0}; - mongoc_ssl_opt_t copt = {0}; -#endif - - topology_scanner = mongoc_topology_scanner_new ( - NULL, NULL, &test_topology_scanner_helper, &finished, TIMEOUT); - -#ifdef MONGOC_ENABLE_SSL - if (with_ssl) { - copt.ca_file = CERT_CA; - copt.weak_cert_validation = 1; - - mongoc_topology_scanner_set_ssl_opts (topology_scanner, &copt); - } -#endif - - for (i = 0; i < NSERVERS; i++) { - /* use max wire versions just to distinguish among responses */ - servers[i] = mock_server_with_auto_hello (i + WIRE_VERSION_MIN); - mock_server_set_rand_delay (servers[i], true); - -#ifdef MONGOC_ENABLE_SSL - if (with_ssl) { - sopt.ca_file = CERT_CA; - sopt.pem_file = CERT_SERVER; - - mock_server_set_ssl_opts (servers[i], &sopt); - } -#endif - - mock_server_run (servers[i]); - - mongoc_topology_scanner_add ( - topology_scanner, - mongoc_uri_get_hosts (mock_server_get_uri (servers[i])), - (uint32_t) i, - false); - } - - for (i = 0; i < 3; i++) { - mongoc_topology_scanner_start (topology_scanner, false); - mongoc_topology_scanner_work (topology_scanner); - } - - BSON_ASSERT (finished == 0); - - mongoc_topology_scanner_destroy (topology_scanner); - - bson_destroy (&q); - - for (i = 0; i < NSERVERS; i++) { - mock_server_destroy (servers[i]); - } -} - - -void -test_topology_scanner (void) -{ - _test_topology_scanner (false); -} - - -#ifdef MONGOC_ENABLE_SSL_OPENSSL -void -test_topology_scanner_ssl (void) -{ - _test_topology_scanner (true); -} -#endif - - -/* - * Servers discovered by a scan should be checked during that scan, CDRIVER-751. - */ -void -test_topology_scanner_discovery (void) -{ - mock_server_t *primary; - mock_server_t *secondary; - char *primary_response; - char *secondary_response; - mongoc_client_t *client; - char *uri_str; - mongoc_read_prefs_t *secondary_pref; - bson_error_t error; - future_t *future; - request_t *request; - mongoc_server_description_t *sd; - - primary = mock_server_new (); - secondary = mock_server_new (); - mock_server_run (primary); - mock_server_run (secondary); - - primary_response = - bson_strdup_printf ("{'ok': 1, " - " 'isWritablePrimary': true," - " 'setName': 'rs'," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'hosts': ['%s', '%s']}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX, - mock_server_get_host_and_port (primary), - mock_server_get_host_and_port (secondary)); - - secondary_response = - bson_strdup_printf ("{'ok': 1, " - " 'isWritablePrimary': false," - " 'secondary': true," - " 'setName': 'rs'," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'hosts': ['%s', '%s']}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX, - mock_server_get_host_and_port (primary), - mock_server_get_host_and_port (secondary)); - - uri_str = bson_strdup_printf ("mongodb://%s/?" MONGOC_URI_REPLICASET "=rs", - mock_server_get_host_and_port (primary)); - client = test_framework_client_new (uri_str, NULL); - secondary_pref = mongoc_read_prefs_new (MONGOC_READ_SECONDARY_PREFERRED); - - future = future_topology_select ( - client->topology, MONGOC_SS_READ, secondary_pref, NULL, &error); - - /* a single scan discovers *and* checks the secondary */ - request = mock_server_receives_any_hello (primary); - reply_to_request_simple (request, primary_response); - request_destroy (request); - - /* let client process that response */ - _mongoc_usleep (250 * 1000); - - /* a check of the secondary is scheduled in this scan */ - request = mock_server_receives_any_hello (secondary); - reply_to_request_simple (request, secondary_response); - - /* scan completes */ - ASSERT_OR_PRINT ((sd = future_get_mongoc_server_description_ptr (future)), - error); - - ASSERT_CMPSTR (sd->host.host_and_port, - mock_server_get_host_and_port (secondary)); - - mongoc_server_description_destroy (sd); - future_destroy (future); - request_destroy (request); - mongoc_read_prefs_destroy (secondary_pref); - bson_free (secondary_response); - bson_free (primary_response); - bson_free (uri_str); - mongoc_client_destroy (client); - mock_server_destroy (secondary); - mock_server_destroy (primary); -} - - -/* scanner shouldn't spin if two primaries point at each other */ -void -test_topology_scanner_oscillate (void) -{ - mock_server_t *server0; - mock_server_t *server1; - char *server0_response; - char *server1_response; - mongoc_client_t *client; - mongoc_topology_scanner_t *scanner; - char *uri_str; - mongoc_read_prefs_t *primary_pref; - bson_error_t error; - future_t *future; - request_t *request; - - server0 = mock_server_new (); - server1 = mock_server_new (); - mock_server_run (server0); - mock_server_run (server1); - - /* server 0 says it's primary, but only server 1 is in the set */ - server0_response = - bson_strdup_printf ("{'ok': 1, " - " 'isWritablePrimary': true," - " 'setName': 'rs'," - " 'hosts': ['%s']}", - mock_server_get_host_and_port (server1)); - - /* the opposite */ - server1_response = - bson_strdup_printf ("{'ok': 1, " - " 'isWritablePrimary': true," - " 'setName': 'rs'," - " 'hosts': ['%s']}", - mock_server_get_host_and_port (server0)); - - /* start with server 0 */ - uri_str = bson_strdup_printf ("mongodb://%s/?" MONGOC_URI_REPLICASET "=rs", - mock_server_get_host_and_port (server0)); - client = test_framework_client_new (uri_str, NULL); - scanner = client->topology->scanner; - primary_pref = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - BSON_ASSERT (!scanner->async->ncmds); - future = future_topology_select ( - client->topology, MONGOC_SS_READ, primary_pref, NULL, &error); - - /* a single scan discovers servers 0 and 1 */ - request = mock_server_receives_any_hello (server0); - reply_to_request_simple (request, server0_response); - request_destroy (request); - - /* let client process that response */ - _mongoc_usleep (250 * 1000); - - request = mock_server_receives_any_hello (server1); - reply_to_request_simple (request, server1_response); - - /* we don't schedule another check of server0 */ - _mongoc_usleep (250 * 1000); - - BSON_ASSERT (!future_get_mongoc_server_description_ptr (future)); - BSON_ASSERT (scanner->async->ncmds == 0); - - future_destroy (future); - request_destroy (request); - mongoc_read_prefs_destroy (primary_pref); - bson_free (server1_response); - bson_free (server0_response); - bson_free (uri_str); - mongoc_client_destroy (client); - mock_server_destroy (server1); - mock_server_destroy (server0); -} - - -void -test_topology_scanner_connection_error (void) -{ - mongoc_client_t *client; - bson_error_t error; - - /* assuming nothing is listening on this port */ - client = test_framework_client_new ("mongodb://localhost:9876", NULL); - - ASSERT (!mongoc_client_command_simple ( - client, "db", tmp_bson ("{'foo': 1}"), NULL, NULL, &error)); - - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - "connection refused calling hello on " - "'localhost:9876'"); - - mongoc_client_destroy (client); -} - - -void -test_topology_scanner_socket_timeout (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_uri_t *uri; - bson_error_t error; - char *expected_msg; - - server = mock_server_new (); - mock_server_run (server); - - uri = mongoc_uri_copy (mock_server_get_uri (server)); - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_CONNECTTIMEOUTMS, 10); - client = test_framework_client_new_from_uri (uri, NULL); - - ASSERT (!mongoc_client_command_simple ( - client, "db", tmp_bson ("{'foo': 1}"), NULL, NULL, &error)); - - /* the mock server did accept connection, but never replied */ - expected_msg = - bson_strdup_printf ("socket timeout calling hello on '%s'", - mongoc_uri_get_hosts (uri)->host_and_port); - - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_SERVER_SELECTION, - MONGOC_ERROR_SERVER_SELECTION_FAILURE, - expected_msg); - - bson_free (expected_msg); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - - -typedef struct { - uint16_t slow_port; - mongoc_client_t *client; -} initiator_data_t; - - -static mongoc_stream_t * -slow_initiator (const mongoc_uri_t *uri, - const mongoc_host_list_t *host, - void *user_data, - bson_error_t *err) -{ - initiator_data_t *data; - - data = (initiator_data_t *) user_data; - - if (host->port == data->slow_port) { - _mongoc_usleep (500 * 1000); /* 500 ms is longer than connectTimeoutMS */ - } - - return mongoc_client_default_stream_initiator (uri, host, data->client, err); -} - - -static void -test_topology_scanner_blocking_initiator (void) -{ - mock_rs_t *rs; - mongoc_uri_t *uri; - mongoc_client_t *client; - initiator_data_t data; - bson_error_t error; - - rs = mock_rs_with_auto_hello (WIRE_VERSION_MIN, /* wire version */ - true, /* has primary */ - 1, /* n_secondaries */ - 0 /* n_arbiters */); - - mock_rs_run (rs); - uri = mongoc_uri_copy (mock_rs_get_uri (rs)); - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_CONNECTTIMEOUTMS, 100); - client = test_framework_client_new_from_uri (uri, NULL); - - /* pretend last host in linked list is slow */ - data.slow_port = mongoc_uri_get_hosts (uri)->next->port; - data.client = client; - mongoc_client_set_stream_initiator (client, slow_initiator, &data); - - ASSERT_OR_PRINT (mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'" HANDSHAKE_CMD_LEGACY_HELLO "': 1}"), - NULL, - NULL, - &error), - error); - - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_rs_destroy (rs); -} - -static mock_server_t * -_mock_server_listening_on (char *server_bind_to) -{ - mock_server_t *mock_server; - mock_server_bind_opts_t opts = {0}; - struct sockaddr_in ipv4_addr = {0}; - struct sockaddr_in6 ipv6_addr = {0}; - - if (strcmp ("both", server_bind_to) == 0) { - opts.bind_addr_len = sizeof (ipv6_addr); - opts.family = AF_INET6; - opts.ipv6_only = 0; - ipv6_addr.sin6_family = AF_INET6; - ipv6_addr.sin6_port = htons (0); /* any port */ - ipv6_addr.sin6_addr = in6addr_any; /* either IPv4 or IPv6 */ - opts.bind_addr = (struct sockaddr_in *) &ipv6_addr; - } else if (strcmp ("ipv4", server_bind_to) == 0) { - opts.bind_addr_len = sizeof (ipv4_addr); - opts.family = AF_INET; - opts.ipv6_only = 0; - ipv4_addr.sin_family = AF_INET; - ipv4_addr.sin_port = htons (0); - BSON_ASSERT (inet_pton (AF_INET, "127.0.0.1", &ipv4_addr.sin_addr)); - opts.bind_addr = &ipv4_addr; - } else if (strcmp ("ipv6", server_bind_to) == 0) { - opts.bind_addr_len = sizeof (ipv6_addr); - opts.family = AF_INET6; - opts.ipv6_only = 1; - ipv6_addr.sin6_family = AF_INET6; - ipv6_addr.sin6_port = htons (0); - BSON_ASSERT (inet_pton (AF_INET6, "::1", &ipv6_addr.sin6_addr)); - opts.bind_addr = (struct sockaddr_in *) &ipv6_addr; - } else { - fprintf (stderr, "bad value of server_bind_to=%s\n", server_bind_to); - ASSERT (false); - } - mock_server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_set_bind_opts (mock_server, &opts); - mock_server_run (mock_server); - return mock_server; -} - -typedef struct dns_testcase { - char *server_bind_to; /* ipv4, ipv6, or both */ - char *client_hostname; /* 127.0.0.1, [::1], or localhost */ - bool should_succeed; - int expected_ncmds; - char *expected_client_bind_to; /* ipv4, ipv6, or either */ -} dns_testcase_t; - -static void -_test_topology_scanner_dns_helper (uint32_t id, - const bson_t *bson, - int64_t rtt_msec, - void *data, - const bson_error_t *error /* IN */) -{ - dns_testcase_t *testcase = (dns_testcase_t *) data; - - BSON_UNUSED (id); - BSON_UNUSED (bson); - BSON_UNUSED (rtt_msec); - - if (testcase->should_succeed) { - ASSERT_OR_PRINT (!error->code, (*error)); - } else { - ASSERT (error->code); - ASSERT_ERROR_CONTAINS ((*error), - MONGOC_ERROR_STREAM, - MONGOC_ERROR_STREAM_CONNECT, - "connection refused"); - } -} - -static void -test_topology_scanner_dns_testcase (dns_testcase_t *testcase) -{ - mongoc_host_list_t host; - mock_server_t *server; - mongoc_topology_scanner_t *ts; - char *host_str; - mongoc_socket_t *sock; - mongoc_topology_scanner_node_t *node; - - server = _mock_server_listening_on (testcase->server_bind_to); - ts = mongoc_topology_scanner_new ( - NULL, NULL, &_test_topology_scanner_dns_helper, testcase, TIMEOUT); - host_str = bson_strdup_printf ( - "%s:%d", testcase->client_hostname, mock_server_get_port (server)); - BSON_ASSERT (_mongoc_host_list_from_string (&host, host_str)); - /* we should only have one host. */ - BSON_ASSERT (!host.next); - bson_free (host_str); - - mongoc_topology_scanner_add (ts, &host, 1, false); - mongoc_topology_scanner_scan (ts, 1 /* any server id is ok. */); - ASSERT_CMPINT ((int) (ts->async->ncmds), ==, testcase->expected_ncmds); - mongoc_topology_scanner_work (ts); - node = mongoc_topology_scanner_get_node (ts, 1); - - /* check the socket that the scanner found. */ - if (testcase->should_succeed) { - ASSERT (node->stream->type == MONGOC_STREAM_SOCKET); - sock = mongoc_stream_socket_get_socket ( - (mongoc_stream_socket_t *) node->stream); - if (strcmp ("ipv4", testcase->expected_client_bind_to) == 0) { - ASSERT (sock->domain == AF_INET); - } else if (strcmp ("ipv6", testcase->expected_client_bind_to) == 0) { - ASSERT (sock->domain == AF_INET6); - } else if (strcmp ("either", testcase->expected_client_bind_to) != 0) { - fprintf (stderr, - "bad value for testcase->expected_client_bind_to=%s\n", - testcase->expected_client_bind_to); - ASSERT (false); - } - } - - mongoc_topology_scanner_destroy (ts); - mock_server_destroy (server); -} - -/* test when clients try connecting to servers varying the DNS results of the - * clients and the socket binding of the server. */ -static void -test_topology_scanner_dns (void) -{ - /* server can bind to: {ipv4 only, ipv6 only, both} - * client can connect to: {127.0.0.1, ::1, localhost} - * there are 9 combinations. */ - int ntests, i; - dns_testcase_t tests[] = {{"ipv4", "127.0.0.1", true, 1, "ipv4"}, - {"ipv4", "[::1]", false, 1, "n/a"}, - {"ipv6", "127.0.0.1", false, 1, "n/a"}, - {"ipv6", "[::1]", true, 1, "ipv6"}, - {"both", "127.0.0.1", true, 1, "ipv4"}, - {"both", "[::1]", true, 1, "ipv6"}}; - /* these tests require a hostname mapping to both IPv4 and IPv6 local. - * this can be localhost normally, but some configurations may have localhost - * only mapping to 127.0.0.1, not ::1. */ - dns_testcase_t tests_with_ipv4_and_ipv6_uri[] = { - {"ipv4", "", true, 2, "ipv4"}, - {"ipv6", "", true, 2, "ipv6"}, - {"both", "", true, 2, "either"}}; - char *ipv4_and_ipv6_host = - test_framework_getenv ("MONGOC_TEST_IPV4_AND_IPV6_HOST"); - - ntests = sizeof (tests) / sizeof (dns_testcase_t); - for (i = 0; i < ntests; ++i) { - test_topology_scanner_dns_testcase (tests + i); - } - - if (ipv4_and_ipv6_host) { - ntests = sizeof (tests_with_ipv4_and_ipv6_uri) / sizeof (dns_testcase_t); - for (i = 0; i < ntests; ++i) { - tests_with_ipv4_and_ipv6_uri[i].client_hostname = ipv4_and_ipv6_host; - test_topology_scanner_dns_testcase (tests_with_ipv4_and_ipv6_uri + i); - } - bson_free (ipv4_and_ipv6_host); - } -} - -static void -_retired_fails_to_initiate_cb (uint32_t id, - const bson_t *bson, - int64_t rtt_msec, - void *data, - const bson_error_t *error /* IN */) -{ - BSON_UNUSED (id); - BSON_UNUSED (bson); - BSON_UNUSED (rtt_msec); - BSON_UNUSED (data); - BSON_UNUSED (error); - /* this should never get called. */ - BSON_ASSERT (false); -} - -static mongoc_stream_t * -null_initiator (mongoc_async_cmd_t *acmd) -{ - BSON_UNUSED (acmd); - - return NULL; -} - -/* test when a retired node fails to initiate a stream. CDRIVER-1972 introduced - * a bug in which the topology callback would be incorrectly called when a - * retired node failed to establish a connection. - */ -static void -test_topology_retired_fails_to_initiate (void) -{ - mock_server_t *server; - mongoc_topology_scanner_t *scanner; - mongoc_async_cmd_t *acmd; - mongoc_host_list_t host_list; - - server = mock_server_with_auto_hello (WIRE_VERSION_MAX); - mock_server_run (server); - - scanner = mongoc_topology_scanner_new ( - NULL, NULL, &_retired_fails_to_initiate_cb, NULL, TIMEOUT); - - BSON_ASSERT (_mongoc_host_list_from_string ( - &host_list, mock_server_get_host_and_port (server))); - - mongoc_topology_scanner_add (scanner, &host_list, 1, false); - mongoc_topology_scanner_start (scanner, false); - BSON_ASSERT (scanner->async->ncmds > 0); - /* retire the node */ - scanner->nodes->retired = true; - /* override the stream initiator of every async command, simulating - * a failed mongoc_socket_new or mongoc_stream_connect. */ - DL_FOREACH (scanner->async->cmds, acmd) - { - scanner->async->cmds->initiator = null_initiator; - } - - mongoc_topology_scanner_work (scanner); - /* we expect the scanner callback not to get called. */ - - mongoc_topology_scanner_destroy (scanner); - mock_server_destroy (server); -} - -static void -heartbeat_failed (const mongoc_apm_server_heartbeat_failed_t *event) -{ - bson_error_t error; - bool *failed = - (bool *) mongoc_apm_server_heartbeat_failed_get_context (event); - - mongoc_apm_server_heartbeat_failed_get_error (event, &error); - - fprintf (stderr, "heartbeat failed: %s\n", error.message); - fflush (stderr); - - *failed = true; -} - -/* CDRIVER-2624: due to a bug, we repeated the TLS handshake on each heartbeat, - * causing some MongoDB versions to hang up */ -static void -_test_topology_scanner_does_not_renegotiate (bool pooled) -{ - mongoc_uri_t *uri; - mongoc_apm_callbacks_t *callbacks; - mongoc_client_pool_t *pool = NULL; - mongoc_client_t *client; - bool failed = false; - bool r; - bson_error_t error; - - uri = test_framework_get_uri (); - mongoc_uri_set_option_as_int32 (uri, "heartbeatFrequencyMS", 500); - /* faster pool shutdown to make the test quick */ - mongoc_uri_set_option_as_int32 (uri, "connectTimeoutMS", 1000); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_server_heartbeat_failed_cb (callbacks, heartbeat_failed); - - if (pooled) { - pool = test_framework_client_pool_new_from_uri (uri, NULL); - test_framework_set_pool_ssl_opts (pool); - mongoc_client_pool_set_apm_callbacks (pool, callbacks, &failed); - client = mongoc_client_pool_pop (pool); - } else { - client = test_framework_client_new_from_uri (uri, NULL); - mongoc_client_set_apm_callbacks (client, callbacks, &failed); - test_framework_set_ssl_opts (client); - } - - /* ensure connection */ - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - - _mongoc_usleep (1500 * 1000); /* 1.5 seconds */ - - r = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'ping': 1}"), NULL, NULL, &error); - ASSERT_OR_PRINT (r, error); - - /* no heartbeats failed */ - BSON_ASSERT (!failed); - - if (pooled) { - mongoc_client_pool_push (pool, client); - mongoc_client_pool_destroy (pool); - } else { - mongoc_client_destroy (client); - } - - mongoc_uri_destroy (uri); - mongoc_apm_callbacks_destroy (callbacks); -} - -static void -test_topology_scanner_does_not_renegotiate_single (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_topology_scanner_does_not_renegotiate (false); -} - -static void -test_topology_scanner_does_not_renegotiate_pooled (void *ctx) -{ - BSON_UNUSED (ctx); - - _test_topology_scanner_does_not_renegotiate (true); -} - -void -test_topology_scanner_install (TestSuite *suite) -{ - TestSuite_AddMockServerTest ( - suite, "/TOPOLOGY/scanner", test_topology_scanner); -#ifdef MONGOC_ENABLE_SSL_OPENSSL - TestSuite_AddMockServerTest ( - suite, "/TOPOLOGY/scanner_ssl", test_topology_scanner_ssl); -#endif - TestSuite_AddMockServerTest ( - suite, "/TOPOLOGY/scanner_discovery", test_topology_scanner_discovery); - TestSuite_AddMockServerTest ( - suite, "/TOPOLOGY/scanner_oscillate", test_topology_scanner_oscillate); - TestSuite_Add (suite, - "/TOPOLOGY/scanner_connection_error", - test_topology_scanner_connection_error); - TestSuite_AddMockServerTest (suite, - "/TOPOLOGY/scanner_socket_timeout", - test_topology_scanner_socket_timeout); - TestSuite_AddMockServerTest (suite, - "/TOPOLOGY/blocking_initiator", - test_topology_scanner_blocking_initiator); - TestSuite_AddMockServerTest (suite, - "/TOPOLOGY/dns", - test_topology_scanner_dns, - test_framework_skip_if_no_dual_ip_hostname); - TestSuite_AddMockServerTest (suite, - "/TOPOLOGY/retired_fails_to_initiate", - test_topology_retired_fails_to_initiate); - TestSuite_AddFull (suite, - "/TOPOLOGY/scanner/renegotiate/single", - test_topology_scanner_does_not_renegotiate_single, - NULL, - NULL, - test_framework_skip_if_slow_or_live); - TestSuite_AddFull (suite, - "/TOPOLOGY/scanner/renegotiate/pooled", - test_topology_scanner_does_not_renegotiate_pooled, - NULL, - NULL, - test_framework_skip_if_slow_or_live); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-transactions.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-transactions.c deleted file mode 100644 index b4553d879..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-transactions.c +++ /dev/null @@ -1,1299 +0,0 @@ -#include - -#include "mongoc/mongoc-collection-private.h" - -#include "json-test.h" -#include "test-libmongoc.h" -#include "mock_server/mock-rs.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" -#include "json-test-operations.h" -#include "mongoc/mongoc-uri-private.h" -#include "mongoc/mongoc-host-list-private.h" -#include "mongoc/mongoc-read-concern-private.h" -#include "mongoc/mongoc-write-concern-private.h" - -/* Reset server state by disabling failpoints, killing sessions, and... running - * a distinct command. */ -static void -_reset_server (json_test_ctx_t *ctx, const char *host_str) -{ - mongoc_client_t *client; - bson_error_t error; - bool res; - mongoc_uri_t *uri = _mongoc_uri_copy_and_replace_host_list ( - ctx->test_framework_uri, host_str); - - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - - /* From Transactions tests runner: "Create a MongoClient and call - * client.admin.runCommand({killAllSessions: []}) to clean up any open - * transactions from previous test failures. Ignore a command failure with - * error code 11601 ("Interrupted") to work around SERVER-38335." - */ - res = mongoc_client_command_simple (client, - "admin", - tmp_bson ("{'killAllSessions': []}"), - NULL, - NULL, - &error); - if (!res && error.code != 11601) { - test_error ("Unexpected error: %s from killAllSessions\n", error.message); - } - - /* From Transactions spec test runner: "When testing against a sharded - * cluster run a distinct command on the newly - * created collection on all mongoses. For an explanation see, Why do tests - * that run distinct sometimes fail with StaleDbVersion?" */ - - ASSERT_OR_PRINT ( - mongoc_client_command_simple ( - client, - mongoc_database_get_name (ctx->db), - tmp_bson ("{'distinct': '%s', 'key': 'test', 'query': {}}", - mongoc_collection_get_name (ctx->collection)), - NULL /* read prefs */, - NULL /* reply */, - &error), - error); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); -} - -static void -_disable_failpoints (json_test_ctx_t *ctx, const char *host_str) -{ - mongoc_client_t *client; - bson_error_t error; - int i; - mongoc_uri_t *uri = _mongoc_uri_copy_and_replace_host_list ( - ctx->test_framework_uri, host_str); - - /* Some transactions tests have a failCommand for "hello" repeat seven - * times. Repeat this seven times. And set a reduced server selection timeout - * so we don't hang on failed hello commands. */ - mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_SERVERSELECTIONTIMEOUTMS, 500); - - for (i = 0; i < 7; i++) { - bool ret; - - client = test_framework_client_new_from_uri (uri, NULL); - ret = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'configureFailPoint': 'failCommand', 'mode': 'off'}"), - NULL, - NULL, - &error); - if (!ret) { - /* Tests that fail with hello also fail to disable the failpoint - * (since we run hello when opening the connection). Ignore those - * errors. */ - BSON_ASSERT (NULL != - strstr (error.message, "No suitable servers found")); - } - mongoc_client_destroy (client); - } - mongoc_uri_destroy (uri); -} - -static void -transactions_test_before_test (json_test_ctx_t *ctx, const bson_t *test) -{ - bson_iter_t test_iter; - bool is_multi_mongos; - - _reset_server (ctx, "localhost:27017"); - - is_multi_mongos = - bson_iter_init_find (&test_iter, test, "useMultipleMongoses") && - bson_iter_as_bool (&test_iter); - - if (is_multi_mongos) { - _reset_server (ctx, "localhost:27018"); - } -} - - -static void -transactions_test_after_test (json_test_ctx_t *ctx, const bson_t *test) -{ - bson_iter_t test_iter; - bool is_multi_mongos; - - _disable_failpoints (ctx, "localhost:27017"); - - is_multi_mongos = - bson_iter_init_find (&test_iter, test, "useMultipleMongoses") && - bson_iter_as_bool (&test_iter); - - if (is_multi_mongos) { - _disable_failpoints (ctx, "localhost:27018"); - } -} - - -typedef struct _cb_ctx_t { - bson_t callback; - json_test_ctx_t *ctx; -} cb_ctx_t; - - -static bool -with_transaction_callback_runner (mongoc_client_session_t *session, - void *ctx, - bson_t **reply, - bson_error_t *error) -{ - cb_ctx_t *cb_ctx = (cb_ctx_t *) ctx; - bson_t operation; - bson_t operations; - bson_t *test; - bson_iter_t iter; - bool res = false; - bson_t local_reply; - - BSON_UNUSED (error); - - test = &(cb_ctx->callback); - - if (bson_has_field (test, "operation")) { - bson_lookup_doc (test, "operation", &operation); - res = json_test_operation (cb_ctx->ctx, - test, - &operation, - cb_ctx->ctx->collection, - session, - &local_reply); - } else { - ASSERT (bson_has_field (test, "operations")); - bson_lookup_doc (test, "operations", &operations); - BSON_ASSERT (bson_iter_init (&iter, &operations)); - - bson_init (&local_reply); - - while (bson_iter_next (&iter)) { - bson_destroy (&local_reply); - bson_iter_bson (&iter, &operation); - res = json_test_operation (cb_ctx->ctx, - test, - &operation, - cb_ctx->ctx->collection, - session, - &local_reply); - if (!res) { - break; - } - } - } - - *reply = bson_copy (&local_reply); - bson_destroy (&local_reply); - - return res; -} - -static bool -transactions_test_run_operation (json_test_ctx_t *ctx, - const bson_t *test, - const bson_t *operation) -{ - mongoc_transaction_opt_t *opts = NULL; - mongoc_client_session_t *session = NULL; - bson_error_t error; - bson_value_t value; - bson_t reply; - bool res; - cb_ctx_t cb_ctx; - - /* If there is a 'callback' field, run the nested operations through - mongoc_client_session_with_transaction(). */ - if (bson_has_field (operation, "arguments.callback")) { - ASSERT (bson_has_field (operation, "object")); - session = session_from_name (ctx, bson_lookup_utf8 (operation, "object")); - ASSERT (session); - - bson_lookup_doc (operation, "arguments.callback", &cb_ctx.callback); - cb_ctx.ctx = ctx; - - if (bson_has_field (operation, "arguments.options")) { - opts = bson_lookup_txn_opts (operation, "arguments.options"); - } - - res = mongoc_client_session_with_transaction ( - session, - with_transaction_callback_runner, - opts, - &cb_ctx, - &reply, - &error); - - value_init_from_doc (&value, &reply); - check_result (test, operation, res, &value, &error); - bson_value_destroy (&value); - - } else { - /* If there is no 'callback' field, then run simply. */ - if (bson_has_field (operation, "arguments.session")) { - session = session_from_name ( - ctx, bson_lookup_utf8 (operation, "arguments.session")); - } - - /* expect some warnings from abortTransaction, but don't suppress others: - * we want to know if any other tests log warnings */ - capture_logs (true); - res = json_test_operation ( - ctx, test, operation, ctx->collection, session, &reply); - assert_all_captured_logs_have_prefix ("Error in abortTransaction:"); - capture_logs (false); - } - - bson_destroy (&reply); - mongoc_transaction_opts_destroy (opts); - - return res; -} - - -static test_skip_t skips[] = { - {"callback is not retried after non-transient error (DuplicateKeyError)", - "Waiting on CDRIVER-4811"}, - {0}}; - - -static void -test_transactions_cb (bson_t *scenario) -{ - json_test_config_t config = JSON_TEST_CONFIG_INIT; - - config.skips = skips; - - config.before_test_cb = transactions_test_before_test; - config.run_operation_cb = transactions_test_run_operation; - config.after_test_cb = transactions_test_after_test; - config.scenario = scenario; - config.command_started_events_only = true; - run_json_general_test (&config); -} - - -static void -test_transactions_supported (void *ctx) -{ - mongoc_client_t *client; - mongoc_client_session_t *session; - mongoc_database_t *db; - mongoc_collection_t *collection; - bson_t *majority = tmp_bson ("{'writeConcern': {'w': 'majority'}}"); - bson_t opts = BSON_INITIALIZER; - bson_error_t error; - bool r; - - BSON_UNUSED (ctx); - - if (test_framework_is_mongos ()) { - bson_destroy (&opts); - return; - } - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - db = mongoc_client_get_database (client, "transaction-tests"); - - /* drop and create collection outside of transaction */ - mongoc_database_write_command_with_opts ( - db, tmp_bson ("{'drop': 'test'}"), majority, NULL, NULL); - collection = - mongoc_database_create_collection (db, "test", majority, &error); - ASSERT_OR_PRINT (collection, error); - - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - - if ((r = mongoc_client_session_start_transaction (session, NULL, &error))) { - r = mongoc_client_session_append (session, &opts, &error); - ASSERT_OR_PRINT (r, error); - - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{}"), &opts, NULL, &error); - - /* insert should fail if replset has no members */ - BSON_ASSERT (r == test_framework_is_replset ()); - } else { - ASSERT_CMPINT32 (error.domain, ==, MONGOC_ERROR_TRANSACTION); - ASSERT_CONTAINS (error.message, "transaction"); - } - - bson_destroy (&opts); - mongoc_collection_destroy (collection); - - if (!r) { - /* suppress "error in abortTransaction" warning from session_destroy */ - capture_logs (true); - } - - mongoc_client_session_destroy (session); - mongoc_database_destroy (db); - mongoc_client_destroy (client); -} - - -static void -test_in_transaction (void *ctx) -{ - mongoc_client_t *client; - mongoc_client_session_t *session; - mongoc_database_t *db; - mongoc_collection_t *collection; - bson_t *majority = tmp_bson ("{'writeConcern': {'w': 'majority'}}"); - bson_t opts = BSON_INITIALIZER; - bson_error_t error; - bool r; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, 2); - db = mongoc_client_get_database (client, "transaction-tests"); - /* drop and create collection outside of transaction */ - mongoc_database_write_command_with_opts ( - db, tmp_bson ("{'drop': 'test'}"), majority, NULL, NULL); - collection = - mongoc_database_create_collection (db, "test", majority, &error); - ASSERT_OR_PRINT (collection, error); - - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - r = mongoc_client_session_append (session, &opts, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (!mongoc_client_session_in_transaction (session)); - ASSERT_CMPINT (mongoc_client_session_get_transaction_state (session), - ==, - MONGOC_TRANSACTION_NONE); - ASSERT_CMPINT (session->txn.state, ==, MONGOC_INTERNAL_TRANSACTION_NONE); - - /* commit an empty transaction */ - r = mongoc_client_session_start_transaction (session, NULL, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (mongoc_client_session_in_transaction (session)); - ASSERT_CMPINT (mongoc_client_session_get_transaction_state (session), - ==, - MONGOC_TRANSACTION_STARTING); - ASSERT_CMPINT (session->txn.state, ==, MONGOC_INTERNAL_TRANSACTION_STARTING); - r = mongoc_client_session_commit_transaction (session, NULL, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (!mongoc_client_session_in_transaction (session)); - ASSERT_CMPINT (mongoc_client_session_get_transaction_state (session), - ==, - MONGOC_TRANSACTION_COMMITTED); - ASSERT_CMPINT ( - session->txn.state, ==, MONGOC_INTERNAL_TRANSACTION_COMMITTED_EMPTY); - - /* commit a transaction with an insert */ - r = mongoc_client_session_start_transaction (session, NULL, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (mongoc_client_session_in_transaction (session)); - ASSERT_CMPINT (mongoc_client_session_get_transaction_state (session), - ==, - MONGOC_TRANSACTION_STARTING); - ASSERT_CMPINT (session->txn.state, ==, MONGOC_INTERNAL_TRANSACTION_STARTING); - r = mongoc_collection_insert_one ( - collection, tmp_bson ("{}"), &opts, NULL, &error); - ASSERT_CMPINT (mongoc_client_session_get_transaction_state (session), - ==, - MONGOC_TRANSACTION_IN_PROGRESS); - ASSERT_CMPINT ( - session->txn.state, ==, MONGOC_INTERNAL_TRANSACTION_IN_PROGRESS); - ASSERT_OR_PRINT (r, error); - r = mongoc_client_session_commit_transaction (session, NULL, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (!mongoc_client_session_in_transaction (session)); - ASSERT_CMPINT (mongoc_client_session_get_transaction_state (session), - ==, - MONGOC_TRANSACTION_COMMITTED); - ASSERT_CMPINT ( - session->txn.state, ==, MONGOC_INTERNAL_TRANSACTION_COMMITTED); - - /* abort a transaction */ - r = mongoc_client_session_start_transaction (session, NULL, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (mongoc_client_session_in_transaction (session)); - ASSERT_CMPINT (mongoc_client_session_get_transaction_state (session), - ==, - MONGOC_TRANSACTION_STARTING); - ASSERT_CMPINT (session->txn.state, ==, MONGOC_INTERNAL_TRANSACTION_STARTING); - ASSERT_OR_PRINT (r, error); - r = mongoc_client_session_abort_transaction (session, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (!mongoc_client_session_in_transaction (session)); - ASSERT_CMPINT (mongoc_client_session_get_transaction_state (session), - ==, - MONGOC_TRANSACTION_ABORTED); - ASSERT_CMPINT (session->txn.state, ==, MONGOC_INTERNAL_TRANSACTION_ABORTED); - - bson_destroy (&opts); - mongoc_collection_destroy (collection); - mongoc_database_destroy (db); - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); -} - - -static bool -hangup_except_hello (request_t *request, void *data) -{ - BSON_UNUSED (data); - - if (!bson_strcasecmp (request->command_name, HANDSHAKE_CMD_LEGACY_HELLO) || - !bson_strcasecmp (request->command_name, "hello")) { - /* allow default response */ - return false; - } - - reply_to_request_with_hang_up (request); - request_destroy (request); - return true; -} - - -static void -_test_transient_txn_err (bool hangup) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_client_session_t *session; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - mongoc_bulk_operation_t *bulk; - mongoc_find_and_modify_opts_t *fam; - bson_t opts = BSON_INITIALIZER; - bson_error_t error; - bson_t *b; - bson_t *u; - const bson_t *doc_out; - const bson_t *error_doc; - bson_t reply; - bool r; - - server = mock_server_new (); - mock_server_run (server); - rs_response_to_hello (server, - WIRE_VERSION_4_0, - true /* primary */, - false /* tags */, - server, - NULL); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - /* allow fast reconnect */ - client->topology->min_heartbeat_frequency_msec = 0; - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - r = mongoc_client_session_start_transaction (session, NULL, &error); - ASSERT_OR_PRINT (r, error); - r = mongoc_client_session_append (session, &opts, &error); - ASSERT_OR_PRINT (r, error); - collection = mongoc_client_get_collection (client, "db", "collection"); - - if (hangup) { - /* test that network errors have TransientTransactionError */ - mock_server_autoresponds (server, hangup_except_hello, NULL, NULL); - } else { - /* test server selection errors have TransientTransactionError */ - mock_server_destroy (server); - server = NULL; - } - - /* warnings when trying to abort the transaction and later, end sessions */ - capture_logs (true); - -#define ASSERT_TRANSIENT_LABEL(_b, _expr) \ - do { \ - if (!mongoc_error_has_label ((_b), "TransientTransactionError")) { \ - test_error ("Reply lacks TransientTransactionError label: %s\n" \ - "Running %s", \ - bson_as_json ((_b), NULL), \ - #_expr); \ - } \ - } while (0) - -#define TEST_CMD_ERR(_expr) \ - do { \ - r = (_expr); \ - BSON_ASSERT (!r); \ - ASSERT_TRANSIENT_LABEL (&reply, _expr); \ - bson_destroy (&reply); \ - /* clean slate for next test */ \ - memset (&reply, 0, sizeof (reply)); \ - } while (0) - - -#define TEST_WRITE_ERR(_expr) \ - do { \ - r = (_expr); \ - ASSERT_TRANSIENT_LABEL (&reply, _expr); \ - bson_destroy (&reply); \ - /* clean slate for next test */ \ - memset (&reply, 0, sizeof (reply)); \ - } while (0) - -#define TEST_CURSOR_ERR(_cursor_expr) \ - do { \ - cursor = (_cursor_expr); \ - r = mongoc_cursor_next (cursor, &doc_out); \ - BSON_ASSERT (!r); \ - r = !mongoc_cursor_error_document (cursor, &error, &error_doc); \ - BSON_ASSERT (!r); \ - BSON_ASSERT (error_doc); \ - ASSERT_TRANSIENT_LABEL (error_doc, _cursor_expr); \ - mongoc_cursor_destroy (cursor); \ - } while (0) - - b = tmp_bson ("{'x': 1}"); - u = tmp_bson ("{'$inc': {'x': 1}}"); - - TEST_CMD_ERR (mongoc_client_command_with_opts ( - client, "db", b, NULL, &opts, &reply, NULL)); - TEST_CMD_ERR (mongoc_client_read_command_with_opts ( - client, "db", b, NULL, &opts, &reply, NULL)); - TEST_CMD_ERR (mongoc_client_write_command_with_opts ( - client, "db", b, &opts, &reply, NULL)); - TEST_CMD_ERR (mongoc_client_read_write_command_with_opts ( - client, "db", b, NULL, &opts, &reply, NULL)); - TEST_CMD_ERR (0 < mongoc_collection_count_documents ( - collection, b, &opts, NULL, &reply, NULL)); - - BEGIN_IGNORE_DEPRECATIONS; - TEST_CMD_ERR (mongoc_collection_create_index_with_opts ( - collection, b, NULL, &opts, &reply, NULL)); - END_IGNORE_DEPRECATIONS - - fam = mongoc_find_and_modify_opts_new (); - mongoc_find_and_modify_opts_append (fam, &opts); - TEST_CMD_ERR (mongoc_collection_find_and_modify_with_opts ( - collection, b, fam, &reply, NULL)); - - TEST_WRITE_ERR ( - mongoc_collection_insert_one (collection, b, &opts, &reply, NULL)); - TEST_WRITE_ERR (mongoc_collection_insert_many ( - collection, (const bson_t **) &b, 1, &opts, &reply, NULL)); - TEST_WRITE_ERR ( - mongoc_collection_update_one (collection, b, u, &opts, &reply, NULL)); - TEST_WRITE_ERR ( - mongoc_collection_update_many (collection, b, u, &opts, &reply, NULL)); - TEST_WRITE_ERR ( - mongoc_collection_replace_one (collection, b, b, &opts, &reply, NULL)); - TEST_WRITE_ERR ( - mongoc_collection_delete_one (collection, b, &opts, &reply, NULL)); - TEST_WRITE_ERR ( - mongoc_collection_delete_many (collection, b, &opts, &reply, NULL)); - - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, &opts); - mongoc_bulk_operation_insert (bulk, b); - TEST_WRITE_ERR (mongoc_bulk_operation_execute (bulk, &reply, NULL)); - - TEST_CURSOR_ERR (mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, tmp_bson ("[{}]"), &opts, NULL)); - TEST_CURSOR_ERR ( - mongoc_collection_find_with_opts (collection, b, &opts, NULL)); - - mongoc_find_and_modify_opts_destroy (fam); - mongoc_bulk_operation_destroy (bulk); - bson_destroy (&opts); - mongoc_collection_destroy (collection); - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); - - if (server) { - mock_server_destroy (server); - } -} - - -static void -test_server_selection_error (void) -{ - _test_transient_txn_err (false /* hangup */); -} - - -static void -test_network_error (void) -{ - _test_transient_txn_err (true /* hangup */); -} - - -/* Transactions Spec: Drivers add the "UnknownTransactionCommitResult" to a - * server selection error from commitTransaction, even if this is the first - * attempt to send commitTransaction. It is true in this case that the driver - * knows the result: the transaction is definitely not committed. However, the - * "UnknownTransactionCommitResult" label properly communicates to the - * application that calling commitTransaction again may succeed. - */ -static void -test_unknown_commit_result (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_client_session_t *session; - mongoc_collection_t *collection; - future_t *future; - request_t *request; - bson_t opts = BSON_INITIALIZER; - bson_error_t error; - bson_t reply; - bool r; - - server = mock_server_new (); - mock_server_run (server); - rs_response_to_hello (server, - WIRE_VERSION_4_0, - true /* primary */, - false /* tags */, - server, - NULL); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - /* allow fast reconnect */ - client->topology->min_heartbeat_frequency_msec = 0; - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - r = mongoc_client_session_start_transaction (session, NULL, &error); - ASSERT_OR_PRINT (r, error); - r = mongoc_client_session_append (session, &opts, &error); - ASSERT_OR_PRINT (r, error); - collection = mongoc_client_get_collection (client, "db", "collection"); - future = future_collection_insert_one ( - collection, tmp_bson ("{}"), &opts, NULL, &error); - request = mock_server_receives_msg ( - server, 0, tmp_bson ("{'insert': 'collection'}"), tmp_bson ("{}")); - reply_to_request_with_ok_and_destroy (request); - ASSERT_OR_PRINT (future_get_bool (future), error); - future_destroy (future); - - /* test server selection errors have UnknownTransactionCommitResult */ - mock_server_destroy (server); - r = mongoc_client_session_commit_transaction (session, &reply, &error); - BSON_ASSERT (!r); - - if (!mongoc_error_has_label (&reply, "UnknownTransactionCommitResult")) { - test_error ("Reply lacks UnknownTransactionCommitResult label: %s", - bson_as_json (&reply, NULL)); - } - - if (mongoc_error_has_label (&reply, "TransientTransactionError")) { - test_error ("Reply shouldn't have TransientTransactionError label: %s", - bson_as_json (&reply, NULL)); - } - - bson_destroy (&reply); - bson_destroy (&opts); - mongoc_collection_destroy (collection); - - /* warning when trying to end the session */ - capture_logs (true); - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); -} - - -static void -test_cursor_primary_read_pref (void *ctx) -{ - mongoc_client_t *client; - mongoc_client_session_t *session; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - bson_t opts = BSON_INITIALIZER; - mongoc_read_prefs_t *read_prefs; - const bson_t *doc; - bson_error_t error; - bool r; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - collection = get_test_collection (client, "test_cursor_primary_read_pref"); - - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - - r = mongoc_client_session_start_transaction (session, NULL, &error); - ASSERT_OR_PRINT (r, error); - - r = mongoc_client_session_append (session, &opts, &error); - ASSERT_OR_PRINT (r, error); - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - cursor = mongoc_collection_find_with_opts ( - collection, tmp_bson ("{}"), &opts, read_prefs); - - bson_destroy (&opts); - mongoc_read_prefs_destroy (read_prefs); - mongoc_collection_destroy (collection); - - ASSERT (!mongoc_cursor_next (cursor, &doc)); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - mongoc_cursor_destroy (cursor); - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); -} - - -/* test the fix to CDRIVER-2815. */ -void -test_inherit_from_client (void *ctx) -{ - mongoc_client_t *client; - mongoc_client_session_t *session; - bson_error_t error; - mongoc_uri_t *uri; - mongoc_read_concern_t *rc; - const mongoc_read_concern_t *returned_rc; - mongoc_read_prefs_t *rp; - const mongoc_read_prefs_t *returned_rp; - mongoc_write_concern_t *wc; - const mongoc_write_concern_t *returned_wc; - mongoc_session_opt_t *sopt; - const mongoc_session_opt_t *returned_sopt; - mongoc_transaction_opt_t *topt; - const mongoc_transaction_opt_t *returned_topt; - - BSON_UNUSED (ctx); - - uri = test_framework_get_uri (); - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_MAJORITY); - mongoc_uri_set_read_concern (uri, rc); - - rp = mongoc_read_prefs_new (MONGOC_READ_NEAREST); - mongoc_uri_set_read_prefs_t (uri, rp); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 0); - mongoc_uri_set_write_concern (uri, wc); - - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - - sopt = mongoc_session_opts_new (); - topt = mongoc_transaction_opts_new (); - - mongoc_transaction_opts_set_read_concern (topt, rc); - mongoc_transaction_opts_set_read_prefs (topt, rp); - mongoc_transaction_opts_set_write_concern (topt, wc); - - mongoc_session_opts_set_default_transaction_opts (sopt, topt); - - session = mongoc_client_start_session (client, sopt, &error); - ASSERT_OR_PRINT (session, error); - - /* test that unacknowledged write concern is actually used, since it should - * result in an error. */ - ASSERT (!mongoc_client_session_start_transaction (session, NULL, &error)); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_TRANSACTION, - MONGOC_ERROR_TRANSACTION_INVALID_STATE, - "Transactions do not support unacknowledged write concern"); - - returned_sopt = mongoc_client_session_get_opts (session); - returned_topt = - mongoc_session_opts_get_default_transaction_opts (returned_sopt); - returned_rc = mongoc_transaction_opts_get_read_concern (returned_topt); - returned_rp = mongoc_transaction_opts_get_read_prefs (returned_topt); - returned_wc = mongoc_transaction_opts_get_write_concern (returned_topt); - - BSON_ASSERT (strcmp (mongoc_read_concern_get_level (returned_rc), - mongoc_read_concern_get_level (rc)) == 0); - BSON_ASSERT (mongoc_write_concern_get_w (returned_wc) == - mongoc_write_concern_get_w (wc)); - BSON_ASSERT (mongoc_read_prefs_get_mode (returned_rp) == - mongoc_read_prefs_get_mode (rp)); - - mongoc_read_concern_destroy (rc); - mongoc_read_prefs_destroy (rp); - mongoc_write_concern_destroy (wc); - mongoc_transaction_opts_destroy (topt); - mongoc_session_opts_destroy (sopt); - mongoc_client_session_destroy (session); - mongoc_uri_destroy (uri); - mongoc_client_destroy (client); -} - -void -test_transaction_fails_on_unsupported_version_or_sharded_cluster (void *ctx) -{ - bson_error_t error; - mongoc_client_session_t *session; - mongoc_client_t *client; - bool r; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - - r = mongoc_client_session_start_transaction (session, NULL, &error); - if (!test_framework_max_wire_version_at_least (7) || - (test_framework_is_mongos () && - !test_framework_max_wire_version_at_least (8))) { - BSON_ASSERT (!r); - ASSERT_CONTAINS (error.message, - "Multi-document transactions are not supported by this " - "server version"); - } else { - ASSERT_OR_PRINT (r, error); - } - - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); -} - - -static void -test_transaction_recovery_token_cleared (void *ctx) -{ - bson_error_t error; - mongoc_client_session_t *session; - mongoc_client_t *client; - mongoc_collection_t *coll; - mongoc_uri_t *uri; - bson_t txn_opts; - - BSON_UNUSED (ctx); - - uri = test_framework_get_uri (); - ASSERT_OR_PRINT ( - mongoc_uri_upsert_host_and_port (uri, "localhost:27018", &error), error); - client = test_framework_client_new_from_uri (uri, NULL); - test_framework_set_ssl_opts (client); - mongoc_uri_destroy (uri); - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - coll = get_test_collection (client, "transaction_test"); - - mongoc_client_command_with_opts (client, - "admin", - tmp_bson ("{'killAllSessions': []}"), - NULL, - NULL, - NULL, - &error); - /* Create the collection by inserting a canary document. You cannot create - * inside a transaction */ - ASSERT_OR_PRINT ( - mongoc_collection_insert_one (coll, tmp_bson ("{}"), NULL, NULL, &error), - error); - - bson_init (&txn_opts); - ASSERT_OR_PRINT (mongoc_client_session_append (session, &txn_opts, &error), - error); - - ASSERT_OR_PRINT ( - mongoc_client_session_start_transaction (session, NULL, &error), error); - - /* Initially no recovery token. */ - BSON_ASSERT (!session->recovery_token); - mongoc_collection_insert_one ( - coll, tmp_bson ("{}"), &txn_opts, NULL, &error); - BSON_ASSERT (session->recovery_token); - ASSERT_OR_PRINT ( - mongoc_client_session_commit_transaction (session, NULL, &error), error); - BSON_ASSERT (session->recovery_token); - - /* Starting a new transaction clears the recovery token. */ - ASSERT_OR_PRINT ( - mongoc_client_session_start_transaction (session, NULL, &error), error); - BSON_ASSERT (!session->recovery_token); - - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{}"), &txn_opts, NULL, &error), - error); - BSON_ASSERT (session->recovery_token); - ASSERT_OR_PRINT ( - mongoc_client_session_commit_transaction (session, NULL, &error), error); - BSON_ASSERT (session->recovery_token); - - /* Transitioning to the "none" state (i.e. a new operation outside of a - * transaction), clears the recovery token */ - ASSERT_OR_PRINT (mongoc_collection_insert_one ( - coll, tmp_bson ("{}"), &txn_opts, NULL, &error), - error); - BSON_ASSERT (!session->recovery_token); - - bson_destroy (&txn_opts); - mongoc_collection_destroy (coll); - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); -} - -static void -test_selected_server_is_pinned_to_mongos (void *ctx) -{ - mongoc_uri_t *uri = NULL; - mongoc_client_t *client = NULL; - const mongoc_set_t *servers = NULL; - mongoc_transaction_opt_t *txn_opts = NULL; - mongoc_session_opt_t *session_opts = NULL; - mongoc_client_session_t *session = NULL; - mongoc_server_stream_t *server_stream = NULL; - bson_error_t error; - bson_t reply; - bson_t *insert_opts = NULL; - mongoc_database_t *db = NULL; - mongoc_collection_t *coll = NULL; - bool r; - uint32_t expected_id; - uint32_t actual_id; - const mongoc_server_description_t *sd = NULL; - - BSON_UNUSED (ctx); - - uri = test_framework_get_uri (); - ASSERT_OR_PRINT ( - mongoc_uri_upsert_host_and_port (uri, "localhost:27018", &error), error); - - client = test_framework_client_new_from_uri (uri, NULL); - BSON_ASSERT (client); - test_framework_set_ssl_opts (client); - - txn_opts = mongoc_transaction_opts_new (); - session_opts = mongoc_session_opts_new (); - - session = mongoc_client_start_session (client, session_opts, &error); - ASSERT_OR_PRINT (session, error); - - /* set the server id to an arbitrary value */ - _mongoc_client_session_pin (session, 42); - BSON_ASSERT (42 == mongoc_client_session_get_server_id (session)); - - /* starting a transaction should clear the server id */ - r = mongoc_client_session_start_transaction (session, txn_opts, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (0 == mongoc_client_session_get_server_id (session)); - - expected_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (expected_id, error); - - /* session should still be unpinned */ - BSON_ASSERT (0 == mongoc_client_session_get_server_id (session)); - - /* should pin to the expected server id */ - server_stream = mongoc_cluster_stream_for_server ( - &client->cluster, expected_id, true, session, NULL, &error); - ASSERT_OR_PRINT (server_stream, error); - ASSERT_CMPINT32 ( - expected_id, ==, mongoc_client_session_get_server_id (session)); - - db = mongoc_client_get_database (client, "db"); - coll = mongoc_database_create_collection (db, "coll", NULL, &error); - - insert_opts = bson_new (); - r = mongoc_client_session_append (session, insert_opts, &error); - ASSERT_OR_PRINT (r, error); - - /* this should not override the expected server id */ - r = mongoc_collection_insert_one ( - coll, tmp_bson ("{}"), insert_opts, NULL, &error); - ASSERT_OR_PRINT (r, error); - actual_id = mongoc_client_session_get_server_id (session); - - ASSERT_CMPINT32 (actual_id, ==, expected_id); - - /* get a valid server id that's different from the pinned server id */ - servers = - mc_tpld_servers_const (mc_tpld_unsafe_get_const (client->topology)); - for (size_t i = 0; i < servers->items_len; i++) { - sd = mongoc_set_get_item_const (servers, i); - if (sd && sd->id != actual_id) { - break; - } - } - - /* attempting to pin to a different but valid server id should fail */ - BSON_ASSERT (sd); - r = mongoc_client_command_with_opts ( - client, - "db", - tmp_bson ("{'ping': 1}"), - NULL, - tmp_bson ("{'serverId': %d, 'sessionId': {'$numberLong': '%ld'}}", - sd->id, - session->client_session_id), - &reply, - &error); - - BSON_ASSERT (!r); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_SERVER_SELECTION_INVALID_ID, - "Requested server id does not matched pinned server id"); - - r = mongoc_client_session_abort_transaction (session, &error); - ASSERT_OR_PRINT (r, error); - - bson_destroy (insert_opts); - bson_destroy (&reply); - mongoc_collection_destroy (coll); - mongoc_database_destroy (db); - mongoc_session_opts_destroy (session_opts); - mongoc_transaction_opts_destroy (txn_opts); - mongoc_server_stream_cleanup (server_stream); - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); -} - -static void -test_get_transaction_opts (void) -{ - mongoc_uri_t *uri = NULL; - mongoc_client_t *client = NULL; - mongoc_client_session_t *session = NULL; - mongoc_transaction_opt_t *expected_txn_opts = NULL; - mongoc_transaction_opt_t *actual_txn_opts = NULL; - mongoc_session_opt_t *session_opts = NULL; - mongoc_read_concern_t *read_concern = NULL; - mongoc_write_concern_t *write_concern = NULL; - mongoc_read_prefs_t *read_prefs = NULL; - mock_server_t *server = NULL; - int64_t max_commit_time_ms = 123; /* arbitrary */ - bson_error_t error; - bool r; - - server = mock_server_new (); - mock_server_run (server); - rs_response_to_hello (server, - WIRE_VERSION_4_0, - true /* primary */, - false /* tags */, - server, - NULL); - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - BSON_ASSERT (client); - - read_concern = mongoc_read_concern_new (); - mongoc_read_concern_set_level (read_concern, "snapshot"); - - write_concern = mongoc_write_concern_new (); - mongoc_write_concern_set_w (write_concern, MONGOC_WRITE_CONCERN_W_MAJORITY); - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - - expected_txn_opts = mongoc_transaction_opts_new (); - - mongoc_transaction_opts_set_read_concern (expected_txn_opts, read_concern); - mongoc_transaction_opts_set_write_concern (expected_txn_opts, write_concern); - mongoc_transaction_opts_set_read_prefs (expected_txn_opts, read_prefs); - mongoc_transaction_opts_set_max_commit_time_ms (expected_txn_opts, - max_commit_time_ms); - - session_opts = mongoc_session_opts_new (); - session = mongoc_client_start_session (client, session_opts, &error); - ASSERT_OR_PRINT (session, error); - /* outside of a txn this function should return NULL */ - BSON_ASSERT (!mongoc_session_opts_get_transaction_opts (session)); - - r = mongoc_client_session_start_transaction ( - session, expected_txn_opts, &error); - ASSERT_OR_PRINT (r, error); - - actual_txn_opts = mongoc_session_opts_get_transaction_opts (session); - BSON_ASSERT (actual_txn_opts); - BSON_ASSERT ( - 0 == bson_compare ( - _mongoc_read_concern_get_bson (actual_txn_opts->read_concern), - _mongoc_read_concern_get_bson (expected_txn_opts->read_concern))); - - BSON_ASSERT (0 == bson_compare (_mongoc_write_concern_get_bson ( - actual_txn_opts->write_concern), - _mongoc_write_concern_get_bson ( - expected_txn_opts->write_concern))); - - BSON_ASSERT (mongoc_read_prefs_get_mode (actual_txn_opts->read_prefs) == - mongoc_read_prefs_get_mode (expected_txn_opts->read_prefs)); - - BSON_ASSERT (actual_txn_opts->max_commit_time_ms == - expected_txn_opts->max_commit_time_ms); - - r = mongoc_client_session_abort_transaction (session, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (!mongoc_session_opts_get_transaction_opts (session)); - - mongoc_read_concern_destroy (read_concern); - mongoc_write_concern_destroy (write_concern); - mongoc_read_prefs_destroy (read_prefs); - mongoc_transaction_opts_destroy (expected_txn_opts); - mongoc_transaction_opts_destroy (actual_txn_opts); - mongoc_session_opts_destroy (session_opts); - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - -static void -test_max_commit_time_ms_is_reset (void *ctx) -{ - mock_rs_t *rs; - mongoc_uri_t *uri = NULL; - mongoc_client_t *client = NULL; - mongoc_transaction_opt_t *txn_opts = NULL; - mongoc_session_opt_t *session_opts = NULL; - mongoc_client_session_t *session = NULL; - bson_error_t error; - bool r; - - BSON_UNUSED (ctx); - - rs = mock_rs_with_auto_hello (WIRE_VERSION_4_2, - true /* has primary */, - 2 /* secondaries */, - 0 /* arbiters */); - - mock_rs_run (rs); - uri = mongoc_uri_copy (mock_rs_get_uri (rs)); - - client = test_framework_client_new_from_uri (uri, NULL); - BSON_ASSERT (client); - - txn_opts = mongoc_transaction_opts_new (); - session_opts = mongoc_session_opts_new (); - - session = mongoc_client_start_session (client, session_opts, &error); - ASSERT_OR_PRINT (session, error); - - mongoc_transaction_opts_set_max_commit_time_ms (txn_opts, 1); - - r = mongoc_client_session_start_transaction (session, txn_opts, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (1 == session->txn.opts.max_commit_time_ms); - - r = mongoc_client_session_abort_transaction (session, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (DEFAULT_MAX_COMMIT_TIME_MS == - session->txn.opts.max_commit_time_ms); - - mongoc_transaction_opts_set_max_commit_time_ms (txn_opts, - DEFAULT_MAX_COMMIT_TIME_MS); - - r = mongoc_client_session_start_transaction (session, txn_opts, &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (DEFAULT_MAX_COMMIT_TIME_MS == - session->txn.opts.max_commit_time_ms); - - r = mongoc_client_session_abort_transaction (session, &error); - ASSERT_OR_PRINT (r, error); - - mongoc_session_opts_destroy (session_opts); - mongoc_transaction_opts_destroy (txn_opts); - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_rs_destroy (rs); -} - -void -test_transactions_install (TestSuite *suite) -{ - install_json_test_suite_with_check (suite, - JSON_DIR, - "transactions/legacy", - test_transactions_cb, - test_framework_skip_if_no_txns, - test_framework_skip_if_slow); - - install_json_test_suite_with_check (suite, - JSON_DIR, - "with_transaction", - test_transactions_cb, - test_framework_skip_if_no_txns, - test_framework_skip_if_slow); - - TestSuite_AddFull (suite, - "/transactions/supported", - test_transactions_supported, - NULL, - NULL, - test_framework_skip_if_no_txns); - TestSuite_AddFull (suite, - "/transactions/in_transaction", - test_in_transaction, - NULL, - NULL, - test_framework_skip_if_no_txns); - TestSuite_AddMockServerTest (suite, - "/transactions/server_selection_err", - test_server_selection_error, - test_framework_skip_if_no_crypto); - TestSuite_AddMockServerTest (suite, - "/transactions/network_err", - test_network_error, - test_framework_skip_if_no_crypto); - TestSuite_AddMockServerTest (suite, - "/transactions/unknown_commit_result", - test_unknown_commit_result, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/transactions/cursor_primary_read_pref", - test_cursor_primary_read_pref, - NULL, - NULL, - test_framework_skip_if_no_txns); - TestSuite_AddFull (suite, - "/transactions/inherit_from_client", - test_inherit_from_client, - NULL, - NULL, - test_framework_skip_if_no_txns); - TestSuite_AddFull ( - suite, - "/transactions/" - "transaction_fails_on_unsupported_version_or_sharded_cluster", - test_transaction_fails_on_unsupported_version_or_sharded_cluster, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/transactions/recovery_token_cleared", - test_transaction_recovery_token_cleared, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_not_mongos); - TestSuite_AddFull (suite, - "/transactions/selected_server_pinned_to_mongos", - test_selected_server_is_pinned_to_mongos, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_max_wire_version_less_than_8, - test_framework_skip_if_not_mongos); - TestSuite_AddMockServerTest (suite, - "/transactions/get_transaction_opts", - test_get_transaction_opts, - test_framework_skip_if_no_crypto); - TestSuite_AddFull (suite, - "/transactions/max_commit_time_ms_is_reset", - test_max_commit_time_ms_is_reset, - NULL, - NULL, - test_framework_skip_if_no_crypto); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-uri.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-uri.c deleted file mode 100644 index 59ff862dc..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-uri.c +++ /dev/null @@ -1,2842 +0,0 @@ -#include -#include - -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-topology-private.h" -#include "mongoc/mongoc-uri-private.h" -#include "mongoc/mongoc-host-list-private.h" - -#include "TestSuite.h" - -#include "test-libmongoc.h" -#include "test-conveniences.h" - -static void -test_mongoc_uri_new (void) -{ - const mongoc_host_list_t *hosts; - const bson_t *options; - const bson_t *credentials; - const bson_t *read_prefs_tags; - const mongoc_read_prefs_t *read_prefs; - bson_t properties; - mongoc_uri_t *uri; - bson_iter_t iter; - bson_iter_t child; - - capture_logs (true); - - /* bad uris */ - ASSERT (!mongoc_uri_new ("mongodb://")); - ASSERT (!mongoc_uri_new ("mongodb://\x80")); - ASSERT (!mongoc_uri_new ("mongodb://localhost/\x80")); - ASSERT (!mongoc_uri_new ("mongodb://localhost:\x80/")); - ASSERT (!mongoc_uri_new ("mongodb://localhost/?ipv6=\x80")); - ASSERT (!mongoc_uri_new ("mongodb://localhost/?foo=\x80")); - ASSERT (!mongoc_uri_new ("mongodb://localhost/?\x80=bar")); - ASSERT (!mongoc_uri_new ("mongodb://\x80:pass@localhost")); - ASSERT (!mongoc_uri_new ("mongodb://user:\x80@localhost")); - ASSERT (!mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" - "?" MONGOC_URI_AUTHMECHANISM "=\x80")); - ASSERT (!mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" - "?" MONGOC_URI_AUTHMECHANISM - "=GSSAPI&" MONGOC_URI_AUTHMECHANISMPROPERTIES - "=SERVICE_NAME:\x80")); - ASSERT (!mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" - "?" MONGOC_URI_AUTHMECHANISM - "=GSSAPI&" MONGOC_URI_AUTHMECHANISMPROPERTIES - "=\x80:mongodb")); - ASSERT (!mongoc_uri_new ("mongodb://::")); - ASSERT (!mongoc_uri_new ("mongodb://[::1]::27017/")); - ASSERT (!mongoc_uri_new ("mongodb://localhost::27017")); - ASSERT (!mongoc_uri_new ("mongodb://localhost,localhost::")); - ASSERT (!mongoc_uri_new ("mongodb://local1,local2,local3/d?k")); - ASSERT (!mongoc_uri_new ("")); - ASSERT (!mongoc_uri_new ("mongodb://,localhost:27017")); - ASSERT (!mongoc_uri_new ("mongodb://localhost:27017,,b")); - ASSERT (!mongoc_uri_new ("mongo://localhost:27017")); - ASSERT (!mongoc_uri_new ("mongodb://localhost::27017")); - ASSERT (!mongoc_uri_new ("mongodb://localhost::27017/")); - ASSERT (!mongoc_uri_new ("mongodb://localhost::27017,abc")); - ASSERT (!mongoc_uri_new ("mongodb://localhost:-1")); - ASSERT (!mongoc_uri_new ("mongodb://localhost:65536")); - ASSERT (!mongoc_uri_new ("mongodb://localhost:foo")); - ASSERT (!mongoc_uri_new ("mongodb://localhost:65536/")); - ASSERT (!mongoc_uri_new ("mongodb://localhost:0/")); - ASSERT (!mongoc_uri_new ("mongodb://[::1%lo0]")); - ASSERT (!mongoc_uri_new ("mongodb://[::1]:-1")); - ASSERT (!mongoc_uri_new ("mongodb://[::1]:foo")); - ASSERT (!mongoc_uri_new ("mongodb://[::1]:65536")); - ASSERT (!mongoc_uri_new ("mongodb://[::1]:65536/")); - ASSERT (!mongoc_uri_new ("mongodb://[::1]:0/")); - ASSERT (!mongoc_uri_new ("mongodb://localhost:27017/test?replicaset=")); - ASSERT (!mongoc_uri_new ("mongodb://local1,local2/?directConnection=true")); - ASSERT (!mongoc_uri_new ("mongodb+srv://local1/?directConnection=true")); - - uri = mongoc_uri_new ( - "mongodb://[::1]:27888,[::2]:27999/?ipv6=true&" MONGOC_URI_SAFE "=true"); - BSON_ASSERT (uri); - hosts = mongoc_uri_get_hosts (uri); - BSON_ASSERT (hosts); - ASSERT_CMPSTR (hosts->host, "::1"); - BSON_ASSERT (hosts->port == 27888); - ASSERT_CMPSTR (hosts->host_and_port, "[::1]:27888"); - mongoc_uri_destroy (uri); - - /* should recognize IPv6 "scope" like "::1%lo0", with % escaped */ - uri = mongoc_uri_new ("mongodb://[::1%25lo0]"); - BSON_ASSERT (uri); - hosts = mongoc_uri_get_hosts (uri); - BSON_ASSERT (hosts); - ASSERT_CMPSTR (hosts->host, "::1%lo0"); - BSON_ASSERT (hosts->port == 27017); - ASSERT_CMPSTR (hosts->host_and_port, "[::1%lo0]:27017"); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://%2Ftmp%2Fmongodb-27017.sock/?"); - ASSERT (uri); - mongoc_uri_destroy (uri); - - /* should normalize to lowercase */ - uri = mongoc_uri_new ("mongodb://cRaZyHoStNaMe"); - BSON_ASSERT (uri); - hosts = mongoc_uri_get_hosts (uri); - BSON_ASSERT (hosts); - ASSERT_CMPSTR (hosts->host, "crazyhostname"); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/?"); - ASSERT (uri); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost:27017/test?replicaset=foo"); - ASSERT (uri); - hosts = mongoc_uri_get_hosts (uri); - ASSERT (hosts); - ASSERT (!hosts->next); - ASSERT_CMPSTR (hosts->host, "localhost"); - ASSERT_CMPINT (hosts->port, ==, 27017); - ASSERT_CMPSTR (hosts->host_and_port, "localhost:27017"); - ASSERT_CMPSTR (mongoc_uri_get_database (uri), "test"); - options = mongoc_uri_get_options (uri); - ASSERT (options); - ASSERT (bson_iter_init_find (&iter, options, "replicaset")); - ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), "foo"); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://local1,local2:999,local3/?replicaset=foo"); - ASSERT (uri); - hosts = mongoc_uri_get_hosts (uri); - ASSERT (hosts); - ASSERT (hosts->next); - ASSERT (hosts->next->next); - ASSERT (!hosts->next->next->next); - ASSERT_CMPSTR (hosts->host, "local1"); - ASSERT_CMPINT (hosts->port, ==, 27017); - ASSERT_CMPSTR (hosts->next->host, "local2"); - ASSERT_CMPINT (hosts->next->port, ==, 999); - ASSERT_CMPSTR (hosts->next->next->host, "local3"); - ASSERT_CMPINT (hosts->next->next->port, ==, 27017); - options = mongoc_uri_get_options (uri); - ASSERT (options); - ASSERT (bson_iter_init_find (&iter, options, "replicaset")); - ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), "foo"); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost:27017/" - "?" MONGOC_URI_READPREFERENCE - "=secondaryPreferred&" MONGOC_URI_READPREFERENCETAGS - "=dc:ny&" MONGOC_URI_READPREFERENCETAGS "="); - ASSERT (uri); - read_prefs = mongoc_uri_get_read_prefs_t (uri); - ASSERT (mongoc_read_prefs_get_mode (read_prefs) == - MONGOC_READ_SECONDARY_PREFERRED); - ASSERT (read_prefs); - read_prefs_tags = mongoc_read_prefs_get_tags (read_prefs); - ASSERT (read_prefs_tags); - ASSERT_CMPINT (bson_count_keys (read_prefs_tags), ==, 2); - ASSERT (bson_iter_init_find (&iter, read_prefs_tags, "0")); - ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - ASSERT (bson_iter_recurse (&iter, &child)); - ASSERT (bson_iter_next (&child)); - ASSERT_CMPSTR (bson_iter_key (&child), "dc"); - ASSERT_CMPSTR (bson_iter_utf8 (&child, NULL), "ny"); - ASSERT (!bson_iter_next (&child)); - ASSERT (bson_iter_next (&iter)); - ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - ASSERT (bson_iter_recurse (&iter, &child)); - ASSERT (!bson_iter_next (&child)); - ASSERT (!bson_iter_next (&iter)); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_SAFE - "=false&" MONGOC_URI_JOURNAL "=false"); - options = mongoc_uri_get_options (uri); - ASSERT (options); - ASSERT_CMPINT (bson_count_keys (options), ==, 2); - ASSERT (bson_iter_init (&iter, options)); - ASSERT (bson_iter_find_case (&iter, "" MONGOC_URI_SAFE "")); - ASSERT (BSON_ITER_HOLDS_BOOL (&iter)); - ASSERT (!bson_iter_bool (&iter)); - ASSERT (bson_iter_find_case (&iter, MONGOC_URI_JOURNAL)); - ASSERT (BSON_ITER_HOLDS_BOOL (&iter)); - ASSERT (!bson_iter_bool (&iter)); - ASSERT (!bson_iter_next (&iter)); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ( - "mongodb://%2Ftmp%2Fmongodb-27017.sock/?" MONGOC_URI_TLS "=false"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host, "/tmp/mongodb-27017.sock"); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ( - "mongodb://%2Ftmp%2Fmongodb-27017.sock,localhost:27017/?" MONGOC_URI_TLS - "=false"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host, "/tmp/mongodb-27017.sock"); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->next->host_and_port, - "localhost:27017"); - ASSERT (!mongoc_uri_get_hosts (uri)->next->next); - mongoc_uri_destroy (uri); - - /* should assign port numbers to correct hosts */ - uri = mongoc_uri_new ("mongodb://host1,host2:30000/foo"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host_and_port, "host1:27017"); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->next->host_and_port, - "host2:30000"); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ( - "mongodb://localhost:27017,%2Ftmp%2Fmongodb-27017.sock/?" MONGOC_URI_TLS - "=false"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host_and_port, "localhost:27017"); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->next->host, - "/tmp/mongodb-27017.sock"); - ASSERT (!mongoc_uri_get_hosts (uri)->next->next); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_HEARTBEATFREQUENCYMS - "=600"); - ASSERT (uri); - ASSERT_CMPINT32 ( - 600, - ==, - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 0)); - - mongoc_uri_destroy (uri); - - /* heartbeat frequency too short */ - ASSERT (!mongoc_uri_new ( - "mongodb://localhost/?" MONGOC_URI_HEARTBEATFREQUENCYMS "=499")); - - /* should use the " MONGOC_URI_AUTHSOURCE " over db when both are specified - */ - uri = mongoc_uri_new ( - "mongodb://christian:secret@localhost:27017/foo?" MONGOC_URI_AUTHSOURCE - "=abcd"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_username (uri), "christian"); - ASSERT_CMPSTR (mongoc_uri_get_password (uri), "secret"); - ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "abcd"); - mongoc_uri_destroy (uri); - - /* should use the default auth source and mechanism */ - uri = mongoc_uri_new ("mongodb://christian:secret@localhost:27017"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "admin"); - ASSERT (!mongoc_uri_get_auth_mechanism (uri)); - mongoc_uri_destroy (uri); - - /* should use the db when no " MONGOC_URI_AUTHSOURCE " is specified */ - uri = mongoc_uri_new ("mongodb://user:password@localhost/foo"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "foo"); - mongoc_uri_destroy (uri); - - /* should recognize an empty password */ - uri = mongoc_uri_new ("mongodb://samantha:@localhost"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_username (uri), "samantha"); - ASSERT_CMPSTR (mongoc_uri_get_password (uri), ""); - mongoc_uri_destroy (uri); - - /* should recognize no password */ - uri = mongoc_uri_new ("mongodb://christian@localhost:27017"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_username (uri), "christian"); - ASSERT (!mongoc_uri_get_password (uri)); - mongoc_uri_destroy (uri); - - /* should recognize a url escaped character in the username */ - uri = mongoc_uri_new ("mongodb://christian%40realm:pwd@localhost:27017"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_username (uri), "christian@realm"); - mongoc_uri_destroy (uri); - - /* should fail on invalid escaped characters */ - capture_logs (true); - uri = mongoc_uri_new ("mongodb://u%ser:pwd@localhost:27017"); - ASSERT (!uri); - ASSERT_CAPTURED_LOG ( - "uri", MONGOC_LOG_LEVEL_WARNING, "Invalid % escape sequence"); - - uri = mongoc_uri_new ("mongodb://user:p%wd@localhost:27017"); - ASSERT (!uri); - ASSERT_CAPTURED_LOG ( - "uri", MONGOC_LOG_LEVEL_WARNING, "Invalid % escape sequence"); - - uri = mongoc_uri_new ("mongodb://user:pwd@local% host:27017"); - ASSERT (!uri); - ASSERT_CAPTURED_LOG ( - "uri", MONGOC_LOG_LEVEL_WARNING, "Invalid % escape sequence"); - - uri = mongoc_uri_new ( - "mongodb://christian%40realm@localhost:27017/?replicaset=%20"); - ASSERT (uri); - options = mongoc_uri_get_options (uri); - ASSERT (options); - ASSERT (bson_iter_init_find (&iter, options, "replicaset")); - ASSERT (BSON_ITER_HOLDS_UTF8 (&iter)); - ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), " "); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ( - "mongodb://christian%40realm@[::6]:27017/?replicaset=%20"); - ASSERT (uri); - options = mongoc_uri_get_options (uri); - ASSERT (options); - ASSERT (bson_iter_init_find (&iter, options, "replicaset")); - ASSERT (BSON_ITER_HOLDS_UTF8 (&iter)); - ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), " "); - mongoc_uri_destroy (uri); - - /* GSSAPI-specific options */ - - /* should recognize the GSSAPI mechanism, and use $external as source */ - uri = mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" - "?" MONGOC_URI_AUTHMECHANISM "=GSSAPI"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "GSSAPI"); - /*ASSERT_CMPSTR(mongoc_uri_get_auth_source(uri), "$external");*/ - mongoc_uri_destroy (uri); - - /* use $external as source when db is specified */ - uri = mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/foo" - "?" MONGOC_URI_AUTHMECHANISM "=GSSAPI"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "$external"); - mongoc_uri_destroy (uri); - - /* should not accept " MONGOC_URI_AUTHSOURCE " other than $external */ - ASSERT (!mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" - "foo?" MONGOC_URI_AUTHMECHANISM - "=GSSAPI&" MONGOC_URI_AUTHSOURCE "=bar")); - - /* should accept MONGOC_URI_AUTHMECHANISMPROPERTIES */ - uri = mongoc_uri_new ("mongodb://user%40DOMAIN.COM:password@localhost/" - "?" MONGOC_URI_AUTHMECHANISM - "=GSSAPI&" MONGOC_URI_AUTHMECHANISMPROPERTIES - "=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:" - "true"); - ASSERT (uri); - credentials = mongoc_uri_get_credentials (uri); - ASSERT (credentials); - ASSERT (mongoc_uri_get_mechanism_properties (uri, &properties)); - BSON_ASSERT (bson_iter_init_find_case (&iter, &properties, "SERVICE_NAME") && - BSON_ITER_HOLDS_UTF8 (&iter) && - (0 == strcmp (bson_iter_utf8 (&iter, NULL), "other"))); - BSON_ASSERT ( - bson_iter_init_find_case (&iter, &properties, "CANONICALIZE_HOST_NAME") && - BSON_ITER_HOLDS_UTF8 (&iter) && - (0 == strcmp (bson_iter_utf8 (&iter, NULL), "true"))); - mongoc_uri_destroy (uri); - - /* reverse order of arguments to ensure parsing still succeeds */ - uri = mongoc_uri_new ( - "mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISMPROPERTIES - "=SERVICE_NAME:other&" MONGOC_URI_AUTHMECHANISM "=GSSAPI"); - ASSERT (uri); - mongoc_uri_destroy (uri); - - /* MONGODB-CR */ - - /* should recognize this mechanism */ - uri = mongoc_uri_new ("mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISM - "=MONGODB-CR"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "MONGODB-CR"); - mongoc_uri_destroy (uri); - - /* X509 */ - - /* should recognize this mechanism, and use $external as the source */ - uri = mongoc_uri_new ("mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISM - "=MONGODB-X509"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "MONGODB-X509"); - /*ASSERT_CMPSTR(mongoc_uri_get_auth_source(uri), "$external");*/ - mongoc_uri_destroy (uri); - - /* use $external as source when db is specified */ - uri = mongoc_uri_new ( - "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality" - "%2CST%3DmyState%2CC%3DmyCountry@localhost/foo" - "?" MONGOC_URI_AUTHMECHANISM "=MONGODB-X509"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "$external"); - mongoc_uri_destroy (uri); - - /* should not accept " MONGOC_URI_AUTHSOURCE " other than $external */ - ASSERT (!mongoc_uri_new ( - "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality" - "%2CST%3DmyState%2CC%3DmyCountry@localhost/foo" - "?" MONGOC_URI_AUTHMECHANISM "=MONGODB-X509&" MONGOC_URI_AUTHSOURCE - "=bar")); - - /* should recognize the encoded username */ - uri = mongoc_uri_new ( - "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality" - "%2CST%3DmyState%2CC%3DmyCountry@localhost/?" MONGOC_URI_AUTHMECHANISM - "=MONGODB-X509"); - ASSERT (uri); - ASSERT_CMPSTR ( - mongoc_uri_get_username (uri), - "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry"); - mongoc_uri_destroy (uri); - - /* PLAIN */ - - /* should recognize this mechanism */ - uri = mongoc_uri_new ("mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISM - "=PLAIN"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "PLAIN"); - mongoc_uri_destroy (uri); - - /* SCRAM-SHA1 */ - - /* should recognize this mechanism */ - uri = mongoc_uri_new ("mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISM - "=SCRAM-SHA1"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "SCRAM-SHA1"); - mongoc_uri_destroy (uri); -} - - -static void -test_mongoc_uri_authmechanismproperties (void) -{ - mongoc_uri_t *uri; - bson_t props; - const bson_t *options; - - capture_logs (true); - - uri = mongoc_uri_new ("mongodb://user@localhost/?" MONGOC_URI_AUTHMECHANISM - "=SCRAM-SHA1" - "&" MONGOC_URI_AUTHMECHANISMPROPERTIES "=a:one,b:two"); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "SCRAM-SHA1"); - ASSERT (mongoc_uri_get_mechanism_properties (uri, &props)); - ASSERT_MATCH (&props, "{'a': 'one', 'b': 'two'}"); - - ASSERT (mongoc_uri_set_auth_mechanism (uri, "MONGODB-CR")); - ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "MONGODB-CR"); - - /* prohibited */ - ASSERT (!mongoc_uri_set_option_as_utf8 ( - uri, MONGOC_URI_AUTHMECHANISM, "SCRAM-SHA1")); - - ASSERT (!mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_AUTHMECHANISM, 1)); - ASSERT_CAPTURED_LOG ("setting authmechanism=1", - MONGOC_LOG_LEVEL_WARNING, - "Unsupported value for \"authmechanism\": 1," - " \"authmechanism\" is not an int32 option"); - - ASSERT (!mongoc_uri_set_option_as_utf8 ( - uri, MONGOC_URI_AUTHMECHANISMPROPERTIES, "a:three")); - - ASSERT ( - mongoc_uri_set_mechanism_properties (uri, tmp_bson ("{'a': 'four'}"))); - - ASSERT (mongoc_uri_get_mechanism_properties (uri, &props)); - ASSERT_MATCH (&props, "{'a': 'four', 'b': {'$exists': false}}"); - - mongoc_uri_destroy (uri); - - /* deprecated gssapiServiceName option */ - uri = mongoc_uri_new ("mongodb://christian%40realm.cc@localhost:27017/" - "?" MONGOC_URI_AUTHMECHANISM - "=GSSAPI&" MONGOC_URI_GSSAPISERVICENAME "=blah"); - ASSERT (uri); - options = mongoc_uri_get_options (uri); - ASSERT (options); - BSON_ASSERT (0 == strcmp (mongoc_uri_get_auth_mechanism (uri), "GSSAPI")); - BSON_ASSERT (0 == - strcmp (mongoc_uri_get_username (uri), "christian@realm.cc")); - ASSERT (mongoc_uri_get_mechanism_properties (uri, &props)); - ASSERT_MATCH (&props, "{'SERVICE_NAME': 'blah'}"); - mongoc_uri_destroy (uri); -} - - -static void -test_mongoc_uri_functions (void) -{ - mongoc_client_t *client; - mongoc_uri_t *uri; - mongoc_database_t *db; - int32_t i; - - uri = mongoc_uri_new ( - "mongodb://foo:bar@localhost:27017/baz?" MONGOC_URI_AUTHSOURCE "=source"); - - ASSERT_CMPSTR (mongoc_uri_get_username (uri), "foo"); - ASSERT_CMPSTR (mongoc_uri_get_password (uri), "bar"); - ASSERT_CMPSTR (mongoc_uri_get_database (uri), "baz"); - ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "source"); - - mongoc_uri_set_username (uri, "longer username that should work"); - ASSERT_CMPSTR (mongoc_uri_get_username (uri), - "longer username that should work"); - - mongoc_uri_set_password (uri, "longer password that should also work"); - ASSERT_CMPSTR (mongoc_uri_get_password (uri), - "longer password that should also work"); - - mongoc_uri_set_database (uri, "longer database that should work"); - ASSERT_CMPSTR (mongoc_uri_get_database (uri), - "longer database that should work"); - ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "source"); - - mongoc_uri_set_auth_source (uri, "longer authsource that should work"); - ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), - "longer authsource that should work"); - ASSERT_CMPSTR (mongoc_uri_get_database (uri), - "longer database that should work"); - - client = test_framework_client_new_from_uri (uri, NULL); - mongoc_uri_destroy (uri); - - ASSERT_CMPSTR (mongoc_uri_get_username (client->uri), - "longer username that should work"); - ASSERT_CMPSTR (mongoc_uri_get_password (client->uri), - "longer password that should also work"); - ASSERT_CMPSTR (mongoc_uri_get_database (client->uri), - "longer database that should work"); - ASSERT_CMPSTR (mongoc_uri_get_auth_source (client->uri), - "longer authsource that should work"); - mongoc_client_destroy (client); - - - uri = mongoc_uri_new ( - "mongodb://localhost/?" MONGOC_URI_SERVERSELECTIONTIMEOUTMS "=3" - "&" MONGOC_URI_JOURNAL "=true" - "&" MONGOC_URI_WTIMEOUTMS "=42" - "&" MONGOC_URI_CANONICALIZEHOSTNAME "=false"); - - ASSERT_CMPINT ( - mongoc_uri_get_option_as_int32 (uri, "serverselectiontimeoutms", 18), - ==, - 3); - ASSERT ( - mongoc_uri_set_option_as_int32 (uri, "serverselectiontimeoutms", 18)); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, "serverselectiontimeoutms", 19), - ==, - 18); - - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 18), ==, 42); - ASSERT_CMPINT64 ( - mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 18), ==, 42); - ASSERT (mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 18)); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 19), ==, 18); - - ASSERT (mongoc_uri_set_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 20)); - ASSERT_CMPINT64 ( - mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 19), ==, 20); - - ASSERT (mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 500)); - - i = mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 1000); - - ASSERT_CMPINT32 (i, ==, 500); - - capture_logs (true); - - /* Server Discovery and Monitoring Spec: "the driver MUST NOT permit users to - * configure it less than minHeartbeatFrequencyMS (500ms)." */ - ASSERT (!mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 499)); - - ASSERT_CAPTURED_LOG ( - "mongoc_uri_set_option_as_int32", - MONGOC_LOG_LEVEL_WARNING, - "Invalid \"heartbeatfrequencyms\" of 499: must be at least 500"); - - /* socketcheckintervalms isn't set, return our fallback */ - ASSERT_CMPINT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 123), - ==, - 123); - ASSERT (mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 18)); - ASSERT_CMPINT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 19), - ==, - 18); - - ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_JOURNAL, false)); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_CANONICALIZEHOSTNAME, true)); - /* tls isn't set, return out fallback */ - ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLS, true)); - - client = test_framework_client_new_from_uri (uri, NULL); - mongoc_uri_destroy (uri); - - ASSERT ( - mongoc_uri_get_option_as_bool (client->uri, MONGOC_URI_JOURNAL, false)); - ASSERT (!mongoc_uri_get_option_as_bool ( - client->uri, MONGOC_URI_CANONICALIZEHOSTNAME, true)); - /* tls isn't set, return out fallback */ - ASSERT (mongoc_uri_get_option_as_bool (client->uri, MONGOC_URI_TLS, true)); - mongoc_client_destroy (client); - - uri = mongoc_uri_new ("mongodb://localhost/"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 (uri, "replicaset", "default"), - "default"); - ASSERT (mongoc_uri_set_option_as_utf8 (uri, "replicaset", "value")); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 (uri, "replicaset", "default"), - "value"); - - mongoc_uri_destroy (uri); - - - uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_SOCKETTIMEOUTMS - "=1&" MONGOC_URI_SOCKETCHECKINTERVALMS "=200"); - ASSERT_CMPINT ( - 1, - ==, - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_SOCKETTIMEOUTMS, 0)); - ASSERT_CMPINT (200, - ==, - mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 0)); - - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_SOCKETTIMEOUTMS, 2); - ASSERT_CMPINT ( - 2, - ==, - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_SOCKETTIMEOUTMS, 0)); - - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 202); - ASSERT_CMPINT (202, - ==, - mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 0)); - - - client = test_framework_client_new_from_uri (uri, NULL); - ASSERT_CMPINT (2, ==, client->cluster.sockettimeoutms); - ASSERT_CMPINT (202, ==, client->cluster.socketcheckintervalms); - - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - - - uri = mongoc_uri_new ("mongodb://host/dbname0"); - ASSERT_CMPSTR (mongoc_uri_get_database (uri), "dbname0"); - mongoc_uri_set_database (uri, "dbname1"); - client = test_framework_client_new_from_uri (uri, NULL); - db = mongoc_client_get_default_database (client); - ASSERT_CMPSTR (mongoc_database_get_name (db), "dbname1"); - - mongoc_database_destroy (db); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://%2Ftmp%2FMongoDB-27017.sock/"); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host, "/tmp/MongoDB-27017.sock"); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host_and_port, - "/tmp/MongoDB-27017.sock"); - - mongoc_uri_destroy (uri); - - capture_logs (true); - uri = mongoc_uri_new ("mongodb://host/?foobar=1"); - ASSERT (uri); - ASSERT_CAPTURED_LOG ("setting URI option foobar=1", - MONGOC_LOG_LEVEL_WARNING, - "Unsupported URI option \"foobar\""); - - mongoc_uri_destroy (uri); -} - -static void -test_mongoc_uri_new_with_error (void) -{ - bson_error_t error = {0}; - mongoc_uri_t *uri; - - capture_logs (true); - ASSERT (!mongoc_uri_new_with_error ("mongodb://", NULL)); - uri = mongoc_uri_new_with_error ("mongodb://localhost", NULL); - ASSERT (uri); - mongoc_uri_destroy (uri); - - ASSERT (!mongoc_uri_new_with_error ("mongodb://", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid host string in URI"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongo://localhost", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid URI Schema, expecting 'mongodb://'"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ( - "mongodb://localhost/?readPreference=unknown", &error)); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Unsupported readPreference value [readPreference=unknown]"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ( - "mongodb://localhost/" - "?appname=" - "WayTooLongAppnameToBeValidSoThisShouldResultInAnErrorWayToLongAppnameToB" - "eValidSoThisShouldResultInAnErrorWayToLongAppnameToBeValidSoThisShouldRe" - "sultInAnError", - &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Unsupported value for \"appname\""); /* ... */ - - uri = mongoc_uri_new ("mongodb://localhost"); - ASSERT (!mongoc_uri_set_option_as_utf8 ( - uri, - MONGOC_URI_APPNAME, - "WayTooLongAppnameToBeValidSoThisShouldResultInAnErrorWayToLongAppnameToB" - "eValidSoThisShouldResultInAnErrorWayToLongAppnameToBeValidSoThisShouldRe" - "sultInAnError")); - mongoc_uri_destroy (uri); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT ( - !mongoc_uri_new_with_error ("mongodb://user%p:pass@localhost/", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Incorrect URI escapes in username. Percent-encode " - "username and password according to RFC 3986"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongodb://l%oc, alhost/", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid host string in URI"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongodb:///tmp/mongodb.sock", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid host string in URI") - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongodb://localhost/db.na%me", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid database name in URI"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ( - "mongodb://localhost/db?journal=true&w=0", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Journal conflicts with w value [w=0]"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ( - "mongodb://localhost/db?journal=true&w=-1", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Journal conflicts with w value [w=-1]"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongodb://localhost/db?w=-5", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Unsupported w value [w=-5]"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ( - "mongodb://localhost/db?heartbeatfrequencyms=10", &error)); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid \"heartbeatfrequencyms\" of 10: must be at least 500"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ( - "mongodb://localhost/db?zlibcompressionlevel=10", &error)); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid \"zlibcompressionlevel\" of 10: must be between -1 and 9"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongodb+srv://", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Missing service name in SRV URI"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongodb+srv://%", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid service name in URI"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongodb+srv://x", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid service name in URI"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongodb+srv://x.y", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid service name in URI"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongodb+srv://a.b.c,d.e.f", &error)); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Multiple service names are prohibited in an SRV URI"); - - memset (&error, 0, sizeof (bson_error_t)); - ASSERT (!mongoc_uri_new_with_error ("mongodb+srv://a.b.c:8000", &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Port numbers are prohibited in an SRV URI"); -} - - -#undef ASSERT_SUPPRESS - - -static void -test_mongoc_uri_compound_setters (void) -{ - mongoc_uri_t *uri; - mongoc_read_prefs_t *prefs; - const mongoc_read_prefs_t *prefs_result; - mongoc_read_concern_t *rc; - const mongoc_read_concern_t *rc_result; - mongoc_write_concern_t *wc; - const mongoc_write_concern_t *wc_result; - - uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READPREFERENCE - "=nearest&" MONGOC_URI_READPREFERENCETAGS - "=dc:ny&" MONGOC_URI_READCONCERNLEVEL - "=majority&" MONGOC_URI_W "=3"); - - prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - mongoc_uri_set_read_prefs_t (uri, prefs); - prefs_result = mongoc_uri_get_read_prefs_t (uri); - ASSERT_CMPINT ( - mongoc_read_prefs_get_mode (prefs_result), ==, MONGOC_READ_SECONDARY); - ASSERT (bson_empty (mongoc_read_prefs_get_tags (prefs_result))); - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, "whatever"); - mongoc_uri_set_read_concern (uri, rc); - rc_result = mongoc_uri_get_read_concern (uri); - ASSERT_CMPSTR (mongoc_read_concern_get_level (rc_result), "whatever"); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 2); - mongoc_uri_set_write_concern (uri, wc); - wc_result = mongoc_uri_get_write_concern (uri); - ASSERT_CMPINT32 (mongoc_write_concern_get_w (wc_result), ==, (int32_t) 2); - - mongoc_read_prefs_destroy (prefs); - mongoc_read_concern_destroy (rc); - mongoc_write_concern_destroy (wc); - mongoc_uri_destroy (uri); -} - - -static void -test_mongoc_host_list_from_string (void) -{ - mongoc_host_list_t host_list = {0}; - - /* shouldn't be parsable */ - capture_logs (true); - ASSERT (!_mongoc_host_list_from_string (&host_list, ":27017")); - ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", - MONGOC_LOG_LEVEL_ERROR, - "Could not parse address"); - capture_logs (true); - ASSERT (!_mongoc_host_list_from_string (&host_list, "example.com:")); - ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", - MONGOC_LOG_LEVEL_ERROR, - "Could not parse address"); - capture_logs (true); - ASSERT (!_mongoc_host_list_from_string (&host_list, "localhost:999999999")); - ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", - MONGOC_LOG_LEVEL_ERROR, - "Could not parse address"); - capture_logs (true); - ASSERT (!_mongoc_host_list_from_string (&host_list, "::1234")); - ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", - MONGOC_LOG_LEVEL_ERROR, - "Could not parse address"); - - capture_logs (true); - ASSERT (!_mongoc_host_list_from_string (&host_list, "]:1234")); - ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", - MONGOC_LOG_LEVEL_ERROR, - "Could not parse address"); - - capture_logs (true); - ASSERT (!_mongoc_host_list_from_string (&host_list, "[]:1234")); - ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", - MONGOC_LOG_LEVEL_ERROR, - "Could not parse address"); - - capture_logs (true); - ASSERT (!_mongoc_host_list_from_string (&host_list, "[::1] foo")); - ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", - MONGOC_LOG_LEVEL_ERROR, - "Could not parse address"); - - capture_logs (true); - ASSERT ( - !_mongoc_host_list_from_string (&host_list, "[::1]extra_chars:27017")); - ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", - MONGOC_LOG_LEVEL_ERROR, - "If present, port should immediately follow the \"]\"" - "in an IPv6 address"); - - /* normal parsing, host and port are split, host is downcased */ - ASSERT (_mongoc_host_list_from_string (&host_list, "localHOST:27019")); - ASSERT_CMPSTR (host_list.host_and_port, "localhost:27019"); - ASSERT_CMPSTR (host_list.host, "localhost"); - ASSERT (host_list.port == 27019); - ASSERT (!host_list.next); - - ASSERT (_mongoc_host_list_from_string (&host_list, "localhost")); - ASSERT_CMPSTR (host_list.host_and_port, "localhost:27017"); - ASSERT_CMPSTR (host_list.host, "localhost"); - ASSERT (host_list.port == 27017); - - ASSERT (_mongoc_host_list_from_string (&host_list, "[::1]")); - ASSERT_CMPSTR (host_list.host_and_port, "[::1]:27017"); - ASSERT_CMPSTR (host_list.host, "::1"); /* no "[" or "]" */ - ASSERT (host_list.port == 27017); - - ASSERT (_mongoc_host_list_from_string (&host_list, "[Fe80::1]:1234")); - ASSERT_CMPSTR (host_list.host_and_port, "[fe80::1]:1234"); - ASSERT_CMPSTR (host_list.host, "fe80::1"); - ASSERT (host_list.port == 1234); - - ASSERT (_mongoc_host_list_from_string (&host_list, "[fe80::1%lo0]:1234")); - ASSERT_CMPSTR (host_list.host_and_port, "[fe80::1%lo0]:1234"); - ASSERT_CMPSTR (host_list.host, "fe80::1%lo0"); - ASSERT (host_list.port == 1234); - - ASSERT (_mongoc_host_list_from_string (&host_list, "[fe80::1%lo0]:1234")); - ASSERT_CMPSTR (host_list.host_and_port, "[fe80::1%lo0]:1234"); - ASSERT_CMPSTR (host_list.host, "fe80::1%lo0"); - ASSERT (host_list.port == 1234); - - /* preserves case */ - ASSERT (_mongoc_host_list_from_string (&host_list, "/Path/to/file.sock")); - ASSERT_CMPSTR (host_list.host_and_port, "/Path/to/file.sock"); - ASSERT_CMPSTR (host_list.host, "/Path/to/file.sock"); - - /* weird cases that should still parse, without crashing */ - ASSERT (_mongoc_host_list_from_string (&host_list, "/Path/to/file.sock:1")); - ASSERT_CMPSTR (host_list.host, "/Path/to/file.sock"); - ASSERT (host_list.family == AF_UNIX); - - ASSERT (_mongoc_host_list_from_string (&host_list, " :1234")); - ASSERT_CMPSTR (host_list.host_and_port, " :1234"); - ASSERT_CMPSTR (host_list.host, " "); - ASSERT (host_list.port == 1234); - - ASSERT (_mongoc_host_list_from_string (&host_list, "[:1234")); - ASSERT_CMPSTR (host_list.host_and_port, "[:1234"); - ASSERT_CMPSTR (host_list.host, "["); - ASSERT (host_list.port == 1234); - - ASSERT (_mongoc_host_list_from_string (&host_list, "[:]")); - ASSERT_CMPSTR (host_list.host_and_port, "[:]:27017"); - ASSERT_CMPSTR (host_list.host, ":"); - ASSERT (host_list.port == 27017); -} - - -static void -test_mongoc_uri_new_for_host_port (void) -{ - mongoc_uri_t *uri; - - uri = mongoc_uri_new_for_host_port ("uber", 555); - ASSERT (uri); - ASSERT (!strcmp ("uber", mongoc_uri_get_hosts (uri)->host)); - ASSERT (!strcmp ("uber:555", mongoc_uri_get_hosts (uri)->host_and_port)); - ASSERT (555 == mongoc_uri_get_hosts (uri)->port); - mongoc_uri_destroy (uri); -} - -static void -test_mongoc_uri_compressors (void) -{ - mongoc_uri_t *uri; - - uri = mongoc_uri_new ("mongodb://localhost/"); - - ASSERT (bson_empty (mongoc_uri_get_compressors (uri))); - -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY - capture_logs (true); - mongoc_uri_set_compressors (uri, "snappy,unknown"); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); - ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "unknown")); - ASSERT_CAPTURED_LOG ("mongoc_uri_set_compressors", - MONGOC_LOG_LEVEL_WARNING, - "Unsupported compressor: 'unknown'"); -#endif - - -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY - capture_logs (true); - mongoc_uri_set_compressors (uri, "snappy"); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); - ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "unknown")); - ASSERT_NO_CAPTURED_LOGS ("snappy uri"); - - /* Overwrite the previous URI, effectively disabling snappy */ - capture_logs (true); - mongoc_uri_set_compressors (uri, "unknown"); - ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); - ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "unknown")); - ASSERT_CAPTURED_LOG ("mongoc_uri_set_compressors", - MONGOC_LOG_LEVEL_WARNING, - "Unsupported compressor: 'unknown'"); -#endif - - capture_logs (true); - mongoc_uri_set_compressors (uri, ""); - ASSERT (bson_empty (mongoc_uri_get_compressors (uri))); - ASSERT_CAPTURED_LOG ("mongoc_uri_set_compressors", - MONGOC_LOG_LEVEL_WARNING, - "Unsupported compressor: ''"); - - - /* Disable compression */ - capture_logs (true); - mongoc_uri_set_compressors (uri, NULL); - ASSERT (bson_empty (mongoc_uri_get_compressors (uri))); - ASSERT_NO_CAPTURED_LOGS ("Disable compression"); - - - mongoc_uri_destroy (uri); - - -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY - uri = mongoc_uri_new ("mongodb://localhost/?compressors=snappy"); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); - mongoc_uri_destroy (uri); - - capture_logs (true); - uri = - mongoc_uri_new ("mongodb://localhost/?compressors=snappy,somethingElse"); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); - ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "somethingElse")); - ASSERT_CAPTURED_LOG ("mongoc_uri_set_compressors", - MONGOC_LOG_LEVEL_WARNING, - "Unsupported compressor: 'somethingElse'"); - mongoc_uri_destroy (uri); -#endif - - -#ifdef MONGOC_ENABLE_COMPRESSION_ZLIB - -#ifdef MONGOC_ENABLE_COMPRESSION_SNAPPY - uri = mongoc_uri_new ("mongodb://localhost/?compressors=snappy,zlib"); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/"); - ASSERT (mongoc_uri_set_compressors (uri, "snappy,zlib")); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/"); - ASSERT (mongoc_uri_set_compressors (uri, "zlib")); - ASSERT (mongoc_uri_set_compressors (uri, "snappy")); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "snappy")); - ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); - mongoc_uri_destroy (uri); -#endif - - uri = mongoc_uri_new ("mongodb://localhost/?compressors=zlib"); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); - mongoc_uri_destroy (uri); - - capture_logs (true); - uri = mongoc_uri_new ("mongodb://localhost/?compressors=zlib,somethingElse"); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); - ASSERT (!bson_has_field (mongoc_uri_get_compressors (uri), "somethingElse")); - ASSERT_CAPTURED_LOG ("mongoc_uri_set_compressors", - MONGOC_LOG_LEVEL_WARNING, - "Unsupported compressor: 'somethingElse'"); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ( - "mongodb://localhost/?compressors=zlib&zlibCompressionLevel=-1"); - ASSERT (bson_has_field (mongoc_uri_get_compressors (uri), "zlib")); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 1), - ==, - -1); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ( - "mongodb://localhost/?compressors=zlib&zlibCompressionLevel=9"); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 1), - ==, - 9); - mongoc_uri_destroy (uri); - - capture_logs (true); - uri = mongoc_uri_new ( - "mongodb://localhost/?compressors=zlib&zlibCompressionLevel=-2"); - ASSERT_CAPTURED_LOG ( - "mongoc_uri_set_compressors", - MONGOC_LOG_LEVEL_WARNING, - "Invalid \"zlibcompressionlevel\" of -2: must be between -1 and 9"); - mongoc_uri_destroy (uri); - - capture_logs (true); - uri = mongoc_uri_new ( - "mongodb://localhost/?compressors=zlib&zlibCompressionLevel=10"); - ASSERT_CAPTURED_LOG ( - "mongoc_uri_set_compressors", - MONGOC_LOG_LEVEL_WARNING, - "Invalid \"zlibcompressionlevel\" of 10: must be between -1 and 9"); - mongoc_uri_destroy (uri); - -#endif -} - -static void -test_mongoc_uri_unescape (void) -{ -#define ASSERT_URIDECODE_STR(_s, _e) \ - do { \ - char *str = mongoc_uri_unescape (_s); \ - ASSERT (!strcmp (str, _e)); \ - bson_free (str); \ - } while (0) -#define ASSERT_URIDECODE_FAIL(_s) \ - do { \ - char *str; \ - capture_logs (true); \ - str = mongoc_uri_unescape (_s); \ - ASSERT (!str); \ - ASSERT_CAPTURED_LOG ( \ - "uri", MONGOC_LOG_LEVEL_WARNING, "Invalid % escape sequence"); \ - } while (0) - - ASSERT_URIDECODE_STR ("", ""); - ASSERT_URIDECODE_STR ("%40", "@"); - ASSERT_URIDECODE_STR ("me%40localhost@localhost", "me@localhost@localhost"); - ASSERT_URIDECODE_STR ("%20", " "); - ASSERT_URIDECODE_STR ("%24%21%40%2A%26%5E%21%40%2A%23%26%5E%21%40%23%2A%26" - "%5E%21%40%2A%23%26%5E%21%40%2A%26%23%5E%7D%7B%7D%7B" - "%22%22%27%7D%7B%5B%5D%3C%3E%3F", - "$!@*&^!@*#&^!@#*&^!@*#&^!@*&#^}{}{\"\"'}{[]<>?"); - - ASSERT_URIDECODE_FAIL ("%"); - ASSERT_URIDECODE_FAIL ("%%"); - ASSERT_URIDECODE_FAIL ("%%%"); - ASSERT_URIDECODE_FAIL ("%FF"); - ASSERT_URIDECODE_FAIL ("%CC"); - ASSERT_URIDECODE_FAIL ("%00"); - -#undef ASSERT_URIDECODE_STR -#undef ASSERT_URIDECODE_FAIL -} - - -typedef struct { - const char *uri; - bool parses; - mongoc_read_mode_t mode; - bson_t *tags; - const char *log_msg; -} read_prefs_test; - - -static void -test_mongoc_uri_read_prefs (void) -{ - const mongoc_read_prefs_t *rp; - mongoc_uri_t *uri; - const read_prefs_test *t; - int i; - - bson_t *tags_dcny = BCON_NEW ("0", "{", "dc", "ny", "}"); - bson_t *tags_dcny_empty = - BCON_NEW ("0", "{", "dc", "ny", "}", "1", "{", "}"); - bson_t *tags_dcnyusessd_dcsf_empty = BCON_NEW ("0", - "{", - "dc", - "ny", - "use", - "ssd", - "}", - "1", - "{", - "dc", - "sf", - "}", - "2", - "{", - "}"); - bson_t *tags_empty = BCON_NEW ("0", "{", "}"); - - const char *conflicts = "Invalid readPreferences"; - - const read_prefs_test tests[] = { - {"mongodb://localhost/", true, MONGOC_READ_PRIMARY, NULL}, - {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=primary", - true, - MONGOC_READ_PRIMARY, - NULL}, - {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=primaryPreferred", - true, - MONGOC_READ_PRIMARY_PREFERRED, - NULL}, - {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=secondary", - true, - MONGOC_READ_SECONDARY, - NULL}, - {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=secondaryPreferred", - true, - MONGOC_READ_SECONDARY_PREFERRED, - NULL}, - {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE "=nearest", - true, - MONGOC_READ_NEAREST, - NULL}, - /* MONGOC_URI_READPREFERENCETAGS conflict with primary mode */ - {"mongodb://localhost/?" MONGOC_URI_READPREFERENCETAGS "=", - false, - MONGOC_READ_PRIMARY, - NULL, - conflicts}, - {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE - "=primary&" MONGOC_URI_READPREFERENCETAGS "=", - false, - MONGOC_READ_PRIMARY, - NULL, - conflicts}, - {"mongodb://localhost/" - "?" MONGOC_URI_READPREFERENCE - "=secondaryPreferred&" MONGOC_URI_READPREFERENCETAGS "=", - true, - MONGOC_READ_SECONDARY_PREFERRED, - tags_empty}, - {"mongodb://localhost/" - "?" MONGOC_URI_READPREFERENCE - "=secondaryPreferred&" MONGOC_URI_READPREFERENCETAGS "=dc:ny", - true, - MONGOC_READ_SECONDARY_PREFERRED, - tags_dcny}, - {"mongodb://localhost/" - "?" MONGOC_URI_READPREFERENCE "=nearest&" MONGOC_URI_READPREFERENCETAGS - "=dc:ny&" MONGOC_URI_READPREFERENCETAGS "=", - true, - MONGOC_READ_NEAREST, - tags_dcny_empty}, - {"mongodb://localhost/" - "?" MONGOC_URI_READPREFERENCE "=nearest&" MONGOC_URI_READPREFERENCETAGS - "=dc:ny,use:ssd&" MONGOC_URI_READPREFERENCETAGS - "=dc:sf&" MONGOC_URI_READPREFERENCETAGS "=", - true, - MONGOC_READ_NEAREST, - tags_dcnyusessd_dcsf_empty}, - {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE - "=nearest&" MONGOC_URI_READPREFERENCETAGS "=foo", - false, - MONGOC_READ_NEAREST, - NULL, - "Unsupported value for \"" MONGOC_URI_READPREFERENCETAGS "\": \"foo\""}, - {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE - "=nearest&" MONGOC_URI_READPREFERENCETAGS "=foo,bar", - false, - MONGOC_READ_NEAREST, - NULL, - "Unsupported value for \"" MONGOC_URI_READPREFERENCETAGS - "\": \"foo,bar\""}, - {"mongodb://localhost/?" MONGOC_URI_READPREFERENCE - "=nearest&" MONGOC_URI_READPREFERENCETAGS "=1", - false, - MONGOC_READ_NEAREST, - NULL, - "Unsupported value for \"" MONGOC_URI_READPREFERENCETAGS "\": \"1\""}, - {NULL}}; - - for (i = 0; tests[i].uri; i++) { - t = &tests[i]; - - capture_logs (true); - uri = mongoc_uri_new (t->uri); - if (t->parses) { - BSON_ASSERT (uri); - ASSERT_NO_CAPTURED_LOGS (t->uri); - } else { - BSON_ASSERT (!uri); - if (t->log_msg) { - ASSERT_CAPTURED_LOG (t->uri, MONGOC_LOG_LEVEL_WARNING, t->log_msg); - } - - continue; - } - - rp = mongoc_uri_get_read_prefs_t (uri); - BSON_ASSERT (rp); - - BSON_ASSERT (t->mode == mongoc_read_prefs_get_mode (rp)); - - if (t->tags) { - BSON_ASSERT (bson_equal (t->tags, mongoc_read_prefs_get_tags (rp))); - } - - mongoc_uri_destroy (uri); - } - - bson_destroy (tags_dcny); - bson_destroy (tags_dcny_empty); - bson_destroy (tags_dcnyusessd_dcsf_empty); - bson_destroy (tags_empty); -} - - -typedef struct { - const char *uri; - bool parses; - int32_t w; - const char *wtag; - int64_t wtimeoutms; - const char *log_msg; -} write_concern_test; - - -static void -test_mongoc_uri_write_concern (void) -{ - const mongoc_write_concern_t *wr; - mongoc_uri_t *uri; - const write_concern_test *t; - int i; - static const write_concern_test tests[] = { - {"mongodb://localhost/?" MONGOC_URI_SAFE "=false", - true, - MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED}, - {"mongodb://localhost/?" MONGOC_URI_SAFE "=true", true, 1}, - {"mongodb://localhost/?" MONGOC_URI_W "=-1", - true, - MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED}, - {"mongodb://localhost/?" MONGOC_URI_W "=0", - true, - MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED}, - {"mongodb://localhost/?" MONGOC_URI_W "=1", true, 1}, - {"mongodb://localhost/?" MONGOC_URI_W "=2", true, 2}, - {"mongodb://localhost/?" MONGOC_URI_W "=majority", - true, - MONGOC_WRITE_CONCERN_W_MAJORITY}, - {"mongodb://localhost/?" MONGOC_URI_W "=10", true, 10}, - {"mongodb://localhost/?" MONGOC_URI_W "=", - true, - MONGOC_WRITE_CONCERN_W_DEFAULT}, - {"mongodb://localhost/?" MONGOC_URI_W "=mytag", - true, - MONGOC_WRITE_CONCERN_W_TAG, - "mytag"}, - {"mongodb://localhost/?" MONGOC_URI_W "=mytag&" MONGOC_URI_SAFE "=false", - true, - MONGOC_WRITE_CONCERN_W_TAG, - "mytag"}, - {"mongodb://localhost/?" MONGOC_URI_W "=1&" MONGOC_URI_SAFE "=false", - true, - 1}, - {"mongodb://localhost/?" MONGOC_URI_JOURNAL "=true", - true, - MONGOC_WRITE_CONCERN_W_DEFAULT}, - {"mongodb://localhost/?" MONGOC_URI_W "=1&" MONGOC_URI_JOURNAL "=true", - true, - 1}, - {"mongodb://localhost/?" MONGOC_URI_W "=2&" MONGOC_URI_WTIMEOUTMS "=1000", - true, - 2, - NULL, - 1000}, - {"mongodb://localhost/?" MONGOC_URI_W "=2&" MONGOC_URI_WTIMEOUTMS - "=2147483648", - true, - 2, - NULL, - 2147483648LL}, - {"mongodb://localhost/?" MONGOC_URI_W "=majority&" MONGOC_URI_WTIMEOUTMS - "=1000", - true, - MONGOC_WRITE_CONCERN_W_MAJORITY, - NULL, - 1000}, - {"mongodb://localhost/?" MONGOC_URI_W "=mytag&" MONGOC_URI_WTIMEOUTMS - "=1000", - true, - MONGOC_WRITE_CONCERN_W_TAG, - "mytag", - 1000}, - {"mongodb://localhost/?" MONGOC_URI_W "=0&" MONGOC_URI_JOURNAL "=true", - false, - MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED, - NULL, - 0, - "Journal conflicts with w value [" MONGOC_URI_W "=0]"}, - {"mongodb://localhost/?" MONGOC_URI_W "=-1&" MONGOC_URI_JOURNAL "=true", - false, - MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED, - NULL, - 0, - "Journal conflicts with w value [" MONGOC_URI_W "=-1]"}, - {NULL}}; - - for (i = 0; tests[i].uri; i++) { - t = &tests[i]; - - capture_logs (true); - uri = mongoc_uri_new (t->uri); - - if (tests[i].log_msg) { - ASSERT_CAPTURED_LOG ( - tests[i].uri, MONGOC_LOG_LEVEL_WARNING, tests[i].log_msg); - } else { - ASSERT_NO_CAPTURED_LOGS (tests[i].uri); - } - - capture_logs (false); /* clear captured logs */ - - if (t->parses) { - BSON_ASSERT (uri); - } else { - BSON_ASSERT (!uri); - continue; - } - - wr = mongoc_uri_get_write_concern (uri); - BSON_ASSERT (wr); - - BSON_ASSERT (t->w == mongoc_write_concern_get_w (wr)); - - if (t->wtag) { - BSON_ASSERT (0 == - strcmp (t->wtag, mongoc_write_concern_get_wtag (wr))); - } - - if (t->wtimeoutms) { - BSON_ASSERT (t->wtimeoutms == - mongoc_write_concern_get_wtimeout_int64 (wr)); - } - - mongoc_uri_destroy (uri); - } -} - -static void -test_mongoc_uri_read_concern (void) -{ - const mongoc_read_concern_t *rc; - mongoc_uri_t *uri; - - uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READCONCERNLEVEL - "=majority"); - rc = mongoc_uri_get_read_concern (uri); - ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "majority"); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/" - "?" MONGOC_URI_READCONCERNLEVEL - "=" MONGOC_READ_CONCERN_LEVEL_MAJORITY); - rc = mongoc_uri_get_read_concern (uri); - ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "majority"); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/" - "?" MONGOC_URI_READCONCERNLEVEL - "=" MONGOC_READ_CONCERN_LEVEL_LINEARIZABLE); - rc = mongoc_uri_get_read_concern (uri); - ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "linearizable"); - mongoc_uri_destroy (uri); - - - uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READCONCERNLEVEL - "=local"); - rc = mongoc_uri_get_read_concern (uri); - ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "local"); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READCONCERNLEVEL - "=" MONGOC_READ_CONCERN_LEVEL_LOCAL); - rc = mongoc_uri_get_read_concern (uri); - ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "local"); - mongoc_uri_destroy (uri); - - - uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READCONCERNLEVEL - "=randomstuff"); - rc = mongoc_uri_get_read_concern (uri); - ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), "randomstuff"); - mongoc_uri_destroy (uri); - - - uri = mongoc_uri_new ("mongodb://localhost/"); - rc = mongoc_uri_get_read_concern (uri); - ASSERT (mongoc_read_concern_get_level (rc) == NULL); - mongoc_uri_destroy (uri); - - - uri = - mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_READCONCERNLEVEL "="); - rc = mongoc_uri_get_read_concern (uri); - ASSERT_CMPSTR (mongoc_read_concern_get_level (rc), ""); - mongoc_uri_destroy (uri); -} - -static void -test_mongoc_uri_long_hostname (void) -{ - char *host; - char *host_and_port; - size_t len = BSON_HOST_NAME_MAX; - char *uri_str; - mongoc_uri_t *uri; - - /* hostname of exactly maximum length */ - host = bson_malloc (len + 1); - memset (host, 'a', len); - host[len] = '\0'; - host_and_port = bson_strdup_printf ("%s:12345", host); - uri_str = bson_strdup_printf ("mongodb://%s", host_and_port); - uri = mongoc_uri_new (uri_str); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host_and_port, host_and_port); - - mongoc_uri_destroy (uri); - uri = mongoc_uri_new_for_host_port (host, 12345); - ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_hosts (uri)->host_and_port, host_and_port); - - mongoc_uri_destroy (uri); - bson_free (uri_str); - bson_free (host_and_port); - bson_free (host); - - /* hostname length exceeds maximum by one */ - len++; - host = bson_malloc (len + 1); - memset (host, 'a', len); - host[len] = '\0'; - host_and_port = bson_strdup_printf ("%s:12345", host); - uri_str = bson_strdup_printf ("mongodb://%s", host_and_port); - - capture_logs (true); - ASSERT (!mongoc_uri_new (uri_str)); - ASSERT_CAPTURED_LOG ("mongoc_uri_new", MONGOC_LOG_LEVEL_ERROR, "too long"); - - clear_captured_logs (); - ASSERT (!mongoc_uri_new_for_host_port (host, 12345)); - ASSERT_CAPTURED_LOG ("mongoc_uri_new", MONGOC_LOG_LEVEL_ERROR, "too long"); - - bson_free (uri_str); - bson_free (host_and_port); - bson_free (host); -} - -static void -test_mongoc_uri_tls_ssl (const char *tls, - const char *tlsCertificateKeyFile, - const char *tlsCertificateKeyPassword, - const char *tlsCAFile, - const char *tlsAllowInvalidCertificates, - const char *tlsAllowInvalidHostnames) -{ - const char *tlsalt; - char url_buffer[2048]; - mongoc_uri_t *uri; - bson_error_t err; - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://CN=client,OU=kerneluser,O=10Gen,L=New York City," - "ST=New York,C=US@ldaptest.10gen.cc/?" - "%s=true&authMechanism=MONGODB-X509&" - "%s=tests/x509gen/ldaptest-client-key-and-cert.pem&" - "%s=tests/x509gen/ldaptest-ca-cert.crt&" - "%s=true", - tls, - tlsCertificateKeyFile, - tlsCAFile, - tlsAllowInvalidHostnames); - uri = mongoc_uri_new (url_buffer); - - ASSERT_CMPSTR ( - mongoc_uri_get_username (uri), - "CN=client,OU=kerneluser,O=10Gen,L=New York City,ST=New York,C=US"); - ASSERT (!mongoc_uri_get_password (uri)); - ASSERT (!mongoc_uri_get_database (uri)); - ASSERT_CMPSTR (mongoc_uri_get_auth_source (uri), "$external"); - ASSERT_CMPSTR (mongoc_uri_get_auth_mechanism (uri), "MONGODB-X509"); - - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "none"), - "tests/x509gen/ldaptest-client-key-and-cert.pem"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, "none"), - "none"); - ASSERT_CMPSTR ( - mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, "none"), - "tests/x509gen/ldaptest-ca-cert.crt"); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); - ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=true&%s=key.pem&%s=ca.pem", - tls, - tlsCertificateKeyFile, - tlsCAFile); - uri = mongoc_uri_new (url_buffer); - - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE, "none"), - "key.pem"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "none"), - "key.pem"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD, "none"), - "none"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, "none"), - "none"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE, "none"), - "ca.pem"); - ASSERT_CMPSTR ( - mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, "none"), - "ca.pem"); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); - mongoc_uri_destroy (uri); - - - bson_snprintf ( - url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tls); - uri = mongoc_uri_new (url_buffer); - - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "none"), - "none"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, "none"), - "none"); - ASSERT_CMPSTR ( - mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, "none"), - "none"); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=true&%s=pa$$word!&%s=encrypted.pem", - tls, - tlsCertificateKeyPassword, - tlsCertificateKeyFile); - uri = mongoc_uri_new (url_buffer); - - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE, "none"), - "encrypted.pem"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "none"), - "encrypted.pem"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD, "none"), - "pa$$word!"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, "none"), - "pa$$word!"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE, "none"), - "none"); - ASSERT_CMPSTR ( - mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, "none"), - "none"); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=true&%s=true", - tls, - tlsAllowInvalidCertificates); - uri = mongoc_uri_new (url_buffer); - - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, "none"), - "none"); - ASSERT_CMPSTR (mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, "none"), - "none"); - ASSERT_CMPSTR ( - mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, "none"), - "none"); - ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false)); - ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, false)); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=foo.pem", - tlsCertificateKeyFile); - uri = mongoc_uri_new (url_buffer); - ASSERT (mongoc_uri_get_ssl (uri)); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=foo.pem", - tlsCAFile); - uri = mongoc_uri_new (url_buffer); - ASSERT (mongoc_uri_get_ssl (uri)); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=true", - tlsAllowInvalidCertificates); - uri = mongoc_uri_new (url_buffer); - ASSERT (mongoc_uri_get_ssl (uri)); - ASSERT (mongoc_uri_get_tls (uri)); - ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false)); - ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=true", - tlsAllowInvalidHostnames); - uri = mongoc_uri_new (url_buffer); - ASSERT (mongoc_uri_get_ssl (uri)); - ASSERT (mongoc_uri_get_tls (uri)); - ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, false)); - ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=false&%s=foo.pem", - tls, - tlsCertificateKeyFile); - uri = mongoc_uri_new (url_buffer); - ASSERT (!mongoc_uri_get_ssl (uri)); - ASSERT (!mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=false&%s=foo.pem", - tls, - tlsCertificateKeyFile); - uri = mongoc_uri_new (url_buffer); - ASSERT (!mongoc_uri_get_ssl (uri)); - ASSERT (!mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=false&%s=true", - tls, - tlsAllowInvalidCertificates); - uri = mongoc_uri_new (url_buffer); - ASSERT (!mongoc_uri_get_ssl (uri)); - ASSERT (!mongoc_uri_get_tls (uri)); - ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false)); - ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); - mongoc_uri_destroy (uri); - - - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=false&%s=false", - tls, - tlsAllowInvalidHostnames); - uri = mongoc_uri_new (url_buffer); - ASSERT (!mongoc_uri_get_ssl (uri)); - ASSERT (!mongoc_uri_get_tls (uri)); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, true)); - ASSERT (!mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, true)); - mongoc_uri_destroy (uri); - - if (!strcmp (tls, "ssl")) { - tlsalt = "tls"; - } else { - tlsalt = "ssl"; - } - - /* Mixing options okay so long as they match */ - capture_logs (true); - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=true&%s=true", - tls, - tlsalt); - uri = mongoc_uri_new (url_buffer); - ASSERT (mongoc_uri_get_option_as_bool (uri, tls, false)); - ASSERT_NO_CAPTURED_LOGS (url_buffer); - mongoc_uri_destroy (uri); - - /* Same option with different values okay, latter overrides */ - capture_logs (true); - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=true&%s=false", - tls, - tls); - uri = mongoc_uri_new (url_buffer); - ASSERT (!mongoc_uri_get_option_as_bool (uri, tls, true)); - if (strcmp (tls, "tls")) { - ASSERT_CAPTURED_LOG ("option: ssl", - MONGOC_LOG_LEVEL_WARNING, - "Overwriting previously provided value for 'ssl'"); - } else { - ASSERT_CAPTURED_LOG ("option: tls", - MONGOC_LOG_LEVEL_WARNING, - "Overwriting previously provided value for 'tls'"); - } - mongoc_uri_destroy (uri); - - /* Mixing options not okay if values differ */ - capture_logs (false); - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb://localhost/?%s=true&%s=false", - tls, - tlsalt); - uri = mongoc_uri_new_with_error (url_buffer, &err); - if (strcmp (tls, "tls")) { - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Deprecated option 'ssl=true' conflicts with " - "canonical name 'tls=false'"); - } else { - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Deprecated option 'ssl=false' conflicts with " - "canonical name 'tls=true'"); - } - mongoc_uri_destroy (uri); - - /* No conflict appears with implicit tls=true via SRV */ - capture_logs (false); - bson_snprintf (url_buffer, - sizeof (url_buffer), - "mongodb+srv://a.b.c/?%s=foo.pem", - tlsCAFile); - uri = mongoc_uri_new (url_buffer); - ASSERT (mongoc_uri_get_option_as_bool (uri, tls, false)); - mongoc_uri_destroy (uri); - - /* Set TLS options after creating mongoc_uri_t from connection string */ - uri = mongoc_uri_new ("mongodb://localhost/"); - ASSERT (mongoc_uri_set_option_as_utf8 ( - uri, tlsCertificateKeyFile, "/path/to/pem")); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/"); - ASSERT (mongoc_uri_set_option_as_utf8 ( - uri, tlsCertificateKeyPassword, "password")); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/"); - ASSERT (mongoc_uri_set_option_as_utf8 (uri, tlsCAFile, "/path/to/pem")); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/"); - ASSERT ( - mongoc_uri_set_option_as_bool (uri, tlsAllowInvalidCertificates, false)); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/"); - ASSERT (mongoc_uri_set_option_as_bool (uri, tlsAllowInvalidHostnames, true)); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); -} - -static void -test_mongoc_uri_tls (void) -{ - bson_error_t err = {0}; - mongoc_uri_t *uri; - - test_mongoc_uri_tls_ssl (MONGOC_URI_TLS, - MONGOC_URI_TLSCERTIFICATEKEYFILE, - MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, - MONGOC_URI_TLSCAFILE, - MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, - MONGOC_URI_TLSALLOWINVALIDHOSTNAMES); - - /* non-canonical case for tls options */ - test_mongoc_uri_tls_ssl ("tls", - "TlsCertificateKeyFile", - "tlsCertificateKeyFilePASSWORD", - "tlsCAFILE", - "TLSALLOWINVALIDCERTIFICATES", - "tLSaLLOWiNVALIDhOSTNAMES"); - - /* non-canonical case for tls option */ - uri = mongoc_uri_new ("mongodb://localhost/?tLs=true"); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/"); - ASSERT (mongoc_uri_set_option_as_bool (uri, "TLS", true)); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - /* tls-only option */ - uri = mongoc_uri_new ("mongodb://localhost/?tlsInsecure=true"); - ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSINSECURE, false)); - mongoc_uri_destroy (uri); - - ASSERT (!mongoc_uri_new_with_error ( - "mongodb://localhost/?tlsInsecure=true&tlsAllowInvalidHostnames=false", - &err)); - ASSERT_ERROR_CONTAINS ( - err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "tlsinsecure may not be specified with " - "tlsallowinvalidcertificates, tlsallowinvalidhostnames, " - "tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck"); - - ASSERT (!mongoc_uri_new_with_error ( - "mongodb://localhost/" - "?tlsInsecure=true&tlsAllowInvalidCertificates=true", - &err)); - ASSERT_ERROR_CONTAINS ( - err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "tlsinsecure may not be specified with " - "tlsallowinvalidcertificates, tlsallowinvalidhostnames, " - "tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck"); -} - -static void -test_mongoc_uri_ssl (void) -{ - mongoc_uri_t *uri; - - test_mongoc_uri_tls_ssl (MONGOC_URI_SSL, - MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE, - MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD, - MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE, - MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, - MONGOC_URI_SSLALLOWINVALIDHOSTNAMES); - - /* non-canonical case for ssl options */ - test_mongoc_uri_tls_ssl ("ssl", - "SslClientCertificateKeyFile", - "sslClientCertificateKeyPASSWORD", - "sslCERTIFICATEAUTHORITYFILE", - "SSLALLOWINVALIDCERTIFICATES", - "sSLaLLOWiNVALIDhOSTNAMES"); - - /* non-canonical case for ssl option */ - uri = mongoc_uri_new ("mongodb://localhost/?sSl=true"); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/"); - ASSERT (mongoc_uri_set_option_as_bool (uri, "SSL", true)); - ASSERT (mongoc_uri_get_tls (uri)); - mongoc_uri_destroy (uri); -} - -static void -test_mongoc_uri_local_threshold_ms (void) -{ - mongoc_uri_t *uri; - - uri = mongoc_uri_new ("mongodb://localhost/"); - - /* localthresholdms isn't set, return the default */ - ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), - ==, - MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS); - ASSERT ( - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_LOCALTHRESHOLDMS, 99)); - ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, 99); - - mongoc_uri_destroy (uri); - - uri = - mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_LOCALTHRESHOLDMS "=0"); - - ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, 0); - ASSERT ( - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_LOCALTHRESHOLDMS, 99)); - ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, 99); - - mongoc_uri_destroy (uri); - - uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_LOCALTHRESHOLDMS - "=-1"); - - /* localthresholdms is invalid, return the default */ - capture_logs (true); - ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), - ==, - MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS); - ASSERT_CAPTURED_LOG ("mongoc_uri_get_local_threshold_option", - MONGOC_LOG_LEVEL_WARNING, - "Invalid localThresholdMS: -1"); - - mongoc_uri_destroy (uri); -} - - -#define INVALID(_uri, _host) \ - BSON_ASSERT (!mongoc_uri_upsert_host ((_uri), (_host), 1, &error)); \ - ASSERT_ERROR_CONTAINS (error, \ - MONGOC_ERROR_STREAM, \ - MONGOC_ERROR_STREAM_NAME_RESOLUTION, \ - "must be subdomain") - -#define VALID(_uri, _host) \ - ASSERT_OR_PRINT (mongoc_uri_upsert_host ((_uri), (_host), 1, &error), error) - - -static void -test_mongoc_uri_srv (void) -{ - mongoc_uri_t *uri; - bson_error_t error; - - capture_logs (true); - - ASSERT (!mongoc_uri_new ("mongodb+srv://")); - /* requires a subdomain, domain, and TLD: "a.example.com" */ - ASSERT (!mongoc_uri_new ("mongodb+srv://foo")); - ASSERT (!mongoc_uri_new ("mongodb+srv://foo.")); - ASSERT (!mongoc_uri_new ("mongodb+srv://.foo")); - ASSERT (!mongoc_uri_new ("mongodb+srv://..")); - ASSERT (!mongoc_uri_new ("mongodb+srv://.a.")); - ASSERT (!mongoc_uri_new ("mongodb+srv://.a.b.c.com")); - ASSERT (!mongoc_uri_new ("mongodb+srv://foo\x08\x00bar")); - ASSERT (!mongoc_uri_new ("mongodb+srv://foo%00bar")); - ASSERT (!mongoc_uri_new ("mongodb+srv://example.com")); - - uri = mongoc_uri_new ("mongodb+srv://c.d.com"); - BSON_ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_srv_hostname (uri), "c.d.com"); - BSON_ASSERT (mongoc_uri_get_hosts (uri) == NULL); - - /* tls is set to true when we use SRV */ - ASSERT_MATCH (mongoc_uri_get_options (uri), "{'tls': true}"); - - /* but we can override tls */ - mongoc_uri_destroy (uri); - uri = mongoc_uri_new ("mongodb+srv://c.d.com/?tls=false"); - BSON_ASSERT (uri); - ASSERT_MATCH (mongoc_uri_get_options (uri), "{'tls': false}"); - - INVALID (uri, "com"); - INVALID (uri, "foo.com"); - INVALID (uri, "d.com"); - INVALID (uri, "cd.com"); - VALID (uri, "c.d.com"); - VALID (uri, "bc.d.com"); - VALID (uri, "longer-string.d.com"); - INVALID (uri, ".c.d.com"); - VALID (uri, "b.c.d.com"); - INVALID (uri, ".b.c.d.com"); - INVALID (uri, "..b.c.d.com"); - VALID (uri, "a.b.c.d.com"); - - mongoc_uri_destroy (uri); - uri = mongoc_uri_new ("mongodb+srv://b.c.d.com"); - - INVALID (uri, "foo.com"); - INVALID (uri, "a.b.d.com"); - INVALID (uri, "d.com"); - VALID (uri, "b.c.d.com"); - VALID (uri, "a.b.c.d.com"); - VALID (uri, "foo.a.b.c.d.com"); - - mongoc_uri_destroy (uri); - - /* trailing dot is OK */ - uri = mongoc_uri_new ("mongodb+srv://service.consul."); - BSON_ASSERT (uri); - ASSERT_CMPSTR (mongoc_uri_get_srv_hostname (uri), "service.consul."); - BSON_ASSERT (mongoc_uri_get_hosts (uri) == NULL); - - INVALID (uri, ".consul."); - INVALID (uri, "service.consul"); - INVALID (uri, "a.service.consul"); - INVALID (uri, "service.a.consul"); - INVALID (uri, "a.com"); - VALID (uri, "service.consul."); - VALID (uri, "a.service.consul."); - VALID (uri, "a.b.service.consul."); - - mongoc_uri_destroy (uri); -} - - -#define PROHIBITED(_key, _value, _type, _where) \ - do { \ - const char *option = _key "=" #_value; \ - char *lkey = bson_strdup (_key); \ - mongoc_lowercase (lkey, lkey); \ - mongoc_uri_parse_options (uri, option, true /* from dns */, &error); \ - ASSERT_ERROR_CONTAINS (error, \ - MONGOC_ERROR_COMMAND, \ - MONGOC_ERROR_COMMAND_INVALID_ARG, \ - "prohibited in TXT record"); \ - BSON_ASSERT (!bson_has_field (mongoc_uri_get_##_where (uri), lkey)); \ - bson_free (lkey); \ - } while (0) - - -static void -test_mongoc_uri_dns_options (void) -{ - mongoc_uri_t *uri; - bson_error_t error; - - uri = mongoc_uri_new ("mongodb+srv://a.b.c"); - BSON_ASSERT (uri); - - BSON_ASSERT (!mongoc_uri_parse_options ( - uri, "tls=false", true /* from dsn */, &error)); - - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "prohibited in TXT record"); - - ASSERT_MATCH (mongoc_uri_get_options (uri), "{'tls': true}"); - - /* key we want to set, value, value type, whether it's option/credential */ - PROHIBITED (MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, true, bool, options); - PROHIBITED (MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, true, bool, options); - PROHIBITED (MONGOC_URI_GSSAPISERVICENAME, malicious, utf8, credentials); - - /* the two options allowed in TXT records, case-insensitive */ - BSON_ASSERT (mongoc_uri_parse_options (uri, "authsource=db", true, NULL)); - BSON_ASSERT (mongoc_uri_parse_options (uri, "RepLIcaSET=rs", true, NULL)); - - /* test that URI string overrides TXT record options */ - mongoc_uri_destroy (uri); - uri = mongoc_uri_new ( - "mongodb+srv://user@a.b.c/?authSource=db1&replicaSet=rs1"); - - capture_logs (true); - /* parse_options returns true, but logs warnings */ - BSON_ASSERT (mongoc_uri_parse_options ( - uri, "authSource=db2&replicaSet=db2", true, NULL)); - ASSERT_CAPTURED_LOG ("parsing TXT record", - MONGOC_LOG_LEVEL_WARNING, - "Cannot override URI option \"authSource\""); - ASSERT_CAPTURED_LOG ("parsing TXT record", - MONGOC_LOG_LEVEL_WARNING, - "Cannot override URI option \"replicaSet\""); - capture_logs (false); - ASSERT_MATCH (mongoc_uri_get_credentials (uri), "{'authsource': 'db1'}"); - ASSERT_MATCH (mongoc_uri_get_options (uri), "{'replicaset': 'rs1'}"); - - mongoc_uri_destroy (uri); -} - - -/* test some invalid accesses and a crash, found with a fuzzer */ -static void -test_mongoc_uri_utf8 (void) -{ - bson_error_t err; - - /* start of 3-byte character, but it's incomplete */ - BSON_ASSERT (!mongoc_uri_new_with_error ("mongodb://\xe8\x03", &err)); - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid UTF-8 in URI"); - - /* start of 6-byte CESU-8 character, but it's incomplete */ - BSON_ASSERT (!mongoc_uri_new_with_error ("mongodb://\xfa", &err)); - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid UTF-8 in URI"); - - - /* "az" with NIL expressed as two-byte sequence */ - BSON_ASSERT (!mongoc_uri_new_with_error ("mongodb://a\xc0\x80z", &err)); - ASSERT_ERROR_CONTAINS (err, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid UTF-8 in URI"); -} - - -/* test behavior on duplicate values for an options. */ -static void -test_mongoc_uri_duplicates (void) -{ - mongoc_uri_t *uri = NULL; - bson_error_t err; - const char *str; - const mongoc_write_concern_t *wc; - const mongoc_read_concern_t *rc; - const bson_t *bson; - const mongoc_read_prefs_t *rp; - bson_iter_t iter = {0}; - -#define RECREATE_URI(opts) \ - mongoc_uri_destroy (uri); \ - uri = mongoc_uri_new_with_error ("mongodb://user:pwd@localhost/test?" opts, \ - &err); \ - ASSERT_OR_PRINT (uri, err); - -#define ASSERT_LOG_DUPE(opt) \ - ASSERT_CAPTURED_LOG ("option: " opt, \ - MONGOC_LOG_LEVEL_WARNING, \ - "Overwriting previously provided value for '" opt \ - "'"); - -/* iterate iter to key, and check that no other occurrences exist. */ -#define BSON_ITER_UNIQUE(key) \ - do { \ - bson_iter_t tmp; \ - BSON_ASSERT (bson_iter_init_find (&iter, bson, key)); \ - tmp = iter; \ - while (bson_iter_next (&tmp)) { \ - if (strcmp (bson_iter_key (&tmp), key) == 0) { \ - ASSERT_WITH_MSG (false, "bson has duplicate keys for: " key); \ - } \ - } \ - } while (0); - - capture_logs (true); - - /* test all URI options, in the order they are defined in mongoc-uri.h. */ - RECREATE_URI (MONGOC_URI_APPNAME "=a&" MONGOC_URI_APPNAME "=b"); - ASSERT_LOG_DUPE (MONGOC_URI_APPNAME); - str = mongoc_uri_get_appname (uri); - BSON_ASSERT (strcmp (str, "b") == 0); - - RECREATE_URI (MONGOC_URI_AUTHMECHANISM "=a&" MONGOC_URI_AUTHMECHANISM "=b"); - ASSERT_LOG_DUPE (MONGOC_URI_AUTHMECHANISM); - bson = mongoc_uri_get_credentials (uri); - BSON_ITER_UNIQUE (MONGOC_URI_AUTHMECHANISM); - BSON_ASSERT (strcmp (bson_iter_utf8 (&iter, NULL), "b") == 0); - - RECREATE_URI (MONGOC_URI_AUTHMECHANISMPROPERTIES - "=a:x&" MONGOC_URI_AUTHMECHANISMPROPERTIES "=b:y"); - ASSERT_LOG_DUPE (MONGOC_URI_AUTHMECHANISMPROPERTIES); - bson = mongoc_uri_get_credentials (uri); - BSON_ASSERT ( - bson_compare ( - bson, tmp_bson ("{'authmechanismproperties': {'b': 'y' }}")) == 0); - - RECREATE_URI (MONGOC_URI_AUTHSOURCE "=a&" MONGOC_URI_AUTHSOURCE "=b"); - ASSERT_LOG_DUPE (MONGOC_URI_AUTHSOURCE); - str = mongoc_uri_get_auth_source (uri); - BSON_ASSERT (strcmp (str, "b") == 0); - - RECREATE_URI (MONGOC_URI_CANONICALIZEHOSTNAME - "=false&" MONGOC_URI_CANONICALIZEHOSTNAME "=true"); - ASSERT_LOG_DUPE (MONGOC_URI_CANONICALIZEHOSTNAME); - BSON_ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_CANONICALIZEHOSTNAME, false)); - - RECREATE_URI (MONGOC_URI_CONNECTTIMEOUTMS "=1&" MONGOC_URI_CONNECTTIMEOUTMS - "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_CONNECTTIMEOUTMS); - BSON_ASSERT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_CONNECTTIMEOUTMS, 0) == 2); - -#if defined(MONGOC_ENABLE_COMPRESSION_SNAPPY) && \ - defined(MONGOC_ENABLE_COMPRESSION_ZLIB) - RECREATE_URI (MONGOC_URI_COMPRESSORS "=snappy&" MONGOC_URI_COMPRESSORS - "=zlib"); - ASSERT_LOG_DUPE (MONGOC_URI_COMPRESSORS); - bson = mongoc_uri_get_compressors (uri); - BSON_ASSERT (bson_compare (bson, tmp_bson ("{'zlib': 'yes'}")) == 0); -#endif - - /* exception: GSSAPISERVICENAME does not overwrite. */ - RECREATE_URI (MONGOC_URI_GSSAPISERVICENAME "=a&" MONGOC_URI_GSSAPISERVICENAME - "=b"); - ASSERT_CAPTURED_LOG ( - "option: " MONGOC_URI_GSSAPISERVICENAME, - MONGOC_LOG_LEVEL_WARNING, - "Overwriting previously provided value for 'gssapiservicename'"); - bson = mongoc_uri_get_credentials (uri); - BSON_ASSERT ( - bson_compare ( - bson, - tmp_bson ("{'authmechanismproperties': {'SERVICE_NAME': 'b' }}")) == - 0); - - RECREATE_URI (MONGOC_URI_HEARTBEATFREQUENCYMS - "=500&" MONGOC_URI_HEARTBEATFREQUENCYMS "=501"); - ASSERT_LOG_DUPE (MONGOC_URI_HEARTBEATFREQUENCYMS); - BSON_ASSERT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, 0) == 501); - - RECREATE_URI (MONGOC_URI_JOURNAL "=false&" MONGOC_URI_JOURNAL "=true"); - ASSERT_LOG_DUPE (MONGOC_URI_JOURNAL); - BSON_ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_JOURNAL, false)); - - RECREATE_URI (MONGOC_URI_LOCALTHRESHOLDMS "=1&" MONGOC_URI_LOCALTHRESHOLDMS - "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_LOCALTHRESHOLDMS); - BSON_ASSERT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_LOCALTHRESHOLDMS, 0) == 2); - - RECREATE_URI (MONGOC_URI_MAXIDLETIMEMS "=1&" MONGOC_URI_MAXIDLETIMEMS "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_MAXIDLETIMEMS); - BSON_ASSERT ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_MAXIDLETIMEMS, 0) == 2); - - RECREATE_URI (MONGOC_URI_MAXPOOLSIZE "=1&" MONGOC_URI_MAXPOOLSIZE "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_MAXPOOLSIZE); - BSON_ASSERT ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_MAXPOOLSIZE, 0) == 2); - - RECREATE_URI (MONGOC_URI_READPREFERENCE - "=secondary&" MONGOC_URI_MAXSTALENESSSECONDS - "=1&" MONGOC_URI_MAXSTALENESSSECONDS "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_MAXSTALENESSSECONDS); - BSON_ASSERT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_MAXSTALENESSSECONDS, 0) == 2); - - RECREATE_URI (MONGOC_URI_MINPOOLSIZE "=1&" MONGOC_URI_MINPOOLSIZE "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_MINPOOLSIZE); - BSON_ASSERT ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_MINPOOLSIZE, 0) == 2); - - RECREATE_URI (MONGOC_URI_READCONCERNLEVEL - "=local&" MONGOC_URI_READCONCERNLEVEL "=majority"); - ASSERT_LOG_DUPE (MONGOC_URI_READCONCERNLEVEL); - rc = mongoc_uri_get_read_concern (uri); - BSON_ASSERT (strcmp (mongoc_read_concern_get_level (rc), "majority") == 0); - - RECREATE_URI (MONGOC_URI_READPREFERENCE - "=secondary&" MONGOC_URI_READPREFERENCE "=primary"); - ASSERT_LOG_DUPE (MONGOC_URI_READPREFERENCE); - rp = mongoc_uri_get_read_prefs_t (uri); - BSON_ASSERT (mongoc_read_prefs_get_mode (rp) == MONGOC_READ_PRIMARY); - - /* exception: read preference tags get appended. */ - RECREATE_URI (MONGOC_URI_READPREFERENCE - "=secondary&" MONGOC_URI_READPREFERENCETAGS - "=a:x&" MONGOC_URI_READPREFERENCETAGS "=b:y"); - bson = mongoc_uri_get_read_prefs (uri); - BSON_ASSERT (bson_compare ( - bson, tmp_bson ("{'0': {'a': 'x'}, '1': {'b': 'y'}}")) == 0); - - RECREATE_URI (MONGOC_URI_REPLICASET "=a&" MONGOC_URI_REPLICASET "=b"); - ASSERT_LOG_DUPE (MONGOC_URI_REPLICASET); - str = mongoc_uri_get_replica_set (uri); - BSON_ASSERT (strcmp (str, "b") == 0); - - RECREATE_URI (MONGOC_URI_RETRYREADS "=false&" MONGOC_URI_RETRYREADS "=true"); - ASSERT_LOG_DUPE (MONGOC_URI_RETRYREADS); - BSON_ASSERT ( - mongoc_uri_get_option_as_bool (uri, MONGOC_URI_RETRYREADS, false)); - - RECREATE_URI (MONGOC_URI_RETRYWRITES "=false&" MONGOC_URI_RETRYWRITES - "=true"); - ASSERT_LOG_DUPE (MONGOC_URI_RETRYWRITES); - BSON_ASSERT ( - mongoc_uri_get_option_as_bool (uri, MONGOC_URI_RETRYWRITES, false)); - - RECREATE_URI (MONGOC_URI_SAFE "=false&" MONGOC_URI_SAFE "=true"); - ASSERT_LOG_DUPE (MONGOC_URI_SAFE); - BSON_ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SAFE, false)); - - RECREATE_URI (MONGOC_URI_SERVERSELECTIONTIMEOUTMS - "=1&" MONGOC_URI_SERVERSELECTIONTIMEOUTMS "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_SERVERSELECTIONTIMEOUTMS); - BSON_ASSERT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_SERVERSELECTIONTIMEOUTMS, 0) == 2); - - RECREATE_URI (MONGOC_URI_SERVERSELECTIONTRYONCE - "=false&" MONGOC_URI_SERVERSELECTIONTRYONCE "=true"); - ASSERT_LOG_DUPE (MONGOC_URI_SERVERSELECTIONTRYONCE); - BSON_ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_SERVERSELECTIONTRYONCE, false)); - - RECREATE_URI (MONGOC_URI_SOCKETCHECKINTERVALMS - "=1&" MONGOC_URI_SOCKETCHECKINTERVALMS "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_SOCKETCHECKINTERVALMS); - BSON_ASSERT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_SOCKETCHECKINTERVALMS, 0) == 2); - - RECREATE_URI (MONGOC_URI_SOCKETTIMEOUTMS "=1&" MONGOC_URI_SOCKETTIMEOUTMS - "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_SOCKETTIMEOUTMS); - BSON_ASSERT ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_SOCKETTIMEOUTMS, 0) == 2); - - RECREATE_URI (MONGOC_URI_TLS "=false&" MONGOC_URI_TLS "=true"); - ASSERT_LOG_DUPE (MONGOC_URI_TLS); - BSON_ASSERT (mongoc_uri_get_tls (uri)); - - RECREATE_URI (MONGOC_URI_TLSCERTIFICATEKEYFILE - "=a&" MONGOC_URI_TLSCERTIFICATEKEYFILE "=b"); - ASSERT_LOG_DUPE (MONGOC_URI_TLSCERTIFICATEKEYFILE); - str = - mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCERTIFICATEKEYFILE, ""); - BSON_ASSERT (strcmp (str, "b") == 0); - - RECREATE_URI (MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD - "=a&" MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD "=b"); - ASSERT_LOG_DUPE (MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD); - str = mongoc_uri_get_option_as_utf8 ( - uri, MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD, ""); - BSON_ASSERT (strcmp (str, "b") == 0); - - RECREATE_URI (MONGOC_URI_TLSCAFILE "=a&" MONGOC_URI_TLSCAFILE "=b"); - ASSERT_LOG_DUPE (MONGOC_URI_TLSCAFILE); - str = mongoc_uri_get_option_as_utf8 (uri, MONGOC_URI_TLSCAFILE, ""); - BSON_ASSERT (strcmp (str, "b") == 0); - - RECREATE_URI (MONGOC_URI_TLSALLOWINVALIDCERTIFICATES - "=false&" MONGOC_URI_TLSALLOWINVALIDCERTIFICATES "=true"); - ASSERT_LOG_DUPE (MONGOC_URI_TLSALLOWINVALIDCERTIFICATES); - BSON_ASSERT (mongoc_uri_get_option_as_bool ( - uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); - - RECREATE_URI (MONGOC_URI_W "=1&" MONGOC_URI_W "=0"); - ASSERT_LOG_DUPE (MONGOC_URI_W); - wc = mongoc_uri_get_write_concern (uri); - BSON_ASSERT (mongoc_write_concern_get_w (wc) == 0); - - /* exception: a string write concern takes precedence over an int */ - RECREATE_URI (MONGOC_URI_W "=majority&" MONGOC_URI_W "=0"); - ASSERT_LOG_DUPE (MONGOC_URI_W); - wc = mongoc_uri_get_write_concern (uri); - BSON_ASSERT (mongoc_write_concern_get_w (wc) == - MONGOC_WRITE_CONCERN_W_MAJORITY); - - RECREATE_URI (MONGOC_URI_WAITQUEUEMULTIPLE "=1&" MONGOC_URI_WAITQUEUEMULTIPLE - "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_WAITQUEUEMULTIPLE); - BSON_ASSERT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_WAITQUEUEMULTIPLE, 0) == 2); - - RECREATE_URI (MONGOC_URI_WAITQUEUETIMEOUTMS - "=1&" MONGOC_URI_WAITQUEUETIMEOUTMS "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_WAITQUEUETIMEOUTMS); - BSON_ASSERT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_WAITQUEUETIMEOUTMS, 0) == 2); - - RECREATE_URI (MONGOC_URI_WTIMEOUTMS "=1&" MONGOC_URI_WTIMEOUTMS "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_WTIMEOUTMS); - BSON_ASSERT ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 0) == 2); - BSON_ASSERT ( - mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 0) == 2); - - RECREATE_URI (MONGOC_URI_ZLIBCOMPRESSIONLEVEL - "=1&" MONGOC_URI_ZLIBCOMPRESSIONLEVEL "=2"); - ASSERT_LOG_DUPE (MONGOC_URI_ZLIBCOMPRESSIONLEVEL); - BSON_ASSERT (mongoc_uri_get_option_as_int32 ( - uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 0) == 2); - - mongoc_uri_destroy (uri); -} - - -/* Tests behavior of int32 and int64 options */ -static void -test_mongoc_uri_int_options (void) -{ - mongoc_uri_t *uri; - - capture_logs (true); - - uri = mongoc_uri_new ("mongodb://localhost/"); - - /* Set an int64 option as int64 succeeds */ - ASSERT (mongoc_uri_set_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 10)); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 0), ==, 10); - ASSERT_CMPINT64 ( - mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 0), ==, 10); - - /* Set an int64 option as int32 succeeds */ - ASSERT (mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 15)); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 0), ==, 15); - ASSERT_CMPINT64 ( - mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 0), ==, 15); - - /* Setting an int32 option through _as_int64 succeeds for 32-bit values but - * emits a warning */ - ASSERT ( - mongoc_uri_set_option_as_int64 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 9)); - ASSERT_CAPTURED_LOG ("option: " MONGOC_URI_ZLIBCOMPRESSIONLEVEL, - MONGOC_LOG_LEVEL_WARNING, - "Setting value for 32-bit option " - "\"zlibcompressionlevel\" through 64-bit method"); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 0), - ==, - 9); - ASSERT_CMPINT64 ( - mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 0), - ==, - 9); - - clear_captured_logs (); - - ASSERT (!mongoc_uri_set_option_as_int64 ( - uri, MONGOC_URI_CONNECTTIMEOUTMS, 2147483648LL)); - ASSERT_CAPTURED_LOG ( - "option: " MONGOC_URI_CONNECTTIMEOUTMS, - MONGOC_LOG_LEVEL_WARNING, - "Unsupported value for \"connecttimeoutms\": 2147483648," - " \"connecttimeoutms\" is not an int64 option"); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_CONNECTTIMEOUTMS, 0), - ==, - 0); - ASSERT_CMPINT64 ( - mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_CONNECTTIMEOUTMS, 0), - ==, - 0); - - clear_captured_logs (); - - /* Setting an int32 option as int32 succeeds */ - ASSERT ( - mongoc_uri_set_option_as_int32 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 9)); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 0), - ==, - 9); - ASSERT_CMPINT64 ( - mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_ZLIBCOMPRESSIONLEVEL, 0), - ==, - 9); - - /* Truncating a 64-bit value when fetching as 32-bit emits a warning */ - ASSERT (mongoc_uri_set_option_as_int64 ( - uri, MONGOC_URI_WTIMEOUTMS, 2147483648LL)); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 5), ==, 5); - ASSERT_CAPTURED_LOG ( - "option: " MONGOC_URI_WTIMEOUTMS " with 64-bit value", - MONGOC_LOG_LEVEL_WARNING, - "Cannot read 64-bit value for \"wtimeoutms\": 2147483648"); - ASSERT_CMPINT64 ( - mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 5), - ==, - 2147483648LL); - - clear_captured_logs (); - - ASSERT (mongoc_uri_set_option_as_int64 ( - uri, MONGOC_URI_WTIMEOUTMS, -2147483649LL)); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 5), ==, 5); - ASSERT_CAPTURED_LOG ( - "option: " MONGOC_URI_WTIMEOUTMS " with 64-bit value", - MONGOC_LOG_LEVEL_WARNING, - "Cannot read 64-bit value for \"wtimeoutms\": -2147483649"); - ASSERT_CMPINT64 ( - mongoc_uri_get_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, 5), - ==, - -2147483649LL); - - clear_captured_logs (); - - /* Setting a INT_MAX and INT_MIN values doesn't cause truncation errors */ - ASSERT ( - mongoc_uri_set_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, INT32_MAX)); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 0), - ==, - INT32_MAX); - ASSERT_NO_CAPTURED_LOGS ("INT_MAX"); - ASSERT ( - mongoc_uri_set_option_as_int64 (uri, MONGOC_URI_WTIMEOUTMS, INT32_MIN)); - ASSERT_CMPINT32 ( - mongoc_uri_get_option_as_int32 (uri, MONGOC_URI_WTIMEOUTMS, 0), - ==, - INT32_MIN); - ASSERT_NO_CAPTURED_LOGS ("INT_MIN"); - - mongoc_uri_destroy (uri); -} - -static void -test_one_tls_option_enables_tls (void) -{ - const char *opts[] = {MONGOC_URI_TLS "=true", - MONGOC_URI_TLSCERTIFICATEKEYFILE "=file.pem", - MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD "=file.pem", - MONGOC_URI_TLSCAFILE "=file.pem", - MONGOC_URI_TLSALLOWINVALIDCERTIFICATES "=true", - MONGOC_URI_TLSALLOWINVALIDHOSTNAMES "=true", - MONGOC_URI_TLSINSECURE "=true", - MONGOC_URI_SSL "=true", - MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE "=file.pem", - MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD "=file.pem", - MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE "=file.pem", - MONGOC_URI_SSLALLOWINVALIDCERTIFICATES "=true", - MONGOC_URI_SSLALLOWINVALIDHOSTNAMES "=true", - MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK "=true", - MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK - "=true"}; - int i; - - for (i = 0; i < sizeof (opts) / sizeof (opts[0]); i++) { - mongoc_uri_t *uri; - bson_error_t error; - char *uri_string; - - uri_string = - bson_strdup_printf ("mongodb://localhost:27017/?%s", opts[i]); - uri = mongoc_uri_new_with_error (uri_string, &error); - bson_free (uri_string); - ASSERT_OR_PRINT (uri, error); - if (!mongoc_uri_get_tls (uri)) { - test_error ( - "unexpected tls not enabled when following option set: %s\n", - opts[i]); - } - mongoc_uri_destroy (uri); - } -} - -static void -test_casing_options (void) -{ - mongoc_uri_t *uri; - bson_error_t error; - - uri = mongoc_uri_new ("mongodb://localhost:27017/"); - mongoc_uri_set_option_as_bool (uri, "TLS", true); - mongoc_uri_parse_options (uri, "ssl=false", false, &error); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "conflicts"); - - mongoc_uri_destroy (uri); -} - -static void -test_parses_long_ipv6 (void) -{ - // Test parsing long malformed IPv6 literals. This is a regression test for - // CDRIVER-4816. - bson_error_t error; - - // Test the largest permitted IPv6 literal. - { - // Construct a string of repeating `:`. - bson_string_t *host = bson_string_new (NULL); - for (int i = 0; i < BSON_HOST_NAME_MAX - 2; i++) { - // Max IPv6 literal is two less due to including `[` and `]`. - bson_string_append (host, ":"); - } - - char *host_and_port = bson_strdup_printf ("[%s]:27017", host->str); - char *uri_string = bson_strdup_printf ("mongodb://%s", host_and_port); - mongoc_uri_t *uri = mongoc_uri_new_with_error (uri_string, &error); - ASSERT_OR_PRINT (uri, error); - const mongoc_host_list_t *hosts = mongoc_uri_get_hosts (uri); - ASSERT_CMPSTR (hosts->host, host->str); - ASSERT_CMPSTR (hosts->host_and_port, host_and_port); - ASSERT_CMPUINT16 (hosts->port, ==, 27017); - ASSERT (!hosts->next); - - mongoc_uri_destroy (uri); - bson_free (uri_string); - bson_free (host_and_port); - bson_string_free (host, true /* free_segment */); - } - - // Test one character more than the largest IPv6 literal. - { - // Construct a string of repeating `:`. - bson_string_t *host = bson_string_new (NULL); - for (int i = 0; i < BSON_HOST_NAME_MAX - 2 + 1; i++) { - bson_string_append (host, ":"); - } - - char *host_and_port = bson_strdup_printf ("[%s]:27017", host->str); - char *uri_string = bson_strdup_printf ("mongodb://%s", host_and_port); - capture_logs (true); - mongoc_uri_t *uri = mongoc_uri_new_with_error (uri_string, &error); - // Expect error parsing IPv6 literal is logged. - ASSERT_CAPTURED_LOG ("parsing IPv6", - MONGOC_LOG_LEVEL_ERROR, - "IPv6 literal provided in URI is too long"); - capture_logs (false); - - // Expect a generic parsing error is also returned. - ASSERT (!uri); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid host string in URI"); - - mongoc_uri_destroy (uri); - bson_free (uri_string); - bson_free (host_and_port); - bson_string_free (host, true /* free_segment */); - } -} - -void -test_uri_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/Uri/new", test_mongoc_uri_new); - TestSuite_Add (suite, "/Uri/new_with_error", test_mongoc_uri_new_with_error); - TestSuite_Add ( - suite, "/Uri/new_for_host_port", test_mongoc_uri_new_for_host_port); - TestSuite_Add (suite, "/Uri/compressors", test_mongoc_uri_compressors); - TestSuite_Add (suite, "/Uri/unescape", test_mongoc_uri_unescape); - TestSuite_Add (suite, "/Uri/read_prefs", test_mongoc_uri_read_prefs); - TestSuite_Add (suite, "/Uri/read_concern", test_mongoc_uri_read_concern); - TestSuite_Add (suite, "/Uri/write_concern", test_mongoc_uri_write_concern); - TestSuite_Add ( - suite, "/HostList/from_string", test_mongoc_host_list_from_string); - TestSuite_Add (suite, - "/Uri/auth_mechanism_properties", - test_mongoc_uri_authmechanismproperties); - TestSuite_Add (suite, "/Uri/functions", test_mongoc_uri_functions); - TestSuite_Add (suite, "/Uri/ssl", test_mongoc_uri_ssl); - TestSuite_Add (suite, "/Uri/tls", test_mongoc_uri_tls); - TestSuite_Add ( - suite, "/Uri/compound_setters", test_mongoc_uri_compound_setters); - TestSuite_Add (suite, "/Uri/long_hostname", test_mongoc_uri_long_hostname); - TestSuite_Add ( - suite, "/Uri/local_threshold_ms", test_mongoc_uri_local_threshold_ms); - TestSuite_Add (suite, "/Uri/srv", test_mongoc_uri_srv); - TestSuite_Add (suite, "/Uri/dns_options", test_mongoc_uri_dns_options); - TestSuite_Add (suite, "/Uri/utf8", test_mongoc_uri_utf8); - TestSuite_Add (suite, "/Uri/duplicates", test_mongoc_uri_duplicates); - TestSuite_Add (suite, "/Uri/int_options", test_mongoc_uri_int_options); - TestSuite_Add (suite, - "/Uri/one_tls_option_enables_tls", - test_one_tls_option_enables_tls); - TestSuite_Add (suite, "/Uri/options_casing", test_casing_options); - TestSuite_Add (suite, "/Uri/parses_long_ipv6", test_parses_long_ipv6); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-usleep.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-usleep.c deleted file mode 100644 index 024a54ea1..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-usleep.c +++ /dev/null @@ -1,115 +0,0 @@ -#include -#include "mongoc/mongoc-util-private.h" -#include "TestSuite.h" -#include "test-libmongoc.h" -#include -#include -#include -#include // tmp_bson - - -static void -test_mongoc_usleep_basic (void) -{ - int64_t start; - int64_t duration; - - start = bson_get_monotonic_time (); - _mongoc_usleep (50 * 1000); /* 50 ms */ - duration = bson_get_monotonic_time () - start; - ASSERT_CMPINT ((int) duration, >, 0); - ASSERT_CMPTIME ((int) duration, 200 * 1000); -} - -static void -custom_usleep_impl (int64_t usec, void *user_data) -{ - if (user_data) { - *(int64_t *) user_data = usec; - } -} - - -// `test_mongoc_usleep_custom` tests a custom sleep function set in -// `mongoc_client_set_usleep_impl` is applied when topology scanning sleeps. -static void -test_mongoc_usleep_custom (void) -{ - mock_server_t *server = mock_server_new (); - mock_server_run (server); - - mongoc_uri_t *uri = mongoc_uri_copy (mock_server_get_uri (server)); - // Tell single-threaded clients to reconnect if an error occcurs. - mongoc_uri_set_option_as_bool ( - uri, MONGOC_URI_SERVERSELECTIONTRYONCE, false); - - mongoc_client_t *client = test_framework_client_new_from_uri (uri, NULL); - ASSERT (client); - - // Bypass the five second cooldown to speed up test. - _mongoc_topology_bypass_cooldown (client->topology); - // Override `min_heartbeat_frequency_msec` to speed up test. - client->topology->min_heartbeat_frequency_msec = 50; - - // Override the sleep. - int64_t last_sleep_dur = 0; - mongoc_client_set_usleep_impl (client, custom_usleep_impl, &last_sleep_dur); - - bson_error_t error; - future_t *future = future_client_command_simple (client, - "db", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL, - &error); - - // Client sends initial `isMaster`. - { - request_t *req = mock_server_receives_any_hello (server); - ASSERT (req); - // Fail the request. - reply_to_request_with_hang_up (req); - request_destroy (req); - } - - // Client sleeps for `min_heartbeat_frequency_msec`, then sends another - // `isMaster`. - { - request_t *req = mock_server_receives_any_hello (server); - ASSERT (req); - reply_to_request_simple ( - req, - tmp_str ("{ 'minWireVersion': %d, 'maxWireVersion' : %d, " - "'isWritablePrimary': true}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX)); - request_destroy (req); - } - - // Expect custom sleep to have been called between making `isMaster` calls. - ASSERT_CMPINT64 (last_sleep_dur, >, 0); - - // Client sends "ping". - { - request_t *req = mock_server_receives_msg ( - server, MONGOC_MSG_NONE, tmp_bson ("{'ping': 1}")); - ASSERT (req); - reply_to_request_with_ok_and_destroy (req); - } - - bool ok = future_wait (future); - ASSERT_OR_PRINT (ok, error); - - future_destroy (future); - mongoc_client_destroy (client); - mongoc_uri_destroy (uri); - mock_server_destroy (server); -} - -void -test_usleep_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/Sleep/basic", test_mongoc_usleep_basic); - TestSuite_AddMockServerTest ( - suite, "/Sleep/custom", test_mongoc_usleep_custom); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-util.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-util.c deleted file mode 100644 index b43f2f394..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-util.c +++ /dev/null @@ -1,129 +0,0 @@ -#include -#include - -#include "TestSuite.h" -#include "test-conveniences.h" - -#undef MONGOC_LOG_DOMAIN -#define MONGOC_LOG_DOMAIN "test-util" - - -static void -test_command_name (void) -{ - bson_t *commands[] = { - tmp_bson ("{'foo': 1}"), - tmp_bson ("{'query': {'foo': 1}}"), - tmp_bson ("{'query': {'foo': 1}, '$readPreference': 1}"), - tmp_bson ("{'$query': {'foo': 1}}"), - tmp_bson ("{'$query': {'foo': 1}, '$readPreference': 1}"), - tmp_bson ("{'$readPreference': 1, '$query': {'foo': 1}}"), - }; - - size_t i; - - for (i = 0; i < sizeof (commands) / sizeof (bson_t *); i++) { - ASSERT_CMPSTR ("foo", _mongoc_get_command_name (commands[i])); - } -} - - -static void -test_rand_simple (void) -{ - int i; - unsigned int seed = 0; - int value, first_value; - - first_value = _mongoc_rand_simple (&seed); - - for (i = 0; i < 1000; i++) { - value = _mongoc_rand_simple (&seed); - if (value != first_value) { - /* success */ - break; - } - } -} - -static void -test_lowercase_utf8 (void) -{ - char *snowman = "\xE2\x9b\x84"; - char *letters = "aBcDe"; - char *buf = bson_malloc0 (strlen (snowman) + 1); - - mongoc_lowercase (snowman, buf); - ASSERT_CMPSTR (snowman, buf); - bson_free (buf); - - buf = bson_malloc0 (strlen (letters) + 1); - mongoc_lowercase (letters, buf); - ASSERT_CMPSTR ("abcde", buf); - bson_free (buf); -} - - -static void -test_wire_server_versions (void) -{ - /* Ensure valid inclusive range. */ - ASSERT_WITH_MSG (WIRE_VERSION_MIN <= WIRE_VERSION_MAX, - "WIRE_VERSION_MAX (%d) must be greater than or equal to " - "WIRE_VERSION_MIN (%d)", - WIRE_VERSION_MAX, - WIRE_VERSION_MIN); - - /* Bumping WIRE_VERSION_MAX must be accompanied by an update to - * `_mongoc_wire_version_to_server_version`. */ - ASSERT_WITH_MSG ( - strcmp (_mongoc_wire_version_to_server_version (WIRE_VERSION_MAX), - "Unknown"), - "WIRE_VERSION_MAX must have a corresponding server version defined in " - "_mongoc_wire_version_to_server_version"); - - /* Unlikely given the minimum version should always be a value older than the - * maximum version, but nevertheless important to assert so warning/error - * messages remain valid. */ - ASSERT_WITH_MSG ( - strcmp (_mongoc_wire_version_to_server_version (WIRE_VERSION_MIN), - "Unknown"), - "WIRE_VERSION_MIN must have a corresponding server version defined in " - "_mongoc_wire_version_to_server_version"); -} - -static void -test_bin_to_hex (void) -{ - const char *bin = "foobar"; - const char *expect = "666f6f626172"; - - char *got = bin_to_hex ((const uint8_t *) bin, (uint32_t) strlen (bin)); - ASSERT_CMPSTR (got, expect); - bson_free (got); -} - -static void -test_hex_to_bin (void) -{ - const char *hexstr = "666f6f62617200"; - const char *expect = "foobar"; - - uint32_t len; - uint8_t *got = hex_to_bin (hexstr, &len); - ASSERT_CMPSTR ((const char *) got, expect); - ASSERT_CMPUINT32 (len, ==, 7); - bson_free (got); -} - -void -test_util_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/Util/command_name", test_command_name); - TestSuite_Add (suite, "/Util/rand_simple", test_rand_simple); - TestSuite_Add (suite, "/Util/lowercase_utf8", test_lowercase_utf8); - TestSuite_Add ( - suite, "/Util/wire_server_versions", test_wire_server_versions); - TestSuite_Add (suite, "/Util/bin_to_hex", test_bin_to_hex); - TestSuite_Add (suite, "/Util/hex_to_bin", test_hex_to_bin); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-version.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-version.c deleted file mode 100644 index 51d93daa9..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-version.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -#include "TestSuite.h" - -static void -test_mongoc_version (void) -{ - ASSERT_CMPINT (mongoc_get_major_version (), ==, MONGOC_MAJOR_VERSION); - ASSERT_CMPINT (mongoc_get_minor_version (), ==, MONGOC_MINOR_VERSION); - ASSERT_CMPINT (mongoc_get_micro_version (), ==, MONGOC_MICRO_VERSION); - ASSERT_CMPSTR (mongoc_get_version (), MONGOC_VERSION_S); - - ASSERT (mongoc_check_version ( - MONGOC_MAJOR_VERSION, MONGOC_MINOR_VERSION, MONGOC_MICRO_VERSION)); - - ASSERT (!mongoc_check_version ( - MONGOC_MAJOR_VERSION, MONGOC_MINOR_VERSION + 1, MONGOC_MICRO_VERSION)); -} - -void -test_version_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/Version", test_mongoc_version); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-with-transaction.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-with-transaction.c deleted file mode 100644 index 22fbaf919..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-with-transaction.c +++ /dev/null @@ -1,99 +0,0 @@ -#include - -#include "json-test.h" -#include "mongoc/mongoc-client-session-private.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" - -/* Note, the with_transaction spec tests are in test-mongoc-transactions.c, - * since it shares the same test runner with the transactions test runner. */ - -static bool -with_transaction_fail_transient_txn (mongoc_client_session_t *session, - void *ctx, - bson_t **reply, - bson_error_t *error) -{ - bson_array_builder_t *labels; - - BSON_UNUSED (ctx); - BSON_UNUSED (error); - - _mongoc_usleep (session->with_txn_timeout_ms * 1000); - - *reply = bson_new (); - BSON_APPEND_ARRAY_BUILDER_BEGIN (*reply, "errorLabels", &labels); - bson_array_builder_append_utf8 (labels, TRANSIENT_TXN_ERR, -1); - bson_append_array_builder_end (*reply, labels); - - return false; -} - -static bool -with_transaction_do_nothing (mongoc_client_session_t *session, - void *ctx, - bson_t **reply, - bson_error_t *error) -{ - BSON_UNUSED (session); - BSON_UNUSED (ctx); - BSON_UNUSED (reply); - BSON_UNUSED (error); - return true; -} - -static void -test_with_transaction_timeout (void *ctx) -{ - mongoc_client_t *client; - mongoc_client_session_t *session; - bson_error_t error; - bool res; - - BSON_UNUSED (ctx); - - client = test_framework_new_default_client (); - - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - - session->with_txn_timeout_ms = 10; - - /* Test Case 1: Test that if the callback returns an - error with the TransientTransactionError label and - we have exceeded the timeout, withTransaction fails. */ - res = mongoc_client_session_with_transaction ( - session, with_transaction_fail_transient_txn, NULL, NULL, NULL, &error); - ASSERT (!res); - - /* Test Case 2: If committing returns an error with the - UnknownTransactionCommitResult label and we have exceeded - the timeout, withTransaction fails. */ - session->fail_commit_label = UNKNOWN_COMMIT_RESULT; - res = mongoc_client_session_with_transaction ( - session, with_transaction_do_nothing, NULL, NULL, NULL, &error); - ASSERT (!res); - - /* Test Case 3: If committing returns an error with the - TransientTransactionError label and we have exceeded the - timeout, withTransaction fails. */ - session->fail_commit_label = TRANSIENT_TXN_ERR; - res = mongoc_client_session_with_transaction ( - session, with_transaction_do_nothing, NULL, NULL, NULL, &error); - ASSERT (!res); - - mongoc_client_session_destroy (session); - mongoc_client_destroy (client); -} - -void -test_with_transaction_install (TestSuite *suite) -{ - TestSuite_AddFull (suite, - "/with_transaction/timeout_tests", - test_with_transaction_timeout, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_crypto); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-write-commands.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-write-commands.c deleted file mode 100644 index 5134add6d..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-write-commands.c +++ /dev/null @@ -1,515 +0,0 @@ -#include -#include - -#include "mongoc/mongoc-client-private.h" -#include "mongoc/mongoc-collection-private.h" -#include "mongoc/mongoc-write-command-private.h" -#include "mongoc/mongoc-write-concern-private.h" - -#include "TestSuite.h" - -#include "test-libmongoc.h" -#include "test-conveniences.h" -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" - - -static void -test_split_insert (void) -{ - mongoc_bulk_write_flags_t write_flags = MONGOC_BULK_WRITE_FLAGS_INIT; - mongoc_write_command_t command; - mongoc_write_result_t result; - mongoc_collection_t *collection; - mongoc_client_t *client; - bson_oid_t oid; - bson_t **docs; - bson_t reply = BSON_INITIALIZER; - bson_error_t error; - mongoc_server_stream_t *server_stream; - int i; - bool r; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - collection = get_test_collection (client, "test_split_insert"); - BSON_ASSERT (collection); - - docs = (bson_t **) bson_malloc (sizeof (bson_t *) * 3000); - - for (i = 0; i < 3000; i++) { - docs[i] = bson_new (); - bson_oid_init (&oid, NULL); - BSON_APPEND_OID (docs[i], "_id", &oid); - } - - _mongoc_write_result_init (&result); - - _mongoc_write_command_init_insert ( - &command, docs[0], NULL, write_flags, ++client->cluster.operation_id); - - for (i = 1; i < 3000; i++) { - _mongoc_write_command_insert_append (&command, docs[i]); - } - - server_stream = mongoc_cluster_stream_for_writes ( - &client->cluster, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (server_stream, error); - _mongoc_write_command_execute (&command, - client, - server_stream, - collection->db, - collection->collection, - NULL, - 0, - NULL, - &result); - - r = MONGOC_WRITE_RESULT_COMPLETE (&result, - 2, - collection->write_concern, - (mongoc_error_domain_t) 0, - &reply, - &error); - ASSERT_OR_PRINT (r, error); - BSON_ASSERT (result.nInserted == 3000); - - _mongoc_write_command_destroy (&command); - _mongoc_write_result_destroy (&result); - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - for (i = 0; i < 3000; i++) { - bson_destroy (docs[i]); - } - - bson_destroy (&reply); - bson_free (docs); - mongoc_server_stream_cleanup (server_stream); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - - -static void -test_invalid_write_concern (void) -{ - mongoc_bulk_write_flags_t write_flags = MONGOC_BULK_WRITE_FLAGS_INIT; - mongoc_write_command_t command; - mongoc_write_result_t result; - mongoc_collection_t *collection; - mongoc_client_t *client; - mongoc_write_concern_t *write_concern; - mongoc_server_stream_t *server_stream; - bson_t *doc; - bson_t reply = BSON_INITIALIZER; - bson_error_t error; - bool r; - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - collection = get_test_collection (client, "test_invalid_write_concern"); - BSON_ASSERT (collection); - - write_concern = mongoc_write_concern_new (); - BSON_ASSERT (write_concern); - mongoc_write_concern_set_w (write_concern, 0); - mongoc_write_concern_set_journal (write_concern, true); - BSON_ASSERT (!mongoc_write_concern_is_valid (write_concern)); - - doc = BCON_NEW ("_id", BCON_INT32 (0)); - - _mongoc_write_command_init_insert ( - &command, doc, NULL, write_flags, ++client->cluster.operation_id); - _mongoc_write_result_init (&result); - server_stream = mongoc_cluster_stream_for_writes ( - &client->cluster, NULL, NULL, NULL, &error); - ASSERT_OR_PRINT (server_stream, error); - _mongoc_write_command_execute (&command, - client, - server_stream, - collection->db, - collection->collection, - write_concern, - 0, - NULL, - &result); - - r = MONGOC_WRITE_RESULT_COMPLETE (&result, - 2, - collection->write_concern, - (mongoc_error_domain_t) 0, - &reply, - &error); - - BSON_ASSERT (!r); - ASSERT_CMPINT (error.domain, ==, MONGOC_ERROR_COMMAND); - ASSERT_CMPINT (error.code, ==, MONGOC_ERROR_COMMAND_INVALID_ARG); - - _mongoc_write_command_destroy (&command); - _mongoc_write_result_destroy (&result); - - bson_destroy (doc); - bson_destroy (&reply); - mongoc_server_stream_cleanup (server_stream); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mongoc_write_concern_destroy (write_concern); -} - -static void -test_bypass_validation (void *context) -{ - mongoc_collection_t *collection2; - mongoc_collection_t *collection; - bson_t reply; - mongoc_bulk_operation_t *bulk; - mongoc_database_t *database; - mongoc_write_concern_t *wr; - mongoc_client_t *client; - bson_error_t error; - bson_t *options; - char *collname; - char *dbname; - int r; - int i; - - BSON_UNUSED (context); - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - dbname = gen_collection_name ("dbtest"); - collname = gen_collection_name ("bypass"); - database = mongoc_client_get_database (client, dbname); - collection = mongoc_database_get_collection (database, collname); - BSON_ASSERT (collection); - - options = tmp_bson ( - "{'validator': {'number': {'$gte': 5}}, 'validationAction': 'error'}"); - collection2 = - mongoc_database_create_collection (database, collname, options, &error); - ASSERT_OR_PRINT (collection2, error); - mongoc_collection_destroy (collection2); - - /* {{{ Default fails validation */ - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - for (i = 0; i < 3; i++) { - bson_t *doc = tmp_bson ("{'number': 3, 'high': %d }", i); - - mongoc_bulk_operation_insert (bulk, doc); - } - r = mongoc_bulk_operation_execute (bulk, &reply, &error); - bson_destroy (&reply); - ASSERT (!r); - - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_COMMAND, 121, "Document failed validation"); - mongoc_bulk_operation_destroy (bulk); - /* }}} */ - - /* {{{ bypass_document_validation=false Fails validation */ - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - mongoc_bulk_operation_set_bypass_document_validation (bulk, false); - for (i = 0; i < 3; i++) { - bson_t *doc = tmp_bson ("{'number': 3, 'high': %d }", i); - - mongoc_bulk_operation_insert (bulk, doc); - } - r = mongoc_bulk_operation_execute (bulk, &reply, &error); - bson_destroy (&reply); - ASSERT (!r); - - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_COMMAND, 121, "Document failed validation"); - mongoc_bulk_operation_destroy (bulk); - /* }}} */ - - /* {{{ bypass_document_validation=true ignores validation */ - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - mongoc_bulk_operation_set_bypass_document_validation (bulk, true); - for (i = 0; i < 3; i++) { - bson_t *doc = tmp_bson ("{'number': 3, 'high': %d }", i); - - mongoc_bulk_operation_insert (bulk, doc); - } - r = mongoc_bulk_operation_execute (bulk, &reply, &error); - bson_destroy (&reply); - ASSERT_OR_PRINT (r, error); - mongoc_bulk_operation_destroy (bulk); - /* }}} */ - - /* {{{ w=0 and bypass_document_validation=set fails */ - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - wr = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wr, 0); - mongoc_bulk_operation_set_write_concern (bulk, wr); - mongoc_bulk_operation_set_bypass_document_validation (bulk, true); - for (i = 0; i < 3; i++) { - bson_t *doc = tmp_bson ("{'number': 3, 'high': %d }", i); - - mongoc_bulk_operation_insert (bulk, doc); - } - r = mongoc_bulk_operation_execute (bulk, &reply, &error); - bson_destroy (&reply); - ASSERT_OR_PRINT (!r, error); - ASSERT_ERROR_CONTAINS ( - error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Cannot set bypassDocumentValidation for unacknowledged writes"); - mongoc_bulk_operation_destroy (bulk); - mongoc_write_concern_destroy (wr); - /* }}} */ - - ASSERT_OR_PRINT (mongoc_collection_drop (collection, &error), error); - - bson_free (dbname); - bson_free (collname); - mongoc_database_destroy (database); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); -} - -static void -test_bypass_command_started (const mongoc_apm_command_started_t *event) -{ - ASSERT_HAS_NOT_FIELD (mongoc_apm_command_started_get_command (event), - "bypassDocumentValidation"); -} - -static void -test_bypass_not_sent (void) -{ - mongoc_collection_t *collection; - mongoc_bulk_operation_t *bulk; - mongoc_find_and_modify_opts_t *opts; - mongoc_client_t *client; - mongoc_database_t *database; - mongoc_apm_callbacks_t *callbacks; - bson_error_t error; - bool r; - bson_t *doc; - const bson_t *agg_doc; - bson_t reply; - bson_t *update; - bson_t *query; - bson_t *pipeline; - bson_t *agg_opts; - mongoc_cursor_t *cursor; - char *collname; - char *dbname; - - client = test_framework_new_default_client (); - - /* set up command monitoring for started commands */ - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, test_bypass_command_started); - mongoc_client_set_apm_callbacks (client, callbacks, NULL); - mongoc_apm_callbacks_destroy (callbacks); - - dbname = "test"; - collname = gen_collection_name ("bypass"); - database = mongoc_client_get_database (client, dbname); - collection = mongoc_database_get_collection (database, collname); - - bulk = mongoc_collection_create_bulk_operation_with_opts (collection, NULL); - - /* we explicitly set this to false to test that it isn't sent */ - mongoc_bulk_operation_set_bypass_document_validation (bulk, false); - - /* insert a doc */ - doc = BCON_NEW ("x", BCON_INT32 (31)); - mongoc_bulk_operation_insert (bulk, doc); - bson_destroy (doc); - r = (bool) mongoc_bulk_operation_execute (bulk, &reply, &error); - bson_destroy (&reply); - ASSERT_OR_PRINT (r, error); - mongoc_bulk_operation_destroy (bulk); - - opts = mongoc_find_and_modify_opts_new (); - - /* we explicitly set this to false to test that it isn't sent */ - mongoc_find_and_modify_opts_set_bypass_document_validation (opts, false); - - /* find the doc we inserted earlier and modify it */ - update = BCON_NEW ("$set", "{", "x", BCON_INT32 (32), "}"); - mongoc_find_and_modify_opts_set_update (opts, update); - bson_destroy (update); - query = BCON_NEW ("x", BCON_INT32 (31)); - r = mongoc_collection_find_and_modify_with_opts ( - collection, query, opts, &reply, &error); - bson_destroy (&reply); - ASSERT_OR_PRINT (r, error); - bson_destroy (query); - mongoc_find_and_modify_opts_destroy (opts); - - /* we explicitly set this to false to test that it isn't sent */ - agg_opts = BCON_NEW ("bypassDocumentValidation", BCON_BOOL (false)); - - /* aggregate match */ - pipeline = BCON_NEW ("pipeline", "[", "]"); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_NONE, pipeline, agg_opts, NULL); - bson_destroy (pipeline); - bson_destroy (agg_opts); - - /* iterate through aggregation results */ - while (mongoc_cursor_next (cursor, &agg_doc)) { - } - - mongoc_cursor_destroy (cursor); - - /* cleanup */ - bson_free (collname); - mongoc_collection_destroy (collection); - mongoc_database_destroy (database); - mongoc_client_destroy (client); -} - -static void -test_disconnect_mid_batch (void) -{ - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *coll; - bson_t **docs; - int i; - bson_error_t error; - future_t *future; - request_t *request; - int n_docs; - - server = mock_server_new (); - mock_server_auto_hello (server, - "{'ok': 1.0," - " 'isWritablePrimary': true," - " 'minWireVersion': %d," - " 'maxWireVersion': %d," - " 'maxBsonObjectSize': 100}", - WIRE_VERSION_MIN, - WIRE_VERSION_MAX); - mock_server_run (server); - - /* create enough documents for two batches. Note, because of our wonky - * batch splitting behavior (to be fixed in CDRIVER-3310) we need add 16K - * of documents. After CDRIVER-3310, we'll need to update this test. */ - n_docs = ((BSON_OBJECT_ALLOWANCE) / tmp_bson ("{ '_id': 1 }")->len) + 1; - docs = bson_malloc (sizeof (bson_t *) * n_docs); - for (i = 0; i < n_docs; i++) { - docs[i] = BCON_NEW ("_id", BCON_INT64 (i)); - } - - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - coll = mongoc_client_get_collection (client, "db", "coll"); - - future = future_collection_insert_many ( - coll, (const bson_t **) docs, n_docs, NULL, NULL, &error); - /* Mock server recieves first insert. */ - request = mock_server_receives_request (server); - BSON_ASSERT (request); - reply_to_request_with_hang_up (request); - request_destroy (request); - - BSON_ASSERT (!future_get_bool (future)); - future_destroy (future); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "socket error"); - - for (i = 0; i < n_docs; i++) { - bson_destroy (docs[i]); - } - bson_free (docs); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -static void -_configure_failpoint (mongoc_client_t *client, - const char *mode, - const char *data) -{ - bool ret; - bson_error_t error; - - ASSERT (client); - - ret = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'configureFailPoint': 'failCommand', 'mode': %s, 'data': %s}", - mode, - data), - NULL, - NULL, - &error); - ASSERT_OR_PRINT (ret, error); -} - -static void -_test_invalid_wc_server_error (void *unused) -{ - mongoc_client_t *client; - mongoc_collection_t *coll; - bool ret; - bson_t reply; - bson_error_t error; - - BSON_UNUSED (unused); - - client = test_framework_new_default_client (); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - coll = get_test_collection (client, "server_wc_error"); - - _configure_failpoint (client, - "{'times': 2}", - "{ 'failCommands': ['insert'], " - "'writeConcernError': {'code' : " - "91.0, 'errmsg': 'Replication is " - "being shut down' }}"); - ret = mongoc_collection_insert_one ( - coll, tmp_bson ("{'x':1}"), NULL /* opts */, &reply, &error); - BSON_ASSERT (!ret); - ASSERT_MATCH (&reply, - "{'writeConcernErrors': [{'code': 91, 'errmsg': " - "'Replication is being shut down'}]}"); - - _configure_failpoint (client, "'off'", "{}"); - - bson_destroy (&reply); - mongoc_collection_destroy (coll); - mongoc_client_destroy (client); -} - -void -test_write_command_install (TestSuite *suite) -{ - TestSuite_AddLive (suite, "/WriteCommand/split_insert", test_split_insert); - TestSuite_AddLive ( - suite, "/WriteCommand/bypass_not_sent", test_bypass_not_sent); - TestSuite_AddLive ( - suite, "/WriteCommand/invalid_write_concern", test_invalid_write_concern); - TestSuite_AddFull (suite, - "/WriteCommand/bypass_validation", - test_bypass_validation, - NULL, - NULL, - TestSuite_CheckLive); - TestSuite_AddMockServerTest (suite, - "/WriteCommand/insert_disconnect_mid_batch", - test_disconnect_mid_batch); - TestSuite_AddFull (suite, - "/WriteCommand/invalid_wc_server_error", - _test_invalid_wc_server_error, - NULL, - NULL, - test_framework_skip_if_no_failpoint, - /* Skipping on sharded clusters; see SERVER-57772 */ - test_framework_skip_if_mongos); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-write-concern.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-write-concern.c deleted file mode 100644 index 1c80e9651..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-write-concern.c +++ /dev/null @@ -1,765 +0,0 @@ -#include -#include -#include - -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "mock_server/mock-server.h" -#include "mock_server/future.h" -#include "mock_server/future-functions.h" - - -static void -test_write_concern_append (void) -{ - mongoc_write_concern_t *wc; - bson_t *cmd; - - cmd = tmp_bson ("{'foo': 1}"); - capture_logs (true); - - /* cannot append invalid writeConcern */ - wc = NULL; - BSON_ASSERT (!mongoc_write_concern_append (wc, cmd)); - - /* append default writeConcern */ - wc = mongoc_write_concern_new (); - ASSERT (mongoc_write_concern_is_default (wc)); - ASSERT_MATCH (cmd, "{'foo': 1, 'writeConcern': {'$exists': false}}"); - - /* append writeConcern with w */ - mongoc_write_concern_set_w (wc, 1); - BSON_ASSERT (mongoc_write_concern_append (wc, cmd)); - - assert_match_bson ( - cmd, tmp_bson ("{'foo': 1, 'writeConcern': {'w': 1}}"), true); - - mongoc_write_concern_destroy (wc); -} - -static void -test_write_concern_basic (void) -{ - mongoc_write_concern_t *write_concern; - const bson_t *bson; - bson_iter_t iter; - - write_concern = mongoc_write_concern_new (); - - BEGIN_IGNORE_DEPRECATIONS; - - /* - * Test defaults. - */ - ASSERT (write_concern); - ASSERT (!mongoc_write_concern_get_fsync (write_concern)); - ASSERT (!mongoc_write_concern_get_journal (write_concern)); - ASSERT (mongoc_write_concern_get_w (write_concern) == - MONGOC_WRITE_CONCERN_W_DEFAULT); - ASSERT (!mongoc_write_concern_get_wtimeout_int64 (write_concern)); - ASSERT (!mongoc_write_concern_get_wmajority (write_concern)); - - mongoc_write_concern_set_fsync (write_concern, true); - ASSERT (mongoc_write_concern_get_fsync (write_concern)); - mongoc_write_concern_set_fsync (write_concern, false); - ASSERT (!mongoc_write_concern_get_fsync (write_concern)); - - mongoc_write_concern_set_journal (write_concern, true); - ASSERT (mongoc_write_concern_get_journal (write_concern)); - mongoc_write_concern_set_journal (write_concern, false); - ASSERT (!mongoc_write_concern_get_journal (write_concern)); - - /* - * Test changes to w. - */ - mongoc_write_concern_set_w (write_concern, MONGOC_WRITE_CONCERN_W_MAJORITY); - ASSERT (mongoc_write_concern_get_wmajority (write_concern)); - mongoc_write_concern_set_w (write_concern, MONGOC_WRITE_CONCERN_W_DEFAULT); - ASSERT (!mongoc_write_concern_get_wmajority (write_concern)); - mongoc_write_concern_set_wmajority (write_concern, 1000); - ASSERT (mongoc_write_concern_get_wmajority (write_concern)); - ASSERT (mongoc_write_concern_get_wtimeout (write_concern) == 1000); - mongoc_write_concern_set_wtimeout (write_concern, 0); - ASSERT (!mongoc_write_concern_get_wtimeout (write_concern)); - mongoc_write_concern_set_wtimeout_int64 (write_concern, INT64_MAX); - ASSERT (mongoc_write_concern_get_wtimeout_int64 (write_concern) == - INT64_MAX); - mongoc_write_concern_set_w (write_concern, MONGOC_WRITE_CONCERN_W_DEFAULT); - ASSERT (mongoc_write_concern_get_w (write_concern) == - MONGOC_WRITE_CONCERN_W_DEFAULT); - mongoc_write_concern_set_w (write_concern, 3); - ASSERT (mongoc_write_concern_get_w (write_concern) == 3); - - /* - * Check generated bson. - */ - mongoc_write_concern_set_fsync (write_concern, true); - mongoc_write_concern_set_journal (write_concern, true); - - bson = _mongoc_write_concern_get_bson (write_concern); - ASSERT (bson); - ASSERT (bson_iter_init_find (&iter, bson, "fsync") && - BSON_ITER_HOLDS_BOOL (&iter) && bson_iter_bool (&iter)); - ASSERT (bson_iter_init_find (&iter, bson, "j") && - BSON_ITER_HOLDS_BOOL (&iter) && bson_iter_bool (&iter)); - ASSERT (bson_iter_init_find (&iter, bson, "w") && - BSON_ITER_HOLDS_INT32 (&iter) && bson_iter_int32 (&iter) == 3); - - mongoc_write_concern_destroy (write_concern); - - END_IGNORE_DEPRECATIONS; -} - - -static void -test_write_concern_bson_omits_defaults (void) -{ - mongoc_write_concern_t *write_concern; - const bson_t *bson; - bson_iter_t iter; - - write_concern = mongoc_write_concern_new (); - - /* - * Check generated bson. - */ - ASSERT (write_concern); - - bson = _mongoc_write_concern_get_bson (write_concern); - ASSERT (bson); - ASSERT (!bson_iter_init_find (&iter, bson, "fsync")); - ASSERT (!bson_iter_init_find (&iter, bson, "j")); - - mongoc_write_concern_destroy (write_concern); -} - - -static void -test_write_concern_bson_includes_false_fsync_and_journal (void) -{ - mongoc_write_concern_t *write_concern; - const bson_t *bson; - bson_iter_t iter; - - write_concern = mongoc_write_concern_new (); - - /* - * Check generated bson. - */ - ASSERT (write_concern); - mongoc_write_concern_set_fsync (write_concern, false); - mongoc_write_concern_set_journal (write_concern, false); - - bson = _mongoc_write_concern_get_bson (write_concern); - ASSERT (bson); - ASSERT (bson_iter_init_find (&iter, bson, "fsync") && - BSON_ITER_HOLDS_BOOL (&iter) && !bson_iter_bool (&iter)); - ASSERT (bson_iter_init_find (&iter, bson, "j") && - BSON_ITER_HOLDS_BOOL (&iter) && !bson_iter_bool (&iter)); - ASSERT (!bson_iter_init_find (&iter, bson, "w")); - - mongoc_write_concern_destroy (write_concern); -} - - -static void -test_write_concern_fsync_and_journal_w1_and_validity (void) -{ - mongoc_write_concern_t *write_concern = mongoc_write_concern_new (); - - /* - * Journal and fsync should imply w=1 regardless of w; however, journal and - * fsync logically conflict with w=0 and w=-1, so a write concern with such - * a combination of options will be considered invalid. - */ - - /* No write concern needs GLE, but not "valid" */ - ASSERT (mongoc_write_concern_is_acknowledged (NULL)); - ASSERT (!mongoc_write_concern_is_valid (NULL)); - - /* Default write concern needs GLE and is valid */ - ASSERT (write_concern); - ASSERT (mongoc_write_concern_is_acknowledged (write_concern)); - ASSERT (mongoc_write_concern_is_valid (write_concern)); - ASSERT (!mongoc_write_concern_journal_is_set (write_concern)); - - /* w=0 does not need GLE and is valid */ - mongoc_write_concern_set_w (write_concern, - MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED); - ASSERT (!mongoc_write_concern_is_acknowledged (write_concern)); - ASSERT (mongoc_write_concern_is_valid (write_concern)); - ASSERT (!mongoc_write_concern_journal_is_set (write_concern)); - - /* fsync=true needs GLE, but it conflicts with w=0 */ - mongoc_write_concern_set_fsync (write_concern, true); - ASSERT (mongoc_write_concern_is_acknowledged (write_concern)); - ASSERT (!mongoc_write_concern_is_valid (write_concern)); - ASSERT (!mongoc_write_concern_journal_is_set (write_concern)); - mongoc_write_concern_set_fsync (write_concern, false); - - /* journal=true needs GLE, but it conflicts with w=0 */ - mongoc_write_concern_set_journal (write_concern, true); - ASSERT (mongoc_write_concern_is_acknowledged (write_concern)); - ASSERT (!mongoc_write_concern_is_valid (write_concern)); - ASSERT (mongoc_write_concern_journal_is_set (write_concern)); - mongoc_write_concern_set_journal (write_concern, false); - - /* w=-1 does not need GLE and is valid */ - mongoc_write_concern_set_w (write_concern, - MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED); - ASSERT (!mongoc_write_concern_is_acknowledged (write_concern)); - ASSERT (mongoc_write_concern_is_valid (write_concern)); - ASSERT (mongoc_write_concern_journal_is_set (write_concern)); - - /* fsync=true needs GLE, but it conflicts with w=-1 */ - mongoc_write_concern_set_fsync (write_concern, true); - ASSERT (mongoc_write_concern_is_acknowledged (write_concern)); - ASSERT (!mongoc_write_concern_is_valid (write_concern)); - ASSERT (mongoc_write_concern_journal_is_set (write_concern)); - - /* journal=true needs GLE, but it conflicts with w=-1 */ - mongoc_write_concern_set_fsync (write_concern, false); - mongoc_write_concern_set_journal (write_concern, true); - ASSERT (mongoc_write_concern_is_acknowledged (write_concern)); - ASSERT (mongoc_write_concern_journal_is_set (write_concern)); - - /* fsync=true with w=default needs GLE and is valid */ - mongoc_write_concern_set_journal (write_concern, false); - mongoc_write_concern_set_fsync (write_concern, true); - mongoc_write_concern_set_w (write_concern, MONGOC_WRITE_CONCERN_W_DEFAULT); - ASSERT (mongoc_write_concern_is_acknowledged (write_concern)); - ASSERT (mongoc_write_concern_is_valid (write_concern)); - ASSERT (mongoc_write_concern_journal_is_set (write_concern)); - - /* journal=true with w=default needs GLE and is valid */ - mongoc_write_concern_set_journal (write_concern, false); - mongoc_write_concern_set_fsync (write_concern, true); - mongoc_write_concern_set_w (write_concern, MONGOC_WRITE_CONCERN_W_DEFAULT); - ASSERT (mongoc_write_concern_is_acknowledged (write_concern)); - ASSERT (mongoc_write_concern_is_valid (write_concern)); - ASSERT (mongoc_write_concern_journal_is_set (write_concern)); - - mongoc_write_concern_destroy (write_concern); -} - -static void -test_write_concern_wtimeout_validity (void) -{ - mongoc_write_concern_t *write_concern = mongoc_write_concern_new (); - - /* Test defaults */ - ASSERT (write_concern); - ASSERT (mongoc_write_concern_get_w (write_concern) == - MONGOC_WRITE_CONCERN_W_DEFAULT); - ASSERT (mongoc_write_concern_get_wtimeout_int64 (write_concern) == 0); - ASSERT (!mongoc_write_concern_get_wmajority (write_concern)); - - /* mongoc_write_concern_set_wtimeout_int64() ignores invalid wtimeout */ - mongoc_write_concern_set_wtimeout_int64 (write_concern, -1); - ASSERT (mongoc_write_concern_get_w (write_concern) == - MONGOC_WRITE_CONCERN_W_DEFAULT); - ASSERT (mongoc_write_concern_get_wtimeout_int64 (write_concern) == 0); - ASSERT (!mongoc_write_concern_get_wmajority (write_concern)); - ASSERT (mongoc_write_concern_is_valid (write_concern)); - - /* mongoc_write_concern_set_wmajority() ignores invalid wtimeout */ - mongoc_write_concern_set_wmajority (write_concern, -1); - ASSERT (mongoc_write_concern_get_w (write_concern) == - MONGOC_WRITE_CONCERN_W_MAJORITY); - ASSERT (mongoc_write_concern_get_wtimeout_int64 (write_concern) == 0); - ASSERT (mongoc_write_concern_get_wmajority (write_concern)); - ASSERT (mongoc_write_concern_is_valid (write_concern)); - - /* Manually assigning a negative wtimeout will make the write concern invalid - */ - write_concern->wtimeout = -1; - ASSERT (!mongoc_write_concern_is_valid (write_concern)); - - mongoc_write_concern_destroy (write_concern); -} - -static void -_test_write_concern_from_iterator (const char *swc, bool ok, bool is_default) -{ - bson_t *bson = tmp_bson (swc); - const bson_t *bson2; - mongoc_write_concern_t *wc; - bson_iter_t iter; - bson_error_t error; - - if (test_suite_debug_output ()) { - fprintf (stdout, " - %s\n", swc); - fflush (stdout); - } - - bson_iter_init_find (&iter, bson, "writeConcern"); - wc = _mongoc_write_concern_new_from_iter (&iter, &error); - if (ok) { - BSON_ASSERT (wc); - ASSERT (mongoc_write_concern_is_default (wc) == is_default); - bson2 = _mongoc_write_concern_get_bson (wc); - ASSERT (bson_compare (bson, bson2)); - mongoc_write_concern_destroy (wc); - } else { - BSON_ASSERT (!wc); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid writeConcern"); - } -} - -static void -test_write_concern_from_iterator (void) -{ - _test_write_concern_from_iterator ("{'writeConcern': {}}", true, true); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 'majority'}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 'majority', 'j': true}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 'sometag'}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 'sometag', 'j': true}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 'sometag', 'j': false}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 1, 'j': true}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 1, 'j': false}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 0, 'j': true}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 0, 'j': false}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 42}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 1}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'j': true}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'j': false}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': -1}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': -2}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': -3}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': -4}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': -5}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 'majority', 'wtimeout': 42}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 'sometag', 'wtimeout': 42}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'wtimeout': 42}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'wtimeout': -42}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'wtimeout': {'$numberLong': '123'}}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'wtimeout': {'$numberLong': '2147483648'}}}", - true, - false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 1, 'wtimeout': 42}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 0, 'wtimeout': 42}}", true, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': 1.0}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': {'some': 'stuff'}}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'w': []}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'wtimeout': 'never'}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'j': 'never'}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'j': 1.0}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'fsync': 1.0}}", false, false); - _test_write_concern_from_iterator ( - "{'writeConcern': {'fsync': true}}", true, false); -} - - -static void -test_write_concern_always_mutable (void) -{ - mongoc_write_concern_t *write_concern; - - write_concern = mongoc_write_concern_new (); - - ASSERT (write_concern); - - mongoc_write_concern_set_fsync (write_concern, true); - ASSERT_MATCH (_mongoc_write_concern_get_bson (write_concern), - "{'fsync': true}"); - - mongoc_write_concern_set_journal (write_concern, true); - ASSERT_MATCH (_mongoc_write_concern_get_bson (write_concern), - "{'fsync': true, 'j': true}"); - - mongoc_write_concern_set_w (write_concern, 2); - ASSERT_MATCH (_mongoc_write_concern_get_bson (write_concern), - "{'w': 2, 'fsync': true, 'j': true}"); - - mongoc_write_concern_set_wtimeout_int64 (write_concern, 100); - ASSERT_MATCH (_mongoc_write_concern_get_bson (write_concern), - "{'w': 2, 'fsync': true, 'j': true, 'wtimeout': 100}"); - - mongoc_write_concern_set_wmajority (write_concern, 200); - ASSERT_MATCH ( - _mongoc_write_concern_get_bson (write_concern), - "{'w': 'majority', 'fsync': true, 'j': true, 'wtimeout': 200}"); - - mongoc_write_concern_set_wtag (write_concern, "MultipleDC"); - ASSERT_MATCH ( - _mongoc_write_concern_get_bson (write_concern), - "{'w': 'MultipleDC', 'fsync': true, 'j': true, 'wtimeout': 200}"); - - mongoc_write_concern_destroy (write_concern); -} - - -static void -_test_wc_request (future_t *future, mock_server_t *server, bson_error_t *error) -{ - request_t *request; - - BSON_UNUSED (error); - - request = mock_server_receives_msg ( - server, - MONGOC_MSG_NONE, - tmp_bson ("{'$db': 'db', 'writeConcern': {'w': 2}}")); - reply_to_request_with_ok_and_destroy (request); - BSON_ASSERT (future_get_bool (future)); - - future_destroy (future); -} - - -static void -test_write_concern (void) -{ - bson_t *opts; - mock_server_t *server; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_cursor_t *cursor; - future_t *future; - bson_error_t error; - - opts = tmp_bson ("{'writeConcern': {'w': 2}}"); - server = mock_server_with_auto_hello (WIRE_VERSION_MIN); - mock_server_run (server); - client = - test_framework_client_new_from_uri (mock_server_get_uri (server), NULL); - collection = mongoc_client_get_collection (client, "db", "collection"); - - /* - * aggregate with $out - */ - cursor = mongoc_collection_aggregate (collection, - MONGOC_QUERY_NONE, - tmp_bson ("[{'$out': 'foo'}]"), - opts, - NULL); - ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); - - /* - * generic mongoc_client_write_command_with_opts - */ - future = future_client_write_command_with_opts ( - client, "db", tmp_bson ("{'foo': 1}"), opts, NULL, &error); - _test_wc_request (future, server, &error); - - /* - * drop - */ - future = future_collection_drop_with_opts (collection, opts, &error); - _test_wc_request (future, server, &error); - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - mock_server_destroy (server); -} - -/* Test that CDRIVER-2902 has been fixed. - * The bug was that we did not correctly swab for the flagBits in OP_MSG. */ -static void -test_write_concern_unacknowledged (void) -{ - mongoc_client_t *client; - mongoc_write_concern_t *wc; - mongoc_collection_t *coll; - bson_error_t error; - bool r; - bson_t reply; - bson_t opts; - const bson_t **docs; - - client = test_framework_new_default_client (); - coll = mongoc_client_get_collection (client, "db", "coll"); - - /* w:0 in OP_MSG is indicated by setting the moreToCome flag in OP_MSG. That - * tells the recipient not to send a response. */ - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED); - bson_init (&opts); - mongoc_write_concern_append (wc, &opts); - - /* In this insert_one with w:0, we write an OP_MSG on the socket, but don't - * read a reply. Before CDRIVER-2902 was fixed, since we forget to set - * moreToCome, the server still sends a reply. */ - r = mongoc_collection_insert_one ( - coll, tmp_bson ("{}"), &opts, &reply, &error); - ASSERT_OR_PRINT (r, error); - ASSERT (bson_empty (&reply)); - bson_destroy (&reply); - bson_destroy (&opts); - - docs = bson_malloc0 (sizeof (bson_t *) * 2); - docs[0] = tmp_bson ("{}"); - docs[1] = tmp_bson ("{}"); - - /* In the next insert_many, before CDRIVER-2902 was fixed, we would read that - * old reply. */ - r = mongoc_collection_insert_many (coll, docs, 2, NULL, &reply, &error); - bson_free ((void *) docs); - ASSERT_OR_PRINT (r, error); - - /* The replies are distinguished by the insertedCount. */ - ASSERT_MATCH (&reply, "{'insertedCount': 2}"); - - bson_destroy (&reply); - mongoc_collection_destroy (coll); - mongoc_write_concern_destroy (wc); - mongoc_client_destroy (client); -} - - -/* Regression test to to demonstrate that a 64-bit wtimeoutms value is properly - * preserved. */ -static void -test_write_concern_wtimeout_preserved (void) -{ - mongoc_write_concern_t *write_concern = mongoc_write_concern_new (); - bson_t *cmd = tmp_bson ("{}"); - bson_iter_t iter; - bson_iter_t child; - - ASSERT (write_concern); - - mongoc_write_concern_set_wtimeout_int64 (write_concern, INT64_MAX); - mongoc_write_concern_append (write_concern, cmd); - - ASSERT (bson_iter_init_find (&iter, cmd, "writeConcern")); - ASSERT (BSON_ITER_HOLDS_DOCUMENT (&iter)); - ASSERT (bson_iter_recurse (&iter, &child)); - ASSERT (bson_iter_next (&child)); - ASSERT_CMPSTR (bson_iter_key (&child), "wtimeout"); - ASSERT_CMPINT64 (bson_iter_int64 (&child), ==, INT64_MAX); - - mongoc_write_concern_destroy (write_concern); -} - -/* callback that records write concern for commands */ -static void -write_concern_count (const mongoc_apm_command_started_t *event) -{ - const bson_t *command = mongoc_apm_command_started_get_command (event); - bson_iter_t iter, iter_rec; - - if (bson_iter_init (&iter, command)) { - int *sent_collection_w = - (int *) mongoc_apm_command_started_get_context (event); - if (bson_iter_find_descendant (&iter, "writeConcern.w", &iter_rec)) { - *sent_collection_w = bson_iter_int32 (&iter_rec); - } else { - *sent_collection_w = MONGOC_WRITE_CONCERN_W_DEFAULT; /* no write - concern sent. - default used */ - } - } -} - -/* Addresses concerns brought up in CDRIVER-3595. This function comprises - * three tests. The first tests that with no txn in progress, wc is inherited - * from collection. The second tests that with a txn in progress, no - * wc is inherited from collection, unacknowledged or acknowledged. - * The third tests that an attempt to send an lsid with an - * unacknowledged wc fails (where wc is inherited from collection). - * All commands are fam commands. */ -static void -test_write_concern_inheritance_fam_txn (bool in_session, bool in_txn) -{ - mongoc_find_and_modify_opts_t *opts = NULL; - bson_t *update; - bson_t *session_id; - bson_error_t error; - bson_t query = BSON_INITIALIZER; - mongoc_write_concern_t *wc; - mongoc_client_t *client; - mongoc_collection_t *collection; - mongoc_client_session_t *session = NULL; - mongoc_apm_callbacks_t *callbacks; - int sent_w = MONGOC_WRITE_CONCERN_W_DEFAULT; - bool success; - - client = test_framework_new_default_client (); - collection = mongoc_client_get_collection (client, "db", "collection"); - - callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_command_started_cb (callbacks, write_concern_count); - mongoc_client_set_apm_callbacks (client, callbacks, (void *) &sent_w); - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, 1); - mongoc_collection_set_write_concern (collection, wc); - - BSON_APPEND_UTF8 (&query, "firstname", "Zlatan"); - update = bson_new (); - session_id = bson_new (); - opts = mongoc_find_and_modify_opts_new (); - - if (in_session) { - session = mongoc_client_start_session (client, NULL, &error); - ASSERT_OR_PRINT (session, error); - success = mongoc_client_session_append (session, session_id, &error); - ASSERT_OR_PRINT (success, error); - mongoc_find_and_modify_opts_append (opts, session_id); - } - if (in_txn) { - BSON_ASSERT (in_session); - success = mongoc_client_session_start_transaction (session, NULL, &error); - ASSERT_OR_PRINT (success, error); - } - - mongoc_find_and_modify_opts_set_update (opts, update); - success = mongoc_collection_find_and_modify_with_opts ( - collection, &query, opts, NULL, &error); - - if (in_txn) { - /* check that the sent write concern is not inherited */ - BSON_ASSERT (sent_w == MONGOC_WRITE_CONCERN_W_DEFAULT); - BSON_ASSERT (success); - } else { - /* assert that write concern is inherited. Two tests reach this - * code. No txn in progress. */ - ASSERT_OR_PRINT (success, error); - BSON_ASSERT (success); - BSON_ASSERT (sent_w == 1); - } - - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED); - mongoc_collection_set_write_concern (collection, wc); - - sent_w = MONGOC_WRITE_CONCERN_W_DEFAULT; - success = mongoc_collection_find_and_modify_with_opts ( - collection, &query, opts, NULL, &error); - - if (in_txn) { - /* check that the sent write concern is not inherited */ - BSON_ASSERT (sent_w == MONGOC_WRITE_CONCERN_W_DEFAULT); - success = - mongoc_client_session_commit_transaction (session, NULL, &error); - ASSERT_OR_PRINT (success, error); - } else if (!in_session) { - /* assert that write concern is inherited */ - BSON_ASSERT (success); - BSON_ASSERT (sent_w == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED); - } else { - /* case where lsid is sent with unacknowledged write concern */ - BSON_ASSERT (!success); - ASSERT_CONTAINS (error.message, - "Cannot use client session with " - "unacknowledged command"); - } - - mongoc_write_concern_destroy (wc); - mongoc_client_session_destroy (session); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_collection_destroy (collection); - mongoc_client_destroy (client); - bson_destroy (update); - bson_destroy (&query); - bson_destroy (session_id); - mongoc_find_and_modify_opts_destroy (opts); -} - -static void -test_fam_no_session_no_txn (void *unused) -{ - BSON_UNUSED (unused); - test_write_concern_inheritance_fam_txn (false, false); -} - -static void -test_fam_session_no_txn (void *unused) -{ - BSON_UNUSED (unused); - test_write_concern_inheritance_fam_txn (true, false); -} - -static void -test_fam_session_txn (void *unused) -{ - BSON_UNUSED (unused); - test_write_concern_inheritance_fam_txn (true, true); -} - -void -test_write_concern_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/WriteConcern/append", test_write_concern_append); - TestSuite_Add (suite, "/WriteConcern/basic", test_write_concern_basic); - TestSuite_Add (suite, - "/WriteConcern/bson_omits_defaults", - test_write_concern_bson_omits_defaults); - TestSuite_Add (suite, - "/WriteConcern/bson_includes_false_fsync_and_journal", - test_write_concern_bson_includes_false_fsync_and_journal); - TestSuite_Add (suite, - "/WriteConcern/fsync_and_journal_gle_and_validity", - test_write_concern_fsync_and_journal_w1_and_validity); - TestSuite_Add (suite, - "/WriteConcern/wtimeout_validity", - test_write_concern_wtimeout_validity); - TestSuite_Add ( - suite, "/WriteConcern/from_iterator", test_write_concern_from_iterator); - TestSuite_Add ( - suite, "/WriteConcern/always_mutable", test_write_concern_always_mutable); - TestSuite_Add (suite, - "/WriteConcern/wtimeout_preserved", - test_write_concern_wtimeout_preserved); - TestSuite_AddMockServerTest (suite, "/WriteConcern", test_write_concern); - TestSuite_AddLive ( - suite, "/WriteConcern/unacknowledged", test_write_concern_unacknowledged); - TestSuite_AddFull (suite, - "/WriteConcern/inherited_fam", - test_fam_no_session_no_txn, - NULL, - NULL, - TestSuite_CheckLive); - TestSuite_AddFull (suite, - "/WriteConcern/inherited_fam_session_no_txn", - test_fam_session_no_txn, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_txns); - TestSuite_AddFull (suite, - "/WriteConcern/inherited_fam_txn", - test_fam_session_txn, - NULL, - NULL, - test_framework_skip_if_no_sessions, - test_framework_skip_if_no_txns); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-x509.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-x509.c deleted file mode 100644 index 0a1c6d36a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-mongoc-x509.c +++ /dev/null @@ -1,99 +0,0 @@ -#include -#include "mongoc/mongoc-ssl-private.h" - -#ifdef MONGOC_ENABLE_SSL_OPENSSL -#include "mongoc/mongoc-openssl-private.h" -#endif - -#include "TestSuite.h" -#include "test-libmongoc.h" - -#if defined(MONGOC_ENABLE_SSL) && !defined(MONGOC_ENABLE_SSL_LIBRESSL) -static void -test_extract_subject (void) -{ - char *subject; - - subject = mongoc_ssl_extract_subject (CERT_SERVER, NULL); - ASSERT_CMPSTR ( - subject, - "C=US,ST=New York,L=New York City,O=MongoDB,OU=Drivers,CN=localhost"); - bson_free (subject); - - subject = mongoc_ssl_extract_subject (CERT_CLIENT, NULL); - ASSERT_CMPSTR ( - subject, "C=US,ST=New York,L=New York City,O=MDB,OU=Drivers,CN=client"); - bson_free (subject); -} -#endif - -#ifdef MONGOC_ENABLE_OCSP_OPENSSL -/* Test parsing a DER encoded tlsfeature extension contents for the - * status_request (value 5). This is a SEQUENCE of INTEGER. libmongoc assumes - * this is a sequence of one byte integers. */ - -static void -_expect_malformed (const char *data, int32_t len) -{ - bool ret; - - ret = _mongoc_tlsfeature_has_status_request ((const uint8_t *) data, len); - BSON_ASSERT (!ret); - ASSERT_CAPTURED_LOG ("mongoc", MONGOC_LOG_LEVEL_ERROR, "malformed"); - clear_captured_logs (); -} - -static void -_expect_no_status_request (const char *data, int32_t len) -{ - bool ret; - ret = _mongoc_tlsfeature_has_status_request ((const uint8_t *) data, len); - BSON_ASSERT (!ret); - ASSERT_NO_CAPTURED_LOGS ("mongoc"); -} - -static void -_expect_status_request (const char *data, int32_t len) -{ - bool ret; - ret = _mongoc_tlsfeature_has_status_request ((const uint8_t *) data, len); - BSON_ASSERT (ret); - ASSERT_NO_CAPTURED_LOGS ("mongoc"); -} - -static void -test_tlsfeature_parsing (void) -{ - capture_logs (true); - /* A sequence of one integer = 5. */ - _expect_status_request ("\x30\x03\x02\x01\x05", 5); - /* A sequence of one integer = 6. */ - _expect_no_status_request ("\x30\x03\x02\x01\x06", 5); - /* A sequence of two integers = 5,6. */ - _expect_status_request ("\x30\x03\x02\x01\x05\x02\x01\x06", 8); - /* A sequence of two integers = 6,5. */ - _expect_status_request ("\x30\x03\x02\x01\x06\x02\x01\x05", 8); - /* A sequence containing a non-integer. Parsing fails. */ - _expect_malformed ("\x30\x03\x03\x01\x05\x02\x01\x06", 8); - /* A non-sequence. It will not read past the first byte (despite the >1 - * length). */ - _expect_malformed ("\xFF", 2); - /* A sequence with a length represented in more than one byte. Parsing fails. - */ - _expect_malformed ("\x30\x82\x04\x48", 4); - /* An integer with length > 1. Parsing fails. */ - _expect_malformed ("\x30\x03\x02\x02\x05\x05", 6); -} -#endif /* MONGOC_ENABLE_OCSP_OPENSSL */ - -void -test_x509_install (TestSuite *suite) -{ -#if defined(MONGOC_ENABLE_SSL) && !defined(MONGOC_ENABLE_SSL_LIBRESSL) - TestSuite_Add (suite, "/X509/extract_subject", test_extract_subject); -#endif - -#ifdef MONGOC_ENABLE_OCSP_OPENSSL - TestSuite_Add (suite, "/X509/tlsfeature_parsing", test_tlsfeature_parsing); -#endif -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-service-gcp.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-service-gcp.c deleted file mode 100644 index b8f457201..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/test-service-gcp.c +++ /dev/null @@ -1,137 +0,0 @@ -#include -#include -#include "TestSuite.h" - -static void -_test_gcp_parse (void) -{ - // Test that we correctly parse the JSON returned by the GCP metadata server - bson_error_t error; - gcp_service_account_token token; - - // server output must be json data - ASSERT (!gcp_access_token_try_parse_from_json ( - &token, "invalid json", -1, &error)); - ASSERT_CMPUINT32 (error.domain, ==, BSON_ERROR_JSON); - - // server output must contain access_token - ASSERT (!gcp_access_token_try_parse_from_json (&token, "{}", -1, &error)); - ASSERT_ERROR_CONTAINS ( - error, MONGOC_ERROR_GCP, MONGOC_ERROR_KMS_SERVER_BAD_JSON, ""); - - // server output must contain a value for access_token - ASSERT (!gcp_access_token_try_parse_from_json ( - &token, BSON_STR ({"access_token" : null}), -1, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_GCP, - MONGOC_ERROR_KMS_SERVER_BAD_JSON, - "One or more required JSON"); - - // server output must contain token_type - ASSERT (!gcp_access_token_try_parse_from_json ( - &token, BSON_STR ({"access_token" : "helloworld"}), -1, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_GCP, - MONGOC_ERROR_KMS_SERVER_BAD_JSON, - "One or more required JSON"); - - // can successfully parse JSON datat into a gcp_service_account_token - ASSERT ( - gcp_access_token_try_parse_from_json (&token, - BSON_STR ({ - "access_token" : "helloworld", - "token_type" : "bearer", - "expires_in" : "3788" - }), - -1, - &error)); - ASSERT_ERROR_CONTAINS (error, 0, 0, ""); - ASSERT_CMPSTR (token.access_token, "helloworld"); - ASSERT_CMPSTR (token.token_type, "bearer"); - - gcp_access_token_destroy (&token); -} - - -static void -_test_gcp_http_request (void) -{ - // Test that we correctly build a http request for the GCP metadata server - gcp_request req; - gcp_request_init (&req, "helloworld.com", 1234, NULL); - bson_string_t *req_str = _mongoc_http_render_request_head (&req.req); - gcp_request_destroy (&req); - ASSERT_CMPSTR ( - req_str->str, - "GET " - "/computeMetadata/v1/instance/service-accounts/default/token HTTP/1.0\r\n" - "Host: helloworld.com:1234\r\n" - "Connection: close\r\n" - "Metadata-Flavor: Google\r\n" - "\r\n"); - bson_string_free (req_str, true); -} - -static const char * -_get_test_host (void) -{ - return getenv ("TEST_KMS_PROVIDER_HOST"); -} - -static void -_run_http_test_case (const char *case_, - mongoc_error_domain_t expect_domain, - mongoc_error_code_t expect_code, - const char *expect_error_message) -{ - bson_error_t error = {0}; - struct _mongoc_host_list_t host; - _mongoc_host_list_from_string_with_err (&host, _get_test_host (), &error); - ASSERT_ERROR_CONTAINS (error, 0, 0, ""); - - gcp_service_account_token token = {0}; - char *const header = - bson_strdup_printf ("X-MongoDB-HTTP-TestParams: case=%s\r\n", case_); - gcp_access_token_from_gcp_server ( - &token, host.host, host.port, header, &error); - bson_free (header); - gcp_access_token_destroy (&token); - ASSERT_ERROR_CONTAINS ( - error, expect_domain, expect_code, expect_error_message); -} - -static void -_test_with_mock_server (void *ctx) -{ - BSON_UNUSED (ctx); - _run_http_test_case ("", 0, 0, ""); // (No error) - _run_http_test_case ( - "404", MONGOC_ERROR_GCP, MONGOC_ERROR_KMS_SERVER_HTTP, ""); - _run_http_test_case ( - "slow", MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "Timeout"); - _run_http_test_case ( - "empty-json", MONGOC_ERROR_GCP, MONGOC_ERROR_KMS_SERVER_BAD_JSON, ""); - _run_http_test_case ( - "bad-json", MONGOC_ERROR_CLIENT, MONGOC_ERROR_STREAM_INVALID_TYPE, ""); - _run_http_test_case ( - "giant", MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "too large"); -} - -static int -have_mock_server_env (TestSuite *ctx) -{ - return _get_test_host () != NULL; -} - -void -test_service_gcp_install (TestSuite *suite) -{ - TestSuite_Add (suite, "/gcp/http/parse", _test_gcp_parse); - TestSuite_Add (suite, "/gcp/http/request", _test_gcp_http_request); - TestSuite_AddFull (suite, - "/gcp/http/talk", - _test_with_mock_server, - NULL, - NULL, - have_mock_server_env); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/entity-map.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/entity-map.c deleted file mode 100644 index 8ffcd35b5..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/entity-map.c +++ /dev/null @@ -1,2415 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "entity-map.h" - -#include "bsonutil/bson-parser.h" -#include "TestSuite.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "utlist.h" -#include "util.h" - -#include - -#include "common-b64-private.h" -#include "mongoc-client-side-encryption-private.h" - -/* TODO: use public API to reduce min heartbeat once CDRIVER-3130 is resolved. - */ -#include "mongoc-client-private.h" -#include "mongoc-topology-private.h" - -#define REDUCED_HEARTBEAT_FREQUENCY_MS 500 -#define REDUCED_MIN_HEARTBEAT_FREQUENCY_MS 50 - -struct _entity_findcursor_t { - const bson_t *first_result; - mongoc_cursor_t *cursor; -}; - -static void -entity_destroy (entity_t *entity); - -entity_map_t * -entity_map_new (void) -{ - return bson_malloc0 (sizeof (entity_map_t)); -} - -void -entity_map_destroy (entity_map_t *entity_map) -{ - entity_t *entity, *tmp; - LL_FOREACH_SAFE (entity_map->entities, entity, tmp) - { - entity_destroy (entity); - } - bson_free (entity_map); -} - -static bool -uri_apply_options (mongoc_uri_t *uri, bson_t *opts, bson_error_t *error) -{ - bson_iter_t iter; - bool ret = false; - bool wcSet = false; - mongoc_write_concern_t *wc = NULL; - - /* There may be multiple URI options (w, wTimeoutMS, journal) for a write - * concern. Parse all options before setting the write concern on the URI. */ - wc = mongoc_write_concern_new (); - - BSON_FOREACH (opts, iter) - { - const char *key; - - key = bson_iter_key (&iter); - - if (0 == strcmp ("readConcernLevel", key)) { - mongoc_read_concern_t *rc = NULL; - - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, bson_iter_utf8 (&iter, NULL)); - mongoc_uri_set_read_concern (uri, rc); - mongoc_read_concern_destroy (rc); - } else if (0 == strcmp ("w", key)) { - wcSet = true; - mongoc_write_concern_set_w (wc, bson_iter_int32 (&iter)); - } else if (mongoc_uri_option_is_int32 (key)) { - mongoc_uri_set_option_as_int32 (uri, key, bson_iter_int32 (&iter)); - } else if (mongoc_uri_option_is_int64 (key)) { - mongoc_uri_set_option_as_int64 (uri, key, bson_iter_int64 (&iter)); - } else if (mongoc_uri_option_is_bool (key)) { - mongoc_uri_set_option_as_bool (uri, key, bson_iter_bool (&iter)); - } else if (0 == strcmp ("appname", key)) { - mongoc_uri_set_appname (uri, bson_iter_utf8 (&iter, NULL)); - } else { - test_set_error ( - error, "Unimplemented test runner support for URI option: %s", key); - goto done; - } - } - - if (wcSet) { - mongoc_uri_set_write_concern (uri, wc); - } - - ret = true; - -done: - mongoc_write_concern_destroy (wc); - return ret; -} - -event_t * -event_new (const char *type) -{ - event_t *event = NULL; - - event = bson_malloc0 (sizeof (event_t)); - event->type = bson_strdup (type); - return event; -} - -void -event_destroy (event_t *event) -{ - if (!event) { - return; - } - - bson_free (event->command_name); - bson_free (event->database_name); - bson_destroy (event->command); - bson_destroy (event->reply); - bson_free (event->type); - bson_free (event); -} - -static entity_t * -entity_new (entity_map_t *em, const char *type) -{ - entity_t *entity = NULL; - entity = bson_malloc0 (sizeof (entity_t)); - entity->type = bson_strdup (type); - entity->entity_map = em; - _mongoc_array_init (&entity->observe_events, sizeof (observe_event_t)); - _mongoc_array_init (&entity->store_events, sizeof (store_event_t)); - return entity; -} - -static bool -is_sensitive_command (event_t *event) -{ - const bson_t *body = event->reply ? event->reply : event->command; - BSON_ASSERT (body); - return mongoc_apm_is_sensitive_command_message (event->command_name, body); -} - -bool -should_ignore_event (entity_t *client_entity, event_t *event) -{ - bson_iter_t iter; - - if (0 == strcmp (event->command_name, "configureFailPoint")) { - return true; - } - - if (client_entity->ignore_command_monitoring_events) { - BSON_FOREACH (client_entity->ignore_command_monitoring_events, iter) - { - if (0 == strcmp (event->command_name, bson_iter_utf8 (&iter, NULL))) { - return true; - } - } - } - - { - observe_event_t *const begin = - (observe_event_t *) client_entity->observe_events.data; - observe_event_t *const end = begin + client_entity->observe_events.len; - - bool is_observed = false; - - for (observe_event_t *iter = begin; iter != end; ++iter) { - if (bson_strcasecmp (iter->type, event->type) == 0) { - is_observed = true; - break; - } - } - - if (!is_observed) { - return true; - } - } - - if (client_entity->observe_sensitive_commands && - *client_entity->observe_sensitive_commands) { - return false; - } - - /* Sensitive commands need to be ignored */ - return is_sensitive_command (event); -} - - -typedef void *(*apm_func_void_t) (const void *); -typedef const bson_t *(*apm_func_bson_t) (const void *); -typedef const char *(*apm_func_utf8_t) (const void *); -typedef int64_t (*apm_func_int64_t) (const void *); -typedef const bson_oid_t *(*apm_func_bson_oid_t) (const void *); -typedef int32_t (*apm_func_int32_t) (const void *); -typedef const mongoc_host_list_t *(*apm_func_host_list_t) (const void *); -typedef void (*apm_func_serialize_t) (bson_t *, const void *); - - -typedef struct command_callback_funcs_t { - apm_func_void_t get_context; - apm_func_bson_t get_command; - apm_func_bson_t get_reply; - apm_func_utf8_t get_command_name; - apm_func_utf8_t get_database_name; - apm_func_int64_t get_request_id; - apm_func_int64_t get_operation_id; - apm_func_bson_oid_t get_service_id; - apm_func_host_list_t get_host; - apm_func_int64_t get_server_connection_id; - apm_func_serialize_t serialize; -} command_callback_funcs_t; - - -static void -observe_event (entity_t *entity, - command_callback_funcs_t funcs, - const char *type, - const void *apm_command) -{ - BSON_ASSERT_PARAM (type); - BSON_ASSERT_PARAM (apm_command); - - BSON_ASSERT (funcs.get_context); - event_t *const event = event_new (type); - - if (funcs.get_command) { - event->command = bson_copy (funcs.get_command (apm_command)); - } - - if (funcs.get_reply) { - event->reply = bson_copy (funcs.get_reply (apm_command)); - } - - BSON_ASSERT (funcs.get_command_name); - event->command_name = bson_strdup (funcs.get_command_name (apm_command)); - - if (funcs.get_database_name) { - event->database_name = - bson_strdup (funcs.get_database_name (apm_command)); - } - - BSON_ASSERT (funcs.get_service_id); - const bson_oid_t *const service_id = funcs.get_service_id (apm_command); - if (service_id) { - bson_oid_copy (service_id, &event->service_id); - } - - BSON_ASSERT (funcs.get_server_connection_id); - event->server_connection_id = funcs.get_server_connection_id (apm_command); - - if (should_ignore_event (entity, event)) { - event_destroy (event); - return; - } - - LL_APPEND (entity->events, event); -} - - -static void -store_event_serialize_started (bson_t *doc, - const mongoc_apm_command_started_t *apm_command) -{ - // Spec: The test runner MAY omit the command field for CommandStartedEvent - // and reply field for CommandSucceededEvent. - // BSON_APPEND_DOCUMENT ( - // doc, "command", mongoc_apm_command_started_get_command (apm_command)); - - BSON_APPEND_UTF8 ( - doc, - "databaseName", - mongoc_apm_command_started_get_database_name (apm_command)); - - BSON_APPEND_UTF8 (doc, - "commandName", - mongoc_apm_command_started_get_command_name (apm_command)); - - BSON_APPEND_INT64 (doc, - "requestId", - mongoc_apm_command_started_get_request_id (apm_command)); - - BSON_APPEND_INT64 ( - doc, - "operationId", - mongoc_apm_command_started_get_operation_id (apm_command)); - - BSON_APPEND_UTF8 ( - doc, - "connectionId", - mongoc_apm_command_started_get_host (apm_command)->host_and_port); - - BSON_APPEND_INT64 ( - doc, - "serverConnectionId", - mongoc_apm_command_started_get_server_connection_id_int64 (apm_command)); - - { - const bson_oid_t *const service_id = - mongoc_apm_command_started_get_service_id (apm_command); - - if (service_id) { - BSON_APPEND_OID (doc, "serviceId", service_id); - } - } -} - - -static void -store_event_serialize_failed (bson_t *doc, - const mongoc_apm_command_failed_t *apm_command) -{ - BSON_APPEND_INT64 ( - doc, "duration", mongoc_apm_command_failed_get_duration (apm_command)); - - BSON_APPEND_UTF8 (doc, - "commandName", - mongoc_apm_command_failed_get_command_name (apm_command)); - - { - bson_error_t error; - mongoc_apm_command_failed_get_error (apm_command, &error); - BSON_APPEND_UTF8 (doc, "failure", error.message); - } - - BSON_APPEND_INT64 ( - doc, "requestId", mongoc_apm_command_failed_get_request_id (apm_command)); - - BSON_APPEND_INT64 (doc, - "operationId", - mongoc_apm_command_failed_get_operation_id (apm_command)); - - BSON_APPEND_UTF8 ( - doc, - "connectionId", - mongoc_apm_command_failed_get_host (apm_command)->host_and_port); - - BSON_APPEND_INT64 ( - doc, - "serverConnectionId", - mongoc_apm_command_failed_get_server_connection_id_int64 (apm_command)); - - { - const bson_oid_t *const service_id = - mongoc_apm_command_failed_get_service_id (apm_command); - - if (service_id) { - BSON_APPEND_OID (doc, "serviceId", service_id); - } - } -} - - -static void -store_event_serialize_succeeded ( - bson_t *doc, const mongoc_apm_command_succeeded_t *apm_command) -{ - BSON_APPEND_INT64 ( - doc, "duration", mongoc_apm_command_succeeded_get_duration (apm_command)); - - // Spec: The test runner MAY omit the command field for CommandStartedEvent - // and reply field for CommandSucceededEvent. - // BSON_APPEND_DOCUMENT ( - // doc, "reply", mongoc_apm_command_succeeded_get_reply (apm_command)); - - BSON_APPEND_UTF8 ( - doc, - "commandName", - mongoc_apm_command_succeeded_get_command_name (apm_command)); - - BSON_APPEND_INT64 ( - doc, - "requestId", - mongoc_apm_command_succeeded_get_request_id (apm_command)); - - BSON_APPEND_INT64 ( - doc, - "operationId", - mongoc_apm_command_succeeded_get_operation_id (apm_command)); - - BSON_APPEND_UTF8 ( - doc, - "connectionId", - mongoc_apm_command_succeeded_get_host (apm_command)->host_and_port); - - BSON_APPEND_INT64 ( - doc, - "serverConnectionId", - mongoc_apm_command_succeeded_get_server_connection_id_int64 ( - apm_command)); - - { - const bson_oid_t *const service_id = - mongoc_apm_command_succeeded_get_service_id (apm_command); - - if (service_id) { - BSON_APPEND_OID (doc, "serviceId", service_id); - } - } -} - - -static void -store_event_to_entities (entity_t *entity, - command_callback_funcs_t funcs, - const char *type, - const void *apm_command) -{ - BSON_ASSERT_PARAM (entity); - BSON_ASSERT_PARAM (type); - - BSON_ASSERT (entity->entity_map); - - entity_map_t *const em = entity->entity_map; - - store_event_t *const begin = (store_event_t *) entity->store_events.data; - store_event_t *const end = begin + entity->store_events.len; - - const int64_t usecs = usecs_since_epoch (); - const double secs = (double) usecs / 1000000.0; - - bson_error_t error = {0}; - - for (store_event_t *iter = begin; iter != end; ++iter) { - if (bson_strcasecmp (iter->type, type) == 0) { - mongoc_array_t *arr = - entity_map_get_bson_array (em, iter->entity_id, &error); - ASSERT_OR_PRINT (arr, error); - - bson_t *doc = bson_new (); - - // Spec: the following fields MUST be stored with each event document: - BSON_APPEND_UTF8 (doc, "name", type); - BSON_APPEND_DOUBLE (doc, "observedAt", secs); - - // The event subscriber MUST serialize the events it receives into a - // document, using the documented properties of the event as field - // names, and append the document to the list stored in the specified - // entity. - funcs.serialize (doc, apm_command); - - _mongoc_array_append_val (arr, doc); // Transfer ownership. - } - } -} - - -static void -apm_command_callback (command_callback_funcs_t funcs, - const char *type, - const void *apm_command) -{ - BSON_ASSERT_PARAM (type); - BSON_ASSERT_PARAM (apm_command); - - BSON_ASSERT (funcs.get_context); - entity_t *const entity = (entity_t *) funcs.get_context (apm_command); - - observe_event (entity, funcs, type, apm_command); - store_event_to_entities (entity, funcs, type, apm_command); -} - - -static void -command_started (const mongoc_apm_command_started_t *started) -{ - command_callback_funcs_t funcs = { - .get_context = (apm_func_void_t) mongoc_apm_command_started_get_context, - .get_command = (apm_func_bson_t) mongoc_apm_command_started_get_command, - .get_reply = NULL, - .get_command_name = - (apm_func_utf8_t) mongoc_apm_command_started_get_command_name, - .get_database_name = - (apm_func_utf8_t) mongoc_apm_command_started_get_database_name, - .get_request_id = - (apm_func_int64_t) mongoc_apm_command_started_get_request_id, - .get_operation_id = - (apm_func_int64_t) mongoc_apm_command_started_get_operation_id, - .get_service_id = - (apm_func_bson_oid_t) mongoc_apm_command_started_get_service_id, - .get_host = (apm_func_host_list_t) mongoc_apm_command_started_get_host, - .get_server_connection_id = (apm_func_int64_t) - mongoc_apm_command_started_get_server_connection_id_int64, - .serialize = (apm_func_serialize_t) store_event_serialize_started, - }; - - apm_command_callback (funcs, "commandStartedEvent", started); -} - -static void -command_failed (const mongoc_apm_command_failed_t *failed) -{ - command_callback_funcs_t funcs = { - .get_context = (apm_func_void_t) mongoc_apm_command_failed_get_context, - .get_command = NULL, - .get_reply = (apm_func_bson_t) mongoc_apm_command_failed_get_reply, - .get_command_name = - (apm_func_utf8_t) mongoc_apm_command_failed_get_command_name, - .get_database_name = NULL, - .get_request_id = - (apm_func_int64_t) mongoc_apm_command_failed_get_request_id, - .get_operation_id = - (apm_func_int64_t) mongoc_apm_command_failed_get_operation_id, - .get_service_id = - (apm_func_bson_oid_t) mongoc_apm_command_failed_get_service_id, - .get_host = (apm_func_host_list_t) mongoc_apm_command_failed_get_host, - .get_server_connection_id = (apm_func_int64_t) - mongoc_apm_command_failed_get_server_connection_id_int64, - .serialize = (apm_func_serialize_t) store_event_serialize_failed, - }; - - apm_command_callback (funcs, "commandFailedEvent", failed); -} - -static void -command_succeeded (const mongoc_apm_command_succeeded_t *succeeded) -{ - command_callback_funcs_t funcs = { - .get_context = (apm_func_void_t) mongoc_apm_command_succeeded_get_context, - .get_command = NULL, - .get_reply = (apm_func_bson_t) mongoc_apm_command_succeeded_get_reply, - .get_command_name = - (apm_func_utf8_t) mongoc_apm_command_succeeded_get_command_name, - .get_database_name = NULL, - .get_request_id = - (apm_func_int64_t) mongoc_apm_command_succeeded_get_request_id, - .get_operation_id = - (apm_func_int64_t) mongoc_apm_command_succeeded_get_operation_id, - .get_service_id = - (apm_func_bson_oid_t) mongoc_apm_command_succeeded_get_service_id, - .get_host = (apm_func_host_list_t) mongoc_apm_command_succeeded_get_host, - .get_server_connection_id = (apm_func_int64_t) - mongoc_apm_command_succeeded_get_server_connection_id_int64, - .serialize = (apm_func_serialize_t) store_event_serialize_succeeded, - }; - - apm_command_callback (funcs, "commandSucceededEvent", succeeded); -} - -// Note: multiple invocations of this function is okay, since all it does -// is set the appropriate pointer in `callbacks`, and the callback function(s) -// being used is always the same for a given type. -static void -set_command_callback (mongoc_apm_callbacks_t *callbacks, const char *type) -{ - typedef void (*cb_t) (const void *); - typedef void (*set_func_t) (mongoc_apm_callbacks_t *, cb_t); - - typedef struct _command_to_cb_t { - const char *type; - set_func_t set; - cb_t cb; - } command_to_cb_t; - - const command_to_cb_t commands[] = { - {.type = "commandStartedEvent", - .set = (set_func_t) mongoc_apm_set_command_started_cb, - .cb = (cb_t) command_started}, - {.type = "commandFailedEvent", - .set = (set_func_t) mongoc_apm_set_command_failed_cb, - .cb = (cb_t) command_failed}, - {.type = "commandSucceededEvent", - .set = (set_func_t) mongoc_apm_set_command_succeeded_cb, - .cb = (cb_t) command_succeeded}, - {.type = NULL, .set = NULL, .cb = NULL}, - }; - - for (const command_to_cb_t *iter = commands; iter->type; ++iter) { - if (bson_strcasecmp (type, iter->type) == 0) { - iter->set (callbacks, iter->cb); - return; - } - } -} - -static void -add_observe_event (entity_t *entity, const char *type) -{ - observe_event_t event = {.type = type}; - - _mongoc_array_append_val (&entity->observe_events, event); -} - -static void -add_store_event (entity_t *entity, const char *type, const char *entity_id) -{ - store_event_t event = {.type = type, .entity_id = entity_id}; - - _mongoc_array_append_val (&entity->store_events, event); -} - - -entity_t * -entity_client_new (entity_map_t *em, bson_t *bson, bson_error_t *error) -{ - entity_t *entity = NULL; - mongoc_client_t *client = NULL; - mongoc_uri_t *uri = NULL; - bool ret = false; - mongoc_apm_callbacks_t *callbacks = NULL; - bson_t *uri_options = NULL; - bool use_multiple_mongoses = false; - bool use_multiple_mongoses_set = false; - bool can_reduce_heartbeat = false; - mongoc_server_api_t *api = NULL; - char *errpath = NULL; - char *err = NULL; - const char *store_entity_id = NULL; - - entity = entity_new (em, "client"); - callbacks = mongoc_apm_callbacks_new (); - - bsonParse ( // - *bson, - // All clients require an ID string - find (keyWithType ("id", utf8), storeStrDup (entity->id)), - else (error ("A client 'id' string is required")), - // Optional 'uriOptions' for the client - find (key ("uriOptions"), - if (not(type (doc)), - then (error ("'uriOptions' must be a document value"))), - storeDocDupPtr (uri_options)), - // Optional 'useMultipleMongoses' bool - find (key ("useMultipleMongoses"), - if (not(type (bool)), - then (error ("'useMultipleMongoses' must be a bool value"))), - do (use_multiple_mongoses_set = true), - storeBool (use_multiple_mongoses)), - // Events to observe: - find (key ("observeEvents"), - if (not(type (array)), - then (error ("'observeEvents' must be an array"))), - visitEach (case ( - // Ensure all elements are strings: - when (not(type (utf8)), - error ("Every 'observeEvents' element must be a string")), - // Dispatch based on the event name: - when (anyOf (iStrEqual ("commandStartedEvent"), - iStrEqual ("commandFailedEvent"), - iStrEqual ("commandSucceededEvent")), - do ({ - const char *const type = - bson_iter_utf8 (&bsonVisitIter, NULL); - set_command_callback (callbacks, type); - add_observe_event (entity, type); - })), - // Unsupported (but known) event names: - when (eval (is_unsupported_event_type ( - bson_iter_utf8 (&bsonVisitIter, NULL))), - do (MONGOC_DEBUG ("Skipping unsupported event type '%s'", - bsonAs (cstr)))), - // An unknown event name is a hard-error: - else (do ( - test_error ("Unknown event type '%s'", bsonAs (cstr))))))), - // Command events to ignore - find ( - key ("ignoreCommandMonitoringEvents"), - if (not(type (array)), - then (error ("'ignoreCommandMonitoringEvents' must be an array"))), - visitEach (if (not(type (utf8)), - then (error ("Every 'ignoreCommandMonitoringEvents' " - "element must be a string")))), - storeDocDupPtr (entity->ignore_command_monitoring_events)), - // Parse the serverApi, if present - find ( - key ("serverApi"), - if (not(type (doc)), then (error ("'serverApi' must be a document"))), - parse ( // The "version" string is required first: - find (keyWithType ("version", utf8), do ({ - mongoc_server_api_version_t ver; - if (!mongoc_server_api_version_from_string (bsonAs (cstr), - &ver)) { - bsonParseError = "Invalid serverApi.version string"; - } else { - api = mongoc_server_api_new (ver); - } - })), - else (error ("Missing 'version' property in 'serverApi' object")), - // Toggle strictness: - find (key ("strict"), - if (not(type (bool)), - then (error ("'serverApi.strict' must be a bool"))), - do (mongoc_server_api_strict (api, bsonAs (bool)))), - // Toggle deprecation errors: - find ( - key ("deprecationErrors"), - if (not(type (bool)), - then (error ("serverApi.deprecationErrors must be a bool"))), - do ( - mongoc_server_api_deprecation_errors (api, bsonAs (bool)))))), - // Toggle observation of sensitive commands - find (key ("observeSensitiveCommands"), - if (not(type (bool)), - then (error ("'observeSensitiveCommands' must be a bool"))), - do ({ - bool *p = entity->observe_sensitive_commands = - bson_malloc (sizeof (bool)); - *p = bsonAs (bool); - })), - // Which events should be available as entities: - find ( - key ("storeEventsAsEntities"), - if (not(type (array)), - then (error ("'storeEventsAsEntities' must be an array"))), - visitEach (parse ( - find (keyWithType ("id", utf8), storeStrRef (store_entity_id), do ({ - if (!entity_map_add_bson_array ( - em, store_entity_id, error)) { - test_error ("failed to create storeEventsAsEntities " - "entity '%s': %s", - store_entity_id, - error->message); - } - })), - find (keyWithType ("events", array), - visitEach (case ( - when (not(type (utf8)), - error ("Every 'storeEventsAsEntities.events' " - "element must be a string")), - when (anyOf (iStrEqual ("commandStartedEvent"), - iStrEqual ("commandFailedEvent"), - iStrEqual ("commandSucceededEvent")), - do ({ - const char *const type = - bson_iter_utf8 (&bsonVisitIter, NULL); - set_command_callback (callbacks, type); - add_store_event (entity, type, store_entity_id); - })), - when (eval (is_unsupported_event_type ( - bson_iter_utf8 (&bsonVisitIter, NULL))), - do (MONGOC_DEBUG ( - "Skipping unsupported event type '%s'", - bsonAs (cstr)))), - else (do (test_error ("Unknown event type '%s'", - bsonAs (cstr))))))), - visitOthers ( - errorf (err, - "Unexpected field '%s' in storeEventsAsEntities", - bson_iter_key (&bsonVisitIter)))))), - visitOthers (dupPath (errpath), - errorf (err, - "At [%s]: Unknown key '%s' given in entity options", - errpath, - bson_iter_key (&bsonVisitIter)))); - - if (bsonParseError) { - test_error ("Error while parsing entity object: %s", bsonParseError); - } - - /* Build the client's URI. */ - uri = test_framework_get_uri (); - /* Apply "useMultipleMongoses" rules to URI. - * If useMultipleMongoses is true, modify the connection string to add a - * host. If useMultipleMongoses is false, require that the connection string - * has one host. If useMultipleMongoses unspecified, make no assertion. - */ - if (test_framework_is_loadbalanced ()) { - /* Quoting the unified test runner specification: - * If the topology type is LoadBalanced, [...] If useMultipleMongoses is - * true or unset, the test runner MUST use the URI of the load balancer - * fronting multiple servers. Otherwise, the test runner MUST use the URI - * of the load balancer fronting a single server. - */ - if (!use_multiple_mongoses_set || use_multiple_mongoses == true) { - mongoc_uri_destroy (uri); - uri = test_framework_get_uri_multi_mongos_loadbalanced (); - } - } else if (use_multiple_mongoses_set) { - if (!test_framework_uri_apply_multi_mongos ( - uri, use_multiple_mongoses, error)) { - goto done; - } - } - - if (uri_options) { - /* Apply URI options. */ - if (!uri_apply_options (uri, uri_options, error)) { - goto done; - } - } - - if (!mongoc_uri_has_option (uri, MONGOC_URI_HEARTBEATFREQUENCYMS)) { - can_reduce_heartbeat = true; - } - - if (can_reduce_heartbeat && em->reduced_heartbeat) { - mongoc_uri_set_option_as_int32 ( - uri, MONGOC_URI_HEARTBEATFREQUENCYMS, REDUCED_HEARTBEAT_FREQUENCY_MS); - } - - client = test_framework_client_new_from_uri (uri, api); - test_framework_set_ssl_opts (client); - mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2); - entity->value = client; - mongoc_client_set_apm_callbacks (client, callbacks, entity); - - if (can_reduce_heartbeat && em->reduced_heartbeat) { - client->topology->min_heartbeat_frequency_msec = - REDUCED_MIN_HEARTBEAT_FREQUENCY_MS; - } - - ret = true; -done: - mongoc_uri_destroy (uri); - mongoc_apm_callbacks_destroy (callbacks); - mongoc_server_api_destroy (api); - bson_destroy (uri_options); - if (!ret) { - entity_destroy (entity); - return NULL; - } - return entity; -} - -static char * -_entity_client_encryption_getenv (const char *name, bson_error_t *error) -{ - char *res = NULL; - - BSON_ASSERT_PARAM (name); - - if (!(res = _mongoc_getenv (name))) { - test_set_error ( - error, "missing required environment variable '%s'", name); - } - - return res; -} - -static bool -_append_kms_provider_value_or_getenv (bson_t *bson, - const char *key, - const char *value, - const char *env_name, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (bson); - BSON_ASSERT_PARAM (env_name); - - /* Prefer explicit value if available. */ - if (value) { - BSON_ASSERT (BSON_APPEND_UTF8 (bson, key, value)); - return true; - } - - /* Fallback to environment variable. */ - { - char *const env_var = _entity_client_encryption_getenv (env_name, error); - - if (env_var) { - BSON_ASSERT (BSON_APPEND_UTF8 (bson, key, env_var)); - bson_free (env_var); - return true; - } - } - - return false; -} - -static bool -_validate_string_or_placeholder (const bson_iter_t *iter, bson_error_t *error) -{ - BSON_ASSERT_PARAM (iter); - - /* Holds a UTF-8 string. */ - if (BSON_ITER_HOLDS_UTF8 (iter)) { - return true; - } - - /* Otherwise, must be a document with a single '$$placeholder' field. */ - if (BSON_ITER_HOLDS_DOCUMENT (iter)) { - bson_val_t *const bson_val = bson_val_from_iter (iter); - bson_val_t *const expected = - bson_val_from_json ("{'$$placeholder': { '$exists': true }}"); - bool is_match = false; - - BSON_ASSERT (bson_val); - BSON_ASSERT (expected); - - is_match = bson_match (expected, bson_val, false, error); - - bson_val_destroy (bson_val); - bson_val_destroy (expected); - - if (is_match) { - return true; - } - } - - test_set_error (error, "expected string or placeholder value"); - - return false; -} - -static bool -_parse_kms_provider_aws (bson_t *kms_providers, - bson_t *tls_opts, - const char *provider, - bson_t *kms_doc, - bson_error_t *error) -{ - bson_t child; - bson_iter_t iter; - - BSON_UNUSED (tls_opts); - - BSON_ASSERT (BSON_APPEND_DOCUMENT_BEGIN (kms_providers, provider, &child)); - - BSON_FOREACH (kms_doc, iter) - { - const char *const key = bson_iter_key (&iter); - const char *const value = bson_iter_utf8 (&iter, NULL); - - if (!_validate_string_or_placeholder (&iter, error)) { - return false; - } - - if (strcmp (key, "accessKeyId") == 0) { - const char *envvar = "MONGOC_TEST_AWS_ACCESS_KEY_ID"; - if (0 == strcmp (provider, "aws:name2")) { - envvar = "MONGOC_TEST_AWSNAME2_ACCESS_KEY_ID"; - } - if (!_append_kms_provider_value_or_getenv ( - &child, key, value, envvar, error)) { - return false; - } - } else if (strcmp (key, "secretAccessKey") == 0) { - const char *envvar = "MONGOC_TEST_AWS_SECRET_ACCESS_KEY"; - if (0 == strcmp (provider, "aws:name2")) { - envvar = "MONGOC_TEST_AWSNAME2_SECRET_ACCESS_KEY"; - } - if (!_append_kms_provider_value_or_getenv ( - &child, key, value, envvar, error)) { - return false; - } - } else { - test_set_error (error, "unexpected field '%s'", key); - return false; - } - } - - BSON_ASSERT (bson_append_document_end (kms_providers, &child)); - - return true; -} - -static bool -_parse_kms_provider_azure (bson_t *kms_providers, - bson_t *tls_opts, - const char *provider, - bson_t *kms_doc, - bson_error_t *error) -{ - bson_t child; - bson_iter_t iter; - - BSON_UNUSED (tls_opts); - - BSON_ASSERT (BSON_APPEND_DOCUMENT_BEGIN (kms_providers, provider, &child)); - - BSON_FOREACH (kms_doc, iter) - { - const char *const key = bson_iter_key (&iter); - const char *const value = bson_iter_utf8 (&iter, NULL); - - if (!_validate_string_or_placeholder (&iter, error)) { - return false; - } - - if (strcmp (key, "tenantId") == 0) { - if (!_append_kms_provider_value_or_getenv ( - &child, key, value, "MONGOC_TEST_AZURE_TENANT_ID", error)) { - return false; - } - } else if (strcmp (key, "clientId") == 0) { - if (!_append_kms_provider_value_or_getenv ( - &child, key, value, "MONGOC_TEST_AZURE_CLIENT_ID", error)) { - return false; - } - } else if (strcmp (key, "clientSecret") == 0) { - if (!_append_kms_provider_value_or_getenv ( - &child, key, value, "MONGOC_TEST_AZURE_CLIENT_SECRET", error)) { - return false; - } - } else { - test_set_error (error, "unexpected field '%s'", value); - return false; - } - } - - BSON_ASSERT (bson_append_document_end (kms_providers, &child)); - - return true; -} - -static bool -_parse_kms_provider_gcp (bson_t *kms_providers, - bson_t *tls_opts, - const char *provider, - bson_t *kms_doc, - bson_error_t *error) -{ - bson_t child; - bson_iter_t iter; - - BSON_UNUSED (tls_opts); - - BSON_ASSERT (BSON_APPEND_DOCUMENT_BEGIN (kms_providers, provider, &child)); - - BSON_FOREACH (kms_doc, iter) - { - const char *const key = bson_iter_key (&iter); - const char *const value = bson_iter_utf8 (&iter, NULL); - - if (!_validate_string_or_placeholder (&iter, error)) { - return false; - } - - if (strcmp (key, "email") == 0) { - if (!_append_kms_provider_value_or_getenv ( - &child, key, value, "MONGOC_TEST_GCP_EMAIL", error)) { - return false; - } - } else if (strcmp (key, "privateKey") == 0) { - if (!_append_kms_provider_value_or_getenv ( - &child, key, value, "MONGOC_TEST_GCP_PRIVATEKEY", error)) { - return false; - } - } else if (strcmp (key, "endpoint") == 0) { - if (value) { - BSON_ASSERT (BSON_APPEND_UTF8 (&child, key, value)); - } - } else { - test_set_error (error, "unexpected field '%s'", value); - return false; - } - } - - BSON_ASSERT (bson_append_document_end (kms_providers, &child)); - - return true; -} - -static bool -_parse_kms_provider_kmip (bson_t *kms_providers, - bson_t *tls_opts, - const char *provider, - bson_t *kms_doc, - bson_error_t *error) -{ - bson_t child; - bson_iter_t iter; - - BSON_ASSERT (BSON_APPEND_DOCUMENT_BEGIN (kms_providers, provider, &child)); - - BSON_FOREACH (kms_doc, iter) - { - const char *const key = bson_iter_key (&iter); - const char *const value = bson_iter_utf8 (&iter, NULL); - - if (!_validate_string_or_placeholder (&iter, error)) { - return false; - } - - if (strcmp (key, "endpoint") == 0) { - if (value) { - BSON_ASSERT (BSON_APPEND_UTF8 (&child, key, value)); - } else { - /* Expect KMIP test server running on port 5698. */ - BSON_ASSERT (BSON_APPEND_UTF8 (&child, key, "localhost:5698")); - } - - /* Configure tlsOptions to enable KMIP TLS connections. */ - { - bson_t tls_child; - BSON_ASSERT ( - BSON_APPEND_DOCUMENT_BEGIN (tls_opts, provider, &tls_child)); - if (!_append_kms_provider_value_or_getenv ( - &tls_child, - "tlsCAFile", - NULL, - "MONGOC_TEST_CSFLE_TLS_CA_FILE", - error)) { - return false; - } - if (!_append_kms_provider_value_or_getenv ( - &tls_child, - "tlsCertificateKeyFile", - NULL, - "MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE", - error)) { - return false; - } - BSON_ASSERT (bson_append_document_end (tls_opts, &tls_child)); - } - } else { - test_set_error (error, "unexpected field '%s'", value); - return false; - } - } - - BSON_ASSERT (bson_append_document_end (kms_providers, &child)); - - return true; -} - -static bool -_parse_kms_provider_local (bson_t *kms_providers, - bson_t *tls_opts, - const char *provider, - bson_t *kms_doc, - bson_error_t *error) -{ - bson_t child; - bson_iter_t iter; - - BSON_UNUSED (tls_opts); - - BSON_ASSERT (BSON_APPEND_DOCUMENT_BEGIN (kms_providers, provider, &child)); - - BSON_FOREACH (kms_doc, iter) - { - const char *const key = bson_iter_key (&iter); - const char *const value = bson_iter_utf8 (&iter, NULL); - - if (!_validate_string_or_placeholder (&iter, error)) { - return false; - } - - if (strcmp (key, "key") == 0) { - if (value) { - BSON_ASSERT (BSON_APPEND_UTF8 (&child, key, value)); - } else { - /* LOCAL_MASTERKEY in base64 encoding as defined in Client Side - * Encryption Tests spec. */ - const char local_masterkey[] = - "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6N" - "mdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZG" - "JkTXVyZG9uSjFk"; - uint8_t data[96]; - BSON_ASSERT (mcommon_b64_pton (local_masterkey, - data, - sizeof (local_masterkey)) == 96); - BSON_APPEND_BINARY (&child, "key", BSON_SUBTYPE_BINARY, data, 96); - } - } else { - test_set_error (error, "unexpected field '%s'", value); - return false; - } - } - - BSON_ASSERT (bson_append_document_end (kms_providers, &child)); - - return true; -} - -static bool -_parse_and_set_kms_providers (mongoc_client_encryption_opts_t *ce_opts, - bson_t *kms_from_file, - bson_error_t *error) -{ - /* Map provider to corresponding KMS parser. */ - typedef struct _prov_map_t { - const char *provider; - bool (*parse) (bson_t *kms_providers, - bson_t *tls_opts, - const char *provider, - bson_t *kms_doc, - bson_error_t *error); - } prov_map_t; - - const prov_map_t prov_map[] = { - {.provider = "aws", .parse = _parse_kms_provider_aws}, - {.provider = "aws:name1", .parse = _parse_kms_provider_aws}, - {.provider = "aws:name2", .parse = _parse_kms_provider_aws}, - {.provider = "azure", .parse = _parse_kms_provider_azure}, - {.provider = "azure:name1", .parse = _parse_kms_provider_azure}, - {.provider = "gcp", .parse = _parse_kms_provider_gcp}, - {.provider = "gcp:name1", .parse = _parse_kms_provider_gcp}, - {.provider = "kmip", .parse = _parse_kms_provider_kmip}, - {.provider = "kmip:name1", .parse = _parse_kms_provider_kmip}, - {.provider = "local", .parse = _parse_kms_provider_local}, - {.provider = "local:name1", .parse = _parse_kms_provider_local}, - {.provider = "local:name2", .parse = _parse_kms_provider_local}}; - - const size_t prov_map_size = sizeof (prov_map) / sizeof (prov_map[0]); - - bool ret = false; - bson_t kms_providers = BSON_INITIALIZER; - bson_t tls_opts = BSON_INITIALIZER; - bson_iter_t iter; - - BSON_FOREACH (kms_from_file, iter) - { - const char *const provider = bson_iter_key (&iter); - bson_t kms_doc; - size_t i = 0u; - bool found = false; - - if (!bson_init_from_value (&kms_doc, bson_iter_value (&iter))) { - test_set_error ( - error, "kmsProviders field '%s' is not a valid document", provider); - goto done; - } - - for (i = 0u; i < prov_map_size; ++i) { - if (strcmp (provider, prov_map[i].provider) == 0) { - found = prov_map[i].parse ( - &kms_providers, &tls_opts, provider, &kms_doc, error); - goto parsed; - } - } - - test_set_error (error, "unexpected KMS provider '%s'", provider); - - parsed: - bson_destroy (&kms_doc); - - if (!found) { - goto done; - } - } - - mongoc_client_encryption_opts_set_kms_providers (ce_opts, &kms_providers); - mongoc_client_encryption_opts_set_tls_opts (ce_opts, &tls_opts); - - ret = true; - -done: - bson_destroy (&kms_providers); - bson_destroy (&tls_opts); - - return ret; -} - -entity_t * -entity_client_encryption_new (entity_map_t *entity_map, - bson_t *bson, - bson_error_t *error) -{ - entity_t *const entity = entity_new (entity_map, "clientEncryption"); - bson_parser_t *const parser = bson_parser_new (); - mongoc_client_encryption_opts_t *const ce_opts = - mongoc_client_encryption_opts_new (); - - bson_t *ce_opts_bson = NULL; - - bson_parser_utf8 (parser, "id", &entity->id); - bson_parser_doc (parser, "clientEncryptionOpts", &ce_opts_bson); - - if (!bson_parser_parse (parser, bson, error)) { - goto done; - } - - { - bson_parser_t *const ce_opts_parser = bson_parser_new (); - - bool ce_opts_success = false; - char *client_id = NULL; - char *kv_ns = NULL; - bson_t *kms = NULL; - - bson_parser_utf8 (ce_opts_parser, "keyVaultClient", &client_id); - bson_parser_utf8 (ce_opts_parser, "keyVaultNamespace", &kv_ns); - bson_parser_doc (ce_opts_parser, "kmsProviders", &kms); - - if (!bson_parser_parse (ce_opts_parser, ce_opts_bson, error)) { - goto ce_opts_done; - } - - { - entity_t *const client_entity = - entity_map_get (entity_map, client_id, error); - mongoc_client_t *client = NULL; - - if (!client_entity) { - goto ce_opts_done; - } - - BSON_ASSERT ((client = (mongoc_client_t *) client_entity->value)); - - mongoc_client_encryption_opts_set_keyvault_client (ce_opts, client); - } - - { - char *const dot = strchr (kv_ns, '.'); - const char *db = NULL; - const char *coll = NULL; - - if (!dot) { - test_set_error ( - error, "keyVaultNamespace does not have required dot separator"); - goto ce_opts_done; - } - - *dot = '\0'; /* e.g. "keyvault.datakeys" -> "keyvault\0datakeys". */ - db = kv_ns; /* "keyvault" (due to null terminator) */ - coll = dot + 1; /* "datakeys" */ - - if (strchr (coll, '.') != NULL) { - test_set_error ( - error, "keyVaultNamespace contains more than one dot separator"); - goto ce_opts_done; - } - - mongoc_client_encryption_opts_set_keyvault_namespace ( - ce_opts, db, coll); - } - - if (!_parse_and_set_kms_providers (ce_opts, kms, error)) { - goto ce_opts_done; - } - - ce_opts_success = true; - - ce_opts_done: - bson_parser_destroy_with_parsed_fields (ce_opts_parser); - - if (!ce_opts_success) { - goto done; - } - } - - entity->value = mongoc_client_encryption_new (ce_opts, error); - -done: - mongoc_client_encryption_opts_destroy (ce_opts); - bson_destroy (ce_opts_bson); - bson_parser_destroy (parser); - - if (!entity->value) { - entity_destroy (entity); - return NULL; - } - - return entity; -} - -typedef struct { - mongoc_read_concern_t *rc; - mongoc_write_concern_t *wc; - mongoc_read_prefs_t *rp; -} coll_or_db_opts_t; - -static coll_or_db_opts_t * -coll_or_db_opts_new (void) -{ - return bson_malloc0 (sizeof (coll_or_db_opts_t)); -} - -static void -coll_or_db_opts_destroy (coll_or_db_opts_t *opts) -{ - if (!opts) { - return; - } - mongoc_read_concern_destroy (opts->rc); - mongoc_read_prefs_destroy (opts->rp); - mongoc_write_concern_destroy (opts->wc); - bson_free (opts); -} - -static bool -coll_or_db_opts_parse (coll_or_db_opts_t *opts, bson_t *in, bson_error_t *error) -{ - bson_parser_t *parser = NULL; - bool ret = false; - - parser = bson_parser_new (); - bson_parser_read_concern_optional (parser, &opts->rc); - bson_parser_read_prefs_optional (parser, &opts->rp); - bson_parser_write_concern_optional (parser, &opts->wc); - if (!bson_parser_parse (parser, in, error)) { - goto done; - } - - ret = true; -done: - bson_parser_destroy (parser); - return ret; -} - -entity_t * -entity_database_new (entity_map_t *entity_map, - bson_t *bson, - bson_error_t *error) -{ - bson_parser_t *parser = NULL; - entity_t *entity = NULL; - const entity_t *client_entity; - char *client_id = NULL; - mongoc_client_t *client = NULL; - mongoc_database_t *db = NULL; - char *database_name = NULL; - bool ret = false; - bson_t *database_opts = NULL; - coll_or_db_opts_t *coll_or_db_opts = NULL; - - entity = entity_new (entity_map, "database"); - parser = bson_parser_new (); - bson_parser_utf8 (parser, "id", &entity->id); - bson_parser_utf8 (parser, "client", &client_id); - bson_parser_utf8 (parser, "databaseName", &database_name); - bson_parser_doc_optional (parser, "databaseOptions", &database_opts); - - if (!bson_parser_parse (parser, bson, error)) { - goto done; - } - - client_entity = entity_map_get (entity_map, client_id, error); - if (!client_entity) { - goto done; - } - - client = (mongoc_client_t *) client_entity->value; - db = mongoc_client_get_database (client, database_name); - entity->value = (void *) db; - - if (database_opts) { - coll_or_db_opts = coll_or_db_opts_new (); - if (!coll_or_db_opts_parse (coll_or_db_opts, database_opts, error)) { - goto done; - } - if (coll_or_db_opts->rc) { - mongoc_database_set_read_concern (db, coll_or_db_opts->rc); - } - if (coll_or_db_opts->rp) { - mongoc_database_set_read_prefs (db, coll_or_db_opts->rp); - } - if (coll_or_db_opts->wc) { - mongoc_database_set_write_concern (db, coll_or_db_opts->wc); - } - } - - ret = true; -done: - bson_free (client_id); - bson_free (database_name); - bson_parser_destroy (parser); - bson_destroy (database_opts); - coll_or_db_opts_destroy (coll_or_db_opts); - if (!ret) { - entity_destroy (entity); - return NULL; - } - return entity; -} - -entity_t * -entity_collection_new (entity_map_t *entity_map, - bson_t *bson, - bson_error_t *error) -{ - bson_parser_t *parser = NULL; - entity_t *entity = NULL; - entity_t *database_entity = NULL; - mongoc_database_t *database = NULL; - mongoc_collection_t *coll = NULL; - bool ret = false; - char *database_id = NULL; - char *collection_name = NULL; - bson_t *collection_opts = NULL; - coll_or_db_opts_t *coll_or_db_opts = NULL; - - entity = entity_new (entity_map, "collection"); - parser = bson_parser_new (); - bson_parser_utf8 (parser, "id", &entity->id); - bson_parser_utf8 (parser, "database", &database_id); - bson_parser_utf8 (parser, "collectionName", &collection_name); - bson_parser_doc_optional (parser, "collectionOptions", &collection_opts); - if (!bson_parser_parse (parser, bson, error)) { - goto done; - } - - database_entity = entity_map_get (entity_map, database_id, error); - if (!database_entity) { - goto done; - } - database = (mongoc_database_t *) database_entity->value; - coll = mongoc_database_get_collection (database, collection_name); - entity->value = (void *) coll; - if (collection_opts) { - coll_or_db_opts = coll_or_db_opts_new (); - if (!coll_or_db_opts_parse (coll_or_db_opts, collection_opts, error)) { - goto done; - } - if (coll_or_db_opts->rc) { - mongoc_collection_set_read_concern (coll, coll_or_db_opts->rc); - } - if (coll_or_db_opts->rp) { - mongoc_collection_set_read_prefs (coll, coll_or_db_opts->rp); - } - if (coll_or_db_opts->wc) { - mongoc_collection_set_write_concern (coll, coll_or_db_opts->wc); - } - } - ret = true; -done: - bson_free (collection_name); - bson_free (database_id); - bson_parser_destroy (parser); - bson_destroy (collection_opts); - coll_or_db_opts_destroy (coll_or_db_opts); - if (!ret) { - entity_destroy (entity); - return NULL; - } - return entity; -} - -mongoc_session_opt_t * -session_opts_new (bson_t *bson, bson_error_t *error) -{ - bool ret = false; - mongoc_session_opt_t *opts = NULL; - bson_parser_t *bp = NULL; - bson_parser_t *bp_opts = NULL; - bool *causal_consistency = NULL; - bool *snapshot = NULL; - bson_t *default_transaction_opts = NULL; - mongoc_write_concern_t *wc = NULL; - mongoc_read_concern_t *rc = NULL; - mongoc_read_prefs_t *rp = NULL; - mongoc_transaction_opt_t *topts = NULL; - - bp = bson_parser_new (); - bson_parser_bool_optional (bp, "causalConsistency", &causal_consistency); - bson_parser_bool_optional (bp, "snapshot", &snapshot); - bson_parser_doc_optional ( - bp, "defaultTransactionOptions", &default_transaction_opts); - if (!bson_parser_parse (bp, bson, error)) { - goto done; - } - - opts = mongoc_session_opts_new (); - if (causal_consistency) { - mongoc_session_opts_set_causal_consistency (opts, *causal_consistency); - } - if (snapshot) { - mongoc_session_opts_set_snapshot (opts, *snapshot); - } - - if (default_transaction_opts) { - bp_opts = bson_parser_new (); - topts = mongoc_transaction_opts_new (); - - bson_parser_write_concern_optional (bp_opts, &wc); - bson_parser_read_concern_optional (bp_opts, &rc); - bson_parser_read_prefs_optional (bp_opts, &rp); - if (!bson_parser_parse (bp_opts, default_transaction_opts, error)) { - goto done; - } - - if (wc) { - mongoc_transaction_opts_set_write_concern (topts, wc); - } - - if (rc) { - mongoc_transaction_opts_set_read_concern (topts, rc); - } - - if (rp) { - mongoc_transaction_opts_set_read_prefs (topts, rp); - } - - mongoc_session_opts_set_default_transaction_opts (opts, topts); - } - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (bp); - bson_parser_destroy_with_parsed_fields (bp_opts); - mongoc_transaction_opts_destroy (topts); - if (!ret) { - mongoc_session_opts_destroy (opts); - return NULL; - } - return opts; -} - -entity_t * -entity_session_new (entity_map_t *entity_map, bson_t *bson, bson_error_t *error) -{ - bson_parser_t *parser = NULL; - entity_t *entity = NULL; - entity_t *client_entity = NULL; - mongoc_client_t *client = NULL; - char *client_id = NULL; - bson_t *session_opts_bson = NULL; - mongoc_session_opt_t *session_opts = NULL; - bool ret = false; - mongoc_client_session_t *session = NULL; - - entity = entity_new (entity_map, "session"); - parser = bson_parser_new (); - bson_parser_utf8 (parser, "id", &entity->id); - bson_parser_utf8 (parser, "client", &client_id); - bson_parser_doc_optional (parser, "sessionOptions", &session_opts_bson); - if (!bson_parser_parse (parser, bson, error)) { - goto done; - } - - client_entity = entity_map_get (entity_map, client_id, error); - if (!client_entity) { - goto done; - } - client = (mongoc_client_t *) client_entity->value; - if (!client) { - goto done; - } - if (session_opts_bson) { - session_opts = session_opts_new (session_opts_bson, error); - if (!session_opts) { - goto done; - } - } - session = mongoc_client_start_session (client, session_opts, error); - if (!session) { - goto done; - } - entity->value = session; - /* Ending a session destroys the session object. - * After a session is ended, match assertions may be made on the lsid. - * So the lsid is copied from the session object on creation. */ - entity->lsid = bson_copy (mongoc_client_session_get_lsid (session)); - ret = true; - - entity->session_client_id = bson_strdup (client_id); -done: - mongoc_session_opts_destroy (session_opts); - bson_free (client_id); - bson_destroy (session_opts_bson); - bson_parser_destroy (parser); - if (!ret) { - entity_destroy (entity); - return NULL; - } - return entity; -} - -entity_t * -entity_bucket_new (entity_map_t *entity_map, bson_t *bson, bson_error_t *error) -{ - bson_parser_t *parser = NULL; - entity_t *entity = NULL; - mongoc_database_t *database = NULL; - char *database_id = NULL; - bool ret = false; - bson_t *bucket_opts_bson = NULL; - bson_parser_t *opts_parser = NULL; - mongoc_read_concern_t *rc = NULL; - mongoc_write_concern_t *wc = NULL; - bson_t *opts = NULL; - - entity = entity_new (entity_map, "bucket"); - parser = bson_parser_new (); - bson_parser_utf8 (parser, "id", &entity->id); - bson_parser_utf8 (parser, "database", &database_id); - bson_parser_doc_optional (parser, "bucketOptions", &bucket_opts_bson); - if (!bson_parser_parse (parser, bson, error)) { - goto done; - } - - database = entity_map_get_database (entity_map, database_id, error); - if (!database) { - goto done; - } - - opts_parser = bson_parser_new (); - bson_parser_allow_extra (opts_parser, true); - bson_parser_read_concern_optional (opts_parser, &rc); - bson_parser_write_concern_optional (opts_parser, &wc); - opts = bson_new (); - bson_concat (opts, bson_parser_get_extra (opts_parser)); - if (rc) { - mongoc_read_concern_append (rc, opts); - } - if (wc) { - mongoc_write_concern_append (wc, opts); - } - - entity->value = - mongoc_gridfs_bucket_new (database, opts, NULL /* read prefs */, error); - if (!entity->value) { - goto done; - } - - ret = true; -done: - bson_free (database_id); - bson_destroy (bucket_opts_bson); - bson_parser_destroy (parser); - bson_parser_destroy_with_parsed_fields (opts_parser); - bson_destroy (opts); - if (!ret) { - entity_destroy (entity); - return NULL; - } - return entity; -} - -/* Caveat: The spec encourages, but does not require, that entities are defined - * in dependency order: - * "Test files SHOULD define entities in dependency order, such that all - * referenced entities (e.g. client) are defined before any of their dependent - * entities (e.g. database, session)." - * If a test ever does break this pattern (flipping dependency order), that can - * be solved by: - * - creating C objects lazily in entity_map_get. - * - creating entities in dependency order (all clients first, then databases, - * etc.) - * The current implementation here does the simple thing and creates the C - * object immediately. - */ -bool -entity_map_create (entity_map_t *entity_map, bson_t *bson, bson_error_t *error) -{ - bson_iter_t iter; - const char *entity_type; - bson_t entity_bson; - entity_t *entity = NULL; - entity_t *entity_iter = NULL; - bool ret = false; - - bson_iter_init (&iter, bson); - if (!bson_iter_next (&iter)) { - test_set_error (error, "Empty entity"); - goto done; - } - - entity_type = bson_iter_key (&iter); - bson_iter_bson (&iter, &entity_bson); - if (bson_iter_next (&iter)) { - test_set_error (error, - "Extra field in entity: %s: %s", - bson_iter_key (&iter), - tmp_json (bson)); - goto done; - } - - if (0 == strcmp (entity_type, "client")) { - entity = entity_client_new (entity_map, &entity_bson, error); - } else if (0 == strcmp (entity_type, "clientEncryption")) { - entity = entity_client_encryption_new (entity_map, &entity_bson, error); - } else if (0 == strcmp (entity_type, "database")) { - entity = entity_database_new (entity_map, &entity_bson, error); - } else if (0 == strcmp (entity_type, "collection")) { - entity = entity_collection_new (entity_map, &entity_bson, error); - } else if (0 == strcmp (entity_type, "session")) { - entity = entity_session_new (entity_map, &entity_bson, error); - } else if (0 == strcmp (entity_type, "bucket")) { - entity = entity_bucket_new (entity_map, &entity_bson, error); - } else { - test_set_error ( - error, "Unknown entity type: %s: %s", entity_type, tmp_json (bson)); - goto done; - } - - if (!entity) { - goto done; - } - - LL_FOREACH (entity_map->entities, entity_iter) - { - if (0 == strcmp (entity_iter->id, entity->id)) { - test_set_error ( - error, "Attempting to create duplicate entity: '%s'", entity->id); - entity_destroy (entity); - goto done; - } - } - - ret = true; -done: - if (!ret) { - entity_destroy (entity); - } else { - LL_PREPEND (entity_map->entities, entity); - } - return ret; -} - -static void -entity_destroy (entity_t *entity) -{ - event_t *event = NULL; - event_t *tmp = NULL; - - if (!entity) { - return; - } - - BSON_ASSERT (entity->type); - - if (0 == strcmp ("client", entity->type)) { - mongoc_client_t *client = NULL; - - client = (mongoc_client_t *) entity->value; - mongoc_client_destroy (client); - } else if (0 == strcmp ("clientEncryption", entity->type)) { - mongoc_client_encryption_t *ce = NULL; - - ce = (mongoc_client_encryption_t *) entity->value; - mongoc_client_encryption_destroy (ce); - } else if (0 == strcmp ("database", entity->type)) { - mongoc_database_t *db = NULL; - - db = (mongoc_database_t *) entity->value; - mongoc_database_destroy (db); - } else if (0 == strcmp ("collection", entity->type)) { - mongoc_collection_t *coll = NULL; - - coll = (mongoc_collection_t *) entity->value; - mongoc_collection_destroy (coll); - } else if (0 == strcmp ("session", entity->type)) { - mongoc_client_session_t *sess = NULL; - - sess = (mongoc_client_session_t *) entity->value; - mongoc_client_session_destroy (sess); - } else if (0 == strcmp ("changestream", entity->type)) { - mongoc_change_stream_t *changestream = NULL; - - changestream = (mongoc_change_stream_t *) entity->value; - mongoc_change_stream_destroy (changestream); - } else if (0 == strcmp ("bson", entity->type)) { - bson_val_t *value = entity->value; - - bson_val_destroy (value); - } else if (0 == strcmp ("bucket", entity->type)) { - mongoc_gridfs_bucket_t *bucket = entity->value; - - mongoc_gridfs_bucket_destroy (bucket); - } else if (0 == strcmp ("findcursor", entity->type)) { - entity_findcursor_t *findcursor = entity->value; - - mongoc_cursor_destroy (findcursor->cursor); - bson_free (findcursor); - } else if (0 == strcmp ("bson_array", entity->type)) { - mongoc_array_t *array = entity->value; - - bson_t **const begin = array->data; - bson_t **const end = begin + array->len; - for (bson_t **iter = begin; iter != end; ++iter) { - bson_destroy (*iter); - } - - _mongoc_array_destroy (array); - bson_free (array); - } else if (0 == strcmp ("size_t", entity->type)) { - size_t *v = entity->value; - - bson_free (v); - } else { - test_error ("Attempting to destroy unrecognized entity type: %s, id: %s", - entity->type, - entity->id); - } - - LL_FOREACH_SAFE (entity->events, event, tmp) - { - event_destroy (event); - } - - _mongoc_array_destroy (&entity->observe_events); - _mongoc_array_destroy (&entity->store_events); - bson_destroy (entity->ignore_command_monitoring_events); - bson_free (entity->type); - bson_free (entity->id); - bson_destroy (entity->lsid); - bson_free (entity->session_client_id); - bson_free (entity->observe_sensitive_commands); - bson_free (entity); -} - -entity_t * -entity_map_get (entity_map_t *entity_map, const char *id, bson_error_t *error) -{ - entity_t *entity = NULL; - LL_FOREACH (entity_map->entities, entity) - { - if (0 == strcmp (entity->id, id)) { - return entity; - } - } - - test_set_error (error, "Entity '%s' not found", id); - return NULL; -} - -bool -entity_map_delete (entity_map_t *em, const char *id, bson_error_t *error) -{ - entity_t *entity = entity_map_get (em, id, error); - if (!entity) { - return false; - } - - LL_DELETE (em->entities, entity); - entity_destroy (entity); - - return true; -} - -static entity_t * -_entity_map_get_by_type (entity_map_t *entity_map, - const char *id, - const char *type, - bson_error_t *error) -{ - entity_t *entity = NULL; - - entity = entity_map_get (entity_map, id, error); - if (!entity) { - return NULL; - } - - if (0 != strcmp (entity->type, type)) { - test_set_error (error, - "Unexpected entity type. Expected: %s, got %s", - type, - entity->type); - return NULL; - } - return entity; -} - -mongoc_client_t * -entity_map_get_client (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = _entity_map_get_by_type (entity_map, id, "client", error); - if (!entity) { - return NULL; - } - return (mongoc_client_t *) entity->value; -} - -mongoc_client_encryption_t * -entity_map_get_client_encryption (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = - _entity_map_get_by_type (entity_map, id, "clientEncryption", error); - if (!entity) { - return NULL; - } - return (mongoc_client_encryption_t *) entity->value; -} - -mongoc_database_t * -entity_map_get_database (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = - _entity_map_get_by_type (entity_map, id, "database", error); - if (!entity) { - return NULL; - } - return (mongoc_database_t *) entity->value; -} - -mongoc_collection_t * -entity_map_get_collection (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = - _entity_map_get_by_type (entity_map, id, "collection", error); - if (!entity) { - return NULL; - } - return (mongoc_collection_t *) entity->value; -} - -mongoc_change_stream_t * -entity_map_get_changestream (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = - _entity_map_get_by_type (entity_map, id, "changestream", error); - if (!entity) { - return NULL; - } - return (mongoc_change_stream_t *) entity->value; -} - -entity_findcursor_t * -entity_map_get_findcursor (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = - _entity_map_get_by_type (entity_map, id, "findcursor", error); - if (!entity) { - return NULL; - } - return (entity_findcursor_t *) entity->value; -} - -bson_val_t * -entity_map_get_bson (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = _entity_map_get_by_type (entity_map, id, "bson", error); - if (!entity) { - return NULL; - } - return (bson_val_t *) entity->value; -} - -mongoc_array_t * -entity_map_get_bson_array (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = - _entity_map_get_by_type (entity_map, id, "bson_array", error); - if (!entity) { - return NULL; - } - return (mongoc_array_t *) entity->value; -} - -size_t * -entity_map_get_size_t (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = _entity_map_get_by_type (entity_map, id, "size_t", error); - if (!entity) { - return NULL; - } - return (size_t *) entity->value; -} - -mongoc_client_session_t * -entity_map_get_session (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = - _entity_map_get_by_type (entity_map, id, "session", error); - if (!entity) { - return NULL; - } - if (!entity->value) { - test_set_error ( - error, - "entity: %s is an ended session that is no longer valid to use", - id); - return NULL; - } - return (mongoc_client_session_t *) entity->value; -} - -static bson_t * -entity_map_get_lsid (entity_map_t *em, char *session_id, bson_error_t *error) -{ - entity_t *entity = NULL; - - entity = entity_map_get (em, session_id, error); - if (!entity) { - return NULL; - } - if (!entity->lsid) { - test_set_error (error, - "entity %s of type %s does not have an lsid", - session_id, - entity->type); - return NULL; - } - return entity->lsid; -} - -mongoc_gridfs_bucket_t * -entity_map_get_bucket (entity_map_t *entity_map, - const char *id, - bson_error_t *error) -{ - entity_t *entity = _entity_map_get_by_type (entity_map, id, "bucket", error); - if (!entity) { - return NULL; - } - return (mongoc_gridfs_bucket_t *) entity->value; -} - -static bool -_entity_map_add (entity_map_t *em, - const char *id, - const char *type, - void *value, - bson_error_t *error) -{ - bson_error_t tmperr; - entity_t *entity = NULL; - - if (NULL != entity_map_get (em, id, &tmperr)) { - test_set_error (error, "Attempting to overwrite entity: %s", id); - return false; - } - - entity = entity_new (em, type); - entity->value = value; - entity->id = bson_strdup (id); - LL_PREPEND (em->entities, entity); - return true; -} - -bool -entity_map_add_changestream (entity_map_t *em, - const char *id, - mongoc_change_stream_t *changestream, - bson_error_t *error) -{ - return _entity_map_add ( - em, id, "changestream", (void *) changestream, error); -} - -void -entity_findcursor_iterate_until_document_or_error ( - entity_findcursor_t *findcursor, - const bson_t **document, - bson_error_t *error, - const bson_t **error_document) -{ - *document = NULL; - - if (findcursor->first_result) { - *document = findcursor->first_result; - findcursor->first_result = NULL; - return; - } - - while (!mongoc_cursor_next (findcursor->cursor, document)) { - if (mongoc_cursor_error_document ( - findcursor->cursor, error, error_document)) { - return; - } - } -} - -bool -entity_map_add_findcursor (entity_map_t *em, - const char *id, - mongoc_cursor_t *cursor, - const bson_t *first_result, - bson_error_t *error) -{ - entity_findcursor_t *findcursor; - - findcursor = - (entity_findcursor_t *) bson_malloc0 (sizeof (entity_findcursor_t)); - findcursor->cursor = cursor; - findcursor->first_result = first_result; - return _entity_map_add (em, id, "findcursor", (void *) findcursor, error); -} - -bool -entity_map_add_bson (entity_map_t *em, - const char *id, - bson_val_t *val, - bson_error_t *error) -{ - return _entity_map_add (em, id, "bson", (void *) bson_val_copy (val), error); -} - -bool -entity_map_add_bson_array (entity_map_t *em, - const char *id, - bson_error_t *error) -{ - // Note: the specification states we should be storing a BSON object of array - // type, but we use an array of BSON objects instead to make append and - // iteration easier. - mongoc_array_t *array = bson_malloc (sizeof (mongoc_array_t)); - mongoc_array_aligned_init (array, bson_t *); - return _entity_map_add (em, id, "bson_array", (void *) array, error); -} - -bool -entity_map_add_size_t (entity_map_t *em, - const char *id, - size_t *value, - bson_error_t *error) -{ - return _entity_map_add (em, id, "size_t", value, error); -} - -/* implement $$sessionLsid */ -static bool -special_session_lsid (bson_matcher_t *matcher, - const bson_t *assertion, - const bson_val_t *actual, - void *ctx, - const char *path, - bson_error_t *error) -{ - bool ret = false; - const char *id; - bson_val_t *session_val = NULL; - bson_t *lsid = NULL; - entity_map_t *em = (entity_map_t *) ctx; - bson_iter_t iter; - - bson_iter_init (&iter, assertion); - bson_iter_next (&iter); - - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - test_set_error (error, - "unexpected $$sessionLsid does not contain utf8: %s", - tmp_json (assertion)); - goto done; - } - - id = bson_iter_utf8 (&iter, NULL); - lsid = entity_map_get_lsid (em, (char *) id, error); - if (!lsid) { - goto done; - } - - session_val = bson_val_from_bson (lsid); - if (!bson_matcher_match (matcher, session_val, actual, path, false, error)) { - goto done; - } - - - ret = true; -done: - bson_val_destroy (session_val); - return ret; -} - -/* implement $$matchesEntity */ -bool -special_matches_entity (bson_matcher_t *matcher, - const bson_t *assertion, - const bson_val_t *actual, - void *ctx, - const char *path, - bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - entity_map_t *em = (entity_map_t *) ctx; - bson_val_t *entity_val = NULL; - const char *id; - - bson_iter_init (&iter, assertion); - BSON_ASSERT (bson_iter_next (&iter)); - - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - test_set_error (error, - "unexpected $$matchesEntity does not contain utf8: %s", - tmp_json (assertion)); - goto done; - } - - id = bson_iter_utf8 (&iter, NULL); - entity_val = entity_map_get_bson (em, id, error); - if (!entity_val) { - goto done; - } - - if (!bson_matcher_match (matcher, entity_val, actual, path, false, error)) { - goto done; - } - - ret = true; -done: - return ret; -} - -bool -entity_map_match (entity_map_t *em, - const bson_val_t *expected, - const bson_val_t *actual, - bool array_of_root_docs, - bson_error_t *error) -{ - bson_matcher_t *matcher; - bool ret; - - matcher = bson_matcher_new (); - bson_matcher_add_special ( - matcher, "$$sessionLsid", special_session_lsid, em); - bson_matcher_add_special ( - matcher, "$$matchesEntity", special_matches_entity, em); - ret = bson_matcher_match ( - matcher, expected, actual, "", array_of_root_docs, error); - bson_matcher_destroy (matcher); - return ret; -} - -char * -event_list_to_string (event_t *events) -{ - bson_string_t *str = NULL; - event_t *eiter = NULL; - - str = bson_string_new (""); - LL_FOREACH (events, eiter) - { - bson_string_append_printf (str, "- %s:", eiter->type); - if (eiter->command_name) { - bson_string_append_printf (str, " cmd=%s", eiter->command_name); - } - if (eiter->database_name) { - bson_string_append_printf (str, " db=%s", eiter->database_name); - } - if (eiter->command) { - bson_string_append_printf (str, " sent %s", tmp_json (eiter->command)); - } - if (eiter->reply) { - bson_string_append_printf ( - str, " received %s", tmp_json (eiter->reply)); - } - bson_string_append (str, "\n"); - } - return bson_string_free (str, false); -} - - -bool -entity_map_end_session (entity_map_t *em, char *session_id, bson_error_t *error) -{ - bool ret = false; - entity_t *entity = NULL; - - entity = entity_map_get (em, session_id, error); - if (!entity) { - goto done; - } - - if (0 != strcmp (entity->type, "session")) { - test_set_error ( - error, "expected session for %s but got %s", session_id, entity->type); - goto done; - } - - mongoc_client_session_destroy ((mongoc_client_session_t *) entity->value); - entity->value = NULL; - ret = true; -done: - return ret; -} - -char * -entity_map_get_session_client_id (entity_map_t *em, - char *session_id, - bson_error_t *error) -{ - char *ret = NULL; - entity_t *entity = NULL; - - entity = entity_map_get (em, session_id, error); - if (!entity) { - goto done; - } - - if (0 != strcmp (entity->type, "session")) { - test_set_error ( - error, "expected session for %s but got %s", session_id, entity->type); - goto done; - } - - ret = entity->session_client_id; -done: - return ret; -} - -void -entity_map_set_reduced_heartbeat (entity_map_t *em, bool val) -{ - em->reduced_heartbeat = val; -} - -void -entity_map_disable_event_listeners (entity_map_t *em) -{ - entity_t *eiter = NULL; - - LL_FOREACH (em->entities, eiter) - { - if (0 == strcmp (eiter->type, "client")) { - mongoc_client_t *client = (mongoc_client_t *) eiter->value; - - mongoc_client_set_apm_callbacks (client, NULL, NULL); - } - } -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/entity-map.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/entity-map.h deleted file mode 100644 index 866e84c0c..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/entity-map.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef UNIFIED_ENTITY_MAP_H -#define UNIFIED_ENTITY_MAP_H - -#include "bson/bson.h" -#include "mongoc/mongoc.h" -#include "mongoc-array-private.h" -#include "bsonutil/bson-match.h" -#include "test-diagnostics.h" - -typedef struct _event_t { - char *type; - char *command_name; - char *database_name; - bson_t *command; - bson_t *reply; - bson_oid_t service_id; - int64_t server_connection_id; - struct _event_t *next; -} event_t; - -typedef struct _observe_event_t { - const char *type; // Non-owning. Type of event to observe. -} observe_event_t; - -typedef struct _store_event_t { - const char *entity_id; // Non-owning. Target entity to store event. - const char *type; // Non-owning. Type of event to store. -} store_event_t; - -typedef struct _entity_t { - char *id; - char *type; - void *value; - bson_t *ignore_command_monitoring_events; - bool *observe_sensitive_commands; - struct _entity_t *next; - event_t *events; - struct _entity_map_t *entity_map; // Parent entity map. - mongoc_array_t observe_events; // observe_event_t [N]. - mongoc_array_t store_events; // store_event_t [N]. - bson_t *lsid; - char *session_client_id; -} entity_t; - -struct _entity_findcursor_t; -typedef struct _entity_findcursor_t entity_findcursor_t; - -/* Operations on the entity map enforce: - * 1. Uniqueness. Attempting to create two entries with the same id is an error. - * 2. Referential integrity. Attempting to get with an unknown id is an error. - */ -typedef struct _entity_map_t { - entity_t *entities; - bool reduced_heartbeat; -} entity_map_t; - -entity_map_t * -entity_map_new (void); - -void -entity_map_destroy (entity_map_t *em); - -/* Creates an entry in the entity map based on what is specified in @bson. - */ -bool -entity_map_create (entity_map_t *em, bson_t *bson, bson_error_t *error); - -/* Steals ownership of changestream. */ -bool -entity_map_add_changestream (entity_map_t *em, - const char *id, - mongoc_change_stream_t *changestream, - bson_error_t *error); - -/* Steals ownership of cursor. */ -bool -entity_map_add_findcursor (entity_map_t *em, - const char *id, - mongoc_cursor_t *cursor, - const bson_t *first_result, - bson_error_t *error); - -/* Copies val */ -bool -entity_map_add_bson (entity_map_t *em, - const char *id, - bson_val_t *val, - bson_error_t *error); - -bool -entity_map_add_bson_array (entity_map_t *em, - const char *id, - bson_error_t *error); - -/* Steals ownership of value. */ -bool -entity_map_add_size_t (entity_map_t *em, - const char *id, - size_t *value, - bson_error_t *error); - -/* Returns NULL and sets @error if @id does not map to an entry. */ -entity_t * -entity_map_get (entity_map_t *em, const char *id, bson_error_t *error); - -/* Removes an entity from the entity map. Returns false and sets @error if @id - * does not map to an entry. */ -bool -entity_map_delete (entity_map_t *em, const char *id, bson_error_t *error); - -mongoc_client_t * -entity_map_get_client (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -mongoc_client_encryption_t * -entity_map_get_client_encryption (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -mongoc_database_t * -entity_map_get_database (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -mongoc_collection_t * -entity_map_get_collection (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -mongoc_change_stream_t * -entity_map_get_changestream (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -entity_findcursor_t * -entity_map_get_findcursor (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -void -entity_findcursor_iterate_until_document_or_error ( - entity_findcursor_t *cursor, - const bson_t **document, - bson_error_t *error, - const bson_t **error_document); - -mongoc_client_session_t * -entity_map_get_session (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -bson_val_t * -entity_map_get_bson (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -mongoc_array_t * -entity_map_get_bson_array (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -size_t * -entity_map_get_size_t (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -mongoc_gridfs_bucket_t * -entity_map_get_bucket (entity_map_t *entity_map, - const char *id, - bson_error_t *error); - -bool -entity_map_match (entity_map_t *em, - const bson_val_t *expected, - const bson_val_t *actual, - bool allow_extra, - bson_error_t *error); - -char * -event_list_to_string (event_t *events); - -bool -entity_map_end_session (entity_map_t *em, - char *session_id, - bson_error_t *error); - -char * -entity_map_get_session_client_id (entity_map_t *em, - char *session_id, - bson_error_t *error); - -void -entity_map_set_reduced_heartbeat (entity_map_t *em, bool val); - -void -entity_map_disable_event_listeners (entity_map_t *em); -#endif /* UNIFIED_ENTITY_MAP_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/operation.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/operation.c deleted file mode 100644 index 371999597..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/operation.c +++ /dev/null @@ -1,4081 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "operation.h" - -#include "mongoc-array-private.h" -#include "mongoc-util-private.h" // hex_to_bin -#include "result.h" -#include "test-diagnostics.h" -#include "test-libmongoc.h" -#include "util.h" -#include "utlist.h" -#include "bson-dsl.h" - -typedef struct { - char *name; - char *object; - bson_t *arguments; - bson_t *expect_error; - bson_val_t *expect_result; - bool *ignore_result_and_error; - char *save_result_as_entity; - bson_parser_t *parser; - char *session_id; - mongoc_client_session_t *session; -} operation_t; - -static void -operation_destroy (operation_t *op) -{ - if (!op) { - return; - } - bson_parser_destroy_with_parsed_fields (op->parser); - bson_free (op->session_id); - bson_free (op); -} - -static operation_t * -operation_new (bson_t *bson, bson_error_t *error) -{ - operation_t *op = bson_malloc0 (sizeof (operation_t)); - op->parser = bson_parser_new (); - bson_parser_utf8 (op->parser, "name", &op->name); - bson_parser_utf8 (op->parser, "object", &op->object); - bson_parser_doc_optional (op->parser, "arguments", &op->arguments); - bson_parser_doc_optional (op->parser, "expectError", &op->expect_error); - bson_parser_any_optional (op->parser, "expectResult", &op->expect_result); - bson_parser_bool_optional ( - op->parser, "ignoreResultAndError", &op->ignore_result_and_error); - bson_parser_utf8_optional ( - op->parser, "saveResultAsEntity", &op->save_result_as_entity); - if (!bson_parser_parse (op->parser, bson, error)) { - operation_destroy (op); - return NULL; - } - return op; -} - -static bool -operation_create_change_stream (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - entity_t *entity = NULL; - bson_parser_t *parser = NULL; - mongoc_change_stream_t *changestream = NULL; - bson_t *pipeline = NULL; - const bson_t *op_reply = NULL; - bson_error_t op_error = {0}; - bson_t *opts = NULL; - - parser = bson_parser_new (); - /* Capture options as all extra fields, and pass them directly as change - * stream options. */ - bson_parser_allow_extra (parser, true); - bson_parser_array (parser, "pipeline", &pipeline); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - entity = entity_map_get (test->entity_map, op->object, error); - if (!entity) { - goto done; - } - - if (0 == strcmp (entity->type, "client")) { - mongoc_client_t *client = (mongoc_client_t *) entity->value; - changestream = mongoc_client_watch (client, pipeline, opts); - } else if (0 == strcmp (entity->type, "database")) { - mongoc_database_t *db = (mongoc_database_t *) entity->value; - changestream = mongoc_database_watch (db, pipeline, opts); - } else if (0 == strcmp (entity->type, "collection")) { - mongoc_collection_t *coll = (mongoc_collection_t *) entity->value; - changestream = mongoc_collection_watch (coll, pipeline, opts); - } - - mongoc_change_stream_error_document (changestream, &op_error, &op_reply); - result_from_val_and_reply (result, NULL, (bson_t *) op_reply, &op_error); - - if (op->save_result_as_entity) { - if (!entity_map_add_changestream (test->entity_map, - op->save_result_as_entity, - changestream, - error)) { - goto done; - } else { - // Successfully saved the changestream - } - } else { - // We're not saving the changestream - mongoc_change_stream_destroy (changestream); - } - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (opts); - return ret; -} - -static bool -operation_list_databases (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_client_t *client = NULL; - mongoc_cursor_t *cursor = NULL; - bson_t *opts = NULL; - - opts = bson_new (); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - if (op->arguments) { - bson_concat (opts, op->arguments); - } - - client = entity_map_get_client (test->entity_map, op->object, error); - if (!client) { - goto done; - } - - cursor = mongoc_client_find_databases_with_opts (client, opts); - - result_from_cursor (result, cursor); - - ret = true; -done: - mongoc_cursor_destroy (cursor); - bson_destroy (opts); - return ret; -} - -static bool -operation_list_database_names (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_client_t *client = NULL; - bson_t *opts = NULL; - - opts = bson_new (); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - if (op->arguments) { - bson_concat (opts, op->arguments); - } - - client = entity_map_get_client (test->entity_map, op->object, error); - if (!client) { - goto done; - } - - char **names = - mongoc_client_get_database_names_with_opts (client, opts, error); - - { - bson_val_t *val = NULL; - if (names) { - bson_t bson = BSON_INITIALIZER; - bson_array_builder_t *element; - - BSON_APPEND_ARRAY_BUILDER_BEGIN (&bson, "v", &element); - for (char **names_iter = names; *names_iter != NULL; ++names_iter) { - bson_array_builder_append_utf8 (element, *names_iter, -1); - } - bson_append_array_builder_end (&bson, element); - - bson_iter_t iter; - bson_iter_init_find (&iter, &bson, "v"); - val = bson_val_from_iter (&iter); - - bson_destroy (&bson); - } - result_from_val_and_reply (result, val, NULL, error); - bson_val_destroy (val); - } - - bson_strfreev (names); - - ret = true; -done: - bson_destroy (opts); - return ret; -} - -static bool -operation_create_datakey (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bson_parser_t *parser = bson_parser_new (); - char *kms_provider = NULL; - bson_t *opts; - mongoc_client_encryption_t *ce = NULL; - mongoc_client_encryption_datakey_opts_t *datakey_opts = NULL; - bson_value_t key_id_value = {0}; - bool ret = false; - - bson_parser_utf8 (parser, "kmsProvider", &kms_provider); - bson_parser_doc_optional (parser, "opts", &opts); - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - if (!(ce = entity_map_get_client_encryption ( - test->entity_map, op->object, error))) { - goto done; - } - - datakey_opts = mongoc_client_encryption_datakey_opts_new (); - - if (opts) { - bson_parser_t *opts_parser = bson_parser_new (); - bson_t *master_key = NULL; - bson_t *key_alt_names = NULL; - bson_val_t *key_material_val = NULL; - bool success = false; - - bson_parser_doc_optional (opts_parser, "masterKey", &master_key); - bson_parser_array_optional (opts_parser, "keyAltNames", &key_alt_names); - bson_parser_any_optional (opts_parser, "keyMaterial", &key_material_val); - - if (!bson_parser_parse (opts_parser, opts, error)) { - goto opts_done; - } - - if (master_key) { - mongoc_client_encryption_datakey_opts_set_masterkey (datakey_opts, - master_key); - } - - if (key_alt_names) { - bson_iter_t iter; - mongoc_array_t arr; - - _mongoc_array_init (&arr, sizeof (char *)); - - BSON_FOREACH (key_alt_names, iter) - { - const char *key_alt_name = bson_iter_utf8 (&iter, NULL); - - _mongoc_array_append_val (&arr, key_alt_name); - } - - BSON_ASSERT (bson_in_range_unsigned (uint32_t, arr.len)); - - mongoc_client_encryption_datakey_opts_set_keyaltnames ( - datakey_opts, arr.data, (uint32_t) arr.len); - - _mongoc_array_destroy (&arr); - } - - if (key_material_val) { - const bson_value_t *value = bson_val_to_value (key_material_val); - - BSON_ASSERT (value); - - if (value->value_type != BSON_TYPE_BINARY || - value->value.v_binary.subtype != BSON_SUBTYPE_BINARY) { - test_set_error ( - error, - "expected field 'keyMaterial' to be binData with subtype 00"); - goto opts_done; - } - - mongoc_client_encryption_datakey_opts_set_keymaterial ( - datakey_opts, - value->value.v_binary.data, - value->value.v_binary.data_len); - } - - success = true; - - opts_done: - bson_parser_destroy_with_parsed_fields (opts_parser); - - if (!success) { - goto done; - } - } - - { - const bool success = mongoc_client_encryption_create_datakey ( - ce, kms_provider, datakey_opts, &key_id_value, error); - bson_val_t *val = NULL; - - if (success) { - val = bson_val_from_value (&key_id_value); - } - - result_from_val_and_reply (result, val, NULL, error); - - bson_val_destroy (val); - } - - ret = true; - -done: - mongoc_client_encryption_datakey_opts_destroy (datakey_opts); - bson_parser_destroy_with_parsed_fields (parser); - bson_value_destroy (&key_id_value); - - return ret; -} - -static bool -operation_rewrap_many_datakey (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bson_parser_t *const parser = bson_parser_new (); - mongoc_client_encryption_rewrap_many_datakey_result_t *const rmd_result = - mongoc_client_encryption_rewrap_many_datakey_result_new (); - - bool ret = false; - mongoc_client_encryption_t *ce = NULL; - bson_t *filter_doc = NULL; - bson_t *opts_doc = NULL; - char *provider = NULL; - bson_t *master_key = NULL; - - bson_parser_doc (parser, "filter", &filter_doc); - bson_parser_doc_optional (parser, "opts", &opts_doc); - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - if (!(ce = entity_map_get_client_encryption ( - test->entity_map, op->object, error))) { - goto done; - } - - if (opts_doc) { - bson_parser_t *const opts_parser = bson_parser_new (); - bool success = false; - - bson_parser_utf8 (opts_parser, "provider", &provider); - bson_parser_doc_optional (opts_parser, "masterKey", &master_key); - - success = bson_parser_parse (opts_parser, opts_doc, error); - - bson_parser_destroy (opts_parser); - - if (!success) { - goto done; - } - } - - if (mongoc_client_encryption_rewrap_many_datakey ( - ce, filter_doc, provider, master_key, rmd_result, error)) { - const bson_t *const bulk_write_result = - mongoc_client_encryption_rewrap_many_datakey_result_get_bulk_write_result ( - rmd_result); - - bson_t doc = BSON_INITIALIZER; - - if (bulk_write_result) { - bson_t *const rewritten = - rewrite_bulk_write_result (bulk_write_result); - BSON_APPEND_DOCUMENT (&doc, "bulkWriteResult", rewritten); - bson_destroy (rewritten); - } - - { - bson_val_t *const val = bson_val_from_bson (&doc); - result_from_val_and_reply (result, val, NULL, error); - bson_val_destroy (val); - } - - bson_destroy (&doc); - } else { - result_from_val_and_reply (result, NULL, NULL, error); - } - - ret = true; - -done: - bson_free (provider); - bson_destroy (master_key); - mongoc_client_encryption_rewrap_many_datakey_result_destroy (rmd_result); - bson_parser_destroy_with_parsed_fields (parser); - - return ret; -} - -static bool -operation_delete_key (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bson_parser_t *const parser = bson_parser_new (); - - bool ret = false; - bson_val_t *id_val = NULL; - mongoc_client_encryption_t *ce = NULL; - - bson_parser_any (parser, "id", &id_val); - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - if (!(ce = entity_map_get_client_encryption ( - test->entity_map, op->object, error))) { - goto done; - } - - { - bson_t reply; - const bool success = mongoc_client_encryption_delete_key ( - ce, bson_val_to_value (id_val), &reply, error); - bson_val_t *const val = success ? bson_val_from_bson (&reply) : NULL; - - result_from_val_and_reply (result, val, NULL, error); - - bson_destroy (&reply); - bson_val_destroy (val); - } - - ret = true; - -done: - bson_parser_destroy_with_parsed_fields (parser); - - return ret; -} - -static bool -operation_get_key (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bson_parser_t *const parser = bson_parser_new (); - - bool ret = false; - bson_val_t *id_val = NULL; - mongoc_client_encryption_t *ce = NULL; - - bson_parser_any (parser, "id", &id_val); - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - if (!(ce = entity_map_get_client_encryption ( - test->entity_map, op->object, error))) { - goto done; - } - - { - bson_t key_doc; - const bool success = mongoc_client_encryption_get_key ( - ce, bson_val_to_value (id_val), &key_doc, error); - const bson_value_t value = {.value_type = BSON_TYPE_NULL}; - bson_val_t *const val = - success ? (bson_empty (&key_doc) ? bson_val_from_value (&value) - : bson_val_from_bson (&key_doc)) - : NULL; - - result_from_val_and_reply (result, val, NULL, error); - - bson_val_destroy (val); - bson_destroy (&key_doc); - } - - ret = true; - -done: - bson_parser_destroy_with_parsed_fields (parser); - - return ret; -} - -static bool -operation_get_keys (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bson_parser_t *const parser = bson_parser_new (); - - bool ret = false; - mongoc_client_encryption_t *ce = NULL; - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - if (!(ce = entity_map_get_client_encryption ( - test->entity_map, op->object, error))) { - goto done; - } - - { - mongoc_cursor_t *const cursor = - mongoc_client_encryption_get_keys (ce, error); - - if (cursor) { - result_from_cursor (result, cursor); - } else { - result_from_val_and_reply (result, NULL, NULL, error); - } - - mongoc_cursor_destroy (cursor); - } - - ret = true; - -done: - bson_parser_destroy_with_parsed_fields (parser); - - return ret; -} - -static bool -operation_add_key_alt_name (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bson_parser_t *const parser = bson_parser_new (); - - bool ret = false; - bson_val_t *id_val = NULL; - char *alt_name = NULL; - mongoc_client_encryption_t *ce = NULL; - - bson_parser_any (parser, "id", &id_val); - bson_parser_utf8 (parser, "keyAltName", &alt_name); - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - if (!(ce = entity_map_get_client_encryption ( - test->entity_map, op->object, error))) { - goto done; - } - - { - bson_t key_doc; - const bool success = mongoc_client_encryption_add_key_alt_name ( - ce, bson_val_to_value (id_val), alt_name, &key_doc, error); - const bson_value_t value = {.value_type = BSON_TYPE_NULL}; - bson_val_t *const val = - success ? (bson_empty (&key_doc) ? bson_val_from_value (&value) - : bson_val_from_bson (&key_doc)) - : NULL; - - result_from_val_and_reply (result, val, NULL, error); - - bson_destroy (&key_doc); - bson_val_destroy (val); - } - - ret = true; - -done: - bson_parser_destroy_with_parsed_fields (parser); - - return ret; -} - -static bool -operation_remove_key_alt_name (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bson_parser_t *const parser = bson_parser_new (); - - bool ret = false; - bson_val_t *id_val = NULL; - char *alt_name = NULL; - mongoc_client_encryption_t *ce = NULL; - - bson_parser_any (parser, "id", &id_val); - bson_parser_utf8 (parser, "keyAltName", &alt_name); - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - if (!(ce = entity_map_get_client_encryption ( - test->entity_map, op->object, error))) { - goto done; - } - - { - bson_t key_doc; - const bool success = mongoc_client_encryption_remove_key_alt_name ( - ce, bson_val_to_value (id_val), alt_name, &key_doc, error); - const bson_value_t value = {.value_type = BSON_TYPE_NULL}; - bson_val_t *const val = - success ? (bson_empty (&key_doc) ? bson_val_from_value (&value) - : bson_val_from_bson (&key_doc)) - : NULL; - - result_from_val_and_reply (result, val, NULL, error); - - bson_destroy (&key_doc); - bson_val_destroy (val); - } - - ret = true; - -done: - bson_parser_destroy_with_parsed_fields (parser); - - return ret; -} - -static bool -operation_get_key_by_alt_name (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bson_parser_t *const parser = bson_parser_new (); - - bool ret = false; - char *keyaltname = NULL; - mongoc_client_encryption_t *ce = NULL; - - bson_parser_utf8 (parser, "keyAltName", &keyaltname); - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - if (!(ce = entity_map_get_client_encryption ( - test->entity_map, op->object, error))) { - goto done; - } - - { - bson_t key_doc; - const bool success = mongoc_client_encryption_get_key_by_alt_name ( - ce, keyaltname, &key_doc, error); - const bson_value_t value = {.value_type = BSON_TYPE_NULL}; - bson_val_t *const val = - success ? (bson_empty (&key_doc) ? bson_val_from_value (&value) - : bson_val_from_bson (&key_doc)) - : NULL; - - result_from_val_and_reply (result, val, NULL, error); - - bson_destroy (&key_doc); - bson_val_destroy (val); - } - - ret = true; - -done: - bson_parser_destroy_with_parsed_fields (parser); - - return ret; -} - -static bool -operation_encrypt (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_client_encryption_t *ce = NULL; - mongoc_client_encryption_encrypt_opts_t *eo = - mongoc_client_encryption_encrypt_opts_new (); - bson_val_t *value = NULL; - bson_t *opts = NULL; - char *opts_keyaltname = NULL; - bson_val_t *opts_id = NULL; - char *opts_algorithm = NULL; - - // Parse `value` and `opts`. - { - bson_parser_t *const parser = bson_parser_new (); - bool success = false; - - bson_parser_any (parser, "value", &value); - bson_parser_doc (parser, "opts", &opts); - - success = bson_parser_parse (parser, op->arguments, error); - - bson_parser_destroy (parser); - - if (!success) { - goto done; - } - } - - // Parse fields in `opts`. - { - bson_parser_t *const parser = bson_parser_new (); - bool success = false; - - bson_parser_utf8_optional (parser, "keyAltName", &opts_keyaltname); - bson_parser_any_optional (parser, "id", &opts_id); - bson_parser_utf8 (parser, "algorithm", &opts_algorithm); - - success = bson_parser_parse (parser, opts, error); - - bson_parser_destroy (parser); - - if (!success) { - goto done; - } - } - - // Get ClientEncryption object. - if (!(ce = entity_map_get_client_encryption ( - test->entity_map, op->object, error))) { - goto done; - } - - // Encrypt. - { - if (opts_id) { - mongoc_client_encryption_encrypt_opts_set_keyid ( - eo, bson_val_to_value (opts_id)); - } - if (opts_keyaltname) { - mongoc_client_encryption_encrypt_opts_set_keyaltname (eo, - opts_keyaltname); - } - mongoc_client_encryption_encrypt_opts_set_algorithm (eo, opts_algorithm); - - bson_value_t ciphertext; - const bool success = mongoc_client_encryption_encrypt ( - ce, bson_val_to_value (value), eo, &ciphertext, error); - bson_val_t *const val = - success ? bson_val_from_value (&ciphertext) : NULL; - result_from_val_and_reply (result, val, NULL /* reply */, error); - bson_value_destroy (&ciphertext); - bson_val_destroy (val); - } - - ret = true; - -done: - - bson_free (opts_algorithm); - bson_val_destroy (opts_id); - bson_free (opts_keyaltname); - bson_destroy (opts); - bson_val_destroy (value); - mongoc_client_encryption_encrypt_opts_destroy (eo); - - return ret; -} - -static bool -operation_decrypt (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_client_encryption_t *ce = NULL; - bson_val_t *value = NULL; - - // Parse `value`. - { - bson_parser_t *const parser = bson_parser_new (); - bool success = false; - - bson_parser_any (parser, "value", &value); - - success = bson_parser_parse (parser, op->arguments, error); - - bson_parser_destroy (parser); - - if (!success) { - goto done; - } - } - - // Get ClientEncryption object. - if (!(ce = entity_map_get_client_encryption ( - test->entity_map, op->object, error))) { - goto done; - } - - // Decrypt. - { - bson_value_t plaintext; - const bool success = mongoc_client_encryption_decrypt ( - ce, bson_val_to_value (value), &plaintext, error); - bson_val_t *const val = success ? bson_val_from_value (&plaintext) : NULL; - result_from_val_and_reply (result, val, NULL /* reply */, error); - bson_value_destroy (&plaintext); - bson_val_destroy (val); - } - - ret = true; - -done: - - bson_val_destroy (value); - - return ret; -} - -static bool -operation_create_collection (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *parser = NULL; - mongoc_database_t *db = NULL; - char *collection = NULL; - bson_error_t op_error = {0}; - bson_t *opts = NULL; - mongoc_collection_t *coll = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_utf8 (parser, "collection", &collection); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - db = entity_map_get_database (test->entity_map, op->object, error); - if (!db) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = mongoc_database_create_collection (db, collection, opts, &op_error); - - result_from_val_and_reply (result, NULL, NULL, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (opts); - mongoc_collection_destroy (coll); - return ret; -} - -static bool -operation_drop_collection (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *parser = NULL; - mongoc_database_t *db = NULL; - mongoc_collection_t *coll = NULL; - char *collection = NULL; - bson_error_t op_error = {0}; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_utf8 (parser, "collection", &collection); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_new (); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - db = entity_map_get_database (test->entity_map, op->object, error); - if (!db) { - goto done; - } - - coll = mongoc_database_get_collection (db, collection); - mongoc_collection_drop_with_opts (coll, opts, &op_error); - - /* Ignore "ns not found" errors. This assumes that the client under test is - * using MONGOC_ERROR_API_VERSION_2. */ - if (op_error.domain == MONGOC_ERROR_SERVER && op_error.code == 26) { - memset (&op_error, 0, sizeof (bson_error_t)); - } - - result_from_val_and_reply (result, NULL, NULL, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - mongoc_collection_destroy (coll); - bson_destroy (opts); - return ret; -} - -static bool -operation_list_collections (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_database_t *db = NULL; - mongoc_cursor_t *cursor = NULL; - bson_t *opts = NULL; - - opts = bson_new (); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - if (op->arguments) { - bson_concat (opts, op->arguments); - } - - db = entity_map_get_database (test->entity_map, op->object, error); - if (!db) { - goto done; - } - - cursor = mongoc_database_find_collections_with_opts (db, opts); - - result_from_cursor (result, cursor); - - ret = true; -done: - mongoc_cursor_destroy (cursor); - bson_destroy (opts); - return ret; -} - -static bool -operation_list_collection_names (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_database_t *db = NULL; - mongoc_cursor_t *cursor = NULL; - char **op_ret = NULL; - bson_error_t op_error = {0}; - bson_t *opts = NULL; - - opts = bson_new (); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - bson_concat (opts, op->arguments); - - db = entity_map_get_database (test->entity_map, op->object, error); - if (!db) { - goto done; - } - - op_ret = - mongoc_database_get_collection_names_with_opts (db, opts, &op_error); - - result_from_ok (result); - - ret = true; -done: - mongoc_cursor_destroy (cursor); - bson_strfreev (op_ret); - bson_destroy (opts); - return ret; -} - -static bool -operation_list_indexes (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - mongoc_cursor_t *cursor = NULL; - bson_t *opts = NULL; - - opts = bson_new (); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - if (op->arguments) { - bson_concat (opts, op->arguments); - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - cursor = mongoc_collection_find_indexes_with_opts (coll, opts); - - result_from_cursor (result, cursor); - - ret = true; -done: - mongoc_cursor_destroy (cursor); - bson_destroy (opts); - return ret; -} - -static bool -operation_run_command (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *parser = NULL; - bson_t *command = NULL; - char *command_name = NULL; - mongoc_database_t *db = NULL; - mongoc_read_prefs_t *rp = NULL; - mongoc_write_concern_t *wc = NULL; - mongoc_read_concern_t *rc = NULL; - bson_error_t op_error = {0}; - bson_t op_reply = BSON_INITIALIZER; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_doc (parser, "command", &command); - bson_parser_utf8 (parser, "commandName", &command_name); - bson_parser_read_concern_optional (parser, &rc); - bson_parser_write_concern_optional (parser, &wc); - bson_parser_read_prefs_optional (parser, &rp); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_new (); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - db = entity_map_get_database (test->entity_map, op->object, error); - if (!db) { - goto done; - } - - if (rc) { - mongoc_read_concern_append (rc, opts); - } - if (wc) { - mongoc_write_concern_append (wc, opts); - } - - bson_destroy (&op_reply); - mongoc_database_command_with_opts ( - db, command, rp, opts, &op_reply, &op_error); - - result_from_val_and_reply (result, NULL, &op_reply, &op_error); - - ret = true; -done: - bson_destroy (&op_reply); - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (opts); - return ret; -} - -static bool -operation_modify_collection (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bson_parser_t *const parser = bson_parser_new (); - - char *coll_name = NULL; - mongoc_database_t *db = NULL; - bson_t command = BSON_INITIALIZER; - bool ret = false; - - bson_parser_utf8 (parser, "collection", &coll_name); - bson_parser_allow_extra (parser, true); - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - if (!(db = entity_map_get_database (test->entity_map, op->object, error))) { - goto done; - } - - BSON_ASSERT (BSON_APPEND_UTF8 (&command, "collMod", coll_name)); - - /* Forward all arguments other than collection name as-is. */ - BSON_ASSERT (bson_concat (&command, bson_parser_get_extra (parser))); - - { - bson_t reply; - - mongoc_database_write_command_with_opts ( - db, &command, NULL, &reply, error); - result_from_val_and_reply (result, NULL, &reply, error); - - bson_destroy (&reply); - } - - ret = true; - -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (&command); - - return ret; -} - -static bool -operation_aggregate (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - entity_t *entity = NULL; - bson_t *pipeline = NULL; - bson_parser_t *parser = NULL; - mongoc_cursor_t *cursor = NULL; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_array (parser, "pipeline", &pipeline); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - entity = entity_map_get (test->entity_map, op->object, error); - if (0 == strcmp (entity->type, "collection")) { - mongoc_collection_t *coll = (mongoc_collection_t *) entity->value; - cursor = mongoc_collection_aggregate ( - coll, 0 /* query flags */, pipeline, opts, NULL /* read prefs */); - } else if (0 == strcmp (entity->type, "database")) { - mongoc_database_t *db = (mongoc_database_t *) entity->value; - cursor = - mongoc_database_aggregate (db, pipeline, opts, NULL /* read prefs */); - } else { - goto done; - } - - result_from_cursor (result, cursor); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - mongoc_cursor_destroy (cursor); - bson_destroy (opts); - return ret; -} - -static bool -bulk_op_append (mongoc_bulk_operation_t *bulk, - bson_t *request, - bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - const char *op_type; - bson_parser_t *parser = NULL; - bson_t *document = NULL, *filter = NULL, *update = NULL, *replacement = NULL; - bson_t request_doc; - - bson_iter_init (&iter, request); - bson_iter_next (&iter); - if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) { - test_set_error (error, - "Unexpected non-document in bulk write model: %s", - bson_iter_key (&iter)); - } - op_type = bson_iter_key (&iter); - bson_iter_bson (&iter, &request_doc); - - parser = bson_parser_new (); - /* Pass extra options to operation. Server errors on unrecognized options. */ - bson_parser_allow_extra (parser, true); - - if (0 == strcmp (op_type, "insertOne")) { - bson_parser_doc (parser, "document", &document); - if (!bson_parser_parse (parser, &request_doc, error)) { - goto done; - } - - mongoc_bulk_operation_insert_with_opts ( - bulk, document, bson_parser_get_extra (parser), error); - } else if (0 == strcmp (op_type, "updateOne")) { - bson_parser_doc (parser, "filter", &filter); - bson_parser_array_or_doc (parser, "update", &update); - if (!bson_parser_parse (parser, &request_doc, error)) { - goto done; - } - - mongoc_bulk_operation_update_one_with_opts ( - bulk, filter, update, bson_parser_get_extra (parser), error); - } else if (0 == strcmp (op_type, "updateMany")) { - bson_parser_doc (parser, "filter", &filter); - bson_parser_array_or_doc (parser, "update", &update); - if (!bson_parser_parse (parser, &request_doc, error)) { - goto done; - } - - mongoc_bulk_operation_update_many_with_opts ( - bulk, filter, update, bson_parser_get_extra (parser), error); - } else if (0 == strcmp (op_type, "deleteOne")) { - bson_parser_doc (parser, "filter", &filter); - - if (!bson_parser_parse (parser, &request_doc, error)) { - goto done; - } - - mongoc_bulk_operation_remove_one_with_opts ( - bulk, filter, bson_parser_get_extra (parser), error); - } else if (0 == strcmp (op_type, "deleteMany")) { - bson_parser_doc (parser, "filter", &filter); - if (!bson_parser_parse (parser, &request_doc, error)) { - goto done; - } - - mongoc_bulk_operation_remove_many_with_opts ( - bulk, filter, bson_parser_get_extra (parser), error); - } else if (0 == strcmp (op_type, "replaceOne")) { - bson_parser_doc (parser, "filter", &filter); - bson_parser_doc (parser, "replacement", &replacement); - if (!bson_parser_parse (parser, &request_doc, error)) { - goto done; - } - - mongoc_bulk_operation_replace_one_with_opts ( - bulk, filter, replacement, bson_parser_get_extra (parser), error); - } - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - return ret; -} - -static bool -operation_bulk_write (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bool *ordered = NULL; - bson_t *requests = NULL; - bson_t *let = NULL; - bson_val_t *comment = NULL; - bson_t *opts = NULL; - bson_iter_t iter; - mongoc_bulk_operation_t *bulk_op = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - - parser = bson_parser_new (); - bson_parser_array (parser, "requests", &requests); - bson_parser_bool_optional (parser, "ordered", &ordered); - bson_parser_doc_optional (parser, "let", &let); - bson_parser_any_optional (parser, "comment", &comment); - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - opts = bson_new (); - if (ordered) { - BSON_APPEND_BOOL (opts, "ordered", *ordered); - } - if (!bson_empty0 (let)) { - BSON_APPEND_DOCUMENT (opts, "let", let); - } - if (comment) { - BSON_APPEND_VALUE (opts, "comment", bson_val_to_value (comment)); - } - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - bulk_op = mongoc_collection_create_bulk_operation_with_opts (coll, opts); - - BSON_FOREACH (requests, iter) - { - bson_t request; - bson_iter_bson (&iter, &request); - if (!bulk_op_append (bulk_op, &request, error)) { - goto done; - } - } - - bson_destroy (&op_reply); - mongoc_bulk_operation_execute (bulk_op, &op_reply, &op_error); - result_from_bulk_write (result, &op_reply, &op_error); - - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (&op_reply); - bson_destroy (opts); - mongoc_bulk_operation_destroy (bulk_op); - return ret; -} - -static bool -operation_count_documents (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t *filter = NULL; - int64_t op_ret = -1; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_val_t *val = NULL; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - bson_destroy (&op_reply); - op_ret = mongoc_collection_count_documents ( - coll, filter, opts, NULL /* read prefs */, &op_reply, &op_error); - - if (op_ret != -1) { - val = bson_val_from_int64 (op_ret); - } - - result_from_val_and_reply (result, val, &op_reply, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (&op_reply); - bson_val_destroy (val); - bson_destroy (opts); - return ret; -} - -static bool -operation_create_find_cursor (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - mongoc_cursor_t *cursor = NULL; - bson_t *filter = NULL; - bson_t *opts = NULL; - const bson_t *op_reply = NULL; - bson_error_t op_error = {0}; - const bson_t *first_result = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - cursor = mongoc_collection_find_with_opts ( - coll, filter, opts, NULL /* read prefs */); - - mongoc_cursor_next (cursor, &first_result); - - mongoc_cursor_error_document (cursor, &op_error, &op_reply); - result_from_val_and_reply (result, NULL, (bson_t *) op_reply, &op_error); - - ret = true; - - if (!op->save_result_as_entity) { - mongoc_cursor_destroy (cursor); - goto done; - } - - if (!entity_map_add_findcursor (test->entity_map, - op->save_result_as_entity, - cursor, - first_result, - error)) { - goto done; - } - -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (opts); - return ret; -} - -static bool -operation_create_index (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *bp = NULL; - char *name = NULL; - bson_t *keys = NULL; - bool *unique = NULL; - bson_t *create_indexes = bson_new (); - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_t *opts = bson_new (); - bson_t *index_opts = bson_new (); - mongoc_index_model_t *im = NULL; - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - bp = bson_parser_new (); - bson_parser_doc (bp, "keys", &keys); - bson_parser_utf8_optional (bp, "name", &name); - bson_parser_bool_optional (bp, "unique", &unique); - - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - if (name) { - BSON_APPEND_UTF8 (index_opts, "name", name); - } - if (unique) { - BSON_APPEND_BOOL (index_opts, "unique", *unique); - } - - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - im = mongoc_index_model_new (keys, index_opts); - mongoc_collection_create_indexes_with_opts ( - coll, &im, 1, opts, &op_reply, &op_error); - - MONGOC_DEBUG ("running createIndexes: %s", tmp_json (create_indexes)); - - printf ("got reply: %s\n", tmp_json (&op_reply)); - - result_from_val_and_reply (result, NULL, &op_reply, &op_error); - - ret = true; -done: - mongoc_index_model_destroy (im); - bson_destroy (index_opts); - bson_parser_destroy_with_parsed_fields (bp); - bson_destroy (&op_reply); - bson_destroy (opts); - bson_destroy (create_indexes); - - return ret; -} - -static bool -operation_delete_one (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t *filter = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - bson_destroy (&op_reply); - mongoc_collection_delete_one (coll, filter, opts, &op_reply, &op_error); - - result_from_delete (result, &op_reply, &op_error); - - ret = true; -done: - bson_destroy (&op_reply); - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (opts); - return ret; -} - -static bool -operation_delete_many (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t *filter = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - bson_destroy (&op_reply); - mongoc_collection_delete_many (coll, filter, opts, &op_reply, &op_error); - - result_from_delete (result, &op_reply, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (&op_reply); - bson_destroy (opts); - return ret; -} - -static bool -operation_distinct (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t *distinct = NULL; - char *field_name = NULL; - bson_t *filter = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_utf8 (parser, "fieldName", &field_name); - bson_parser_doc (parser, "filter", &filter); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - distinct = BCON_NEW ("distinct", - mongoc_collection_get_name (coll), - "key", - BCON_UTF8 (field_name), - "query", - "{", - &filter, - "}"); - - bson_destroy (&op_reply); - mongoc_collection_read_command_with_opts ( - coll, distinct, NULL /* read prefs */, opts, &op_reply, &op_error); - - result_from_distinct (result, &op_reply, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (&op_reply); - bson_destroy (distinct); - bson_destroy (opts); - return ret; -} - -static bool -operation_estimated_document_count (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - int64_t op_ret; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_val_t *val = NULL; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - bson_destroy (&op_reply); - op_ret = mongoc_collection_estimated_document_count ( - coll, opts, NULL /* read prefs */, &op_reply, &op_error); - - if (op_ret != -1) { - val = bson_val_from_int64 (op_ret); - } - - result_from_val_and_reply (result, val, &op_reply, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (&op_reply); - bson_val_destroy (val); - bson_destroy (opts); - return ret; -} - -static bool -operation_find (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - mongoc_cursor_t *cursor = NULL; - bson_t *filter = NULL; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - cursor = mongoc_collection_find_with_opts ( - coll, filter, opts, NULL /* read prefs */); - - result_from_cursor (result, cursor); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (opts); - mongoc_cursor_destroy (cursor); - return ret; -} - -static bool -operation_find_one_and_update (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_t *filter = NULL; - char *return_document = NULL; - mongoc_find_and_modify_opts_t *opts = NULL; - mongoc_find_and_modify_flags_t flags = 0; - bson_val_t *val = NULL; - bson_iter_t iter; - bson_t *session_opts = bson_new (); - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - bson_parser_utf8_optional (parser, "returnDocument", &return_document); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - opts = mongoc_find_and_modify_opts_new (); - if (return_document && 0 == strcmp (return_document, "After")) { - flags |= MONGOC_FIND_AND_MODIFY_RETURN_NEW; - } - mongoc_find_and_modify_opts_set_flags (opts, flags); - mongoc_find_and_modify_opts_append (opts, bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, session_opts, error)) { - goto done; - } - } - mongoc_find_and_modify_opts_append (opts, session_opts); - - bson_destroy (&op_reply); - mongoc_collection_find_and_modify_with_opts ( - coll, filter, opts, &op_reply, &op_error); - - if (bson_iter_init_find (&iter, &op_reply, "value")) { - val = bson_val_from_iter (&iter); - } - result_from_val_and_reply (result, val, &op_reply, &op_error); - - ret = true; -done: - bson_val_destroy (val); - bson_parser_destroy_with_parsed_fields (parser); - mongoc_find_and_modify_opts_destroy (opts); - bson_destroy (&op_reply); - bson_destroy (session_opts); - return ret; -} - -static bool -operation_find_one_and_replace (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_t *filter = NULL; - bson_t *replacement = NULL; - char *return_document = NULL; - mongoc_find_and_modify_opts_t *opts = NULL; - mongoc_find_and_modify_flags_t flags = 0; - bson_val_t *val = NULL; - bson_iter_t iter; - bson_t *session_opts = bson_new (); - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - bson_parser_doc (parser, "replacement", &replacement); - bson_parser_utf8_optional (parser, "returnDocument", &return_document); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - opts = mongoc_find_and_modify_opts_new (); - if (return_document && 0 == strcmp (return_document, "After")) { - flags |= MONGOC_FIND_AND_MODIFY_RETURN_NEW; - } - mongoc_find_and_modify_opts_set_flags (opts, flags); - mongoc_find_and_modify_opts_append (opts, bson_parser_get_extra (parser)); - mongoc_find_and_modify_opts_set_update (opts, replacement); - if (op->session) { - if (!mongoc_client_session_append (op->session, session_opts, error)) { - goto done; - } - } - mongoc_find_and_modify_opts_append (opts, session_opts); - - bson_destroy (&op_reply); - mongoc_collection_find_and_modify_with_opts ( - coll, filter, opts, &op_reply, &op_error); - - if (bson_iter_init_find (&iter, &op_reply, "value")) { - val = bson_val_from_iter (&iter); - } - result_from_val_and_reply (result, val, &op_reply, &op_error); - - ret = true; -done: - bson_val_destroy (val); - bson_parser_destroy_with_parsed_fields (parser); - mongoc_find_and_modify_opts_destroy (opts); - bson_destroy (&op_reply); - bson_destroy (session_opts); - return ret; -} - -static bool -operation_find_one_and_delete (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_t *filter = NULL; - mongoc_find_and_modify_opts_t *opts = NULL; - mongoc_find_and_modify_flags_t flags = 0; - bson_val_t *val = NULL; - bson_iter_t iter; - bson_t *session_opts = bson_new (); - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - opts = mongoc_find_and_modify_opts_new (); - flags |= MONGOC_FIND_AND_MODIFY_REMOVE; - mongoc_find_and_modify_opts_set_flags (opts, flags); - mongoc_find_and_modify_opts_append (opts, bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, session_opts, error)) { - goto done; - } - } - mongoc_find_and_modify_opts_append (opts, session_opts); - - bson_destroy (&op_reply); - mongoc_collection_find_and_modify_with_opts ( - coll, filter, opts, &op_reply, &op_error); - - if (bson_iter_init_find (&iter, &op_reply, "value")) { - val = bson_val_from_iter (&iter); - } - result_from_val_and_reply (result, val, &op_reply, &op_error); - - ret = true; -done: - bson_val_destroy (val); - bson_parser_destroy_with_parsed_fields (parser); - mongoc_find_and_modify_opts_destroy (opts); - bson_destroy (&op_reply); - bson_destroy (session_opts); - return ret; -} - -static bool -operation_insert_many (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t *documents = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_iter_t iter; - int n_docs = 0, i = 0; - bson_t **docs = NULL; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_array (parser, "documents", &documents); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - BSON_FOREACH (documents, iter) - { - n_docs++; - } - docs = bson_malloc0 (n_docs * sizeof (bson_t *)); - - MONGOC_DEBUG ("ndocs=%d", n_docs); - BSON_FOREACH (documents, iter) - { - bson_t doc; - - bson_iter_bson (&iter, &doc); - docs[i] = bson_copy (&doc); - i++; - } - - bson_destroy (&op_reply); - mongoc_collection_insert_many ( - coll, (const bson_t **) docs, n_docs, opts, &op_reply, &op_error); - result_from_insert_many (result, &op_reply, &op_error); - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - if (docs) { - for (i = 0; i < n_docs; i++) { - bson_destroy (docs[i]); - } - } - bson_free (docs); - bson_destroy (&op_reply); - bson_destroy (opts); - return ret; -} - -static bool -operation_insert_one (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_t *document = NULL; - bson_parser_t *parser = NULL; - bson_error_t op_error = {0}; - bson_t op_reply = BSON_INITIALIZER; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "document", &document); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - bson_destroy (&op_reply); - mongoc_collection_insert_one (coll, document, opts, &op_reply, &op_error); - result_from_insert_one (result, &op_reply, &op_error); - - - ret = true; -done: - bson_destroy (&op_reply); - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (opts); - return ret; -} - -static bool -operation_replace_one (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t *filter = NULL; - bson_t *replacement = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - bson_parser_doc (parser, "replacement", &replacement); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - bson_destroy (&op_reply); - mongoc_collection_replace_one ( - coll, filter, replacement, opts, &op_reply, &op_error); - - result_from_update_or_replace (result, &op_reply, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (&op_reply); - bson_destroy (opts); - return ret; -} - -static bool -operation_update_one (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t *filter = NULL; - bson_t *update = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - bson_parser_array_or_doc (parser, "update", &update); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - bson_destroy (&op_reply); - mongoc_collection_update_one ( - coll, filter, update, opts, &op_reply, &op_error); - - result_from_update_or_replace (result, &op_reply, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (&op_reply); - bson_destroy (opts); - return ret; -} - -static bool -operation_update_many (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_collection_t *coll = NULL; - bson_parser_t *parser = NULL; - bson_t *filter = NULL; - bson_t *update = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - bson_t *opts = NULL; - - parser = bson_parser_new (); - bson_parser_allow_extra (parser, true); - bson_parser_doc (parser, "filter", &filter); - bson_parser_array_or_doc (parser, "update", &update); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - opts = bson_copy (bson_parser_get_extra (parser)); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - bson_destroy (&op_reply); - mongoc_collection_update_many ( - coll, filter, update, opts, &op_reply, &op_error); - - result_from_update_or_replace (result, &op_reply, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (&op_reply); - bson_destroy (opts); - return ret; -} - -static bool -operation_iterate_until_document_or_error (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_change_stream_t *changestream = NULL; - entity_findcursor_t *findcursor = NULL; - const bson_t *doc = NULL; - const bson_t *op_reply = NULL; - bson_error_t op_error = {0}; - bson_val_t *val = NULL; - entity_t *entity; - - entity = entity_map_get (test->entity_map, op->object, error); - if (!entity) { - goto done; - } - - if (strcmp ("changestream", entity->type) == 0) { - changestream = - entity_map_get_changestream (test->entity_map, op->object, error); - if (!changestream) { - goto done; - } - - /* Loop until error or document is returned. */ - while (!mongoc_change_stream_next (changestream, &doc)) { - if (mongoc_change_stream_error_document ( - changestream, &op_error, &op_reply)) { - break; - } - } - } else { - findcursor = - entity_map_get_findcursor (test->entity_map, op->object, error); - if (!findcursor) { - goto done; - } - - entity_findcursor_iterate_until_document_or_error ( - findcursor, &doc, &op_error, &op_reply); - } - - if (NULL != doc) { - val = bson_val_from_bson ((bson_t *) doc); - } - - result_from_val_and_reply (result, val, (bson_t *) op_reply, &op_error); - - ret = true; -done: - bson_val_destroy (val); - return ret; -} - -static bool -operation_close (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - entity_t *entity; - entity = entity_map_get (test->entity_map, op->object, error); - if (!entity) { - goto done; - } - - if (0 != strcmp (entity->type, "findcursor") && - 0 != strcmp (entity->type, "changestream")) { - test_set_error ( - error, "attempting to close an unsupported entity: %s", entity->type); - goto done; - } - - entity_map_delete (test->entity_map, op->object, error); - - result_from_ok (result); - - ret = true; -done: - return ret; -} - -static bool -operation_drop_index (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - entity_t *entity; - bson_parser_t *parser = NULL; - char *index = NULL; - bson_t *opts = NULL; - mongoc_collection_t *coll = NULL; - bson_error_t op_error = {0}; - - parser = bson_parser_new (); - bson_parser_utf8 (parser, "name", &index); - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - entity = entity_map_get (test->entity_map, op->object, error); - if (!entity) { - goto done; - } - - opts = bson_new (); - if (op->session) { - if (!mongoc_client_session_append (op->session, opts, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - mongoc_collection_drop_index (coll, index, error); - result_from_val_and_reply (result, NULL, NULL, &op_error); - ret = true; - -done: - bson_parser_destroy_with_parsed_fields (parser); - bson_destroy (opts); - return ret; -} - -static bool -operation_failpoint (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = NULL; - char *client_id = NULL; - mongoc_client_t *client = NULL; - bson_t *failpoint = NULL; - mongoc_read_prefs_t *rp = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - - bp = bson_parser_new (); - bson_parser_utf8 (bp, "client", &client_id); - bson_parser_doc (bp, "failPoint", &failpoint); - - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - client = entity_map_get_client (test->entity_map, client_id, error); - if (!client) { - goto done; - } - - rp = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - bson_destroy (&op_reply); - mongoc_client_command_simple ( - client, "admin", failpoint, rp, &op_reply, &op_error); - result_from_val_and_reply (result, NULL /* value */, &op_reply, &op_error); - - /* Add failpoint to list of test_t's known failpoints */ - register_failpoint ( - test, - (char *) bson_lookup_utf8 (failpoint, "configureFailPoint"), - client_id, - 0); - - ret = true; -done: - mongoc_read_prefs_destroy (rp); - bson_parser_destroy_with_parsed_fields (bp); - bson_destroy (&op_reply); - return ret; -} - -static bool -operation_targeted_failpoint (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = NULL; - char *client_id = NULL; - mongoc_client_t *client = NULL; - bson_t *failpoint = NULL; - mongoc_read_prefs_t *rp = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - uint32_t server_id; - - bp = bson_parser_new (); - bson_parser_doc (bp, "failPoint", &failpoint); - - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - if (!op->session) { - test_set_error (error, "%s", "session unset"); - goto done; - } - - client_id = entity_map_get_session_client_id ( - test->entity_map, op->session_id, error); - if (!client_id) { - goto done; - } - - client = entity_map_get_client (test->entity_map, client_id, error); - if (!client) { - goto done; - } - - server_id = mongoc_client_session_get_server_id (op->session); - if (0 == server_id) { - test_set_error ( - error, "expected session %s to be pinned but was not", op->session_id); - goto done; - } - - rp = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - bson_destroy (&op_reply); - mongoc_client_command_simple_with_server_id ( - client, "admin", failpoint, rp, server_id, &op_reply, &op_error); - result_from_val_and_reply (result, NULL /* value */, &op_reply, &op_error); - - /* Add failpoint to list of test_t's known failpoints */ - register_failpoint ( - test, - (char *) bson_lookup_utf8 (failpoint, "configureFailPoint"), - client_id, - server_id); - - ret = true; -done: - mongoc_read_prefs_destroy (rp); - bson_parser_destroy_with_parsed_fields (bp); - bson_destroy (&op_reply); - return ret; -} - -static bool -operation_delete (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_gridfs_bucket_t *bucket = NULL; - bson_parser_t *bp = NULL; - bson_val_t *id = NULL; - bson_error_t op_error = {0}; - - bp = bson_parser_new (); - bson_parser_any (bp, "id", &id); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - bucket = entity_map_get_bucket (test->entity_map, op->object, error); - if (!bucket) { - goto done; - } - - mongoc_gridfs_bucket_delete_by_id ( - bucket, bson_val_to_value (id), &op_error); - result_from_val_and_reply (result, NULL, NULL, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (bp); - return ret; -} - -static bool -operation_download (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_gridfs_bucket_t *bucket = NULL; - bson_parser_t *bp = NULL; - bson_val_t *id = NULL; - bson_error_t op_error = {0}; - mongoc_stream_t *stream = NULL; - uint8_t buf[256]; - ssize_t bytes_read = 0; - mongoc_array_t all_bytes; - bson_val_t *val = NULL; - - _mongoc_array_init (&all_bytes, sizeof (uint8_t)); - bp = bson_parser_new (); - bson_parser_any (bp, "id", &id); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - bucket = entity_map_get_bucket (test->entity_map, op->object, error); - if (!bucket) { - goto done; - } - - stream = mongoc_gridfs_bucket_open_download_stream ( - bucket, bson_val_to_value (id), &op_error); - - if (stream) { - while ((bytes_read = - mongoc_stream_read (stream, buf, sizeof (buf), 1, 0)) > 0) { - ASSERT (bson_in_range_signed (uint32_t, bytes_read)); - _mongoc_array_append_vals (&all_bytes, buf, (uint32_t) bytes_read); - } - mongoc_gridfs_bucket_stream_error (stream, &op_error); - } - - ASSERT (bson_in_range_unsigned (uint32_t, all_bytes.len)); - val = bson_val_from_bytes (all_bytes.data, (uint32_t) all_bytes.len); - result_from_val_and_reply (result, val, NULL, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (bp); - _mongoc_array_destroy (&all_bytes); - bson_val_destroy (val); - mongoc_stream_destroy (stream); - return ret; -} - -static bool -operation_upload (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_gridfs_bucket_t *bucket = NULL; - bson_parser_t *bp = NULL; - bson_t *source = NULL; - char *filename = NULL; - mongoc_stream_t *stream = NULL; - bson_value_t file_id; - bson_error_t op_error = {0}; - bson_val_t *val = NULL; - - bp = bson_parser_new (); - bson_parser_allow_extra (bp, true); - bson_parser_doc (bp, "source", &source); - bson_parser_utf8 (bp, "filename", &filename); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - bucket = entity_map_get_bucket (test->entity_map, op->object, error); - if (!bucket) { - goto done; - } - - stream = mongoc_gridfs_bucket_open_upload_stream ( - bucket, filename, bson_parser_get_extra (bp), &file_id, &op_error); - - if (stream) { - size_t total_written = 0u; - uint8_t *source_bytes; - uint32_t source_bytes_len; - bson_iter_t iter; - - if (!bson_iter_init_find (&iter, source, "$$hexBytes") || - !BSON_ITER_HOLDS_UTF8 (&iter)) { - test_set_error (error, "$$hexBytes not found in source data"); - goto done; - } - - source_bytes = - hex_to_bin (bson_iter_utf8 (&iter, NULL), &source_bytes_len); - while (total_written < source_bytes_len) { - const ssize_t bytes_written = mongoc_stream_write ( - stream, source_bytes, source_bytes_len - total_written, 0); - if (bytes_written < 0) { - break; - } - total_written += (size_t) bytes_written; - } - mongoc_gridfs_bucket_stream_error (stream, &op_error); - bson_free (source_bytes); - } - - val = bson_val_from_value (&file_id); - result_from_val_and_reply (result, val, NULL, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (bp); - mongoc_stream_destroy (stream); - bson_val_destroy (val); - return ret; -} - -static bool -assert_session_dirty_helper (test_t *test, - operation_t *op, - result_t *result, - bool check_dirty, - bson_error_t *error) -{ - bool ret = false; - - BSON_UNUSED (test); - - if (!op->session) { - test_set_error (error, "%s", "session unset"); - goto done; - } - - if (check_dirty != mongoc_client_session_get_dirty (op->session)) { - test_set_error (error, - "expected session to%s be dirty but was not", - check_dirty ? "" : " not"); - goto done; - } - - result_from_ok (result); - - ret = true; -done: - return ret; -} -static bool -operation_assert_session_not_dirty (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - return assert_session_dirty_helper (test, op, result, false, error); -} - -static bool -operation_assert_session_dirty (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - return assert_session_dirty_helper (test, op, result, true, error); -} - -static event_t * -next_started_event (event_t *iter) -{ - if (!iter) { - return NULL; - } - - iter = iter->next; - while (iter && 0 != strcmp (iter->type, "commandStartedEvent")) { - iter = iter->next; - } - return iter; -} - -static bool -assert_lsid_on_last_two_commands (test_t *test, - operation_t *op, - result_t *result, - bool check_same, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = NULL; - char *client_id = NULL; - entity_t *entity = NULL; - event_t *a, *b; - bson_iter_t iter; - bson_t a_lsid; - bson_t b_lsid; - - bp = bson_parser_new (); - bson_parser_utf8 (bp, "client", &client_id); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - entity = entity_map_get (test->entity_map, client_id, error); - if (!entity) { - goto done; - } - - if (0 != strcmp (entity->type, "client")) { - goto done; - } - - a = NULL; - b = entity->events; - if (b && 0 != strcmp (b->type, "commandStartedEvent")) { - b = next_started_event (b); - } - - while (next_started_event (b) != NULL) { - a = b; - b = next_started_event (b); - } - - if (NULL == a || NULL == b) { - test_set_error (error, - "unable to find two commandStartedEvents on client: %s", - client_id); - goto done; - } - - if (!bson_iter_init_find (&iter, a->command, "lsid")) { - test_set_error ( - error, - "unable to find lsid in second to last commandStartedEvent: %s", - tmp_json (a->command)); - goto done; - } - - bson_iter_bson (&iter, &a_lsid); - - if (!bson_iter_init_find (&iter, b->command, "lsid")) { - test_set_error ( - error, - "unable to find lsid in second to last commandStartedEvent: %s", - tmp_json (b->command)); - goto done; - } - - bson_iter_bson (&iter, &b_lsid); - - if (check_same != bson_equal (&a_lsid, &b_lsid)) { - test_set_error (error, - "expected $lsid's to be%s equal, but got: %s and %s", - check_same ? "" : " not", - tmp_json (&a_lsid), - tmp_json (&b_lsid)); - goto done; - } - - result_from_ok (result); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (bp); - return ret; -} - -static bool -operation_assert_same_lsid_on_last_two_commands (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - return assert_lsid_on_last_two_commands (test, op, result, true, error); -} - -static bool -operation_assert_different_lsid_on_last_two_commands (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - return assert_lsid_on_last_two_commands (test, op, result, false, error); -} - -static bool -operation_end_session (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - - if (!entity_map_end_session (test->entity_map, op->object, error)) { - goto done; - } - result_from_ok (result); - - ret = true; -done: - return ret; -} - -static bool -operation_start_transaction (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_client_session_t *session = NULL; - bson_error_t op_error = {0}; - mongoc_transaction_opt_t *opts = NULL; - mongoc_read_concern_t *rc = NULL; - mongoc_write_concern_t *wc = NULL; - mongoc_read_prefs_t *rp = NULL; - bson_parser_t *bp = NULL; - - opts = mongoc_transaction_opts_new (); - bp = bson_parser_new (); - bson_parser_read_concern_optional (bp, &rc); - bson_parser_write_concern_optional (bp, &wc); - bson_parser_read_prefs_optional (bp, &rp); - if (rc) { - mongoc_transaction_opts_set_read_concern (opts, rc); - } - - if (wc) { - mongoc_transaction_opts_set_write_concern (opts, wc); - } - - if (rp) { - mongoc_transaction_opts_set_read_prefs (opts, rp); - } - - session = entity_map_get_session (test->entity_map, op->object, error); - if (!session) { - goto done; - } - - mongoc_client_session_start_transaction (session, opts, &op_error); - result_from_val_and_reply (result, NULL, NULL, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (bp); - mongoc_transaction_opts_destroy (opts); - return ret; -} - -const char * -transaction_state_to_string (mongoc_transaction_state_t tstate) -{ - switch (tstate) { - case MONGOC_TRANSACTION_NONE: - return "none"; - case MONGOC_TRANSACTION_STARTING: - return "starting"; - case MONGOC_TRANSACTION_IN_PROGRESS: - return "in_progress"; - case MONGOC_TRANSACTION_COMMITTED: - return "committed"; - case MONGOC_TRANSACTION_ABORTED: - return "aborted"; - default: - return "invalid"; - } -} - -static bool -operation_assert_session_transaction_state (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = NULL; - char *expected = NULL; - const char *actual; - mongoc_transaction_state_t state; - - BSON_UNUSED (test); - - bp = bson_parser_new (); - bson_parser_utf8 (bp, "state", &expected); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - if (!op->session) { - test_set_error (error, "expected session"); - goto done; - } - - state = mongoc_client_session_get_transaction_state (op->session); - actual = transaction_state_to_string (state); - if (0 != strcmp (expected, actual)) { - test_set_error ( - error, "expected state: %s, got state: %s", expected, actual); - goto done; - } - - result_from_ok (result); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (bp); - return ret; -} - -static bool -assert_collection_exists (test_t *test, - operation_t *op, - result_t *result, - bool expect_exist, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = NULL; - char *collection_name = NULL; - char *database_name = NULL; - mongoc_database_t *db = NULL; - bson_error_t op_error = {0}; - bool actual_exist = false; - char **head = NULL, **iter = NULL; - - bp = bson_parser_new (); - bson_parser_utf8 (bp, "collectionName", &collection_name); - bson_parser_utf8 (bp, "databaseName", &database_name); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - db = mongoc_client_get_database ( - test->test_file->test_runner->internal_client, database_name); - head = mongoc_database_get_collection_names_with_opts (db, NULL, &op_error); - for (iter = head; *iter; iter++) { - if (0 == strcmp (*iter, collection_name)) { - actual_exist = true; - break; - } - } - - if (expect_exist != actual_exist) { - test_set_error (error, - "expected collection %s %s exist but %s", - collection_name, - expect_exist ? "to" : "to not", - expect_exist ? "did not" : "did"); - goto done; - } - - result_from_val_and_reply (result, NULL, NULL, &op_error); - - ret = true; -done: - bson_strfreev (head); - mongoc_database_destroy (db); - bson_parser_destroy_with_parsed_fields (bp); - return ret; -} - -static bool -operation_assert_collection_exists (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - return assert_collection_exists (test, op, result, true, error); -} - -static bool -operation_assert_collection_not_exists (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - return assert_collection_exists (test, op, result, false, error); -} - -static bool -operation_commit_transaction (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_client_session_t *session = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - - session = entity_map_get_session (test->entity_map, op->object, error); - if (!session) { - goto done; - } - - bson_destroy (&op_reply); - mongoc_client_session_commit_transaction (session, &op_reply, &op_error); - result_from_val_and_reply (result, NULL, &op_reply, &op_error); - - ret = true; -done: - bson_destroy (&op_reply); - return ret; -} - -static bool -operation_abort_transaction (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - mongoc_client_session_t *session = NULL; - bson_error_t op_error = {0}; - - session = entity_map_get_session (test->entity_map, op->object, error); - if (!session) { - goto done; - } - - mongoc_client_session_abort_transaction (session, &op_error); - result_from_val_and_reply (result, NULL, NULL, &op_error); - - ret = true; -done: - return ret; -} - -static bool -assert_index_exists (test_t *test, - operation_t *op, - result_t *result, - bool expect_exist, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = NULL; - char *collection_name = NULL; - char *database_name = NULL; - char *index_name = NULL; - mongoc_collection_t *coll = NULL; - bson_error_t op_error = {0}; - bool actual_exist = false; - mongoc_cursor_t *cursor = NULL; - const bson_t *index; - const bson_t *error_doc = NULL; - - bp = bson_parser_new (); - bson_parser_utf8 (bp, "collectionName", &collection_name); - bson_parser_utf8 (bp, "databaseName", &database_name); - bson_parser_utf8 (bp, "indexName", &index_name); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - coll = mongoc_client_get_collection ( - test->test_file->test_runner->internal_client, - database_name, - collection_name); - cursor = mongoc_collection_find_indexes_with_opts (coll, NULL); - while (mongoc_cursor_next (cursor, &index)) { - bson_iter_t iter; - - if (!bson_iter_init_find (&iter, index, "name")) { - continue; - } - - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - continue; - } - - if (0 != strcmp (bson_iter_utf8 (&iter, NULL), index_name)) { - continue; - } - - actual_exist = true; - break; - } - - mongoc_cursor_error_document (cursor, &op_error, &error_doc); - - if (expect_exist != actual_exist) { - test_set_error (error, - "expected index %s %s exist but %s", - index_name, - expect_exist ? "to" : "to not", - expect_exist ? "did not" : "did"); - goto done; - } - - result_from_val_and_reply (result, NULL, (bson_t *) error_doc, &op_error); - - ret = true; -done: - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (coll); - bson_parser_destroy_with_parsed_fields (bp); - return ret; -} - -static bool -operation_assert_index_exists (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - return assert_index_exists (test, op, result, true, error); -} - -static bool -operation_assert_index_not_exists (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - return assert_index_exists (test, op, result, false, error); -} - -typedef struct { - test_t *test; - bson_t *ops; -} txn_ctx_t; - -static bool -with_transaction_cb (mongoc_client_session_t *session, - void *ctx, - bson_t **reply, - bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - txn_ctx_t *tctx = NULL; - - BSON_UNUSED (session); - BSON_UNUSED (reply); - - tctx = (txn_ctx_t *) ctx; - - BSON_FOREACH (tctx->ops, iter) - { - bson_t op_bson; - - bson_iter_bson (&iter, &op_bson); - MONGOC_DEBUG ("in with_transaction_cb running: %s", tmp_json (&op_bson)); - if (!operation_run (tctx->test, &op_bson, error)) { - goto done; - } - } - - ret = true; -done: - return ret; -} - -static bool -operation_with_transaction (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = NULL; - mongoc_client_session_t *session = NULL; - bson_t op_reply = BSON_INITIALIZER; - bson_error_t op_error = {0}; - mongoc_read_concern_t *rc = NULL; - mongoc_write_concern_t *wc = NULL; - mongoc_read_prefs_t *rp = NULL; - mongoc_transaction_opt_t *topts = NULL; - txn_ctx_t tctx; - - session = entity_map_get_session (test->entity_map, op->object, error); - if (!session) { - goto done; - } - - topts = mongoc_transaction_opts_new (); - - bp = bson_parser_new (); - bson_parser_array (bp, "callback", &tctx.ops); - bson_parser_read_concern_optional (bp, &rc); - bson_parser_write_concern_optional (bp, &wc); - bson_parser_read_prefs_optional (bp, &rp); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - if (rc) { - mongoc_transaction_opts_set_read_concern (topts, rc); - } - - if (wc) { - mongoc_transaction_opts_set_write_concern (topts, wc); - } - - if (rp) { - mongoc_transaction_opts_set_read_prefs (topts, rp); - } - - tctx.test = test; - bson_destroy (&op_reply); - mongoc_client_session_with_transaction ( - session, with_transaction_cb, topts, &tctx, &op_reply, &op_error); - - result_from_val_and_reply (result, NULL, &op_reply, &op_error); - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (bp); - mongoc_transaction_opts_destroy (topts); - bson_destroy (&op_reply); - return ret; -} - -static bool -assert_session_pinned (test_t *test, - operation_t *op, - result_t *result, - bool expect_pinned, - bson_error_t *error) -{ - bool ret = false; - bool actual_pinned = false; - - BSON_UNUSED (test); - - if (!op->session) { - test_set_error (error, "%s", "expected session to be set"); - goto done; - } - - if (0 != mongoc_client_session_get_server_id (op->session)) { - actual_pinned = true; - } - - if (actual_pinned != expect_pinned) { - test_set_error (error, - "expected session to be %s but got %s", - expect_pinned ? "pinned" : "unpinned", - expect_pinned ? "unpinned" : "pinnned"); - goto done; - } - - result_from_ok (result); - ret = true; -done: - return ret; -} - -static bool -operation_assert_session_pinned (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - return assert_session_pinned (test, op, result, true, error); -} - -static bool -operation_assert_session_unpinned (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - return assert_session_pinned (test, op, result, false, error); -} - -static bool -create_loop_bson_array_entity (entity_map_t *em, - const char *id, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (em); - BSON_ASSERT (id || true); - BSON_ASSERT (error || true); - - if (!id) { - // Nothing to do. - return true; - } - - const entity_t *const entity = entity_map_get (em, id, error); - - // If the entity does not exist, the test runner MUST create it with the - // type of BSON array. - if (!entity) { - return entity_map_add_bson_array (em, id, error); - } - - // If the entity exists and is of type BSON array, the test runner MUST do - // nothing. - else if (strcmp (entity->type, "bson_array") == 0) { - return true; - } - - // If the entity exists and is of a different type, the test runner MUST - // raise an error. - else { - test_set_error ( - error, "loop entity %s exists but is not of type BSON array", id); - return false; - } -} - -static bool -create_loop_size_t_entity (entity_map_t *em, - const char *id, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (em); - BSON_ASSERT (id || true); - BSON_ASSERT (error || true); - - if (!id) { - return true; - } - - const entity_t *const entity = entity_map_get (em, id, error); - - // If the entity of the specified name already exists, the test runner MUST - // raise an error. - if (entity) { - test_set_error ( - error, "loop entity %s already exists when it should not", id); - return false; - } - - return entity_map_add_size_t (em, id, bson_malloc0 (sizeof (size_t)), error); -} - -static void -increment_loop_counter (entity_map_t *em, const char *id) -{ - BSON_ASSERT_PARAM (em); - BSON_ASSERT (id || true); - - if (id) { - bson_error_t error = {0}; - size_t *const counter = entity_map_get_size_t (em, id, &error); - - // Entity should always be valid at this point. - ASSERT_OR_PRINT (counter, error); - - *counter += 1u; - } -} - -static bool -append_loop_error (entity_map_t *em, - const char *id, - bson_error_t *op_error, - bson_error_t *error) -{ - BSON_ASSERT_PARAM (em); - BSON_ASSERT (id || true); - BSON_ASSERT_PARAM (op_error); - BSON_ASSERT (error || true); - - if (!id) { - return true; - } - - mongoc_array_t *array = entity_map_get_bson_array (em, id, error); - - if (!array) { - return false; - } - - const int64_t usecs = usecs_since_epoch (); - const double secs = (double) usecs / 1000000.0; - - bson_t *doc = bson_new (); - BSON_APPEND_UTF8 (doc, "error", op_error->message); - BSON_APPEND_DOUBLE (doc, "time", secs); - - _mongoc_array_append_val (array, doc); // Transfer ownership. - - return true; -} - -// Expected to be set by a SIGINT (on Linux and OS X) or CTRL_BREAK_EVENT (on -// Windows) handler when test suite is being executed by test-atlas-executor. -volatile sig_atomic_t operation_loop_terminated = false; - -static bool -operation_loop (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - - BSON_ASSERT_PARAM (test); - BSON_ASSERT_PARAM (op); - BSON_ASSERT_PARAM (result); - BSON_ASSERT_PARAM (error); - - if (test->loop_operation_executed) { - test_set_error (error, - "test should not contain more than one loop operation"); - return false; - } else { - test->loop_operation_executed = true; - } - - if (!op->object || strcmp (op->object, "testRunner") != 0) { - test_set_error (error, "loop operation object should be \"testRunner\""); - return false; - } - - bson_t *operations = NULL; - char *errors_as_entity = NULL; - char *failures_as_entity = NULL; - char *successes_as_entity = NULL; - char *iterations_as_entity = NULL; - - bson_parser_t *const parser = bson_parser_new (); - - bson_parser_array (parser, "operations", &operations); - bson_parser_utf8_optional (parser, "storeErrorsAsEntity", &errors_as_entity); - bson_parser_utf8_optional ( - parser, "storeFailuresAsEntity", &failures_as_entity); - bson_parser_utf8_optional ( - parser, "storeSuccessesAsEntity", &successes_as_entity); - bson_parser_utf8_optional ( - parser, "storeIterationsAsEntity", &iterations_as_entity); - - if (!bson_parser_parse (parser, op->arguments, error)) { - goto done; - } - - // If the test runner propagates an error or failure (e.g. it is not captured - // by the loop or occurs outside of the loop), it MUST be reported by the - // workload executor. - const bool should_propagate = !failures_as_entity && !errors_as_entity; - - // Guarantee propagation of errors if captures are not defined by the loop. - if (should_propagate) { - // Ensure any errors or failures are still reported. - errors_as_entity = bson_strdup ("errors"); - } - - // If only one of errors or failures is provided, all failures and errors - // must be stored in the provided entity. - if ((errors_as_entity ? 1 : 0) != (failures_as_entity ? 1 : 0)) { - if (errors_as_entity) { - failures_as_entity = bson_strdup (errors_as_entity); - } else { - errors_as_entity = bson_strdup (failures_as_entity); - } - } - - if (!create_loop_bson_array_entity ( - test->entity_map, errors_as_entity, error)) { - goto done; - } - - if (!create_loop_bson_array_entity ( - test->entity_map, failures_as_entity, error)) { - goto done; - } - - if (!create_loop_size_t_entity ( - test->entity_map, successes_as_entity, error)) { - goto done; - } - - if (!create_loop_size_t_entity ( - test->entity_map, iterations_as_entity, error)) { - goto done; - } - - MONGOC_DEBUG ("running loop operations..."); - // `operation_loop_terminated` may be set to true within the loop if - // `should_propagate` is true on error/failure or by test-atlas-executor upon - // receiving a termination request. - while (!operation_loop_terminated) { - // Clear any prior errors that may have occurred. - error->code = 0; - - increment_loop_counter (test->entity_map, iterations_as_entity); - - bson_iter_t iter; - BSON_FOREACH (operations, iter) - { - bson_t op_bson; - bson_iter_bson (&iter, &op_bson); - - bson_error_t op_error = {0}; - - // Execute the loop sub-operation. - const bool res = operation_run (test, &op_bson, &op_error); - - if (res) { - increment_loop_counter (test->entity_map, successes_as_entity); - } else { - // Categorize errors triggered by a sub-operation as a "failure". - // If this operation fails, categorize as an "error" instead. - (void) append_loop_error ( - test->entity_map, failures_as_entity, &op_error, error); - - // If neither storeErrorsAsEntity nor storeFailuresAsEntity are - // specified, the loop MUST terminate and raise the error/failure - // (i.e. the error/failure will interrupt the test). - operation_loop_terminated = - operation_loop_terminated || should_propagate; - - // If, in the course of executing sub-operations, a sub-operation - // yields an error or failure, the test runner MUST NOT execute - // subsequent sub-operations in the same loop iteration. - break; - } - } // End of loop sub-operations, but *not* end of loop iterations. - - // Categorize errors triggered outside of sub-operation execution as - // "errors". - if (error->code != 0) { - // We have a problem if we can't store errors without triggering a new - // error. Terminate the test suite early instead of looping with an - // irrecoverable state. - ASSERT_OR_PRINT (append_loop_error ( - test->entity_map, errors_as_entity, error, error), - (*error)); - - // If neither storeErrorsAsEntity nor storeFailuresAsEntity are - // specified, the loop MUST terminate and raise the error/failure - // (i.e. the error/failure will interrupt the test). - operation_loop_terminated = - operation_loop_terminated || should_propagate; - } - } - MONGOC_DEBUG ("running loop operations... done."); - - result_from_ok (result); - ret = true; - -done: - bson_parser_destroy_with_parsed_fields (parser); - - return ret; -} - -static bool -operation_assert_number_connections_checked_out (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - BSON_UNUSED (test); - BSON_UNUSED (op); - BSON_UNUSED (error); - /* "This operation only applies to drivers that implement connection pooling - * and should be skipped for drivers that do not." - * TODO: (CDRIVER-3525) add this assertion when CMAP is implemented. */ - result_from_ok (result); - return true; -} - -static bool -operation_rename (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - // First validate the arguments - const char *object = op->object; - bson_parser_t *bp = bson_parser_new (); - bool ret = false; - bool *drop_target = false; - char *new_name = NULL; - bson_parser_utf8 (bp, "to", &new_name); - bson_parser_bool_optional (bp, "dropTarget", &drop_target); - bool parse_ok = bson_parser_parse (bp, op->arguments, error); - bson_parser_destroy (bp); - if (!parse_ok) { - goto done; - } - - // Now get the entity - entity_t *ent = entity_map_get (test->entity_map, object, error); - if (!ent) { - goto done; - } - // We only support collections so far - if (0 != strcmp (ent->type, "collection")) { - test_set_error (error, - "'rename' is only supported for collection objects " - "'%s' has type '%s'", - object, - ent->type); - goto done; - } - - // Rename the collection in the server, - mongoc_collection_t *coll = ent->value; - if (!mongoc_collection_rename (coll, NULL, new_name, drop_target, error)) { - goto done; - } - result_from_ok (result); - ret = true; -done: - bson_free (new_name); - bson_free (drop_target); - return ret; -} - -static bool -operation_createSearchIndex (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = bson_parser_new (); - bson_t *model = NULL; - mongoc_collection_t *coll = NULL; - bson_error_t op_error; - bson_t op_reply = BSON_INITIALIZER; - bson_t *cmd = bson_new (); - - // Parse arguments. - bson_parser_doc (bp, "model", &model); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - // Build command. - bsonBuildAppend (*cmd, - kv ("createSearchIndexes", cstr (coll->collection)), - kv ("indexes", array (bson (*model)))); - ASSERT (!bsonBuildError); - - mongoc_collection_command_simple ( - coll, cmd, NULL /* read_prefs */, NULL /* reply */, &op_error); - result_from_val_and_reply (result, NULL, &op_reply, &op_error); - ret = true; -done: - bson_destroy (cmd); - bson_parser_destroy_with_parsed_fields (bp); - bson_destroy (&op_reply); - return ret; -} - -static bool -operation_createSearchIndexes (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = bson_parser_new (); - bson_t *models = NULL; - mongoc_collection_t *coll = NULL; - bson_error_t op_error; - bson_t op_reply = BSON_INITIALIZER; - bson_t *cmd = bson_new (); - - // Parse arguments. - bson_parser_array (bp, "models", &models); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - // Build command. - bsonBuildAppend (*cmd, - kv ("createSearchIndexes", cstr (coll->collection)), - kv ("indexes", bsonArray (*models))); - ASSERT (!bsonBuildError); - - mongoc_collection_command_simple ( - coll, cmd, NULL /* read_prefs */, NULL /* reply */, &op_error); - result_from_val_and_reply (result, NULL, &op_reply, &op_error); - ret = true; -done: - bson_destroy (cmd); - bson_parser_destroy_with_parsed_fields (bp); - bson_destroy (&op_reply); - return ret; -} - -static bool -operation_dropSearchIndex (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = bson_parser_new (); - char *name = NULL; - mongoc_collection_t *coll = NULL; - bson_error_t op_error; - bson_t op_reply = BSON_INITIALIZER; - bson_t *cmd = bson_new (); - - // Parse arguments. - bson_parser_utf8 (bp, "name", &name); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - // Build command. - bsonBuildAppend (*cmd, - kv ("dropSearchIndex", cstr (coll->collection)), - kv ("name", cstr (name))); - ASSERT (!bsonBuildError); - - mongoc_collection_command_simple ( - coll, cmd, NULL /* read_prefs */, NULL /* reply */, &op_error); - result_from_val_and_reply (result, NULL, &op_reply, &op_error); - ret = true; -done: - bson_destroy (cmd); - bson_parser_destroy_with_parsed_fields (bp); - bson_destroy (&op_reply); - return ret; -} - -static bool -operation_listSearchIndexes (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = bson_parser_new (); - bson_t *aggregateOptions = NULL; - char *name = NULL; - mongoc_collection_t *coll = NULL; - bson_t *pipeline = bson_new (); - mongoc_cursor_t *cursor = NULL; - - // Parse arguments. - if (op->arguments) { - bson_parser_utf8_optional (bp, "name", &name); - bson_parser_doc_optional (bp, "aggregationOptions", &aggregateOptions); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - // Build command. - bsonBuildAppend ( - *pipeline, - kv ("pipeline", - array (doc (kv ("$listSearchIndexes", - if (name != NULL, - then (doc (kv ("name", cstr (name)))), - else (doc ()))))))); - ASSERT (!bsonBuildError); - - cursor = mongoc_collection_aggregate (coll, - MONGOC_QUERY_NONE, - pipeline, - aggregateOptions /* opts */, - NULL /* read_prefs */); - - result_from_cursor (result, cursor); - ret = true; -done: - mongoc_cursor_destroy (cursor); - bson_destroy (pipeline); - bson_parser_destroy_with_parsed_fields (bp); - return ret; -} - -static bool -operation_updateSearchIndex (test_t *test, - operation_t *op, - result_t *result, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = bson_parser_new (); - bson_t *definition = NULL; - char *name = NULL; - mongoc_collection_t *coll = NULL; - bson_error_t op_error; - bson_t op_reply = BSON_INITIALIZER; - bson_t *cmd = bson_new (); - - // Parse arguments. - bson_parser_doc (bp, "definition", &definition); - bson_parser_utf8_optional (bp, "name", &name); - if (!bson_parser_parse (bp, op->arguments, error)) { - goto done; - } - - coll = entity_map_get_collection (test->entity_map, op->object, error); - if (!coll) { - goto done; - } - - // Build command. - bsonBuildAppend (*cmd, - kv ("updateSearchIndex", cstr (coll->collection)), - kv ("definition", bson (*definition)), - if (name != NULL, then (kv ("name", cstr (name))))); - ASSERT (!bsonBuildError); - - mongoc_collection_command_simple ( - coll, cmd, NULL /* read_prefs */, NULL /* reply */, &op_error); - result_from_val_and_reply (result, NULL, &op_reply, &op_error); - ret = true; -done: - bson_destroy (cmd); - bson_parser_destroy_with_parsed_fields (bp); - bson_destroy (&op_reply); - return ret; -} - -typedef struct { - const char *op; - bool (*fn) (test_t *, operation_t *, result_t *, bson_error_t *); -} op_to_fn_t; - -bool -operation_run (test_t *test, bson_t *op_bson, bson_error_t *error) -{ - operation_t *op = NULL; - result_t *result = NULL; - int i, num_ops; - bool check_result = true; - op_to_fn_t op_to_fn_map[] = { - /* Client operations */ - {"createChangeStream", operation_create_change_stream}, - {"listDatabases", operation_list_databases}, - {"listDatabaseNames", operation_list_database_names}, - - /* ClientEncryption operations */ - {"createDataKey", operation_create_datakey}, - {"rewrapManyDataKey", operation_rewrap_many_datakey}, - {"deleteKey", operation_delete_key}, - {"getKey", operation_get_key}, - {"getKeys", operation_get_keys}, - {"addKeyAltName", operation_add_key_alt_name}, - {"removeKeyAltName", operation_remove_key_alt_name}, - {"getKeyByAltName", operation_get_key_by_alt_name}, - {"encrypt", operation_encrypt}, - {"decrypt", operation_decrypt}, - - /* Database operations */ - {"createCollection", operation_create_collection}, - {"dropCollection", operation_drop_collection}, - {"listCollections", operation_list_collections}, - {"listCollectionNames", operation_list_collection_names}, - {"listIndexes", operation_list_indexes}, - {"runCommand", operation_run_command}, - {"modifyCollection", operation_modify_collection}, - - /* Collection operations */ - {"aggregate", operation_aggregate}, - {"bulkWrite", operation_bulk_write}, - {"countDocuments", operation_count_documents}, - {"createFindCursor", operation_create_find_cursor}, - {"createIndex", operation_create_index}, - {"deleteOne", operation_delete_one}, - {"deleteMany", operation_delete_many}, - {"distinct", operation_distinct}, - {"estimatedDocumentCount", operation_estimated_document_count}, - {"find", operation_find}, - {"findOneAndDelete", operation_find_one_and_delete}, - {"findOneAndReplace", operation_find_one_and_replace}, - {"findOneAndUpdate", operation_find_one_and_update}, - {"insertMany", operation_insert_many}, - {"insertOne", operation_insert_one}, - {"replaceOne", operation_replace_one}, - {"updateOne", operation_update_one}, - {"updateMany", operation_update_many}, - {"rename", operation_rename}, - {"createSearchIndex", operation_createSearchIndex}, - {"createSearchIndexes", operation_createSearchIndexes}, - {"dropSearchIndex", operation_dropSearchIndex}, - {"listSearchIndexes", operation_listSearchIndexes}, - {"updateSearchIndex", operation_updateSearchIndex}, - - /* Change stream and cursor operations */ - {"iterateUntilDocumentOrError", - operation_iterate_until_document_or_error}, - {"close", operation_close}, - {"dropIndex", operation_drop_index}, - - /* Test runner operations */ - {"failPoint", operation_failpoint}, - {"targetedFailPoint", operation_targeted_failpoint}, - {"assertSessionDirty", operation_assert_session_dirty}, - {"assertSessionNotDirty", operation_assert_session_not_dirty}, - {"assertSameLsidOnLastTwoCommands", - operation_assert_same_lsid_on_last_two_commands}, - {"assertDifferentLsidOnLastTwoCommands", - operation_assert_different_lsid_on_last_two_commands}, - {"assertSessionTransactionState", - operation_assert_session_transaction_state}, - {"assertCollectionNotExists", operation_assert_collection_not_exists}, - {"assertCollectionExists", operation_assert_collection_exists}, - {"assertIndexNotExists", operation_assert_index_not_exists}, - {"assertIndexExists", operation_assert_index_exists}, - {"assertSessionPinned", operation_assert_session_pinned}, - {"assertSessionUnpinned", operation_assert_session_unpinned}, - {"loop", operation_loop}, - {"assertNumberConnectionsCheckedOut", - operation_assert_number_connections_checked_out}, - - /* GridFS operations */ - {"delete", operation_delete}, - {"download", operation_download}, - {"upload", operation_upload}, - - /* Session operations. */ - {"endSession", operation_end_session}, - {"startTransaction", operation_start_transaction}, - {"commitTransaction", operation_commit_transaction}, - {"withTransaction", operation_with_transaction}, - {"abortTransaction", operation_abort_transaction}, - - }; - bool ret = false; - - op = operation_new (op_bson, error); - if (!op) { - goto done; - } - - /* Check for a "session" argument in all operations, it can be - * an argument for any operation. */ - if (op->arguments && bson_has_field (op->arguments, "session")) { - bson_t copied; - mongoc_client_session_t *session = NULL; - - op->session_id = - bson_strdup (bson_lookup_utf8 (op->arguments, "session")); - session = - entity_map_get_session (test->entity_map, op->session_id, error); - - if (!session) { - goto done; - } - - bson_copy_to_excluding (op->arguments, &copied, "session", NULL); - bson_destroy (op->arguments); - op->arguments = bson_copy (&copied); - bson_destroy (&copied); - op->session = session; - } - - // Avoid spamming output with sub-operations when executing loop operation. - if (!test->loop_operation_executed || operation_loop_terminated) { - MONGOC_DEBUG ("running operation: %s", tmp_json (op_bson)); - } - - num_ops = sizeof (op_to_fn_map) / sizeof (op_to_fn_t); - result = result_new (); - - if (op->ignore_result_and_error && *op->ignore_result_and_error) { - check_result = false; - } - - for (i = 0; i < num_ops; i++) { - if (0 == strcmp (op->name, op_to_fn_map[i].op)) { - if (!op_to_fn_map[i].fn (test, op, result, error)) { - goto done; - } - if (check_result && !result_check (result, - test->entity_map, - op->expect_result, - op->expect_error, - error)) { - test_diagnostics_error_info ( - "checking for result (%s) / error (%s)", - bson_val_to_json (op->expect_result), - tmp_json (op->expect_error)); - goto done; - } - if (result_get_val (result) != NULL && op->save_result_as_entity) { - if (!entity_map_add_bson (test->entity_map, - op->save_result_as_entity, - result_get_val (result), - error)) { - goto done; - } - } - break; - } - } - - if (i == num_ops) { - test_set_error (error, "unrecognized operation: %s", op->name); - goto done; - } - - ret = true; -done: - operation_destroy (op); - result_destroy (result); - return ret; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/result.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/result.c deleted file mode 100644 index ddc2bbaac..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/result.c +++ /dev/null @@ -1,661 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "result.h" - -#include "bson/bson.h" -#include "bsonutil/bson-parser.h" -#include "bsonutil/bson-match.h" -#include "mongoc-error-private.h" -#include "test-conveniences.h" -#include "util.h" -#include "TestSuite.h" - -struct _result_t { - bool ok; - bson_val_t *value; - bson_error_t error; - /* For a write operation, reply is the original unmodified write result for a - write operation. - For a read operation, reply is an optional server reply. */ - bson_t *reply; - char *str; - bool array_of_root_docs; -}; - -result_t * -result_new (void) -{ - return bson_malloc0 (sizeof (result_t)); -} - -static void -_result_init (result_t *result, - const bson_val_t *value, - const bson_t *reply, - const bson_error_t *error) -{ - bson_string_t *str; - - str = bson_string_new (""); - - if (value) { - result->value = bson_val_copy (value); - bson_string_append_printf (str, "value=%s ", bson_val_to_json (value)); - } - - if (reply) { - char *reply_str = bson_as_canonical_extended_json (reply, NULL); - - bson_string_append_printf (str, "reply=%s ", reply_str); - result->reply = bson_copy (reply); - bson_free (reply_str); - } - - bson_string_append_printf (str, "bson_error=%s", error->message); - memcpy (&result->error, error, sizeof (bson_error_t)); - result->ok = (error->code == 0); - result->str = bson_string_free (str, false); -} - -void -result_destroy (result_t *result) -{ - if (!result) { - return; - } - bson_val_destroy (result->value); - bson_destroy (result->reply); - bson_free (result->str); - bson_free (result); -} - -const char * -result_to_string (result_t *result) -{ - return result->str; -} - -bson_val_t * -result_get_val (result_t *result) -{ - return result->value; -} - -bson_t * -rewrite_upserted_ids (bson_t *mongoc_upserted_ids) -{ - bson_t *upserted_ids; - bson_iter_t iter; - - upserted_ids = bson_new (); - BSON_FOREACH (mongoc_upserted_ids, iter) - { - bson_t el; - bson_parser_t *el_bp; - int64_t *index; - bson_val_t *id; - char storage[16]; - const char *key; - - bson_iter_bson (&iter, &el); - el_bp = bson_parser_new (); - bson_parser_int (el_bp, "index", &index); - bson_parser_any (el_bp, "_id", &id); - bson_parser_parse_or_assert (el_bp, &el); - bson_uint32_to_string ( - (uint32_t) *index, &key, storage, sizeof (storage)); - BSON_APPEND_VALUE (upserted_ids, key, bson_val_to_value (id)); - bson_parser_destroy_with_parsed_fields (el_bp); - } - - return upserted_ids; -} - -bson_t * -rewrite_bulk_write_result (const bson_t *bulk_write_result) -{ - bson_t *const res = bson_new (); - if (!bson_empty0 (bulk_write_result)) { - BCON_APPEND ( - res, - "insertedCount", - BCON_INT32 (bson_lookup_int32 (bulk_write_result, "nInserted")), - "deletedCount", - BCON_INT32 (bson_lookup_int32 (bulk_write_result, "nRemoved")), - "matchedCount", - BCON_INT32 (bson_lookup_int32 (bulk_write_result, "nMatched")), - "modifiedCount", - BCON_INT32 (bson_lookup_int32 (bulk_write_result, "nModified")), - "upsertedCount", - BCON_INT32 (bson_lookup_int32 (bulk_write_result, "nUpserted"))); - - if (bson_has_field (bulk_write_result, "upserted")) { - bson_t *const upserted_ids = - bson_lookup_bson (bulk_write_result, "upserted"); - bson_t *const rewritten_upserted_ids = - rewrite_upserted_ids (upserted_ids); - BSON_APPEND_DOCUMENT (res, "upsertedIds", rewritten_upserted_ids); - bson_destroy (upserted_ids); - bson_destroy (rewritten_upserted_ids); - } else { - /* upsertedIds is a required field in BulkWriteResult, so append an - * empty document even if no documents were upserted. */ - bson_t empty = BSON_INITIALIZER; - BSON_APPEND_DOCUMENT (res, "upsertedIds", &empty); - } - } - return res; -} - -void -result_from_bulk_write (result_t *result, - const bson_t *reply, - const bson_error_t *error) -{ - bson_t *const write_result = rewrite_bulk_write_result (reply); - bson_val_t *const val = bson_val_from_bson (write_result); - - _result_init (result, val, reply, error); - - bson_val_destroy (val); - bson_destroy (write_result); -} - -void -result_from_insert_one (result_t *result, - const bson_t *reply, - const bson_error_t *error) -{ - bson_t *write_result; - bson_val_t *val; - - write_result = bson_new (); - if (!bson_empty (reply)) { - BCON_APPEND (write_result, - "insertedCount", - BCON_INT32 (bson_lookup_int32 (reply, "insertedCount"))); - } - - val = bson_val_from_bson (write_result); - _result_init (result, val, reply, error); - bson_val_destroy (val); - bson_destroy (write_result); -} - -void -result_from_insert_many (result_t *result, - const bson_t *reply, - const bson_error_t *error) -{ - bson_t *write_result; - bson_val_t *val; - - write_result = bson_new (); - if (!bson_empty (reply)) { - BCON_APPEND (write_result, - "insertedCount", - BCON_INT32 (bson_lookup_int32 (reply, "insertedCount")), - "deletedCount", - BCON_INT32 (0), - "matchedCount", - BCON_INT32 (0), - "modifiedCount", - BCON_INT32 (0), - "upsertedCount", - BCON_INT32 (0), - "upsertedIds", - "{", - "}"); - } - - val = bson_val_from_bson (write_result); - _result_init (result, val, reply, error); - bson_val_destroy (val); - bson_destroy (write_result); -} - -void -result_from_update_or_replace (result_t *result, - const bson_t *reply, - const bson_error_t *error) -{ - bson_t *write_result; - bson_val_t *val; - bson_iter_t iter; - - write_result = bson_new (); - if (!bson_empty (reply)) { - BCON_APPEND (write_result, - "matchedCount", - BCON_INT32 (bson_lookup_int32 (reply, "matchedCount")), - "modifiedCount", - BCON_INT32 (bson_lookup_int32 (reply, "modifiedCount")), - "upsertedCount", - BCON_INT32 (bson_lookup_int32 (reply, "upsertedCount"))); - - if (bson_iter_init_find (&iter, reply, "upsertedId")) { - BSON_APPEND_VALUE ( - write_result, "upsertedId", bson_iter_value (&iter)); - } - } - - val = bson_val_from_bson (write_result); - _result_init (result, val, reply, error); - bson_val_destroy (val); - bson_destroy (write_result); -} - -void -result_from_delete (result_t *result, - const bson_t *reply, - const bson_error_t *error) -{ - bson_t *write_result; - bson_val_t *val; - - write_result = bson_new (); - if (!bson_empty (reply)) { - BCON_APPEND (write_result, - "deletedCount", - BCON_INT32 (bson_lookup_int32 (reply, "deletedCount"))); - } - - val = bson_val_from_bson (write_result); - _result_init (result, val, reply, error); - bson_val_destroy (val); - bson_destroy (write_result); -} - -void -result_from_distinct (result_t *result, - const bson_t *reply, - const bson_error_t *error) -{ - bson_val_t *val = NULL; - bson_iter_t iter; - - if (!bson_empty (reply)) { - if (bson_iter_init_find (&iter, reply, "values")) { - val = bson_val_from_iter (&iter); - } - } - - _result_init (result, val, reply, error); - bson_val_destroy (val); -} - -void -result_from_cursor (result_t *result, mongoc_cursor_t *cursor) -{ - bson_error_t error = {0}; - const bson_t *reply = NULL; - bson_t *documents = bson_new (); - uint32_t i = 0; - const bson_t *doc; - bson_val_t *val; - - while (mongoc_cursor_next (cursor, &doc)) { - const char *key; - char storage[16]; - - bson_uint32_to_string ( - i, &key, storage, sizeof (storage) / sizeof (char)); - BSON_APPEND_DOCUMENT (documents, key, doc); - i++; - } - - mongoc_cursor_error_document (cursor, &error, &reply); - val = bson_val_from_array (documents); - - _result_init (result, val, (bson_t *) reply, &error); - result->array_of_root_docs = true; - bson_destroy (documents); - bson_val_destroy (val); -} - -void -result_from_val_and_reply (result_t *result, - const bson_val_t *val, - const bson_t *reply, - const bson_error_t *error) -{ - _result_init (result, val, reply, error); -} - -void -result_from_ok (result_t *result) -{ - bson_error_t error = {0}; - _result_init (result, NULL, NULL, &error); -} - -bool -result_check (result_t *result, - entity_map_t *em, - bson_val_t *expect_result, - bson_t *expect_error, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *parser = NULL; - bool *is_error; - bool *is_client_error; - char *error_contains; - int64_t *error_code; - char *error_code_name; - bson_t *error_labels_contain; - bson_t *error_labels_omit; - bson_val_t *error_expect_result; - bson_val_t *error_response; - - if (!expect_result && !expect_error) { - if (!result->ok) { - test_set_error (error, - "expected success, but got error: %s", - result->error.message); - goto done; - } - ret = true; - goto done; - } - - /* check result. */ - if (expect_result) { - if (!result->ok) { - test_set_error ( - error, "expected result, but got error: %s", result->error.message); - goto done; - } - if (!entity_map_match (em, - expect_result, - result->value, - result->array_of_root_docs, - error)) { - test_diagnostics_error_info ( - "expectResult mismatch:\nExpected: %s\nActual: %s\n", - bson_val_to_json (expect_result), - bson_val_to_json (result->value)); - goto done; - } - } - - if (expect_error) { - parser = bson_parser_new (); - bson_parser_bool_optional (parser, "isError", &is_error); - bson_parser_bool_optional (parser, "isClientError", &is_client_error); - bson_parser_utf8_optional (parser, "errorContains", &error_contains); - bson_parser_int_optional (parser, "errorCode", &error_code); - bson_parser_utf8_optional (parser, "errorCodeName", &error_code_name); - bson_parser_array_optional ( - parser, "errorLabelsContain", &error_labels_contain); - bson_parser_array_optional ( - parser, "errorLabelsOmit", &error_labels_omit); - bson_parser_any_optional (parser, "expectResult", &error_expect_result); - bson_parser_any_optional (parser, "errorResponse", &error_response); - if (!bson_parser_parse (parser, expect_error, error)) { - goto done; - } - - MONGOC_DEBUG ("expected error"); - - if (result->ok) { - test_set_error (error, - "expected error, but no error: %s", - bson_val_to_json (result->value)); - goto done; - } - - if (is_client_error && *is_client_error) { - /* from errors.rst: "In Version 2, error codes originating on the - * server always have error domain ``MONGOC_ERROR_SERVER`` or - * ``MONGOC_ERROR_WRITE_CONCERN``" */ - if (result->error.domain == MONGOC_ERROR_SERVER || - result->error.domain == MONGOC_ERROR_WRITE_CONCERN_ERROR) { - test_set_error (error, - "expected client side error, but got: %" PRIu32 - ", %" PRIu32, - result->error.domain, - result->error.code); - goto done; - } - } - - if (error_contains) { - if (strstr (result->error.message, error_contains) == NULL) { - test_set_error (error, - "expected error to contain \"%s\", but got: \"%s\"", - error_contains, - result->error.message); - goto done; - } - } - - if (error_code) { - if ((*error_code) != (int64_t) result->error.code) { - test_set_error (error, - "expected error code %" PRIi64 - ", but got: %" PRIi64, - *error_code, - (int64_t) result->error.code); - goto done; - } - } - - /* Waiting on CDRIVER-3147 - if (error_code_name) { - bson_iter_t iter; - - if (!result->reply) { - test_set_error (error, "%s", "expected error code name, but no error - reply set"); goto done; - } - - if (!bson_iter_init_find (&iter, result->reply, "codeName") || - !BSON_ITER_HOLDS_UTF8 (&iter)) { - test_set_error (error, "utf8 codeName not found in error reply: %s", - tmp_json (result->reply)); goto done; - } - - if (0 != - bson_strcasecmp (bson_iter_utf8 (&iter, NULL), error_code_name)) { - test_set_error (error, "expected codeName: %s, got: %s", - error_code_name, bson_iter_utf8 (&iter, NULL)); goto done; - } - } - */ - - if (error_labels_contain) { - bson_iter_t iter; - - if (!result->reply) { - test_set_error ( - error, - "%s", - "expected error to contain labels, but got no error document"); - goto done; - } - - BSON_FOREACH (error_labels_contain, iter) - { - const char *label; - - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - test_set_error (error, - "expected UTF8 error label, got: %s", - bson_type_to_string (bson_iter_type (&iter))); - goto done; - } - - label = bson_iter_utf8 (&iter, NULL); - if (!mongoc_error_has_label (result->reply, label)) { - test_set_error ( - error, - "expected error to contain label: %s, but got: %s", - label, - tmp_json (result->reply)); - goto done; - } - } - } - - if (error_labels_omit) { - bson_iter_t iter; - - if (!result->reply) { - test_set_error ( - error, - "%s", - "expected error to omit labels, but got no error document"); - goto done; - } - - BSON_FOREACH (error_labels_omit, iter) - { - const char *label; - - if (!BSON_ITER_HOLDS_UTF8 (&iter)) { - test_set_error (error, - "expected UTF8 error label, got: %s", - bson_type_to_string (bson_iter_type (&iter))); - goto done; - } - - label = bson_iter_utf8 (&iter, NULL); - if (mongoc_error_has_label (result->reply, label)) { - test_set_error (error, - "expected error to omit label: %s, but got: %s", - label, - tmp_json (result->reply)); - goto done; - } - } - } - - if (error_expect_result) { - if (!result->value) { - test_set_error ( - error, "%s", "expected error with result, but result unset"); - goto done; - } - - /* Note: expectError.expectResult is not used for cursor-bearing - * operations, so array_of_root_docs should always be false */ - BSON_ASSERT (!result->array_of_root_docs); - - if (!bson_match (error_expect_result, - result->value, - result->array_of_root_docs, - error)) { - test_diagnostics_error_info ( - "error.expectResult mismatch:\nExpected: %s\nActual: %s\n", - bson_val_to_json (error_expect_result), - bson_val_to_json (result->value)); - goto done; - } - } - - if (error_response) { - if (!result->reply) { - test_set_error ( - error, "%s", "expected error with a reply, but reply unset"); - goto done; - } - - /* Write operations have the raw response wrapped in a errorReplies - * array. Read operations return the raw response as the reply. */ - bson_t doc_to_match; - bson_iter_t iter; - - if (bson_iter_init_find (&iter, result->reply, "errorReplies")) { - bson_iter_t child; - - if (!BSON_ITER_HOLDS_ARRAY (&iter)) { - test_set_error ( - error, - "expected errorReplies to be an array, but received %s", - bson_type_to_string (bson_iter_type (&iter))); - goto done; - } - bson_iter_recurse (&iter, &child); - bson_iter_next (&child); - if (!BSON_ITER_HOLDS_DOCUMENT (&child)) { - test_set_error ( - error, - "expected errorReplies.0 to be a document but received %s", - bson_type_to_string (bson_iter_type (&iter))); - goto done; - } - bson_iter_bson (&child, &doc_to_match); - } else { - bson_copy_to (result->reply, &doc_to_match); - } - - bson_val_t *val_to_match = bson_val_from_bson (&doc_to_match); - - if (!bson_match (error_response, - val_to_match, - result->array_of_root_docs, - error)) { - test_diagnostics_error_info ( - "error.errorResponse mismatch:\nExpected: %s\nActual: %s\n", - bson_val_to_json (error_response), - bson_as_json (result->reply, NULL)); - bson_val_destroy (val_to_match); - bson_destroy (&doc_to_match); - goto done; - } - bson_val_destroy (val_to_match); - bson_destroy (&doc_to_match); - } - } - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (parser); - return ret; -} - -static void -test_resultfrombulkwrite (void) -{ - bson_error_t error; - result_t *result; - bson_t *reply; - bson_val_t *expect; - bson_error_t empty = {0}; - - result = result_new (); - reply = tmp_bson ("{ 'nInserted': 0, 'nRemoved' : 1, 'nMatched' : 2, " - "'nModified' : 3, 'nUpserted' : 4 }"); - expect = bson_val_from_json ( - "{ 'insertedCount': 0, 'deletedCount': 1, 'matchedCount': 2, " - "'modifiedCount': 3, 'upsertedCount': 4}"); - result_from_bulk_write (result, reply, &empty); - MONGOC_DEBUG ("rewritten to: %s", bson_val_to_json (result->value)); - if (!result_check (result, NULL, expect, NULL, &error)) { - test_error ("result_check error: %s", error.message); - } - result_destroy (result); - bson_val_destroy (expect); -} - -void -test_result_install (TestSuite *suite) -{ - TestSuite_Add ( - suite, "/unified/result/resultfrombulkwrite", test_resultfrombulkwrite); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/result.h b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/result.h deleted file mode 100644 index 0ecff3e91..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/result.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef UNIFIED_OPERATION_RESULT_H -#define UNIFIED_OPERATION_RESULT_H - -#include "test-diagnostics.h" -#include "bsonutil/bson-val.h" -#include "entity-map.h" -#include "mongoc-cursor.h" - -typedef struct _result_t result_t; - -result_t * -result_new (void); - -void -result_destroy (result_t *result); - -void -result_from_bulk_write (result_t *result, - const bson_t *reply, - const bson_error_t *error); - -void -result_from_insert_one (result_t *result, - const bson_t *reply, - const bson_error_t *error); - -void -result_from_insert_many (result_t *result, - const bson_t *reply, - const bson_error_t *error); - -void -result_from_delete (result_t *result, - const bson_t *reply, - const bson_error_t *error); - -void -result_from_distinct (result_t *result, - const bson_t *reply, - const bson_error_t *error); - -void -result_from_update_or_replace (result_t *result, - const bson_t *reply, - const bson_error_t *error); - -void -result_from_cursor (result_t *result, mongoc_cursor_t *cursor); - -void -result_from_val_and_reply (result_t *result, - const bson_val_t *value, - const bson_t *reply, - const bson_error_t *error); - -void -result_from_ok (result_t *result); - -const char * -result_to_string (result_t *result); - -bson_val_t * -result_get_val (result_t *result); - -bson_t * -rewrite_bulk_write_result (const bson_t *bulk_write_result); - -bool -result_check (result_t *result, - entity_map_t *em, - bson_val_t *expect_result, - bson_t *expect_error, - bson_error_t *error); - -#endif /* UNIFIED_OPERATION_RESULT_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/runner.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/runner.c deleted file mode 100644 index 3926fa0dd..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/runner.c +++ /dev/null @@ -1,1880 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "bsonutil/bson-parser.h" -#include "entity-map.h" -#include "json-test.h" -#include "operation.h" -#include "runner.h" -#include "test-conveniences.h" -#include "test-libmongoc.h" -#include "test-diagnostics.h" -#include "utlist.h" -#include "util.h" - - -typedef struct { - const char *file_description; - const char *test_description; -} skipped_unified_test_t; - -#define SKIP_ALL_TESTS NULL - -// clang-format off -skipped_unified_test_t SKIPPED_TESTS[] = { - // CDRIVER-4001, DRIVERS-1781, and DRIVERS-1448: 5.0 cursor behavior - {"poc-command-monitoring", "A successful find event with a getmore and the server kills the cursor"}, - // libmongoc does not have a distinct helper, so skip snapshot tests testing particular distinct functionality - {"snapshot-sessions", "Distinct operation with snapshot"}, - {"snapshot-sessions", "Mixed operation with snapshot"}, - // CDRIVER-3886: serverless testing (schema version 1.4) - {"poc-crud", SKIP_ALL_TESTS}, - {"db-aggregate", SKIP_ALL_TESTS}, - {"mongos-unpin", SKIP_ALL_TESTS}, - // CDRIVER-2871: CMAP is not implemented - {"assertNumberConnectionsCheckedOut", SKIP_ALL_TESTS}, - {"entity-client-cmap-events", SKIP_ALL_TESTS}, - {"expectedEventsForClient-eventType", SKIP_ALL_TESTS}, - // CDRIVER-4115: listCollections does not support batchSize. - {"cursors are correctly pinned to connections for load-balanced clusters", "listCollections pins the cursor to a connection"}, - // CDRIVER-4116: listIndexes does not support batchSize. - {"cursors are correctly pinned to connections for load-balanced clusters", "listIndexes pins the cursor to a connection"}, - // libmongoc does not pin connections to cursors. It cannot force an error from waitQueueTimeoutMS by creating cursors in load balanced mode. - {"wait queue timeout errors include details about checked out connections", SKIP_ALL_TESTS}, - // libmongoc does not support the optional findOne helper. - {"retryable reads handshake failures", "collection.findOne succeeds after retryable handshake network error"}, - {"retryable reads handshake failures", "collection.findOne succeeds after retryable handshake server error (ShutdownInProgress)"}, - // libmongoc does not support the optional listIndexNames helper. - {"retryable reads handshake failures", "collection.listIndexNames succeeds after retryable handshake network error"}, - {"retryable reads handshake failures", "collection.listIndexNames succeeds after retryable handshake server error (ShutdownInProgress)"}, - {0}, -}; -// clang-format on - -static bool -is_test_file_skipped (test_file_t *test_file) -{ - skipped_unified_test_t *skip; - - for (skip = SKIPPED_TESTS; skip->file_description != NULL; skip++) { - if (!strcmp (skip->file_description, test_file->description) && - skip->test_description == SKIP_ALL_TESTS) { - return true; - } - } - - return false; -} - -static bool -is_test_skipped (test_t *test) -{ - skipped_unified_test_t *skip; - - for (skip = SKIPPED_TESTS; skip->file_description != NULL; skip++) { - if (!strcmp (skip->file_description, test->test_file->description) && - !strcmp (skip->test_description, test->description)) { - return true; - } - } - - return false; -} - -struct _failpoint_t { - char *client_id; - char *name; - uint32_t server_id; - struct _failpoint_t *next; -}; - -failpoint_t * -failpoint_new (char *name, char *client_id, uint32_t server_id) -{ - failpoint_t *fp = (failpoint_t *) bson_malloc0 (sizeof (failpoint_t)); - - fp->name = bson_strdup (name); - fp->client_id = bson_strdup (client_id); - fp->server_id = server_id; - return fp; -} - -void -failpoint_destroy (failpoint_t *fp) -{ - if (!fp) { - return; - } - bson_free (fp->name); - bson_free (fp->client_id); - bson_free (fp); -} - -/* Set server_id to 0 if the failpoint was not against a pinned mongos. */ -void -register_failpoint (test_t *test, - char *name, - char *client_id, - uint32_t server_id) -{ - failpoint_t *fp = NULL; - - fp = failpoint_new (name, client_id, server_id); - LL_APPEND (test->failpoints, fp); -} - -static bool -cleanup_failpoints (test_t *test, bson_error_t *error) -{ - bool ret = false; - failpoint_t *iter = NULL; - mongoc_read_prefs_t *rp = NULL; - - rp = mongoc_read_prefs_new (MONGOC_READ_PRIMARY_PREFERRED); - - LL_FOREACH (test->failpoints, iter) - { - mongoc_client_t *client = NULL; - bson_t *disable_cmd = NULL; - - client = entity_map_get_client (test->entity_map, iter->client_id, error); - if (!client) { - goto done; - } - - disable_cmd = - tmp_bson ("{'configureFailPoint': '%s', 'mode': 'off' }", iter->name); - if (iter->server_id != 0) { - if (!mongoc_client_command_simple_with_server_id (client, - "admin", - disable_cmd, - rp, - iter->server_id, - NULL /* reply */, - error)) { - bson_destroy (disable_cmd); - goto done; - } - } else { - if (!mongoc_client_command_simple ( - client, "admin", disable_cmd, rp, NULL /* reply */, error)) { - bson_destroy (disable_cmd); - goto done; - } - } - } - - ret = true; -done: - mongoc_read_prefs_destroy (rp); - return ret; -} - -static bool -test_has_operation (test_t *test, char *op_name) -{ - bson_iter_t iter; - - BSON_FOREACH (test->operations, iter) - { - bson_t op_bson; - - bson_iter_bson (&iter, &op_bson); - if (0 == strcmp (bson_lookup_utf8 (&op_bson, "name"), op_name)) { - return true; - } - } - return false; -} - -static const char * -get_topology_type (mongoc_client_t *client); - -static bool -is_topology_type_sharded (const char *topology_type) -{ - return 0 == strcmp ("sharded", topology_type) || - 0 == strcmp ("sharded-replicaset", topology_type); -} - -static bool -is_topology_type_compatible (const char *test_topology_type, - const char *server_topology_type) -{ - if (0 == strcmp (test_topology_type, server_topology_type)) { - return true; - } - /* If a requirement specifies a "sharded" topology and server is of type - * "sharded-replicaset", that is also compatible. */ - return 0 == strcmp (test_topology_type, "sharded") && - is_topology_type_sharded (server_topology_type); -} - -/* This callback tracks the set of server IDs for all connected servers. - * The set of server IDs is used when sending a command to each individual - * server. - */ -static void -on_topology_changed (const mongoc_apm_topology_changed_t *event) -{ - test_runner_t *test_runner = NULL; - const mongoc_topology_description_t *td; - mongoc_server_description_t **sds; - size_t sds_len; - size_t i; - - test_runner = - (test_runner_t *) mongoc_apm_topology_changed_get_context (event); - _mongoc_array_clear (&test_runner->server_ids); - td = mongoc_apm_topology_changed_get_new_description (event); - sds = mongoc_topology_description_get_servers (td, &sds_len); - for (i = 0; i < sds_len; i++) { - uint32_t server_id = mongoc_server_description_id (sds[i]); - MONGOC_DEBUG ("topology changed, adding server id: %d", (int) server_id); - _mongoc_array_append_val (&test_runner->server_ids, server_id); - } - mongoc_server_descriptions_destroy_all (sds, sds_len); -} - -/* Returns an array of all known servers IDs that the test runner - * is connected to. The server IDs can be used to target commands to - * specific servers with mongoc_client_command_simple_with_server_id(). - */ -static void -test_runner_get_all_server_ids (test_runner_t *test_runner, mongoc_array_t *out) -{ - bson_error_t error; - bool ret; - - /* Run a 'ping' command to make sure topology has been scanned. */ - ret = mongoc_client_command_simple (test_runner->internal_client, - "admin", - tmp_bson ("{'ping': 1}"), - NULL /* read prefs */, - NULL /* reply */, - NULL /* error */); - ASSERT_OR_PRINT (ret, error); - - _mongoc_array_copy (out, &test_runner->server_ids); -} - -/* Run killAllSessions against the primary or each mongos to terminate any - * lingering open transactions. - * See also: Spec section "Terminating Open Transactions" - */ -static bool -test_runner_terminate_open_transactions (test_runner_t *test_runner, - bson_error_t *error) -{ - bson_t *kill_all_sessions_cmd = NULL; - bool ret = false; - bool cmd_ret = false; - bson_error_t cmd_error = {0}; - - if (test_framework_getenv_bool ("MONGOC_TEST_ATLAS")) { - // Not applicable when running as test-atlas-executor. - return true; - } else if (0 == test_framework_skip_if_no_txns ()) { - ret = true; - goto done; - } - - kill_all_sessions_cmd = tmp_bson ("{'killAllSessions': []}"); - /* Run on each mongos. Target each server individually. */ - if (is_topology_type_sharded (test_runner->topology_type)) { - mongoc_array_t server_ids; - size_t i; - - _mongoc_array_init (&server_ids, sizeof (uint32_t)); - test_runner_get_all_server_ids (test_runner, &server_ids); - for (i = 0; i < server_ids.len; i++) { - uint32_t server_id = _mongoc_array_index (&server_ids, uint32_t, i); - - cmd_ret = mongoc_client_command_simple_with_server_id ( - test_runner->internal_client, - "admin", - kill_all_sessions_cmd, - NULL /* read prefs. */, - server_id, - NULL, - &cmd_error); - - /* Ignore error code 11601 as a workaround for SERVER-38335. */ - if (!cmd_ret && cmd_error.code != 11601) { - test_set_error ( - error, - "Unexpected error running killAllSessions on server (%d): %s", - (int) server_id, - cmd_error.message); - _mongoc_array_destroy (&server_ids); - goto done; - } - } - _mongoc_array_destroy (&server_ids); - } else { - /* Run on primary. */ - cmd_ret = mongoc_client_command_simple (test_runner->internal_client, - "admin", - kill_all_sessions_cmd, - NULL /* read prefs. */, - NULL, - &cmd_error); - - /* Ignore error code 11601 as a workaround for SERVER-38335. */ - if (!cmd_ret && cmd_error.code != 11601) { - test_set_error ( - error, - "Unexpected error running killAllSessions on primary: %s", - cmd_error.message); - goto done; - } - } - - ret = true; -done: - return ret; -} - -static test_runner_t * -test_runner_new (void) -{ - bson_error_t error; - - // Avoid executing unnecessary commands when running as test-atlas-executor. - const bool is_atlas = test_framework_getenv_bool ("MONGOC_TEST_ATLAS"); - - test_runner_t *const test_runner = bson_malloc0 (sizeof (test_runner_t)); - - _mongoc_array_init (&test_runner->server_ids, sizeof (uint32_t)); - - { - mongoc_uri_t *const uri = test_framework_get_uri (); - - test_runner->internal_client = - test_framework_client_new_from_uri (uri, NULL); - - /* In load balanced mode, the internal client must use the - * SINGLE_LB_MONGOS_URI. */ - if (!is_atlas && !test_framework_is_loadbalanced ()) { - /* Always use multiple mongoses if speaking to a mongos. - * Some test operations require communicating with all known mongos */ - if (!test_framework_uri_apply_multi_mongos (uri, true, &error)) { - test_error ("error applying multiple mongos: %s", error.message); - } - } - - mongoc_uri_destroy (uri); - } - - { - mongoc_apm_callbacks_t *const callbacks = mongoc_apm_callbacks_new (); - mongoc_apm_set_topology_changed_cb (callbacks, on_topology_changed); - mongoc_client_set_apm_callbacks ( - test_runner->internal_client, callbacks, test_runner); - mongoc_apm_callbacks_destroy (callbacks); - } - - test_framework_set_ssl_opts (test_runner->internal_client); - - mongoc_client_set_error_api (test_runner->internal_client, - MONGOC_ERROR_API_VERSION_2); - - test_runner->topology_type = - get_topology_type (test_runner->internal_client); - server_semver (test_runner->internal_client, &test_runner->server_version); - - test_runner->is_serverless = test_framework_is_serverless (); - - /* Terminate any possible open transactions. */ - if (!test_runner_terminate_open_transactions (test_runner, &error)) { - test_error ("error terminating transactions: %s", error.message); - } - - { - bson_t reply; - /* Cache server parameters to check runOnRequirements. */ - if (!mongoc_client_command_simple (test_runner->internal_client, - "admin", - tmp_bson ("{'getParameter': '*'}"), - NULL, - &reply, - &error)) { - test_error ("error getting server parameters: %s, full reply: %s", - error.message, - tmp_json (&reply)); - } - test_runner->server_parameters = bson_copy (&reply); - bson_destroy (&reply); - } - - return test_runner; -} - -static void -test_runner_destroy (test_runner_t *test_runner) -{ - mongoc_client_destroy (test_runner->internal_client); - _mongoc_array_destroy (&test_runner->server_ids); - bson_destroy (test_runner->server_parameters); - bson_free (test_runner); -} - -static test_file_t * -test_file_new (test_runner_t *test_runner, bson_t *bson) -{ - test_file_t *test_file = NULL; - bson_parser_t *parser = NULL; - char *schema_version = NULL; - - test_file = bson_malloc0 (sizeof (test_file_t)); - test_file->test_runner = test_runner; - - parser = bson_parser_new (); - bson_parser_utf8 (parser, "description", &test_file->description); - bson_parser_utf8 (parser, "schemaVersion", &schema_version); - bson_parser_array_optional ( - parser, "runOnRequirements", &test_file->run_on_requirements); - bson_parser_array_optional ( - parser, "createEntities", &test_file->create_entities); - bson_parser_array_optional (parser, "initialData", &test_file->initial_data); - bson_parser_doc_optional (parser, "_yamlAnchors", &test_file->yaml_anchors); - bson_parser_array (parser, "tests", &test_file->tests); - bson_parser_parse_or_assert (parser, bson); - bson_parser_destroy (parser); - - semver_parse (schema_version, &test_file->schema_version); - bson_free (schema_version); - return test_file; -} - -static void -test_file_destroy (test_file_t *test_file) -{ - bson_free (test_file->description); - bson_destroy (test_file->tests); - bson_destroy (test_file->initial_data); - bson_destroy (test_file->create_entities); - bson_destroy (test_file->run_on_requirements); - bson_destroy (test_file->yaml_anchors); - bson_free (test_file); -} - -static test_t * -test_new (test_file_t *test_file, bson_t *bson) -{ - test_t *test = NULL; - bson_parser_t *parser = NULL; - - test = bson_malloc0 (sizeof (test_t)); - test->test_file = test_file; - parser = bson_parser_new (); - bson_parser_utf8 (parser, "description", &test->description); - bson_parser_array_optional ( - parser, "runOnRequirements", &test->run_on_requirements); - bson_parser_utf8_optional (parser, "skipReason", &test->skip_reason); - bson_parser_array (parser, "operations", &test->operations); - bson_parser_array_optional (parser, "expectEvents", &test->expect_events); - bson_parser_array_optional (parser, "outcome", &test->outcome); - bson_parser_parse_or_assert (parser, bson); - bson_parser_destroy (parser); - - test->entity_map = entity_map_new (); - return test; -} - -static void -test_destroy (test_t *test) -{ - failpoint_t *fpiter, *fptmp; - - LL_FOREACH_SAFE (test->failpoints, fpiter, fptmp) - { - failpoint_destroy (fpiter); - } - - entity_map_destroy (test->entity_map); - bson_destroy (test->outcome); - bson_destroy (test->expect_events); - bson_destroy (test->operations); - bson_destroy (test->run_on_requirements); - bson_free (test->description); - bson_free (test->skip_reason); - bson_free (test); -} - -static bool -is_replset (bson_t *hello_reply) -{ - if (bson_has_field (hello_reply, "setName")) { - return true; - } - - if (bson_has_field (hello_reply, "isreplicaset") && - bson_lookup_bool (hello_reply, "isreplicaset") == true) { - return true; - } - - return false; -} - -static bool -is_sharded (bson_t *hello_reply) -{ - const char *val; - if (!bson_has_field (hello_reply, "msg")) { - return false; - } - - - val = bson_lookup_utf8 (hello_reply, "msg"); - if (0 == strcmp (val, "isdbgrid")) { - return true; - } - return false; -} - -static const char * -get_topology_type (mongoc_client_t *client) -{ - bool ret; - bson_t reply; - bson_error_t error; - const char *topology_type = "single"; - - ASSERT (client); - - if (test_framework_is_loadbalanced ()) { - return "load-balanced"; - } - - ret = mongoc_client_command_simple ( - client, "admin", tmp_bson ("{'hello': 1}"), NULL, &reply, &error); - if (!ret) { - bson_destroy (&reply); - ret = mongoc_client_command_simple ( - client, - "admin", - tmp_bson ("{'" HANDSHAKE_CMD_LEGACY_HELLO "': 1}"), - NULL, - &reply, - &error); - } - ASSERT_OR_PRINT (ret, error); - - if (is_replset (&reply)) { - topology_type = "replicaset"; - } else if (is_sharded (&reply)) { - bool is_sharded_replset; - mongoc_collection_t *config_shards = NULL; - mongoc_cursor_t *cursor = NULL; - const bson_t *shard_doc; - - /* Check if this is a sharded-replicaset by querying the config.shards - * collection. */ - is_sharded_replset = true; - config_shards = mongoc_client_get_collection (client, "config", "shards"); - cursor = mongoc_collection_find_with_opts (config_shards, - tmp_bson ("{}"), - NULL /* opts */, - NULL /* read prefs */); - if (mongoc_cursor_error (cursor, &error)) { - test_error ("Attempting to query config.shards collection failed: %s", - error.message); - } - while (mongoc_cursor_next (cursor, &shard_doc)) { - const char *host = bson_lookup_utf8 (shard_doc, "host"); - if (NULL == strstr (host, "/")) { - is_sharded_replset = false; - break; - } - } - - mongoc_cursor_destroy (cursor); - mongoc_collection_destroy (config_shards); - - if (is_sharded_replset) { - topology_type = "sharded-replicaset"; - } else { - topology_type = "sharded"; - } - } - - bson_destroy (&reply); - return topology_type; -} - -static void -check_schema_version (test_file_t *test_file) -{ - const char *supported_version_strs[] = { - "1.8", /* fully supported through this version */ - "1.12", /* partially supported (expectedError.errorResponse assertions) */ - "1.18" /* partially supported (additional properties in kmsProviders) */}; - int i; - - for (i = 0; i < sizeof (supported_version_strs) / - sizeof (supported_version_strs[0]); - i++) { - semver_t supported_version; - - semver_parse (supported_version_strs[i], &supported_version); - if (supported_version.major != test_file->schema_version.major) { - continue; - } - if (!supported_version.has_minor) { - /* All minor versions for this major version are supported. */ - return; - } - if (supported_version.minor >= test_file->schema_version.minor) { - return; - } - } - - test_error ("Unsupported schema version: %s", - semver_to_string (&test_file->schema_version)); -} - -static bool -check_run_on_requirement (test_runner_t *test_runner, - bson_t *run_on_requirement, - const char *server_topology_type, - semver_t *server_version, - char **fail_reason) -{ - bson_iter_t req_iter; - - BSON_FOREACH (run_on_requirement, req_iter) - { - const char *key = bson_iter_key (&req_iter); - - if (0 == strcmp (key, "minServerVersion")) { - semver_t min_server_version; - - semver_parse (bson_iter_utf8 (&req_iter, NULL), &min_server_version); - if (semver_cmp (server_version, &min_server_version) < 0) { - *fail_reason = bson_strdup_printf ( - "Server version(%s) is lower than minServerVersion(%s)", - semver_to_string (server_version), - semver_to_string (&min_server_version)); - return false; - } - continue; - } - - if (0 == strcmp (key, "maxServerVersion")) { - semver_t max_server_version; - - semver_parse (bson_iter_utf8 (&req_iter, NULL), &max_server_version); - if (semver_cmp (server_version, &max_server_version) > 0) { - *fail_reason = bson_strdup_printf ( - "Server version(%s) is higher than maxServerVersion (%s)", - semver_to_string (server_version), - semver_to_string (&max_server_version)); - return false; - } - continue; - } - - if (0 == strcmp (key, "topologies")) { - bool found = false; - bson_t topologies; - bson_iter_t topology_iter; - - bson_iter_bson (&req_iter, &topologies); - BSON_FOREACH (&topologies, topology_iter) - { - const char *test_topology_type = - bson_iter_utf8 (&topology_iter, NULL); - if (is_topology_type_compatible (test_topology_type, - server_topology_type)) { - found = true; - continue; - } - } - - if (!found) { - *fail_reason = bson_strdup_printf ( - "Topology (%s) was not found among listed topologies: %s", - server_topology_type, - tmp_json (&topologies)); - return false; - } - continue; - } - - if (0 == strcmp (key, "serverParameters")) { - bson_t expected_params; - bson_val_t *actual_val = NULL; - bson_val_t *expected_val = NULL; - bool matched; - bson_error_t error = {0}; - - bson_iter_bson (&req_iter, &expected_params); - expected_val = bson_val_from_bson (&expected_params); - actual_val = bson_val_from_bson (test_runner->server_parameters); - matched = bson_match (expected_val, actual_val, false, &error); - bson_val_destroy (actual_val); - bson_val_destroy (expected_val); - if (!matched) { - *fail_reason = bson_strdup_printf ("serverParameters mismatch: %s", - error.message); - return false; - } - continue; - } - - if (0 == strcmp (key, "serverless")) { - const char *serverless_mode = bson_iter_utf8 (&req_iter, NULL); - - if (0 == strcmp (serverless_mode, "allow")) { - continue; - } else if (0 == strcmp (serverless_mode, "require")) { - if (!test_runner->is_serverless) { - *fail_reason = - bson_strdup_printf ("Not running in serverless mode"); - return false; - } - - continue; - } else if (0 == strcmp (serverless_mode, "forbid")) { - if (test_runner->is_serverless) { - *fail_reason = bson_strdup_printf ("Running in serverless mode"); - return false; - } - - continue; - } else { - test_error ("Unexpected serverless mode: %s", serverless_mode); - } - - continue; - } - - if (0 == strcmp (key, "auth")) { - bool auth_requirement = bson_iter_bool (&req_iter); - - if (auth_requirement == test_framework_has_auth ()) { - continue; - } - - *fail_reason = bson_strdup_printf ( - "Server does not match auth requirement, test %s authentication.", - auth_requirement ? "requires" : "forbids"); - - return false; - } - -#if defined(MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION) - if (0 == strcmp (key, "csfle")) { - const bool csfle_required = bson_iter_bool (&req_iter); - semver_t min_server_version; - - semver_parse ("4.2.0", &min_server_version); - if (semver_cmp (server_version, &min_server_version) < 0) { - *fail_reason = - bson_strdup_printf ("Server version %s is lower than " - "minServerVersion %s required by CSFLE", - semver_to_string (server_version), - semver_to_string (&min_server_version)); - return false; - } - - if (csfle_required) { - continue; - } - - *fail_reason = - bson_strdup_printf ("CSFLE is not allowed but libmongoc was built " - "with MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION=ON"); - - return false; -#else - if (0 == strcmp (key, "csfle")) { - const bool csfle_required = bson_iter_bool (&req_iter); - - if (!csfle_required) { - continue; - } - - *fail_reason = bson_strdup_printf ( - "CSFLE is required but libmongoc was built " - "without MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION=ON"); - - return false; -#endif /* !defined(MONGOC_CLIENT_SIDE_ENCRYPTION) */ - } - - test_error ("Unexpected runOnRequirement field: %s", key); - } - return true; -} - -static bool -check_run_on_requirements (test_runner_t *test_runner, - bson_t *run_on_requirements, - const char **reason) -{ - bson_string_t *fail_reasons = NULL; - bool requirements_satisfied = false; - bson_iter_t iter; - - fail_reasons = bson_string_new (""); - BSON_FOREACH (run_on_requirements, iter) - { - bson_t run_on_requirement; - char *fail_reason = NULL; - - bson_iter_bson (&iter, &run_on_requirement); - fail_reason = NULL; - if (check_run_on_requirement (test_runner, - &run_on_requirement, - test_runner->topology_type, - &test_runner->server_version, - &fail_reason)) { - requirements_satisfied = true; - break; - } - - bson_string_append_printf (fail_reasons, - "- Requirement %s failed because: %s\n", - bson_iter_key (&iter), - fail_reason); - bson_free (fail_reason); - } - - *reason = NULL; - if (!requirements_satisfied) { - (*reason) = - tmp_str ("runOnRequirements not satisfied:\n%s", fail_reasons->str); - } - bson_string_free (fail_reasons, true); - return requirements_satisfied; -} - -static bool -test_setup_initial_data (test_t *test, bson_error_t *error) -{ - test_runner_t *test_runner = NULL; - test_file_t *test_file = NULL; - bson_iter_t initial_data_iter; - - test_file = test->test_file; - test_runner = test_file->test_runner; - - if (!test_file->initial_data) { - return true; - } - - BSON_FOREACH (test_file->initial_data, initial_data_iter) - { - bson_parser_t *parser = NULL; - bson_t collection_data; - char *collection_name = NULL; - char *database_name = NULL; - bson_t *documents = NULL; - mongoc_database_t *db = NULL; - mongoc_collection_t *coll = NULL; - mongoc_bulk_operation_t *bulk_insert = NULL; - mongoc_write_concern_t *wc = NULL; - bson_t *bulk_opts = NULL; - bson_t *drop_opts = NULL; - bson_t *create_opts = NULL; - bool ret = false; - - bson_iter_bson (&initial_data_iter, &collection_data); - parser = bson_parser_new (); - bson_parser_utf8 (parser, "databaseName", &database_name); - bson_parser_utf8 (parser, "collectionName", &collection_name); - bson_parser_array (parser, "documents", &documents); - if (!bson_parser_parse (parser, &collection_data, error)) { - goto loopexit; - } - - wc = mongoc_write_concern_new (); - mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY); - bulk_opts = bson_new (); - mongoc_write_concern_append (wc, bulk_opts); - - /* Drop the collection. */ - /* Check if the server supports majority write concern on 'drop' and - * 'create'. */ - if (semver_cmp_str (&test_runner->server_version, "3.4") >= 0) { - drop_opts = bson_new (); - mongoc_write_concern_append (wc, drop_opts); - create_opts = bson_new (); - mongoc_write_concern_append (wc, create_opts); - } - coll = mongoc_client_get_collection ( - test_runner->internal_client, database_name, collection_name); - if (!mongoc_collection_drop_with_opts (coll, drop_opts, error)) { - if (error->code != 26 && - (NULL == strstr (error->message, "ns not found"))) { - /* This is not a "ns not found" error. Fail the test. */ - goto loopexit; - } - /* Clear an "ns not found" error. */ - memset (error, 0, sizeof (bson_error_t)); - } - - /* Insert documents if specified. */ - if (bson_count_keys (documents) > 0) { - bson_iter_t documents_iter; - - bulk_insert = - mongoc_collection_create_bulk_operation_with_opts (coll, bulk_opts); - - BSON_FOREACH (documents, documents_iter) - { - bson_t document; - - bson_iter_bson (&documents_iter, &document); - mongoc_bulk_operation_insert (bulk_insert, &document); - } - - if (!mongoc_bulk_operation_execute (bulk_insert, NULL, error)) { - goto loopexit; - } - } else { - mongoc_collection_t *new_coll = NULL; - /* Test does not need data inserted, just create the collection. */ - db = mongoc_client_get_database (test_runner->internal_client, - database_name); - new_coll = mongoc_database_create_collection ( - db, collection_name, create_opts, error); - if (!new_coll) { - goto loopexit; - } - mongoc_collection_destroy (new_coll); - } - - ret = true; - - loopexit: - mongoc_bulk_operation_destroy (bulk_insert); - bson_destroy (bulk_opts); - bson_destroy (drop_opts); - bson_destroy (create_opts); - bson_destroy (documents); - mongoc_write_concern_destroy (wc); - mongoc_collection_destroy (coll); - bson_free (database_name); - bson_free (collection_name); - bson_parser_destroy (parser); - mongoc_database_destroy (db); - if (!ret) { - return false; - } - } - return true; -} - -static bool -test_create_entities (test_t *test, bson_error_t *error) -{ - test_file_t *test_file = NULL; - bson_iter_t iter; - - test_file = test->test_file; - - if (!test_file->create_entities) { - return true; - } - - /* If a test runs a 'configureFailPoint' operation, reduce heartbeat on new - * clients. */ - if (test_has_operation (test, "configureFailPoint")) { - entity_map_set_reduced_heartbeat (test->entity_map, true); - } - - BSON_FOREACH (test_file->create_entities, iter) - { - bson_t entity_bson; - - bson_iter_bson (&iter, &entity_bson); - if (!entity_map_create (test->entity_map, &entity_bson, error)) { - return false; - } - } - return true; -} - -static bool -test_run_operations (test_t *test, bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - - BSON_FOREACH (test->operations, iter) - { - bson_t op_bson; - bson_iter_bson (&iter, &op_bson); - - if (!operation_run (test, &op_bson, error)) { - test_diagnostics_error_info ("running operation: %s", - tmp_json (&op_bson)); - goto done; - } - } - - ret = true; -done: - return ret; -} - -static bool -test_check_event (test_t *test, - bson_t *expected, - event_t *actual, - bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - bson_t expected_bson; - bson_parser_t *bp = NULL; - const char *expected_event_type; - bson_t *expected_command = NULL; - char *expected_command_name = NULL; - char *expected_database_name = NULL; - bson_t *expected_reply = NULL; - bool *expected_has_service_id = NULL; - bool *expected_has_server_connection_id = NULL; - - if (bson_count_keys (expected) != 1) { - test_set_error (error, - "expected 1 key in expected event, but got: %s", - tmp_json (expected)); - goto done; - } - - bson_iter_init (&iter, expected); - bson_iter_next (&iter); - expected_event_type = bson_iter_key (&iter); - if (0 != bson_strcasecmp (expected_event_type, actual->type)) { - test_set_error (error, - "expected event type: %s, but got: %s", - expected_event_type, - actual->type); - goto done; - } - - if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) { - test_set_error (error, - "unexpected non-document event assertion: %s", - tmp_json (expected)); - goto done; - } - bson_iter_bson (&iter, &expected_bson); - - bp = bson_parser_new (); - bson_parser_doc_optional (bp, "command", &expected_command); - bson_parser_utf8_optional (bp, "commandName", &expected_command_name); - bson_parser_utf8_optional (bp, "databaseName", &expected_database_name); - bson_parser_doc_optional (bp, "reply", &expected_reply); - bson_parser_bool_optional (bp, "hasServiceId", &expected_has_service_id); - bson_parser_bool_optional ( - bp, "hasServerConnectionId", &expected_has_server_connection_id); - if (!bson_parser_parse (bp, &expected_bson, error)) { - goto done; - } - - if (expected_command) { - bson_val_t *expected_val; - bson_val_t *actual_val; - - if (!actual || !actual->command) { - test_set_error (error, "Expected a value but got NULL"); - goto done; - } - - expected_val = bson_val_from_bson (expected_command); - actual_val = bson_val_from_bson (actual->command); - - if (!entity_map_match ( - test->entity_map, expected_val, actual_val, false, error)) { - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - goto done; - } - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - } - - if (expected_command_name && - 0 != strcmp (expected_command_name, actual->command_name)) { - test_set_error (error, - "expected commandName: %s, but got: %s", - expected_command_name, - actual->command_name); - goto done; - } - - if (expected_database_name && - 0 != strcmp (expected_database_name, actual->database_name)) { - test_set_error (error, - "expected databaseName: %s, but got: %s", - expected_database_name, - actual->database_name); - goto done; - } - - if (expected_reply) { - bson_val_t *expected_val = bson_val_from_bson (expected_reply); - bson_val_t *actual_val = bson_val_from_bson (actual->reply); - if (!entity_map_match ( - test->entity_map, expected_val, actual_val, false, error)) { - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - goto done; - } - bson_val_destroy (expected_val); - bson_val_destroy (actual_val); - } - - if (expected_has_service_id) { - char oid_str[25] = {0}; - bool has_service_id = false; - - bson_oid_to_string (&actual->service_id, oid_str); - has_service_id = - 0 != bson_oid_compare (&actual->service_id, &kZeroServiceId); - - if (*expected_has_service_id && !has_service_id) { - test_error ("expected serviceId, but got none"); - } - - if (!*expected_has_service_id && has_service_id) { - test_error ("expected no serviceId, but got %s", oid_str); - } - } - - if (expected_has_server_connection_id) { - const bool has_server_connection_id = - actual->server_connection_id != MONGOC_NO_SERVER_CONNECTION_ID; - - if (*expected_has_server_connection_id && !has_server_connection_id) { - test_error ("expected server connectionId, but got none"); - } - - if (!*expected_has_server_connection_id && has_server_connection_id) { - test_error ("expected no server connectionId, but got %" PRId64, - actual->server_connection_id); - } - } - - ret = true; -done: - bson_parser_destroy_with_parsed_fields (bp); - return ret; -} - -static bool -test_check_expected_events_for_client (test_t *test, - bson_t *expected_events_for_client, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = NULL; - char *client_id = NULL; - bson_t *expected_events = NULL; - bool just_false = false; - bool *ignore_extra_events = &just_false; - entity_t *entity = NULL; - bson_iter_t iter; - event_t *eiter = NULL; - uint32_t expected_num_events; - uint32_t actual_num_events = 0; - char *event_type = NULL; - - bp = bson_parser_new (); - bson_parser_utf8 (bp, "client", &client_id); - bson_parser_array (bp, "events", &expected_events); - bson_parser_bool_optional (bp, "ignoreExtraEvents", &ignore_extra_events); - bson_parser_utf8_optional (bp, "eventType", &event_type); - if (!bson_parser_parse (bp, expected_events_for_client, error)) { - goto done; - } - - if (event_type) { - if (0 == strcmp (event_type, "cmap")) { - /* TODO: (CDRIVER-3525) Explicitly ignore cmap events until CMAP is - * supported. */ - ret = true; - goto done; - } else if (0 != strcmp (event_type, "command")) { - test_set_error (error, "unexpected event type: %s", event_type); - goto done; - } - } - - entity = entity_map_get (test->entity_map, client_id, error); - if (0 != strcmp (entity->type, "client")) { - test_set_error (error, - "expected entity %s to be client, got: %s", - entity->id, - entity->type); - goto done; - } - - expected_num_events = bson_count_keys (expected_events); - LL_COUNT (entity->events, eiter, actual_num_events); - if (expected_num_events != actual_num_events) { - bool too_many_events = actual_num_events > expected_num_events; - if (ignore_extra_events && *ignore_extra_events) { - // We can never have too many events - too_many_events = false; - } - bool too_few_events = actual_num_events < expected_num_events; - if (too_few_events || too_many_events) { - test_set_error (error, - "expected: %" PRIu32 " events but got %" PRIu32, - expected_num_events, - actual_num_events); - goto done; - } - } - - eiter = entity->events; - BSON_FOREACH (expected_events, iter) - { - bson_t expected_event; - - bson_iter_bson (&iter, &expected_event); - if (!eiter) { - test_set_error ( - error, "could not find event: %s", tmp_json (&expected_event)); - goto done; - } - if (!test_check_event (test, &expected_event, eiter, error)) { - test_diagnostics_error_info ("checking for expected event: %s", - tmp_json (&expected_event)); - goto done; - } - eiter = eiter->next; - } - - ret = true; -done: - if (!ret) { - if (entity && entity->events) { - char *event_list_string = NULL; - - event_list_string = event_list_to_string (entity->events); - test_diagnostics_error_info ("all captured events:\n%s", - event_list_string); - bson_free (event_list_string); - } - } - bson_parser_destroy_with_parsed_fields (bp); - return ret; -} - -static bool -test_check_expected_events (test_t *test, bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - - if (!test->expect_events) { - ret = true; - goto done; - } - - BSON_FOREACH (test->expect_events, iter) - { - bson_t expected_events_for_client; - bson_iter_bson (&iter, &expected_events_for_client); - if (!test_check_expected_events_for_client ( - test, &expected_events_for_client, error)) { - test_diagnostics_error_info ("checking expectations: %s", - tmp_json (&expected_events_for_client)); - goto done; - } - } - - - ret = true; -done: - return ret; -} - -static bool -test_check_outcome_collection (test_t *test, - bson_t *collection_data, - bson_error_t *error) -{ - bool ret = false; - bson_parser_t *bp = NULL; - char *database_name = NULL; - char *collection_name = NULL; - bson_t *documents = NULL; - mongoc_collection_t *coll = NULL; - mongoc_cursor_t *cursor = NULL; - bson_t *opts = NULL; - mongoc_read_concern_t *rc = NULL; - mongoc_read_prefs_t *rp = NULL; - const bson_t *out; - bson_t *actual_data = NULL; - uint32_t i; - bson_iter_t iter; - bson_iter_t eiter; - - bp = bson_parser_new (); - bson_parser_utf8 (bp, "databaseName", &database_name); - bson_parser_utf8 (bp, "collectionName", &collection_name); - bson_parser_array (bp, "documents", &documents); - if (!bson_parser_parse (bp, collection_data, error)) { - goto done; - } - - coll = mongoc_client_get_collection ( - test->test_file->test_runner->internal_client, - database_name, - collection_name); - opts = BCON_NEW ("sort", "{", "_id", BCON_INT32 (1), "}"); - rc = mongoc_read_concern_new (); - mongoc_read_concern_set_level (rc, MONGOC_READ_CONCERN_LEVEL_LOCAL); - rp = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - cursor = mongoc_collection_find_with_opts ( - coll, tmp_bson ("{}"), tmp_bson ("{'sort': {'_id': 1}}"), rp); - /* Read the full cursor into a BSON array so error messages can include the - * full list of documents. */ - actual_data = bson_new (); - i = 0; - while (mongoc_cursor_next (cursor, &out)) { - char storage[16]; - const char *key; - - bson_uint32_to_string (i, &key, storage, sizeof (storage)); - BSON_APPEND_DOCUMENT (actual_data, key, out); - i++; - } - - if (mongoc_cursor_error (cursor, error)) { - goto done; - } - - if (bson_count_keys (actual_data) != bson_count_keys (documents)) { - test_set_error (error, - "expected collection %s to contain: %s\nbut got: %s", - collection_name, - tmp_json (documents), - tmp_json (actual_data)); - goto done; - } - - - bson_iter_init (&eiter, documents); - bson_iter_next (&eiter); - - BSON_FOREACH (actual_data, iter) - { - bson_t actual; - bson_t expected; - bson_t *actual_sorted = NULL; - bson_t *expected_sorted = NULL; - - bson_iter_bson (&iter, &actual); - actual_sorted = bson_copy_and_sort (&actual); - - bson_iter_bson (&eiter, &expected); - expected_sorted = bson_copy_and_sort (&expected); - - - if (!bson_equal (actual_sorted, expected_sorted)) { - test_set_error (error, - "expected %s, but got %s", - tmp_json (expected_sorted), - tmp_json (actual_sorted)); - bson_destroy (actual_sorted); - bson_destroy (expected_sorted); - goto done; - } - - bson_destroy (actual_sorted); - bson_destroy (expected_sorted); - - bson_iter_next (&eiter); - } - - ret = true; -done: - bson_destroy (opts); - mongoc_collection_destroy (coll); - mongoc_cursor_destroy (cursor); - mongoc_read_concern_destroy (rc); - mongoc_read_prefs_destroy (rp); - bson_destroy (actual_data); - bson_parser_destroy_with_parsed_fields (bp); - return ret; -} - -static bool -test_check_outcome (test_t *test, bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - - if (!test->outcome) { - ret = true; - goto done; - } - - BSON_FOREACH (test->outcome, iter) - { - bson_t collection_data; - - bson_iter_bson (&iter, &collection_data); - if (!test_check_outcome_collection (test, &collection_data, error)) { - goto done; - } - } - - ret = true; -done: - return ret; -} - -static void -append_size_t (bson_t *doc, const char *key, size_t value) -{ - BSON_ASSERT (bson_in_range_unsigned (int64_t, value)); - BSON_ASSERT (BSON_APPEND_INT64 (doc, key, (int64_t) value)); -} - -static void -append_bson_array (bson_t *doc, const char *key, const mongoc_array_t *array) -{ - BSON_ASSERT_PARAM (key); - BSON_ASSERT (array || true); - - if (!array) { - bson_t empty = BSON_INITIALIZER; - BSON_ASSERT (BSON_APPEND_ARRAY (doc, key, &empty)); - bson_destroy (&empty); - } else { - bson_t **const begin = array->data; - bson_t **const end = begin + array->len; - - bson_array_builder_t *elements; - - BSON_ASSERT (BSON_APPEND_ARRAY_BUILDER_BEGIN (doc, key, &elements)); - for (bson_t **iter = begin; iter != end; ++iter) { - BSON_ASSERT (bson_array_builder_append_document (elements, *iter)); - } - BSON_ASSERT (bson_append_array_builder_end (doc, elements)); - } -} - -static bool -test_generate_atlas_results (test_t *test, bson_error_t *error) -{ - BSON_ASSERT_PARAM (test); - BSON_ASSERT_PARAM (error); - - // This is only applicable when the unified test runner is being run by - // test-atlas-executor. Must be implemented within unified test runner in - // order to capture entities before destruction of parent test object. - if (!test_framework_getenv_bool ("MONGOC_TEST_ATLAS")) { - return true; - } - - MONGOC_DEBUG ("generating events.json and results.json files..."); - - size_t *const iterations = - entity_map_get_size_t (test->entity_map, "iterations", NULL); - size_t *const successes = - entity_map_get_size_t (test->entity_map, "successes", NULL); - mongoc_array_t *const errors = - entity_map_get_bson_array (test->entity_map, "errors", NULL); - mongoc_array_t *const failures = - entity_map_get_bson_array (test->entity_map, "failures", NULL); - mongoc_array_t *const events = - entity_map_get_bson_array (test->entity_map, "events", NULL); - - bson_t events_doc = BSON_INITIALIZER; - bson_t results_doc = BSON_INITIALIZER; - - append_bson_array (&events_doc, "events", events); - append_bson_array (&events_doc, "failures", failures); - append_bson_array (&events_doc, "errors", errors); - - append_size_t (&results_doc, "numErrors", errors ? errors->len : 0u); - append_size_t (&results_doc, "numFailures", failures ? failures->len : 0u); - append_size_t (&results_doc, "numIterations", iterations ? *iterations : 0u); - append_size_t (&results_doc, "numSuccesses", successes ? *successes : 0u); - -#ifdef WIN32 - const int perms = _S_IWRITE; -#else - const int perms = S_IRWXU; -#endif - - mongoc_stream_t *const events_file = mongoc_stream_file_new_for_path ( - "events.json", O_CREAT | O_WRONLY | O_TRUNC, perms); - ASSERT_WITH_MSG (events_file, "could not open events.json"); - - mongoc_stream_t *const results_file = mongoc_stream_file_new_for_path ( - "results.json", O_CREAT | O_WRONLY | O_TRUNC, perms); - ASSERT_WITH_MSG (results_file, "could not open results.json"); - - size_t events_json_len = 0u; - size_t results_json_len = 0u; - char *const events_json = bson_as_json (&events_doc, &events_json_len); - char *const results_json = bson_as_json (&results_doc, &results_json_len); - - ASSERT_WITH_MSG (events_json, - "failed to convert events BSON document to JSON"); - ASSERT_WITH_MSG (results_json, - "failed to convert results BSON document to JSON"); - - ASSERT_WITH_MSG ( - mongoc_stream_write (events_file, events_json, events_json_len, 500) > 0, - "failed to write events to events.json"); - ASSERT_WITH_MSG (mongoc_stream_write ( - results_file, results_json, results_json_len, 500) > 0, - "failed to write results to results.json"); - - bson_free (events_json); - bson_free (results_json); - - mongoc_stream_destroy (events_file); - mongoc_stream_destroy (results_file); - - bson_destroy (&events_doc); - bson_destroy (&results_doc); - - MONGOC_DEBUG ("generating events.json and results.json files... done."); - - return true; -} - -static bool -run_distinct_on_each_mongos (test_t *test, - char *db_name, - char *coll_name, - bson_error_t *error) -{ - bool ret = false; - bson_t *cmd = NULL; - test_runner_t *runner = test->test_file->test_runner; - - cmd = BCON_NEW ("distinct", coll_name, "key", "x", "query", "{", "}"); - - for (size_t i = 0u; i < runner->server_ids.len; i++) { - const uint32_t server_id = - _mongoc_array_index (&runner->server_ids, uint32_t, i); - if (!mongoc_client_command_simple_with_server_id ( - test->test_file->test_runner->internal_client, - db_name, - cmd, - NULL /* read prefs */, - server_id, - NULL /* reply */, - error)) { - goto done; - } - } - - - ret = true; -done: - bson_destroy (cmd); - return ret; -} - -static bool -test_run_distinct_workaround (test_t *test, bson_error_t *error) -{ - bool ret = false; - bson_iter_t iter; - bson_parser_t *bp = NULL; - mongoc_collection_t *coll = NULL; - - if (0 != strcmp (test->test_file->test_runner->topology_type, "sharded") && - 0 != strcmp (test->test_file->test_runner->topology_type, - "sharded-replicaset")) { - ret = true; - goto done; - } - - if (!test_has_operation (test, "distinct")) { - ret = true; - goto done; - } - - /* Get the database/collection name from each collection entity. */ - BSON_FOREACH (test->test_file->create_entities, iter) - { - bson_t entity_bson; - char *coll_name = NULL; - char *db_id = NULL; - char *db_name = NULL; - mongoc_database_t *db = NULL; - bson_iter_t entity_iter; - - if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) { - test_set_error (error, - "unexpected non-document createEntity: %s", - bson_iter_key (&iter)); - goto done; - } - - bson_iter_recurse (&iter, &entity_iter); - - if (!bson_iter_find (&entity_iter, "collection")) { - continue; - } - - if (!BSON_ITER_HOLDS_DOCUMENT (&entity_iter)) { - test_set_error (error, - "unexpected non-document in iter: %s", - bson_iter_key (&entity_iter)); - goto done; - } - - bson_iter_bson (&entity_iter, &entity_bson); - - bp = bson_parser_new (); - bson_parser_allow_extra (bp, true); - bson_parser_utf8 (bp, "collectionName", &coll_name); - bson_parser_utf8 (bp, "database", &db_id); - if (!bson_parser_parse (bp, &entity_bson, error)) { - goto done; - } - - db = entity_map_get_database (test->entity_map, db_id, error); - if (!db) { - goto done; - } - - db_name = (char *) mongoc_database_get_name (db); - - if (!run_distinct_on_each_mongos (test, db_name, coll_name, error)) { - goto done; - } - - bson_parser_destroy_with_parsed_fields (bp); - bp = NULL; - } - - ret = true; -done: - mongoc_collection_destroy (coll); - bson_parser_destroy_with_parsed_fields (bp); - return ret; -} - -/* This returns an error on failure instead of asserting where possible. - * This allows the test runner to perform server clean up even on failure (e.g. - * disable failpoints). - */ -bool -test_run (test_t *test, bson_error_t *error) -{ - bool ret = false; - test_runner_t *test_runner = NULL; - test_file_t *test_file = NULL; - char *subtest_selector = NULL; - bson_error_t nonfatal_error; - - test_file = test->test_file; - test_runner = test_file->test_runner; - - if (is_test_skipped (test)) { - MONGOC_DEBUG ( - "SKIPPING test '%s'. Reason: 'explicitly skipped in runner.c'", - test->description); - ret = true; - goto done; - } - - subtest_selector = _mongoc_getenv ("MONGOC_JSON_SUBTEST"); - if (subtest_selector && - NULL == strstr (test->description, subtest_selector)) { - MONGOC_DEBUG ( - "SKIPPING test '%s'. Reason: 'skipped by MONGOC_JSON_SUBTEST'", - test->description); - ret = true; - goto done; - } - - if (test->skip_reason != NULL) { - MONGOC_DEBUG ("SKIPPING test '%s'. Reason: '%s'", - test->description, - test->skip_reason); - ret = true; - goto done; - } - - if (test->run_on_requirements) { - const char *reason; - if (!check_run_on_requirements ( - test_runner, test->run_on_requirements, &reason)) { - MONGOC_DEBUG ( - "SKIPPING test '%s'. Reason: '%s'", test->description, reason); - ret = true; - goto done; - } - } - - if (!test_setup_initial_data (test, error)) { - test_diagnostics_error_info ("%s", "setting up initial data"); - goto done; - } - - if (!test_create_entities (test, error)) { - test_diagnostics_error_info ("%s", "creating entities"); - goto done; - } - - if (!test_run_distinct_workaround (test, error)) { - test_diagnostics_error_info ("%s", "sending distinct to each mongos"); - goto done; - } - - if (!test_run_operations (test, error)) { - test_diagnostics_error_info ("%s", "running operations"); - goto done; - } - - entity_map_disable_event_listeners (test->entity_map); - - if (!test_check_expected_events (test, error)) { - test_diagnostics_error_info ("%s", "checking expectations"); - goto done; - } - - if (!test_check_outcome (test, error)) { - test_diagnostics_error_info ("%s", "checking outcome"); - goto done; - } - - if (!test_generate_atlas_results (test, error)) { - test_diagnostics_error_info ("%s", "generating Atlas test results"); - goto done; - } - - ret = true; -done: - /* always clean up failpoints, even on test failure */ - if (!cleanup_failpoints (test, &nonfatal_error)) { - MONGOC_DEBUG ("error cleaning up failpoints: %s", nonfatal_error.message); - } - /* always terminate transactions, even on test failure. */ - if (!test_runner_terminate_open_transactions (test_runner, - &nonfatal_error)) { - MONGOC_DEBUG ("error terminating transactions: %s", - nonfatal_error.message); - } - bson_free (subtest_selector); - return ret; -} - -void -run_one_test_file (bson_t *bson) -{ - test_runner_t *test_runner = NULL; - test_file_t *test_file = NULL; - bson_iter_t test_iter; - - test_diagnostics_init (); - - test_runner = test_runner_new (); - test_file = test_file_new (test_runner, bson); - - test_diagnostics_test_info ("test file: %s", test_file->description); - - if (is_test_file_skipped (test_file)) { - MONGOC_DEBUG ( - "SKIPPING test file '%s'. Reason: 'explicitly skipped in runner.c'", - test_file->description); - goto done; - } - - check_schema_version (test_file); - if (test_file->run_on_requirements) { - const char *reason; - if (!check_run_on_requirements ( - test_runner, test_file->run_on_requirements, &reason)) { - MONGOC_DEBUG ("SKIPPING test file (%s). Reason:\n%s", - test_file->description, - reason); - goto done; - } - } - - BSON_FOREACH (test_file->tests, test_iter) - { - test_t *test = NULL; - bson_t test_bson; - bool test_ok; - bson_error_t error = {0}; - - test_diagnostics_reset (); - test_diagnostics_test_info ("test file: %s", test_file->description); - - bson_iter_bson (&test_iter, &test_bson); - test = test_new (test_file, &test_bson); - test_diagnostics_test_info ("running test: %s", test->description); - test_ok = test_run (test, &error); - if (!test_ok) { - test_diagnostics_abort (&error); - } - test_destroy (test); - } - -done: - test_file_destroy (test_file); - test_runner_destroy (test_runner); - test_diagnostics_cleanup (); -} - -void -run_unified_tests (TestSuite *suite, const char *base, const char *subdir) -{ - install_json_test_suite_with_check (suite, - base, - subdir, - &run_one_test_file, - TestSuite_CheckLive, - test_framework_skip_if_no_crypto); -} - -void -test_install_unified (TestSuite *suite) -{ - run_unified_tests (suite, JSON_DIR, "unified"); - - run_unified_tests (suite, JSON_DIR, "crud/unified"); - - run_unified_tests (suite, JSON_DIR, "transactions/unified"); - - run_unified_tests (suite, JSON_DIR, "collection-management"); - - run_unified_tests (suite, JSON_DIR, "sessions/unified"); - - run_unified_tests (suite, JSON_DIR, "change_streams/unified"); - - run_unified_tests (suite, JSON_DIR, "load_balancers"); - - run_unified_tests (suite, JSON_DIR, "client_side_encryption/unified"); - - run_unified_tests (suite, JSON_DIR, "retryable_reads/unified"); - - run_unified_tests (suite, JSON_DIR, "retryable_writes/unified"); - - run_unified_tests (suite, JSON_DIR, "index-management"); -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/util.c b/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/util.c deleted file mode 100644 index 601b4a8f6..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/libmongoc/tests/unified/util.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2020-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "util.h" - -#include "test-conveniences.h" -#include "TestSuite.h" - -static int -cmp_key (const void *a, const void *b) -{ - return strcmp (*(const char **) a, *(const char **) b); -} - -bson_t * -bson_copy_and_sort (const bson_t *in) -{ - bson_t *out = bson_new (); - bson_iter_t iter; - const char **keys; - int nkeys = bson_count_keys (in); - int i = 0; - - keys = bson_malloc0 (sizeof (const char *) * nkeys); - BSON_FOREACH (in, iter) - { - keys[i] = bson_iter_key (&iter); - i++; - } - - qsort ((void *) keys, nkeys, sizeof (const char *), cmp_key); - for (i = 0; i < nkeys; i++) { - BSON_ASSERT (bson_iter_init_find (&iter, in, keys[i])); - BSON_APPEND_VALUE (out, keys[i], bson_iter_value (&iter)); - } - bson_free ((void *) keys); - return out; -} - -typedef struct { - const char *str; - bson_type_t type; -} bson_string_and_type_t; - -/* List of aliases: https://www.mongodb.com/docs/manual/reference/bson-types/ */ -bson_string_and_type_t bson_type_map[] = { - {"double", BSON_TYPE_DOUBLE}, - {"string", BSON_TYPE_UTF8}, - {"object", BSON_TYPE_DOCUMENT}, - {"array", BSON_TYPE_ARRAY}, - {"binData", BSON_TYPE_BINARY}, - {"undefined", BSON_TYPE_UNDEFINED}, - {"objectId", BSON_TYPE_OID}, - {"bool", BSON_TYPE_BOOL}, - {"date", BSON_TYPE_DATE_TIME}, - {"null", BSON_TYPE_NULL}, - {"regex", BSON_TYPE_REGEX}, - {"dbPointer", BSON_TYPE_DBPOINTER}, - {"javascript", BSON_TYPE_CODE}, - {"javascriptWithScope", BSON_TYPE_CODEWSCOPE}, - {"int", BSON_TYPE_INT32}, - {"timestamp", BSON_TYPE_TIMESTAMP}, - {"long", BSON_TYPE_INT64}, - {"decimal", BSON_TYPE_DECIMAL128}, - {"minKey", BSON_TYPE_MINKEY}, - {"maxKey", BSON_TYPE_MAXKEY}, - {"eod", BSON_TYPE_EOD}, -}; - -bson_type_t -bson_type_from_string (const char *in) -{ - int i; - for (i = 0; i < sizeof (bson_type_map) / sizeof (bson_type_map[0]); i++) { - if (0 == strcmp (in, bson_type_map[i].str)) { - return bson_type_map[i].type; - } - } - test_error ("unrecognized type string: %s\n", in); - return BSON_TYPE_EOD; -} - -const char * -bson_type_to_string (bson_type_t btype) -{ - int i; - for (i = 0; i < sizeof (bson_type_map) / sizeof (bson_type_map[0]); i++) { - if (btype == bson_type_map[i].type) { - return bson_type_map[i].str; - } - } - test_error ("unrecognized type: %d\n", (int) btype); - return "invalid"; -} - -static void -test_copy_and_sort (void) -{ - bson_t *in = tmp_bson ("{'b': 1, 'a': 1, 'd': 1, 'c': 1}"); - bson_t *expect = tmp_bson ("{'a': 1, 'b': 1, 'c': 1, 'd': 1}"); - bson_t *out = bson_copy_and_sort (in); - if (!bson_equal (expect, out)) { - test_error ("expected: %s, got: %s", tmp_json (expect), tmp_json (out)); - } - bson_destroy (out); -} - -void -test_bson_util_install (TestSuite *suite) -{ - TestSuite_Add ( - suite, "/unified/selftest/util/copy_and_sort", test_copy_and_sort); -} - -/* TODO (CDRIVER-3525) add test support for CMAP events once the C driver - * supports CMAP. */ -bool -is_unsupported_event_type (const char *event_type) -{ - char *unsupported_event_types[] = {"poolCreatedEvent", - "poolReadyEvent", - "poolClearedEvent", - "poolClosedEvent", - "connectionCreatedEvent", - "connectionReadyEvent", - "connectionClosedEvent", - "connectionCheckOutStartedEvent", - "connectionCheckOutFailedEvent", - "connectionCheckedOutEvent", - "connectionCheckedInEvent", - NULL}; - - char **iter; - - for (iter = unsupported_event_types; *iter != NULL; iter++) { - if (0 == bson_strcasecmp (event_type, *iter)) { - return true; - } - } - return false; -} - -int64_t -usecs_since_epoch (void) -{ - struct timeval tv; - BSON_ASSERT (bson_gettimeofday (&tv) == 0); - - BSON_ASSERT (bson_in_range_signed (int64_t, tv.tv_sec)); - BSON_ASSERT (bson_in_range_signed (int64_t, tv.tv_usec)); - - const int64_t secs = (int64_t) tv.tv_sec; - const int64_t usecs = (int64_t) tv.tv_usec; - - const int64_t factor = 1000000; - - BSON_ASSERT (INT64_MAX / factor >= secs); - BSON_ASSERT (INT64_MAX - (factor * secs) >= usecs); - - return secs * factor + usecs; -} diff --git a/3rdparty/mongo-c-driver-1.26.2/src/zlib-1.2.13/CMakeLists.txt b/3rdparty/mongo-c-driver-1.26.2/src/zlib-1.2.13/CMakeLists.txt deleted file mode 100644 index b412dc7fe..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/zlib-1.2.13/CMakeLists.txt +++ /dev/null @@ -1,213 +0,0 @@ -cmake_minimum_required(VERSION 2.4.4) -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) - -project(zlib C) - -set(VERSION "1.2.13") - -set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") -set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") -set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") -set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") -set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") - -include(CheckTypeSize) -include(CheckFunctionExists) -include(CheckIncludeFile) -include(CheckCSourceCompiles) -enable_testing() - -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(stdint.h HAVE_STDINT_H) -check_include_file(stddef.h HAVE_STDDEF_H) - -# -# Check to see if we have large file support -# -set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) -# We add these other definitions here because CheckTypeSize.cmake -# in CMake 2.4.x does not automatically do so and we want -# compatibility with CMake 2.4.x. -if(HAVE_SYS_TYPES_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) -endif() -if(HAVE_STDINT_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) -endif() -if(HAVE_STDDEF_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) -endif() -check_type_size(off64_t OFF64_T) -if(HAVE_OFF64_T) - add_definitions(-D_LARGEFILE64_SOURCE=1) -endif() -set(CMAKE_REQUIRED_DEFINITIONS) # clear variable - -# -# Check for fseeko -# -check_function_exists(fseeko HAVE_FSEEKO) -if(NOT HAVE_FSEEKO) - add_definitions(-DNO_FSEEKO) -endif() - -# -# Check for unistd.h -# -check_include_file(unistd.h Z_HAVE_UNISTD_H) - -if(MSVC) - set(CMAKE_DEBUG_POSTFIX "d") - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -endif() - -if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) - # If we're doing an out of source build and the user has a zconf.h - # in their source tree... - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) - message(STATUS "Renaming") - message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h") - message(STATUS "to 'zconf.h.included' because this file is included with zlib") - message(STATUS "but CMake generates it automatically in the build directory.") - file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included) - endif() -endif() - -set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein - ${ZLIB_PC} @ONLY) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein - ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) - - -#============================================================================ -# zlib -#============================================================================ - -set(ZLIB_PUBLIC_HDRS - ${CMAKE_CURRENT_BINARY_DIR}/zconf.h - zlib.h -) -set(ZLIB_PRIVATE_HDRS - crc32.h - deflate.h - gzguts.h - inffast.h - inffixed.h - inflate.h - inftrees.h - trees.h - zutil.h -) -set(ZLIB_SRCS - adler32.c - compress.c - crc32.c - deflate.c - gzclose.c - gzlib.c - gzread.c - gzwrite.c - inflate.c - infback.c - inftrees.c - inffast.c - trees.c - uncompr.c - zutil.c -) - -if(NOT MINGW) - set(ZLIB_DLL_SRCS - win32/zlib1.rc # If present will override custom build rule below. - ) -endif() - -# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) -string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" - "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) - -if(MINGW) - # This gets us DLL resource information when compiling on MinGW. - if(NOT CMAKE_RC_COMPILER) - set(CMAKE_RC_COMPILER windres.exe) - endif() - - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - COMMAND ${CMAKE_RC_COMPILER} - -D GCC_WINDRES - -I ${CMAKE_CURRENT_SOURCE_DIR} - -I ${CMAKE_CURRENT_BINARY_DIR} - -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) - set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) -endif(MINGW) - -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) -set_target_properties(zlib PROPERTIES SOVERSION 1) - -if(NOT CYGWIN) - # This property causes shared libraries on Linux to have the full version - # encoded into their final filename. We disable this on Cygwin because - # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll - # seems to be the default. - # - # This has no effect with MSVC, on that platform the version info for - # the DLL comes from the resource file win32/zlib1.rc - set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) -endif() - -if(UNIX) - # On unix-like platforms the library is almost always called libz - set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) - if(NOT APPLE) - set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") - endif() -elseif(BUILD_SHARED_LIBS AND WIN32) - # Creates zlib1.dll when building shared library version - set_target_properties(zlib PROPERTIES SUFFIX "1.dll") -endif() - -if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) - install(TARGETS zlib zlibstatic - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" - ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) -endif() -if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) - install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}") -endif() -if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) - install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3") -endif() -if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) - install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") -endif() - -#============================================================================ -# Example binaries -#============================================================================ - -add_executable(example test/example.c) -target_link_libraries(example zlib) -add_test(example example) - -add_executable(minigzip test/minigzip.c) -target_link_libraries(minigzip zlib) - -if(HAVE_OFF64_T) - add_executable(example64 test/example.c) - target_link_libraries(example64 zlib) - set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") - add_test(example64 example64) - - add_executable(minigzip64 test/minigzip.c) - target_link_libraries(minigzip64 zlib) - set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") -endif() diff --git a/3rdparty/mongo-c-driver-1.26.2/src/zlib-1.2.13/zlib.3.pdf b/3rdparty/mongo-c-driver-1.26.2/src/zlib-1.2.13/zlib.3.pdf deleted file mode 100644 index 8132d840c..000000000 Binary files a/3rdparty/mongo-c-driver-1.26.2/src/zlib-1.2.13/zlib.3.pdf and /dev/null differ diff --git a/3rdparty/mongo-c-driver-1.26.2/src/zlib-1.2.13/zlib2ansi b/3rdparty/mongo-c-driver-1.26.2/src/zlib-1.2.13/zlib2ansi deleted file mode 100755 index 23b2a1d5a..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/src/zlib-1.2.13/zlib2ansi +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/perl - -# Transform K&R C function definitions into ANSI equivalent. -# -# Author: Paul Marquess -# Version: 1.0 -# Date: 3 October 2006 - -# TODO -# -# Assumes no function pointer parameters. unless they are typedefed. -# Assumes no literal strings that look like function definitions -# Assumes functions start at the beginning of a line - -use strict; -use warnings; - -local $/; -$_ = <>; - -my $sp = qr{ \s* (?: /\* .*? \*/ )? \s* }x; # assume no nested comments - -my $d1 = qr{ $sp (?: [\w\*\s]+ $sp)* $sp \w+ $sp [\[\]\s]* $sp }x ; -my $decl = qr{ $sp (?: \w+ $sp )+ $d1 }xo ; -my $dList = qr{ $sp $decl (?: $sp , $d1 )* $sp ; $sp }xo ; - - -while (s/^ - ( # Start $1 - ( # Start $2 - .*? # Minimal eat content - ( ^ \w [\w\s\*]+ ) # $3 -- function name - \s* # optional whitespace - ) # $2 - Matched up to before parameter list - - \( \s* # Literal "(" + optional whitespace - ( [^\)]+ ) # $4 - one or more anythings except ")" - \s* \) # optional whitespace surrounding a Literal ")" - - ( (?: $dList )+ ) # $5 - - $sp ^ { # literal "{" at start of line - ) # Remember to $1 - //xsom - ) -{ - my $all = $1 ; - my $prefix = $2; - my $param_list = $4 ; - my $params = $5; - - StripComments($params); - StripComments($param_list); - $param_list =~ s/^\s+//; - $param_list =~ s/\s+$//; - - my $i = 0 ; - my %pList = map { $_ => $i++ } - split /\s*,\s*/, $param_list; - my $pMatch = '(\b' . join('|', keys %pList) . '\b)\W*$' ; - - my @params = split /\s*;\s*/, $params; - my @outParams = (); - foreach my $p (@params) - { - if ($p =~ /,/) - { - my @bits = split /\s*,\s*/, $p; - my $first = shift @bits; - $first =~ s/^\s*//; - push @outParams, $first; - $first =~ /^(\w+\s*)/; - my $type = $1 ; - push @outParams, map { $type . $_ } @bits; - } - else - { - $p =~ s/^\s+//; - push @outParams, $p; - } - } - - - my %tmp = map { /$pMatch/; $_ => $pList{$1} } - @outParams ; - - @outParams = map { " $_" } - sort { $tmp{$a} <=> $tmp{$b} } - @outParams ; - - print $prefix ; - print "(\n" . join(",\n", @outParams) . ")\n"; - print "{" ; - -} - -# Output any trailing code. -print ; -exit 0; - - -sub StripComments -{ - - no warnings; - - # Strip C & C++ comments - # From the perlfaq - $_[0] =~ - - s{ - /\* ## Start of /* ... */ comment - [^*]*\*+ ## Non-* followed by 1-or-more *'s - ( - [^/*][^*]*\*+ - )* ## 0-or-more things which don't start with / - ## but do end with '*' - / ## End of /* ... */ comment - - | ## OR C++ Comment - // ## Start of C++ comment // - [^\n]* ## followed by 0-or-more non end of line characters - - | ## OR various things which aren't comments: - - ( - " ## Start of " ... " string - ( - \\. ## Escaped char - | ## OR - [^"\\] ## Non "\ - )* - " ## End of " ... " string - - | ## OR - - ' ## Start of ' ... ' string - ( - \\. ## Escaped char - | ## OR - [^'\\] ## Non '\ - )* - ' ## End of ' ... ' string - - | ## OR - - . ## Anything other char - [^/"'\\]* ## Chars which doesn't start a comment, string or escape - ) - }{$2}gxs; - -} diff --git a/3rdparty/mongo-c-driver-1.26.2/tools/init.ps1 b/3rdparty/mongo-c-driver-1.26.2/tools/init.ps1 deleted file mode 100644 index 5299e04ab..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/tools/init.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -$ErrorActionPreference = "Stop" - -$is_windows = $PSVersionTable.Platform -eq "Win32NT" -or $PSVersionTable.PSEdition -eq "Desktop" - -if (-not $is_windows) { - throw "This script is meant for Windows only." -} - -$USER_CACHES_DIR = $env:USER_CACHES_DIR -if ([String]::IsNullOrEmpty($USER_CACHES_DIR)) { - $USER_CACHES_DIR = $env:LOCALAPPDATA -} - -$BUILD_CACHE_BUST = $env:BUILD_CACHE_BUST -if ([String]::IsNullOrEmpty($BUILD_CACHE_BUST)) { - $BUILD_CACHE_BUST = "1" -} -$BUILD_CACHE_DIR = Join-Path $USER_CACHES_DIR "mongoc.$BUILD_CACHE_BUST" -Write-Debug "Calculated mongoc build cache directory to be [$BUILD_CACHE_DIR]" - - -function Test-Command { - param ( - [string[]]$Name, - [System.Management.Automation.CommandTypes]$CommandType = 'All' - ) - $found = @(Get-Command -Name:$Name -CommandType:$CommandType -ErrorAction Ignore -TotalCount 1) - if ($found.Length -ne 0) { - return $true - } - return $false -} - -function Find-Python { - if (Test-Command "py" -CommandType Application -and (& py -c "(x:=0)")) { - $found = "py" - } - else { - foreach ($n in 20..8) { - $cand = "python3.$n" - Write-Debug "Try Python: [$cand]" - if (!(Test-Command $cand -CommandType Application)) { - continue; - } - if (& "$cand" -c "(x:=0)") { - $found = "$cand" - break - } - } - } - $found = (Get-Command "$found" -CommandType Application).Source - $ver = (& $found -c "import sys; print(sys.version)" | Out-String).Trim() - Write-Debug "Found Python: [$found] (Version $ver)" - return $found -} diff --git a/3rdparty/mongo-c-driver-1.26.2/tools/poetry.ps1 b/3rdparty/mongo-c-driver-1.26.2/tools/poetry.ps1 deleted file mode 100644 index f1ed08c71..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/tools/poetry.ps1 +++ /dev/null @@ -1,102 +0,0 @@ -<# -.SYNOPSIS - Execute a pinned and cached installation of Poetry -.DESCRIPTION - This command will execute a Poetry command subprocess. It first looks for - an installed version, installs it if it is absent, and then uses the - installed Poetry to execute the requested command. - - For help from Poetry, Use the 'poetry.ps1 help' command as seen in example 1. -.EXAMPLE - > poetry.ps1 help - - Print help messages from Poetry itself -.EXAMPLE - > poetry.ps1 install --with=docs --with=env - - Installs the project dependencies in the active virtualenv. This operation - is idempotent -.EXAMPLE - > poetry.ps1 shell - - Spawn a new interactive PowerShell session with the project's virtualenv - active. With this, the project's dependencies will be available on - $env:PATH. -.EXAMPLE - > poetry.ps1 run sphinx-build -bhtml docs/ out/docs/html - - Execute the sphinx-build executable that is installed within the - Poetry-managed virtual environment. -.LINK - https://python-poetry.org - - The Poetry website. -#> -[CmdletBinding(PositionalBinding = $false)] -param( - # The version of Poetry that we want to install. By default, installs 1.4.2 - [string] - $PoetryVersion = "1.4.2", - # Force the directory in which Poetry will be installed - [string] - $PoetryHome, - # The Poetry subcommand to execute. (If any Poetry arguments conflict with - # PowerShell argument parsing, enquote them to ensure they are passed as - # positional string arguments.) - [Parameter(Position = 2, ValueFromRemainingArguments)] - [string[]] - $Command -) - -# Halt on subcommand errors -$ErrorActionPreference = 'Stop' - -# We assume Windows and pwsh 7+ -$is_pwsh_win = $PSVersionTable.Platform -eq "Win32NT" -or $PSVersionTable.PSEdition -eq "Desktop" -if (-not $is_pwsh_win) { - throw "This script is meant for PowerShell 7+ on Windows. (Use 'pwsh' on Windows, and use poetry.sh for Unix-like systems.)" -} - -# The directory that contains this file: -$this_dir = $PSScriptRoot - -# Load util vars and functions: -. "$this_dir/init.ps1" - -# The directory in which we are installing Poetry: -if ([String]::IsNullOrEmpty($PoetryHome)) { - $PoetryHome = "$BUILD_CACHE_DIR/poetry-$PoetryVersion" -} -$stamp_file = Join-Path $PoetryHome ".installed.done" - -# Poetry respects the POETRY_HOME environment variable. -$env:POETRY_HOME = $PoetryHome - -$py = Find-Python - -# Create the Poetry installation if it is not already present -if (!(Test-Path $stamp_file)) { - Write-Debug "Installing Poetry $PoetryVersion into [$PoetryHome]" - # Lock to prevent concurrent installations - $mtx = New-Object System.Threading.Mutex($false, "Global\MongoCPoetryInstall") - [void]$mtx.WaitOne() - # (No need to double-check, since a second install is a no-op) - try { - # Do the actual install: - & $py -u "$this_dir/install-poetry.py" --yes --version "$PoetryVersion" - if ($LASTEXITCODE -ne 0) { - throw "Poetry installation failed [$LASTEXITCODE]" - } - # Touch the stamp file to tell future runs that the install is okay: - Set-Content $stamp_file "" - } - finally { - [void]$mtx.ReleaseMutex() - } -} - -# Execute the Poetry command -$poetry_exe = Join-Path $PoetryHome "bin/poetry.exe" -& $poetry_exe env use --quiet $py -& $poetry_exe @Command -exit $LASTEXITCODE diff --git a/3rdparty/mongo-c-driver-1.26.2/tools/poetry.sh b/3rdparty/mongo-c-driver-1.26.2/tools/poetry.sh deleted file mode 100755 index 80692f129..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/tools/poetry.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash - -# Automatically installs and invokes a pinned version of Poetry (https://python-poetry.org/) -# -## Commands defined by this file: -# -# * run-poetry [ ...] -# • Execute the given Poetry command. This script can also be executed -# directly to run the same Poetry command. -# -# On first run, will install a new Poetry instance in a user-local cache -# directory. This script DOES NOT respect POETRY_HOME! Instead, use -# FORCE_POETRY_HOME to force a directory in which to install Poetry. -# -# * ensure-poetry [ []] -# • Ensures that Poetry of the given is installed into . -# This is an idempotent operation. Defaults are from WANT_POETRY_VERSION -# and POETRY_HOME (see below). -# -## Variables set by this file: -# -# * POETRY_HOME -# • The default user-local directory in which Poetry will be installed. -# This can be overriden by setting FORCE_POETRY_HOME. -# * POETRY_EXE -# • The default full path to the Poetry that will be installed and run by -# this script (not present until after ensure-poetry or run-poetry is -# executed). -# * WANT_POETRY_VERSION (overridable) (default 1.5.1) -# • The version of Poetry that will be installed by run-poetry when executed. -# * POETRY_PYTHON_VERSION (overridable) (default to result of find-python) -# • The Python binary to use by the Poetry installer and virtual environment(s). - -# Load vars and utils: -. "$(dirname "${BASH_SOURCE[0]}")/use.sh" python paths base with_lock download - -: "${WANT_POETRY_VERSION:=1.5.1}" -: "${POETRY_PYTHON_BINARY:="$(find-python)"}" -declare -r -x POETRY_HOME=${FORCE_POETRY_HOME:-"$BUILD_CACHE_DIR/poetry-$WANT_POETRY_VERSION"} -declare -r POETRY_EXE=$POETRY_HOME/bin/poetry$EXE_SUFFIX - -# Usage: install-poetry -install-poetry() { - declare poetry_version=$1 - declare poetry_home=$2 - log "Installing Poetry $poetry_version into [$poetry_home]" - mkdir -p "$poetry_home" - # Download the automated installer: - installer=$poetry_home/install-poetry.py - download-file --uri=https://install.python-poetry.org --out="$installer" - # Run the install: - with-lock "$POETRY_HOME/.install.lock" \ - env POETRY_HOME="$poetry_home" \ - "$POETRY_PYTHON_BINARY" -u "$installer" --yes --version "$poetry_version" \ - || ( - cat -- poetry-installer*.log && fail "Poetry installation failed" - ) - printf %s "$poetry_version" > "$POETRY_HOME/installed.txt" -} - -# Idempotent installation: -# Usage: ensure-poetry -ensure-poetry() { - declare version=${1:-$WANT_POETRY_VERSION} - declare home=${2:-$POETRY_HOME} - if ! is-file "$home/installed.txt" || [[ "$(cat "$home/installed.txt")" != "$version" ]]; then - install-poetry "$version" "$home" - fi - # Extra step must be taken to ensure Poetry's virtual environment uses the correct Python binary. - # See: https://github.com/python-poetry/poetry/issues/522 - with-lock "$POETRY_HOME/.install.lock" \ - env POETRY_HOME="$POETRY_HOME" \ - "$POETRY_EXE" env use --quiet -- "$POETRY_PYTHON_BINARY" \ - || ( - fail "Poetry failed to set Python binary to $POETRY_PYTHON_BINARY" - ) -} - -run-poetry() { - ensure-poetry "$WANT_POETRY_VERSION" "$POETRY_HOME" - env POETRY_HOME="$POETRY_HOME" "$POETRY_EXE" "$@" -} - -# Poetry bug: Poetry uses the keyring, even for non-authenticating commands, -# which can wreak havoc in cases where the keyring is unavailable -# (i.e. SSH and non-interactive sessions) -# (https://github.com/python-poetry/poetry/issues/1917) -export PYTHON_KEYRING_BACKEND="keyring.backends.null.Keyring" - -if is-main; then - if [[ "$*" = "--ensure-installed" ]]; then - # Just install, don't run it - ensure-poetry "$WANT_POETRY_VERSION" "$POETRY_HOME" - else - # Run the Poetry command: - run-poetry "$@" - fi -fi diff --git a/3rdparty/mongo-c-driver-1.26.2/tools/python.sh b/3rdparty/mongo-c-driver-1.26.2/tools/python.sh deleted file mode 100755 index 0392f9718..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/tools/python.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash - -## Commands defined by this file: -# -# * run-python [...] -# • Execute the Python interpreter with the given arguments -# * find-python -# • Searches for a Python executable that supports Python 3.8 or newer -# -# Run this file directly to invoke the same Python executable. -# Invoke this script with "--where" to print the path to the Python executable -# that would be used. - -. "$(dirname "${BASH_SOURCE[0]}")/use.sh" base - -find-python() { - pys=( - py - python3.14 - python3.13 - python3.12 - python3.11 - python3.10 - python3.9 - python3.8 - python3 - python - ) - for cand in "${pys[@]}"; do - # Find a Python that supports "x := 0", which was added in Python 3.8 - if have-command "$cand" && "$cand" -c "(x:=0)" > /dev/null 2>&1; then - _found=$(type -P "$cand") - break - fi - done - if ! is-set _found; then - fail "No Python (≥3.8) executable was found" - fi - - debug "Found Python: $_found" - printf %s "$_found" -} - -run-python() { - local py - py=$(find-python) - "$py" "$@" -} - -if is-main; then - if [[ "$*" = "--where" ]]; then - printf "%s\n" "$(find-python)" - else - run-python "$@" - fi -fi diff --git a/3rdparty/mongo-c-driver-1.26.2/tools/str.sh b/3rdparty/mongo-c-driver-1.26.2/tools/str.sh deleted file mode 100755 index 826878277..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/tools/str.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/sh - -# This is a tiny shell utility for string manipulation. -# Allow us to use "local" -# shellcheck disable=SC3043 - -set -eu - -_HELP='Usage: - str {lower,upper} - str test - -Commands: - lower, upper - Convert input (stdin) to all-lowercase or all-uppercase, respectively - - test (-ieq|-ine|-contains|-matches) - Like "test", but with additional string comparisons: - -ieq • case-insensitive equal - -ine • case-insensitive not-equal - -contains • Check if contains - -matches • Check if matches pattern (A grep -E pattern) -' - -fail() { - # shellcheck disable=SC2059 - printf -- "$@" 1>&2 - printf -- "\n" 1>&2 - return 1 -} - -__str__upper() { - __justStdin upper __upper "$@" -} -__upper() { - tr '[:lower:]' '[:upper:]' -} - -__str__lower() { - __justStdin lower __lower "$@" -} -__lower() { - tr '[:upper:]' '[:lower:]' -} - -__justStdin() { - if test $# -gt 2; then - fail "Command '%s' does not take any arguments (write input into stdin)" "$1" || return - fi - "$2" -} - -__str__help() { - printf %s "$_HELP" -} -__str____help() { - __str help -} -__str___h() { - __str help -} -__str___help() { - __str help -} - -__str__test() { - test "$#" -eq 3 || fail '“str test†expects three arguments (Got %d: “%sâ€)' $# "$*" \ - || return - local lhs="$1" - local op="$2" - local rhs="$3" - local norm_lhs norm_rhs; - norm_lhs=$(echo "$lhs" | __str lower) || return - norm_rhs=$(echo "$rhs" | __str lower) || return - case $op in - -ieq) - test "$norm_lhs" = "$norm_rhs";; - -ine) - test "$norm_lhs" != "$norm_rhs";; - -matches) - printf %s "$lhs" | grep -qE -- "$rhs";; - -contains) - printf %s "$lhs" | grep -qF -- "$rhs";; - -*|=*) - # Just defer to the underlying test command - test "$lhs" "$op" "$rhs" - esac -} - -__str() { - local _Command="$1" - local _CommandIdent - _CommandIdent="$(echo "__str__$_Command" | sed ' - s/-/_/g - s/\./__/g - ')" - shift - "$_CommandIdent" "$@" -} - -__str "$@" diff --git a/3rdparty/mongo-c-driver-1.26.2/tools/with_lock.sh b/3rdparty/mongo-c-driver-1.26.2/tools/with_lock.sh deleted file mode 100755 index ba81c0431..000000000 --- a/3rdparty/mongo-c-driver-1.26.2/tools/with_lock.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -. "$(dirname "${BASH_SOURCE[0]}")/use.sh" base - -# * with-lock [command ...] -# Execute ‘command’ while holding as an exclusive lock. This -# requires the ‘lckdo’ command, otherwise it executes the command without -# taking any lock. The parent directory of must exists. NOTE: -# the given command must be an application, and not a shell-internal or -# shell function. -with-lock() { - [[ "$#" -gt 1 ]] || fail "with-lock requires a lock filename and a command to run" - if ! have-command lckdo; then - log "No ‘lckdo’ program is installed. We'll run without the lock, but parallel tasks may contend." - log " (‘lckdo’ is part of the ‘moreutils’ package)" - shift - command "$@" - else - lckdo -W 30 -- "$@" - fi -} diff --git a/3rdparty/mongo-c-driver-2.1.0/.clang-format b/3rdparty/mongo-c-driver-2.1.0/.clang-format new file mode 100644 index 000000000..070df9950 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.clang-format @@ -0,0 +1,325 @@ +--- +# Note: the "Language" option is omitted to apply this format style to all files +# regardless of the detected language. +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: true + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: Never +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AllowShortNamespacesOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AttributeMacros: + - __capability + - BSON_GNUC_WARN_UNUSED_RESULT + - BSON_DEPRECATED + - BSON_DEPRECATED_FOR +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Never +BreakAfterJavaFieldAnnotations: false +BreakAfterReturnType: All +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Linux +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakBinaryOperations: Never +BreakConstructorInitializers: BeforeColon +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +BreakTemplateDeclarations: MultiLine +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 3 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH + - mlib_foreach_irange + - mlib_foreach_urange + - mlib_foreach + - mlib_foreach_arr +IfMacros: + - mlib_assert_aborts + - KJ_IF_MAYBE +IncludeBlocks: Regroup +IncludeCategories: + # The prelude header must always come first + - Regex: '-prelude\.h>' + Priority: 1 + # Relative "in this directory" headers next + - Regex: '"\./|"\.\./' + Priority: 2 + # Private API headers + - Regex: '-private\.h>' + Priority: 5 + # All other `mongoc/` headers + - Regex: '' + Priority: 90 + # Darwin platform headers + - Regex: '<(Availability|AvailabilityMacros|TargetConditionals|CommonCrypto/.*|Security/.*|CoreFoundation/.*)\.h>' + CaseSensitive: false + Priority: 90 + # Windows platform headers + - Regex: '<(win(dows|sock2|error|trnl|error|crypt|ver|dns)|sspi|ws2tcpip|ntstatus|mstcpip|process)\.h>' + CaseSensitive: false + Priority: 90 + # Standard library headers are near last + - Regex: '<(assert|string|ctype|limits|time|math|errno|inttypes|signal).h>|' + Priority: 100 + # Other -I headers get sorted before platform headers + - Regex: '<' + Priority: 80 +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: false +IndentExportBlock: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 3 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: false + AtStartOfFile: false +KeepFormFeed: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MainIncludeChar: AngleBracket +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakBeforeMemberAccess: 150 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +PPIndentWidth: -1 +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: Always +RemoveBracesLLVM: false +RemoveEmptyLinesInUnwrappedLines: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: Always +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterPlacementOperator: false + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Cpp11 +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TableGenBreakInsideDAGArg: DontBreak +TabWidth: 3 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +WrapNamespaceBodyWithEmptyLines: Leave +... diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/.codecov.yml b/3rdparty/mongo-c-driver-2.1.0/.evergreen/.codecov.yml similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/.codecov.yml rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/.codecov.yml diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/benchmark.yml b/3rdparty/mongo-c-driver-2.1.0/.evergreen/benchmark.yml similarity index 78% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/benchmark.yml rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/benchmark.yml index 4b1ea88c7..48b7995f9 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/benchmark.yml +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/benchmark.yml @@ -35,8 +35,8 @@ variables: set -o errexit set -o verbose - cmake -DENABLE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=mongoc -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF . && make -j8 && make install - git clone git@github.com:mongodb/mongo-c-driver-performance.git + cmake -DENABLE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=mongoc . && make -j8 && make install + git clone https://github.com/mongodb/mongo-c-driver-performance.git cd mongo-c-driver-performance cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=../mongoc . && make -j8 @@ -170,10 +170,44 @@ functions: file_location: mongo-c-driver/report.json "send dashboard data" : - command: perf.send - params: - name: perf - file: mongo-c-driver/results.json + # Here we begin to generate the request to send the data to Signal Processing Service (SPS) + - command: shell.exec + params: + script: | + # We use the requester expansion to determine whether the data is from a mainline evergreen run or not + if [ "${requester}" == "commit" ]; then + echo "is_mainline: true" >> expansion.yml + else + echo "is_mainline: false" >> expansion.yml + fi + + # We parse the username out of the order_id as patches append that in and SPS does not need that information + echo "parsed_order_id: $(echo "${revision_order_id}" | awk -F'_' '{print $NF}')" >> expansion.yml + - command: expansions.update + params: + file: expansion.yml + - command: shell.exec + params: + script: | + # Submit the performance data to the SPS endpoint + response=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -X 'POST' \ + "https://performance-monitoring-api.corp.mongodb.com/raw_perf_results/cedar_report?project=${project_id}&version=${version_id}&variant=${build_variant}&order=${parsed_order_id}&task_name=${task_name}&task_id=${task_id}&execution=${execution}&mainline=${is_mainline}" \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d @mongo-c-driver/results.json) + + http_status=$(echo "$response" | grep "HTTP_STATUS" | awk -F':' '{print $2}') + response_body=$(echo "$response" | sed '/HTTP_STATUS/d') + + # We want to throw an error if the data was not successfully submitted + if [ "$http_status" -ne 200 ]; then + echo "Error: Received HTTP status $http_status" + echo "Response Body: $response_body" + exit 1 + fi + + echo "Response Body: $response_body" + echo "HTTP Status: $http_status" "backtrace": - command: shell.exec diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config.yml b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config.yml similarity index 92% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config.yml rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config.yml index 5f5d71331..7612d3564 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config.yml +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config.yml @@ -20,10 +20,6 @@ pre_error_fails_task: true # teardown_group commands of appropriate task groups. post_error_fails_task: false -# Unlikely, but document loudly when task failure is due to early termination. -early_termination: - - func: early-termination - # TODO: move into timeout commands of appropriate task groups. timeout: - func: backtrace diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/README.md b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/README.md new file mode 100644 index 000000000..f8a425e86 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/README.md @@ -0,0 +1,35 @@ +# Generating the Evergreen Configuration Files + +The scripts in this directory are used to generate the Evergreen configuration +files stored in `.evergreen/generated_configs/`. + +The easiest way to execute these scripts is to use [uv](https://docs.astral.sh/uv/) to run the scripts. + +**Note**: These scripts require Python 3.10 or newer. + + +## Setting Up + +`uv` is required to run Python scripts. See ["Installing uv"](https://docs.astral.sh/uv/getting-started/installation/) for instructions on how to obtain `uv`. + + +## Running the Generator + +The package provides the `mc-evg-generate` [entry point](https://packaging.python.org/en/latest/specifications/entry-points): + +```sh +uv run --frozen mc-evg-generate +``` + +This command will ready the generation files and generate a new set of Evergreen +configs in `.evergreen/config_generator/generated_configs`. + +The `mc-evg-generate` command executes `main` function defined in +`config_generator/generate.py`. + + +## Modifying the Configs + +To modify the Evergreen configuration, update the Python scripts within the +`etc/`, `config_generator/`, and `legacy_config_generator/` directories, and +execute `mc-evg-generate` again. diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/abi_compliance_check.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/abi_compliance_check.py new file mode 100644 index 000000000..1ea3ac0d3 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/abi_compliance_check.py @@ -0,0 +1,62 @@ +from shrub.v3.evg_command import EvgCommandType +from shrub.v3.evg_command import s3_put +from shrub.v3.evg_task import EvgTask + +from config_generator.components.funcs.set_cache_dir import SetCacheDir + +from config_generator.etc.function import Function +from config_generator.etc.utils import bash_exec + + +class CheckABICompliance(Function): + name = 'abi-compliance-check' + commands = SetCacheDir.commands + [ + bash_exec( + command_type=EvgCommandType.SETUP, + working_dir='mongoc', + include_expansions_in_env=['MONGO_C_DRIVER_CACHE_DIR'], + script='.evergreen/scripts/abi-compliance-check-setup.sh' + ), + bash_exec( + command_type=EvgCommandType.TEST, + add_expansions_to_env=True, + working_dir='mongoc', + include_expansions_in_env=['MONGO_C_DRIVER_CACHE_DIR'], + script='.evergreen/scripts/abi-compliance-check.sh' + ), + s3_put( + command_type=EvgCommandType.SYSTEM, + aws_key='${aws_key}', + aws_secret='${aws_secret}', + bucket='mciuploads', + content_type='text/html', + display_name='ABI Compliance Check: ', + local_files_include_filter='abi-compliance/compat_reports/**/compat_report.html', + permissions='public-read', + remote_file='${project}/${branch_name}/${revision}/${version_id}/${build_id}/${task_id}/${execution}/abi-compliance-check/', + ), + s3_put( + command_type=EvgCommandType.SYSTEM, + aws_key='${aws_key}', + aws_secret='${aws_secret}', + bucket='mciuploads', + content_type='text/plain', + display_name='ABI Compliance Check: ', + local_files_include_filter='abi-compliance/logs/**/log.txt', + permissions='public-read', + remote_file='${project}/${branch_name}/${revision}/${version_id}/${build_id}/${task_id}/${execution}/abi-compliance-check/', + ), + ] + + +def functions(): + return CheckABICompliance.defn() + + +def tasks(): + return [ + EvgTask( + name=CheckABICompliance.name, + commands=[CheckABICompliance.call()], + ) + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/c_std_compile.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/c_std_compile.py new file mode 100644 index 000000000..3640495b6 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/c_std_compile.py @@ -0,0 +1,113 @@ +from shrub.v3.evg_build_variant import BuildVariant +from shrub.v3.evg_command import EvgCommandType +from shrub.v3.evg_task import EvgTask, EvgTaskRef + +from config_generator.components.funcs.find_cmake_latest import FindCMakeLatest + +from config_generator.etc.distros import find_large_distro +from config_generator.etc.distros import make_distro_str +from config_generator.etc.distros import compiler_to_vars +from config_generator.etc.function import Function +from config_generator.etc.utils import bash_exec + + +TAG = 'std-matrix' + + +# pylint: disable=line-too-long +# fmt: off +MATRIX = [ + ('rhel80', 'clang', None, [99, 11, 17, ]), # Clang 7.0 + ('ubuntu2004', 'clang-10', None, [99, 11, 17, 23]), # Clang 10.0 (max: C2x) + ('rhel84', 'clang', None, [99, 11, 17, 23]), # Clang 11.0 (max: C2x) + ('ubuntu2204', 'clang-12', None, [99, 11, 17, 23]), # Clang 12.0 (max: C2x) + ('rhel90', 'clang', None, [99, 11, 17, 23]), # Clang 13.0 (max: C2x) + ('rhel91', 'clang', None, [99, 11, 17, 23]), # Clang 14.0 (max: C2x) + ('rhel92', 'clang', None, [99, 11, 17, 23]), # Clang 15.0 (max: C2x) + ('rhel93', 'clang', None, [99, 11, 17, 23]), # Clang 16.0 (max: C2x) + ('rhel94', 'clang', None, [99, 11, 17, 23]), # Clang 17.0 (max: C2x) + ('rhel95', 'clang', None, [99, 11, 17, 23]), # Clang 18.0 (max: C23) + + ('rhel7-latest', 'gcc', None, [99, 11, ]), # GCC 4.8 (max: C11) + ('rhel80', 'gcc', None, [99, 11, 17, ]), # GCC 8.2 (max: C17) + ('rhel84', 'gcc', None, [99, 11, 17, ]), # GCC 8.4 (max: C17) + ('ubuntu2004', 'gcc-9', None, [99, 11, 17, 23]), # GCC 9.4 (max: C2x) + ('debian11', 'gcc-10', None, [99, 11, 17, 23]), # GCC 10.2 (max: C2x) + ('rhel90', 'gcc', None, [99, 11, 17, 23]), # GCC 11.2 (max: C2x) + ('rhel92', 'gcc', None, [99, 11, 17, 23]), # GCC 11.3 (max: C2x) + ('rhel94', 'gcc', None, [99, 11, 17, 23]), # GCC 11.4 (max: C2x) + ('rhel95', 'gcc', None, [99, 11, 17, 23]), # GCC 11.5 (max: C2x) + ('ubuntu2404', 'gcc-13', None, [99, 11, 17, 23]), # GCC 13.3 (max: C2x) + + ('windows-vsCurrent', 'vs2015x64', None, [99, 11, ]), # Max: C11 + ('windows-vsCurrent', 'vs2017x64', None, [99, 11, ]), # Max: C11 + ('windows-vsCurrent', 'vs2019x64', None, [99, 11, 17]), # Max: C17 + ('windows-vsCurrent', 'vs2022x64', None, [99, 11, 17]), # Max: C17 +] +# fmt: on +# pylint: enable=line-too-long + + +class StdCompile(Function): + name = 'std-compile' + commands = [ + bash_exec( + command_type=EvgCommandType.TEST, + add_expansions_to_env=True, + working_dir='mongoc', + script='.evergreen/scripts/compile-std.sh', + ), + ] + + +def functions(): + return StdCompile.defn() + + +def tasks(): + res = [] + + for distro_name, compiler, arch, stds in MATRIX: + compiler_type = compiler.split('-')[0] + + tags = [TAG, distro_name, compiler_type, 'compile'] + + distro = find_large_distro(distro_name) + + compile_vars = None + compile_vars = compiler_to_vars(compiler) + + if arch: + tags.append(arch) + compile_vars.update({'MARCH': arch}) + + distro_str = make_distro_str(distro_name, compiler_type, arch) + + for std in stds: + with_std = {'C_STD_VERSION': std} + + task_name = f'std-c{std}-{distro_str}-compile' + + res.append( + EvgTask( + name=task_name, + run_on=distro.name, + tags=tags + [f'std-c{std}'], + commands=[ + FindCMakeLatest.call(), + StdCompile.call(vars=compile_vars | with_std) + ], + ) + ) + + return res + + +def variants(): + return [ + BuildVariant( + name=TAG, + display_name=TAG, + tasks=[EvgTaskRef(name=f'.{TAG}')], + ), + ] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/check_mongoc_public_headers.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/check_mongoc_public_headers.py similarity index 90% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/check_mongoc_public_headers.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/check_mongoc_public_headers.py index 830aa9023..66283d4ae 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/check_mongoc_public_headers.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/check_mongoc_public_headers.py @@ -20,10 +20,6 @@ class CheckMongocPublicHeaders(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return CheckMongocPublicHeaders.defn() diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/clang_format.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/clang_format.py new file mode 100644 index 000000000..821b1a1ef --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/clang_format.py @@ -0,0 +1,48 @@ +from shrub.v3.evg_build_variant import BuildVariant +from shrub.v3.evg_command import EvgCommandType +from shrub.v3.evg_task import EvgTask +from shrub.v3.evg_task import EvgTaskRef + +from config_generator.etc.distros import find_small_distro +from config_generator.etc.function import Function +from config_generator.etc.utils import bash_exec + + +TAG = "clang-format" + + +class ClangFormat(Function): + name = TAG + commands = [ + bash_exec( + command_type=EvgCommandType.TEST, + working_dir="mongoc", + env={ + "DRYRUN": "1", + }, + script="uv run --frozen --only-group=format tools/format.py --mode=check", + ), + ] + + +def functions(): + return ClangFormat.defn() + + +def tasks(): + yield EvgTask( + name=TAG, + tags=[TAG], + commands=[ClangFormat.call()], + ) + + +def variants(): + return [ + BuildVariant( + name=TAG, + display_name=TAG, + run_on=[find_small_distro("ubuntu2204").name], + tasks=[EvgTaskRef(name=f".{TAG}")], + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/cse/darwinssl.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/cse/darwinssl.py new file mode 100644 index 000000000..8fa99061a --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/cse/darwinssl.py @@ -0,0 +1,80 @@ +from shrub.v3.evg_build_variant import BuildVariant +from shrub.v3.evg_task import EvgTaskRef + +from config_generator.etc.compile import generate_compile_tasks + +from config_generator.etc.cse.compile import CompileCommon +from config_generator.etc.cse.test import generate_test_tasks + + +SSL = 'darwinssl' +TAG = f'cse-matrix-{SSL}' + + +# pylint: disable=line-too-long +# fmt: off +COMPILE_MATRIX = [ + ('macos-14', 'clang', None, ['cyrus']), + + ('macos-11-arm64', 'clang', None, ['cyrus']), + ('macos-14-arm64', 'clang', None, ['cyrus']), +] + +# TODO (CDRIVER-3789): test cse with the 'sharded' topology. +TEST_MATRIX = [ + ('macos-14', 'clang', None, 'cyrus', ['auth'], ['server'], ['4.2', '4.4', '5.0']), + + ('macos-11-arm64', 'clang', None, 'cyrus', ['auth'], ['server'], ['6.0']), + ('macos-14-arm64', 'clang', None, 'cyrus', ['auth'], ['server'], ['6.0']), + + # Test 7.0+ with a replica set since Queryable Encryption does not support the 'server' topology. Queryable Encryption tests require 7.0+. + ('macos-14-arm64', 'clang', None, 'cyrus', ['auth'], ['server', 'replica' ], ['7.0', '8.0', 'latest']), +] +# fmt: on +# pylint: enable=line-too-long + + +class DarwinSSLCompileCommon(CompileCommon): + ssl = 'DARWIN' + + +class SaslCyrusDarwinSSLCompile(DarwinSSLCompileCommon): + name = 'cse-sasl-cyrus-darwinssl-compile' + commands = DarwinSSLCompileCommon.compile_commands(sasl='CYRUS') + + +def functions(): + return SaslCyrusDarwinSSLCompile.defn() + + +def tasks(): + res = [] + + SASL_TO_FUNC = { + 'cyrus': SaslCyrusDarwinSSLCompile, + } + + MORE_TAGS = ['cse'] + + res += generate_compile_tasks( + SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS + ) + + res += generate_test_tasks(SSL, TAG, TEST_MATRIX) + + return res + + +def variants(): + expansions = { + 'CLIENT_SIDE_ENCRYPTION': 'on', + } + + return [ + BuildVariant( + name=TAG, + display_name=TAG, + tasks=[EvgTaskRef(name=f'.{TAG}')], + expansions=expansions, + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/cse/openssl.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/cse/openssl.py new file mode 100644 index 000000000..9be2cc12a --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/cse/openssl.py @@ -0,0 +1,123 @@ +from shrub.v3.evg_build_variant import BuildVariant + +from config_generator.etc.compile import generate_compile_tasks +from config_generator.etc.function import merge_defns +from config_generator.etc.utils import TaskRef + +from config_generator.etc.cse.compile import CompileCommon +from config_generator.etc.cse.test import generate_test_tasks + + +SSL = 'openssl' +TAG = f'cse-matrix-{SSL}' + + +# pylint: disable=line-too-long +# fmt: off +COMPILE_MATRIX = [ + # For test matrix. + ('rhel8-latest', 'gcc', None, ['cyrus']), + ('rhel8-zseries', 'gcc', None, ['cyrus']), + ('ubuntu2004-arm64', 'gcc', None, ['cyrus']), + ('windows-vsCurrent', 'vs2017x64', None, ['cyrus']), + + # For compile only. + ('debian11', 'clang', None, ['cyrus']), + ('debian11', 'gcc', None, ['cyrus']), + ('debian12', 'clang', None, ['cyrus']), + ('debian12', 'gcc', None, ['cyrus']), + ('rhel80', 'gcc', None, ['cyrus']), + ('ubuntu2004', 'gcc', None, ['cyrus']), + ('ubuntu2004', 'clang', None, ['cyrus']), + ('ubuntu2204', 'gcc', None, ['cyrus']), + ('ubuntu2204', 'clang-12', None, ['cyrus']), + ('ubuntu2404', 'gcc', None, ['cyrus']), + ('ubuntu2404', 'clang-14', None, ['cyrus']), +] + +# TODO (CDRIVER-3789): test cse with the 'sharded' topology. +# CSFLE requires 4.2+. QE requires 7.0+ and are skipped on "server" tasks. +TEST_MATRIX = [ + # rhel8-latest provides 4.2+. + ('rhel8-latest', 'gcc', None, 'cyrus', ['auth'], ['server', 'replica'], ['4.2', '4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), + + # windows-vsCurrent provides 4.2+. + ('windows-vsCurrent', 'vs2017x64', None, 'cyrus', ['auth'], ['server', 'replica'], ['4.2', '4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), + + # ubuntu2004-arm64 provides 4.4+. + ('ubuntu2004-arm64', 'gcc', None, 'cyrus', ['auth'], ['server', 'replica'], ['4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), + + # rhel8-zseries provides 5.0+. + ('rhel8-zseries', 'gcc', None, 'cyrus', ['auth'], ['server', 'replica'], ['5.0', '6.0', '7.0', '8.0', 'latest']), +] +# fmt: on +# pylint: enable=line-too-long + + +class OpenSSLCompileCommon(CompileCommon): + ssl = 'OPENSSL' + + +class SaslCyrusOpenSSLCompile(OpenSSLCompileCommon): + name = 'cse-sasl-cyrus-openssl-compile' + commands = OpenSSLCompileCommon.compile_commands(sasl='CYRUS') + + +def functions(): + return merge_defns( + SaslCyrusOpenSSLCompile.defn(), + ) + + +SASL_TO_FUNC = { + 'cyrus': SaslCyrusOpenSSLCompile, +} + +MORE_TAGS = ['cse'] + +TASKS = [ + *generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS), + *generate_test_tasks(SSL, TAG, TEST_MATRIX), +] + + +def tasks(): + res = TASKS.copy() + + # PowerPC and zSeries are limited resources. + for task in res: + if any(pattern in task.run_on for pattern in ["power", "zseries"]): + task.patchable = False + + return res + + +def variants(): + expansions = { + 'CLIENT_SIDE_ENCRYPTION': 'on', + } + + tasks = [] + + # PowerPC and zSeries are limited resources. + for task in TASKS: + if any(pattern in task.run_on for pattern in ["power", "zseries"]): + tasks.append( + TaskRef( + name=task.name, + batchtime=1440, # 1 day + ) + ) + else: + tasks.append(task.get_task_ref()) + + tasks.sort(key=lambda t: t.name) + + return [ + BuildVariant( + name=TAG, + display_name=TAG, + tasks=tasks, + expansions=expansions, + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/cse/winssl.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/cse/winssl.py new file mode 100644 index 000000000..ff3a08646 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/cse/winssl.py @@ -0,0 +1,74 @@ +from shrub.v3.evg_build_variant import BuildVariant +from shrub.v3.evg_task import EvgTaskRef + +from config_generator.etc.compile import generate_compile_tasks + +from config_generator.etc.cse.compile import CompileCommon +from config_generator.etc.cse.test import generate_test_tasks + + +SSL = 'winssl' +TAG = f'cse-matrix-{SSL}' + + +# pylint: disable=line-too-long +# fmt: off +COMPILE_MATRIX = [ + ('windows-vsCurrent', 'vs2017x64', None, ['cyrus']), +] + +# TODO (CDRIVER-3789): test cse with the 'sharded' topology. +TEST_MATRIX = [ + ('windows-vsCurrent', 'vs2017x64', None, 'cyrus', ['auth'], ['server'], ['4.2', '4.4', '5.0', '6.0' ]), + + # Test 7.0+ with a replica set since Queryable Encryption does not support the 'server' topology. Queryable Encryption tests require 7.0+. + ('windows-vsCurrent', 'vs2017x64', None, 'cyrus', ['auth'], ['server', 'replica' ], [ '7.0', '8.0', 'latest']), +] +# fmt: on +# pylint: enable=line-too-long + + +class WinSSLCompileCommon(CompileCommon): + ssl = 'WINDOWS' + + +class SaslCyrusWinSSLCompile(WinSSLCompileCommon): + name = 'cse-sasl-cyrus-winssl-compile' + commands = WinSSLCompileCommon.compile_commands(sasl='CYRUS') + + +def functions(): + return SaslCyrusWinSSLCompile.defn() + + +def tasks(): + res = [] + + SASL_TO_FUNC = { + 'cyrus': SaslCyrusWinSSLCompile, + } + + MORE_TAGS = ['cse'] + + res += generate_compile_tasks( + SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS + ) + + res += generate_test_tasks(SSL, TAG, TEST_MATRIX) + + return res + + +def variants(): + expansions = { + 'CLIENT_SIDE_ENCRYPTION': 'on', + } + + return [ + BuildVariant( + name=TAG, + display_name=TAG, + tasks=[EvgTaskRef(name=f'.{TAG}')], + expansions=expansions, + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/earthly.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/earthly.py new file mode 100644 index 000000000..178e7f637 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/earthly.py @@ -0,0 +1,323 @@ +from __future__ import annotations + +import functools +import re +from typing import Iterable, Literal, Mapping, NamedTuple, TypeVar + +from shrub.v3.evg_build_variant import BuildVariant +from shrub.v3.evg_command import ( + BuiltInCommand, + EvgCommandType, + KeyValueParam, + ec2_assume_role, + expansions_update, + subprocess_exec, +) +from shrub.v3.evg_task import EvgTask, EvgTaskRef + +from config_generator.etc.function import Function + +from ..etc.utils import all_possible + +T = TypeVar("T") + +_ENV_PARAM_NAME = "MONGOC_EARTHLY_ENV" +_CC_PARAM_NAME = "MONGOC_EARTHLY_C_COMPILER" +"The name of the EVG expansion for the Earthly c_compiler argument" + + +EnvKey = Literal[ + "u16", + "u18", + "u20", + "u22", + "alpine3.16", + "alpine3.17", + "alpine3.18", + "alpine3.19", + "archlinux", + "centos7", +] +"Identifiers for environments. These correspond to special 'env.*' targets in the Earthfile." +CompilerName = Literal["gcc", "clang"] +"The name of the compiler program that is used for the build. Passed via --c_compiler to Earthly." + +# Other options: SSPI (Windows only), AUTO (not reliably test-able without more environments) +SASLOption = Literal["Cyrus", "off"] +"Valid options for the SASL configuration parameter" +TLSOption = Literal["OpenSSL", "off"] +"Options for the TLS backend configuration parameter (AKA 'ENABLE_SSL')" +CxxVersion = Literal["master", "r4.1.0", "none"] +"C++ driver refs that are under CI test" + +# A separator character, since we cannot use whitespace +_SEPARATOR = "\N{NO-BREAK SPACE}\N{BULLET}\N{NO-BREAK SPACE}" + + +def os_split(env: EnvKey) -> tuple[str, None | str]: + """Convert the environment key into a pretty name+version pair""" + match env: + # match 'alpine3.18' 'alpine53.123' etc. + case alp if mat := re.match(r"alpine(\d+\.\d+)", alp): + return ("Alpine", mat[1]) + case "archlinux": + return "ArchLinux", None + # Match 'u22', 'u20', 'u71' etc. + case ubu if mat := re.match(r"u(\d\d)", ubu): + return "Ubuntu", f"{mat[1]}.04" + case "centos7": + return "CentOS", "7.0" + case _: + raise ValueError( + f"Failed to split OS env key {env=} into a name+version pair (unrecognized)" + ) + + +class EarthlyVariant(NamedTuple): + """ + Define a "variant" that runs under a set of Earthly parameters. These are + turned into real EVG variants later on. The Earthly arguments are passed via + expansion parameters. + """ + + env: EnvKey + c_compiler: CompilerName + + @property + def display_name(self) -> str: + """The pretty name for this variant""" + base: str + match os_split(self.env): + case name, None: + base = name + case name, version: + base = f"{name} {version}" + toolchain: str + match self.c_compiler: + case "clang": + toolchain = "LLVM/Clang" + case "gcc": + toolchain = "GCC" + return f"{base} ({toolchain})" + + @property + def task_selector_tag(self) -> str: + """ + The task tag that is used to select the tasks that want to run on this + variant. + """ + return f"{self.env}-{self.c_compiler}" + + @property + def expansions(self) -> Mapping[str, str]: + """ + Expansion values that are defined for the build variant that is generated + from this object. + """ + return { + _CC_PARAM_NAME: self.c_compiler, + _ENV_PARAM_NAME: self.env, + } + + def as_evg_variant(self) -> BuildVariant: + return BuildVariant( + name=f"{self.task_selector_tag}", + tasks=[EvgTaskRef(name=f".{self.task_selector_tag}")], + display_name=self.display_name, + expansions=dict(self.expansions), + ) + + +class Configuration(NamedTuple): + """ + Represent a complete set of argument values to give to the Earthly task + execution. Each field name matches the ARG in the Earthfile. + + Adding/removing fields will add/remove dimensions on the task matrix. + + Some Earthly parameters are not encoded here, but are rather part of the variant (EarthlyVariant). + """ + + sasl: SASLOption + tls: TLSOption + test_mongocxx_ref: CxxVersion + + @property + def suffix(self) -> str: + return _SEPARATOR.join(f"{k}={v}" for k, v in self._asdict().items()) + + +# Authenticate with DevProd-provided Amazon ECR instance to use as pull-through cache for DockerHub. +class DockerLoginAmazonECR(Function): + name = "docker-login-amazon-ecr" + commands = [ + # Avoid inadvertently using a pre-existing and potentially conflicting Docker config. + expansions_update( + updates=[KeyValueParam(key="DOCKER_CONFIG", value="${workdir}/.docker")] + ), + ec2_assume_role( + role_arn="arn:aws:iam::901841024863:role/ecr-role-evergreen-ro" + ), + subprocess_exec( + binary="bash", + command_type=EvgCommandType.SETUP, + include_expansions_in_env=[ + "AWS_ACCESS_KEY_ID", + "AWS_SECRET_ACCESS_KEY", + "AWS_SESSION_TOKEN", + "DOCKER_CONFIG", + ], + args=[ + "-c", + "aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 901841024863.dkr.ecr.us-east-1.amazonaws.com", + ], + ), + ] + + +def task_filter(env: EarthlyVariant, conf: Configuration) -> bool: + """ + Control which tasks are actually defined by matching on the platform and + configuration values. + """ + match env, conf: + # u16/u18/centos7 are not capable of building mongocxx + case e, (_sasl, _tls, cxx) if re.match( + r"^Ubuntu 16|^Ubuntu 18|^CentOS 7", e.display_name + ): + # Only build if C++ driver is test is disabled + return cxx == "none" + # Anything else: Allow it to run: + case _: + return True + + +def variants_for(config: Configuration) -> Iterable[EarthlyVariant]: + """Get all Earthly variants that are not excluded for the given build configuration""" + all_envs = all_possible(EarthlyVariant) + allow_env_for_config = functools.partial(task_filter, conf=config) + return filter(allow_env_for_config, all_envs) + + +def earthly_exec( + *, + kind: Literal["test", "setup", "system"], + target: str, + secrets: Mapping[str, str] | None = None, + args: Mapping[str, str] | None = None, +) -> BuiltInCommand: + """Create a subprocess_exec command that runs Earthly with the given arguments""" + env: dict[str, str] = {k: v for k, v in (secrets or {}).items()} + return subprocess_exec( + "./tools/earthly.sh", + args=[ + # Use Amazon ECR as pull-through cache for DockerHub to avoid rate limits. + "--buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3", + *(f"--secret={k}" for k in (secrets or ())), + f"+{target}", + # Use Amazon ECR as pull-through cache for DockerHub to avoid rate limits. + "--default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub", + *(f"--{arg}={val}" for arg, val in (args or {}).items()), + ], + command_type=EvgCommandType(kind), + include_expansions_in_env=["DOCKER_CONFIG"], + env=env if env else None, + working_dir="mongoc", + ) + + +def earthly_task( + *, + name: str, + targets: Iterable[str], + config: Configuration, +) -> EvgTask | None: + """ + Create an EVG task which executes earthly using the given parameters. If this + function returns `None`, then the task configuration is excluded from executing + and no task should be defined. + """ + # Attach tags to the task to allow build variants to select + # these tasks by the environment of that variant. + env_tags = sorted(e.task_selector_tag for e in sorted(variants_for(config))) + if not env_tags: + # All environments have been excluded for this configuration. This means + # the task itself should not be run: + return + # Generate the build-arg arguments based on the configuration options. The + # NamedTuple field names must match with the ARG keys in the Earthfile! + earthly_args = config._asdict() + earthly_args |= { + # Add arguments that come from parameter expansions defined in the build variant + "env": f"${{{_ENV_PARAM_NAME}}}", + "c_compiler": f"${{{_CC_PARAM_NAME}}}", + } + return EvgTask( + name=name, + commands=[ + DockerLoginAmazonECR.call(), + # First, just build the "env-warmup" which will prepare the build environment. + # This won't generate any output, but allows EVG to track it as a separate build step + # for timing and logging purposes. The subequent build step will cache-hit the + # warmed-up build environments. + earthly_exec( + kind="setup", + target="env-warmup", + args=earthly_args, + ), + # Now execute the main tasks: + earthly_exec( + kind="test", + target="run", + # The "targets" arg is for +run to specify which targets to run + args={"targets": " ".join(targets)} | earthly_args, + ), + ], # type: ignore (The type annots on `commands` is wrong) + tags=["earthly", "pr-merge-gate", *env_tags], + run_on=CONTAINER_RUN_DISTROS, + ) + + +CONTAINER_RUN_DISTROS = [ + "amazon2", + "debian11-large", + "debian12-large", + "ubuntu2204-large", + "ubuntu2404-large", +] + + +def functions(): + return DockerLoginAmazonECR.defn() + + +def tasks() -> Iterable[EvgTask]: + for conf in all_possible(Configuration): + # test-example is a target in all configurations + targets = ["test-example"] + + # test-cxx-driver is only a target in configurations with specified mongocxx versions + if conf.test_mongocxx_ref != "none": + targets.append("test-cxx-driver") + + task = earthly_task( + name=f"check:{conf.suffix}", + targets=targets, + config=conf, + ) + if task is not None: + yield task + + yield EvgTask( + name="verify-headers", + commands=[ + DockerLoginAmazonECR.call(), + earthly_exec(kind="test", target="verify-headers"), + ], + tags=["pr-merge-gate"], + run_on=CONTAINER_RUN_DISTROS, + ) + + +def variants() -> Iterable[BuildVariant]: + yield from (ev.as_evg_variant() for ev in all_possible(EarthlyVariant)) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/backtrace.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/backtrace.py similarity index 79% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/backtrace.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/backtrace.py index 43f77ffe1..01d309724 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/backtrace.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/backtrace.py @@ -11,10 +11,6 @@ class Backtrace(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return Backtrace.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/bootstrap_mongo_orchestration.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/bootstrap_mongo_orchestration.py similarity index 89% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/bootstrap_mongo_orchestration.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/bootstrap_mongo_orchestration.py index 54f6f3e16..d371571dd 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/bootstrap_mongo_orchestration.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/bootstrap_mongo_orchestration.py @@ -21,10 +21,6 @@ class BootstrapMongoOrchestration(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return BootstrapMongoOrchestration.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/fetch_build.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/fetch_build.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/fetch_build.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/fetch_build.py diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/fetch_det.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/fetch_det.py similarity index 87% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/fetch_det.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/fetch_det.py index 9859770ff..75c8c3bf5 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/fetch_det.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/fetch_det.py @@ -12,7 +12,7 @@ class FetchDET(Function): command_type=EvgCommandType.SETUP, script='''\ if [[ ! -d drivers-evergreen-tools ]]; then - git clone --depth=1 git@github.com:mongodb-labs/drivers-evergreen-tools.git + git clone --depth=1 https://github.com/mongodb-labs/drivers-evergreen-tools.git fi ''', ), @@ -40,10 +40,6 @@ class FetchDET(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return FetchDET.defn() diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/fetch_source.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/fetch_source.py new file mode 100644 index 000000000..81ff94983 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/fetch_source.py @@ -0,0 +1,44 @@ +from shrub.v3.evg_command import EvgCommandType +from shrub.v3.evg_command import expansions_update +from shrub.v3.evg_command import git_get_project + +from config_generator.etc.function import Function +from config_generator.etc.utils import bash_exec + + +class FetchSource(Function): + name = 'fetch-source' + command_type = EvgCommandType.SETUP + commands = [ + git_get_project(command_type=command_type, directory='mongoc'), + bash_exec( + command_type=command_type, + working_dir='mongoc', + script='''\ + set -o errexit + set -o pipefail + if [ -n "${github_pr_number}" -o "${is_patch}" = "true" ]; then + VERSION=patch-${version_id} + else + VERSION=latest + fi + echo "CURRENT_VERSION: $VERSION" > expansion.yml + ''' + ), + expansions_update(command_type=command_type, + file='mongoc/expansion.yml'), + # Scripts may not be executable on Windows. + bash_exec( + command_type=EvgCommandType.SETUP, + working_dir='mongoc', + script='''\ + for file in $(find .evergreen/scripts -type f); do + chmod +rx "$file" || exit + done + ''' + ), + ] + + +def functions(): + return FetchSource.defn() diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/find_cmake_latest.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/find_cmake_latest.py new file mode 100644 index 000000000..89387fbcf --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/find_cmake_latest.py @@ -0,0 +1,31 @@ +from shrub.v3.evg_command import EvgCommandType + +from config_generator.etc.function import Function +from config_generator.etc.utils import bash_exec + + +class FindCMakeLatest(Function): + ''' + Call `find_cmake_latest` in an attempt to download-and-build the latest + CMake version as a Setup task with `retry_on_failure: true` prior to + subsequent use of `find-cmake-latest.sh` by compile and build scripts. + ''' + + name = 'find-cmake-latest' + command_type = EvgCommandType.SETUP + commands = [ + bash_exec( + command_type=command_type, + retry_on_failure=True, + working_dir='mongoc', + script='. .evergreen/scripts/find-cmake-latest.sh && find_cmake_latest' + ), + ] + + @classmethod + def call(cls, **kwargs): + return cls.default_call(**kwargs) + + +def functions(): + return FindCMakeLatest.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/restore_instance_profile.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/restore_instance_profile.py similarity index 93% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/restore_instance_profile.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/restore_instance_profile.py index 48813f6bb..3d79e75c0 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/restore_instance_profile.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/restore_instance_profile.py @@ -34,10 +34,6 @@ class RestoreInstanceProfile(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return RestoreInstanceProfile.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/run_mock_kms_servers.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/run_mock_kms_servers.py similarity index 96% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/run_mock_kms_servers.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/run_mock_kms_servers.py index d9b26439d..72e9d9429 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/run_mock_kms_servers.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/run_mock_kms_servers.py @@ -47,6 +47,7 @@ class RunMockKMSServers(Function): python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 9000 & python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 9001 & python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --require_client_cert --port 9002 & + python -u kms_failpoint_server.py --port 9003 & python -u kms_kmip_server.py & deactivate echo "Starting mock KMS TLS servers... done." @@ -54,10 +55,6 @@ class RunMockKMSServers(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return RunMockKMSServers.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/run_simple_http_server.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/run_simple_http_server.py similarity index 89% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/run_simple_http_server.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/run_simple_http_server.py index 85604155a..7eafc13aa 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/run_simple_http_server.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/run_simple_http_server.py @@ -22,10 +22,6 @@ class RunSimpleHTTPServer(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return RunSimpleHTTPServer.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/run_tests.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/run_tests.py similarity index 84% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/run_tests.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/run_tests.py index 12fd2c4aa..299cd001c 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/run_tests.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/run_tests.py @@ -15,10 +15,6 @@ class RunTests(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return RunTests.defn() diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/set_cache_dir.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/set_cache_dir.py new file mode 100644 index 000000000..cd8d114c0 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/set_cache_dir.py @@ -0,0 +1,43 @@ +from config_generator.etc.function import Function +from config_generator.etc.utils import bash_exec + +from shrub.v3.evg_command import EvgCommandType, expansions_update + + +class SetCacheDir(Function): + name = 'set-cache-dir' + commands = [ + bash_exec( + command_type=EvgCommandType.SETUP, + script='''\ + if [[ -n "$XDG_CACHE_DIR" ]]; then + cache_dir="$XDG_CACHE_DIR" # XDG Base Directory specification. + elif [[ -n "$LOCALAPPDATA" ]]; then + cache_dir="$LOCALAPPDATA" # Windows. + elif [[ -n "$USERPROFILE" ]]; then + cache_dir="$USERPROFILE/.cache" # Windows (fallback). + elif [[ -d "$HOME/Library/Caches" ]]; then + cache_dir="$HOME/Library/Caches" # MacOS. + elif [[ -n "$HOME" ]]; then + cache_dir="$HOME/.cache" # Linux-like. + elif [[ -d ~/.cache ]]; then + cache_dir="~/.cache" # Linux-like (fallback). + else + cache_dir="$(pwd)/.cache" # EVG task directory (fallback). + fi + + mkdir -p "$cache_dir/mongo-c-driver" || exit + cache_dir="$(cd "$cache_dir/mongo-c-driver" && pwd)" || exit + + printf "MONGO_C_DRIVER_CACHE_DIR: %s\\n" "$cache_dir" >|expansions.set-cache-dir.yml + ''', + ), + expansions_update( + command_type=EvgCommandType.SETUP, + file='expansions.set-cache-dir.yml' + ), + ] + + +def functions(): + return SetCacheDir.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/stop_load_balancer.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/stop_load_balancer.py similarity index 88% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/stop_load_balancer.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/stop_load_balancer.py index 03c193354..5e867948f 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/stop_load_balancer.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/stop_load_balancer.py @@ -19,10 +19,6 @@ class StopLoadBalancer(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return StopLoadBalancer.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/stop_mongo_orchestration.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/stop_mongo_orchestration.py similarity index 83% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/stop_mongo_orchestration.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/stop_mongo_orchestration.py index d7c1e2e30..0e549e2a7 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/stop_mongo_orchestration.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/stop_mongo_orchestration.py @@ -14,10 +14,6 @@ class StopMongoOrchestration(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return StopMongoOrchestration.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/upload_build.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/upload_build.py similarity index 89% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/upload_build.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/upload_build.py index 52c73fe07..c0c3f58e2 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/upload_build.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/upload_build.py @@ -22,10 +22,6 @@ class UploadBuild(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return UploadBuild.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/upload_mo_artifacts.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/upload_mo_artifacts.py similarity index 97% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/upload_mo_artifacts.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/upload_mo_artifacts.py index 246ed65ca..e9a4def31 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/upload_mo_artifacts.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/upload_mo_artifacts.py @@ -87,10 +87,6 @@ class UploadMOArtifacts(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return UploadMOArtifacts.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/upload_test_results.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/upload_test_results.py similarity index 87% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/upload_test_results.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/upload_test_results.py index ae63f7a6b..dc756a2d9 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/funcs/upload_test_results.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/funcs/upload_test_results.py @@ -19,10 +19,6 @@ class UploadTestResults(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return UploadTestResults.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/kms_divergence_check.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/kms_divergence_check.py similarity index 89% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/kms_divergence_check.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/kms_divergence_check.py index 17c26d891..6cc7736d5 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/kms_divergence_check.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/kms_divergence_check.py @@ -16,10 +16,6 @@ class KmsDivergenceCheck(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return KmsDivergenceCheck.defn() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/loadbalanced.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/loadbalanced.py similarity index 85% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/loadbalanced.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/loadbalanced.py index 55508aefb..d15b83977 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/loadbalanced.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/loadbalanced.py @@ -1,18 +1,19 @@ from shrub.v3.evg_build_variant import BuildVariant from shrub.v3.evg_command import EvgCommandType, FunctionCall, expansions_update -from shrub.v3.evg_task import EvgTaskRef, EvgTaskDependency +from shrub.v3.evg_task import EvgTask, EvgTaskRef, EvgTaskDependency from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration from config_generator.components.funcs.fetch_build import FetchBuild from config_generator.components.funcs.fetch_det import FetchDET +from config_generator.components.funcs.find_cmake_latest import FindCMakeLatest from config_generator.components.funcs.run_simple_http_server import RunSimpleHTTPServer from config_generator.components.funcs.run_tests import RunTests from config_generator.components.funcs.upload_build import UploadBuild from config_generator.etc.distros import make_distro_str, find_small_distro, find_large_distro -from config_generator.etc.utils import Task, bash_exec +from config_generator.etc.utils import bash_exec -# Use `rhel8.7` distro. `rhel8.7` distro includes necessary dependency: `haproxy`. -_DISTRO_NAME = "rhel87" +# Use `rhel8-latest` distro. `rhel8-latest` distro includes necessary dependency: `haproxy`. +_DISTRO_NAME = "rhel8-latest" _COMPILER = "gcc" @@ -39,11 +40,11 @@ def make_test_task(auth: bool, ssl: bool, server_version: str): auth_str = "auth" if auth else "noauth" ssl_str = "openssl" if ssl else "nossl" distro_str = make_distro_str(_DISTRO_NAME, _COMPILER, None) - return Task( + return EvgTask( name=f"loadbalanced-{distro_str}-test-{server_version}-{auth_str}-{ssl_str}", depends_on=[EvgTaskDependency( name=f"loadbalanced-{distro_str}-compile")], - run_on=find_small_distro(_DISTRO_NAME).name, + run_on=find_large_distro(_DISTRO_NAME).name, # DEVPROD-18763 tags=['loadbalanced', _DISTRO_NAME, _COMPILER, auth_str, ssl_str], commands=[ FetchBuild.call(build_name=f"loadbalanced-{distro_str}-compile"), @@ -71,17 +72,17 @@ def make_test_task(auth: bool, ssl: bool, server_version: str): def tasks(): distro_str = make_distro_str(_DISTRO_NAME, _COMPILER, None) - yield Task( + yield EvgTask( name=f"loadbalanced-{distro_str}-compile", run_on=find_large_distro(_DISTRO_NAME).name, tags=['loadbalanced', _DISTRO_NAME, _COMPILER], commands=[ + FindCMakeLatest.call(), bash_exec( command_type=EvgCommandType.TEST, env={ 'CC': _COMPILER, 'CFLAGS': '-fno-omit-frame-pointer', - 'EXTRA_CONFIGURE_FLAGS': '-DENABLE_EXTRA_ALIGNMENT=OFF', 'SSL': 'OPENSSL' }, working_dir='mongoc', @@ -92,13 +93,13 @@ def tasks(): ) # Satisfy requirements specified in - # https://github.com/mongodb/specifications/blob/14916f76fd92b2686d8e3d1f0e4c2d2ef88ca5a7/source/load-balancers/tests/README.rst#testing-requirements + # https://github.com/mongodb/specifications/blob/master/source/load-balancers/tests/README.md#testing-requirements # # > For each server version that supports load balanced clusters, drivers # > MUST add two Evergreen tasks: one with a sharded cluster with both # > authentication and TLS enabled and one with a sharded cluster with # > authentication and TLS disabled. - server_versions = ['5.0', '6.0', '7.0', 'latest'] + server_versions = ['5.0', '6.0', '7.0', '8.0', 'latest'] for server_version in server_versions: yield make_test_task(auth=False, ssl=False, server_version=server_version) yield make_test_task(auth=True, ssl=True, server_version=server_version) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/make_docs.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/make_docs.py similarity index 89% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/make_docs.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/make_docs.py index 27a65e981..aa49b6532 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/make_docs.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/make_docs.py @@ -2,6 +2,8 @@ from shrub.v3.evg_command import s3_put from shrub.v3.evg_task import EvgTask +from config_generator.components.funcs.find_cmake_latest import FindCMakeLatest + from config_generator.etc.function import Function from config_generator.etc.function import merge_defns from config_generator.etc.utils import bash_exec @@ -15,18 +17,12 @@ class MakeDocs(Function): working_dir="mongoc", include_expansions_in_env=["distro_id"], script="""\ - set -o errexit - bash tools/poetry.sh install --with=docs # See SphinxBuild.cmake for EVG_DOCS_BUILD reasoning - bash tools/poetry.sh run env EVG_DOCS_BUILD=1 bash .evergreen/scripts/build-docs.sh - """, + uv run --frozen --only-group docs env EVG_DOCS_BUILD=1 .evergreen/scripts/build-docs.sh + """, ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - class UploadDocs(Function): name = "upload-docs" @@ -69,10 +65,6 @@ class UploadDocs(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - class UploadManPages(Function): name = "upload-man-pages" @@ -114,10 +106,6 @@ class UploadManPages(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return merge_defns( @@ -132,6 +120,7 @@ def tasks(): EvgTask( name="make-docs", commands=[ + FindCMakeLatest.call(), MakeDocs.call(), UploadDocs.call(), UploadManPages.call(), diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/mock_server.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/mock_server.py similarity index 89% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/mock_server.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/mock_server.py index ffa61d218..b103cda65 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/mock_server.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/mock_server.py @@ -1,21 +1,22 @@ from shrub.v3.evg_build_variant import BuildVariant from shrub.v3.evg_command import EvgCommandType -from shrub.v3.evg_task import EvgTaskRef +from shrub.v3.evg_task import EvgTask, EvgTaskRef from config_generator.components.funcs.fetch_det import FetchDET +from config_generator.components.funcs.find_cmake_latest import FindCMakeLatest from config_generator.components.funcs.run_simple_http_server import RunSimpleHTTPServer -from config_generator.etc.utils import Task from config_generator.etc.utils import bash_exec def tasks(): return [ - Task( + EvgTask( name="mock-server-test", run_on="ubuntu2204-small", commands=[ # Call fetch-det to define PYTHON3_BINARY expansion required for run-simple-http-server. FetchDET.call(), RunSimpleHTTPServer.call(), + FindCMakeLatest.call(), bash_exec( command_type=EvgCommandType.TEST, add_expansions_to_env=True, @@ -41,7 +42,6 @@ def variants(): 'CC': 'gcc', 'ASAN': 'on', 'CFLAGS': '-fno-omit-frame-pointer', - 'EXTRA_CONFIGURE_FLAGS': '-DENABLE_EXTRA_ALIGNMENT=OFF', 'SANITIZE': 'address,undefined', } ), diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/openssl_static_compile.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/openssl_static_compile.py similarity index 75% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/openssl_static_compile.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/openssl_static_compile.py index 8bd808540..454ad8114 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/openssl_static_compile.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/openssl_static_compile.py @@ -1,13 +1,14 @@ from shrub.v3.evg_build_variant import BuildVariant from shrub.v3.evg_command import EvgCommandType -from shrub.v3.evg_task import EvgTaskRef +from shrub.v3.evg_task import EvgTask, EvgTaskRef + +from config_generator.components.funcs.find_cmake_latest import FindCMakeLatest from config_generator.etc.distros import find_large_distro from config_generator.etc.distros import make_distro_str -from config_generator.etc.distros import to_cc +from config_generator.etc.distros import compiler_to_vars from config_generator.etc.function import Function from config_generator.etc.utils import bash_exec -from config_generator.etc.utils import Task SSL = 'openssl-static' TAG = f'{SSL}-matrix' @@ -16,10 +17,11 @@ # pylint: disable=line-too-long # fmt: off MATRIX = [ - ('debian92', 'gcc', None), - ('debian10', 'gcc', None), ('debian11', 'gcc', None), + ('debian12', 'gcc', None), ('ubuntu2004', 'gcc', None), + ('ubuntu2204', 'gcc', None), + ('ubuntu2404', 'gcc', None), ] # fmt: on # pylint: enable=line-too-long @@ -36,10 +38,6 @@ class StaticOpenSSLCompile(Function): ), ] - @classmethod - def call(cls, **kwargs): - return cls.default_call(**kwargs) - def functions(): return StaticOpenSSLCompile.defn() @@ -54,7 +52,7 @@ def tasks(): distro = find_large_distro(distro_name) compile_vars = None - compile_vars = {'CC': to_cc(compiler)} + compile_vars = compiler_to_vars(compiler) if arch: tags.append(arch) @@ -65,11 +63,14 @@ def tasks(): task_name = f'openssl-static-compile-{distro_str}' res.append( - Task( + EvgTask( name=task_name, run_on=distro.name, tags=tags, - commands=[StaticOpenSSLCompile.call(vars=compile_vars)], + commands=[ + FindCMakeLatest.call(), + StaticOpenSSLCompile.call(vars=compile_vars if compile_vars else None), + ], ) ) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/asan.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/asan.py similarity index 88% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/asan.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/asan.py index 69e18df47..b55d16123 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/asan.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/asan.py @@ -10,7 +10,6 @@ def variants(): 'ASAN': 'on', 'CFLAGS': '-fno-omit-frame-pointer', 'CHECK_LOG': 'ON', - 'EXTRA_CONFIGURE_FLAGS': '-DENABLE_EXTRA_ALIGNMENT=OFF', 'SANITIZE': 'address,undefined', } diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/asan_cse.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/asan_cse.py new file mode 100644 index 000000000..c597c48ad --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/asan_cse.py @@ -0,0 +1,48 @@ +from config_generator.etc.compile import generate_compile_tasks + +from config_generator.etc.sanitizers.test import generate_test_tasks + +from config_generator.components.cse.openssl import SaslCyrusOpenSSLCompile + +from config_generator.components.sanitizers.asan import TAG + + +# pylint: disable=line-too-long +# fmt: off +COMPILE_MATRIX = [ + ('rhel8-latest', 'clang', None, ['cyrus']), +] + +# CSFLE requires 4.2+. QE requires 7.0+ and are skipped on "server" tasks. +TEST_MATRIX = [ + # rhel8-latest provides 4.2 through latest. + ('rhel8-latest', 'clang', None, 'cyrus', ['auth'], ['server', 'replica'], ['4.2', '4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), +] +# fmt: on +# pylint: enable=line-too-long + + +MORE_TAGS = ['cse', 'asan'] + + +def tasks(): + res = [] + + SSL = 'openssl' + SASL_TO_FUNC = { + 'cyrus': SaslCyrusOpenSSLCompile, + } + + res += generate_compile_tasks( + SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS + ) + + res += generate_test_tasks(SSL, TAG, TEST_MATRIX, MORE_TAGS) + + res += generate_test_tasks( + SSL, TAG, TEST_MATRIX, MORE_TAGS, + MORE_TEST_TAGS=['with-mongocrypt'], + MORE_VARS={'SKIP_CRYPT_SHARED_LIB': 'on'} + ) + + return res diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/asan_sasl.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/asan_sasl.py new file mode 100644 index 000000000..0275869de --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/asan_sasl.py @@ -0,0 +1,39 @@ +from config_generator.etc.compile import generate_compile_tasks + +from config_generator.etc.sanitizers.test import generate_test_tasks + +from config_generator.components.sasl.openssl import SaslCyrusOpenSSLCompile + +from config_generator.components.sanitizers.asan import TAG + + +# pylint: disable=line-too-long +# fmt: off +COMPILE_MATRIX = [ + ('rhel8-latest', 'clang', None, ['cyrus']), +] + +TEST_MATRIX = [ + # rhel8-latest provides 4.2 through latest. + ('rhel8-latest', 'clang', None, 'cyrus', ['auth'], ['server', 'replica', 'sharded'], ['4.2', '4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), +] +# fmt: on +# pylint: enable=line-too-long + + +def tasks(): + res = [] + + SSL = 'openssl' + + SASL_TO_FUNC = { + 'cyrus': SaslCyrusOpenSSLCompile, + } + + res += generate_compile_tasks( + SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, ['asan'] + ) + + res += generate_test_tasks(SSL, TAG, TEST_MATRIX, ['asan']) + + return res diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/tsan.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/tsan.py similarity index 83% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/tsan.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/tsan.py index deb645fc2..d506f43b8 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/components/sanitizers/tsan.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/tsan.py @@ -9,7 +9,7 @@ def variants(): expansions = { 'CFLAGS': '-fno-omit-frame-pointer', 'CHECK_LOG': 'ON', - 'EXTRA_CONFIGURE_FLAGS': '-DENABLE_EXTRA_ALIGNMENT=OFF -DENABLE_SHM_COUNTERS=OFF', + 'EXTRA_CONFIGURE_FLAGS': '-DENABLE_SHM_COUNTERS=OFF', 'SANITIZE': 'thread', } diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/tsan_sasl.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/tsan_sasl.py new file mode 100644 index 000000000..305326d10 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sanitizers/tsan_sasl.py @@ -0,0 +1,39 @@ +from config_generator.etc.compile import generate_compile_tasks + +from config_generator.etc.sanitizers.test import generate_test_tasks + +from config_generator.components.sasl.openssl import SaslCyrusOpenSSLCompile + +from config_generator.components.sanitizers.tsan import TAG + + +# pylint: disable=line-too-long +# fmt: off +COMPILE_MATRIX = [ + ('rhel8-latest', 'clang', None, ['cyrus']), +] + +TEST_OPENSSL_MATRIX = [ + # rhel8-latest provides 4.2 through latest. + ('rhel8-latest', 'clang', None, 'cyrus', ['auth'], ['server', 'replica', 'sharded'], ['4.2', '4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), +] +# fmt: on +# pylint: enable=line-too-long + + +MORE_TAGS = ['tsan'] + + +def tasks(): + res = [] + + SSL = 'openssl' + SASL_TO_FUNC = {'cyrus': SaslCyrusOpenSSLCompile} + + res += generate_compile_tasks( + SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS + ) + + res += generate_test_tasks(SSL, TAG, TEST_OPENSSL_MATRIX, MORE_TAGS) + + return res diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/darwinssl.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/darwinssl.py new file mode 100644 index 000000000..6bb5240c8 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/darwinssl.py @@ -0,0 +1,72 @@ +from shrub.v3.evg_build_variant import BuildVariant +from shrub.v3.evg_task import EvgTaskRef + +from config_generator.etc.function import merge_defns +from config_generator.etc.compile import generate_compile_tasks + +from config_generator.etc.sasl.compile import CompileCommon +from config_generator.etc.sasl.test import generate_test_tasks + + +SSL = 'darwinssl' +TAG = f'sasl-matrix-{SSL}' + + +# pylint: disable=line-too-long +# fmt: off +COMPILE_MATRIX = [ + ('macos-14', 'clang', None, ['cyrus']), + + ('macos-11-arm64', 'clang', None, ['cyrus']), + ('macos-14-arm64', 'clang', None, ['cyrus']), +] + +TEST_MATRIX = [ + ('macos-14', 'clang', None, 'cyrus', ['auth'], ['server'], ['4.2', '4.4', '5.0']), + + ('macos-11-arm64', 'clang', None, 'cyrus', ['auth'], ['server'], ['6.0', '7.0', ]), + ('macos-14-arm64', 'clang', None, 'cyrus', ['auth'], ['server'], ['6.0', '7.0', '8.0', 'latest']), +] +# fmt: on +# pylint: enable=line-too-long + + +class DarwinSSLCompileCommon(CompileCommon): + ssl = 'DARWIN' + + +class SaslCyrusDarwinSSLCompile(DarwinSSLCompileCommon): + name = 'sasl-cyrus-darwinssl-compile' + commands = DarwinSSLCompileCommon.compile_commands(sasl='CYRUS') + + +def functions(): + return merge_defns( + SaslCyrusDarwinSSLCompile.defn(), + ) + + +def tasks(): + res = [] + + SASL_TO_FUNC = { + 'cyrus': SaslCyrusDarwinSSLCompile, + } + + res += generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX) + res += generate_test_tasks(SSL, TAG, TEST_MATRIX) + + return res + + +def variants(): + expansions = {} + + return [ + BuildVariant( + name=TAG, + display_name=TAG, + tasks=[EvgTaskRef(name=f'.{TAG}')], + expansions=expansions, + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/nossl.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/nossl.py new file mode 100644 index 000000000..2f8b7a980 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/nossl.py @@ -0,0 +1,72 @@ +from shrub.v3.evg_build_variant import BuildVariant +from shrub.v3.evg_task import EvgTaskRef + +from config_generator.etc.function import merge_defns +from config_generator.etc.compile import generate_compile_tasks + +from config_generator.etc.sasl.compile import CompileCommon +from config_generator.etc.sasl.test import generate_test_tasks + + +SSL = 'nossl' +TAG = f'sasl-matrix-{SSL}' + + +# pylint: disable=line-too-long +# fmt: off +COMPILE_MATRIX = [ + # For test matrix. + ('rhel8-latest', 'gcc', None, ['off']), + + # For compile only. + ('ubuntu2204', 'gcc', None, ['off']), + ('ubuntu2404', 'gcc', None, ['off']), + ('windows-vsCurrent', 'vs2017x64', None, ['off']), +] + +TEST_MATRIX = [ + ('rhel8-latest', 'gcc', None, 'off', ['noauth'], ['server', 'replica', 'sharded'], ['4.2', '4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), +] +# fmt: on +# pylint: enable=line-too-long + + +class NoSSLCompileCommon(CompileCommon): + ssl = 'OFF' + + +class SaslOffNoSSLCompile(NoSSLCompileCommon): + name = 'sasl-off-nossl-compile' + commands = NoSSLCompileCommon.compile_commands(sasl='OFF') + + +def functions(): + return merge_defns( + SaslOffNoSSLCompile.defn(), + ) + + +def tasks(): + res = [] + + SASL_TO_FUNC = { + 'off': SaslOffNoSSLCompile, + } + + res += generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX) + res += generate_test_tasks(SSL, TAG, TEST_MATRIX) + + return res + + +def variants(): + expansions = {} + + return [ + BuildVariant( + name=TAG, + display_name=TAG, + tasks=[EvgTaskRef(name=f'.{TAG}')], + expansions=expansions, + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/openssl.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/openssl.py new file mode 100644 index 000000000..40541ddd5 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/openssl.py @@ -0,0 +1,114 @@ +from shrub.v3.evg_build_variant import BuildVariant + +from config_generator.etc.utils import TaskRef +from config_generator.etc.function import merge_defns +from config_generator.etc.compile import generate_compile_tasks + +from config_generator.etc.sasl.compile import CompileCommon +from config_generator.etc.sasl.test import generate_test_tasks + + +SSL = 'openssl' +TAG = f'sasl-matrix-{SSL}' + + +# pylint: disable=line-too-long +# fmt: off +COMPILE_MATRIX = [ + # For test matrix. + ('amazon2023-arm64-latest-large-m8g', 'gcc', None, ['cyrus']), + ('rhel8-latest', 'gcc', None, ['cyrus']), + ('rhel8-power', 'gcc', None, ['cyrus']), + ('rhel8-zseries', 'gcc', None, ['cyrus']), + ('ubuntu2004-arm64', 'gcc', None, ['cyrus']), + ('windows-vsCurrent', 'vs2017x64', None, ['cyrus']), + + # For compile only. + ('debian11', 'gcc', None, ['cyrus']), + ('debian12', 'gcc', None, ['cyrus']), + ('rhel80', 'gcc', None, ['cyrus']), + ('ubuntu2004', 'clang', None, ['cyrus']), + ('ubuntu2204', 'gcc', None, ['cyrus']), + ('ubuntu2204', 'clang-12', None, ['cyrus']), + ('ubuntu2404', 'gcc', None, ['cyrus']), + ('ubuntu2404', 'clang-14', None, ['cyrus']), +] + +TEST_MATRIX = [ + ('rhel8-latest', 'gcc', None, 'cyrus', ['auth'], ['server'], ['4.2', '4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), + ('rhel8-power', 'gcc', None, 'cyrus', ['auth'], ['server'], ['4.2', '4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), + ('rhel8-zseries', 'gcc', None, 'cyrus', ['auth'], ['server'], [ '5.0', '6.0', '7.0', '8.0', 'latest']), + + ('ubuntu2004-arm64', 'gcc', None, 'cyrus', ['auth'], ['server'], ['4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), + ('windows-vsCurrent', 'vs2017x64', None, 'cyrus', ['auth'], ['server'], [ 'latest']), + + # Test with Graviton processor: + ('amazon2023-arm64-latest-large-m8g', 'gcc', None, 'cyrus', ['auth'], ['server', 'replica', 'sharded'], ['latest']), +] +# fmt: on +# pylint: enable=line-too-long + + +class OpenSSLCompileCommon(CompileCommon): + ssl = 'OPENSSL' + + +class SaslCyrusOpenSSLCompile(OpenSSLCompileCommon): + name = 'sasl-cyrus-openssl-compile' + commands = OpenSSLCompileCommon.compile_commands(sasl='CYRUS') + + +def functions(): + return merge_defns( + SaslCyrusOpenSSLCompile.defn(), + ) + + +SASL_TO_FUNC = { + 'cyrus': SaslCyrusOpenSSLCompile, +} + +TASKS = [ + *generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX), + *generate_test_tasks(SSL, TAG, TEST_MATRIX), +] + + +def tasks(): + res = TASKS.copy() + + # PowerPC and zSeries are limited resources. + for task in res: + if any(pattern in task.run_on for pattern in ["power", "zseries"]): + task.patchable = False + + return res + + +def variants(): + expansions = {} + + tasks = [] + + # PowerPC and zSeries are limited resources. + for task in TASKS: + if any(pattern in task.run_on for pattern in ["power", "zseries"]): + tasks.append( + TaskRef( + name=task.name, + batchtime=1440, # 1 day + ) + ) + else: + tasks.append(task.get_task_ref()) + + tasks.sort(key=lambda t: t.name) + + return [ + BuildVariant( + name=TAG, + display_name=TAG, + tasks=tasks, + expansions=expansions, + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/winssl.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/winssl.py new file mode 100644 index 000000000..742c0329a --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sasl/winssl.py @@ -0,0 +1,78 @@ +from shrub.v3.evg_build_variant import BuildVariant +from shrub.v3.evg_task import EvgTaskRef + +from config_generator.etc.function import merge_defns +from config_generator.etc.compile import generate_compile_tasks + +from config_generator.etc.sasl.compile import CompileCommon +from config_generator.etc.sasl.test import generate_test_tasks + + +SSL = 'winssl' +TAG = f'sasl-matrix-{SSL}' + + +# pylint: disable=line-too-long +# fmt: off +COMPILE_MATRIX = [ + ('windows-vsCurrent', 'mingw', None, [ 'sspi']), + ('windows-vsCurrent', 'vs2017x64', None, ['off', 'sspi']), + ('windows-vsCurrent', 'vs2017x86', None, ['off', 'sspi']), +] + +TEST_MATRIX = [ + ('windows-vsCurrent', 'vs2017x64', None, 'sspi', ['auth'], ['server'], ['4.2', '4.4', '5.0', '6.0', '7.0', '8.0', 'latest']), + + ('windows-vsCurrent', 'mingw', None, 'sspi', ['auth'], ['server'], ['8.0', 'latest']), + ('windows-vsCurrent', 'vs2017x86', None, 'sspi', ['auth'], ['server'], ['8.0', 'latest']), +] +# fmt: on +# pylint: enable=line-too-long + + +class WinSSLCompileCommon(CompileCommon): + ssl = 'WINDOWS' + + +class SaslOffWinSSLCompile(WinSSLCompileCommon): + name = 'sasl-off-winssl-compile' + commands = WinSSLCompileCommon.compile_commands(sasl='OFF') + + +class SaslSspiWinSSLCompile(WinSSLCompileCommon): + name = 'sasl-sspi-winssl-compile' + commands = WinSSLCompileCommon.compile_commands(sasl='SSPI') + + +def functions(): + return merge_defns( + SaslOffWinSSLCompile.defn(), + SaslSspiWinSSLCompile.defn(), + ) + + +def tasks(): + res = [] + + SASL_TO_FUNC = { + 'off': SaslOffWinSSLCompile, + 'sspi': SaslSspiWinSSLCompile, + } + + res += generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX) + res += generate_test_tasks(SSL, TAG, TEST_MATRIX) + + return res + + +def variants(): + expansions = {} + + return [ + BuildVariant( + name=TAG, + display_name=TAG, + tasks=[EvgTaskRef(name=f'.{TAG}')], + expansions=expansions, + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sbom.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sbom.py new file mode 100644 index 000000000..dd2af1b6e --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/sbom.py @@ -0,0 +1,123 @@ +from config_generator.etc.distros import find_small_distro +from config_generator.etc.function import Function, merge_defns +from config_generator.etc.utils import bash_exec + +from shrub.v3.evg_build_variant import BuildVariant +from shrub.v3.evg_command import ( + BuiltInCommand, + EvgCommandType, + KeyValueParam, + ec2_assume_role, + expansions_update, + s3_put, +) +from shrub.v3.evg_task import EvgTask, EvgTaskRef + +from pydantic import ConfigDict + + +TAG = 'sbom' + + +class CustomCommand(BuiltInCommand): + command: str + model_config = ConfigDict(arbitrary_types_allowed=True) + + +class SBOM(Function): + name = 'sbom' + commands = [ + # Authenticate with Kondukto. + *[ + ec2_assume_role( + command_type=EvgCommandType.SETUP, + role_arn='${kondukto_role_arn}', + ), + bash_exec( + command_type=EvgCommandType.SETUP, + include_expansions_in_env=[ + 'AWS_ACCESS_KEY_ID', + 'AWS_SECRET_ACCESS_KEY', + 'AWS_SESSION_TOKEN', + ], + script='''\ + set -o errexit + set -o pipefail + kondukto_token="$(aws secretsmanager get-secret-value --secret-id "kondukto-token" --region "us-east-1" --query 'SecretString' --output text)" + printf "KONDUKTO_TOKEN: %s\\n" "$kondukto_token" >|expansions.kondukto.yml + ''', + ), + expansions_update( + command_type=EvgCommandType.SETUP, + file='expansions.kondukto.yml', + ), + ], + # Authenticate with Amazon ECR. + *[ + # Avoid inadvertently using a pre-existing and potentially conflicting Podman config. + # Note: podman understands and uses DOCKER_CONFIG despite the name. + expansions_update(updates=[KeyValueParam(key='DOCKER_CONFIG', value='${workdir}/.docker')]), + ec2_assume_role(role_arn="arn:aws:iam::901841024863:role/ecr-role-evergreen-ro"), + bash_exec( + command_type=EvgCommandType.SETUP, + include_expansions_in_env=[ + "AWS_ACCESS_KEY_ID", + "AWS_SECRET_ACCESS_KEY", + "AWS_SESSION_TOKEN", + "DOCKER_CONFIG", + ], + script='aws ecr get-login-password --region us-east-1 | podman login --username AWS --password-stdin 901841024863.dkr.ecr.us-east-1.amazonaws.com', + ), + ], + bash_exec( + command_type=EvgCommandType.TEST, + working_dir='mongoc', + include_expansions_in_env=[ + 'branch_name', + 'DOCKER_CONFIG', + "KONDUKTO_TOKEN", + ], + script='.evergreen/scripts/sbom.sh', + ), + s3_put( + command_type=EvgCommandType.TEST, + aws_key='${aws_key}', + aws_secret='${aws_secret}', + bucket='mciuploads', + content_type='application/json', + display_name='Augmented SBOM', + local_file='mongoc/augmented-sbom.json', + permissions='public-read', + remote_file='${project}/${build_variant}/${revision}/${version_id}/${build_id}/sbom/augmented-sbom.json', + ), + ] + + +def functions(): + return merge_defns( + SBOM.defn(), + ) + + +def tasks(): + distro_name = 'rhel80' + distro = find_small_distro(distro_name) + + yield EvgTask( + name='sbom', + tags=[TAG, distro_name], + run_on=distro.name, + commands=[ + SBOM.call(), + ], + ) + + +def variants(): + return [ + BuildVariant( + name=TAG, + display_name='SBOM', + tasks=[EvgTaskRef(name=f'.{TAG}')], + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/scan_build.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/scan_build.py new file mode 100644 index 000000000..cace4f67b --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/components/scan_build.py @@ -0,0 +1,88 @@ +from shrub.v3.evg_build_variant import BuildVariant +from shrub.v3.evg_command import EvgCommandType +from shrub.v3.evg_command import FunctionCall +from shrub.v3.evg_task import EvgTask, EvgTaskRef + +from config_generator.components.funcs.find_cmake_latest import FindCMakeLatest + +from config_generator.etc.distros import find_large_distro +from config_generator.etc.distros import make_distro_str +from config_generator.etc.distros import compiler_to_vars +from config_generator.etc.function import Function +from config_generator.etc.utils import bash_exec + + +TAG = 'scan-build-matrix' + + +# pylint: disable=line-too-long +# fmt: off +MATRIX = [ + ('macos-14-arm64', 'clang', None ), + ('ubuntu2004-arm64', 'clang', None ), + ('ubuntu2004', 'clang', 'i686'), +] +# fmt: on +# pylint: enable=line-too-long + + +class ScanBuild(Function): + name = 'scan-build' + commands = [ + bash_exec( + command_type=EvgCommandType.TEST, + add_expansions_to_env=True, + redirect_standard_error_to_output=True, + working_dir='mongoc', + script='.evergreen/scripts/compile-scan-build.sh', + ), + ] + + +def functions(): + return ScanBuild.defn() + + +def tasks(): + res = [] + + for distro_name, compiler, arch in MATRIX: + tags = [TAG, distro_name, compiler] + + distro = find_large_distro(distro_name) + + compile_vars = None + compile_vars = compiler_to_vars(compiler) + + if arch: + tags.append(arch) + compile_vars.update({'MARCH': arch}) + + distro_str = make_distro_str(distro_name, compiler, arch) + + task_name = f'scan-build-{distro_str}' + + res.append( + EvgTask( + name=task_name, + run_on=distro.name, + tags=tags, + commands=[ + FindCMakeLatest.call(), + ScanBuild.call(vars=compile_vars if compile_vars else None), + FunctionCall(func='upload scan artifacts'), + ], + ) + ) + + return res + + +def variants(): + return [ + BuildVariant( + name=TAG, + display_name=TAG, + tasks=[EvgTaskRef(name=f'.{TAG}')], + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/compile.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/compile.py new file mode 100644 index 000000000..6e72b5757 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/compile.py @@ -0,0 +1,53 @@ +from shrub.v3.evg_task import EvgTask + +from config_generator.etc.distros import find_large_distro +from config_generator.etc.distros import make_distro_str +from config_generator.etc.distros import compiler_to_vars + +from config_generator.components.funcs.find_cmake_latest import FindCMakeLatest +from config_generator.components.funcs.upload_build import UploadBuild + + +def generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, MATRIX, MORE_TAGS=None, MORE_VARS=None): + res = [] + + MORE_TAGS = MORE_TAGS if MORE_TAGS else [] + MORE_VARS = MORE_VARS if MORE_VARS else {} + + for distro_name, compiler, arch, sasls, in MATRIX: + tags = [TAG, 'compile', distro_name, compiler] + MORE_TAGS + + distro = find_large_distro(distro_name) + + compile_vars = None + compile_vars = compiler_to_vars(compiler) + + if arch: + tags.append(arch) + compile_vars.update({'MARCH': arch}) + + compile_vars.update(MORE_VARS) + + distro_str = make_distro_str(distro_name, compiler, arch) + + for sasl in sasls: + task_name = f'sasl-{sasl}-{SSL}-{distro_str}-compile' + + for tag in MORE_TAGS: + task_name = f'{tag}-{task_name}' + + commands = [] + commands.append(FindCMakeLatest.call()) + commands.append(SASL_TO_FUNC[sasl].call(vars=compile_vars if compile_vars else None)) + commands.append(UploadBuild.call()) + + res.append( + EvgTask( + name=task_name, + run_on=distro.name, + tags=tags + [f'sasl-{sasl}'], + commands=commands, + ) + ) + + return res diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/cse/compile.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/cse/compile.py new file mode 100644 index 000000000..47ced2755 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/cse/compile.py @@ -0,0 +1,37 @@ +from typing import ClassVar + +from shrub.v3.evg_command import EvgCommand +from shrub.v3.evg_command import EvgCommandType +from shrub.v3.evg_command import expansions_update +from shrub.v3.evg_command import KeyValueParam + +from config_generator.etc.utils import bash_exec + +from config_generator.etc.function import Function + + +class CompileCommon(Function): + ssl: ClassVar[str | None] + + @classmethod + def compile_commands(cls, sasl=None) -> list[EvgCommand]: + updates = [] + + if cls.ssl: + updates.append(KeyValueParam(key='SSL', value=cls.ssl)) + + if sasl: + updates.append(KeyValueParam(key='SASL', value=sasl)) + + return [ + expansions_update(updates=updates), + bash_exec( + command_type=EvgCommandType.TEST, + script='EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON ${EXTRA_CONFIGURE_FLAGS}" .evergreen/scripts/compile.sh', + working_dir='mongoc', + add_expansions_to_env=True, + env={ + 'COMPILE_LIBMONGOCRYPT': 'ON', + }, + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/cse/test.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/cse/test.py new file mode 100644 index 000000000..ae2fe60de --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/cse/test.py @@ -0,0 +1,78 @@ +from itertools import product + +from shrub.v3.evg_command import expansions_update +from shrub.v3.evg_command import KeyValueParam +from shrub.v3.evg_task import EvgTask, EvgTaskDependency + +from config_generator.etc.distros import find_large_distro, find_small_distro +from config_generator.etc.distros import make_distro_str +from config_generator.etc.distros import compiler_to_vars + +from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration +from config_generator.components.funcs.fetch_build import FetchBuild +from config_generator.components.funcs.fetch_det import FetchDET +from config_generator.components.funcs.run_mock_kms_servers import RunMockKMSServers +from config_generator.components.funcs.run_tests import RunTests + + +def generate_test_tasks(SSL, TAG, MATRIX): + res = [] + + TOPOLOGY_TO_STR = { + 'server': 'server', + 'replica': 'replica_set', + 'sharded': 'sharded_cluster', + } + + for distro_name, compiler, arch, sasl, auths, topologies, server_vers in MATRIX: + tags = [TAG, 'test', distro_name, compiler, f'sasl-{sasl}', 'cse'] + if distro_name == 'rhel8-latest': + test_distro = find_large_distro(distro_name) # DEVPROD-18763 + else: + test_distro = find_small_distro(distro_name) + + compile_vars = [] + compile_vars = [KeyValueParam(key=key, value=value) for key, value in compiler_to_vars(compiler).items()] + + if arch: + tags.append(arch) + compile_vars.append(KeyValueParam(key='MARCH', value=arch)) + + distro_str = make_distro_str(distro_name, compiler, arch) + compile_task_name = f'cse-sasl-{sasl}-{SSL}-{distro_str}-compile' + + for auth, topology, server_ver in product(auths, topologies, server_vers): + test_tags = tags + [auth, topology, server_ver] + # Do not add `nossl` tag to prevent being selected by legacy config variants. + # Remove the `if` when CDRIVER-4571 is resolved. + if SSL != 'nossl': + test_tags += [SSL] + test_task_name = f'cse-sasl-{sasl}-{SSL}-{distro_str}-test-{server_ver}-{topology}-{auth}' + + test_commands = [] + test_commands.append(FetchBuild.call(build_name=compile_task_name)) + + updates = compile_vars + [ + KeyValueParam(key='AUTH', value=auth), + KeyValueParam(key='MONGODB_VERSION', value=server_ver), + KeyValueParam(key='TOPOLOGY', value=TOPOLOGY_TO_STR[topology]), + KeyValueParam(key='SSL', value=SSL), + ] + + test_commands.append(expansions_update(updates=updates)) + test_commands.append(FetchDET.call()) + test_commands.append(BootstrapMongoOrchestration.call()) + test_commands.append(RunMockKMSServers.call()) + test_commands.append(RunTests.call()) + + res.append( + EvgTask( + name=test_task_name, + run_on=test_distro.name, + tags=test_tags, + depends_on=[EvgTaskDependency(name=compile_task_name)], + commands=test_commands, + ) + ) + + return res diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/distros.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/distros.py new file mode 100644 index 000000000..d4305bd7a --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/distros.py @@ -0,0 +1,234 @@ +from typing import Literal + +from pydantic import BaseModel, validator +from packaging.version import Version + + +class Distro(BaseModel): + """ + Defines common properties of a given Evergreen distro. + + * name: Name of the distro. + * os: Name of the operating system. + * os_type: One of Linux, MacOS, or Windows. + * os_ver: Version of the operating system. + * vs_ver: Version of Visual Studio available. + * size: Size of tasks the distro is designed to handle. + * arch: Target architecture. + """ + + name: str + os: str | None = None + os_type: Literal['linux', 'macos', 'windows'] | None = None + os_ver: str | None = None + vs_ver: Literal[ + '2013', + '2015', + '2017', + '2019', + '2022', + 'vsCurrent', + ] | None = None + size: Literal['small', 'large'] | None = None + arch: Literal['arm64', 'power', 'zseries'] | None = None + + @validator('os_ver') + @classmethod + def validate_os_ver(cls, value): + return value == 'latest' or Version(value) + + +def ls_distro(name, **kwargs): + return [ + Distro(name=f'{name}-large', size='large', **kwargs), + Distro(name=f'{name}-small', size='small', **kwargs), + ] + + +DEBIAN_DISTROS = [ + *ls_distro(name='debian11', os='debian', os_type='linux', os_ver='11'), + *ls_distro(name='debian12', os='debian', os_type='linux', os_ver='12'), +] + +MACOS_DISTROS = [ + Distro(name='macos-14', os='macos', os_type='macos', os_ver='14'), +] + +MACOS_ARM64_DISTROS = [ + Distro(name='macos-11-arm64', os='macos', os_type='macos', os_ver='11', arch='arm64'), + Distro(name='macos-14-arm64', os='macos', os_type='macos', os_ver='14', arch='arm64'), +] + +RHEL_DISTROS = [ + *ls_distro(name='rhel7-latest', os='rhel', os_type='linux', os_ver='7'), + *ls_distro(name='rhel8-latest', os='rhel', os_type='linux', os_ver='8'), + + *ls_distro(name='rhel80', os='rhel', os_type='linux', os_ver='8.0'), + *ls_distro(name='rhel84', os='rhel', os_type='linux', os_ver='8.4'), + *ls_distro(name='rhel90', os='rhel', os_type='linux', os_ver='9.0'), + *ls_distro(name='rhel91', os='rhel', os_type='linux', os_ver='9.1'), + *ls_distro(name='rhel92', os='rhel', os_type='linux', os_ver='9.2'), + *ls_distro(name='rhel93', os='rhel', os_type='linux', os_ver='9.3'), + *ls_distro(name='rhel94', os='rhel', os_type='linux', os_ver='9.4'), + *ls_distro(name='rhel95', os='rhel', os_type='linux', os_ver='9.5'), # rhel9-latest +] + +RHEL_POWER_DISTROS = [ + *ls_distro(name='rhel8-power', os='rhel', os_type='linux', os_ver='8', arch='power'), +] + +RHEL_ZSERIES_DISTROS = [ + *ls_distro(name='rhel8-zseries', os='rhel', os_type='linux', os_ver='8', arch='zseries'), +] + +UBUNTU_DISTROS = [ + *ls_distro(name='ubuntu2004', os='ubuntu', os_type='linux', os_ver='20.04'), + *ls_distro(name='ubuntu2204', os='ubuntu', os_type='linux', os_ver='22.04'), + *ls_distro(name='ubuntu2404', os='ubuntu', os_type='linux', os_ver='24.04'), +] + +UBUNTU_ARM64_DISTROS = [ + *ls_distro(name='ubuntu2004-arm64', os='ubuntu', os_type='linux', os_ver='20.04', arch='arm64'), +] + +WINDOWS_DISTROS = [ + *ls_distro(name='windows-vsCurrent', os='windows', os_type='windows', vs_ver='vsCurrent'), # Windows Server 2019 +] + +GRAVITON_DISTROS = [ + Distro(name='amazon2023-arm64-latest-large-m8g', os='amazon2023', os_type='linux', os_ver='2023', arch='arm64'), + Distro(name='amazon2-arm64-latest-large-m8g', os='amazon2', os_type='linux', os_ver='2', arch='arm64'), +] + +# See: https://evergreen.mongodb.com/distros +# Ensure no-arch distros are ordered before arch-specific distros. +ALL_DISTROS = [ + *DEBIAN_DISTROS, + *GRAVITON_DISTROS, + *MACOS_DISTROS, + *MACOS_ARM64_DISTROS, + *RHEL_DISTROS, + *RHEL_POWER_DISTROS, + *RHEL_ZSERIES_DISTROS, + *UBUNTU_DISTROS, + *UBUNTU_ARM64_DISTROS, + *WINDOWS_DISTROS, +] + + +def find_distro(name) -> Distro: + candidates = [d for d in ALL_DISTROS if name == d.name] + + if not candidates: + raise ValueError(f'could not find a distro with the name {name}') + + return candidates[0] + + +def find_large_distro(name) -> Distro: + candidates = [d for d in ALL_DISTROS if f'{name}-large' == d.name] + + if candidates: + return candidates[0] + + return find_distro(name) + + +def find_small_distro(name) -> Distro: + candidates = [d for d in ALL_DISTROS if f'{name}-small' == d.name] + + if candidates: + return candidates[0] + + return find_distro(name) + + +def make_distro_str(distro_name, compiler, arch) -> str: + if distro_name.startswith('windows-vsCurrent'): + # Rename `windows-vsCurrent-*` distros to `windows-` where`` + # is the Windows Server version used by the distro, e.g.: + # ('windows-vsCurrent-2022', 'vs2017x64', None) -> windows-2022-vs2017-x64 + # ('windows-vsCurrent-2022', 'mingw', None) -> windows-2022-mingw + # ('windows-vsCurrent', 'vs2017x64', None) -> windows-2019-vs2017-x64 + # ('windows-vsCurrent', 'mingw', None) -> windows-2019-mingw + maybe_arch = compiler[len('vs20XY'):] + if maybe_arch in ('x86', 'x64'): + compiler_str = compiler[:-len(maybe_arch)] + '-' + maybe_arch + else: + compiler_str = compiler + if distro_name.startswith('windows-vsCurrent-'): + distro_str = 'windows-' + \ + distro_name[len('windows-vsCurrent-'):] + f'-{compiler_str}' + else: + distro_str = 'windows-2019-' + compiler_str + else: + distro_str = distro_name + if compiler: + distro_str += f'-{compiler}' + + if arch: + distro_str += f'-{arch}' + + return distro_str + + +def to_cc(compiler): + return { + 'vs2015x64': 'Visual Studio 14 2015', + 'vs2015x86': 'Visual Studio 14 2015', + 'vs2017x64': 'Visual Studio 15 2017', + 'vs2017x86': 'Visual Studio 15 2017', + 'vs2019x64': 'Visual Studio 16 2019', + 'vs2019x86': 'Visual Studio 16 2019', + 'vs2022x64': 'Visual Studio 17 2022', + 'vs2022x86': 'Visual Studio 17 2022', + }.get(compiler, compiler) + + +def to_platform(compiler): + return { + 'vs2015x64': 'x64', + 'vs2015x86': 'Win32', + 'vs2017x64': 'x64', + 'vs2017x86': 'Win32', + 'vs2019x64': 'x64', + 'vs2019x86': 'Win32', + 'vs2022x64': 'x64', + 'vs2022x86': 'Win32', + }.get(compiler, compiler) + + +def compiler_to_vars(compiler): + if compiler is None: + return {} + + match compiler, compiler.split('-'): + case _, ['gcc', *rest]: + return { + 'CC': '-'.join(['gcc'] + rest), + 'CXX': '-'.join(['g++'] + rest), + } + + case _, ['clang', *rest]: + return { + 'CC': '-'.join(['clang'] + rest), + 'CXX': '-'.join(['clang++'] + rest), + } + + case str(vs), _ if 'vs' in vs: + return { + 'CMAKE_GENERATOR': to_cc(vs), + 'CMAKE_GENERATOR_PLATFORM': to_platform(vs), + } + + case _, ['mingw', *rest]: + return { + 'CC': '-'.join(['gcc'] + rest), + 'CXX': '-'.join(['g++'] + rest), + } + + case compiler, _: + return { + 'CC': compiler, + 'CXX': compiler, + } diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/function.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/function.py similarity index 83% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/function.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/function.py index 837590a25..61398dced 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/etc/function.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/function.py @@ -18,6 +18,10 @@ def defn(cls) -> Mapping[str, list[EvgCommand]]: def default_call(cls, **kwargs) -> FunctionCall: return FunctionCall(func=cls.name, **kwargs) + @classmethod + def call(cls, **kwargs) -> FunctionCall: + return cls.default_call(**kwargs) + def merge_defns(*args): return ChainMap(*args) diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/sanitizers/test.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/sanitizers/test.py new file mode 100644 index 000000000..e8cf927ec --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/sanitizers/test.py @@ -0,0 +1,107 @@ +from itertools import product + +from shrub.v3.evg_command import expansions_update +from shrub.v3.evg_command import KeyValueParam +from shrub.v3.evg_task import EvgTask, EvgTaskDependency + +from config_generator.etc.distros import find_large_distro, find_small_distro +from config_generator.etc.distros import make_distro_str +from config_generator.etc.distros import compiler_to_vars + +from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration +from config_generator.components.funcs.fetch_build import FetchBuild +from config_generator.components.funcs.fetch_det import FetchDET +from config_generator.components.funcs.run_simple_http_server import RunSimpleHTTPServer +from config_generator.components.funcs.run_mock_kms_servers import RunMockKMSServers +from config_generator.components.funcs.run_tests import RunTests + + +def generate_test_tasks(SSL, TAG, MATRIX, MORE_COMPILE_TAGS=None, MORE_TEST_TAGS=None, MORE_VARS=None): + res = [] + + TOPOLOGY_TO_STR = { + 'server': 'server', + 'replica': 'replica_set', + 'sharded': 'sharded_cluster', + } + + MORE_COMPILE_TAGS = MORE_COMPILE_TAGS if MORE_COMPILE_TAGS else [] + MORE_TEST_TAGS = MORE_TEST_TAGS if MORE_TEST_TAGS else [] + MORE_VARS = MORE_VARS if MORE_VARS else {} + + for distro_name, compiler, arch, sasl, auths, topologies, server_vers in MATRIX: + tags = [ + TAG, 'test', distro_name, compiler, f'sasl-{sasl}' + ] + MORE_COMPILE_TAGS + + if distro_name == 'rhel8-latest': + test_distro = find_large_distro(distro_name) # DEVPROD-18763 + else: + test_distro = find_small_distro(distro_name) + + compile_vars = [] + compile_vars = [KeyValueParam(key=key, value=value) for key, value in compiler_to_vars(compiler).items()] + + if arch: + tags.append(arch) + compile_vars.append(KeyValueParam(key='MARCH', value=arch)) + + distro_str = make_distro_str(distro_name, compiler, arch) + + base_task_name = f'sasl-{sasl}-{SSL}-{distro_str}' + + for tag in MORE_COMPILE_TAGS: + base_task_name = f'{tag}-{base_task_name}' + + compile_task_name = f'{base_task_name}-compile' + + for auth, topology, server_ver in product(auths, topologies, server_vers): + test_tags = tags + [auth, topology, server_ver] + MORE_TEST_TAGS + # Do not add `nossl` tag to prevent being selected by legacy config variants. + # Remove the `if` when CDRIVER-4571 is resolved. + if SSL != 'nossl': + test_tags += [SSL] + test_task_name = f'{base_task_name}-test-{server_ver}-{topology}-{auth}' + + for tag in MORE_TEST_TAGS: + test_task_name += f'-{tag}' + + test_commands = [] + test_commands.append(FetchBuild.call(build_name=compile_task_name)) + + updates = compile_vars + [ + KeyValueParam(key='AUTH', value=auth), + KeyValueParam(key='MONGODB_VERSION', value=server_ver), + KeyValueParam(key='TOPOLOGY', value=TOPOLOGY_TO_STR[topology]), + KeyValueParam(key='SSL', value=SSL), + ] + + if 'cse' in MORE_COMPILE_TAGS: + updates.append( + KeyValueParam(key='CLIENT_SIDE_ENCRYPTION', value='on') + ) + + for key, value in MORE_VARS.items(): + updates.append(KeyValueParam(key=key, value=value)) + + test_commands.append(expansions_update(updates=updates)) + test_commands.append(FetchDET.call()) + test_commands.append(BootstrapMongoOrchestration.call()) + test_commands.append(RunSimpleHTTPServer.call()) + + if 'cse' in MORE_COMPILE_TAGS: + test_commands.append(RunMockKMSServers.call()) + + test_commands.append(RunTests.call()) + + res.append( + EvgTask( + name=test_task_name, + run_on=test_distro.name, + tags=test_tags, + depends_on=[EvgTaskDependency(name=compile_task_name)], + commands=test_commands, + ) + ) + + return res diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/sasl/compile.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/sasl/compile.py new file mode 100644 index 000000000..f32467280 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/sasl/compile.py @@ -0,0 +1,32 @@ +from typing import ClassVar + +from shrub.v3.evg_command import EvgCommand +from shrub.v3.evg_command import EvgCommandType + +from config_generator.etc.utils import bash_exec + +from config_generator.etc.function import Function + + +class CompileCommon(Function): + ssl: ClassVar[str | None] + + @classmethod + def compile_commands(cls, sasl=None) -> list[EvgCommand]: + env = {} + + if cls.ssl: + env['SSL'] = cls.ssl + + if sasl: + env['SASL'] = sasl + + return [ + bash_exec( + command_type=EvgCommandType.TEST, + add_expansions_to_env=True, + env=env, + working_dir='mongoc', + script='.evergreen/scripts/compile.sh', + ), + ] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/sasl/test.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/sasl/test.py new file mode 100644 index 000000000..661656f98 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/sasl/test.py @@ -0,0 +1,79 @@ +from itertools import product + +from shrub.v3.evg_command import expansions_update +from shrub.v3.evg_command import KeyValueParam +from shrub.v3.evg_task import EvgTask, EvgTaskDependency + +from config_generator.etc.distros import find_large_distro, find_small_distro +from config_generator.etc.distros import make_distro_str +from config_generator.etc.distros import compiler_to_vars + +from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration +from config_generator.components.funcs.fetch_build import FetchBuild +from config_generator.components.funcs.fetch_det import FetchDET +from config_generator.components.funcs.run_simple_http_server import RunSimpleHTTPServer +from config_generator.components.funcs.run_tests import RunTests + + +def generate_test_tasks(SSL, TAG, MATRIX): + res = [] + + TOPOLOGY_TO_STR = { + 'server': 'server', + 'replica': 'replica_set', + 'sharded': 'sharded_cluster', + } + + for distro_name, compiler, arch, sasl, auths, topologies, server_vers in MATRIX: + tags = [TAG, 'test', distro_name, compiler] + if distro_name == 'rhel8-latest': + test_distro = find_large_distro(distro_name) # DEVPROD-18763 + else: + test_distro = find_small_distro(distro_name) + + compile_vars = [] + compile_vars = [KeyValueParam(key=key, value=value) for key, value in compiler_to_vars(compiler).items()] + + if arch: + tags.append(arch) + compile_vars.append(KeyValueParam(key='MARCH', value=arch)) + + distro_str = make_distro_str(distro_name, compiler, arch) + compile_task_name = f'sasl-{sasl}-{SSL}-{distro_str}-compile' + + for auth, topology, server_ver in product(auths, topologies, server_vers): + test_tags = tags + [f'sasl-{sasl}', auth, topology, server_ver] + # Do not add `nossl` tag to prevent being selected by legacy config variants. + # Remove the `if` when CDRIVER-4571 is resolved. + if SSL != 'nossl': + test_tags += [SSL] + + test_task_name = f'sasl-{sasl}-{SSL}-{distro_str}-test-{server_ver}-{topology}-{auth}' + + test_commands = [] + test_commands.append(FetchBuild.call(build_name=compile_task_name)) + + updates = compile_vars + [ + KeyValueParam(key='AUTH', value=auth), + KeyValueParam(key='MONGODB_VERSION', value=server_ver), + KeyValueParam(key='TOPOLOGY', value=TOPOLOGY_TO_STR[topology]), + KeyValueParam(key='SSL', value=SSL), + ] + + test_commands.append(expansions_update(updates=updates)) + test_commands.append(FetchDET.call()) + test_commands.append(BootstrapMongoOrchestration.call()) + test_commands.append(RunSimpleHTTPServer.call()) + test_commands.append(RunTests.call()) + + res.append( + EvgTask( + name=test_task_name, + run_on=test_distro.name, + tags=test_tags, + depends_on=[EvgTaskDependency(name=compile_task_name)], + commands=test_commands, + ) + ) + + return res diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/utils.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/utils.py new file mode 100644 index 000000000..0dd183278 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/etc/utils.py @@ -0,0 +1,182 @@ +import itertools +from importlib import import_module +from inspect import isclass +from pathlib import Path +from textwrap import dedent +from typing import (Any, Iterable, Literal, Mapping, Type, TypeVar, + Union, cast) + +import yaml +from shrub.v3.evg_command import EvgCommandType, subprocess_exec +from shrub.v3.evg_project import EvgProject +from shrub.v3.shrub_service import ConfigDumper +from shrub.v3.evg_task import EvgTaskRef +from typing_extensions import get_args, get_origin, get_type_hints + +T = TypeVar('T') + + +# Equivalent to EvgTaskRef but defines additional properties. +class TaskRef(EvgTaskRef): + """ + An evergreen task reference model that also includes additional properties. + + (The shrub.py model is missing some properties) + """ + + batchtime: int | None = None + + +# Automatically formats the provided script and invokes it in Bash. +def bash_exec( + script, + *, + include_expansions_in_env: Iterable[str] | None = None, + working_dir: str | None = None, + command_type: EvgCommandType | None = None, + retry_on_failure: bool | None = None, + env: Mapping[str, str] | None = None, + **kwargs, +): + ret = subprocess_exec( + binary="bash", + args=["-c", dedent(script)], + include_expansions_in_env=list(include_expansions_in_env) if include_expansions_in_env else None, + working_dir=working_dir, + command_type=command_type, + env=dict(env) if env else None, + **kwargs, + ) + + if retry_on_failure is not None: + ret.params |= {"retry_on_failure": retry_on_failure} + + return ret + + +def all_components(): + res = [] + + # .evergreen/config_generator/etc/utils.py -> .evergreen/config_generator/components + components_dir = Path(__file__).parent.parent / 'components' + + all_paths = components_dir.glob('**/*.py') + + for path in sorted(all_paths): + component_path = path.relative_to(components_dir) + component_str = str(component_path.with_suffix('')) # Drop '.py'. + component_str = component_str.replace('/', '.') # 'a/b' -> 'a.b' + module_name = f'config_generator.components.{component_str}' + res.append(import_module(module_name)) + + return res + + +# Helper function to print component name for diagnostic purposes. +def component_name(component): + component_prefix = 'config_generator.components.' + res = component.__name__[len(component_prefix):] + return res + + +def write_to_file(yml, filename): + # .evergreen/config_generator/etc/utils.py -> .evergreen + evergreen_dir = Path(__file__).parent.parent.parent + filename = evergreen_dir / 'generated_configs' / filename + + with open(filename.resolve(), 'w', encoding='utf-8') as file: + file.write(yml) + + +class Dumper(ConfigDumper): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # List all tags on a single line. + self.FLOW_TAG_COUNT = float('inf') + + # Make an effort to order fields in a readable manner. + # Ordering applies to *all* mappings regardless of the parent node. + def represent_mapping(self, tag, mapping, flow_style=False): + if len(mapping) == 2 and 'key' in mapping and 'value' in mapping: + flow_style = True + + before = [ + 'name', + 'display_name', + 'command', + 'type', + 'run_on', + 'tags', + 'depends_on', + 'binary', + 'working_dir', + ] + + after = [ + 'commands', + 'args', + ] + + ordered = { + field: mapping.pop(field) for field in before if field in mapping + } + + suffix = { + field: mapping.pop(field) for field in after if field in mapping + } + + ordered.update(sorted(mapping.items())) + ordered.update(suffix) + + return self.represent_special_mapping(tag, ordered.items(), flow_style) + + +def to_yaml(project: EvgProject) -> str: + return yaml.dump( + project.dict(exclude_none=True, exclude_unset=True, by_alias=True), + Dumper=Dumper, + default_flow_style=False, + width=float('inf'), + ) + + +def all_possible(typ: Type[T]) -> Iterable[T]: + """ + Given a finite type, enumerate all possible values of that type. + The following are "finite" types: + + - Literal[...] types + - Union[...] of finite types + - NamedTuple where each field is a finite type + - None + """ + origin = get_origin(typ) + if typ is type(None): + yield cast(T, None) + elif origin is Literal: + # It is a literal type, so enumerate its literal operands + yield from get_args(typ) + return + elif origin == Union: + args = get_args(typ) + yield from itertools.chain.from_iterable(map(all_possible, args)) + elif isclass(typ) and issubclass(typ, tuple): + # Iter each NamedTuple field: + fields: Iterable[tuple[str, type]] = get_type_hints(typ).items() + # Generate lists of pairs of field names and their possible values + all_pairs: Iterable[Iterable[tuple[str, str]]] = ( + # Generate a (key, opt) pair for each option for 'key' + [(key, opt) for opt in all_possible(typ)] + # Over each field and type thereof: + for key, typ in fields + ) + # Now generate the cross product of all alternative for all fields: + matrix: Iterable[dict[str, Any]] = map(dict, itertools.product(*all_pairs)) + for items in matrix: + # Reconstruct as a NamedTuple: + yield typ(**items) # type: ignore + else: + raise TypeError( + f'Do not know how to do "all_possible" of type {typ!r} ({origin=})' + ) diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generate.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generate.py new file mode 100644 index 000000000..f32b79ef0 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generate.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +# Generates *.yml files under .evergreen/generated_configs. + + +import sys + +from importlib import import_module + + +GENERATOR_NAMES = [ + "functions", + "tasks", + "task_groups", + "variants", + "legacy_config", +] + + +def main(): + # Requires Python 3.10 or newer. + assert sys.version_info.major >= 3 + assert sys.version_info.minor >= 10 + + for name in GENERATOR_NAMES: + m = import_module(f"config_generator.generators.{name}") + print(f"Running {name}.generate()...") + m.generate() + print(f"Running {name}.generate()... done.") + + +if __name__ == "__main__": + main() diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generators/functions.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generators/functions.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generators/functions.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generators/functions.py diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generators/legacy_config.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generators/legacy_config.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generators/legacy_config.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generators/legacy_config.py diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generators/task_groups.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generators/task_groups.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generators/task_groups.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generators/task_groups.py diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generators/tasks.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generators/tasks.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generators/tasks.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generators/tasks.py diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generators/variants.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generators/variants.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/config_generator/generators/variants.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/config_generator/generators/variants.py diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/ecs_hosted_test.js b/3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/ecs_hosted_test.js similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/ecs_hosted_test.js rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/ecs_hosted_test.js diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/kerberos.realm b/3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/kerberos.realm similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/kerberos.realm rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/kerberos.realm diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/mongo-c-driver.spec b/3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/mongo-c-driver.spec similarity index 89% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/mongo-c-driver.spec rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/mongo-c-driver.spec index 030a9c881..9ff705e9e 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/mongo-c-driver.spec +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/mongo-c-driver.spec @@ -1,8 +1,8 @@ # remirepo/fedora spec file for mongo-c-driver # -# Copyright (c) 2015-2024 Remi Collet -# License: CC-BY-SA-4.0 -# http://creativecommons.org/licenses/by-sa/4.0/ +# SPDX-FileCopyrightText: Copyright 2015-2025 Remi Collet +# SPDX-License-Identifier: CECILL-2.1 +# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt # # Please, preserve the changelog entries # @@ -10,7 +10,7 @@ %global gh_project mongo-c-driver %global libname libmongoc %global libver 1.0 -%global up_version 1.26.1 +%global up_version 1.30.2 #global up_prever rc0 # disabled as require a MongoDB server %bcond_with tests @@ -18,6 +18,12 @@ # disable for bootstrap (libmongocrypt needs libbson) %bcond_without libmongocrypt +%if 0%{?rhel} == 8 +%bcond_with libutf8proc +%else +%bcond_without libutf8proc +%endif + Name: mongo-c-driver Summary: Client library written in C for MongoDB Version: %{up_version}%{?up_prever:~%{up_prever}} @@ -37,7 +43,9 @@ BuildRequires: openssl-devel BuildRequires: pkgconfig(libsasl2) BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(snappy) +%if %{with libutf8proc} BuildRequires: pkgconfig(libutf8proc) +%endif BuildRequires: pkgconfig(libzstd) >= 0.8.0 %if %{with tests} BuildRequires: mongodb-server @@ -45,7 +53,7 @@ BuildRequires: openssl %endif %if %{with libmongocrypt} # grep VERSION_LESS src/*/CMakeLists.txt -BuildRequires: cmake(mongocrypt) >= 1.8.0 +BuildRequires: cmake(mongocrypt) >= 1.12.0 %endif BuildRequires: perl-interpreter # From man pages @@ -65,6 +73,10 @@ Provides: %{name}-tools%{?_isa} = %{version} %package libs Summary: Shared libraries for %{name} +%if %{without libutf8proc} +Provides: bundled(libutf8proc) = 2.8.0 +%endif +Provides: bundled(uthash) = 2.3.0 %description libs This package contains the shared libraries for %{name}. @@ -146,7 +158,11 @@ Documentation: http://mongoc.org/libbson/%{version}/ -DENABLE_CLIENT_SIDE_ENCRYPTION:BOOL=OFF \ %endif -DCMAKE_SKIP_RPATH:BOOL=ON \ +%if %{with libutf8proc} -DUSE_BUNDLED_UTF8PROC:BOOL=OFF \ +%else + -DUSE_BUNDLED_UTF8PROC:BOOL=ON \ +%endif -DENABLE_SRV:BOOL=ON \ -DENABLE_MONGODB_AWS_AUTH:STRING=ON \ -S . @@ -211,7 +227,6 @@ exit $ret %{_bindir}/mongoc-stat %files libs -%{!?_licensedir:%global license %%doc} %license COPYING %license THIRD_PARTY_NOTICES %{_libdir}/%{libname}-%{libver}.so.* @@ -240,9 +255,75 @@ exit $ret %{_libdir}/cmake/bson-%{libver} %{_libdir}/pkgconfig/libbson-*.pc %{_mandir}/man3/bson* +%{_mandir}/man3/libbson* %changelog +* Wed Mar 5 2025 Remi Collet - 1.30.2-1 +- update to 1.30.2 + +* Tue Feb 25 2025 Remi Collet - 1.30.1-1 +- update to 1.30.1 + +* Tue Feb 18 2025 Remi Collet - 1.30.0-2 +- add upstream patch for GCC 15 + https://jira.mongodb.org/browse/CDRIVER-5889 + +* Thu Feb 6 2025 Remi Collet - 1.30.0-1 +- update to 1.30.0 + +* Fri Jan 17 2025 Fedora Release Engineering - 1.29.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Tue Jan 7 2025 Remi Collet - 1.29.2-1 +- update to 1.29.2 + +* Thu Dec 12 2024 Remi Collet - 1.29.1-1 +- update to 1.29.1 +- re-license spec file to CECILL-2.1 + +* Thu Nov 7 2024 Remi Collet - 1.29.0-1 +- update to 1.29.0 +- raise dependency to libmongocrypt 1.12.0 + +* Thu Oct 10 2024 Remi Collet - 1.28.1-1 +- update to 1.28.1 + +* Mon Oct 7 2024 Remi Collet - 1.28.0-2 +- rebuild for utf8proc #2316935 + +* Thu Sep 19 2024 Remi Collet - 1.28.0-1 +- update to 1.28.0 +- raise dependency to libmongocrypt 1.11.0 + +* Wed Sep 4 2024 Remi Collet - 1.27.6-1 +- update to 1.27.6 + +* Wed Aug 7 2024 Remi Collet - 1.27.5-1 +- update to 1.27.5 + +* Thu Jul 18 2024 Fedora Release Engineering - 1.27.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Wed Jul 3 2024 Remi Collet - 1.27.4-1 +- update to 1.27.4 + +* Tue Jul 2 2024 Remi Collet - 1.27.3-1 +- update to 1.27.3 + +* Wed Jun 5 2024 Remi Collet - 1.27.2-1 +- update to 1.27.2 + +* Mon May 13 2024 Remi Collet - 1.27.1-1 +- update to 1.27.1 + +* Thu May 2 2024 Remi Collet - 1.27.0-1 +- update to 1.27.0 +- raise dependency to libmongocrypt 1.10.0 + +* Wed Apr 3 2024 Remi Collet - 1.26.2-1 +- update to 1.26.2 + * Wed Mar 6 2024 Remi Collet - 1.26.1-1 - update to 1.26.1 diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/require-api-version.js b/3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/require-api-version.js similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/require-api-version.js rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/require-api-version.js diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/skip-tests.txt b/3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/skip-tests.txt similarity index 93% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/skip-tests.txt rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/skip-tests.txt index 3b9d066e3..5a732edbd 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/etc/skip-tests.txt +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/skip-tests.txt @@ -28,6 +28,8 @@ /transactions/legacy/mongos-recovery-token/"commitTransaction retry fails on new mongos" # fails with server selection timeout (CDRIVER-4268) /transactions/legacy/pin-mongos/"unpin after transient error within a transaction and commit" # (CDRIVER-4351) server selection timeout (on ASAN Tests Ubuntu 18.04 build variant) -/Samples # (CDRIVER-4352) strange "heartbeat failed" error /client_side_encryption/bypass_spawning_mongocryptd/mongocryptdBypassSpawn # Fails if crypt_shared is visible + +/Stepdown/getmore/single # SPEC-1442: C Driver does not implement connection pools or CMAP. +/Stepdown/getmore/pooled # SPEC-1442: C Driver does not implement connection pools or CMAP. diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/spec.patch b/3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/spec.patch new file mode 100644 index 000000000..93f587b46 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/etc/spec.patch @@ -0,0 +1,20 @@ +--- mongo-c-driver.spec.orig 2025-02-28 17:04:19.401176260 -0500 ++++ mongo-c-driver.spec 2025-02-28 17:05:52.190076172 -0500 +@@ -10,7 +10,7 @@ + %global gh_project mongo-c-driver + %global libname libmongoc + %global libver 1.0 +-%global up_version 1.30.2 ++%global up_version 1.31.0 + #global up_prever rc0 + # disabled as require a MongoDB server + %bcond_with tests +@@ -26,7 +26,7 @@ + + Name: mongo-c-driver + Summary: Client library written in C for MongoDB +-Version: %{up_version}%{?up_prever:~%{up_prever}} ++Version: %{up_version}%{?up_prever} + Release: 1%{?dist} + # See THIRD_PARTY_NOTICES + License: Apache-2.0 AND ISC AND MIT AND Zlib diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/functions.yml b/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/functions.yml similarity index 75% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/functions.yml rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/functions.yml index e7ac4f554..ec2f3b768 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/functions.yml +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/functions.yml @@ -1,37 +1,79 @@ functions: abi-compliance-check: + - command: subprocess.exec + type: setup + params: + binary: bash + args: + - -c + - | + if [[ -n "$XDG_CACHE_DIR" ]]; then + cache_dir="$XDG_CACHE_DIR" # XDG Base Directory specification. + elif [[ -n "$LOCALAPPDATA" ]]; then + cache_dir="$LOCALAPPDATA" # Windows. + elif [[ -n "$USERPROFILE" ]]; then + cache_dir="$USERPROFILE/.cache" # Windows (fallback). + elif [[ -d "$HOME/Library/Caches" ]]; then + cache_dir="$HOME/Library/Caches" # MacOS. + elif [[ -n "$HOME" ]]; then + cache_dir="$HOME/.cache" # Linux-like. + elif [[ -d ~/.cache ]]; then + cache_dir="~/.cache" # Linux-like (fallback). + else + cache_dir="$(pwd)/.cache" # EVG task directory (fallback). + fi + + mkdir -p "$cache_dir/mongo-c-driver" || exit + cache_dir="$(cd "$cache_dir/mongo-c-driver" && pwd)" || exit + + printf "MONGO_C_DRIVER_CACHE_DIR: %s\n" "$cache_dir" >|expansions.set-cache-dir.yml + - command: expansions.update + type: setup + params: + file: expansions.set-cache-dir.yml - command: subprocess.exec type: setup params: binary: bash working_dir: mongoc - add_expansions_to_env: true + include_expansions_in_env: + - MONGO_C_DRIVER_CACHE_DIR args: - -c - - .evergreen/scripts/abi-compliance-check.sh + - .evergreen/scripts/abi-compliance-check-setup.sh - command: subprocess.exec type: test params: binary: bash working_dir: mongoc - env: - AWS_ACCESS_KEY_ID: ${aws_key} - AWS_SECRET_ACCESS_KEY: ${aws_secret} + add_expansions_to_env: true + include_expansions_in_env: + - MONGO_C_DRIVER_CACHE_DIR args: - -c - - | - aws s3 cp abi-compliance/compat_reports s3://mciuploads/${project}/${build_variant}/${revision}/${version_id}/${build_id}/abi-compliance/compat_reports --recursive --acl public-read --region us-east-1 - [[ ! -f ./abi-compliance/abi-error.txt ]] + - .evergreen/scripts/abi-compliance-check.sh - command: s3.put + type: system params: - display_name: "ABI Report:" + display_name: "ABI Compliance Check: " aws_key: ${aws_key} aws_secret: ${aws_secret} bucket: mciuploads content_type: text/html - local_files_include_filter: mongoc/abi-compliance/compat_reports/**/*.html + local_files_include_filter: abi-compliance/compat_reports/**/compat_report.html + permissions: public-read + remote_file: ${project}/${branch_name}/${revision}/${version_id}/${build_id}/${task_id}/${execution}/abi-compliance-check/ + - command: s3.put + type: system + params: + display_name: "ABI Compliance Check: " + aws_key: ${aws_key} + aws_secret: ${aws_secret} + bucket: mciuploads + content_type: text/plain + local_files_include_filter: abi-compliance/logs/**/log.txt permissions: public-read - remote_file: ${project}/${build_variant}/${revision}/${version_id}/${build_id}/abi-compliance/compat_report.html + remote_file: ${project}/${branch_name}/${revision}/${version_id}/${build_id}/${task_id}/${execution}/abi-compliance-check/ backtrace: - command: subprocess.exec params: @@ -71,6 +113,17 @@ functions: args: - -c - .evergreen/scripts/check-preludes.py . + clang-format: + - command: subprocess.exec + type: test + params: + binary: bash + working_dir: mongoc + env: + DRYRUN: "1" + args: + - -c + - uv run --frozen --only-group=format tools/format.py --mode=check cse-sasl-cyrus-darwinssl-compile: - command: expansions.update params: @@ -122,15 +175,26 @@ functions: args: - -c - EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON ${EXTRA_CONFIGURE_FLAGS}" .evergreen/scripts/compile.sh - early-termination: + docker-login-amazon-ecr: + - command: expansions.update + params: + updates: + - { key: DOCKER_CONFIG, value: "${workdir}/.docker" } + - command: ec2.assume_role + params: + role_arn: arn:aws:iam::901841024863:role/ecr-role-evergreen-ro - command: subprocess.exec + type: setup params: binary: bash + include_expansions_in_env: + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN + - DOCKER_CONFIG args: - -c - - | - echo 'EVERGREEN HOST WAS UNEXPECTEDLY TERMINATED!!!' 1>&2 - echo 'Restart this Evergreen task and try again!' 1>&2 + - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 901841024863.dkr.ecr.us-east-1.amazonaws.com fetch-build: - command: subprocess.exec type: setup @@ -171,7 +235,7 @@ functions: - -c - | if [[ ! -d drivers-evergreen-tools ]]; then - git clone --depth=1 git@github.com:mongodb-labs/drivers-evergreen-tools.git + git clone --depth=1 https://github.com/mongodb-labs/drivers-evergreen-tools.git fi - command: subprocess.exec type: setup @@ -211,14 +275,7 @@ functions: set -o errexit set -o pipefail if [ -n "${github_pr_number}" -o "${is_patch}" = "true" ]; then - # This is a GitHub PR or patch build, probably branched from master - if command -v python3 &>/dev/null; then - # Prefer python3 if it is available - echo $(python3 ./build/calc_release_version.py --next-minor) > VERSION_CURRENT - else - echo $(python ./build/calc_release_version.py --next-minor) > VERSION_CURRENT - fi - VERSION=$VERSION_CURRENT-${version_id} + VERSION=patch-${version_id} else VERSION=latest fi @@ -238,6 +295,16 @@ functions: for file in $(find .evergreen/scripts -type f); do chmod +rx "$file" || exit done + find-cmake-latest: + - command: subprocess.exec + type: setup + params: + binary: bash + working_dir: mongoc + retry_on_failure: true + args: + - -c + - . .evergreen/scripts/find-cmake-latest.sh && find_cmake_latest kms-divergence-check: - command: subprocess.exec type: test @@ -258,10 +325,8 @@ functions: args: - -c - | - set -o errexit - bash tools/poetry.sh install --with=docs # See SphinxBuild.cmake for EVG_DOCS_BUILD reasoning - bash tools/poetry.sh run env EVG_DOCS_BUILD=1 bash .evergreen/scripts/build-docs.sh + uv run --frozen --only-group docs env EVG_DOCS_BUILD=1 .evergreen/scripts/build-docs.sh openssl-static-compile: - command: subprocess.exec type: test @@ -272,27 +337,6 @@ functions: args: - -c - .evergreen/scripts/compile-openssl-static.sh - prepare-kerberos: - - command: subprocess.exec - type: setup - params: - binary: bash - working_dir: mongoc - silent: true - args: - - -c - - | - if test "${keytab|}" && command -v kinit >/dev/null; then - echo "${keytab}" > /tmp/drivers.keytab.base64 - base64 --decode /tmp/drivers.keytab.base64 > /tmp/drivers.keytab - if touch /etc/krb5.conf 2>/dev/null; then - cat .evergreen/etc/kerberos.realm | tee -a /etc/krb5.conf - elif command sudo true 2>/dev/null; then - cat .evergreen/etc/kerberos.realm | sudo tee -a /etc/krb5.conf - else - echo "Cannot append kerberos.realm to /etc/krb5.conf; skipping." 1>&2 - fi - fi restore-instance-profile: - command: subprocess.exec params: @@ -364,6 +408,7 @@ functions: python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 9000 & python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 9001 & python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --require_client_cert --port 9002 & + python -u kms_failpoint_server.py --port 9003 & python -u kms_kmip_server.py & deactivate echo "Starting mock KMS TLS servers... done." @@ -418,19 +463,6 @@ functions: args: - -c - .evergreen/scripts/compile.sh - sasl-cyrus-winssl-compile: - - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongoc - add_expansions_to_env: true - env: - SASL: CYRUS - SSL: WINDOWS - args: - - -c - - .evergreen/scripts/compile.sh sasl-off-nossl-compile: - command: subprocess.exec type: test @@ -470,6 +502,72 @@ functions: args: - -c - .evergreen/scripts/compile.sh + sbom: + - command: ec2.assume_role + type: setup + params: + role_arn: ${kondukto_role_arn} + - command: subprocess.exec + type: setup + params: + binary: bash + include_expansions_in_env: + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN + args: + - -c + - | + set -o errexit + set -o pipefail + kondukto_token="$(aws secretsmanager get-secret-value --secret-id "kondukto-token" --region "us-east-1" --query 'SecretString' --output text)" + printf "KONDUKTO_TOKEN: %s\n" "$kondukto_token" >|expansions.kondukto.yml + - command: expansions.update + type: setup + params: + file: expansions.kondukto.yml + - command: expansions.update + params: + updates: + - { key: DOCKER_CONFIG, value: "${workdir}/.docker" } + - command: ec2.assume_role + params: + role_arn: arn:aws:iam::901841024863:role/ecr-role-evergreen-ro + - command: subprocess.exec + type: setup + params: + binary: bash + include_expansions_in_env: + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN + - DOCKER_CONFIG + args: + - -c + - aws ecr get-login-password --region us-east-1 | podman login --username AWS --password-stdin 901841024863.dkr.ecr.us-east-1.amazonaws.com + - command: subprocess.exec + type: test + params: + binary: bash + working_dir: mongoc + include_expansions_in_env: + - branch_name + - DOCKER_CONFIG + - KONDUKTO_TOKEN + args: + - -c + - .evergreen/scripts/sbom.sh + - command: s3.put + type: test + params: + display_name: Augmented SBOM + aws_key: ${aws_key} + aws_secret: ${aws_secret} + bucket: mciuploads + content_type: application/json + local_file: mongoc/augmented-sbom.json + permissions: public-read + remote_file: ${project}/${build_variant}/${revision}/${version_id}/${build_id}/sbom/augmented-sbom.json scan-build: - command: subprocess.exec type: test @@ -481,6 +579,38 @@ functions: args: - -c - .evergreen/scripts/compile-scan-build.sh + set-cache-dir: + - command: subprocess.exec + type: setup + params: + binary: bash + args: + - -c + - | + if [[ -n "$XDG_CACHE_DIR" ]]; then + cache_dir="$XDG_CACHE_DIR" # XDG Base Directory specification. + elif [[ -n "$LOCALAPPDATA" ]]; then + cache_dir="$LOCALAPPDATA" # Windows. + elif [[ -n "$USERPROFILE" ]]; then + cache_dir="$USERPROFILE/.cache" # Windows (fallback). + elif [[ -d "$HOME/Library/Caches" ]]; then + cache_dir="$HOME/Library/Caches" # MacOS. + elif [[ -n "$HOME" ]]; then + cache_dir="$HOME/.cache" # Linux-like. + elif [[ -d ~/.cache ]]; then + cache_dir="~/.cache" # Linux-like (fallback). + else + cache_dir="$(pwd)/.cache" # EVG task directory (fallback). + fi + + mkdir -p "$cache_dir/mongo-c-driver" || exit + cache_dir="$(cd "$cache_dir/mongo-c-driver" && pwd)" || exit + + printf "MONGO_C_DRIVER_CACHE_DIR: %s\n" "$cache_dir" >|expansions.set-cache-dir.yml + - command: expansions.update + type: setup + params: + file: expansions.set-cache-dir.yml start-load-balancer: - command: subprocess.exec type: setup diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/legacy-config.yml b/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/legacy-config.yml new file mode 100644 index 000000000..34560acfc --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/legacy-config.yml @@ -0,0 +1,16535 @@ +#################################### +# Evergreen configuration +# +# Generated with evergreen_config_generator from +# github.com/mongodb-labs/drivers-evergreen-tools +# +# DO NOT EDIT THIS FILE +# +#################################### +functions: + install ssl: + - command: shell.exec + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + .evergreen/scripts/install-ssl.sh + upload coverage: + - command: shell.exec + params: + silent: true + working_dir: mongoc + shell: bash + script: |- + set -o errexit + export AWS_ACCESS_KEY_ID=${aws_key} + export AWS_SECRET_ACCESS_KEY=${aws_secret} + aws s3 cp coverage s3://mciuploads/${project}/${build_variant}/${revision}/${version_id}/${build_id}/coverage/ --recursive --acl public-read --region us-east-1 + - command: s3.put + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/${build_variant}/${revision}/${version_id}/${build_id}/coverage/index.html + bucket: mciuploads + permissions: public-read + local_file: mongoc/coverage/index.html + content_type: text/html + display_name: Coverage Report + upload scan artifacts: + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + if find scan -name \*.html | grep -q html; then + (cd scan && find . -name index.html -exec echo "
  • {}
  • " \;) >> scan.html + else + echo "No issues found" > scan.html + fi + - command: shell.exec + params: + silent: true + working_dir: mongoc + shell: bash + script: |- + set -o errexit + export AWS_ACCESS_KEY_ID=${aws_key} + export AWS_SECRET_ACCESS_KEY=${aws_secret} + aws s3 cp scan s3://mciuploads/${project}/${build_variant}/${revision}/${version_id}/${build_id}/scan/ --recursive --acl public-read --region us-east-1 + - command: s3.put + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/${build_variant}/${revision}/${version_id}/${build_id}/scan/index.html + bucket: mciuploads + permissions: public-read + local_file: mongoc/scan.html + content_type: text/html + display_name: Scan Build Report + run auth tests: + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + .evergreen/scripts/run-auth-tests.sh + link sample program: + - command: shell.exec + type: test + params: + working_dir: mongoc + include_expansions_in_env: + - distro_id + shell: bash + script: |- + set -o errexit + # Compile a program that links dynamically or statically to libmongoc, + # using variables from pkg-config or CMake's find_package command. + export BUILD_SAMPLE_WITH_CMAKE=${BUILD_SAMPLE_WITH_CMAKE} + export ENABLE_SSL=${ENABLE_SSL} + export ENABLE_SNAPPY=${ENABLE_SNAPPY} + LINK_STATIC= .evergreen/scripts/link-sample-program.sh + LINK_STATIC=1 .evergreen/scripts/link-sample-program.sh + link sample program bson: + - command: shell.exec + type: test + params: + working_dir: mongoc + include_expansions_in_env: + - distro_id + shell: bash + script: |- + set -o errexit + # Compile a program that links dynamically or statically to libbson, + # using variables from pkg-config or from CMake's find_package command. + BUILD_SAMPLE_WITH_CMAKE= LINK_STATIC= .evergreen/scripts/link-sample-program-bson.sh + BUILD_SAMPLE_WITH_CMAKE= LINK_STATIC=1 .evergreen/scripts/link-sample-program-bson.sh + BUILD_SAMPLE_WITH_CMAKE=1 LINK_STATIC= .evergreen/scripts/link-sample-program-bson.sh + BUILD_SAMPLE_WITH_CMAKE=1 LINK_STATIC=1 .evergreen/scripts/link-sample-program-bson.sh + link sample program MSVC: + - command: shell.exec + type: test + params: + working_dir: mongoc + include_expansions_in_env: + - distro_id + shell: bash + script: |- + set -o errexit + # Build libmongoc with CMake and compile a program that links + # dynamically or statically to it, using variables from CMake's + # find_package command. + export ENABLE_SSL=${ENABLE_SSL} + export ENABLE_SNAPPY=${ENABLE_SNAPPY} + . .evergreen/scripts/use-tools.sh paths + . .evergreen/scripts/find-cmake-latest.sh + export CMAKE="$(native-path "$(find_cmake_latest)")" + LINK_STATIC= cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc.cmd + LINK_STATIC=1 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc.cmd + link sample program mingw: + - command: shell.exec + type: test + params: + working_dir: mongoc + include_expansions_in_env: + - distro_id + shell: bash + script: |- + set -o errexit + # Build libmongoc with CMake and compile a program that links + # dynamically to it, using variables from pkg-config.exe. + . .evergreen/scripts/use-tools.sh paths + . .evergreen/scripts/find-cmake-latest.sh + export CMAKE="$(native-path "$(find_cmake_latest)")" + cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw.cmd + link sample program MSVC bson: + - command: shell.exec + type: test + params: + working_dir: mongoc + include_expansions_in_env: + - distro_id + shell: bash + script: |- + set -o errexit + # Build libmongoc with CMake and compile a program that links + # dynamically or statically to it, using variables from CMake's + # find_package command. + export ENABLE_SSL=${ENABLE_SSL} + export ENABLE_SNAPPY=${ENABLE_SNAPPY} + . .evergreen/scripts/use-tools.sh paths + . .evergreen/scripts/find-cmake-latest.sh + export CMAKE="$(native-path "$(find_cmake_latest)")" + LINK_STATIC= cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc-bson.cmd + LINK_STATIC=1 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc-bson.cmd + link sample program mingw bson: + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + # Build libmongoc with CMake and compile a program that links + # dynamically to it, using variables from pkg-config.exe. + . .evergreen/scripts/use-tools.sh paths + . .evergreen/scripts/find-cmake-latest.sh + export CMAKE="$(native-path "$(find_cmake_latest)")" + cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw-bson.cmd + update codecov.io: + - command: shell.exec + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + # Note: coverage is currently only enabled on the ubuntu1804 distro. + # This script does not support MacOS, Windows, or non-x86_64 distros. + # Update accordingly if code coverage is expanded to other distros. + curl -Os https://uploader.codecov.io/latest/linux/codecov + chmod +x codecov + # -Z: Exit with a non-zero value if error. + # -g: Run with gcov support. + # -t: Codecov upload token. + # perl: filter verbose "Found" list and "Processing" messages. + ./codecov -Zgt "${codecov_token}" | perl -lne 'print if not m|^.*\.gcov(\.\.\.)?$|' + compile coverage: + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + COVERAGE=ON .evergreen/scripts/compile.sh + build mongohouse: + - command: ec2.assume_role + params: + role_arn: ${aws_test_secrets_role} + - command: shell.exec + type: test + params: + include_expansions_in_env: + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN + shell: bash + script: |- + set -o errexit + cd drivers-evergreen-tools + export DRIVERS_TOOLS=$(pwd) + .evergreen/atlas_data_lake/pull-mongohouse-image.sh + run mongohouse: + - command: shell.exec + type: test + params: + shell: bash + script: |- + set -o errexit + cd drivers-evergreen-tools + export DRIVERS_TOOLS=$(pwd) + .evergreen/atlas_data_lake/run-mongohouse-image.sh + test mongohouse: + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + echo "Waiting for mongohouse to start..." + wait_for_mongohouse() { + for _ in $(seq 300); do + # Exit code 7: "Failed to connect to host". + if curl -s localhost:$1; (("$?" != 7)); then + return 0 + else + sleep 1 + fi + done + echo "Could not detect mongohouse on port $1" 1>&2 + return 1 + } + wait_for_mongohouse 27017 || exit + echo "Waiting for mongohouse to start... done." + pgrep -a "mongohouse" + export RUN_MONGOHOUSE_TESTS=ON + ./cmake-build/src/libmongoc/test-libmongoc --no-fork -l /mongohouse/* -d --skip-tests .evergreen/etc/skip-tests.txt + run aws tests: + - command: ec2.assume_role + params: + role_arn: ${aws_test_secrets_role} + - command: shell.exec + type: test + params: + working_dir: mongoc + include_expansions_in_env: + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN + shell: bash + script: |- + set -o errexit + pushd ../drivers-evergreen-tools/.evergreen/auth_aws + ./setup_secrets.sh drivers/aws_auth + popd # ../drivers-evergreen-tools/.evergreen/auth_aws + - command: shell.exec + type: test + params: + working_dir: mongoc + include_expansions_in_env: + - TESTCASE + shell: bash + script: |- + set -o errexit + pushd ../drivers-evergreen-tools/.evergreen/auth_aws + . ./activate-authawsvenv.sh + popd # ../drivers-evergreen-tools/.evergreen/auth_aws + .evergreen/scripts/run-aws-tests.sh +tasks: +- name: hardened-compile + tags: + - hardened + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env CFLAGS="-fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -fPIE -O" LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now" SNAPPY="OFF" ZLIB="OFF" ZSTD="OFF" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-compression-zlib + tags: + - compression + - zlib + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SNAPPY="OFF" ZLIB="BUNDLED" ZSTD="OFF" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-compression-snappy + tags: + - compression + - snappy + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SNAPPY="ON" ZLIB="OFF" ZSTD="OFF" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-compression-zstd + tags: + - compression + - zstd + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SNAPPY="OFF" ZLIB="OFF" ZSTD="ON" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-nosasl-nossl + tags: + - debug-compile + - nosasl + - nossl + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SSL="OFF" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-lto + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env CFLAGS="-flto" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-lto-thin + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env CFLAGS="-flto=thin" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-no-counters + tags: + - debug-compile + - no-counters + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env ENABLE_SHM_COUNTERS="OFF" .evergreen/scripts/compile.sh + - func: upload-build +- name: compile-tracing + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env CFLAGS="-Werror -Wno-cast-align" TRACING="ON" .evergreen/scripts/compile.sh + - func: upload-build +- name: release-compile + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env RELEASE="ON" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-nosasl-openssl + tags: + - debug-compile + - nosasl + - openssl + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SSL="OPENSSL" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-nosasl-openssl-static + tags: + - debug-compile + - nosasl + - openssl-static + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SSL="OPENSSL_STATIC" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-nosasl-darwinssl + tags: + - darwinssl + - debug-compile + - nosasl + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SSL="DARWIN" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-nosasl-winssl + tags: + - debug-compile + - nosasl + - winssl + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SSL="WINDOWS" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-sasl-openssl + tags: + - debug-compile + - openssl + - sasl + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SASL="AUTO" SSL="OPENSSL" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-sasl-openssl-static + tags: + - debug-compile + - openssl-static + - sasl + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SASL="AUTO" SSL="OPENSSL_STATIC" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-sasl-darwinssl + tags: + - darwinssl + - debug-compile + - sasl + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SASL="AUTO" SSL="DARWIN" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-rdtscp + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env ENABLE_RDTSCP="ON" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-sspi-winssl + tags: + - debug-compile + - sspi + - winssl + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SASL="SSPI" SSL="WINDOWS" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-nosrv + tags: + - debug-compile + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SRV="OFF" .evergreen/scripts/compile.sh + - func: upload-build +- name: link-with-cmake + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: link sample program + vars: + BUILD_SAMPLE_WITH_CMAKE: 1 +- name: link-with-cmake-ssl + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: link sample program + vars: + BUILD_SAMPLE_WITH_CMAKE: 1 + ENABLE_SSL: 1 +- name: link-with-cmake-snappy + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: link sample program + vars: + BUILD_SAMPLE_WITH_CMAKE: 1 + ENABLE_SNAPPY: 'ON' +- name: link-with-cmake-mac + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: link sample program + vars: + BUILD_SAMPLE_WITH_CMAKE: 1 +- name: link-with-cmake-windows + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: link sample program MSVC +- name: link-with-cmake-windows-ssl + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + SSL: openssl + - func: link sample program MSVC + vars: + ENABLE_SSL: 1 +- name: link-with-cmake-windows-snappy + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: link sample program MSVC + vars: + ENABLE_SNAPPY: 'ON' +- name: link-with-cmake-mingw + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: link sample program mingw +- name: link-with-pkg-config + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: link sample program +- name: link-with-pkg-config-mac + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: link sample program +- name: link-with-pkg-config-ssl + commands: + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: link sample program + vars: + ENABLE_SSL: 1 +- name: link-with-bson + commands: + - func: link sample program bson +- name: link-with-bson-mac + commands: + - func: link sample program bson +- name: link-with-bson-windows + commands: + - func: link sample program MSVC bson +- name: link-with-bson-mingw + commands: + - func: link sample program mingw bson +- name: debian-package-build + commands: + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + export IS_PATCH="${is_patch}" + .evergreen/scripts/debian_package_build.sh + - command: s3.put + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/${branch_name}/mongo-c-driver-debian-packages-${CURRENT_VERSION}.tar.gz + bucket: mciuploads + permissions: public-read + local_file: deb.tar.gz + content_type: ${content_type|application/x-gzip} + - command: s3.put + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-debian-packages.tar.gz + bucket: mciuploads + permissions: public-read + local_file: deb.tar.gz + content_type: ${content_type|application/x-gzip} + - command: s3.put + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/${branch_name}/mongo-c-driver-debian-packages-i386-${CURRENT_VERSION}.tar.gz + bucket: mciuploads + permissions: public-read + local_file: deb-i386.tar.gz + content_type: ${content_type|application/x-gzip} + - command: s3.put + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-debian-packages-i386.tar.gz + bucket: mciuploads + permissions: public-read + local_file: deb-i386.tar.gz + content_type: ${content_type|application/x-gzip} +- name: rpm-package-build + commands: + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + export IS_PATCH="${is_patch}" + .evergreen/scripts/check_rpm_spec.sh + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + .evergreen/scripts/build_snapshot_rpm.sh + - command: s3.put + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/${branch_name}/mongo-c-driver-rpm-packages-${CURRENT_VERSION}.tar.gz + bucket: mciuploads + permissions: public-read + local_file: rpm.tar.gz + content_type: ${content_type|application/x-gzip} + - command: s3.put + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: ${project}/${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-rpm-packages.tar.gz + bucket: mciuploads + permissions: public-read + local_file: rpm.tar.gz + content_type: ${content_type|application/x-gzip} + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + sudo rm -rf ../build ../mock-result ../rpm.tar.gz + export MOCK_TARGET_CONFIG=rocky+epel-9-aarch64 + .evergreen/scripts/build_snapshot_rpm.sh + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + sudo rm -rf ../build ../mock-result ../rpm.tar.gz + export MOCK_TARGET_CONFIG=rocky+epel-8-aarch64 + .evergreen/scripts/build_snapshot_rpm.sh +- name: debug-compile-with-warnings + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env CFLAGS="-Werror -Wno-cast-align" .evergreen/scripts/compile.sh + - func: upload-build +- name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: install ssl + vars: + SSL: openssl-1.0.1u + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env CFLAGS="-Wno-redundant-decls" SASL="OFF" SSL="OPENSSL" .evergreen/scripts/compile.sh + - func: upload-build +- name: build-and-test-with-toolchain + commands: + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: mongo-c-toolchain/${distro_id}/2023/06/07/mongo-c-toolchain.tar.gz + bucket: mongo-c-toolchain + local_file: mongo-c-toolchain.tar.gz + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + .evergreen/scripts/build-and-test-with-toolchain.sh +- name: install-libmongoc-after-libbson + commands: + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + .evergreen/scripts/install-libmongoc-after-libbson.sh +- name: test-coverage-latest-replica-set-auth-sasl-openssl + tags: + - latest + - test-coverage + commands: + - func: compile coverage + vars: + SASL: AUTO + SSL: OPENSSL + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: latest + SSL: openssl + TOPOLOGY: replica_set + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: auth + COVERAGE: 'ON' + SSL: openssl + - func: upload coverage + - func: update codecov.io +- name: test-coverage-latest-replica-set-auth-sasl-openssl-cse + tags: + - client-side-encryption + - latest + - test-coverage + commands: + - func: compile coverage + vars: + COMPILE_LIBMONGOCRYPT: 'ON' + EXTRA_CONFIGURE_FLAGS: EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON" + SASL: AUTO + SSL: OPENSSL + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: latest + SSL: openssl + TOPOLOGY: replica_set + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + vars: + AUTH: auth + CLIENT_SIDE_ENCRYPTION: 'ON' + COVERAGE: 'ON' + SSL: openssl + - func: upload coverage + - func: update codecov.io +- name: test-dns-openssl + depends_on: + name: debug-compile-sasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sasl-openssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + SSL: ssl + TOPOLOGY: replica_set + - func: run-tests + vars: + AUTH: noauth + DNS: 'on' + SSL: ssl +- name: test-dns-winssl + depends_on: + name: debug-compile-sspi-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sspi-winssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + SSL: ssl + TOPOLOGY: replica_set + - func: run-tests + vars: + AUTH: noauth + DNS: 'on' + SSL: ssl +- name: test-dns-darwinssl + depends_on: + name: debug-compile-sasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sasl-darwinssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + SSL: ssl + TOPOLOGY: replica_set + - func: run-tests + vars: + AUTH: noauth + DNS: 'on' + SSL: ssl +- name: test-dns-loadbalanced-openssl + depends_on: + name: debug-compile-sasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sasl-openssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + LOAD_BALANCER: 'on' + SSL: ssl + TOPOLOGY: sharded_cluster + - func: fetch-det + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: noauth + DNS: loadbalanced + SSL: ssl +- name: test-dns-auth-openssl + depends_on: + name: debug-compile-sasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sasl-openssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + SSL: ssl + TOPOLOGY: replica_set + - func: run-tests + vars: + AUTH: auth + DNS: dns-auth + SSL: ssl +- name: test-dns-auth-winssl + depends_on: + name: debug-compile-sspi-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sspi-winssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + SSL: ssl + TOPOLOGY: replica_set + - func: run-tests + vars: + AUTH: auth + DNS: dns-auth + SSL: ssl +- name: test-dns-auth-darwinssl + depends_on: + name: debug-compile-sasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sasl-darwinssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + SSL: ssl + TOPOLOGY: replica_set + - func: run-tests + vars: + AUTH: auth + DNS: dns-auth + SSL: ssl +- name: test-latest-server-compression-zlib + tags: + - compression + - latest + - zlib + depends_on: + name: debug-compile-compression-zlib + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-compression-zlib + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + SSL: nossl + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: noauth + COMPRESSORS: zlib + SSL: nossl +- name: test-latest-server-compression-snappy + tags: + - compression + - latest + - snappy + depends_on: + name: debug-compile-compression-snappy + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-compression-snappy + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + SSL: nossl + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: noauth + COMPRESSORS: snappy + SSL: nossl +- name: test-latest-server-compression-zstd + tags: + - compression + - latest + - zstd + depends_on: + name: debug-compile-compression-zstd + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-compression-zstd + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + SSL: nossl + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: noauth + COMPRESSORS: zstd + SSL: nossl +- name: retry-true-latest-server + depends_on: + name: debug-compile-sasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sasl-openssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + TOPOLOGY: server + - func: run-simple-http-server + - func: run-tests + vars: + URI: mongodb://localhost/?retryWrites=true +- name: test-latest-server-hardened + tags: + - hardened + - latest + depends_on: + name: hardened-compile + commands: + - func: fetch-build + vars: + BUILD_NAME: hardened-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + TOPOLOGY: server + - func: run-simple-http-server + - func: run-tests + vars: + URI: null +- name: authentication-tests-openssl + tags: + - authentication-tests + - openssl + - sasl + depends_on: + name: debug-compile-sasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sasl-openssl + - func: run auth tests +- name: authentication-tests-darwinssl + tags: + - authentication-tests + - darwinssl + - sasl + depends_on: + name: debug-compile-sasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sasl-darwinssl + - func: run auth tests +- name: authentication-tests-winssl + tags: + - authentication-tests + - sspi + - winssl + depends_on: + name: debug-compile-sspi-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sspi-winssl + - func: run auth tests +- name: authentication-tests-openssl-nosasl + tags: + - authentication-tests + - nosasl + - openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: run auth tests +- name: test-mongohouse + depends_on: + name: debug-compile-sasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-sasl-openssl + - func: fetch-det + - func: build mongohouse + - func: run mongohouse + - func: test mongohouse +- name: authentication-tests-asan-memcheck + tags: + - asan + - authentication-tests + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SANITIZE=address SASL=AUTO SSL=OPENSSL .evergreen/scripts/compile.sh + - func: run auth tests + vars: + ASAN: 'on' +- name: test-versioned-api-8.0 + tags: + - '8.0' + - versioned-api + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '8.0' + REQUIRE_API_VERSION: 'true' + SSL: ssl + TOPOLOGY: server + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: auth + MONGODB_API_VERSION: 1 + SSL: ssl +- name: test-versioned-api-accept-version-two-8.0 + tags: + - '8.0' + - versioned-api + depends_on: + name: debug-compile-nosasl-nossl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-nossl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + MONGODB_VERSION: '8.0' + ORCHESTRATION_FILE: versioned-api-testing.json + SSL: nossl + TOPOLOGY: server + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: noauth + MONGODB_API_VERSION: 1 + SSL: nossl +- name: test-versioned-api-7.0 + tags: + - '7.0' + - versioned-api + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '7.0' + REQUIRE_API_VERSION: 'true' + SSL: ssl + TOPOLOGY: server + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: auth + MONGODB_API_VERSION: 1 + SSL: ssl +- name: test-versioned-api-accept-version-two-7.0 + tags: + - '7.0' + - versioned-api + depends_on: + name: debug-compile-nosasl-nossl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-nossl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + MONGODB_VERSION: '7.0' + ORCHESTRATION_FILE: versioned-api-testing.json + SSL: nossl + TOPOLOGY: server + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: noauth + MONGODB_API_VERSION: 1 + SSL: nossl +- name: test-versioned-api-6.0 + tags: + - '6.0' + - versioned-api + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '6.0' + REQUIRE_API_VERSION: 'true' + SSL: ssl + TOPOLOGY: server + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: auth + MONGODB_API_VERSION: 1 + SSL: ssl +- name: test-versioned-api-accept-version-two-6.0 + tags: + - '6.0' + - versioned-api + depends_on: + name: debug-compile-nosasl-nossl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-nossl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + MONGODB_VERSION: '6.0' + ORCHESTRATION_FILE: versioned-api-testing.json + SSL: nossl + TOPOLOGY: server + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: noauth + MONGODB_API_VERSION: 1 + SSL: nossl +- name: test-versioned-api-5.0 + tags: + - '5.0' + - versioned-api + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '5.0' + REQUIRE_API_VERSION: 'true' + SSL: ssl + TOPOLOGY: server + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: auth + MONGODB_API_VERSION: 1 + SSL: ssl +- name: test-versioned-api-accept-version-two-5.0 + tags: + - '5.0' + - versioned-api + depends_on: + name: debug-compile-nosasl-nossl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-nossl + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + MONGODB_VERSION: '5.0' + ORCHESTRATION_FILE: versioned-api-testing.json + SSL: nossl + TOPOLOGY: server + - func: run-simple-http-server + - func: run-tests + vars: + AUTH: noauth + MONGODB_API_VERSION: 1 + SSL: nossl +- name: build-and-run-authentication-tests-openssl-1.0.1 + commands: + - func: install ssl + vars: + SSL: openssl-1.0.1u + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env CFLAGS=-Wno-redundant-decls SASL=OFF SSL=OPENSSL .evergreen/scripts/compile.sh + - func: run auth tests + - func: upload-build +- name: build-and-run-authentication-tests-openssl-1.0.1-fips + commands: + - func: install ssl + vars: + SSL: openssl-1.0.1u-fips + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env CFLAGS=-Wno-redundant-decls SASL=OFF SSL=OPENSSL .evergreen/scripts/compile.sh + - func: run auth tests + - func: upload-build +- name: build-and-run-authentication-tests-openssl-1.0.2 + commands: + - func: install ssl + vars: + SSL: openssl-1.0.2l + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env CFLAGS=-Wno-redundant-decls SASL=OFF SSL=OPENSSL .evergreen/scripts/compile.sh + - func: run auth tests + - func: upload-build +- name: build-and-run-authentication-tests-openssl-1.1.0 + commands: + - func: install ssl + vars: + SSL: openssl-1.1.0l + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + env SASL=OFF SSL=OPENSSL .evergreen/scripts/compile.sh + - func: run auth tests + - func: upload-build +- name: test-latest-server-ipv6-client-ipv6-noauth-nosasl-nossl + tags: + - ipv4-ipv6 + - latest + - nosasl + - nossl + - server + depends_on: + name: debug-compile-nosasl-nossl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-nossl + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + vars: + URI: mongodb://[::1]/ +- name: test-latest-server-ipv6-client-ipv4-noauth-nosasl-nossl + tags: + - ipv4-ipv6 + - latest + - nosasl + - nossl + - server + depends_on: + name: debug-compile-nosasl-nossl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-nossl + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + vars: + URI: mongodb://127.0.0.1/ +- name: test-latest-server-ipv4-client-ipv4-noauth-nosasl-nossl + tags: + - ipv4-ipv6 + - latest + - nosasl + - nossl + - server + depends_on: + name: debug-compile-nosasl-nossl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-nossl + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + vars: + URI: mongodb://127.0.0.1/ +- name: test-latest-server-ipv4-client-localhost-noauth-nosasl-nossl + tags: + - ipv4-ipv6 + - latest + - nosasl + - nossl + - server + depends_on: + name: debug-compile-nosasl-nossl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-nossl + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + vars: + URI: mongodb://localhost/ +- name: debug-compile-aws + commands: + - func: find-cmake-latest + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + export distro_id='${distro_id}' # Required by find_cmake_latest. + . .evergreen/scripts/find-cmake-latest.sh + cmake_binary="$(find_cmake_latest)" + # Use ccache if able. + . .evergreen/scripts/find-ccache.sh + find_ccache_and_export_vars "$(pwd)" || true + # Compile test-awsauth. Disable unnecessary dependencies since test-awsauth is copied to a remote Ubuntu 20.04 ECS cluster for testing, which may not have all dependent libraries. + export CC='${CC}' + "$cmake_binary" -DENABLE_TRACING=ON -DENABLE_SASL=OFF -DENABLE_SNAPPY=OFF -DENABLE_ZSTD=OFF -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF . + "$cmake_binary" --build . --target test-awsauth + - func: upload-build +- name: test-aws-openssl-regular-latest + tags: + - latest + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: latest + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: REGULAR +- name: test-aws-openssl-regular-8.0 + tags: + - '8.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '8.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: REGULAR +- name: test-aws-openssl-regular-7.0 + tags: + - '7.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '7.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: REGULAR +- name: test-aws-openssl-regular-6.0 + tags: + - '6.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '6.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: REGULAR +- name: test-aws-openssl-regular-5.0 + tags: + - '5.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '5.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: REGULAR +- name: test-aws-openssl-regular-4.4 + tags: + - '4.4' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '4.4' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: REGULAR +- name: test-aws-openssl-ec2-latest + tags: + - latest + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: latest + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: EC2 +- name: test-aws-openssl-ec2-8.0 + tags: + - '8.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '8.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: EC2 +- name: test-aws-openssl-ec2-7.0 + tags: + - '7.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '7.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: EC2 +- name: test-aws-openssl-ec2-6.0 + tags: + - '6.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '6.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: EC2 +- name: test-aws-openssl-ec2-5.0 + tags: + - '5.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '5.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: EC2 +- name: test-aws-openssl-ec2-4.4 + tags: + - '4.4' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '4.4' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: EC2 +- name: test-aws-openssl-ecs-latest + tags: + - latest + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: latest + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ECS +- name: test-aws-openssl-ecs-8.0 + tags: + - '8.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '8.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ECS +- name: test-aws-openssl-ecs-7.0 + tags: + - '7.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '7.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ECS +- name: test-aws-openssl-ecs-6.0 + tags: + - '6.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '6.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ECS +- name: test-aws-openssl-ecs-5.0 + tags: + - '5.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '5.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ECS +- name: test-aws-openssl-ecs-4.4 + tags: + - '4.4' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '4.4' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ECS +- name: test-aws-openssl-lambda-latest + tags: + - latest + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: latest + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: LAMBDA +- name: test-aws-openssl-lambda-8.0 + tags: + - '8.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '8.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: LAMBDA +- name: test-aws-openssl-lambda-7.0 + tags: + - '7.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '7.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: LAMBDA +- name: test-aws-openssl-lambda-6.0 + tags: + - '6.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '6.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: LAMBDA +- name: test-aws-openssl-lambda-5.0 + tags: + - '5.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '5.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: LAMBDA +- name: test-aws-openssl-lambda-4.4 + tags: + - '4.4' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '4.4' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: LAMBDA +- name: test-aws-openssl-assume_role-latest + tags: + - latest + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: latest + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE +- name: test-aws-openssl-assume_role-8.0 + tags: + - '8.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '8.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE +- name: test-aws-openssl-assume_role-7.0 + tags: + - '7.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '7.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE +- name: test-aws-openssl-assume_role-6.0 + tags: + - '6.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '6.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE +- name: test-aws-openssl-assume_role-5.0 + tags: + - '5.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '5.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE +- name: test-aws-openssl-assume_role-4.4 + tags: + - '4.4' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '4.4' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE +- name: test-aws-openssl-assume_role_with_web_identity-latest + tags: + - latest + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: latest + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY +- name: test-aws-openssl-assume_role_with_web_identity-8.0 + tags: + - '8.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '8.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY +- name: test-aws-openssl-assume_role_with_web_identity-7.0 + tags: + - '7.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '7.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY +- name: test-aws-openssl-assume_role_with_web_identity-6.0 + tags: + - '6.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '6.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY +- name: test-aws-openssl-assume_role_with_web_identity-5.0 + tags: + - '5.0' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '5.0' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY +- name: test-aws-openssl-assume_role_with_web_identity-4.4 + tags: + - '4.4' + - test-aws + depends_on: + name: debug-compile-aws + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-aws + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + MONGODB_VERSION: '4.4' + ORCHESTRATION_FILE: auth-aws.json + TOPOLOGY: server + - func: run aws tests + vars: + TESTCASE: ASSUME_ROLE_WITH_WEB_IDENTITY +- name: ocsp-openssl-test_1-rsa-delegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-delegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-delegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-delegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-delegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-delegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-delegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-delegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-delegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-delegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-delegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-delegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-delegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-delegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-rsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-rsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_1-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_1-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-delegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-delegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-delegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-delegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-delegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-delegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-delegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-delegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-delegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-delegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-delegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-delegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-delegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-delegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-rsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-rsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_2-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_2-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-delegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-delegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-delegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-delegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-delegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-delegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-delegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-delegate-latest + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-delegate-8.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-delegate-7.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-delegate-6.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-delegate-5.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-delegate-4.4 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-delegate-latest + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-delegate-8.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-delegate-7.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-delegate-6.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-delegate-5.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-delegate-4.4 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-delegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-delegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-delegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-delegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-delegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-delegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-delegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-rsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-rsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-nodelegate-latest + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-nodelegate-8.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-nodelegate-7.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-nodelegate-6.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-nodelegate-5.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_3-rsa-nodelegate-4.4 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-nodelegate-latest + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-nodelegate-8.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-nodelegate-7.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-nodelegate-6.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-nodelegate-5.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_3-rsa-nodelegate-4.4 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_3-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_3-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_3 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-delegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-delegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-delegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-delegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-delegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-delegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-delegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-delegate-latest + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-delegate-8.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-delegate-7.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-delegate-6.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-delegate-5.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-delegate-4.4 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-delegate-latest + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-delegate-8.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-delegate-7.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-delegate-6.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-delegate-5.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-delegate-4.4 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-delegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-delegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-delegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-delegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-delegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-delegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-delegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-rsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-rsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-nodelegate-latest + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-nodelegate-8.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-nodelegate-7.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-nodelegate-6.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-nodelegate-5.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-test_4-rsa-nodelegate-4.4 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-nodelegate-latest + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-nodelegate-8.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-nodelegate-7.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-nodelegate-6.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-nodelegate-5.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-test_4-rsa-nodelegate-4.4 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-test_4-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-test_4-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-rsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-rsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-latest + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-8.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-7.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-6.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-5.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-soft_fail_test-rsa-nodelegate-4.4 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-latest + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-8.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-7.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-6.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-5.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-soft_fail_test-rsa-nodelegate-4.4 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-soft_fail_test-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-soft_fail_test-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=SOFT_FAIL_TEST CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-delegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-delegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-latest + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-8.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-7.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-6.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-5.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-delegate-4.4 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-latest + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-8.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-7.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-6.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-5.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-delegate-4.4 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-delegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-delegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=ON .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-rsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-rsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-latest + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-8.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-7.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-6.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-5.0 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-darwinssl-malicious_server_test_1-rsa-nodelegate-4.4 + tags: + - ocsp-darwinssl + depends_on: + name: debug-compile-nosasl-darwinssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-darwinssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-latest + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-8.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-7.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-6.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-5.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_1-rsa-nodelegate-4.4 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_1-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_1-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_1 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-rsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-rsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-latest + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-8.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-7.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-6.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-5.0 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-winssl-malicious_server_test_2-rsa-nodelegate-4.4 + tags: + - ocsp-winssl + depends_on: + name: debug-compile-nosasl-winssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-winssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=rsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-malicious_server_test_2-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-malicious_server_test_2-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN=MALICIOUS_SERVER_TEST_2 CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-test.sh + patchable: false +- name: ocsp-openssl-cache-rsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-rsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-rsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-rsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-rsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-rsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-rsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=rsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=rsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-ecdsa-nodelegate-latest + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-cache-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl + depends_on: + name: debug-compile-nosasl-openssl + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-latest + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: latest + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-8.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '8.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-7.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '7.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-6.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '6.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-5.0 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '5.0' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: ocsp-openssl-1.0.1-cache-ecdsa-nodelegate-4.4 + tags: + - ocsp-openssl-1.0.1 + depends_on: + name: debug-compile-nosasl-openssl-1.0.1 + commands: + - func: fetch-build + vars: + BUILD_NAME: debug-compile-nosasl-openssl-1.0.1 + - func: fetch-det + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + TEST_COLUMN=TEST_4 CERT_TYPE=ecdsa USE_DELEGATE=OFF .evergreen/scripts/run-ocsp-responder.sh + - func: bootstrap-mongo-orchestration + vars: + MONGODB_VERSION: '4.4' + OCSP: 'on' + ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json + SSL: ssl + TOPOLOGY: server + - command: shell.exec + type: test + params: + working_dir: mongoc + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE=ecdsa .evergreen/scripts/run-ocsp-cache-test.sh + patchable: false +- name: testazurekms-task + commands: + - func: fetch-source + - func: find-cmake-latest + - command: shell.exec + params: + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + echo "Building test-azurekms ... begin" + pushd mongoc + .evergreen/scripts/compile-test-azurekms.sh + popd + echo "Building test-azurekms ... end" + echo "Copying files ... begin" + export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup} + export AZUREKMS_VMNAME=${AZUREKMS_VMNAME} + export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey + DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools + mkdir testazurekms + cp ./mongoc/src/libmongoc/test-azurekms ./mongoc/install/lib/libmongocrypt.* testazurekms + tar czf testazurekms.tgz testazurekms/* + AZUREKMS_SRC="testazurekms.tgz" \ + AZUREKMS_DST="./" \ + $DRIVERS_TOOLS/.evergreen/csfle/azurekms/copy-file.sh + echo "Copying files ... end" + echo "Untarring file ... begin" + AZUREKMS_CMD="tar xf testazurekms.tgz" \ + $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh + echo "Untarring file ... end" + - command: shell.exec + type: test + params: + shell: bash + script: |- + set -o errexit + export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup} + export AZUREKMS_VMNAME=${AZUREKMS_VMNAME} + export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey + DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools + AZUREKMS_CMD="LD_LIBRARY_PATH=./testazurekms MONGODB_URI='mongodb://localhost:27017' KEY_NAME='${testazurekms_keyname}' KEY_VAULT_ENDPOINT='${testazurekms_keyvaultendpoint}' ./testazurekms/test-azurekms" \ + $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh +- name: testazurekms-fail-task + commands: + - func: fetch-source + - func: find-cmake-latest + - command: shell.exec + params: + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + pushd mongoc + .evergreen/scripts/compile-test-azurekms.sh + popd + - command: shell.exec + type: test + params: + shell: bash + script: |- + set -o errexit + LD_LIBRARY_PATH=$PWD/install \ + MONGODB_URI='mongodb://localhost:27017' \ + KEY_NAME='${testazurekms_keyname}' \ + KEY_VAULT_ENDPOINT='${testazurekms_keyvaultendpoint}' \ + EXPECT_ERROR='Error from Azure IMDS server' \ + ./mongoc/src/libmongoc/test-azurekms +- name: testgcpkms-task + commands: + - func: fetch-source + - func: find-cmake-latest + - command: shell.exec + params: + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + echo "Building test-gcpkms ... begin" + pushd mongoc + .evergreen/scripts/compile-test-gcpkms.sh + popd + echo "Building test-gcpkms ... end" + echo "Copying files ... begin" + export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} + export GCPKMS_PROJECT=${GCPKMS_PROJECT} + export GCPKMS_ZONE=${GCPKMS_ZONE} + export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} + DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools + mkdir testgcpkms + cp ./mongoc/src/libmongoc/test-gcpkms ./mongoc/install/lib/libmongocrypt.* testgcpkms + tar czf testgcpkms.tgz testgcpkms/* + GCPKMS_SRC="testgcpkms.tgz" GCPKMS_DST=$GCPKMS_INSTANCENAME: $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/copy-file.sh + echo "Copying files ... end" + echo "Untarring file ... begin" + GCPKMS_CMD="tar xf testgcpkms.tgz" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh + echo "Untarring file ... end" + - command: shell.exec + type: test + params: + shell: bash + script: |- + set -o errexit + export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} + export GCPKMS_PROJECT=${GCPKMS_PROJECT} + export GCPKMS_ZONE=${GCPKMS_ZONE} + export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} + DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools + GCPKMS_CMD="LD_LIBRARY_PATH=./testgcpkms MONGODB_URI='mongodb://localhost:27017' ./testgcpkms/test-gcpkms" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh +- name: testgcpkms-fail-task + commands: + - func: find-cmake-latest + - command: shell.exec + params: + add_expansions_to_env: true + shell: bash + script: |- + set -o errexit + pushd mongoc + .evergreen/scripts/compile-test-gcpkms.sh + popd + - command: shell.exec + type: test + params: + shell: bash + script: |- + set -o errexit + export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} + export GCPKMS_PROJECT=${GCPKMS_PROJECT} + export GCPKMS_ZONE=${GCPKMS_ZONE} + export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} + LD_LIBRARY_PATH=$(pwd)/install MONGODB_URI='mongodb://localhost:27017' EXPECT_ERROR='Failed to connect to: metadata.google.internal' ./mongoc/src/libmongoc/test-gcpkms +task_groups: +- name: testazurekms_task_group + setup_group: + - func: fetch-det + - command: ec2.assume_role + params: + role_arn: ${aws_test_secrets_role} + - command: shell.exec + params: + include_expansions_in_env: + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN + shell: bash + script: |- + set -o errexit + DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools + echo '${testazurekms_publickey}' > /tmp/testazurekms_publickey + echo '${testazurekms_privatekey}' > /tmp/testazurekms_privatekey + # Set 600 permissions on private key file. Otherwise ssh / scp may error with permissions "are too open". + chmod 600 /tmp/testazurekms_privatekey + export AZUREKMS_CLIENTID=${testazurekms_clientid} + export AZUREKMS_TENANTID=${testazurekms_tenantid} + export AZUREKMS_SECRET=${testazurekms_secret} + export AZUREKMS_DRIVERS_TOOLS=$DRIVERS_TOOLS + export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup} + export AZUREKMS_PUBLICKEYPATH=/tmp/testazurekms_publickey + export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey + export AZUREKMS_SCOPE=${testazurekms_scope} + export AZUREKMS_VMNAME_PREFIX=CDRIVER + $DRIVERS_TOOLS/.evergreen/csfle/azurekms/create-and-setup-vm.sh + - command: expansions.update + params: + file: testazurekms-expansions.yml + teardown_group: + - command: expansions.update + params: + file: testazurekms-expansions.yml + - command: shell.exec + params: + shell: bash + script: |- + set -o errexit + DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools + export AZUREKMS_VMNAME=${AZUREKMS_VMNAME} + export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup} + $DRIVERS_TOOLS/.evergreen/csfle/azurekms/delete-vm.sh + setup_group_can_fail_task: true + setup_group_timeout_secs: 1800 + tasks: + - testazurekms-task +- name: testgcpkms_task_group + setup_group: + - func: fetch-det + - command: shell.exec + params: + shell: bash + script: |- + set -o errexit + DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools + echo '${testgcpkms_key_file}' > /tmp/testgcpkms_key_file.json + export GCPKMS_KEYFILE=/tmp/testgcpkms_key_file.json + export GCPKMS_DRIVERS_TOOLS=$DRIVERS_TOOLS + export GCPKMS_SERVICEACCOUNT="${testgcpkms_service_account}" + $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/create-and-setup-instance.sh + - command: expansions.update + params: + file: testgcpkms-expansions.yml + teardown_group: + - command: shell.exec + params: + shell: bash + script: |- + set -o errexit + DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools + export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} + export GCPKMS_PROJECT=${GCPKMS_PROJECT} + export GCPKMS_ZONE=${GCPKMS_ZONE} + export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} + $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/delete-instance.sh + setup_group_can_fail_task: true + setup_group_timeout_secs: 1800 + tasks: + - testgcpkms-task +buildvariants: +- name: abi-compliance-check + display_name: ABI Compliance Check + run_on: + - ubuntu2004-small + - ubuntu2004-medium + - ubuntu2004-large + tasks: + - abi-compliance-check +- name: smoke + display_name: Smoke Tests + expansions: + SKIP_LEGACY_SHELL: '1' + run_on: ubuntu2204-small + tasks: + - make-docs + - kms-divergence-check + - release-compile + - debug-compile-no-counters + - compile-tracing + - link-with-cmake + - link-with-cmake-ssl + - link-with-cmake-snappy + - verify-headers + - name: link-with-cmake-mac + distros: + - macos-14-arm64 + - name: link-with-cmake-windows + distros: + - windows-vsCurrent-large + - name: link-with-cmake-windows-ssl + distros: + - windows-vsCurrent-large + - name: link-with-cmake-windows-snappy + distros: + - windows-vsCurrent-large + - name: link-with-cmake-mingw + distros: + - windows-vsCurrent-large + - name: link-with-pkg-config + distros: + - ubuntu2004-test + - name: link-with-pkg-config-mac + distros: + - macos-14-arm64 + - link-with-pkg-config-ssl + - link-with-bson + - name: link-with-bson-windows + distros: + - windows-vsCurrent-large + - name: link-with-bson-mac + distros: + - macos-14-arm64 + - name: link-with-bson-mingw + distros: + - windows-vsCurrent-large + - check-headers + - debug-compile-with-warnings + - name: build-and-test-with-toolchain + distros: + - debian11-small + - install-libmongoc-after-libbson + tags: + - pr-merge-gate +- name: openssl + display_name: OpenSSL + run_on: archlinux-build + tasks: + - build-and-run-authentication-tests-openssl-1.0.1 + - build-and-run-authentication-tests-openssl-1.0.2 + - build-and-run-authentication-tests-openssl-1.1.0 + - build-and-run-authentication-tests-openssl-1.0.1-fips +- name: clang37 + display_name: clang 3.7 (Archlinux) + expansions: + CC: clang + run_on: archlinux-test + tasks: + - release-compile + - debug-compile-sasl-openssl + - debug-compile-nosasl-openssl + - .authentication-tests .openssl +- name: clang100-i686 + display_name: clang 10.0 (i686) (Ubuntu 20.04) + expansions: + CC: clang + MARCH: i686 + run_on: ubuntu2004-test + tasks: + - release-compile + - debug-compile-nosasl-nossl + - .debug-compile !.sspi .nossl .nosasl + - .latest .nossl .nosasl +- name: gcc82rhel + display_name: GCC 8.2 (RHEL 8.0) + expansions: + CC: gcc + run_on: rhel80-test + tasks: + - .hardened + - .compression !.snappy !.zstd + - release-compile + - debug-compile-nosasl-nossl + - debug-compile-nosasl-openssl + - debug-compile-sasl-openssl + - .authentication-tests .openssl + - .latest .nossl +- name: gcc102 + display_name: GCC 10.2 (Debian 11.0) + expansions: + CC: gcc + run_on: debian11-large + tasks: + - release-compile + - debug-compile-nosasl-nossl + - .latest .nossl +- name: gcc94-i686 + display_name: GCC 9.4 (i686) (Ubuntu 20.04) + expansions: + CC: gcc + MARCH: i686 + run_on: ubuntu2004-test + tasks: + - release-compile + - debug-compile-nosasl-nossl + - .latest .nossl .nosasl +- name: gcc94 + display_name: GCC 9.4 (Ubuntu 20.04) + expansions: + CC: gcc + run_on: ubuntu2004-test + tasks: + - .compression !.zstd + - debug-compile-nosrv + - release-compile + - debug-compile-nosasl-nossl + - debug-compile-sasl-openssl + - debug-compile-nosasl-openssl + - .authentication-tests .openssl + - .authentication-tests .asan + - .test-coverage + - .latest .nossl + - retry-true-latest-server + - test-dns-openssl + - test-dns-auth-openssl + - test-dns-loadbalanced-openssl +- name: darwin + display_name: '*Darwin, macOS (Apple LLVM)' + expansions: + CC: clang + run_on: macos-14-arm64 + tasks: + - .compression !.snappy + - release-compile + - debug-compile-nosasl-nossl + - debug-compile-nosrv + - debug-compile-sasl-darwinssl + - debug-compile-nosasl-nossl + - .authentication-tests .darwinssl + - .latest .nossl + - test-dns-darwinssl + - test-dns-auth-darwinssl + - debug-compile-lto + - debug-compile-lto-thin + - debug-compile-aws + - test-aws-openssl-regular-latest +- name: darwin-intel + display_name: '*Darwin, Intel macOS (Apple LLVM)' + expansions: + CC: clang + run_on: macos-14 + tasks: + - debug-compile-aws + - debug-compile-rdtscp + - test-aws-openssl-regular-4.4 +- name: windows-2017-32 + display_name: Windows (i686) (VS 2017) + expansions: + CC: Visual Studio 15 2017 + run_on: windows-vsCurrent-large + tasks: + - debug-compile-nosasl-nossl + - .latest .nossl .nosasl +- name: windows-2017 + display_name: Windows (VS 2017) + expansions: + CC: Visual Studio 15 2017 Win64 + run_on: windows-vsCurrent-large + tasks: + - release-compile + - debug-compile-nosasl-nossl + - debug-compile-nosasl-openssl + - debug-compile-sspi-winssl + - debug-compile-nosrv + - .latest .nossl + - .nosasl .latest .nossl + - .compression !.snappy !.zstd !.latest + - test-dns-winssl + - test-dns-auth-winssl + - debug-compile-aws + - test-aws-openssl-regular-4.4 + - test-aws-openssl-regular-latest + - .authentication-tests .openssl !.sasl + - .authentication-tests .winssl +- name: mingw-windows2016 + display_name: MinGW-W64 (Windows Server 2016) + expansions: + CC: mingw + run_on: windows-vsCurrent-large + tasks: + - debug-compile-nosasl-nossl + - .latest .nossl .nosasl .server +- name: rhel8-power + display_name: Power (ppc64le) (RHEL 8) + expansions: + CC: gcc + run_on: rhel8-power-large + tasks: + - release-compile + - debug-compile-nosasl-nossl + - debug-compile-sasl-openssl + - .latest .nossl + - test-dns-openssl + patchable: false + batchtime: 1440 +- name: arm-ubuntu2004 + display_name: '*ARM (aarch64) (Ubuntu 20.04)' + expansions: + CC: gcc + run_on: ubuntu2004-arm64-large + tasks: + - .compression !.snappy !.zstd + - release-compile + - debug-compile-nosasl-nossl + - debug-compile-nosasl-openssl + - debug-compile-sasl-openssl + - .authentication-tests .openssl + - .latest .nossl + - test-dns-openssl + batchtime: 1440 +- name: zseries-rhel8 + display_name: '*zSeries' + expansions: + CC: gcc + run_on: rhel8-zseries-large + tasks: + - release-compile + - debug-compile-nosasl-nossl + - debug-compile-nosasl-openssl + - debug-compile-sasl-openssl + - .authentication-tests .openssl + - .latest .nossl + patchable: false + batchtime: 1440 +- name: clang100ubuntu + display_name: clang 10.0 (Ubuntu 20.04) + expansions: + CC: clang + run_on: ubuntu2004-test + tasks: + - debug-compile-sasl-openssl-static + - .authentication-tests .asan +- name: aws-ubuntu2004 + display_name: AWS Tests (Ubuntu 20.04) + expansions: + CC: clang + run_on: ubuntu2004-small + tasks: + - debug-compile-aws + - .test-aws .4.4 + - .test-aws .5.0 +- name: aws-ubuntu2204 + display_name: AWS Tests (Ubuntu 22.04) + expansions: + CC: clang + run_on: ubuntu2004-small + tasks: + - debug-compile-aws + - .test-aws .6.0 + - .test-aws .7.0 + - .test-aws .8.0 + - .test-aws .latest +- name: mongohouse + display_name: Mongohouse Test + run_on: ubuntu2204-small + tasks: + - debug-compile-sasl-openssl + - test-mongohouse +- name: ocsp + display_name: OCSP tests + run_on: ubuntu2004-small + tasks: + - name: debug-compile-nosasl-openssl + - name: debug-compile-nosasl-openssl-static + - name: debug-compile-nosasl-darwinssl + distros: + - macos-14-arm64 + - name: debug-compile-nosasl-winssl + distros: + - windows-vsCurrent-large + - name: .ocsp-openssl + - name: .ocsp-darwinssl + distros: + - macos-14-arm64 + - name: .ocsp-winssl + distros: + - windows-vsCurrent-large + - name: debug-compile-nosasl-openssl-1.0.1 + - name: .ocsp-openssl-1.0.1 + batchtime: 10080 + display_tasks: + - execution_tasks: + - .ocsp-openssl + name: ocsp-openssl + - execution_tasks: + - .ocsp-darwinssl + name: ocsp-darwinssl + - execution_tasks: + - .ocsp-winssl + name: ocsp-winssl + - execution_tasks: + - .ocsp-openssl-1.0.1 + name: ocsp-openssl-1.0.1 +- name: packaging + display_name: Linux Distro Packaging + run_on: debian12-latest-small + tasks: + - debian-package-build + - name: rpm-package-build + distros: + - rhel90-arm64-small + tags: + - pr-merge-gate +- name: versioned-api-ubuntu2004 + display_name: Versioned API Tests (Ubuntu 20.04) + run_on: ubuntu2004-test + tasks: + - debug-compile-nosasl-openssl + - debug-compile-nosasl-nossl + - .versioned-api .5.0 + - .versioned-api .6.0 + - .versioned-api .7.0 + - .versioned-api .8.0 +- name: testazurekms-variant + display_name: Azure KMS + run_on: debian11-small + tasks: + - testazurekms_task_group + - testazurekms-fail-task + batchtime: 20160 +- name: testgcpkms-variant + display_name: GCP KMS + run_on: debian11-small + tasks: + - testgcpkms_task_group + - testgcpkms-fail-task + batchtime: 20160 diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/task_groups.yml b/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/task_groups.yml similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/generated_configs/task_groups.yml rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/task_groups.yml diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/tasks.yml b/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/tasks.yml new file mode 100644 index 000000000..407eed823 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/tasks.yml @@ -0,0 +1,6795 @@ +tasks: + - name: abi-compliance-check + commands: + - func: abi-compliance-check + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, compile, rhel8-latest, clang, cse, asan, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-4.2-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "4.2", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-4.2-replica-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "4.2", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-4.2-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "4.2", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-4.2-server-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "4.2", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-4.4-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "4.4", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-4.4-replica-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "4.4", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-4.4-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "4.4", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-4.4-server-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "4.4", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-5.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "5.0", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-5.0-replica-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "5.0", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-5.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "5.0", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-5.0-server-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "5.0", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-6.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "6.0", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-6.0-replica-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "6.0", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-6.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "6.0", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-6.0-server-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "6.0", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-7.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "7.0", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-7.0-replica-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "7.0", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-7.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "7.0", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-7.0-server-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "7.0", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-8.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "8.0", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-8.0-replica-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, "8.0", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-8.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "8.0", openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-8.0-server-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, "8.0", with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-latest-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, latest, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-latest-replica-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, replica, latest, with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-latest-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, latest, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-test-latest-server-auth-with-mongocrypt + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, cse, asan, auth, server, latest, with-mongocrypt, openssl] + depends_on: [{ name: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-cse-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - { key: CLIENT_SIDE_ENCRYPTION, value: "on" } + - { key: SKIP_CRYPT_SHARED_LIB, value: "on" } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-mock-kms-servers + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, compile, rhel8-latest, clang, asan, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.2-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, replica, "4.2", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.2-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, server, "4.2", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.2-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, sharded, "4.2", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.4-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, replica, "4.4", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.4-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, server, "4.4", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.4-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, sharded, "4.4", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-5.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, replica, "5.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-5.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, server, "5.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-5.0-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, sharded, "5.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-6.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, replica, "6.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-6.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, server, "6.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-6.0-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, sharded, "6.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-7.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, replica, "7.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-7.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, server, "7.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-7.0-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, sharded, "7.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-8.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, replica, "8.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-8.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, server, "8.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-8.0-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, sharded, "8.0", openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-latest-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, replica, latest, openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-latest-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, server, latest, openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: asan-sasl-cyrus-openssl-rhel8-latest-clang-test-latest-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-asan, test, rhel8-latest, clang, sasl-cyrus, asan, auth, sharded, latest, openssl] + depends_on: [{ name: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: asan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: check-headers + commands: + - func: check-headers + - name: "check:sasl=Cyrus\_\u2022\_tls=OpenSSL\_\u2022\_test_mongocxx_ref=master" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=Cyrus + - --tls=OpenSSL + - --test_mongocxx_ref=master + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example test-cxx-driver + - --sasl=Cyrus + - --tls=OpenSSL + - --test_mongocxx_ref=master + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=Cyrus\_\u2022\_tls=OpenSSL\_\u2022\_test_mongocxx_ref=none" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, centos7-clang, centos7-gcc, u16-clang, u16-gcc, u18-clang, u18-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=Cyrus + - --tls=OpenSSL + - --test_mongocxx_ref=none + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example + - --sasl=Cyrus + - --tls=OpenSSL + - --test_mongocxx_ref=none + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=Cyrus\_\u2022\_tls=OpenSSL\_\u2022\_test_mongocxx_ref=r4.1.0" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=Cyrus + - --tls=OpenSSL + - --test_mongocxx_ref=r4.1.0 + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example test-cxx-driver + - --sasl=Cyrus + - --tls=OpenSSL + - --test_mongocxx_ref=r4.1.0 + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=Cyrus\_\u2022\_tls=off\_\u2022\_test_mongocxx_ref=master" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=Cyrus + - --tls=off + - --test_mongocxx_ref=master + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example test-cxx-driver + - --sasl=Cyrus + - --tls=off + - --test_mongocxx_ref=master + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=Cyrus\_\u2022\_tls=off\_\u2022\_test_mongocxx_ref=none" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, centos7-clang, centos7-gcc, u16-clang, u16-gcc, u18-clang, u18-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=Cyrus + - --tls=off + - --test_mongocxx_ref=none + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example + - --sasl=Cyrus + - --tls=off + - --test_mongocxx_ref=none + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=Cyrus\_\u2022\_tls=off\_\u2022\_test_mongocxx_ref=r4.1.0" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=Cyrus + - --tls=off + - --test_mongocxx_ref=r4.1.0 + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example test-cxx-driver + - --sasl=Cyrus + - --tls=off + - --test_mongocxx_ref=r4.1.0 + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=off\_\u2022\_tls=OpenSSL\_\u2022\_test_mongocxx_ref=master" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=off + - --tls=OpenSSL + - --test_mongocxx_ref=master + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example test-cxx-driver + - --sasl=off + - --tls=OpenSSL + - --test_mongocxx_ref=master + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=off\_\u2022\_tls=OpenSSL\_\u2022\_test_mongocxx_ref=none" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, centos7-clang, centos7-gcc, u16-clang, u16-gcc, u18-clang, u18-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=off + - --tls=OpenSSL + - --test_mongocxx_ref=none + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example + - --sasl=off + - --tls=OpenSSL + - --test_mongocxx_ref=none + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=off\_\u2022\_tls=OpenSSL\_\u2022\_test_mongocxx_ref=r4.1.0" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=off + - --tls=OpenSSL + - --test_mongocxx_ref=r4.1.0 + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example test-cxx-driver + - --sasl=off + - --tls=OpenSSL + - --test_mongocxx_ref=r4.1.0 + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=off\_\u2022\_tls=off\_\u2022\_test_mongocxx_ref=master" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=off + - --tls=off + - --test_mongocxx_ref=master + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example test-cxx-driver + - --sasl=off + - --tls=off + - --test_mongocxx_ref=master + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=off\_\u2022\_tls=off\_\u2022\_test_mongocxx_ref=none" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, centos7-clang, centos7-gcc, u16-clang, u16-gcc, u18-clang, u18-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=off + - --tls=off + - --test_mongocxx_ref=none + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example + - --sasl=off + - --tls=off + - --test_mongocxx_ref=none + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: "check:sasl=off\_\u2022\_tls=off\_\u2022\_test_mongocxx_ref=r4.1.0" + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: setup + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +env-warmup + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --sasl=off + - --tls=off + - --test_mongocxx_ref=r4.1.0 + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +run + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub + - --targets=test-example test-cxx-driver + - --sasl=off + - --tls=off + - --test_mongocxx_ref=r4.1.0 + - --env=${MONGOC_EARTHLY_ENV} + - --c_compiler=${MONGOC_EARTHLY_C_COMPILER} + - name: clang-format + tags: [clang-format] + commands: + - func: clang-format + - name: cse-sasl-cyrus-darwinssl-macos-11-arm64-clang-compile + run_on: macos-11-arm64 + tags: [cse-matrix-darwinssl, compile, macos-11-arm64, clang, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-darwinssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: cse-sasl-cyrus-darwinssl-macos-11-arm64-clang-test-6.0-server-auth + run_on: macos-11-arm64 + tags: [cse-matrix-darwinssl, test, macos-11-arm64, clang, sasl-cyrus, cse, auth, server, "6.0", darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-11-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-11-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + run_on: macos-14-arm64 + tags: [cse-matrix-darwinssl, compile, macos-14-arm64, clang, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-darwinssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-test-6.0-server-auth + run_on: macos-14-arm64 + tags: [cse-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, cse, auth, server, "6.0", darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-test-7.0-replica-auth + run_on: macos-14-arm64 + tags: [cse-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, cse, auth, replica, "7.0", darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-test-7.0-server-auth + run_on: macos-14-arm64 + tags: [cse-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, cse, auth, server, "7.0", darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-test-8.0-replica-auth + run_on: macos-14-arm64 + tags: [cse-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, cse, auth, replica, "8.0", darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-test-8.0-server-auth + run_on: macos-14-arm64 + tags: [cse-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, cse, auth, server, "8.0", darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-test-latest-replica-auth + run_on: macos-14-arm64 + tags: [cse-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, cse, auth, replica, latest, darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-test-latest-server-auth + run_on: macos-14-arm64 + tags: [cse-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, cse, auth, server, latest, darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-darwinssl-macos-14-clang-compile + run_on: macos-14 + tags: [cse-matrix-darwinssl, compile, macos-14, clang, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-darwinssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: cse-sasl-cyrus-darwinssl-macos-14-clang-test-4.2-server-auth + run_on: macos-14 + tags: [cse-matrix-darwinssl, test, macos-14, clang, sasl-cyrus, cse, auth, server, "4.2", darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-14-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-14-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-darwinssl-macos-14-clang-test-4.4-server-auth + run_on: macos-14 + tags: [cse-matrix-darwinssl, test, macos-14, clang, sasl-cyrus, cse, auth, server, "4.4", darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-14-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-14-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-darwinssl-macos-14-clang-test-5.0-server-auth + run_on: macos-14 + tags: [cse-matrix-darwinssl, test, macos-14, clang, sasl-cyrus, cse, auth, server, "5.0", darwinssl] + depends_on: [{ name: cse-sasl-cyrus-darwinssl-macos-14-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-darwinssl-macos-14-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-debian11-clang-compile + run_on: debian11-large + tags: [cse-matrix-openssl, compile, debian11, clang, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-debian11-gcc-compile + run_on: debian11-large + tags: [cse-matrix-openssl, compile, debian11, gcc, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-debian12-clang-compile + run_on: debian12-large + tags: [cse-matrix-openssl, compile, debian12, clang, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-debian12-gcc-compile + run_on: debian12-large + tags: [cse-matrix-openssl, compile, debian12, gcc, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, compile, rhel8-latest, gcc, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-4.2-replica-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, replica, "4.2", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-4.2-server-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, server, "4.2", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-4.4-replica-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, replica, "4.4", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-4.4-server-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, server, "4.4", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-5.0-replica-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, replica, "5.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-5.0-server-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, server, "5.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-6.0-replica-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, replica, "6.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-6.0-server-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, server, "6.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-7.0-replica-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, replica, "7.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-7.0-server-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, server, "7.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-8.0-replica-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, replica, "8.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-8.0-server-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, server, "8.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-latest-replica-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, replica, latest, openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-latest-server-auth + run_on: rhel8-latest-large + tags: [cse-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, cse, auth, server, latest, openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + run_on: rhel8-zseries-large + tags: [cse-matrix-openssl, compile, rhel8-zseries, gcc, cse, sasl-cyrus] + patchable: false + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-5.0-replica-auth + run_on: rhel8-zseries-small + tags: [cse-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, cse, auth, replica, "5.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-5.0-server-auth + run_on: rhel8-zseries-small + tags: [cse-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, cse, auth, server, "5.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-6.0-replica-auth + run_on: rhel8-zseries-small + tags: [cse-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, cse, auth, replica, "6.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-6.0-server-auth + run_on: rhel8-zseries-small + tags: [cse-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, cse, auth, server, "6.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-7.0-replica-auth + run_on: rhel8-zseries-small + tags: [cse-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, cse, auth, replica, "7.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-7.0-server-auth + run_on: rhel8-zseries-small + tags: [cse-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, cse, auth, server, "7.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-8.0-replica-auth + run_on: rhel8-zseries-small + tags: [cse-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, cse, auth, replica, "8.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-8.0-server-auth + run_on: rhel8-zseries-small + tags: [cse-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, cse, auth, server, "8.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-latest-replica-auth + run_on: rhel8-zseries-small + tags: [cse-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, cse, auth, replica, latest, openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-latest-server-auth + run_on: rhel8-zseries-small + tags: [cse-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, cse, auth, server, latest, openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-rhel80-gcc-compile + run_on: rhel80-large + tags: [cse-matrix-openssl, compile, rhel80, gcc, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + run_on: ubuntu2004-arm64-large + tags: [cse-matrix-openssl, compile, ubuntu2004-arm64, gcc, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-4.4-replica-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, replica, "4.4", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-4.4-server-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, server, "4.4", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-5.0-replica-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, replica, "5.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-5.0-server-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, server, "5.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-6.0-replica-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, replica, "6.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-6.0-server-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, server, "6.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-7.0-replica-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, replica, "7.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-7.0-server-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, server, "7.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-8.0-replica-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, replica, "8.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-8.0-server-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, server, "8.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-latest-replica-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, replica, latest, openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-latest-server-auth + run_on: ubuntu2004-arm64-small + tags: [cse-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, cse, auth, server, latest, openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-ubuntu2004-clang-compile + run_on: ubuntu2004-large + tags: [cse-matrix-openssl, compile, ubuntu2004, clang, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile + run_on: ubuntu2004-large + tags: [cse-matrix-openssl, compile, ubuntu2004, gcc, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-ubuntu2204-clang-12-compile + run_on: ubuntu2204-large + tags: [cse-matrix-openssl, compile, ubuntu2204, clang-12, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: clang-12 + CXX: clang++-12 + - func: upload-build + - name: cse-sasl-cyrus-openssl-ubuntu2204-gcc-compile + run_on: ubuntu2204-large + tags: [cse-matrix-openssl, compile, ubuntu2204, gcc, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-ubuntu2404-clang-14-compile + run_on: ubuntu2404-large + tags: [cse-matrix-openssl, compile, ubuntu2404, clang-14, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: clang-14 + CXX: clang++-14 + - func: upload-build + - name: cse-sasl-cyrus-openssl-ubuntu2404-gcc-compile + run_on: ubuntu2404-large + tags: [cse-matrix-openssl, compile, ubuntu2404, gcc, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + run_on: windows-vsCurrent-large + tags: [cse-matrix-openssl, compile, windows-vsCurrent, vs2017x64, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-openssl-compile + vars: + CMAKE_GENERATOR: Visual Studio 15 2017 + CMAKE_GENERATOR_PLATFORM: x64 + - func: upload-build + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-4.2-replica-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, "4.2", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-4.2-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "4.2", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-4.4-replica-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, "4.4", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-4.4-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "4.4", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-5.0-replica-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, "5.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-5.0-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "5.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-6.0-replica-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, "6.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-6.0-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "6.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-7.0-replica-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, "7.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-7.0-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "7.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-8.0-replica-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, "8.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-8.0-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "8.0", openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-latest-replica-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, latest, openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-latest-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, latest, openssl] + depends_on: [{ name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + run_on: windows-vsCurrent-large + tags: [cse-matrix-winssl, compile, windows-vsCurrent, vs2017x64, cse, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: cse-sasl-cyrus-winssl-compile + vars: + CMAKE_GENERATOR: Visual Studio 15 2017 + CMAKE_GENERATOR_PLATFORM: x64 + - func: upload-build + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-4.2-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "4.2", winssl] + depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-4.4-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "4.4", winssl] + depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-5.0-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "5.0", winssl] + depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-6.0-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "6.0", winssl] + depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-7.0-replica-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, "7.0", winssl] + depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-7.0-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "7.0", winssl] + depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-8.0-replica-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, "8.0", winssl] + depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-8.0-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, "8.0", winssl] + depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-latest-replica-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, replica, latest, winssl] + depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-test-latest-server-auth + run_on: windows-vsCurrent-small + tags: [cse-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, cse, auth, server, latest, winssl] + depends_on: [{ name: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-mock-kms-servers + - func: run-tests + - name: kms-divergence-check + commands: + - func: kms-divergence-check + - name: loadbalanced-rhel8-latest-gcc-compile + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc] + commands: + - func: find-cmake-latest + - command: subprocess.exec + type: test + params: + binary: bash + working_dir: mongoc + env: + CC: gcc + CFLAGS: -fno-omit-frame-pointer + SSL: OPENSSL + args: + - -c + - .evergreen/scripts/compile.sh + - func: upload-build + - name: loadbalanced-rhel8-latest-gcc-test-5.0-auth-openssl + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc, auth, openssl] + depends_on: [{ name: loadbalanced-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: loadbalanced-rhel8-latest-gcc-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + LOAD_BALANCER: "on" + MONGODB_VERSION: "5.0" + SSL: openssl + TOPOLOGY: sharded_cluster + - func: run-simple-http-server + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: auth + CC: gcc + LOADBALANCED: loadbalanced + SSL: openssl + - name: loadbalanced-rhel8-latest-gcc-test-5.0-noauth-nossl + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc, noauth, nossl] + depends_on: [{ name: loadbalanced-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: loadbalanced-rhel8-latest-gcc-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + LOAD_BALANCER: "on" + MONGODB_VERSION: "5.0" + SSL: nossl + TOPOLOGY: sharded_cluster + - func: run-simple-http-server + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: noauth + CC: gcc + LOADBALANCED: loadbalanced + SSL: nossl + - name: loadbalanced-rhel8-latest-gcc-test-6.0-auth-openssl + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc, auth, openssl] + depends_on: [{ name: loadbalanced-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: loadbalanced-rhel8-latest-gcc-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + LOAD_BALANCER: "on" + MONGODB_VERSION: "6.0" + SSL: openssl + TOPOLOGY: sharded_cluster + - func: run-simple-http-server + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: auth + CC: gcc + LOADBALANCED: loadbalanced + SSL: openssl + - name: loadbalanced-rhel8-latest-gcc-test-6.0-noauth-nossl + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc, noauth, nossl] + depends_on: [{ name: loadbalanced-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: loadbalanced-rhel8-latest-gcc-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + LOAD_BALANCER: "on" + MONGODB_VERSION: "6.0" + SSL: nossl + TOPOLOGY: sharded_cluster + - func: run-simple-http-server + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: noauth + CC: gcc + LOADBALANCED: loadbalanced + SSL: nossl + - name: loadbalanced-rhel8-latest-gcc-test-7.0-auth-openssl + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc, auth, openssl] + depends_on: [{ name: loadbalanced-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: loadbalanced-rhel8-latest-gcc-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + LOAD_BALANCER: "on" + MONGODB_VERSION: "7.0" + SSL: openssl + TOPOLOGY: sharded_cluster + - func: run-simple-http-server + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: auth + CC: gcc + LOADBALANCED: loadbalanced + SSL: openssl + - name: loadbalanced-rhel8-latest-gcc-test-7.0-noauth-nossl + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc, noauth, nossl] + depends_on: [{ name: loadbalanced-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: loadbalanced-rhel8-latest-gcc-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + LOAD_BALANCER: "on" + MONGODB_VERSION: "7.0" + SSL: nossl + TOPOLOGY: sharded_cluster + - func: run-simple-http-server + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: noauth + CC: gcc + LOADBALANCED: loadbalanced + SSL: nossl + - name: loadbalanced-rhel8-latest-gcc-test-8.0-auth-openssl + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc, auth, openssl] + depends_on: [{ name: loadbalanced-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: loadbalanced-rhel8-latest-gcc-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + LOAD_BALANCER: "on" + MONGODB_VERSION: "8.0" + SSL: openssl + TOPOLOGY: sharded_cluster + - func: run-simple-http-server + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: auth + CC: gcc + LOADBALANCED: loadbalanced + SSL: openssl + - name: loadbalanced-rhel8-latest-gcc-test-8.0-noauth-nossl + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc, noauth, nossl] + depends_on: [{ name: loadbalanced-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: loadbalanced-rhel8-latest-gcc-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + LOAD_BALANCER: "on" + MONGODB_VERSION: "8.0" + SSL: nossl + TOPOLOGY: sharded_cluster + - func: run-simple-http-server + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: noauth + CC: gcc + LOADBALANCED: loadbalanced + SSL: nossl + - name: loadbalanced-rhel8-latest-gcc-test-latest-auth-openssl + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc, auth, openssl] + depends_on: [{ name: loadbalanced-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: loadbalanced-rhel8-latest-gcc-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: auth + LOAD_BALANCER: "on" + MONGODB_VERSION: latest + SSL: openssl + TOPOLOGY: sharded_cluster + - func: run-simple-http-server + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: auth + CC: gcc + LOADBALANCED: loadbalanced + SSL: openssl + - name: loadbalanced-rhel8-latest-gcc-test-latest-noauth-nossl + run_on: rhel8-latest-large + tags: [loadbalanced, rhel8-latest, gcc, noauth, nossl] + depends_on: [{ name: loadbalanced-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: loadbalanced-rhel8-latest-gcc-compile + - func: fetch-det + - func: bootstrap-mongo-orchestration + vars: + AUTH: noauth + LOAD_BALANCER: "on" + MONGODB_VERSION: latest + SSL: nossl + TOPOLOGY: sharded_cluster + - func: run-simple-http-server + - func: start-load-balancer + vars: + MONGODB_URI: mongodb://localhost:27017,localhost:27018 + - func: run-tests + vars: + AUTH: noauth + CC: gcc + LOADBALANCED: loadbalanced + SSL: nossl + - name: make-docs + commands: + - func: find-cmake-latest + - func: make-docs + - func: upload-docs + - func: upload-man-pages + - name: mock-server-test + run_on: ubuntu2204-small + commands: + - func: fetch-det + - func: run-simple-http-server + - func: find-cmake-latest + - command: subprocess.exec + type: test + params: + binary: bash + working_dir: mongoc + add_expansions_to_env: true + args: + - -c + - .evergreen/scripts/compile.sh + - command: subprocess.exec + type: test + params: + binary: bash + working_dir: mongoc + args: + - -c + - .evergreen/scripts/run-mock-server-tests.sh + - name: openssl-static-compile-debian11-gcc + run_on: debian11-large + tags: [openssl-static-matrix, debian11, gcc] + commands: + - func: find-cmake-latest + - func: openssl-static-compile + vars: + CC: gcc + CXX: g++ + - name: openssl-static-compile-debian12-gcc + run_on: debian12-large + tags: [openssl-static-matrix, debian12, gcc] + commands: + - func: find-cmake-latest + - func: openssl-static-compile + vars: + CC: gcc + CXX: g++ + - name: openssl-static-compile-ubuntu2004-gcc + run_on: ubuntu2004-large + tags: [openssl-static-matrix, ubuntu2004, gcc] + commands: + - func: find-cmake-latest + - func: openssl-static-compile + vars: + CC: gcc + CXX: g++ + - name: openssl-static-compile-ubuntu2204-gcc + run_on: ubuntu2204-large + tags: [openssl-static-matrix, ubuntu2204, gcc] + commands: + - func: find-cmake-latest + - func: openssl-static-compile + vars: + CC: gcc + CXX: g++ + - name: openssl-static-compile-ubuntu2404-gcc + run_on: ubuntu2404-large + tags: [openssl-static-matrix, ubuntu2404, gcc] + commands: + - func: find-cmake-latest + - func: openssl-static-compile + vars: + CC: gcc + CXX: g++ + - name: sasl-cyrus-darwinssl-macos-11-arm64-clang-compile + run_on: macos-11-arm64 + tags: [sasl-matrix-darwinssl, compile, macos-11-arm64, clang, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-darwinssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: sasl-cyrus-darwinssl-macos-11-arm64-clang-test-6.0-server-auth + run_on: macos-11-arm64 + tags: [sasl-matrix-darwinssl, test, macos-11-arm64, clang, sasl-cyrus, auth, server, "6.0", darwinssl] + depends_on: [{ name: sasl-cyrus-darwinssl-macos-11-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-darwinssl-macos-11-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-darwinssl-macos-11-arm64-clang-test-7.0-server-auth + run_on: macos-11-arm64 + tags: [sasl-matrix-darwinssl, test, macos-11-arm64, clang, sasl-cyrus, auth, server, "7.0", darwinssl] + depends_on: [{ name: sasl-cyrus-darwinssl-macos-11-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-darwinssl-macos-11-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + run_on: macos-14-arm64 + tags: [sasl-matrix-darwinssl, compile, macos-14-arm64, clang, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-darwinssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: sasl-cyrus-darwinssl-macos-14-arm64-clang-test-6.0-server-auth + run_on: macos-14-arm64 + tags: [sasl-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, auth, server, "6.0", darwinssl] + depends_on: [{ name: sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-darwinssl-macos-14-arm64-clang-test-7.0-server-auth + run_on: macos-14-arm64 + tags: [sasl-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, auth, server, "7.0", darwinssl] + depends_on: [{ name: sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-darwinssl-macos-14-arm64-clang-test-8.0-server-auth + run_on: macos-14-arm64 + tags: [sasl-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, auth, server, "8.0", darwinssl] + depends_on: [{ name: sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-darwinssl-macos-14-arm64-clang-test-latest-server-auth + run_on: macos-14-arm64 + tags: [sasl-matrix-darwinssl, test, macos-14-arm64, clang, sasl-cyrus, auth, server, latest, darwinssl] + depends_on: [{ name: sasl-cyrus-darwinssl-macos-14-arm64-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-darwinssl-macos-14-arm64-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-darwinssl-macos-14-clang-compile + run_on: macos-14 + tags: [sasl-matrix-darwinssl, compile, macos-14, clang, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-darwinssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: sasl-cyrus-darwinssl-macos-14-clang-test-4.2-server-auth + run_on: macos-14 + tags: [sasl-matrix-darwinssl, test, macos-14, clang, sasl-cyrus, auth, server, "4.2", darwinssl] + depends_on: [{ name: sasl-cyrus-darwinssl-macos-14-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-darwinssl-macos-14-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-darwinssl-macos-14-clang-test-4.4-server-auth + run_on: macos-14 + tags: [sasl-matrix-darwinssl, test, macos-14, clang, sasl-cyrus, auth, server, "4.4", darwinssl] + depends_on: [{ name: sasl-cyrus-darwinssl-macos-14-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-darwinssl-macos-14-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-darwinssl-macos-14-clang-test-5.0-server-auth + run_on: macos-14 + tags: [sasl-matrix-darwinssl, test, macos-14, clang, sasl-cyrus, auth, server, "5.0", darwinssl] + depends_on: [{ name: sasl-cyrus-darwinssl-macos-14-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-darwinssl-macos-14-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: darwinssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-compile + run_on: amazon2023-arm64-latest-large-m8g + tags: [sasl-matrix-openssl, compile, amazon2023-arm64-latest-large-m8g, gcc, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-test-latest-replica-auth + run_on: amazon2023-arm64-latest-large-m8g + tags: [sasl-matrix-openssl, test, amazon2023-arm64-latest-large-m8g, gcc, sasl-cyrus, auth, replica, latest, openssl] + depends_on: [{ name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-test-latest-server-auth + run_on: amazon2023-arm64-latest-large-m8g + tags: [sasl-matrix-openssl, test, amazon2023-arm64-latest-large-m8g, gcc, sasl-cyrus, auth, server, latest, openssl] + depends_on: [{ name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-test-latest-sharded-auth + run_on: amazon2023-arm64-latest-large-m8g + tags: [sasl-matrix-openssl, test, amazon2023-arm64-latest-large-m8g, gcc, sasl-cyrus, auth, sharded, latest, openssl] + depends_on: [{ name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-debian11-gcc-compile + run_on: debian11-large + tags: [sasl-matrix-openssl, compile, debian11, gcc, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-cyrus-openssl-debian12-gcc-compile + run_on: debian12-large + tags: [sasl-matrix-openssl, compile, debian12, gcc, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-cyrus-openssl-rhel8-latest-gcc-compile + run_on: rhel8-latest-large + tags: [sasl-matrix-openssl, compile, rhel8-latest, gcc, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-4.2-server-auth + run_on: rhel8-latest-large + tags: [sasl-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, auth, server, "4.2", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-4.4-server-auth + run_on: rhel8-latest-large + tags: [sasl-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, auth, server, "4.4", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-5.0-server-auth + run_on: rhel8-latest-large + tags: [sasl-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, auth, server, "5.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-6.0-server-auth + run_on: rhel8-latest-large + tags: [sasl-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, auth, server, "6.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-7.0-server-auth + run_on: rhel8-latest-large + tags: [sasl-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, auth, server, "7.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-8.0-server-auth + run_on: rhel8-latest-large + tags: [sasl-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, auth, server, "8.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-latest-server-auth + run_on: rhel8-latest-large + tags: [sasl-matrix-openssl, test, rhel8-latest, gcc, sasl-cyrus, auth, server, latest, openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-power-gcc-compile + run_on: rhel8-power-large + tags: [sasl-matrix-openssl, compile, rhel8-power, gcc, sasl-cyrus] + patchable: false + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-4.2-server-auth + run_on: rhel8-power-small + tags: [sasl-matrix-openssl, test, rhel8-power, gcc, sasl-cyrus, auth, server, "4.2", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-power-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-power-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-4.4-server-auth + run_on: rhel8-power-small + tags: [sasl-matrix-openssl, test, rhel8-power, gcc, sasl-cyrus, auth, server, "4.4", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-power-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-power-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-5.0-server-auth + run_on: rhel8-power-small + tags: [sasl-matrix-openssl, test, rhel8-power, gcc, sasl-cyrus, auth, server, "5.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-power-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-power-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-6.0-server-auth + run_on: rhel8-power-small + tags: [sasl-matrix-openssl, test, rhel8-power, gcc, sasl-cyrus, auth, server, "6.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-power-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-power-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-7.0-server-auth + run_on: rhel8-power-small + tags: [sasl-matrix-openssl, test, rhel8-power, gcc, sasl-cyrus, auth, server, "7.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-power-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-power-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-8.0-server-auth + run_on: rhel8-power-small + tags: [sasl-matrix-openssl, test, rhel8-power, gcc, sasl-cyrus, auth, server, "8.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-power-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-power-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-latest-server-auth + run_on: rhel8-power-small + tags: [sasl-matrix-openssl, test, rhel8-power, gcc, sasl-cyrus, auth, server, latest, openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-power-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-power-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-compile + run_on: rhel8-zseries-large + tags: [sasl-matrix-openssl, compile, rhel8-zseries, gcc, sasl-cyrus] + patchable: false + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-test-5.0-server-auth + run_on: rhel8-zseries-small + tags: [sasl-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, auth, server, "5.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-test-6.0-server-auth + run_on: rhel8-zseries-small + tags: [sasl-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, auth, server, "6.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-test-7.0-server-auth + run_on: rhel8-zseries-small + tags: [sasl-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, auth, server, "7.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-test-8.0-server-auth + run_on: rhel8-zseries-small + tags: [sasl-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, auth, server, "8.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-test-latest-server-auth + run_on: rhel8-zseries-small + tags: [sasl-matrix-openssl, test, rhel8-zseries, gcc, sasl-cyrus, auth, server, latest, openssl] + depends_on: [{ name: sasl-cyrus-openssl-rhel8-zseries-gcc-compile }] + patchable: false + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-rhel8-zseries-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-rhel80-gcc-compile + run_on: rhel80-large + tags: [sasl-matrix-openssl, compile, rhel80, gcc, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + run_on: ubuntu2004-arm64-large + tags: [sasl-matrix-openssl, compile, ubuntu2004-arm64, gcc, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-4.4-server-auth + run_on: ubuntu2004-arm64-small + tags: [sasl-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, auth, server, "4.4", openssl] + depends_on: [{ name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-5.0-server-auth + run_on: ubuntu2004-arm64-small + tags: [sasl-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, auth, server, "5.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-6.0-server-auth + run_on: ubuntu2004-arm64-small + tags: [sasl-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, auth, server, "6.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-7.0-server-auth + run_on: ubuntu2004-arm64-small + tags: [sasl-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, auth, server, "7.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-8.0-server-auth + run_on: ubuntu2004-arm64-small + tags: [sasl-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, auth, server, "8.0", openssl] + depends_on: [{ name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-latest-server-auth + run_on: ubuntu2004-arm64-small + tags: [sasl-matrix-openssl, test, ubuntu2004-arm64, gcc, sasl-cyrus, auth, server, latest, openssl] + depends_on: [{ name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-cyrus-openssl-ubuntu2004-clang-compile + run_on: ubuntu2004-large + tags: [sasl-matrix-openssl, compile, ubuntu2004, clang, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: sasl-cyrus-openssl-ubuntu2204-clang-12-compile + run_on: ubuntu2204-large + tags: [sasl-matrix-openssl, compile, ubuntu2204, clang-12, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: clang-12 + CXX: clang++-12 + - func: upload-build + - name: sasl-cyrus-openssl-ubuntu2204-gcc-compile + run_on: ubuntu2204-large + tags: [sasl-matrix-openssl, compile, ubuntu2204, gcc, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-cyrus-openssl-ubuntu2404-clang-14-compile + run_on: ubuntu2404-large + tags: [sasl-matrix-openssl, compile, ubuntu2404, clang-14, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: clang-14 + CXX: clang++-14 + - func: upload-build + - name: sasl-cyrus-openssl-ubuntu2404-gcc-compile + run_on: ubuntu2404-large + tags: [sasl-matrix-openssl, compile, ubuntu2404, gcc, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + run_on: windows-vsCurrent-large + tags: [sasl-matrix-openssl, compile, windows-vsCurrent, vs2017x64, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CMAKE_GENERATOR: Visual Studio 15 2017 + CMAKE_GENERATOR_PLATFORM: x64 + - func: upload-build + - name: sasl-cyrus-openssl-windows-2019-vs2017-x64-test-latest-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-openssl, test, windows-vsCurrent, vs2017x64, sasl-cyrus, auth, server, latest, openssl] + depends_on: [{ name: sasl-cyrus-openssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-compile + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, compile, rhel8-latest, gcc, sasl-off] + commands: + - func: find-cmake-latest + - func: sasl-off-nossl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-off-nossl-rhel8-latest-gcc-test-4.2-replica-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, replica, "4.2"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-4.2-server-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, server, "4.2"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-4.2-sharded-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, sharded, "4.2"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-4.4-replica-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, replica, "4.4"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-4.4-server-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, server, "4.4"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-4.4-sharded-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, sharded, "4.4"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-5.0-replica-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, replica, "5.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-5.0-server-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, server, "5.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-5.0-sharded-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, sharded, "5.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-6.0-replica-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, replica, "6.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-6.0-server-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, server, "6.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-6.0-sharded-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, sharded, "6.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-7.0-replica-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, replica, "7.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-7.0-server-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, server, "7.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-7.0-sharded-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, sharded, "7.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-8.0-replica-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, replica, "8.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-8.0-server-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, server, "8.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-8.0-sharded-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, sharded, "8.0"] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-latest-replica-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, replica, latest] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-latest-server-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, server, latest] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-rhel8-latest-gcc-test-latest-sharded-noauth + run_on: rhel8-latest-large + tags: [sasl-matrix-nossl, test, rhel8-latest, gcc, sasl-off, noauth, sharded, latest] + depends_on: [{ name: sasl-off-nossl-rhel8-latest-gcc-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-off-nossl-rhel8-latest-gcc-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: noauth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: nossl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-off-nossl-ubuntu2204-gcc-compile + run_on: ubuntu2204-large + tags: [sasl-matrix-nossl, compile, ubuntu2204, gcc, sasl-off] + commands: + - func: find-cmake-latest + - func: sasl-off-nossl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-off-nossl-ubuntu2404-gcc-compile + run_on: ubuntu2404-large + tags: [sasl-matrix-nossl, compile, ubuntu2404, gcc, sasl-off] + commands: + - func: find-cmake-latest + - func: sasl-off-nossl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-off-nossl-windows-2019-vs2017-x64-compile + run_on: windows-vsCurrent-large + tags: [sasl-matrix-nossl, compile, windows-vsCurrent, vs2017x64, sasl-off] + commands: + - func: find-cmake-latest + - func: sasl-off-nossl-compile + vars: + CMAKE_GENERATOR: Visual Studio 15 2017 + CMAKE_GENERATOR_PLATFORM: x64 + - func: upload-build + - name: sasl-off-winssl-windows-2019-vs2017-x64-compile + run_on: windows-vsCurrent-large + tags: [sasl-matrix-winssl, compile, windows-vsCurrent, vs2017x64, sasl-off] + commands: + - func: find-cmake-latest + - func: sasl-off-winssl-compile + vars: + CMAKE_GENERATOR: Visual Studio 15 2017 + CMAKE_GENERATOR_PLATFORM: x64 + - func: upload-build + - name: sasl-off-winssl-windows-2019-vs2017-x86-compile + run_on: windows-vsCurrent-large + tags: [sasl-matrix-winssl, compile, windows-vsCurrent, vs2017x86, sasl-off] + commands: + - func: find-cmake-latest + - func: sasl-off-winssl-compile + vars: + CMAKE_GENERATOR: Visual Studio 15 2017 + CMAKE_GENERATOR_PLATFORM: Win32 + - func: upload-build + - name: sasl-sspi-winssl-windows-2019-mingw-compile + run_on: windows-vsCurrent-large + tags: [sasl-matrix-winssl, compile, windows-vsCurrent, mingw, sasl-sspi] + commands: + - func: find-cmake-latest + - func: sasl-sspi-winssl-compile + vars: + CC: gcc + CXX: g++ + - func: upload-build + - name: sasl-sspi-winssl-windows-2019-mingw-test-8.0-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, mingw, sasl-sspi, auth, server, "8.0", winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-mingw-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-mingw-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-sspi-winssl-windows-2019-mingw-test-latest-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, mingw, sasl-sspi, auth, server, latest, winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-mingw-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-mingw-compile + - command: expansions.update + params: + updates: + - { key: CC, value: gcc } + - { key: CXX, value: g++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-sspi-winssl-windows-2019-vs2017-x64-compile + run_on: windows-vsCurrent-large + tags: [sasl-matrix-winssl, compile, windows-vsCurrent, vs2017x64, sasl-sspi] + commands: + - func: find-cmake-latest + - func: sasl-sspi-winssl-compile + vars: + CMAKE_GENERATOR: Visual Studio 15 2017 + CMAKE_GENERATOR_PLATFORM: x64 + - func: upload-build + - name: sasl-sspi-winssl-windows-2019-vs2017-x64-test-4.2-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-sspi, auth, server, "4.2", winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-sspi-winssl-windows-2019-vs2017-x64-test-4.4-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-sspi, auth, server, "4.4", winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-sspi-winssl-windows-2019-vs2017-x64-test-5.0-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-sspi, auth, server, "5.0", winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-sspi-winssl-windows-2019-vs2017-x64-test-6.0-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-sspi, auth, server, "6.0", winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-sspi-winssl-windows-2019-vs2017-x64-test-7.0-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-sspi, auth, server, "7.0", winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-sspi-winssl-windows-2019-vs2017-x64-test-8.0-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-sspi, auth, server, "8.0", winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-sspi-winssl-windows-2019-vs2017-x64-test-latest-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x64, sasl-sspi, auth, server, latest, winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x64-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x64-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: x64 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-sspi-winssl-windows-2019-vs2017-x86-compile + run_on: windows-vsCurrent-large + tags: [sasl-matrix-winssl, compile, windows-vsCurrent, vs2017x86, sasl-sspi] + commands: + - func: find-cmake-latest + - func: sasl-sspi-winssl-compile + vars: + CMAKE_GENERATOR: Visual Studio 15 2017 + CMAKE_GENERATOR_PLATFORM: Win32 + - func: upload-build + - name: sasl-sspi-winssl-windows-2019-vs2017-x86-test-8.0-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x86, sasl-sspi, auth, server, "8.0", winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x86-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x86-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: Win32 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sasl-sspi-winssl-windows-2019-vs2017-x86-test-latest-server-auth + run_on: windows-vsCurrent-small + tags: [sasl-matrix-winssl, test, windows-vsCurrent, vs2017x86, sasl-sspi, auth, server, latest, winssl] + depends_on: [{ name: sasl-sspi-winssl-windows-2019-vs2017-x86-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: sasl-sspi-winssl-windows-2019-vs2017-x86-compile + - command: expansions.update + params: + updates: + - { key: CMAKE_GENERATOR, value: Visual Studio 15 2017 } + - { key: CMAKE_GENERATOR_PLATFORM, value: Win32 } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: winssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: sbom + run_on: rhel80-small + tags: [sbom, rhel80] + commands: + - func: sbom + - name: scan-build-macos-14-arm64-clang + run_on: macos-14-arm64 + tags: [scan-build-matrix, macos-14-arm64, clang] + commands: + - func: find-cmake-latest + - func: scan-build + vars: + CC: clang + CXX: clang++ + - func: upload scan artifacts + - name: scan-build-ubuntu2004-arm64-clang + run_on: ubuntu2004-arm64-large + tags: [scan-build-matrix, ubuntu2004-arm64, clang] + commands: + - func: find-cmake-latest + - func: scan-build + vars: + CC: clang + CXX: clang++ + - func: upload scan artifacts + - name: scan-build-ubuntu2004-clang-i686 + run_on: ubuntu2004-large + tags: [scan-build-matrix, ubuntu2004, clang, i686] + commands: + - func: find-cmake-latest + - func: scan-build + vars: + CC: clang + CXX: clang++ + MARCH: i686 + - func: upload scan artifacts + - name: std-c11-debian11-gcc-compile + run_on: debian11-large + tags: [std-matrix, debian11, gcc, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-10 + CXX: g++-10 + C_STD_VERSION: 11 + - name: std-c11-rhel7-latest-gcc-compile + run_on: rhel7-latest-large + tags: [std-matrix, rhel7-latest, gcc, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 11 + - name: std-c11-rhel80-clang-compile + run_on: rhel80-large + tags: [std-matrix, rhel80, clang, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 11 + - name: std-c11-rhel80-gcc-compile + run_on: rhel80-large + tags: [std-matrix, rhel80, gcc, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 11 + - name: std-c11-rhel84-clang-compile + run_on: rhel84-large + tags: [std-matrix, rhel84, clang, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 11 + - name: std-c11-rhel84-gcc-compile + run_on: rhel84-large + tags: [std-matrix, rhel84, gcc, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 11 + - name: std-c11-rhel90-clang-compile + run_on: rhel90-large + tags: [std-matrix, rhel90, clang, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 11 + - name: std-c11-rhel90-gcc-compile + run_on: rhel90-large + tags: [std-matrix, rhel90, gcc, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 11 + - name: std-c11-rhel91-clang-compile + run_on: rhel91-large + tags: [std-matrix, rhel91, clang, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 11 + - name: std-c11-rhel92-clang-compile + run_on: rhel92-large + tags: [std-matrix, rhel92, clang, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 11 + - name: std-c11-rhel92-gcc-compile + run_on: rhel92-large + tags: [std-matrix, rhel92, gcc, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 11 + - name: std-c11-rhel93-clang-compile + run_on: rhel93-large + tags: [std-matrix, rhel93, clang, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 11 + - name: std-c11-rhel94-clang-compile + run_on: rhel94-large + tags: [std-matrix, rhel94, clang, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 11 + - name: std-c11-rhel94-gcc-compile + run_on: rhel94-large + tags: [std-matrix, rhel94, gcc, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 11 + - name: std-c11-rhel95-clang-compile + run_on: rhel95-large + tags: [std-matrix, rhel95, clang, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 11 + - name: std-c11-rhel95-gcc-compile + run_on: rhel95-large + tags: [std-matrix, rhel95, gcc, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 11 + - name: std-c11-ubuntu2004-clang-compile + run_on: ubuntu2004-large + tags: [std-matrix, ubuntu2004, clang, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang-10 + CXX: clang++-10 + C_STD_VERSION: 11 + - name: std-c11-ubuntu2004-gcc-compile + run_on: ubuntu2004-large + tags: [std-matrix, ubuntu2004, gcc, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-9 + CXX: g++-9 + C_STD_VERSION: 11 + - name: std-c11-ubuntu2204-clang-compile + run_on: ubuntu2204-large + tags: [std-matrix, ubuntu2204, clang, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang-12 + CXX: clang++-12 + C_STD_VERSION: 11 + - name: std-c11-ubuntu2404-gcc-compile + run_on: ubuntu2404-large + tags: [std-matrix, ubuntu2404, gcc, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-13 + CXX: g++-13 + C_STD_VERSION: 11 + - name: std-c11-windows-2019-vs2015-x64-compile + run_on: windows-vsCurrent-large + tags: [std-matrix, windows-vsCurrent, vs2015x64, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CMAKE_GENERATOR: Visual Studio 14 2015 + CMAKE_GENERATOR_PLATFORM: x64 + C_STD_VERSION: 11 + - name: std-c11-windows-2019-vs2017-x64-compile + run_on: windows-vsCurrent-large + tags: [std-matrix, windows-vsCurrent, vs2017x64, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CMAKE_GENERATOR: Visual Studio 15 2017 + CMAKE_GENERATOR_PLATFORM: x64 + C_STD_VERSION: 11 + - name: std-c11-windows-2019-vs2019-x64-compile + run_on: windows-vsCurrent-large + tags: [std-matrix, windows-vsCurrent, vs2019x64, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CMAKE_GENERATOR: Visual Studio 16 2019 + CMAKE_GENERATOR_PLATFORM: x64 + C_STD_VERSION: 11 + - name: std-c11-windows-2019-vs2022-x64-compile + run_on: windows-vsCurrent-large + tags: [std-matrix, windows-vsCurrent, vs2022x64, compile, std-c11] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CMAKE_GENERATOR: Visual Studio 17 2022 + CMAKE_GENERATOR_PLATFORM: x64 + C_STD_VERSION: 11 + - name: std-c17-debian11-gcc-compile + run_on: debian11-large + tags: [std-matrix, debian11, gcc, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-10 + CXX: g++-10 + C_STD_VERSION: 17 + - name: std-c17-rhel80-clang-compile + run_on: rhel80-large + tags: [std-matrix, rhel80, clang, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 17 + - name: std-c17-rhel80-gcc-compile + run_on: rhel80-large + tags: [std-matrix, rhel80, gcc, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 17 + - name: std-c17-rhel84-clang-compile + run_on: rhel84-large + tags: [std-matrix, rhel84, clang, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 17 + - name: std-c17-rhel84-gcc-compile + run_on: rhel84-large + tags: [std-matrix, rhel84, gcc, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 17 + - name: std-c17-rhel90-clang-compile + run_on: rhel90-large + tags: [std-matrix, rhel90, clang, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 17 + - name: std-c17-rhel90-gcc-compile + run_on: rhel90-large + tags: [std-matrix, rhel90, gcc, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 17 + - name: std-c17-rhel91-clang-compile + run_on: rhel91-large + tags: [std-matrix, rhel91, clang, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 17 + - name: std-c17-rhel92-clang-compile + run_on: rhel92-large + tags: [std-matrix, rhel92, clang, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 17 + - name: std-c17-rhel92-gcc-compile + run_on: rhel92-large + tags: [std-matrix, rhel92, gcc, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 17 + - name: std-c17-rhel93-clang-compile + run_on: rhel93-large + tags: [std-matrix, rhel93, clang, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 17 + - name: std-c17-rhel94-clang-compile + run_on: rhel94-large + tags: [std-matrix, rhel94, clang, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 17 + - name: std-c17-rhel94-gcc-compile + run_on: rhel94-large + tags: [std-matrix, rhel94, gcc, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 17 + - name: std-c17-rhel95-clang-compile + run_on: rhel95-large + tags: [std-matrix, rhel95, clang, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 17 + - name: std-c17-rhel95-gcc-compile + run_on: rhel95-large + tags: [std-matrix, rhel95, gcc, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 17 + - name: std-c17-ubuntu2004-clang-compile + run_on: ubuntu2004-large + tags: [std-matrix, ubuntu2004, clang, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang-10 + CXX: clang++-10 + C_STD_VERSION: 17 + - name: std-c17-ubuntu2004-gcc-compile + run_on: ubuntu2004-large + tags: [std-matrix, ubuntu2004, gcc, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-9 + CXX: g++-9 + C_STD_VERSION: 17 + - name: std-c17-ubuntu2204-clang-compile + run_on: ubuntu2204-large + tags: [std-matrix, ubuntu2204, clang, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang-12 + CXX: clang++-12 + C_STD_VERSION: 17 + - name: std-c17-ubuntu2404-gcc-compile + run_on: ubuntu2404-large + tags: [std-matrix, ubuntu2404, gcc, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-13 + CXX: g++-13 + C_STD_VERSION: 17 + - name: std-c17-windows-2019-vs2019-x64-compile + run_on: windows-vsCurrent-large + tags: [std-matrix, windows-vsCurrent, vs2019x64, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CMAKE_GENERATOR: Visual Studio 16 2019 + CMAKE_GENERATOR_PLATFORM: x64 + C_STD_VERSION: 17 + - name: std-c17-windows-2019-vs2022-x64-compile + run_on: windows-vsCurrent-large + tags: [std-matrix, windows-vsCurrent, vs2022x64, compile, std-c17] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CMAKE_GENERATOR: Visual Studio 17 2022 + CMAKE_GENERATOR_PLATFORM: x64 + C_STD_VERSION: 17 + - name: std-c23-debian11-gcc-compile + run_on: debian11-large + tags: [std-matrix, debian11, gcc, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-10 + CXX: g++-10 + C_STD_VERSION: 23 + - name: std-c23-rhel84-clang-compile + run_on: rhel84-large + tags: [std-matrix, rhel84, clang, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 23 + - name: std-c23-rhel90-clang-compile + run_on: rhel90-large + tags: [std-matrix, rhel90, clang, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 23 + - name: std-c23-rhel90-gcc-compile + run_on: rhel90-large + tags: [std-matrix, rhel90, gcc, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 23 + - name: std-c23-rhel91-clang-compile + run_on: rhel91-large + tags: [std-matrix, rhel91, clang, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 23 + - name: std-c23-rhel92-clang-compile + run_on: rhel92-large + tags: [std-matrix, rhel92, clang, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 23 + - name: std-c23-rhel92-gcc-compile + run_on: rhel92-large + tags: [std-matrix, rhel92, gcc, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 23 + - name: std-c23-rhel93-clang-compile + run_on: rhel93-large + tags: [std-matrix, rhel93, clang, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 23 + - name: std-c23-rhel94-clang-compile + run_on: rhel94-large + tags: [std-matrix, rhel94, clang, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 23 + - name: std-c23-rhel94-gcc-compile + run_on: rhel94-large + tags: [std-matrix, rhel94, gcc, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 23 + - name: std-c23-rhel95-clang-compile + run_on: rhel95-large + tags: [std-matrix, rhel95, clang, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 23 + - name: std-c23-rhel95-gcc-compile + run_on: rhel95-large + tags: [std-matrix, rhel95, gcc, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 23 + - name: std-c23-ubuntu2004-clang-compile + run_on: ubuntu2004-large + tags: [std-matrix, ubuntu2004, clang, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang-10 + CXX: clang++-10 + C_STD_VERSION: 23 + - name: std-c23-ubuntu2004-gcc-compile + run_on: ubuntu2004-large + tags: [std-matrix, ubuntu2004, gcc, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-9 + CXX: g++-9 + C_STD_VERSION: 23 + - name: std-c23-ubuntu2204-clang-compile + run_on: ubuntu2204-large + tags: [std-matrix, ubuntu2204, clang, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang-12 + CXX: clang++-12 + C_STD_VERSION: 23 + - name: std-c23-ubuntu2404-gcc-compile + run_on: ubuntu2404-large + tags: [std-matrix, ubuntu2404, gcc, compile, std-c23] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-13 + CXX: g++-13 + C_STD_VERSION: 23 + - name: std-c99-debian11-gcc-compile + run_on: debian11-large + tags: [std-matrix, debian11, gcc, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-10 + CXX: g++-10 + C_STD_VERSION: 99 + - name: std-c99-rhel7-latest-gcc-compile + run_on: rhel7-latest-large + tags: [std-matrix, rhel7-latest, gcc, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 99 + - name: std-c99-rhel80-clang-compile + run_on: rhel80-large + tags: [std-matrix, rhel80, clang, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 99 + - name: std-c99-rhel80-gcc-compile + run_on: rhel80-large + tags: [std-matrix, rhel80, gcc, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 99 + - name: std-c99-rhel84-clang-compile + run_on: rhel84-large + tags: [std-matrix, rhel84, clang, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 99 + - name: std-c99-rhel84-gcc-compile + run_on: rhel84-large + tags: [std-matrix, rhel84, gcc, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 99 + - name: std-c99-rhel90-clang-compile + run_on: rhel90-large + tags: [std-matrix, rhel90, clang, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 99 + - name: std-c99-rhel90-gcc-compile + run_on: rhel90-large + tags: [std-matrix, rhel90, gcc, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 99 + - name: std-c99-rhel91-clang-compile + run_on: rhel91-large + tags: [std-matrix, rhel91, clang, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 99 + - name: std-c99-rhel92-clang-compile + run_on: rhel92-large + tags: [std-matrix, rhel92, clang, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 99 + - name: std-c99-rhel92-gcc-compile + run_on: rhel92-large + tags: [std-matrix, rhel92, gcc, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 99 + - name: std-c99-rhel93-clang-compile + run_on: rhel93-large + tags: [std-matrix, rhel93, clang, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 99 + - name: std-c99-rhel94-clang-compile + run_on: rhel94-large + tags: [std-matrix, rhel94, clang, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 99 + - name: std-c99-rhel94-gcc-compile + run_on: rhel94-large + tags: [std-matrix, rhel94, gcc, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 99 + - name: std-c99-rhel95-clang-compile + run_on: rhel95-large + tags: [std-matrix, rhel95, clang, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang + CXX: clang++ + C_STD_VERSION: 99 + - name: std-c99-rhel95-gcc-compile + run_on: rhel95-large + tags: [std-matrix, rhel95, gcc, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc + CXX: g++ + C_STD_VERSION: 99 + - name: std-c99-ubuntu2004-clang-compile + run_on: ubuntu2004-large + tags: [std-matrix, ubuntu2004, clang, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang-10 + CXX: clang++-10 + C_STD_VERSION: 99 + - name: std-c99-ubuntu2004-gcc-compile + run_on: ubuntu2004-large + tags: [std-matrix, ubuntu2004, gcc, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-9 + CXX: g++-9 + C_STD_VERSION: 99 + - name: std-c99-ubuntu2204-clang-compile + run_on: ubuntu2204-large + tags: [std-matrix, ubuntu2204, clang, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: clang-12 + CXX: clang++-12 + C_STD_VERSION: 99 + - name: std-c99-ubuntu2404-gcc-compile + run_on: ubuntu2404-large + tags: [std-matrix, ubuntu2404, gcc, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CC: gcc-13 + CXX: g++-13 + C_STD_VERSION: 99 + - name: std-c99-windows-2019-vs2015-x64-compile + run_on: windows-vsCurrent-large + tags: [std-matrix, windows-vsCurrent, vs2015x64, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CMAKE_GENERATOR: Visual Studio 14 2015 + CMAKE_GENERATOR_PLATFORM: x64 + C_STD_VERSION: 99 + - name: std-c99-windows-2019-vs2017-x64-compile + run_on: windows-vsCurrent-large + tags: [std-matrix, windows-vsCurrent, vs2017x64, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CMAKE_GENERATOR: Visual Studio 15 2017 + CMAKE_GENERATOR_PLATFORM: x64 + C_STD_VERSION: 99 + - name: std-c99-windows-2019-vs2019-x64-compile + run_on: windows-vsCurrent-large + tags: [std-matrix, windows-vsCurrent, vs2019x64, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CMAKE_GENERATOR: Visual Studio 16 2019 + CMAKE_GENERATOR_PLATFORM: x64 + C_STD_VERSION: 99 + - name: std-c99-windows-2019-vs2022-x64-compile + run_on: windows-vsCurrent-large + tags: [std-matrix, windows-vsCurrent, vs2022x64, compile, std-c99] + commands: + - func: find-cmake-latest + - func: std-compile + vars: + CMAKE_GENERATOR: Visual Studio 17 2022 + CMAKE_GENERATOR_PLATFORM: x64 + C_STD_VERSION: 99 + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, compile, rhel8-latest, clang, tsan, sasl-cyrus] + commands: + - func: find-cmake-latest + - func: sasl-cyrus-openssl-compile + vars: + CC: clang + CXX: clang++ + - func: upload-build + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.2-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, replica, "4.2", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.2-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, server, "4.2", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.2-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, sharded, "4.2", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.2" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.4-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, replica, "4.4", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.4-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, server, "4.4", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-4.4-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, sharded, "4.4", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "4.4" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-5.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, replica, "5.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-5.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, server, "5.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-5.0-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, sharded, "5.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "5.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-6.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, replica, "6.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-6.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, server, "6.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-6.0-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, sharded, "6.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "6.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-7.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, replica, "7.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-7.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, server, "7.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-7.0-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, sharded, "7.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "7.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-8.0-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, replica, "8.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-8.0-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, server, "8.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-8.0-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, sharded, "8.0", openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: "8.0" } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-latest-replica-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, replica, latest, openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: replica_set } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-latest-server-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, server, latest, openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: server } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-test-latest-sharded-auth + run_on: rhel8-latest-large + tags: [sanitizers-matrix-tsan, test, rhel8-latest, clang, sasl-cyrus, tsan, auth, sharded, latest, openssl] + depends_on: [{ name: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile }] + commands: + - func: fetch-build + vars: + BUILD_NAME: tsan-sasl-cyrus-openssl-rhel8-latest-clang-compile + - command: expansions.update + params: + updates: + - { key: CC, value: clang } + - { key: CXX, value: clang++ } + - { key: AUTH, value: auth } + - { key: MONGODB_VERSION, value: latest } + - { key: TOPOLOGY, value: sharded_cluster } + - { key: SSL, value: openssl } + - func: fetch-det + - func: bootstrap-mongo-orchestration + - func: run-simple-http-server + - func: run-tests + - name: verify-headers + run_on: + - amazon2 + - debian11-large + - debian12-large + - ubuntu2204-large + - ubuntu2404-large + tags: [pr-merge-gate] + commands: + - func: docker-login-amazon-ecr + - command: subprocess.exec + type: test + params: + binary: ./tools/earthly.sh + working_dir: mongoc + include_expansions_in_env: + - DOCKER_CONFIG + args: + - --buildkit-image=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub/earthly/buildkitd:v0.8.3 + - +verify-headers + - --default_search_registry=901841024863.dkr.ecr.us-east-1.amazonaws.com/dockerhub diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/variants.yml b/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/variants.yml new file mode 100644 index 000000000..30437749e --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/generated_configs/variants.yml @@ -0,0 +1,363 @@ +buildvariants: + - name: alpine3.16-clang + display_name: Alpine 3.16 (LLVM/Clang) + expansions: + MONGOC_EARTHLY_C_COMPILER: clang + MONGOC_EARTHLY_ENV: alpine3.16 + tasks: + - name: .alpine3.16-clang + - name: alpine3.16-gcc + display_name: Alpine 3.16 (GCC) + expansions: + MONGOC_EARTHLY_C_COMPILER: gcc + MONGOC_EARTHLY_ENV: alpine3.16 + tasks: + - name: .alpine3.16-gcc + - name: alpine3.17-clang + display_name: Alpine 3.17 (LLVM/Clang) + expansions: + MONGOC_EARTHLY_C_COMPILER: clang + MONGOC_EARTHLY_ENV: alpine3.17 + tasks: + - name: .alpine3.17-clang + - name: alpine3.17-gcc + display_name: Alpine 3.17 (GCC) + expansions: + MONGOC_EARTHLY_C_COMPILER: gcc + MONGOC_EARTHLY_ENV: alpine3.17 + tasks: + - name: .alpine3.17-gcc + - name: alpine3.18-clang + display_name: Alpine 3.18 (LLVM/Clang) + expansions: + MONGOC_EARTHLY_C_COMPILER: clang + MONGOC_EARTHLY_ENV: alpine3.18 + tasks: + - name: .alpine3.18-clang + - name: alpine3.18-gcc + display_name: Alpine 3.18 (GCC) + expansions: + MONGOC_EARTHLY_C_COMPILER: gcc + MONGOC_EARTHLY_ENV: alpine3.18 + tasks: + - name: .alpine3.18-gcc + - name: alpine3.19-clang + display_name: Alpine 3.19 (LLVM/Clang) + expansions: + MONGOC_EARTHLY_C_COMPILER: clang + MONGOC_EARTHLY_ENV: alpine3.19 + tasks: + - name: .alpine3.19-clang + - name: alpine3.19-gcc + display_name: Alpine 3.19 (GCC) + expansions: + MONGOC_EARTHLY_C_COMPILER: gcc + MONGOC_EARTHLY_ENV: alpine3.19 + tasks: + - name: .alpine3.19-gcc + - name: archlinux-clang + display_name: ArchLinux (LLVM/Clang) + expansions: + MONGOC_EARTHLY_C_COMPILER: clang + MONGOC_EARTHLY_ENV: archlinux + tasks: + - name: .archlinux-clang + - name: archlinux-gcc + display_name: ArchLinux (GCC) + expansions: + MONGOC_EARTHLY_C_COMPILER: gcc + MONGOC_EARTHLY_ENV: archlinux + tasks: + - name: .archlinux-gcc + - name: centos7-clang + display_name: CentOS 7.0 (LLVM/Clang) + expansions: + MONGOC_EARTHLY_C_COMPILER: clang + MONGOC_EARTHLY_ENV: centos7 + tasks: + - name: .centos7-clang + - name: centos7-gcc + display_name: CentOS 7.0 (GCC) + expansions: + MONGOC_EARTHLY_C_COMPILER: gcc + MONGOC_EARTHLY_ENV: centos7 + tasks: + - name: .centos7-gcc + - name: clang-format + display_name: clang-format + run_on: + - ubuntu2204-small + tasks: + - name: .clang-format + - name: cse-matrix-darwinssl + display_name: cse-matrix-darwinssl + expansions: + CLIENT_SIDE_ENCRYPTION: "on" + tasks: + - name: .cse-matrix-darwinssl + - name: cse-matrix-openssl + display_name: cse-matrix-openssl + expansions: + CLIENT_SIDE_ENCRYPTION: "on" + tasks: + - name: cse-sasl-cyrus-openssl-debian11-clang-compile + - name: cse-sasl-cyrus-openssl-debian11-gcc-compile + - name: cse-sasl-cyrus-openssl-debian12-clang-compile + - name: cse-sasl-cyrus-openssl-debian12-gcc-compile + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-compile + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-4.2-replica-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-4.2-server-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-4.4-replica-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-4.4-server-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-5.0-replica-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-5.0-server-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-6.0-replica-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-6.0-server-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-7.0-replica-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-7.0-server-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-8.0-replica-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-8.0-server-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-latest-replica-auth + - name: cse-sasl-cyrus-openssl-rhel8-latest-gcc-test-latest-server-auth + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-compile + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-5.0-replica-auth + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-5.0-server-auth + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-6.0-replica-auth + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-6.0-server-auth + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-7.0-replica-auth + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-7.0-server-auth + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-8.0-replica-auth + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-8.0-server-auth + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-latest-replica-auth + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel8-zseries-gcc-test-latest-server-auth + batchtime: 1440 + - name: cse-sasl-cyrus-openssl-rhel80-gcc-compile + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-4.4-replica-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-4.4-server-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-5.0-replica-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-5.0-server-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-6.0-replica-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-6.0-server-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-7.0-replica-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-7.0-server-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-8.0-replica-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-8.0-server-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-latest-replica-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-latest-server-auth + - name: cse-sasl-cyrus-openssl-ubuntu2004-clang-compile + - name: cse-sasl-cyrus-openssl-ubuntu2004-gcc-compile + - name: cse-sasl-cyrus-openssl-ubuntu2204-clang-12-compile + - name: cse-sasl-cyrus-openssl-ubuntu2204-gcc-compile + - name: cse-sasl-cyrus-openssl-ubuntu2404-clang-14-compile + - name: cse-sasl-cyrus-openssl-ubuntu2404-gcc-compile + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-4.2-replica-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-4.2-server-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-4.4-replica-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-4.4-server-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-5.0-replica-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-5.0-server-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-6.0-replica-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-6.0-server-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-7.0-replica-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-7.0-server-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-8.0-replica-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-8.0-server-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-latest-replica-auth + - name: cse-sasl-cyrus-openssl-windows-2019-vs2017-x64-test-latest-server-auth + - name: cse-matrix-winssl + display_name: cse-matrix-winssl + expansions: + CLIENT_SIDE_ENCRYPTION: "on" + tasks: + - name: .cse-matrix-winssl + - name: loadbalanced + display_name: loadbalanced + tasks: + - name: .loadbalanced + - name: mock-server-test + display_name: Mock Server Test + expansions: + ASAN: "on" + CC: gcc + CFLAGS: -fno-omit-frame-pointer + SANITIZE: address,undefined + tasks: + - name: mock-server-test + - name: openssl-static-matrix + display_name: openssl-static-matrix + tasks: + - name: .openssl-static-matrix + - name: sanitizers-matrix-asan + display_name: sanitizers-matrix-asan + expansions: + ASAN: "on" + CFLAGS: -fno-omit-frame-pointer + CHECK_LOG: "ON" + SANITIZE: address,undefined + tasks: + - name: .sanitizers-matrix-asan + - name: sanitizers-matrix-tsan + display_name: sanitizers-matrix-tsan + expansions: + CFLAGS: -fno-omit-frame-pointer + CHECK_LOG: "ON" + EXTRA_CONFIGURE_FLAGS: -DENABLE_SHM_COUNTERS=OFF + SANITIZE: thread + tasks: + - name: .sanitizers-matrix-tsan + - name: sasl-matrix-darwinssl + display_name: sasl-matrix-darwinssl + expansions: {} + tasks: + - name: .sasl-matrix-darwinssl + - name: sasl-matrix-nossl + display_name: sasl-matrix-nossl + expansions: {} + tasks: + - name: .sasl-matrix-nossl + - name: sasl-matrix-openssl + display_name: sasl-matrix-openssl + expansions: {} + tasks: + - name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-compile + - name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-test-latest-replica-auth + - name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-test-latest-server-auth + - name: sasl-cyrus-openssl-amazon2023-arm64-latest-large-m8g-gcc-test-latest-sharded-auth + - name: sasl-cyrus-openssl-debian11-gcc-compile + - name: sasl-cyrus-openssl-debian12-gcc-compile + - name: sasl-cyrus-openssl-rhel8-latest-gcc-compile + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-4.2-server-auth + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-4.4-server-auth + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-5.0-server-auth + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-6.0-server-auth + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-7.0-server-auth + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-8.0-server-auth + - name: sasl-cyrus-openssl-rhel8-latest-gcc-test-latest-server-auth + - name: sasl-cyrus-openssl-rhel8-power-gcc-compile + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-4.2-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-4.4-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-5.0-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-6.0-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-7.0-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-8.0-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-power-gcc-test-latest-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-compile + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-test-5.0-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-test-6.0-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-test-7.0-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-test-8.0-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel8-zseries-gcc-test-latest-server-auth + batchtime: 1440 + - name: sasl-cyrus-openssl-rhel80-gcc-compile + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-compile + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-4.4-server-auth + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-5.0-server-auth + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-6.0-server-auth + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-7.0-server-auth + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-8.0-server-auth + - name: sasl-cyrus-openssl-ubuntu2004-arm64-gcc-test-latest-server-auth + - name: sasl-cyrus-openssl-ubuntu2004-clang-compile + - name: sasl-cyrus-openssl-ubuntu2204-clang-12-compile + - name: sasl-cyrus-openssl-ubuntu2204-gcc-compile + - name: sasl-cyrus-openssl-ubuntu2404-clang-14-compile + - name: sasl-cyrus-openssl-ubuntu2404-gcc-compile + - name: sasl-cyrus-openssl-windows-2019-vs2017-x64-compile + - name: sasl-cyrus-openssl-windows-2019-vs2017-x64-test-latest-server-auth + - name: sasl-matrix-winssl + display_name: sasl-matrix-winssl + expansions: {} + tasks: + - name: .sasl-matrix-winssl + - name: sbom + display_name: SBOM + tasks: + - name: .sbom + - name: scan-build-matrix + display_name: scan-build-matrix + tasks: + - name: .scan-build-matrix + - name: std-matrix + display_name: std-matrix + tasks: + - name: .std-matrix + - name: u16-clang + display_name: Ubuntu 16.04 (LLVM/Clang) + expansions: + MONGOC_EARTHLY_C_COMPILER: clang + MONGOC_EARTHLY_ENV: u16 + tasks: + - name: .u16-clang + - name: u16-gcc + display_name: Ubuntu 16.04 (GCC) + expansions: + MONGOC_EARTHLY_C_COMPILER: gcc + MONGOC_EARTHLY_ENV: u16 + tasks: + - name: .u16-gcc + - name: u18-clang + display_name: Ubuntu 18.04 (LLVM/Clang) + expansions: + MONGOC_EARTHLY_C_COMPILER: clang + MONGOC_EARTHLY_ENV: u18 + tasks: + - name: .u18-clang + - name: u18-gcc + display_name: Ubuntu 18.04 (GCC) + expansions: + MONGOC_EARTHLY_C_COMPILER: gcc + MONGOC_EARTHLY_ENV: u18 + tasks: + - name: .u18-gcc + - name: u20-clang + display_name: Ubuntu 20.04 (LLVM/Clang) + expansions: + MONGOC_EARTHLY_C_COMPILER: clang + MONGOC_EARTHLY_ENV: u20 + tasks: + - name: .u20-clang + - name: u20-gcc + display_name: Ubuntu 20.04 (GCC) + expansions: + MONGOC_EARTHLY_C_COMPILER: gcc + MONGOC_EARTHLY_ENV: u20 + tasks: + - name: .u20-gcc + - name: u22-clang + display_name: Ubuntu 22.04 (LLVM/Clang) + expansions: + MONGOC_EARTHLY_C_COMPILER: clang + MONGOC_EARTHLY_ENV: u22 + tasks: + - name: .u22-clang + - name: u22-gcc + display_name: Ubuntu 22.04 (GCC) + expansions: + MONGOC_EARTHLY_C_COMPILER: gcc + MONGOC_EARTHLY_ENV: u22 + tasks: + - name: .u22-gcc diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/__init__.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/__init__.py new file mode 100644 index 000000000..b5bb4aa3e --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/__init__.py @@ -0,0 +1,108 @@ +# Copyright 2009-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import sys +from collections import OrderedDict as OD +from typing import Any, Iterable, Mapping, MutableMapping, MutableSequence, Sequence, Union + +Scalar = Union[str, bool, int, None, float] +"YAML simple schema scalar types" +ValueSequence = Sequence["Value"] +"Sequence of YAML simple values" +MutableValueArray = MutableSequence["Value"] +"A mutable sequence of JSON values" +ValueMapping = Mapping[Scalar, "Value"] +"A YAML mapping type (arbitrary scalars as keys)" +MutableValueMapping = MutableMapping[Scalar, "Value"] +"A mutable YAML mapping type" +Value = Union[ValueSequence, ValueMapping, Scalar] +"Any YAML simple value" +MutableValue = Union[MutableValueMapping, MutableValueArray, Scalar] +"Any YAML simple value, which may be a mutable sequence or map" + +ValueOrderedDict = OD[Scalar, Value] +"An OrderedDict of YAML values" + + +import yaml +import yamlloader + + +class ConfigObject(object): + @property + def name(self) -> str: + return "UNSET" + + def to_dict(self) -> Value: + return OD([("name", self.name)]) + + +# We want legible YAML tasks: +# +# - name: debug-compile +# tags: [zlib, snappy, compression, openssl] +# commands: +# - command: shell.exec +# params: +# script: |- +# set -o errexit +# ... +# +# Write values compactly except multiline strings, which use "|" style. Write +# tag sets as lists. + + +class _Dumper(yamlloader.ordereddict.Dumper): + def __init__(self, *args: Value, **kwargs: Value): + super().__init__(*args, **kwargs) # type: ignore + self.add_representer(set, type(self).represent_set) + # Use "multi_representer" to represent all subclasses of ConfigObject. + self.add_multi_representer(ConfigObject, type(self).represent_config_object) + + def represent_scalar(self, tag: str, value: Value, style: str | None = None) -> yaml.ScalarNode: + if isinstance(value, (str)) and "\n" in value: + style = "|" + return super().represent_scalar(tag, value, style) # type: ignore + + def represent_set(self, data: Iterable[Value]) -> yaml.MappingNode: + return super().represent_list(sorted(set(data))) # type: ignore + + def represent_config_object(self, obj: ConfigObject) -> yaml.Node: + d = obj.to_dict() + return super().represent_data(d) # type: ignore + + +def yaml_dump(obj: Any): + return yaml.dump(obj, Dumper=_Dumper, default_flow_style=False) + + +def generate(config: Any, path: str): + """Dump config to a file as YAML. + config is a dict, preferably an OrderedDict. path is a file path. + """ + f = open(path, "w+") + f.write( + """#################################### +# Evergreen configuration +# +# Generated with evergreen_config_generator from +# github.com/mongodb-labs/drivers-evergreen-tools +# +# DO NOT EDIT THIS FILE +# +#################################### +""" + ) + f.write(yaml_dump(config)) diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/functions.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/functions.py new file mode 100644 index 000000000..75d0ab0c2 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/functions.py @@ -0,0 +1,127 @@ +# Copyright 2009-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from collections import OrderedDict as OD +from textwrap import dedent +from typing import Iterable + +from evergreen_config_generator import ConfigObject + +from . import Value, MutableValueMapping, ValueMapping, ValueOrderedDict + + +def func(func_name: str, **kwargs: Value) -> MutableValueMapping: + od: MutableValueMapping = OD([("func", func_name)]) + if kwargs: + od["vars"] = OD(sorted(kwargs.items())) + + return od + + +def s3_put(remote_file: str, project_path: bool = True, **kwargs: Value) -> ValueMapping: + if project_path: + remote_file = "${project}/" + remote_file + + return ValueOrderedDict( + [ + ("command", "s3.put"), + ( + "params", + ValueOrderedDict( + ( + ("aws_key", "${aws_key}"), + ("aws_secret", "${aws_secret}"), + ("remote_file", remote_file), + ("bucket", "mciuploads"), + ("permissions", "public-read"), + *kwargs.items(), + ) + ), + ), + ] + ) + + +def strip_lines(s: str) -> str: + return "\n".join(line for line in s.split("\n") if line.strip()) + + +def shell_exec( + script: str, + test: bool = True, + errexit: bool = True, + xtrace: bool = False, + silent: bool = False, + continue_on_err: bool = False, + working_dir: str | None = None, + background: bool = False, + add_expansions_to_env: bool = False, + redirect_standard_error_to_output: bool = False, + include_expansions_in_env: Iterable[str] = (), +) -> ValueMapping: + dedented = "" + if errexit: + dedented += "set -o errexit\n" + + if xtrace: + dedented += "set -o xtrace\n" + + dedented += dedent(strip_lines(script)) + command = ValueOrderedDict([("command", "shell.exec")]) + if test: + command["type"] = "test" + + command["params"] = OD() + if silent: + command["params"]["silent"] = True + + if working_dir is not None: + command["params"]["working_dir"] = working_dir + + if continue_on_err: + command["params"]["continue_on_err"] = True + + if background: + command["params"]["background"] = True + + if add_expansions_to_env: + command["params"]["add_expansions_to_env"] = True + + if redirect_standard_error_to_output: + command["params"]["redirect_standard_error_to_output"] = True + + if include_expansions_in_env: + command["params"]["include_expansions_in_env"] = list(include_expansions_in_env) + + command["params"]["shell"] = "bash" + command["params"]["script"] = dedented + return command + + +def targz_pack(target: str, source_dir: str, *include: str) -> ValueMapping: + return OD( + [ + ("command", "archive.targz_pack"), + ("params", OD([("target", target), ("source_dir", source_dir), ("include", list(include))])), + ] + ) + + +class Function(ConfigObject): + def __init__(self, *commands: Value): + super(Function, self).__init__() + self.commands = commands + + def to_dict(self) -> Value: + return list(self.commands) diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/taskgroups.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/taskgroups.py new file mode 100644 index 000000000..47263e3b8 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/taskgroups.py @@ -0,0 +1,60 @@ +# Copyright 2009-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import MutableMapping +from evergreen_config_generator import ConfigObject + +from . import Value, ValueSequence + + +class TaskGroup(ConfigObject): + def __init__(self, name: str): + self._task_group_name = name + self.setup_group: ValueSequence | None = None + self.teardown_group: ValueSequence | None = None + self.setup_task: str | None = None + self.teardown_task: str | None = None + self.max_hosts: int | None = None + self.timeout: int | None = None + self.setup_group_can_fail_task: bool | None = None + self.setup_group_timeout_secs: int | None = None + self.share_processes: bool | None = None + self.tasks: ValueSequence | None = None + + @property + def name(self) -> str: + return self._task_group_name + + def to_dict(self) -> Value: + v = super().to_dict() + assert isinstance(v, MutableMapping) + # See possible TaskGroup attributes from the Evergreen wiki: + # https://github.com/evergreen-ci/evergreen/wiki/Project-Configuration-Files#task-groups + attrs = [ + "setup_group", + "teardown_group", + "setup_task", + "teardown_task", + "max_hosts", + "timeout", + "setup_group_can_fail_task", + "setup_group_timeout_secs", + "share_processes", + "tasks", + ] + + for i in attrs: + if getattr(self, i, None): + v[i] = getattr(self, i) + return v diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/tasks.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/tasks.py new file mode 100644 index 000000000..3ea807259 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/tasks.py @@ -0,0 +1,230 @@ +# Copyright 2009-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from collections import OrderedDict as OD +import copy +from itertools import chain, product +import itertools +from typing import ClassVar, Iterable, Literal, Mapping, MutableMapping, Sequence, Union + +from evergreen_config_generator import ConfigObject +from evergreen_config_generator.functions import func + +from . import Value, MutableValueMapping, ValueSequence + + +DependencySpec = Union[str, Mapping[str, Value]] + + +class Task(ConfigObject): + def __init__( + self, + task_name: str | None = None, + commands: Iterable[Value] = (), + tags: Iterable[str] = (), + depends_on: Iterable[DependencySpec] = (), + exec_timeout_secs: int | None = None, + ): + self._name = task_name + self._tags = list(tags) + self.options: MutableValueMapping = OD() + self.commands: ValueSequence = list(commands) + self.exec_timeout_secs = exec_timeout_secs + self._depends_on = list(map(self._normal_dep, depends_on)) + + if exec_timeout_secs is not None: + self.options["exec_timeout_secs"] = exec_timeout_secs + + @property + def dependencies(self) -> Sequence[Mapping[str, Value]]: + main = list(self._depends_on) + main.extend(map(self._normal_dep, self.additional_dependencies())) + return tuple(main) + + def _normal_dep(self, spec: DependencySpec) -> Mapping[str, Value]: + if isinstance(spec, str): + return OD([("name", spec)]) + return spec + + @property + def tags(self) -> Sequence[str]: + return tuple(sorted(chain(self.additional_tags(), self._tags))) + + def pre_commands(self) -> Iterable[Value]: + return () + + def main_commands(self) -> Iterable[Value]: + return () + + def post_commands(self) -> Iterable[Value]: + return () + + def additional_dependencies(self) -> Iterable[DependencySpec]: + return () + + @property + def name(self) -> str: + assert self._name is not None, f'Task {self} did not set a name, and did not override the "name" property' + return self._name + + def additional_tags(self) -> Iterable[str]: + return () + + def add_dependency(self, dependency: DependencySpec): + if isinstance(dependency, str): + dependency = OD([("name", dependency)]) + + self._depends_on.append(dependency) + + def to_dict(self): + task: MutableValueMapping = super().to_dict() # type: ignore + assert isinstance(task, MutableMapping) + if self.tags: + task["tags"] = list(self.tags) + task.update(self.options) + deps: Sequence[MutableValueMapping] = list(self.dependencies) # type: ignore + if deps: + if len(deps) == 1: + task["depends_on"] = OD(deps[0]) + else: + task["depends_on"] = copy.deepcopy(deps) + task["commands"] = list( + itertools.chain( + self.pre_commands(), + self.main_commands(), + self.commands, + self.post_commands(), + ) + ) + return task + + +NamedTask = Task + + +class FuncTask(NamedTask): + def __init__( + self, + task_name: str, + functions: Iterable[str], + tags: Iterable[str] = (), + depends_on: Iterable[DependencySpec] = (), + exec_timeout_secs: int | None = None, + ): + commands = [func(func_name) for func_name in functions] + super().__init__(task_name, commands, tags=tags, depends_on=depends_on, exec_timeout_secs=exec_timeout_secs) + super(FuncTask, self).__init__(task_name, commands=commands) + + +class Prohibited(Exception): + pass + + +def require(rule: bool) -> None: + if not rule: + raise Prohibited() + + +def prohibit(rule: bool) -> None: + if rule: + raise Prohibited() + + +def both_or_neither(rule0: bool, rule1: bool) -> None: + if rule0: + require(rule1) + else: + prohibit(rule1) + + +class SettingsAccess: + def __init__(self, inst: "MatrixTask") -> None: + self._task = inst + + def __getattr__(self, __setting: str) -> str | bool: + return self._task.setting_value(__setting) + + +class MatrixTask(Task): + axes: ClassVar[Mapping[str, Sequence[str | bool]]] = OD() + + def __init__(self, settings: Mapping[str, str | bool]): + super().__init__() + self._settings = {k: v for k, v in settings.items()} + for axis, options in type(self).axes.items(): + if axis not in self._settings: + self._settings[axis] = options[0] + + def display(self, axis_name: str) -> str: + value = self.setting_value(axis_name) + if value is False: + # E.g., if self.auth is False, return 'noauth'. + return f"no{axis_name}" + elif value is True: + return axis_name + else: + return value + + def on_off(self, key: str, val: str) -> Literal["on", "off"]: + return "on" if self.setting_value(key) == val else "off" + + @property + def name(self) -> str: + return "-".join(self.name_parts()) + + def name_parts(self) -> Iterable[str]: + raise NotImplementedError + + @property + def settings(self) -> SettingsAccess: + return SettingsAccess(self) + + def setting_value(self, axis: str) -> str | bool: + assert ( + axis in type(self).axes.keys() + ), f'Attempted to inspect setting "{axis}", which is not defined for this task type' + return self._settings[axis] + + def setting_eq(self, axis: str, val: str | bool) -> bool: + current = self.setting_value(axis) + options = type(self).axes[axis] + assert ( + val in options + ), f'Looking for value "{val}" on setting "{axis}", but that is not a supported option (Expects one of {options})' + return current == val + + def is_valid_combination(self) -> bool: + try: + return self.do_is_valid_combination() + except Prohibited: + print(f"Ignoring invalid combination {self.name!r}") + return False + + def do_is_valid_combination(self) -> bool: + return True + + @classmethod + def matrix(cls): + for cell in product(*cls.axes.values()): + axis_values = dict(zip(cls.axes, cell)) + task = cls(settings=axis_values) + if task.allowed: + yield task + + @property + def allowed(self): + try: + return self.do_is_valid_combination() + except Prohibited: + return False diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/variants.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/variants.py new file mode 100644 index 000000000..3d328b95d --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_generator/variants.py @@ -0,0 +1,59 @@ +# Copyright 2009-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Iterable, Mapping +from evergreen_config_generator import ConfigObject + +from . import ValueMapping + + +class Variant(ConfigObject): + def __init__( + self, + name: str, + display_name: str, + run_on: list[str] | str, + tasks: Iterable[str | ValueMapping], + expansions: Mapping[str, str] | None = None, + tags: Iterable[str] | None = None, + patchable: bool | None = None, + batchtime: int | None = None, + display_tasks: Iterable[ValueMapping] = None, + ): + super(Variant, self).__init__() + self._variant_name = name + self.display_name = display_name + self.run_on = run_on + self.tasks = tasks + self.expansions = expansions + self.tags = tags + self.patchable = patchable + self.batchtime = batchtime + self.display_tasks = display_tasks + + @property + def name(self): + return self._variant_name + + def to_dict(self): + v = super(Variant, self).to_dict() + for i in "display_name", "expansions", "run_on", "tasks", "patchable", "batchtime", "tags", "display_tasks": + attr = getattr(self, i) + + # Allow `False`, but ignore empty lists and dicts. + if isinstance(attr, None | list | dict) and not attr: + continue + + v[i] = attr + return v diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/__init__.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/__init__.py new file mode 100644 index 000000000..1841636e1 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/__init__.py @@ -0,0 +1,43 @@ +# Copyright 2009-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Iterable +from evergreen_config_generator.functions import shell_exec + + +def shell_mongoc( + script: str, + test: bool = True, + errexit: bool = True, + xtrace: bool = False, + silent: bool = False, + continue_on_err: bool = False, + background: bool = False, + add_expansions_to_env: bool = False, + redirect_standard_error_to_output: bool = False, + include_expansions_in_env: Iterable[str] = (), +): + return shell_exec( + script, + working_dir="mongoc", + test=test, + errexit=errexit, + xtrace=xtrace, + silent=silent, + continue_on_err=continue_on_err, + background=background, + add_expansions_to_env=add_expansions_to_env, + include_expansions_in_env=include_expansions_in_env, + redirect_standard_error_to_output=redirect_standard_error_to_output, + ) diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/functions.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/functions.py new file mode 100644 index 000000000..2131e616f --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/functions.py @@ -0,0 +1,224 @@ +# Copyright 2009-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from collections import OrderedDict as OD + +from evergreen_config_generator.functions import ( + Function, s3_put, shell_exec) +from evergreen_config_lib import shell_mongoc + +build_path = '${build_variant}/${revision}/${version_id}/${build_id}' + +all_functions = OD([ + ('install ssl', Function( + shell_mongoc(r''' + .evergreen/scripts/install-ssl.sh + ''', test=False, add_expansions_to_env=True), + )), + ('upload coverage', Function( + shell_mongoc(r''' + export AWS_ACCESS_KEY_ID=${aws_key} + export AWS_SECRET_ACCESS_KEY=${aws_secret} + aws s3 cp coverage s3://mciuploads/${project}/%s/coverage/ --recursive --acl public-read --region us-east-1 + ''' % (build_path,), test=False, silent=True), + s3_put(build_path + '/coverage/index.html', aws_key='${aws_key}', + aws_secret='${aws_secret}', + local_file='mongoc/coverage/index.html', bucket='mciuploads', + permissions='public-read', content_type='text/html', + display_name='Coverage Report'), + )), + ('upload scan artifacts', Function( + shell_mongoc(r''' + if find scan -name \*.html | grep -q html; then + (cd scan && find . -name index.html -exec echo "
  • {}
  • " \;) >> scan.html + else + echo "No issues found" > scan.html + fi + '''), + shell_mongoc(r''' + export AWS_ACCESS_KEY_ID=${aws_key} + export AWS_SECRET_ACCESS_KEY=${aws_secret} + aws s3 cp scan s3://mciuploads/${project}/%s/scan/ --recursive --acl public-read --region us-east-1 + ''' % (build_path,), test=False, silent=True), + s3_put(build_path + '/scan/index.html', aws_key='${aws_key}', + aws_secret='${aws_secret}', local_file='mongoc/scan.html', + bucket='mciuploads', permissions='public-read', + content_type='text/html', display_name='Scan Build Report'), + )), + # Use "silent=True" to hide output since errors may contain credentials. + ('run auth tests', Function( + shell_mongoc(r''' + .evergreen/scripts/run-auth-tests.sh + ''', add_expansions_to_env=True), + )), + ('link sample program', Function( + shell_mongoc(r''' + # Compile a program that links dynamically or statically to libmongoc, + # using variables from pkg-config or CMake's find_package command. + export BUILD_SAMPLE_WITH_CMAKE=${BUILD_SAMPLE_WITH_CMAKE} + export ENABLE_SSL=${ENABLE_SSL} + export ENABLE_SNAPPY=${ENABLE_SNAPPY} + LINK_STATIC= .evergreen/scripts/link-sample-program.sh + LINK_STATIC=1 .evergreen/scripts/link-sample-program.sh + ''', + include_expansions_in_env=['distro_id']), + )), + ('link sample program bson', Function( + shell_mongoc(r''' + # Compile a program that links dynamically or statically to libbson, + # using variables from pkg-config or from CMake's find_package command. + BUILD_SAMPLE_WITH_CMAKE= LINK_STATIC= .evergreen/scripts/link-sample-program-bson.sh + BUILD_SAMPLE_WITH_CMAKE= LINK_STATIC=1 .evergreen/scripts/link-sample-program-bson.sh + BUILD_SAMPLE_WITH_CMAKE=1 LINK_STATIC= .evergreen/scripts/link-sample-program-bson.sh + BUILD_SAMPLE_WITH_CMAKE=1 LINK_STATIC=1 .evergreen/scripts/link-sample-program-bson.sh + ''', + include_expansions_in_env=['distro_id']), + )), + ('link sample program MSVC', Function( + shell_mongoc(r''' + # Build libmongoc with CMake and compile a program that links + # dynamically or statically to it, using variables from CMake's + # find_package command. + export ENABLE_SSL=${ENABLE_SSL} + export ENABLE_SNAPPY=${ENABLE_SNAPPY} + . .evergreen/scripts/use-tools.sh paths + . .evergreen/scripts/find-cmake-latest.sh + export CMAKE="$(native-path "$(find_cmake_latest)")" + LINK_STATIC= cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc.cmd + LINK_STATIC=1 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc.cmd + ''', + include_expansions_in_env=['distro_id']), + )), + ('link sample program mingw', Function( + shell_mongoc(r''' + # Build libmongoc with CMake and compile a program that links + # dynamically to it, using variables from pkg-config.exe. + . .evergreen/scripts/use-tools.sh paths + . .evergreen/scripts/find-cmake-latest.sh + export CMAKE="$(native-path "$(find_cmake_latest)")" + cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw.cmd + ''', + include_expansions_in_env=['distro_id']), + )), + ('link sample program MSVC bson', Function( + shell_mongoc(r''' + # Build libmongoc with CMake and compile a program that links + # dynamically or statically to it, using variables from CMake's + # find_package command. + export ENABLE_SSL=${ENABLE_SSL} + export ENABLE_SNAPPY=${ENABLE_SNAPPY} + . .evergreen/scripts/use-tools.sh paths + . .evergreen/scripts/find-cmake-latest.sh + export CMAKE="$(native-path "$(find_cmake_latest)")" + LINK_STATIC= cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc-bson.cmd + LINK_STATIC=1 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc-bson.cmd + ''', + include_expansions_in_env=['distro_id']), + )), + ('link sample program mingw bson', Function( + shell_mongoc(r''' + # Build libmongoc with CMake and compile a program that links + # dynamically to it, using variables from pkg-config.exe. + . .evergreen/scripts/use-tools.sh paths + . .evergreen/scripts/find-cmake-latest.sh + export CMAKE="$(native-path "$(find_cmake_latest)")" + cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw-bson.cmd + '''), + )), + ('update codecov.io', Function( + shell_mongoc(r''' + # Note: coverage is currently only enabled on the ubuntu1804 distro. + # This script does not support MacOS, Windows, or non-x86_64 distros. + # Update accordingly if code coverage is expanded to other distros. + curl -Os https://uploader.codecov.io/latest/linux/codecov + chmod +x codecov + # -Z: Exit with a non-zero value if error. + # -g: Run with gcov support. + # -t: Codecov upload token. + # perl: filter verbose "Found" list and "Processing" messages. + ./codecov -Zgt "${codecov_token}" | perl -lne 'print if not m|^.*\.gcov(\.\.\.)?$|' + ''', test=False), + )), + ('compile coverage', Function( + shell_mongoc(r''' + COVERAGE=ON .evergreen/scripts/compile.sh + ''', add_expansions_to_env=True), + )), + ('build mongohouse', Function( + # Assume role to get AWS secrets. + { + "command": "ec2.assume_role", + "params": { + "role_arn": "${aws_test_secrets_role}" + } + }, + + shell_exec(r''' + cd drivers-evergreen-tools + export DRIVERS_TOOLS=$(pwd) + .evergreen/atlas_data_lake/pull-mongohouse-image.sh + ''', include_expansions_in_env=[ "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN" ]), + )), + ('run mongohouse', Function( + shell_exec(r''' + cd drivers-evergreen-tools + export DRIVERS_TOOLS=$(pwd) + .evergreen/atlas_data_lake/run-mongohouse-image.sh + '''), + )), + ('test mongohouse', Function( + shell_mongoc(r''' + echo "Waiting for mongohouse to start..." + wait_for_mongohouse() { + for _ in $(seq 300); do + # Exit code 7: "Failed to connect to host". + if curl -s localhost:$1; (("$?" != 7)); then + return 0 + else + sleep 1 + fi + done + echo "Could not detect mongohouse on port $1" 1>&2 + return 1 + } + wait_for_mongohouse 27017 || exit + echo "Waiting for mongohouse to start... done." + pgrep -a "mongohouse" + export RUN_MONGOHOUSE_TESTS=ON + ./cmake-build/src/libmongoc/test-libmongoc --no-fork -l /mongohouse/* -d --skip-tests .evergreen/etc/skip-tests.txt + '''), + )), + ('run aws tests', Function( + # Assume role to get AWS secrets. + { + "command": "ec2.assume_role", + "params": { + "role_arn": "${aws_test_secrets_role}" + } + }, + + shell_mongoc(r''' + pushd ../drivers-evergreen-tools/.evergreen/auth_aws + ./setup_secrets.sh drivers/aws_auth + popd # ../drivers-evergreen-tools/.evergreen/auth_aws + ''', include_expansions_in_env=["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]), + + shell_mongoc(r''' + pushd ../drivers-evergreen-tools/.evergreen/auth_aws + . ./activate-authawsvenv.sh + popd # ../drivers-evergreen-tools/.evergreen/auth_aws + .evergreen/scripts/run-aws-tests.sh + ''', include_expansions_in_env=["TESTCASE"]) + )), +]) diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/taskgroups.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/taskgroups.py new file mode 100644 index 000000000..50cc79a44 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/taskgroups.py @@ -0,0 +1,18 @@ +# Copyright 2009-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Sequence +from evergreen_config_generator.taskgroups import TaskGroup + +all_task_groups: Sequence[TaskGroup] = [] diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/tasks.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/tasks.py new file mode 100644 index 000000000..afe05bcf1 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/tasks.py @@ -0,0 +1,1006 @@ +# Copyright 2009-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from collections import OrderedDict as OD +from itertools import chain +from typing import ClassVar, Iterable, Literal, Mapping, MutableMapping, MutableSequence, Optional, Sequence + +from evergreen_config_generator import Value, Scalar +from evergreen_config_generator.functions import func, s3_put +from evergreen_config_generator.tasks import ( + both_or_neither, + MatrixTask, + NamedTask, + prohibit, + require, + Task, + DependencySpec, +) +from evergreen_config_lib import shell_mongoc +from packaging.version import Version + + +ToggleStr = Literal["OFF", "ON"] +OptToggleStr = Optional[ToggleStr] +TopologyStr = Literal["server"] + + +class CompileTask(NamedTask): + cls_compile_sh_env: ClassVar[Mapping[str, str]] = {} + cls_tags: ClassVar[Sequence[str]] = () + cls_sanitize: ClassVar[Sequence[str]] = () + + def __init__( + self, + task_name: str, + tags: Iterable[str] = (), + config: str = "debug", + compression: str | None = "default", + suffix_commands: Iterable[Value] = (), + depends_on: Iterable[DependencySpec] = (), + prefix_commands: Iterable[Value] = (), + sanitize: Iterable[Literal["undefined", "address", "thread"]] = (), + *, + CFLAGS: str | None = None, + LDFLAGS: str | None = None, + EXTRA_CONFIGURE_FLAGS: str | None = None, + SSL: Literal["WINDOWS", "DARWIN", "OPENSSL", "OPENSSL_STATIC", "OFF", None] = None, + ENABLE_SHM_COUNTERS: OptToggleStr = None, + CHECK_LOG: OptToggleStr = None, + TRACING: OptToggleStr = None, + SASL: Literal[None, "OFF", "AUTO", "CYRUS", "SSPI"] = None, + ENABLE_RDTSCP: OptToggleStr = None, + SRV: OptToggleStr = None, + ): + super(CompileTask, self).__init__(task_name=task_name, depends_on=depends_on, tags=tags) + + self.suffix_commands = list(suffix_commands) + self.prefix_commands = list(prefix_commands) + + # Environment variables for .evergreen/scripts/compile.sh. + self.compile_sh_opt: dict[str, str] = {} + + if config != "debug": + assert config == "release" + self.compile_sh_opt["RELEASE"] = "ON" + + if CFLAGS: + self.compile_sh_opt["CFLAGS"] = CFLAGS + if LDFLAGS: + self.compile_sh_opt["LDFLAGS"] = LDFLAGS + if EXTRA_CONFIGURE_FLAGS: + self.compile_sh_opt["EXTRA_CONFIGURE_FLAGS"] = EXTRA_CONFIGURE_FLAGS + if SSL: + self.compile_sh_opt["SSL"] = SSL + if ENABLE_SHM_COUNTERS: + self.compile_sh_opt["ENABLE_SHM_COUNTERS"] = ENABLE_SHM_COUNTERS + if CHECK_LOG: + self.compile_sh_opt["CHECK_LOG"] = CHECK_LOG + if TRACING: + self.compile_sh_opt["TRACING"] = TRACING + if SASL: + self.compile_sh_opt["SASL"] = SASL + if ENABLE_RDTSCP: + self.compile_sh_opt["ENABLE_RDTSCP"] = ENABLE_RDTSCP + if SRV: + self.compile_sh_opt["SRV"] = SRV + + if compression != "default": + self.compile_sh_opt["SNAPPY"] = "ON" if compression in ("all", "snappy") else "OFF" + self.compile_sh_opt["ZLIB"] = "BUNDLED" if compression in ("all", "zlib") else "OFF" + self.compile_sh_opt["ZSTD"] = "ON" if compression in ("all", "zstd") else "OFF" + + if sanitize: + self.compile_sh_opt["SANITIZE"] = ",".join(sanitize) + + self.compile_sh_opt.update(type(self).cls_compile_sh_env) + + def additional_script_env(self) -> Mapping[str, str]: + return {} + + def to_dict(self): + task = super(CompileTask, self).to_dict() + commands = task["commands"] + assert isinstance(commands, MutableSequence), task + + commands.extend(self.prefix_commands) + + script = "env" + for opt, value in sorted(self.compile_sh_opt.items()): + script += ' %s="%s"' % (opt, value) + + script += " .evergreen/scripts/compile.sh" + + commands.append(func('find-cmake-latest')) + commands.append(shell_mongoc(script, add_expansions_to_env=True)) + commands.append(func("upload-build")) + commands.extend(self.suffix_commands) + return task + + def additional_tags(self) -> Iterable[str]: + yield from super().additional_tags() + yield from self.cls_tags + + +class SpecialTask(CompileTask): + cls_tags: ClassVar[Sequence[str]] = ["special"] + + +class CompileWithClientSideEncryption(CompileTask): + cls_compile_sh_env: ClassVar[Mapping[str, str]] = dict( + # Compiling with ClientSideEncryption support requires linking against the library libmongocrypt. + COMPILE_LIBMONGOCRYPT="ON", + EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON", + ) + cls_tags: ClassVar[Sequence[str]] = "client-side-encryption", "special" + + +class CompileWithClientSideEncryptionAsan(CompileTask): + cls_compile_sh_env: ClassVar[Mapping[str, str]] = dict( + CFLAGS="-fno-omit-frame-pointer", + COMPILE_LIBMONGOCRYPT="ON", + CHECK_LOG="ON", + PATH="/usr/lib/llvm-3.8/bin:$PATH", + ) + cls_tags: ClassVar[Sequence[str]] = ["client-side-encryption"] + cls_sanitize: ClassVar[Sequence[str]] = ["address"] + + +class LinkTask(NamedTask): + def __init__( + self, task_name: str, suffix_commands: Iterable[Value], orchestration: Literal[True, False, "ssl"] = True + ): + if orchestration == "ssl": + # Actual value of SSL does not matter here so long as it is not 'nossl'. + bootstrap_commands = [func("fetch-det"), func("bootstrap-mongo-orchestration", SSL="openssl")] + elif orchestration: + bootstrap_commands = [func("fetch-det"), func("bootstrap-mongo-orchestration")] + else: + bootstrap_commands = [] + + super().__init__( + task_name=task_name, + commands=bootstrap_commands + list(suffix_commands), + ) + + +all_tasks = [ + CompileTask( + "hardened-compile", + tags=["hardened"], + compression=None, + CFLAGS="-fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -fPIE -O", + LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now", + ), + CompileTask("debug-compile-compression-zlib", tags=["zlib", "compression"], compression="zlib"), + CompileTask("debug-compile-compression-snappy", tags=["snappy", "compression"], compression="snappy"), + CompileTask("debug-compile-compression-zstd", tags=["zstd", "compression"], compression="zstd"), + CompileTask("debug-compile-nosasl-nossl", tags=["debug-compile", "nosasl", "nossl"], SSL="OFF"), + CompileTask("debug-compile-lto", CFLAGS="-flto"), + CompileTask("debug-compile-lto-thin", CFLAGS="-flto=thin"), + CompileTask("debug-compile-no-counters", tags=["debug-compile", "no-counters"], ENABLE_SHM_COUNTERS="OFF"), + CompileTask("compile-tracing", TRACING="ON", CFLAGS="-Werror -Wno-cast-align"), + CompileTask("release-compile", config="release"), + CompileTask("debug-compile-nosasl-openssl", tags=["debug-compile", "nosasl", "openssl"], SSL="OPENSSL"), + CompileTask( + "debug-compile-nosasl-openssl-static", tags=["debug-compile", "nosasl", "openssl-static"], SSL="OPENSSL_STATIC" + ), + CompileTask("debug-compile-nosasl-darwinssl", tags=["debug-compile", "nosasl", "darwinssl"], SSL="DARWIN"), + CompileTask("debug-compile-nosasl-winssl", tags=["debug-compile", "nosasl", "winssl"], SSL="WINDOWS"), + CompileTask("debug-compile-sasl-openssl", tags=["debug-compile", "sasl", "openssl"], SASL="AUTO", SSL="OPENSSL"), + CompileTask( + "debug-compile-sasl-openssl-static", + tags=["debug-compile", "sasl", "openssl-static"], + SASL="AUTO", + SSL="OPENSSL_STATIC", + ), + CompileTask("debug-compile-sasl-darwinssl", tags=["debug-compile", "sasl", "darwinssl"], SASL="AUTO", SSL="DARWIN"), + CompileTask("debug-compile-rdtscp", ENABLE_RDTSCP="ON"), + CompileTask("debug-compile-sspi-winssl", tags=["debug-compile", "sspi", "winssl"], SASL="SSPI", SSL="WINDOWS"), + CompileTask("debug-compile-nosrv", tags=["debug-compile"], SRV="OFF"), + LinkTask("link-with-cmake", suffix_commands=[func("link sample program", BUILD_SAMPLE_WITH_CMAKE=1)]), + LinkTask( + "link-with-cmake-ssl", + suffix_commands=[func("link sample program", BUILD_SAMPLE_WITH_CMAKE=1, ENABLE_SSL=1)], + ), + LinkTask( + "link-with-cmake-snappy", + suffix_commands=[func("link sample program", BUILD_SAMPLE_WITH_CMAKE=1, ENABLE_SNAPPY="ON")], + ), + LinkTask("link-with-cmake-mac", suffix_commands=[func("link sample program", BUILD_SAMPLE_WITH_CMAKE=1)]), + LinkTask("link-with-cmake-windows", suffix_commands=[func("link sample program MSVC")]), + LinkTask( + "link-with-cmake-windows-ssl", + suffix_commands=[func("link sample program MSVC", ENABLE_SSL=1)], + orchestration="ssl", + ), + LinkTask("link-with-cmake-windows-snappy", suffix_commands=[func("link sample program MSVC", ENABLE_SNAPPY="ON")]), + LinkTask("link-with-cmake-mingw", suffix_commands=[func("link sample program mingw")]), + LinkTask("link-with-pkg-config", suffix_commands=[func("link sample program")]), + LinkTask("link-with-pkg-config-mac", suffix_commands=[func("link sample program")]), + LinkTask("link-with-pkg-config-ssl", suffix_commands=[func("link sample program", ENABLE_SSL=1)]), + LinkTask("link-with-bson", suffix_commands=[func("link sample program bson")], orchestration=False), + LinkTask("link-with-bson-mac", suffix_commands=[func("link sample program bson")], orchestration=False), + LinkTask("link-with-bson-windows", suffix_commands=[func("link sample program MSVC bson")], orchestration=False), + LinkTask("link-with-bson-mingw", suffix_commands=[func("link sample program mingw bson")], orchestration=False), + NamedTask( + "debian-package-build", + commands=[ + shell_mongoc('export IS_PATCH="${is_patch}"\n' ".evergreen/scripts/debian_package_build.sh"), + s3_put( + local_file="deb.tar.gz", + remote_file="${branch_name}/mongo-c-driver-debian-packages-${CURRENT_VERSION}.tar.gz", + content_type="${content_type|application/x-gzip}", + ), + s3_put( + local_file="deb.tar.gz", + remote_file="${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-debian-packages.tar.gz", + content_type="${content_type|application/x-gzip}", + ), + s3_put( + local_file="deb-i386.tar.gz", + remote_file="${branch_name}/mongo-c-driver-debian-packages-i386-${CURRENT_VERSION}.tar.gz", + content_type="${content_type|application/x-gzip}", + ), + s3_put( + local_file="deb-i386.tar.gz", + remote_file="${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-debian-packages-i386.tar.gz", + content_type="${content_type|application/x-gzip}", + ), + ], + ), + NamedTask( + "rpm-package-build", + commands=[ + shell_mongoc('export IS_PATCH="${is_patch}"\n' ".evergreen/scripts/check_rpm_spec.sh"), + shell_mongoc(".evergreen/scripts/build_snapshot_rpm.sh"), + s3_put( + local_file="rpm.tar.gz", + remote_file="${branch_name}/mongo-c-driver-rpm-packages-${CURRENT_VERSION}.tar.gz", + content_type="${content_type|application/x-gzip}", + ), + s3_put( + local_file="rpm.tar.gz", + remote_file="${branch_name}/${revision}/${version_id}/${build_id}/${execution}/mongo-c-driver-rpm-packages.tar.gz", + content_type="${content_type|application/x-gzip}", + ), + shell_mongoc("sudo rm -rf ../build ../mock-result ../rpm.tar.gz\n" "export MOCK_TARGET_CONFIG=rocky+epel-9-aarch64\n" ".evergreen/scripts/build_snapshot_rpm.sh"), + shell_mongoc("sudo rm -rf ../build ../mock-result ../rpm.tar.gz\n" "export MOCK_TARGET_CONFIG=rocky+epel-8-aarch64\n" ".evergreen/scripts/build_snapshot_rpm.sh"), + ], + ), + CompileTask("debug-compile-with-warnings", CFLAGS="-Werror -Wno-cast-align"), + CompileTask( + "debug-compile-nosasl-openssl-1.0.1", + prefix_commands=[func("install ssl", SSL="openssl-1.0.1u")], + CFLAGS="-Wno-redundant-decls", + SSL="OPENSSL", + SASL="OFF", + ), + NamedTask( + "build-and-test-with-toolchain", + commands=[ + OD( + [ + ("command", "s3.get"), + ( + "params", + OD( + [ + ("aws_key", "${aws_key}"), + ("aws_secret", "${aws_secret}"), + ("remote_file", "mongo-c-toolchain/${distro_id}/2023/06/07/mongo-c-toolchain.tar.gz"), + ("bucket", "mongo-c-toolchain"), + ("local_file", "mongo-c-toolchain.tar.gz"), + ] + ), + ), + ] + ), + shell_mongoc(".evergreen/scripts/build-and-test-with-toolchain.sh"), + ], + ), + NamedTask( + "install-libmongoc-after-libbson", + commands=[shell_mongoc(".evergreen/scripts/install-libmongoc-after-libbson.sh"),], + ), +] + + +class CoverageTask(MatrixTask): + axes = OD( + [ + ("version", ["latest"]), + ("topology", ["replica_set"]), + ("auth", [True]), + ("sasl", ["sasl"]), + ("ssl", ["openssl"]), + ("cse", [False, True]), + ] + ) + + def additional_tags(self) -> Iterable[str]: + yield from super().additional_tags() + yield "test-coverage" + yield str(self.settings.version) + if self.cse: + yield "client-side-encryption" + + def name_parts(self) -> Iterable[str]: + yield "test-coverage" + yield self.display("version") + yield self.display("topology").replace("_", "-") + yield from map(self.display, ("auth", "sasl", "ssl")) + if self.settings.cse: + yield "cse" + + @property + def cse(self) -> bool: + return bool(self.settings.cse) + + def post_commands(self) -> Iterable[Value]: + if self.cse: + yield func( + "compile coverage", + SASL="AUTO", + SSL="OPENSSL", + COMPILE_LIBMONGOCRYPT="ON", + EXTRA_CONFIGURE_FLAGS='EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON"', + ) + else: + yield func("compile coverage", SASL="AUTO", SSL="OPENSSL") + + yield func("fetch-det") + yield func( + "bootstrap-mongo-orchestration", + MONGODB_VERSION=self.settings.version, + TOPOLOGY=self.settings.topology, + AUTH=self.display("auth"), + SSL=self.display("ssl"), + ) + yield func("run-simple-http-server") + extra = {"COVERAGE": "ON"} + if self.cse: + extra["CLIENT_SIDE_ENCRYPTION"] = "ON" + yield func("run-mock-kms-servers") + yield func("run-tests", AUTH=self.display("auth"), SSL=self.display("ssl"), **extra) + yield func("upload coverage") + yield func("update codecov.io") + + def do_is_valid_combination(self) -> bool: + # Limit coverage tests to test-coverage-latest-replica-set-auth-sasl-openssl (+ cse). + require(self.setting_eq("topology", "replica_set")) + require(self.setting_eq("sasl", "sasl")) + require(self.setting_eq("ssl", "openssl")) + require(self.setting_eq("version", "latest")) + require(self.settings.auth is True) + + if not self.cse: + # No further requirements + return True + + # CSE has extra requirements + if self.settings.version != "latest": + # We only work with 4.2 or newer for CSE + require(Version(str(self.settings.version)) >= Version("4.2")) + return True + + +all_tasks = chain(all_tasks, CoverageTask.matrix()) + + +class DNSTask(MatrixTask): + axes = OD( + [ + ("auth", [False, True]), + ("loadbalanced", [False, True]), + ("ssl", ["openssl", "winssl", "darwinssl"]), + ] + ) + + name_prefix = "test-dns" + + def additional_dependencies(self) -> Iterable[DependencySpec]: + yield self.build_task_name + + @property + def build_task_name(self) -> str: + sasl = "sspi" if self.settings.ssl == "winssl" else "sasl" + return f'debug-compile-{sasl}-{self.display("ssl")}' + + def name_parts(self) -> Iterable[str]: + yield "test-dns" + if self.settings.auth: + yield "auth" + if self.settings.loadbalanced: + yield "loadbalanced" + yield self.display("ssl") + + def post_commands(self) -> Iterable[Value]: + yield func("fetch-build", BUILD_NAME=self.build_task_name) + yield func("fetch-det") + if self.settings.loadbalanced: + orchestration = func( + "bootstrap-mongo-orchestration", + TOPOLOGY="sharded_cluster", + AUTH="auth" if self.settings.auth else "noauth", + SSL="ssl", + LOAD_BALANCER="on", + ) + else: + orchestration = func( + "bootstrap-mongo-orchestration", + TOPOLOGY="replica_set", + AUTH="auth" if self.settings.auth else "noauth", + SSL="ssl", + ) + + yield orchestration + + dns = "on" + if self.settings.loadbalanced: + dns = "loadbalanced" + yield func("fetch-det") + yield func("start-load-balancer", MONGODB_URI="mongodb://localhost:27017,localhost:27018") + elif self.settings.auth: + dns = "dns-auth" + yield func("run-tests", SSL="ssl", AUTH=self.display("auth"), DNS=dns) + + def do_is_valid_combination(self) -> bool: + prohibit(bool(self.settings.loadbalanced) and bool(self.settings.auth)) + # Load balancer tests only run on some Linux hosts in Evergreen until CDRIVER-4041 is resolved. + prohibit(bool(self.settings.loadbalanced) and self.settings.ssl in ["darwinssl", "winssl"]) + return True + + +all_tasks = chain(all_tasks, DNSTask.matrix()) + + +class CompressionTask(MatrixTask): + axes = OD([("compression", ["zlib", "snappy", "zstd"])]) + name_prefix = "test-latest-server" + + def additional_dependencies(self) -> Iterable[DependencySpec]: + yield self.build_task_name + + @property + def build_task_name(self) -> str: + return f"debug-compile-{self._compressor_suffix()}" + + def additional_tags(self) -> Iterable[str]: + yield from super().additional_tags() + yield "compression" + yield "latest" + yield from self._compressor_list() + + def name_parts(self) -> Iterable[str]: + return [self.name_prefix, self._compressor_suffix()] + + def post_commands(self) -> Iterable[Value]: + yield func("fetch-build", BUILD_NAME=self.build_task_name) + yield func("fetch-det") + yield func("bootstrap-mongo-orchestration", AUTH="noauth", SSL="nossl") + yield func("run-simple-http-server") + yield func("run-tests", AUTH="noauth", SSL="nossl", COMPRESSORS=",".join(self._compressor_list())) + + def _compressor_suffix(self): + if self.settings.compression == "zlib": + return "compression-zlib" + elif self.settings.compression == "snappy": + return "compression-snappy" + elif self.settings.compression == "zstd": + return "compression-zstd" + else: + return "compression" + + def _compressor_list(self): + if self.settings.compression == "zlib": + return ["zlib"] + elif self.settings.compression == "snappy": + return ["snappy"] + elif self.settings.compression == "zstd": + return ["zstd"] + else: + return ["snappy", "zlib", "zstd"] + + +all_tasks = chain(all_tasks, CompressionTask.matrix()) + + +class SpecialIntegrationTask(NamedTask): + def __init__( + self, + task_name: str, + main_dep: str = "debug-compile-sasl-openssl", + uri: str | None = None, + tags: Iterable[str] = (), + version: str = "latest", + topology: str = "server", + ): + self._main_dep = main_dep + super().__init__(task_name, depends_on=[self._main_dep], tags=tags) + self._uri = uri + self._version = version + self._topo = topology + + def pre_commands(self) -> Iterable[Value]: + yield func("fetch-build", BUILD_NAME=self._main_dep) + yield func("fetch-det") + yield func("bootstrap-mongo-orchestration", MONGODB_VERSION=self._version, TOPOLOGY=self._topo) + yield func("run-simple-http-server") + yield func("run-tests", URI=self._uri) + + +all_tasks = chain( + all_tasks, + [ + # Verify that retryWrites=true is ignored with standalone. + SpecialIntegrationTask("retry-true-latest-server", uri="mongodb://localhost/?retryWrites=true"), + SpecialIntegrationTask("test-latest-server-hardened", "hardened-compile", tags=["hardened", "latest"]), + ], +) + + +class AuthTask(MatrixTask): + axes = OD([("sasl", ["sasl", "sspi", False]), ("ssl", ["openssl", "darwinssl", "winssl"])]) + + name_prefix = "authentication-tests" + + def additional_tags(self) -> Iterable[str]: + yield from super().additional_tags() + yield "authentication-tests" + yield self.display("ssl") + yield self.display("sasl") + + def additional_dependencies(self) -> Iterable[DependencySpec]: + yield self.build_task_name + + def post_commands(self) -> Iterable[Value]: + yield func("fetch-build", BUILD_NAME=self.build_task_name) + yield func("run auth tests") + + @property + def build_task_name(self) -> str: + return f'debug-compile-{self.display("sasl")}-{self.display("ssl")}' + + def name_parts(self) -> Iterable[str]: + yield self.name_prefix + yield self.display("ssl") + if not self.settings.sasl: + yield "nosasl" + + def do_is_valid_combination(self) -> bool: + both_or_neither(self.settings.ssl == "winssl", self.settings.sasl == "sspi") + if not self.settings.sasl: + require(self.settings.ssl == "openssl") + return True + + +all_tasks = chain(all_tasks, AuthTask.matrix()) + + +class PostCompileTask(NamedTask): + def __init__(self, name: str, tags: Iterable[str], get_build: str, commands: Iterable[Value]): + super().__init__(name, commands=commands, tags=tags, depends_on=[get_build]) + self._dep = get_build + + def pre_commands(self) -> Iterable[Value]: + yield func("fetch-build", BUILD_NAME=self._dep) + + +all_tasks = chain( + all_tasks, + [ + PostCompileTask( + "test-mongohouse", + tags=[], + get_build="debug-compile-sasl-openssl", + commands=[func("fetch-det"), func("build mongohouse"), func("run mongohouse"), func("test mongohouse")], + ), + NamedTask( + "authentication-tests-asan-memcheck", + tags=["authentication-tests", "asan"], + commands=[ + func("find-cmake-latest"), + shell_mongoc( + """ + env SANITIZE=address SASL=AUTO SSL=OPENSSL .evergreen/scripts/compile.sh + """, + add_expansions_to_env=True, + ), + func("run auth tests", ASAN="on"), + ], + ) + ], +) + +# Add API version tasks. +for server_version in [ "8.0", "7.0", "6.0", "5.0"]: + all_tasks = chain( + all_tasks, + [ + PostCompileTask( + "test-versioned-api-" + server_version, + tags=["versioned-api", f"{server_version}"], + get_build="debug-compile-nosasl-openssl", + commands=[ + func("fetch-det"), + func( + "bootstrap-mongo-orchestration", + TOPOLOGY="server", + AUTH="auth", + SSL="ssl", + MONGODB_VERSION=server_version, + REQUIRE_API_VERSION="true", + ), + func("run-simple-http-server"), + func("run-tests", MONGODB_API_VERSION=1, AUTH="auth", SSL="ssl"), + ], + ), + PostCompileTask( + "test-versioned-api-accept-version-two-" + server_version, + tags=["versioned-api", f"{server_version}"], + get_build="debug-compile-nosasl-nossl", + commands=[ + func("fetch-det"), + func( + "bootstrap-mongo-orchestration", + TOPOLOGY="server", + AUTH="noauth", + SSL="nossl", + MONGODB_VERSION=server_version, + ORCHESTRATION_FILE="versioned-api-testing.json", + ), + func("run-simple-http-server"), + func("run-tests", MONGODB_API_VERSION=1, AUTH="noauth", SSL="nossl"), + ], + ) + ] + ) + + +class SSLTask(Task): + def __init__( + self, + version: str, + patch: str, + cflags: str = "", + fips: bool = False, + enable_ssl: str | Literal[False] = False, + test_params: Mapping[str, Scalar] | None = None, + ): + full_version = version + patch + ("-fips" if fips else "") + self.enable_ssl = enable_ssl + script = "env" + if cflags: + script += f" CFLAGS={cflags}" + + script += " SASL=OFF" + + if enable_ssl is not False: + script += " SSL=" + enable_ssl + else: + script += " SSL=OPENSSL" + + script += " .evergreen/scripts/compile.sh" + + super(SSLTask, self).__init__( + commands=[ + func("install ssl", SSL=full_version), + func("find-cmake-latest"), + shell_mongoc(script, add_expansions_to_env=True), + func("run auth tests", **(test_params or {})), + func("upload-build"), + ] + ) + + self.version = version + self.fips = fips + + @property + def name(self): + s = "build-and-run-authentication-tests-" + self.version + if self.fips: + return s + "-fips" + if self.enable_ssl is not False: + return s + "-" + str(self.enable_ssl).lower() + + return s + + +all_tasks = chain( + all_tasks, + [ + SSLTask( + "openssl-1.0.1", + "u", + cflags="-Wno-redundant-decls", + ), + SSLTask("openssl-1.0.1", "u", cflags="-Wno-redundant-decls", fips=True), + SSLTask( + "openssl-1.0.2", + "l", + cflags="-Wno-redundant-decls", + ), + SSLTask("openssl-1.1.0", "l") + ], +) + + +class IPTask(MatrixTask): + axes = OD( + [ + ("client", ["ipv6", "ipv4", "localhost"]), + ("server", ["ipv6", "ipv4"]), + ] + ) + + name_prefix = "test-latest" + + def additional_dependencies(self) -> Iterable[DependencySpec]: + yield "debug-compile-nosasl-nossl" + + def additional_tags(self) -> Iterable[str]: + yield from super().additional_tags() + yield from ("nossl", "nosasl", "server", "ipv4-ipv6", "latest") + + def post_commands(self) -> Iterable[Value]: + return [ + func("fetch-build", BUILD_NAME="debug-compile-nosasl-nossl"), + func("fetch-det"), + func("bootstrap-mongo-orchestration"), + func("run-simple-http-server"), + func( + "run-tests", + URI={ + "ipv6": "mongodb://[::1]/", + "ipv4": "mongodb://127.0.0.1/", + "localhost": "mongodb://localhost/", + }[str(self.settings.client)], + ), + ] + + def name_parts(self) -> Iterable[str]: + return ( + self.name_prefix, + f'server-{self.display("server")}', + f'client-{self.display("client")}', + "noauth", + "nosasl", + "nossl", + ) + + def do_is_valid_combination(self) -> bool: + # This would fail by design. + if self.settings.server == "ipv4": + prohibit(self.settings.client == "ipv6") + + # Default configuration is tested in other variants. + if self.settings.server == "ipv6": + prohibit(self.settings.client == "localhost") + return True + + +all_tasks = chain(all_tasks, IPTask.matrix()) + +aws_compile_task = NamedTask( + "debug-compile-aws", + commands=[ + func('find-cmake-latest'), + shell_mongoc( + """ + export distro_id='${distro_id}' # Required by find_cmake_latest. + . .evergreen/scripts/find-cmake-latest.sh + cmake_binary="$(find_cmake_latest)" + + # Use ccache if able. + . .evergreen/scripts/find-ccache.sh + find_ccache_and_export_vars "$(pwd)" || true + + # Compile test-awsauth. Disable unnecessary dependencies since test-awsauth is copied to a remote Ubuntu 20.04 ECS cluster for testing, which may not have all dependent libraries. + export CC='${CC}' + "$cmake_binary" -DENABLE_TRACING=ON -DENABLE_SASL=OFF -DENABLE_SNAPPY=OFF -DENABLE_ZSTD=OFF -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF . + "$cmake_binary" --build . --target test-awsauth + """ + ), + func("upload-build"), + ], +) + +all_tasks = chain(all_tasks, [aws_compile_task]) + + +class AWSTestTask(MatrixTask): + axes = OD( + [ + ("testcase", ["regular", "ec2", "ecs", "lambda", "assume_role", "assume_role_with_web_identity"]), + ("version", ["latest", "8.0", "7.0", "6.0", "5.0", "4.4"]), + ] + ) + + name_prefix = "test-aws-openssl" + + def additional_dependencies(self) -> Iterable[DependencySpec]: + yield "debug-compile-aws" + + def additional_tags(self) -> Iterable[str]: + yield from super().additional_tags() + yield f'{self.settings.version}' + yield f'test-aws' + + def post_commands(self) -> Iterable[Value]: + return [ + func("fetch-build", BUILD_NAME="debug-compile-aws"), + func("fetch-det"), + func( + "bootstrap-mongo-orchestration", + AUTH="auth", + ORCHESTRATION_FILE="auth-aws.json", + MONGODB_VERSION=self.settings.version, + TOPOLOGY="server", + ), + func("run aws tests", TESTCASE=str(self.settings.testcase).upper()), + ] + + @property + def name(self): + return f"{self.name_prefix}-{self.settings.testcase}-{self.settings.version}" + + +all_tasks = chain(all_tasks, AWSTestTask.matrix()) + + +class OCSPTask(MatrixTask): + axes = OD( + [ + ( + "test", + [ + "test_1", + "test_2", + "test_3", + "test_4", + "soft_fail_test", + "malicious_server_test_1", + "malicious_server_test_2", + "cache", + ], + ), + ("delegate", ["delegate", "nodelegate"]), + ("cert", ["rsa", "ecdsa"]), + ("ssl", ["openssl", "openssl-1.0.1", "darwinssl", "winssl"]), + ("version", ["latest", "8.0", "7.0", "6.0", "5.0", "4.4"]), + ] + ) + + name_prefix = "test-ocsp" + + @property + def build_task_name(self) -> str: + return f'debug-compile-nosasl-{self.display("ssl")}' + + def additional_tags(self) -> Iterable[str]: + yield from super().additional_tags() + yield f'ocsp-{self.display("ssl")}' + + def additional_dependencies(self) -> Iterable[DependencySpec]: + yield self.build_task_name + + @property + def name(self): + return f"ocsp-{self.settings.ssl}-{self.test}-{self.settings.cert}-{self.settings.delegate}-{self.settings.version}" + + @property + def test(self) -> str: + return str(self.settings.test) + + def post_commands(self) -> Iterable[Value]: + yield func("fetch-build", BUILD_NAME=self.build_task_name) + yield func("fetch-det") + + stapling = "mustStaple" + if self.test in ["test_3", "test_4", "soft_fail_test", "cache"]: + stapling = "disableStapling" + if self.test in ["malicious_server_test_1", "malicious_server_test_2"]: + stapling = "mustStaple-disableStapling" + + orchestration = func( + "bootstrap-mongo-orchestration", + MONGODB_VERSION=self.settings.version, + TOPOLOGY="server", + SSL="ssl", + OCSP="on", + ORCHESTRATION_FILE=f"{self.settings.cert}-basic-tls-ocsp-{stapling}.json", + ) + + # The cache test expects a revoked response from an OCSP responder, exactly like TEST_4. + test_column = "TEST_4" if self.test == "cache" else str(self.test).upper() + use_delegate = "ON" if self.settings.delegate == "delegate" else "OFF" + + yield ( + shell_mongoc( + f""" + TEST_COLUMN={test_column} CERT_TYPE={self.settings.cert} USE_DELEGATE={use_delegate} .evergreen/scripts/run-ocsp-responder.sh + """ + ) + ) + + yield (orchestration) + + if self.build_task_name == "debug-compile-nosasl-openssl-1.0.1": + # LD_LIBRARY_PATH is needed so the in-tree OpenSSL 1.0.1 is found at runtime + if self.test == "cache": + yield ( + shell_mongoc( + f""" + LD_LIBRARY_PATH=$(pwd)/install-dir/lib CERT_TYPE={self.settings.cert} .evergreen/scripts/run-ocsp-cache-test.sh + """ + ) + ) + else: + yield ( + shell_mongoc( + f""" + LD_LIBRARY_PATH=$(pwd)/install-dir/lib TEST_COLUMN={self.test.upper()} CERT_TYPE={self.settings.cert} .evergreen/scripts/run-ocsp-test.sh + """ + ) + ) + else: + if self.test == "cache": + yield ( + shell_mongoc( + f""" + CERT_TYPE={self.settings.cert} .evergreen/scripts/run-ocsp-cache-test.sh + """ + ) + ) + else: + yield ( + shell_mongoc( + f""" + TEST_COLUMN={self.test.upper()} CERT_TYPE={self.settings.cert} .evergreen/scripts/run-ocsp-test.sh + """ + ) + ) + + def to_dict(self): + task = super(MatrixTask, self).to_dict() + + # OCSP tests should run with a batchtime of 14 days. Avoid running OCSP + # tests in patch builds by default (only in commit builds). + task["patchable"] = False + + return task + + # Testing in OCSP has a lot of exceptions. + def do_is_valid_combination(self) -> bool: + if self.settings.ssl == "darwinssl": + # Secure Transport quietly ignores a must-staple certificate with no stapled response. + prohibit(self.test == "malicious_server_test_2") + + # ECDSA certs can't be loaded (in the PEM format they're stored) on Windows/macOS. Skip them. + if self.settings.ssl == "darwinssl" or self.settings.ssl == "winssl": + prohibit(self.settings.cert == "ecdsa") + + # OCSP stapling is not supported on macOS or Windows. + if self.settings.ssl == "darwinssl" or self.settings.ssl == "winssl": + prohibit(self.test in ["test_1", "test_2", "cache"]) + + if self.test == "soft_fail_test" or self.test == "malicious_server_test_2" or self.test == "cache": + prohibit(self.settings.delegate == "delegate") + return True + + +all_tasks = chain(all_tasks, OCSPTask.matrix()) + +all_tasks = list(all_tasks) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/testazurekms.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/testazurekms.py similarity index 92% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/testazurekms.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/testazurekms.py index acf16b35d..5160fa73e 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/testazurekms.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/testazurekms.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2022-present MongoDB, Inc. +# Copyright 2009-present MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,11 +29,12 @@ def _create_tasks(): passtask = NamedTask(task_name="testazurekms-task") passtask.commands = [ func("fetch-source"), + func("find-cmake-latest"), shell_exec( r""" echo "Building test-azurekms ... begin" pushd mongoc - ./.evergreen/scripts/compile-test-azurekms.sh + .evergreen/scripts/compile-test-azurekms.sh popd echo "Building test-azurekms ... end" @@ -73,10 +74,11 @@ def _create_tasks(): failtask = NamedTask(task_name="testazurekms-fail-task") failtask.commands = [ func("fetch-source"), + func("find-cmake-latest"), shell_exec( r""" pushd mongoc - ./.evergreen/scripts/compile-test-azurekms.sh + .evergreen/scripts/compile-test-azurekms.sh popd """, test=False, @@ -101,7 +103,7 @@ def _create_variant(): name="testazurekms-variant", display_name="Azure KMS", # Azure Virtual Machine created is Debian 10. - run_on="debian10-small", + run_on="debian11-small", tasks=["testazurekms_task_group", "testazurekms-fail-task"], batchtime=20160, ) # Use a batchtime of 14 days as suggested by the CSFLE test README @@ -113,6 +115,13 @@ def _create_task_group(): task_group.setup_group_timeout_secs = 1800 # 30 minutes task_group.setup_group = [ func("fetch-det"), + # Assume role to get AWS secrets. + { + "command": "ec2.assume_role", + "params": { + "role_arn": "${aws_test_secrets_role}" + } + }, shell_exec( r""" DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools @@ -132,6 +141,7 @@ def _create_task_group(): $DRIVERS_TOOLS/.evergreen/csfle/azurekms/create-and-setup-vm.sh """, test=False, + include_expansions_in_env=[ "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN" ] ), # Load the AZUREKMS_VMNAME expansion. OD( diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/testgcpkms.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/testgcpkms.py similarity index 94% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/testgcpkms.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/testgcpkms.py index bfdb6170b..ccdf67200 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/evergreen_config_lib/testgcpkms.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/testgcpkms.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2022 - present MongoDB, Inc. +# Copyright 2009-present MongoDB, Inc. # # Licensed under the Apache License, Version 2.0(the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ from collections import OrderedDict as OD from typing import MutableSequence +from config_generator.components.funcs.find_cmake_latest import FindCMakeLatest + from evergreen_config_generator.functions import shell_exec, func from evergreen_config_generator.tasks import NamedTask from evergreen_config_generator.variants import Variant @@ -28,11 +30,12 @@ def _create_tasks(): task_name="testgcpkms-task", commands=[ func("fetch-source"), + func("find-cmake-latest"), shell_exec( r""" echo "Building test-gcpkms ... begin" pushd mongoc - ./.evergreen/scripts/compile-test-gcpkms.sh + .evergreen/scripts/compile-test-gcpkms.sh popd echo "Building test-gcpkms ... end" echo "Copying files ... begin" @@ -69,10 +72,11 @@ def _create_tasks(): failtask = NamedTask( task_name="testgcpkms-fail-task", commands=[ + func("find-cmake-latest"), shell_exec( r""" pushd mongoc - ./.evergreen/scripts/compile-test-gcpkms.sh + .evergreen/scripts/compile-test-gcpkms.sh popd""", test=False, add_expansions_to_env=True, diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/variants.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/variants.py new file mode 100644 index 000000000..79eacf67d --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/evergreen_config_lib/variants.py @@ -0,0 +1,385 @@ +# Copyright 2009-present MongoDB, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from collections import OrderedDict as OD + +from evergreen_config_generator.variants import Variant + + +mobile_flags = ( + " -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY" + " -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY" + " -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER" + " -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY" +) + + +def days(n: int) -> int: + "Calculate the number of minutes in the given number of days" + return n * 24 * 60 + + +all_variants = [ + Variant( + "abi-compliance-check", + "ABI Compliance Check", + ["ubuntu2004-small", "ubuntu2004-medium", "ubuntu2004-large"], + ["abi-compliance-check"], + ), + Variant( + "smoke", + "Smoke Tests", + "ubuntu2204-small", + [ + "make-docs", + "kms-divergence-check", + "release-compile", + "debug-compile-no-counters", + "compile-tracing", + "link-with-cmake", + "link-with-cmake-ssl", + "link-with-cmake-snappy", + "verify-headers", + OD([("name", "link-with-cmake-mac"), ("distros", ["macos-14-arm64"])]), + OD([("name", "link-with-cmake-windows"), ("distros", ["windows-vsCurrent-large"])]), + OD([("name", "link-with-cmake-windows-ssl"), ("distros", ["windows-vsCurrent-large"])]), + OD([("name", "link-with-cmake-windows-snappy"), ("distros", ["windows-vsCurrent-large"])]), + OD([("name", "link-with-cmake-mingw"), ("distros", ["windows-vsCurrent-large"])]), + OD([("name", "link-with-pkg-config"), ("distros", ["ubuntu2004-test"])]), + OD([("name", "link-with-pkg-config-mac"), ("distros", ["macos-14-arm64"])]), + "link-with-pkg-config-ssl", + "link-with-bson", + OD([("name", "link-with-bson-windows"), ("distros", ["windows-vsCurrent-large"])]), + OD([("name", "link-with-bson-mac"), ("distros", ["macos-14-arm64"])]), + OD([("name", "link-with-bson-mingw"), ("distros", ["windows-vsCurrent-large"])]), + "check-headers", + "debug-compile-with-warnings", + OD([("name", "build-and-test-with-toolchain"), ("distros", ["debian11-small"])]), + "install-libmongoc-after-libbson", + ], + { + # Disable the MongoDB legacy shell download, which is not available in 5.0 for u22 + "SKIP_LEGACY_SHELL": "1" + }, + tags=["pr-merge-gate"], + ), + Variant( + "openssl", + "OpenSSL", + "archlinux-build", + [ + "build-and-run-authentication-tests-openssl-1.0.1", + "build-and-run-authentication-tests-openssl-1.0.2", + "build-and-run-authentication-tests-openssl-1.1.0", + "build-and-run-authentication-tests-openssl-1.0.1-fips", + ], + {}, + ), + Variant( + "clang37", + "clang 3.7 (Archlinux)", + "archlinux-test", + [ + "release-compile", + "debug-compile-sasl-openssl", + "debug-compile-nosasl-openssl", + ".authentication-tests .openssl", + ], + {"CC": "clang"}, + ), + Variant( + "clang100-i686", + "clang 10.0 (i686) (Ubuntu 20.04)", + "ubuntu2004-test", + [ + "release-compile", + "debug-compile-nosasl-nossl", + ".debug-compile !.sspi .nossl .nosasl", + ".latest .nossl .nosasl", + ], + {"CC": "clang", "MARCH": "i686"}, + ), + Variant( + "gcc82rhel", + "GCC 8.2 (RHEL 8.0)", + "rhel80-test", + [ + ".hardened", + ".compression !.snappy !.zstd", + "release-compile", + "debug-compile-nosasl-nossl", + "debug-compile-nosasl-openssl", + "debug-compile-sasl-openssl", + ".authentication-tests .openssl", + ".latest .nossl", + ], + {"CC": "gcc"}, + ), + Variant( + "gcc102", + "GCC 10.2 (Debian 11.0)", + "debian11-large", + ["release-compile", "debug-compile-nosasl-nossl", ".latest .nossl"], + {"CC": "gcc"}, + ), + Variant( + "gcc94-i686", + "GCC 9.4 (i686) (Ubuntu 20.04)", + "ubuntu2004-test", + ["release-compile", "debug-compile-nosasl-nossl", ".latest .nossl .nosasl"], + {"CC": "gcc", "MARCH": "i686"}, + ), + Variant( + "gcc94", + "GCC 9.4 (Ubuntu 20.04)", + "ubuntu2004-test", + [ + ".compression !.zstd", + "debug-compile-nosrv", + "release-compile", + "debug-compile-nosasl-nossl", + "debug-compile-sasl-openssl", + "debug-compile-nosasl-openssl", + ".authentication-tests .openssl", + ".authentication-tests .asan", + ".test-coverage", + ".latest .nossl", + "retry-true-latest-server", + "test-dns-openssl", + "test-dns-auth-openssl", + "test-dns-loadbalanced-openssl", + ], + {"CC": "gcc"}, + ), + Variant( + "darwin", + "*Darwin, macOS (Apple LLVM)", + "macos-14-arm64", + [ + ".compression !.snappy", + "release-compile", + "debug-compile-nosasl-nossl", + "debug-compile-nosrv", + "debug-compile-sasl-darwinssl", + "debug-compile-nosasl-nossl", + ".authentication-tests .darwinssl", + ".latest .nossl", + "test-dns-darwinssl", + "test-dns-auth-darwinssl", + "debug-compile-lto", + "debug-compile-lto-thin", + "debug-compile-aws", + "test-aws-openssl-regular-latest", + ], + {"CC": "clang"}, + ), + Variant( + "darwin-intel", + "*Darwin, Intel macOS (Apple LLVM)", + "macos-14", + [ + "debug-compile-aws", + "debug-compile-rdtscp", + "test-aws-openssl-regular-4.4", + ], + {"CC": "clang"}, + ), + Variant( + "windows-2017-32", + "Windows (i686) (VS 2017)", + "windows-vsCurrent-large", + ["debug-compile-nosasl-nossl", ".latest .nossl .nosasl"], + {"CC": "Visual Studio 15 2017"}, + ), + Variant( + "windows-2017", + "Windows (VS 2017)", + "windows-vsCurrent-large", + [ + "release-compile", + "debug-compile-nosasl-nossl", + "debug-compile-nosasl-openssl", + "debug-compile-sspi-winssl", + "debug-compile-nosrv", + ".latest .nossl", + ".nosasl .latest .nossl", + ".compression !.snappy !.zstd !.latest", + "test-dns-winssl", + "test-dns-auth-winssl", + "debug-compile-aws", + "test-aws-openssl-regular-4.4", + "test-aws-openssl-regular-latest", + # Authentication tests with OpenSSL on Windows are only run on the vs2017 variant. + # Older vs variants fail to verify certificates against Atlas tests. + ".authentication-tests .openssl !.sasl", + ".authentication-tests .winssl", + ], + {"CC": "Visual Studio 15 2017 Win64"}, + ), + Variant( + "mingw-windows2016", + "MinGW-W64 (Windows Server 2016)", + "windows-vsCurrent-large", + ["debug-compile-nosasl-nossl", ".latest .nossl .nosasl .server"], + {"CC": "mingw"}, + ), + Variant( + "rhel8-power", + "Power (ppc64le) (RHEL 8)", + "rhel8-power-large", + [ + "release-compile", + "debug-compile-nosasl-nossl", + "debug-compile-sasl-openssl", + ".latest .nossl", + "test-dns-openssl", + ], + {"CC": "gcc"}, + patchable=False, + batchtime=days(1), + ), + Variant( + "arm-ubuntu2004", + "*ARM (aarch64) (Ubuntu 20.04)", + "ubuntu2004-arm64-large", + [ + ".compression !.snappy !.zstd", + "release-compile", + "debug-compile-nosasl-nossl", + "debug-compile-nosasl-openssl", + "debug-compile-sasl-openssl", + ".authentication-tests .openssl", + ".latest .nossl", + "test-dns-openssl", + ], + {"CC": "gcc"}, + batchtime=days(1), + ), + Variant( + "zseries-rhel8", + "*zSeries", + "rhel8-zseries-large", + [ + "release-compile", + # '.compression', --> TODO: waiting on ticket CDRIVER-3258 + "debug-compile-nosasl-nossl", + "debug-compile-nosasl-openssl", + "debug-compile-sasl-openssl", + ".authentication-tests .openssl", + ".latest .nossl", + ], + {"CC": "gcc"}, + patchable=False, + batchtime=days(1), + ), + Variant( + "clang100ubuntu", + "clang 10.0 (Ubuntu 20.04)", + "ubuntu2004-test", + [ + "debug-compile-sasl-openssl-static", + ".authentication-tests .asan", + ], + {"CC": "clang"}, + ), + # Run AWS tests for MongoDB 4.4 and 5.0 on Ubuntu 20.04. AWS setup scripts + # expect Ubuntu 20.04+. MongoDB 4.4 and 5.0 are not available on 22.04. + Variant( + "aws-ubuntu2004", + "AWS Tests (Ubuntu 20.04)", + "ubuntu2004-small", + [ + "debug-compile-aws", + ".test-aws .4.4", + ".test-aws .5.0", + ], + {"CC": "clang"}, + ), + Variant( + "aws-ubuntu2204", + "AWS Tests (Ubuntu 22.04)", + "ubuntu2004-small", + [ + "debug-compile-aws", + ".test-aws .6.0", + ".test-aws .7.0", + ".test-aws .8.0", + ".test-aws .latest", + ], + {"CC": "clang"}, + ), + Variant("mongohouse", "Mongohouse Test", "ubuntu2204-small", ["debug-compile-sasl-openssl", "test-mongohouse"], {}), + Variant( + "ocsp", + "OCSP tests", + "ubuntu2004-small", + [ + OD([("name", "debug-compile-nosasl-openssl")]), + OD([("name", "debug-compile-nosasl-openssl-static")]), + OD([("name", "debug-compile-nosasl-darwinssl"), ("distros", ["macos-14-arm64"])]), + OD([("name", "debug-compile-nosasl-winssl"), ("distros", ["windows-vsCurrent-large"])]), + OD([("name", ".ocsp-openssl")]), + OD([("name", ".ocsp-darwinssl"), ("distros", ["macos-14-arm64"])]), + OD([("name", ".ocsp-winssl"), ("distros", ["windows-vsCurrent-large"])]), + OD([("name", "debug-compile-nosasl-openssl-1.0.1")]), + OD([("name", ".ocsp-openssl-1.0.1")]), + ], + {}, + batchtime=days(7), + display_tasks=[ + { + "name": "ocsp-openssl", + "execution_tasks": [".ocsp-openssl"], + }, + { + "name": "ocsp-darwinssl", + "execution_tasks": [".ocsp-darwinssl"], + }, + { + "name": "ocsp-winssl", + "execution_tasks": [".ocsp-winssl"], + }, + { + "name": "ocsp-openssl-1.0.1", + "execution_tasks": [".ocsp-openssl-1.0.1"], + }, + ], + ), + Variant( + "packaging", + "Linux Distro Packaging", + "debian12-latest-small", + [ + "debian-package-build", + OD([("name", "rpm-package-build"), ("distros", ["rhel90-arm64-small"])]), + ], + {}, + tags=["pr-merge-gate"], + ), + # Test 7.0+ with Ubuntu 20.04+ since MongoDB 7.0 no longer ships binaries for Ubuntu 18.04. + Variant( + "versioned-api-ubuntu2004", + "Versioned API Tests (Ubuntu 20.04)", + "ubuntu2004-test", + [ + "debug-compile-nosasl-openssl", + "debug-compile-nosasl-nossl", + ".versioned-api .5.0", + ".versioned-api .6.0", + ".versioned-api .7.0", + ".versioned-api .8.0", + ], + {}, + ), +] diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/generate-evergreen-config.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/generate-evergreen-config.py similarity index 97% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/generate-evergreen-config.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/generate-evergreen-config.py index c3088d207..904581b57 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/legacy_config_generator/generate-evergreen-config.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/legacy_config_generator/generate-evergreen-config.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2018-present MongoDB, Inc. +# Copyright 2009-present MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/README.md b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/README.md similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/README.md rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/README.md diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/README.txt b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/README.txt similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/README.txt rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/README.txt diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/certs.yml b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/certs.yml similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/certs.yml rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/certs.yml diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/ca.crt b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/ca.crt similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/ca.crt rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/ca.crt diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/ca.key b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/ca.key similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/ca.key rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/ca.key diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/ca.pem b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/ca.pem similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/ca.pem rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/ca.pem diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/mock-delegate-revoked.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/mock-delegate-revoked.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/mock-delegate-revoked.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/mock-delegate-revoked.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/mock-delegate-valid.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/mock-delegate-valid.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/mock-delegate-valid.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/mock-delegate-valid.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/mock-revoked.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/mock-revoked.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/mock-revoked.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/mock-revoked.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/mock-valid.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/mock-valid.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/mock-valid.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/mock-valid.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/ocsp-responder.crt b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/ocsp-responder.crt similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/ocsp-responder.crt rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/ocsp-responder.crt diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/ocsp-responder.key b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/ocsp-responder.key similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/ocsp-responder.key rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/ocsp-responder.key diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/rename.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/rename.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/rename.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/rename.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/server-mustStaple.pem b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/server-mustStaple.pem similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/server-mustStaple.pem rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/server-mustStaple.pem diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/server.pem b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/server.pem similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ecdsa/server.pem rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ecdsa/server.pem diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/mock_ocsp_responder.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/mock_ocsp_responder.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/mock_ocsp_responder.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/mock_ocsp_responder.py diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ocsp_mock.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ocsp_mock.py similarity index 98% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ocsp_mock.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ocsp_mock.py index 04963b385..d89b9d45b 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/ocsp_mock.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/ocsp_mock.py @@ -1,4 +1,5 @@ -#! /usr/bin/env python3 +#!/usr/bin/env python3 + """ Python script to interface as a mock OCSP responder. """ diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/ca.crt b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/ca.crt similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/ca.crt rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/ca.crt diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/ca.key b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/ca.key similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/ca.key rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/ca.key diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/ca.pem b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/ca.pem similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/ca.pem rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/ca.pem diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/mock-delegate-revoked.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/mock-delegate-revoked.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/mock-delegate-revoked.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/mock-delegate-revoked.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/mock-delegate-valid.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/mock-delegate-valid.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/mock-delegate-valid.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/mock-delegate-valid.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/mock-revoked.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/mock-revoked.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/mock-revoked.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/mock-revoked.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/mock-valid.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/mock-valid.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/mock-valid.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/mock-valid.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/ocsp-responder.crt b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/ocsp-responder.crt similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/ocsp-responder.crt rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/ocsp-responder.crt diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/ocsp-responder.key b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/ocsp-responder.key similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/ocsp-responder.key rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/ocsp-responder.key diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/responder.logs b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/responder.logs similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/responder.logs rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/responder.logs diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/server-mustStaple.pem b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/server-mustStaple.pem similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/server-mustStaple.pem rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/server-mustStaple.pem diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/server.pem b/3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/server.pem similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/ocsp/rsa/server.pem rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/ocsp/rsa/server.pem diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/abi-compliance-check-setup.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/abi-compliance-check-setup.sh new file mode 100755 index 000000000..be59f0e3e --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/abi-compliance-check-setup.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail + +declare working_dir +working_dir="$(pwd)" + +export PATH +PATH="${working_dir:?}/install/bin:${PATH:-}" + +# Install prefix to use for ABI compatibility scripts. +if [[ ! -d "${working_dir}/install" ]]; then + echo "Creating install directory at ${working_dir}/install" + mkdir -p "${working_dir}/install" +fi + +declare parallel_level +parallel_level="$(("$(nproc)" + 1))" + +export PATH +PATH="${MONGO_C_DRIVER_CACHE_DIR:?}/bin:${PATH:-}" # abi-compliance-checker + +# Obtain abi-compliance-checker. +echo "Fetching abi-compliance-checker..." +[[ -d "${MONGO_C_DRIVER_CACHE_DIR:?}/checker-2.3" ]] || { + git clone -b "2.3" --depth 1 https://github.com/lvc/abi-compliance-checker.git "${MONGO_C_DRIVER_CACHE_DIR:?}/checker-2.3" + pushd "${MONGO_C_DRIVER_CACHE_DIR:?}/checker-2.3" + make -j "${parallel_level:?}" --no-print-directory install prefix="${MONGO_C_DRIVER_CACHE_DIR:?}" + popd # "${MONGO_C_DRIVER_CACHE_DIR:?}/checker-2.3" +} >/dev/null +echo "Fetching abi-compliance-checker... done." + +# Obtain ctags. +echo "Fetching ctags..." +[[ -d "${MONGO_C_DRIVER_CACHE_DIR:?}/ctags-6.0.0" ]] || { + git clone -b "v6.0.0" --depth 1 https://github.com/universal-ctags/ctags.git "${MONGO_C_DRIVER_CACHE_DIR:?}/ctags-6.0.0" + pushd "${MONGO_C_DRIVER_CACHE_DIR:?}/ctags-6.0.0" + ./autogen.sh + ./configure --prefix="${MONGO_C_DRIVER_CACHE_DIR:?}" + make -j "${parallel_level:?}" + make install + popd # "${MONGO_C_DRIVER_CACHE_DIR:?}/ctags-6.0.0" +} >/dev/null +echo "Fetching ctags... done." + +command -V abi-compliance-checker diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/abi-compliance-check.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/abi-compliance-check.sh new file mode 100755 index 000000000..6f9f3a7ac --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/abi-compliance-check.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail + +# create all needed directories +mkdir abi-compliance +mkdir abi-compliance/current-install +mkdir abi-compliance/base-install +mkdir abi-compliance/dumps + +declare head_commit today +# The 10 digits of the base commit +head_commit=$(git rev-parse --revs-only --short=10 "HEAD^{commit}") +# The YYYYMMDD date +today=$(date +%Y%m%d) + +declare current base +current="$(cat VERSION_CURRENT)-${today:?}+git${head_commit:?}" # e.g. 2.3.4-dev +base=$(cat etc/prior_version.txt) # e.g. 1.2.3 + +current_verdir="$(echo "${current:?}" | perl -lne 'm|^(\d+\.\d+\.\d+).*$|; print $1')" # Strip any suffixes. +base_verdir="${base:?}" + +# Double-check we are testing against the same API major version. +if [[ "${base_verdir:?}" != 2.* ]]; then + echo "API major version mismatch: base version is ${base:?} but current version is ${current:?}" >&2 + exit 1 +fi + +declare working_dir +working_dir="$(pwd)" + +export PATH +PATH="${MONGO_C_DRIVER_CACHE_DIR:?}/bin:${PATH:-}" # abi-compliance-checker + +cmake_configure_flags=( + "-DENABLE_STATIC=OFF" + "-DENABLE_TESTS=OFF" + "-DENABLE_EXAMPLES=OFF" +) + +# build the current changes +env \ + CFLAGS="-g -Og" \ + EXTRA_CONFIGURE_FLAGS="-DCMAKE_INSTALL_PREFIX=./abi-compliance/current-install ${cmake_configure_flags[*]:?}" \ + .evergreen/scripts/compile.sh + +# checkout the base release +git checkout "tags/${base:?}" -f + +declare compile_script +compile_script=".evergreen/scripts/compile.sh" + +# build the base release +env \ + CFLAGS="-g -Og" \ + EXTRA_CONFIGURE_FLAGS="-DCMAKE_INSTALL_PREFIX=./abi-compliance/base-install ${cmake_configure_flags[*]:?}" \ + bash "${compile_script}" + +# check for abi compliance. Generates HTML Reports. +cd abi-compliance + +cat >|old.xml < + ${base:?} +
    + + + $(pwd)/base-install/lib + + + + $(pwd)/base-install/include/bson-${base_verdir:?}/ + $(pwd)/base-install/include/mongoc-${base_verdir:?}/ + + + + $(pwd)/base-install/include/bson-${base_verdir:?}/bson/bson.h + $(pwd)/base-install/include/mongoc-${base_verdir:?}/mongoc/mongoc.h + +DOC + +cat >|new.xml < + ${current:?} +
    + + + $(pwd)/current-install/lib + + + + $(pwd)/current-install/include/bson-${current_verdir:?}/ + $(pwd)/current-install/include/mongoc-${current_verdir:?}/ + + + + $(pwd)/current-install/include/bson-${current_verdir:?}/bson/bson.h + $(pwd)/current-install/include/mongoc-${current_verdir:?}/mongoc/mongoc.h + +DOC + +# Allow task to upload the HTML report despite failed status. +if ! abi-compliance-checker -lib mongo-c-driver -old old.xml -new new.xml; then + find . -name log.txt -exec cat {} + >&2 || true + declare status + status='{"status":"failed", "type":"test", "should_continue":true, "desc":"abi-compliance-checker emitted one or more errors"}' + curl -sS -d "${status:?}" -H "Content-Type: application/json" -X POST localhost:2285/task_status || true +fi diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/add-build-dirs-to-paths.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/add-build-dirs-to-paths.sh old mode 100644 new mode 100755 similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/add-build-dirs-to-paths.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/add-build-dirs-to-paths.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/build-and-test-with-toolchain.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/build-and-test-with-toolchain.sh similarity index 92% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/build-and-test-with-toolchain.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/build-and-test-with-toolchain.sh index 219246609..63342cf06 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/build-and-test-with-toolchain.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/build-and-test-with-toolchain.sh @@ -35,8 +35,6 @@ toolchain_base_dir="$(readlink -f /opt/mongo-c-toolchain)" declare toolchain_lib_dir="${toolchain_base_dir}/lib" declare -a ssl_vers=( - "libressl-2.5" - "libressl-3.0" "openssl-1.0.1" "openssl-1.0.1-fips" "openssl-1.0.2" @@ -60,11 +58,7 @@ for ssl_ver in "${ssl_vers[@]}"; do "${cmake_binary}" --version declare ssl - if [[ "${ssl_ver#*libressl}" != "${ssl_ver}" ]]; then - ssl="LIBRESSL" - else - ssl="OPENSSL" - fi + ssl="OPENSSL" declare output_file output_file="$(mktemp)" @@ -77,7 +71,7 @@ for ssl_ver in "${ssl_vers[@]}"; do LD_LIBRARY_PATH="${toolchain_lib_dir}" \ PATH="${new_path}" \ SSL="${ssl}" \ - bash .evergreen/scripts/compile-unix.sh 2>&1 >|"${output_file}" + .evergreen/scripts/compile-unix.sh 2>&1 >|"${output_file}" # Verify that the toolchain components were used if grep -Ec "[-]I/opt/mongo-c-toolchain/include" "${output_file}" >/dev/null && diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/build-docs.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/build-docs.sh old mode 100644 new mode 100755 similarity index 76% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/build-docs.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/build-docs.sh index e88924ce8..850825286 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/build-docs.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/build-docs.sh @@ -9,12 +9,8 @@ CMAKE=$(find_cmake_latest) # Check that a CLion user didn't accidentally convert NEWS from UTF-8 to ASCII grep "á" NEWS > /dev/null || (echo "NEWS file appears to have lost its UTF-8 encoding?" || exit 1) -debug "Calculating release version..." -python build/calc_release_version.py >VERSION_CURRENT -python build/calc_release_version.py -p >VERSION_RELEASED - build_dir=$MONGOC_DIR/_build/for-docs -"$CMAKE" -S "$MONGOC_DIR" -B "$build_dir" \ +"$CMAKE" --fresh -S "$MONGOC_DIR" -B "$build_dir" \ -D ENABLE_MAN_PAGES=ON \ -D ENABLE_HTML_DOCS=ON \ -D ENABLE_ZLIB=BUNDLED diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/build_snapshot_rpm.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/build_snapshot_rpm.sh old mode 100644 new mode 100755 similarity index 90% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/build_snapshot_rpm.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/build_snapshot_rpm.sh index 2038609c2..05b7f4812 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/build_snapshot_rpm.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/build_snapshot_rpm.sh @@ -7,7 +7,7 @@ set -o errexit # # -# Copyright 2018 MongoDB, Inc. +# Copyright 2009-present MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ set -o errexit for arg in "$@"; do if [ "$arg" = "-h" ]; then - echo "Usage: ./.evergreen/scripts/build_snapshot_rpm.sh" + echo "Usage: .evergreen/scripts/build_snapshot_rpm.sh" echo "" echo " This script is used to build a .rpm package directly from a snapshot of the" echo " current repository." @@ -39,7 +39,7 @@ done package=mongo-c-driver spec_file=../mongo-c-driver.spec -config=${MOCK_TARGET_CONFIG:=fedora-38-aarch64} +config=${MOCK_TARGET_CONFIG:=fedora-40-aarch64} if [ ! -x /usr/bin/rpmbuild -o ! -x /usr/bin/rpmspec ]; then echo "Missing the rpmbuild or rpmspec utility from the rpm-build package" @@ -76,13 +76,15 @@ build_dir=$(basename $(pwd)) sudo mock -r ${config} --use-bootstrap-image --isolation=simple --clean sudo mock -r ${config} --use-bootstrap-image --isolation=simple --init mock_root=$(sudo mock -r ${config} --use-bootstrap-image --isolation=simple --print-root-path) -sudo mock -r ${config} --use-bootstrap-image --isolation=simple --install rpmdevtools git rpm-build cmake python gcc openssl-devel +sudo mock -r ${config} --use-bootstrap-image --isolation=simple --install rpmdevtools git rpm-build cmake python3.11 gcc openssl-devel + +# This step is needed to avoid the following error on rocky+epel8: +# Problem: conflicting requests +# - package utf8proc-devel-2.6.1-3.module+el8.7.0+1065+42200b2e.aarch64 from powertools is filtered out by modular filtering +sudo mock -r ${config} --use-bootstrap-image --isolation=simple --dnf-cmd --setopt=powertools.module_hotfixes=true install utf8proc-devel + sudo mock -r ${config} --use-bootstrap-image --isolation=simple --copyin "$(pwd)" "$(pwd)/${spec_file}" /tmp -sudo mock -r ${config} --use-bootstrap-image --isolation=simple --cwd "/tmp/${build_dir}" --chroot -- /bin/sh -c "( - python build/calc_release_version.py | sed -E 's/([^-]+).*/\1/' > VERSION_CURRENT ; - python build/calc_release_version.py -p > VERSION_RELEASED - )" -sudo mock -r ${config} --use-bootstrap-image --isolation=simple --copyout "/tmp/${build_dir}/VERSION_CURRENT" "/tmp/${build_dir}/VERSION_RELEASED" . +sudo mock -r ${config} --use-bootstrap-image --isolation=simple --copyout "/tmp/${build_dir}/VERSION_CURRENT" . bare_upstream_version=$(rpmspec --srpm -q --qf '%{version}' "$spec_file") # Upstream version in the .spec file cannot have hyphen (-); replace the current diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/bypass-dlclose.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/bypass-dlclose.sh old mode 100644 new mode 100755 similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/bypass-dlclose.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/bypass-dlclose.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-preludes.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/check-preludes.py similarity index 85% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-preludes.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/check-preludes.py index d9ce78b33..3b5807f37 100644 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-preludes.py +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/check-preludes.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2019-present MongoDB, Inc. +# Copyright 2009-present MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ MONGOC_PREFIX = Path("src/libmongoc/src/mongoc") BSON_PREFIX = Path("src/libbson/src/bson") -COMMON_PREFIX = Path("src/common") +COMMON_PREFIX = Path("src/common/src") checks = [ { @@ -35,13 +35,12 @@ MONGOC_PREFIX / "mongoc-prelude.h", MONGOC_PREFIX / "mongoc.h", ], - "include": '#include "mongoc-prelude.h"', + "include": "#include ", }, { "name": "libbson", - "headers": list(BSON_PREFIX.glob("*.h")), + "headers": list(BSON_PREFIX.glob("bson-*.h")), "exclusions": [ - BSON_PREFIX / "bson-dsl.h", BSON_PREFIX / "bson-prelude.h", BSON_PREFIX / "bson.h", ], @@ -51,7 +50,7 @@ "name": "common", "headers": list(COMMON_PREFIX.glob("*.h")), "exclusions": [COMMON_PREFIX / "common-prelude.h"], - "include": '#include "common-prelude.h"', + "include": "#include ", }, ] @@ -60,7 +59,7 @@ print(f"Checking headers for {NAME}") assert len(check["headers"]) > 0 for header in check["headers"]: - if header in check["exclusions"]: + if header in check["exclusions"] or header.name.endswith("-private.h"): continue lines = Path(header).read_text(encoding="utf-8").splitlines() if check["include"] not in lines: diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-public-decls.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/check-public-decls.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-public-decls.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/check-public-decls.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-symlink.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/check-symlink.sh old mode 100644 new mode 100755 similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check-symlink.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/check-symlink.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check_rpm_spec.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/check_rpm_spec.sh old mode 100644 new mode 100755 similarity index 97% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check_rpm_spec.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/check_rpm_spec.sh index e5ce3c9ea..a669842c2 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/check_rpm_spec.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/check_rpm_spec.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # -# Copyright 2024 MongoDB, Inc. +# Copyright 2009-present MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/cmake.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/cmake.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/cmake.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/cmake.sh diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-libmongocrypt.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-libmongocrypt.sh new file mode 100755 index 000000000..297e37442 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-libmongocrypt.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +compile_libmongocrypt() { + declare -r cmake_binary="${1:?}" + declare -r mongoc_dir="${2:?}" + declare -r install_dir="${3:?}" + + # When updating libmongocrypt, consider also updating the copy of + # libmongocrypt's kms-message in `src/kms-message`. Run + # `.evergreen/scripts/kms-divergence-check.sh` to ensure that there is no + # divergence in the copied files. + + # Clone libmongocrypt and check-out 1.13.0. + git clone -q --depth=1 https://github.com/mongodb/libmongocrypt --branch 1.13.0 || return + + declare -a crypt_cmake_flags=( + "-DMONGOCRYPT_MONGOC_DIR=${mongoc_dir}" + "-DBUILD_TESTING=OFF" + "-DENABLE_ONLINE_TESTS=OFF" + "-DENABLE_MONGOC=OFF" + "-DBUILD_VERSION=1.13.0" + ) + + . "$(dirname "${BASH_SOURCE[0]}")/find-ccache.sh" + find_ccache_and_export_vars "$(pwd)/libmongocrypt" || true + if command -v "${CMAKE_C_COMPILER_LAUNCHER:-}" && [[ "${OSTYPE:?}" == cygwin ]]; then + crypt_cmake_flags+=( + "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW" + "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded" + ) + fi + + env \ + DEBUG="0" \ + CMAKE_EXE="${cmake_binary}" \ + MONGOCRYPT_INSTALL_PREFIX=${install_dir} \ + DEFAULT_BUILD_ONLY=true \ + LIBMONGOCRYPT_EXTRA_CMAKE_FLAGS="${crypt_cmake_flags[*]}" \ + ./libmongocrypt/.evergreen/compile.sh || return +} + +: "${1:?"missing path to CMake binary"}" +: "${2:?"missing path to mongoc directory"}" +: "${3:?"missing path to install directory"}" + +compile_libmongocrypt "${1}" "${2}" "${3}" diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-openssl-static.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-openssl-static.sh similarity index 89% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-openssl-static.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-openssl-static.sh index aefb4d303..e74eda132 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-openssl-static.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-openssl-static.sh @@ -8,6 +8,8 @@ set -o pipefail . "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" paths check_var_opt CC +check_var_opt CMAKE_GENERATOR +check_var_opt CMAKE_GENERATOR_PLATFORM check_var_opt MARCH declare script_dir @@ -39,7 +41,6 @@ configure_flags_append_if_not_null() { } configure_flags_append "-DCMAKE_SKIP_RPATH=TRUE" # Avoid hardcoding absolute paths to dependency libraries. -configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF" configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON" configure_flags_append "-DENABLE_SSL=OPENSSL" configure_flags_append "-DOPENSSL_USE_STATIC_LIBS=ON" @@ -77,15 +78,6 @@ if [[ "${OSTYPE}" == darwin* ]]; then CFLAGS+=" -Wno-unknown-pragmas" fi -case "${CC}" in -clang) - CXX=clang++ - ;; -gcc) - CXX=g++ - ;; -esac - if [[ "${OSTYPE}" == darwin* && "${HOSTTYPE}" == "arm64" ]]; then configure_flags_append "-DCMAKE_OSX_ARCHITECTURES=arm64" fi @@ -109,10 +101,9 @@ if [[ "${OSTYPE}" == darwin* ]]; then } fi -# Allow reuse of ccache compilation results between different build directories. -export CCACHE_BASEDIR CCACHE_NOHASHDIR -CCACHE_BASEDIR="$(pwd)" -CCACHE_NOHASHDIR=1 +# Use ccache if able. +. "${script_dir:?}/find-ccache.sh" +find_ccache_and_export_vars "$(pwd)" || true "${CMAKE}" "${configure_flags[@]}" . "${CMAKE}" --build . -- -j "$(nproc)" diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-scan-build.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-scan-build.sh old mode 100644 new mode 100755 similarity index 83% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-scan-build.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-scan-build.sh index 2b6711efa..789e571df --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-scan-build.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-scan-build.sh @@ -32,7 +32,6 @@ configure_flags_append_if_not_null() { configure_flags_append "-DCMAKE_PREFIX_PATH=${cmake_prefix_path}" configure_flags_append "-DCMAKE_SKIP_RPATH=TRUE" # Avoid hardcoding absolute paths to dependency libraries. -configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF" configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=ON" configure_flags_append "-DENABLE_DEBUG_ASSERTIONS=ON" configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON" @@ -126,32 +125,39 @@ if [[ -d /usr/local/Cellar/llvm ]]; then done fi -scan_build_directories+=( - # Prefer toolchain scan-build if available. - "/opt/mongodbtoolchain/v4/bin" - "/opt/mongodbtoolchain/v3/bin" - - # Use system scan-build otherwise. - "/usr/bin" -) - -declare scan_build_binary -for dir in "${scan_build_directories[@]}"; do - if command -v "${dir}/scan-build" && command -v "${dir}/clang" && command -v "${dir}/clang++"; then - # Ensure compilers are consistent with scan-build binary. All three binaries - # should be present in the same directory. - scan_build_binary="${dir}/scan-build" - CC="${dir}/clang" - CXX="${dir}/clang++" - break - fi -done +if command -v scan-build && command -v clang && command -v clang++; then + scan_build_binary="scan-build" + CC="clang" + CXX="clang++" +else + scan_build_directories+=( + # Prefer toolchain scan-build if available. + "/opt/mongodbtoolchain/v4/bin" + "/opt/mongodbtoolchain/v3/bin" + + # Use system scan-build otherwise. + "/usr/bin" + ) + + declare scan_build_binary + for dir in "${scan_build_directories[@]}"; do + if command -v "${dir}/scan-build" && command -v "${dir}/clang" && command -v "${dir}/clang++"; then + # Ensure compilers are consistent with scan-build binary. All three binaries + # should be present in the same directory. + scan_build_binary="${dir}/scan-build" + CC="${dir}/clang" + CXX="${dir}/clang++" + break + fi + done +fi : "${scan_build_binary:?"could not find a scan-build binary!"}" +: "${CC:?}" +: "${CXX:?}" -# Allow reuse of ccache compilation results between different build directories. -export CCACHE_BASEDIR CCACHE_NOHASHDIR -CCACHE_BASEDIR="$(pwd)" -CCACHE_NOHASHDIR=1 +# Use ccache if able. +. "${script_dir:?}/find-ccache.sh" +find_ccache_and_export_vars "$(pwd)" || true "${scan_build_binary}" --use-cc="${CC}" --use-c++="${CXX}" "${cmake_binary}" "${configure_flags[@]}" . diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-std.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-std.sh new file mode 100755 index 000000000..b3fa436f1 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-std.sh @@ -0,0 +1,225 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail + +# shellcheck source=.evergreen/scripts/env-var-utils.sh +. "$(dirname "${BASH_SOURCE[0]}")/env-var-utils.sh" +. "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" paths + +check_var_opt CC +check_var_opt CMAKE_GENERATOR +check_var_opt CMAKE_GENERATOR_PLATFORM + +check_var_req C_STD_VERSION +check_var_opt CFLAGS +check_var_opt CXXFLAGS +check_var_opt MARCH + +declare script_dir +script_dir="$(to_absolute "$(dirname "${BASH_SOURCE[0]}")")" + +declare mongoc_dir +mongoc_dir="$(to_absolute "${script_dir}/../..")" + +declare libmongocrypt_install_dir="${mongoc_dir}/libmongocrypt-install-dir" + +declare -a configure_flags + +configure_flags_append() { + configure_flags+=("${@:?}") +} + +configure_flags_append_if_not_null() { + declare var="${1:?}" + if [[ -n "${!var:-}" ]]; then + shift + configure_flags+=("${@:?}") + fi +} + +configure_flags_append "-DCMAKE_PREFIX_PATH=${libmongocrypt_install_dir:?}" +configure_flags_append "-DCMAKE_SKIP_RPATH=TRUE" # Avoid hardcoding absolute paths to dependency libraries. +configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=ON" +configure_flags_append "-DENABLE_DEBUG_ASSERTIONS=ON" +configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON" + +if [[ "${C_STD_VERSION}" == "latest" ]]; then + [[ "${CMAKE_GENERATOR:-}" =~ "Visual Studio" ]] || { + echo "C_STD_VERSION=latest to enable /std:clatest is only supported with Visual Studio generators" 1>&2 + exit 1 + } + + configure_flags_append "-DCMAKE_C_FLAGS=/std:clatest" +else + configure_flags_append_if_not_null C_STD_VERSION "-DCMAKE_C_STANDARD=${C_STD_VERSION}" +fi + +if [[ "${OSTYPE}" == darwin* && "${HOSTTYPE}" == "arm64" ]]; then + configure_flags_append "-DCMAKE_OSX_ARCHITECTURES=arm64" +fi + +if [[ "${CMAKE_GENERATOR:-}" =~ "Visual Studio" ]]; then + # Avoid C standard conformance issues with Windows 10 SDK headers. + # See: https://developercommunity.visualstudio.com/t/stdc17-generates-warning-compiling-windowsh/1249671#T-N1257345 + configure_flags_append "-DCMAKE_SYSTEM_VERSION=10.0.20348.0" +fi + +declare -a flags + +if [[ "${CMAKE_GENERATOR:-}" =~ "Visual Studio" ]]; then + # Even with -DCMAKE_SYSTEM_VERSION=10.0.20348.0, winbase.h emits conformance warnings. + flags+=('/wd5105') +fi + +if [[ "${OSTYPE}" == darwin* ]]; then + flags+=('-Wno-unknown-pragmas') +fi + +# CMake and compiler environment variables. +export CFLAGS +export CXXFLAGS + +CFLAGS+=" ${flags+${flags[*]}}" +CXXFLAGS+=" ${flags+${flags[*]}}" + +# Ensure find-cmake-latest.sh is sourced *before* add-build-dirs-to-paths.sh +# to avoid interfering with potential CMake build configuration. +# shellcheck source=.evergreen/scripts/find-cmake-latest.sh +. "${script_dir}/find-cmake-latest.sh" +declare cmake_binary +cmake_binary="$(find_cmake_latest)" + +declare mongoc_build_dir mongoc_install_dir +mongoc_build_dir="cmake-build" +mongoc_install_dir="cmake-install" + +configure_flags_append "-DCMAKE_INSTALL_PREFIX=${mongoc_install_dir:?}" + +# shellcheck source=.evergreen/scripts/add-build-dirs-to-paths.sh +. "${script_dir}/add-build-dirs-to-paths.sh" + +if [[ "${OSTYPE}" == darwin* ]]; then + # MacOS does not have nproc. + nproc() { + sysctl -n hw.logicalcpu + } +fi + +export CMAKE_BUILD_PARALLEL_LEVEL +CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)" + +if [[ "${CMAKE_GENERATOR:-}" =~ "Visual Studio" ]]; then + # MSBuild needs additional assistance. + # https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/ + export UseMultiToolTask=1 + export EnforceProcessCountAcrossBuilds=1 +fi + +echo "Checking requested C standard is supported..." +pushd "$(mktemp -d)" +cat >CMakeLists.txt <= version + else() + failure() # Both are old: latest < version + endif() + elseif(CMAKE_C_STANDARD_LATEST IN_LIST old_std_versions) + failure() # latest (old) < version (new) + elseif(c_std_version IN_LIST old_std_versions) + success() # latest (new) >= version (old) + elseif(CMAKE_C_STANDARD_LATEST GREATER_EQUAL c_std_version) + success() # Both are new: latest >= version. + else() + failure() # Both are new: latest < version. + endif() +endif() +DOC +"${cmake_binary:?}" -S . -B build +popd # "$(tmpfile -d)" +echo "Checking requested C standard is supported... done." + +echo "Installing libmongocrypt..." +# shellcheck source=.evergreen/scripts/compile-libmongocrypt.sh +"${script_dir}/compile-libmongocrypt.sh" "${cmake_binary}" "${mongoc_dir}" "${libmongocrypt_install_dir:?}" &>output.txt || { + cat output.txt 1>&2 + exit 1 +} +echo "Installing libmongocrypt... done." + +# Use ccache if able. +. "${script_dir:?}/find-ccache.sh" +find_ccache_and_export_vars "$(pwd)" || true +if command -v "${CMAKE_C_COMPILER_LAUNCHER:-}" && [[ "${OSTYPE:?}" == cygwin ]]; then + configure_flags_append "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW" + configure_flags_append "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=$<$:Embedded>" +fi + +echo "CFLAGS: ${CFLAGS}" +echo "configure_flags: ${configure_flags[*]}" + +if [[ "${CMAKE_GENERATOR:-}" =~ "Visual Studio" ]]; then + all_target="ALL_BUILD" +else + all_target="all" +fi + +# Ensure we're starting with a clean slate. +rm -rf "${mongoc_build_dir:?}" "${mongoc_install_dir:?}" + +"${cmake_binary}" -S . -B "${mongoc_build_dir:?}" "${configure_flags[@]}" +"${cmake_binary}" --build "${mongoc_build_dir:?}" --config Debug \ + --target mongo_c_driver_tests \ + --target mongo_c_driver_examples \ + --target public-header-warnings \ + --target "${all_target:?}" +"${cmake_binary}" --install "${mongoc_build_dir:?}" --config Debug + +# "lib" vs. "lib64" +if [[ -d "${mongoc_install_dir:?}/lib64" ]]; then + lib_dir="lib64" +else + lib_dir="lib" +fi + +# This file should not be deleted! +touch "${mongoc_install_dir:?}/${lib_dir:?}/canary.txt" + +# Linux/MacOS: uninstall.sh +# Windows: uninstall.cmd +"${cmake_binary}" --build "${mongoc_build_dir:?}" --target uninstall + +# No files should remain except canary.txt. +# No directories except top-level directories should remain. +echo "Checking results of uninstall..." +diff <(cd "${mongoc_install_dir:?}" && find . -mindepth 1 | sort) <( + echo "./bin" + echo "./include" + echo "./${lib_dir:?}" + echo "./${lib_dir:?}/canary.txt" + echo "./share" +) +echo "Checking results of uninstall... done." diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-test-azurekms.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-test-azurekms.sh similarity index 85% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-test-azurekms.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-test-azurekms.sh index 2a11ea387..1ac0986e6 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-test-azurekms.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-test-azurekms.sh @@ -16,10 +16,9 @@ echo "Installing libmongocrypt ... begin" } echo "Installing libmongocrypt ... end" -# Allow reuse of ccache compilation results between different build directories. -export CCACHE_BASEDIR CCACHE_NOHASHDIR -CCACHE_BASEDIR="$(pwd)" -CCACHE_NOHASHDIR=1 +# Use ccache if able. +. .evergreen/scripts/find-ccache.sh +find_ccache_and_export_vars "$(pwd)" || true echo "Compile test-azurekms ... begin" # Disable unnecessary dependencies. test-azurekms is copied to a remote host for testing, which may not have all dependent libraries. diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-test-gcpkms.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-test-gcpkms.sh similarity index 85% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-test-gcpkms.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-test-gcpkms.sh index 9d63883ae..79647291d 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-test-gcpkms.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-test-gcpkms.sh @@ -16,10 +16,9 @@ echo "Installing libmongocrypt ... begin" } echo "Installing libmongocrypt ... end" -# Allow reuse of ccache compilation results between different build directories. -export CCACHE_BASEDIR CCACHE_NOHASHDIR -CCACHE_BASEDIR="$(pwd)" -CCACHE_NOHASHDIR=1 +# Use ccache if able. +. .evergreen/scripts/find-ccache.sh +find_ccache_and_export_vars "$(pwd)" || true echo "Compile test-gcpkms ... begin" # Disable unnecessary dependencies. test-gcpkms is copied to a remote host for testing, which may not have all dependent libraries. diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-unix.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-unix.sh similarity index 85% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-unix.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-unix.sh index 303ba70b9..5263e6f31 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/compile-unix.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-unix.sh @@ -10,12 +10,13 @@ set -o pipefail check_var_opt BYPASS_FIND_CMAKE "OFF" check_var_opt C_STD_VERSION # CMake default: 99. check_var_opt CC +check_var_opt CMAKE_GENERATOR +check_var_opt CMAKE_GENERATOR_PLATFORM check_var_opt CFLAGS check_var_opt CHECK_LOG "OFF" check_var_opt COMPILE_LIBMONGOCRYPT "OFF" check_var_opt COVERAGE # CMake default: OFF. check_var_opt CXXFLAGS -check_var_opt DEBUG "OFF" check_var_opt ENABLE_SHM_COUNTERS # CMake default: AUTO. check_var_opt EXTRA_CMAKE_PREFIX_PATH check_var_opt EXTRA_CONFIGURE_FLAGS @@ -67,7 +68,6 @@ configure_flags_append_if_not_null() { configure_flags_append "-DCMAKE_INSTALL_PREFIX=${install_dir}" configure_flags_append "-DCMAKE_PREFIX_PATH=${cmake_prefix_path}" configure_flags_append "-DCMAKE_SKIP_RPATH=TRUE" # Avoid hardcoding absolute paths to dependency libraries. -configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF" configure_flags_append "-DENABLE_HTML_DOCS=OFF" configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON" configure_flags_append "-DENABLE_MAN_PAGES=OFF" @@ -82,10 +82,11 @@ configure_flags_append_if_not_null SRV "-DENABLE_SRV=${SRV}" configure_flags_append_if_not_null TRACING "-DENABLE_TRACING=${TRACING}" configure_flags_append_if_not_null ZLIB "-DENABLE_ZLIB=${ZLIB}" -if [[ "${DEBUG}" == "ON" ]]; then - configure_flags_append "-DCMAKE_BUILD_TYPE=Debug" -else +if [[ "${RELEASE}" == "ON" ]]; then configure_flags_append "-DCMAKE_BUILD_TYPE=RelWithDebInfo" +else + configure_flags_append "-DCMAKE_BUILD_TYPE=Debug" + configure_flags_append "-DENABLE_DEBUG_ASSERTIONS=ON" fi if [[ "${SSL}" == "OPENSSL_STATIC" ]]; then @@ -98,10 +99,6 @@ if [[ "${COVERAGE}" == "ON" ]]; then configure_flags_append "-DENABLE_COVERAGE=ON" "-DENABLE_EXAMPLES=OFF" fi -if [[ "${RELEASE}" != "ON" ]]; then - configure_flags_append "-DENABLE_DEBUG_ASSERTIONS=ON" -fi - declare -a flags case "${MARCH}" in @@ -123,8 +120,6 @@ powerpc64le) esac # CMake and compiler environment variables. -export CC -export CXX export CFLAGS export CXXFLAGS @@ -139,15 +134,6 @@ if [[ "${OSTYPE}" == darwin* && "${HOSTTYPE}" == "arm64" ]]; then configure_flags_append "-DCMAKE_OSX_ARCHITECTURES=arm64" fi -case "${CC}" in -clang) - CXX=clang++ - ;; -gcc) - CXX=g++ - ;; -esac - declare cmake_binary if [[ "${BYPASS_FIND_CMAKE}" == "OFF" ]]; then # Ensure find-cmake-latest.sh is sourced *before* add-build-dirs-to-paths.sh @@ -181,6 +167,8 @@ if [[ "${OSTYPE}" == darwin* ]]; then sysctl -n hw.logicalcpu } fi +export CMAKE_BUILD_PARALLEL_LEVEL +CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)" declare -a extra_configure_flags IFS=' ' read -ra extra_configure_flags <<<"${EXTRA_CONFIGURE_FLAGS:-}" @@ -202,11 +190,24 @@ else configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=OFF" fi -# Allow reuse of ccache compilation results between different build directories. -export CCACHE_BASEDIR CCACHE_NOHASHDIR -CCACHE_BASEDIR="$(pwd)" -CCACHE_NOHASHDIR=1 +# Use ccache if able. +. "${script_dir:?}/find-ccache.sh" +find_ccache_and_export_vars "$(pwd)" || true + +declare build_dir +build_dir="cmake-build" -"${cmake_binary}" "${configure_flags[@]}" ${extra_configure_flags[@]+"${extra_configure_flags[@]}"} . -"${cmake_binary}" --build . -- -j "$(nproc)" -"${cmake_binary}" --build . --target install +"${cmake_binary}" -S . -B "${build_dir:?}" "${configure_flags[@]}" ${extra_configure_flags[@]+"${extra_configure_flags[@]}"} . +"${cmake_binary}" --build "${build_dir:?}" +"${cmake_binary}" --install "${build_dir:?}" + +# For use by test tasks, which directly use the binary directory contents. +"${cmake_binary}" --build "${build_dir:?}" --target mongo_c_driver_tests + +# Also validate examples. +"${cmake_binary}" --build "${build_dir:?}" --target mongo_c_driver_examples + +if [[ "$EXTRA_CONFIGURE_FLAGS" != *"ENABLE_MONGOC=OFF"* ]]; then + # Check public headers for extra warnings. + "${cmake_binary}" --build "${build_dir:?}" --target public-header-warnings +fi diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-windows.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-windows.sh new file mode 100755 index 000000000..179ba3d32 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile-windows.sh @@ -0,0 +1,157 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail + +set -o igncr # Ignore CR in this script for Windows compatibility. + +# shellcheck source=.evergreen/scripts/env-var-utils.sh +. "$(dirname "${BASH_SOURCE[0]}")/env-var-utils.sh" +. "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" paths + +check_var_opt BYPASS_FIND_CMAKE "OFF" +check_var_opt C_STD_VERSION # CMake default: 99. +check_var_opt CC +check_var_opt CMAKE_GENERATOR +check_var_opt CMAKE_GENERATOR_PLATFORM +check_var_opt COMPILE_LIBMONGOCRYPT "OFF" +check_var_opt EXTRA_CONFIGURE_FLAGS +check_var_opt RELEASE "OFF" +check_var_opt SASL "SSPI" # CMake default: AUTO. +check_var_opt SNAPPY # CMake default: AUTO. +check_var_opt SRV # CMake default: AUTO. +check_var_opt SSL "WINDOWS" # CMake default: OFF. +check_var_opt ZSTD # CMake default: AUTO. +check_var_opt ZLIB # CMake default: AUTO. + +declare script_dir +script_dir="$(to_absolute "$(dirname "${BASH_SOURCE[0]}")")" + +declare mongoc_dir +mongoc_dir="$(to_absolute "${script_dir}/../..")" + +declare -a configure_flags + +configure_flags_append() { + configure_flags+=("${@:?}") +} + +configure_flags_append_if_not_null() { + declare var="${1:?}" + if [[ -n "${!var:-}" ]]; then + shift + configure_flags+=("${@:?}") + fi +} + +declare install_dir="${mongoc_dir}/install-dir" + +declare -a extra_configure_flags +IFS=' ' read -ra extra_configure_flags <<<"${EXTRA_CONFIGURE_FLAGS:-}" + +## * Note: For additional configure-time context, the following lines can be +## * uncommented to enable CMake's debug output: +# configure_flags_append --log-level=debug +# configure_flags_append --log-context + +configure_flags_append "-DCMAKE_INSTALL_PREFIX=$(native-path "${install_dir}")" +configure_flags_append "-DCMAKE_PREFIX_PATH=$(native-path "${install_dir}")" +configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON" + +configure_flags_append_if_not_null C_STD_VERSION "-DCMAKE_C_STANDARD=${C_STD_VERSION:-}" +configure_flags_append_if_not_null SASL "-DENABLE_SASL=${SASL:-}" +configure_flags_append_if_not_null SNAPPY "-DENABLE_SNAPPY=${SNAPPY:-}" +configure_flags_append_if_not_null SRV "-DENABLE_SRV=${SRV:-}" +configure_flags_append_if_not_null ZLIB "-DENABLE_ZLIB=${ZLIB:-}" + +declare build_config +if [[ "${RELEASE}" == "ON" ]]; then + build_config="RelWithDebInfo" +else + build_config="Debug" + configure_flags_append "-DENABLE_DEBUG_ASSERTIONS=ON" +fi +configure_flags_append "-DCMAKE_BUILD_TYPE=${build_config:?}" + +if [ "${SSL}" == "OPENSSL_STATIC" ]; then + configure_flags_append "-DENABLE_SSL=OPENSSL" "-DOPENSSL_USE_STATIC_LIBS=ON" +else + configure_flags_append "-DENABLE_SSL=${SSL}" +fi + +declare cmake_binary +if [[ "${BYPASS_FIND_CMAKE:-}" == "OFF" ]]; then + # shellcheck source=.evergreen/scripts/find-cmake-version.sh + . "${script_dir}/find-cmake-latest.sh" + + cmake_binary="$(find_cmake_latest)" +else + cmake_binary="cmake" +fi + +"${cmake_binary:?}" --version + +export CMAKE_BUILD_PARALLEL_LEVEL +CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)" + +declare build_dir +build_dir="cmake-build" + +if [[ "${CC}" =~ 'gcc' ]]; then + # MinGW has trouble compiling src/cpp-check.cpp without some assistance. + configure_flags_append "-DCMAKE_CXX_STANDARD=11" + + env \ + "${cmake_binary:?}" \ + -S . \ + -B "${build_dir:?}" \ + -G "Ninja" \ + "${configure_flags[@]}" \ + "${extra_configure_flags[@]}" + + env "${cmake_binary:?}" --build "${build_dir:?}" + env "${cmake_binary:?}" --build "${build_dir:?}" --target mongo_c_driver_tests + env "${cmake_binary:?}" --build "${build_dir:?}" --target mongo_c_driver_examples + exit 0 +fi + +# MSBuild needs additional assistance. +# https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/ +export UseMultiToolTask=1 +export EnforceProcessCountAcrossBuilds=1 + +if [ "${COMPILE_LIBMONGOCRYPT}" = "ON" ]; then + echo "Installing libmongocrypt..." + # shellcheck source=.evergreen/scripts/compile-libmongocrypt.sh + "${script_dir}/compile-libmongocrypt.sh" "${cmake_binary}" "$(native-path "${mongoc_dir}")" "${install_dir}" &>output.txt || { + cat output.txt 1>&2 + exit 1 + } + echo "Installing libmongocrypt... done." + + # Fail if the C driver is unable to find the installed libmongocrypt. + configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=ON" +fi + +# Use ccache if able. +. "${script_dir:?}/find-ccache.sh" +find_ccache_and_export_vars "$(pwd)" || true +if command -v "${CMAKE_C_COMPILER_LAUNCHER:-}" && [[ "${OSTYPE:?}" == cygwin ]]; then + configure_flags_append "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW" + configure_flags_append "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=$<$:Embedded>" +fi + +"${cmake_binary:?}" -S . -B "${build_dir:?}" "${configure_flags[@]}" "${extra_configure_flags[@]}" +"${cmake_binary:?}" --build "${build_dir:?}" --config "${build_config:?}" +"${cmake_binary:?}" --install "${build_dir:?}" --config "${build_config:?}" + +# For use by test tasks, which directly use the binary directory contents. +"${cmake_binary:?}" --build "${build_dir:?}" --config "${build_config:?}" --target mongo_c_driver_tests + +# Also validate examples. +"${cmake_binary:?}" --build "${build_dir:?}" --config "${build_config:?}" --target mongo_c_driver_examples + +if [[ "$EXTRA_CONFIGURE_FLAGS" != *"ENABLE_MONGOC=OFF"* ]]; then + # Check public headers for extra warnings. + "${cmake_binary:?}" --build "${build_dir:?}" --config "${build_config:?}" --target public-header-warnings +fi diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile.sh new file mode 100755 index 000000000..b86a8c40e --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/compile.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if [[ "${OSTYPE}" == "cygwin" ]]; then + .evergreen/scripts/compile-windows.sh +else + .evergreen/scripts/compile-unix.sh +fi diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/debian_package_build.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/debian_package_build.sh similarity index 83% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/debian_package_build.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/debian_package_build.sh index 3d49fbfc6..9c5452060 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/debian_package_build.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/debian_package_build.sh @@ -20,6 +20,9 @@ on_exit () { } trap on_exit EXIT +git config user.email "evergreen-build@example.com" +git config user.name "Evergreen Build" + if [ "${IS_PATCH}" = "true" ]; then git diff HEAD > ../upstream.patch git clean -fdx @@ -47,15 +50,11 @@ export DEBOOTSTRAP_DIR=`pwd`/debootstrap.git sudo -E ./debootstrap.git/debootstrap --variant=buildd unstable ./unstable-chroot/ http://cdn-aws.deb.debian.org/debian cp -a mongoc ./unstable-chroot/tmp/ sudo chroot ./unstable-chroot /bin/bash -c '(\ - apt-get install -y build-essential git-buildpackage fakeroot dpkg-dev debhelper cmake libssl-dev pkgconf python3-sphinx python3-sphinx-design furo libmongocrypt-dev zlib1g-dev libsasl2-dev libsnappy-dev libutf8proc-dev libzstd-dev libjs-mathjax && \ + apt-get install -y build-essential git-buildpackage fakeroot dpkg-dev debhelper cmake libssl-dev pkgconf python3-sphinx python3-sphinx-design furo libmongocrypt-dev zlib1g-dev libsasl2-dev libsnappy-dev libutf8proc-dev libzstd-dev libjs-mathjax python3-packaging && \ chown -R root:root /tmp/mongoc && \ cd /tmp/mongoc && \ git clean -fdx && \ git reset --hard HEAD && \ - python3 build/calc_release_version.py > VERSION_CURRENT && \ - python3 build/calc_release_version.py -p > VERSION_RELEASED && \ - git add --force VERSION_CURRENT VERSION_RELEASED && \ - git commit VERSION_CURRENT VERSION_RELEASED -m "Set current/released versions" && \ git remote remove upstream || true && \ git remote add upstream https://github.com/mongodb/mongo-c-driver && \ git fetch upstream && \ @@ -67,7 +66,7 @@ sudo chroot ./unstable-chroot /bin/bash -c '(\ LANG=C /bin/bash ./debian/build_snapshot.sh && \ debc ../*.changes && \ dpkg -i ../*.deb && \ - gcc -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 -o example-client src/libmongoc/examples/example-client.c -lmongoc-1.0 -lbson-1.0 )' + gcc $(pkgconf --cflags bson2 mongoc2) -o example-client src/libmongoc/examples/example-client.c -lmongoc2 -lbson2 )' [ -e ./unstable-chroot/tmp/mongoc/example-client ] || (echo "Example was not built!" ; exit 1) (cd ./unstable-chroot/tmp/ ; tar zcvf ../../deb.tar.gz *.dsc *.orig.tar.gz *.debian.tar.xz *.build *.deb) @@ -88,10 +87,6 @@ sudo chroot ./unstable-i386-chroot /bin/bash -c '(\ cd /tmp/mongoc && \ git clean -fdx && \ git reset --hard HEAD && \ - python3 build/calc_release_version.py > VERSION_CURRENT && \ - python3 build/calc_release_version.py -p > VERSION_RELEASED && \ - git add --force VERSION_CURRENT VERSION_RELEASED && \ - git commit VERSION_CURRENT VERSION_RELEASED -m "Set current/released versions" && \ git remote remove upstream || true && \ git remote add upstream https://github.com/mongodb/mongo-c-driver && \ git fetch upstream && \ @@ -103,7 +98,7 @@ sudo chroot ./unstable-i386-chroot /bin/bash -c '(\ LANG=C /bin/bash ./debian/build_snapshot.sh && \ debc ../*.changes && \ dpkg -i ../*.deb && \ - gcc -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 -o example-client src/libmongoc/examples/example-client.c -lmongoc-1.0 -lbson-1.0 )' + gcc $(pkgconf --cflags bson2 mongoc2) -o example-client src/libmongoc/examples/example-client.c -lmongoc2 -lbson2 )' [ -e ./unstable-i386-chroot/tmp/mongoc/example-client ] || (echo "Example was not built!" ; exit 1) (cd ./unstable-i386-chroot/tmp/ ; tar zcvf ../../deb-i386.tar.gz *.dsc *.orig.tar.gz *.debian.tar.xz *.build *.deb) diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/debug-core-evergreen.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/debug-core-evergreen.sh similarity index 87% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/debug-core-evergreen.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/debug-core-evergreen.sh index 970320687..de0be7c54 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/debug-core-evergreen.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/debug-core-evergreen.sh @@ -8,7 +8,7 @@ fi shopt -s nullglob for i in *.core; do echo $i - echo "backtrace full" | gdb -q ./src/libmongoc/test-libmongoc $i + echo "backtrace full" | gdb -q ./cmake-build/src/libmongoc/test-libmongoc $i done # If there is still a test-libmongoc process running (perhaps due to diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/env-var-utils.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/env-var-utils.sh old mode 100644 new mode 100755 similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/env-var-utils.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/env-var-utils.sh diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/find-ccache.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/find-ccache.sh new file mode 100755 index 000000000..fab09022f --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/find-ccache.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +find_ccache_check() { + : "${1:?}" + + if command -v "${1:?}" >/dev/null; then + declare version + version="$("${1:?}" --version | head -n 1)" + echo "Found ${1:?}: ${version:-}" 1>&2 + echo "${1:?}" + return 0 + fi + + return 1 +} + +# find_ccache +# +# Usage: +# find_ccache +# ccache_binary="$(find_ccache)" +# ccache_binary="$(find_ccache 2>/dev/null)" +# +# Return 0 (true) if a ccache binary is found. +# Return a non-zero (false) value otherwise. +# +# If successful, print the name of the ccache binary to stdout (pipe 1). +# Otherwise, no output is printed to stdout. +# +# Diagnostic messages may be printed to stderr (pipe 2). Redirect to /dev/null +# with `2>/dev/null` to silence these messages. +find_ccache() { + # Most distros provide ccache via system paths. + { + find_ccache_check ccache && return + } || true + + # Some distros provide ccache via mongodbtoolchain. + { + find_ccache_check /opt/mongodbtoolchain/v4/bin/ccache && return + } || { + find_ccache_check /opt/mongodbtoolchain/v3/bin/ccache && return + } || true + + # Could not find ccache. + echo "Could not find a ccache binary." 1>&2 + return 1 +} + +# Find, export, and set ccache env vars in one command for convenience. +# Requires base_dir as first argument. +# Returns a non-zero (false) value if a ccache binary is not found. +# Redirects find_ccache's stderr to stdout to avoid output sync issues on EVG. +find_ccache_and_export_vars() { + declare base_dir + base_dir="${1:?"missing base_dir"}" + + declare ccache_binary + ccache_binary="$(find_ccache)" 2>&1 || return + + export CMAKE_C_COMPILER_LAUNCHER="${ccache_binary:?}" + export CMAKE_CXX_COMPILER_LAUNCHER="${ccache_binary:?}" + + # Allow reuse of ccache compilation results between different build directories. + if [[ "${OSTYPE:?}" =~ cygwin ]]; then + export CCACHE_BASEDIR="$(cygpath -aw ${base_dir:?})" + else + export CCACHE_BASEDIR="${base_dir:?}" + fi + export CCACHE_NOHASHDIR=1 +} diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/find-cmake-latest.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/find-cmake-latest.sh old mode 100644 new mode 100755 similarity index 92% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/find-cmake-latest.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/find-cmake-latest.sh index d4ca3c69c..95ced0140 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/find-cmake-latest.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/find-cmake-latest.sh @@ -9,5 +9,5 @@ find_cmake_latest() { # shellcheck source=.evergreen/scripts/find-cmake-version.sh . "${script_dir}/find-cmake-version.sh" || return - find_cmake_version 3 29 0 + find_cmake_version 3 30 2 } diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/find-cmake-version.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/find-cmake-version.sh similarity index 99% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/find-cmake-version.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/find-cmake-version.sh index 0c4126cfd..6424302a4 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/find-cmake-version.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/find-cmake-version.sh @@ -231,7 +231,7 @@ find_cmake_version() { cd "${tmp_cmake_dir}" || return - curl "${curl_args[@]}" "${cmake_url}" --output "cmake.tar.gz" || return + curl "${cmake_url}" --output "cmake.tar.gz" || return tar xzf cmake.tar.gz || return if [[ "${OSTYPE}" == darwin* ]]; then diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-libmongoc-after-libbson.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/install-libmongoc-after-libbson.sh similarity index 79% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-libmongoc-after-libbson.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/install-libmongoc-after-libbson.sh index 5b42c5049..665273a8e 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-libmongoc-after-libbson.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/install-libmongoc-after-libbson.sh @@ -6,8 +6,8 @@ set -o nounset # Install libbson only. EXTRA_CONFIGURE_FLAGS="-DENABLE_MONGOC=OFF" \ - ./.evergreen/scripts/compile.sh + .evergreen/scripts/compile.sh # Install libmongoc using the system installed libbson. EXTRA_CONFIGURE_FLAGS="-DENABLE_MONGOC=ON -DUSE_SYSTEM_LIBBSON=ON" \ - ./.evergreen/scripts/compile.sh + .evergreen/scripts/compile.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-ssl.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/install-ssl.sh old mode 100644 new mode 100755 similarity index 82% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-ssl.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/install-ssl.sh index 75a024b31..9ab557775 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/install-ssl.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/install-ssl.sh @@ -47,9 +47,9 @@ install_openssl() { declare ssl_version="${SSL##openssl-}" declare tmp tmp="$(echo "${ssl_version:?}" | tr . _)" - curl -L --retry 5 -o ssl.tar.gz "https://github.com/openssl/openssl/archive/OpenSSL_${tmp}.tar.gz" + curl -L --retry 5 -o ssl.tar.gz "https://github.com/openssl/openssl/releases/download/OpenSSL_${tmp}/openssl-${ssl_version}.tar.gz" tar zxf ssl.tar.gz - pushd "openssl-OpenSSL_${tmp}" + pushd "openssl-${ssl_version}" ( set -o xtrace ./config --prefix="${openssl_install_dir}" "${ssl_extra_flags[@]}" shared -fPIC @@ -61,11 +61,11 @@ install_openssl() { make -j make install_sw ) >/dev/null - popd # "openssl-OpenSSL_${tmp}" + popd # "openssl-${ssl_version}" } install_openssl_fips() { - curl --retry 5 -o fips.tar.gz https://www.openssl.org/source/openssl-fips-2.0.16.tar.gz + curl -L --retry 5 -o fips.tar.gz https://github.com/openssl/openssl/releases/download/OpenSSL-fips-2_0_16/openssl-fips-2.0.16.tar.gz tar zxf fips.tar.gz pushd openssl-fips-2.0.16 ( @@ -81,18 +81,6 @@ install_openssl_fips() { install_openssl } -install_libressl() { - curl --retry 5 -o ssl.tar.gz "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/${SSL}.tar.gz" - tar zxf ssl.tar.gz - pushd "${SSL}" - ( - set -o xtrace - ./configure --prefix="${install_dir}" - make -s -j "${njobs}" install - ) >/dev/null - popd # "${SSL}" -} - case "${SSL}" in openssl-*-fips) export LC_ALL @@ -106,7 +94,4 @@ openssl-*) install_openssl ;; -libressl-*) - install_libressl - ;; esac diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/integration-tests.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/integration-tests.sh new file mode 100755 index 000000000..4ea2d5eff --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/integration-tests.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +# +# Start up mongo-orchestration (a server to spawn mongodb clusters) and set up a cluster. +# +# Specify the following environment variables: +# +# MONGODB_VERSION: latest, 4.2, 4.0 +# TOPOLOGY: server, replica_set, sharded_cluster +# AUTH: auth, noauth +# SSL: openssl, darwinssl, winssl, nossl +# ORCHESTRATION_FILE: +# REQUIRE_API_VERSION: set to a non-empty string to set the requireApiVersion parameter +# This is currently only supported for standalone servers +# LOAD_BALANCER: off, on +# +# This script may be run locally. +# + +set -o errexit # Exit the script with error if any of the commands fail + +# shellcheck source=.evergreen/scripts/env-var-utils.sh +. "$(dirname "${BASH_SOURCE[0]:?}")/env-var-utils.sh" +. "$(dirname "${BASH_SOURCE[0]:?}")/use-tools.sh" paths + +: "${AUTH:="noauth"}" +: "${LOAD_BALANCER:="off"}" +: "${MONGODB_VERSION:="latest"}" +: "${ORCHESTRATION_FILE:-}" +: "${REQUIRE_API_VERSION:-}" +: "${SSL:="nossl"}" +: "${TOPOLOGY:="server"}" + +declare script_dir +script_dir="$(to_absolute "$(dirname "${BASH_SOURCE[0]:?}")")" + +# By fetch-det. +export DRIVERS_TOOLS +DRIVERS_TOOLS="$(cd ../drivers-evergreen-tools && pwd)" # ./mongoc -> ./drivers-evergreen-tools +if [[ "${OSTYPE:?}" == cygwin ]]; then + DRIVERS_TOOLS="$(cygpath -m "${DRIVERS_TOOLS:?}")" +fi + +export MONGO_ORCHESTRATION_HOME="${DRIVERS_TOOLS:?}/.evergreen/orchestration" +export MONGODB_BINARIES="${DRIVERS_TOOLS:?}/mongodb/bin" +export PATH="${MONGODB_BINARIES:?}:$PATH" + +# Workaround absence of `tls=true` URI in the `mongodb_auth_uri` field returned by mongo orchestration. +if [[ -n "${REQUIRE_API_VERSION:-}" && "${SSL:?}" != nossl ]]; then + prev='$MONGODB_BINARIES/mongosh $URI $MONGO_ORCHESTRATION_HOME/require-api-version.js' + + # Use `--tlsAllowInvalidCertificates` to avoid self-signed certificate errors. + next='$MONGODB_BINARIES/mongosh --tls --tlsAllowInvalidCertificates $URI $MONGO_ORCHESTRATION_HOME/require-api-version.js' + + sed -i -e "s|${prev:?}|${next:?}|" "${DRIVERS_TOOLS:?}/.evergreen/run-orchestration.sh" +fi + +"${DRIVERS_TOOLS:?}/.evergreen/run-orchestration.sh" + +echo "Waiting for mongo-orchestration to start..." +wait_for_mongo_orchestration() { + declare port="${1:?"wait_for_mongo_orchestration requires a server port"}" + + for _ in $(seq 300); do + # Exit code 7: "Failed to connect to host". + if + curl -s --max-time 1 "localhost:${port:?}" >/dev/null + test $? -ne 7 + then + return 0 + else + sleep 1 + fi + done + echo "Could not detect mongo-orchestration on port ${port:?}" + return 1 +} +wait_for_mongo_orchestration 8889 +echo "Waiting for mongo-orchestration to start... done." diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/kms-divergence-check.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/kms-divergence-check.sh old mode 100644 new mode 100755 similarity index 94% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/kms-divergence-check.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/kms-divergence-check.sh index a95bb06d8..46f4adaaf --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/kms-divergence-check.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/kms-divergence-check.sh @@ -13,7 +13,7 @@ LIBMONGOCRYPT_DIR="$MONGOC_DIR/libmongocrypt-for-kms-divergence-check" # LIBMONGOCRYPT_GITREF is expected to refer to the version of libmongocrypt # where kms-message was last copied. -LIBMONGOCRYPT_GITREF="4ebe317d01a0793b6225209139e9a00042a68306" +LIBMONGOCRYPT_GITREF="34a9572c416e0827a1fa988baf88411c4b5f2c7b" cleanup() { if [ -d "$LIBMONGOCRYPT_DIR" ]; then diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-bson.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-bson.sh new file mode 100755 index 000000000..c17230c9b --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-bson.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash +set -o errexit # Exit the script with error if any of the commands fail + +# Supported/used environment variables: +# LINK_STATIC Whether to statically link to libbson +# BUILD_SAMPLE_WITH_CMAKE Link program w/ CMake. Default: use pkg-config. + + +echo "LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE" + +DIR=$(dirname $0) +. $DIR/find-cmake-latest.sh +CMAKE=$(find_cmake_latest) +. $DIR/check-symlink.sh + +# The major version of the project. Appears in certain install filenames. +_full_version=$(cat "$DIR/../../VERSION_CURRENT") +version="${_full_version%-*}" # 1.2.3-dev → 1.2.3 +major="${version%%.*}" # 1.2.3 → 1 +echo "major version: $major" +echo " full version: $version" + +# Get the kernel name, lowercased +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +echo "OS: $OS" + +if [ "$OS" = "darwin" ]; then + LDD="otool -L" +else + LDD=ldd +fi + +SRCROOT=`pwd` +SCRATCH_DIR=$(pwd)/.scratch +rm -rf "$SCRATCH_DIR" +mkdir -p "$SCRATCH_DIR" +cp -r -- "$SRCROOT"/* "$SCRATCH_DIR" + +BUILD_DIR=$SCRATCH_DIR/build-dir +rm -rf $BUILD_DIR +mkdir $BUILD_DIR + +INSTALL_DIR=$SCRATCH_DIR/install-dir +rm -rf $INSTALL_DIR +mkdir -p $INSTALL_DIR + +cd $BUILD_DIR + +# Use ccache if able. +if [[ -f $DIR/find-ccache.sh ]]; then + . $DIR/find-ccache.sh + find_ccache_and_export_vars "$SCRATCH_DIR" || true +fi + +if [ "$LINK_STATIC" ]; then + # Our CMake system builds shared and static by default. + $CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DBUILD_TESTING=OFF -DENABLE_TESTS=OFF -DENABLE_MONGOC=OFF "$SCRATCH_DIR" + $CMAKE --build . --parallel + $CMAKE --build . --parallel --target install +else + $CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DBUILD_TESTING=OFF -DENABLE_TESTS=OFF -DENABLE_MONGOC=OFF -DENABLE_STATIC=OFF "$SCRATCH_DIR" + $CMAKE --build . --parallel + $CMAKE --build . --parallel --target install +fi + +# Revert ccache options, they no longer apply. +unset CCACHE_BASEDIR CCACHE_NOHASHDIR + +ls -l $INSTALL_DIR/lib + +cd $SRCROOT + +if [ "$BUILD_SAMPLE_WITH_CMAKE" ]; then + EXAMPLE_DIR=$SRCROOT/src/libbson/examples/cmake/find_package + + if [ "$LINK_STATIC" ]; then + EXAMPLE_DIR="${EXAMPLE_DIR}_static" + fi + + cd $EXAMPLE_DIR + $CMAKE -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake . + $CMAKE --build . --parallel +else + # Test our pkg-config file. + export PKG_CONFIG_PATH=$INSTALL_DIR/lib/pkgconfig + cd $SRCROOT/src/libbson/examples + + if [ "$LINK_STATIC" ]; then + echo "pkg-config output:" + echo $(pkg-config --libs --cflags bson$major-static) + env major=$major ./compile-with-pkg-config-static.sh + else + echo "pkg-config output:" + echo $(pkg-config --libs --cflags bson$major) + env major=$major ./compile-with-pkg-config.sh + fi +fi + +if [ ! "$LINK_STATIC" ]; then + if [ "$OS" = "darwin" ]; then + export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib + else + export LD_LIBRARY_PATH=$INSTALL_DIR/lib + fi +fi + +echo "ldd hello_bson:" +$LDD hello_bson + +./hello_bson diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-mingw-bson.cmd b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-mingw-bson.cmd new file mode 100755 index 000000000..b329ee139 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-mingw-bson.cmd @@ -0,0 +1,57 @@ +rem Load environment for Visual Studio 15 2017. +rem https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-150 +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat" || goto :error + +echo on +echo + +set TAR=C:\cygwin\bin\tar +set LINK_STATIC=1 + +set SRCROOT=%CD% +set BUILD_DIR=%CD%\build-dir +rmdir /S /Q %BUILD_DIR% 2>nul || true +mkdir %BUILD_DIR% || goto :error + +set INSTALL_DIR=%CD%\install-dir +rmdir /S /Q %INSTALL_DIR% 2>nul || true +mkdir %INSTALL_DIR% || goto :error + +set PATH=%PATH%;%INSTALL_DIR%\bin + +set major=1 +set version=1.31.0 + +cd %BUILD_DIR% || goto :error + +rem Build libmongoc, with flags that the downstream R driver mongolite uses +%CMAKE% -G "Ninja" DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_C_FLAGS="-pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake -DENABLE_STATIC=ON .. || goto :error +%CMAKE% --build . --parallel || goto :error +%CMAKE% --build . --target install || goto :error + +rem Test our pkg-config file +set EXAMPLE_DIR=%SRCROOT%\src\libbson\examples\ +cd %EXAMPLE_DIR% || goto :error + +rem Proceed from here once we have pkg-config on Windows +exit /B 0 + +set PKG_CONFIG_PATH=%INSTALL_DIR%\lib\pkgconfig + +rem http://stackoverflow.com/questions/2323292 +for /f %%i in ('pkg-config --libs --cflags bson%major%') do set PKG_CONFIG_OUT=%%i + +echo PKG_CONFIG_OUT is %PKG_CONFIG_OUT% + +%CC% -o hello_bson hello_bson.c %PKG_CONFIG_OUT% || goto :error + +dumpbin.exe /dependents Debug\hello_bson.exe || goto :error + +rem Add DLLs to PATH +set PATH=%PATH%;%INSTALL_DIR%\bin + +Debug\hello_bson.exe %MONGODB_EXAMPLE_URI% || goto :error + +goto :EOF +:error +exit /B %errorlevel% diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-mingw.cmd b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-mingw.cmd new file mode 100755 index 000000000..401280151 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-mingw.cmd @@ -0,0 +1,57 @@ +rem Load environment for Visual Studio 15 2017. +rem https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-150 +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat" || goto :error + +echo on +echo + +rem Use DENABLE_SSL=OFF. Windows hosts do not have a MinGW ABI compatible OpenSSL install. +set CMAKE_FLAGS=-DENABLE_SSL=OFF -DENABLE_SASL=CYRUS +set TAR=C:\cygwin\bin\tar + +set SRCROOT=%CD% +set BUILD_DIR=%CD%\build-dir +rmdir /S /Q %BUILD_DIR% 2>nul || true +mkdir %BUILD_DIR% || goto :error + +set INSTALL_DIR=%CD%\install-dir +rmdir /S /Q %INSTALL_DIR% 2>nul || true +mkdir %INSTALL_DIR% || goto :error + +set PATH=%PATH%;%INSTALL_DIR%\bin + +set major=1 + +cd %BUILD_DIR% || goto :error + +rem Build libmongoc, with flags that the downstream R driver mongolite uses +%CMAKE% -G "Ninja" -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_C_FLAGS="-pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake %CMAKE_FLAGS% .. || goto :error +%CMAKE% --build . --parallel || goto :error +%CMAKE% --build . --target install || goto :error + +rem Test our pkg-config file +set EXAMPLE_DIR=%SRCROOT%\src\libmongoc\examples\ +cd %EXAMPLE_DIR% || goto :error + +rem Proceed from here once we have pkg-config on Windows +exit /B 0 + +set PKG_CONFIG_PATH=%INSTALL_DIR%\lib\pkgconfig + +rem http://stackoverflow.com/questions/2323292 +for /f %%i in ('pkg-config --libs --cflags mongoc%major%') do set PKG_CONFIG_OUT=%%i + +echo PKG_CONFIG_OUT is %PKG_CONFIG_OUT% + +%CC% -o hello_mongoc hello_mongoc.c %PKG_CONFIG_OUT% || goto :error + +dumpbin.exe /dependents Debug\hello_mongoc.exe || goto :error + +rem Add DLLs to PATH +set PATH=%PATH%;%INSTALL_DIR%\bin + +Debug\hello_mongoc.exe %MONGODB_EXAMPLE_URI% || goto :error + +goto :EOF +:error +exit /B %errorlevel% diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-msvc-bson.cmd b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-msvc-bson.cmd new file mode 100755 index 000000000..b7e3eab14 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-msvc-bson.cmd @@ -0,0 +1,56 @@ +REM Supported/used environment variables: +REM LINK_STATIC Whether to statically link to libbson + +rem Ensure Cygwin executables like sh.exe are not in PATH +rem set PATH=C:\Windows\system32;C:\Windows + +rem Load environment for Visual Studio 15 2017. +rem https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-150 +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat" || goto :error + +echo on +echo + +set TAR=C:\cygwin\bin\tar + +set SRCROOT=%CD% +set BUILD_DIR=%CD%\build-dir +rmdir /S /Q %BUILD_DIR% 2>nul || true +mkdir %BUILD_DIR% || goto :error + +set INSTALL_DIR=%CD%\install-dir +rmdir /S /Q %INSTALL_DIR% 2>nul || true +mkdir %INSTALL_DIR% || goto :error + +set PATH=%PATH%;%INSTALL_DIR%\bin + +cd %BUILD_DIR% || goto :error + +if "%LINK_STATIC%"=="1" ( + %CMAKE% -G "Visual Studio 15 2017" -A x64 -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DENABLE_TESTS=OFF .. || goto :error +) else ( + %CMAKE% -G "Visual Studio 15 2017" -A x64 -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DENABLE_TESTS=OFF -DENABLE_STATIC=OFF .. || goto :error +) + +%CMAKE% --build . --config "Debug" --target ALL_BUILD -- /m || goto :error +%CMAKE% --build . --config "Debug" --target INSTALL -- /m || goto :error + +rem Test our CMake package config file with CMake's find_package command. +set EXAMPLE_DIR=%SRCROOT%\src\libbson\examples\cmake\find_package + +if "%LINK_STATIC%"=="1" ( + set EXAMPLE_DIR="%EXAMPLE_DIR%_static" +) + +cd %EXAMPLE_DIR% || goto :error +%CMAKE% -G "Visual Studio 15 2017" -A x64 -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake . || goto :error +%CMAKE% --build . --config "Debug" --target ALL_BUILD -- /m || goto :error + +rem Yes, they should've named it "dependencies". +dumpbin.exe /dependents Debug\hello_bson.exe || goto :error + +Debug\hello_bson.exe || goto :error + +goto :EOF +:error +exit /B %errorlevel% diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-msvc.cmd b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-msvc.cmd new file mode 100755 index 000000000..a6a73efd7 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program-msvc.cmd @@ -0,0 +1,80 @@ +REM Supported/used environment variables: +REM LINK_STATIC Whether to statically link to libmongoc +REM ENABLE_SSL Enable SSL with Microsoft Secure Channel +REM ENABLE_SNAPPY Enable Snappy compression + +rem Ensure Cygwin executables like sh.exe are not in PATH +rem set PATH=C:\Windows\system32;C:\Windows + +rem Load environment for Visual Studio 15 2017. +rem https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-150 +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat" || goto :error + +echo on +echo + +set TAR=C:\cygwin\bin\tar + +set SRCROOT=%CD% +set BUILD_DIR=%CD%\build-dir +rmdir /S /Q %BUILD_DIR% 2>nul || true +mkdir %BUILD_DIR% || goto :error + +set INSTALL_DIR=%CD%\install-dir +rmdir /S /Q %INSTALL_DIR% 2>nul || true +mkdir %INSTALL_DIR% || goto :error + +set PATH=%PATH%;%INSTALL_DIR%\bin + +cd %BUILD_DIR% || goto :error + +if "%ENABLE_SNAPPY%"=="1" ( + rem Enable Snappy + curl -sS --retry 5 -LO https://github.com/google/snappy/archive/1.1.7.tar.gz || goto :error + %TAR% xzf 1.1.7.tar.gz || goto :error + cd snappy-1.1.7 || goto :error + %CMAKE% -G "Visual Studio 15 2017" -A x64 -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -S snappy-1.1.7 -B snappy-1.1.7-build || goto :error + %CMAKE% --build snappy-1.1.7-build --config "Debug" --target ALL_BUILD -- /m || goto :error + %CMAKE% --build snappy-1.1.7-build --config "Debug" --target INSTALL -- /m || goto :error + set SNAPPY_OPTION=-DENABLE_SNAPPY=ON +) else ( + set SNAPPY_OPTION=-DENABLE_SNAPPY=OFF +) + +cd %BUILD_DIR% || goto :error +rem Build libmongoc +if "%ENABLE_SSL%"=="1" ( + %CMAKE% -G "Visual Studio 15 2017" -A x64 -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DENABLE_SSL=WINDOWS %ENABLE_SNAPPY_OPTION% .. || goto :error +) else ( + %CMAKE% -G "Visual Studio 15 2017" -A x64 -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DENABLE_SSL=OFF %ENABLE_SNAPPY_OPTION% .. || goto :error +) + +%CMAKE% --build . --config "Debug" --target ALL_BUILD -- /m || goto :error +%CMAKE% --build . --config "Debug" --target INSTALL -- /m || goto :error + +rem Test our CMake package config file with CMake's find_package command. +set EXAMPLE_DIR=%SRCROOT%\src\libmongoc\examples\cmake\find_package + +if "%LINK_STATIC%"=="1" ( + set EXAMPLE_DIR="%EXAMPLE_DIR%_static" +) + +cd %EXAMPLE_DIR% || goto :error + +if "%ENABLE_SSL%"=="1" ( + cp ..\..\..\tests\x509gen\client.pem . || goto :error + cp ..\..\..\tests\x509gen\ca.pem . || goto :error + set MONGODB_EXAMPLE_URI="mongodb://localhost/?ssl=true&sslclientcertificatekeyfile=client.pem&sslcertificateauthorityfile=ca.pem&sslallowinvalidhostnames=true" +) + +%CMAKE% -G "Visual Studio 15 2017" -A x64 -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake . || goto :error +%CMAKE% --build . --config "Debug" --target ALL_BUILD -- /m || goto :error + +rem Yes, they should've named it "dependencies". +dumpbin.exe /dependents Debug\hello_mongoc.exe || goto :error + +Debug\hello_mongoc.exe %MONGODB_EXAMPLE_URI% || goto :error + +goto :EOF +:error +exit /B %errorlevel% diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program.sh new file mode 100755 index 000000000..52d4c0f1e --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/link-sample-program.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env bash +set -o errexit # Exit the script with error if any of the commands fail + +# Supported/used environment variables: +# LINK_STATIC Whether to statically link to libmongoc +# BUILD_SAMPLE_WITH_CMAKE Link program w/ CMake. Default: use pkg-config. +# ENABLE_SSL Set -DENABLE_SSL +# ENABLE_SNAPPY Set -DENABLE_SNAPPY +# CMAKE Path to cmake executable. + + +echo "LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE" + +DIR=$(dirname $0) +. $DIR/find-cmake-latest.sh +CMAKE=$(find_cmake_latest) +. $DIR/check-symlink.sh + +# The major version of the project. Appears in certain install filenames. +_full_version=$(cat "$DIR/../../VERSION_CURRENT") +version="${_full_version%-*}" # 1.2.3-dev → 1.2.3 +major="${version%%.*}" # 1.2.3 → 1 +echo "major version: $major" +echo " full version: $version" + +# Get the kernel name, lowercased +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +echo "OS: $OS" + +if [ "$OS" = "darwin" ]; then + LDD="otool -L" +else + LDD=ldd +fi + +SRCROOT=`pwd` +SCRATCH_DIR=$(pwd)/.scratch +rm -rf "$SCRATCH_DIR" +mkdir -p "$SCRATCH_DIR" +cp -r -- "$SRCROOT"/* "$SCRATCH_DIR" + +BUILD_DIR=$SCRATCH_DIR/build-dir +rm -rf $BUILD_DIR +mkdir $BUILD_DIR + +INSTALL_DIR=$SCRATCH_DIR/install-dir +rm -rf $INSTALL_DIR +mkdir -p $INSTALL_DIR + +cd $BUILD_DIR + +if [ "$ENABLE_SNAPPY" ]; then + SNAPPY_CMAKE_OPTION="-DENABLE_SNAPPY=ON" +else + SNAPPY_CMAKE_OPTION="-DENABLE_SNAPPY=OFF" +fi + +if [ "$ENABLE_SSL" ]; then + if [ "$OS" = "darwin" ]; then + SSL_CMAKE_OPTION="-DENABLE_SSL:BOOL=DARWIN" + else + SSL_CMAKE_OPTION="-DENABLE_SSL:BOOL=OPENSSL" + fi +else + SSL_CMAKE_OPTION="-DENABLE_SSL:BOOL=OFF" +fi + + +if [ "$LINK_STATIC" ]; then + STATIC_CMAKE_OPTION="-DENABLE_STATIC=ON -DENABLE_TESTS=ON" +else + STATIC_CMAKE_OPTION="-DENABLE_STATIC=OFF -DENABLE_TESTS=OFF" +fi + +ZSTD="AUTO" + +# Use ccache if able. +if [[ -f $DIR/find-ccache.sh ]]; then + . $DIR/find-ccache.sh + find_ccache_and_export_vars "$SCRATCH_DIR" || true + if command -v "${CMAKE_C_COMPILER_LAUNCHER:-}" && [[ "${OSTYPE:?}" == cygwin ]]; then + configure_flags_append "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW" + configure_flags_append "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=$<$:Embedded>" + fi +fi + +$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake -DBUILD_TESTING=OFF $SSL_CMAKE_OPTION $SNAPPY_CMAKE_OPTION $STATIC_CMAKE_OPTION -DENABLE_ZSTD=$ZSTD "$SCRATCH_DIR" +$CMAKE --build . --parallel +$CMAKE --build . --parallel --target install + +# Revert ccache options, they no longer apply. +unset CCACHE_BASEDIR CCACHE_NOHASHDIR + +ls -l $INSTALL_DIR/lib + +if [ "$OS" = "darwin" ] && [ "${HOSTTYPE:?}" != "arm64" ]; then + if test -f $INSTALL_DIR/bin/mongoc$major-stat; then + echo "mongoc$major-stat shouldn't have been installed" + exit 1 + fi +else + if test ! -f $INSTALL_DIR/bin/mongoc$major-stat; then + echo "mongoc$major-stat missing!" + exit 1 + else + echo "mongoc$major-stat check ok" + fi +fi + +if [ "$BUILD_SAMPLE_WITH_CMAKE" ]; then + # Test our CMake package config file with CMake's find_package command. + if [ "$BUILD_SAMPLE_WITH_CMAKE_DEPRECATED" ]; then + EXAMPLE_DIR=$SRCROOT/src/libmongoc/examples/cmake-deprecated/find_package + else + EXAMPLE_DIR=$SRCROOT/src/libmongoc/examples/cmake/find_package + fi + + if [ "$LINK_STATIC" ]; then + EXAMPLE_DIR="${EXAMPLE_DIR}_static" + fi + + cd $EXAMPLE_DIR + $CMAKE -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake . + $CMAKE --build . +else + # Test our pkg-config file. + export PKG_CONFIG_PATH=$INSTALL_DIR/lib/pkgconfig + cd $SRCROOT/src/libmongoc/examples + + if [ "$LINK_STATIC" ]; then + echo "pkg-config output:" + echo $(pkg-config --libs --cflags mongoc$major-static) + env major=$major ./compile-with-pkg-config-static.sh + else + echo "pkg-config output:" + echo $(pkg-config --libs --cflags mongoc$major) + env major=$major ./compile-with-pkg-config.sh + fi +fi + +if [ ! "$LINK_STATIC" ]; then + if [ "$OS" = "darwin" ]; then + export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib + else + export LD_LIBRARY_PATH=$INSTALL_DIR/lib + fi +fi + +echo "ldd hello_mongoc:" +$LDD hello_mongoc + +./hello_mongoc diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/llvm-gcov.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/llvm-gcov.sh new file mode 100755 index 000000000..eeae94f84 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/llvm-gcov.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +exec llvm-cov gcov "$@" diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/man-pages-to-html.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/man-pages-to-html.sh old mode 100644 new mode 100755 similarity index 98% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/man-pages-to-html.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/man-pages-to-html.sh index 060cc82f5..e7e5b5fdf --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/man-pages-to-html.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/man-pages-to-html.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # Make HTML page of all man pages so we can see them in Evergreen. # diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-auth-tests.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-auth-tests.sh new file mode 100755 index 000000000..64abf9867 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-auth-tests.sh @@ -0,0 +1,235 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail + +set +o xtrace # Don't echo commands + +# shellcheck source=.evergreen/scripts/env-var-utils.sh +. "$(dirname "${BASH_SOURCE[0]}")/env-var-utils.sh" +. "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" platform paths + +declare script_dir +script_dir="$(to_absolute "$(dirname "${BASH_SOURCE[0]}")")" + +declare mongoc_dir +mongoc_dir="$(to_absolute "${script_dir}/../..")" + +declare install_dir="${mongoc_dir}/install-dir" +declare openssl_install_dir="${mongoc_dir}/openssl-install-dir" + +# Create directory for secrets within Evergreen task directory. Task directory is cleaned up between tasks. +declare secrets_dir +secrets_dir="$(to_absolute "${mongoc_dir}/../secrets")" +mkdir -p "${secrets_dir}" +chmod 700 "${secrets_dir}" + +# Create certificate to test X509 auth with Atlas on cloud-prod: +atlas_x509_path="${secrets_dir:?}/atlas_x509.pem" +echo "${atlas_x509_cert_base64:?}" | base64 --decode > "${secrets_dir:?}/atlas_x509.pem" +# Fix path on Windows: +if $IS_WINDOWS; then + atlas_x509_path="$(cygpath -m "${atlas_x509_path}")" +fi + +# Create certificate to test X509 auth with Atlas on cloud-dev +atlas_x509_dev_path="${secrets_dir:?}/atlas_x509_dev.pem" +echo "${atlas_x509_dev_cert_base64:?}" | base64 --decode > "${atlas_x509_dev_path:?}" +# Fix path on Windows: +if $IS_WINDOWS; then + atlas_x509_dev_path="$(cygpath -m "${atlas_x509_dev_path}")" +fi + +# Create Kerberos config and keytab files. +echo "Setting up Kerberos ... begin" +if command -v kinit >/dev/null; then + # Copy host config and append realm: + if [ -e /etc/krb5.conf ]; then + cat /etc/krb5.conf > "${secrets_dir:?}/krb5.conf" + fi + cat "${mongoc_dir}/.evergreen/etc/kerberos.realm" >> "${secrets_dir:?}/krb5.conf" + # Set up keytab: + echo "${keytab:?}" | base64 --decode > "${secrets_dir:?}/drivers.keytab" + # Initialize kerberos: + KRB5_CONFIG="${secrets_dir:?}/krb5.conf" kinit -k -t "${secrets_dir:?}/drivers.keytab" -p drivers@LDAPTEST.10GEN.CC + echo "Setting up Kerberos ... done" +else + echo "No 'kinit' detected" + echo "Setting up Kerberos ... skipping" +fi + +declare c_timeout="connectTimeoutMS=30000&serverSelectionTryOnce=false" + +declare sasl="OFF" +if grep -r -q "#define MONGOC_ENABLE_SASL 1" "${install_dir:?}"; then + sasl="ON" +fi + +declare ssl="OFF" +if grep -r -q "#define MONGOC_ENABLE_SSL 1" "${install_dir:?}"; then + ssl="ON" +fi + +# shellcheck source=.evergreen/scripts/add-build-dirs-to-paths.sh +. "${script_dir}/add-build-dirs-to-paths.sh" + +# shellcheck source=.evergreen/scripts/bypass-dlclose.sh +. "${script_dir}/bypass-dlclose.sh" + +declare ping +declare test_gssapi +declare ip_addr +case "${OSTYPE}" in +cygwin) + ping="${mongoc_dir}/cmake-build/src/libmongoc/Debug/mongoc-ping.exe" + test_gssapi="${mongoc_dir}/cmake-build/src/libmongoc/Debug/test-mongoc-gssapi.exe" + ip_addr="$(getent hosts "${auth_host:?}" | head -n 1 | awk '{print $1}')" + ;; + +darwin*) + ping="${mongoc_dir}/cmake-build/src/libmongoc/mongoc-ping" + test_gssapi="${mongoc_dir}/cmake-build/src/libmongoc/test-mongoc-gssapi" + ip_addr="$(dig "${auth_host:?}" +short | tail -1)" + ;; + +*) + ping="${mongoc_dir}/cmake-build/src/libmongoc/mongoc-ping" + test_gssapi="${mongoc_dir}/cmake-build/src/libmongoc/test-mongoc-gssapi" + ip_addr="$(getent hosts "${auth_host:?}" | head -n 1 | awk '{print $1}')" + ;; +esac +: "${ping:?}" +: "${test_gssapi:?}" +: "${ip_addr:?}" + +# Archlinux (which we use for testing various self-installed OpenSSL versions) +# stores their trust list under /etc/ca-certificates/extracted/. +# We need to copy it to our custom installed OpenSSL trust store. +declare pem_file="/etc/ca-certificates/extracted/tls-ca-bundle.pem" +if [[ -f "${pem_file}" ]]; then + [[ ! -d "${install_dir}" ]] || cp -v "${pem_file}" "${install_dir}/cert.pem" + [[ ! -d "${install_dir}/ssl" ]] || cp -v "${pem_file}" "${install_dir}/ssl/cert.pem" + [[ ! -d "${openssl_install_dir}" ]] || cp -v "${pem_file}" "${openssl_install_dir}/cert.pem" + [[ ! -d "${openssl_install_dir}/ssl" ]] || cp -v "${pem_file}" "${openssl_install_dir}/ssl/cert.pem" +fi + +# Custom OpenSSL library may be installed. Only prepend to LD_LIBRARY_PATH when +# necessary to avoid conflicting with system binary requirements. +declare openssl_lib_prefix="${LD_LIBRARY_PATH:-}" +if [[ -d "${openssl_install_dir}" ]]; then + openssl_lib_prefix="${openssl_install_dir}/lib:${openssl_lib_prefix:-}" +fi + +# There may be additional certs required by auth tests. Direct OpenSSL to use +# the system cert directory if available. +[[ ! -d /etc/ssl/certs ]] || export SSL_CERT_DIR=/etc/ssl/certs + +ulimit -c unlimited || true + +if command -v ldd >/dev/null; then + LD_LIBRARY_PATH="${openssl_lib_prefix}" ldd "${ping}" | grep "libssl" || true + LD_LIBRARY_PATH="${openssl_lib_prefix}" ldd "${test_gssapi}" | grep "libssl" || true +elif command -v otool >/dev/null; then + # Try using otool on MacOS if ldd is not available. + LD_LIBRARY_PATH="${openssl_lib_prefix}" otool -L "${ping}" | grep "libssl" || true + LD_LIBRARY_PATH="${openssl_lib_prefix}" otool -L "${test_gssapi}" | grep "libssl" || true +fi + +maybe_skip() { + if true; then + # TODO: Remove if-block when resolving CDRIVER-5995. + echo "Skipping test until DEVPROD-9029 is resolved." + return + fi + + if $IS_ZSERIES; then + # TODO: Remove if-block when resolving CDRIVER-5990. + echo "Skipping test until DEVPROD-16954 is resolved." + return + fi + # Run the test command: + "$@" +} + +if [[ "${ssl}" != "OFF" ]]; then + # FIXME: CDRIVER-2008 for the cygwin check + if [[ "${OSTYPE}" != "cygwin" ]]; then + echo "Authenticating using X.509" + LD_LIBRARY_PATH="${openssl_lib_prefix}" maybe_skip "${ping}" "mongodb://CN=client,OU=kerneluser,O=10Gen,L=New York City,ST=New York,C=US@${auth_host}/?ssl=true&authMechanism=MONGODB-X509&sslClientCertificateKeyFile=src/libmongoc/tests/x509gen/ldaptest-client-key-and-cert.pem&sslCertificateAuthorityFile=src/libmongoc/tests/x509gen/ldaptest-ca-cert.crt&sslAllowInvalidHostnames=true&${c_timeout}" + fi + echo "Connecting to Atlas Free Tier" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_free:?}&${c_timeout}" + echo "Connecting to Atlas Free Tier with SRV" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_free_srv:?}&${c_timeout}" + echo "Connecting to Atlas Replica Set" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_replset:?}&${c_timeout}" + echo "Connecting to Atlas Replica Set with SRV" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_replset_srv:?}${c_timeout}" + echo "Connecting to Atlas Sharded Cluster" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_shard:?}&${c_timeout}" + echo "Connecting to Atlas Sharded Cluster with SRV" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_shard_srv:?}${c_timeout}" + if [[ -z "${require_tls12:-}" ]]; then + echo "Connecting to Atlas with only TLS 1.1 enabled" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_tls11:?}&${c_timeout}" + echo "Connecting to Atlas with only TLS 1.1 enabled with SRV" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_tls11_srv:?}${c_timeout}" + fi + echo "Connecting to Atlas with only TLS 1.2 enabled" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_tls12:?}&${c_timeout}" + echo "Connecting to Atlas with only TLS 1.2 enabled with SRV" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_tls12_srv:?}${c_timeout}" + HAS_CIPHERSUITES_FOR_SERVERLESS="YES" + if [[ "${OSTYPE}" == "cygwin" ]]; then + # Windows Server 2008 hosts do not appear to share TLS 1.2 cipher suites with Atlas Serverless. + WINDOWS_OSNAME="$(systeminfo | grep 'OS Name:' | awk -F ':' '{print $2}')" + if [[ "${WINDOWS_OSNAME}" == *"Windows Server 2008"* ]]; then + echo "Detected Windows Server 2008 ... skipping Atlas Serverless test due to no shared cipher suites." + HAS_CIPHERSUITES_FOR_SERVERLESS="NO" + fi + fi + if [[ "${HAS_CIPHERSUITES_FOR_SERVERLESS}" == "YES" ]]; then + echo "Connecting to Atlas Serverless with SRV" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_serverless_srv:?}/?${c_timeout}" + echo "Connecting to Atlas Serverless" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_serverless:?}&${c_timeout}" + fi + + echo "Connecting to Atlas (cloud-prod) with X509" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_x509:?}&tlsCertificateKeyFile=${atlas_x509_path}&${c_timeout}" + + echo "Connecting to Atlas (cloud-dev) with X509" + LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_x509_dev:?}&tlsCertificateKeyFile=${atlas_x509_dev_path}&${c_timeout}" + +fi + +echo "Authenticating using PLAIN" +LD_LIBRARY_PATH="${openssl_lib_prefix}" maybe_skip "${ping}" "mongodb://${auth_plain:?}@${auth_host}/?authMechanism=PLAIN&${c_timeout}" + +echo "Authenticating using default auth mechanism" +# Though the auth source is named "mongodb-cr", authentication uses the default mechanism (currently SCRAM-SHA-1). +LD_LIBRARY_PATH="${openssl_lib_prefix}" maybe_skip "${ping}" "mongodb://${auth_mongodbcr:?}@${auth_host}/mongodb-cr?${c_timeout}" + +if [[ "${sasl}" != "OFF" ]]; then + echo "Authenticating using GSSAPI" + LD_LIBRARY_PATH="${openssl_lib_prefix}" maybe_skip "${ping}" "mongodb://${auth_gssapi:?}@${auth_host}/?authMechanism=GSSAPI&${c_timeout}" + + echo "Authenticating with CANONICALIZE_HOST_NAME" + LD_LIBRARY_PATH="${openssl_lib_prefix}" maybe_skip "${ping}" "mongodb://${auth_gssapi:?}@${ip_addr}/?authMechanism=GSSAPI&authMechanismProperties=CANONICALIZE_HOST_NAME:true&${c_timeout}" + + declare ld_preload="${LD_PRELOAD:-}" + if [[ "${ASAN:-}" == "on" ]]; then + ld_preload="$(bypass_dlclose):${ld_preload}" + fi + + echo "Test threaded GSSAPI auth" + LD_LIBRARY_PATH="${openssl_lib_prefix}" MONGOC_TEST_GSSAPI_HOST="${auth_host}" MONGOC_TEST_GSSAPI_USER="${auth_gssapi}" LD_PRELOAD="${ld_preload:-}" maybe_skip "${test_gssapi}" + echo "Threaded GSSAPI auth OK" + + if [[ "${OSTYPE}" == "cygwin" ]]; then + echo "Authenticating using GSSAPI (service realm: LDAPTEST.10GEN.CC)" + LD_LIBRARY_PATH="${openssl_lib_prefix}" maybe_skip "${ping}" "mongodb://${auth_crossrealm:?}@${auth_host}/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_REALM:LDAPTEST.10GEN.CC&${c_timeout}" + echo "Authenticating using GSSAPI (UTF-8 credentials)" + LD_LIBRARY_PATH="${openssl_lib_prefix}" maybe_skip "${ping}" "mongodb://${auth_gssapi_utf8:?}@${auth_host}/?authMechanism=GSSAPI&${c_timeout}" + fi +fi diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-aws-tests.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-aws-tests.sh similarity index 98% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-aws-tests.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-aws-tests.sh index b87478ac1..b29c6c78e 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-aws-tests.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-aws-tests.sh @@ -127,7 +127,7 @@ if [[ "${TESTCASE}" == "ECS" ]]; then # Run the test pushd "${drivers_tools_dir}/.evergreen/auth_aws" - PROJECT_DIRECTORY="$ECS_SRC_DIR" MONGODB_BINARIES=${mongoc_dir}/mongodb/bin ./aws_setup.sh ecs + PROJECT_DIRECTORY="$ECS_SRC_DIR" MONGODB_BINARIES=${drivers_tools_dir}/mongodb/bin ./aws_setup.sh ecs popd # "${drivers_tools_dir}/.evergreen/auth_aws" exit fi diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-mock-server-tests.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-mock-server-tests.sh similarity index 87% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-mock-server-tests.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-mock-server-tests.sh index 189fa38ec..ce97a24ff 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-mock-server-tests.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-mock-server-tests.sh @@ -46,12 +46,12 @@ fi case "${OSTYPE}" in cygwin) - LD_PRELOAD="${ld_preload:-}" ./src/libmongoc/test-libmongoc.exe "${test_args[@]}" + LD_PRELOAD="${ld_preload:-}" ./cmake-build/src/libmongoc/test-libmongoc.exe "${test_args[@]}" ;; *) ulimit -c unlimited || true - LD_PRELOAD="${ld_preload:-}" ./src/libmongoc/test-libmongoc --no-fork "${test_args[@]}" + LD_PRELOAD="${ld_preload:-}" ./cmake-build/src/libmongoc/test-libmongoc --no-fork "${test_args[@]}" ;; esac diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-mongodb-aws-ecs-test.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-mongodb-aws-ecs-test.sh old mode 100644 new mode 100755 similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-mongodb-aws-ecs-test.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-mongodb-aws-ecs-test.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-ocsp-cache-test.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-ocsp-cache-test.sh similarity index 95% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-ocsp-cache-test.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-ocsp-cache-test.sh index 55bbd471e..25a0cf47d 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-ocsp-cache-test.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-ocsp-cache-test.sh @@ -68,7 +68,7 @@ if [[ -d "${openssl_install_dir}" ]]; then fi # This test will hang after the first ping. -LD_LIBRARY_PATH="${openssl_lib_prefix}" "${mongoc_dir}/src/libmongoc/test-mongoc-cache" "${mongoc_dir}/.evergreen/ocsp/${CERT_TYPE}/ca.pem" & +LD_LIBRARY_PATH="${openssl_lib_prefix}" "${mongoc_dir}/cmake-build/src/libmongoc/test-mongoc-cache" "${mongoc_dir}/.evergreen/ocsp/${CERT_TYPE}/ca.pem" & sleep 5 # Give the program time to contact the OCSP responder pkill -nf "ocsp_mock" # We assume that the mock OCSP responder is named "ocsp_mock" diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-ocsp-responder.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-ocsp-responder.sh old mode 100644 new mode 100755 similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-ocsp-responder.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-ocsp-responder.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-ocsp-test.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-ocsp-test.sh similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-ocsp-test.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-ocsp-test.sh diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-tests-mingw.bat b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-tests-mingw.bat new file mode 100644 index 000000000..ff3acca39 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-tests-mingw.bat @@ -0,0 +1,15 @@ +rem "make install" would work, except we run tests on different Evergreen hosts, +rem in different working directories, than where the driver was built. This +rem causes errors in "make install" like: +rem CMake Error at cmake_install cannot find +rem "C:/data/mci/d3ba3391950aca9119e841818a8884bc/mongoc/src/libbson/libbson-1.0.dll" +rem +rem So just copy files manually + +rmdir /Q /S C:\mongo-c-driver +md C:\mongo-c-driver +md C:\mongo-c-driver\bin +copy /Y libmongoc-1.0.dll C:\mongo-c-driver\bin +copy /Y cmake-build\src\libbson\libbson-1.0.dll C:\mongo-c-driver\bin + +.\cmake-build\src\libmongoc\test-libmongoc.exe --no-fork -d -F test-results.json --skip-tests .evergreen\etc\skip-tests.txt diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-tests.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-tests.sh similarity index 90% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-tests.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-tests.sh index 798e3a6aa..760738e7e 100755 --- a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/run-tests.sh +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/run-tests.sh @@ -14,7 +14,6 @@ check_var_opt CLIENT_SIDE_ENCRYPTION check_var_opt COMPRESSORS "nocompressors" check_var_opt COVERAGE # CMake default: OFF. check_var_opt DNS "nodns" -check_var_opt IPV4_ONLY check_var_opt LOADBALANCED "noloadbalanced" check_var_opt MARCH check_var_opt MONGODB_API_VERSION @@ -30,6 +29,9 @@ script_dir="$(to_absolute "$(dirname "${BASH_SOURCE[0]}")")" declare mongoc_dir mongoc_dir="$(to_absolute "${script_dir}/../..")" +declare det_dir +det_dir="${mongoc_dir}/../drivers-evergreen-tools" + declare openssl_install_dir="${mongoc_dir}/openssl-install-dir" if [[ "${COMPRESSORS}" != "nocompressors" ]]; then @@ -53,10 +55,6 @@ export MONGOC_TEST_SERVER_LOG="json" export MONGOC_TEST_SKIP_MOCK="on" export MONGOC_TEST_IPV4_AND_IPV6_HOST="ipv4_and_ipv6.test.build.10gen.cc" -if [[ "${IPV4_ONLY}" != "on" ]]; then - export MONGOC_CHECK_IPV6="on" -fi - # Only set creds if testing with Client Side Encryption. # libmongoc may build with CSE enabled (if the host has libmongocrypt installed) # and will try to run those tests (which fail on ASAN unless spawning is bypassed). @@ -64,7 +62,7 @@ if [[ -n "${CLIENT_SIDE_ENCRYPTION}" ]]; then echo "Testing with Client Side Encryption enabled." echo "Setting temporary credentials..." - pushd "${mongoc_dir}/../drivers-evergreen-tools/.evergreen/csfle" + pushd "${det_dir:?}/.evergreen/csfle" { export AWS_SECRET_ACCESS_KEY="${client_side_encryption_aws_secret_access_key:?}" export AWS_ACCESS_KEY_ID="${client_side_encryption_aws_access_key_id:?}" @@ -113,8 +111,19 @@ fi # Sanitizer environment variables. export ASAN_OPTIONS="detect_leaks=1 abort_on_error=1 symbolize=1" export ASAN_SYMBOLIZER_PATH="/opt/mongodbtoolchain/v3/bin/llvm-symbolizer" -export TSAN_OPTIONS="suppressions=./.tsan-suppressions" -export UBSAN_OPTIONS="print_stacktrace=1 abort_on_error=1" +export TSAN_OPTIONS="suppressions=.tsan-suppressions" + +ubsan_opts=( + "print_stacktrace=1" + "abort_on_error=1" +) + +# UBSan with Clang 3.8 fails to parse the suppression file. +if [[ "${distro_id:?}" != ubuntu1604-* ]]; then + ubsan_opts+=("suppressions=.ubsan-suppressions") +fi + +export UBSAN_OPTIONS="${ubsan_opts[*]}" declare -a test_args=( "-d" @@ -159,12 +168,12 @@ wait_for_server() { return 1 } -if [[ "${CC}" =~ mingw ]]; then +if [[ "${OSTYPE:?}" == cygwin && "${CC}" =~ gcc ]]; then echo "Waiting for simple HTTP server to start..." - wait_for_server "simple HTTP" 8000 + wait_for_server "simple HTTP" 18000 echo "Waiting for simple HTTP server to start... done." - chmod -f +x ./src/libmongoc/test-libmongoc.exe + chmod -f +x ./cmake-build/src/libmongoc/test-libmongoc.exe cmd.exe /c "$(native-path "${script_dir}/run-tests-mingw.bat")" exit fi @@ -198,9 +207,6 @@ if [[ "${CLIENT_SIDE_ENCRYPTION}" == "on" ]]; then # Check if tests should use the crypt_shared library. if [[ "${SKIP_CRYPT_SHARED_LIB}" == "on" ]]; then echo "crypt_shared library is skipped due to SKIP_CRYPT_SHARED_LIB=on" - elif [[ -d /cygdrive/c ]]; then - # We have trouble with this test on Windows. only set cryptSharedLibPath on other platforms - echo "crypt_shared library is skipped due to running on Windows" else export MONGOC_TEST_CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH}" echo "crypt_shared library will be loaded with cryptSharedLibPath: [${MONGOC_TEST_CRYPT_SHARED_LIB_PATH}]" @@ -247,23 +253,20 @@ if [[ "${ASAN}" == "on" ]]; then ld_preload="$(bypass_dlclose):${ld_preload}" fi +# For mongocryptd, by integration-tests.sh. +export PATH="${det_dir:?}/mongodb/bin:${PATH:-}" + case "${OSTYPE}" in cygwin) - export PATH - PATH+=":/cygdrive/c/mongodb/bin" - PATH+=":/cygdrive/c/libmongocrypt/bin" - check_mongocryptd - chmod -f +x src/libmongoc/Debug/test-libmongoc.exe - LD_PRELOAD="${ld_preload:-}" ./src/libmongoc/Debug/test-libmongoc.exe "${test_args[@]}" + chmod -f +x cmake-build/src/libmongoc/Debug/test-libmongoc.exe + LD_PRELOAD="${ld_preload:-}" ./cmake-build/src/libmongoc/Debug/test-libmongoc.exe "${test_args[@]}" ;; *) ulimit -c unlimited || true - # Need mongocryptd on the path. - export PATH - PATH+=":$(pwd)/mongodb/bin" + check_mongocryptd # Custom OpenSSL library may be installed. Only prepend to LD_LIBRARY_PATH @@ -273,7 +276,7 @@ cygwin) openssl_lib_prefix="${openssl_install_dir}/lib:${openssl_lib_prefix:-}" fi - LD_LIBRARY_PATH="${openssl_lib_prefix}" LD_PRELOAD="${ld_preload:-}" ./src/libmongoc/test-libmongoc --no-fork "${test_args[@]}" + LD_LIBRARY_PATH="${openssl_lib_prefix}" LD_PRELOAD="${ld_preload:-}" ./cmake-build/src/libmongoc/test-libmongoc --no-fork "${test_args[@]}" ;; esac diff --git a/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/sbom.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/sbom.sh new file mode 100755 index 000000000..4a2a01dff --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/sbom.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail + +: "${branch_name:?}" +: "${DOCKER_CONFIG:?}" +: "${KONDUKTO_TOKEN:?}" + +command -v podman >/dev/null || { + echo "missing required program podman" 1>&2 + exit 1 +} + +silkbomb="901841024863.dkr.ecr.us-east-1.amazonaws.com/release-infrastructure/silkbomb:2.0" + +# Ensure latest version of SilkBomb is being used. +podman pull "${silkbomb:?}" + +silkbomb_augment_flags=( + --repo mongodb/mongo-c-driver + --branch "${branch_name:?}" + --sbom-in /pwd/etc/cyclonedx.sbom.json + --sbom-out /pwd/augmented-sbom.json + + # Any notable updates to the Augmented SBOM version should be done manually after careful inspection. + # Otherwise, it should be equal to the SBOM Lite version, which should normally be `1`. + --no-update-sbom-version +) + +# First validate the SBOM Lite. +podman run -it --rm -v "$(pwd):/pwd" "${silkbomb:?}" \ + validate --purls /pwd/etc/purls.txt --sbom-in /pwd/etc/cyclonedx.sbom.json --exclude jira + +# Then download the Augmented SBOM. Allow the timestamp to be updated. +podman run -it --rm -v "$(pwd):/pwd" --env 'KONDUKTO_TOKEN' "${silkbomb:?}" \ + augment "${silkbomb_augment_flags[@]:?}" + +[[ -f ./augmented-sbom.json ]] || { + echo "failed to download Augmented SBOM" 1>&2 + exit 1 +} diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/simple_http_server.py b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/simple_http_server.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/simple_http_server.py rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/simple_http_server.py diff --git a/3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/use-tools.sh b/3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/use-tools.sh old mode 100644 new mode 100755 similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.evergreen/scripts/use-tools.sh rename to 3rdparty/mongo-c-driver-2.1.0/.evergreen/scripts/use-tools.sh diff --git a/3rdparty/mongo-c-driver-1.26.2/.gdbinit b/3rdparty/mongo-c-driver-2.1.0/.gdbinit similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.gdbinit rename to 3rdparty/mongo-c-driver-2.1.0/.gdbinit diff --git a/3rdparty/mongo-c-driver-2.1.0/.git-blame-ignore-revs b/3rdparty/mongo-c-driver-2.1.0/.git-blame-ignore-revs new file mode 100644 index 000000000..dc072a3c4 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Format source files with ColumnLimit: 120 +482ea4e8d20a6af4be9c01d4fd220dd63b231332 diff --git a/3rdparty/mongo-c-driver-2.1.0/.gitattributes b/3rdparty/mongo-c-driver-2.1.0/.gitattributes new file mode 100644 index 000000000..0f545b96f --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.gitattributes @@ -0,0 +1,2 @@ +tests/binary/* text eol=lf +*.bat text eol=crlf diff --git a/3rdparty/mongo-c-driver-2.1.0/.github/CODEOWNERS b/3rdparty/mongo-c-driver-2.1.0/.github/CODEOWNERS new file mode 100644 index 000000000..8c946193d --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Listing code owners is required by DRIVERS-3098 +* @mongodb/dbx-c-cxx diff --git a/3rdparty/mongo-c-driver-2.1.0/.gitignore b/3rdparty/mongo-c-driver-2.1.0/.gitignore new file mode 100644 index 000000000..fc7b66b0e --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.gitignore @@ -0,0 +1,42 @@ +*.a +*.dylib +*.gcda +*.gcno +*.gz +*.o +*.lo +*.pc +*.so +*.so.* +.githooks +.scratch/ +cmake-build +cmake_install.cmake +CMakeCache.txt +CMakeFiles +CPackConfig.cmake +CPackSourceConfig.cmake +CTestTestfile.cmake +_build/ +dist_manifest.txt +test-results.json +*.pyc + +# Windows things +*.sdf +*.sln +*.vcxproj* +.vs +Debug +install_manifest.txt +x64 + +# "dist" is produced during the release process +dist + +# `secrets-export.sh` is created by the drivers-evergreen-tools `setup_secrets.sh` script. +# Ignore this file to reduce risk of committing credentials during local development. +secrets-export.sh + +# A file that can be used to store secrets for Earthly +.secret \ No newline at end of file diff --git a/3rdparty/mongo-c-driver-1.26.2/.gitmodules b/3rdparty/mongo-c-driver-2.1.0/.gitmodules similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.gitmodules rename to 3rdparty/mongo-c-driver-2.1.0/.gitmodules diff --git a/3rdparty/mongo-c-driver-1.26.2/.lsan-suppressions b/3rdparty/mongo-c-driver-2.1.0/.lsan-suppressions similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/.lsan-suppressions rename to 3rdparty/mongo-c-driver-2.1.0/.lsan-suppressions diff --git a/3rdparty/mongo-c-driver-2.1.0/.tsan-suppressions b/3rdparty/mongo-c-driver-2.1.0/.tsan-suppressions new file mode 100644 index 000000000..3a04c1c6b --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.tsan-suppressions @@ -0,0 +1 @@ +race:mongoc_counter* diff --git a/3rdparty/mongo-c-driver-2.1.0/.ubsan-suppressions b/3rdparty/mongo-c-driver-2.1.0/.ubsan-suppressions new file mode 100644 index 000000000..ef507b2df --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/.ubsan-suppressions @@ -0,0 +1,10 @@ +# src/utf8proc-2.8.0/utf8proc.c:368:53: runtime error: applying zero offset to null pointer +# src/utf8proc-2.8.0/utf8proc.c:554:20: runtime error: applying zero offset to null pointer +# +# Upstream Fix: https://github.com/JuliaStrings/utf8proc/pull/240 +# +# Context: https://github.com/llvm/llvm-project/commit/536b0ee40ab97f2878dc124a321cf9108ee3d233 +# > To make things more fun, in C (6.5.6p8), applying *any* offset to null pointer +# > is undefined, although Clang front-end pessimizes the code by not lowering +# > that info, so this UB is "harmless". +pointer-overflow:utf8proc.c diff --git a/3rdparty/mongo-c-driver-2.1.0/CMakeLists.txt b/3rdparty/mongo-c-driver-2.1.0/CMakeLists.txt new file mode 100644 index 000000000..58a673749 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/CMakeLists.txt @@ -0,0 +1,534 @@ +cmake_minimum_required (VERSION 3.15...4.0) + +list (INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/build/cmake") +# Defines BUILD_VERSION, which we use throughout: +include (BuildVersion) + +project ( + mongo-c-driver + LANGUAGES C + # BUILD_VERSION_SIMPLE is a CMake-compatible version number that omits suffixes + VERSION "${BUILD_VERSION_SIMPLE}" +) + +# Set MONGOC_MAJOR_VERSION, MONGOC_MINOR_VERSION, etc. +include (ParseVersion) +ParseVersion ("${BUILD_VERSION}" MONGOC) +# Defines additional similar variables: +include (LoadVersion) +LoadVersion (VERSION_CURRENT MONGOC) + +# Extended version attributes that CMake doesn't (yet) understand, which include +# the prerelease tag. Named here to match the variables generated by project() +set(mongo-c-driver_VERSION_PRERELEASE ${MONGOC_PRERELEASE_VERSION}) +set(mongo-c-driver_VERSION_FULL ${MONGOC_VERSION}) + +include(FeatureSummary) + +include (MongoSettings) +include (MongoPlatform) +include (GeneratePkgConfig) +include (VerifyHeaders) + +# Subcomponents: +mongo_bool_setting(ENABLE_MONGOC "Enable the build of libmongoc libraries (The MongoDB C database driver)") +mongo_bool_setting( + USE_SYSTEM_LIBBSON [[Use an existing libbson library (via find_package()) instead of building one from source]] + DEFAULT VALUE OFF + ADVANCED +) + +# Deprecated option "ENABLE_BSON" is gone, but old caches may rely on SYSTEM to +# disable the libbson build. Allow ENABLE_BSON=SYSTEM only if USE_SYSTEM_LIBBSON +# is also true, to allow both ENABLE_BSON=SYSTEM and USE_SYSTEM_LIBBSON=TRUE to +# simplify downstream build scripts +if(ENABLE_BSON STREQUAL "SYSTEM" AND NOT USE_SYSTEM_LIBBSON) + # User set ENABLE_BSON=SYSTEM, so they intend for us to build against an external + # libbson, but they didn't set USE_SYSTEM_LIBBSON=ON, so they are probably + # unaware of this change. Rather than miscompile, stop what we're doing: + message(FATAL_ERROR "ENABLE_BSON=SYSTEM is no longer supported. Use USE_SYSTEM_LIBBSON=ON for the same effect.") +endif() + +# Toggle static libraries: +mongo_setting( + ENABLE_STATIC "Enable building and installing static library archive artifacts" + OPTIONS ON OFF BUILD_ONLY + DEFAULT VALUE "ON" +) +# Toggle dynamic libraries: +mongo_bool_setting(ENABLE_SHARED "Enable building and installing dynamic library artifacts") + +# Toggle PIC +if(NOT WIN32) + mongo_bool_setting(ENABLE_PIC "Enable position-independent code when building static libraries (Not applicable on Windows)") +elseif(DEFINED ENABLE_PIC) + # We are on Windows, and ENABLE_PIC is defined. + message(STATUS "ENABLE_PIC=“${ENABLE_PIC}†has no effect on Windows (All Windows code is position-independent)") +else() + # We are on Windows, and ENABLE_PIC is not defined, which is normal +endif() + +# Dev mode checks: +mongo_bool_setting( + ENABLE_MAINTAINER_FLAGS "Enable stricter build-time checks" + DEFAULT VALUE OFF + DEVEL EVAL [[ + if(MSVC) + set(DEFAULT OFF) + else() + set(DEFAULT ON) + endif() + ]]) + +# Toggle instrumentation: +mongo_bool_setting(ENABLE_TRACING "Enable runtime tracing output in the built libmongoc (Very noisy!)" + DEFAULT VALUE OFF) +mongo_bool_setting(ENABLE_COVERAGE "Build code with coverage instrumentation" + DEFAULT VALUE OFF DEVEL VALUE ON) +mongo_bool_setting(ENABLE_DEBUG_ASSERTIONS "Build library with runtime debug assertions enabled" + DEFAULT VALUE OFF DEVEL VALUE ON) +# for MONGO_SANITIZE: +include(Sanitizers) + +# Toggle optional components: +mongo_bool_setting(ENABLE_TESTS "Enable building MongoDB C Driver tests") +mongo_bool_setting(ENABLE_EXAMPLES "Enable building MongoDB C Driver examples") +mongo_bool_setting(ENABLE_MAN_PAGES "Enable building the manual pages" DEFAULT VALUE OFF) +mongo_bool_setting(ENABLE_HTML_DOCS "Enable building the HTML documentation" DEFAULT VALUE OFF) +mongo_bool_setting(ENABLE_UNINSTALL "Generate an 'uninstall' script and an 'uninstall' build target") +mongo_bool_setting(ENABLE_SRV "Enable support for mongodb+srv URIs.") + +# Optional features that are ENABLED when necessary dependencies are found: +mongo_setting(ENABLE_SNAPPY "Enable Snappy compression support" + OPTIONS ON OFF AUTO + DEFAULT VALUE AUTO) +mongo_setting(ENABLE_ZSTD "Enable zstd compression support" + OPTIONS ON OFF AUTO + DEFAULT VALUE AUTO) +mongo_setting(ENABLE_ZLIB "Enable zlib compression support" + OPTIONS BUNDLED SYSTEM OFF + DEFAULT VALUE BUNDLED) +mongo_bool_setting(USE_BUNDLED_UTF8PROC "Enable building with utf8proc. Needed for SCRAM-SHA-256 authentication with non-ASCII passwords" + ADVANCED) +mongo_setting( + ENABLE_SSL [[Enable TLS connection and SCRAM authentication.]] + OPTIONS WINDOWS DARWIN OPENSSL OFF AUTO + DEFAULT VALUE AUTO + VALIDATE CODE [[ + if(ENABLE_SSL STREQUAL "DARWIN" AND NOT APPLE) + message(WARNING "ENABLE_SSL=DARWIN is only supported on Apple platforms") + elseif(ENABLE_SSL STREQUAL "WINDOWS" AND NOT WIN32) + message(WARNING "ENABLE_SSL=WINDOWS is only supported on Windows platforms") + endif() + ]] +) +mongo_bool_setting( + ENABLE_SHM_COUNTERS "Enable memory performance counters" + DEFAULT EVAL [[ + set(DEFAULT OFF) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" OR (APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")) + set(DEFAULT ON) + endif() + ]] + VALIDATE CODE [[ + if(ENABLE_SHM_COUNTERS + AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" + AND NOT (APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")) + message(WARNING "ENABLE_SHM_COUNTERS=ON is only supported on Linux or ARM Darwin") + endif() + ]] +) + +mongo_setting( + ENABLE_SASL "Enable SASL authentication (Kerberos)" + OPTIONS CYRUS SSPI OFF AUTO + DEFAULT VALUE AUTO + VALIDATE CODE [[ + if(ENABLE_SASL STREQUAL "SSPI" AND NOT WIN32) + message(WARNING "ENABLE_SASL=SSPI is only supported on Windows platforms") + endif() + if(ENABLE_SASL STREQUAL "CYRUS" AND WIN32) + message(WARNING "ENABLE_SASL=CYRUS on Windows platforms is unsupported. Use ENABLE_SASL=SSPI or ENABLE_SASL=OFF instead") + endif() + ]] +) + +mongo_setting(ENABLE_CLIENT_SIDE_ENCRYPTION "Enable In-Use Encryption support. Requires additional support libraries." + OPTIONS ON OFF AUTO + DEFAULT VALUE AUTO) +mongo_setting(ENABLE_MONGODB_AWS_AUTH "Enable support for the MONGODB-AWS authentication mechanism" + OPTIONS ON OFF AUTO + DEFAULT VALUE AUTO + VALIDATE CODE [[ + if(NOT ENABLE_MONGODB_AWS_AUTH STREQUAL "ON") + return() + endif() + if(MSVC AND MSVC_VERSION LESS 1900) + message(FATAL_ERROR "Visual Studio 2015 or newer is required for ENABLE_MONGODB_AWS_AUTH=ON") + elseif(ENABLE_SSL STREQUAL "OFF") + message(FATAL_ERROR "ENABLE_MONGODB_AWS_AUTH=ON requires that ENABLE_SSL not be 'OFF'") + endif() + ]]) + +# Optional features that are DISABLED by default: +mongo_bool_setting(ENABLE_RDTSCP "Enable fast performance counters using the Intel RDTSCP instruction" + DEFAULT VALUE OFF) +mongo_bool_setting( + ENABLE_CRYPTO_SYSTEM_PROFILE "Use system crypto profile" + DEFAULT VALUE OFF + VALIDATE CODE [[ + if(ENABLE_CRYPTO_SYSTEM_PROFILE AND NOT ENABLE_SSL STREQUAL "OPENSSL") + message(WARNING "ENABLE_CRYPTO_SYSTEM_PROFILE=TRUE is only applicable when ENABLE_SSL=OPENSSL") + endif() + ]] +) + +# Announce the build configuration. Used by `mlib_build_config_is()` in `mlib/config.h` +add_compile_definitions(_MLIB_BUILD_CONFIG=$) + +if(ENABLE_COVERAGE) + mongo_platform_link_options(--coverage) + mongo_platform_compile_options($) +endif() + +# Enable multi-threading: +set(THREADS_PREFER_PTHREAD_FLAG TRUE) +find_package(Threads REQUIRED) +mongo_platform_use_target(Threads::Threads) + +set_property(DIRECTORY APPEND PROPERTY pkg_config_LIBS ${CMAKE_THREAD_LIBS_INIT}) + +if(WIN32) + # Required for gethostbyname on Windows: + mongo_platform_link_libraries(ws2_32) +endif() + +# librt needed on linux for clock_gettime +find_library(RT_LIBRARY rt PATHS /usr/lib32) +if(RT_LIBRARY) + mongo_platform_link_libraries(${RT_LIBRARY}) + # Set required libraries for CHECK_FUNCTION_EXISTS + list(APPEND CMAKE_REQUIRED_LIBRARIES "${RT_LIBRARY}") + # Export the rt linkage as a pkg-config property: + get_filename_component(rt_dir "${RT_LIBRARY}" DIRECTORY) + set_property(DIRECTORY APPEND PROPERTY pkg_config_LIBS "-L${rt_dir}" -lrt) +endif() + +# On macOS Big Sur, libm resolves to the SDK's tbd file, like: +# /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd +# Not all consumers can easily link to a tbd file (notably golang will reject a tbd suffix by default) +# macOS includes libm as part of libSystem (along with libc). +# It does not need to be explicitly linked. +if(NOT APPLE) + find_library(M_LIBRARY m) + if(M_LIBRARY) + mongo_platform_link_libraries(${M_LIBRARY}) + endif() +endif() + +# Optionally enable C++ to do some C++-specific tests +include (CheckLanguage) +check_language (CXX) +if (CMAKE_CXX_COMPILER) + enable_language (CXX) + if (NOT CMAKE_CXX_STANDARD) + # Default to C++11 for purposes of testing. + set (CMAKE_CXX_STANDARD 11) + endif () +else () + message (STATUS "No CXX support") +endif () + +if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set (CMAKE_BUILD_TYPE "RelWithDebInfo") + message ( + STATUS "No CMAKE_BUILD_TYPE selected, defaulting to ${CMAKE_BUILD_TYPE}" + ) +endif () + +include (InstallRequiredSystemLibraries) +include (CMakeDependentOption) + +# Installation paths +include (GNUInstallDirs) +# The directory where CMake config packages will be installed, based on the libdir from GNUInstallDirs +mongo_setting( + MONGO_C_DRIVER_INSTALL_CMAKEDIR "The directory in which CMake package files will be installed" + TYPE STRING + DEFAULT VALUE "${CMAKE_INSTALL_LIBDIR}/cmake" + VALIDATE CODE [[ + if(IS_ABSOLUTE "${MONGO_C_DRIVER_INSTALL_CMAKEDIR}") + message(SEND_ERROR "The CMake installation directory must be a relative path (Got “${MONGO_C_DRIVER_INSTALL_CMAKEDIR}â€)") + endif() + ]] +) + +include(MongoC-Warnings) + +# Enable "maintainer flags," which are supplementary but not mandatory. +# (As opposed to MongoC-Warnings.cmake, which defines "the code is broken" warnings) +if(ENABLE_MAINTAINER_FLAGS) + mongoc_add_warning_options( + gnu-like:-Werror + gnu-like:-pedantic + gnu-like:-Wall + gnu-like:-Wempty-body + gnu:not-gcc-lt7:-Wexpansion-to-defined + gnu-like:-Winit-self + gnu-like:-Wmissing-include-dirs + gnu-like:-Wredundant-decls + gnu-like:-Wshadow + gnu-like:lang-c:-Wstrict-prototypes + gnu-like:-Wswitch-default + gnu-like:-Wswitch-enum + gnu-like:-Wundef + gnu-like:-Wuninitialized + # Disabled, for now: + gnu-like:-Wno-strict-aliasing + # Sign-comparison-mismatch: + gnu-like:-Wsign-compare + msvc:/we4018 + ) +endif() + +# Link with LLD, if possible +if (NOT MSVC) + include (LLDLinker) +endif () + +if ( (ENABLE_BUILD_DEPENDECIES STREQUAL OFF) AND (NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) ) + set (ENABLE_BUILD_DEPENDECIES ON) +endif () + +mongo_pick(MONGOC_ENABLE_RDTSCP 1 0 ENABLE_RDTSCP) + +mongo_pick(MONGOC_ENABLE_STATIC_BUILD 1 0 ENABLE_STATIC) +mongo_pick(MONGOC_ENABLE_STATIC_INSTALL 1 0 + [[ENABLE_STATIC AND NOT ENABLE_STATIC STREQUAL "BUILD_ONLY"]]) + +if (USE_SYSTEM_LIBBSON) + find_package (bson "${PROJECT_VERSION}" REQUIRED) + # Disable test-libmongoc since we are using a system libbson + set (ENABLE_TESTS OFF) + + set (USING_SYSTEM_BSON TRUE) + if (NOT TARGET bson::shared) + message (FATAL_ERROR "System libbson built without shared library target") + endif () + if (NOT TARGET bson::static) + message (FATAL_ERROR "System libbson built without static library target") + endif () +endif () + +set (BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR}) + +# Enable CTest +include (CTest) +if (BUILD_TESTING) + include (TestFixtures) + include (src/libmongoc/tests/import-tests.cmake) +endif () + +# Ensure the default behavior: don't ignore RPATH settings. +set (CMAKE_SKIP_BUILD_RPATH OFF) + +# Ensure the default behavior: don't use the final install destination as the +# temporary RPATH for executables (ensure we can run tests and programs from +# the build directory). +set (CMAKE_BUILD_WITH_INSTALL_RPATH OFF) + +# Include any custom library paths in the final RPATH. +set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) + +# Install libs with names like @rpath/libfoo.dylib, not bare names. +set (CMAKE_MACOSX_RPATH ON) + +# Distinguish DLL import libs with a .dll.lib suffix. Also prevents filename collisions +# between static libraries and the import libraries +if(WIN32) + set (CMAKE_IMPORT_LIBRARY_SUFFIX .dll.lib) +endif() + +# By default, ensure conformance with a minimum C standard. +# Required extensions to the language (i.e. POSIX) are (re)enabled further below. +if (NOT DEFINED CMAKE_C_STANDARD) + set (CMAKE_C_STANDARD 99) +endif () +if (NOT DEFINED CMAKE_C_STANDARD_REQUIRED) + set (CMAKE_C_STANDARD_REQUIRED ON) +endif () +if (NOT DEFINED CMAKE_C_EXTENSIONS) + set (CMAKE_C_EXTENSIONS OFF) +endif () + +# https://man7.org/linux/man-pages/man7/feature_test_macros.7.html +# https://pubs.opengroup.org/onlinepubs/7908799/xsh/compilation.html +# Enable POSIX features up to POSIX.1-2008 plus the XSI extension and BSD-derived definitions. +# Both _BSD_SOURCE and _DEFAULT_SOURCE are defined for backwards-compatibility with glibc 2.19 and earlier. +# _BSD_SOURCE and _DEFAULT_SOURCE are required by `getpagesize`, `h_errno`, etc. +# _XOPEN_SOURCE=700 is required by `strnlen`, `strerror_l`, etc. +add_definitions (-D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_DEFAULT_SOURCE) +list (APPEND CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_DEFAULT_SOURCE) + +# Enable non-standard features on FreeBSD with __BSD_VISIBLE=1 +if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + add_definitions (-D__BSD_VISIBLE=1) + list (APPEND CMAKE_REQUIRED_DEFINITIONS -D__BSD_VISIBLE=1) +endif () + +# https://opensource.apple.com/source/Libc/Libc-1439.40.11/gen/compat.5.auto.html +# Non-POSIX extensions are required by `_SC_NPROCESSORS_ONLN`. +if (CMAKE_SYSTEM_NAME MATCHES "Darwin") + add_definitions (-D_DARWIN_C_SOURCE) + list (APPEND CMAKE_REQUIRED_DEFINITIONS -D_DARWIN_C_SOURCE) +endif () + +# Convenience targets to build all tests or all examples. +add_custom_target(mongo_c_driver_tests) +add_custom_target(mongo_c_driver_examples) + +add_subdirectory (src/common) + +if (NOT USING_SYSTEM_BSON) + message (STATUS "Using bundled libbson") + add_subdirectory (src/libbson) +endif () + +if (MSVC) + add_definitions (-D_CRT_SECURE_NO_WARNINGS) + list (APPEND CMAKE_REQUIRED_DEFINITIONS -D_CRT_SECURE_NO_WARNINGS) +endif () + +if (ENABLE_MONGOC) + if (ENABLE_TESTS AND NOT MONGOC_ENABLE_STATIC_BUILD) + message (FATAL_ERROR "ENABLE_TESTS requires ENABLE_STATIC or ENABLE_STATIC_BUILD") + endif () + + set (CPACK_RESOURCE_FILE_LICENSE "${mongo-c-driver_SOURCE_DIR}/COPYING") + + include (CPack) + + # Ensure the default behavior: don't ignore RPATH settings. + set (CMAKE_SKIP_BUILD_RPATH OFF) + + if (NOT ENABLE_MONGODB_AWS_AUTH MATCHES "ON|OFF|AUTO") + message (FATAL_ERROR "ENABLE_MONGODB_AWS_AUTH option must be ON, AUTO, or OFF") + endif () + set (MONGOC_ENABLE_MONGODB_AWS_AUTH 0) + if (ENABLE_MONGODB_AWS_AUTH STREQUAL "AUTO") + if (MSVC AND MSVC_VERSION LESS 1900) + message (WARNING "MS Visual Studio too old for ENABLE_MONGODB_AWS_AUTH") + elseif (NOT ENABLE_SSL) + message (WARNING + "Option ENABLE_MONGODB_AWS_AUTH requires ENABLE_SSL not set to OFF" + ) + else () + set (MONGOC_ENABLE_MONGODB_AWS_AUTH 1) + endif () + elseif (ENABLE_MONGODB_AWS_AUTH) + if (MSVC AND MSVC_VERSION LESS 1900) + message (FATAL_ERROR "Use Visual Studio 2015 or higher for ENABLE_MONGODB_AWS_AUTH") + endif () + if (NOT ENABLE_SSL) + message (FATAL_ERROR + "Option ENABLE_MONGODB_AWS_AUTH requires ENABLE_SSL not set to OFF" + ) + endif () + set (MONGOC_ENABLE_MONGODB_AWS_AUTH 1) + endif () + + add_subdirectory (src/libmongoc) + + if (MONGOC_ENABLE_MONGODB_AWS_AUTH) + message (STATUS "Building with MONGODB-AWS auth support") + endif () + + if (ENABLE_MAN_PAGES STREQUAL ON OR ENABLE_HTML_DOCS STREQUAL ON) + find_package (Sphinx REQUIRED) + add_custom_target (doc + ALL + DEPENDS + $<$>:bson-doc> + $<$:mongoc-doc> + ) + endif () + + # sub-directory 'doc' was already included above + add_subdirectory (src) + # 'src/libbson' was already included, so 'src' will not include it directly + # 'src/kms-message' was already included if appropriate + # 'src/libmongoc' was already included, so 'src' will not include it directly +endif () + +install (FILES COPYING NEWS README.rst THIRD_PARTY_NOTICES + DESTINATION ${CMAKE_INSTALL_DATADIR}/mongo-c-driver/${PROJECT_VERSION} +) + +if (ENABLE_UNINSTALL) + # Create uninstall program and associated uninstall target + # + # This needs to be last (after all other add_subdirectory calls) to ensure that + # the generated uninstall program is complete and correct + if (NOT ENABLE_MONGOC) + # Generate a different script name for uninstalling libbson only: + set (UNINSTALL_SCRIPT_NAME "uninstall-bson") + endif () + set (UNINSTALL_PROG_DIR "${CMAKE_INSTALL_DATADIR}/mongo-c-driver/${PROJECT_VERSION}") + include (GenerateUninstaller) +endif () + +# Spit out some information regarding the generated build system +message (STATUS "Build files generated for:") +message (STATUS "\tbuild system: ${CMAKE_GENERATOR}") +if (CMAKE_GENERATOR_INSTANCE) + message (STATUS "\tinstance: ${CMAKE_GENERATOR_INSTANCE}") +endif () +if (CMAKE_GENERATOR_PLATFORM) + message (STATUS "\tinstance: ${CMAKE_GENERATOR_PLATFORM}") +endif () +if (CMAKE_GENERATOR_TOOLSET) + message (STATUS "\tinstance: ${CMAKE_GENERATOR_TOOLSET}") +endif () + +if (TARGET test-libmongoc) + # Generate a file that can be included by CTest to load and enumerate all of the + # tests defined by the test-libmongoc executable. Generate one for each + # configuration in case of multiconf generators. + string (CONFIGURE [=[ + set (TEST_LIBMONGOC_EXE [[$]]) + set (SRC_ROOT [[@PROJECT_SOURCE_DIR@]]) + set (IS_MULTICONF $) + if (NOT IS_MULTICONF OR CTEST_CONFIGURATION_TYPE STREQUAL "$") + # We are not in multi-conf, or the current config matches our config. + include ("${SRC_ROOT}/build/cmake/LoadTests.cmake") + elseif (NOT CTEST_CONFIGURATION_TYPE) + # We are in multi-conf, but no '-C' config was specified + message (WARNING "Specify a --build-config when using CTest with a multi-config build") + else () + # Do nothing. Not our config. + endif () + ]=] code @ONLY) + file (GENERATE + OUTPUT "${PROJECT_BINARY_DIR}/LoadTests-$.cmake" + CONTENT "${code}") + if (CMAKE_CONFIGURATION_TYPES) + foreach (conf IN LISTS CMAKE_CONFIGURATION_TYPES) + # Direct the generated CTest code to include() the file that loads the tests: + set_property ( + DIRECTORY + APPEND PROPERTY + TEST_INCLUDE_FILES "${PROJECT_BINARY_DIR}/LoadTests-${conf}.cmake") + endforeach () + else () + set_property ( + DIRECTORY + APPEND PROPERTY + TEST_INCLUDE_FILES "${PROJECT_BINARY_DIR}/LoadTests-${CMAKE_BUILD_TYPE}.cmake") + endif () +endif () + +if (CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND PROJECT_IS_TOP_LEVEL) + set (CMAKE_CROSS_CONFIGS "all") +endif () + +feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES) diff --git a/3rdparty/mongo-c-driver-1.26.2/CONTRIBUTING.md b/3rdparty/mongo-c-driver-2.1.0/CONTRIBUTING.md similarity index 85% rename from 3rdparty/mongo-c-driver-1.26.2/CONTRIBUTING.md rename to 3rdparty/mongo-c-driver-2.1.0/CONTRIBUTING.md index c25555d8c..3c1653b93 100644 --- a/3rdparty/mongo-c-driver-1.26.2/CONTRIBUTING.md +++ b/3rdparty/mongo-c-driver-2.1.0/CONTRIBUTING.md @@ -15,7 +15,7 @@ The mongo-c-driver has a few guidelines that help direct the process. ### Portability mongo-c-driver is portable software. It needs to run on a multitude of -[Supported Platforms](https://mongoc.org/libmongoc/current/installing.html#supported-platforms). +[Supported Platforms](https://www.mongodb.com/docs/languages/c/c-driver/current/libmongoc/ref/platforms/). ### Licensing @@ -111,23 +111,19 @@ a block comment like the following: Public functions do not need these comment blocks, since they are documented in the .rst files. -To build the documentation, it is recommended to use the Poetry-managed Python -project to ensure that the exact tooling versions match. If you do not have -Poetry installed, you can use the `poetry.sh` or `poetry.ps1` scripts in the -`tools/` directory. First, install dependencies: +To build the documentation, it is recommended to run Sphinx commands through `uv`: -```sh -./tools/poetry.sh install --with=docs +```bash +uv run --frozen sphinx-build -WEn -bhtml src/libmongoc/doc/ src/libmongoc/doc/html ``` -Then, execute `sphinx-build` in the Python environment, using the paths to the -documentation to be generated: +`sphinx-autobuild` can be used to serve docs locally. This can be convenient when editing. Files are rebuilt +when changes are detected: -```sh -./tools/poetry.sh run sphinx-build -WEn -bhtml src/libmongoc/doc/ src/libmongoc/doc/html +```bash +uv run --frozen --with 'sphinx-autobuild' sphinx-autobuild -b html src/libmongoc/doc/ src/libmongoc/doc/html --re-ignore ".*.pickle" --re-ignore ".*.doctree" -j auto ``` - ### Testing To run the entire test suite, including authentication and support for the @@ -142,7 +138,7 @@ $ mongod --auth --setParameter enableTestCommands=1 --dbpath db/ In another terminal, use the `mongosh` shell to create a user: ``` -$ mongosh --eval "db.createUser({user: 'admin', pwd: 'pass', roles: ['root']})" admin +$ mongosh --eval "db.createUser({user: 'bob', pwd: 'pwd123', roles: ['root']})" admin ``` Authentication in MongoDB 3.0 and later uses SCRAM-SHA-1, which in turn @@ -151,8 +147,8 @@ requires a driver built with SSL. Set the user and password environment variables, then build and run the tests: ``` -$ export MONGOC_TEST_USER=admin -$ export MONGOC_TEST_PASSWORD=pass +$ export MONGOC_TEST_USER=bob +$ export MONGOC_TEST_PASSWORD=pwd123 $ ./test-libmongoc ``` @@ -183,6 +179,13 @@ If you start `mongod` with SSL, set these variables to configure how * `MONGOC_TEST_SSL_CRL_FILE`: path to a certificate revocation list. * `MONGOC_TEST_SSL_WEAK_CERT_VALIDATION`: set to `on` to relax the client's validation of the server's certificate. +* `MONGOC_TEST_SCHANNEL_CRL=on`: set to `on` to enable Windows Secure Channel tests loading CRL files. + * If CRL tests abort before deleting the CRL file, this may cause later test errors like `The certificate is revoked`. Manually remove the CRL file with: + ```powershell + $crl = ".\src\libmongoc\tests\x509gen\crl.pem" + $fingerprint = (openssl crl -in ".\src\libmongoc\tests\x509gen\crl.pem" -noout -fingerprint) -replace 'SHA1 Fingerprint=', '' -replace ':', '' + certutil -delstore Root $fingerprint + ``` The SASL / GSSAPI / Kerberos tests are skipped by default. To run them, set up a separate `mongod` with Kerberos and set its host and Kerberos principal name @@ -221,10 +224,6 @@ Some tests run against a local mock server, these can be skipped with: * `MONGOC_TEST_SKIP_MOCK=on` -If you have started with MongoDB with `--ipv6`, you can test IPv6 with: - -* `MONGOC_CHECK_IPV6=on` - The tests for mongodb+srv:// connection strings require some setup, see the Initial DNS Seedlist Discovery Spec. By default these connection strings are NOT tested, enable them with: @@ -241,7 +240,7 @@ The mock server timeout threshold for future functions can be set with: This is useful for debugging, so future calls don't timeout when stepping through code. -Tests of Client-Side Field Level Encryption require credentials to external KMS providers. +Tests of In-Use Encryption require credentials to external KMS providers. For AWS: @@ -261,7 +260,7 @@ For GCP: * `MONGOC_TEST_GCP_EMAIL=` * `MONGOC_TEST_GCP_PRIVATEKEY=` -Tests of Client-Side Field Level Encryption also require temporary credentials to external KMS providers. +Tests of In-Use Encryption also require temporary credentials to external KMS providers. For AWS: @@ -269,12 +268,12 @@ For AWS: * `MONGOC_TEST_AWS_TEMP_ACCESS_KEY_ID=` * `MONGOC_TEST_AWS_TEMP_SESSION_TOKEN=` -Tests of Client-Side Field Level Encryption spawn an extra process, "mongocryptd", by default. To bypass this spawning, +Tests of In-Use Encryption spawn an extra process, "mongocryptd", by default. To bypass this spawning, start mongocryptd on port 27020 and set the following: * `MONGOC_TEST_MONGOCRYPTD_BYPASS_SPAWN=on` -KMS TLS tests for Client-Side Field Level Encryption require mock KMS servers to be running in the background. +KMS TLS tests for In-Use Encryption require mock KMS servers to be running in the background. The [Setup instructions](https://github.com/mongodb/specifications/tree/master/source/client-side-encryption/tests#setup-3) given in the Client Side Encryption Tests specification provide additional information. @@ -287,8 +286,9 @@ The set of mock KMS servers running in the background and their corresponding in | 8999 | ca.pem | server.pem | python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 8999 | 9000 | ca.pem | expired.pem | python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 9000 | 9001 | ca.pem | wrong-host.pem | python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 9001 -| 9002 | ca.pem | server.pem | python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port --require_client_cert 9002 +| 9002 | ca.pem | server.pem | python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --require_client_cert --port 9002 | 5698 | ca.pem | server.pem | python -u kms_kmip_server.py +| 9003 | ca.pem | server.pem | python kms_failpoint_server.py --port 9003 The path to `ca.pem` and `client.pem` must be passed through the following environment variables: @@ -318,6 +318,10 @@ To test a load balanced deployment, set the following environment variables: * `SINGLE_MONGOS_LB_URI=` to a MongoDB URI with a host of a load balancer fronting one mongos. * `MULTI_MONGOS_LB_URI=` to a MongoDB URI with a host of a load balancer fronting multiple mongos processes. +To run test cases with large allocations, set: + +* `MONGOC_TEST_LARGE_ALLOCATIONS=on` This may result in sudden test suite termination due to allocation failure. Use with caution. + All tests should pass before submitting a patch. ## Configuring the test runner diff --git a/3rdparty/mongo-c-driver-1.26.2/COPYING b/3rdparty/mongo-c-driver-2.1.0/COPYING similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/COPYING rename to 3rdparty/mongo-c-driver-2.1.0/COPYING diff --git a/3rdparty/mongo-c-driver-2.1.0/Earthfile b/3rdparty/mongo-c-driver-2.1.0/Earthfile new file mode 100644 index 000000000..b4c344562 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/Earthfile @@ -0,0 +1,572 @@ +VERSION --arg-scope-and-set --pass-args --use-function-keyword 0.7 +LOCALLY + +# Allow setting the "default" container image registry to use for image short names (e.g. to Amazon ECR). +ARG --global default_search_registry=docker.io + +IMPORT ./tools/ AS tools + +# For target names, descriptions, and build parameters, run the "doc" Earthly subcommand. +# Example use: +build --env=u22 --sasl=off --tls=OpenSSL --c_compiler=gcc + +# COPY_SOURCE : +# Copy source files required for the build into the specified "--into" directory +COPY_SOURCE: + FUNCTION + ARG --required into + COPY --dir \ + build/ \ + CMakeLists.txt \ + COPYING \ + NEWS \ + README.rst \ + src/ \ + THIRD_PARTY_NOTICES \ + VERSION_CURRENT \ + "$into" + +# CONFIGURE : +# Configure the project in $source_dir into $build_dir with a common set of configuration options +CONFIGURE: + FUNCTION + ARG --required source_dir + ARG --required build_dir + ARG --required tls + ARG --required sasl + RUN cmake -S "$source_dir" -B "$build_dir" -G "Ninja Multi-Config" \ + -D ENABLE_MAINTAINER_FLAGS=ON \ + -D ENABLE_SHM_COUNTERS=ON \ + -D ENABLE_SASL=$(echo $sasl | __str upper) \ + -D ENABLE_SNAPPY=ON \ + -D ENABLE_SRV=ON \ + -D ENABLE_ZLIB=BUNDLED \ + -D ENABLE_SSL=$(echo $tls | __str upper) \ + -D ENABLE_COVERAGE=ON \ + -D ENABLE_DEBUG_ASSERTIONS=ON \ + -Werror + +# build : +# Build libmongoc and libbson using the specified environment. +# +# The --env argument specifies the build environment among the `+env.xyz` environment +# targets, using --purpose=build for the build environment. Refer to the target +# list for a list of available build environments. +build: + # env is an argument + ARG --required env + FROM --pass-args +env.$env --purpose=build + # The configuration to be built + ARG config=RelWithDebInfo + # The prefix at which to install the built result + ARG install_prefix=/opt/mongo-c-driver + # Build configuration parameters. Will be case-normalized for CMake usage. + ARG --required sasl + ARG --required tls + LET source_dir=/opt/mongoc/source + LET build_dir=/opt/mongoc/build + DO +COPY_SOURCE --into=$source_dir + ENV CCACHE_HOME=/root/.cache/ccache + DO --pass-args +CONFIGURE --source_dir=$source_dir --build_dir=$build_dir + RUN --mount=type=cache,target=$CCACHE_HOME \ + env CCACHE_BASE="$source_dir" \ + cmake --build $build_dir --config $config + RUN cmake --install $build_dir --prefix="$install_prefix" --config $config + SAVE ARTIFACT /opt/mongoc/build/* /build-tree/ + SAVE ARTIFACT /opt/mongo-c-driver/* /root/ + +# test-example will build one of the libmongoc example projects using the build +# that comes from the +build target. Arguments for +build should also be provided +test-example: + ARG --required env + FROM --pass-args +env.$env --purpose=build + # Grab the built library + COPY --pass-args +build/root /opt/mongo-c-driver + # Add the example files + COPY --dir \ + src/libmongoc/examples/cmake \ + src/libmongoc/examples/hello_mongoc.c \ + /opt/mongoc-test/ + # Configure and build it + RUN cmake \ + -S /opt/mongoc-test/cmake/find_package \ + -B /bld \ + -G Ninja \ + -D CMAKE_PREFIX_PATH=/opt/mongo-c-driver + RUN cmake --build /bld + +# test-cxx-driver : +# Clone and build the mongo-cxx-driver project, using the current mongo-c-driver +# for the build. +# +# The “--test_mongocxx_ref†argument must be a clone-able Git ref. The driver source +# will be cloned at this point and built. +# +# The “--cxx_version_current†argument will be inserted into the VERSION_CURRENT +# file for the cxx-driver build. The default value is “0.0.0†+# +# Arguments for +build should be provided. +test-cxx-driver: + ARG --required env + ARG --required test_mongocxx_ref + FROM --pass-args +env.$env --purpose=build + ARG cxx_compiler + IF test "$cxx_compiler" = "" + # No cxx_compiler is set, so infer based on a possible c_compiler option + ARG c_compiler + IF test "$c_compiler" != "" + # ADD_CXX_COMPILER will remap the C compiler name to an appropriate C++ name + LET cxx_compiler="$c_compiler" + ELSE + LET cxx_compiler = gcc + END + END + ARG cxx_version_current=0.0.0 + DO tools+ADD_CXX_COMPILER --cxx_compiler=$cxx_compiler + COPY --pass-args +build/root /opt/mongo-c-driver + LET source=/opt/mongo-cxx-driver/src + LET build=/opt/mongo-cxx-driver/bld + GIT CLONE --branch=$test_mongocxx_ref https://github.com/mongodb/mongo-cxx-driver.git $source + RUN echo $cxx_version_current > $source/build/VERSION_CURRENT + RUN cmake -S $source -B $build -G Ninja -D CMAKE_PREFIX_PATH=/opt/mongo-c-driver -D CMAKE_CXX_STANDARD=17 + ENV CCACHE_HOME=/root/.cache/ccache + ENV CCACHE_BASE=$source + RUN --mount=type=cache,target=$CCACHE_HOME cmake --build $build + +# PREP_CMAKE "warms up" the CMake installation cache for the current environment +PREP_CMAKE: + FUNCTION + LET scratch=/opt/mongoc-cmake + # Copy the minimal amount that we need, as to avoid cache invalidation + COPY tools/use.sh tools/platform.sh tools/paths.sh tools/base.sh tools/download.sh \ + $scratch/tools/ + COPY .evergreen/scripts/find-cmake-version.sh \ + .evergreen/scripts/use-tools.sh \ + .evergreen/scripts/find-cmake-latest.sh \ + .evergreen/scripts/cmake.sh \ + $scratch/.evergreen/scripts/ + # "Install" a shim that runs our managed CMake executable: + RUN __alias cmake /opt/mongoc-cmake/.evergreen/scripts/cmake.sh + # Executing any CMake command will warm the cache: + RUN cmake --version + +env-warmup: + ARG --required env + BUILD --pass-args +env.$env --purpose=build + BUILD --pass-args +env.$env --purpose=test + +# Simultaneously builds and tests multiple different platforms +multibuild: + BUILD +run --targets "test-example" \ + --env=alpine3.16 --env=alpine3.17 --env=alpine3.18 --env=alpine3.19 \ + --env=u16 --env=u18 --env=u20 --env=u22 --env=centos7 \ + --env=archlinux \ + --tls=OpenSSL --tls=off \ + --sasl=Cyrus --sasl=off \ + --c_compiler=gcc --c_compiler=clang \ + --test_mongocxx_ref=master + +# release-archive : +# Create a release archive of the source tree. (Refer to dev docs) +release-archive: + FROM $default_search_registry/library/alpine:3.20 + RUN apk add git bash + ARG --required prefix + ARG --required ref + + WORKDIR /s + COPY --dir .git . + + # Get the commit hash that we are archiving. Use ^{commit} to "dereference" tag objects + LET revision = $(git rev-parse "$ref^{commit}") + RUN git restore --quiet --source=$revision -- VERSION_CURRENT + LET version = $(cat VERSION_CURRENT) + + # Pick the waterfall project based on the tag + COPY tools+tools-dir/__str /usr/local/bin/__str + IF __str test "$version" -matches ".*\.0\$" + # This is a minor release. Link to the build on the main project. + LET base = "mongo_c_driver" + ELSE + # This is (probably) a patch release. Link to the build on the release branch. + LET base = "mongo_c_driver_latest_release" + END + + # The augmented SBOM must be manually obtained from a recent execution of + # the `sbom` task in an Evergreen patch or commit build in advance. + COPY etc/augmented-sbom.json cyclonedx.sbom.json + + # The full link to the build for this commit + LET waterfall_url = "https://spruce.mongodb.com/version/${base}_${revision}" + # Insert the URL into the SSDLC report + COPY etc/ssdlc.md ssdlc_compliance_report.md + RUN sed -i " + s|@waterfall_url@|$waterfall_url|g + s|@version@|$version|g + " ssdlc_compliance_report.md + # Generate the archive + RUN git archive -o release.tar.gz \ + --prefix="$prefix/" \ # Set the archive path prefix + "$revision" \ # Add the source tree + --add-file cyclonedx.sbom.json \ # Add the SBOM + --add-file ssdlc_compliance_report.md + SAVE ARTIFACT release.tar.gz + +# Obtain the signing public key. Exported as an artifact /c-driver.pub +signing-pubkey: + FROM $default_search_registry/library/alpine:3.20 + RUN apk add curl + RUN curl --location --silent --fail "https://pgp.mongodb.com/c-driver.pub" -o /c-driver.pub + SAVE ARTIFACT /c-driver.pub + +# sign-file : +# Sign an arbitrary file. This uses internal MongoDB tools and requires authentication +# to be used to access them. (Refer to dev docs) +sign-file: + # Pull from Garasign: + FROM 901841024863.dkr.ecr.us-east-1.amazonaws.com/release-infrastructure/garasign-gpg + # Copy the file to be signed + ARG --required file + COPY $file /s/file + # Run the GPG signing command. Requires secrets! + RUN --secret GRS_CONFIG_USER1_USERNAME --secret GRS_CONFIG_USER1_PASSWORD \ + gpgloader && \ + gpg --yes --verbose --armor --detach-sign --output=/s/signature.asc /s/file + # Export the detatched signature + SAVE ARTIFACT /s/signature.asc / + # Verify the file signature against the public key + COPY +signing-pubkey/c-driver.pub /s/ + RUN touch /keyring && \ + gpg --no-default-keyring --keyring /keyring --import /s/c-driver.pub && \ + gpgv --keyring=/keyring /s/signature.asc /s/file + +# signed-release : +# Generate a signed release artifact. Refer to the "Earthly" page of our dev docs for more information. +# (Refer to dev docs) +signed-release: + FROM $default_search_registry/library/alpine:3.20 + RUN apk add git + # The version of the release. This affects the filepaths of the output and is the default for --ref + ARG --required version + # The Git revision of the repository to be archived. By default, archives the tag of the given version + ARG ref=refs/tags/$version + # File stem and archive prefix: + LET stem="mongo-c-driver-$version" + WORKDIR /s + # Run the commands "locally" so that the files can be transferred between the + # targets via the host filesystem. + LOCALLY + # Clean out a scratch space for us to work with + LET rel_dir = ".scratch/release" + RUN rm -rf -- "$rel_dir" + # Primary artifact files + LET rel_tgz = "$rel_dir/$stem.tar.gz" + LET rel_asc = "$rel_dir/$stem.tar.gz.asc" + # Make the release archive: + COPY (+release-archive/ --prefix=$stem --ref=$ref) $rel_dir/ + RUN mv $rel_dir/release.tar.gz $rel_tgz + # Sign the release archive: + COPY (+sign-file/signature.asc --file $rel_tgz) $rel_asc + # Save them as an artifact. + SAVE ARTIFACT $rel_dir /dist + # Remove our scratch space from the host. Getting at the artifacts requires `earthly --artifact` + RUN rm -rf -- "$rel_dir" + +# This target is simply an environment in which the SilkBomb executable is available. +silkbomb: + FROM 901841024863.dkr.ecr.us-east-1.amazonaws.com/release-infrastructure/silkbomb:2.0 + # Alias the silkbomb executable to a simpler name: + RUN ln -s /python/src/sbom/silkbomb/bin /usr/local/bin/silkbomb + +# sbom-generate : +# Generate/update the etc/cyclonedx.sbom.json file from the etc/purls.txt file. +# +# This target will update the existing etc/cyclonedx.sbom.json file in-place based +# on the content of etc/purls.txt and etc/cyclonedx.sbom.json. +sbom-generate: + FROM +silkbomb + # Copy in the relevant files: + WORKDIR /s + COPY etc/purls.txt etc/cyclonedx.sbom.json /s/ + # Update the SBOM file: + RUN silkbomb update \ + --refresh \ + --no-update-sbom-version \ + --purls purls.txt \ + --sbom-in cyclonedx.sbom.json \ + --sbom-out cyclonedx.sbom.json + # Save the result back to the host: + SAVE ARTIFACT /s/cyclonedx.sbom.json AS LOCAL etc/cyclonedx.sbom.json + +# sbom-generate-new-serial-number: +# Equivalent to +sbom-generate but includes the --generate-new-serial-number +# flag to generate a new unique serial number and reset the SBOM version to 1. +# +# This target will update the existing etc/cyclonedx.sbom.json file in-place based +# on the content of etc/purls.txt and etc/cyclonedx.sbom.json. +sbom-generate-new-serial-number: + FROM +silkbomb + # Copy in the relevant files: + WORKDIR /s + COPY etc/purls.txt etc/cyclonedx.sbom.json /s/ + # Update the SBOM file: + RUN silkbomb update \ + --refresh \ + --generate-new-serial-number \ + --purls purls.txt \ + --sbom-in cyclonedx.sbom.json \ + --sbom-out cyclonedx.sbom.json + # Save the result back to the host: + SAVE ARTIFACT /s/cyclonedx.sbom.json AS LOCAL etc/cyclonedx.sbom.json + +# sbom-validate: +# Validate the SBOM Lite for the given branch. +sbom-validate: + FROM +silkbomb + # Copy in the relevant files: + WORKDIR /s + COPY etc/purls.txt etc/cyclonedx.sbom.json /s/ + # Run the SilkBomb tool to download the artifact that matches the requested branch + RUN silkbomb validate \ + --purls purls.txt \ + --sbom-in cyclonedx.sbom.json \ + --exclude jira + +snyk: + FROM --platform=linux/amd64 $default_search_registry/library/ubuntu:24.04 + RUN apt-get update && apt-get -y install curl + RUN curl --location https://github.com/snyk/cli/releases/download/v1.1291.1/snyk-linux -o /usr/local/bin/snyk + RUN chmod a+x /usr/local/bin/snyk + +snyk-test: + FROM +snyk + WORKDIR /s + # Take the scan from within the `src/` directory. This seems to help Snyk + # actually find the external dependencies that live there. + COPY --dir src . + WORKDIR src/ + # Snaptshot the repository and run the scan + RUN --no-cache --secret SNYK_TOKEN \ + snyk test --unmanaged --json > snyk.json + SAVE ARTIFACT snyk.json + +# snyk-monitor-snapshot : +# Post a crafted snapshot of the repository to Snyk for monitoring. Refer to "Snyk Scanning" +# in the dev docs for more details. +snyk-monitor-snapshot: + FROM +snyk + WORKDIR /s + ARG remote="https://github.com/mongodb/mongo-c-driver.git" + ARG --required branch + ARG --required name + IF test "$remote" = "local" + COPY --dir src . + ELSE + GIT CLONE --branch $branch $remote clone + RUN mv clone/src . + END + # Take the scan from within the `src/` directory. This seems to help Snyk + # actually find the external dependencies that live there. + WORKDIR src/ + # Snaptshot the repository and run the scan + RUN --no-cache --secret SNYK_TOKEN --secret SNYK_ORGANIZATION \ + snyk monitor \ + --org=$SNYK_ORGANIZATION \ + --target-reference=$name \ + --unmanaged \ + --print-deps \ + --project-name=mongo-c-driver \ + --remote-repo-url=https://github.com/mongodb/mongo-c-driver + +# test-vcpkg-classic : +# Builds src/libmongoc/examples/cmake/vcpkg by using vcpkg to download and +# install a mongo-c-driver build in "classic mode". *Does not* use the local +# mongo-c-driver repository. +test-vcpkg-classic: + FROM +vcpkg-base + RUN vcpkg install mongo-c-driver + RUN rm -rf _build && \ + make test-classic + +# test-vcpkg-manifest-mode : +# Builds src/libmongoc/examples/cmake/vcpkg by using vcpkg to download and +# install a mongo-c-driver package based on the content of a vcpkg.json manifest +# that is injected into the project. +test-vcpkg-manifest-mode: + FROM +vcpkg-base + RUN apk add jq + RUN jq -n ' { \ + name: "test-app", \ + version: "1.2.3", \ + dependencies: ["mongo-c-driver"], \ + }' > vcpkg.json && \ + cat vcpkg.json + RUN rm -rf _build && \ + make test-manifest-mode + +vcpkg-base: + FROM $default_search_registry/library/alpine:3.18 + RUN apk add cmake curl gcc g++ musl-dev ninja-is-really-ninja zip unzip tar \ + build-base git pkgconf perl bash linux-headers + ENV VCPKG_ROOT=/opt/vcpkg-git + ENV VCPKG_FORCE_SYSTEM_BINARIES=1 + GIT CLONE --branch=2023.06.20 https://github.com/microsoft/vcpkg $VCPKG_ROOT + RUN $VCPKG_ROOT/bootstrap-vcpkg.sh -disableMetrics && \ + install -spD -m 755 $VCPKG_ROOT/vcpkg /usr/local/bin/ + LET src_dir=/opt/mongoc-vcpkg-example + COPY src/libmongoc/examples/cmake/vcpkg/ $src_dir + WORKDIR $src_dir + +# verify-headers : +# Execute CMake header verification on the sources +# +# See `earthly.rst` for more details. +verify-headers: + # We test against multiple different platforms, because glibc/musl versions may + # rearrange their header contents and requirements, so we want to check against as + # many as possible. + BUILD +do-verify-headers-impl \ + --from +env.alpine3.19 \ + --from +env.u22 \ + --from +env.centos7 \ + --sasl=off --tls=off --cxx_compiler=gcc --c_compiler=gcc + +do-verify-headers-impl: + ARG --required from + # We don't really care about the specifics of the build env/settings, so set some + # reasonable defaults so the caller doesn't need to specify. In the future, it is + # possible that we will need to test other environments and build settings. + FROM --pass-args "$from" --purpose=build + # Add C++ so we can test as C++ headers + DO --pass-args tools+ADD_CXX_COMPILER + DO +COPY_SOURCE --into=/s + DO --pass-args +CONFIGURE --source_dir /s --build_dir /s/_build + # The "all_verify_interface_header_sets" target is created automatically + # by CMake for the VERIFY_INTERFACE_HEADER_SETS target property. + RUN cmake --build /s/_build --target all_verify_interface_header_sets + +# run : +# Run one or more targets simultaneously. +# +# The “--targets†argument should be a single-string space-separated list of +# target names (not including a leading ‘+’) identifying targets to mark for +# execution. Targets will be executed concurrently. Other build arguments +# will be forwarded to the executed targets. +run: + LOCALLY + ARG --required targets + FOR __target IN $targets + BUILD +$__target + END + + +# d88888b d8b db db db d888888b d8888b. .d88b. d8b db .88b d88. d88888b d8b db d888888b .d8888. +# 88' 888o 88 88 88 `88' 88 `8D .8P Y8. 888o 88 88'YbdP`88 88' 888o 88 `~~88~~' 88' YP +# 88ooooo 88V8o 88 Y8 8P 88 88oobY' 88 88 88V8o 88 88 88 88 88ooooo 88V8o 88 88 `8bo. +# 88~~~~~ 88 V8o88 `8b d8' 88 88`8b 88 88 88 V8o88 88 88 88 88~~~~~ 88 V8o88 88 `Y8b. +# 88. 88 V888 `8bd8' .88. 88 `88. `8b d8' 88 V888 88 88 88 88. 88 V888 88 db 8D +# Y88888P VP V8P YP Y888888P 88 YD `Y88P' VP V8P YP YP YP Y88888P VP V8P YP `8888Y' + +env.u16: + DO --pass-args +UBUNTU_ENV --version=16.04 + +env.u18: + DO --pass-args +UBUNTU_ENV --version=18.04 + +env.u20: + DO --pass-args +UBUNTU_ENV --version=20.04 + +env.u22: + DO --pass-args +UBUNTU_ENV --version=22.04 + +env.alpine3.16: + DO --pass-args +ALPINE_ENV --version=3.16 + +env.alpine3.17: + DO --pass-args +ALPINE_ENV --version=3.17 + +env.alpine3.18: + DO --pass-args +ALPINE_ENV --version=3.18 + +env.alpine3.19: + DO --pass-args +ALPINE_ENV --version=3.19 + +env.archlinux: + FROM --pass-args tools+init-env --from $default_search_registry/library/archlinux + RUN pacman-key --init + ARG --required purpose + + RUN __install ninja snappy + + IF test "$purpose" = build + RUN __install ccache + END + + # We don't install SASL here, because it's pre-installed on Arch + DO --pass-args tools+ADD_TLS + DO --pass-args tools+ADD_C_COMPILER + DO +PREP_CMAKE + +env.centos7: + DO --pass-args +CENTOS_ENV --version=7 + +ALPINE_ENV: + FUNCTION + ARG --required version + FROM --pass-args tools+init-env --from $default_search_registry/library/alpine:$version + # XXX: On Alpine, we just use the system's CMake. At time of writing, it is + # very up-to-date and much faster than building our own from source (since + # Kitware does not (yet) provide libmuslc builds of CMake) + RUN __install bash curl cmake ninja musl-dev make + ARG --required purpose + + IF test "$purpose" = "build" + RUN __install snappy-dev ccache + ELSE IF test "$purpose" = "test" + RUN __install snappy + END + + DO --pass-args tools+ADD_SASL + DO --pass-args tools+ADD_TLS + # Add "gcc" when installing Clang, since it pulls in a lot of runtime libraries and + # utils that are needed for linking with Clang + DO --pass-args tools+ADD_C_COMPILER --clang_pkg="gcc clang compiler-rt" + +UBUNTU_ENV: + FUNCTION + ARG --required version + FROM --pass-args tools+init-env --from $default_search_registry/library/ubuntu:$version + RUN __install curl build-essential + ARG --required purpose + + IF test "$purpose" = build + RUN __install ninja-build gcc ccache libsnappy-dev zlib1g-dev + ELSE IF test "$purpose" = test + RUN __install libsnappy1v5 ninja-build + END + + DO --pass-args tools+ADD_SASL + DO --pass-args tools+ADD_TLS + DO --pass-args tools+ADD_C_COMPILER + DO +PREP_CMAKE + +CENTOS_ENV: + FUNCTION + ARG --required version + FROM --pass-args tools+init-env --from $default_search_registry/library/centos:$version + # Update repositories to use vault.centos.org + RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \ + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* + RUN yum -y --enablerepo=extras install epel-release && yum -y update + RUN yum -y install curl gcc gcc-c++ make + ARG --required purpose + + IF test "$purpose" = build + RUN yum -y install ninja-build ccache snappy-devel zlib-devel + ELSE IF test "$purpose" = test + RUN yum -y install ninja-build snappy + END + + DO --pass-args tools+ADD_SASL --cyrus_dev_pkg="cyrus-sasl-devel" --cyrus_rt_pkg="cyrus-sasl-lib" + DO --pass-args tools+ADD_TLS --openssl_dev_pkg="openssl-devel" --openssl_rt_pkg="openssl-libs" + DO --pass-args tools+ADD_C_COMPILER + DO +PREP_CMAKE diff --git a/3rdparty/mongo-c-driver-2.1.0/NEWS b/3rdparty/mongo-c-driver-2.1.0/NEWS new file mode 100644 index 000000000..df3fd6403 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/NEWS @@ -0,0 +1,4167 @@ +libmongoc 2.1.0 +=============== + +## Fixes + +* The uninstall script for Windows is fixed so it no longer "succeeds" with a non-zero `%ERRORLABEL%` value. +* The uninstall script for non-Windows environments now calls `find "$dir" -maxdepth 1` instead of `ls --almost-all "$dir"` when detecting non-empty directories to fix macOS compatibility. + +## Notes + +* The minimum supported MongoDB Server version is raised from 4.0 to 4.2. This is in accordance with [MongoDB Software Lifecycle Schedules](https://www.mongodb.com/legal/support-policy/lifecycles). + +## Changes + +* The CMake project now sets a CMake policy max version of `4.0` (previously unset). + +## Removed + +* Support for Debian 9 and Debian 10. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Ezra Chung + * Colby Pike + * Adrian Dole + * Azat Khuzhin + * Jeroen Ooms + * Roberto C. Sánchez + * Micah Scott + + +libmongoc 2.0.2 +=============== + +Fixes: + + * Fix message of `bson_strerror_r` on Windows. + * Fix memory leaks with Windows Secure Channel. + * Fix loading PKCS#8 RSA keys with Windows Secure Channel. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Colby Pike + + +libmongoc 1.30.5 +================ + +Fixes: + + * Fix message of `bson_strerror_r` on Windows. + * Fix memory leaks with Windows Secure Channel. + * Fix loading PKCS#8 RSA keys with Windows Secure Channel. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Colby Pike + + +libmongoc 2.0.1 +=============== + +Fixes: + + * Fix username handling for MONGODB-X509 authentication when C driver is configured to use Secure Transport (CMake option `ENABLE_SSL=DARWIN`) or Secure Channel (CMake option `ENABLE_SSL=WINDOWS`). + * Do not set empty partial result on client error for `mongoc_bulkwrite_execute`. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + + +libmongoc 1.30.4 +================ + +Fixes: + + * Fix username handling for MONGODB-X509 authentication when C driver is configured to use Secure Transport (CMake option `ENABLE_SSL=DARWIN`) or Secure Channel (CMake option `ENABLE_SSL=WINDOWS`). + * Do not set empty partial result on client error for `mongoc_bulkwrite_execute`. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + + +libmongoc 1.30.3 +================ + +New Features: + +* In anticipation of the 2.0 release of mongo-c-driver, new CMake packages and + imported targets have been defined (for both `bson` and `mongoc`). To import + `mongoc` with the new names, call `find_package` for the `mongoc` package. The + new imported targets are named `mongoc::static`, `mongoc::shared`, and + `mongoc::mongoc` (which points to either the static or the shared library, + depending on an import-time configuration option). + + The new package and target names will remain unchanged when upgrading to the + 2.0 release, allowing consumers to support both major versions without + modifying their CMake project. The current imported target names will be + removed from the 2.0 release, and should not be used for + forward-compatibility. + + Programs that link to BSON libraries directly should also use the new target + names `bson::static`, `bson::shared`, or `bson::bson`. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Ezra Chung + * Colby Pike + +libmongoc 2.0.0 +=============== + +## Notes + +* In a future minor release the minimum supported MongoDB Server version will be raised from 4.0 to 4.2. This is in accordance with [MongoDB Software Lifecycle Schedules](https://www.mongodb.com/legal/support-policy/lifecycles). +* Raise required version of libmongocrypt to 1.13.0 to support In-Use Encryption (corresponds to the CMake option: `ENABLE_CLIENT_SIDE_ENCRYPTION`). + +## Changes + +* Passing `batchSize:0` as an option to `mongoc_client_watch`, `mongoc_database_watch`, or `mongoc_collection_watch` + now applies `batchSize:0` to the `aggregate` command. Useful to request an immediate cursor. Previously the value + was ignored. +* `bson_oid_init_sequence` is removed. Use `bson_oid_init` instead. +* `mongoc_server_description_host` changes the return type from `mongoc_host_list_t *` to `const mongoc_host_list_t *`. +* URI authentication credentials validation (only applicable during creation of a new `mongoc_uri_t` object from a connection string): + * The requirement that a username is non-empty when specified is now enforced regardless of authentication mechanism. + * Username and password specification requirements are now validated and returns a client error for the specified authentication mechanism. + * e.g. it is a client error to not specify a username or a password for SCRAM-SHA-1, SCRAM-SHA-256, and PLAIN. + * e.g. it is a client error to specify a password for MONGODB-X509. + * e.g. it is a client error to specify a username or a password without the other for MONGODB-AWS. + * `authSource` is now correctly defaulted to `"$external"` for MONGODB-AWS (instead of the database name or `"admin"`). + * `authMechanism` is now validated and returns a client error for invalid or unsupported values. + * `authMechanismProperties` is now validated and returns a client error for invalid or unsupported properties for the specified authentication mechanism. + * `authMechanismProperties` now correctly supports `':'` within property values. + * Old behavior: `authMechanismProperties=A:B,C:D:E,F:G` is parsed as `{'A': 'B', 'C': 'D:E,F:G'}`. + * New behavior: `authMechanismProperties=A:B,C:D:E,F:G` is parsed as `{'A': 'B': 'C': 'D:E', 'F': 'G'}`. +* Calling `mongoc_bulk_operation_execute` on the same `mongoc_bulk_operation_t` repeatedly is an error. Previously this was only discouraged in documentation. +* Consistently apply `__cdecl` calling convention to function declarations in public API. Intended to support consumers building their code using a different [default calling convention](https://learn.microsoft.com/en-us/cpp/build/reference/gd-gr-gv-gz-calling-convention) with MSVC. The mongoc and bson libraries only support being built with the `__cdecl` default calling convention. +* `mongoc_client_set_ssl_opts` now ignores a pooled `mongoc_client_t` and logs an error. Use `mongoc_client_pool_set_ssl_opts` to set TLS options on a `mongoc_client_pool_t` before popping any clients. +* `mongoc_client_set_ssl_stream_initiator` now ignores a pooled `mongoc_client_t` and logs an error. +* The pkg-config files `libmongoc-1.0`, `libmongoc-static-1.0`, `libbson-1.0`, + and `libbson-static-1.0` have been renamed to `mongoc2`, `mongoc2-static`, + `bson2`, and `bson2-static`, respectively. + +### CMake Packages and Imported Targets + +The `mongoc-1.0` (and `bson-1.0`) CMake packages have been removed. Instead, use +`mongoc` or `bson`, and specify a version or version range to be imported: + +```cmake +find_package(mongoc 1.30...2.0) +``` + +The new packages import different target names: + +- `mongo::mongoc_static` → `mongoc::static` +- `mongo::mongoc_shared` → `mongoc::shared` +- The target `mongoc::mongoc` is a shim target that points to either the shared + library or the static library. + +The BSON library has had similar name changes. + +## Removals + +* The `bson_md5_t` struct and associated API is removed. +* The client side matching feature, `mongoc_matcher_t` and related functions are removed. +* `mongoc_server_description_ismaster` is removed. Use the equivalent `mongoc_server_description_hello` instead. +* `MONGOC_QUERY_SLAVE_OK` is removed. Use the equivalent `MONGOC_QUERY_SECONDARY_OK` instead. +* `MONGOC_URI_SLAVEOK` is removed. It was unused. +* `mongoc_client_command`, `mongoc_database_command`, and `mongoc_collection_command` are removed. Use `mongoc_client_command_simple`, `mongoc_database_command_simple`, and `mongoc_collection_command_simple` instead. +* `MONGOC_URI_MAXIDLETIMEMS` and `MONGOC_URI_WAITQUEUEMULTIPLE` are removed. They were unused. +* `bson_string_t` and associated functions are removed. +* Support for `ENABLE_SASL=CYRUS` on Windows is removed. Use `ENABLE_SASL=SSPI` or `ENABLE_SASL=OFF` instead. + * The associated Windows-only option `CYRUS_PLUGIN_PATH_PREFIX` is removed. +* Support for the deprecated `minPoolSize` URI option is removed along with associated API: `MONGOC_URI_MINPOOLSIZE` and `mongoc_client_pool_min_size`. +* Support for LibreSSL (the CMake option `ENABLE_SSL=LIBRESSL`) is removed. Associated API is removed (`MONGOC_ENABLE_SSL_LIBRESSL` and `mongoc_stream_tls_libressl_new`). +* `MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED` (value -1) is removed. Use `MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED` (value 0) which is handled equivalently. If specified in a URI, replace: `mongodb://host/?w=-1` with `mongodb://host/?w=0`. +* The deprecated CMake option `ENABLE_AUTOMATIC_INIT_AND_CLEANUP` is removed. See [Initialization and cleanup](https://mongoc.org/libmongoc/1.30.2/init-cleanup.html) for expected use of `mongoc_init()` and `mongoc_cleanup()`. +* `mongoc_client_get_database_names` is removed. Use `mongoc_client_get_database_names_with_opts` instead. +* `mongoc_client_find_databases` is removed. Use `mongoc_client_find_databases_with_opts` instead. +* `mongoc_client_get_max_message_size` is removed. +* `mongoc_client_get_max_bson_size` is removed. +* Deprecated `mongoc_apm_command_*_get_server_connection_id` functions are removed. Use `mongoc_apm_command_*_get_server_connection_id_int64` instead. +* Deprecated index management API is removed: + * `mongoc_collection_create_index_with_opts`, `mongoc_collection_create_index`, and `mongoc_collection_ensure_index` are removed. Use `mongoc_collection_create_indexes_with_opts` instead. + * `mongoc_index_opt_t`, `mongoc_index_opt_geo_t` `mongoc_index_opt_wt_t` are removed. Pass options using `bson_t` to `mongoc_collection_create_indexes_with_opts` instead. + * `mongoc_collection_find_indexes` is removed. Use `mongoc_collection_find_indexes_with_opts` instead. + * See [MongoDB documentation](https://www.mongodb.com/docs/languages/c/c-driver/current/indexes/) for working with indexes. +* Deprecated cursor API is removed: + * `mongoc_cursor_is_alive` is removed. Use the equivalent `mongoc_cursor_more` instead. + * `mongoc_cursor_set_hint` is removed. Use the equivalent `mongoc_cursor_set_server_id` instead. + * `mongoc_cursor_get_hint` is removed. Use the equivalent `mongoc_cursor_get_server_id` instead. + * `mongoc_cursor_new_from_command_reply` is removed. Use `mongoc_cursor_new_from_command_reply_with_opts` instead. +* Deprecated CRUD API is removed: + * `mongoc_collection_save` is removed. Use `mongoc_collection_insert_one` or `mongoc_collection_replace_one` instead. + * `mongoc_collection_delete` is removed. Use `mongoc_collection_delete_one` or `mongoc_collection_delete_many` instead. + * `mongoc_delete_flags_t` and `mongoc_reply_flags_t` are removed. + * `mongoc_collection_find` is removed. Use `mongoc_collection_find_with_opts` instead. + * `mongoc_collection_insert_bulk` is removed. Use `mongoc_collection_insert_many` instead. + * `mongoc_collection_create_bulk_operation` is removed. Use `mongoc_collection_create_bulk_operation_with_opts` instead. + * `mongoc_collection_get_last_error` is removed. To get results from write operations, instead use: + * `mongoc_collection_update_one` + * `mongoc_collection_update_many` + * `mongoc_collection_replace_one` + * `mongoc_collection_delete_one` + * `mongoc_collection_delete_many` + * `mongoc_collection_insert_one` + * `mongoc_collection_insert_many` + * `mongoc_bulkwrite_t` + * `mongoc_bulk_operation_t` + * `mongoc_bulk_operation_delete` is removed. Use `mongoc_bulk_operation_remove()` instead. + * `mongoc_bulk_operation_delete_one` is removed. Use `mongoc_bulk_operation_remove_one` instead. + * `mongoc_bulk_operation_get_hint` is removed. Use `mongoc_bulk_operation_get_server_id` instead. + * `mongoc_bulk_operation_set_hint` is removed. Use `mongoc_bulk_operation_set_server_id` instead. + * `mongoc_collection_count` and `mongoc_collection_count_with_opts` are removed. Use `mongoc_collection_count_documents` or `mongoc_collection_estimated_document_count` instead. +* `mongoc_collection_stats` is removed. Use the [$collStats aggregation pipeline stage](https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/) with `mongoc_collection_aggregate` instead. +* `mongoc_collection_validate` is removed. Run the [validate](https://www.mongodb.com/docs/manual/reference/command/validate/) command directly with `mongoc_client_read_command_with_opts` instead. +* Deprecated API for `mongoc_database_t` is removed: + * `mongoc_database_find_collections` is removed. Use `mongoc_database_find_collections_with_opts` instead. + * `mongoc_database_get_collection_names` is removed. Use `mongoc_database_get_collection_names_with_opts` instead. +* Deprecated GridFS API has been removed: + * `mongoc_gridfs_find` is removed. Use `mongoc_gridfs_find_with_opts` instead. + * `mongoc_gridfs_find_one` is removed. Use `mongoc_gridfs_find_one_with_opts` instead. +* Deprecated TLS stream API is removed: + * `mongoc_stream_tls_do_handshake` is removed. Use `mongoc_stream_tls_handshake` instead. + * `mongoc_stream_tls_check_cert` is removed. Use `mongoc_stream_tls_handshake` instead. + * `mongoc_stream_tls_new` is removed. Use `mongoc_stream_tls_new_with_hostname` instead. +* Deprecated URI API has been removed: + * `mongoc_uri_get_service` is removed. Use `mongoc_uri_get_srv_hostname` instead. + * `mongoc_uri_get_read_prefs` is removed. Use `mongoc_uri_get_read_prefs_t` instead. + * `mongoc_uri_get_ssl` is removed. Use `mongoc_uri_get_tls` instead. +* Deprecated write concern API is removed: + * `mongoc_write_concern_get_fsync` is removed. Use `mongoc_write_concern_get_journal` instead. + * `mongoc_write_concern_set_fsync` is removed. Use `mongoc_write_concern_set_journal` instead. +* The `libmongoc-ssl-1.0` pkg-config file has been removed. + +### Forwarding headers (`#include ` and `#include `) + +The compatibility "forwarding" headers have been removed (previously added in 1.13.0). This means it is no longer valid to include the literal header names `mongoc.h` or `bson.h` directly: + +```c +#include // No longer provided! +#include // No longer provided! +``` + +Instead, the names must be prefixed with the parent directory: `mongoc/mongoc.h` and `bson/bson.h`: + +```c +#include +#include +``` + +### `mongoc_client_kill_cursor` + +`mongoc_client_kill_cursor` is removed. It did not accept a server identifier. It was only reliable when connected to a single server. + +Sending [killCursors](https://www.mongodb.com/docs/manual/reference/command/killCursors/) is not typically needed. `mongoc_cursor_t` manages the cursor lifetime. If needed, use a generic command helper to manually send a `killCursors` command: + +```c +bson_t *cmd = BCON_NEW ("killCursors", "coll", "cursors", "[", BCON_INT64 (cursor_id), "]"); +bool ok = mongoc_client_command_simple_with_server_id (client, "db", cmd, NULL, server_id, NULL, &error); +if (!ok) { + printf ("Failed to send 'killCursors': %s\n", error.message); +} +bson_destroy (cmd); +``` + +### `mongoc_client_get_server_status` + +`mongoc_client_get_server_status` is removed. Use a command helper to run the "serverStatus" command instead: + +```c +bson_t *cmd = BCON_NEW("serverStatus", BCON_INT32(1)); +if (!mongoc_client_command_simple(client, "db", cmd, NULL, &reply, &error)) { + printf("Failed to send 'serverStatus': %s\n", error.message); +} else { + // TODO: use `reply` +} +bson_destroy(&reply); +bson_destroy(cmd); +``` + +## Contributors + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Ezra Chung + * Colby Pike + * Micah Scott + * Jeroen Ooms + + +libmongoc 1.30.2 +================ + +Fixes: + + * Fix C23 build on Windows. + +Thanks to everyone who contributed to the development of this release. + + * Jeroen Ooms + +libmongoc 1.30.1 +================ + +No changes since 1.30.0. Version incremented to match the libbson version. + +libmongoc 1.30.0 +================ + +Fixes: + + * Additional APM events required by the SDAM specification will now be delivered: + * Servers that have seen `server_opening` will now see a `server_closed` prior to `topology_closed`. + * Before `topology_closed`, a `topology_changed` event will transition to `Unknown` topology type. + * Fix reporting insert IDs in `mongoc_bulkwrite_t` when verbose results requested. + +Improvements: + + * Improve performance of `mongoc_server_description_new_copy`. + +New Features: + + * Add support for structured logging. + * See `mongoc_client_set_structured_log_opts` and `mongoc_client_pool_set_structured_log_opts`. + * Add option to configure cache lifetime of In-Use Encryption data encryption keys. + * See `mongoc_auto_encryption_opts_set_key_expiration` and `mongoc_client_encryption_opts_set_key_expiration`. + * Support `sort` option for update and replace operations. + * Support constructing a `mongoc_bulkwrite_t` without a client. + * See `mongoc_bulkwrite_new` and `mongoc_bulkwrite_set_client`. + +Deprecated: + + * Support for Debian 9 and Debian 10. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Micah Scott + * Jeremy Mikola + * Adrian Dole + * Ezra Chung + * Antony Polukhin + * Jeroen Ooms + +libmongoc 1.29.2 +================ + +Fixes: + * Rename `set_error` function to avoid symbol conflicts. + * Fix Windows ARM 64 build. + * Fix comparison of uninitialized bytes. + * Fix format specifier on macOS. + +Notes: + * Windows ARM 64 is not-yet officially tested or supported. Support is community driven. + +Thanks to everyone who contributed to the development of this release. + + * Adrian Dole + * Christian Schmitz + * Antony Polukhin + * Kevin Albertson + + + +libmongoc 1.29.1 +================ + +Fixes: + + * Assert session is consistent with client in `mongoc_bulkwrite_set_session`. + +Thanks to everyone who contributed to the development of this release. + + * Jeremy Mikola + * Kevin Albertson + + + +libmongoc 1.29.0 +================ + +Improvements: + + * Retry KMS requests on transient errors. + +Platform Support: + + * Support for Visual Studio 2013 is dropped. + +Deprecated: + + * `mongoc_client_command` is deprecated and planned for removal in a future release. Use `mongoc_client_command_simple` instead. + * `mongoc_database_command` is deprecated and planned for removal in a future release. Use `mongoc_database_command_simple` instead. + * `mongoc_collection_command` is deprecated and planned for removal in a future release. Use `mongoc_collection_command_simple` instead. + +Notes: + + * Raise required version of libmongocrypt to 1.12.0 to support In-Use Encryption (corresponds to the CMake option: `ENABLE_CLIENT_SIDE_ENCRYPTION`). + * A future minor release will raise the minimum supported MongoDB Server version from 4.0 to 4.2. This is in accordance with [MongoDB Software Lifecycle Schedules](https://www.mongodb.com/legal/support-policy/lifecycles). **Support for MongoDB Server 4.0 will be dropped in a future release!** + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Ezra Chung + * Micah Scott + * Adrian Dole + * Andreas Braun + * Joshua Siegel + + +libmongoc 1.28.1 +================ + +Fixes: + + * Do not return result in `mongoc_bulkwritereturn_t` if there are no known successful writes. + * Validate lengths in ill-formed server responses. + * Do not override read preference when using aggregate with `$out/$merge` with unscanned servers. + * Remove unexpected warning if `authSource` in TXT record is overriden by URI option. + * Fix crash when non-existent CA file configured with OpenSSL. + +libmongoc 1.28.0 +================ + +New features: + + * Support In-Use Encryption range queries. + * Include insert ID on result of `mongoc_collection_insert_one`. + * Add new bulk write API `mongoc_bulkwrite_t`. Requires MongoDB 8.0. Reduces round-trips for mixed writes. + - Add `serverMonitoringMode` URI option. + +Improvements: + + * Improve performance of OpenSSL connection creation. + * Improve performance when trace logging is configured (`ENABLE_TRACING=ON`) but disabled at runtime. + * Prefer FIPS compliant functions for SCRAM-SHA-256 key derivation. + * Remove required slash to delimit options in MongoDB URI (e.g. `mongodb://example.com?w=1` parses the same as `mongodb://example.com/?w=1`). + * Include topology description in server selection timeout errors. + +Notes: + + * Bump minimum wire protocol version from 6 (MongoDB 3.6) to 7 (MongoDB 4.0). + * Raise required version of libmongocrypt to 1.11.0 to support In-Use Encryption (corresponds to the CMake option: `ENABLE_CLIENT_SIDE_ENCRYPTION`). + +Build Configuration: + + * Remove automatic ccache detection and usage (CCache.cmake). + * Set [`CMAKE__COMPILER_LAUNCHER`](https://cmake.org/cmake/help/latest/envvar/CMAKE_LANG_COMPILER_LAUNCHER.html) to build with ccache. + * Remove `MONGO_USE_CCACHE` (no longer applicable; see above). + +Changed: + + * Test and example targets are excluded from the `ALL` target. + * All test targets can be built using the `mongo_c_driver_tests` target. + * All example targets can be built using the `mongo_c_driver_examples` target. + * Use `#!/usr/bin/env bash` instead of `#!/bin/sh` in uninstall script generated by `ENABLE_UNINSTALL=ON`. + +Deprecated: + + * Use of `*_hint` functions is deprecated in favor of more aptly named `*_server_id` functions: + * `mongoc_bulk_operation_set_hint` is deprecated for `mongoc_bulk_operation_set_server_id` + * `mongoc_bulk_operation_get_hint` is deprecated for `mongoc_bulk_operation_get_server_id` + * `mongoc_cursor_set_hint` is deprecated for `mongoc_cursor_set_server_id` + * `mongoc_cursor_get_hint` is deprecated for `mongoc_cursor_get_server_id` + + * A future minor release plans to drop support for Visual Studio 2013. + * `ENABLE_SSL=LIBRESSL` is deprecated along with `mongoc_stream_tls_libressl_new`. Support for LibreSSL may be dropped in a future major release. + * `ENABLE_SASL=CYRUS` on Windows platforms is deprecated. Support for `ENABLE_SASL=CYRUS` on Windows may be dropped in a future major release. + * The associated Windows-only option `CYRUS_PLUGIN_PATH_PREFIX` is deprecated. + +libmongoc 1.27.6 +================ + +Fixes: + + * Fix TSan warning. + * Fix C23 compile. + +Improvements: + + * Document expected behavior of command errors in a transaction. + +Thanks to everyone who contributed to the development of this release. + + * Adrian Dole + * Ezra Chung + * Joshua Siegel + * Kevin Albertson + + + +libmongoc 1.27.5 +================ + +Fixes: + + * Fix possible build error in environments where `bool` or `_Bool` is a macro. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + + +libmongoc 1.27.4 +================ + +Fixes: + + * Fix possible crash reading malformed wire protocol message. + * Fix build with Visual Studio 2013. + +Thanks to everyone who contributed to the development of this release. + + * Ezra Chung + * Kevin Albertson + + + +libmongoc 1.27.3 +================ + +Notes: + + * This patch release introduces changes surrounding the development processes, + including new code signing and dependency tracking. There are no behavioral + or API changes. + +Fixes: + + * Upgraded bundled Zlib from 1.2.3 to 1.3.1 + +Thanks to everyone who contributed to the development of this release. + + * Colby Pike + + + +libmongoc 1.27.2 +================ + +Fixes: + + * Close leftover connections to removed servers. + +New features: + + * Check environment variable `MONGOC_EXPERIMENTAL_SRV_PREFER_TCP` to prefer TCP for SRV lookup. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + + + +libmongoc 1.27.1 +================ + +No changes since 1.27.0. Version incremented to match the libbson version. + +libmongoc 1.27.0 +================ + +Notes: + + * Raise required version of libmongocrypt to 1.10.0 to support In-Use Encryption (corresponds to the CMake option: `ENABLE_CLIENT_SIDE_ENCRYPTION`). + * A future minor release plans to raise the minimum supported MongoDB Server version from 3.6 to 4.0. This is in accordance with [MongoDB Software Lifecycle Schedules](https://www.mongodb.com/legal/support-policy/lifecycles). + +Fixes: + + * Fix possible crash when client is configured with empty password. + +New Features: + + * Add database name to command events: `mongoc_apm_command_failed_get_database_name` and `mongoc_apm_command_succeeded_get_database_name`. + * Support delegated KMIP protocol for In-Use Encryption. + * Enable setting socket timeout per client. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Adrian Dole + * Ezra Chung + * Roberto C. Sánchez + * Scott Hunt + +libmongoc 1.26.2 +================ + +Cyrus SASL: + + * Disable plugin loading with Cyrus SASL on Windows by default. To re-enable, set the CMake option `CYRUS_PLUGIN_PATH_PREFIX` to the absolute path prefix of the Cyrus SASL plugins. + +Fixes: + + * Fix possible hang if `mongoc_gridfs_file_readv` is called with a corrupt chunk with incomplete data. + * Fix assert with legacy exhaust cursor protocol when connected to server < 4.2. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + +libmongoc 1.26.1 +================ + +Fixes: + + * Fix 32-bit compile with 64-bit `time_t` + +Thanks to everyone who contributed to the development of this release. + + * Roberto C. Sánchez + + + +libmongoc 1.26.0 +================ + +New Features: + + * Support named KMS providers. + * Redirect retries in sharded clusters to another mongos if possible. + +Improvements: + + * Add `VERSION_CURRENT` file in source to ease building. + * Consider more errors retryable. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Jeremy Mikola + * Adrian Dole + * Kyle Kloberdanz + * Ezra Chung + * MongoCaleb + * Roberto C. Sánchez + * itrofimow + + + +libmongoc 1.25.4 +================ + +Fixes: + + * Restore support for Sphinx 1.7.6 for man page build. + +libmongoc 1.25.3 +================ + +Fixes: + + * Disable shared libmongoc targets if `ENABLE_SHARED=OFF` + * Fix documentation build with Python 3.9. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + +libmongoc 1.25.2 +================ + +Fixes: + + * Fix data race in `mongoc_cursor_get_host`. + * Accept discouraged timeout values for backwards compatibility. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Ezra Chung + * Kyle Kloberdanz + * Roberto C. Sánchez + +libmongoc 1.25.1 +================ + +Fixes: + + * Add back support for `BUILD_VERSION` CMake option. `BUILD_VERSION` was unintentionally removed in 1.25.0. + +libmongoc 1.25.0 +================ + +Fixes: + + * Send `recoveryToken` in transactions when connected to a load balancer. + +Improvements: + + * Remove optional dependency of libicu. + * Use OP_MSG exhaust for mongod >= 4.2. Enable exhaust cursors for mongos >= 7.1. + * Share cached credentials for SCRAM authentication among all clients to improve performance. + * Use polling monitoring in FaaS environments. + +Build Configuration: + + * Remove `ENABLE_SRV=AUTO`. Only support boolean values for `ENABLE_SRV`. + +Platform Support: + + * Support for macOS 10.14 is dropped. + * Support for Ubuntu 14.04 is dropped. + * Support for Debian 8.1 is dropped. + +Other: + + * The constructed source-distribution archive is no longer available as a + release artifact. Please instead use the per-release repository archive + attached to a GitHub release, or clone the repository at the desired release + tag. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Colby Pike + * Adrian Dole + * Roberto C. Sánchez + * Ezra Chung + * Joshua Siegel + * Kyle Kloberdanz + * Jeremy Mikola + +libmongoc 1.24.4 +================ + +Fixes: + * Fix build failure caused by missing `bson-dsl.h` install in libbson. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + +libmongoc 1.24.3 +================ + +Fixes: + + * Fix possible memory leak on SCRAM authentication failure. + * Fix possible recursive lock on network error in single-threaded client. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Jeremy Mikola + * Roberto C. Sánchez + +libmongoc 1.24.2 +================ + +Fixes: + + * Fix possible crash if thread creation fails. + * Fix possible assertion if `mongoc_cursor_new_from_command_reply_with_opts` is called with open cursor and no `serverId` option. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + +libmongoc 1.24.1 +================ + +Fixes: + + * Remove unnecessary assert in bulk API. May result in an abort when creating bulk operations with the `mongoc_bulk_operation_new` API intended for wrapping drivers. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + +libmongoc 1.24.0 +================ + +New Features: + + * Support MongoDB server version 7.0. + * Support updated Queryable Encryption protocol. + * Introduces backwards breaking changes to the Queryable Encryption protocol. Using Queryable Encryption now requires MongoDB server version 7.0+. + * Support new Queryable Encryption features. + * Add `mongoc_client_encryption_create_encrypted_collection` to automatically create data encryption keys when creating a new encrypted collection. + * Support new security features. + * Add ability to fetch KMS credentials automatically from Azure, GCP, and AWS environments. + * Support authentication with KMS AWS temporary credentials. + * Cache fetched AWS credentials. + * Support AWS IAM Roles for service accounts, EKS in particular. + * Retry operations if the connection handshake fails. + * Add index creation helper: `mongoc_collection_create_indexes_with_opts`. + +Fixes: + + * Fix default applied credentials for Kerberos with SSPI on Windows. + * Fix possible overcounting in Performance Counters used by `mongoc-stat`. + +Language Standard Support: + + * C89 support has been dropped. C99 is the default tested C standard. + +Platform Support: + + * Support for macOS 10.14 will be dropped in an upcoming release. + * Support for Ubuntu 14.04 will be dropped in an upcoming release. + * Support for Debian 8.1 will be dropped in an upcoming release. + +Build Configuration: + + * The `ENABLE_BSON` configure-time option has been removed. Build scripts that + used `ENABLE_BSON=SYSTEM` should be updated to use `USE_SYSTEM_LIBBSON=TRUE`. + If the build script needs to support building arbitrary versions of the C + driver, add both `ENABLE_BSON=SYSTEM` and `USE_SYSTEM_LIBBSON=TRUE`. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Ezra Chung + * Colby Pike + * Gil Alon + * Kyle Kloberdanz + * Jeremy Mikola + * Andreas Braun + * Kondaiah Valagonda + * Joshua Siegel + * Roberto C. Sánchez + * Romain Geissler @ Amadeus + * bisht2050 + * Adrian Dole + +libmongoc 1.23.5 +================ + +Fixes: + + * Fix potential crash due to insufficient memory when allocating performance counters. + * Fix compilation error on Android platforms due to missing `aligned_alloc`. + * Return an error if `RewrapManyDataKey` is invoked without a `provider` when a `masterKey` is given. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Romain Geissler @ Amadeus + + +libmongoc 1.23.4 +================ + +Fixes: + + * Fix possible failure to authenticate with MONGODB-X509 after network error. + +Thanks to everyone who contributed to the development of this release. + + * Andreas Braun + * Kevin Albertson + * Kyle Kloberdanz + + + +libmongoc 1.23.3 +================ + +Fixes: + + * Better handle malformed `hello` responses + * Handle `connectionId` of type `double`. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Gil Alon + * Kondaiah Valagonda + + + +libmongoc 1.23.2 +================ + +Bug fixes: + + * Fix compile on M1 macOS fails due to undeclared function (getpagesize) + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Kyle Kloberdanz + + +libmongoc 1.22.2 +================ + + * Fix connectivity to Atlas Data Lake + * Additional bugfixes from libbson 1.22.2 + +Thanks to everyone who contributed to the development of this release. + + * Andreas Braun + * Kevin Albertson + * Roberto C. Sánchez + + +libmongoc 1.23.1 +================ + +Bug fixes: + + * Fix connectivity to Atlas Data Lake + * Fix crash when dropping a malformed Queryable Encryption collection. + +Thanks to everyone who contributed to the development of this release. + + * Andreas Braun + * Kevin Albertson + + + +libmongoc 1.23.0 +================ + +Features: + + * Add on-demand Credentials Callback for CSFLE + * Support obtaining AWS credentials for CSFLE in the same way as for MONGODB-AWS + +Improvements: + + * Reducing Warnings of Misaligned Address of Over-Aligned Types + +Bug fixes: + + * Do not spawn mongocryptd if mongo_shared shared library is loaded. + +Thanks to everyone who contributed to the development of this release. + + * Ezra Chung + * Colby Pike + * Kevin Albertson + * Roberto C. Sánchez + + + +libmongoc 1.22.1 +================ + +Bug fixes: + + * Fix documentation build when using Sphinx 5.0 or newer + * Update patch release of libmongocrypt to 1.5.2: Fix a potential data + corruption bug in RewrapManyDataKey when rotating encrypted data encryption + keys backed by GCP or Azure key services. + + The following conditions will trigger this bug: + + A GCP-backed or Azure-backed data encryption key being rewrapped requires + fetching an access token for decryption of the data encryption key. + + The result of this bug is that the key material for all data encryption keys + being rewrapped is replaced by new randomly generated material, destroying + the original key material. + + To mitigate potential data corruption, upgrade to this version or higher + before using RewrapManyDataKey to rotate Azure-backed or GCP-backed data + encryption keys. A backup of the key vault collection should always be taken + before key rotation. + +Other: + + * Update to Fedora 37 for RPM builds + * Dependency build of libmongocrypt re-uses the libbson of the depending + libmongoc + +Thanks to everyone who contributed to the development of this release. + + * Ezra Chung + * Roberto C. Sánchez + * Kevin Albertson + + + +libmongoc 1.21.2 +================ + +Bug Fixes: + * Address vulnerability in bundled zlib by updating to 1.1.12. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Colby Pike + + + +libmongoc 1.22.0 +================ + +Bug fixes: + + * Do not auto decrypt before emitting CommandSucceeded events. + +Improvements: + + * Use OP_MSG if a server API version is requested. + +Features: + + * Add server connectionId to command monitoring events. + * Add support for the comment field to all helpers. + * Support mongo_shared shared library. + * Support pre-point-in-time change stream events. + * Support Queryable Encryption. + * Support 'let' option for multiple CRUD commands. + * Add Key Management API functions. + +Notes: + + * The 5.0-compat release (1.18.0) accidentally broke estimatedDocumentCount on views by changing its implementation to use aggregate and a $collStats stage instead of the count command. + * The new release is fixing estimatedDocumentCount on views by reverting back to using count in its implementation. + * Due to an oversight, the count command was omitted from the Stable API in server versions 5.0.0 - 5.0.8 and 5.1.0 - 5.3.1, so users of the Stable API with estimatedDocumentCount are recommended to upgrade their MongoDB clusters to 5.0.9 or 5.3.2 (if on Atlas) or set apiStrict: false when constructing their MongoClients. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Jeremy Mikola + * Colby Pike + * Ezra Chung + * Roberto C. Sánchez + * Jake Molnar + * Jesse Williamson + * Remi Collet + + + +libmongoc 1.21.1 +================ + +Bug Fixes: + * Use static decls for OpenSSL 1.1 polyfills + * Prevent possible crash in _mongoc_cursor_fetch_stream + +Thanks to everyone who contributed to the development of this release. + + * Jeremy Mikola + * Remi Collet + + + +libmongoc 1.21.0 +================ + +Bug Fixes: + * Addressed VS 2013 build failures due to missing C99 features. + +Features: + * Support conditional $merge and $out aggregation on secondaries. + * Bump minimum wire protocol version from 3 (MongoDB 3.0) to 6 (MongoDB 3.6). + * Bump maximum wire protocol version from 14 (MongoDB 5.1) to 15 (MongODB 5.2). + +Improvements: + * Update algorithm used for generation of OID values to reduce collisions. + +Thanks to everyone who contributed to the development of this release. + + * Ezra Chung + * Colby Pike + * Kevin Albertson + * Roberto C. Sánchez + * David CARLIER + * Jeremy Mikola + + + +libmongoc 1.20.1 +================ + +Bug fixes: + + * Fix bug where first hello command on a single-threaded client may not include full handshake. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + +libmongoc 1.20.0 +================ + +Features: + + * Improve multi-threaded performance of client pool. + * Support KMIP as a provider for Client-Side Field Level Encryption (CSFLE). + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Ezra Chung + * Colby Pike + * Jesse Williamson + * Jeremy Mikola + * Kaitlin Mahar + +mongo-c-driver 1.19.2 +===================== + +Announcing libmongoc 1.19.2. + +Bug fixes: + +* Fix assert on invalid URI options in client pools connected to load balanced clusters when a topology closed callback is registered. + +Thanks to everyone who contributed to the development of this release. + +--Kevin Albertson + +libmongoc 1.19.1 +================ + +It is my pleasure to announce libmongoc 1.19.1. + +Bug fixes: + + * Permit NULL platform argument in mongoc_handshake_data_append. + * Fix wire version check in server selection when maxStalenessSeconds is specified in read preferences. + * Fix assert on invalid URI options in client pools connected to load balanced clusters. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Ezra Chung + +--Kevin Albertson + + +mongo-c-driver 1.19.0 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.19.0 release. +This release adds full support for MongoDB 5.0 servers and MongoDB Atlas Serverless Instances. + +Features: + + * Add full support to connect to MongoDB Atlas Serverless Instances. + * Add support for snapshot reads on a session with mongoc_session_opts_set_snapshot. + * Support the new URI option loadBalanced to connect to a MongoDB cluster behind a TCP load balancer. + +Bug fixes: + + * Fix the uploadDate set on newly created GridFS files in the mongoc_gridfs_bucket_t API. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Jeremy Mikola + * Benjamin Rewis + * Andreas Braun + * Colby Pike + * Ezra Chung + * Roberto C. Sánchez + * Jesse Williamson + +--Kevin Albertson + + +mongo-c-driver 1.18.0 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.18.0 release. +This release adds partial support for MongoDB 5.0 servers. + +Features: + + * Introduces support to select an API version when connecting to a MongoDB instance. + * Supports Azure and Google Cloud Platform as Key Management Service (KMS) providers in Client-Side Field Level Encryption (CSFLE). + * Support "let" option in aggregate command. + * Support time series collections. + * Relax validation for insert and replace documents to support fields containing dots and dollars. + * Expose the reason operations fail document validation. + +Bug fixes: + + * Forward opts from mongoc_gridfs_bucket_find to underlying find operation. + * Fixes a possible hang when a limited size client pool is waiting for a client to become available in mongoc_client_pool_pop. + +Improvements + + * Deprecate API containing deprecated terminology. + * Use "hello" command for monitoring servers. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Roberto C. Sánchez + * Andreas Braun + * Clyde Bazile + * Benjamin Rewis + * Jeremy Mikola + * Andrew Witten + * Samantha Ritter + * samantharitter + * Fermín Galán Márquez + * David Carlier + * Colby Pike + * Josh Weinstein + * Pierre Mickael Gonzalo + +mongo-c-driver 1.18.0-alpha +=========================== + +It is my pleasure to announce the MongoDB C Driver 1.18.0-alpha. + +This is an unstable prerelease and is unsuitable for production applications. + +Features: + + * Introduces support to select an API version when connecting to a MongoDB instance. + * Supports Azure and Google Cloud Platform as Key Management Service (KMS) providers in Client-Side Field Level Encryption (CSFLE) + +Bug fixes: + + * Fixes a possible hang when a limited size client pool is waiting for a client to become available in mongoc_client_pool_pop. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Roberto C. Sánchez + * Clyde Bazile + * Andreas Braun + * Andrew Witten + * Samantha Ritter + * Benjamin Rewis + * Fermín Galán Márquez + * David Carlier + * Josh Weinstein + * Pierre Mickael Gonzalo + +mongo-c-driver 1.17.7 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.17.7. + +- Print correct error message when DNS resolution fails +- Mix time to avoid duplicate RAND_bytes for the same PIDs + +Thanks to everyone who contributed to the development of this release. + + * Andreas Braun + * Jeremy Mikola + +--Kevin Albertson + + +mongo-c-driver 1.17.6 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.17.6. + +Bug fixes: + + * Fix possible crash when speculative authentication fails with network error. + +Thanks to everyone who contributed to the development of this release. + + * Andreas Braun + +--Kevin Albertson + + +mongo-c-driver 1.17.5 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.17.5. + +Improvements: + + * Fix documentation regarding when to call mongoc_log_set_handler + +Thanks to everyone who contributed to the development of this release. + + * Clyde Bazile + * Fermín Galán Márquez + +--Kevin Albertson + + +mongo-c-driver 1.17.4 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.17.4. + +Bug fixes: + + * Fix crash on macOS on client pool shutdown. + * Fix spacing in extended JSON output for numberLong. + * Clear error in mongoc_collection_find_and_modify_with_opts on a successful retry. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Samantha Ritter + +-- Kevin Albertson + + +mongo-c-driver 1.17.3 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.17.3. + +Bug fixes: + + * Do not send session ID on GSSAPI auth commands. + * Fix build against zlib when zlib is installed in non-standard location. + * Fix build when source directory path contains a space. + * Fix a platform-specific bug causing mongoc_client_pool_pop to block indefinitely if all clients are checked out. + * Fix a possible buffer overflow with hostnames resolving to IPv6 addresses on OpenSSL. + + +Thanks to everyone who contributed to the development of this release. + + * Roberto C. Sánchez + * Kevin Albertson + * Andrew Witten + * gonzalo + +-- Kevin Albertson + + +mongo-c-driver 1.17.2 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.17.2. + +Bug fixes: + + * Stop the SRV polling thread when an SRV URI is used to connect to a deployment other than a sharded cluster. + +Thanks to everyone who contributed to the development of this release. + + * Roberto C. Sánchez + * Kevin Albertson + +-- Kevin Albertson + + +mongo-c-driver 1.17.1 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.17.1. + +Bug fixes: + + * Fix SRV/TXT record lookup for DNS records exceeding 1024 bytes. + +-- Kevin Albertson + + +mongo-c-driver 1.17.0 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.17.0 release. +This release adds support for MongoDB 4.4 servers. + +Features: + + * Support streamable server monitoring to reduce recovery time when the server topology changes. + * Support the MONGODB-AWS authentication mechanism. + * Support Online Certificate Status Protocol (OCSP). + * Support configuring hedged reads in read preferences. + * Reduce the number of round trips necessary for SCRAM and X509 authentication. + * Monitor servers in parallel when using a mongoc_client_pool_t instead of doing serial scans. + * Support the "hint" option in operations using the update, replace, delete, and findAndModify commands. + * Improve behavior for retryable writes. + * Improve resuming behavior of change streams on server errors. + * Remove restriction of 255 character collection namespaces. + +Bug fixes: + + * Fix criteria for resumable errors in change streams. + * Fix rare crashes when server is invalidated during authentication. + * Reject client session for mongoc_collection_estimated_document_count. + * Fix behavior of a SecondaryPreferred read preference for exhaust cursor operations against a sharded cluster. Prior to the fix, a nonzero maxStalenessSeconds would not trigger sending the read preference. + * Fix SRV polling. Prior to the fix, SRV polling did not properly apply newly discovered results. + * Fix checks for existing GridFS indexes to handle indexes created by the MongoDB shell. + * Fix possible use of invalidated streams during an unordered OP_QUERY bulk write, and when ending many pooled sessions at client destruction. + * Fix a crash when setting the crl_file TLS option for Secure Channel. + * Avoid emitting duplicate ServerChanged events when no change is observed during monitoring. + * Properly handle large SASL messages instead of erroring. + +Notes: + + * Deprecated "lib" prefixed artifacts are no longer produced when building on Windows. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Roberto C. Sánchez + * Andrew Witten + * Andreas Braun + * Clyde Bazile + * Josh Weinstein + +-- Kevin Albertson + +mongo-c-driver 1.17.0 rc0 +========================= + +It is my pleasure to announce the MongoDB C Driver 1.17.0 rc0 release. +This release adds support for MongoDB 4.4 servers. + +Features: + + * Support streamable server monitoring to reduce recovery time when the server topology changes. + * Support tlsDisableCertificateRevocationCheck when built with Secure Channel. + +Bug fixes: + + * Fix criteria for resumable errors in change streams. + * Fix rare crashes when server is invalidated during authentication. + * Improve behavior when reaching out to OCSP responders for certificate revocation checking. + * Reject client session for mongoc_collection_estimated_document_count. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Andrew Witten + * Roberto C. Sánchez + * Clyde Bazile + +-- Kevin Albertson + +mongo-c-driver 1.17.0 beta2 +=========================== + +It is my pleasure to announce the MongoDB C Driver 1.17.0 beta2 release. + +Features: + + * Support Online Certificate Status Protocol (OCSP) response caching. + * Support configuring hedged reads in read preferences. + * Reduce the number of round trips necessary for SCRAM and X509 authentication. + * Monitor servers in parallel when using a mongoc_client_pool_t instead of doing serial scans. + * Support OCSP on older versions of OpenSSL (1.0.1+). + +Bug fixes: + + * Fix behavior of a SecondaryPreferred read preference for exhaust cursor operations against a sharded cluster. Prior to the fix, a nonzero maxStalenessSeconds would not trigger sending the read preference. + * Fix SRV polling. Prior to the fix, SRV polling did not properly apply newly discovered results. + * Fix checks for existing GridFS indexes to handle indexes created by the MongoDB shell. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Roberto C. Sánchez + * Andreas Braun + * Clyde Bazile + * Josh Weinstein + +-- Kevin Albertson + + +mongo-c-driver 1.17.0 beta +========================== + +It is my pleasure to announce the MongoDB C Driver 1.17.0 beta release. + +Features: + + * Support the MONGODB-AWS authentication mechanism. + * Support the Online Certificate Status Protocol (OCSP) for OpenSSL 1.1.0+, Secure Transport, and Secure Channel. + * Support the "hint" option in operations using the update, replace, delete, and findAndModify commands. + * Improve behavior for retryable writes. + * Improve resuming behavior of change streams on server errors. + * Remove an extra round trip for SCRAM authentication. + * Remove restriction of 255 character collection namespaces. + +Bug fixes: + + * Fix possible use of invalidated streams during an unordered OP_QUERY bulk write, and when ending many pooled sessions at client destruction. + * Fix a crash when setting the crl_file TLS option for Secure Channel. + * Avoid emitting duplicate ServerChanged events when no change is observed during monitoring. + * Properly handle large SASL messages instead of erroring. + +Notes: + + * Deprecated "lib" prefixed artifacts are no longer produced when building on Windows. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Roberto C. Sánchez + * Andreas Braun + * Clyde Bazile + * Jeremy Mikola + * Sara Golemon + +-- Kevin Albertson + + +mongo-c-driver 1.16.1 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.16.1. + +Bug fixes: + + * Fix listed library dependency on mongoc_static target when building with libmongocrypt. + * Replace a call of free to bson_free. + * Vendor Sphinx basic theme and correctly list static files for docs. + * Fix a compilation warning introduced in 1.16.0. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + +Peace, + + Kevin Albertson + + +mongo-c-driver 1.16.0 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.16.0. + +Features: + + * Support Client-side Field Level Encryption. + * Support ability to pass an index hint to update operations. + * Add cmake export targets. + +Bug fixes: + * Fix a bug with Windows SSPI failing to authenticate with GSSAPI when using + pooled clients for certain operations. + * Fix behavior for bulk writes that retry to keep track of the successful server. + * Remove hard limit of 1024 characters for SRV response. + * Fix racy crash when using client pool against a sharded cluster if a server is invalidated shortly before a new socket is opened against it. + * Remove unnecessary library dependencies causing overlinking. + * Ensure server proof has been validated during SCRAM conversation. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Jeremy Mikola + * Clyde Bazile + * Andreas Braun + * Roberto C. Sánchez + * Samantha Ritter + * Isabel Atkinson + * Kaitlin Mahar + * Diego Barrios Romero + * Sara Golemon + * Vasil Velichkov + * EGuesnet + +Peace, + + Kevin Albertson + +mongo-c-driver 1.15.3 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.15.3. + +Bug fixes: + * Fix a hang on macOS when connecting to a server over TLS + * Add zstd as a dependency when libmongoc static library is compiled with zstd support + * Fix compilation on AIX 6.1 + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Samantha Ritter + * EGuesnet + +mongo-c-driver 1.15.2 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.15.2. + +Bug fixes: + * Prevent mongoc_transaction_opts_set_max_commit_time_ms from applying to subsequent transactions that should be using the default. + * Do not report the initial error if a retry for a change stream function (mongoc_collection_watch, mongoc_database_watch, or mongoc_client_watch) succeeds + +Thanks to everyone who contributed to the development of this release. + + * Andreas Braun + * Clyde Bazile + +Peace, + + Kevin Albertson + + +mongo-c-driver 1.15.1 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.15.1. + +Bug fixes: + * Fix change stream resume logic when no documents received + * Reduce the required cmake version to build with zstd support + * Minor fixes to mongos pinning logic + * Do not resume a change stream on NonResumableChangeStreamError + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Clyde Bazile + +Peace, + + Clyde Bazile + +mongo-c-driver 1.15.0 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.15.0. This release adds +support for MongoDB 4.2 features. + +Features: + + * Support for sharded transactions on MongoDB sharded clusters 4.2+. + * Add convenient transaction runner (mongoc_client_session_with_transaction), + which accepts a callback and performs appropriate retry logic. + * Add a new transaction option to specify maximum time to wait for a commit, + mongoc_transaction_opts_set_max_commit_time_ms. + * Add URI option "retryReads=true" safely and automatically retries certain + read operations if the server is a MongoDB 3.6+. + * Poll SRV records to mongos servers periodically. + * Keep connections alive after a primary stepdown detected. + * Standardizes URI options supported across all spec-compliant MongoDB drivers. + * "retryWrites" URI option now defaults to true (requires crypto for session + support). + * Send any aggregate with $out or $merge stage to a primary. + * Add the ability to specify an aggregate pipeline as an update document. + * Add a database aggregate helper, mongoc_database_aggregate. + * Add option for change streams, "startAfter". + * Add mongoc_change_stream_get_resume_token, which returns the resume token + which should be used to resume a change stream. + * Add support for zstd compression. + +Bug fixes: + * Correctly report an error in mongoc_change_stream_next if the resume token + (_id) is not a document. Previously, an error was only reported if the + field was missing. + * Fix mongoc_collection_update with MONGOC_UPDATE_MULTI_UPDATE, + mongoc_collection_remove, and mongoc_collection_delete when retryWrites + was enabled. They would fail previously. + * Command options are now correctly taken into account when batching bulk + writes for OP_QUERY. It was possible to exceed the maximum document size + before. + * Fix a crash if a multi-batch bulk write with OP_MSG errored on a batch. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * Jeremy Mikola + * Haris Sheikh + * Samantha Ritter + * Isabel Atkinson + * Sara Golemon + * Clyde Bazile + * Roberto C. Sánchez + * Lior Kaplan + * pasniak + +Peace, + + Kevin Albertson + + +mongo-c-driver 1.14.1 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.14.1. + +Bug fixes: + + * Prohibit starting a transaction for pre-4.0 MongoDB servers. + * Prohibit starting a sharded transaction for pre-4.2 MongoDB servers. + +Thanks to everyone who contributed to the development of this release. + + * Jeremy Mikola + * Clyde Bazile + +Peace, + + Kevin Albertson + + +mongo-c-driver 1.14.0 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.14.0. + + +Features: + + * Support for OpenSSL 1.1.1 and its implementation of TLS v1.3. + * New function mongoc_stream_should_retry. + * New accessor mongoc_server_description_last_update_time. + * New method mongoc_client_reset to be called after forking. + +Bug fixes: + + * OP_MSG with unacknowledged writes (write concern of w:0) would serialize + incorrectly on big-endian platforms, causing writes to use the default + write concern of w:1. + * mongoc_collection_update_many and mongoc_collection_delete_many would fail + with the URI option retryWrites=true. + * In a transaction, the driver now properly ignores the readConcern configured + on a client, database, or collection: only the mongoc_transaction_opt_t's + readConcern is used. + * Remove timestamp from uninstall scripts to permit reproducible build. + * Setting mongoc_ssl_opt_t.pem_file or ca_file to a bad file path caused a + hang with Darwin SSL. + * Fix the ENABLE_SASL cmake option: + * Remove unnecessary GSSAPI value. It was equivalent to specifying ENABLE_SASL=CYRUS. + * ENABLE_SASL=AUTO now correctly chooses SSPI on Windows instead of CYRUS. + * The client pool failed to set proper apm callbacks for clients created + via try_pop(). + + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Roberto C. Sánchez + * Kevin Albertson + * Samantha Ritter + * Spencer McKenney + * Henrik Edin + * Jeremy Mikola + * Evgeni Dobranov + * Derick Rethans + * 平民·寻梦(Pingmin Fenlly Liu) + * David Carlier + * Gustaf Neumann + * Jeroen + * Jeroen Ooms + * Kaitlin Mahar + * Tomas Mozes + * Clyde Bazile + +Peace, + + Samantha Ritter + + +mongo-c-driver 1.13.1 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.13.1. + +Bug fixes: + + * mongoc_collection_update_many and mongoc_collection_delete_many would fail + with the URI option retryWrites=true. + * Remove timestamp from uninstall scripts to permit reproducible build. + * Add missing header files to the release tarball to fix compilation when + configuring with ENABLE_SASL=GSSAPI. + * Separate libmongoc and libbson uninstall scripts so they do not overwrite + each other. + * Fix running make install with DESTDIR. + +Thanks to everyone who contributed to the development of this release. + + * Kevin Albertson + * A. Jesse Jiryu Davis + * Henrik Edin + +Peace, + + Kevin Albertson + + +mongo-c-driver 1.13.0 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.13.0. + +Features: + + * Report a new error code, MONGOC_ERROR_GRIDFS_CORRUPT, when a chunk larger + than chunkSize is detected. Before, the driver had crashed with an assert. + * Restructure of install directory. All mongoc headers are under mongoc/ + and all bson headers are under bson/. The preferred way of including the + headers are mongoc/mongoc.h and bson/bson.h respectively. + Forwarding headers in the root are provided for backwards compatibility. + (**Update**: These headers were removed in the 2.0 release) + * The default CMake build type had been unspecified, now it is RelWithDebInfo. + * Support LibreSSL 2.7+. + +Bug fixes: + + * mongoc_collection_replace_one is now a correctly exported symbol. + * Fix multiple issues with readConcern and writeConcern inheritance. + * Fix rare crash with mongodb+srv URIs on Windows. + * mongoc_gridfs_create_file_from_stream ignored errors while writing chunks + to the server. + * The following functions should not have taken a "bypassDocumentValidation" + option in bson_t *opts, the option is now prohibited: + - mongoc_bulk_operation_insert_with_opts + - mongoc_bulk_operation_update_one_with_opts + - mongoc_bulk_operation_update_many_with_opts + - mongoc_bulk_operation_replace_one_with_opts + * The heartbeat-succeeded and heartbeat-failed events (part of SDAM + Monitoring) had uninitialized "duration" fields, they are now set correctly. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Roberto C. Sánchez + * Kevin Albertson + * Henrik Edin + * Spencer McKenney + * Jeremy Mikola + * Evgeni Dobranov + * Tomas Mozes + * Derick Rethans + * Gustaf Neumann + * Jeroen Ooms + * Kaitlin Mahar + +Peace, + + Kevin Albertson + + +mongo-c-driver 1.12.0 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.12.0. + +Features: + + * New function mongoc_client_session_in_transaction to check if a multi- + document transaction is started. + * New examples for change streams and transactions, improved guide for + migrating from mongoc_collection_count to mongoc_collection_count_documents + +Bug fixes: + + * Fix occasional crash in sharded queries + * Retry all retryable write concern errors + * mongoc_client_session_commit_transaction sets the correct error label when + the primary is unavailable + * mongoc_collection_find_with_opts had prohibited read preference "primary" + in a transaction + * mongoc_collection_aggregate had not inherited its mongoc_collection_t's + read preference; only an explicitly provided read preference was used. + * Allow unencoded delimiters in username/password if unambiguous + +Thanks to everyone who contributed to the development of this release. + + * Roberto C. Sánchez + * A. Jesse Jiryu Davis + * Kevin Albertson + * Spencer McKenney + * Evgeni Dobranov + * Jeremy Mikola + * 平民·寻梦(Pingmin Fenlly Liu) + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.11.0 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.11.0. This release adds +support for MongoDB 4.0 features. It includes the following additions and +improvements: + + * Multi-document transactions, see mongoc_client_session_start_transaction + * New function mongoc_error_has_label to check for specific error labels such + as "TransientTransactionError" or "UnknownTransactionCommitResult" in + error replies. + * New functions to subscribe to changes on an entire client or database: + - mongoc_client_watch + - mongoc_database_watch + * New option for change streams, "startAtOperationTime". + * mongoc_collection_count_with_opts is deprecated for two new functions: + - mongoc_collection_count_documents + - mongoc_collection_estimated_document_count + * Support for SCRAM-SHA-256 authentication, including support for non-ASCII + passwords using libicu is an optional dependency. + * Faster mongoc_database_get_collection_names_with_opts fetches only names, + not the entire collection metadata. + +Additional changes not specific to MongoDB 4.0: + + * All "destroy" functions such as mongoc_collection_destroy now ignore a NULL + argument. + * The driver now returns an error if you attempt to use "arrayFilters" in an + update with a MongoDB server older than 3.6. + * Update functions include a new "upsertedCount" field in the reply document. + * Replace MD5 with FNV-1a hash to generate ObjectIds (for FIPS compliance). + +Bug fixes: + + * Functions incorrectly marked with the "const" compiler attribute are now + marked as "pure", fixes build error when link-time optimization is enabled. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Kevin Albertson + * Evgeni Dobranov + * Spencer McKenney + * Jeremy Mikola + * Roberto C. Sánchez + * Remi Collet + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.10.3 +===================== + +No change since 1.10.2; released to keep pace with libbson's version. + +-- A. Jesse Jiryu Davis + + +mongo-c-driver 1.10.2 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.10.2. This release fixes +the libbson and libmongoc installed library filenames and SONAMEs on Linux. +They had changed unintentionally with the switch to CMake in 1.10.0; they are +now consistent with 1.9.x and previous releases. Thanks to Roberto C. Sánchez +for the fix. + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.10.1 +===================== + +It is my pleasure to announce the MongoDB C Driver 1.10.1. This release fixes +the following bugs introduced in version 1.10.0: + + * Client sessions were not prohibited with unacknowledged write concern and + mongoc_bulk_operation_execute; now they are prohibited. Client sessions have + been prohibited with all other unacknowledged writes since 1.10. + * The "arrayFilters" update option, new in MongoDB 3.6 and supported since + libmongoc 1.9.0, was inadvertently prohibited by + mongoc_bulk_operation_update_one_with_opts and + mongoc_bulk_operation_update_many_with_opts in 1.10. The option is now + permitted again. + * The mongoc-stat tool for displaying shared counters was disabled on Linux + and not installed; it is now restored. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Jeremy Mikola + * Remi Collet + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.10.0 +===================== + +It is my pleasure to announce MongoDB C Driver 1.10.0. This version drops +support for MongoDB 2.6 and adds the following features and bugfixes: + + * libbson and libmongoc are now maintained in the mongo-c-driver repository, + although they are still built as separate libraries, and libbson can still + be used without libmongoc. + * Building libbson and libmongoc now requires CMake on all platforms. The + Autotools build scripts ("configure" and related scripts) have been deleted. + See the "installing" page for updated instructions, including the new + ENABLE_MONGOC option and changes to the ENABLE_BSON option. + * IPv6 is now fully supported and conforms to RFC-6555. If a hostname has both + IPv4 and IPv6 DNS records, the driver tries connecting with IPv6 first. If a + connection can't be established after 250ms then IPv4 is tried in parallel. + Whichever succeeds connection first cancels the other. The successful DNS + result is cached for 10 minutes. + * If CMake is configured with ENABLE_SSL=AUTO (the default), libmongoc now + uses native TLS libraries on Mac and Windows, and OpenSSL everywhere else. + Before, it would search for OpenSSL on all platforms and only use native + TLS on Mac and Windows as a fallback. + * The driver now handshakes SSL connections to multiple servers in a replica + set or sharded cluster in parallel, so long as it uses OpenSSL or Windows + SChannel. (SSL handshakes with Apple's Secure Transport are still serial.) + A larger receive buffer with SChannel increases performance over slow + connections. + * All functions that accept read concern now prohibit it, if MongoDB is too + old to support it (MongoDB 3.0). + * Client sessions are now prohibited with unacknowledged writes. + * mongoc_collection_find_and_modify_with_opts now prohibits write concern if + MongoDB is too old to support it (MongoDB 3.0). + * Other helper functions for commands that write, now prohibit write concern + if MongoDB is too old to support it (pre-3.4): + mongoc_client_read_write_command_with_opts + mongoc_client_write_command_with_opts + mongoc_collection_read_write_command_with_opts + mongoc_collection_write_command_with_opts + mongoc_database_read_write_command_with_opts + mongoc_database_write_command_with_opts + mongoc_collection_aggregate with $out + mongoc_collection_drop_index_with_opts + mongoc_collection_drop_with_opts + mongoc_collection_rename_with_opts + mongoc_database_drop_with_opts + Write concern behavior is unchanged for regular CRUD functions. + * Setting a negative writeConcern level of -2 or smaller, via the "opts" + parameter to functions that accept BSON options, is now prohibited. The + special "w" values -2 through -4 are only used internally. The deprecated + "w=-1" is still allowed, as a synonym for "w=0". + * The Kerberos URI option authMechanismProperties=CANONICALIZE_HOST_NAME:true + is now implemented with the Windows Kerberos provider, SSPI. + * This repository now includes GDB and LLDB customizations for pretty-printing + bson_t structs as JSON while debugging. See the "debugging" page. + * The internal preprocessor symbol HAVE_STRINGS_H has been renamed + BSON_HAVE_STRINGS_H. If you maintain a handwritten bson-config.h you must + rename this symbol. + * The following helper functions do not work with mongoc_client_session_t, + they are deprecated in favor of running MongoDB commands directly with a + function like mongoc_client_read_command_with_opts: + mongoc_client_get_server_status + mongoc_collection_stats + mongoc_collection_validate + * mongoc_cursor_is_alive is now deprecated for mongoc_cursor_more, which is + functionally equivalent. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Kevin Albertson + * Roberto C. Sánchez + * Jeremy Mikola + * Xiangyu Yao + * Jeroen Ooms + * Derick Rethans + * Kaitlin Mahar + * Pavithra Vetriselvan + * NotSpooky + * Iulian Rotaru + * Katherine Walker + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.9.5 +==================== + +It is my pleasure to announce mongo-c-driver 1.9.5. This release fixes the following bugs: + + * New change streams API functions were not marked extern "C" + * mongoc_collection_watch now accepts a pipeline argument as a BSON array, in + addition to accepting a BSON document with a "pipeline" array field + * Crashes in several change stream error handling paths + * Commands could return false with an empty bson_error_t after a replica set + reconfig + * Network error messages omitted the command name when using OP_MSG + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Kevin Albertson + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.9.4 +==================== + +It is my pleasure to announce mongo-c-driver 1.9.4. This release offers +compatibility with Sphinx 1.7.0 and above and fixes two bugs: + + * Ensure a change stream uses the proper session id while iterating + * Fix a rare crash in pooled mode when a replica set member was disconnected + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Kevin Albertson + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.9.3 +==================== + +It is my pleasure to announce mongo-c-driver 1.9.3. This version fixes a +session-management bug that could cause an authentication error while connected +to MongoDB 3.6+ and iterating a cursor, and it permits the $gleStats modifier +with mongoc_collection_aggregate. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Jeremy Mikola + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.9.2 +==================== + +No change since 1.9.1; released to keep pace with libbson's version number. + +-- A. Jesse Jiryu Davis + + +mongo-c-driver 1.9.1 +==================== + +It is my pleasure to announce mongo-c-driver 1.9.1. This release fixes a bug +that caused session ID to be included in authentication and server monitoring +commands. Thanks to Jeremy Mikola for finding and fixing the issue. + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.9.0 +==================== + +It is my pleasure to announce mongo-c-driver 1.9.0. This version drops support +for MongoDB 2.4 and adds support for MongoDB 3.6 features: + + * New struct mongoc_change_stream_t to watch a collection for changes. + * New struct mongoc_client_session_t represents a MongoDB 3.6 session, + which supports causal consistency: you are guaranteed to read your writes + and to perform monotonic reads, even when reading from secondaries or in + a sharded cluster. + * New functions that accept flexible options as a BSON document. These + accept a "sessionId" option and any future options. In addition, the + two new "update" functions accept the "arrayFilters" option that is new + in MongoDB 3.6: + mongoc_collection_insert_one + mongoc_collection_insert_many + mongoc_collection_update_one + mongoc_collection_update_many + mongoc_collection_replace_one + mongoc_collection_delete_one + mongoc_collection_delete_many + mongoc_client_command_with_opts + mongoc_database_command_with_opts + mongoc_collection_command_with_opts + mongoc_client_find_databases_with_opts + mongoc_client_get_database_names_with_opts + mongoc_collection_create_bulk_operation_with_opts + mongoc_collection_find_indexes_with_opts + mongoc_database_find_collections_with_opts + mongoc_database_get_collection_names_with_opts + * New URI option "retryWrites=true" safely and automatically retries certain + write operations if the server is a MongoDB 3.6 replica set or sharded + cluster. + * Support for MongoDB OP_MSG wire protocol. + +Additional changes not specific to MongoDB 3.6: + + * Support for mongodb+srv URIs to query DNS for SRV and TXT records that + configure the connection to MongoDB. + * Support LibreSSL with CMake build + * The "minPoolSize" URI option is deprecated: it's confusing and not useful. + +Bug fixes: + + * mongoc_bulk_operation_execute did not always initialize "reply". + * Fix C99 pedantic warnings. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Jeremy Mikola + * Kevin Albertson + * Jeroen Ooms + * Iulian Rotaru + * Derick Rethans + * Graham Whitted + * Brian Moss + * Alex Masterov + * Michael Kuhn + * Sriharsha Vardhan + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.8.2 +==================== + +It is my pleasure to announce mongo-c-driver 1.8.2. This release fixes the +following bugs: + + * Remove option to bundle the Snappy compression library, it caused issues + for programs linking to libmongoc + * Fix pkg-config and CMake config file flags for programs that statically + link to libmongoc when libmongoc is statically linked to zLib + * The configure flag "--with-zlib=no" was ignored + Crash in authentication when username is NULL + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Derick Rethans + * Hannes Magnusson + * Jeremy Mikola + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.8.1 +==================== + +It is my pleasure to announce mongo-c-driver 1.8.1. This release fixes the +following bugs: + + * Remove a syntax error in the configure script that affects some shells. + * The configure script respects --with-zlib=system and --with-snappy=system. + * The internal mongoc_server_description_t struct is properly reinitialized + after a network error. + * Fix the encoding of this NEWS file. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Jeremy Mikola + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.8.0 +==================== + + * The zLib and Snappy compression libraries are bundled if not available. + Wire protocol compression is enabled on Windows. + * mongoc_collection_find_and_modify_with_opts now respects a "writeConcern" + field in the "extra" BSON document in its mongoc_find_and_modify_opts_t. + * The command functions mongoc_client_read_write_command_with_opts, + mongoc_database_read_write_command_with_opts, and + mongoc_collection_read_write_command_with_opts now ignore the "read_prefs" + parameter. + * mongoc_collection_create_index and mongoc_collection_create_index_with_opts + are both now deprecated. Use mongoc_database_write_command_with_opts + instead; a guide to creating an index using that function has been added. + * Use select, not WSAPoll, on Windows. + * Always mark a server "Unknown" after a network error (besides a timeout). + * mongoc_client_pool_t sends platform metadata to the server; before, only a + single mongoc_client_t did. + * New stream method mongoc_stream_timed_out. + * Wire version checks introduced in 1.8.0 will prevent the driver from + connecting to a future MongoDB server version if its wire protocol is + incompatible. + * New CMake option ENABLE_MAINTAINER_FLAGS. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Jeremy Mikola + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.7.0 +==================== + +It is my pleasure to announce mongo-c-driver 1.7.0. + +New features and bug fixes: + + * CMake build now installs .pc files for programs that link to libmongoc using + pkg-config. Both the CMake and Autotools build systems now install .cmake + files for programs that link to libmongoc using CMake. Linking to libmongoc + statically or dynamically is now much more convenient. See the new tutorial + section "Include and link libmongoc in your C program". + * New CMake option ENABLE_STATIC can be ON, OFF, or AUTO (the default) + * Minimum required CMake version has been increased to 3.1. + * CMake remains experimental on non-Windows platforms and issues a warning now + * Support for wire compression. + * Support for snappy and zlib. MongoDB 3.4 only supports snappy, while zlib + support is expected in MongoDB 3.6. + The enable, configure mongoc like so: + ./configure --with-snappy --with-zlib + * New functions: mongoc_uri_get_compressors & mongoc_uri_set_compressors, to + get and set compressor configuration on mongoc_uri_t + * Added support for comma separated "compressors" connection string option (e.g. + mongodb://localhost/?compressors=snappy,zlib) + * Added support for configuring zlib compression level in the connection string + (e.g. mongodb://localhost/?compressors=zlib&zlibcompressionlevel=8) + * Now requires the use of CMake config files for libbson to build libmongoc + with CMake + * Added pkg-config support for libressl. + * New function mongoc_uri_set_auth_mechanism to update the authentication + mechanism of a mongoc_uri_t after it is created from a string. + * New function mongoc_bulk_operation_insert_with_opts provides immediate + error checking. + * New function mongoc_uri_new_with_error provides a way to parse a connection + string, and retrieve the failure reason, if any. + * Support for MongoDB Connection String specification + * All connection string options are now represented by MONGOC_URI_xxx macros + * Paths to Unix Domain Sockets must be url encoded + * Repeated options now issue warnings + * Special characters in username, password and other values must be url encoded + * Unsupported connection string options now issue warnings + * Boolean values can now be represented as true/yes/y/t/1 and false/no/n/f/0. + * Case is now preserved in Unix domain paths. + * New function mongoc_cursor_error_document provides access to server's error + reply if a query or command fails. + * New function mongoc_write_concern_is_default determines whether any write + concern options have been set, and mongoc_read_concern_is_default checks if + read concern options are set. + * mongoc_gridfs_find_one_with_opts optimized to use limit 1. + +Thanks to everyone who contributed to the development of this release. + + * Hannes Magnusson + * A. Jesse Jiryu Davis + * David Golden + * Jeremy Mikola + * Bernard Spil + * Aleksander Melnikov + * Adam Seering + * Remi Collet + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.6.0 +==================== + +It is my pleasure to announce mongo-c-driver 1.6.0. + +New features and bug fixes: + + * Enterprise authentication on Windows now uses the native GSSAPI library; + Cyrus SASL is no longer required for enterprise auth on Windows. + * BSON documents are more thoroughly validated before insert or update. + * New function mongoc_uri_set_mechanism_properties to replace all the + authMechanismProperties on an existing URI. + * mongoc_uri_get_mechanism_properties asserts its inputs are not NULL. + * For consistency with other MongoDB drivers, mongoc_collection_save is + deprecated in favor of mongoc_collection_insert or mongoc_collection_update. + * The driver is now built and continuously tested with MinGW-W64 on Windows. + * Experimental support for HPUX. + * The correct operation ids are now passed to Command Monitoring callbacks. + * Fix a crash if the driver couldn't connect to the server to create an index. + * The documentation is ported from Mallard XML to ReStructured Text, the + HTML documentation is restyled, and numerous man page syntax errors fixed. + * Getter functions for options in mongoc_find_and_modify_opts_t: + * mongoc_find_and_modify_opts_get_bypass_document_validation + * mongoc_find_and_modify_opts_get_fields + * mongoc_find_and_modify_opts_get_flags + * mongoc_find_and_modify_opts_get_max_time_ms + * mongoc_find_and_modify_opts_get_sort + * mongoc_find_and_modify_opts_get_update + * All public functions now have the __cdecl calling convention on Windows. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Aleksander Melnikov + * Jeroen Ooms + * Brian McCarthy + * Jonathan Wang + * Peter Beckman + * Remi Collet + * Rockford Wei + * Alexey Ponomarev + * Christopher Wang + * David Golden + * Jeremy Mikola + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.5.5 +==================== + +It is my pleasure to announce mongo-c-driver 1.5.5. This release fixes bugs +parsing the localThresholdMS option from the MongoDB URI, and a crash in +mongoc_cursor_destroy if "query" or "filter" are invalid. Thanks to Jeremy +Mikola. + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.5.4 +==================== + +It is my pleasure to announce mongo-c-driver 1.5.4. This release fixes an error +in cursor iteration when a readConcern is set. Thanks to Jeremy Mikola and +Hannes Magnusson. + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.5.3 +==================== + +This release fixes a bug that prevented connecting to IPv4-only MongoDB servers +by hostname. + +https://jira.mongodb.org/browse/CDRIVER-1988 + +The driver has reverted to its 1.5.1 behavior: it connects to MongoDB over IPv6 +if given an IPv6 connection string like "mongodb://[::1]", and requires an IPv4 +connection when given a hostname like "mongodb://localhost". + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.5.2 +==================== + +It is my pleasure to announce mongo-c-driver 1.5.2. + +Thanks to everyone who contributed to the development of this release. + +New bug fixes: + * CDRIVER-1975 allow mixed $ and non-$ query ops. + * CDRIVER-1972 Support for ipv6 hostnames. + * CDRIVER-1971 Missing exports of mongoc_gridfs_file_set_*() functions. + * CDRIVER-1970 update define constants for "find" opts to be unique. + * CDRIVER-1964 Windows CA stores should be opened with read-only flag. + +Thanks to everyone who contributed to the development of this release. + + * Hannes Magnusson + * A. Jesse Jiryu Davis + * Alexey Ponomarev + * Peter Beckman + * Rockford Wei + +Peace, + + Hannes Magnusson + + +mongo-c-driver 1.5.1 +==================== + +It is my pleasure to announce mongo-c-driver 1.5.1. This is a bugfix release: + + * Fix SEGFAULT with performance counters on NUMA (thanks to Jonathan Wang). + * Prevent rare assertion error in mongoc_cluster_stream_for_server. + * Improve error messages from auth failure. + * Escape quotes when appending CFLAGS to handshake metadata. + * Fix OpenSSL header lookups in non-default paths. + * Fix build failure with LibreSSL. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Jeroen Ooms + * Jonathan Wang + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.5.0 +==================== + +It is my pleasure to announce mongo-c-driver 1.5.0. + +New features and bug fixes: + * MongoDB 3.4 Support + * New URI and read preference option, "maxStalenessSeconds" + * MongoDB Handshake + * writeConcern and readConcern enhancements + * Collation allows users to specify language-specific rules for string + comparison when sorting documents. See the code examples for + mongoc_client_read_command_with_opts, mongoc_collection_count_with_opts, + mongoc_collection_find_with_opts, and mongoc_index_opt_t, as well as the + "Setting Collation Order" section of the "Bulk Write Operations" guide. + * mongoc_collection_count_with_opts uses the collection's read preference if + none is passed in + * Improved TLS support + * Fixed LibreSSL (libssl) support + * Added LibreSSL (libtls) support + * Fixed Secure Channel build on VS 2010 + * OpenSSL now supports SNI (all others already do) + * Additional features for Application Performance Monitoring: + * mongoc_topology_description_has_writable_server + * mongoc_topology_description_has_readable_server + * New functions accept flexible options as a BSON document: + * mongoc_collection_find_with_opts + * mongoc_client_read_command_with_opts + * mongoc_client_write_command_with_opts + * mongoc_client_read_write_command_with_opts + * mongoc_database_read_command_with_opts + * mongoc_database_write_command_with_opts + * mongoc_database_read_write_command_with_opts + * mongoc_collection_read_command_with_opts + * mongoc_collection_write_command_with_opts + * mongoc_collection_read_write_command_with_opts + * mongoc_gridfs_find_with_opts + * mongoc_gridfs_find_one_with_opts + * mongoc_collection_find is now deprecated in favor of + mongoc_collection_find_with_opts. + * New helper function to include read concern in one of the above function's + options parameter: mongoc_read_concern_append. + * mongoc_client_command no longer applies the client's read preference and + read concern by default. Same change for mongoc_database_command and + mongoc_collection_command. + * mongoc_collection_count_with_opts now applies the collection's read + preference if no read preference is provided + * mongoc_collection_create_index and mongoc_collection_drop_index now apply + the collection's write concern. + * connectTimeoutMS timer now begins after DNS resolution, and resets + for each interface attempted (e.g., if the driver first tries IPv6, + then IPv4). + * New error code MONGOC_ERROR_DUPLICATE_KEY. + * mongoc_collection_find no longer treats the "filter" key specially in + queries - querying for a document with a key named "filter" is the same + now as any other key. + * The server description parameter to the following functions is "const": + * mongoc_server_description_host + * mongoc_server_description_id + * mongoc_server_description_ismaster + * mongoc_server_description_round_trip_time + * mongoc_server_description_type + * Exported symbols are no longer declared in separate export files. + This could break ABI with applications using clang, which previously + exported symbols from the internal private ABI. + * mongoc no longer crashes when multi roundtrip bulk operation fails. + * Added support for the new readConcernLevel "linearizable". + * Clients now check for misformatted "readPreferenceTags" in URI. + * New CMake option ENABLE_TRACING allows debug output, which before had only + been available with "configure --enable-tracing". + * Bugfix: "PossiblePrimary"-type replicas could be selected for reads + * Bugfixes: The random number generator used to select servers is now properly + seeded, and secondary queries are now properly distributed according to + localThresholdMS, not just to the lowest-latency secondary. + * mongoc_collection_insert, mongoc_collection_update, mongoc_collection_remove + consistently use domain MONGOC_ERROR_BSON, code MONGOC_ERROR_BSON_INVALID + if passed oversized BSON, and MONGOC_ERROR_COLLECTION for other errors. + mongoc_bulk_operation_execute continues to use MONGOC_ERROR_COMMAND for + all errors. + * If mongoc_client_pool_t fails to start its scanner thread in the background, + it logs and aborts instead of silently continuing, then failing to connect. + * The driver now updates its view of the whole topology with information from + each new connection handshake. + * mongoc_client_set_apm_callbacks can be used repeatedly to change or clear + the list of monitoring callbacks. + * Improved error reporting when the driver fails to reach the server. + +Deprecations: + * mongoc_collection_find is deprecated for mongoc_collection_find_with_opts. + +Removed configure flags: + * --enable-experimental has been removed. All previously experimental + features are now always on. + * The configure option "--enable-hardening" had had no effect. It is removed + in favor of system-wide compiler configuration. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Fiona Rowan + * Ian Boros + * Remi Collet + * Brian McCarthy + * Jeroen Ooms + * J. Rassi + * Christoph Schwarz + * Alexey Vorobeyev + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.4.2 +==================== + +It is my pleasure to announce mongo-c-driver 1.4.2. This release fixes bugs in +"minPoolSize" logic, see CDRIVER-1558 for details. + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.4.1 +==================== + +It is my pleasure to announce mongo-c-driver 1.4.1. This is a bugfix release: + + * mongoc_client_get_server_descriptions could return a list including NULLs + * Tailable cursors on MongoDB 3.2 only worked with MONGOC_QUERY_AWAIT_DATA + * Spurious warnings with MONGOC_DISABLE_SHM + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.4.0 +==================== + +It is my pleasure to announce the release of mongo-c-driver 1.4.0. + +TLS +--- + +The driver can now use the native TLS and crypto functions included in macOS +and Windows. OpenSSL is no longer required for TLS or authentication on Mac or +Windows. By default, OpenSSL is used if available, the default will switch in +version 2.0 to prefer native TLS. + +For native TLS on Mac: + + ./configure --enable-ssl=darwin + +For Windows: + + cmake "-DENABLE_SSL=WINDOWS" -G "Visual Studio 10 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" + +All of the TLS implementations now load the native default certificate store, +with OpenSSL on Windows falling back on the Windows native certificate store if +no other can be found. + +The "ca_dir" field on mongoc_ssl_opt_t is only supported by OpenSSL. All other +fields, including "pem_file", are supported by all implementations. + +A new field, "allow_invalid_hostname", has been added to mongoc_ssl_opt_t and is +preferred over the existing "allow_invalid_certificate" to disable hostname +verification. + +The driver now supports the latest OpenSSL 1.1 in addition to past versions. + +Application Performance Monitoring +---------------------------------- + +The driver implements the MongoDB Command Monitoring Spec. Applications can +record the duration and other details of every operation the driver performs on +the server. See "Introduction to Application Performance Monitoring" in the +docs. + +Error API +--------- + +New functions mongoc_client_set_error_api and mongoc_client_pool_set_error_api +allow applications to distinguish client and server errors. See the "Error +Reporting" doc. + +Unacknowledged Write Results +---------------------------- + +Unacknowledged writes (writes whose mongoc_write_concern_t "w" value is zero) +now reply with an empty document instead of one with nInserted: 0, nUpdated: 0, +and so on. + +Command functions now ignore the read preferences set on a client, database, +or collection. Instead, they use the mongoc_read_prefs_t passed in explicitly, +or default to "primary". This change was made to bring them in line with the +Server Selection Spec. These are the affected functions: + + * mongoc_client_command + * mongoc_client_command_simple + * mongoc_database_command + * mongoc_database_command_simple + * mongoc_collection_command + * mongoc_collection_command_simple + +On the other hand, the following command-specific helper functions now use the +collection's read preference: + + * mongoc_collection_count + * mongoc_collection_stats + +New functions to send maxTimeMS or any arbitrary options with findAndModify: + + * mongoc_find_and_modify_opts_set_max_time_ms + * mongoc_find_and_modify_opts_append + +New function to include a write concern with a generic command function +like mongoc_client_command_simple: + + * mongoc_write_concern_append + +Public API For Higher-Level Drivers +----------------------------------- + +New functions support language drivers (specifically the PHP and HHVM drivers) +using only the libmongoc public API: + + * mongoc_bulk_operation_get_hint + * mongoc_client_command_simple_with_server_id + * mongoc_client_get_server_description + * mongoc_client_get_server_description_by_id + * mongoc_client_get_server_descriptions + * mongoc_client_select_server + * mongoc_cursor_get_limit + * mongoc_cursor_new_from_command_reply + * mongoc_cursor_set_hint + * mongoc_cursor_set_limit + * mongoc_log_trace_disable + * mongoc_log_trace_enable + * mongoc_server_description_ismaster + * mongoc_server_description_round_trip_time + * mongoc_server_description_type + * mongoc_server_descriptions_destroy_all + * mongoc_uri_get_option_as_bool + * mongoc_uri_get_option_as_int32 + * mongoc_uri_get_option_as_utf8 + * mongoc_uri_option_is_bool + * mongoc_uri_option_is_int32 + * mongoc_uri_option_is_utf8 + * mongoc_uri_set_auth_source + * mongoc_uri_set_database + * mongoc_uri_set_option_as_bool + * mongoc_uri_set_option_as_int32 + * mongoc_uri_set_option_as_utf8 + * mongoc_uri_set_password + * mongoc_uri_set_read_concern + * mongoc_uri_set_read_prefs_t + * mongoc_uri_set_username + * mongoc_uri_set_write_concern + * mongoc_write_concern_is_acknowledged + * mongoc_write_concern_is_valid + * mongoc_write_concern_journal_is_set + +Now that these public APIs are available, the PHP drivers no longer define the +MONGOC_I_AM_A_DRIVER preprocessor symbol to access private APIs. The symbol is +removed from C Driver headers, and libmongoc-priv.so is no longer installed. + +Other Features +-------------- + + * New connection string option "localThresholdMS". + * zSeries and POWER8 platform support. + * Performance enhancements, reduce allocation and copying in command code. + * All man page names now begin with "mongoc_" to avoid install conflicts. + * New function mongoc_gridfs_file_set_id. + +Deprecations +------------ + +Automatically calling mongoc_init and mongoc_cleanup is a GCC-specific feature +that is now deprecated, and will be removed in version 2. The driver should be +built with: + +./configure --disable-automatic-init-and-cleanup + +Or: + + cmake "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF" -G "Visual Studio 10 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" + +In this configuration, applications must explicitly init and cleanup libmongoc. + +Deprecated functions: + + * mongoc_write_concern_get_fsync + * mongoc_write_concern_set_fsync + +Notable Bug Fixes +----------------- + + * Logic bugs using tag sets to select replica set members with complex configs + * mongoc_client_get_database_names no longer filters out a replica set + member's "local" database. + * mongoc_client_get_gridfs now ensures the proper indexes on the files and + chunks collections. + * SecondaryPreferred fails if primary matches tags but secondaries don't. + * mongoc_collection_find_and_modify_with_opts can return true on + writeConcernError. + * mongoc_collection_validate doesn't always init "reply". + * The strings referred to by mongoc_ssl_opt_t, like pem_file and ca_file, are + now copied into the client or client pool by mongoc_client_set_ssl_opts or + mongoc_client_pool_set_ssl_opts, and need not be kept valid afterward. + * mongoc_collection_count_with_opts ignored flags and read_prefs. + * minPoolSize of 0 should mean "no minimum". + * mongoc_database_create_collection should always use the primary. + * The GSSAPI properties SERVICE_NAME and CANONICALIZE_HOST_NAME are now + properly parsed from the URI, see the "Authentication" doc for details. + * Comprehensive compatibility with various C standards and compilers. + +Acknowledgements +---------------- + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Ian Boros + * Fiona Rowan + * Jeremy Mikola + * Christoph Schwarz + * Mike Lloyd + * Remi Collet + * Jean-Bernard Jansen + * David Hatch + * Derick Rethans + * Brian Samek + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.3.5 +==================== + +It is my pleasure to announce mongo-c-driver 1.3.5. This release fixes a crash +in mongoc_cleanup when an allocator had been set with bson_mem_set_vtable, and +introduces a configure option MONGOC_NO_AUTOMATIC_GLOBALS which prevents code +built with GCC from automatically calling mongoc_init and mongoc_cleanup when +your code does not. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.3.4 +==================== + +It is my pleasure to announce the MongoDB C Driver 1.3.4. This release fixes a +security vulnerability: when a mongoc_client_t uses SSL and is disconnected, it +failed to re-verify the server certificate after reconnecting. This flaw affects +single clients, not pooled ones. + +Thanks to everyone who contributed to the development of this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Remi Collet + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.3.3 +==================== + +It is my pleasure to announce MongoDB C Driver 1.3.3. This fixes a bug where +a slightly-oversized bulk write operation was not split into batches; instead, +it was sent whole to the server, which rejected it. + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.3.2 +==================== + +It is my pleasure to announce MongoDB C Driver 1.3.2. This is a bugfix release: + + * A socket is properly discarded after a network error from a command. + * mongoc_database_get_collection now copies the database's read preferences, + read concern, and write concern, instead of copying the client's. + * mongoc_cursor_t's private struct now allows a negative limit. + +Thanks to everyone who contributed to this release. + + * A. Jesse Jiryu Davis + * Jeremy Mikola + * Hannes Magnusson + +Peace, + + A. Jesse Jiryu Davis + + + +mongo-c-driver 1.3.1 +==================== + +It is my pleasure to announce MongoDB C Driver 1.3.1. This is a bugfix release: + + * mongoc_client_get_gridfs now copies the client's read preferences, read + concern, and write concern to the newly created mongoc_gridfs_t. Before + this fix, GridFS operations were always executed with the default config: + data was read from the primary, with the read concern level "local", and + written with write concern "acknowledged". Now, if you have configured any + of these options on the mongoc_client_t, they are respected by the + mongoc_gridfs_t. + * CMakeLists.txt now includes and installs the pkg-config files. + +Thanks to everyone who contributed to this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Christopher Wang + * Jean-Bernard Jansen + * Jeremy Mikola + * Jeroen Ooms + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.3.0 +==================== + +It is my pleasure to announce to you the release of the MongoDB C Driver 1.3.0. + +Changes since the release candidate 1.3.0-rc0: + + * Fix a cursor bug introduced on big-endian platforms in 1.3.0-beta0. + * Improve documentation for mongoc_host_list_t. + * Move private mongoc_host_list_t functions from public header. + * Refactor the build system to declare library version in one place. + +All new features and changes since the previous stable release, 1.2.1: + + * If the driver is compiled without SSL support but a URI with "ssl=true" + is passed to mongoc_client_new, mongoc_client_new_from_uri, or + mongoc_client_pool_new, the function logs an error and returns NULL. Before, + the driver would attempt a non-SSL connection. + * mongoc_collection_find_and_modify will now apply the mongoc_collection_t's + write_concern_t when talking to MongoDB 3.2. + * Support for MongoDB 3.2's "readConcern" feature for queries, counts, and + aggregations. The option "readConcernLevel" is now accepted in the MongoDB + URI. New struct mongoc_read_concern_t, and functions operating on it: + - mongoc_client_get_read_concern + - mongoc_client_set_read_concern + - mongoc_database_get_read_concern + - mongoc_database_set_read_concern + - mongoc_collection_get_read_concern + - mongoc_collection_set_read_concern + - mongoc_read_concern_copy + - mongoc_read_concern_destroy + - mongoc_read_concern_get_level + - mongoc_read_concern_new + - mongoc_read_concern_set_level + - mongoc_uri_get_read_concern + * Support for MongoDB 3.2's "bypassDocumentValidation" option for writes. + * New struct mongoc_bulk_write_flags_t and related functions: + - mongoc_bulk_operation_set_bypass_document_validation + * New struct mongoc_find_and_modify_opts_t and related functions: + - mongoc_find_and_modify_opts_new + - mongoc_find_and_modify_opts_destroy + - mongoc_find_and_modify_opts_set_sort + - mongoc_find_and_modify_opts_set_update + - mongoc_find_and_modify_opts_set_fields + - mongoc_find_and_modify_opts_set_flags + - mongoc_find_and_modify_opts_set_bypass_document_validation + - mongoc_collection_find_and_modify_with_opts + * New functions to copy database and collection handles: + - mongoc_collection_copy + - mongoc_database_copy + * Support for MongoDB 3.2 wire protocol: use commands in place of OP_QUERY, + OP_GETMORE, and OP_KILLCURSORS messages. + * To explain a query plan with MongoDB 3.2, you must now call the "explain" + command, instead of including the "$explain" key in a mongoc_collection_find + query. See the mongoc_collection_find documentation page for details. + * Configurable wait time on tailable cursors with MongoDB 3.2: + - mongoc_cursor_get_max_await_time_ms + - mongoc_cursor_set_max_await_time_ms + * Use electionId to detect a stale replica set primary during a network split. + * Disconnect from replica set members whose "me" field does not match the + connection address. + * The client side matching feature, mongoc_matcher_t and related functions, + are deprecated and scheduled for removal in version 2.0. + * New CMake options ENABLE_SSL, ENABLE_SASL, ENABLE_TESTS, and ENABLE_EXAMPLES. + * Use constant-time comparison when verifying credentials. + * Combine environment's CFLAGS with configure options when building. + * Improved man page output and "whatis" entries. + +There are extensive bugfixes and improvements in GridFS since 1.2.1, including: + + * Handle seeking, reading, and writing past the end of a GridFS file. + * If a GridFS chunk is missing, mongoc_gridfs_file_readv sets file->error to + domain MONGOC_ERROR_GRIDFS and a new code MONGOC_ERROR_GRIDFS_CHUNK_MISSING. + * Optimization for long seeks forward with mongoc_gridfs_file_seek. + +Other fixes since 1.2.1: + + * Memory leaks in mongoc_database_has_collection and mongoc_cursor_next. + * Report writeConcern failures from findAndModify and from legacy writes. + * Memory leak in mongoc_database_find_collections. + * Set OP_QUERY's nToReturn from the provided limit. + * Fix compiler warnings and errors, especially with Visual Studio 2015, + GCC 4.8, and IBM XL C. + * Bugs and typos in tutorial examples. + +Thanks to everyone who contributed to this release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Kyle Suarez + * Jose Sebastian Battig + * Matt Cotter + * Claudio Canella + * alexeyvo + * Christopher Wang + * Flavio Medeiros + * Iago Rubio + * Jeremy Mikola + * Victor Leschuk + * Jason Carey + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.3.0-rc0 +======================== + +It is my pleasure to announce to you the first release candidate of MongoDB C +driver 1.3.0. It includes additive ABI changes and bugfixes, and support for +the upcoming MongoDB 3.2. It is compatible with MongoDB 2.4 and later. + +New features and changes since 1.3.0-beta0: + + * If the driver is compiled without SSL support but a URI with "ssl=true" + is passed to mongoc_client_new, mongoc_client_new_from_uri, or + mongoc_client_pool_new, the function logs an error and returns NULL. Before, + the driver would attempt a non-SSL connection. + * New functions to copy database and collection handles: + - mongoc_collection_copy + - mongoc_database_copy + * If a GridFS chunk is missing, mongoc_gridfs_file_readv sets file->error to + domain MONGOC_ERROR_GRIDFS and a new code MONGOC_ERROR_GRIDFS_CHUNK_MISSING. + * Use electionId to detect a stale replica set primary during a network split. + * Disconnect from replica set members whose "me" field does not match the + connection address. + * The client side matching feature, mongoc_matcher_t and related functions, + are deprecated and scheduled for removal in version 2.0. + * New CMake options ENABLE_SSL, ENABLE_SASL, ENABLE_TESTS, and ENABLE_EXAMPLES. + * The build system is refactored to declare the current version and latest + release in one place. + +Other fixes: + + * Memory leaks in mongoc_database_has_collection and mongoc_cursor_next. + * Report writeConcern failures from findAndModify and from legacy writes. + +Thanks to everyone who contributed to this release candidate. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Matt Cotter + * Claudio Canella + * Victor Leschuk + * Flavio Medeiros + * Christopher Wang + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.3.0-beta0 +========================== + +It is my pleasure to announce to you the beta of MongoDB C driver 1.3.0. +This beta includes additive ABI changes and bugfixes, and support for +the upcoming MongoDB 3.2. It is compatible with MongoDB 2.4 and later. + +New features and changes: + + * mongoc_collection_find_and_modify will now apply the mongoc_collection_t's + write_concern_t when talking to MongoDB 3.2. + * Support for MongoDB 3.2's "readConcern" feature for queries, counts, and + aggregations. The option "readConcernLevel" is now accepted in the MongoDB + URI. New struct mongoc_read_concern_t, and functions operating on it: + - mongoc_client_get_read_concern + - mongoc_client_set_read_concern + - mongoc_database_get_read_concern + - mongoc_database_set_read_concern + - mongoc_collection_get_read_concern + - mongoc_collection_set_read_concern + - mongoc_read_concern_copy + - mongoc_read_concern_destroy + - mongoc_read_concern_get_level + - mongoc_read_concern_new + - mongoc_read_concern_set_level + - mongoc_uri_get_read_concern + * Support for MongoDB 3.2's "bypassDocumentValidation" option for writes. + * New struct mongoc_bulk_write_flags_t and related functions: + - mongoc_bulk_operation_set_bypass_document_validation + * New struct mongoc_find_and_modify_opts_t and related functions: + - mongoc_find_and_modify_opts_new + - mongoc_find_and_modify_opts_destroy + - mongoc_find_and_modify_opts_set_sort + - mongoc_find_and_modify_opts_set_update + - mongoc_find_and_modify_opts_set_fields + - mongoc_find_and_modify_opts_set_flags + - mongoc_find_and_modify_opts_set_bypass_document_validation + - mongoc_collection_find_and_modify_with_opts + * Configurable wait time on tailable cursors with MongoDB 3.2: + - mongoc_cursor_get_max_await_time_ms + - mongoc_cursor_set_max_await_time_ms + * Support for MongoDB 3.2 wire protocol: use commands in place of OP_QUERY, + OP_GETMORE, and OP_KILLCURSORS messages. + * To explain a query plan with MongoDB 3.2, you must now call the "explain" + command, instead of including the "$explain" key in a mongoc_collection_find + query. See the mongoc_collection_find documentation page for details. + * Use constant-time comparison when verifying credentials. + * Combine environment's CFLAGS with configure options when building. + * Improved man page output and "whatis" entries. + +Extensive bugfixes and improvements in GridFS, including: + + * Handle seeking, reading, and writing past the end of a GridFS file. + * Optimization for long seeks forward with mongoc_gridfs_file_seek. + +Other fixes: + + * Memory leak in mongoc_database_find_collections. + * Set OP_QUERY's nToReturn from the provided limit. + * Fix compiler warnings and errors, especially with Visual Studio 2015, + GCC 4.8, and IBM XL C. + * Bugs and typos in tutorial examples + +Thanks to everyone who contributed to this beta release. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Kyle Suarez + * Jose Sebastian Battig + * Jeremy Mikola + * Iago Rubio + * Matt Cotter + * alexeyvo + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.2.2 +==================== + +It is my pleasure to announce to you the MongoDB C driver 1.2.2. + +This release fixes a rare bug where the driver can direct reads to hidden +secondaries unintentionally. It also includes fixes and improvements to the +build system. + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.2.1 +==================== + +It is my pleasure to announce to you the MongoDB C driver 1.2.1. + +This release includes critical bugfixes for SSL connections with +mongoc_client_pool_t, and for Unix domain socket connections. + +The documentation is updated for a change introduced in version 1.2.0: +mongoc_client_set_ssl_opts and mongoc_client_pool_set_ssl_opts now configure +the driver to require an SSL connection to the server, even if "ssl=true" is +omitted from the MongoDB URI. Before, SSL options were ignored unless +"ssl=true" was included in the URI. + +The build instructions are improved, including the steps to build with OpenSSL +on OS X El Capitan. Build errors and warnings are fixed for clang in gnu99 +mode and MinGW. + +Thanks to everyone who contributed to this version of libmongoc. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Tamas Nagy + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.2.0 +==================== + +It is my pleasure to announce to you the MongoDB C driver 1.2.0. + +This is a stable release with additive ABI changes and bugfixes. It is +compatible with MongoDB version 2.4 and later. + +The following notes summarize changes since the previous stable release, +1.1.11, including changes in the 1.2.0 betas and release candidate. + +This version rewrites mongoc_client_t's internals to match two important new +specs for MongoDB drivers: the Server Discovery And Monitoring Spec and the +Server Selection Spec. The rewritten client has many advantages: + + * All replica set members or mongos servers are discovered and periodically + checked in parallel. The driver's performance is dramatically better and + more predictable with multi-server deployments, or with a flaky network, + or when some servers are slow or down. + * Clients from the same mongoc_client_pool_t share a background thread that + discovers and monitors all servers in parallel. + * Unnecessary round trips for server checks and pings are eliminated. + * Behavior is documented in the specs, and consistent with other drivers, + even in complex or unusual scenarios. + * The URI's "replicaSet" option is enforced: the driver now refuses to connect + to a server unless it is a member of a replica set with the correct setName. + * Many race conditions related to changing deployment conditions are fixed. + +To conform to the new specs, the client now accepts these options in the +MongoDB URI; see the mongoc_uri_t documentation for details: + + * heartbeatFrequencyMS + * serverSelectionTimeoutMS + * serverSelectionTryOnce + * socketCheckIntervalMS + +Other features: + + * All timeouts that can be configured in the URI now interpret 0 to mean "use + the default value for this timeout". + * The client's read preference can be configured in the URI with the new + options "readPreference" and "readPreferenceTags"; see the mongoc_uri_t + documentation. + * The new mongoc_uri_get_read_prefs_t function retrieves both the read mode + and tags from a mongoc_uri_t. + * New accessors mongoc_gridfs_file_get_id, mongoc_client_get_default_database, + and mongoc_bulk_operation_get_write_concern. + * Debug tracing can be controlled at runtime with mongoc_log_trace_enable and + mongoc_log_trace_disable. + * Set mongoc_client_pool_t's size with mongoc_client_pool_min_size() + and mongoc_client_pool_max_size(). + +Other changes: + + * Enable runtime asserts in release build. + * The libbson submodule's URL now uses the recommended https://, not git:// + * mongoc_client_kill_cursor is now deprecated and will be removed in 2.0. + * The write concern "w=-1" is documented as obsolete. + +These notable bugs have been fixed since 1.1.11: + + * The driver now uses the server's maxWireVersion to avoid an error and + extra round-trip when executing aggregations on MongoDB 2.4 and older. + * Much improved reporting of network errors, unavailable servers, and + authentication failure + * Off-by-one error in mongoc_gridfs_file_seek with mode SEEK_END + * The writeConcernErrors field of bulk results is properly formatted. + * A cursor with a server "hint" sets slaveOkay and / or $readPreference. + * Destroying an exhaust cursor must close its socket + * "wtimeoutms" was ignored for write concerns besides "majority". + * Bulk write operations might fail in mixed-version sharded clusters with + some pre-2.6 mongos servers. + * A variety of bugs and incorrect results in mongoc_bulk_operation_execute. + * Numerous compiler warnings and build failures on various platforms. + * Copious refinements to the documentation. + +Thanks to everyone who contributed to this version of libmongoc. + + * Jason Carey + * Samantha Ritter + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Kyle Suarez + * Jeremy Mikola + * Remi Collet + * Jose Sebastian Battig + * Derick Rethans + * Yuchen Xie + * Manuel Schoenlaub + * Sujan Dutta + * Lloyd Zhou + * rubicks + * Pawel Szczurko + * Yuval Hager + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.2.0-rc0 +======================== + +It is my pleasure to announce the release candidate of the MongoDB C driver +1.2.0. It includes features and bugfixes developed since 1.2.0-beta1. + +Notable bugs fixed: + + * Much improved reporting of network errors, unavailable servers, and + authentication failure + * Destroying an exhaust cursor must close its socket + * Various bugs in server reconnection logic + * mongoc_collection_aggregate returned invalid cursor after failure + * Wrong error message after failed network write on Sparc + * Missing JSON test files in release tarball + +Other changes: + + * Enable runtime asserts in release build. + * mongoc_client_kill_cursor is now deprecated and will be removed in + version 2.0. + +This release candidate also includes all bugfixes from 1.1.11. + +Version 1.2.0 final will be a stable release with additive ABI changes and +bugfixes. It is compatible with MongoDB version 2.4 and later. + +Thanks to everyone who contributed to this version of libmongoc. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Kyle Suarez + * rubicks + * Jose Sebastian Battig + * Jason Carey + * Remi Collet + * Yuval Hager + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.2.0-beta1 +========================== + +It is my pleasure to announce the second beta release of the MongoDB C driver +1.2.0. It includes features and bugfixes developed since 1.2.0-beta. + +New features: + + * Set mongoc_client_pool_t's size with mongoc_client_pool_min_size() + and mongoc_client_pool_max_size(). + * The write concern "w=-1" is now documented as obsolete. + * Abundant fixes and additions to the documentation, beyond those in the + previous beta. + +Notable bugs fixed: + + * Crashes and races in several replica set scenarios. + * The driver now uses the server's maxWireVersion to avoid an error and + extra round-trip when executing aggregations on MongoDB 2.4 and older. + * Fixed network error handling in multiple code paths. + * connectTimeoutMS limits the time the driver can spend reconnecting to + servers in single-threaded (non-pooled) mode with serverSelectionTryOnce. + +Version 1.2.0 final will be a stable release with additive ABI changes and +bugfixes. It is compatible with MongoDB version 2.4 and later. + +Thanks to everyone who contributed to this version of libmongoc. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Manuel Schoenlaub + * Kyle Suarez + * Remi Collet + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.2.0-beta +========================= + +It is my pleasure to announce to you the first beta release of the MongoDB C +driver 1.2.0. + +This release is a stable release with additive ABI changes and bugfixes. +It is compatible with MongoDB version 2.4 and later. + +Version 1.2.0 rewrites mongoc_client_t's internals to match two important new +specs for MongoDB drivers: the Server Discovery And Monitoring Spec and the +Server Selection Spec. The rewritten client has many advantages: + + * All replica set members or mongoses are discovered and periodically + checked in parallel. The driver's performance is dramatically better and + more predictable with multi-server deployments, or with a flaky network, + or when some servers are slow or down. + * Clients from the same mongoc_client_pool_t share a background thread that + discovers and monitors all servers in parallel. + * Unnecessary round trips for server checks and pings are eliminated. + * Behavior is documented in the specs, and consistent with other drivers, even + in complex or unusual scenarios. + * The URI's "replicaSet" option is enforced: the driver now refuses to connect + to a server unless it is a member of a replica set with the right setName. + * Many race conditions related to changing deployment conditions are fixed. + +To conform to the new specs, the client now accepts these options in the MongoDB +URI; see the mongoc_uri_t documentation for details: + + * heartbeatFrequencyMS + * serverSelectionTimeoutMS + * serverSelectionTryOnce + * socketCheckIntervalMS + +Other features: + + * All timeouts that can be configured in the URI now interpret 0 to mean "use + the default value for this timeout". + * The client's read preference can be configured in the URI with the new + options "readPreference" and "readPreferenceTags", see the mongoc_uri_t + documentation. + * The new mongoc_uri_get_read_prefs_t function retrieves both the read mode + and tags from a mongoc_uri_t. + * New accessors mongoc_gridfs_file_get_id, mongoc_client_get_default_database, + and mongoc_bulk_operation_get_write_concern. + * Debug tracing can be controlled at runtime with mongoc_log_trace_enable and + mongoc_log_trace_disable. + +Notable bugs fixed: + + * "wtimeoutms" was ignored for write concerns besides "majority". + * Bulk write operations might fail in mixed-version sharded clusters with + some pre-2.6 mongos servers. + * Normal operations were logged during startup and could not be silenced. + * A variety of bugs and incorrect results in mongoc_bulk_operation_execute. + * Numerous compiler warnings and build failures on various platforms. + * Copious refinements to the documentation. + +Thanks to everyone who contributed to this version of libmongoc. + + * A. Jesse Jiryu Davis + * Sujan Dutta + * Jason Carey + * Hannes Magnusson + * Jeremy Mikola + * Derick Rethans + * Samantha Ritter + * Yuchen Xie + * Lloyd Zhou + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.1.11 +===================== + +It is my pleasure to announce to you the MongoDB C driver 1.1.11. + +This is a patch release with bug fixes: + + * Undetected network errors when sending messages to the server + * Off-by-one error in mongoc_gridfs_file_seek with mode SEEK_END + * Memory leak parsing a URI that contains an invalid option + * The libbson submodule's URL now uses the recommended https://, not git:// + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + + * A. Jesse Jiryu Davis + * Hannes Magnusson + * Jason Carey + * Jose Sebastian Battig + * rubicks + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.1.10 +===================== + +It is my pleasure to announce to you the MongoDB C driver 1.1.10. + +This is a patch release with bug fixes: + + * Occasional crash reconnecting to replica set. + * Queries sent to recovering replica set members. + * Memory leak when calling ismaster on replica set members. + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + + * A. Jesse Jiryu Davis + * Daniil Zaitsev + * Jason Carey + * Jeremy Mikola + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.1.9 +==================== + +It is my pleasure to announce to you the MongoDB C driver 1.1.9. + +This release fixes a common crash in 1.1.8, which itself was introduced while +fixing a rare crash in 1.1.7. For further details: + +https://jira.mongodb.org/browse/CDRIVER-721 +https://jira.mongodb.org/browse/CDRIVER-695 + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.1.8 +==================== + +UPDATE: 1.1.8 suffered a severe new bug so I removed the release from GitHub: + +https://jira.mongodb.org/browse/CDRIVER-721 + +This is a patch release with bug fixes: + + * Crash freeing client after a replica set auth error. + * Compile error strict C89 mode. + +mongo-c-driver 1.1.7 +==================== + +It is my pleasure to announce to you the 1.1.7 release of the MongoDB C driver. + +This is a patch release with bug fixes: + + * Thread-safe use of Cyrus SASL library. + * Experimental support for building with CMake and SASL. + * Faster reconnection to replica set with some hosts down. + * Crash iterating a cursor after reconnecting to a replica set. + * Unchecked errors decoding invalid UTF-8 in MongoDB URIs. + * Fix error reporting from mongoc_client_get_database_names. + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + + * A. Jesse Jiryu Davis + * Jason Carey + * Hannes Magnusson + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.1.6 +==================== + +It is my pleasure to announce to you the 1.1.6 release of the MongoDB C driver. + +This is a patch release with performance enhancements and bug fixes: + + * mongoc_bulk_operation_execute now coalesces consecutive update operations + into a single message to a MongoDB 2.6+ server, yielding huge performance + gains. Same for remove operations. (Inserts were always coalesced.) + * Large numbers of insert operations are now properly batched according to + number of documents and total data size. + * GSSAPI / Kerberos auth now works. + * The driver no longer tries three times in vain to reconnect to a primary, + so socketTimeoutMS and connectTimeoutMS now behave *closer* to what you + expect for replica sets with down members. A full fix awaits 1.2.0. + +I snuck in a feature: + + * mongoc_matcher_t now supports basic subdocument and array matching + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + + * A. Jesse Jiryu Davis + * Jason Carey + * Kai Mast + * Matt Cotter + +Peace, + + A. Jesse Jiryu Davis + + +mongo-c-driver 1.1.5 +==================== + +It is my pleasure to announce to you the 1.1.5 release of the MongoDB C driver. + +This is a patch release with performance enhancements and bug fixes: + + * The fsync and j write concern flags now imply acknowledged writes + * Prevent using fsync or j with conflicting w=0 write concern + * Obey socket timeout consistently in TLS/SSL mode + * Return an error promptly after a network hangup in TLS mode + * Prevent crash using SSL in FIPS mode + * Always return NULL from mongoc_database_get_collection_names on error + * Fix version check for GCC 5 and future versions of Clang + * Fix warnings and errors building on various platforms + * Add configure flag to enable/disable shared memory performance counters + * Minor docs improvements and fix links from C Driver docs to Libbson docs + +With this release, Libbson abandons the convention that odd-numbered patch +versions indicate unstable releases. We switch to simple semantic versioning: +1.1.5 is a stable release with bug fixes since 1.1.4. During subsequent +development the version will be "1.1.6-dev". + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + + * A. Jesse Jiryu Davis + * Christian Hergert + * Jason Carey + * Jeremy Mikola + * Jeroen Ooms + * Hannes Magnusson + +Enjoy! + +-- A. Jesse Jiryu Davis + + +mongo-c-driver 1.1.4 +==================== + +It is my pleasure to announce to you the 1.1.4 release of the MongoDB C driver. + +This release is a stable release with performance enhancements and bugfixes. + +Changes include: + * Fixed client pool concurrency issues + * Fixed some scenarios where replica sets would fail to reconnect on primary + step down. + * Improved write concern handling + * Validate port number in URI + * Various other fixes + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + + * Jason Carey + * Andrew Clayton + * A. Jesse Jiryu Davis + * Jeremy Mikola + +Enjoy! + +-- Jason Carey + + +mongo-c-driver 1.1.2 +==================== + +It is my pleasure to announce to you the 1.1.2 release of the MongoDB C driver. + +This release is a stable release with performance enhancements and bugfixes. + +Changes include: + * Process connectTimeoutMS cast insensitively + * Addition of missing trace macros + * Improvement of internal error messages + * Fix a segfault in OpenSSL cleanup routines + * Fix for IPv6 support for replica sets + * Coalesce small vectorized TLS writes + * MinGW fixups + * Fix for a memory leak in get_database_names() + * Fixes for patching write concern through the bulk api + * Fix to normalize hostnames in uri parsing + * Fix for managing connections in the client pool + * Various other fixes + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + + * Andrew Clayton + * Denis Gladkikh + * Hannes Magnusson + * Jason Carey + * Jeremy Mikola + * mschoenlaub + * Samantha Ritter + * Tyler Brock + +Enjoy! + +-- Jason Carey + + +mongo-c-driver 1.1.0 +==================== + +It is my pleasure to announce to you the 1.1.0 release of the MongoDB C driver. + +This release is a stable release with additive ABI changes and bugfixes. + +The below changes include some carried over from RC0. + +Changes include: + * RC0 + * ABI versioning for 1.1 versus 1.0 symbols + * additional geo index options + * authMechanismProperties in URI + * fixes for OS X Yosemite + * removal of replica set member limit + * SCRAM-SHA-1 SASL mechanism + * updated dependency on libbson 1.1 abi + * validation for bulk insert + * various memory leak fixes + * Fixes to documentation typos + * "How to Ask For Help" in the README + * Removed dependency on sasl for PLAIN authentication + * Use provided username, if available, for X.509 auth + * Fixed WriteConcern error reporting for some writes + * Check for closed sockets before attempting RPCs + * Fixes for gridfs file seek + * Fixes for mongoc_cursor_clone() + * Fixes for unix domain socket support + * Fixes for polling on win32 + * Improved warnings on failure to connect + * Addition of wired tiger options + * Fixes for examples + +Additions to the ABI include: + * support for extra option in count + - mongoc_collection_count_with_opts + * additional index options + - mongoc_index_opt_geo_get_default + - mongoc_index_opt_geo_init + - mongoc_index_opt_wt_get_default + - mongoc_index_opt_wt_init + * rand interface to seed and verify the strong random number generation needed + by some auth mechanisms + - mongoc_rand_seed + - mongoc_rand_add + - mongoc_rand_status + * URI additions to support more complicated auth credentials + - mongoc_uri_get_credentials + - mongoc_uri_get_mechanism_properties + * Support for cursor returning metadata crud operations + - mongoc_client_find_databases + - mongoc_collection_find_indexes + - mongoc_database_find_collections + * Kill cursor support + - mongoc_client_kill_cursor + * Various get/setters on cursor + - mongoc_cursor_get_batch_size + - mongoc_cursor_get_id + - mongoc_cursor_set_batch_size + * More socket/stream options + - mongoc_socket_check_closed + - mongoc_socket_inet_ntop + - mongoc_stream_check_closed + - mongoc_stream_write + +Additional Notes: + Existing complex index names may contain a zero instead of a type due to +a bug in mongoc_collection_keys_to_index_string. As a result those indexes may +be hard to drop from the driver as they have a name you would not expect. + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + + * Adam Midvidy + * aherlihy + * alexeyvo + * Christian Hergert + * Hannes Magnusson + * Jason Carey + * Jérôme Lebel + * Jesse Jiryu Davis + * lloydzhou + * Mark Benevenuto + * Paul Melnikow + * Samantha Ritter + * Shraya Ramani + * Spencer Jackson + * Tyler Brock + + +Enjoy! + +-- Jason Carey + + +mongo-c-driver 1.1.0-rc0 +======================== + +It is my pleasure to announce to you the 1.1.0-rc0 release of the MongoDB C driver. + +This release is a release candidate with additive ABI changes and bugfixes. + +Changes include: + * ABI versioning for 1.1 versus 1.0 symbols + * additional geo index options + * authMechanismProperties in URI + * fixes for OS X Yosemite + * removal of replica set member limit + * SCRAM-SHA-1 SASL mechanism + * updated dependency on libbson 1.1 abi + * validation for bulk insert + * various memory leak fixes + +Additions to the ABI include: + * support for extra option in count + - mongoc_collection_count_with_opts + * extra index and collection info + - mongoc_collection_get_index_info + - mongoc_database_get_collection_info + * additional geo options + - mongoc_index_opt_geo_get_default + - mongoc_index_opt_geo_init + * rand interface to seed and verify the strong random number generation needed + by some auth mechanisms + - mongoc_rand_seed + - mongoc_rand_add + - mongoc_rand_status + * URI additions to support more complicated auth credentials + - mongoc_uri_get_credentials + - mongoc_uri_get_mechanism_properties + +Additional Notes: + Existing complex index names may contain a zero instead of a type due to +a bug in mongoc_collection_keys_to_index_string. As a result those indexes may +be hard to drop from the driver as they have a name you would not expect. + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + + * Adam Midvidy + * aherlihy + * alexeyvo + * Christian Hergert + * Jason Carey + * Jérôme Lebel + * Samantha Ritter + * Spencer Jackson + * Tyler Brock + + +Enjoy! + +-- Jason Carey + + +mongo-c-driver 1.0.2 +==================== + +It is my pleasure to announce to you the 1.0.2 release of the MongoDB C driver. + +This release is a minor point release with no ABI changes and mostly small +bugfixes. + +Changes include: + * A variety of fixes for read preference based node selection + * Avoided inclusion of getLastError in 2.6 writeConcern + * Correct handling of pass through params for collection_aggregate + * Improved error reporting in socket connect + * Public MONGOC_DEFAULT_CONNECTTIMEOUTMS + +Thanks to everyone who contributed to the development of this point release for +libmongoc. + + * Adam Midvidy + * Christian Hergert + * Denis Gladkikh + * Jason Carey + * Jeremy Mikola + * Jérôme Lebel + * Tyler Brock + * Wisdom Omuya + +-- Jason Carey + + +mongo-c-driver 1.0.0 +==================== + +It is my very distinct pleasure to announce to you the 1.0 release of +the MongoDB C driver! + +This is the culmination of just over a year of work and could not have +been done without the help of our wonderful community. + +Thanks to everyone who contributed to the development of this driver! + + * Christian Hergert + * Jason Carey + * Gary Murakami + * Christian Heckl + * Frank Watson Song + * Hannes Magnusson + * JeÌroÌ‚me Lebel + * Kyle Suarez + * Maga Napanga + * Michael Kuhn + * Vincent Giersch + * essentia44 + * yuqing + +Happy Hacking! + +-- Christian Hergert + + +mongo-c-driver 0.98.2 +===================== + +One final step before our journey to 1.0! + +This is a relatively small release, adding some features needed for drivers +building on top of the C driver. + +A new libmongoc-priv.so library is installed that does not have symbols +hidden. You can access private headers via the -private.h variants. This +means you will need to recompile your project every time the library is +changed (if you use those private headers, as they are subject to change). + +A special thanks to Hannes Magnusson for patches in this release. + +See `git shortlog 0.98.0..0.98.2` for a list of all the changes. + +-- Christian Hergert + + +mongo-c-driver 0.98.0 +===================== + +Another step in the rapidly approaching path to 1.0! + +This release is primarily a bugfix release and stablization effort as we +approach 1.0 of the MongoDB C driver. + +This release requires 0.98.0 of Libbson for improvements to the memory +management system. You can now setup custom memory allocators at the +start of the process. + +This is a RC release that with a few improvements will likely become 1.0. + +A special thanks to the following for patches in this cycle: + + * Kyle Suarez + * yuqing + +See `git shortlog 0.96.4..0.98.0` for a list of all the changes. + +-- Christian Hergert + + +mongo-c-driver 0.96.4 +===================== + +Another incremental feature update and bugfix release! + +In this release, you will find the following changes: + + * build/mci.sh script for automatically building Debian packages, RPMs, and + Solaris packaging based on the host operating system. + * Various libbson improvements, now depending on 0.8.4. + * Alignment fixes for Solaris Studio C compiler via libbson. + * Addition of mongoc_gridfs_remove_by_filename() for removing a file from + gridfs by filename. + * client command functions can now take a fully qualified namespace. + * collections can now support names that indicate a command namespace. + * Commands will no longer fail if they do not contain an "ok" field. + * OP_QUERY will now set the slaveOk bit in the wire protocol if + * readPreferences are set to non-PRIMARY. + * Various documentation and build fixes. + +Thanks again to all the contributors, and happy hacking! + + +mongo-c-driver 0.96.2 +===================== + +Hot on the heels of 0.96.0 we would like to present mongo-c-driver 0.96.2! + +This is primarily a bugfix release. Included in this release are: + + * Ensure batchSize is used in cursor GETMORE operations with `aggregate`. + * Ensure enough buffer space is allocated for incoming RPC when buffering + from a stream. + * Require libbson 0.8.2 for more robust `bson_next_power_of_two()` when + using `size_t` and BCON compilation fix with C++. + * Handle cursor id's that are not 64-bit values in response from + `aggregate` command. + * Handle upsert on MongoDB < 2.6 when _id does not contain an `ObjectId`. + * Use 100 for default batchSize in `aggregate` command. + +Happy Hacking! + + +mongo-c-driver 0.96.0 +===================== + +It's that time again, time for another mongo-c-driver release! + +This release includes much new documentation, which can be found at +https://www.mongodb.com/docs/ecosystem/drivers/c/. + +Additionally, this release improves support for various exotic systems. +Solaris 10 is supported much better on SPARC and x86_64 based systems. + +Some workarounds for mixed-mode sharded-clusters have been added to improve +resiliency when rolling upgrades are performed. + +Build improvements have been added to help us detect SASL and SSL +implementations on platforms that do not support pkg-config. This should +simplify building for some of you. + +We've added some more logging to SASL authentication to help debug +authentication failures. + +A bug causing an abort() when SSL is used and a server is down has been fixed. + +We've renamed various _delete() functions to _remove() to provide consistency +with other MongoDB drivers. + +You can now specify SSL options for client pools. + +-D_REENTRANT is always defined now on Solaris to help with errno detection. +This may not have been done before if using a non-GCC platform with pthreads. + +A bug was fixed where timeouts could have been 1000x longer than expected +due to failure to convert from microseconds to milliseconds. + +A bug was fixed with authentication in sharded cluster and replica set +scenarios. + +Happy Hacking! + + +mongo-c-driver 0.94.2 +===================== + +Hot on the heels of 0.94.0 is 0.94.2, a bugfix release. + +A bug has been fixed when using TLS streams and large result sets. + +In this release, we added support for Sun's C compiler (Sun Pro C) on Solaris. +This allows for builds on Solaris 10 with SPARC using the native toolchain. + +This release contains a couple of fixes in libbson as well. + +Keep those bug reports coming, and as always, Happy Hacking! + + +mongo-c-driver 0.94.0 +===================== + +The mongo-c-driver team is proud to announce the release of 0.94.0. This +release is a followup to the previous release adding more features to be found +in MongoDB 2.6. + +You will find some new API's, bug fixes, and more documentation. Under the +hood, 0.94.0 uses the new write-commands as part of MongoDB 2.6 when it +discovers it is communicating with a MongoDB server. There is now a bulk +operation API (See `mongoc-bulk-operation.h`). + +Helpers for common server commands have been added. You can find most of +them `mongoc-collection.h`. + +To simply using mongo-c-driver from Windows, we've included pre-built binaries +on the release page. + +Thanks to all of the contributors this release! + +Happy Hacking! + + +mongo-c-driver 0.92.0 +===================== + +The mongo-c-driver team is proud to announce the release of 0.92.0. This +release is the culimation of a few months work and has many bug fixes and +new features. It contains over 350 commits from 4 authors since the 0.90.0 +release. + +The mongo-c-driver release tarballs now contain a bundled copy of libbson. +If you do not have libbson installed or the system installed libbson is too +old, the bundled copy of libbson will be installed. + + * Revamped build system to simplify installation. + * Windows Vista and newer support. + * Various GridFS fixes and features. + * Kerberos support via cyrus-sasl. + * Various SSL improvements. + * Support for Solaris 11, FreeBSD 10, RHEL 5+, and SmartOS. + * A new client side expression matcher to perform basic query processing. + It can perform queries such as {'field': {'$in': [1,2,3]}}. See + mongoc_matcher_t for more information. + * A new socket abstraction for platform independent network sockets. + * A new mongoc-dump example for how to write a simple mongodump replacement. + * Counters can use rdtscp instruction on Core iX systems for very fast + counters. + * configure has new options. If in doubt, the defaults are sensible. + * --enable-coverage=yes|no + * --enable-debug=yes|no + * --enable-debug-symbols=yes|no + * --enable-hardening=yes|no + * --enable-optimizations=yes|no + * --enable-ssl=yes|no + * --enable-sasl=yes|no + * --enable-tracing=yes|no + * --with-libbson=auto|system|bundled + +mongo-c-driver 0.92.0 requires libbson 0.6.4 or newer. + +Happy Hacking! + + +Libmongoc 0.90.0 +================ + +This is the initial release of the new Libmongoc. We chose 0.90.0 for the +release version to differentiate ourselves from the, now legacy, version of +libmongoc. We will rapidly work towards reaching an API/ABI stable library fit +for a 1.0.0 release. + +Libmongoc is Apache licensed so it can be embedded in a multitude of scenarios. + +The API of 0.90.0 is completely different from the previous versions. We think +this allowed us to create a high-quality library that you will enjoy using in +your applications. + +Many outstanding bugs were closed in the process of creating Libbson 0.90.0. So +if you had a pet issue, please take a look to see if it was resolved as part of +this effort! + +Thanks, and enjoy developing your applications with libmongoc! diff --git a/3rdparty/mongo-c-driver-1.26.2/README.rst b/3rdparty/mongo-c-driver-2.1.0/README.rst similarity index 88% rename from 3rdparty/mongo-c-driver-1.26.2/README.rst rename to 3rdparty/mongo-c-driver-2.1.0/README.rst index 6b615d1b7..fb1d3e041 100644 --- a/3rdparty/mongo-c-driver-1.26.2/README.rst +++ b/3rdparty/mongo-c-driver-2.1.0/README.rst @@ -12,12 +12,14 @@ mongo-c-driver is a project that includes two libraries: If libmongoc is not needed, it is possible to build and install only libbson. +This project uses `Semantic Versioning `_. + Documentation / Support / Feedback ================================== The documentation is available at `MongoDB C Driver Docs `_ and https://www.mongoc.org. For issues with, questions about, or feedback for libmongoc, please look into -our `support channels `_. Please +our `support channels `_. Please do not email any of the libmongoc developers directly with issues or questions - you're more likely to get an answer on the `MongoDB Community Forums`_ or `StackOverflow `_. @@ -73,7 +75,7 @@ information: Can you tell me what I need to install? Thanks! -.. _MongoDB Community Forums: https://community.mongodb.com/tags/c/drivers-odms-connectors/7/c-driver +.. _MongoDB Community Forums: https://www.mongodb.com/community/forums/tags/c/data/drivers/7/c-driver Security Vulnerabilities ------------------------ @@ -87,12 +89,12 @@ Installation ============ Detailed installation instructions are in the manual: -https://www.mongoc.org/libmongoc/current/installing.html +https://www.mongodb.com/docs/languages/c/c-driver/current/libmongoc/tutorials/obtaining-libraries/ Resources ============ -* `Getting Started Tutorial `_. +* `Getting Started Tutorial `_. * `MongoDB C Driver Examples `_. -* Tutorials, videos, and code examples using the MongoDB C Driver can also be found in the `MongoDB Developer Center `_. \ No newline at end of file +* Tutorials, videos, and code examples using the MongoDB C Driver can also be found in the `MongoDB Developer Center `_. diff --git a/3rdparty/mongo-c-driver-2.1.0/THIRD_PARTY_NOTICES b/3rdparty/mongo-c-driver-2.1.0/THIRD_PARTY_NOTICES new file mode 100644 index 000000000..dbab9f4dc --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/THIRD_PARTY_NOTICES @@ -0,0 +1,184 @@ +The MongoDB C Driver uses third-party code distributed under different licenses. + +License notice for uthash +------------------------------------------------------------------------------- + +Copyright (c) 2003-2021, Troy D. Hanson http://troydhanson.github.com/uthash/ +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for common-b64.c +------------------------------------------------------------------------------- + +ISC License + +Copyright: 1996, 1998 Internet Software Consortium + 1995 International Business Machines, Inc. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +Portions Copyright (c) 1995 by International Business Machines, Inc. + +International Business Machines, Inc. (hereinafter called IBM) grants +permission under its copyrights to use, copy, modify, and distribute this +Software with or without fee, provided that the above copyright notice and +all paragraphs of this notice appear in all copies, and that the name of IBM +not be used in connection with the marketing of any product incorporating +the Software or modifications thereof, without specific, written prior +permission. + +To the extent it has a right to do so, IBM grants an immunity from suit +under its patents, if any, for the use, sale or manufacture of products to +the extent that such products are used for performing Domain Name System +dynamic updates in TCP/IP networks by means of the Software. No immunity is +granted for any product per se or for any other function of any product. + +THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, +DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING +OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN +IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +License notice for mongoc.css_t +------------------------------------------------------------------------------- + +MIT License + +Portions Copyright 2013 by Ignacy Sokolowski. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +License notice for zlib +------------------------------------------------------------------------------- +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.11, January 15th, 2017 + + Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 + (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). +*/ + +License notice for common-md5.c +------------------------------------------------------------------------------- + +ZLib License + +Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + +L. Peter Deutsch +ghost@aladdin.com + +License notice for utf8proc +------------------------------------------------------------------------------- + +**utf8proc** is a software package originally developed +by Jan Behrens and the rest of the Public Software Group, who +deserve nearly all of the credit for this library, that is now maintained by the Julia-language developers. Like the original utf8proc, +whose copyright and license statements are reproduced below, all new +work on the utf8proc library is licensed under the [MIT "expat" +license](http://opensource.org/licenses/MIT): + +*Copyright © 2014-2021 by Steven G. Johnson, Jiahao Chen, Tony Kelman, Jonas Fonseca, and other contributors listed in the git history.* + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/3rdparty/mongo-c-driver-2.1.0/VERSION_CURRENT b/3rdparty/mongo-c-driver-2.1.0/VERSION_CURRENT new file mode 100644 index 000000000..7ec1d6db4 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/VERSION_CURRENT @@ -0,0 +1 @@ +2.1.0 diff --git a/3rdparty/mongo-c-driver-1.26.2/build/.gitignore b/3rdparty/mongo-c-driver-2.1.0/build/.gitignore similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/.gitignore rename to 3rdparty/mongo-c-driver-2.1.0/build/.gitignore diff --git a/3rdparty/mongo-c-driver-2.1.0/build/bottle.py b/3rdparty/mongo-c-driver-2.1.0/build/bottle.py new file mode 100644 index 000000000..cb7dd2083 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/bottle.py @@ -0,0 +1,4680 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Bottle is a fast and simple micro-framework for small web applications. It +offers request dispatching (Routes) with URL parameter support, templates, +a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and +template engines - all in a single file and with no dependencies other than the +Python Standard Library. + +Homepage and documentation: http://bottlepy.org/ + +Copyright (c) 2009-2024, Marcel Hellkamp. +License: MIT (see LICENSE for details) +""" + +from __future__ import print_function +import sys + +__author__ = 'Marcel Hellkamp' +__version__ = '0.13.2' +__license__ = 'MIT' + +############################################################################### +# Command-line interface ###################################################### +############################################################################### +# INFO: Some server adapters need to monkey-patch std-lib modules before they +# are imported. This is why some of the command-line handling is done here, but +# the actual call to _main() is at the end of the file. + + +def _cli_parse(args): # pragma: no coverage + from argparse import ArgumentParser + + parser = ArgumentParser(prog=args[0], usage="%(prog)s [options] package.module:app") + opt = parser.add_argument + opt("--version", action="store_true", help="show version number.") + opt("-b", "--bind", metavar="ADDRESS", help="bind socket to ADDRESS.") + opt("-s", "--server", default='wsgiref', help="use SERVER as backend.") + opt("-p", "--plugin", action="append", help="install additional plugin/s.") + opt("-c", "--conf", action="append", metavar="FILE", + help="load config values from FILE.") + opt("-C", "--param", action="append", metavar="NAME=VALUE", + help="override config values.") + opt("--debug", action="store_true", help="start server in debug mode.") + opt("--reload", action="store_true", help="auto-reload on file changes.") + opt('app', help='WSGI app entry point.', nargs='?') + + cli_args = parser.parse_args(args[1:]) + + return cli_args, parser + + +def _cli_patch(cli_args): # pragma: no coverage + parsed_args, _ = _cli_parse(cli_args) + opts = parsed_args + if opts.server: + if opts.server.startswith('gevent'): + import gevent.monkey + gevent.monkey.patch_all() + elif opts.server.startswith('eventlet'): + import eventlet + eventlet.monkey_patch() + + +if __name__ == '__main__': + _cli_patch(sys.argv) + +############################################################################### +# Imports and Python 2/3 unification ########################################## +############################################################################### + +import base64, calendar, email.utils, functools, hmac, itertools,\ + mimetypes, os, re, tempfile, threading, time, warnings, weakref, hashlib + +from types import FunctionType +from datetime import date as datedate, datetime, timedelta +from tempfile import NamedTemporaryFile +from traceback import format_exc, print_exc +from unicodedata import normalize + +try: + from ujson import dumps as json_dumps, loads as json_lds +except ImportError: + from json import dumps as json_dumps, loads as json_lds + +py = sys.version_info +py3k = py.major > 2 + +# Lots of stdlib and builtin differences. +if py3k: + import http.client as httplib + import _thread as thread + from urllib.parse import urljoin, SplitResult as UrlSplitResult + from urllib.parse import urlencode, quote as urlquote, unquote as urlunquote + urlunquote = functools.partial(urlunquote, encoding='latin1') + from http.cookies import SimpleCookie, Morsel, CookieError + from collections.abc import MutableMapping as DictMixin + from types import ModuleType as new_module + import pickle + from io import BytesIO + import configparser + from datetime import timezone + UTC = timezone.utc + # getfullargspec was deprecated in 3.5 and un-deprecated in 3.6 + # getargspec was deprecated in 3.0 and removed in 3.11 + from inspect import getfullargspec + def getargspec(func): + spec = getfullargspec(func) + kwargs = makelist(spec[0]) + makelist(spec.kwonlyargs) + return kwargs, spec[1], spec[2], spec[3] + + basestring = str + unicode = str + json_loads = lambda s: json_lds(touni(s)) + callable = lambda x: hasattr(x, '__call__') + imap = map + + def _raise(*a): + raise a[0](a[1]).with_traceback(a[2]) +else: # 2.x + warnings.warn("Python 2 support will be dropped in Bottle 0.14", DeprecationWarning) + import httplib + import thread + from urlparse import urljoin, SplitResult as UrlSplitResult + from urllib import urlencode, quote as urlquote, unquote as urlunquote + from Cookie import SimpleCookie, Morsel, CookieError + from itertools import imap + import cPickle as pickle + from imp import new_module + from StringIO import StringIO as BytesIO + import ConfigParser as configparser + from collections import MutableMapping as DictMixin + from inspect import getargspec + from datetime import tzinfo + + class _UTC(tzinfo): + def utcoffset(self, dt): return timedelta(0) + def tzname(self, dt): return "UTC" + def dst(self, dt): return timedelta(0) + UTC = _UTC() + + unicode = unicode + json_loads = json_lds + + exec(compile('def _raise(*a): raise a[0], a[1], a[2]', '', 'exec')) + +# Some helpers for string/byte handling +def tob(s, enc='utf8'): + if isinstance(s, unicode): + return s.encode(enc) + return b'' if s is None else bytes(s) + + +def touni(s, enc='utf8', err='strict'): + if isinstance(s, bytes): + return s.decode(enc, err) + return unicode("" if s is None else s) + + +tonat = touni if py3k else tob + + +def _stderr(*args): + try: + print(*args, file=sys.stderr) + except (IOError, AttributeError): + pass # Some environments do not allow printing (mod_wsgi) + + +# A bug in functools causes it to break if the wrapper is an instance method +def update_wrapper(wrapper, wrapped, *a, **ka): + try: + functools.update_wrapper(wrapper, wrapped, *a, **ka) + except AttributeError: + pass + +# These helpers are used at module level and need to be defined first. +# And yes, I know PEP-8, but sometimes a lower-case classname makes more sense. + + +def depr(major, minor, cause, fix, stacklevel=3): + text = "Warning: Use of deprecated feature or API. (Deprecated in Bottle-%d.%d)\n"\ + "Cause: %s\n"\ + "Fix: %s\n" % (major, minor, cause, fix) + if DEBUG == 'strict': + raise DeprecationWarning(text) + warnings.warn(text, DeprecationWarning, stacklevel=stacklevel) + return DeprecationWarning(text) + + +def makelist(data): # This is just too handy + if isinstance(data, (tuple, list, set, dict)): + return list(data) + elif data: + return [data] + else: + return [] + + +class DictProperty(object): + """ Property that maps to a key in a local dict-like attribute. """ + + def __init__(self, attr, key=None, read_only=False): + self.attr, self.key, self.read_only = attr, key, read_only + + def __call__(self, func): + functools.update_wrapper(self, func, updated=[]) + self.getter, self.key = func, self.key or func.__name__ + return self + + def __get__(self, obj, cls): + if obj is None: return self + key, storage = self.key, getattr(obj, self.attr) + if key not in storage: storage[key] = self.getter(obj) + return storage[key] + + def __set__(self, obj, value): + if self.read_only: raise AttributeError("Read-Only property.") + getattr(obj, self.attr)[self.key] = value + + def __delete__(self, obj): + if self.read_only: raise AttributeError("Read-Only property.") + del getattr(obj, self.attr)[self.key] + + +class cached_property(object): + """ A property that is only computed once per instance and then replaces + itself with an ordinary attribute. Deleting the attribute resets the + property. """ + + def __init__(self, func): + update_wrapper(self, func) + self.func = func + + def __get__(self, obj, cls): + if obj is None: return self + value = obj.__dict__[self.func.__name__] = self.func(obj) + return value + + +class lazy_attribute(object): + """ A property that caches itself to the class object. """ + + def __init__(self, func): + functools.update_wrapper(self, func, updated=[]) + self.getter = func + + def __get__(self, obj, cls): + value = self.getter(cls) + setattr(cls, self.__name__, value) + return value + + +############################################################################### +# Exceptions and Events ####################################################### +############################################################################### + + +class BottleException(Exception): + """ A base class for exceptions used by bottle. """ + pass + +############################################################################### +# Routing ###################################################################### +############################################################################### + + +class RouteError(BottleException): + """ This is a base class for all routing related exceptions """ + + +class RouteReset(BottleException): + """ If raised by a plugin or request handler, the route is reset and all + plugins are re-applied. """ + + +class RouterUnknownModeError(RouteError): + + pass + + +class RouteSyntaxError(RouteError): + """ The route parser found something not supported by this router. """ + + +class RouteBuildError(RouteError): + """ The route could not be built. """ + + +def _re_flatten(p): + """ Turn all capturing groups in a regular expression pattern into + non-capturing groups. """ + if '(' not in p: + return p + return re.sub(r'(\\*)(\(\?P<[^>]+>|\((?!\?))', lambda m: m.group(0) if + len(m.group(1)) % 2 else m.group(1) + '(?:', p) + + +class Router(object): + """ A Router is an ordered collection of route->target pairs. It is used to + efficiently match WSGI requests against a number of routes and return + the first target that satisfies the request. The target may be anything, + usually a string, ID or callable object. A route consists of a path-rule + and a HTTP method. + + The path-rule is either a static path (e.g. `/contact`) or a dynamic + path that contains wildcards (e.g. `/wiki/`). The wildcard syntax + and details on the matching order are described in docs:`routing`. + """ + + default_pattern = '[^/]+' + default_filter = 're' + + #: The current CPython regexp implementation does not allow more + #: than 99 matching groups per regular expression. + _MAX_GROUPS_PER_PATTERN = 99 + + def __init__(self, strict=False): + self.rules = [] # All rules in order + self._groups = {} # index of regexes to find them in dyna_routes + self.builder = {} # Data structure for the url builder + self.static = {} # Search structure for static routes + self.dyna_routes = {} + self.dyna_regexes = {} # Search structure for dynamic routes + #: If true, static routes are no longer checked first. + self.strict_order = strict + self.filters = { + 're': lambda conf: (_re_flatten(conf or self.default_pattern), + None, None), + 'int': lambda conf: (r'-?\d+', int, lambda x: str(int(x))), + 'float': lambda conf: (r'-?[\d.]+', float, lambda x: str(float(x))), + 'path': lambda conf: (r'.+?', None, None) + } + + def add_filter(self, name, func): + """ Add a filter. The provided function is called with the configuration + string as parameter and must return a (regexp, to_python, to_url) tuple. + The first element is a string, the last two are callables or None. """ + self.filters[name] = func + + rule_syntax = re.compile('(\\\\*)' + '(?:(?::([a-zA-Z_][a-zA-Z_0-9]*)?()(?:#(.*?)#)?)' + '|(?:<([a-zA-Z_][a-zA-Z_0-9]*)?(?::([a-zA-Z_]*)' + '(?::((?:\\\\.|[^\\\\>])+)?)?)?>))') + + def _itertokens(self, rule): + offset, prefix = 0, '' + for match in self.rule_syntax.finditer(rule): + prefix += rule[offset:match.start()] + g = match.groups() + if g[2] is not None: + depr(0, 13, "Use of old route syntax.", + "Use instead of :name in routes.", + stacklevel=4) + if len(g[0]) % 2: # Escaped wildcard + prefix += match.group(0)[len(g[0]):] + offset = match.end() + continue + if prefix: + yield prefix, None, None + name, filtr, conf = g[4:7] if g[2] is None else g[1:4] + yield name, filtr or 'default', conf or None + offset, prefix = match.end(), '' + if offset <= len(rule) or prefix: + yield prefix + rule[offset:], None, None + + def add(self, rule, method, target, name=None): + """ Add a new rule or replace the target for an existing rule. """ + anons = 0 # Number of anonymous wildcards found + keys = [] # Names of keys + pattern = '' # Regular expression pattern with named groups + filters = [] # Lists of wildcard input filters + builder = [] # Data structure for the URL builder + is_static = True + + for key, mode, conf in self._itertokens(rule): + if mode: + is_static = False + if mode == 'default': mode = self.default_filter + mask, in_filter, out_filter = self.filters[mode](conf) + if not key: + pattern += '(?:%s)' % mask + key = 'anon%d' % anons + anons += 1 + else: + pattern += '(?P<%s>%s)' % (key, mask) + keys.append(key) + if in_filter: filters.append((key, in_filter)) + builder.append((key, out_filter or str)) + elif key: + pattern += re.escape(key) + builder.append((None, key)) + + self.builder[rule] = builder + if name: self.builder[name] = builder + + if is_static and not self.strict_order: + self.static.setdefault(method, {}) + self.static[method][self.build(rule)] = (target, None) + return + + try: + re_pattern = re.compile('^(%s)$' % pattern) + re_match = re_pattern.match + except re.error as e: + raise RouteSyntaxError("Could not add Route: %s (%s)" % (rule, e)) + + if filters: + + def getargs(path): + url_args = re_match(path).groupdict() + for name, wildcard_filter in filters: + try: + url_args[name] = wildcard_filter(url_args[name]) + except ValueError: + raise HTTPError(400, 'Path has wrong format.') + return url_args + elif re_pattern.groupindex: + + def getargs(path): + return re_match(path).groupdict() + else: + getargs = None + + flatpat = _re_flatten(pattern) + whole_rule = (rule, flatpat, target, getargs) + + if (flatpat, method) in self._groups: + if DEBUG: + msg = 'Route <%s %s> overwrites a previously defined route' + warnings.warn(msg % (method, rule), RuntimeWarning, stacklevel=3) + self.dyna_routes[method][ + self._groups[flatpat, method]] = whole_rule + else: + self.dyna_routes.setdefault(method, []).append(whole_rule) + self._groups[flatpat, method] = len(self.dyna_routes[method]) - 1 + + self._compile(method) + + def _compile(self, method): + all_rules = self.dyna_routes[method] + comborules = self.dyna_regexes[method] = [] + maxgroups = self._MAX_GROUPS_PER_PATTERN + for x in range(0, len(all_rules), maxgroups): + some = all_rules[x:x + maxgroups] + combined = (flatpat for (_, flatpat, _, _) in some) + combined = '|'.join('(^%s$)' % flatpat for flatpat in combined) + combined = re.compile(combined).match + rules = [(target, getargs) for (_, _, target, getargs) in some] + comborules.append((combined, rules)) + + def build(self, _name, *anons, **query): + """ Build an URL by filling the wildcards in a rule. """ + builder = self.builder.get(_name) + if not builder: + raise RouteBuildError("No route with that name.", _name) + try: + for i, value in enumerate(anons): + query['anon%d' % i] = value + url = ''.join([f(query.pop(n)) if n else f for (n, f) in builder]) + return url if not query else url + '?' + urlencode(query) + except KeyError as E: + raise RouteBuildError('Missing URL argument: %r' % E.args[0]) + + def match(self, environ): + """ Return a (target, url_args) tuple or raise HTTPError(400/404/405). """ + verb = environ['REQUEST_METHOD'].upper() + path = environ['PATH_INFO'] or '/' + + methods = ('PROXY', 'HEAD', 'GET', 'ANY') if verb == 'HEAD' else ('PROXY', verb, 'ANY') + + for method in methods: + if method in self.static and path in self.static[method]: + target, getargs = self.static[method][path] + return target, getargs(path) if getargs else {} + elif method in self.dyna_regexes: + for combined, rules in self.dyna_regexes[method]: + match = combined(path) + if match: + target, getargs = rules[match.lastindex - 1] + return target, getargs(path) if getargs else {} + + # No matching route found. Collect alternative methods for 405 response + allowed = set([]) + nocheck = set(methods) + for method in set(self.static) - nocheck: + if path in self.static[method]: + allowed.add(method) + for method in set(self.dyna_regexes) - allowed - nocheck: + for combined, rules in self.dyna_regexes[method]: + match = combined(path) + if match: + allowed.add(method) + if allowed: + allow_header = ",".join(sorted(allowed)) + raise HTTPError(405, "Method not allowed.", Allow=allow_header) + + # No matching route and no alternative method found. We give up + raise HTTPError(404, "Not found: " + repr(path)) + + +class Route(object): + """ This class wraps a route callback along with route specific metadata and + configuration and applies Plugins on demand. It is also responsible for + turning an URL path rule into a regular expression usable by the Router. + """ + + def __init__(self, app, rule, method, callback, + name=None, + plugins=None, + skiplist=None, **config): + #: The application this route is installed to. + self.app = app + #: The path-rule string (e.g. ``/wiki/``). + self.rule = rule + #: The HTTP method as a string (e.g. ``GET``). + self.method = method + #: The original callback with no plugins applied. Useful for introspection. + self.callback = callback + #: The name of the route (if specified) or ``None``. + self.name = name or None + #: A list of route-specific plugins (see :meth:`Bottle.route`). + self.plugins = plugins or [] + #: A list of plugins to not apply to this route (see :meth:`Bottle.route`). + self.skiplist = skiplist or [] + #: Additional keyword arguments passed to the :meth:`Bottle.route` + #: decorator are stored in this dictionary. Used for route-specific + #: plugin configuration and meta-data. + self.config = app.config._make_overlay() + self.config.load_dict(config) + + @cached_property + def call(self): + """ The route callback with all plugins applied. This property is + created on demand and then cached to speed up subsequent requests.""" + return self._make_callback() + + def reset(self): + """ Forget any cached values. The next time :attr:`call` is accessed, + all plugins are re-applied. """ + self.__dict__.pop('call', None) + + def prepare(self): + """ Do all on-demand work immediately (useful for debugging).""" + self.call + + def all_plugins(self): + """ Yield all Plugins affecting this route. """ + unique = set() + for p in reversed(self.app.plugins + self.plugins): + if True in self.skiplist: break + name = getattr(p, 'name', False) + if name and (name in self.skiplist or name in unique): continue + if p in self.skiplist or type(p) in self.skiplist: continue + if name: unique.add(name) + yield p + + def _make_callback(self): + callback = self.callback + for plugin in self.all_plugins(): + try: + if hasattr(plugin, 'apply'): + callback = plugin.apply(callback, self) + else: + callback = plugin(callback) + except RouteReset: # Try again with changed configuration. + return self._make_callback() + if callback is not self.callback: + update_wrapper(callback, self.callback) + return callback + + def get_undecorated_callback(self): + """ Return the callback. If the callback is a decorated function, try to + recover the original function. """ + func = self.callback + func = getattr(func, '__func__' if py3k else 'im_func', func) + closure_attr = '__closure__' if py3k else 'func_closure' + while hasattr(func, closure_attr) and getattr(func, closure_attr): + attributes = getattr(func, closure_attr) + func = attributes[0].cell_contents + + # in case of decorators with multiple arguments + if not isinstance(func, FunctionType): + # pick first FunctionType instance from multiple arguments + func = filter(lambda x: isinstance(x, FunctionType), + map(lambda x: x.cell_contents, attributes)) + func = list(func)[0] # py3 support + return func + + def get_callback_args(self): + """ Return a list of argument names the callback (most likely) accepts + as keyword arguments. If the callback is a decorated function, try + to recover the original function before inspection. """ + return getargspec(self.get_undecorated_callback())[0] + + def get_config(self, key, default=None): + """ Lookup a config field and return its value, first checking the + route.config, then route.app.config.""" + depr(0, 13, "Route.get_config() is deprecated.", + "The Route.config property already includes values from the" + " application config for missing keys. Access it directly.") + return self.config.get(key, default) + + def __repr__(self): + cb = self.get_undecorated_callback() + return '<%s %s -> %s:%s>' % (self.method, self.rule, cb.__module__, cb.__name__) + +############################################################################### +# Application Object ########################################################### +############################################################################### + + +class Bottle(object): + """ Each Bottle object represents a single, distinct web application and + consists of routes, callbacks, plugins, resources and configuration. + Instances are callable WSGI applications. + + :param catchall: If true (default), handle all exceptions. Turn off to + let debugging middleware handle exceptions. + """ + + @lazy_attribute + def _global_config(cls): + cfg = ConfigDict() + cfg.meta_set('catchall', 'validate', bool) + return cfg + + def __init__(self, **kwargs): + #: A :class:`ConfigDict` for app specific configuration. + self.config = self._global_config._make_overlay() + self.config._add_change_listener( + functools.partial(self.trigger_hook, 'config')) + + self.config.update({ + "catchall": True + }) + + if kwargs.get('catchall') is False: + depr(0, 13, "Bottle(catchall) keyword argument.", + "The 'catchall' setting is now part of the app " + "configuration. Fix: `app.config['catchall'] = False`") + self.config['catchall'] = False + if kwargs.get('autojson') is False: + depr(0, 13, "Bottle(autojson) keyword argument.", + "The 'autojson' setting is now part of the app " + "configuration. Fix: `app.config['json.enable'] = False`") + self.config['json.disable'] = True + + self._mounts = [] + + #: A :class:`ResourceManager` for application files + self.resources = ResourceManager() + + self.routes = [] # List of installed :class:`Route` instances. + self.router = Router() # Maps requests to :class:`Route` instances. + self.error_handler = {} + + # Core plugins + self.plugins = [] # List of installed plugins. + self.install(JSONPlugin()) + self.install(TemplatePlugin()) + + #: If true, most exceptions are caught and returned as :exc:`HTTPError` + catchall = DictProperty('config', 'catchall') + + __hook_names = 'before_request', 'after_request', 'app_reset', 'config' + __hook_reversed = {'after_request'} + + @cached_property + def _hooks(self): + return dict((name, []) for name in self.__hook_names) + + def add_hook(self, name, func): + """ Attach a callback to a hook. Three hooks are currently implemented: + + before_request + Executed once before each request. The request context is + available, but no routing has happened yet. + after_request + Executed once after each request regardless of its outcome. + app_reset + Called whenever :meth:`Bottle.reset` is called. + """ + if name in self.__hook_reversed: + self._hooks[name].insert(0, func) + else: + self._hooks[name].append(func) + + def remove_hook(self, name, func): + """ Remove a callback from a hook. """ + if name in self._hooks and func in self._hooks[name]: + self._hooks[name].remove(func) + return True + + def trigger_hook(self, __name, *args, **kwargs): + """ Trigger a hook and return a list of results. """ + return [hook(*args, **kwargs) for hook in self._hooks[__name][:]] + + def hook(self, name): + """ Return a decorator that attaches a callback to a hook. See + :meth:`add_hook` for details.""" + + def decorator(func): + self.add_hook(name, func) + return func + + return decorator + + def _mount_wsgi(self, prefix, app, **options): + segments = [p for p in prefix.split('/') if p] + if not segments: + raise ValueError('WSGI applications cannot be mounted to "/".') + path_depth = len(segments) + + def mountpoint_wrapper(): + try: + request.path_shift(path_depth) + rs = HTTPResponse([]) + + def start_response(status, headerlist, exc_info=None): + if exc_info: + _raise(*exc_info) + if py3k: + # Errors here mean that the mounted WSGI app did not + # follow PEP-3333 (which requires latin1) or used a + # pre-encoding other than utf8 :/ + status = status.encode('latin1').decode('utf8') + headerlist = [(k, v.encode('latin1').decode('utf8')) + for (k, v) in headerlist] + rs.status = status + for name, value in headerlist: + rs.add_header(name, value) + return rs.body.append + + body = app(request.environ, start_response) + rs.body = itertools.chain(rs.body, body) if rs.body else body + return rs + finally: + request.path_shift(-path_depth) + + options.setdefault('skip', True) + options.setdefault('method', 'PROXY') + options.setdefault('mountpoint', {'prefix': prefix, 'target': app}) + options['callback'] = mountpoint_wrapper + + self.route('/%s/<:re:.*>' % '/'.join(segments), **options) + if not prefix.endswith('/'): + self.route('/' + '/'.join(segments), **options) + + def _mount_app(self, prefix, app, **options): + if app in self._mounts or '_mount.app' in app.config: + depr(0, 13, "Application mounted multiple times. Falling back to WSGI mount.", + "Clone application before mounting to a different location.") + return self._mount_wsgi(prefix, app, **options) + + if options: + depr(0, 13, "Unsupported mount options. Falling back to WSGI mount.", + "Do not specify any route options when mounting bottle application.") + return self._mount_wsgi(prefix, app, **options) + + if not prefix.endswith("/"): + depr(0, 13, "Prefix must end in '/'. Falling back to WSGI mount.", + "Consider adding an explicit redirect from '/prefix' to '/prefix/' in the parent application.") + return self._mount_wsgi(prefix, app, **options) + + self._mounts.append(app) + app.config['_mount.prefix'] = prefix + app.config['_mount.app'] = self + for route in app.routes: + route.rule = prefix + route.rule.lstrip('/') + self.add_route(route) + + def mount(self, prefix, app, **options): + """ Mount an application (:class:`Bottle` or plain WSGI) to a specific + URL prefix. Example:: + + parent_app.mount('/prefix/', child_app) + + :param prefix: path prefix or `mount-point`. + :param app: an instance of :class:`Bottle` or a WSGI application. + + Plugins from the parent application are not applied to the routes + of the mounted child application. If you need plugins in the child + application, install them separately. + + While it is possible to use path wildcards within the prefix path + (:class:`Bottle` childs only), it is highly discouraged. + + The prefix path must end with a slash. If you want to access the + root of the child application via `/prefix` in addition to + `/prefix/`, consider adding a route with a 307 redirect to the + parent application. + """ + + if not prefix.startswith('/'): + raise ValueError("Prefix must start with '/'") + + if isinstance(app, Bottle): + return self._mount_app(prefix, app, **options) + else: + return self._mount_wsgi(prefix, app, **options) + + def merge(self, routes): + """ Merge the routes of another :class:`Bottle` application or a list of + :class:`Route` objects into this application. The routes keep their + 'owner', meaning that the :data:`Route.app` attribute is not + changed. """ + if isinstance(routes, Bottle): + routes = routes.routes + for route in routes: + self.add_route(route) + + def install(self, plugin): + """ Add a plugin to the list of plugins and prepare it for being + applied to all routes of this application. A plugin may be a simple + decorator or an object that implements the :class:`Plugin` API. + """ + if hasattr(plugin, 'setup'): plugin.setup(self) + if not callable(plugin) and not hasattr(plugin, 'apply'): + raise TypeError("Plugins must be callable or implement .apply()") + self.plugins.append(plugin) + self.reset() + return plugin + + def uninstall(self, plugin): + """ Uninstall plugins. Pass an instance to remove a specific plugin, a type + object to remove all plugins that match that type, a string to remove + all plugins with a matching ``name`` attribute or ``True`` to remove all + plugins. Return the list of removed plugins. """ + removed, remove = [], plugin + for i, plugin in list(enumerate(self.plugins))[::-1]: + if remove is True or remove is plugin or remove is type(plugin) \ + or getattr(plugin, 'name', True) == remove: + removed.append(plugin) + del self.plugins[i] + if hasattr(plugin, 'close'): plugin.close() + if removed: self.reset() + return removed + + def reset(self, route=None): + """ Reset all routes (force plugins to be re-applied) and clear all + caches. If an ID or route object is given, only that specific route + is affected. """ + if route is None: routes = self.routes + elif isinstance(route, Route): routes = [route] + else: routes = [self.routes[route]] + for route in routes: + route.reset() + if DEBUG: + for route in routes: + route.prepare() + self.trigger_hook('app_reset') + + def close(self): + """ Close the application and all installed plugins. """ + for plugin in self.plugins: + if hasattr(plugin, 'close'): plugin.close() + + def run(self, **kwargs): + """ Calls :func:`run` with the same parameters. """ + run(self, **kwargs) + + def match(self, environ): + """ Search for a matching route and return a (:class:`Route`, urlargs) + tuple. The second value is a dictionary with parameters extracted + from the URL. Raise :exc:`HTTPError` (404/405) on a non-match.""" + return self.router.match(environ) + + def get_url(self, routename, **kargs): + """ Return a string that matches a named route """ + scriptname = request.environ.get('SCRIPT_NAME', '').strip('/') + '/' + location = self.router.build(routename, **kargs).lstrip('/') + return urljoin(urljoin('/', scriptname), location) + + def add_route(self, route): + """ Add a route object, but do not change the :data:`Route.app` + attribute.""" + self.routes.append(route) + self.router.add(route.rule, route.method, route, name=route.name) + if DEBUG: route.prepare() + + def route(self, + path=None, + method='GET', + callback=None, + name=None, + apply=None, + skip=None, **config): + """ A decorator to bind a function to a request URL. Example:: + + @app.route('/hello/') + def hello(name): + return 'Hello %s' % name + + The ```` part is a wildcard. See :class:`Router` for syntax + details. + + :param path: Request path or a list of paths to listen to. If no + path is specified, it is automatically generated from the + signature of the function. + :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of + methods to listen to. (default: `GET`) + :param callback: An optional shortcut to avoid the decorator + syntax. ``route(..., callback=func)`` equals ``route(...)(func)`` + :param name: The name for this route. (default: None) + :param apply: A decorator or plugin or a list of plugins. These are + applied to the route callback in addition to installed plugins. + :param skip: A list of plugins, plugin classes or names. Matching + plugins are not installed to this route. ``True`` skips all. + + Any additional keyword arguments are stored as route-specific + configuration and passed to plugins (see :meth:`Plugin.apply`). + """ + if callable(path): path, callback = None, path + plugins = makelist(apply) + skiplist = makelist(skip) + + def decorator(callback): + if isinstance(callback, basestring): callback = load(callback) + for rule in makelist(path) or yieldroutes(callback): + for verb in makelist(method): + verb = verb.upper() + route = Route(self, rule, verb, callback, + name=name, + plugins=plugins, + skiplist=skiplist, **config) + self.add_route(route) + return callback + + return decorator(callback) if callback else decorator + + def get(self, path=None, method='GET', **options): + """ Equals :meth:`route`. """ + return self.route(path, method, **options) + + def post(self, path=None, method='POST', **options): + """ Equals :meth:`route` with a ``POST`` method parameter. """ + return self.route(path, method, **options) + + def put(self, path=None, method='PUT', **options): + """ Equals :meth:`route` with a ``PUT`` method parameter. """ + return self.route(path, method, **options) + + def delete(self, path=None, method='DELETE', **options): + """ Equals :meth:`route` with a ``DELETE`` method parameter. """ + return self.route(path, method, **options) + + def patch(self, path=None, method='PATCH', **options): + """ Equals :meth:`route` with a ``PATCH`` method parameter. """ + return self.route(path, method, **options) + + def error(self, code=500, callback=None): + """ Register an output handler for a HTTP error code. Can + be used as a decorator or called directly :: + + def error_handler_500(error): + return 'error_handler_500' + + app.error(code=500, callback=error_handler_500) + + @app.error(404) + def error_handler_404(error): + return 'error_handler_404' + + """ + + def decorator(callback): + if isinstance(callback, basestring): callback = load(callback) + self.error_handler[int(code)] = callback + return callback + + return decorator(callback) if callback else decorator + + def default_error_handler(self, res): + return tob(template(ERROR_PAGE_TEMPLATE, e=res, template_settings=dict(name='__ERROR_PAGE_TEMPLATE'))) + + def _handle(self, environ): + path = environ['bottle.raw_path'] = environ['PATH_INFO'] + if py3k: + environ['PATH_INFO'] = path.encode('latin1').decode('utf8', 'ignore') + + environ['bottle.app'] = self + request.bind(environ) + response.bind() + + try: + while True: # Remove in 0.14 together with RouteReset + out = None + try: + self.trigger_hook('before_request') + route, args = self.router.match(environ) + environ['route.handle'] = route + environ['bottle.route'] = route + environ['route.url_args'] = args + out = route.call(**args) + break + except HTTPResponse as E: + out = E + break + except RouteReset: + depr(0, 13, "RouteReset exception deprecated", + "Call route.call() after route.reset() and " + "return the result.") + route.reset() + continue + finally: + if isinstance(out, HTTPResponse): + out.apply(response) + try: + self.trigger_hook('after_request') + except HTTPResponse as E: + out = E + out.apply(response) + except (KeyboardInterrupt, SystemExit, MemoryError): + raise + except Exception as E: + if not self.catchall: raise + stacktrace = format_exc() + environ['wsgi.errors'].write(stacktrace) + environ['wsgi.errors'].flush() + environ['bottle.exc_info'] = sys.exc_info() + out = HTTPError(500, "Internal Server Error", E, stacktrace) + out.apply(response) + + return out + + def _cast(self, out, peek=None): + """ Try to convert the parameter into something WSGI compatible and set + correct HTTP headers when possible. + Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like, + iterable of strings and iterable of unicodes + """ + + # Empty output is done here + if not out: + if 'Content-Length' not in response: + response['Content-Length'] = 0 + return [] + # Join lists of byte or unicode strings. Mixed lists are NOT supported + if isinstance(out, (tuple, list))\ + and isinstance(out[0], (bytes, unicode)): + out = out[0][0:0].join(out) # b'abc'[0:0] -> b'' + # Encode unicode strings + if isinstance(out, unicode): + out = out.encode(response.charset) + # Byte Strings are just returned + if isinstance(out, bytes): + if 'Content-Length' not in response: + response['Content-Length'] = len(out) + return [out] + # HTTPError or HTTPException (recursive, because they may wrap anything) + # TODO: Handle these explicitly in handle() or make them iterable. + if isinstance(out, HTTPError): + out.apply(response) + out = self.error_handler.get(out.status_code, + self.default_error_handler)(out) + return self._cast(out) + if isinstance(out, HTTPResponse): + out.apply(response) + return self._cast(out.body) + + # File-like objects. + if hasattr(out, 'read'): + if 'wsgi.file_wrapper' in request.environ: + return request.environ['wsgi.file_wrapper'](out) + elif hasattr(out, 'close') or not hasattr(out, '__iter__'): + return WSGIFileWrapper(out) + + # Handle Iterables. We peek into them to detect their inner type. + try: + iout = iter(out) + first = next(iout) + while not first: + first = next(iout) + except StopIteration: + return self._cast('') + except HTTPResponse as E: + first = E + except (KeyboardInterrupt, SystemExit, MemoryError): + raise + except Exception as error: + if not self.catchall: raise + first = HTTPError(500, 'Unhandled exception', error, format_exc()) + + # These are the inner types allowed in iterator or generator objects. + if isinstance(first, HTTPResponse): + return self._cast(first) + elif isinstance(first, bytes): + new_iter = itertools.chain([first], iout) + elif isinstance(first, unicode): + encoder = lambda x: x.encode(response.charset) + new_iter = imap(encoder, itertools.chain([first], iout)) + else: + msg = 'Unsupported response type: %s' % type(first) + return self._cast(HTTPError(500, msg)) + if hasattr(out, 'close'): + new_iter = _closeiter(new_iter, out.close) + return new_iter + + def wsgi(self, environ, start_response): + """ The bottle WSGI-interface. """ + try: + out = self._cast(self._handle(environ)) + # rfc2616 section 4.3 + if response._status_code in (100, 101, 204, 304)\ + or environ['REQUEST_METHOD'] == 'HEAD': + if hasattr(out, 'close'): out.close() + out = [] + exc_info = environ.get('bottle.exc_info') + if exc_info is not None: + del environ['bottle.exc_info'] + start_response(response._wsgi_status_line(), response.headerlist, exc_info) + return out + except (KeyboardInterrupt, SystemExit, MemoryError): + raise + except Exception as E: + if not self.catchall: raise + err = '

    Critical error while processing request: %s

    ' \ + % html_escape(environ.get('PATH_INFO', '/')) + if DEBUG: + err += '

    Error:

    \n
    \n%s\n
    \n' \ + '

    Traceback:

    \n
    \n%s\n
    \n' \ + % (html_escape(repr(E)), html_escape(format_exc())) + environ['wsgi.errors'].write(err) + environ['wsgi.errors'].flush() + headers = [('Content-Type', 'text/html; charset=UTF-8')] + start_response('500 INTERNAL SERVER ERROR', headers, sys.exc_info()) + return [tob(err)] + + def __call__(self, environ, start_response): + """ Each instance of :class:'Bottle' is a WSGI application. """ + return self.wsgi(environ, start_response) + + def __enter__(self): + """ Use this application as default for all module-level shortcuts. """ + default_app.push(self) + return self + + def __exit__(self, exc_type, exc_value, traceback): + default_app.pop() + + def __setattr__(self, name, value): + if name in self.__dict__: + raise AttributeError("Attribute %s already defined. Plugin conflict?" % name) + object.__setattr__(self, name, value) + +############################################################################### +# HTTP and WSGI Tools ########################################################## +############################################################################### + + +class BaseRequest(object): + """ A wrapper for WSGI environment dictionaries that adds a lot of + convenient access methods and properties. Most of them are read-only. + + Adding new attributes to a request actually adds them to the environ + dictionary (as 'bottle.request.ext.'). This is the recommended + way to store and access request-specific data. + """ + + __slots__ = ('environ', ) + + #: Maximum size of memory buffer for :attr:`body` in bytes. + MEMFILE_MAX = 102400 + + def __init__(self, environ=None): + """ Wrap a WSGI environ dictionary. """ + #: The wrapped WSGI environ dictionary. This is the only real attribute. + #: All other attributes actually are read-only properties. + self.environ = {} if environ is None else environ + self.environ['bottle.request'] = self + + @DictProperty('environ', 'bottle.app', read_only=True) + def app(self): + """ Bottle application handling this request. """ + raise RuntimeError('This request is not connected to an application.') + + @DictProperty('environ', 'bottle.route', read_only=True) + def route(self): + """ The bottle :class:`Route` object that matches this request. """ + raise RuntimeError('This request is not connected to a route.') + + @DictProperty('environ', 'route.url_args', read_only=True) + def url_args(self): + """ The arguments extracted from the URL. """ + raise RuntimeError('This request is not connected to a route.') + + @property + def path(self): + """ The value of ``PATH_INFO`` with exactly one prefixed slash (to fix + broken clients and avoid the "empty path" edge case). """ + return '/' + self.environ.get('PATH_INFO', '').lstrip('/') + + @property + def method(self): + """ The ``REQUEST_METHOD`` value as an uppercase string. """ + return self.environ.get('REQUEST_METHOD', 'GET').upper() + + @DictProperty('environ', 'bottle.request.headers', read_only=True) + def headers(self): + """ A :class:`WSGIHeaderDict` that provides case-insensitive access to + HTTP request headers. """ + return WSGIHeaderDict(self.environ) + + def get_header(self, name, default=None): + """ Return the value of a request header, or a given default value. """ + return self.headers.get(name, default) + + @DictProperty('environ', 'bottle.request.cookies', read_only=True) + def cookies(self): + """ Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT + decoded. Use :meth:`get_cookie` if you expect signed cookies. """ + cookies = SimpleCookie(self.environ.get('HTTP_COOKIE', '')).values() + return FormsDict((c.key, c.value) for c in cookies) + + def get_cookie(self, key, default=None, secret=None, digestmod=hashlib.sha256): + """ Return the content of a cookie. To read a `Signed Cookie`, the + `secret` must match the one used to create the cookie (see + :meth:`BaseResponse.set_cookie`). If anything goes wrong (missing + cookie or wrong signature), return a default value. """ + value = self.cookies.get(key) + if secret: + # See BaseResponse.set_cookie for details on signed cookies. + if value and value.startswith('!') and '?' in value: + sig, msg = map(tob, value[1:].split('?', 1)) + hash = hmac.new(tob(secret), msg, digestmod=digestmod).digest() + if _lscmp(sig, base64.b64encode(hash)): + dst = pickle.loads(base64.b64decode(msg)) + if dst and dst[0] == key: + return dst[1] + return default + return value or default + + @DictProperty('environ', 'bottle.request.query', read_only=True) + def query(self): + """ The :attr:`query_string` parsed into a :class:`FormsDict`. These + values are sometimes called "URL arguments" or "GET parameters", but + not to be confused with "URL wildcards" as they are provided by the + :class:`Router`. """ + get = self.environ['bottle.get'] = FormsDict() + pairs = _parse_qsl(self.environ.get('QUERY_STRING', '')) + for key, value in pairs: + get[key] = value + return get + + @DictProperty('environ', 'bottle.request.forms', read_only=True) + def forms(self): + """ Form values parsed from an `url-encoded` or `multipart/form-data` + encoded POST or PUT request body. The result is returned as a + :class:`FormsDict`. All keys and values are strings. File uploads + are stored separately in :attr:`files`. """ + forms = FormsDict() + forms.recode_unicode = self.POST.recode_unicode + for name, item in self.POST.allitems(): + if not isinstance(item, FileUpload): + forms[name] = item + return forms + + @DictProperty('environ', 'bottle.request.params', read_only=True) + def params(self): + """ A :class:`FormsDict` with the combined values of :attr:`query` and + :attr:`forms`. File uploads are stored in :attr:`files`. """ + params = FormsDict() + for key, value in self.query.allitems(): + params[key] = value + for key, value in self.forms.allitems(): + params[key] = value + return params + + @DictProperty('environ', 'bottle.request.files', read_only=True) + def files(self): + """ File uploads parsed from `multipart/form-data` encoded POST or PUT + request body. The values are instances of :class:`FileUpload`. + + """ + files = FormsDict() + files.recode_unicode = self.POST.recode_unicode + for name, item in self.POST.allitems(): + if isinstance(item, FileUpload): + files[name] = item + return files + + @DictProperty('environ', 'bottle.request.json', read_only=True) + def json(self): + """ If the ``Content-Type`` header is ``application/json`` or + ``application/json-rpc``, this property holds the parsed content + of the request body. Only requests smaller than :attr:`MEMFILE_MAX` + are processed to avoid memory exhaustion. + Invalid JSON raises a 400 error response. + """ + ctype = self.environ.get('CONTENT_TYPE', '').lower().split(';')[0] + if ctype in ('application/json', 'application/json-rpc'): + b = self._get_body_string(self.MEMFILE_MAX) + if not b: + return None + try: + return json_loads(b) + except (ValueError, TypeError): + raise HTTPError(400, 'Invalid JSON') + return None + + def _iter_body(self, read, bufsize): + maxread = max(0, self.content_length) + while maxread: + part = read(min(maxread, bufsize)) + if not part: break + yield part + maxread -= len(part) + + @staticmethod + def _iter_chunked(read, bufsize): + err = HTTPError(400, 'Error while parsing chunked transfer body.') + rn, sem, bs = tob('\r\n'), tob(';'), tob('') + while True: + header = read(1) + while header[-2:] != rn: + c = read(1) + header += c + if not c: raise err + if len(header) > bufsize: raise err + size, _, _ = header.partition(sem) + try: + maxread = int(tonat(size.strip()), 16) + except ValueError: + raise err + if maxread == 0: break + buff = bs + while maxread > 0: + if not buff: + buff = read(min(maxread, bufsize)) + part, buff = buff[:maxread], buff[maxread:] + if not part: raise err + yield part + maxread -= len(part) + if read(2) != rn: + raise err + + @DictProperty('environ', 'bottle.request.body', read_only=True) + def _body(self): + try: + read_func = self.environ['wsgi.input'].read + except KeyError: + self.environ['wsgi.input'] = BytesIO() + return self.environ['wsgi.input'] + body_iter = self._iter_chunked if self.chunked else self._iter_body + body, body_size, is_temp_file = BytesIO(), 0, False + for part in body_iter(read_func, self.MEMFILE_MAX): + body.write(part) + body_size += len(part) + if not is_temp_file and body_size > self.MEMFILE_MAX: + body, tmp = NamedTemporaryFile(mode='w+b'), body + body.write(tmp.getvalue()) + del tmp + is_temp_file = True + self.environ['wsgi.input'] = body + body.seek(0) + return body + + def _get_body_string(self, maxread): + """ Read body into a string. Raise HTTPError(413) on requests that are + too large. """ + if self.content_length > maxread: + raise HTTPError(413, 'Request entity too large') + data = self.body.read(maxread + 1) + if len(data) > maxread: + raise HTTPError(413, 'Request entity too large') + return data + + @property + def body(self): + """ The HTTP request body as a seek-able file-like object. Depending on + :attr:`MEMFILE_MAX`, this is either a temporary file or a + :class:`io.BytesIO` instance. Accessing this property for the first + time reads and replaces the ``wsgi.input`` environ variable. + Subsequent accesses just do a `seek(0)` on the file object. """ + self._body.seek(0) + return self._body + + @property + def chunked(self): + """ True if Chunked transfer encoding was. """ + return 'chunked' in self.environ.get( + 'HTTP_TRANSFER_ENCODING', '').lower() + + #: An alias for :attr:`query`. + GET = query + + @DictProperty('environ', 'bottle.request.post', read_only=True) + def POST(self): + """ The values of :attr:`forms` and :attr:`files` combined into a single + :class:`FormsDict`. Values are either strings (form values) or + instances of :class:`FileUpload`. + """ + post = FormsDict() + content_type = self.environ.get('CONTENT_TYPE', '') + content_type, options = _parse_http_header(content_type)[0] + # We default to application/x-www-form-urlencoded for everything that + # is not multipart and take the fast path (also: 3.1 workaround) + if not content_type.startswith('multipart/'): + body = tonat(self._get_body_string(self.MEMFILE_MAX), 'latin1') + for key, value in _parse_qsl(body): + post[key] = value + return post + + post.recode_unicode = False + charset = options.get("charset", "utf8") + boundary = options.get("boundary") + if not boundary: + raise MultipartError("Invalid content type header, missing boundary") + parser = _MultipartParser(self.body, boundary, self.content_length, + mem_limit=self.MEMFILE_MAX, memfile_limit=self.MEMFILE_MAX, + charset=charset) + + for part in parser.parse(): + if not part.filename and part.is_buffered(): + post[part.name] = tonat(part.value, 'utf8') + else: + post[part.name] = FileUpload(part.file, part.name, + part.filename, part.headerlist) + + return post + + @property + def url(self): + """ The full request URI including hostname and scheme. If your app + lives behind a reverse proxy or load balancer and you get confusing + results, make sure that the ``X-Forwarded-Host`` header is set + correctly. """ + return self.urlparts.geturl() + + @DictProperty('environ', 'bottle.request.urlparts', read_only=True) + def urlparts(self): + """ The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. + The tuple contains (scheme, host, path, query_string and fragment), + but the fragment is always empty because it is not visible to the + server. """ + env = self.environ + http = env.get('HTTP_X_FORWARDED_PROTO') \ + or env.get('wsgi.url_scheme', 'http') + host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST') + if not host: + # HTTP 1.1 requires a Host-header. This is for HTTP/1.0 clients. + host = env.get('SERVER_NAME', '127.0.0.1') + port = env.get('SERVER_PORT') + if port and port != ('80' if http == 'http' else '443'): + host += ':' + port + path = urlquote(self.fullpath) + return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '') + + @property + def fullpath(self): + """ Request path including :attr:`script_name` (if present). """ + return urljoin(self.script_name, self.path.lstrip('/')) + + @property + def query_string(self): + """ The raw :attr:`query` part of the URL (everything in between ``?`` + and ``#``) as a string. """ + return self.environ.get('QUERY_STRING', '') + + @property + def script_name(self): + """ The initial portion of the URL's `path` that was removed by a higher + level (server or routing middleware) before the application was + called. This script path is returned with leading and tailing + slashes. """ + script_name = self.environ.get('SCRIPT_NAME', '').strip('/') + return '/' + script_name + '/' if script_name else '/' + + def path_shift(self, shift=1): + """ Shift path segments from :attr:`path` to :attr:`script_name` and + vice versa. + + :param shift: The number of path segments to shift. May be negative + to change the shift direction. (default: 1) + """ + script, path = path_shift(self.environ.get('SCRIPT_NAME', '/'), self.path, shift) + self['SCRIPT_NAME'], self['PATH_INFO'] = script, path + + @property + def content_length(self): + """ The request body length as an integer. The client is responsible to + set this header. Otherwise, the real length of the body is unknown + and -1 is returned. In this case, :attr:`body` will be empty. """ + return int(self.environ.get('CONTENT_LENGTH') or -1) + + @property + def content_type(self): + """ The Content-Type header as a lowercase-string (default: empty). """ + return self.environ.get('CONTENT_TYPE', '').lower() + + @property + def is_xhr(self): + """ True if the request was triggered by a XMLHttpRequest. This only + works with JavaScript libraries that support the `X-Requested-With` + header (most of the popular libraries do). """ + requested_with = self.environ.get('HTTP_X_REQUESTED_WITH', '') + return requested_with.lower() == 'xmlhttprequest' + + @property + def is_ajax(self): + """ Alias for :attr:`is_xhr`. "Ajax" is not the right term. """ + return self.is_xhr + + @property + def auth(self): + """ HTTP authentication data as a (user, password) tuple. This + implementation currently supports basic (not digest) authentication + only. If the authentication happened at a higher level (e.g. in the + front web-server or a middleware), the password field is None, but + the user field is looked up from the ``REMOTE_USER`` environ + variable. On any errors, None is returned. """ + basic = parse_auth(self.environ.get('HTTP_AUTHORIZATION', '')) + if basic: return basic + ruser = self.environ.get('REMOTE_USER') + if ruser: return (ruser, None) + return None + + @property + def remote_route(self): + """ A list of all IPs that were involved in this request, starting with + the client IP and followed by zero or more proxies. This does only + work if all proxies support the ```X-Forwarded-For`` header. Note + that this information can be forged by malicious clients. """ + proxy = self.environ.get('HTTP_X_FORWARDED_FOR') + if proxy: return [ip.strip() for ip in proxy.split(',')] + remote = self.environ.get('REMOTE_ADDR') + return [remote] if remote else [] + + @property + def remote_addr(self): + """ The client IP as a string. Note that this information can be forged + by malicious clients. """ + route = self.remote_route + return route[0] if route else None + + def copy(self): + """ Return a new :class:`Request` with a shallow :attr:`environ` copy. """ + return Request(self.environ.copy()) + + def get(self, value, default=None): + return self.environ.get(value, default) + + def __getitem__(self, key): + return self.environ[key] + + def __delitem__(self, key): + self[key] = "" + del (self.environ[key]) + + def __iter__(self): + return iter(self.environ) + + def __len__(self): + return len(self.environ) + + def keys(self): + return self.environ.keys() + + def __setitem__(self, key, value): + """ Change an environ value and clear all caches that depend on it. """ + + if self.environ.get('bottle.request.readonly'): + raise KeyError('The environ dictionary is read-only.') + + self.environ[key] = value + todelete = () + + if key == 'wsgi.input': + todelete = ('body', 'forms', 'files', 'params', 'post', 'json') + elif key == 'QUERY_STRING': + todelete = ('query', 'params') + elif key.startswith('HTTP_'): + todelete = ('headers', 'cookies') + + for key in todelete: + self.environ.pop('bottle.request.' + key, None) + + def __repr__(self): + return '<%s: %s %s>' % (self.__class__.__name__, self.method, self.url) + + def __getattr__(self, name): + """ Search in self.environ for additional user defined attributes. """ + try: + var = self.environ['bottle.request.ext.%s' % name] + return var.__get__(self) if hasattr(var, '__get__') else var + except KeyError: + raise AttributeError('Attribute %r not defined.' % name) + + def __setattr__(self, name, value): + """ Define new attributes that are local to the bound request environment. """ + if name == 'environ': return object.__setattr__(self, name, value) + key = 'bottle.request.ext.%s' % name + if hasattr(self, name): + raise AttributeError("Attribute already defined: %s" % name) + self.environ[key] = value + + def __delattr__(self, name): + try: + del self.environ['bottle.request.ext.%s' % name] + except KeyError: + raise AttributeError("Attribute not defined: %s" % name) + + +def _hkey(key): + if '\n' in key or '\r' in key or '\0' in key: + raise ValueError("Header names must not contain control characters: %r" % key) + return key.title().replace('_', '-') + + +def _hval(value): + value = tonat(value) + if '\n' in value or '\r' in value or '\0' in value: + raise ValueError("Header value must not contain control characters: %r" % value) + return value + + +class HeaderProperty(object): + def __init__(self, name, reader=None, writer=None, default=''): + self.name, self.default = name, default + self.reader, self.writer = reader, writer + self.__doc__ = 'Current value of the %r header.' % name.title() + + def __get__(self, obj, _): + if obj is None: return self + value = obj.get_header(self.name, self.default) + return self.reader(value) if self.reader else value + + def __set__(self, obj, value): + obj[self.name] = self.writer(value) if self.writer else value + + def __delete__(self, obj): + del obj[self.name] + + +class BaseResponse(object): + """ Storage class for a response body as well as headers and cookies. + + This class does support dict-like case-insensitive item-access to + headers, but is NOT a dict. Most notably, iterating over a response + yields parts of the body and not the headers. + """ + + default_status = 200 + default_content_type = 'text/html; charset=UTF-8' + + # Header denylist for specific response codes + # (rfc2616 section 10.2.3 and 10.3.5) + bad_headers = { + 204: frozenset(('Content-Type', 'Content-Length')), + 304: frozenset(('Allow', 'Content-Encoding', 'Content-Language', + 'Content-Length', 'Content-Range', 'Content-Type', + 'Content-Md5', 'Last-Modified')) + } + + def __init__(self, body='', status=None, headers=None, **more_headers): + """ Create a new response object. + + :param body: The response body as one of the supported types. + :param status: Either an HTTP status code (e.g. 200) or a status line + including the reason phrase (e.g. '200 OK'). + :param headers: A dictionary or a list of name-value pairs. + + Additional keyword arguments are added to the list of headers. + Underscores in the header name are replaced with dashes. + """ + self._cookies = None + self._headers = {} + self.body = body + self.status = status or self.default_status + if headers: + if isinstance(headers, dict): + headers = headers.items() + for name, value in headers: + self.add_header(name, value) + if more_headers: + for name, value in more_headers.items(): + self.add_header(name, value) + + def copy(self, cls=None): + """ Returns a copy of self. """ + cls = cls or BaseResponse + assert issubclass(cls, BaseResponse) + copy = cls() + copy.status = self.status + copy._headers = dict((k, v[:]) for (k, v) in self._headers.items()) + if self._cookies: + cookies = copy._cookies = SimpleCookie() + for k,v in self._cookies.items(): + cookies[k] = v.value + cookies[k].update(v) # also copy cookie attributes + return copy + + def __iter__(self): + return iter(self.body) + + def close(self): + if hasattr(self.body, 'close'): + self.body.close() + + @property + def status_line(self): + """ The HTTP status line as a string (e.g. ``404 Not Found``).""" + return self._status_line + + @property + def status_code(self): + """ The HTTP status code as an integer (e.g. 404).""" + return self._status_code + + def _set_status(self, status): + if isinstance(status, int): + code, status = status, _HTTP_STATUS_LINES.get(status) + elif ' ' in status: + if '\n' in status or '\r' in status or '\0' in status: + raise ValueError('Status line must not include control chars.') + status = status.strip() + code = int(status.split()[0]) + else: + raise ValueError('String status line without a reason phrase.') + if not 100 <= code <= 999: + raise ValueError('Status code out of range.') + self._status_code = code + self._status_line = str(status or ('%d Unknown' % code)) + + def _get_status(self): + return self._status_line + + status = property( + _get_status, _set_status, None, + ''' A writeable property to change the HTTP response status. It accepts + either a numeric code (100-999) or a string with a custom reason + phrase (e.g. "404 Brain not found"). Both :data:`status_line` and + :data:`status_code` are updated accordingly. The return value is + always a status string. ''') + del _get_status, _set_status + + @property + def headers(self): + """ An instance of :class:`HeaderDict`, a case-insensitive dict-like + view on the response headers. """ + hdict = HeaderDict() + hdict.dict = self._headers + return hdict + + def __contains__(self, name): + return _hkey(name) in self._headers + + def __delitem__(self, name): + del self._headers[_hkey(name)] + + def __getitem__(self, name): + return self._headers[_hkey(name)][-1] + + def __setitem__(self, name, value): + self._headers[_hkey(name)] = [_hval(value)] + + def get_header(self, name, default=None): + """ Return the value of a previously defined header. If there is no + header with that name, return a default value. """ + return self._headers.get(_hkey(name), [default])[-1] + + def set_header(self, name, value): + """ Create a new response header, replacing any previously defined + headers with the same name. """ + self._headers[_hkey(name)] = [_hval(value)] + + def add_header(self, name, value): + """ Add an additional response header, not removing duplicates. """ + self._headers.setdefault(_hkey(name), []).append(_hval(value)) + + def iter_headers(self): + """ Yield (header, value) tuples, skipping headers that are not + allowed with the current response status code. """ + return self.headerlist + + def _wsgi_status_line(self): + """ WSGI conform status line (latin1-encodeable) """ + if py3k: + return self._status_line.encode('utf8').decode('latin1') + return self._status_line + + @property + def headerlist(self): + """ WSGI conform list of (header, value) tuples. """ + out = [] + headers = list(self._headers.items()) + if 'Content-Type' not in self._headers: + headers.append(('Content-Type', [self.default_content_type])) + if self._status_code in self.bad_headers: + bad_headers = self.bad_headers[self._status_code] + headers = [h for h in headers if h[0] not in bad_headers] + out += [(name, val) for (name, vals) in headers for val in vals] + if self._cookies: + for c in self._cookies.values(): + out.append(('Set-Cookie', _hval(c.OutputString()))) + if py3k: + out = [(k, v.encode('utf8').decode('latin1')) for (k, v) in out] + return out + + content_type = HeaderProperty('Content-Type') + content_length = HeaderProperty('Content-Length', reader=int, default=-1) + expires = HeaderProperty( + 'Expires', + reader=lambda x: datetime.fromtimestamp(parse_date(x), UTC), + writer=lambda x: http_date(x)) + + @property + def charset(self, default='UTF-8'): + """ Return the charset specified in the content-type header (default: utf8). """ + if 'charset=' in self.content_type: + return self.content_type.split('charset=')[-1].split(';')[0].strip() + return default + + def set_cookie(self, name, value, secret=None, digestmod=hashlib.sha256, **options): + """ Create a new cookie or replace an old one. If the `secret` parameter is + set, create a `Signed Cookie` (described below). + + :param name: the name of the cookie. + :param value: the value of the cookie. + :param secret: a signature key required for signed cookies. + + Additionally, this method accepts all RFC 2109 attributes that are + supported by :class:`cookie.Morsel`, including: + + :param maxage: maximum age in seconds. (default: None) + :param expires: a datetime object or UNIX timestamp. (default: None) + :param domain: the domain that is allowed to read the cookie. + (default: current domain) + :param path: limits the cookie to a given path (default: current path) + :param secure: limit the cookie to HTTPS connections (default: off). + :param httponly: prevents client-side javascript to read this cookie + (default: off, requires Python 2.6 or newer). + :param samesite: Control or disable third-party use for this cookie. + Possible values: `lax`, `strict` or `none` (default). + + If neither `expires` nor `maxage` is set (default), the cookie will + expire at the end of the browser session (as soon as the browser + window is closed). + + Signed cookies may store any pickle-able object and are + cryptographically signed to prevent manipulation. Keep in mind that + cookies are limited to 4kb in most browsers. + + Warning: Pickle is a potentially dangerous format. If an attacker + gains access to the secret key, he could forge cookies that execute + code on server side if unpickled. Using pickle is discouraged and + support for it will be removed in later versions of bottle. + + Warning: Signed cookies are not encrypted (the client can still see + the content) and not copy-protected (the client can restore an old + cookie). The main intention is to make pickling and unpickling + save, not to store secret information at client side. + """ + if not self._cookies: + self._cookies = SimpleCookie() + + # Monkey-patch Cookie lib to support 'SameSite' parameter + # https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1 + if py < (3, 8, 0): + Morsel._reserved.setdefault('samesite', 'SameSite') + + if secret: + if not isinstance(value, basestring): + depr(0, 13, "Pickling of arbitrary objects into cookies is " + "deprecated.", "Only store strings in cookies. " + "JSON strings are fine, too.") + encoded = base64.b64encode(pickle.dumps([name, value], -1)) + sig = base64.b64encode(hmac.new(tob(secret), encoded, + digestmod=digestmod).digest()) + value = touni(tob('!') + sig + tob('?') + encoded) + elif not isinstance(value, basestring): + raise TypeError('Secret key required for non-string cookies.') + + # Cookie size plus options must not exceed 4kb. + if len(name) + len(value) > 3800: + raise ValueError('Content does not fit into a cookie.') + + self._cookies[name] = value + + for key, value in options.items(): + if key in ('max_age', 'maxage'): # 'maxage' variant added in 0.13 + key = 'max-age' + if isinstance(value, timedelta): + value = value.seconds + value.days * 24 * 3600 + if key == 'expires': + value = http_date(value) + if key in ('same_site', 'samesite'): # 'samesite' variant added in 0.13 + key, value = 'samesite', (value or "none").lower() + if value not in ('lax', 'strict', 'none'): + raise CookieError("Invalid value for SameSite") + if key in ('secure', 'httponly') and not value: + continue + self._cookies[name][key] = value + + def delete_cookie(self, key, **kwargs): + """ Delete a cookie. Be sure to use the same `domain` and `path` + settings as used to create the cookie. """ + kwargs['max_age'] = -1 + kwargs['expires'] = 0 + self.set_cookie(key, '', **kwargs) + + def __repr__(self): + out = '' + for name, value in self.headerlist: + out += '%s: %s\n' % (name.title(), value.strip()) + return out + + +def _local_property(): + ls = threading.local() + + def fget(_): + try: + return ls.var + except AttributeError: + raise RuntimeError("Request context not initialized.") + + def fset(_, value): + ls.var = value + + def fdel(_): + del ls.var + + return property(fget, fset, fdel, 'Thread-local property') + + +class LocalRequest(BaseRequest): + """ A thread-local subclass of :class:`BaseRequest` with a different + set of attributes for each thread. There is usually only one global + instance of this class (:data:`request`). If accessed during a + request/response cycle, this instance always refers to the *current* + request (even on a multithreaded server). """ + bind = BaseRequest.__init__ + environ = _local_property() + + +class LocalResponse(BaseResponse): + """ A thread-local subclass of :class:`BaseResponse` with a different + set of attributes for each thread. There is usually only one global + instance of this class (:data:`response`). Its attributes are used + to build the HTTP response at the end of the request/response cycle. + """ + bind = BaseResponse.__init__ + _status_line = _local_property() + _status_code = _local_property() + _cookies = _local_property() + _headers = _local_property() + body = _local_property() + + +Request = BaseRequest +Response = BaseResponse + + +class HTTPResponse(Response, BottleException): + """ A subclass of :class:`Response` that can be raised or returned from request + handlers to short-curcuit request processing and override changes made to the + global :data:`request` object. This bypasses error handlers, even if the status + code indicates an error. Return or raise :class:`HTTPError` to trigger error + handlers. + """ + + def __init__(self, body='', status=None, headers=None, **more_headers): + super(HTTPResponse, self).__init__(body, status, headers, **more_headers) + + def apply(self, other): + """ Copy the state of this response to a different :class:`Response` object. """ + other._status_code = self._status_code + other._status_line = self._status_line + other._headers = self._headers + other._cookies = self._cookies + other.body = self.body + + +class HTTPError(HTTPResponse): + """ A subclass of :class:`HTTPResponse` that triggers error handlers. """ + + default_status = 500 + + def __init__(self, + status=None, + body=None, + exception=None, + traceback=None, **more_headers): + self.exception = exception + self.traceback = traceback + super(HTTPError, self).__init__(body, status, **more_headers) + +############################################################################### +# Plugins ###################################################################### +############################################################################### + + +class PluginError(BottleException): + pass + + +class JSONPlugin(object): + name = 'json' + api = 2 + + def __init__(self, json_dumps=json_dumps): + self.json_dumps = json_dumps + + def setup(self, app): + app.config._define('json.enable', default=True, validate=bool, + help="Enable or disable automatic dict->json filter.") + app.config._define('json.ascii', default=False, validate=bool, + help="Use only 7-bit ASCII characters in output.") + app.config._define('json.indent', default=True, validate=bool, + help="Add whitespace to make json more readable.") + app.config._define('json.dump_func', default=None, + help="If defined, use this function to transform" + " dict into json. The other options no longer" + " apply.") + + def apply(self, callback, route): + dumps = self.json_dumps + if not self.json_dumps: return callback + + @functools.wraps(callback) + def wrapper(*a, **ka): + try: + rv = callback(*a, **ka) + except HTTPResponse as resp: + rv = resp + + if isinstance(rv, dict): + #Attempt to serialize, raises exception on failure + json_response = dumps(rv) + #Set content type only if serialization successful + response.content_type = 'application/json' + return json_response + elif isinstance(rv, HTTPResponse) and isinstance(rv.body, dict): + rv.body = dumps(rv.body) + rv.content_type = 'application/json' + return rv + + return wrapper + + +class TemplatePlugin(object): + """ This plugin applies the :func:`view` decorator to all routes with a + `template` config parameter. If the parameter is a tuple, the second + element must be a dict with additional options (e.g. `template_engine`) + or default variables for the template. """ + name = 'template' + api = 2 + + def setup(self, app): + app.tpl = self + + def apply(self, callback, route): + conf = route.config.get('template') + if isinstance(conf, (tuple, list)) and len(conf) == 2: + return view(conf[0], **conf[1])(callback) + elif isinstance(conf, str): + return view(conf)(callback) + else: + return callback + + +#: Not a plugin, but part of the plugin API. TODO: Find a better place. +class _ImportRedirect(object): + def __init__(self, name, impmask): + """ Create a virtual package that redirects imports (see PEP 302). """ + self.name = name + self.impmask = impmask + self.module = sys.modules.setdefault(name, new_module(name)) + self.module.__dict__.update({ + '__file__': __file__, + '__path__': [], + '__all__': [], + '__loader__': self + }) + sys.meta_path.append(self) + + def find_spec(self, fullname, path, target=None): + if '.' not in fullname: return + if fullname.rsplit('.', 1)[0] != self.name: return + from importlib.util import spec_from_loader + return spec_from_loader(fullname, self) + + def find_module(self, fullname, path=None): + if '.' not in fullname: return + if fullname.rsplit('.', 1)[0] != self.name: return + return self + + def create_module(self, spec): + return self.load_module(spec.name) + + def exec_module(self, module): + pass # This probably breaks importlib.reload() :/ + + def load_module(self, fullname): + if fullname in sys.modules: return sys.modules[fullname] + modname = fullname.rsplit('.', 1)[1] + realname = self.impmask % modname + __import__(realname) + module = sys.modules[fullname] = sys.modules[realname] + setattr(self.module, modname, module) + module.__loader__ = self + return module + +############################################################################### +# Common Utilities ############################################################# +############################################################################### + + +class MultiDict(DictMixin): + """ This dict stores multiple values per key, but behaves exactly like a + normal dict in that it returns only the newest value for any given key. + There are special methods available to access the full list of values. + """ + + def __init__(self, *a, **k): + self.dict = dict((k, [v]) for (k, v) in dict(*a, **k).items()) + + def __len__(self): + return len(self.dict) + + def __iter__(self): + return iter(self.dict) + + def __contains__(self, key): + return key in self.dict + + def __delitem__(self, key): + del self.dict[key] + + def __getitem__(self, key): + return self.dict[key][-1] + + def __setitem__(self, key, value): + self.append(key, value) + + def keys(self): + return self.dict.keys() + + if py3k: + + def values(self): + return (v[-1] for v in self.dict.values()) + + def items(self): + return ((k, v[-1]) for k, v in self.dict.items()) + + def allitems(self): + return ((k, v) for k, vl in self.dict.items() for v in vl) + + iterkeys = keys + itervalues = values + iteritems = items + iterallitems = allitems + + else: + + def values(self): + return [v[-1] for v in self.dict.values()] + + def items(self): + return [(k, v[-1]) for k, v in self.dict.items()] + + def iterkeys(self): + return self.dict.iterkeys() + + def itervalues(self): + return (v[-1] for v in self.dict.itervalues()) + + def iteritems(self): + return ((k, v[-1]) for k, v in self.dict.iteritems()) + + def iterallitems(self): + return ((k, v) for k, vl in self.dict.iteritems() for v in vl) + + def allitems(self): + return [(k, v) for k, vl in self.dict.iteritems() for v in vl] + + def get(self, key, default=None, index=-1, type=None): + """ Return the most recent value for a key. + + :param default: The default value to be returned if the key is not + present or the type conversion fails. + :param index: An index for the list of available values. + :param type: If defined, this callable is used to cast the value + into a specific type. Exception are suppressed and result in + the default value to be returned. + """ + try: + val = self.dict[key][index] + return type(val) if type else val + except Exception: + pass + return default + + def append(self, key, value): + """ Add a new value to the list of values for this key. """ + self.dict.setdefault(key, []).append(value) + + def replace(self, key, value): + """ Replace the list of values with a single value. """ + self.dict[key] = [value] + + def getall(self, key): + """ Return a (possibly empty) list of values for a key. """ + return self.dict.get(key) or [] + + #: Aliases for WTForms to mimic other multi-dict APIs (Django) + getone = get + getlist = getall + + +class FormsDict(MultiDict): + """ This :class:`MultiDict` subclass is used to store request form data. + Additionally to the normal dict-like item access methods (which return + unmodified data as native strings), this container also supports + attribute-like access to its values. Attributes are automatically de- + or recoded to match :attr:`input_encoding` (default: 'utf8'). Missing + attributes default to an empty string. """ + + #: Encoding used for attribute values. + input_encoding = 'utf8' + #: If true (default), unicode strings are first encoded with `latin1` + #: and then decoded to match :attr:`input_encoding`. + recode_unicode = True + + def _fix(self, s, encoding=None): + if isinstance(s, unicode) and self.recode_unicode: # Python 3 WSGI + return s.encode('latin1').decode(encoding or self.input_encoding) + elif isinstance(s, bytes): # Python 2 WSGI + return s.decode(encoding or self.input_encoding) + else: + return s + + def decode(self, encoding=None): + """ Returns a copy with all keys and values de- or recoded to match + :attr:`input_encoding`. Some libraries (e.g. WTForms) want a + unicode dictionary. """ + copy = FormsDict() + enc = copy.input_encoding = encoding or self.input_encoding + copy.recode_unicode = False + for key, value in self.allitems(): + copy.append(self._fix(key, enc), self._fix(value, enc)) + return copy + + def getunicode(self, name, default=None, encoding=None): + """ Return the value as a unicode string, or the default. """ + try: + return self._fix(self[name], encoding) + except (UnicodeError, KeyError): + return default + + def __getattr__(self, name, default=unicode()): + # Without this guard, pickle generates a cryptic TypeError: + if name.startswith('__') and name.endswith('__'): + return super(FormsDict, self).__getattr__(name) + return self.getunicode(name, default=default) + +class HeaderDict(MultiDict): + """ A case-insensitive version of :class:`MultiDict` that defaults to + replace the old value instead of appending it. """ + + def __init__(self, *a, **ka): + self.dict = {} + if a or ka: self.update(*a, **ka) + + def __contains__(self, key): + return _hkey(key) in self.dict + + def __delitem__(self, key): + del self.dict[_hkey(key)] + + def __getitem__(self, key): + return self.dict[_hkey(key)][-1] + + def __setitem__(self, key, value): + self.dict[_hkey(key)] = [_hval(value)] + + def append(self, key, value): + self.dict.setdefault(_hkey(key), []).append(_hval(value)) + + def replace(self, key, value): + self.dict[_hkey(key)] = [_hval(value)] + + def getall(self, key): + return self.dict.get(_hkey(key)) or [] + + def get(self, key, default=None, index=-1): + return MultiDict.get(self, _hkey(key), default, index) + + def filter(self, names): + for name in (_hkey(n) for n in names): + if name in self.dict: + del self.dict[name] + + +class WSGIHeaderDict(DictMixin): + """ This dict-like class wraps a WSGI environ dict and provides convenient + access to HTTP_* fields. Keys and values are native strings + (2.x bytes or 3.x unicode) and keys are case-insensitive. If the WSGI + environment contains non-native string values, these are de- or encoded + using a lossless 'latin1' character set. + + The API will remain stable even on changes to the relevant PEPs. + Currently PEP 333, 444 and 3333 are supported. (PEP 444 is the only one + that uses non-native strings.) + """ + #: List of keys that do not have a ``HTTP_`` prefix. + cgikeys = ('CONTENT_TYPE', 'CONTENT_LENGTH') + + def __init__(self, environ): + self.environ = environ + + def _ekey(self, key): + """ Translate header field name to CGI/WSGI environ key. """ + key = key.replace('-', '_').upper() + if key in self.cgikeys: + return key + return 'HTTP_' + key + + def raw(self, key, default=None): + """ Return the header value as is (may be bytes or unicode). """ + return self.environ.get(self._ekey(key), default) + + def __getitem__(self, key): + val = self.environ[self._ekey(key)] + if py3k: + if isinstance(val, unicode): + val = val.encode('latin1').decode('utf8') + else: + val = val.decode('utf8') + return val + + def __setitem__(self, key, value): + raise TypeError("%s is read-only." % self.__class__) + + def __delitem__(self, key): + raise TypeError("%s is read-only." % self.__class__) + + def __iter__(self): + for key in self.environ: + if key[:5] == 'HTTP_': + yield _hkey(key[5:]) + elif key in self.cgikeys: + yield _hkey(key) + + def keys(self): + return [x for x in self] + + def __len__(self): + return len(self.keys()) + + def __contains__(self, key): + return self._ekey(key) in self.environ + +_UNSET = object() + +class ConfigDict(dict): + """ A dict-like configuration storage with additional support for + namespaces, validators, meta-data and overlays. + + This dict-like class is heavily optimized for read access. + Read-only methods and item access should be as fast as a native dict. + """ + + __slots__ = ('_meta', '_change_listener', '_overlays', '_virtual_keys', '_source', '__weakref__') + + def __init__(self): + self._meta = {} + self._change_listener = [] + #: Weak references of overlays that need to be kept in sync. + self._overlays = [] + #: Config that is the source for this overlay. + self._source = None + #: Keys of values copied from the source (values we do not own) + self._virtual_keys = set() + + def load_module(self, name, squash=True): + """Load values from a Python module. + + Import a python module by name and add all upper-case module-level + variables to this config dict. + + :param name: Module name to import and load. + :param squash: If true (default), nested dicts are assumed to + represent namespaces and flattened (see :meth:`load_dict`). + """ + config_obj = load(name) + obj = {key: getattr(config_obj, key) + for key in dir(config_obj) if key.isupper()} + + if squash: + self.load_dict(obj) + else: + self.update(obj) + return self + + def load_config(self, filename, **options): + """ Load values from ``*.ini`` style config files using configparser. + + INI style sections (e.g. ``[section]``) are used as namespace for + all keys within that section. Both section and key names may contain + dots as namespace separators and are converted to lower-case. + + The special sections ``[bottle]`` and ``[ROOT]`` refer to the root + namespace and the ``[DEFAULT]`` section defines default values for all + other sections. + + :param filename: The path of a config file, or a list of paths. + :param options: All keyword parameters are passed to the underlying + :class:`python:configparser.ConfigParser` constructor call. + + """ + options.setdefault('allow_no_value', True) + if py3k: + options.setdefault('interpolation', + configparser.ExtendedInterpolation()) + conf = configparser.ConfigParser(**options) + conf.read(filename) + for section in conf.sections(): + for key in conf.options(section): + value = conf.get(section, key) + if section not in ('bottle', 'ROOT'): + key = section + '.' + key + self[key.lower()] = value + return self + + def load_dict(self, source, namespace=''): + """ Load values from a dictionary structure. Nesting can be used to + represent namespaces. + + >>> c = ConfigDict() + >>> c.load_dict({'some': {'namespace': {'key': 'value'} } }) + {'some.namespace.key': 'value'} + """ + for key, value in source.items(): + if isinstance(key, basestring): + nskey = (namespace + '.' + key).strip('.') + if isinstance(value, dict): + self.load_dict(value, namespace=nskey) + else: + self[nskey] = value + else: + raise TypeError('Key has type %r (not a string)' % type(key)) + return self + + def update(self, *a, **ka): + """ If the first parameter is a string, all keys are prefixed with this + namespace. Apart from that it works just as the usual dict.update(). + + >>> c = ConfigDict() + >>> c.update('some.namespace', key='value') + """ + prefix = '' + if a and isinstance(a[0], basestring): + prefix = a[0].strip('.') + '.' + a = a[1:] + for key, value in dict(*a, **ka).items(): + self[prefix + key] = value + + def setdefault(self, key, value=None): + if key not in self: + self[key] = value + return self[key] + + def __setitem__(self, key, value): + if not isinstance(key, basestring): + raise TypeError('Key has type %r (not a string)' % type(key)) + + self._virtual_keys.discard(key) + + value = self.meta_get(key, 'filter', lambda x: x)(value) + if key in self and self[key] is value: + return + + self._on_change(key, value) + dict.__setitem__(self, key, value) + + for overlay in self._iter_overlays(): + overlay._set_virtual(key, value) + + def __delitem__(self, key): + if key not in self: + raise KeyError(key) + if key in self._virtual_keys: + raise KeyError("Virtual keys cannot be deleted: %s" % key) + + if self._source and key in self._source: + # Not virtual, but present in source -> Restore virtual value + dict.__delitem__(self, key) + self._set_virtual(key, self._source[key]) + else: # not virtual, not present in source. This is OUR value + self._on_change(key, None) + dict.__delitem__(self, key) + for overlay in self._iter_overlays(): + overlay._delete_virtual(key) + + def _set_virtual(self, key, value): + """ Recursively set or update virtual keys. """ + if key in self and key not in self._virtual_keys: + return # Do nothing for non-virtual keys. + + self._virtual_keys.add(key) + if key in self and self[key] is not value: + self._on_change(key, value) + dict.__setitem__(self, key, value) + for overlay in self._iter_overlays(): + overlay._set_virtual(key, value) + + def _delete_virtual(self, key): + """ Recursively delete virtual entry. """ + if key not in self._virtual_keys: + return # Do nothing for non-virtual keys. + + if key in self: + self._on_change(key, None) + dict.__delitem__(self, key) + self._virtual_keys.discard(key) + for overlay in self._iter_overlays(): + overlay._delete_virtual(key) + + def _on_change(self, key, value): + for cb in self._change_listener: + if cb(self, key, value): + return True + + def _add_change_listener(self, func): + self._change_listener.append(func) + return func + + def meta_get(self, key, metafield, default=None): + """ Return the value of a meta field for a key. """ + return self._meta.get(key, {}).get(metafield, default) + + def meta_set(self, key, metafield, value): + """ Set the meta field for a key to a new value. + + Meta-fields are shared between all members of an overlay tree. + """ + self._meta.setdefault(key, {})[metafield] = value + + def meta_list(self, key): + """ Return an iterable of meta field names defined for a key. """ + return self._meta.get(key, {}).keys() + + def _define(self, key, default=_UNSET, help=_UNSET, validate=_UNSET): + """ (Unstable) Shortcut for plugins to define own config parameters. """ + if default is not _UNSET: + self.setdefault(key, default) + if help is not _UNSET: + self.meta_set(key, 'help', help) + if validate is not _UNSET: + self.meta_set(key, 'validate', validate) + + def _iter_overlays(self): + for ref in self._overlays: + overlay = ref() + if overlay is not None: + yield overlay + + def _make_overlay(self): + """ (Unstable) Create a new overlay that acts like a chained map: Values + missing in the overlay are copied from the source map. Both maps + share the same meta entries. + + Entries that were copied from the source are called 'virtual'. You + can not delete virtual keys, but overwrite them, which turns them + into non-virtual entries. Setting keys on an overlay never affects + its source, but may affect any number of child overlays. + + Other than collections.ChainMap or most other implementations, this + approach does not resolve missing keys on demand, but instead + actively copies all values from the source to the overlay and keeps + track of virtual and non-virtual keys internally. This removes any + lookup-overhead. Read-access is as fast as a build-in dict for both + virtual and non-virtual keys. + + Changes are propagated recursively and depth-first. A failing + on-change handler in an overlay stops the propagation of virtual + values and may result in an partly updated tree. Take extra care + here and make sure that on-change handlers never fail. + + Used by Route.config + """ + # Cleanup dead references + self._overlays[:] = [ref for ref in self._overlays if ref() is not None] + + overlay = ConfigDict() + overlay._meta = self._meta + overlay._source = self + self._overlays.append(weakref.ref(overlay)) + for key in self: + overlay._set_virtual(key, self[key]) + return overlay + + + + +class AppStack(list): + """ A stack-like list. Calling it returns the head of the stack. """ + + def __call__(self): + """ Return the current default application. """ + return self.default + + def push(self, value=None): + """ Add a new :class:`Bottle` instance to the stack """ + if not isinstance(value, Bottle): + value = Bottle() + self.append(value) + return value + new_app = push + + @property + def default(self): + try: + return self[-1] + except IndexError: + return self.push() + + +class WSGIFileWrapper(object): + def __init__(self, fp, buffer_size=1024 * 64): + self.fp, self.buffer_size = fp, buffer_size + for attr in 'fileno', 'close', 'read', 'readlines', 'tell', 'seek': + if hasattr(fp, attr): setattr(self, attr, getattr(fp, attr)) + + def __iter__(self): + buff, read = self.buffer_size, self.read + part = read(buff) + while part: + yield part + part = read(buff) + + +class _closeiter(object): + """ This only exists to be able to attach a .close method to iterators that + do not support attribute assignment (most of itertools). """ + + def __init__(self, iterator, close=None): + self.iterator = iterator + self.close_callbacks = makelist(close) + + def __iter__(self): + return iter(self.iterator) + + def close(self): + for func in self.close_callbacks: + func() + + +class ResourceManager(object): + """ This class manages a list of search paths and helps to find and open + application-bound resources (files). + + :param base: default value for :meth:`add_path` calls. + :param opener: callable used to open resources. + :param cachemode: controls which lookups are cached. One of 'all', + 'found' or 'none'. + """ + + def __init__(self, base='./', opener=open, cachemode='all'): + self.opener = opener + self.base = base + self.cachemode = cachemode + + #: A list of search paths. See :meth:`add_path` for details. + self.path = [] + #: A cache for resolved paths. ``res.cache.clear()`` clears the cache. + self.cache = {} + + def add_path(self, path, base=None, index=None, create=False): + """ Add a new path to the list of search paths. Return False if the + path does not exist. + + :param path: The new search path. Relative paths are turned into + an absolute and normalized form. If the path looks like a file + (not ending in `/`), the filename is stripped off. + :param base: Path used to absolutize relative search paths. + Defaults to :attr:`base` which defaults to ``os.getcwd()``. + :param index: Position within the list of search paths. Defaults + to last index (appends to the list). + + The `base` parameter makes it easy to reference files installed + along with a python module or package:: + + res.add_path('./resources/', __file__) + """ + base = os.path.abspath(os.path.dirname(base or self.base)) + path = os.path.abspath(os.path.join(base, os.path.dirname(path))) + path += os.sep + if path in self.path: + self.path.remove(path) + if create and not os.path.isdir(path): + os.makedirs(path) + if index is None: + self.path.append(path) + else: + self.path.insert(index, path) + self.cache.clear() + return os.path.exists(path) + + def __iter__(self): + """ Iterate over all existing files in all registered paths. """ + search = self.path[:] + while search: + path = search.pop() + if not os.path.isdir(path): continue + for name in os.listdir(path): + full = os.path.join(path, name) + if os.path.isdir(full): search.append(full) + else: yield full + + def lookup(self, name): + """ Search for a resource and return an absolute file path, or `None`. + + The :attr:`path` list is searched in order. The first match is + returned. Symlinks are followed. The result is cached to speed up + future lookups. """ + if name not in self.cache or DEBUG: + for path in self.path: + fpath = os.path.join(path, name) + if os.path.isfile(fpath): + if self.cachemode in ('all', 'found'): + self.cache[name] = fpath + return fpath + if self.cachemode == 'all': + self.cache[name] = None + return self.cache[name] + + def open(self, name, mode='r', *args, **kwargs): + """ Find a resource and return a file object, or raise IOError. """ + fname = self.lookup(name) + if not fname: raise IOError("Resource %r not found." % name) + return self.opener(fname, mode=mode, *args, **kwargs) + + +class FileUpload(object): + def __init__(self, fileobj, name, filename, headers=None): + """ Wrapper for a single file uploaded via ``multipart/form-data``. """ + #: Open file(-like) object (BytesIO buffer or temporary file) + self.file = fileobj + #: Name of the upload form field + self.name = name + #: Raw filename as sent by the client (may contain unsafe characters) + self.raw_filename = filename + #: A :class:`HeaderDict` with additional headers (e.g. content-type) + self.headers = HeaderDict(headers) if headers else HeaderDict() + + content_type = HeaderProperty('Content-Type') + content_length = HeaderProperty('Content-Length', reader=int, default=-1) + + def get_header(self, name, default=None): + """ Return the value of a header within the multipart part. """ + return self.headers.get(name, default) + + @cached_property + def filename(self): + """ Name of the file on the client file system, but normalized to ensure + file system compatibility. An empty filename is returned as 'empty'. + + Only ASCII letters, digits, dashes, underscores and dots are + allowed in the final filename. Accents are removed, if possible. + Whitespace is replaced by a single dash. Leading or tailing dots + or dashes are removed. The filename is limited to 255 characters. + """ + fname = self.raw_filename + if not isinstance(fname, unicode): + fname = fname.decode('utf8', 'ignore') + fname = normalize('NFKD', fname) + fname = fname.encode('ASCII', 'ignore').decode('ASCII') + fname = os.path.basename(fname.replace('\\', os.path.sep)) + fname = re.sub(r'[^a-zA-Z0-9-_.\s]', '', fname).strip() + fname = re.sub(r'[-\s]+', '-', fname).strip('.-') + return fname[:255] or 'empty' + + def _copy_file(self, fp, chunk_size=2 ** 16): + read, write, offset = self.file.read, fp.write, self.file.tell() + while 1: + buf = read(chunk_size) + if not buf: break + write(buf) + self.file.seek(offset) + + def save(self, destination, overwrite=False, chunk_size=2 ** 16): + """ Save file to disk or copy its content to an open file(-like) object. + If *destination* is a directory, :attr:`filename` is added to the + path. Existing files are not overwritten by default (IOError). + + :param destination: File path, directory or file(-like) object. + :param overwrite: If True, replace existing files. (default: False) + :param chunk_size: Bytes to read at a time. (default: 64kb) + """ + if isinstance(destination, basestring): # Except file-likes here + if os.path.isdir(destination): + destination = os.path.join(destination, self.filename) + if not overwrite and os.path.exists(destination): + raise IOError('File exists.') + with open(destination, 'wb') as fp: + self._copy_file(fp, chunk_size) + else: + self._copy_file(destination, chunk_size) + +############################################################################### +# Application Helper ########################################################### +############################################################################### + + +def abort(code=500, text='Unknown Error.'): + """ Aborts execution and causes a HTTP error. """ + raise HTTPError(code, text) + + +def redirect(url, code=None): + """ Aborts execution and causes a 303 or 302 redirect, depending on + the HTTP protocol version. """ + if not code: + code = 303 if request.get('SERVER_PROTOCOL') == "HTTP/1.1" else 302 + res = response.copy(cls=HTTPResponse) + res.status = code + res.body = "" + res.set_header('Location', urljoin(request.url, url)) + raise res + + +def _rangeiter(fp, offset, limit, bufsize=1024 * 1024): + """ Yield chunks from a range in a file. """ + fp.seek(offset) + while limit > 0: + part = fp.read(min(limit, bufsize)) + if not part: + break + limit -= len(part) + yield part + + +def static_file(filename, root, + mimetype=True, + download=False, + charset='UTF-8', + etag=None, + headers=None): + """ Open a file in a safe way and return an instance of :exc:`HTTPResponse` + that can be sent back to the client. + + :param filename: Name or path of the file to send, relative to ``root``. + :param root: Root path for file lookups. Should be an absolute directory + path. + :param mimetype: Provide the content-type header (default: guess from + file extension) + :param download: If True, ask the browser to open a `Save as...` dialog + instead of opening the file with the associated program. You can + specify a custom filename as a string. If not specified, the + original filename is used (default: False). + :param charset: The charset for files with a ``text/*`` mime-type. + (default: UTF-8) + :param etag: Provide a pre-computed ETag header. If set to ``False``, + ETag handling is disabled. (default: auto-generate ETag header) + :param headers: Additional headers dict to add to the response. + + While checking user input is always a good idea, this function provides + additional protection against malicious ``filename`` parameters from + breaking out of the ``root`` directory and leaking sensitive information + to an attacker. + + Read-protected files or files outside of the ``root`` directory are + answered with ``403 Access Denied``. Missing files result in a + ``404 Not Found`` response. Conditional requests (``If-Modified-Since``, + ``If-None-Match``) are answered with ``304 Not Modified`` whenever + possible. ``HEAD`` and ``Range`` requests (used by download managers to + check or continue partial downloads) are also handled automatically. + """ + + root = os.path.join(os.path.abspath(root), '') + filename = os.path.abspath(os.path.join(root, filename.strip('/\\'))) + headers = headers.copy() if headers else {} + getenv = request.environ.get + + if not filename.startswith(root): + return HTTPError(403, "Access denied.") + if not os.path.exists(filename) or not os.path.isfile(filename): + return HTTPError(404, "File does not exist.") + if not os.access(filename, os.R_OK): + return HTTPError(403, "You do not have permission to access this file.") + + if mimetype is True: + name = download if isinstance(download, str) else filename + mimetype, encoding = mimetypes.guess_type(name) + if encoding == 'gzip': + mimetype = 'application/gzip' + elif encoding: # e.g. bzip2 -> application/x-bzip2 + mimetype = 'application/x-' + encoding + + if charset and mimetype and 'charset=' not in mimetype \ + and (mimetype[:5] == 'text/' or mimetype == 'application/javascript'): + mimetype += '; charset=%s' % charset + + if mimetype: + headers['Content-Type'] = mimetype + + if download is True: + download = os.path.basename(filename) + + if download: + download = download.replace('"','') + headers['Content-Disposition'] = 'attachment; filename="%s"' % download + + stats = os.stat(filename) + headers['Content-Length'] = clen = stats.st_size + headers['Last-Modified'] = email.utils.formatdate(stats.st_mtime, usegmt=True) + headers['Date'] = email.utils.formatdate(time.time(), usegmt=True) + + if etag is None: + etag = '%d:%d:%d:%d:%s' % (stats.st_dev, stats.st_ino, stats.st_mtime, + clen, filename) + etag = hashlib.sha1(tob(etag)).hexdigest() + + if etag: + headers['ETag'] = etag + check = getenv('HTTP_IF_NONE_MATCH') + if check and check == etag: + return HTTPResponse(status=304, **headers) + + ims = getenv('HTTP_IF_MODIFIED_SINCE') + if ims: + ims = parse_date(ims.split(";")[0].strip()) + if ims is not None and ims >= int(stats.st_mtime): + return HTTPResponse(status=304, **headers) + + body = '' if request.method == 'HEAD' else open(filename, 'rb') + + headers["Accept-Ranges"] = "bytes" + range_header = getenv('HTTP_RANGE') + if range_header: + ranges = list(parse_range_header(range_header, clen)) + if not ranges: + return HTTPError(416, "Requested Range Not Satisfiable") + offset, end = ranges[0] + rlen = end - offset + headers["Content-Range"] = "bytes %d-%d/%d" % (offset, end - 1, clen) + headers["Content-Length"] = str(rlen) + if body: body = _closeiter(_rangeiter(body, offset, rlen), body.close) + return HTTPResponse(body, status=206, **headers) + return HTTPResponse(body, **headers) + +############################################################################### +# HTTP Utilities and MISC (TODO) ############################################### +############################################################################### + + +def debug(mode=True): + """ Change the debug level. + There is only one debug level supported at the moment.""" + global DEBUG + if mode: warnings.simplefilter('default') + DEBUG = bool(mode) + + +def http_date(value): + if isinstance(value, basestring): + return value + if isinstance(value, datetime): + # aware datetime.datetime is converted to UTC time + # naive datetime.datetime is treated as UTC time + value = value.utctimetuple() + elif isinstance(value, datedate): + # datetime.date is naive, and is treated as UTC time + value = value.timetuple() + if not isinstance(value, (int, float)): + # convert struct_time in UTC to UNIX timestamp + value = calendar.timegm(value) + return email.utils.formatdate(value, usegmt=True) + + +def parse_date(ims): + """ Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch. """ + try: + ts = email.utils.parsedate_tz(ims) + return calendar.timegm(ts[:8] + (0, )) - (ts[9] or 0) + except (TypeError, ValueError, IndexError, OverflowError): + return None + + +def parse_auth(header): + """ Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None""" + try: + method, data = header.split(None, 1) + if method.lower() == 'basic': + user, pwd = touni(base64.b64decode(tob(data))).split(':', 1) + return user, pwd + except (KeyError, ValueError): + return None + + +def parse_range_header(header, maxlen=0): + """ Yield (start, end) ranges parsed from a HTTP Range header. Skip + unsatisfiable ranges. The end index is non-inclusive.""" + if not header or header[:6] != 'bytes=': return + ranges = [r.split('-', 1) for r in header[6:].split(',') if '-' in r] + for start, end in ranges: + try: + if not start: # bytes=-100 -> last 100 bytes + start, end = max(0, maxlen - int(end)), maxlen + elif not end: # bytes=100- -> all but the first 99 bytes + start, end = int(start), maxlen + else: # bytes=100-200 -> bytes 100-200 (inclusive) + start, end = int(start), min(int(end) + 1, maxlen) + if 0 <= start < end <= maxlen: + yield start, end + except ValueError: + pass + + +#: Header tokenizer used by _parse_http_header() +_hsplit = re.compile('(?:(?:"((?:[^"\\\\]|\\\\.)*)")|([^;,=]+))([;,=]?)').findall + +def _parse_http_header(h): + """ Parses a typical multi-valued and parametrised HTTP header (e.g. Accept headers) and returns a list of values + and parameters. For non-standard or broken input, this implementation may return partial results. + :param h: A header string (e.g. ``text/html,text/plain;q=0.9,*/*;q=0.8``) + :return: List of (value, params) tuples. The second element is a (possibly empty) dict. + """ + values = [] + if '"' not in h: # INFO: Fast path without regexp (~2x faster) + for value in h.split(','): + parts = value.split(';') + values.append((parts[0].strip(), {})) + for attr in parts[1:]: + name, value = attr.split('=', 1) + values[-1][1][name.strip().lower()] = value.strip() + else: + lop, key, attrs = ',', None, {} + for quoted, plain, tok in _hsplit(h): + value = plain.strip() if plain else quoted.replace('\\"', '"') + if lop == ',': + attrs = {} + values.append((value, attrs)) + elif lop == ';': + if tok == '=': + key = value + else: + attrs[value.strip().lower()] = '' + elif lop == '=' and key: + attrs[key.strip().lower()] = value + key = None + lop = tok + return values + + +def _parse_qsl(qs): + r = [] + for pair in qs.split('&'): + if not pair: continue + nv = pair.split('=', 1) + if len(nv) != 2: nv.append('') + key = urlunquote(nv[0].replace('+', ' ')) + value = urlunquote(nv[1].replace('+', ' ')) + r.append((key, value)) + return r + + +def _lscmp(a, b): + """ Compares two strings in a cryptographically safe way: + Runtime is not affected by length of common prefix. """ + return not sum(0 if x == y else 1 + for x, y in zip(a, b)) and len(a) == len(b) + + +def cookie_encode(data, key, digestmod=None): + """ Encode and sign a pickle-able object. Return a (byte) string """ + depr(0, 13, "cookie_encode() will be removed soon.", + "Do not use this API directly.") + digestmod = digestmod or hashlib.sha256 + msg = base64.b64encode(pickle.dumps(data, -1)) + sig = base64.b64encode(hmac.new(tob(key), msg, digestmod=digestmod).digest()) + return tob('!') + sig + tob('?') + msg + + +def cookie_decode(data, key, digestmod=None): + """ Verify and decode an encoded string. Return an object or None.""" + depr(0, 13, "cookie_decode() will be removed soon.", + "Do not use this API directly.") + data = tob(data) + if cookie_is_encoded(data): + sig, msg = data.split(tob('?'), 1) + digestmod = digestmod or hashlib.sha256 + hashed = hmac.new(tob(key), msg, digestmod=digestmod).digest() + if _lscmp(sig[1:], base64.b64encode(hashed)): + return pickle.loads(base64.b64decode(msg)) + return None + + +def cookie_is_encoded(data): + """ Return True if the argument looks like a encoded cookie.""" + depr(0, 13, "cookie_is_encoded() will be removed soon.", + "Do not use this API directly.") + return bool(data.startswith(tob('!')) and tob('?') in data) + + +def html_escape(string): + """ Escape HTML special characters ``&<>`` and quotes ``'"``. """ + return string.replace('&', '&').replace('<', '<').replace('>', '>')\ + .replace('"', '"').replace("'", ''') + + +def html_quote(string): + """ Escape and quote a string to be used as an HTTP attribute.""" + return '"%s"' % html_escape(string).replace('\n', ' ')\ + .replace('\r', ' ').replace('\t', ' ') + + +def yieldroutes(func): + """ Return a generator for routes that match the signature (name, args) + of the func parameter. This may yield more than one route if the function + takes optional keyword arguments. The output is best described by example:: + + a() -> '/a' + b(x, y) -> '/b//' + c(x, y=5) -> '/c/' and '/c//' + d(x=5, y=6) -> '/d' and '/d/' and '/d//' + """ + path = '/' + func.__name__.replace('__', '/').lstrip('/') + spec = getargspec(func) + argc = len(spec[0]) - len(spec[3] or []) + path += ('/<%s>' * argc) % tuple(spec[0][:argc]) + yield path + for arg in spec[0][argc:]: + path += '/<%s>' % arg + yield path + + +def path_shift(script_name, path_info, shift=1): + """ Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa. + + :return: The modified paths. + :param script_name: The SCRIPT_NAME path. + :param script_name: The PATH_INFO path. + :param shift: The number of path fragments to shift. May be negative to + change the shift direction. (default: 1) + """ + if shift == 0: return script_name, path_info + pathlist = path_info.strip('/').split('/') + scriptlist = script_name.strip('/').split('/') + if pathlist and pathlist[0] == '': pathlist = [] + if scriptlist and scriptlist[0] == '': scriptlist = [] + if 0 < shift <= len(pathlist): + moved = pathlist[:shift] + scriptlist = scriptlist + moved + pathlist = pathlist[shift:] + elif 0 > shift >= -len(scriptlist): + moved = scriptlist[shift:] + pathlist = moved + pathlist + scriptlist = scriptlist[:shift] + else: + empty = 'SCRIPT_NAME' if shift < 0 else 'PATH_INFO' + raise AssertionError("Cannot shift. Nothing left from %s" % empty) + new_script_name = '/' + '/'.join(scriptlist) + new_path_info = '/' + '/'.join(pathlist) + if path_info.endswith('/') and pathlist: new_path_info += '/' + return new_script_name, new_path_info + + +def auth_basic(check, realm="private", text="Access denied"): + """ Callback decorator to require HTTP auth (basic). + TODO: Add route(check_auth=...) parameter. """ + + def decorator(func): + + @functools.wraps(func) + def wrapper(*a, **ka): + user, password = request.auth or (None, None) + if user is None or not check(user, password): + err = HTTPError(401, text) + err.add_header('WWW-Authenticate', 'Basic realm="%s"' % realm) + return err + return func(*a, **ka) + + return wrapper + + return decorator + +# Shortcuts for common Bottle methods. +# They all refer to the current default application. + + +def make_default_app_wrapper(name): + """ Return a callable that relays calls to the current default app. """ + + @functools.wraps(getattr(Bottle, name)) + def wrapper(*a, **ka): + return getattr(app(), name)(*a, **ka) + + return wrapper + + +route = make_default_app_wrapper('route') +get = make_default_app_wrapper('get') +post = make_default_app_wrapper('post') +put = make_default_app_wrapper('put') +delete = make_default_app_wrapper('delete') +patch = make_default_app_wrapper('patch') +error = make_default_app_wrapper('error') +mount = make_default_app_wrapper('mount') +hook = make_default_app_wrapper('hook') +install = make_default_app_wrapper('install') +uninstall = make_default_app_wrapper('uninstall') +url = make_default_app_wrapper('get_url') + + +############################################################################### +# Multipart Handling ########################################################### +############################################################################### +# cgi.FieldStorage was deprecated in Python 3.11 and removed in 3.13 +# This implementation is based on https://github.com/defnull/multipart/ + + +class MultipartError(HTTPError): + def __init__(self, msg): + HTTPError.__init__(self, 400, "MultipartError: " + msg) + + +class _MultipartParser(object): + def __init__( + self, + stream, + boundary, + content_length=-1, + disk_limit=2 ** 30, + mem_limit=2 ** 20, + memfile_limit=2 ** 18, + buffer_size=2 ** 16, + charset="latin1", + ): + self.stream = stream + self.boundary = boundary + self.content_length = content_length + self.disk_limit = disk_limit + self.memfile_limit = memfile_limit + self.mem_limit = min(mem_limit, self.disk_limit) + self.buffer_size = min(buffer_size, self.mem_limit) + self.charset = charset + + if not boundary: + raise MultipartError("No boundary.") + + if self.buffer_size - 6 < len(boundary): # "--boundary--\r\n" + raise MultipartError("Boundary does not fit into buffer_size.") + + def _lineiter(self): + """ Iterate over a binary file-like object (crlf terminated) line by + line. Each line is returned as a (line, crlf) tuple. Lines larger + than buffer_size are split into chunks where all but the last chunk + has an empty string instead of crlf. Maximum chunk size is twice the + buffer size. + """ + + read = self.stream.read + maxread, maxbuf = self.content_length, self.buffer_size + partial = b"" # Contains the last (partial) line + + while True: + chunk = read(maxbuf if maxread < 0 else min(maxbuf, maxread)) + maxread -= len(chunk) + if not chunk: + if partial: + yield partial, b'' + break + + if partial: + chunk = partial + chunk + + scanpos = 0 + while True: + i = chunk.find(b'\r\n', scanpos) + if i >= 0: + yield chunk[scanpos:i], b'\r\n' + scanpos = i + 2 + else: # CRLF not found + partial = chunk[scanpos:] if scanpos else chunk + break + + if len(partial) > maxbuf: + yield partial[:-1], b"" + partial = partial[-1:] + + def parse(self): + """ Return a MultiPart iterator. Can only be called once. """ + + lines, line = self._lineiter(), "" + separator = b"--" + tob(self.boundary) + terminator = separator + b"--" + mem_used, disk_used = 0, 0 # Track used resources to prevent DoS + is_tail = False # True if the last line was incomplete (cutted) + + # Consume first boundary. Ignore any preamble, as required by RFC + # 2046, section 5.1.1. + for line, nl in lines: + if line in (separator, terminator): + break + else: + raise MultipartError("Stream does not contain boundary") + + # First line is termainating boundary -> empty multipart stream + if line == terminator: + for _ in lines: + raise MultipartError("Found data after empty multipart stream") + return + + part_options = { + "buffer_size": self.buffer_size, + "memfile_limit": self.memfile_limit, + "charset": self.charset, + } + part = _MultipartPart(**part_options) + + for line, nl in lines: + if not is_tail and (line == separator or line == terminator): + part.finish() + if part.is_buffered(): + mem_used += part.size + else: + disk_used += part.size + yield part + if line == terminator: + break + part = _MultipartPart(**part_options) + else: + is_tail = not nl # The next line continues this one + try: + part.feed(line, nl) + if part.is_buffered(): + if part.size + mem_used > self.mem_limit: + raise MultipartError("Memory limit reached.") + elif part.size + disk_used > self.disk_limit: + raise MultipartError("Disk limit reached.") + except MultipartError: + part.close() + raise + else: + part.close() + + if line != terminator: + raise MultipartError("Unexpected end of multipart stream.") + + +class _MultipartPart(object): + def __init__(self, buffer_size=2 ** 16, memfile_limit=2 ** 18, charset="latin1"): + self.headerlist = [] + self.headers = None + self.file = False + self.size = 0 + self._buf = b"" + self.disposition = None + self.name = None + self.filename = None + self.content_type = None + self.charset = charset + self.memfile_limit = memfile_limit + self.buffer_size = buffer_size + + def feed(self, line, nl=""): + if self.file: + return self.write_body(line, nl) + return self.write_header(line, nl) + + def write_header(self, line, nl): + line = line.decode(self.charset) + + if not nl: + raise MultipartError("Unexpected end of line in header.") + + if not line.strip(): # blank line -> end of header segment + self.finish_header() + elif line[0] in " \t" and self.headerlist: + name, value = self.headerlist.pop() + self.headerlist.append((name, value + line.strip())) + else: + if ":" not in line: + raise MultipartError("Syntax error in header: No colon.") + + name, value = line.split(":", 1) + self.headerlist.append((name.strip(), value.strip())) + + def write_body(self, line, nl): + if not line and not nl: + return # This does not even flush the buffer + + self.size += len(line) + len(self._buf) + self.file.write(self._buf + line) + self._buf = nl + + if self.content_length > 0 and self.size > self.content_length: + raise MultipartError("Size of body exceeds Content-Length header.") + + if self.size > self.memfile_limit and isinstance(self.file, BytesIO): + self.file, old = NamedTemporaryFile(mode="w+b"), self.file + old.seek(0) + + copied, maxcopy, chunksize = 0, self.size, self.buffer_size + read, write = old.read, self.file.write + while copied < maxcopy: + chunk = read(min(chunksize, maxcopy - copied)) + write(chunk) + copied += len(chunk) + + def finish_header(self): + self.file = BytesIO() + self.headers = HeaderDict(self.headerlist) + content_disposition = self.headers.get("Content-Disposition") + content_type = self.headers.get("Content-Type") + + if not content_disposition: + raise MultipartError("Content-Disposition header is missing.") + + self.disposition, self.options = _parse_http_header(content_disposition)[0] + self.name = self.options.get("name") + if "filename" in self.options: + self.filename = self.options.get("filename") + if self.filename[1:3] == ":\\" or self.filename[:2] == "\\\\": + self.filename = self.filename.split("\\")[-1] # ie6 bug + + self.content_type, options = _parse_http_header(content_type)[0] if content_type else (None, {}) + self.charset = options.get("charset") or self.charset + + self.content_length = int(self.headers.get("Content-Length", "-1")) + + def finish(self): + if not self.file: + raise MultipartError("Incomplete part: Header section not closed.") + self.file.seek(0) + + def is_buffered(self): + """ Return true if the data is fully buffered in memory.""" + return isinstance(self.file, BytesIO) + + @property + def value(self): + """ Data decoded with the specified charset """ + + return self.raw.decode(self.charset) + + @property + def raw(self): + """ Data without decoding """ + pos = self.file.tell() + self.file.seek(0) + + try: + return self.file.read() + finally: + self.file.seek(pos) + + def close(self): + if self.file: + self.file.close() + self.file = False + +############################################################################### +# Server Adapter ############################################################### +############################################################################### + +# Before you edit or add a server adapter, please read: +# - https://github.com/bottlepy/bottle/pull/647#issuecomment-60152870 +# - https://github.com/bottlepy/bottle/pull/865#issuecomment-242795341 + +class ServerAdapter(object): + quiet = False + + def __init__(self, host='127.0.0.1', port=8080, **options): + self.options = options + self.host = host + self.port = int(port) + + def run(self, handler): # pragma: no cover + pass + + def __repr__(self): + args = ', '.join('%s=%s' % (k, repr(v)) + for k, v in self.options.items()) + return "%s(%s)" % (self.__class__.__name__, args) + + +class CGIServer(ServerAdapter): + quiet = True + + def run(self, handler): # pragma: no cover + from wsgiref.handlers import CGIHandler + + def fixed_environ(environ, start_response): + environ.setdefault('PATH_INFO', '') + return handler(environ, start_response) + + CGIHandler().run(fixed_environ) + + +class FlupFCGIServer(ServerAdapter): + def run(self, handler): # pragma: no cover + import flup.server.fcgi + self.options.setdefault('bindAddress', (self.host, self.port)) + flup.server.fcgi.WSGIServer(handler, **self.options).run() + + +class WSGIRefServer(ServerAdapter): + def run(self, app): # pragma: no cover + from wsgiref.simple_server import make_server + from wsgiref.simple_server import WSGIRequestHandler, WSGIServer + import socket + + class FixedHandler(WSGIRequestHandler): + def address_string(self): # Prevent reverse DNS lookups please. + return self.client_address[0] + + def log_request(*args, **kw): + if not self.quiet: + return WSGIRequestHandler.log_request(*args, **kw) + + handler_cls = self.options.get('handler_class', FixedHandler) + server_cls = self.options.get('server_class', WSGIServer) + + if ':' in self.host: # Fix wsgiref for IPv6 addresses. + if getattr(server_cls, 'address_family') == socket.AF_INET: + + class server_cls(server_cls): + address_family = socket.AF_INET6 + + self.srv = make_server(self.host, self.port, app, server_cls, + handler_cls) + self.port = self.srv.server_port # update port actual port (0 means random) + try: + self.srv.serve_forever() + except KeyboardInterrupt: + self.srv.server_close() # Prevent ResourceWarning: unclosed socket + raise + + +class CherryPyServer(ServerAdapter): + def run(self, handler): # pragma: no cover + depr(0, 13, "The wsgi server part of cherrypy was split into a new " + "project called 'cheroot'.", "Use the 'cheroot' server " + "adapter instead of cherrypy.") + from cherrypy import wsgiserver # This will fail for CherryPy >= 9 + + self.options['bind_addr'] = (self.host, self.port) + self.options['wsgi_app'] = handler + + certfile = self.options.get('certfile') + if certfile: + del self.options['certfile'] + keyfile = self.options.get('keyfile') + if keyfile: + del self.options['keyfile'] + + server = wsgiserver.CherryPyWSGIServer(**self.options) + if certfile: + server.ssl_certificate = certfile + if keyfile: + server.ssl_private_key = keyfile + + try: + server.start() + finally: + server.stop() + + +class CherootServer(ServerAdapter): + def run(self, handler): # pragma: no cover + from cheroot import wsgi + from cheroot.ssl import builtin + self.options['bind_addr'] = (self.host, self.port) + self.options['wsgi_app'] = handler + certfile = self.options.pop('certfile', None) + keyfile = self.options.pop('keyfile', None) + chainfile = self.options.pop('chainfile', None) + server = wsgi.Server(**self.options) + if certfile and keyfile: + server.ssl_adapter = builtin.BuiltinSSLAdapter( + certfile, keyfile, chainfile) + try: + server.start() + finally: + server.stop() + + +class WaitressServer(ServerAdapter): + def run(self, handler): + from waitress import serve + serve(handler, host=self.host, port=self.port, _quiet=self.quiet, **self.options) + + +class PasteServer(ServerAdapter): + def run(self, handler): # pragma: no cover + from paste import httpserver + from paste.translogger import TransLogger + handler = TransLogger(handler, setup_console_handler=(not self.quiet)) + httpserver.serve(handler, + host=self.host, + port=str(self.port), **self.options) + + +class MeinheldServer(ServerAdapter): + def run(self, handler): + from meinheld import server + server.listen((self.host, self.port)) + server.run(handler) + + +class FapwsServer(ServerAdapter): + """ Extremely fast webserver using libev. See https://github.com/william-os4y/fapws3 """ + + def run(self, handler): # pragma: no cover + depr(0, 13, "fapws3 is not maintained and support will be dropped.") + import fapws._evwsgi as evwsgi + from fapws import base, config + port = self.port + if float(config.SERVER_IDENT[-2:]) > 0.4: + # fapws3 silently changed its API in 0.5 + port = str(port) + evwsgi.start(self.host, port) + # fapws3 never releases the GIL. Complain upstream. I tried. No luck. + if 'BOTTLE_CHILD' in os.environ and not self.quiet: + _stderr("WARNING: Auto-reloading does not work with Fapws3.") + _stderr(" (Fapws3 breaks python thread support)") + evwsgi.set_base_module(base) + + def app(environ, start_response): + environ['wsgi.multiprocess'] = False + return handler(environ, start_response) + + evwsgi.wsgi_cb(('', app)) + evwsgi.run() + + +class TornadoServer(ServerAdapter): + """ The super hyped asynchronous server by facebook. Untested. """ + + def run(self, handler): # pragma: no cover + import tornado.wsgi, tornado.httpserver, tornado.ioloop + container = tornado.wsgi.WSGIContainer(handler) + server = tornado.httpserver.HTTPServer(container) + server.listen(port=self.port, address=self.host) + tornado.ioloop.IOLoop.instance().start() + + +class AppEngineServer(ServerAdapter): + """ Adapter for Google App Engine. """ + quiet = True + + def run(self, handler): + depr(0, 13, "AppEngineServer no longer required", + "Configure your application directly in your app.yaml") + from google.appengine.ext.webapp import util + # A main() function in the handler script enables 'App Caching'. + # Lets makes sure it is there. This _really_ improves performance. + module = sys.modules.get('__main__') + if module and not hasattr(module, 'main'): + module.main = lambda: util.run_wsgi_app(handler) + util.run_wsgi_app(handler) + + +class TwistedServer(ServerAdapter): + """ Untested. """ + + def run(self, handler): + from twisted.web import server, wsgi + from twisted.python.threadpool import ThreadPool + from twisted.internet import reactor + thread_pool = ThreadPool() + thread_pool.start() + reactor.addSystemEventTrigger('after', 'shutdown', thread_pool.stop) + factory = server.Site(wsgi.WSGIResource(reactor, thread_pool, handler)) + reactor.listenTCP(self.port, factory, interface=self.host) + if not reactor.running: + reactor.run() + + +class DieselServer(ServerAdapter): + """ Untested. """ + + def run(self, handler): + depr(0, 13, "Diesel is not tested or supported and will be removed.") + from diesel.protocols.wsgi import WSGIApplication + app = WSGIApplication(handler, port=self.port) + app.run() + + +class GeventServer(ServerAdapter): + """ Untested. Options: + + * See gevent.wsgi.WSGIServer() documentation for more options. + """ + + def run(self, handler): + from gevent import pywsgi, local + if not isinstance(threading.local(), local.local): + msg = "Bottle requires gevent.monkey.patch_all() (before import)" + raise RuntimeError(msg) + if self.quiet: + self.options['log'] = None + address = (self.host, self.port) + server = pywsgi.WSGIServer(address, handler, **self.options) + if 'BOTTLE_CHILD' in os.environ: + import signal + signal.signal(signal.SIGINT, lambda s, f: server.stop()) + server.serve_forever() + + +class GunicornServer(ServerAdapter): + """ Untested. See http://gunicorn.org/configure.html for options. """ + + def run(self, handler): + from gunicorn.app.base import BaseApplication + + if self.host.startswith("unix:"): + config = {'bind': self.host} + else: + config = {'bind': "%s:%d" % (self.host, self.port)} + + config.update(self.options) + + class GunicornApplication(BaseApplication): + def load_config(self): + for key, value in config.items(): + self.cfg.set(key, value) + + def load(self): + return handler + + GunicornApplication().run() + + +class EventletServer(ServerAdapter): + """ Untested. Options: + + * `backlog` adjust the eventlet backlog parameter which is the maximum + number of queued connections. Should be at least 1; the maximum + value is system-dependent. + * `family`: (default is 2) socket family, optional. See socket + documentation for available families. + """ + + def run(self, handler): + from eventlet import wsgi, listen, patcher + if not patcher.is_monkey_patched(os): + msg = "Bottle requires eventlet.monkey_patch() (before import)" + raise RuntimeError(msg) + socket_args = {} + for arg in ('backlog', 'family'): + try: + socket_args[arg] = self.options.pop(arg) + except KeyError: + pass + address = (self.host, self.port) + try: + wsgi.server(listen(address, **socket_args), handler, + log_output=(not self.quiet)) + except TypeError: + # Fallback, if we have old version of eventlet + wsgi.server(listen(address), handler) + + +class BjoernServer(ServerAdapter): + """ Fast server written in C: https://github.com/jonashaag/bjoern """ + + def run(self, handler): + from bjoern import run + run(handler, self.host, self.port, reuse_port=True) + +class AsyncioServerAdapter(ServerAdapter): + """ Extend ServerAdapter for adding custom event loop """ + def get_event_loop(self): + pass + +class AiohttpServer(AsyncioServerAdapter): + """ Asynchronous HTTP client/server framework for asyncio + https://pypi.python.org/pypi/aiohttp/ + https://pypi.org/project/aiohttp-wsgi/ + """ + + def get_event_loop(self): + import asyncio + return asyncio.new_event_loop() + + def run(self, handler): + import asyncio + from aiohttp_wsgi.wsgi import serve + self.loop = self.get_event_loop() + asyncio.set_event_loop(self.loop) + + if 'BOTTLE_CHILD' in os.environ: + import signal + signal.signal(signal.SIGINT, lambda s, f: self.loop.stop()) + + serve(handler, host=self.host, port=self.port) + + +class AiohttpUVLoopServer(AiohttpServer): + """uvloop + https://github.com/MagicStack/uvloop + """ + def get_event_loop(self): + import uvloop + return uvloop.new_event_loop() + +class AutoServer(ServerAdapter): + """ Untested. """ + adapters = [WaitressServer, PasteServer, TwistedServer, CherryPyServer, + CherootServer, WSGIRefServer] + + def run(self, handler): + for sa in self.adapters: + try: + return sa(self.host, self.port, **self.options).run(handler) + except ImportError: + pass + + +server_names = { + 'cgi': CGIServer, + 'flup': FlupFCGIServer, + 'wsgiref': WSGIRefServer, + 'waitress': WaitressServer, + 'cherrypy': CherryPyServer, + 'cheroot': CherootServer, + 'paste': PasteServer, + 'fapws3': FapwsServer, + 'tornado': TornadoServer, + 'gae': AppEngineServer, + 'twisted': TwistedServer, + 'diesel': DieselServer, + 'meinheld': MeinheldServer, + 'gunicorn': GunicornServer, + 'eventlet': EventletServer, + 'gevent': GeventServer, + 'bjoern': BjoernServer, + 'aiohttp': AiohttpServer, + 'uvloop': AiohttpUVLoopServer, + 'auto': AutoServer, +} + +############################################################################### +# Application Control ########################################################## +############################################################################### + + +def load(target, **namespace): + """ Import a module or fetch an object from a module. + + * ``package.module`` returns `module` as a module object. + * ``pack.mod:name`` returns the module variable `name` from `pack.mod`. + * ``pack.mod:func()`` calls `pack.mod.func()` and returns the result. + + The last form accepts not only function calls, but any type of + expression. Keyword arguments passed to this function are available as + local variables. Example: ``import_string('re:compile(x)', x='[a-z]')`` + """ + module, target = target.split(":", 1) if ':' in target else (target, None) + if module not in sys.modules: __import__(module) + if not target: return sys.modules[module] + if target.isalnum(): return getattr(sys.modules[module], target) + package_name = module.split('.')[0] + namespace[package_name] = sys.modules[package_name] + return eval('%s.%s' % (module, target), namespace) + + +def load_app(target): + """ Load a bottle application from a module and make sure that the import + does not affect the current default application, but returns a separate + application object. See :func:`load` for the target parameter. """ + global NORUN + NORUN, nr_old = True, NORUN + tmp = default_app.push() # Create a new "default application" + try: + rv = load(target) # Import the target module + return rv if callable(rv) else tmp + finally: + default_app.remove(tmp) # Remove the temporary added default application + NORUN = nr_old + + +_debug = debug + + +def run(app=None, + server='wsgiref', + host='127.0.0.1', + port=8080, + interval=1, + reloader=False, + quiet=False, + plugins=None, + debug=None, + config=None, **kargs): + """ Start a server instance. This method blocks until the server terminates. + + :param app: WSGI application or target string supported by + :func:`load_app`. (default: :func:`default_app`) + :param server: Server adapter to use. See :data:`server_names` keys + for valid names or pass a :class:`ServerAdapter` subclass. + (default: `wsgiref`) + :param host: Server address to bind to. Pass ``0.0.0.0`` to listens on + all interfaces including the external one. (default: 127.0.0.1) + :param port: Server port to bind to. Values below 1024 require root + privileges. (default: 8080) + :param reloader: Start auto-reloading server? (default: False) + :param interval: Auto-reloader interval in seconds (default: 1) + :param quiet: Suppress output to stdout and stderr? (default: False) + :param options: Options passed to the server adapter. + """ + if NORUN: return + if reloader and not os.environ.get('BOTTLE_CHILD'): + import subprocess + fd, lockfile = tempfile.mkstemp(prefix='bottle.', suffix='.lock') + environ = os.environ.copy() + environ['BOTTLE_CHILD'] = 'true' + environ['BOTTLE_LOCKFILE'] = lockfile + args = [sys.executable] + sys.argv + # If a package was loaded with `python -m`, then `sys.argv` needs to be + # restored to the original value, or imports might break. See #1336 + if getattr(sys.modules.get('__main__'), '__package__', None): + args[1:1] = ["-m", sys.modules['__main__'].__package__] + + try: + os.close(fd) # We never write to this file + while os.path.exists(lockfile): + p = subprocess.Popen(args, env=environ) + while p.poll() is None: + os.utime(lockfile, None) # Tell child we are still alive + time.sleep(interval) + if p.returncode == 3: # Child wants to be restarted + continue + sys.exit(p.returncode) + except KeyboardInterrupt: + pass + finally: + if os.path.exists(lockfile): + os.unlink(lockfile) + return + + try: + if debug is not None: _debug(debug) + app = app or default_app() + if isinstance(app, basestring): + app = load_app(app) + if not callable(app): + raise ValueError("Application is not callable: %r" % app) + + for plugin in plugins or []: + if isinstance(plugin, basestring): + plugin = load(plugin) + app.install(plugin) + + if config: + app.config.update(config) + + if server in server_names: + server = server_names.get(server) + if isinstance(server, basestring): + server = load(server) + if isinstance(server, type): + server = server(host=host, port=port, **kargs) + if not isinstance(server, ServerAdapter): + raise ValueError("Unknown or unsupported server: %r" % server) + + server.quiet = server.quiet or quiet + if not server.quiet: + _stderr("Bottle v%s server starting up (using %s)..." % + (__version__, repr(server))) + if server.host.startswith("unix:"): + _stderr("Listening on %s" % server.host) + else: + _stderr("Listening on http://%s:%d/" % + (server.host, server.port)) + _stderr("Hit Ctrl-C to quit.\n") + + if reloader: + lockfile = os.environ.get('BOTTLE_LOCKFILE') + bgcheck = FileCheckerThread(lockfile, interval) + with bgcheck: + server.run(app) + if bgcheck.status == 'reload': + sys.exit(3) + else: + server.run(app) + except KeyboardInterrupt: + pass + except (SystemExit, MemoryError): + raise + except: + if not reloader: raise + if not getattr(server, 'quiet', quiet): + print_exc() + time.sleep(interval) + sys.exit(3) + + +class FileCheckerThread(threading.Thread): + """ Interrupt main-thread as soon as a changed module file is detected, + the lockfile gets deleted or gets too old. """ + + def __init__(self, lockfile, interval): + threading.Thread.__init__(self) + self.daemon = True + self.lockfile, self.interval = lockfile, interval + #: Is one of 'reload', 'error' or 'exit' + self.status = None + + def run(self): + exists = os.path.exists + mtime = lambda p: os.stat(p).st_mtime + files = dict() + + for module in list(sys.modules.values()): + path = getattr(module, '__file__', '') or '' + if path[-4:] in ('.pyo', '.pyc'): path = path[:-1] + if path and exists(path): files[path] = mtime(path) + + while not self.status: + if not exists(self.lockfile)\ + or mtime(self.lockfile) < time.time() - self.interval - 5: + self.status = 'error' + thread.interrupt_main() + for path, lmtime in list(files.items()): + if not exists(path) or mtime(path) > lmtime: + self.status = 'reload' + thread.interrupt_main() + break + time.sleep(self.interval) + + def __enter__(self): + self.start() + + def __exit__(self, exc_type, *_): + if not self.status: self.status = 'exit' # silent exit + self.join() + return exc_type is not None and issubclass(exc_type, KeyboardInterrupt) + +############################################################################### +# Template Adapters ############################################################ +############################################################################### + + +class TemplateError(BottleException): + pass + + +class BaseTemplate(object): + """ Base class and minimal API for template adapters """ + extensions = ['tpl', 'html', 'thtml', 'stpl'] + settings = {} #used in prepare() + defaults = {} #used in render() + + def __init__(self, + source=None, + name=None, + lookup=None, + encoding='utf8', **settings): + """ Create a new template. + If the source parameter (str or buffer) is missing, the name argument + is used to guess a template filename. Subclasses can assume that + self.source and/or self.filename are set. Both are strings. + The lookup, encoding and settings parameters are stored as instance + variables. + The lookup parameter stores a list containing directory paths. + The encoding parameter should be used to decode byte strings or files. + The settings parameter contains a dict for engine-specific settings. + """ + self.name = name + self.source = source.read() if hasattr(source, 'read') else source + self.filename = source.filename if hasattr(source, 'filename') else None + self.lookup = [os.path.abspath(x) for x in lookup] if lookup else [] + self.encoding = encoding + self.settings = self.settings.copy() # Copy from class variable + self.settings.update(settings) # Apply + if not self.source and self.name: + self.filename = self.search(self.name, self.lookup) + if not self.filename: + raise TemplateError('Template %s not found.' % repr(name)) + if not self.source and not self.filename: + raise TemplateError('No template specified.') + self.prepare(**self.settings) + + @classmethod + def search(cls, name, lookup=None): + """ Search name in all directories specified in lookup. + First without, then with common extensions. Return first hit. """ + if not lookup: + raise depr(0, 12, "Empty template lookup path.", "Configure a template lookup path.") + + if os.path.isabs(name): + raise depr(0, 12, "Use of absolute path for template name.", + "Refer to templates with names or paths relative to the lookup path.") + + for spath in lookup: + spath = os.path.abspath(spath) + os.sep + fname = os.path.abspath(os.path.join(spath, name)) + if not fname.startswith(spath): continue + if os.path.isfile(fname): return fname + for ext in cls.extensions: + if os.path.isfile('%s.%s' % (fname, ext)): + return '%s.%s' % (fname, ext) + + @classmethod + def global_config(cls, key, *args): + """ This reads or sets the global settings stored in class.settings. """ + if args: + cls.settings = cls.settings.copy() # Make settings local to class + cls.settings[key] = args[0] + else: + return cls.settings[key] + + def prepare(self, **options): + """ Run preparations (parsing, caching, ...). + It should be possible to call this again to refresh a template or to + update settings. + """ + raise NotImplementedError + + def render(self, *args, **kwargs): + """ Render the template with the specified local variables and return + a single byte or unicode string. If it is a byte string, the encoding + must match self.encoding. This method must be thread-safe! + Local variables may be provided in dictionaries (args) + or directly, as keywords (kwargs). + """ + raise NotImplementedError + + +class MakoTemplate(BaseTemplate): + def prepare(self, **options): + from mako.template import Template + from mako.lookup import TemplateLookup + options.update({'input_encoding': self.encoding}) + options.setdefault('format_exceptions', bool(DEBUG)) + lookup = TemplateLookup(directories=self.lookup, **options) + if self.source: + self.tpl = Template(self.source, lookup=lookup, **options) + else: + self.tpl = Template(uri=self.name, + filename=self.filename, + lookup=lookup, **options) + + def render(self, *args, **kwargs): + for dictarg in args: + kwargs.update(dictarg) + _defaults = self.defaults.copy() + _defaults.update(kwargs) + return self.tpl.render(**_defaults) + + +class CheetahTemplate(BaseTemplate): + def prepare(self, **options): + from Cheetah.Template import Template + self.context = threading.local() + self.context.vars = {} + options['searchList'] = [self.context.vars] + if self.source: + self.tpl = Template(source=self.source, **options) + else: + self.tpl = Template(file=self.filename, **options) + + def render(self, *args, **kwargs): + for dictarg in args: + kwargs.update(dictarg) + self.context.vars.update(self.defaults) + self.context.vars.update(kwargs) + out = str(self.tpl) + self.context.vars.clear() + return out + + +class Jinja2Template(BaseTemplate): + def prepare(self, filters=None, tests=None, globals={}, **kwargs): + from jinja2 import Environment, FunctionLoader + self.env = Environment(loader=FunctionLoader(self.loader), **kwargs) + if filters: self.env.filters.update(filters) + if tests: self.env.tests.update(tests) + if globals: self.env.globals.update(globals) + if self.source: + self.tpl = self.env.from_string(self.source) + else: + self.tpl = self.env.get_template(self.name) + + def render(self, *args, **kwargs): + for dictarg in args: + kwargs.update(dictarg) + _defaults = self.defaults.copy() + _defaults.update(kwargs) + return self.tpl.render(**_defaults) + + def loader(self, name): + if name == self.filename: + fname = name + else: + fname = self.search(name, self.lookup) + if not fname: return + with open(fname, "rb") as f: + return (f.read().decode(self.encoding), fname, lambda: False) + + +class SimpleTemplate(BaseTemplate): + def prepare(self, + escape_func=html_escape, + noescape=False, + syntax=None, **ka): + self.cache = {} + enc = self.encoding + self._str = lambda x: touni(x, enc) + self._escape = lambda x: escape_func(touni(x, enc)) + self.syntax = syntax + if noescape: + self._str, self._escape = self._escape, self._str + + @cached_property + def co(self): + return compile(self.code, self.filename or '', 'exec') + + @cached_property + def code(self): + source = self.source + if not source: + with open(self.filename, 'rb') as f: + source = f.read() + try: + source, encoding = touni(source), 'utf8' + except UnicodeError: + raise depr(0, 11, 'Unsupported template encodings.', 'Use utf-8 for templates.') + parser = StplParser(source, encoding=encoding, syntax=self.syntax) + code = parser.translate() + self.encoding = parser.encoding + return code + + def _rebase(self, _env, _name=None, **kwargs): + _env['_rebase'] = (_name, kwargs) + + def _include(self, _env, _name=None, **kwargs): + env = _env.copy() + env.update(kwargs) + if _name not in self.cache: + self.cache[_name] = self.__class__(name=_name, lookup=self.lookup, syntax=self.syntax) + return self.cache[_name].execute(env['_stdout'], env) + + def execute(self, _stdout, kwargs): + env = self.defaults.copy() + env.update(kwargs) + env.update({ + '_stdout': _stdout, + '_printlist': _stdout.extend, + 'include': functools.partial(self._include, env), + 'rebase': functools.partial(self._rebase, env), + '_rebase': None, + '_str': self._str, + '_escape': self._escape, + 'get': env.get, + 'setdefault': env.setdefault, + 'defined': env.__contains__ + }) + exec(self.co, env) + if env.get('_rebase'): + subtpl, rargs = env.pop('_rebase') + rargs['base'] = ''.join(_stdout) #copy stdout + del _stdout[:] # clear stdout + return self._include(env, subtpl, **rargs) + return env + + def render(self, *args, **kwargs): + """ Render the template using keyword arguments as local variables. """ + env = {} + stdout = [] + for dictarg in args: + env.update(dictarg) + env.update(kwargs) + self.execute(stdout, env) + return ''.join(stdout) + + +class StplSyntaxError(TemplateError): + pass + + +class StplParser(object): + """ Parser for stpl templates. """ + _re_cache = {} #: Cache for compiled re patterns + + # This huge pile of voodoo magic splits python code into 8 different tokens. + # We use the verbose (?x) regex mode to make this more manageable + + _re_tok = r'''( + [urbURB]* + (?: ''(?!') + |""(?!") + |'{6} + |"{6} + |'(?:[^\\']|\\.)+?' + |"(?:[^\\"]|\\.)+?" + |'{3}(?:[^\\]|\\.|\n)+?'{3} + |"{3}(?:[^\\]|\\.|\n)+?"{3} + ) + )''' + + _re_inl = _re_tok.replace(r'|\n', '') # We re-use this string pattern later + + _re_tok += r''' + # 2: Comments (until end of line, but not the newline itself) + |(\#.*) + + # 3: Open and close (4) grouping tokens + |([\[\{\(]) + |([\]\}\)]) + + # 5,6: Keywords that start or continue a python block (only start of line) + |^([\ \t]*(?:if|for|while|with|try|def|class)\b) + |^([\ \t]*(?:elif|else|except|finally)\b) + + # 7: Our special 'end' keyword (but only if it stands alone) + |((?:^|;)[\ \t]*end[\ \t]*(?=(?:%(block_close)s[\ \t]*)?\r?$|;|\#)) + + # 8: A customizable end-of-code-block template token (only end of line) + |(%(block_close)s[\ \t]*(?=\r?$)) + + # 9: And finally, a single newline. The 10th token is 'everything else' + |(\r?\n) + ''' + + # Match the start tokens of code areas in a template + _re_split = r'''(?m)^[ \t]*(\\?)((%(line_start)s)|(%(block_start)s))''' + # Match inline statements (may contain python strings) + _re_inl = r'''%%(inline_start)s((?:%s|[^'"\n])*?)%%(inline_end)s''' % _re_inl + + # add the flag in front of the regexp to avoid Deprecation warning (see Issue #949) + # verbose and dot-matches-newline mode + _re_tok = '(?mx)' + _re_tok + _re_inl = '(?mx)' + _re_inl + + + default_syntax = '<% %> % {{ }}' + + def __init__(self, source, syntax=None, encoding='utf8'): + self.source, self.encoding = touni(source, encoding), encoding + self.set_syntax(syntax or self.default_syntax) + self.code_buffer, self.text_buffer = [], [] + self.lineno, self.offset = 1, 0 + self.indent, self.indent_mod = 0, 0 + self.paren_depth = 0 + + def get_syntax(self): + """ Tokens as a space separated string (default: <% %> % {{ }}) """ + return self._syntax + + def set_syntax(self, syntax): + self._syntax = syntax + self._tokens = syntax.split() + if syntax not in self._re_cache: + names = 'block_start block_close line_start inline_start inline_end' + etokens = map(re.escape, self._tokens) + pattern_vars = dict(zip(names.split(), etokens)) + patterns = (self._re_split, self._re_tok, self._re_inl) + patterns = [re.compile(p % pattern_vars) for p in patterns] + self._re_cache[syntax] = patterns + self.re_split, self.re_tok, self.re_inl = self._re_cache[syntax] + + syntax = property(get_syntax, set_syntax) + + def translate(self): + if self.offset: raise RuntimeError('Parser is a one time instance.') + while True: + m = self.re_split.search(self.source, pos=self.offset) + if m: + text = self.source[self.offset:m.start()] + self.text_buffer.append(text) + self.offset = m.end() + if m.group(1): # Escape syntax + line, sep, _ = self.source[self.offset:].partition('\n') + self.text_buffer.append(self.source[m.start():m.start(1)] + + m.group(2) + line + sep) + self.offset += len(line + sep) + continue + self.flush_text() + self.offset += self.read_code(self.source[self.offset:], + multiline=bool(m.group(4))) + else: + break + self.text_buffer.append(self.source[self.offset:]) + self.flush_text() + return ''.join(self.code_buffer) + + def read_code(self, pysource, multiline): + code_line, comment = '', '' + offset = 0 + while True: + m = self.re_tok.search(pysource, pos=offset) + if not m: + code_line += pysource[offset:] + offset = len(pysource) + self.write_code(code_line.strip(), comment) + break + code_line += pysource[offset:m.start()] + offset = m.end() + _str, _com, _po, _pc, _blk1, _blk2, _end, _cend, _nl = m.groups() + if self.paren_depth > 0 and (_blk1 or _blk2): # a if b else c + code_line += _blk1 or _blk2 + continue + if _str: # Python string + code_line += _str + elif _com: # Python comment (up to EOL) + comment = _com + if multiline and _com.strip().endswith(self._tokens[1]): + multiline = False # Allow end-of-block in comments + elif _po: # open parenthesis + self.paren_depth += 1 + code_line += _po + elif _pc: # close parenthesis + if self.paren_depth > 0: + # we could check for matching parentheses here, but it's + # easier to leave that to python - just check counts + self.paren_depth -= 1 + code_line += _pc + elif _blk1: # Start-block keyword (if/for/while/def/try/...) + code_line = _blk1 + self.indent += 1 + self.indent_mod -= 1 + elif _blk2: # Continue-block keyword (else/elif/except/...) + code_line = _blk2 + self.indent_mod -= 1 + elif _cend: # The end-code-block template token (usually '%>') + if multiline: multiline = False + else: code_line += _cend + elif _end: + self.indent -= 1 + self.indent_mod += 1 + else: # \n + self.write_code(code_line.strip(), comment) + self.lineno += 1 + code_line, comment, self.indent_mod = '', '', 0 + if not multiline: + break + + return offset + + def flush_text(self): + text = ''.join(self.text_buffer) + del self.text_buffer[:] + if not text: return + parts, pos, nl = [], 0, '\\\n' + ' ' * self.indent + for m in self.re_inl.finditer(text): + prefix, pos = text[pos:m.start()], m.end() + if prefix: + parts.append(nl.join(map(repr, prefix.splitlines(True)))) + if prefix.endswith('\n'): parts[-1] += nl + parts.append(self.process_inline(m.group(1).strip())) + if pos < len(text): + prefix = text[pos:] + lines = prefix.splitlines(True) + if lines[-1].endswith('\\\\\n'): lines[-1] = lines[-1][:-3] + elif lines[-1].endswith('\\\\\r\n'): lines[-1] = lines[-1][:-4] + parts.append(nl.join(map(repr, lines))) + code = '_printlist((%s,))' % ', '.join(parts) + self.lineno += code.count('\n') + 1 + self.write_code(code) + + @staticmethod + def process_inline(chunk): + if chunk[0] == '!': return '_str(%s)' % chunk[1:] + return '_escape(%s)' % chunk + + def write_code(self, line, comment=''): + code = ' ' * (self.indent + self.indent_mod) + code += line.lstrip() + comment + '\n' + self.code_buffer.append(code) + + +def template(*args, **kwargs): + """ + Get a rendered template as a string iterator. + You can use a name, a filename or a template string as first parameter. + Template rendering arguments can be passed as dictionaries + or directly (as keyword arguments). + """ + tpl = args[0] if args else None + for dictarg in args[1:]: + kwargs.update(dictarg) + adapter = kwargs.pop('template_adapter', SimpleTemplate) + lookup = kwargs.pop('template_lookup', TEMPLATE_PATH) + tplid = (id(lookup), tpl) + if tplid not in TEMPLATES or DEBUG: + settings = kwargs.pop('template_settings', {}) + if isinstance(tpl, adapter): + TEMPLATES[tplid] = tpl + if settings: TEMPLATES[tplid].prepare(**settings) + elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl: + TEMPLATES[tplid] = adapter(source=tpl, lookup=lookup, **settings) + else: + TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings) + if not TEMPLATES[tplid]: + abort(500, 'Template (%s) not found' % tpl) + return TEMPLATES[tplid].render(kwargs) + + +mako_template = functools.partial(template, template_adapter=MakoTemplate) +cheetah_template = functools.partial(template, + template_adapter=CheetahTemplate) +jinja2_template = functools.partial(template, template_adapter=Jinja2Template) + + +def view(tpl_name, **defaults): + """ Decorator: renders a template for a handler. + The handler can control its behavior like that: + + - return a dict of template vars to fill out the template + - return something other than a dict and the view decorator will not + process the template, but return the handler result as is. + This includes returning a HTTPResponse(dict) to get, + for instance, JSON with autojson or other castfilters. + """ + + def decorator(func): + + @functools.wraps(func) + def wrapper(*args, **kwargs): + result = func(*args, **kwargs) + if isinstance(result, (dict, DictMixin)): + tplvars = defaults.copy() + tplvars.update(result) + return template(tpl_name, **tplvars) + elif result is None: + return template(tpl_name, **defaults) + return result + + return wrapper + + return decorator + + +mako_view = functools.partial(view, template_adapter=MakoTemplate) +cheetah_view = functools.partial(view, template_adapter=CheetahTemplate) +jinja2_view = functools.partial(view, template_adapter=Jinja2Template) + +############################################################################### +# Constants and Globals ######################################################## +############################################################################### + +TEMPLATE_PATH = ['./', './views/'] +TEMPLATES = {} +DEBUG = False +NORUN = False # If set, run() does nothing. Used by load_app() + +#: A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found') +HTTP_CODES = httplib.responses.copy() +HTTP_CODES[418] = "I'm a teapot" # RFC 2324 +HTTP_CODES[428] = "Precondition Required" +HTTP_CODES[429] = "Too Many Requests" +HTTP_CODES[431] = "Request Header Fields Too Large" +HTTP_CODES[451] = "Unavailable For Legal Reasons" # RFC 7725 +HTTP_CODES[511] = "Network Authentication Required" +_HTTP_STATUS_LINES = dict((k, '%d %s' % (k, v)) + for (k, v) in HTTP_CODES.items()) + +#: The default template used for error pages. Override with @error() +ERROR_PAGE_TEMPLATE = """ +%%try: + %%from %s import DEBUG, request + + + + Error: {{e.status}} + + + +

    Error: {{e.status}}

    +

    Sorry, the requested URL {{repr(request.url)}} + caused an error:

    +
    {{e.body}}
    + %%if DEBUG and e.exception: +

    Exception:

    + %%try: + %%exc = repr(e.exception) + %%except: + %%exc = '' %% type(e.exception).__name__ + %%end +
    {{exc}}
    + %%end + %%if DEBUG and e.traceback: +

    Traceback:

    +
    {{e.traceback}}
    + %%end + + +%%except ImportError: + ImportError: Could not generate the error page. Please add bottle to + the import path. +%%end +""" % __name__ + +#: A thread-safe instance of :class:`LocalRequest`. If accessed from within a +#: request callback, this instance always refers to the *current* request +#: (even on a multi-threaded server). +request = LocalRequest() + +#: A thread-safe instance of :class:`LocalResponse`. It is used to change the +#: HTTP response for the *current* request. +response = LocalResponse() + +#: A thread-safe namespace. Not used by Bottle. +local = threading.local() + +# Initialize app stack (create first empty Bottle app now deferred until needed) +# BC: 0.6.4 and needed for run() +apps = app = default_app = AppStack() + +#: A virtual package that redirects import statements. +#: Example: ``import bottle.ext.sqlite`` actually imports `bottle_sqlite`. +ext = _ImportRedirect('bottle.ext' if __name__ == '__main__' else + __name__ + ".ext", 'bottle_%s').module + + +def _main(argv): # pragma: no coverage + args, parser = _cli_parse(argv) + + def _cli_error(cli_msg): + parser.print_help() + _stderr('\nError: %s\n' % cli_msg) + sys.exit(1) + + if args.version: + print('Bottle %s' % __version__) + sys.exit(0) + if not args.app: + _cli_error("No application entry point specified.") + + sys.path.insert(0, '.') + sys.modules.setdefault('bottle', sys.modules['__main__']) + + host, port = (args.bind or 'localhost'), 8080 + if ':' in host and host.rfind(']') < host.rfind(':'): + host, port = host.rsplit(':', 1) + host = host.strip('[]') + + config = ConfigDict() + + for cfile in args.conf or []: + try: + if cfile.endswith('.json'): + with open(cfile, 'rb') as fp: + config.load_dict(json_loads(fp.read())) + else: + config.load_config(cfile) + except configparser.Error as parse_error: + _cli_error(parse_error) + except IOError: + _cli_error("Unable to read config file %r" % cfile) + except (UnicodeError, TypeError, ValueError) as error: + _cli_error("Unable to parse config file %r: %s" % (cfile, error)) + + for cval in args.param or []: + if '=' in cval: + config.update((cval.split('=', 1),)) + else: + config[cval] = True + + run(args.app, + host=host, + port=int(port), + server=args.server, + reloader=args.reload, + plugins=args.plugin, + debug=args.debug, + config=config) + + +def main(): + _main(sys.argv) + + +if __name__ == '__main__': # pragma: no coverage + main() diff --git a/3rdparty/mongo-c-driver-2.1.0/build/cmake/BuildVersion.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/BuildVersion.cmake new file mode 100644 index 000000000..b6d0e6601 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/BuildVersion.cmake @@ -0,0 +1,25 @@ +include_guard(GLOBAL) + +#[[ + Attempts to find the current build version string by reading VERSION_CURRENT + from the current source directory. + + The computed build version is set in the parent scope according to `outvar`. +]] +function(compute_build_version outvar) + list(APPEND CMAKE_MESSAGE_CONTEXT ${CMAKE_CURRENT_FUNCTION}) + # If it is present, defer to the VERSION_CURRENT file: + set(ver_cur_file "${CMAKE_CURRENT_SOURCE_DIR}/VERSION_CURRENT") + message(DEBUG "Using existing VERSION_CURRENT file as BUILD_VERSION [${ver_cur_file}]") + file(READ "${ver_cur_file}" version) + message(DEBUG "VERSION_CURRENT is “${version}â€") + set("${outvar}" "${version}" PARENT_SCOPE) +endfunction() + +# Compute the BUILD_VERSION if it is not already defined: +if(NOT DEFINED BUILD_VERSION) + compute_build_version(BUILD_VERSION) +endif() + +# Set a BUILD_VERSION_SIMPLE, which is just a three-number-triple that CMake understands +string (REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+).*$" "\\1" BUILD_VERSION_SIMPLE "${BUILD_VERSION}") diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/CheckSchedGetCPU.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/CheckSchedGetCPU.cmake similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/CheckSchedGetCPU.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/CheckSchedGetCPU.cmake diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/FindSASL2.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/FindSASL2.cmake similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/FindSASL2.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/FindSASL2.cmake diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/FindSnappy.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/FindSnappy.cmake similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/FindSnappy.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/FindSnappy.cmake diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/FindSphinx.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/FindSphinx.cmake similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/FindSphinx.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/FindSphinx.cmake diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/FindUtf8Proc.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/FindUtf8Proc.cmake similarity index 81% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/FindUtf8Proc.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/FindUtf8Proc.cmake index 62fb9f8c4..271fc1408 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/FindUtf8Proc.cmake +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/FindUtf8Proc.cmake @@ -1,6 +1,6 @@ if(USE_BUNDLED_UTF8PROC) message (STATUS "Enabling utf8proc (bundled)") - add_library (utf8proc_obj OBJECT "${UTF8PROC_SOURCES}") + add_library (utf8proc_obj OBJECT "${mongo-c-driver_SOURCE_DIR}/src/utf8proc-2.8.0/utf8proc.c") set_property (TARGET utf8proc_obj PROPERTY POSITION_INDEPENDENT_CODE TRUE) target_compile_definitions (utf8proc_obj PUBLIC UTF8PROC_STATIC) else () diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/GeneratePkgConfig.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/GeneratePkgConfig.cmake similarity index 96% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/GeneratePkgConfig.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/GeneratePkgConfig.cmake index 99f38fa2a..8e9d77f17 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/GeneratePkgConfig.cmake +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/GeneratePkgConfig.cmake @@ -225,7 +225,8 @@ function(mongo_generate_pkg_config target) file(READ [[@gx_tmpfile@]] content) # Insert the install prefix: string(REPLACE "%INSTALL_PLACEHOLDER%" "${CMAKE_INSTALL_PREFIX}" content "${content}") - # Write it before installing again: + # Write it before installing again. Lock the file to sync with parallel installs. + file(LOCK [[@inst_tmp@.lock]] GUARD PROCESS) file(WRITE [[@inst_tmp@]] "${content}") > $<$: @@ -277,8 +278,11 @@ function(_generate_pkg_config_content out) set(libs) # Link options: set(gx_libs - "-L\${libdir}" - "-l$" + $,STATIC_LIBRARY>, + # If linking static, emit the full path to the static library file + \${libdir}/$, + # Otherwise, link to the dynamic library namelink + -L\${libdir} -l$> $> $> ) diff --git a/3rdparty/mongo-c-driver-2.1.0/build/cmake/GenerateUninstaller.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/GenerateUninstaller.cmake new file mode 100644 index 000000000..ef2d993bb --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/GenerateUninstaller.cmake @@ -0,0 +1,276 @@ +# This script may be executed in script mode by the uninstall target. +cmake_policy(VERSION 3.15...4.0) + +# Avoid CMake Issue 26678: https://gitlab.kitware.com/cmake/cmake/-/issues/26678 +if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.27") + cmake_policy(SET CMP0147 OLD) +endif() + +if(NOT CMAKE_SCRIPT_MODE_FILE) + # We are being included from within a project, so we should generate the install rules + # The script name is "uninstall" by default: + if(NOT DEFINED UNINSTALL_SCRIPT_NAME) + set(UNINSTALL_SCRIPT_NAME "uninstall") + endif() + # We need a directory where we should install the script: + if(NOT UNINSTALL_PROG_DIR) + message(SEND_ERROR "We require an UNINSTALL_PROG_DIR to be defined") + endif() + # Platform dependent values: + if(WIN32) + set(_script_ext "cmd") + else() + set(_script_ext "sh") + endif() + # The script filename and path: + set(_script_filename "${UNINSTALL_SCRIPT_NAME}.${_script_ext}") + get_filename_component(_uninstaller_script "${CMAKE_CURRENT_BINARY_DIR}/${_script_filename}" ABSOLUTE) + # Code that will do the work at install-time: + string(CONFIGURE [==[ + function(__generate_uninstall) + set(UNINSTALL_IS_WIN32 "@WIN32@") + set(UNINSTALL_WRITE_FILE "@_uninstaller_script@") + set(UNINSTALL_SCRIPT_SELF "@UNINSTALL_PROG_DIR@/@_script_filename@") + include("@CMAKE_CURRENT_LIST_FILE@") + endfunction() + __generate_uninstall() + ]==] code @ONLY ESCAPE_QUOTES) + install(CODE "${code}") + # Add a rule to install that file: + install( + FILES "${_uninstaller_script}" + DESTINATION "${UNINSTALL_PROG_DIR}" + PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + ) + + # If applicable, generate an "uninstall" target to run the uninstaller: + if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR OR PROJECT_IS_TOP_LEVEL) + add_custom_target( + uninstall + COMMAND "${_uninstaller_script}" + COMMENT Uninstalling... + ) + endif() + # Stop here: The rest of the file is for install-time + return() +endif() + +if(NOT DEFINED CMAKE_INSTALL_MANIFEST_FILES) + message(FATAL_ERROR "This file is only for use with CMake's install(CODE/SCRIPT) command") +endif() +if(NOT DEFINED UNINSTALL_WRITE_FILE) + message(FATAL_ERROR "Expected a variable “UNINSTALL_WRITE_FILE†to be defined") +endif() + +# Lock the uninstall file to synchronize with parallel install processes. +file(LOCK "${UNINSTALL_WRITE_FILE}.lock" GUARD PROCESS RESULT_VARIABLE lockres) +# Clear out the uninstall script before we begin writing: +file(WRITE "${UNINSTALL_WRITE_FILE}" "") + +# Append a line to the uninstall script file. Single quotes will be replaced with doubles, +# and an appropriate newline will be added. +function(append_line line) + string(REPLACE "'" "\"" line "${line}") + file(APPEND "${UNINSTALL_WRITE_FILE}" "${line}\n") +endfunction() + +# Ensure generated uninstall script has executable permissions. +if ("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.19.0") + file ( + CHMOD "${UNINSTALL_WRITE_FILE}" + PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + ) +else () + # Workaround lack of file(CHMOD). + get_filename_component(_script_filename "${UNINSTALL_WRITE_FILE}" NAME) + file ( + COPY "${UNINSTALL_WRITE_FILE}" + DESTINATION "${_script_filename}.d" + FILE_PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + ) + file (RENAME "${_script_filename}.d/${_script_filename}" "${_script_filename}") +endif () + +# The copyright header: +set(header [[ +MongoDB C Driver uninstall program, generated with CMake + +Copyright 2009-present MongoDB, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.]]) +string(STRIP header "${header}") +string(REPLACE "\n" ";" header_lines "${header}") + +# Prefix for the shell script: +set(sh_preamble [[ +set -eu + +__rmfile() { + set -eu + abs=$__prefix/$1 + printf "Remove file %s: " "$abs" + if test -f "$abs" || test -L "$abs" + then + rm -- "$abs" + echo "ok" + else + echo "skipped: not present" + fi +} + +__rmdir() { + set -eu + abs=$__prefix/$1 + printf "Remove directory %s: " "$abs" + if test -d "$abs" + then + list="$(find "$abs" -mindepth 1)" + if test "$list" = "" + then + rmdir -- "$abs" 2>/dev/null && echo "ok" || echo "skipped: not empty" + fi + else + echo "skipped: not present" + fi +} +]]) + +# Convert the install prefix to an absolute path with the native path format: +get_filename_component(install_prefix "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) +file(TO_NATIVE_PATH "${install_prefix}" install_prefix) +# Handling DESTDIR requires careful handling of root path redirection: +set(root_path) +set(relative_prefix "${install_prefix}") +if(COMMAND cmake_path) + cmake_path(GET install_prefix ROOT_PATH root_path) + cmake_path(GET install_prefix RELATIVE_PART relative_prefix) +endif() + +# The first lines that will be written to the script: +set(init_lines) + +if(UNINSTALL_IS_WIN32) + # Comment the header: + list(TRANSFORM header_lines PREPEND "rem " REGEX "^.+$") + list(TRANSFORM header_lines PREPEND "rem" REGEX "^$") + # Add the preamble + list(APPEND init_lines + "@echo off" + "" + "${header_lines}" + "" + "if \"%DESTDIR%\"==\"\" (set __prefix=${install_prefix}) else (set __prefix=!DESTDIR!\\${relative_prefix})" + "" + "(GOTO) 2>nul & (") +else() + # Comment the header: + list(TRANSFORM header_lines PREPEND "# " REGEX "^.+$") + list(TRANSFORM header_lines PREPEND "#" REGEX "^$") + # Add the preamble + list(APPEND init_lines + "#!/usr/bin/env bash" + "#" + "${header_lines}" + "" + "${sh_preamble}" + "__prefix=\${DESTDIR:-}${install_prefix}" + "") +endif() + +# Add the first lines to the file: +string(REPLACE ";" "\n" init "${init_lines}") +append_line("${init}") + +# Generate a "remove a file" command +function(add_rmfile filename) + file(TO_NATIVE_PATH "${filename}" native) + if(WIN32) + set(file "%__prefix%\\${native}") + set(rmfile_lines + " nul && echo - ok || echo - skipped ^(non-empty?^)" + " ) ELSE echo - skipped: not present" + ") && (") + string(REPLACE ";" "\n" rmdir "${rmdir_lines}") + append_line("${rmdir}") + else() + append_line("__rmdir '${native}'") + endif() +endfunction() + +set(script_self "${install_prefix}/${UNINSTALL_SCRIPT_SELF}") +set(dirs_to_remove) +foreach(installed IN LISTS CMAKE_INSTALL_MANIFEST_FILES script_self) + # Get the relative path from the prefix (the uninstaller will fix it up later) + file(RELATIVE_PATH relpath "${install_prefix}" "${installed}") + # Add a removal: + add_rmfile("${relpath}") + # Climb the path and collect directories: + while("1") + get_filename_component(installed "${installed}" DIRECTORY) + file(TO_NATIVE_PATH "${installed}" installed) + get_filename_component(parent "${installed}" DIRECTORY) + file(TO_NATIVE_PATH "${parent}" parent) + # Don't account for the prefix or direct children of the prefix: + if(installed STREQUAL install_prefix OR parent STREQUAL install_prefix) + break() + endif() + # Keep track of this directory for later: + list(APPEND dirs_to_remove "${installed}") + endwhile() +endforeach() + +# Now generate commands to remove (empty) directories: +list(REMOVE_DUPLICATES dirs_to_remove) +# Order them by depth so that we remove subdirectories before their parents: +list(SORT dirs_to_remove ORDER DESCENDING) +foreach(dir IN LISTS dirs_to_remove) + file(RELATIVE_PATH relpath "${install_prefix}" "${dir}") + add_rmdir("${relpath}") +endforeach() + +# Allow the batch script delete itself without error. +if(WIN32) + append_line(" ver>nul") + append_line(")") +endif() + +message(STATUS "Generated uninstaller: ${UNINSTALL_WRITE_FILE}") diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/LLDLinker.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/LLDLinker.cmake similarity index 91% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/LLDLinker.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/LLDLinker.cmake index 998ec8570..20b06768d 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/LLDLinker.cmake +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/LLDLinker.cmake @@ -56,5 +56,7 @@ endif () if (MONGO_USE_LLD) message (STATUS "Linking using LLVM lld. Disable by setting MONGO_USE_LLD to OFF") - add_link_options (-fuse-ld=lld) + # We only tested with C, so only use LLD on C (some platforms don't support lld with g++) + # XXX: This should use $ when we can require CMake 3.18+ + add_link_options ($<$:-fuse-ld=lld>) endif () diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/LoadTests.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/LoadTests.cmake similarity index 92% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/LoadTests.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/LoadTests.cmake index c837559ab..262797b47 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/LoadTests.cmake +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/LoadTests.cmake @@ -52,5 +52,8 @@ foreach (line IN LISTS lines) TIMEOUT 45 FIXTURES_REQUIRED "${all_fixtures}" ENVIRONMENT "${all_env}" + # Mark all tests generated from the executable, so they can be (de)selected + # for execution separately. + LABELS "test-libmongoc-generated" ) endforeach () diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/LoadVersion.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/LoadVersion.cmake similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/LoadVersion.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/LoadVersion.cmake diff --git a/3rdparty/mongo-c-driver-2.1.0/build/cmake/MongoC-Warnings.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/MongoC-Warnings.cmake new file mode 100644 index 000000000..aad93436e --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/MongoC-Warnings.cmake @@ -0,0 +1,106 @@ +#[[ + This file sets warning options in the "mongoc-warning-options" variable when included. + + These warnings are intended to be ported to each supported platform, and + especially for high-value warnings that are very likely to catch latent bugs + early in the process before the code is even run. +]] + +#[[ + Appends additional compile options to the "mongoc-warning-options" variable, conditioned + on the compiler being used. + + Each option should be prefixed by `gnu:`, `clang:`, `msvc:`, or `gnu-like:`. + Those options will be conditionally enabled for GCC, Clang, or MSVC. +]] +function (mongoc_add_warning_options) + list(APPEND CMAKE_MESSAGE_CONTEXT ${CMAKE_CURRENT_FUNCTION}) + # Conditional prefixes: + set(cond/gnu $) + set(cond/llvm-clang $) + set(cond/apple-clang $) + set(cond/clang $) + set(cond/gnu-like $) + set(cond/msvc $) + set(cond/lang-c $) + # "Old" GNU is GCC < 5, which is missing several warning options + set(cond/gcc-lt5 $,5>>) + set(cond/gcc-lt7 $,7>>) + set(cond/gcc-lt8 $,8>>) + set(cond/gcc-lt11 $,11>>) + set(cond/clang-lt4 $,4>>) + set(cond/clang-lt10 $,10>>) + set(cond/clang-lt19 $,19>>) + # Process options: + foreach (opt IN LISTS ARGV) + # Replace prefixes. Matches right-most first: + while (opt MATCHES "(.*)(^|:)([a-z0-9-]+):(.*)") + set(before "${CMAKE_MATCH_1}${CMAKE_MATCH_2}") + set(prefix "${CMAKE_MATCH_3}") + set(suffix "${CMAKE_MATCH_4}") + message(TRACE "Substitution: prefix “${prefix}†in “${opt}â€, suffix is “${suffix}â€") + set(cond "cond/${prefix}") + set(not 0) + if(prefix MATCHES "^not-(.*)") + set(cond "cond/${CMAKE_MATCH_1}") + set(not 1) + endif() + if(DEFINED "${cond}") + set(expr "${${cond}}") + if(not) + set(expr "$") + endif() + set(opt "$<${expr}:${suffix}>") + else () + message (SEND_ERROR "Unknown option prefix to ${CMAKE_CURRENT_FUNCTION}(): “${prefix}†in “${opt}â€") + break() + endif () + set(opt "${before}${opt}") + message(TRACE "Become: ${opt}") + endwhile () + list(APPEND mongoc-warning-options "${opt}") + endforeach () + set(mongoc-warning-options "${mongoc-warning-options}" PARENT_SCOPE) +endfunction () + +set (is_c_lang "$") + +set (mongoc-warning-options "") + +# These below warnings should always be unconditional hard errors, as the code is +# almost definitely broken +mongoc_add_warning_options ( + # Implicit function or variable declarations + gnu-like:lang-c:-Werror=implicit msvc:/we4013 msvc:/we4431 + # Missing return types/statements + gnu-like:-Werror=return-type msvc:/we4716 + # Incompatible pointer types + gnu-like:lang-c:not-gcc-lt5:-Werror=incompatible-pointer-types msvc:/we4113 + # Integral/pointer conversions + gnu-like:lang-c:not-gcc-lt5:-Werror=int-conversion msvc:/we4047 + # Discarding qualifiers + gnu:lang-c:not-gcc-lt5:-Werror=discarded-qualifiers + clang:lang-c:-Werror=ignored-qualifiers + msvc:/we4090 + # Definite use of uninitialized value + gnu-like:-Werror=uninitialized msvc:/we4700 + + # Format strings. + gnu-like:-Werror=format + gnu-like:-Werror=format=2 + # GCC does not document the full list of warnings enabled by -Wformat. + # For assurance, explicitly include those not listed by -Wformat or -Wformat=2. + gnu:not-gcc-lt11:-Werror=format-diag + gnu:not-gcc-lt8:-Werror=format-overflow=2 + gnu:not-gcc-lt5:-Werror=format-signedness + gnu:not-gcc-lt8:-Werror=format-truncation=2 + # Clang does not include several flags in `-Wformat` or `-Wformat=2`. + # For assurance, explicitly include those not listed by -Wformat or -Wformat=2. + clang:-Werror=format-non-iso + clang:not-clang-lt4:-Werror=format-pedantic + clang:not-clang-lt19:-Werror=format-signedness + clang:not-clang-lt10:-Werror=format-type-confusion + + # Aside: Disable CRT insecurity warnings + msvc:/D_CRT_SECURE_NO_WARNINGS + ) diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/MongoPlatform.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/MongoPlatform.cmake similarity index 88% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/MongoPlatform.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/MongoPlatform.cmake index d5e5d1075..e5dccab3a 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/MongoPlatform.cmake +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/MongoPlatform.cmake @@ -8,9 +8,9 @@ Use mongo_platform_compile_options and mongo_platform_link_options to add usage requirements to this library. The mongo::detail::c_platform library is installed and exported with the -bson-targets export set as an implementation detail. It is installed with this +mongo-platform-targets export set as an implementation detail. It is installed with this export set so that it is available to both libbson and libmongoc (attempting to -install this target in both bson-targets and mongoc-targets export sets would +install this target in both mongo-platform-targets and mongoc-targets export sets would lead to duplicate definitions of mongo::detail::c_platform for downstream users). @@ -23,9 +23,9 @@ else () # The system libbson exports the `mongo::detail::c_platform` target. # Do not define the `mongo::detail::c_platform` target, to prevent an "already defined" error. endif () -set_property(TARGET _mongo-platform PROPERTY EXPORT_NAME detail::c_platform) -install(TARGETS _mongo-platform EXPORT bson-targets) - +set_property(TARGET _mongo-platform PROPERTY EXPORT_NAME mongo::detail::c_platform) +# This export set is installed as part of libbson. Search: PLATFORM-EXPORT-TARGET-INSTALL +install(TARGETS _mongo-platform EXPORT mongo-platform-targets) #[[ Define additional platform-support compile options diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/MongoSettings.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/MongoSettings.cmake similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/MongoSettings.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/MongoSettings.cmake diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/ParseVersion.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/ParseVersion.cmake similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/ParseVersion.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/ParseVersion.cmake diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/ResSearch.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/ResSearch.cmake similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/ResSearch.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/ResSearch.cmake diff --git a/3rdparty/mongo-c-driver-2.1.0/build/cmake/Sanitizers.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/Sanitizers.cmake new file mode 100644 index 000000000..d4e4f978f --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/Sanitizers.cmake @@ -0,0 +1,60 @@ +include (CheckCSourceCompiles) +include (CMakePushCheckState) +include (MongoSettings) + +mongo_setting ( + MONGO_SANITIZE "Semicolon/comma-separated list of sanitizers to apply when building" + DEFAULT + DEVEL EVAL [[ + if(NOT MSVC) + set(DEFAULT "address,undefined") + endif() + ]]) + +mongo_bool_setting( + MONGO_FUZZ "Enable libFuzzer integration (Requires a C++ compiler)" + DEFAULT VALUE OFF + VALIDATE CODE [[ + if (MONGO_FUZZ AND NOT ENABLE_STATIC) + message (FATAL_ERROR "MONGO_FUZZ requires ENABLE_STATIC=ON or ENABLE_STATIC=BUILD_ONLY") + endif () + ]] +) + +if (MONGO_FUZZ) + set(mongo_fuzz_options "address,undefined,fuzzer-no-link") + if (MONGO_SANITIZE AND NOT "${MONGO_SANITIZE}" STREQUAL "${mongo_fuzz_options}") + message(WARNING "Overriding user-provided MONGO_SANITIZE options due to MONGO_FUZZ=ON") + endif () + set_property (CACHE MONGO_SANITIZE PROPERTY VALUE "${mongo_fuzz_options}") +endif () + +# Replace commas with semicolons for the genex +string(REPLACE ";" "," _sanitize "${MONGO_SANITIZE}") + +if (_sanitize) + string (MAKE_C_IDENTIFIER "HAVE_SANITIZE_${_sanitize}" ident) + string (TOUPPER "${ident}" varname) + set (flag -fsanitize=${_sanitize} -fno-sanitize-recover=all) + + cmake_push_check_state () + set (CMAKE_REQUIRED_FLAGS "${flag}") + set (CMAKE_REQUIRED_LIBRARIES "${flag}") + check_c_source_compiles ([[ + #include + + int main (void) { + puts ("Hello, world!"); + return 0; + } + ]] "${varname}") + cmake_pop_check_state () + + if (NOT "${${varname}}") + message (SEND_ERROR "Requested sanitizer option '${flag}' is not supported by the compiler+linker") + else () + message (STATUS "Enabling sanitizers: ${flag}") + mongo_platform_compile_options ($) + mongo_platform_link_options (${flag}) + endif () +endif () diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/SphinxBuild.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/SphinxBuild.cmake similarity index 96% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/SphinxBuild.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/SphinxBuild.cmake index b9329b2b4..a25434fd2 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/SphinxBuild.cmake +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/SphinxBuild.cmake @@ -87,13 +87,6 @@ function (sphinx_build_html target_name doc_dir) DESTINATION ${CMAKE_INSTALL_DOCDIR}/${doc_dir}/html ) - if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/static) - install (DIRECTORY - ${SPHINX_HTML_DIR}/_images - DESTINATION - ${CMAKE_INSTALL_DOCDIR}/${doc_dir}/html - ) - endif () add_custom_target (${target_name} DEPENDS ${doc_htmls}) endfunction () diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/TestFixtures.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/TestFixtures.cmake similarity index 94% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/TestFixtures.cmake rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/TestFixtures.cmake index 270e4808d..d79d15ae6 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/cmake/TestFixtures.cmake +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/TestFixtures.cmake @@ -11,7 +11,7 @@ set (_MONGOC_PROC_CTL_COMMAND "$" -u -- "${_MO function (mongo_define_subprocess_fixture name) cmake_parse_arguments(PARSE_ARGV 1 ARG "" "SPAWN_WAIT;STOP_WAIT;WORKING_DIRECTORY" "COMMAND") - string (MAKE_C_IDENTIFIER ident "${name}") + string (MAKE_C_IDENTIFIER "${name}" ident) if (NOT ARG_SPAWN_WAIT) set (ARG_SPAWN_WAIT 1) endif () @@ -40,8 +40,8 @@ endfunction () # Create a fixture that runs a fake Azure IMDS server mongo_define_subprocess_fixture( - mongoc/fixtures/fake_imds - SPAWN_WAIT 0.2 + mongoc/fixtures/fake_kms_provider_server + SPAWN_WAIT 1 COMMAND "$" -u -- "${_MONGOC_BUILD_SCRIPT_DIR}/bottle.py" fake_kms_provider_server:kms_provider diff --git a/3rdparty/mongo-c-driver-2.1.0/build/cmake/TestProject.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/TestProject.cmake new file mode 100644 index 000000000..a89532be1 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/TestProject.cmake @@ -0,0 +1,266 @@ +#[[ +Add a CMake test that configures, builds, and tests a CMake project. + + add_test_cmake_project( + + [INSTALL_PARENT] + [BUILD_DIR ] + [GENERATOR ] + [CONFIG ] + [PASSTHRU_VARS ...] + [PASSTHRU_VARS_REGEX ] + [CONFIGURE_ARGS ...] + [SETTINGS ...] + ) + +The generated test will run CMake configure on the project at `` (which +is resolved relative to the caller's source directory). + +If INSTALL_PARENT is specified, then the host CMake project will be installed to a +temporary prefix, and that prefix will be passed along with CMAKE_PREFIX_PATH +when the test project is configured. + +PASSTHRU_VARS is a list of CMake variables visible in the current scope that should +be made visible to the subproject with the same name and value. PASSTHRU_VARS_REGEX +takes a single regular expression. Any variables currently defined which match +the regex will be passed through as-if they were specified with PASSTHRU_VARS. + +SETTINGS is list of a `[name]=[value]` strings for additional `-D` arguments to +pass to the sub-project. List arguments *are* supported. + +If CONFIG is unspecified, then the generated test will configure+build the project +according to the configuration of CTest (passed with the `-C` argument). + +The default for GENERATOR is to use the same generator as the host project. + +The default BUILD_DIR will be a temporary directory that will be automatically +deleted at the start of each test to ensure a fresh configure+build cycle. + +Additional Variables +#################### + +In addition to the variables specified explicitly in the call, all variables +with the suffix `_PATH` or `_DIR` will be passed to the sub-project with +`HOST_PROJECT_` prepended. For example, CMAKE_SOURCE_DIR will be passed to +the sub-project as HOST_PROJECT_CMAKE_SOURCE_DIR +]] +function(add_test_cmake_project name path) + # Logging context + list(APPEND CMAKE_MESSAGE_CONTEXT "${CMAKE_CURRENT_FUNCTION}") + + # Parse command arguments: + set(options INSTALL_PARENT) + set(args BUILD_DIR GENERATOR CONFIG PASSTHRU_VARS_REGEX) + set(list_args SETTINGS PASSTHRU_VARS CONFIGURE_ARGS) + cmake_parse_arguments(PARSE_ARGV 2 _tp_arg "${options}" "${args}" "${list_args}") + foreach(unknown IN LISTS _tp_arg_UNPARSED_ARGUMENTS) + message(SEND_ERROR "Unknown argument: “${unknown}â€") + endforeach() + if(_tp_arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Bad arguments (see above)") + endif() + + # Default values: + if(NOT DEFINED _tp_arg_BUILD_DIR) + set(dirname "${name}") + if(WIN32) + # Escape specials + string(REPLACE "%" "%25" dirname "${dirname}") + string(REPLACE ":" "%3A" dirname "${dirname}") + string(REPLACE "?" "%3F" dirname "${dirname}") + string(REPLACE "*" "%2A" dirname "${dirname}") + string(REPLACE "\"" "%22" dirname "${dirname}") + string(REPLACE "\\" "%5C" dirname "${dirname}") + string(REPLACE "<" "%3C" dirname "${dirname}") + string(REPLACE ">" "%3E" dirname "${dirname}") + string(REPLACE "|" "%7C" dirname "${dirname}") + endif() + set(_tp_arg_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/TestProject/${dirname}") + endif() + if(NOT DEFINED _tp_arg_GENERATOR) + set(_tp_arg_GENERATOR "${CMAKE_GENERATOR}") + endif() + # Normalize paths + if(NOT IS_ABSOLUTE "${_tp_arg_BUILD_DIR}") + set(_tp_arg_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${_tp_arg_BUILD_DIR}") + endif() + get_filename_component(path "${path}" ABSOLUTE) + message(VERBOSE "Add test project [${path}]") + + # Arguments that will be given during the CMake configure step: + string(REPLACE ";" $ configure_args "${_tp_arg_CONFIGURE_ARGS}") + + # Build the argument lists that will be passed-through to project configuration -D flags: + set(settings_passthru) + + # Pass through all _DIR and _PATH variables with a HOST_PROJECT_ prefix: + get_directory_property(fwd_path_vars VARIABLES) + list(FILTER fwd_path_vars INCLUDE REGEX "_DIR$|_PATH$") + list(FILTER fwd_path_vars EXCLUDE REGEX "^_") + list(SORT fwd_path_vars CASE INSENSITIVE) + set(dir_passthrough) + foreach(var IN LISTS fwd_path_vars) + string(REPLACE ";" $ value "${${var}}") + list(APPEND settings_passthru "HOST_PROJECT_${var}=${value}") + endforeach() + + # Pass through other variables without a prefix: + set(passthru_vars "${_tp_arg_PASSTHRU_VARS}") + # Some platform variables should always go through: + list(APPEND passthru_vars + CMAKE_C_COMPILER + CMAKE_CXX_COMPILER + ) + if(DEFINED _tp_arg_PASSTHRU_VARS_REGEX) + # Pass through variables matching a certain pattern: + get_directory_property(fwd_vars VARIABLES) + list(FILTER fwd_vars INCLUDE REGEX "${_tp_arg_PASSTHRU_VARS_REGEX}") + list(APPEND passthru_vars "${fwd_vars}") + endif() + + # Pass through all variables that we've marked to be forwarded + foreach(var IN LISTS passthru_vars) + string(REPLACE ";" $ value "${${var}}") + list(APPEND settings_passthru "${var}=${value}") + endforeach() + + # Settings set with SETTINGS + list(TRANSFORM _tp_arg_SETTINGS REPLACE ";" $ OUTPUT_VARIABLE settings_escaped) + list(APPEND settings_passthru ${settings_escaped}) + + # Add a prefix to each variable to mark it as a pass-thru variable: + list(TRANSFORM settings_passthru PREPEND "-D;TEST_PROJECT_SETTINGS/") + + # Generate the test case: + add_test( + NAME "${name}" + COMMAND ${CMAKE_COMMAND} + --log-context + -D "TEST_PROJECT_NAME=${name}" + -D "TEST_PROJECT_PARENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" + -D "TEST_PROJECT_SOURCE_DIR=${path}" + -D "TEST_PROJECT_BINARY_DIR=${_tp_arg_BUILD_DIR}" + -D "TEST_PROJECT_GENERATOR=${_tp_arg_GENERATOR}" + -D TEST_PROJECT_INSTALL_PARENT=${_tp_arg_INSTALL_PARENT} + -D "TEST_PROJECT_CONFIGURE_ARGS=${_tp_arg_CONFIGURE_ARGS}" + -D "TEST_PROJECT_CONFIG=$" + ${settings_passthru} + -D __test_project_run=1 + -P "${CMAKE_CURRENT_FUNCTION_LIST_FILE}" + ) +endfunction() + +# This function implements the actual test. +function(__do_test_project) + list(APPEND CMAKE_MESSAGE_CONTEXT "TestProject Execution") + cmake_path(ABSOLUTE_PATH TEST_PROJECT_SOURCE_DIR NORMALIZE OUTPUT_VARIABLE src_dir) + cmake_path(ABSOLUTE_PATH TEST_PROJECT_BINARY_DIR NORMALIZE OUTPUT_VARIABLE bin_dir) + + string(MD5 test_name_hash "${TEST_PROJECT_NAME}") + set(tmp_install_prefix "${TEST_PROJECT_PARENT_BINARY_DIR}/TestProject-install/${test_name_hash}") + file(REMOVE_RECURSE "${tmp_install_prefix}") + list(APPEND TEST_PROJECT_SETTINGS/CMAKE_INSTALL_PREFIX "${tmp_install_prefix}") + list(APPEND TEST_PROJECT_SETTINGS/CMAKE_PREFIX_PATH "${tmp_install_prefix}") + + if(TEST_PROJECT_INSTALL_PARENT) + cmake_path(ABSOLUTE_PATH tmp_install_prefix NORMALIZE) + message(STATUS "Installing parent project into [${tmp_install_prefix}]") + execute_process( + COMMAND + # Suppress DESTDIR + ${CMAKE_COMMAND} -E env --unset=DESTDIR + # Do the install: + ${CMAKE_COMMAND} + --install "${TEST_PROJECT_PARENT_BINARY_DIR}" + --prefix "${tmp_install_prefix}" + --config "${TEST_PROJECT_CONFIG}" + COMMAND_ERROR_IS_FATAL LAST + ) + endif() + message(STATUS "Project source dir: [${src_dir}]") + message(STATUS "Project build dir: [${bin_dir}]") + message(STATUS "Deleting build directory …") + file(REMOVE_RECURSE "${bin_dir}") + file(MAKE_DIRECTORY "${bin_dir}") + + # Grab settings passed-through from the parent project: + get_directory_property(vars VARIABLES) + set(fwd_settings) + list(FILTER vars INCLUDE REGEX "^TEST_PROJECT_SETTINGS/") + if(vars) + message(STATUS "Configuration settings:") + endif() + foreach(var IN LISTS vars) + set(value "${${var}}") + # Remove our prefix + string(REGEX REPLACE "^TEST_PROJECT_SETTINGS/" "" varname "${var}") + # Print the value we received for debugging purposes + message(STATUS " • ${varname}=${value}") + # Escape nested lists + string(REPLACE ";" "\\;" value "${value}") + list(APPEND fwd_settings -D "${varname}=${value}") + endforeach() + + message(STATUS "Configuring project [${src_dir}] …") + set(config_log "${bin_dir}/TestProject-configure.log") + message(STATUS "CMake configure output will be written to [${config_log}]") + execute_process( + COMMAND_ECHO STDERR + WORKING_DIRECTORY "${bin_dir}" + RESULT_VARIABLE retc + OUTPUT_VARIABLE output + ERROR_VARIABLE output + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + COMMAND ${CMAKE_COMMAND} + -S "${src_dir}" + -B "${bin_dir}" + -G "${TEST_PROJECT_GENERATOR}" + -D "CMAKE_BUILD_TYPE=${TEST_PROJECT_BUILD_TYPE}" + --no-warn-unused-cli + --log-context + --log-level=debug + ${fwd_settings} + ${TEST_PROJECT_CONFIGURE_ARGS} + ) + file(WRITE "${config_log}" "${output}") + if(retc) + message(FATAL_ERROR "Configure subcommand failed [${retc}]") + endif() + message(STATUS "CMake configure completed") + + set(build_log "${bin_dir}/TestProject-build.log") + message(STATUS "Build output will be written to [${build_log}]") + message(STATUS "Building configured project [${bin_dir}] …") + execute_process( + COMMAND_ECHO STDERR + WORKING_DIRECTORY "${bin_dir}" + RESULT_VARIABLE retc + OUTPUT_VARIABLE out + ERROR_VARIABLE out + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + COMMAND ${CMAKE_COMMAND} + --build "${bin_dir}" + --config "${TEST_PROJECT_CONFIG}" + ) + file(WRITE "${build_log}" "${output}") + if(retc) + message(FATAL_ERROR "Project build failed [${retc}]") + endif() + message(STATUS "Project build completed") + + execute_process( + COMMAND ${CMAKE_CTEST_COMMAND} + -T Start -T Test + -C "${TEST_PROJECT_CONFIG}" + --output-on-failure + WORKING_DIRECTORY "${bin_dir}" + COMMAND_ERROR_IS_FATAL LAST + ) +endfunction() + +if(__test_project_run) + cmake_minimum_required(VERSION 3.20) # cmake_path/execute_process + __do_test_project() +endif() diff --git a/3rdparty/mongo-c-driver-2.1.0/build/cmake/VerifyHeaders.cmake b/3rdparty/mongo-c-driver-2.1.0/build/cmake/VerifyHeaders.cmake new file mode 100644 index 000000000..894071278 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/VerifyHeaders.cmake @@ -0,0 +1,116 @@ +include_guard(DIRECTORY) + +#[==[ +Add header verification targets for given headers: + + mongo_verify_headers( + + [USES_LIBRARIES [ ...]] + [HEADERS [ ...]] + [EXCLUDE_REGEX [ ...]] + ) + +Here `` is an arbitrary string that is used to qualify the internal target +created for the verification. The `` expressions are used to automatically +collect sources files (relative to the current source directory). All files +collected by `` must live within the current source directory. + +After collecting sources according to the `` patterns, sources are +excluded if the filepath contains any substring that matches any regular +expression in the `` list. Each `` is tested against the +relative path to the header file that was found by ``, and not the +absolute path to the file. + +The header verification targets are compiled according to the usage requirements +from all `` arguments. +]==] +function(mongo_verify_headers tag) + list(APPEND CMAKE_MESSAGE_CONTEXT "${CMAKE_CURRENT_FUNCTION}(${tag})") + cmake_parse_arguments( + PARSE_ARGV 1 arg + "" # No flags + "" # No args + "HEADERS;EXCLUDE_REGEX;USE_LIBRARIES" # List args + ) + if(arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + # Collect headers according to our patterns + set(headers_to_verify) + foreach(pattern IN LISTS arg_HEADERS) + # Use a recursive glob from the current source dir: + file(GLOB_RECURSE more + # Make the paths relative to the calling dir to prevent parent paths + # from interfering with the exclusion regex logic below + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + # We need to re-run configuration if any files are added/removed + CONFIGURE_DEPENDS + "${pattern}" + ) + # Warn if this pattern didn't match anything. It is probably a mistake + # in the caller's argument list. + if(NOT more) + message(WARNING "Globbing pattern “${pattern}†did not match any files") + endif() + list(APPEND headers_to_verify ${more}) + endforeach() + + # Exclude anything that matches any exclusion regex + foreach(pattern IN LISTS arg_EXCLUDE_REGEX) + list(FILTER headers_to_verify EXCLUDE REGEX "${pattern}") + endforeach() + + # Drop duplicates since globs may grab a file more than once + list(REMOVE_DUPLICATES headers_to_verify) + list(SORT headers_to_verify) + foreach(file IN LISTS headers_to_verify) + message(DEBUG "Verify header file: ${file}") + endforeach() + + # We create two targets: One for C and one for C++ + # C target + set(c_target ${tag}-verify-headers-c) + message(DEBUG "Defining header verification target “${c_target}†(C)") + # Create object libraries. They will only have one empty compiled source file. + # The source file language will tell CMake how to verify the associated header files. + add_library(${c_target} OBJECT "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/empty.c") + # Define the file set + target_sources(${c_target} PUBLIC FILE_SET HEADERS) + # Conditionally do the same thing for C++ + if(CMAKE_CXX_COMPILER) + # C++ is available. define it + set(cxx_target ${tag}-verify-headers-cxx) + message(DEBUG "Defining header verification targets “${cxx_target}†(C++)") + add_library(${cxx_target} OBJECT "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/empty.cpp") + target_sources(${cxx_target} PUBLIC FILE_SET HEADERS) + else() + message(AUTHOR_WARNING "No C++ compiler is available, so the header-check C++ targets won't be defined") + unset(cxx_target) + endif() + # Populate the properties and file sets. + set_target_properties(${c_target} ${cxx_target} PROPERTIES + # The main header file set: + HEADER_SET "${headers_to_verify}" + # Enable header verification: + VERIFY_INTERFACE_HEADER_SETS TRUE + # Add the usage requirements that propagate to the generated compilation rules: + INTERFACE_LINK_LIBRARIES "${arg_USE_LIBRARIES}" + ) +endfunction() + +#[[ +Variable set to TRUE if-and-only-if CMake supports header verification. +]] +set(MONGO_CAN_VERIFY_HEADERS FALSE) +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24") + set(MONGO_CAN_VERIFY_HEADERS TRUE) +endif() + +# Try to enable C++, but don't require it. This will be used to conditionally +# define the C++ header-check tests +include(CheckLanguage) +check_language(CXX) +if(CMAKE_CXX_COMPILER) + enable_language(CXX) +endif() diff --git a/3rdparty/mongo-c-driver-2.1.0/build/cmake/empty.c b/3rdparty/mongo-c-driver-2.1.0/build/cmake/empty.c new file mode 100644 index 000000000..deb1f24d1 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/empty.c @@ -0,0 +1,3 @@ +/* This is an empty placeholder file used for miscellaneous build system tasks + */ +#include diff --git a/3rdparty/mongo-c-driver-2.1.0/build/cmake/empty.cpp b/3rdparty/mongo-c-driver-2.1.0/build/cmake/empty.cpp new file mode 100644 index 000000000..3c896c870 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/empty.cpp @@ -0,0 +1,2 @@ +// This is an empty placeholder file used for miscellaneous build system tasks +#include diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/libmongoc-hidden-symbols.map b/3rdparty/mongo-c-driver-2.1.0/build/cmake/libmongoc-hidden-symbols.map similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/libmongoc-hidden-symbols.map rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/libmongoc-hidden-symbols.map diff --git a/3rdparty/mongo-c-driver-1.26.2/build/cmake/libmongoc-hidden-symbols.txt b/3rdparty/mongo-c-driver-2.1.0/build/cmake/libmongoc-hidden-symbols.txt similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/cmake/libmongoc-hidden-symbols.txt rename to 3rdparty/mongo-c-driver-2.1.0/build/cmake/libmongoc-hidden-symbols.txt diff --git a/3rdparty/mongo-c-driver-2.1.0/build/cmake/packageConfigVersion.cmake.in b/3rdparty/mongo-c-driver-2.1.0/build/cmake/packageConfigVersion.cmake.in new file mode 100644 index 000000000..5e100c32c --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/cmake/packageConfigVersion.cmake.in @@ -0,0 +1,58 @@ +#[[ + This package version check file is based on the one that ships with CMake, + but supports version ranges that span major versions, while also doing + SameMajorVersion matching when a non-range is specified. +]] +set(PACKAGE_VERSION "@PROJECT_VERSION@") +set(__package_version_major "@PROJECT_VERSION_MAJOR@") + +# Announce that we are incompatible unless some condition below is satisfied +set(PACKAGE_VERSION_COMPATIBLE FALSE) + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + # The find_package() requested a version that is at least newer than our own version + # Not compatible +elseif(NOT DEFINED PACKAGE_FIND_VERSION_RANGE) + # A simple version check (no range) + if(PACKAGE_FIND_VERSION_MAJOR EQUAL __package_version_major) + # We are the same major version. Okay! + set(PACKAGE_VERSION_COMPATIBLE TRUE) + endif() + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + # We are an exact match to the requested version + set(PACKAGE_VERSION_EXACT TRUE) + endif() +elseif(PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX) + # Package is newer than the range max (we already checked the range min) + # Not compatible +else() + # We are doing a version range check and our version is within the + # requested inclusive range. Set compatible, but we may be incompatible if we are + # an exclusive range: + set(PACKAGE_VERSION_COMPATIBLE TRUE) + # Check whether the range endpoints are compatible: + if(PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION_MAX + AND PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE") + # The upper version is excluded from compatibility + set(PACKAGE_VERSION_COMPATIBLE FALSE) + elseif(PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION_MIN + AND PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "EXCLUDE") + # The lower version is excluded from the range + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() +endif() + +# Check if pointer sizes match (this is relevant e.g. if we are a 32-bit build and +# CMake is building for 64-bit) +if(CMAKE_SIZEOF_VOID_P STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") + # Unknown pointer size. Don't check + return() +endif() +# Check: +if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@") + math(EXPR bits "@CMAKE_SIZEOF_VOID_P@ * 8") + # Announce the bitness of this package for diagnostics: + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${bits}bit)") + # This package is unsuitable, regardless of version requested in the importer + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/3rdparty/mongo-c-driver-1.26.2/build/fake_kms_provider_server.py b/3rdparty/mongo-c-driver-2.1.0/build/fake_kms_provider_server.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/fake_kms_provider_server.py rename to 3rdparty/mongo-c-driver-2.1.0/build/fake_kms_provider_server.py diff --git a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-functions.c.template b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-functions.c.template similarity index 94% rename from 3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-functions.c.template rename to 3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-functions.c.template index e62633e4e..4582dc052 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-functions.c.template +++ b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-functions.c.template @@ -14,9 +14,9 @@ * controlling the server from the main thread. */ -#include "mongoc/mongoc-topology-private.h" +#include -#include "future-functions.h" +#include "mock_server/future-functions.h" {% for F in future_functions %} static @@ -41,8 +41,8 @@ BSON_THREAD_FUN (background_{{ F.name }}, data) BSON_THREAD_RETURN; } {% endfor %} - {% for F in future_functions %} + future_t * {{ F|future_function_name }} ({% for P in F.params %} {{ P.type_name }} {{ P.name }}{% if not loop.last %},{% endif %}{% endfor %}) @@ -56,5 +56,4 @@ future_t * future_start (future, background_{{ F.name }}); return future; } -{% endfor %} - +{%- endfor %} diff --git a/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-functions.h.template b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-functions.h.template new file mode 100644 index 000000000..5f8ae6796 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-functions.h.template @@ -0,0 +1,19 @@ +#ifndef FUTURE_FUNCTIONS_H +#define FUTURE_FUNCTIONS_H + +#include "mock_server/future-value.h" +#include "mock_server/future.h" +#include + +{{ header_comment }} + +{% for F in future_functions %} +future_t * +{{ F|future_function_name }} ( +{% for P in F.params %} + {{ P.type_name }} {{ P.name }}{% if not loop.last %},{% endif %}{% endfor %} +); + +{% endfor %} + +#endif /* FUTURE_FUNCTIONS_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-value.c.template b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-value.c.template similarity index 93% rename from 3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-value.c.template rename to 3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-value.c.template index 5e719145b..dbe88a0a4 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-value.c.template +++ b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-value.c.template @@ -1,4 +1,4 @@ -#include "future-value.h" +#include "mock_server/future-value.h" {{ header_comment }} @@ -19,8 +19,8 @@ future_value_get_void (future_value_t *future_value) { BSON_ASSERT (future_value->type == future_value_void_type); } - {% for T in type_list %} + void future_value_set_{{ T }} (future_value_t *future_value, {{ T }} value) { @@ -34,4 +34,4 @@ future_value_get_{{ T }} (future_value_t *future_value) BSON_ASSERT (future_value->type == future_value_{{ T }}_type); return future_value->value.{{ T }}_value; } -{% endfor %} +{%- endfor %} diff --git a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-value.h.template b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-value.h.template similarity index 92% rename from 3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-value.h.template rename to 3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-value.h.template index ebc943b96..19705c646 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future-value.h.template +++ b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future-value.h.template @@ -4,8 +4,8 @@ #include -#include "mongoc/mongoc-cluster-private.h" -#include "mongoc/mongoc-topology-private.h" +#include +#include {{ header_comment }} diff --git a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future.c.template b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future.c.template similarity index 96% rename from 3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future.c.template rename to 3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future.c.template index 4245045b7..71e00f70e 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future.c.template +++ b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future.c.template @@ -1,8 +1,8 @@ #include -#include "mongoc/mongoc-array-private.h" -#include "mongoc/mongoc-thread-private.h" -#include "future.h" +#include +#include +#include "mock_server/future.h" #include "../test-libmongoc.h" {{ header_comment }} diff --git a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future.h.template b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future.h.template similarity index 92% rename from 3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future.h.template rename to 3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future.h.template index c851e7bd2..2537fc96e 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/future_function_templates/future.h.template +++ b/3rdparty/mongo-c-driver-2.1.0/build/future_function_templates/future.h.template @@ -3,8 +3,8 @@ #include -#include "future-value.h" -#include "mongoc/mongoc-thread-private.h" +#include "mock_server/future-value.h" +#include {{ header_comment }} @@ -42,4 +42,3 @@ future_get_{{ T }} (future_t *future); void future_destroy (future_t *future); #endif /* FUTURE_H */ - diff --git a/3rdparty/mongo-c-driver-1.26.2/build/generate-future-functions.py b/3rdparty/mongo-c-driver-2.1.0/build/generate-future-functions.py similarity index 90% rename from 3rdparty/mongo-c-driver-1.26.2/build/generate-future-functions.py rename to 3rdparty/mongo-c-driver-2.1.0/build/generate-future-functions.py index c5a2e8a45..1fa42a5f5 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/generate-future-functions.py +++ b/3rdparty/mongo-c-driver-2.1.0/build/generate-future-functions.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2015 MongoDB, Inc. +# Copyright 2009-present MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -87,7 +87,6 @@ typedef("mongoc_iovec_ptr", "mongoc_iovec_t *"), typedef("mongoc_server_stream_ptr", "mongoc_server_stream_t *"), typedef("mongoc_query_flags_t", None), - typedef("const_mongoc_index_opt_t", "const mongoc_index_opt_t *"), typedef("mongoc_server_description_ptr", "mongoc_server_description_t *"), typedef("mongoc_ss_optype_t", None), typedef("mongoc_topology_ptr", "mongoc_topology_t *"), @@ -102,6 +101,9 @@ typedef("const_mongoc_read_prefs_ptr", "const mongoc_read_prefs_t *"), typedef("const_mongoc_write_concern_ptr", "const mongoc_write_concern_t *"), + typedef("const_mongoc_ss_log_context_ptr", + "const mongoc_ss_log_context_t *"), + typedef("mongoc_index_model_t_ptr_const_ptr", "mongoc_index_model_t *const *") ] type_list = [T.name for T in typedef_list] @@ -199,11 +201,6 @@ param("bson_ptr", "reply"), param("bson_error_ptr", "error")]), - future_function("void", - "mongoc_client_kill_cursor", - [param("mongoc_client_ptr", "client"), - param("int64_t", "cursor_id")]), - future_function("mongoc_change_stream_ptr", "mongoc_client_watch", [param("mongoc_client_ptr", "client"), @@ -218,32 +215,11 @@ param("const_bson_ptr", "options"), param("const_mongoc_read_prefs_ptr", "read_prefs")]), - future_function("int64_t", - "mongoc_collection_count", - [param("mongoc_collection_ptr", "collection"), - param("mongoc_query_flags_t", "flags"), - param("const_bson_ptr", "query"), - param("int64_t", "skip"), - param("int64_t", "limit"), - param("const_mongoc_read_prefs_ptr", "read_prefs"), - param("bson_error_ptr", "error")]), - - future_function("int64_t", - "mongoc_collection_count_with_opts", - [param("mongoc_collection_ptr", "collection"), - param("mongoc_query_flags_t", "flags"), - param("const_bson_ptr", "query"), - param("int64_t", "skip"), - param("int64_t", "limit"), - param("const_bson_ptr", "opts"), - param("const_mongoc_read_prefs_ptr", "read_prefs"), - param("bson_error_ptr", "error")]), - future_function("bool", - "mongoc_collection_create_index_with_opts", + "mongoc_collection_create_indexes_with_opts", [param("mongoc_collection_ptr", "collection"), - param("const_bson_ptr", "keys"), - param("const_mongoc_index_opt_t", "opt"), + param("mongoc_index_model_t_ptr_const_ptr", "models"), + param("size_t", "num_models"), param("const_bson_ptr", "opts"), param("bson_ptr", "reply"), param("bson_error_ptr", "error")]), @@ -287,13 +263,6 @@ [param("mongoc_collection_ptr", "collection"), param("const_bson_ptr", "opts")]), - future_function("bool", - "mongoc_collection_stats", - [param("mongoc_collection_ptr", "collection"), - param("const_bson_ptr", "options"), - param("bson_ptr", "stats"), - param("bson_error_ptr", "error")]), - future_function("bool", "mongoc_collection_insert_many", [param("mongoc_collection_ptr", "collection"), @@ -337,15 +306,6 @@ param("bson_ptr", "reply"), param("bson_error_ptr", "error")]), - future_function("bool", - "mongoc_collection_insert_bulk", - [param("mongoc_collection_ptr", "collection"), - param("mongoc_insert_flags_t", "flags"), - param("const_bson_ptr_ptr", "documents"), - param("uint32_t", "n_documents"), - param("const_mongoc_write_concern_ptr", "write_concern"), - param("bson_error_ptr", "error")]), - future_function("bool", "mongoc_cluster_run_command_parts", [param("mongoc_cluster_ptr", "cluster"), @@ -418,12 +378,6 @@ param("size_t", "min_bytes"), param("uint32_t", "timeout_msec")]), - future_function("mongoc_gridfs_file_ptr", - "mongoc_gridfs_find_one", - [param("mongoc_gridfs_ptr", "gridfs"), - param("const_bson_ptr", "query"), - param("bson_error_ptr", "error")]), - future_function("bool", "mongoc_gridfs_file_remove", [param("mongoc_gridfs_file_ptr", "file"), @@ -453,6 +407,7 @@ "mongoc_topology_select", [param("mongoc_topology_ptr", "topology"), param("mongoc_ss_optype_t", "optype"), + param("const_mongoc_ss_log_context_ptr", "log_context"), param("const_mongoc_read_prefs_ptr", "read_prefs"), param("bool_ptr", "must_use_primary"), param("bson_error_ptr", "error")]), @@ -570,7 +525,7 @@ def future_function_name(fn): # E.g. future_cursor_next(). return 'future' + fn.name[len('mongoc'):] else: - # E.g. future__mongoc_client_kill_cursor(). + # E.g. future_mongoc_client_command_simple(). return 'future_' + fn.name diff --git a/3rdparty/mongo-c-driver-1.26.2/build/generate-opts.py b/3rdparty/mongo-c-driver-2.1.0/build/generate-opts.py similarity index 90% rename from 3rdparty/mongo-c-driver-1.26.2/build/generate-opts.py rename to 3rdparty/mongo-c-driver-2.1.0/build/generate-opts.py index 01ffa4d44..71736433a 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/generate-opts.py +++ b/3rdparty/mongo-c-driver-2.1.0/build/generate-opts.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2017-present MongoDB, Inc. +# Copyright 2009-present MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ def flatten(items): class Struct(OrderedDict): def __init__(self, items, opts_name='opts', generate_rst=True, - generate_code=True, allow_extra=True, **defaults): + generate_code=True, allow_extra=True, rst_prelude=None, **defaults): """Define an options struct. - items: List of pairs: (optionName, info) @@ -64,6 +64,7 @@ def __init__(self, items, opts_name='opts', generate_rst=True, self.generate_code = generate_code self.allow_extra = allow_extra self.defaults = defaults + self.rst_prelude = rst_prelude def default(self, item, fallback): return self.defaults.get(item, fallback) @@ -115,12 +116,12 @@ def __init__(self, items, **defaults): validate_option = ('validate', { 'type': 'bson_validate_flags_t', 'convert': '_mongoc_convert_validate_flags', - 'help': 'Construct a bitwise-or of all desired :symbol:`bson_validate_flags_t `. Set to ``false`` to skip client-side validation of the provided BSON documents.' + 'help': 'Construct a bitwise-or of all desired :symbol:`bson_validate_flags_t`. Set to ``false`` to skip client-side validation of the provided BSON documents.' }) collation_option = ('collation', { 'type': 'document', - 'help': 'Configure textual comparisons. See :ref:`Setting Collation Order `, and `the MongoDB Manual entry on Collation `_. Collation requires MongoDB 3.2 or later, otherwise an error is returned.' + 'help': 'Configure textual comparisons. See `Setting Collation Order `_, and `the MongoDB Manual entry on Collation `_. Collation requires MongoDB 3.2 or later, otherwise an error is returned.' }) array_filters_option = ('arrayFilters', { @@ -214,6 +215,7 @@ def __init__(self, items, **defaults): ('mongoc_update_one_opts_t', Struct([ ('update', {'type': 'mongoc_update_opts_t'}), array_filters_option, + ('sort', {'type': 'document', 'help': 'Specify a sort order when matching documents.'}) ], validate='_mongoc_default_update_vflags')), ('mongoc_update_many_opts_t', Struct([ @@ -223,6 +225,7 @@ def __init__(self, items, **defaults): ('mongoc_replace_one_opts_t', Struct([ ('update', {'type': 'mongoc_update_opts_t'}), + ('sort', {'type': 'document', 'help': 'Specify a sort order when matching documents.'}) ], validate='_mongoc_default_replace_vflags')), ('mongoc_bulk_opts_t', Struct([ @@ -251,6 +254,7 @@ def __init__(self, items, **defaults): ('mongoc_bulk_update_one_opts_t', Struct( [ ('update', {'type': 'mongoc_bulk_update_opts_t'}), + ('sort', {'type': 'document', 'help': 'Specify a sort order when matching documents.'}), array_filters_option, ], multi='false', @@ -267,7 +271,10 @@ def __init__(self, items, **defaults): allow_extra=False)), ('mongoc_bulk_replace_one_opts_t', Struct( - [('update', {'type': 'mongoc_bulk_update_opts_t'})], + [ + ('update', {'type': 'mongoc_bulk_update_opts_t'}), + ('sort', {'type': 'document', 'help': 'Specify a sort order when matching documents.'}) + ], multi='false', validate='_mongoc_default_replace_vflags', allow_extra=False)), @@ -287,7 +294,7 @@ def __init__(self, items, **defaults): ], limit=0, allow_extra=False)), ('mongoc_change_stream_opts_t', Struct([ - ('batchSize', {'type': 'int32_t', 'help': 'An ``int32`` representing number of documents requested to be returned on each call to :symbol:`mongoc_change_stream_next`'}), + ('batchSize', {'type': 'int32_t', 'help': 'An ``int32`` requesting a limit of documents returned in each server reply. If positive, the ``batchSize`` is applied to both ``aggregate`` and ``getMore`` commands. If 0, the ``batchSize`` is only applied to the ``aggregate`` command (Useful to request an immediate cursor without significant server-side work. See `Aggregate Data Specifying Batch Size `_). If omitted or negative, the value is ignored and server defaults are used (See `Cursor Batches `_ for a description of server defaults).'}), ('resumeAfter', {'type': 'document', 'help': 'A ``Document`` representing the logical starting point of the change stream. The result of :symbol:`mongoc_change_stream_get_resume_token()` or the ``_id`` field of any change received from a change stream can be used here. This option is mutually exclusive with ``startAfter`` and ``startAtOperationTime``.'}), ('startAfter', {'type': 'document', 'help': 'A ``Document`` representing the logical starting point of the change stream. Unlike ``resumeAfter``, this can resume notifications after an "invalidate" event. The result of :symbol:`mongoc_change_stream_get_resume_token()` or the ``_id`` field of any change received from a change stream can be used here. This option is mutually exclusive with ``resumeAfter`` and ``startAtOperationTime``.'}), ('startAtOperationTime', {'type': 'timestamp', 'help': 'A ``Timestamp``. The change stream only provides changes that occurred at or after the specified timestamp. Any command run against the server will return an operation time that can be used here. This option is mutually exclusive with ``resumeAfter`` and ``startAfter``.'}), @@ -311,7 +318,7 @@ def __init__(self, items, **defaults): }), ('showExpandedEvents', { 'type': 'bool', 'help': 'Set to ``true`` to return an expanded list of change stream events. Available only on MongoDB versions >=6.0'}), comment_option_string_pre_4_4, - ], fullDocument=None, fullDocumentBeforeChange=None)), + ], fullDocument=None, fullDocumentBeforeChange=None, batchSize=-1, rst_prelude=".. versionchanged:: 2.0.0 ``batchSize`` of 0 is applied to the ``aggregate`` command. 0 was previously ignored.")), ('mongoc_create_index_opts_t', Struct([ write_concern_option, @@ -468,6 +475,9 @@ def document_opts(struct, f): print(file_name) f = open(joinpath(doc_includes, file_name), 'w') f.write (disclaimer) + if struct.rst_prelude is not None: + f.write(struct.rst_prelude) + f.write("\n\n") f.write( "``%s`` may be NULL or a BSON document with additional" " command options:\n\n" % struct.opts_name) diff --git a/3rdparty/mongo-c-driver-1.26.2/build/mongodl.py b/3rdparty/mongo-c-driver-2.1.0/build/mongodl.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/mongodl.py rename to 3rdparty/mongo-c-driver-2.1.0/build/mongodl.py diff --git a/3rdparty/mongo-c-driver-2.1.0/build/opts_templates/mongoc-opts-private.h.template b/3rdparty/mongo-c-driver-2.1.0/build/opts_templates/mongoc-opts-private.h.template new file mode 100644 index 000000000..b73e6783b --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/opts_templates/mongoc-opts-private.h.template @@ -0,0 +1,70 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_OPTS_H +#define MONGOC_OPTS_H + +#include + +#include +#include +#include + +{{ header_comment }} + +{% for struct_type, description in opts_structs.items() %} +{% if not description.generate_code %}{% continue %}{% endif %} +typedef struct _{{ struct_type }} { +{% for opt_name, info in description.items() %} +{% if info['type'] == 'utf8' %} +{% set the_type = 'const char *' %} +{% elif info['type'] in ('document', 'array') %} +{% set the_type = 'bson_t' %} +{% elif info['type'] == 'timestamp' %} +{% set the_type = 'mongoc_timestamp_t' %} +{% else %} +{% set the_type = info['type'] %} +{% endif %} +{% set the_name = info.get('field', opt_name) %} +{% set space = '' if the_type.endswith('*') else ' ' %} + {{ the_type }}{{ space }}{{ the_name }}; +{% if info.check_set %} + bool {{ the_name }}_is_set; +{% endif %} +{% endfor %} +{% if not description.is_shared %} + bson_t extra; +{% endif %} +} {{ struct_type }}; + +{% endfor %} +{% for struct_type, description in opts_structs.items() %} +{% if description.is_shared or not description.generate_code %}{% continue %}{% endif %} +{% set struct_name = struct_type.split('_t', -1)[0] %} +bool +_{{ struct_name }}_parse ( + mongoc_client_t *client, + const bson_t *opts, + {{ struct_type }} *{{ struct_name }}, + bson_error_t *error); + +void +_{{ struct_name }}_cleanup ({{ struct_type }} *{{ struct_name }}); + +{% endfor %} +#endif /* MONGOC_OPTS_H */ diff --git a/3rdparty/mongo-c-driver-1.26.2/build/opts_templates/mongoc-opts.c.template b/3rdparty/mongo-c-driver-2.1.0/build/opts_templates/mongoc-opts.c.template similarity index 82% rename from 3rdparty/mongo-c-driver-1.26.2/build/opts_templates/mongoc-opts.c.template rename to 3rdparty/mongo-c-driver-2.1.0/build/opts_templates/mongoc-opts.c.template index 7f46b3be3..09efda593 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/opts_templates/mongoc-opts.c.template +++ b/3rdparty/mongo-c-driver-2.1.0/build/opts_templates/mongoc-opts.c.template @@ -1,8 +1,8 @@ -#include "mongoc-opts-helpers-private.h" -#include "mongoc-opts-private.h" -#include "mongoc-error.h" -#include "mongoc-util-private.h" -#include "mongoc-client-private.h" +#include +#include +#include +#include +#include {{ header_comment }} {% for struct_type, description in opts_structs.items() %} @@ -54,10 +54,10 @@ _{{ struct_name }}_parse ( } if (!bson_iter_init (&iter, opts)) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Invalid 'opts' parameter."); + _mongoc_set_error (error, + MONGOC_ERROR_BSON, + MONGOC_ERROR_BSON_INVALID, + "Invalid 'opts' parameter."); return false; } @@ -100,18 +100,18 @@ _{{ struct_name }}_parse ( &{{ struct_name }}->extra, bson_iter_key (&iter), bson_iter_value (&iter))) { - bson_set_error (error, - MONGOC_ERROR_BSON, - MONGOC_ERROR_BSON_INVALID, - "Invalid 'opts' parameter."); + _mongoc_set_error (error, + MONGOC_ERROR_BSON, + MONGOC_ERROR_BSON_INVALID, + "Invalid 'opts' parameter."); return false; } {% else %} - bson_set_error (error, - MONGOC_ERROR_COMMAND, - MONGOC_ERROR_COMMAND_INVALID_ARG, - "Invalid option '%s'", - bson_iter_key (&iter)); + _mongoc_set_error (error, + MONGOC_ERROR_COMMAND, + MONGOC_ERROR_COMMAND_INVALID_ARG, + "Invalid option '%s'", + bson_iter_key (&iter)); return false; {% endif %} } diff --git a/3rdparty/mongo-c-driver-1.26.2/build/proc-ctl.py b/3rdparty/mongo-c-driver-2.1.0/build/proc-ctl.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/proc-ctl.py rename to 3rdparty/mongo-c-driver-2.1.0/build/proc-ctl.py diff --git a/3rdparty/mongo-c-driver-1.26.2/build/requirements.txt b/3rdparty/mongo-c-driver-2.1.0/build/requirements.txt similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/requirements.txt rename to 3rdparty/mongo-c-driver-2.1.0/build/requirements.txt diff --git a/3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/.gitignore b/3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/.gitignore similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/.gitignore rename to 3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/.gitignore diff --git a/3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/conf.py b/3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/conf.py new file mode 100644 index 000000000..f1fae6c5e --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/conf.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +from docutils import nodes +import os +import sys + +# Import common docs config. +this_path = os.path.dirname(__file__) +sys.path.append(os.path.normpath(os.path.join(this_path, '../'))) + +from mongoc_common import * + +with open(this_path + '/../../../VERSION_CURRENT') as vc: + release = version = vc.read() + +# -- General configuration ------------------------------------------------ +templates_path = ['_templates'] +source_suffix = '.rst' +master_doc = 'index' + +# General information about the project. +project = u'mongoc.org' +copyright = u'2009-present, MongoDB, Inc.' +author = u'MongoDB, Inc' +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# Support :download-link:`bson` or :download-link:`mongoc`. +def download_link(typ, rawtext, text, lineno, inliner, options={}, content=[]): + if text == "mongoc": + lib = "mongo-c-driver" + else: + raise ValueError( + "download link must be mongoc, not \"%s\"" % text) + + title = "%s-%s" % (lib, version) + url = ("https://github.com/mongodb/mongo-c-driver/releases/tag/%(version)s") % { + "version": version + } + + pnode = nodes.reference(title, title, internal=False, refuri=url) + return [pnode], [] + +def setup(app): + mongoc_common_setup(app) + + app.add_role('download-link', download_link) + +# -- Options for HTML output ---------------------------------------------- + +html_theme = 'furo' +html_title = html_shorttitle = 'MongoDB C Driver %s' % version +# html_favicon = None +html_use_smartypants = False +html_show_sourcelink = False +html_use_index = False +rst_prolog = rf""" + +.. _mongodb_docs_cdriver: https://www.mongodb.com/docs/languages/c/c-driver/current/ + +""" + +html_sidebars = { + '**': [] +} + +# Note: http://www.sphinx-doc.org/en/1.5.1/config.html#confval-html_copy_source +# This will degrade the Javascript quicksearch if we ever use it. +html_copy_source = False diff --git a/3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/index.rst b/3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/index.rst new file mode 100644 index 000000000..56b79c1f7 --- /dev/null +++ b/3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/index.rst @@ -0,0 +1,40 @@ +MongoDB C Driver - API +====================== + +**A Cross Platform MongoDB Client Library for C** + +The MongoDB C Driver, also known as "libmongoc", is a library for using MongoDB from C applications, and for writing MongoDB drivers in higher-level languages. + +It depends on `libbson `_ to generate and parse BSON documents, the native data format of MongoDB. + +This site documents the API. For tutorials, guides, and explainers, see `MongoDB C Driver `_. + +Download +-------- + +Latest release: :download-link:`mongoc` + +Documentation +------------- + +For tutorials, guides, and explainers, see `MongoDB C Driver `_. + +- `libmongoc API documentation `_ + +- `libbson API documentation `_ + +How To Ask For Help +------------------- + +For help using the driver: `MongoDB Community Forums `_. + +To file a bug or feature request: `MongoDB Jira Issue Tracker `_. + +Documentation for Older Versions +-------------------------------- + +.. toctree:: + :titlesonly: + + libmongoc-releases + libbson-releases diff --git a/3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/libbson-releases.rst b/3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/libbson-releases.rst similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/libbson-releases.rst rename to 3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/libbson-releases.rst diff --git a/3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/libmongoc-releases.rst b/3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/libmongoc-releases.rst similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/sphinx/homepage-config/libmongoc-releases.rst rename to 3rdparty/mongo-c-driver-2.1.0/build/sphinx/homepage-config/libmongoc-releases.rst diff --git a/3rdparty/mongo-c-driver-1.26.2/build/sphinx/mongoc/__init__.py b/3rdparty/mongo-c-driver-2.1.0/build/sphinx/mongoc/__init__.py similarity index 100% rename from 3rdparty/mongo-c-driver-1.26.2/build/sphinx/mongoc/__init__.py rename to 3rdparty/mongo-c-driver-2.1.0/build/sphinx/mongoc/__init__.py diff --git a/3rdparty/mongo-c-driver-1.26.2/build/sphinx/mongoc_common.py b/3rdparty/mongo-c-driver-2.1.0/build/sphinx/mongoc_common.py similarity index 91% rename from 3rdparty/mongo-c-driver-1.26.2/build/sphinx/mongoc_common.py rename to 3rdparty/mongo-c-driver-2.1.0/build/sphinx/mongoc_common.py index 44bd1689a..f46a805d2 100644 --- a/3rdparty/mongo-c-driver-1.26.2/build/sphinx/mongoc_common.py +++ b/3rdparty/mongo-c-driver-2.1.0/build/sphinx/mongoc_common.py @@ -8,6 +8,7 @@ from sphinx.application import Sphinx from sphinx.application import logger as sphinx_log + try: from sphinx.builders.dirhtml import DirectoryHTMLBuilder except ImportError: @@ -16,7 +17,8 @@ from sphinx.config import Config from docutils.parsers.rst import Directive -needs_sphinx = "1.7" # Do not require newer sphinx. EPEL packages build man pages with Sphinx 1.7.6. Refer: CDRIVER-4767 +# Do not require newer sphinx. EPEL packages build man pages with Sphinx 1.7.6. Refer: CDRIVER-4767 +needs_sphinx = "1.7" author = "MongoDB, Inc" # -- Options for HTML output ---------------------------------------------- @@ -38,7 +40,8 @@ def _file_man_page_name(fpath: Path) -> Union[str, None]: continue return mat[1] -def _collect_man (app: Sphinx): + +def _collect_man(app: Sphinx): # Note: 'app' is partially-formed, as this is called from the Sphinx.__init__ docdir = Path(app.srcdir) # Find everything: @@ -61,6 +64,7 @@ def _collect_man (app: Sphinx): assert docname, filepath man_pages.append((docname, man_name, "", [author], 3)) + # -- Options for manual page output --------------------------------------- # NOTE: This starts empty, but we populate it in `setup` in _collect_man() (see above) @@ -81,14 +85,14 @@ def add_ga_javascript(app: Sphinx, pagename: str, templatename: str, context: Di context["metatags"] = ( context.get("metatags", "") + """ - - + +